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  # All rights reserved. 
  6  # 
  7  # Redistribution and use in source and binary forms, with or without 
  8  # modification, are permitted provided that the following conditions are 
  9  # met: 
 10  # 
 11  # 1. Redistributions of source code must retain the above copyright notice, 
 12  # this list of conditions and the following disclaimer. 
 13  # 
 14  # 2. Redistributions in binary form must reproduce the above copyright 
 15  # notice, this list of conditions and the following disclaimer in the 
 16  # documentation and/or other materials provided with the distribution. 
 17  # 
 18  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 
 19  # IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 
 20  # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
 21  # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
 22  # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
 23  # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
 24  # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
 25  # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
 26  # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
 27  # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
 28  # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 29   
 30   
 31  """Module containing constants and functions for filesystem paths. 
 32   
 33  """ 
 34   
 35  from ganeti import _constants 
 36  from ganeti import compat 
 37  from ganeti import vcluster 
 38   
 39   
 40  # Build-time constants 
 41  DEFAULT_FILE_STORAGE_DIR = "/srv/ganeti/file-storage" 
 42  DEFAULT_FILE_STORAGE_DIR = vcluster.AddNodePrefix(DEFAULT_FILE_STORAGE_DIR) 
 43  DEFAULT_SHARED_FILE_STORAGE_DIR = "/srv/ganeti/shared-file-storage" 
 44  DEFAULT_SHARED_FILE_STORAGE_DIR = \ 
 45      vcluster.AddNodePrefix(DEFAULT_SHARED_FILE_STORAGE_DIR) 
 46  DEFAULT_GLUSTER_STORAGE_DIR = "/var/run/ganeti/gluster" 
 47  DEFAULT_GLUSTER_STORAGE_DIR = \ 
 48      vcluster.AddNodePrefix(DEFAULT_GLUSTER_STORAGE_DIR) 
 49  EXPORT_DIR = vcluster.AddNodePrefix(_constants.EXPORT_DIR) 
 50  BACKUP_DIR = vcluster.AddNodePrefix(_constants.BACKUP_DIR) 
 51  OS_SEARCH_PATH = _constants.OS_SEARCH_PATH 
 52  ES_SEARCH_PATH = _constants.ES_SEARCH_PATH 
 53  SSH_CONFIG_DIR = _constants.SSH_CONFIG_DIR 
 54  XEN_CONFIG_DIR = vcluster.AddNodePrefix(_constants.XEN_CONFIG_DIR) 
 55  SYSCONFDIR = vcluster.AddNodePrefix(_constants.SYSCONFDIR) 
 56  TOOLSDIR = _constants.TOOLSDIR 
 57  PKGLIBDIR = _constants.PKGLIBDIR 
 58  SHAREDIR = _constants.SHAREDIR 
 59  LOCALSTATEDIR = vcluster.AddNodePrefix(_constants.LOCALSTATEDIR) 
 60   
 61  # Paths which don't change for a virtual cluster 
 62  DAEMON_UTIL = _constants.PKGLIBDIR + "/daemon-util" 
 63  IMPORT_EXPORT_DAEMON = _constants.PKGLIBDIR + "/import-export" 
 64  KVM_CONSOLE_WRAPPER = _constants.PKGLIBDIR + "/tools/kvm-console-wrapper" 
 65  KVM_IFUP = _constants.PKGLIBDIR + "/kvm-ifup" 
 66  PREPARE_NODE_JOIN = _constants.PKGLIBDIR + "/prepare-node-join" 
 67  NODE_DAEMON_SETUP = _constants.PKGLIBDIR + "/node-daemon-setup" 
 68  XEN_CONSOLE_WRAPPER = _constants.PKGLIBDIR + "/tools/xen-console-wrapper" 
 69  CFGUPGRADE = _constants.PKGLIBDIR + "/tools/cfgupgrade" 
 70  POST_UPGRADE = _constants.PKGLIBDIR + "/tools/post-upgrade" 
 71  ENSURE_DIRS = _constants.PKGLIBDIR + "/ensure-dirs" 
 72  ETC_HOSTS = vcluster.ETC_HOSTS 
 73   
 74  # Top-level paths 
 75  DATA_DIR = LOCALSTATEDIR + "/lib/ganeti" 
 76  LOCK_DIR = LOCALSTATEDIR + "/lock" 
 77  LOG_DIR = LOCALSTATEDIR + "/log/ganeti" 
 78  RUN_DIR = LOCALSTATEDIR + "/run/ganeti" 
 79   
 80  #: Script to configure master IP address 
 81  DEFAULT_MASTER_SETUP_SCRIPT = TOOLSDIR + "/master-ip-setup" 
 82   
 83  SSH_HOST_DSA_PRIV = _constants.SSH_HOST_DSA_PRIV 
 84  SSH_HOST_DSA_PUB = _constants.SSH_HOST_DSA_PUB 
 85  SSH_HOST_RSA_PRIV = _constants.SSH_HOST_RSA_PRIV 
 86  SSH_HOST_RSA_PUB = _constants.SSH_HOST_RSA_PUB 
 87   
 88  BDEV_CACHE_DIR = RUN_DIR + "/bdev-cache" 
 89  DISK_LINKS_DIR = RUN_DIR + "/instance-disks" 
 90  SOCKET_DIR = RUN_DIR + "/socket" 
 91  CRYPTO_KEYS_DIR = RUN_DIR + "/crypto" 
 92  IMPORT_EXPORT_DIR = RUN_DIR + "/import-export" 
 93  INSTANCE_STATUS_FILE = RUN_DIR + "/instance-status" 
 94  INSTANCE_REASON_DIR = RUN_DIR + "/instance-reason" 
 95  #: User-id pool lock directory (used user IDs have a corresponding lock file in 
 96  #: this directory) 
 97  UIDPOOL_LOCKDIR = RUN_DIR + "/uid-pool" 
 98   
 99  SSCONF_LOCK_FILE = LOCK_DIR + "/ganeti-ssconf.lock" 
