4 # Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 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
29 RELEASE_VERSION = _autoconf.PACKAGE_VERSION
33 OS_API_VERSIONS = frozenset([OS_API_V10, OS_API_V15, OS_API_V20])
34 VCS_VERSION = _autoconf.VCS_VERSION
39 # Format for CONFIG_VERSION:
40 # 01 03 0123 = 01030123
42 # | | + Configuration version/revision
46 # It stored as an integer. Make sure not to write an octal number.
48 # BuildVersion and SplitVersion must be in here because we can't import other
49 # modules. The cfgupgrade tool must be able to read and write version numbers
50 # and thus requires these functions. To avoid code duplication, they're kept in
53 def BuildVersion(major, minor, revision):
54 """Calculates int version number from major, minor and revision numbers.
56 Returns: int representing version number
59 assert isinstance(major, int)
60 assert isinstance(minor, int)
61 assert isinstance(revision, int)
62 return (1000000 * major +
67 def SplitVersion(version):
68 """Splits version number stored in an int.
70 Returns: tuple; (major, minor, revision)
73 assert isinstance(version, int)
75 (major, remainder) = divmod(version, 1000000)
76 (minor, revision) = divmod(remainder, 10000)
78 return (major, minor, revision)
81 CONFIG_MAJOR = int(_autoconf.VERSION_MAJOR)
82 CONFIG_MINOR = int(_autoconf.VERSION_MINOR)
84 CONFIG_VERSION = BuildVersion(CONFIG_MAJOR, CONFIG_MINOR, CONFIG_REVISION)
86 #: RPC protocol version
87 PROTOCOL_VERSION = BuildVersion(CONFIG_MAJOR, CONFIG_MINOR, 0)
90 DAEMONS_GROUP = _autoconf.DAEMONS_GROUP
91 ADMIN_GROUP = _autoconf.ADMIN_GROUP
92 MASTERD_USER = _autoconf.MASTERD_USER
93 MASTERD_GROUP = _autoconf.MASTERD_GROUP
94 RAPI_USER = _autoconf.RAPI_USER
95 RAPI_GROUP = _autoconf.RAPI_GROUP
96 CONFD_USER = _autoconf.CONFD_USER
97 CONFD_GROUP = _autoconf.CONFD_GROUP
98 NODED_USER = _autoconf.NODED_USER
103 WIPE_BLOCK_SIZE = 1024**2
104 MAX_WIPE_CHUNK = 1024 # 1GB
105 MIN_WIPE_CHUNK_PERCENT = 10
109 DATA_DIR = _autoconf.LOCALSTATEDIR + "/lib/ganeti"
110 RUN_DIR = _autoconf.LOCALSTATEDIR + "/run"
111 RUN_GANETI_DIR = RUN_DIR + "/ganeti"
112 BDEV_CACHE_DIR = RUN_GANETI_DIR + "/bdev-cache"
113 DISK_LINKS_DIR = RUN_GANETI_DIR + "/instance-disks"
115 SOCKET_DIR = RUN_GANETI_DIR + "/socket"
116 SECURE_DIR_MODE = 0700
117 SECURE_FILE_MODE = 0600
118 SOCKET_DIR_MODE = 0750
119 CRYPTO_KEYS_DIR = RUN_GANETI_DIR + "/crypto"
120 CRYPTO_KEYS_DIR_MODE = SECURE_DIR_MODE
121 IMPORT_EXPORT_DIR = RUN_GANETI_DIR + "/import-export"
122 IMPORT_EXPORT_DIR_MODE = 0755
123 # keep RUN_GANETI_DIR first here, to make sure all get created when the node
124 # daemon is started (this takes care of RUN_DIR being tmpfs)
125 SUB_RUN_DIRS = [ RUN_GANETI_DIR, BDEV_CACHE_DIR, DISK_LINKS_DIR ]
126 LOCK_DIR = _autoconf.LOCALSTATEDIR + "/lock"
127 SSCONF_LOCK_FILE = LOCK_DIR + "/ganeti-ssconf.lock"
128 # User-id pool lock directory
129 # The user-ids that are in use have a corresponding lock file in this directory
130 UIDPOOL_LOCKDIR = RUN_GANETI_DIR + "/uid-pool"
131 CLUSTER_CONF_FILE = DATA_DIR + "/config.data"
132 NODED_CERT_FILE = DATA_DIR + "/server.pem"
133 RAPI_CERT_FILE = DATA_DIR + "/rapi.pem"
134 CONFD_HMAC_KEY = DATA_DIR + "/hmac.key"
135 CLUSTER_DOMAIN_SECRET_FILE = DATA_DIR + "/cluster-domain-secret"
136 WATCHER_STATEFILE = DATA_DIR + "/watcher.data"
137 WATCHER_PAUSEFILE = DATA_DIR + "/watcher.pause"
138 INSTANCE_UPFILE = RUN_GANETI_DIR + "/instance-status"
139 SSH_KNOWN_HOSTS_FILE = DATA_DIR + "/known_hosts"
140 RAPI_USERS_FILE = DATA_DIR + "/rapi/users"
141 QUEUE_DIR = DATA_DIR + "/queue"
142 DAEMON_UTIL = _autoconf.PKGLIBDIR + "/daemon-util"
143 SETUP_SSH = _autoconf.TOOLSDIR + "/setup-ssh"
144 KVM_IFUP = _autoconf.PKGLIBDIR + "/kvm-ifup"
145 ETC_HOSTS = "/etc/hosts"
146 DEFAULT_FILE_STORAGE_DIR = _autoconf.FILE_STORAGE_DIR
147 ENABLE_FILE_STORAGE = _autoconf.ENABLE_FILE_STORAGE
148 SYSCONFDIR = _autoconf.SYSCONFDIR
149 TOOLSDIR = _autoconf.TOOLSDIR
150 CONF_DIR = SYSCONFDIR + "/ganeti"
152 ALL_CERT_FILES = frozenset([NODED_CERT_FILE, RAPI_CERT_FILE])
154 MASTER_SOCKET = SOCKET_DIR + "/ganeti-master"
156 NODED = "ganeti-noded"
157 CONFD = "ganeti-confd"
159 MASTERD = "ganeti-masterd"
160 # used in the ganeti-nbma project
164 # daemon-name: ("proto", "default-port")
165 NODED: ("tcp", 1811),
166 CONFD: ("udp", 1814),
169 # used in the ganeti-nbma project
172 DEFAULT_NODED_PORT = DAEMONS_PORTS[NODED][1]
173 DEFAULT_CONFD_PORT = DAEMONS_PORTS[CONFD][1]
174 DEFAULT_RAPI_PORT = DAEMONS_PORTS[RAPI][1]
175 # used in the ganeti-nbma project
176 DEFAULT_NLD_PORT = DAEMONS_PORTS[NLD][1]
178 FIRST_DRBD_PORT = 11000
179 LAST_DRBD_PORT = 14999
180 MASTER_SCRIPT = "ganeti-master"
182 LOG_DIR = _autoconf.LOCALSTATEDIR + "/log/ganeti/"
184 # "daemon-name": "logfile"
185 NODED: LOG_DIR + "node-daemon.log",
186 CONFD: LOG_DIR + "conf-daemon.log",
187 RAPI: LOG_DIR + "rapi-daemon.log",
188 MASTERD: LOG_DIR + "master-daemon.log",
189 # used in the ganeti-nbma project
190 NLD: LOG_DIR + "nl-daemon.log",
193 LOG_OS_DIR = LOG_DIR + "os"
194 LOG_WATCHER = LOG_DIR + "watcher.log"
195 LOG_COMMANDS = LOG_DIR + "commands.log"
196 LOG_BURNIN = LOG_DIR + "burnin.log"
197 LOG_SETUP_SSH = LOG_DIR + "setup-ssh.log"
199 DEV_CONSOLE = "/dev/console"
201 PROC_MOUNTS = "/proc/mounts"
203 # luxi related constants
205 LUXI_VERSION = CONFIG_VERSION
207 # one of 'no', 'yes', 'only'
208 SYSLOG_USAGE = _autoconf.SYSLOG_USAGE
212 SYSLOG_SOCKET = "/dev/log"
214 OS_SEARCH_PATH = _autoconf.OS_SEARCH_PATH
215 EXPORT_DIR = _autoconf.EXPORT_DIR
217 EXPORT_CONF_FILE = "config.ini"
219 XEN_BOOTLOADER = _autoconf.XEN_BOOTLOADER
220 XEN_KERNEL = _autoconf.XEN_KERNEL
221 XEN_INITRD = _autoconf.XEN_INITRD
223 KVM_PATH = _autoconf.KVM_PATH
224 SOCAT_PATH = _autoconf.SOCAT_PATH
225 SOCAT_USE_ESCAPE = _autoconf.SOCAT_USE_ESCAPE
226 SOCAT_USE_COMPRESS = _autoconf.SOCAT_USE_COMPRESS
227 SOCAT_ESCAPE_CODE = "0x1d"
229 #: Console as SSH command
232 #: Console as VNC server
235 #: Display a message for console access
239 CONS_ALL = frozenset([CONS_SSH, CONS_VNC, CONS_MESSAGE])
241 # For RSA keys more bits are better, but they also make operations more
242 # expensive. NIST SP 800-131 recommends a minimum of 2048 bits from the year
246 # Ciphers allowed for SSL connections. For the format, see ciphers(1). A better
247 # way to disable ciphers would be to use the exclamation mark (!), but socat
248 # versions below 1.5 can't parse exclamation marks in options properly. When
249 # modifying the ciphers, ensure not to accidentially add something after it's
250 # been removed. Use the "openssl" utility to check the allowed ciphers, e.g.
251 # "openssl ciphers -v HIGH:-DES".
252 OPENSSL_CIPHERS = "HIGH:-DES:-3DES:-EXPORT:-ADH"
254 # Digest used to sign certificates ("openssl x509" uses SHA1 by default)
255 X509_CERT_SIGN_DIGEST = "SHA1"
257 # Default validity of certificates in days
258 X509_CERT_DEFAULT_VALIDITY = 365 * 5
260 # commonName (CN) used in certificates
261 X509_CERT_CN = "ganeti.example.com"
263 X509_CERT_SIGNATURE_HEADER = "X-Ganeti-Signature"
265 IMPORT_EXPORT_DAEMON = _autoconf.PKGLIBDIR + "/import-export"
267 # Import/export daemon mode
268 IEM_IMPORT = "import"
269 IEM_EXPORT = "export"
271 # Import/export transport compression
274 IEC_ALL = frozenset([
279 IE_CUSTOM_SIZE = "fd"
281 IE_MAGIC_RE = re.compile(r"^[-_.a-zA-Z0-9]{5,100}$")
284 # Direct file I/O, equivalent to a shell's I/O redirection using '<' or '>'
286 # Raw block device I/O using "dd"
287 IEIO_RAW_DISK = "raw"
288 # OS definition import/export script
289 IEIO_SCRIPT = "script"
291 VALUE_DEFAULT = "default"
293 VALUE_GENERATE = "generate"
296 VALUE_FALSE = "false"
298 # External script validation mask
299 EXT_PLUGIN_MASK = re.compile("^[a-zA-Z0-9_-]+$")
301 # hooks-related constants
302 HOOKS_BASE_DIR = CONF_DIR + "/hooks"
303 HOOKS_PHASE_PRE = "pre"
304 HOOKS_PHASE_POST = "post"
305 HOOKS_NAME_CFGUPDATE = "config-update"
306 HOOKS_NAME_WATCHER = "watcher"
309 # hooks subject type (what object type does the LU deal with)
310 HTYPE_CLUSTER = "CLUSTER"
312 HTYPE_GROUP = "GROUP"
313 HTYPE_INSTANCE = "INSTANCE"
325 # first two are valid in LU context only, not passed to backend
328 # and the rest are valid in backend
333 SF_ALLOCATABLE = "allocatable"
336 SO_FIX_CONSISTENCY = "fix-consistency"
338 # Available fields per storage type
339 VALID_STORAGE_FIELDS = frozenset([SF_NAME, SF_TYPE, SF_SIZE,
340 SF_USED, SF_FREE, SF_ALLOCATABLE])
342 VALID_STORAGE_TYPES = frozenset([ST_FILE, ST_LVM_PV, ST_LVM_VG])
344 MODIFIABLE_STORAGE_FIELDS = {
345 ST_LVM_PV: frozenset([SF_ALLOCATABLE]),
348 VALID_STORAGE_OPERATIONS = {
349 ST_LVM_VG: frozenset([SO_FIX_CONSISTENCY]),
353 # Note: Code depends on LDS_OKAY < LDS_UNKNOWN < LDS_FAULTY
356 LDS_FAULTY) = range(1, 4)
358 # disk template types
359 DT_DISKLESS = "diskless"
364 # the set of network-mirrored disk templates
365 DTS_NET_MIRROR = frozenset([DT_DRBD8])
367 # the set of non-lvm-based disk templates
368 DTS_NOT_LVM = frozenset([DT_DISKLESS, DT_FILE])
370 # the set of disk templates which can be grown
371 DTS_GROWABLE = frozenset([DT_PLAIN, DT_DRBD8, DT_FILE])
373 # the set of disk templates that allow adoption
374 DTS_MAY_ADOPT = frozenset([DT_PLAIN])
380 LDS_BLOCK = frozenset([LD_LV, LD_DRBD8])
383 DRBD_HMAC_ALG = "md5"
384 DRBD_NET_PROTOCOL = "C"
385 DRBD_BARRIERS = _autoconf.DRBD_BARRIERS
387 # file backend driver
391 # the set of drbd-like disk types
392 LDS_DRBD = frozenset([LD_DRBD8])
397 DISK_ACCESS_SET = frozenset([DISK_RDONLY, DISK_RDWR])
399 # disk replacement mode
400 REPLACE_DISK_PRI = "replace_on_primary" # replace disks on primary
401 REPLACE_DISK_SEC = "replace_on_secondary" # replace disks on secondary
402 REPLACE_DISK_CHG = "replace_new_secondary" # change secondary node
403 REPLACE_DISK_AUTO = "replace_auto"
404 REPLACE_MODES = frozenset([
411 # Instance export mode
412 EXPORT_MODE_LOCAL = "local"
413 EXPORT_MODE_REMOTE = "remote"
414 EXPORT_MODES = frozenset([
419 # lock recalculate mode
420 LOCKS_REPLACE = 'replace'
421 LOCKS_APPEND = 'append'
423 # instance creation modes
424 INSTANCE_CREATE = "create"
425 INSTANCE_IMPORT = "import"
426 INSTANCE_REMOTE_IMPORT = "remote-import"
427 INSTANCE_CREATE_MODES = frozenset([
430 INSTANCE_REMOTE_IMPORT,
433 # Remote import/export handshake message and version
435 RIE_HANDSHAKE = "Hi, I'm Ganeti"
437 # Remote import/export certificate validity in seconds
438 RIE_CERT_VALIDITY = 24 * 60 * 60
440 # Overall timeout for establishing connection
441 RIE_CONNECT_TIMEOUT = 180
443 # Export only: how long to wait per connection attempt (seconds)
444 RIE_CONNECT_ATTEMPT_TIMEOUT = 20
446 # Export only: number of attempts to connect
447 RIE_CONNECT_RETRIES = 10
449 #: Give child process up to 5 seconds to exit after sending a signal
450 CHILD_LINGER_TIMEOUT = 5.0
452 DISK_TEMPLATES = frozenset([DT_DISKLESS, DT_PLAIN,
455 FILE_DRIVER = frozenset([FD_LOOP, FD_BLKTAP])
457 # import/export config options
458 INISECT_EXP = "export"
459 INISECT_INS = "instance"
460 INISECT_HYP = "hypervisor"
461 INISECT_BEP = "backend"
464 # dynamic device modification
466 DDM_REMOVE = "remove"
467 DDMS_VALUES = frozenset([DDM_ADD, DDM_REMOVE])
474 EXIT_NODESETUP_ERROR = 12
475 EXIT_CONFIRMATION = 13 # need user confirmation
477 #: Exit code for query operations with unknown fields
478 EXIT_UNKNOWN_FIELD = 14
481 TAG_CLUSTER = "cluster"
483 TAG_INSTANCE = "instance"
484 VALID_TAG_TYPES = frozenset([
490 MAX_TAGS_PER_OBJ = 4096
493 DEFAULT_BRIDGE = "xen-br0"
494 SYNC_SPEED = 60 * 1024
495 IP4_ADDRESS_LOCALHOST = "127.0.0.1"
496 IP4_ADDRESS_ANY = "0.0.0.0"
497 IP6_ADDRESS_LOCALHOST = "::1"
498 IP6_ADDRESS_ANY = "::"
501 TCP_PING_TIMEOUT = 10
502 GANETI_RUNAS = "root"
504 DEFAULT_DRBD_HELPER = "/bin/true"
506 DEFAULT_MAC_PREFIX = "aa:00:00"
507 LVM_STRIPECOUNT = _autoconf.LVM_STRIPECOUNT
508 # default maximum instance wait time, in seconds.
509 DEFAULT_SHUTDOWN_TIMEOUT = 120
510 NODE_MAX_CLOCK_SKEW = 150
511 # Time for an intra-cluster disk transfer to wait for a connection
512 DISK_TRANSFER_CONNECT_TIMEOUT = 60
513 # Disk index separator
514 DISK_SEPARATOR = _autoconf.DISK_SEPARATOR
519 RUNPARTS_ERR) = range(3)
521 RUNPARTS_STATUS = frozenset([RUNPARTS_SKIP, RUNPARTS_RUN, RUNPARTS_ERR])
525 RPC_ENCODING_ZLIB_BASE64) = range(2)
527 # os related constants
528 OS_SCRIPT_CREATE = 'create'
529 OS_SCRIPT_IMPORT = 'import'
530 OS_SCRIPT_EXPORT = 'export'
531 OS_SCRIPT_RENAME = 'rename'
532 OS_SCRIPT_VERIFY = 'verify'
533 OS_SCRIPTS = frozenset([OS_SCRIPT_CREATE, OS_SCRIPT_IMPORT,
534 OS_SCRIPT_EXPORT, OS_SCRIPT_RENAME,
537 OS_API_FILE = 'ganeti_api_version'
538 OS_VARIANTS_FILE = 'variants.list'
539 OS_PARAMETERS_FILE = 'parameters.list'
541 OS_VALIDATE_PARAMETERS = 'parameters'
542 OS_VALIDATE_CALLS = frozenset([OS_VALIDATE_PARAMETERS])
545 SSH_CONFIG_DIR = _autoconf.SSH_CONFIG_DIR
546 SSH_HOST_DSA_PRIV = SSH_CONFIG_DIR + "/ssh_host_dsa_key"
547 SSH_HOST_DSA_PUB = SSH_HOST_DSA_PRIV + ".pub"
548 SSH_HOST_RSA_PRIV = SSH_CONFIG_DIR + "/ssh_host_rsa_key"
549 SSH_HOST_RSA_PUB = SSH_HOST_RSA_PRIV + ".pub"
554 INSTANCE_REBOOT_SOFT = "soft"
555 INSTANCE_REBOOT_HARD = "hard"
556 INSTANCE_REBOOT_FULL = "full"
558 REBOOT_TYPES = frozenset([INSTANCE_REBOOT_SOFT,
559 INSTANCE_REBOOT_HARD,
560 INSTANCE_REBOOT_FULL])
562 VTYPE_STRING = 'string'
563 VTYPE_MAYBE_STRING = "maybe-string"
565 VTYPE_SIZE = 'size' # size, in MiBs
567 ENFORCEABLE_TYPES = frozenset([
575 # HV parameter names (global namespace)
576 HV_BOOT_ORDER = "boot_order"
577 HV_CDROM_IMAGE_PATH = "cdrom_image_path"
578 HV_NIC_TYPE = "nic_type"
579 HV_DISK_TYPE = "disk_type"
580 HV_VNC_BIND_ADDRESS = "vnc_bind_address"
581 HV_VNC_PASSWORD_FILE = "vnc_password_file"
582 HV_VNC_TLS = "vnc_tls"
583 HV_VNC_X509 = "vnc_x509_path"
584 HV_VNC_X509_VERIFY = "vnc_x509_verify"
587 HV_USE_BOOTLOADER = "use_bootloader"
588 HV_BOOTLOADER_ARGS = "bootloader_args"
589 HV_BOOTLOADER_PATH = "bootloader_path"
590 HV_KERNEL_ARGS = "kernel_args"
591 HV_KERNEL_PATH = "kernel_path"
592 HV_INITRD_PATH = "initrd_path"
593 HV_ROOT_PATH = "root_path"
594 HV_SERIAL_CONSOLE = "serial_console"
595 HV_USB_MOUSE = "usb_mouse"
596 HV_DEVICE_MODEL = "device_model"
597 HV_INIT_SCRIPT = "init_script"
598 HV_MIGRATION_PORT = "migration_port"
599 HV_MIGRATION_BANDWIDTH = "migration_bandwidth"
600 HV_MIGRATION_DOWNTIME = "migration_downtime"
601 HV_MIGRATION_MODE = "migration_mode"
602 HV_USE_LOCALTIME = "use_localtime"
603 HV_DISK_CACHE = "disk_cache"
604 HV_SECURITY_MODEL = "security_model"
605 HV_SECURITY_DOMAIN = "security_domain"
606 HV_KVM_FLAG = "kvm_flag"
607 HV_VHOST_NET = "vhost_net"
608 HV_KVM_USE_CHROOT = "use_chroot"
609 HV_CPU_MASK = "cpu_mask"
610 HV_MEM_PATH = "mem_path"
611 HV_BLOCKDEV_PREFIX = "blockdev_prefix"
613 HVS_PARAMETER_TYPES = {
614 HV_BOOT_ORDER: VTYPE_STRING,
615 HV_CDROM_IMAGE_PATH: VTYPE_STRING,
616 HV_NIC_TYPE: VTYPE_STRING,
617 HV_DISK_TYPE: VTYPE_STRING,
618 HV_VNC_PASSWORD_FILE: VTYPE_STRING,
619 HV_VNC_BIND_ADDRESS: VTYPE_STRING,
620 HV_VNC_TLS: VTYPE_BOOL,
621 HV_VNC_X509: VTYPE_STRING,
622 HV_VNC_X509_VERIFY: VTYPE_BOOL,
625 HV_USE_BOOTLOADER: VTYPE_BOOL,
626 HV_BOOTLOADER_PATH: VTYPE_STRING,
627 HV_BOOTLOADER_ARGS: VTYPE_STRING,
628 HV_KERNEL_PATH: VTYPE_STRING,
629 HV_KERNEL_ARGS: VTYPE_STRING,
630 HV_INITRD_PATH: VTYPE_STRING,
631 HV_ROOT_PATH: VTYPE_STRING,
632 HV_SERIAL_CONSOLE: VTYPE_BOOL,
633 HV_USB_MOUSE: VTYPE_STRING,
634 HV_DEVICE_MODEL: VTYPE_STRING,
635 HV_INIT_SCRIPT: VTYPE_STRING,
636 HV_MIGRATION_PORT: VTYPE_INT,
637 HV_MIGRATION_BANDWIDTH: VTYPE_INT,
638 HV_MIGRATION_DOWNTIME: VTYPE_INT,
639 HV_MIGRATION_MODE: VTYPE_STRING,
640 HV_USE_LOCALTIME: VTYPE_BOOL,
641 HV_DISK_CACHE: VTYPE_STRING,
642 HV_SECURITY_MODEL: VTYPE_STRING,
643 HV_SECURITY_DOMAIN: VTYPE_STRING,
644 HV_KVM_FLAG: VTYPE_STRING,
645 HV_VHOST_NET: VTYPE_BOOL,
646 HV_KVM_USE_CHROOT: VTYPE_BOOL,
647 HV_CPU_MASK: VTYPE_STRING,
648 HV_MEM_PATH: VTYPE_STRING,
649 HV_BLOCKDEV_PREFIX: VTYPE_STRING,
652 HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
657 BE_AUTO_BALANCE = "auto_balance"
659 BES_PARAMETER_TYPES = {
660 BE_MEMORY: VTYPE_SIZE,
662 BE_AUTO_BALANCE: VTYPE_BOOL,
665 BES_PARAMETERS = frozenset(BES_PARAMETER_TYPES.keys())
667 # Node parameter names
668 ND_OOB_PROGRAM = "oob_program"
670 NDS_PARAMETER_TYPES = {
671 ND_OOB_PROGRAM: VTYPE_MAYBE_STRING,
674 NDS_PARAMETERS = frozenset(NDS_PARAMETER_TYPES.keys())
676 # OOB supported commands
677 OOB_POWER_ON = "power-on"
678 OOB_POWER_OFF = "power-off"
679 OOB_POWER_CYCLE = "power-cycle"
680 OOB_POWER_STATUS = "power-status"
681 OOB_HEALTH = "health"
683 OOB_COMMANDS = frozenset([OOB_POWER_ON, OOB_POWER_OFF, OOB_POWER_CYCLE,
684 OOB_POWER_STATUS, OOB_HEALTH])
686 OOB_POWER_STATUS_POWERED = "powered"
688 OOB_TIMEOUT = 60 # 60 seconds
691 OOB_STATUS_WARNING = "WARNING"
692 OOB_STATUS_CRITICAL = "CRITICAL"
693 OOB_STATUS_UNKNOWN = "UNKNOWN"
695 OOB_STATUSES = frozenset([
702 # Instance Parameters Profile
703 PP_DEFAULT = "default"
708 NIC_MODE_BRIDGED = "bridged"
709 NIC_MODE_ROUTED = "routed"
711 NIC_VALID_MODES = frozenset([NIC_MODE_BRIDGED, NIC_MODE_ROUTED])
713 NICS_PARAMETER_TYPES = {
714 NIC_MODE: VTYPE_STRING,
715 NIC_LINK: VTYPE_STRING,
718 NICS_PARAMETERS = frozenset(NICS_PARAMETER_TYPES.keys())
722 IDISK_ADOPT = "adopt"
724 IDISK_PARAMS_TYPES = {
725 IDISK_SIZE: VTYPE_SIZE,
726 IDISK_MODE: VTYPE_STRING,
727 IDISK_ADOPT: VTYPE_STRING,
728 IDISK_VG: VTYPE_STRING,
730 IDISK_PARAMS = frozenset(IDISK_PARAMS_TYPES.keys())
736 INIC_BRIDGE = "bridge"
737 INIC_PARAMS_TYPES = {
738 INIC_BRIDGE: VTYPE_STRING,
739 INIC_IP: VTYPE_MAYBE_STRING,
740 INIC_LINK: VTYPE_STRING,
741 INIC_MAC: VTYPE_STRING,
742 INIC_MODE: VTYPE_STRING,
744 INIC_PARAMS = frozenset(INIC_PARAMS_TYPES.keys())
746 # Hypervisor constants
747 HT_XEN_PVM = "xen-pvm"
749 HT_XEN_HVM = "xen-hvm"
753 HYPER_TYPES = frozenset([
761 HTS_REQ_PORT = frozenset([HT_XEN_HVM, HT_KVM])
764 VNC_PASSWORD_FILE = CONF_DIR + "/vnc-cluster-password"
765 VNC_DEFAULT_BIND_ADDRESS = IP4_ADDRESS_ANY
768 HT_NIC_RTL8139 = "rtl8139"
769 HT_NIC_NE2K_PCI = "ne2k_pci"
770 HT_NIC_NE2K_ISA = "ne2k_isa"
771 HT_NIC_I82551 = "i82551"
772 HT_NIC_I85557B = "i82557b"
773 HT_NIC_I8259ER = "i82559er"
774 HT_NIC_PCNET = "pcnet"
775 HT_NIC_E1000 = "e1000"
776 HT_NIC_PARAVIRTUAL = HT_DISK_PARAVIRTUAL = "paravirtual"
778 HT_HVM_VALID_NIC_TYPES = frozenset([HT_NIC_RTL8139, HT_NIC_NE2K_PCI,
779 HT_NIC_E1000, HT_NIC_NE2K_ISA,
781 HT_KVM_VALID_NIC_TYPES = frozenset([HT_NIC_RTL8139, HT_NIC_NE2K_PCI,
782 HT_NIC_NE2K_ISA, HT_NIC_I82551,
783 HT_NIC_I85557B, HT_NIC_I8259ER,
784 HT_NIC_PCNET, HT_NIC_E1000,
787 HT_DISK_IOEMU = "ioemu"
789 HT_DISK_SCSI = "scsi"
792 HT_DISK_PFLASH = "pflash"
794 HT_CACHE_DEFAULT = "default"
795 HT_CACHE_NONE = "none"
796 HT_CACHE_WTHROUGH = "writethrough"
797 HT_CACHE_WBACK = "writeback"
798 HT_VALID_CACHE_TYPES = frozenset([HT_CACHE_DEFAULT,
803 HT_HVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IOEMU])
804 HT_KVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IDE,
805 HT_DISK_SCSI, HT_DISK_SD, HT_DISK_MTD,
809 HT_MOUSE_MOUSE = "mouse"
810 HT_MOUSE_TABLET = "tablet"
812 HT_KVM_VALID_MOUSE_TYPES = frozenset([HT_MOUSE_MOUSE, HT_MOUSE_TABLET])
815 HT_BO_CDROM = "cdrom"
817 HT_BO_NETWORK = "network"
819 HT_KVM_VALID_BO_TYPES = frozenset([HT_BO_CDROM, HT_BO_DISK, HT_BO_NETWORK])
826 HT_KVM_VALID_SM_TYPES = frozenset([HT_SM_NONE, HT_SM_USER, HT_SM_POOL])
829 HT_KVM_ENABLED = "enabled"
830 HT_KVM_DISABLED = "disabled"
832 HT_KVM_FLAG_VALUES = frozenset([HT_KVM_ENABLED, HT_KVM_DISABLED])
835 HT_MIGRATION_LIVE = "live"
836 HT_MIGRATION_NONLIVE = "non-live"
837 HT_MIGRATION_MODES = frozenset([HT_MIGRATION_LIVE, HT_MIGRATION_NONLIVE])
839 # Cluster Verify steps
840 VERIFY_NPLUSONE_MEM = 'nplusone_mem'
841 VERIFY_OPTIONAL_CHECKS = frozenset([VERIFY_NPLUSONE_MEM])
843 # Node verify constants
844 NV_DRBDHELPER = "drbd-helper"
845 NV_DRBDLIST = "drbd-list"
846 NV_FILELIST = "filelist"
848 NV_HYPERVISOR = "hypervisor"
849 NV_HVPARAMS = "hvparms"
850 NV_INSTANCELIST = "instancelist"
852 NV_MASTERIP = "master-ip"
853 NV_NODELIST = "nodelist"
854 NV_NODENETTEST = "node-net-test"
855 NV_NODESETUP = "nodesetup"
859 NV_VERSION = "version"
861 NV_VMNODES = "vmnodes"
862 NV_OOB_PATHS = "oob-paths"
864 # SSL certificate check constants (in days)
865 SSL_CERT_EXPIRATION_WARN = 30
866 SSL_CERT_EXPIRATION_ERROR = 7
868 # Allocator framework constants
869 IALLOCATOR_VERSION = 2
870 IALLOCATOR_DIR_IN = "in"
871 IALLOCATOR_DIR_OUT = "out"
872 VALID_IALLOCATOR_DIRECTIONS = frozenset([
876 IALLOCATOR_MODE_ALLOC = "allocate"
877 IALLOCATOR_MODE_RELOC = "relocate"
878 IALLOCATOR_MODE_MEVAC = "multi-evacuate"
879 VALID_IALLOCATOR_MODES = frozenset([
880 IALLOCATOR_MODE_ALLOC,
881 IALLOCATOR_MODE_RELOC,
882 IALLOCATOR_MODE_MEVAC,
884 IALLOCATOR_SEARCH_PATH = _autoconf.IALLOCATOR_SEARCH_PATH
887 JOB_QUEUE_VERSION = 1
888 JOB_QUEUE_LOCK_FILE = QUEUE_DIR + "/lock"
889 JOB_QUEUE_VERSION_FILE = QUEUE_DIR + "/version"
890 JOB_QUEUE_SERIAL_FILE = QUEUE_DIR + "/serial"
891 JOB_QUEUE_ARCHIVE_DIR = QUEUE_DIR + "/archive"
892 JOB_QUEUE_DRAIN_FILE = QUEUE_DIR + "/drain"
893 JOB_QUEUE_SIZE_HARD_LIMIT = 5000
894 JOB_QUEUE_DIRS = [QUEUE_DIR, JOB_QUEUE_ARCHIVE_DIR]
895 JOB_QUEUE_DIRS_MODE = SECURE_DIR_MODE
897 JOB_ID_TEMPLATE = r"\d+"
899 # unchanged job return
900 JOB_NOTCHANGED = "nochange"
903 JOB_STATUS_QUEUED = "queued"
904 JOB_STATUS_WAITLOCK = "waiting"
905 JOB_STATUS_CANCELING = "canceling"
906 JOB_STATUS_RUNNING = "running"
907 JOB_STATUS_CANCELED = "canceled"
908 JOB_STATUS_SUCCESS = "success"
909 JOB_STATUS_ERROR = "error"
910 JOBS_FINALIZED = frozenset([
915 JOB_STATUS_ALL = frozenset([
918 JOB_STATUS_CANCELING,
924 OP_STATUS_QUEUED = "queued"
925 OP_STATUS_WAITLOCK = "waiting"
926 OP_STATUS_CANCELING = "canceling"
927 OP_STATUS_RUNNING = "running"
929 OP_STATUS_CANCELED = "canceled"
930 OP_STATUS_SUCCESS = "success"
931 OP_STATUS_ERROR = "error"
932 OPS_FINALIZED = frozenset([OP_STATUS_CANCELED,
938 OP_PRIO_HIGHEST = -20
944 OP_PRIO_SUBMIT_VALID = frozenset([
950 OP_PRIO_DEFAULT = OP_PRIO_NORMAL
952 # Execution log types
953 ELOG_MESSAGE = "message"
954 ELOG_PROGRESS = "progress"
955 ELOG_REMOTE_IMPORT = "remote-import"
956 ELOG_JQUEUE_TEST = "jqueue-test"
958 # /etc/hosts modification
959 ETC_HOSTS_ADD = "add"
960 ETC_HOSTS_REMOVE = "remove"
963 JQT_MSGPREFIX = "TESTMSG="
964 JQT_EXPANDNAMES = "expandnames"
966 JQT_LOGMSG = "logmsg"
967 JQT_STARTMSG = "startmsg"
968 JQT_ALL = frozenset([
976 QR_INSTANCE = "instance"
981 #: List of resources which can be queried using L{opcodes.OpQuery}
982 QR_OP_QUERY = frozenset([QR_INSTANCE, QR_NODE, QR_GROUP])
984 #: List of resources which can be queried using LUXI
985 QR_OP_LUXI = QR_OP_QUERY.union([
990 QFT_UNKNOWN = "unknown"
993 QFT_NUMBER = "number"
995 QFT_TIMESTAMP = "timestamp"
998 #: All query field types
999 QFT_ALL = frozenset([
1009 # Query result field status (don't change or reuse values as they're used by
1011 #: Normal field status
1015 #: No data (e.g. RPC error), can be used instead of L{RS_OFFLINE}
1017 #: Value unavailable/unsupported for item; if this field is supported
1018 #: but we cannot get the data for the moment, RS_NODATA or
1019 #: RS_OFFLINE should be used
1021 #: Resource marked offline
1024 RS_ALL = frozenset([
1032 # max dynamic devices
1037 SS_CLUSTER_NAME = "cluster_name"
1038 SS_CLUSTER_TAGS = "cluster_tags"
1039 SS_FILE_STORAGE_DIR = "file_storage_dir"
1040 SS_MASTER_CANDIDATES = "master_candidates"
1041 SS_MASTER_CANDIDATES_IPS = "master_candidates_ips"
1042 SS_MASTER_IP = "master_ip"
1043 SS_MASTER_NETDEV = "master_netdev"
1044 SS_MASTER_NODE = "master_node"
1045 SS_NODE_LIST = "node_list"
1046 SS_NODE_PRIMARY_IPS = "node_primary_ips"
1047 SS_NODE_SECONDARY_IPS = "node_secondary_ips"
1048 SS_OFFLINE_NODES = "offline_nodes"
1049 SS_ONLINE_NODES = "online_nodes"
1050 SS_PRIMARY_IP_FAMILY = "primary_ip_family"
1051 SS_INSTANCE_LIST = "instance_list"
1052 SS_RELEASE_VERSION = "release_version"
1053 SS_HYPERVISOR_LIST = "hypervisor_list"
1054 SS_MAINTAIN_NODE_HEALTH = "maintain_node_health"
1055 SS_UID_POOL = "uid_pool"
1056 SS_NODEGROUPS = "nodegroups"
1058 # cluster wide default parameters
1059 DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM
1063 HV_USE_BOOTLOADER: False,
1064 HV_BOOTLOADER_PATH: XEN_BOOTLOADER,
1065 HV_BOOTLOADER_ARGS: '',
1066 HV_KERNEL_PATH: "/boot/vmlinuz-2.6-xenU",
1068 HV_ROOT_PATH: '/dev/sda1',
1069 HV_KERNEL_ARGS: 'ro',
1070 HV_MIGRATION_PORT: 8002,
1071 HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1072 HV_BLOCKDEV_PREFIX: "sd",
1075 HV_BOOT_ORDER: "cd",
1076 HV_CDROM_IMAGE_PATH: '',
1077 HV_NIC_TYPE: HT_NIC_RTL8139,
1078 HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
1079 HV_VNC_BIND_ADDRESS: IP4_ADDRESS_ANY,
1080 HV_VNC_PASSWORD_FILE: VNC_PASSWORD_FILE,
1083 HV_KERNEL_PATH: "/usr/lib/xen/boot/hvmloader",
1084 HV_DEVICE_MODEL: "/usr/lib/xen/bin/qemu-dm",
1085 HV_MIGRATION_PORT: 8002,
1086 HV_MIGRATION_MODE: HT_MIGRATION_NONLIVE,
1087 HV_USE_LOCALTIME: False,
1088 HV_BLOCKDEV_PREFIX: "hd",
1091 HV_KERNEL_PATH: "/boot/vmlinuz-2.6-kvmU",
1093 HV_KERNEL_ARGS: 'ro',
1094 HV_ROOT_PATH: '/dev/vda1',
1096 HV_SERIAL_CONSOLE: True,
1097 HV_VNC_BIND_ADDRESS: '',
1100 HV_VNC_X509_VERIFY: False,
1101 HV_VNC_PASSWORD_FILE: '',
1102 HV_CDROM_IMAGE_PATH: '',
1103 HV_BOOT_ORDER: HT_BO_DISK,
1104 HV_NIC_TYPE: HT_NIC_PARAVIRTUAL,
1105 HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
1107 HV_MIGRATION_PORT: 8102,
1108 HV_MIGRATION_BANDWIDTH: 32, # MiB/s
1109 HV_MIGRATION_DOWNTIME: 30, # ms
1110 HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1111 HV_USE_LOCALTIME: False,
1112 HV_DISK_CACHE: HT_CACHE_DEFAULT,
1113 HV_SECURITY_MODEL: HT_SM_NONE,
1114 HV_SECURITY_DOMAIN: '',
1116 HV_VHOST_NET: False,
1117 HV_KVM_USE_CHROOT: False,
1123 HV_INIT_SCRIPT: "/ganeti-chroot",
1130 HVC_GLOBALS = frozenset([
1132 HV_MIGRATION_BANDWIDTH,
1139 BE_AUTO_BALANCE: True,
1143 ND_OOB_PROGRAM: None,
1147 NIC_MODE: NIC_MODE_BRIDGED,
1148 NIC_LINK: DEFAULT_BRIDGE,
1151 MASTER_POOL_SIZE_DEFAULT = 10
1153 CONFD_PROTOCOL_VERSION = 1
1156 CONFD_REQ_NODE_ROLE_BYNAME = 1
1157 CONFD_REQ_NODE_PIP_BY_INSTANCE_IP = 2
1158 CONFD_REQ_CLUSTER_MASTER = 3
1159 CONFD_REQ_NODE_PIP_LIST = 4
1160 CONFD_REQ_MC_PIP_LIST = 5
1161 CONFD_REQ_INSTANCES_IPS_LIST = 6
1163 # Confd request query fields. These are used to narrow down queries.
1164 # These must be strings rather than integers, because json-encoding
1165 # converts them to strings anyway, as they're used as dict-keys.
1166 CONFD_REQQ_LINK = "0"
1168 CONFD_REQQ_IPLIST = "2"
1169 CONFD_REQQ_FIELDS = "3"
1171 CONFD_REQFIELD_NAME = "0"
1172 CONFD_REQFIELD_IP = "1"
1173 CONFD_REQFIELD_MNODE_PIP = "2"
1175 CONFD_REQS = frozenset([
1177 CONFD_REQ_NODE_ROLE_BYNAME,
1178 CONFD_REQ_NODE_PIP_BY_INSTANCE_IP,
1179 CONFD_REQ_CLUSTER_MASTER,
1180 CONFD_REQ_NODE_PIP_LIST,
1181 CONFD_REQ_MC_PIP_LIST,
1182 CONFD_REQ_INSTANCES_IPS_LIST,
1185 CONFD_REPL_STATUS_OK = 0
1186 CONFD_REPL_STATUS_ERROR = 1
1187 CONFD_REPL_STATUS_NOTIMPLEMENTED = 2
1189 CONFD_REPL_STATUSES = frozenset([
1190 CONFD_REPL_STATUS_OK,
1191 CONFD_REPL_STATUS_ERROR,
1192 CONFD_REPL_STATUS_NOTIMPLEMENTED,
1195 (CONFD_NODE_ROLE_MASTER,
1196 CONFD_NODE_ROLE_CANDIDATE,
1197 CONFD_NODE_ROLE_OFFLINE,
1198 CONFD_NODE_ROLE_DRAINED,
1199 CONFD_NODE_ROLE_REGULAR,
1202 # A few common errors for confd
1203 CONFD_ERROR_UNKNOWN_ENTRY = 1
1204 CONFD_ERROR_INTERNAL = 2
1205 CONFD_ERROR_ARGUMENT = 3
1207 # Each request is "salted" by the current timestamp.
1208 # This constants decides how many seconds of skew to accept.
1209 # TODO: make this a default and allow the value to be more configurable
1210 CONFD_MAX_CLOCK_SKEW = 2 * NODE_MAX_CLOCK_SKEW
1212 # When we haven't reloaded the config for more than this amount of seconds, we
1213 # force a test to see if inotify is betraying us.
1214 CONFD_CONFIG_RELOAD_TIMEOUT = 60
1216 # If we receive more than one update in this amount of seconds, we move to
1217 # polling every RATELIMIT seconds, rather than relying on inotify, to be able
1218 # to serve more requests.
1219 CONFD_CONFIG_RELOAD_RATELIMIT = 2
1221 # Magic number prepended to all confd queries.
1222 # This allows us to distinguish different types of confd protocols and handle
1223 # them. For example by changing this we can move the whole payload to be
1224 # compressed, or move away from json.
1225 CONFD_MAGIC_FOURCC = 'plj0'
1227 # By default a confd request is sent to the minimum between this number and all
1228 # MCs. 6 was chosen because even in the case of a disastrous 50% response rate,
1229 # we should have enough answers to be able to compare more than one.
1230 CONFD_DEFAULT_REQ_COVERAGE = 6
1232 # Timeout in seconds to expire pending query request in the confd client
1233 # library. We don't actually expect any answer more than 10 seconds after we
1235 CONFD_CLIENT_EXPIRE_TIMEOUT = 10
1237 # Maximum UDP datagram size.
1238 # On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
1239 # On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
1240 # (assuming we can't use jumbo frames)
1241 # We just set this to 60K, which should be enough
1242 MAX_UDP_DATA_SIZE = 61440
1244 # User-id pool minimum/maximum acceptable user-ids.
1246 UIDPOOL_UID_MAX = 2**32-1 # Assuming 32 bit user-ids
1248 # Name or path of the pgrep command
1251 # Name of the node group that gets created at cluster init or upgrade
1252 INITIAL_NODE_GROUP_NAME = "default"
1254 # Possible values for NodeGroup.alloc_policy
1255 ALLOC_POLICY_PREFERRED = "preferred"
1256 ALLOC_POLICY_LAST_RESORT = "last_resort"
1257 ALLOC_POLICY_UNALLOCABLE = "unallocable"
1258 VALID_ALLOC_POLICIES = [
1259 ALLOC_POLICY_PREFERRED,
1260 ALLOC_POLICY_LAST_RESORT,
1261 ALLOC_POLICY_UNALLOCABLE,