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  DEFAULT_FILE_STORAGE_DIR = "/srv/ganeti/file-storage" 
 33  DEFAULT_FILE_STORAGE_DIR = vcluster.AddNodePrefix(DEFAULT_FILE_STORAGE_DIR) 
 34  DEFAULT_SHARED_FILE_STORAGE_DIR = "/srv/ganeti/shared-file-storage" 
 35  DEFAULT_SHARED_FILE_STORAGE_DIR = \ 
 36      vcluster.AddNodePrefix(DEFAULT_SHARED_FILE_STORAGE_DIR) 
 37  EXPORT_DIR = vcluster.AddNodePrefix(_autoconf.EXPORT_DIR) 
 38  OS_SEARCH_PATH = _autoconf.OS_SEARCH_PATH 
 39  ES_SEARCH_PATH = _autoconf.ES_SEARCH_PATH 
 40  SSH_CONFIG_DIR = _autoconf.SSH_CONFIG_DIR 
 41  XEN_CONFIG_DIR = vcluster.AddNodePrefix(_autoconf.XEN_CONFIG_DIR) 
 42  SYSCONFDIR = vcluster.AddNodePrefix(_autoconf.SYSCONFDIR) 
 43  TOOLSDIR = _autoconf.TOOLSDIR 
 44  LOCALSTATEDIR = vcluster.AddNodePrefix(_autoconf.LOCALSTATEDIR) 
 45   
 46  # Paths which don't change for a virtual cluster 
 47  DAEMON_UTIL = _autoconf.PKGLIBDIR + "/daemon-util" 
 48  IMPORT_EXPORT_DAEMON = _autoconf.PKGLIBDIR + "/import-export" 
 49  KVM_CONSOLE_WRAPPER = _autoconf.PKGLIBDIR + "/tools/kvm-console-wrapper" 
 50  KVM_IFUP = _autoconf.PKGLIBDIR + "/kvm-ifup" 
 51  PREPARE_NODE_JOIN = _autoconf.PKGLIBDIR + "/prepare-node-join" 
 52  NODE_DAEMON_SETUP = _autoconf.PKGLIBDIR + "/node-daemon-setup" 
 53  XEN_CONSOLE_WRAPPER = _autoconf.PKGLIBDIR + "/tools/xen-console-wrapper" 
 54  ETC_HOSTS = vcluster.ETC_HOSTS 
 55   
 56  # Top-level paths 
 57  DATA_DIR = LOCALSTATEDIR + "/lib/ganeti" 
 58  LOCK_DIR = LOCALSTATEDIR + "/lock" 
 59  LOG_DIR = LOCALSTATEDIR + "/log/ganeti" 
 60  RUN_DIR = LOCALSTATEDIR + "/run/ganeti" 
 61   
 62  #: Script to configure master IP address 
 63  DEFAULT_MASTER_SETUP_SCRIPT = TOOLSDIR + "/master-ip-setup" 
 64   
 65  SSH_HOST_DSA_PRIV = SSH_CONFIG_DIR + "/ssh_host_dsa_key" 
 66  SSH_HOST_DSA_PUB = SSH_HOST_DSA_PRIV + ".pub" 
 67  SSH_HOST_RSA_PRIV = SSH_CONFIG_DIR + "/ssh_host_rsa_key" 
 68  SSH_HOST_RSA_PUB = SSH_HOST_RSA_PRIV + ".pub" 
 69   
 70  BDEV_CACHE_DIR = RUN_DIR + "/bdev-cache" 
 71  DISK_LINKS_DIR = RUN_DIR + "/instance-disks" 
 72  SOCKET_DIR = RUN_DIR + "/socket" 
 73  CRYPTO_KEYS_DIR = RUN_DIR + "/crypto" 
 74  IMPORT_EXPORT_DIR = RUN_DIR + "/import-export" 
 75  INSTANCE_STATUS_FILE = RUN_DIR + "/instance-status" 
 76  INSTANCE_REASON_DIR = RUN_DIR + "/instance-reason" 
 77  #: User-id pool lock directory (used user IDs have a corresponding lock file in 
 78  #: this directory) 
 79  UIDPOOL_LOCKDIR = RUN_DIR + "/uid-pool" 
 80   
 81  SSCONF_LOCK_FILE = LOCK_DIR + "/ganeti-ssconf.lock" 
 82   
 83  CLUSTER_CONF_FILE = DATA_DIR + "/config.data" 
 84  RAPI_CERT_FILE = DATA_DIR + "/rapi.pem" 
 85  CONFD_HMAC_KEY = DATA_DIR + "/hmac.key" 
 86  SPICE_CERT_FILE = DATA_DIR + "/spice.pem" 
 87  SPICE_CACERT_FILE = DATA_DIR + "/spice-ca.pem" 
 88  CLUSTER_DOMAIN_SECRET_FILE = DATA_DIR + "/cluster-domain-secret" 
 89  SSH_KNOWN_HOSTS_FILE = DATA_DIR + "/known_hosts" 
 90  RAPI_USERS_FILE = DATA_DIR + "/rapi/users" 
 91  QUEUE_DIR = DATA_DIR + "/queue" 
 92  CONF_DIR = SYSCONFDIR + "/ganeti" 
 93  USER_SCRIPTS_DIR = CONF_DIR + "/scripts" 
 94  VNC_PASSWORD_FILE = CONF_DIR + "/vnc-cluster-password" 
 95  HOOKS_BASE_DIR = CONF_DIR + "/hooks" 
 96  FILE_STORAGE_PATHS_FILE = CONF_DIR + "/file-storage-paths" 
 97  RESTRICTED_COMMANDS_DIR = CONF_DIR + "/restricted-commands" 
 98   
 99  #: Node daemon certificate path 
