Package ganeti :: Module pathutils
[hide private]
[frames] | no frames]

Source Code for Module ganeti.pathutils

  1  # 
  2  # 
  3   
  4  # Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Google Inc. 
  5  # 
  6  # This program is free software; you can redistribute it and/or modify 
  7  # it under the terms of the GNU General Public License as published by 
  8  # the Free Software Foundation; either version 2 of the License, or 
  9  # (at your option) any later version. 
 10  # 
 11  # This program is distributed in the hope that it will be useful, but 
 12  # WITHOUT ANY WARRANTY; without even the implied warranty of 
 13  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
 14  # General Public License for more details. 
 15  # 
 16  # You should have received a copy of the GNU General Public License 
 17  # along with this program; if not, write to the Free Software 
 18  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
 19  # 02110-1301, USA. 
 20   
 21   
 22  """Module containing constants and functions for filesystem paths. 
 23   
 24  """ 
 25   
 26  from ganeti import _autoconf 
 27  from ganeti import compat 
 28  from ganeti import vcluster 
 29   
 30   
 31  # Build-time constants 
 32  if _autoconf.ENABLE_FILE_STORAGE: 
 33    DEFAULT_FILE_STORAGE_DIR = vcluster.AddNodePrefix(_autoconf.FILE_STORAGE_DIR) 
 34  else: 
 35    DEFAULT_FILE_STORAGE_DIR = _autoconf.FILE_STORAGE_DIR 
 36  if _autoconf.ENABLE_SHARED_FILE_STORAGE: 
 37    DEFAULT_SHARED_FILE_STORAGE_DIR = \ 
 38      vcluster.AddNodePrefix(_autoconf.SHARED_FILE_STORAGE_DIR) 
 39  else: 
 40    DEFAULT_SHARED_FILE_STORAGE_DIR = _autoconf.SHARED_FILE_STORAGE_DIR 
 41  EXPORT_DIR = vcluster.AddNodePrefix(_autoconf.EXPORT_DIR) 
 42  OS_SEARCH_PATH = _autoconf.OS_SEARCH_PATH 
 43  ES_SEARCH_PATH = _autoconf.ES_SEARCH_PATH 
 44  SSH_CONFIG_DIR = _autoconf.SSH_CONFIG_DIR 
 45  XEN_CONFIG_DIR = vcluster.AddNodePrefix(_autoconf.XEN_CONFIG_DIR) 
 46  SYSCONFDIR = vcluster.AddNodePrefix(_autoconf.SYSCONFDIR) 
 47  TOOLSDIR = _autoconf.TOOLSDIR 
 48  LOCALSTATEDIR = vcluster.AddNodePrefix(_autoconf.LOCALSTATEDIR) 
 49   
 50  # Paths which don't change for a virtual cluster 
 51  DAEMON_UTIL = _autoconf.PKGLIBDIR + "/daemon-util" 
 52  IMPORT_EXPORT_DAEMON = _autoconf.PKGLIBDIR + "/import-export" 
 53  KVM_CONSOLE_WRAPPER = _autoconf.PKGLIBDIR + "/tools/kvm-console-wrapper" 
 54  KVM_IFUP = _autoconf.PKGLIBDIR + "/kvm-ifup" 
 55  PREPARE_NODE_JOIN = _autoconf.PKGLIBDIR + "/prepare-node-join" 
 56  NODE_DAEMON_SETUP = _autoconf.PKGLIBDIR + "/node-daemon-setup" 
 57  XEN_CONSOLE_WRAPPER = _autoconf.PKGLIBDIR + "/tools/xen-console-wrapper" 
 58  ETC_HOSTS = vcluster.ETC_HOSTS 
 59   
 60  # Top-level paths 
 61  DATA_DIR = LOCALSTATEDIR + "/lib/ganeti" 
 62  LOCK_DIR = LOCALSTATEDIR + "/lock" 
 63  LOG_DIR = LOCALSTATEDIR + "/log/ganeti" 
 64  RUN_DIR = LOCALSTATEDIR + "/run/ganeti" 
 65   
 66  #: Script to configure master IP address 
 67  DEFAULT_MASTER_SETUP_SCRIPT = TOOLSDIR + "/master-ip-setup" 
 68   
 69  SSH_HOST_DSA_PRIV = SSH_CONFIG_DIR + "/ssh_host_dsa_key" 
 70  SSH_HOST_DSA_PUB = SSH_HOST_DSA_PRIV + ".pub" 
 71  SSH_HOST_RSA_PRIV = SSH_CONFIG_DIR + "/ssh_host_rsa_key" 
 72  SSH_HOST_RSA_PUB = SSH_HOST_RSA_PRIV + ".pub" 
 73   
 74  BDEV_CACHE_DIR = RUN_DIR + "/bdev-cache" 
 75  DISK_LINKS_DIR = RUN_DIR + "/instance-disks" 
 76  SOCKET_DIR = RUN_DIR + "/socket" 
 77  CRYPTO_KEYS_DIR = RUN_DIR + "/crypto" 
 78  IMPORT_EXPORT_DIR = RUN_DIR + "/import-export" 
 79  INSTANCE_STATUS_FILE = RUN_DIR + "/instance-status" 
 80  INSTANCE_REASON_DIR = RUN_DIR + "/instance-reason" 
 81  #: User-id pool lock directory (used user IDs have a corresponding lock file in 
 82  #: this directory) 
 83  UIDPOOL_LOCKDIR = RUN_DIR + "/uid-pool" 
 84   
 85  SSCONF_LOCK_FILE = LOCK_DIR + "/ganeti-ssconf.lock" 
 86   
 87  CLUSTER_CONF_FILE = DATA_DIR + "/config.data" 
 88  RAPI_CERT_FILE = DATA_DIR + "/rapi.pem" 
 89  CONFD_HMAC_KEY = DATA_DIR + "/hmac.key" 
 90  SPICE_CERT_FILE = DATA_DIR + "/spice.pem" 
 91  SPICE_CACERT_FILE = DATA_DIR + "/spice-ca.pem" 
 92  CLUSTER_DOMAIN_SECRET_FILE = DATA_DIR + "/cluster-domain-secret" 
 93  SSH_KNOWN_HOSTS_FILE = DATA_DIR + "/known_hosts" 
 94  RAPI_USERS_FILE = DATA_DIR + "/rapi/users" 
 95  QUEUE_DIR = DATA_DIR + "/queue" 
 96  CONF_DIR = SYSCONFDIR + "/ganeti" 
 97  USER_SCRIPTS_DIR = CONF_DIR + "/scripts" 
 98  VNC_PASSWORD_FILE = CONF_DIR + "/vnc-cluster-password" 
 99  HOOKS_BASE_DIR = CONF_DIR + "/hooks" 