100   
101  CLUSTER_CONF_FILE = DATA_DIR + "/config.data" 
102  RAPI_CERT_FILE = DATA_DIR + "/rapi.pem" 
103  CONFD_HMAC_KEY = DATA_DIR + "/hmac.key" 
104  SPICE_CERT_FILE = DATA_DIR + "/spice.pem" 
105  SPICE_CACERT_FILE = DATA_DIR + "/spice-ca.pem" 
106  CLUSTER_DOMAIN_SECRET_FILE = DATA_DIR + "/cluster-domain-secret" 
107  SSH_KNOWN_HOSTS_FILE = DATA_DIR + "/known_hosts" 
108  RAPI_USERS_FILE = DATA_DIR + "/rapi/users" 
109  QUEUE_DIR = DATA_DIR + "/queue" 
110  INTENT_TO_UPGRADE = DATA_DIR + "/intent-to-upgrade" 
111  CONF_DIR = SYSCONFDIR + "/ganeti" 
112  USER_SCRIPTS_DIR = CONF_DIR + "/scripts" 
113  VNC_PASSWORD_FILE = CONF_DIR + "/vnc-cluster-password" 
114  HOOKS_BASE_DIR = CONF_DIR + "/hooks" 
115  FILE_STORAGE_PATHS_FILE = CONF_DIR + "/file-storage-paths" 
116  RESTRICTED_COMMANDS_DIR = CONF_DIR + "/restricted-commands" 
117   
118  #: Node daemon certificate path 
119  NODED_CERT_FILE = DATA_DIR + "/server.pem" 
120  NODED_CLIENT_CERT_FILE = DATA_DIR + "/client.pem" 
121  NODED_CLIENT_CERT_FILE_TMP = DATA_DIR + "/client.pem.tmp" 
122   
123  #: Node daemon certificate file permissions 
124  NODED_CERT_MODE = 0440 
125   
126  #: Locked in exclusive mode while noded verifies a remote command 
127  RESTRICTED_COMMANDS_LOCK_FILE = LOCK_DIR + "/ganeti-restricted-commands.lock" 
128   
129  #: Lock file for watcher, locked in shared mode by watcher; lock in exclusive 
130  # mode to block watcher (see L{cli._RunWhileClusterStoppedHelper.Call} 
131  WATCHER_LOCK_FILE = LOCK_DIR + "/ganeti-watcher.lock" 
132   
133  #: Status file for per-group watcher, locked in exclusive mode by watcher 
134  WATCHER_GROUP_STATE_FILE = DATA_DIR + "/watcher.%s.data" 
135   
136  #: File for per-group instance status, merged into L{INSTANCE_STATUS_FILE} by 
137  #: per-group processes 
138  WATCHER_GROUP_INSTANCE_STATUS_FILE = DATA_DIR + "/watcher.%s.instance-status" 
139   
140  #: File containing Unix timestamp until which watcher should be paused 
141  WATCHER_PAUSEFILE = DATA_DIR + "/watcher.pause" 
142   
143  #: User-provided master IP setup script 
144  EXTERNAL_MASTER_SETUP_SCRIPT = USER_SCRIPTS_DIR + "/master-ip-setup" 
145   
146  #: LUXI socket used for job execution 
147  MASTER_SOCKET = SOCKET_DIR + "/ganeti-master" 
148  #: LUXI socket used for queries only 
149  QUERY_SOCKET = SOCKET_DIR + "/ganeti-query" 
150   
151  LOG_OS_DIR = LOG_DIR + "/os" 
152  LOG_ES_DIR = LOG_DIR + "/extstorage" 
153  #: Directory for storing Xen config files after failed instance starts 
154  LOG_XEN_DIR = LOG_DIR + "/xen" 
155   
156  # Job queue paths 
157  JOB_QUEUE_LOCK_FILE = QUEUE_DIR + "/lock" 
158  JOB_QUEUE_VERSION_FILE = QUEUE_DIR + "/version" 
159  JOB_QUEUE_SERIAL_FILE = QUEUE_DIR + "/serial" 
160  JOB_QUEUE_ARCHIVE_DIR = QUEUE_DIR + "/archive" 
161  JOB_QUEUE_DRAIN_FILE = QUEUE_DIR + "/drain" 
162   
163  ALL_CERT_FILES = compat.UniqueFrozenset([ 
164    NODED_CERT_FILE, 
165    RAPI_CERT_FILE, 
166    SPICE_CERT_FILE, 
167    SPICE_CACERT_FILE, 
168    ]) 
169   
170   
171 -def GetLogFilename(daemon_name):
172 """Returns the full path for a daemon's log file. 173 174 """ 175 return "%s/%s.log" % (LOG_DIR, daemon_name)
176 177 178 LOG_WATCHER = GetLogFilename("watcher") 179 LOG_COMMANDS = GetLogFilename("commands") 180 LOG_BURNIN = GetLogFilename("burnin") 181