4 # Copyright (C) 2006, 2007 Google Inc.
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.
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.
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
22 """Module holding different constants."""
26 from ganeti import _autoconf
31 RELEASE_VERSION = _autoconf.PACKAGE_VERSION
38 DATA_DIR = _autoconf.LOCALSTATEDIR + "/lib/ganeti"
39 RUN_DIR = _autoconf.LOCALSTATEDIR + "/run"
40 RUN_GANETI_DIR = RUN_DIR + "/ganeti"
41 BDEV_CACHE_DIR = RUN_GANETI_DIR # TODO(2.0): move deeper
42 DISK_LINKS_DIR = RUN_GANETI_DIR + "/instance-disks"
43 # keep RUN_GANETI_DIR first here, to make sure all get created when the node
44 # daemon is started (this takes care of RUN_DIR being tmpfs)
45 SUB_RUN_DIRS = [ RUN_GANETI_DIR, BDEV_CACHE_DIR, DISK_LINKS_DIR ]
46 LOCK_DIR = _autoconf.LOCALSTATEDIR + "/lock"
47 CLUSTER_CONF_FILE = DATA_DIR + "/config.data"
48 SSL_CERT_FILE = DATA_DIR + "/server.pem"
49 WATCHER_STATEFILE = DATA_DIR + "/watcher.data"
50 SSH_KNOWN_HOSTS_FILE = DATA_DIR + "/known_hosts"
51 ETC_HOSTS = "/etc/hosts"
53 NODE_INITD_SCRIPT = _autoconf.SYSCONFDIR + "/init.d/ganeti"
54 DEFAULT_NODED_PORT = 1811
55 FIRST_DRBD_PORT = 11000
56 LAST_DRBD_PORT = 14999
57 MASTER_SCRIPT = "ganeti-master"
59 LOG_DIR = _autoconf.LOCALSTATEDIR + "/log/ganeti"
60 LOG_OS_DIR = LOG_DIR + "/os"
61 LOG_NODESERVER = LOG_DIR + "/node-daemon.log"
62 LOG_RAPISERVER = LOG_DIR + "/rapi-daemon.log"
63 LOG_RAPIACCESS = LOG_DIR + "/rapi-access.log"
64 LOG_WATCHER = LOG_DIR + "/watcher.log"
66 OS_SEARCH_PATH = _autoconf.OS_SEARCH_PATH
67 EXPORT_DIR = _autoconf.EXPORT_DIR
69 EXPORT_CONF_FILE = "config.ini"
71 XEN_KERNEL = _autoconf.XEN_KERNEL
72 XEN_INITRD = _autoconf.XEN_INITRD
74 VALUE_DEFAULT = "default"
76 VALUE_GENERATE = "generate"
79 # External script validation mask
80 EXT_PLUGIN_MASK = re.compile("^[a-zA-Z0-9_-]+$")
82 # hooks-related constants
83 HOOKS_BASE_DIR = _autoconf.SYSCONFDIR + "/ganeti/hooks"
84 HOOKS_PHASE_PRE = "pre"
85 HOOKS_PHASE_POST = "post"
86 HOOKS_NAME_CFGUPDATE = "config-update"
89 # hooks subject type (what object type does the LU deal with)
90 HTYPE_CLUSTER = "CLUSTER"
92 HTYPE_INSTANCE = "INSTANCE"
99 DT_DISKLESS = "diskless"
101 DT_LOCAL_RAID1 = "local_raid1"
102 DT_REMOTE_RAID1 = "remote_raid1"
105 # the set of network-mirrored disk templates
106 DTS_NET_MIRROR = frozenset([DT_REMOTE_RAID1, DT_DRBD8])
110 LD_MD_R1 = "md_raid1"
114 # the set of drbd-like disk types
115 LDS_DRBD = frozenset([LD_DRBD7, LD_DRBD8])
117 # disk replacement mode
118 REPLACE_DISK_PRI = "replace_primary"
119 REPLACE_DISK_SEC = "replace_secondary"
120 REPLACE_DISK_ALL = "replace_all"
122 # instance creation modes
123 INSTANCE_CREATE = "create"
124 INSTANCE_IMPORT = "import"
126 DISK_TEMPLATES = frozenset([DT_DISKLESS, DT_PLAIN,
127 DT_LOCAL_RAID1, DT_REMOTE_RAID1,
130 # import/export config options
131 INISECT_EXP = "export"
132 INISECT_INS = "instance"
138 EXIT_NODESETUP_ERROR = 12
139 EXIT_CONFIRMATION = 13 # need user confirmation
142 TAG_CLUSTER = "cluster"
144 TAG_INSTANCE = "instance"
146 MAX_TAGS_PER_OBJ = 48
149 DEFAULT_BRIDGE = "xen-br0"
150 SYNC_SPEED = 60 * 1024
151 LOCALHOST_IP_ADDRESS = "127.0.0.1"
152 TCP_PING_TIMEOUT = 10
153 GANETI_RUNAS = "root"
154 BIND_ADDRESS_GLOBAL = "0.0.0.0"
156 # migration rpc steps
157 (DRBD_RECONF_RPC_INIT,
158 DRBD_RECONF_RPC_DISCONNECT,
159 DRBD_RECONF_RPC_RECONNECT,
160 DRBD_RECONF_RPC_SECONDARY,
161 DRBD_RECONF_RPC_WFSYNC,
165 OS_VALID_STATUS = "VALID"
168 SSH_INITD_SCRIPT = _autoconf.SSH_INITD_SCRIPT
169 SSH_CONFIG_DIR = "/etc/ssh/"
170 SSH_HOST_DSA_PRIV = SSH_CONFIG_DIR + "ssh_host_dsa_key"
171 SSH_HOST_DSA_PUB = SSH_HOST_DSA_PRIV + ".pub"
172 SSH_HOST_RSA_PRIV = SSH_CONFIG_DIR + "ssh_host_rsa_key"
173 SSH_HOST_RSA_PUB = SSH_HOST_RSA_PRIV + ".pub"
176 INSTANCE_REBOOT_SOFT = "soft"
177 INSTANCE_REBOOT_HARD = "hard"
178 INSTANCE_REBOOT_FULL = "full"
180 # Hypervisor constants
181 HT_XEN_PVM30 = "xen-3.0"
183 HT_XEN_HVM31 = "xen-hvm-3.1"
184 HYPER_TYPES = frozenset([HT_XEN_PVM30, HT_FAKE, HT_XEN_HVM31])
185 HTS_REQ_PORT = frozenset([HT_XEN_HVM31])
187 HT_HVM_VNC_BASE_PORT = 5900
188 HT_HVM_DEFAULT_BOOT_ORDER = 'dc'
189 HT_HVM_DEFAULT_ACPI_MODE = '1'
190 HT_HVM_DEFAULT_PAE_MODE = '1'
191 VNC_PASSWORD_FILE = _autoconf.SYSCONFDIR + "/ganeti/vnc-cluster-password"
192 VNC_DEFAULT_BIND_ADDRESS = '0.0.0.0'
195 HT_HVM_NIC_RTL8139 = "rtl8139"
196 HT_HVM_NIC_NE2K_PCI = "ne2k_pci"
197 HT_HVM_NIC_NE2K_ISA = "ne2k_isa"
198 HT_HVM_DEV_PARAVIRTUAL = "paravirtual"
199 HT_HVM_DEV_IOEMU = "ioemu"
200 HT_HVM_VALID_NIC_TYPES = frozenset([HT_HVM_NIC_RTL8139, HT_HVM_NIC_NE2K_PCI,
202 HT_HVM_DEV_PARAVIRTUAL])
203 HT_HVM_VALID_DISK_TYPES = frozenset([HT_HVM_DEV_PARAVIRTUAL, HT_HVM_DEV_IOEMU])
205 # Cluster Verify steps
206 VERIFY_NPLUSONE_MEM = 'nplusone_mem'
207 VERIFY_OPTIONAL_CHECKS = frozenset([VERIFY_NPLUSONE_MEM])
209 # Allocator framework constants
210 IALLOCATOR_DIR_IN = "in"
211 IALLOCATOR_DIR_OUT = "out"
212 IALLOCATOR_MODE_ALLOC = "allocate"
213 IALLOCATOR_MODE_RELOC = "relocate"
214 IALLOCATOR_SEARCH_PATH = _autoconf.IALLOCATOR_SEARCH_PATH
219 # Remote API constants
220 RAPI_ENABLE = _autoconf.RAPI_ENABLE