100  FILE_STORAGE_PATHS_FILE = CONF_DIR + "/file-storage-paths" 
101  RESTRICTED_COMMANDS_DIR = CONF_DIR + "/restricted-commands" 
102   
103  #: Node daemon certificate path 
104  NODED_CERT_FILE = DATA_DIR + "/server.pem" 
105   
106  #: Node daemon certificate file permissions 
107  NODED_CERT_MODE = 0440 
108   
109  #: Locked in exclusive mode while noded verifies a remote command 
110  RESTRICTED_COMMANDS_LOCK_FILE = LOCK_DIR + "/ganeti-restricted-commands.lock" 
111   
112  #: Lock file for watcher, locked in shared mode by watcher; lock in exclusive 
113  # mode to block watcher (see L{cli._RunWhileClusterStoppedHelper.Call} 
114  WATCHER_LOCK_FILE = LOCK_DIR + "/ganeti-watcher.lock" 
115   
116  #: Status file for per-group watcher, locked in exclusive mode by watcher 
117  WATCHER_GROUP_STATE_FILE = DATA_DIR + "/watcher.%s.data" 
118   
119  #: File for per-group instance status, merged into L{INSTANCE_STATUS_FILE} by 
120  #: per-group processes 
121  WATCHER_GROUP_INSTANCE_STATUS_FILE = DATA_DIR + "/watcher.%s.instance-status" 
122   
123  #: File containing Unix timestamp until which watcher should be paused 
124  WATCHER_PAUSEFILE = DATA_DIR + "/watcher.pause" 
125   
126  #: User-provided master IP setup script 
127  EXTERNAL_MASTER_SETUP_SCRIPT = USER_SCRIPTS_DIR + "/master-ip-setup" 
128   
129  #: LUXI socket used for job execution 
130  MASTER_SOCKET = SOCKET_DIR + "/ganeti-master" 
131  #: LUXI socket used for queries only 
132  QUERY_SOCKET = SOCKET_DIR + "/ganeti-query" 
133   
134  LOG_OS_DIR = LOG_DIR + "/os" 
135  LOG_ES_DIR = LOG_DIR + "/extstorage" 
136  #: Directory for storing Xen config files after failed instance starts 
137  LOG_XEN_DIR = LOG_DIR + "/xen" 
138   
139  # Job queue paths 
140  JOB_QUEUE_LOCK_FILE = QUEUE_DIR + "/lock" 
141  JOB_QUEUE_VERSION_FILE = QUEUE_DIR + "/version" 
142  JOB_QUEUE_SERIAL_FILE = QUEUE_DIR + "/serial" 
143  JOB_QUEUE_ARCHIVE_DIR = QUEUE_DIR + "/archive" 
144  JOB_QUEUE_DRAIN_FILE = QUEUE_DIR + "/drain" 
145   
146  ALL_CERT_FILES = compat.UniqueFrozenset([ 
147    NODED_CERT_FILE, 
148    RAPI_CERT_FILE, 
149    SPICE_CERT_FILE, 
150    SPICE_CACERT_FILE, 
151    ]) 
152   
153   
154 -def GetLogFilename(daemon_name):
155 """Returns the full path for a daemon's log file. 156 157 """ 158 return "%s/%s.log" % (LOG_DIR, daemon_name)
159 160 161 LOG_WATCHER = GetLogFilename("watcher") 162 LOG_COMMANDS = GetLogFilename("commands") 163 LOG_BURNIN = GetLogFilename("burnin") 164