100  NODED_CERT_FILE = DATA_DIR + "/server.pem" 
101   
102  #: Node daemon certificate file permissions 
103  NODED_CERT_MODE = 0440 
104   
105  #: Locked in exclusive mode while noded verifies a remote command 
106  RESTRICTED_COMMANDS_LOCK_FILE = LOCK_DIR + "/ganeti-restricted-commands.lock" 
107   
108  #: Lock file for watcher, locked in shared mode by watcher; lock in exclusive 
109  # mode to block watcher (see L{cli._RunWhileClusterStoppedHelper.Call} 
110  WATCHER_LOCK_FILE = LOCK_DIR + "/ganeti-watcher.lock" 
111   
112  #: Status file for per-group watcher, locked in exclusive mode by watcher 
113  WATCHER_GROUP_STATE_FILE = DATA_DIR + "/watcher.%s.data" 
114   
115  #: File for per-group instance status, merged into L{INSTANCE_STATUS_FILE} by 
116  #: per-group processes 
117  WATCHER_GROUP_INSTANCE_STATUS_FILE = DATA_DIR + "/watcher.%s.instance-status" 
118   
119  #: File containing Unix timestamp until which watcher should be paused 
120  WATCHER_PAUSEFILE = DATA_DIR + "/watcher.pause" 
121   
122  #: User-provided master IP setup script 
123  EXTERNAL_MASTER_SETUP_SCRIPT = USER_SCRIPTS_DIR + "/master-ip-setup" 
124   
125  #: LUXI socket used for job execution 
126  MASTER_SOCKET = SOCKET_DIR + "/ganeti-master" 
127  #: LUXI socket used for queries only 
128  QUERY_SOCKET = SOCKET_DIR + "/ganeti-query" 
129   
130  LOG_OS_DIR = LOG_DIR + "/os" 
131  LOG_ES_DIR = LOG_DIR + "/extstorage" 
132  #: Directory for storing Xen config files after failed instance starts 
133  LOG_XEN_DIR = LOG_DIR + "/xen" 
134   
135  # Job queue paths 
136  JOB_QUEUE_LOCK_FILE = QUEUE_DIR + "/lock" 
137  JOB_QUEUE_VERSION_FILE = QUEUE_DIR + "/version" 
138  JOB_QUEUE_SERIAL_FILE = QUEUE_DIR + "/serial" 
139  JOB_QUEUE_ARCHIVE_DIR = QUEUE_DIR + "/archive" 
140  JOB_QUEUE_DRAIN_FILE = QUEUE_DIR + "/drain" 
141   
142  ALL_CERT_FILES = compat.UniqueFrozenset([ 
143    NODED_CERT_FILE, 
144    RAPI_CERT_FILE, 
145    SPICE_CERT_FILE, 
146    SPICE_CACERT_FILE, 
147    ]) 
148   
149   
150 -def GetLogFilename(daemon_name):
151 """Returns the full path for a daemon's log file. 152 153 """ 154 return "%s/%s.log" % (LOG_DIR, daemon_name)
155 156 157 LOG_WATCHER = GetLogFilename("watcher") 158 LOG_COMMANDS = GetLogFilename("commands") 159 LOG_BURNIN = GetLogFilename("burnin") 160