4 # Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 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."""
27 from ganeti import _autoconf
28 from ganeti import _vcsversion
31 RELEASE_VERSION = _autoconf.PACKAGE_VERSION
35 OS_API_VERSIONS = frozenset([OS_API_V10, OS_API_V15, OS_API_V20])
36 VCS_VERSION = _vcsversion.VCS_VERSION
41 # Format for CONFIG_VERSION:
42 # 01 03 0123 = 01030123
44 # | | + Configuration version/revision
48 # It stored as an integer. Make sure not to write an octal number.
50 # BuildVersion and SplitVersion must be in here because we can't import other
51 # modules. The cfgupgrade tool must be able to read and write version numbers
52 # and thus requires these functions. To avoid code duplication, they're kept in
55 def BuildVersion(major, minor, revision):
56 """Calculates int version number from major, minor and revision numbers.
58 Returns: int representing version number
61 assert isinstance(major, int)
62 assert isinstance(minor, int)
63 assert isinstance(revision, int)
64 return (1000000 * major +
69 def SplitVersion(version):
70 """Splits version number stored in an int.
72 Returns: tuple; (major, minor, revision)
75 assert isinstance(version, int)
77 (major, remainder) = divmod(version, 1000000)
78 (minor, revision) = divmod(remainder, 10000)
80 return (major, minor, revision)
83 CONFIG_MAJOR = int(_autoconf.VERSION_MAJOR)
84 CONFIG_MINOR = int(_autoconf.VERSION_MINOR)
86 CONFIG_VERSION = BuildVersion(CONFIG_MAJOR, CONFIG_MINOR, CONFIG_REVISION)
88 #: RPC protocol version
89 PROTOCOL_VERSION = BuildVersion(CONFIG_MAJOR, CONFIG_MINOR, 0)
92 DAEMONS_GROUP = _autoconf.DAEMONS_GROUP
93 ADMIN_GROUP = _autoconf.ADMIN_GROUP
94 MASTERD_USER = _autoconf.MASTERD_USER
95 MASTERD_GROUP = _autoconf.MASTERD_GROUP
96 RAPI_USER = _autoconf.RAPI_USER
97 RAPI_GROUP = _autoconf.RAPI_GROUP
98 CONFD_USER = _autoconf.CONFD_USER
99 CONFD_GROUP = _autoconf.CONFD_GROUP
100 NODED_USER = _autoconf.NODED_USER
101 NODED_GROUP = _autoconf.NODED_GROUP
103 # cpu pinning separators and constants
104 CPU_PINNING_SEP = ":"
105 CPU_PINNING_ALL = "all"
106 # internal representation of "all"
107 CPU_PINNING_ALL_VAL = -1
108 # one "all" entry in a CPU list means CPU pinning is off
109 CPU_PINNING_OFF = [CPU_PINNING_ALL_VAL]
111 # A Xen-specific implementation detail - there is no way to actually say
112 # "use any cpu for pinning" in a Xen configuration file, as opposed to the
113 # command line, where you can say "xm vcpu-pin <domain> <vcpu> all".
114 # The workaround used in Xen is "0-63" (see source code function
115 # xm_vcpu_pin in <xen-source>/tools/python/xen/xm/main.py).
116 # To support future changes, the following constant is treated as a
117 # blackbox string that simply means use-any-cpu-for-pinning-under-xen.
118 CPU_PINNING_ALL_XEN = "0-63"
120 # A KVM-specific implementation detail - the following value is used
121 # to set CPU affinity to all processors (#0 through #31), per taskset
123 # FIXME: This only works for machines with up to 32 CPU cores
124 CPU_PINNING_ALL_KVM = 0xFFFFFFFF
128 WIPE_BLOCK_SIZE = 1024 ** 2
129 MAX_WIPE_CHUNK = 1024 # 1GB
130 MIN_WIPE_CHUNK_PERCENT = 10
134 DATA_DIR = _autoconf.LOCALSTATEDIR + "/lib/ganeti"
135 RUN_DIR = _autoconf.LOCALSTATEDIR + "/run"
136 RUN_GANETI_DIR = RUN_DIR + "/ganeti"
137 BDEV_CACHE_DIR = RUN_GANETI_DIR + "/bdev-cache"
138 DISK_LINKS_DIR = RUN_GANETI_DIR + "/instance-disks"
140 SOCKET_DIR = RUN_GANETI_DIR + "/socket"
141 SECURE_DIR_MODE = 0700
142 SECURE_FILE_MODE = 0600
143 CRYPTO_KEYS_DIR = RUN_GANETI_DIR + "/crypto"
144 IMPORT_EXPORT_DIR = RUN_GANETI_DIR + "/import-export"
145 ADOPTABLE_BLOCKDEV_ROOT = "/dev/disk/"
146 LOCK_DIR = _autoconf.LOCALSTATEDIR + "/lock"
147 SSCONF_LOCK_FILE = LOCK_DIR + "/ganeti-ssconf.lock"
148 # User-id pool lock directory
149 # The user-ids that are in use have a corresponding lock file in this directory
150 UIDPOOL_LOCKDIR = RUN_GANETI_DIR + "/uid-pool"
151 CLUSTER_CONF_FILE = DATA_DIR + "/config.data"
152 NODED_CERT_FILE = DATA_DIR + "/server.pem"
153 RAPI_CERT_FILE = DATA_DIR + "/rapi.pem"
154 CONFD_HMAC_KEY = DATA_DIR + "/hmac.key"
155 SPICE_CERT_FILE = DATA_DIR + "/spice.pem"
156 SPICE_CACERT_FILE = DATA_DIR + "/spice-ca.pem"
157 CLUSTER_DOMAIN_SECRET_FILE = DATA_DIR + "/cluster-domain-secret"
158 INSTANCE_STATUS_FILE = RUN_GANETI_DIR + "/instance-status"
159 SSH_KNOWN_HOSTS_FILE = DATA_DIR + "/known_hosts"
160 RAPI_USERS_FILE = DATA_DIR + "/rapi/users"
161 QUEUE_DIR = DATA_DIR + "/queue"
162 DAEMON_UTIL = _autoconf.PKGLIBDIR + "/daemon-util"
163 SETUP_SSH = _autoconf.TOOLSDIR + "/setup-ssh"
164 KVM_IFUP = _autoconf.PKGLIBDIR + "/kvm-ifup"
165 KVM_CONSOLE_WRAPPER = _autoconf.PKGLIBDIR + "/tools/kvm-console-wrapper"
166 XM_CONSOLE_WRAPPER = _autoconf.PKGLIBDIR + "/tools/xm-console-wrapper"
167 ETC_HOSTS = "/etc/hosts"
168 DEFAULT_FILE_STORAGE_DIR = _autoconf.FILE_STORAGE_DIR
169 DEFAULT_SHARED_FILE_STORAGE_DIR = _autoconf.SHARED_FILE_STORAGE_DIR
170 ENABLE_FILE_STORAGE = _autoconf.ENABLE_FILE_STORAGE
171 ENABLE_SHARED_FILE_STORAGE = _autoconf.ENABLE_SHARED_FILE_STORAGE
172 SYSCONFDIR = _autoconf.SYSCONFDIR
173 TOOLSDIR = _autoconf.TOOLSDIR
174 CONF_DIR = SYSCONFDIR + "/ganeti"
175 USER_SCRIPTS_DIR = CONF_DIR + "/scripts"
176 ENABLE_CONFD = _autoconf.ENABLE_CONFD
177 HS_CONFD = _autoconf.HS_CONFD
178 ENABLE_SPLIT_QUERY = _autoconf.ENABLE_SPLIT_QUERY
180 #: Lock file for watcher, locked in shared mode by watcher; lock in exclusive
181 # mode to block watcher (see L{cli._RunWhileClusterStoppedHelper.Call}
182 WATCHER_LOCK_FILE = LOCK_DIR + "/ganeti-watcher.lock"
184 #: Status file for per-group watcher, locked in exclusive mode by watcher
185 WATCHER_GROUP_STATE_FILE = DATA_DIR + "/watcher.%s.data"
187 #: File for per-group instance status, merged into L{INSTANCE_STATUS_FILE} by
188 #: per-group processes
189 WATCHER_GROUP_INSTANCE_STATUS_FILE = DATA_DIR + "/watcher.%s.instance-status"
191 #: File containing Unix timestamp until which watcher should be paused
192 WATCHER_PAUSEFILE = DATA_DIR + "/watcher.pause"
194 # Master IP address setup scripts paths (default and user-provided)
195 DEFAULT_MASTER_SETUP_SCRIPT = TOOLSDIR + "/master-ip-setup"
196 EXTERNAL_MASTER_SETUP_SCRIPT = USER_SCRIPTS_DIR + "/master-ip-setup"
198 ALL_CERT_FILES = frozenset([
205 #: LUXI socket used for job execution
206 MASTER_SOCKET = SOCKET_DIR + "/ganeti-master"
207 #: LUXI socket used for queries only
208 QUERY_SOCKET = SOCKET_DIR + "/ganeti-query"
210 NODED = "ganeti-noded"
211 CONFD = "ganeti-confd"
213 MASTERD = "ganeti-masterd"
214 # used in the ganeti-nbma project
218 # daemon-name: ("proto", "default-port")
219 NODED: ("tcp", 1811),
220 CONFD: ("udp", 1814),
223 # used in the ganeti-nbma project
226 DEFAULT_NODED_PORT = DAEMONS_PORTS[NODED][1]
227 DEFAULT_CONFD_PORT = DAEMONS_PORTS[CONFD][1]
228 DEFAULT_RAPI_PORT = DAEMONS_PORTS[RAPI][1]
229 # used in the ganeti-nbma project
230 DEFAULT_NLD_PORT = DAEMONS_PORTS[NLD][1]
232 FIRST_DRBD_PORT = 11000
233 LAST_DRBD_PORT = 14999
235 LOG_DIR = _autoconf.LOCALSTATEDIR + "/log/ganeti/"
237 # "daemon-name": "logfile"
238 NODED: LOG_DIR + "node-daemon.log",
239 CONFD: LOG_DIR + "conf-daemon.log",
240 RAPI: LOG_DIR + "rapi-daemon.log",
241 MASTERD: LOG_DIR + "master-daemon.log",
242 # used in the ganeti-nbma project
243 NLD: LOG_DIR + "nl-daemon.log",
246 LOG_OS_DIR = LOG_DIR + "os"
247 LOG_WATCHER = LOG_DIR + "watcher.log"
248 LOG_COMMANDS = LOG_DIR + "commands.log"
249 LOG_BURNIN = LOG_DIR + "burnin.log"
250 LOG_SETUP_SSH = LOG_DIR + "setup-ssh.log"
252 DEV_CONSOLE = "/dev/console"
254 PROC_MOUNTS = "/proc/mounts"
256 # Local UniX Interface related constants
258 LUXI_VERSION = CONFIG_VERSION
260 # one of "no", "yes", "only"
261 SYSLOG_USAGE = _autoconf.SYSLOG_USAGE
265 SYSLOG_SOCKET = "/dev/log"
267 OS_SEARCH_PATH = _autoconf.OS_SEARCH_PATH
268 EXPORT_DIR = _autoconf.EXPORT_DIR
270 EXPORT_CONF_FILE = "config.ini"
272 XEN_BOOTLOADER = _autoconf.XEN_BOOTLOADER
273 XEN_KERNEL = _autoconf.XEN_KERNEL
274 XEN_INITRD = _autoconf.XEN_INITRD
277 # FIXME: This will be made configurable using hvparams in Ganeti 2.7
278 XEN_CMD = _autoconf.XEN_CMD
280 KVM_PATH = _autoconf.KVM_PATH
281 KVM_KERNEL = _autoconf.KVM_KERNEL
282 SOCAT_PATH = _autoconf.SOCAT_PATH
283 SOCAT_USE_ESCAPE = _autoconf.SOCAT_USE_ESCAPE
284 SOCAT_USE_COMPRESS = _autoconf.SOCAT_USE_COMPRESS
285 SOCAT_ESCAPE_CODE = "0x1d"
287 #: Console as SSH command
290 #: Console as VNC server
293 #: Console as SPICE server
296 #: Display a message for console access
300 CONS_ALL = frozenset([CONS_SSH, CONS_VNC, CONS_SPICE, CONS_MESSAGE])
302 # For RSA keys more bits are better, but they also make operations more
303 # expensive. NIST SP 800-131 recommends a minimum of 2048 bits from the year
307 # Ciphers allowed for SSL connections. For the format, see ciphers(1). A better
308 # way to disable ciphers would be to use the exclamation mark (!), but socat
309 # versions below 1.5 can't parse exclamation marks in options properly. When
310 # modifying the ciphers, ensure not to accidentially add something after it's
311 # been removed. Use the "openssl" utility to check the allowed ciphers, e.g.
312 # "openssl ciphers -v HIGH:-DES".
313 OPENSSL_CIPHERS = "HIGH:-DES:-3DES:-EXPORT:-ADH"
315 # Digest used to sign certificates ("openssl x509" uses SHA1 by default)
316 X509_CERT_SIGN_DIGEST = "SHA1"
318 # Default validity of certificates in days
319 X509_CERT_DEFAULT_VALIDITY = 365 * 5
321 # commonName (CN) used in certificates
322 X509_CERT_CN = "ganeti.example.com"
324 X509_CERT_SIGNATURE_HEADER = "X-Ganeti-Signature"
326 IMPORT_EXPORT_DAEMON = _autoconf.PKGLIBDIR + "/import-export"
328 # Import/export daemon mode
329 IEM_IMPORT = "import"
330 IEM_EXPORT = "export"
332 # Import/export transport compression
335 IEC_ALL = frozenset([
340 IE_CUSTOM_SIZE = "fd"
342 IE_MAGIC_RE = re.compile(r"^[-_.a-zA-Z0-9]{5,100}$")
345 # Direct file I/O, equivalent to a shell's I/O redirection using '<' or '>'
347 # Raw block device I/O using "dd"
348 IEIO_RAW_DISK = "raw"
349 # OS definition import/export script
350 IEIO_SCRIPT = "script"
352 VALUE_DEFAULT = "default"
354 VALUE_GENERATE = "generate"
357 VALUE_FALSE = "false"
359 # External script validation mask
360 EXT_PLUGIN_MASK = re.compile("^[a-zA-Z0-9_-]+$")
362 # hooks-related constants
363 HOOKS_BASE_DIR = CONF_DIR + "/hooks"
364 HOOKS_PHASE_PRE = "pre"
365 HOOKS_PHASE_POST = "post"
366 HOOKS_NAME_CFGUPDATE = "config-update"
367 HOOKS_NAME_WATCHER = "watcher"
369 HOOKS_PATH = "/sbin:/bin:/usr/sbin:/usr/bin"
371 # hooks subject type (what object type does the LU deal with)
372 HTYPE_CLUSTER = "CLUSTER"
374 HTYPE_GROUP = "GROUP"
375 HTYPE_INSTANCE = "INSTANCE"
387 # first two are valid in LU context only, not passed to backend
390 # and the rest are valid in backend
395 SF_ALLOCATABLE = "allocatable"
398 SO_FIX_CONSISTENCY = "fix-consistency"
400 # Available fields per storage type
401 VALID_STORAGE_FIELDS = frozenset([
410 VALID_STORAGE_TYPES = frozenset([ST_FILE, ST_LVM_PV, ST_LVM_VG])
412 MODIFIABLE_STORAGE_FIELDS = {
413 ST_LVM_PV: frozenset([SF_ALLOCATABLE]),
416 VALID_STORAGE_OPERATIONS = {
417 ST_LVM_VG: frozenset([SO_FIX_CONSISTENCY]),
421 # Note: Code depends on LDS_OKAY < LDS_UNKNOWN < LDS_FAULTY
424 LDS_FAULTY) = range(1, 4)
426 # disk template types
427 DT_DISKLESS = "diskless"
431 DT_SHARED_FILE = "sharedfile"
432 DT_BLOCK = "blockdev"
435 # the set of network-mirrored disk templates
436 DTS_INT_MIRROR = frozenset([DT_DRBD8])
438 # the set of externally-mirrored disk templates (e.g. SAN, NAS)
439 DTS_EXT_MIRROR = frozenset([DT_SHARED_FILE, DT_BLOCK, DT_RBD])
441 # the set of non-lvm-based disk templates
442 DTS_NOT_LVM = frozenset([DT_DISKLESS, DT_FILE, DT_SHARED_FILE,
445 # the set of disk templates which can be grown
446 DTS_GROWABLE = frozenset([DT_PLAIN, DT_DRBD8, DT_FILE, DT_SHARED_FILE, DT_RBD])
448 # the set of disk templates that allow adoption
449 DTS_MAY_ADOPT = frozenset([DT_PLAIN, DT_BLOCK])
451 # the set of disk templates that *must* use adoption
452 DTS_MUST_ADOPT = frozenset([DT_BLOCK])
454 # the set of disk templates that allow migrations
455 DTS_MIRRORED = frozenset.union(DTS_INT_MIRROR, DTS_EXT_MIRROR)
457 # the set of file based disk templates
458 DTS_FILEBASED = frozenset([DT_FILE, DT_SHARED_FILE])
464 LD_BLOCKDEV = "blockdev"
466 LOGICAL_DISK_TYPES = frozenset([
474 LDS_BLOCK = frozenset([LD_LV, LD_DRBD8, LD_BLOCKDEV, LD_RBD])
477 DRBD_HMAC_ALG = "md5"
478 DRBD_NET_PROTOCOL = "C"
480 #: Size of DRBD meta block device
485 DRBD_B_DISK_BARRIERS = "b"
486 DRBD_B_DISK_DRAIN = "d"
487 DRBD_B_DISK_FLUSH = "f"
489 # Valid barrier combinations: "n" or any non-null subset of "bfd"
490 DRBD_VALID_BARRIER_OPT = frozenset([
491 frozenset([DRBD_B_NONE]),
492 frozenset([DRBD_B_DISK_BARRIERS]),
493 frozenset([DRBD_B_DISK_DRAIN]),
494 frozenset([DRBD_B_DISK_FLUSH]),
495 frozenset([DRBD_B_DISK_DRAIN, DRBD_B_DISK_FLUSH]),
496 frozenset([DRBD_B_DISK_DRAIN, DRBD_B_DISK_FLUSH]),
497 frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_DRAIN]),
498 frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_FLUSH]),
499 frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_FLUSH, DRBD_B_DISK_DRAIN]),
505 # file backend driver
509 # the set of drbd-like disk types
510 LDS_DRBD = frozenset([LD_DRBD8])
515 DISK_ACCESS_SET = frozenset([DISK_RDONLY, DISK_RDWR])
517 # disk replacement mode
518 REPLACE_DISK_PRI = "replace_on_primary" # replace disks on primary
519 REPLACE_DISK_SEC = "replace_on_secondary" # replace disks on secondary
520 REPLACE_DISK_CHG = "replace_new_secondary" # change secondary node
521 REPLACE_DISK_AUTO = "replace_auto"
522 REPLACE_MODES = frozenset([
529 # Instance export mode
530 EXPORT_MODE_LOCAL = "local"
531 EXPORT_MODE_REMOTE = "remote"
532 EXPORT_MODES = frozenset([
537 # instance creation modes
538 INSTANCE_CREATE = "create"
539 INSTANCE_IMPORT = "import"
540 INSTANCE_REMOTE_IMPORT = "remote-import"
541 INSTANCE_CREATE_MODES = frozenset([
544 INSTANCE_REMOTE_IMPORT,
547 # Remote import/export handshake message and version
549 RIE_HANDSHAKE = "Hi, I'm Ganeti"
551 # Remote import/export certificate validity in seconds
552 RIE_CERT_VALIDITY = 24 * 60 * 60
554 # Overall timeout for establishing connection
555 RIE_CONNECT_TIMEOUT = 180
557 # Export only: how long to wait per connection attempt (seconds)
558 RIE_CONNECT_ATTEMPT_TIMEOUT = 20
560 # Export only: number of attempts to connect
561 RIE_CONNECT_RETRIES = 10
563 #: Give child process up to 5 seconds to exit after sending a signal
564 CHILD_LINGER_TIMEOUT = 5.0
566 DISK_TEMPLATES = frozenset([
576 FILE_DRIVER = frozenset([FD_LOOP, FD_BLKTAP])
578 # import/export config options
579 INISECT_EXP = "export"
580 INISECT_INS = "instance"
581 INISECT_HYP = "hypervisor"
582 INISECT_BEP = "backend"
585 # dynamic device modification
587 DDM_MODIFY = "modify"
588 DDM_REMOVE = "remove"
589 DDMS_VALUES = frozenset([DDM_ADD, DDM_REMOVE])
590 DDMS_VALUES_WITH_MODIFY = (DDMS_VALUES | frozenset([
593 # TODO: DDM_SWAP, DDM_MOVE?
600 EXIT_NODESETUP_ERROR = 12
601 EXIT_CONFIRMATION = 13 # need user confirmation
603 #: Exit code for query operations with unknown fields
604 EXIT_UNKNOWN_FIELD = 14
607 TAG_CLUSTER = "cluster"
608 TAG_NODEGROUP = "nodegroup"
610 TAG_INSTANCE = "instance"
611 VALID_TAG_TYPES = frozenset([
618 MAX_TAGS_PER_OBJ = 4096
621 DEFAULT_BRIDGE = "xen-br0"
622 CLASSIC_DRBD_SYNC_SPEED = 60 * 1024 # 60 MiB, expressed in KiB
623 IP4_ADDRESS_LOCALHOST = "127.0.0.1"
624 IP4_ADDRESS_ANY = "0.0.0.0"
625 IP6_ADDRESS_LOCALHOST = "::1"
626 IP6_ADDRESS_ANY = "::"
629 VALID_IP_VERSIONS = frozenset([IP4_VERSION, IP6_VERSION])
630 # for export to htools
631 IP4_FAMILY = socket.AF_INET
632 IP6_FAMILY = socket.AF_INET6
634 TCP_PING_TIMEOUT = 10
635 GANETI_RUNAS = "root"
637 DEFAULT_DRBD_HELPER = "/bin/true"
639 DEFAULT_MAC_PREFIX = "aa:00:00"
640 # default maximum instance wait time, in seconds.
641 DEFAULT_SHUTDOWN_TIMEOUT = 120
642 NODE_MAX_CLOCK_SKEW = 150
643 # Time for an intra-cluster disk transfer to wait for a connection
644 DISK_TRANSFER_CONNECT_TIMEOUT = 60
645 # Disk index separator
646 DISK_SEPARATOR = _autoconf.DISK_SEPARATOR
647 IP_COMMAND_PATH = _autoconf.IP_PATH
649 #: Key for job IDs in opcode result
655 RUNPARTS_ERR) = range(3)
657 RUNPARTS_STATUS = frozenset([RUNPARTS_SKIP, RUNPARTS_RUN, RUNPARTS_ERR])
661 RPC_ENCODING_ZLIB_BASE64) = range(2)
663 # Various time constants for the timeout table
664 RPC_TMO_URGENT = 60 # one minute
665 RPC_TMO_FAST = 5 * 60 # five minutes
666 RPC_TMO_NORMAL = 15 * 60 # 15 minutes
667 RPC_TMO_SLOW = 3600 # one hour
668 RPC_TMO_4HRS = 4 * 3600
671 # Timeout for connecting to nodes (seconds)
672 RPC_CONNECT_TIMEOUT = 5
674 # os related constants
675 OS_SCRIPT_CREATE = "create"
676 OS_SCRIPT_IMPORT = "import"
677 OS_SCRIPT_EXPORT = "export"
678 OS_SCRIPT_RENAME = "rename"
679 OS_SCRIPT_VERIFY = "verify"
680 OS_SCRIPTS = frozenset([
688 OS_API_FILE = "ganeti_api_version"
689 OS_VARIANTS_FILE = "variants.list"
690 OS_PARAMETERS_FILE = "parameters.list"
692 OS_VALIDATE_PARAMETERS = "parameters"
693 OS_VALIDATE_CALLS = frozenset([OS_VALIDATE_PARAMETERS])
696 SSH_CONFIG_DIR = _autoconf.SSH_CONFIG_DIR
697 SSH_HOST_DSA_PRIV = SSH_CONFIG_DIR + "/ssh_host_dsa_key"
698 SSH_HOST_DSA_PUB = SSH_HOST_DSA_PRIV + ".pub"
699 SSH_HOST_RSA_PRIV = SSH_CONFIG_DIR + "/ssh_host_rsa_key"
700 SSH_HOST_RSA_PUB = SSH_HOST_RSA_PRIV + ".pub"
705 INSTANCE_REBOOT_SOFT = "soft"
706 INSTANCE_REBOOT_HARD = "hard"
707 INSTANCE_REBOOT_FULL = "full"
709 REBOOT_TYPES = frozenset([
710 INSTANCE_REBOOT_SOFT,
711 INSTANCE_REBOOT_HARD,
715 # instance reboot behaviors
716 INSTANCE_REBOOT_ALLOWED = "reboot"
717 INSTANCE_REBOOT_EXIT = "exit"
719 REBOOT_BEHAVIORS = frozenset([
720 INSTANCE_REBOOT_ALLOWED,
724 VTYPE_STRING = "string"
725 VTYPE_MAYBE_STRING = "maybe-string"
727 VTYPE_SIZE = "size" # size, in MiBs
729 ENFORCEABLE_TYPES = frozenset([
737 # Constant representing that the user does not specify any IP version
738 IFACE_NO_IP_VERSION_SPECIFIED = 0
740 # HV parameter names (global namespace)
741 HV_BOOT_ORDER = "boot_order"
742 HV_CDROM_IMAGE_PATH = "cdrom_image_path"
743 HV_KVM_CDROM2_IMAGE_PATH = "cdrom2_image_path"
744 HV_KVM_FLOPPY_IMAGE_PATH = "floppy_image_path"
745 HV_NIC_TYPE = "nic_type"
746 HV_DISK_TYPE = "disk_type"
747 HV_KVM_CDROM_DISK_TYPE = "cdrom_disk_type"
748 HV_VNC_BIND_ADDRESS = "vnc_bind_address"
749 HV_VNC_PASSWORD_FILE = "vnc_password_file"
750 HV_VNC_TLS = "vnc_tls"
751 HV_VNC_X509 = "vnc_x509_path"
752 HV_VNC_X509_VERIFY = "vnc_x509_verify"
753 HV_KVM_SPICE_BIND = "spice_bind"
754 HV_KVM_SPICE_IP_VERSION = "spice_ip_version"
755 HV_KVM_SPICE_PASSWORD_FILE = "spice_password_file"
756 HV_KVM_SPICE_LOSSLESS_IMG_COMPR = "spice_image_compression"
757 HV_KVM_SPICE_JPEG_IMG_COMPR = "spice_jpeg_wan_compression"
758 HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR = "spice_zlib_glz_wan_compression"
759 HV_KVM_SPICE_STREAMING_VIDEO_DETECTION = "spice_streaming_video"
760 HV_KVM_SPICE_AUDIO_COMPR = "spice_playback_compression"
761 HV_KVM_SPICE_USE_TLS = "spice_use_tls"
762 HV_KVM_SPICE_TLS_CIPHERS = "spice_tls_ciphers"
763 HV_KVM_SPICE_USE_VDAGENT = "spice_use_vdagent"
766 HV_USE_BOOTLOADER = "use_bootloader"
767 HV_BOOTLOADER_ARGS = "bootloader_args"
768 HV_BOOTLOADER_PATH = "bootloader_path"
769 HV_KERNEL_ARGS = "kernel_args"
770 HV_KERNEL_PATH = "kernel_path"
771 HV_INITRD_PATH = "initrd_path"
772 HV_ROOT_PATH = "root_path"
773 HV_SERIAL_CONSOLE = "serial_console"
774 HV_USB_MOUSE = "usb_mouse"
776 HV_DEVICE_MODEL = "device_model"
777 HV_INIT_SCRIPT = "init_script"
778 HV_MIGRATION_PORT = "migration_port"
779 HV_MIGRATION_BANDWIDTH = "migration_bandwidth"
780 HV_MIGRATION_DOWNTIME = "migration_downtime"
781 HV_MIGRATION_MODE = "migration_mode"
782 HV_USE_LOCALTIME = "use_localtime"
783 HV_DISK_CACHE = "disk_cache"
784 HV_SECURITY_MODEL = "security_model"
785 HV_SECURITY_DOMAIN = "security_domain"
786 HV_KVM_FLAG = "kvm_flag"
787 HV_VHOST_NET = "vhost_net"
788 HV_KVM_USE_CHROOT = "use_chroot"
789 HV_CPU_MASK = "cpu_mask"
790 HV_MEM_PATH = "mem_path"
791 HV_PASSTHROUGH = "pci_pass"
792 HV_BLOCKDEV_PREFIX = "blockdev_prefix"
793 HV_REBOOT_BEHAVIOR = "reboot_behavior"
794 HV_CPU_TYPE = "cpu_type"
796 HVS_PARAMETER_TYPES = {
797 HV_BOOT_ORDER: VTYPE_STRING,
798 HV_KVM_FLOPPY_IMAGE_PATH: VTYPE_STRING,
799 HV_CDROM_IMAGE_PATH: VTYPE_STRING,
800 HV_KVM_CDROM2_IMAGE_PATH: VTYPE_STRING,
801 HV_NIC_TYPE: VTYPE_STRING,
802 HV_DISK_TYPE: VTYPE_STRING,
803 HV_KVM_CDROM_DISK_TYPE: VTYPE_STRING,
804 HV_VNC_PASSWORD_FILE: VTYPE_STRING,
805 HV_VNC_BIND_ADDRESS: VTYPE_STRING,
806 HV_VNC_TLS: VTYPE_BOOL,
807 HV_VNC_X509: VTYPE_STRING,
808 HV_VNC_X509_VERIFY: VTYPE_BOOL,
809 HV_KVM_SPICE_BIND: VTYPE_STRING,
810 HV_KVM_SPICE_IP_VERSION: VTYPE_INT,
811 HV_KVM_SPICE_PASSWORD_FILE: VTYPE_STRING,
812 HV_KVM_SPICE_LOSSLESS_IMG_COMPR: VTYPE_STRING,
813 HV_KVM_SPICE_JPEG_IMG_COMPR: VTYPE_STRING,
814 HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR: VTYPE_STRING,
815 HV_KVM_SPICE_STREAMING_VIDEO_DETECTION: VTYPE_STRING,
816 HV_KVM_SPICE_AUDIO_COMPR: VTYPE_BOOL,
817 HV_KVM_SPICE_USE_TLS: VTYPE_BOOL,
818 HV_KVM_SPICE_TLS_CIPHERS: VTYPE_STRING,
819 HV_KVM_SPICE_USE_VDAGENT: VTYPE_BOOL,
822 HV_USE_BOOTLOADER: VTYPE_BOOL,
823 HV_BOOTLOADER_PATH: VTYPE_STRING,
824 HV_BOOTLOADER_ARGS: VTYPE_STRING,
825 HV_KERNEL_PATH: VTYPE_STRING,
826 HV_KERNEL_ARGS: VTYPE_STRING,
827 HV_INITRD_PATH: VTYPE_STRING,
828 HV_ROOT_PATH: VTYPE_MAYBE_STRING,
829 HV_SERIAL_CONSOLE: VTYPE_BOOL,
830 HV_USB_MOUSE: VTYPE_STRING,
831 HV_KEYMAP: VTYPE_STRING,
832 HV_DEVICE_MODEL: VTYPE_STRING,
833 HV_INIT_SCRIPT: VTYPE_STRING,
834 HV_MIGRATION_PORT: VTYPE_INT,
835 HV_MIGRATION_BANDWIDTH: VTYPE_INT,
836 HV_MIGRATION_DOWNTIME: VTYPE_INT,
837 HV_MIGRATION_MODE: VTYPE_STRING,
838 HV_USE_LOCALTIME: VTYPE_BOOL,
839 HV_DISK_CACHE: VTYPE_STRING,
840 HV_SECURITY_MODEL: VTYPE_STRING,
841 HV_SECURITY_DOMAIN: VTYPE_STRING,
842 HV_KVM_FLAG: VTYPE_STRING,
843 HV_VHOST_NET: VTYPE_BOOL,
844 HV_KVM_USE_CHROOT: VTYPE_BOOL,
845 HV_CPU_MASK: VTYPE_STRING,
846 HV_MEM_PATH: VTYPE_STRING,
847 HV_PASSTHROUGH: VTYPE_STRING,
848 HV_BLOCKDEV_PREFIX: VTYPE_STRING,
849 HV_REBOOT_BEHAVIOR: VTYPE_STRING,
850 HV_CPU_TYPE: VTYPE_STRING,
853 HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
855 HVS_PARAMETER_TITLES = {
857 HV_BOOT_ORDER: "Boot_order",
858 HV_CDROM_IMAGE_PATH: "CDROM_image_path",
859 HV_DISK_TYPE: "Disk_type",
860 HV_INITRD_PATH: "Initrd_path",
861 HV_KERNEL_PATH: "Kernel_path",
862 HV_NIC_TYPE: "NIC_type",
864 HV_VNC_BIND_ADDRESS: "VNC_bind_address",
865 HV_PASSTHROUGH: "pci_pass",
866 HV_CPU_TYPE: "cpu_type",
870 HV_MIGRATION_COMPLETED = "completed"
871 HV_MIGRATION_ACTIVE = "active"
872 HV_MIGRATION_FAILED = "failed"
873 HV_MIGRATION_CANCELLED = "cancelled"
875 HV_MIGRATION_VALID_STATUSES = frozenset([
876 HV_MIGRATION_COMPLETED,
879 HV_MIGRATION_CANCELLED,
882 HV_MIGRATION_FAILED_STATUSES = frozenset([
884 HV_MIGRATION_CANCELLED,
887 # KVM-specific statuses
888 HV_KVM_MIGRATION_VALID_STATUSES = HV_MIGRATION_VALID_STATUSES
891 HV_NODEINFO_KEY_VERSION = "hv_version"
894 HVST_MEMORY_TOTAL = "mem_total"
895 HVST_MEMORY_NODE = "mem_node"
896 HVST_MEMORY_HV = "mem_hv"
897 HVST_CPU_TOTAL = "cpu_total"
898 HVST_CPU_NODE = "cpu_node"
901 HVST_MEMORY_TOTAL: 0,
908 HVSTS_PARAMETER_TYPES = {
909 HVST_MEMORY_TOTAL: VTYPE_INT,
910 HVST_MEMORY_NODE: VTYPE_INT,
911 HVST_MEMORY_HV: VTYPE_INT,
912 HVST_CPU_TOTAL: VTYPE_INT,
913 HVST_CPU_NODE: VTYPE_INT,
916 HVSTS_PARAMETERS = frozenset(HVSTS_PARAMETER_TYPES.keys())
919 DS_DISK_TOTAL = "disk_total"
920 DS_DISK_RESERVED = "disk_reserved"
921 DS_DISK_OVERHEAD = "disk_overhead"
929 DSS_PARAMETER_TYPES = {
930 DS_DISK_TOTAL: VTYPE_INT,
931 DS_DISK_RESERVED: VTYPE_INT,
932 DS_DISK_OVERHEAD: VTYPE_INT,
935 DSS_PARAMETERS = frozenset(DSS_PARAMETER_TYPES.keys())
936 DS_VALID_TYPES = frozenset([LD_LV])
938 # Backend parameter names
939 BE_MEMORY = "memory" # deprecated and replaced by max and min mem
943 BE_AUTO_BALANCE = "auto_balance"
944 BE_ALWAYS_FAILOVER = "always_failover"
945 BE_SPINDLE_USE = "spindle_use"
947 BES_PARAMETER_TYPES = {
948 BE_MAXMEM: VTYPE_SIZE,
949 BE_MINMEM: VTYPE_SIZE,
951 BE_AUTO_BALANCE: VTYPE_BOOL,
952 BE_ALWAYS_FAILOVER: VTYPE_BOOL,
953 BE_SPINDLE_USE: VTYPE_INT,
956 BES_PARAMETER_TITLES = {
957 BE_AUTO_BALANCE: "Auto_balance",
958 BE_MAXMEM: "ConfigMaxMem",
959 BE_MINMEM: "ConfigMinMem",
960 BE_VCPUS: "ConfigVCPUs",
963 BES_PARAMETER_COMPAT = {
964 BE_MEMORY: VTYPE_SIZE,
966 BES_PARAMETER_COMPAT.update(BES_PARAMETER_TYPES)
968 BES_PARAMETERS = frozenset(BES_PARAMETER_TYPES.keys())
971 ISPEC_MEM_SIZE = "memory-size"
972 ISPEC_CPU_COUNT = "cpu-count"
973 ISPEC_DISK_COUNT = "disk-count"
974 ISPEC_DISK_SIZE = "disk-size"
975 ISPEC_NIC_COUNT = "nic-count"
976 ISPEC_SPINDLE_USE = "spindle-use"
978 ISPECS_PARAMETER_TYPES = {
979 ISPEC_MEM_SIZE: VTYPE_INT,
980 ISPEC_CPU_COUNT: VTYPE_INT,
981 ISPEC_DISK_COUNT: VTYPE_INT,
982 ISPEC_DISK_SIZE: VTYPE_INT,
983 ISPEC_NIC_COUNT: VTYPE_INT,
984 ISPEC_SPINDLE_USE: VTYPE_INT,
987 ISPECS_PARAMETERS = frozenset(ISPECS_PARAMETER_TYPES.keys())
992 IPOLICY_DTS = "disk-templates"
993 IPOLICY_VCPU_RATIO = "vcpu-ratio"
994 IPOLICY_SPINDLE_RATIO = "spindle-ratio"
996 IPOLICY_ISPECS = frozenset([
1002 IPOLICY_PARAMETERS = frozenset([
1004 IPOLICY_SPINDLE_RATIO,
1007 IPOLICY_ALL_KEYS = (IPOLICY_ISPECS |
1008 IPOLICY_PARAMETERS |
1009 frozenset([IPOLICY_DTS]))
1011 # Node parameter names
1012 ND_OOB_PROGRAM = "oob_program"
1013 ND_SPINDLE_COUNT = "spindle_count"
1015 NDS_PARAMETER_TYPES = {
1016 ND_OOB_PROGRAM: VTYPE_STRING,
1017 ND_SPINDLE_COUNT: VTYPE_INT,
1020 NDS_PARAMETERS = frozenset(NDS_PARAMETER_TYPES.keys())
1022 NDS_PARAMETER_TITLES = {
1023 ND_OOB_PROGRAM: "OutOfBandProgram",
1024 ND_SPINDLE_COUNT: "SpindleCount",
1027 # Logical Disks parameters
1028 LDP_RESYNC_RATE = "resync-rate"
1029 LDP_STRIPES = "stripes"
1030 LDP_BARRIERS = "disabled-barriers"
1031 LDP_NO_META_FLUSH = "disable-meta-flush"
1032 LDP_DEFAULT_METAVG = "default-metavg"
1033 LDP_DISK_CUSTOM = "disk-custom"
1034 LDP_NET_CUSTOM = "net-custom"
1035 LDP_DYNAMIC_RESYNC = "dynamic-resync"
1036 LDP_PLAN_AHEAD = "c-plan-ahead"
1037 LDP_FILL_TARGET = "c-fill-target"
1038 LDP_DELAY_TARGET = "c-delay-target"
1039 LDP_MAX_RATE = "c-max-rate"
1040 LDP_MIN_RATE = "c-min-rate"
1043 LDP_RESYNC_RATE: VTYPE_INT,
1044 LDP_STRIPES: VTYPE_INT,
1045 LDP_BARRIERS: VTYPE_STRING,
1046 LDP_NO_META_FLUSH: VTYPE_BOOL,
1047 LDP_DEFAULT_METAVG: VTYPE_STRING,
1048 LDP_DISK_CUSTOM: VTYPE_STRING,
1049 LDP_NET_CUSTOM: VTYPE_STRING,
1050 LDP_DYNAMIC_RESYNC: VTYPE_BOOL,
1051 LDP_PLAN_AHEAD: VTYPE_INT,
1052 LDP_FILL_TARGET: VTYPE_INT,
1053 LDP_DELAY_TARGET: VTYPE_INT,
1054 LDP_MAX_RATE: VTYPE_INT,
1055 LDP_MIN_RATE: VTYPE_INT,
1056 LDP_POOL: VTYPE_STRING,
1058 DISK_LD_PARAMETERS = frozenset(DISK_LD_TYPES.keys())
1060 # Disk template parameters (can be set/changed by the user via gnt-cluster and
1062 DRBD_RESYNC_RATE = "resync-rate"
1063 DRBD_DATA_STRIPES = "data-stripes"
1064 DRBD_META_STRIPES = "meta-stripes"
1065 DRBD_DISK_BARRIERS = "disk-barriers"
1066 DRBD_META_BARRIERS = "meta-barriers"
1067 DRBD_DEFAULT_METAVG = "metavg"
1068 DRBD_DISK_CUSTOM = "disk-custom"
1069 DRBD_NET_CUSTOM = "net-custom"
1070 DRBD_DYNAMIC_RESYNC = "dynamic-resync"
1071 DRBD_PLAN_AHEAD = "c-plan-ahead"
1072 DRBD_FILL_TARGET = "c-fill-target"
1073 DRBD_DELAY_TARGET = "c-delay-target"
1074 DRBD_MAX_RATE = "c-max-rate"
1075 DRBD_MIN_RATE = "c-min-rate"
1076 LV_STRIPES = "stripes"
1079 DRBD_RESYNC_RATE: VTYPE_INT,
1080 DRBD_DATA_STRIPES: VTYPE_INT,
1081 DRBD_META_STRIPES: VTYPE_INT,
1082 DRBD_DISK_BARRIERS: VTYPE_STRING,
1083 DRBD_META_BARRIERS: VTYPE_BOOL,
1084 DRBD_DEFAULT_METAVG: VTYPE_STRING,
1085 DRBD_DISK_CUSTOM: VTYPE_STRING,
1086 DRBD_NET_CUSTOM: VTYPE_STRING,
1087 DRBD_DYNAMIC_RESYNC: VTYPE_BOOL,
1088 DRBD_PLAN_AHEAD: VTYPE_INT,
1089 DRBD_FILL_TARGET: VTYPE_INT,
1090 DRBD_DELAY_TARGET: VTYPE_INT,
1091 DRBD_MAX_RATE: VTYPE_INT,
1092 DRBD_MIN_RATE: VTYPE_INT,
1093 LV_STRIPES: VTYPE_INT,
1094 RBD_POOL: VTYPE_STRING,
1097 DISK_DT_PARAMETERS = frozenset(DISK_DT_TYPES.keys())
1099 # OOB supported commands
1100 OOB_POWER_ON = "power-on"
1101 OOB_POWER_OFF = "power-off"
1102 OOB_POWER_CYCLE = "power-cycle"
1103 OOB_POWER_STATUS = "power-status"
1104 OOB_HEALTH = "health"
1106 OOB_COMMANDS = frozenset([
1114 OOB_POWER_STATUS_POWERED = "powered"
1116 OOB_TIMEOUT = 60 # 60 seconds
1117 OOB_POWER_DELAY = 2.0 # 2 seconds
1119 OOB_STATUS_OK = "OK"
1120 OOB_STATUS_WARNING = "WARNING"
1121 OOB_STATUS_CRITICAL = "CRITICAL"
1122 OOB_STATUS_UNKNOWN = "UNKNOWN"
1124 OOB_STATUSES = frozenset([
1127 OOB_STATUS_CRITICAL,
1131 # Instance Parameters Profile
1132 PP_DEFAULT = "default"
1134 # NIC_* constants are used inside the ganeti config
1138 NIC_MODE_BRIDGED = "bridged"
1139 NIC_MODE_ROUTED = "routed"
1141 NIC_VALID_MODES = frozenset([NIC_MODE_BRIDGED, NIC_MODE_ROUTED])
1143 NICS_PARAMETER_TYPES = {
1144 NIC_MODE: VTYPE_STRING,
1145 NIC_LINK: VTYPE_STRING,
1148 NICS_PARAMETERS = frozenset(NICS_PARAMETER_TYPES.keys())
1150 # IDISK_* constants are used in opcodes, to create/change disks
1153 IDISK_ADOPT = "adopt"
1155 IDISK_METAVG = "metavg"
1156 IDISK_PARAMS_TYPES = {
1157 IDISK_SIZE: VTYPE_SIZE,
1158 IDISK_MODE: VTYPE_STRING,
1159 IDISK_ADOPT: VTYPE_STRING,
1160 IDISK_VG: VTYPE_STRING,
1161 IDISK_METAVG: VTYPE_STRING,
1163 IDISK_PARAMS = frozenset(IDISK_PARAMS_TYPES.keys())
1165 # INIC_* constants are used in opcodes, to create/change nics
1170 INIC_PARAMS_TYPES = {
1171 INIC_IP: VTYPE_MAYBE_STRING,
1172 INIC_LINK: VTYPE_STRING,
1173 INIC_MAC: VTYPE_STRING,
1174 INIC_MODE: VTYPE_STRING,
1176 INIC_PARAMS = frozenset(INIC_PARAMS_TYPES.keys())
1178 # Hypervisor constants
1179 HT_XEN_PVM = "xen-pvm"
1181 HT_XEN_HVM = "xen-hvm"
1183 HT_CHROOT = "chroot"
1185 HYPER_TYPES = frozenset([
1193 HTS_REQ_PORT = frozenset([HT_XEN_HVM, HT_KVM])
1195 VNC_BASE_PORT = 5900
1196 VNC_PASSWORD_FILE = CONF_DIR + "/vnc-cluster-password"
1197 VNC_DEFAULT_BIND_ADDRESS = IP4_ADDRESS_ANY
1200 HT_NIC_RTL8139 = "rtl8139"
1201 HT_NIC_NE2K_PCI = "ne2k_pci"
1202 HT_NIC_NE2K_ISA = "ne2k_isa"
1203 HT_NIC_I82551 = "i82551"
1204 HT_NIC_I85557B = "i82557b"
1205 HT_NIC_I8259ER = "i82559er"
1206 HT_NIC_PCNET = "pcnet"
1207 HT_NIC_E1000 = "e1000"
1208 HT_NIC_PARAVIRTUAL = HT_DISK_PARAVIRTUAL = "paravirtual"
1210 HT_HVM_VALID_NIC_TYPES = frozenset([
1217 HT_KVM_VALID_NIC_TYPES = frozenset([
1230 HT_DISK_IOEMU = "ioemu"
1232 HT_DISK_SCSI = "scsi"
1235 HT_DISK_PFLASH = "pflash"
1237 HT_CACHE_DEFAULT = "default"
1238 HT_CACHE_NONE = "none"
1239 HT_CACHE_WTHROUGH = "writethrough"
1240 HT_CACHE_WBACK = "writeback"
1241 HT_VALID_CACHE_TYPES = frozenset([
1248 HT_HVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IOEMU])
1249 HT_KVM_VALID_DISK_TYPES = frozenset([
1250 HT_DISK_PARAVIRTUAL,
1259 HT_MOUSE_MOUSE = "mouse"
1260 HT_MOUSE_TABLET = "tablet"
1262 HT_KVM_VALID_MOUSE_TYPES = frozenset([HT_MOUSE_MOUSE, HT_MOUSE_TABLET])
1265 HT_BO_FLOPPY = "floppy"
1266 HT_BO_CDROM = "cdrom"
1268 HT_BO_NETWORK = "network"
1270 HT_KVM_VALID_BO_TYPES = frozenset([
1277 # SPICE lossless image compression options
1278 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ = "auto_glz"
1279 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ = "auto_lz"
1280 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC = "quic"
1281 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ = "glz"
1282 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ = "lz"
1283 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF = "off"
1285 HT_KVM_SPICE_VALID_LOSSLESS_IMG_COMPR_OPTIONS = frozenset([
1286 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ,
1287 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ,
1288 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC,
1289 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ,
1290 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ,
1291 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF,
1294 # SPICE lossy image compression options (valid for both jpeg and zlib-glz)
1295 HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO = "auto"
1296 HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER = "never"
1297 HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS = "always"
1299 HT_KVM_SPICE_VALID_LOSSY_IMG_COMPR_OPTIONS = frozenset([
1300 HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO,
1301 HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER,
1302 HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS,
1305 # SPICE video stream detection
1306 HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF = "off"
1307 HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL = "all"
1308 HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER = "filter"
1310 HT_KVM_SPICE_VALID_VIDEO_STREAM_DETECTION_OPTIONS = frozenset([
1311 HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF,
1312 HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL,
1313 HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER,
1321 HT_KVM_VALID_SM_TYPES = frozenset([HT_SM_NONE, HT_SM_USER, HT_SM_POOL])
1324 HT_KVM_ENABLED = "enabled"
1325 HT_KVM_DISABLED = "disabled"
1327 HT_KVM_FLAG_VALUES = frozenset([HT_KVM_ENABLED, HT_KVM_DISABLED])
1330 HT_MIGRATION_LIVE = "live"
1331 HT_MIGRATION_NONLIVE = "non-live"
1332 HT_MIGRATION_MODES = frozenset([HT_MIGRATION_LIVE, HT_MIGRATION_NONLIVE])
1334 # Cluster Verify steps
1335 VERIFY_NPLUSONE_MEM = "nplusone_mem"
1336 VERIFY_OPTIONAL_CHECKS = frozenset([VERIFY_NPLUSONE_MEM])
1338 # Cluster Verify error classes
1339 CV_TCLUSTER = "cluster"
1341 CV_TINSTANCE = "instance"
1343 # Cluster Verify error codes and documentation
1345 (CV_TCLUSTER, "ECLUSTERCFG", "Cluster configuration verification failure")
1347 (CV_TCLUSTER, "ECLUSTERCERT",
1348 "Cluster certificate files verification failure")
1349 CV_ECLUSTERFILECHECK = \
1350 (CV_TCLUSTER, "ECLUSTERFILECHECK",
1351 "Cluster configuration verification failure")
1352 CV_ECLUSTERDANGLINGNODES = \
1353 (CV_TNODE, "ECLUSTERDANGLINGNODES",
1354 "Some nodes belong to non-existing groups")
1355 CV_ECLUSTERDANGLINGINST = \
1356 (CV_TNODE, "ECLUSTERDANGLINGINST",
1357 "Some instances have a non-existing primary node")
1358 CV_EINSTANCEBADNODE = \
1359 (CV_TINSTANCE, "EINSTANCEBADNODE",
1360 "Instance marked as running lives on an offline node")
1361 CV_EINSTANCEDOWN = \
1362 (CV_TINSTANCE, "EINSTANCEDOWN", "Instance not running on its primary node")
1363 CV_EINSTANCELAYOUT = \
1364 (CV_TINSTANCE, "EINSTANCELAYOUT", "Instance has multiple secondary nodes")
1365 CV_EINSTANCEMISSINGDISK = \
1366 (CV_TINSTANCE, "EINSTANCEMISSINGDISK", "Missing volume on an instance")
1367 CV_EINSTANCEFAULTYDISK = \
1368 (CV_TINSTANCE, "EINSTANCEFAULTYDISK",
1369 "Impossible to retrieve status for a disk")
1370 CV_EINSTANCEWRONGNODE = \
1371 (CV_TINSTANCE, "EINSTANCEWRONGNODE", "Instance running on the wrong node")
1372 CV_EINSTANCESPLITGROUPS = \
1373 (CV_TINSTANCE, "EINSTANCESPLITGROUPS",
1374 "Instance with primary and secondary nodes in different groups")
1375 CV_EINSTANCEPOLICY = \
1376 (CV_TINSTANCE, "EINSTANCEPOLICY",
1377 "Instance does not meet policy")
1379 (CV_TNODE, "ENODEDRBD", "Error parsing the DRBD status file")
1380 CV_ENODEDRBDHELPER = \
1381 (CV_TNODE, "ENODEDRBDHELPER", "Error caused by the DRBD helper")
1382 CV_ENODEFILECHECK = \
1383 (CV_TNODE, "ENODEFILECHECK",
1384 "Error retrieving the checksum of the node files")
1386 (CV_TNODE, "ENODEHOOKS", "Communication failure in hooks execution")
1388 (CV_TNODE, "ENODEHV", "Hypervisor parameters verification failure")
1390 (CV_TNODE, "ENODELVM", "LVM-related node error")
1392 (CV_TNODE, "ENODEN1", "Not enough memory to accommodate instance failovers")
1394 (CV_TNODE, "ENODENET", "Network-related node error")
1396 (CV_TNODE, "ENODEOS", "OS-related node error")
1397 CV_ENODEORPHANINSTANCE = \
1398 (CV_TNODE, "ENODEORPHANINSTANCE", "Unknown intance running on a node")
1399 CV_ENODEORPHANLV = \
1400 (CV_TNODE, "ENODEORPHANLV", "Unknown LVM logical volume")
1402 (CV_TNODE, "ENODERPC",
1403 "Error during connection to the primary node of an instance")
1405 (CV_TNODE, "ENODESSH", "SSH-related node error")
1407 (CV_TNODE, "ENODEVERSION",
1408 "Protocol version mismatch or Ganeti version mismatch")
1410 (CV_TNODE, "ENODESETUP", "Node setup error")
1412 (CV_TNODE, "ENODETIME", "Node returned invalid time")
1414 (CV_TNODE, "ENODEOOBPATH", "Invalid Out Of Band path")
1415 CV_ENODEUSERSCRIPTS = \
1416 (CV_TNODE, "ENODEUSERSCRIPTS", "User scripts not present or not executable")
1418 CV_ALL_ECODES = frozenset([
1421 CV_ECLUSTERFILECHECK,
1422 CV_ECLUSTERDANGLINGNODES,
1423 CV_ECLUSTERDANGLINGINST,
1424 CV_EINSTANCEBADNODE,
1427 CV_EINSTANCEMISSINGDISK,
1428 CV_EINSTANCEFAULTYDISK,
1429 CV_EINSTANCEWRONGNODE,
1430 CV_EINSTANCESPLITGROUPS,
1441 CV_ENODEORPHANINSTANCE,
1449 CV_ENODEUSERSCRIPTS,
1452 CV_ALL_ECODES_STRINGS = frozenset(estr for (_, estr, _) in CV_ALL_ECODES)
1454 # Node verify constants
1455 NV_DRBDHELPER = "drbd-helper"
1456 NV_DRBDLIST = "drbd-list"
1457 NV_FILELIST = "filelist"
1458 NV_HVINFO = "hvinfo"
1459 NV_HYPERVISOR = "hypervisor"
1460 NV_HVPARAMS = "hvparms"
1461 NV_INSTANCELIST = "instancelist"
1462 NV_LVLIST = "lvlist"
1463 NV_MASTERIP = "master-ip"
1464 NV_NODELIST = "nodelist"
1465 NV_NODENETTEST = "node-net-test"
1466 NV_NODESETUP = "nodesetup"
1467 NV_OSLIST = "oslist"
1468 NV_PVLIST = "pvlist"
1470 NV_VERSION = "version"
1471 NV_VGLIST = "vglist"
1472 NV_VMNODES = "vmnodes"
1473 NV_OOB_PATHS = "oob-paths"
1474 NV_BRIDGES = "bridges"
1475 NV_USERSCRIPTS = "user-scripts"
1478 INSTST_RUNNING = "running"
1479 INSTST_ADMINDOWN = "ADMIN_down"
1480 INSTST_ADMINOFFLINE = "ADMIN_offline"
1481 INSTST_NODEOFFLINE = "ERROR_nodeoffline"
1482 INSTST_NODEDOWN = "ERROR_nodedown"
1483 INSTST_WRONGNODE = "ERROR_wrongnode"
1484 INSTST_ERRORUP = "ERROR_up"
1485 INSTST_ERRORDOWN = "ERROR_down"
1486 INSTST_ALL = frozenset([
1489 INSTST_ADMINOFFLINE,
1499 ADMINST_DOWN = "down"
1500 ADMINST_OFFLINE = "offline"
1501 ADMINST_ALL = frozenset([
1513 NR_ALL = frozenset([
1521 # SSL certificate check constants (in days)
1522 SSL_CERT_EXPIRATION_WARN = 30
1523 SSL_CERT_EXPIRATION_ERROR = 7
1525 # Allocator framework constants
1526 IALLOCATOR_VERSION = 2
1527 IALLOCATOR_DIR_IN = "in"
1528 IALLOCATOR_DIR_OUT = "out"
1529 VALID_IALLOCATOR_DIRECTIONS = frozenset([
1533 IALLOCATOR_MODE_ALLOC = "allocate"
1534 IALLOCATOR_MODE_RELOC = "relocate"
1535 IALLOCATOR_MODE_CHG_GROUP = "change-group"
1536 IALLOCATOR_MODE_NODE_EVAC = "node-evacuate"
1537 IALLOCATOR_MODE_MULTI_ALLOC = "multi-allocate"
1538 VALID_IALLOCATOR_MODES = frozenset([
1539 IALLOCATOR_MODE_ALLOC,
1540 IALLOCATOR_MODE_RELOC,
1541 IALLOCATOR_MODE_CHG_GROUP,
1542 IALLOCATOR_MODE_NODE_EVAC,
1543 IALLOCATOR_MODE_MULTI_ALLOC,
1545 IALLOCATOR_SEARCH_PATH = _autoconf.IALLOCATOR_SEARCH_PATH
1547 IALLOCATOR_NEVAC_PRI = "primary-only"
1548 IALLOCATOR_NEVAC_SEC = "secondary-only"
1549 IALLOCATOR_NEVAC_ALL = "all"
1550 IALLOCATOR_NEVAC_MODES = frozenset([
1551 IALLOCATOR_NEVAC_PRI,
1552 IALLOCATOR_NEVAC_SEC,
1553 IALLOCATOR_NEVAC_ALL,
1557 NODE_EVAC_PRI = "primary-only"
1558 NODE_EVAC_SEC = "secondary-only"
1559 NODE_EVAC_ALL = "all"
1560 NODE_EVAC_MODES = frozenset([
1567 JOB_QUEUE_VERSION = 1
1568 JOB_QUEUE_LOCK_FILE = QUEUE_DIR + "/lock"
1569 JOB_QUEUE_VERSION_FILE = QUEUE_DIR + "/version"
1570 JOB_QUEUE_SERIAL_FILE = QUEUE_DIR + "/serial"
1571 JOB_QUEUE_ARCHIVE_DIR = QUEUE_DIR + "/archive"
1572 JOB_QUEUE_DRAIN_FILE = QUEUE_DIR + "/drain"
1573 JOB_QUEUE_SIZE_HARD_LIMIT = 5000
1575 JOB_ID_TEMPLATE = r"\d+"
1576 JOB_FILE_RE = re.compile(r"^job-(%s)$" % JOB_ID_TEMPLATE)
1578 # unchanged job return
1579 JOB_NOTCHANGED = "nochange"
1582 JOB_STATUS_QUEUED = "queued"
1583 JOB_STATUS_WAITING = "waiting"
1584 JOB_STATUS_CANCELING = "canceling"
1585 JOB_STATUS_RUNNING = "running"
1586 JOB_STATUS_CANCELED = "canceled"
1587 JOB_STATUS_SUCCESS = "success"
1588 JOB_STATUS_ERROR = "error"
1589 JOBS_FINALIZED = frozenset([
1590 JOB_STATUS_CANCELED,
1594 JOB_STATUS_ALL = frozenset([
1597 JOB_STATUS_CANCELING,
1603 OP_STATUS_QUEUED = "queued"
1604 OP_STATUS_WAITING = "waiting"
1605 OP_STATUS_CANCELING = "canceling"
1606 OP_STATUS_RUNNING = "running"
1608 OP_STATUS_CANCELED = "canceled"
1609 OP_STATUS_SUCCESS = "success"
1610 OP_STATUS_ERROR = "error"
1611 OPS_FINALIZED = frozenset([
1618 OP_PRIO_LOWEST = +19
1619 OP_PRIO_HIGHEST = -20
1625 OP_PRIO_SUBMIT_VALID = frozenset([
1631 OP_PRIO_DEFAULT = OP_PRIO_NORMAL
1633 # Lock recalculate mode
1634 LOCKS_REPLACE = "replace"
1635 LOCKS_APPEND = "append"
1637 # Lock timeout (sum) before we should go into blocking acquire (still
1638 # can be reset by priority change); computed as max time (10 hours)
1639 # before we should actually go into blocking acquire given that we
1640 # start from default priority level; in seconds
1642 LOCK_ATTEMPTS_TIMEOUT = 10 * 3600 / (OP_PRIO_DEFAULT - OP_PRIO_HIGHEST)
1643 LOCK_ATTEMPTS_MAXWAIT = 15.0
1644 LOCK_ATTEMPTS_MINWAIT = 1.0
1646 # Execution log types
1647 ELOG_MESSAGE = "message"
1648 ELOG_REMOTE_IMPORT = "remote-import"
1649 ELOG_JQUEUE_TEST = "jqueue-test"
1651 # /etc/hosts modification
1652 ETC_HOSTS_ADD = "add"
1653 ETC_HOSTS_REMOVE = "remove"
1656 JQT_MSGPREFIX = "TESTMSG="
1657 JQT_EXPANDNAMES = "expandnames"
1659 JQT_LOGMSG = "logmsg"
1660 JQT_STARTMSG = "startmsg"
1661 JQT_ALL = frozenset([
1669 QR_CLUSTER = "cluster"
1670 QR_INSTANCE = "instance"
1676 QR_EXPORT = "export"
1678 #: List of resources which can be queried using L{opcodes.OpQuery}
1679 QR_VIA_OP = frozenset([
1688 #: List of resources which can be queried using Local UniX Interface
1689 QR_VIA_LUXI = QR_VIA_OP.union([
1694 #: List of resources which can be queried using RAPI
1695 QR_VIA_RAPI = QR_VIA_LUXI
1698 QFT_UNKNOWN = "unknown"
1701 QFT_NUMBER = "number"
1703 QFT_TIMESTAMP = "timestamp"
1706 #: All query field types
1707 QFT_ALL = frozenset([
1717 # Query result field status (don't change or reuse values as they're used by
1719 #: Normal field status
1723 #: No data (e.g. RPC error), can be used instead of L{RS_OFFLINE}
1725 #: Value unavailable/unsupported for item; if this field is supported
1726 #: but we cannot get the data for the moment, RS_NODATA or
1727 #: RS_OFFLINE should be used
1729 #: Resource marked offline
1732 RS_ALL = frozenset([
1740 #: Dictionary with special field cases and their verbose/terse formatting
1742 RS_UNKNOWN: ("(unknown)", "??"),
1743 RS_NODATA: ("(nodata)", "?"),
1744 RS_OFFLINE: ("(offline)", "*"),
1745 RS_UNAVAIL: ("(unavail)", "-"),
1748 # max dynamic devices
1752 # SSCONF file prefix
1753 SSCONF_FILEPREFIX = "ssconf_"
1755 SS_CLUSTER_NAME = "cluster_name"
1756 SS_CLUSTER_TAGS = "cluster_tags"
1757 SS_FILE_STORAGE_DIR = "file_storage_dir"
1758 SS_SHARED_FILE_STORAGE_DIR = "shared_file_storage_dir"
1759 SS_MASTER_CANDIDATES = "master_candidates"
1760 SS_MASTER_CANDIDATES_IPS = "master_candidates_ips"
1761 SS_MASTER_IP = "master_ip"
1762 SS_MASTER_NETDEV = "master_netdev"
1763 SS_MASTER_NETMASK = "master_netmask"
1764 SS_MASTER_NODE = "master_node"
1765 SS_NODE_LIST = "node_list"
1766 SS_NODE_PRIMARY_IPS = "node_primary_ips"
1767 SS_NODE_SECONDARY_IPS = "node_secondary_ips"
1768 SS_OFFLINE_NODES = "offline_nodes"
1769 SS_ONLINE_NODES = "online_nodes"
1770 SS_PRIMARY_IP_FAMILY = "primary_ip_family"
1771 SS_INSTANCE_LIST = "instance_list"
1772 SS_RELEASE_VERSION = "release_version"
1773 SS_HYPERVISOR_LIST = "hypervisor_list"
1774 SS_MAINTAIN_NODE_HEALTH = "maintain_node_health"
1775 SS_UID_POOL = "uid_pool"
1776 SS_NODEGROUPS = "nodegroups"
1778 SS_FILE_PERMS = 0444
1780 # cluster wide default parameters
1781 DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM
1785 HV_USE_BOOTLOADER: False,
1786 HV_BOOTLOADER_PATH: XEN_BOOTLOADER,
1787 HV_BOOTLOADER_ARGS: "",
1788 HV_KERNEL_PATH: XEN_KERNEL,
1790 HV_ROOT_PATH: "/dev/sda1",
1791 HV_KERNEL_ARGS: "ro",
1792 HV_MIGRATION_PORT: 8002,
1793 HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1794 HV_BLOCKDEV_PREFIX: "sd",
1795 HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1796 HV_CPU_MASK: CPU_PINNING_ALL,
1799 HV_BOOT_ORDER: "cd",
1800 HV_CDROM_IMAGE_PATH: "",
1801 HV_NIC_TYPE: HT_NIC_RTL8139,
1802 HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
1803 HV_VNC_BIND_ADDRESS: IP4_ADDRESS_ANY,
1804 HV_VNC_PASSWORD_FILE: VNC_PASSWORD_FILE,
1807 HV_KERNEL_PATH: "/usr/lib/xen/boot/hvmloader",
1808 HV_DEVICE_MODEL: "/usr/lib/xen/bin/qemu-dm",
1809 HV_MIGRATION_PORT: 8002,
1810 HV_MIGRATION_MODE: HT_MIGRATION_NONLIVE,
1811 HV_USE_LOCALTIME: False,
1812 HV_BLOCKDEV_PREFIX: "hd",
1814 HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1815 HV_CPU_MASK: CPU_PINNING_ALL,
1818 HV_KERNEL_PATH: KVM_KERNEL,
1820 HV_KERNEL_ARGS: "ro",
1821 HV_ROOT_PATH: "/dev/vda1",
1823 HV_SERIAL_CONSOLE: True,
1824 HV_VNC_BIND_ADDRESS: "",
1827 HV_VNC_X509_VERIFY: False,
1828 HV_VNC_PASSWORD_FILE: "",
1829 HV_KVM_SPICE_BIND: "",
1830 HV_KVM_SPICE_IP_VERSION: IFACE_NO_IP_VERSION_SPECIFIED,
1831 HV_KVM_SPICE_PASSWORD_FILE: "",
1832 HV_KVM_SPICE_LOSSLESS_IMG_COMPR: "",
1833 HV_KVM_SPICE_JPEG_IMG_COMPR: "",
1834 HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR: "",
1835 HV_KVM_SPICE_STREAMING_VIDEO_DETECTION: "",
1836 HV_KVM_SPICE_AUDIO_COMPR: True,
1837 HV_KVM_SPICE_USE_TLS: False,
1838 HV_KVM_SPICE_TLS_CIPHERS: OPENSSL_CIPHERS,
1839 HV_KVM_SPICE_USE_VDAGENT: True,
1840 HV_KVM_FLOPPY_IMAGE_PATH: "",
1841 HV_CDROM_IMAGE_PATH: "",
1842 HV_KVM_CDROM2_IMAGE_PATH: "",
1843 HV_BOOT_ORDER: HT_BO_DISK,
1844 HV_NIC_TYPE: HT_NIC_PARAVIRTUAL,
1845 HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
1846 HV_KVM_CDROM_DISK_TYPE: "",
1849 HV_MIGRATION_PORT: 8102,
1850 HV_MIGRATION_BANDWIDTH: 32, # MiB/s
1851 HV_MIGRATION_DOWNTIME: 30, # ms
1852 HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1853 HV_USE_LOCALTIME: False,
1854 HV_DISK_CACHE: HT_CACHE_DEFAULT,
1855 HV_SECURITY_MODEL: HT_SM_NONE,
1856 HV_SECURITY_DOMAIN: "",
1858 HV_VHOST_NET: False,
1859 HV_KVM_USE_CHROOT: False,
1861 HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1862 HV_CPU_MASK: CPU_PINNING_ALL,
1867 HV_INIT_SCRIPT: "/ganeti-chroot",
1874 HVC_GLOBALS = frozenset([
1876 HV_MIGRATION_BANDWIDTH,
1884 BE_AUTO_BALANCE: True,
1885 BE_ALWAYS_FAILOVER: False,
1891 ND_SPINDLE_COUNT: 1,
1894 DISK_LD_DEFAULTS = {
1896 LDP_RESYNC_RATE: CLASSIC_DRBD_SYNC_SPEED,
1897 LDP_BARRIERS: _autoconf.DRBD_BARRIERS,
1898 LDP_NO_META_FLUSH: _autoconf.DRBD_NO_META_FLUSH,
1899 LDP_DEFAULT_METAVG: DEFAULT_VG,
1900 LDP_DISK_CUSTOM: "",
1902 LDP_DYNAMIC_RESYNC: False,
1904 # The default values for the DRBD dynamic resync speed algorithm are taken
1905 # from the drbsetup 8.3.11 man page, except for c-plan-ahead (that we
1906 # don't need to set to 0, because we have a separate option to enable it)
1907 # and for c-max-rate, that we cap to the default value for the static resync
1909 LDP_PLAN_AHEAD: 20, # ds
1910 LDP_FILL_TARGET: 0, # sectors
1911 LDP_DELAY_TARGET: 1, # ds
1912 LDP_MAX_RATE: CLASSIC_DRBD_SYNC_SPEED, # KiB/s
1913 LDP_MIN_RATE: 4 * 1024, # KiB/s
1916 LDP_STRIPES: _autoconf.LVM_STRIPECOUNT
1925 # readability shortcuts
1926 _LV_DEFAULTS = DISK_LD_DEFAULTS[LD_LV]
1927 _DRBD_DEFAULTS = DISK_LD_DEFAULTS[LD_DRBD8]
1929 DISK_DT_DEFAULTS = {
1931 LV_STRIPES: DISK_LD_DEFAULTS[LD_LV][LDP_STRIPES],
1934 DRBD_RESYNC_RATE: _DRBD_DEFAULTS[LDP_RESYNC_RATE],
1935 DRBD_DATA_STRIPES: _LV_DEFAULTS[LDP_STRIPES],
1936 DRBD_META_STRIPES: _LV_DEFAULTS[LDP_STRIPES],
1937 DRBD_DISK_BARRIERS: _DRBD_DEFAULTS[LDP_BARRIERS],
1938 DRBD_META_BARRIERS: _DRBD_DEFAULTS[LDP_NO_META_FLUSH],
1939 DRBD_DEFAULT_METAVG: _DRBD_DEFAULTS[LDP_DEFAULT_METAVG],
1940 DRBD_DISK_CUSTOM: _DRBD_DEFAULTS[LDP_DISK_CUSTOM],
1941 DRBD_NET_CUSTOM: _DRBD_DEFAULTS[LDP_NET_CUSTOM],
1942 DRBD_DYNAMIC_RESYNC: _DRBD_DEFAULTS[LDP_DYNAMIC_RESYNC],
1943 DRBD_PLAN_AHEAD: _DRBD_DEFAULTS[LDP_PLAN_AHEAD],
1944 DRBD_FILL_TARGET: _DRBD_DEFAULTS[LDP_FILL_TARGET],
1945 DRBD_DELAY_TARGET: _DRBD_DEFAULTS[LDP_DELAY_TARGET],
1946 DRBD_MAX_RATE: _DRBD_DEFAULTS[LDP_MAX_RATE],
1947 DRBD_MIN_RATE: _DRBD_DEFAULTS[LDP_MIN_RATE],
1954 RBD_POOL: DISK_LD_DEFAULTS[LD_RBD][LDP_POOL]
1958 # we don't want to export the shortcuts
1959 del _LV_DEFAULTS, _DRBD_DEFAULTS
1962 NIC_MODE: NIC_MODE_BRIDGED,
1963 NIC_LINK: DEFAULT_BRIDGE,
1966 # All of the following values are quite arbitrarily - there are no
1967 # "good" defaults, these must be customised per-site
1968 IPOLICY_DEFAULTS = {
1970 ISPEC_MEM_SIZE: 128,
1972 ISPEC_DISK_COUNT: 1,
1973 ISPEC_DISK_SIZE: 1024,
1975 ISPEC_SPINDLE_USE: 1,
1978 ISPEC_MEM_SIZE: 32768,
1980 ISPEC_DISK_COUNT: MAX_DISKS,
1981 ISPEC_DISK_SIZE: 1024 * 1024,
1982 ISPEC_NIC_COUNT: MAX_NICS,
1983 ISPEC_SPINDLE_USE: 12,
1986 ISPEC_MEM_SIZE: 128,
1988 ISPEC_DISK_COUNT: 1,
1989 ISPEC_DISK_SIZE: 1024,
1991 ISPEC_SPINDLE_USE: 1,
1993 IPOLICY_DTS: DISK_TEMPLATES,
1994 IPOLICY_VCPU_RATIO: 4.0,
1995 IPOLICY_SPINDLE_RATIO: 32.0,
1998 MASTER_POOL_SIZE_DEFAULT = 10
2000 CONFD_PROTOCOL_VERSION = 1
2003 CONFD_REQ_NODE_ROLE_BYNAME = 1
2004 CONFD_REQ_NODE_PIP_BY_INSTANCE_IP = 2
2005 CONFD_REQ_CLUSTER_MASTER = 3
2006 CONFD_REQ_NODE_PIP_LIST = 4
2007 CONFD_REQ_MC_PIP_LIST = 5
2008 CONFD_REQ_INSTANCES_IPS_LIST = 6
2009 CONFD_REQ_NODE_DRBD = 7
2011 # Confd request query fields. These are used to narrow down queries.
2012 # These must be strings rather than integers, because json-encoding
2013 # converts them to strings anyway, as they're used as dict-keys.
2014 CONFD_REQQ_LINK = "0"
2016 CONFD_REQQ_IPLIST = "2"
2017 CONFD_REQQ_FIELDS = "3"
2019 CONFD_REQFIELD_NAME = "0"
2020 CONFD_REQFIELD_IP = "1"
2021 CONFD_REQFIELD_MNODE_PIP = "2"
2023 CONFD_REQS = frozenset([
2025 CONFD_REQ_NODE_ROLE_BYNAME,
2026 CONFD_REQ_NODE_PIP_BY_INSTANCE_IP,
2027 CONFD_REQ_CLUSTER_MASTER,
2028 CONFD_REQ_NODE_PIP_LIST,
2029 CONFD_REQ_MC_PIP_LIST,
2030 CONFD_REQ_INSTANCES_IPS_LIST,
2031 CONFD_REQ_NODE_DRBD,
2034 CONFD_REPL_STATUS_OK = 0
2035 CONFD_REPL_STATUS_ERROR = 1
2036 CONFD_REPL_STATUS_NOTIMPLEMENTED = 2
2038 CONFD_REPL_STATUSES = frozenset([
2039 CONFD_REPL_STATUS_OK,
2040 CONFD_REPL_STATUS_ERROR,
2041 CONFD_REPL_STATUS_NOTIMPLEMENTED,
2044 (CONFD_NODE_ROLE_MASTER,
2045 CONFD_NODE_ROLE_CANDIDATE,
2046 CONFD_NODE_ROLE_OFFLINE,
2047 CONFD_NODE_ROLE_DRAINED,
2048 CONFD_NODE_ROLE_REGULAR,
2051 # A few common errors for confd
2052 CONFD_ERROR_UNKNOWN_ENTRY = 1
2053 CONFD_ERROR_INTERNAL = 2
2054 CONFD_ERROR_ARGUMENT = 3
2056 # Each request is "salted" by the current timestamp.
2057 # This constants decides how many seconds of skew to accept.
2058 # TODO: make this a default and allow the value to be more configurable
2059 CONFD_MAX_CLOCK_SKEW = 2 * NODE_MAX_CLOCK_SKEW
2061 # When we haven't reloaded the config for more than this amount of seconds, we
2062 # force a test to see if inotify is betraying us.
2063 CONFD_CONFIG_RELOAD_TIMEOUT = 60
2065 # If we receive more than one update in this amount of seconds, we move to
2066 # polling every RATELIMIT seconds, rather than relying on inotify, to be able
2067 # to serve more requests.
2068 CONFD_CONFIG_RELOAD_RATELIMIT = 2
2070 # Magic number prepended to all confd queries.
2071 # This allows us to distinguish different types of confd protocols and handle
2072 # them. For example by changing this we can move the whole payload to be
2073 # compressed, or move away from json.
2074 CONFD_MAGIC_FOURCC = "plj0"
2076 # By default a confd request is sent to the minimum between this number and all
2077 # MCs. 6 was chosen because even in the case of a disastrous 50% response rate,
2078 # we should have enough answers to be able to compare more than one.
2079 CONFD_DEFAULT_REQ_COVERAGE = 6
2081 # Timeout in seconds to expire pending query request in the confd client
2082 # library. We don't actually expect any answer more than 10 seconds after we
2084 CONFD_CLIENT_EXPIRE_TIMEOUT = 10
2086 # Maximum UDP datagram size.
2087 # On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
2088 # On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
2089 # (assuming we can't use jumbo frames)
2090 # We just set this to 60K, which should be enough
2091 MAX_UDP_DATA_SIZE = 61440
2093 # User-id pool minimum/maximum acceptable user-ids.
2095 UIDPOOL_UID_MAX = 2 ** 32 - 1 # Assuming 32 bit user-ids
2097 # Name or path of the pgrep command
2100 # Name of the node group that gets created at cluster init or upgrade
2101 INITIAL_NODE_GROUP_NAME = "default"
2103 # Possible values for NodeGroup.alloc_policy
2104 ALLOC_POLICY_PREFERRED = "preferred"
2105 ALLOC_POLICY_LAST_RESORT = "last_resort"
2106 ALLOC_POLICY_UNALLOCABLE = "unallocable"
2107 VALID_ALLOC_POLICIES = [
2108 ALLOC_POLICY_PREFERRED,
2109 ALLOC_POLICY_LAST_RESORT,
2110 ALLOC_POLICY_UNALLOCABLE,
2113 # Temporary external/shared storage parameters
2114 BLOCKDEV_DRIVER_MANUAL = "manual"
2116 # qemu-img path, required for ovfconverter
2117 QEMUIMG_PATH = _autoconf.QEMUIMG_PATH
2119 # Whether htools was enabled at compilation time
2120 HTOOLS = _autoconf.HTOOLS
2121 # The hail iallocator
2122 IALLOC_HAIL = "hail"
2124 # Fake opcodes for functions that have hooks attached to them via
2125 # backend.RunLocalHooks
2126 FAKE_OP_MASTER_TURNUP = "OP_CLUSTER_IP_TURNUP"
2127 FAKE_OP_MASTER_TURNDOWN = "OP_CLUSTER_IP_TURNDOWN"
2129 # Do not re-export imported modules
2130 del re, _vcsversion, _autoconf, socket