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
29 from ganeti import compat
30 from ganeti import pathutils
34 RELEASE_VERSION = _autoconf.PACKAGE_VERSION
38 OS_API_VERSIONS = compat.UniqueFrozenset([
43 VCS_VERSION = _vcsversion.VCS_VERSION
48 # Format for CONFIG_VERSION:
49 # 01 03 0123 = 01030123
51 # | | + Configuration version/revision
55 # It is stored as an integer. Make sure not to write an octal number.
57 # BuildVersion and SplitVersion must be in here because we can't import other
58 # modules. The cfgupgrade tool must be able to read and write version numbers
59 # and thus requires these functions. To avoid code duplication, they're kept in
62 def BuildVersion(major, minor, revision):
63 """Calculates int version number from major, minor and revision numbers.
65 Returns: int representing version number
68 assert isinstance(major, int)
69 assert isinstance(minor, int)
70 assert isinstance(revision, int)
71 return (1000000 * major +
76 def SplitVersion(version):
77 """Splits version number stored in an int.
79 Returns: tuple; (major, minor, revision)
82 assert isinstance(version, int)
84 (major, remainder) = divmod(version, 1000000)
85 (minor, revision) = divmod(remainder, 10000)
87 return (major, minor, revision)
90 CONFIG_MAJOR = int(_autoconf.VERSION_MAJOR)
91 CONFIG_MINOR = int(_autoconf.VERSION_MINOR)
93 CONFIG_VERSION = BuildVersion(CONFIG_MAJOR, CONFIG_MINOR, CONFIG_REVISION)
95 #: RPC protocol version
96 PROTOCOL_VERSION = BuildVersion(CONFIG_MAJOR, CONFIG_MINOR, 0)
99 DAEMONS_GROUP = _autoconf.DAEMONS_GROUP
100 ADMIN_GROUP = _autoconf.ADMIN_GROUP
101 MASTERD_USER = _autoconf.MASTERD_USER
102 MASTERD_GROUP = _autoconf.MASTERD_GROUP
103 RAPI_USER = _autoconf.RAPI_USER
104 RAPI_GROUP = _autoconf.RAPI_GROUP
105 CONFD_USER = _autoconf.CONFD_USER
106 CONFD_GROUP = _autoconf.CONFD_GROUP
107 NODED_USER = _autoconf.NODED_USER
108 NODED_GROUP = _autoconf.NODED_GROUP
109 SSH_LOGIN_USER = _autoconf.SSH_LOGIN_USER
110 SSH_CONSOLE_USER = _autoconf.SSH_CONSOLE_USER
112 # cpu pinning separators and constants
113 CPU_PINNING_SEP = ":"
114 CPU_PINNING_ALL = "all"
115 # internal representation of "all"
116 CPU_PINNING_ALL_VAL = -1
117 # one "all" entry in a CPU list means CPU pinning is off
118 CPU_PINNING_OFF = [CPU_PINNING_ALL_VAL]
120 # A Xen-specific implementation detail - there is no way to actually say
121 # "use any cpu for pinning" in a Xen configuration file, as opposed to the
122 # command line, where you can say "xm vcpu-pin <domain> <vcpu> all".
123 # The workaround used in Xen is "0-63" (see source code function
124 # xm_vcpu_pin in <xen-source>/tools/python/xen/xm/main.py).
125 # To support future changes, the following constant is treated as a
126 # blackbox string that simply means use-any-cpu-for-pinning-under-xen.
127 CPU_PINNING_ALL_XEN = "0-63"
129 # A KVM-specific implementation detail - the following value is used
130 # to set CPU affinity to all processors (#0 through #31), per taskset
132 # FIXME: This only works for machines with up to 32 CPU cores
133 CPU_PINNING_ALL_KVM = 0xFFFFFFFF
137 MAX_WIPE_CHUNK = 1024 # 1GB
138 MIN_WIPE_CHUNK_PERCENT = 10
141 SECURE_DIR_MODE = 0700
142 SECURE_FILE_MODE = 0600
143 ADOPTABLE_BLOCKDEV_ROOT = "/dev/disk/"
144 ENABLE_FILE_STORAGE = _autoconf.ENABLE_FILE_STORAGE
145 ENABLE_SHARED_FILE_STORAGE = _autoconf.ENABLE_SHARED_FILE_STORAGE
146 ENABLE_CONFD = _autoconf.ENABLE_CONFD
147 ENABLE_SPLIT_QUERY = _autoconf.ENABLE_SPLIT_QUERY
148 ENABLE_RESTRICTED_COMMANDS = _autoconf.ENABLE_RESTRICTED_COMMANDS
150 NODED = "ganeti-noded"
151 CONFD = "ganeti-confd"
153 MASTERD = "ganeti-masterd"
156 # daemon-name: ("proto", "default-port")
157 NODED: ("tcp", 1811),
158 CONFD: ("udp", 1814),
162 DEFAULT_NODED_PORT = DAEMONS_PORTS[NODED][1]
163 DEFAULT_CONFD_PORT = DAEMONS_PORTS[CONFD][1]
164 DEFAULT_RAPI_PORT = DAEMONS_PORTS[RAPI][1]
166 FIRST_DRBD_PORT = 11000
167 LAST_DRBD_PORT = 14999
170 NODED: pathutils.GetLogFilename("node-daemon"),
171 CONFD: pathutils.GetLogFilename("conf-daemon"),
172 RAPI: pathutils.GetLogFilename("rapi-daemon"),
173 MASTERD: pathutils.GetLogFilename("master-daemon"),
176 DEV_CONSOLE = "/dev/console"
178 PROC_MOUNTS = "/proc/mounts"
180 # Local UniX Interface related constants
182 LUXI_VERSION = CONFIG_VERSION
184 # one of "no", "yes", "only"
185 SYSLOG_USAGE = _autoconf.SYSLOG_USAGE
189 SYSLOG_SOCKET = "/dev/log"
191 EXPORT_CONF_FILE = "config.ini"
193 XEN_BOOTLOADER = _autoconf.XEN_BOOTLOADER
194 XEN_KERNEL = _autoconf.XEN_KERNEL
195 XEN_INITRD = _autoconf.XEN_INITRD
198 # FIXME: This will be made configurable using hvparams in Ganeti 2.7
199 XEN_CMD = _autoconf.XEN_CMD
200 # When the Xen toolstack used is "xl", live migration requires the source host
201 # to connect to the target host via ssh (xl runs this command). We need to pass
202 # the command xl runs some extra info so that it can use Ganeti's key
203 # verification and not fail. Note that this string is incomplete: it must be
204 # filled with the cluster name before being used.
205 XL_SSH_CMD = ("ssh -l %s -oGlobalKnownHostsFile=%s"
206 " -oUserKnownHostsFile=/dev/null"
207 " -oCheckHostIp=no -oStrictHostKeyChecking=yes"
208 " -oHostKeyAlias=%%s") % (SSH_LOGIN_USER,
209 pathutils.SSH_KNOWN_HOSTS_FILE)
211 KVM_PATH = _autoconf.KVM_PATH
212 KVM_KERNEL = _autoconf.KVM_KERNEL
213 SOCAT_PATH = _autoconf.SOCAT_PATH
214 SOCAT_USE_ESCAPE = _autoconf.SOCAT_USE_ESCAPE
215 SOCAT_USE_COMPRESS = _autoconf.SOCAT_USE_COMPRESS
216 SOCAT_ESCAPE_CODE = "0x1d"
218 #: Console as SSH command
221 #: Console as VNC server
224 #: Console as SPICE server
227 #: Display a message for console access
231 CONS_ALL = compat.UniqueFrozenset([
238 # For RSA keys more bits are better, but they also make operations more
239 # expensive. NIST SP 800-131 recommends a minimum of 2048 bits from the year
243 # Ciphers allowed for SSL connections. For the format, see ciphers(1). A better
244 # way to disable ciphers would be to use the exclamation mark (!), but socat
245 # versions below 1.5 can't parse exclamation marks in options properly. When
246 # modifying the ciphers, ensure not to accidentially add something after it's
247 # been removed. Use the "openssl" utility to check the allowed ciphers, e.g.
248 # "openssl ciphers -v HIGH:-DES".
249 OPENSSL_CIPHERS = "HIGH:-DES:-3DES:-EXPORT:-ADH"
251 # Digest used to sign certificates ("openssl x509" uses SHA1 by default)
252 X509_CERT_SIGN_DIGEST = "SHA1"
254 # Default validity of certificates in days
255 X509_CERT_DEFAULT_VALIDITY = 365 * 5
257 # commonName (CN) used in certificates
258 X509_CERT_CN = "ganeti.example.com"
260 X509_CERT_SIGNATURE_HEADER = "X-Ganeti-Signature"
262 # Import/export daemon mode
263 IEM_IMPORT = "import"
264 IEM_EXPORT = "export"
266 # Import/export transport compression
269 IEC_ALL = compat.UniqueFrozenset([
274 IE_CUSTOM_SIZE = "fd"
276 IE_MAGIC_RE = re.compile(r"^[-_.a-zA-Z0-9]{5,100}$")
279 # Direct file I/O, equivalent to a shell's I/O redirection using '<' or '>'
281 # Raw block device I/O using "dd"
282 IEIO_RAW_DISK = "raw"
283 # OS definition import/export script
284 IEIO_SCRIPT = "script"
286 VALUE_DEFAULT = "default"
288 VALUE_GENERATE = "generate"
291 VALUE_FALSE = "false"
293 # External script validation mask
294 EXT_PLUGIN_MASK = re.compile("^[a-zA-Z0-9_-]+$")
296 # hooks-related constants
297 HOOKS_PHASE_PRE = "pre"
298 HOOKS_PHASE_POST = "post"
299 HOOKS_NAME_CFGUPDATE = "config-update"
300 HOOKS_NAME_WATCHER = "watcher"
302 HOOKS_PATH = "/sbin:/bin:/usr/sbin:/usr/bin"
304 # hooks subject type (what object type does the LU deal with)
305 HTYPE_CLUSTER = "CLUSTER"
307 HTYPE_GROUP = "GROUP"
308 HTYPE_INSTANCE = "INSTANCE"
309 HTYPE_NETWORK = "NETWORK"
321 # first two are valid in LU context only, not passed to backend
324 # and the rest are valid in backend
329 SF_ALLOCATABLE = "allocatable"
332 SO_FIX_CONSISTENCY = "fix-consistency"
334 # Available fields per storage type
335 VALID_STORAGE_FIELDS = compat.UniqueFrozenset([
344 VALID_STORAGE_TYPES = compat.UniqueFrozenset([
350 MODIFIABLE_STORAGE_FIELDS = {
351 ST_LVM_PV: frozenset([SF_ALLOCATABLE]),
354 VALID_STORAGE_OPERATIONS = {
355 ST_LVM_VG: frozenset([SO_FIX_CONSISTENCY]),
359 # Note: Code depends on LDS_OKAY < LDS_UNKNOWN < LDS_FAULTY
362 LDS_FAULTY) = range(1, 4)
364 # disk template types
365 DT_DISKLESS = "diskless"
369 DT_SHARED_FILE = "sharedfile"
370 DT_BLOCK = "blockdev"
374 # the set of network-mirrored disk templates
375 DTS_INT_MIRROR = compat.UniqueFrozenset([DT_DRBD8])
377 # the set of externally-mirrored disk templates (e.g. SAN, NAS)
378 DTS_EXT_MIRROR = compat.UniqueFrozenset([
385 # the set of non-lvm-based disk templates
386 DTS_NOT_LVM = compat.UniqueFrozenset([
395 # the set of disk templates which can be grown
396 DTS_GROWABLE = compat.UniqueFrozenset([
405 # the set of disk templates that allow adoption
406 DTS_MAY_ADOPT = compat.UniqueFrozenset([
411 # the set of disk templates that *must* use adoption
412 DTS_MUST_ADOPT = compat.UniqueFrozenset([DT_BLOCK])
414 # the set of disk templates that allow migrations
415 DTS_MIRRORED = frozenset.union(DTS_INT_MIRROR, DTS_EXT_MIRROR)
417 # the set of file based disk templates
418 DTS_FILEBASED = compat.UniqueFrozenset([
423 # the set of disk templates that are supported by exclusive_storage
424 DTS_EXCL_STORAGE = compat.UniqueFrozenset([DT_PLAIN])
426 # templates for which we don't perform checks on free space
427 DTS_NO_FREE_SPACE_CHECK = compat.UniqueFrozenset([
438 LD_BLOCKDEV = "blockdev"
441 LOGICAL_DISK_TYPES = compat.UniqueFrozenset([
450 LDS_BLOCK = compat.UniqueFrozenset([
459 DRBD_HMAC_ALG = "md5"
460 DRBD_NET_PROTOCOL = "C"
461 DRBD_STATUS_FILE = "/proc/drbd"
463 #: Size of DRBD meta block device
468 DRBD_B_DISK_BARRIERS = "b"
469 DRBD_B_DISK_DRAIN = "d"
470 DRBD_B_DISK_FLUSH = "f"
472 # Valid barrier combinations: "n" or any non-null subset of "bfd"
473 DRBD_VALID_BARRIER_OPT = compat.UniqueFrozenset([
474 frozenset([DRBD_B_NONE]),
475 frozenset([DRBD_B_DISK_BARRIERS]),
476 frozenset([DRBD_B_DISK_DRAIN]),
477 frozenset([DRBD_B_DISK_FLUSH]),
478 frozenset([DRBD_B_DISK_DRAIN, DRBD_B_DISK_FLUSH]),
479 frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_DRAIN]),
480 frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_FLUSH]),
481 frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_FLUSH, DRBD_B_DISK_DRAIN]),
487 # file backend driver
491 # the set of drbd-like disk types
492 LDS_DRBD = compat.UniqueFrozenset([LD_DRBD8])
497 DISK_ACCESS_SET = compat.UniqueFrozenset([DISK_RDONLY, DISK_RDWR])
499 # disk replacement mode
500 REPLACE_DISK_PRI = "replace_on_primary" # replace disks on primary
501 REPLACE_DISK_SEC = "replace_on_secondary" # replace disks on secondary
502 REPLACE_DISK_CHG = "replace_new_secondary" # change secondary node
503 REPLACE_DISK_AUTO = "replace_auto"
504 REPLACE_MODES = compat.UniqueFrozenset([
511 # Instance export mode
512 EXPORT_MODE_LOCAL = "local"
513 EXPORT_MODE_REMOTE = "remote"
514 EXPORT_MODES = compat.UniqueFrozenset([
519 # instance creation modes
520 INSTANCE_CREATE = "create"
521 INSTANCE_IMPORT = "import"
522 INSTANCE_REMOTE_IMPORT = "remote-import"
523 INSTANCE_CREATE_MODES = compat.UniqueFrozenset([
526 INSTANCE_REMOTE_IMPORT,
529 # Remote import/export handshake message and version
531 RIE_HANDSHAKE = "Hi, I'm Ganeti"
533 # Remote import/export certificate validity in seconds
534 RIE_CERT_VALIDITY = 24 * 60 * 60
536 # Overall timeout for establishing connection
537 RIE_CONNECT_TIMEOUT = 180
539 # Export only: how long to wait per connection attempt (seconds)
540 RIE_CONNECT_ATTEMPT_TIMEOUT = 20
542 # Export only: number of attempts to connect
543 RIE_CONNECT_RETRIES = 10
545 #: Give child process up to 5 seconds to exit after sending a signal
546 CHILD_LINGER_TIMEOUT = 5.0
548 DISK_TEMPLATES = compat.UniqueFrozenset([
559 FILE_DRIVER = compat.UniqueFrozenset([FD_LOOP, FD_BLKTAP])
561 # import/export config options
562 INISECT_EXP = "export"
563 INISECT_INS = "instance"
564 INISECT_HYP = "hypervisor"
565 INISECT_BEP = "backend"
568 # dynamic device modification
570 DDM_MODIFY = "modify"
571 DDM_REMOVE = "remove"
572 DDMS_VALUES = compat.UniqueFrozenset([DDM_ADD, DDM_REMOVE])
573 DDMS_VALUES_WITH_MODIFY = (DDMS_VALUES | frozenset([
576 # TODO: DDM_SWAP, DDM_MOVE?
583 EXIT_NODESETUP_ERROR = 12
584 EXIT_CONFIRMATION = 13 # need user confirmation
586 #: Exit code for query operations with unknown fields
587 EXIT_UNKNOWN_FIELD = 14
590 TAG_CLUSTER = "cluster"
591 TAG_NODEGROUP = "nodegroup"
593 TAG_INSTANCE = "instance"
594 TAG_NETWORK = "network"
595 VALID_TAG_TYPES = compat.UniqueFrozenset([
603 MAX_TAGS_PER_OBJ = 4096
606 DEFAULT_BRIDGE = "xen-br0"
607 CLASSIC_DRBD_SYNC_SPEED = 60 * 1024 # 60 MiB, expressed in KiB
608 IP4_ADDRESS_LOCALHOST = "127.0.0.1"
609 IP4_ADDRESS_ANY = "0.0.0.0"
610 IP6_ADDRESS_LOCALHOST = "::1"
611 IP6_ADDRESS_ANY = "::"
614 VALID_IP_VERSIONS = compat.UniqueFrozenset([IP4_VERSION, IP6_VERSION])
615 # for export to htools
616 IP4_FAMILY = socket.AF_INET
617 IP6_FAMILY = socket.AF_INET6
619 TCP_PING_TIMEOUT = 10
621 DEFAULT_DRBD_HELPER = "/bin/true"
623 DEFAULT_MAC_PREFIX = "aa:00:00"
624 # default maximum instance wait time, in seconds.
625 DEFAULT_SHUTDOWN_TIMEOUT = 120
626 NODE_MAX_CLOCK_SKEW = 150
627 # Time for an intra-cluster disk transfer to wait for a connection
628 DISK_TRANSFER_CONNECT_TIMEOUT = 60
629 # Disk index separator
630 DISK_SEPARATOR = _autoconf.DISK_SEPARATOR
631 IP_COMMAND_PATH = _autoconf.IP_PATH
633 #: Key for job IDs in opcode result
639 RUNPARTS_ERR) = range(3)
641 RUNPARTS_STATUS = compat.UniqueFrozenset([
649 RPC_ENCODING_ZLIB_BASE64) = range(2)
651 # Various time constants for the timeout table
652 RPC_TMO_URGENT = 60 # one minute
653 RPC_TMO_FAST = 5 * 60 # five minutes
654 RPC_TMO_NORMAL = 15 * 60 # 15 minutes
655 RPC_TMO_SLOW = 3600 # one hour
656 RPC_TMO_4HRS = 4 * 3600
659 # Timeout for connecting to nodes (seconds)
660 RPC_CONNECT_TIMEOUT = 5
662 # os related constants
663 OS_SCRIPT_CREATE = "create"
664 OS_SCRIPT_IMPORT = "import"
665 OS_SCRIPT_EXPORT = "export"
666 OS_SCRIPT_RENAME = "rename"
667 OS_SCRIPT_VERIFY = "verify"
668 OS_SCRIPTS = compat.UniqueFrozenset([
676 OS_API_FILE = "ganeti_api_version"
677 OS_VARIANTS_FILE = "variants.list"
678 OS_PARAMETERS_FILE = "parameters.list"
680 OS_VALIDATE_PARAMETERS = "parameters"
681 OS_VALIDATE_CALLS = compat.UniqueFrozenset([OS_VALIDATE_PARAMETERS])
683 # External Storage (ES) related constants
684 ES_ACTION_CREATE = "create"
685 ES_ACTION_REMOVE = "remove"
686 ES_ACTION_GROW = "grow"
687 ES_ACTION_ATTACH = "attach"
688 ES_ACTION_DETACH = "detach"
689 ES_ACTION_SETINFO = "setinfo"
690 ES_ACTION_VERIFY = "verify"
692 ES_SCRIPT_CREATE = ES_ACTION_CREATE
693 ES_SCRIPT_REMOVE = ES_ACTION_REMOVE
694 ES_SCRIPT_GROW = ES_ACTION_GROW
695 ES_SCRIPT_ATTACH = ES_ACTION_ATTACH
696 ES_SCRIPT_DETACH = ES_ACTION_DETACH
697 ES_SCRIPT_SETINFO = ES_ACTION_SETINFO
698 ES_SCRIPT_VERIFY = ES_ACTION_VERIFY
699 ES_SCRIPTS = frozenset([
709 ES_PARAMETERS_FILE = "parameters.list"
716 INSTANCE_REBOOT_SOFT = "soft"
717 INSTANCE_REBOOT_HARD = "hard"
718 INSTANCE_REBOOT_FULL = "full"
720 REBOOT_TYPES = compat.UniqueFrozenset([
721 INSTANCE_REBOOT_SOFT,
722 INSTANCE_REBOOT_HARD,
723 INSTANCE_REBOOT_FULL,
726 # instance reboot behaviors
727 INSTANCE_REBOOT_ALLOWED = "reboot"
728 INSTANCE_REBOOT_EXIT = "exit"
730 REBOOT_BEHAVIORS = compat.UniqueFrozenset([
731 INSTANCE_REBOOT_ALLOWED,
732 INSTANCE_REBOOT_EXIT,
735 VTYPE_STRING = "string"
736 VTYPE_MAYBE_STRING = "maybe-string"
738 VTYPE_SIZE = "size" # size, in MiBs
740 ENFORCEABLE_TYPES = compat.UniqueFrozenset([
748 # Constant representing that the user does not specify any IP version
749 IFACE_NO_IP_VERSION_SPECIFIED = 0
751 VALID_SERIAL_SPEEDS = compat.UniqueFrozenset([
772 # HV parameter names (global namespace)
773 HV_BOOT_ORDER = "boot_order"
774 HV_CDROM_IMAGE_PATH = "cdrom_image_path"
775 HV_KVM_CDROM2_IMAGE_PATH = "cdrom2_image_path"
776 HV_KVM_FLOPPY_IMAGE_PATH = "floppy_image_path"
777 HV_NIC_TYPE = "nic_type"
778 HV_DISK_TYPE = "disk_type"
779 HV_KVM_CDROM_DISK_TYPE = "cdrom_disk_type"
780 HV_VNC_BIND_ADDRESS = "vnc_bind_address"
781 HV_VNC_PASSWORD_FILE = "vnc_password_file"
782 HV_VNC_TLS = "vnc_tls"
783 HV_VNC_X509 = "vnc_x509_path"
784 HV_VNC_X509_VERIFY = "vnc_x509_verify"
785 HV_KVM_SPICE_BIND = "spice_bind"
786 HV_KVM_SPICE_IP_VERSION = "spice_ip_version"
787 HV_KVM_SPICE_PASSWORD_FILE = "spice_password_file"
788 HV_KVM_SPICE_LOSSLESS_IMG_COMPR = "spice_image_compression"
789 HV_KVM_SPICE_JPEG_IMG_COMPR = "spice_jpeg_wan_compression"
790 HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR = "spice_zlib_glz_wan_compression"
791 HV_KVM_SPICE_STREAMING_VIDEO_DETECTION = "spice_streaming_video"
792 HV_KVM_SPICE_AUDIO_COMPR = "spice_playback_compression"
793 HV_KVM_SPICE_USE_TLS = "spice_use_tls"
794 HV_KVM_SPICE_TLS_CIPHERS = "spice_tls_ciphers"
795 HV_KVM_SPICE_USE_VDAGENT = "spice_use_vdagent"
798 HV_USE_BOOTLOADER = "use_bootloader"
799 HV_BOOTLOADER_ARGS = "bootloader_args"
800 HV_BOOTLOADER_PATH = "bootloader_path"
801 HV_KERNEL_ARGS = "kernel_args"
802 HV_KERNEL_PATH = "kernel_path"
803 HV_INITRD_PATH = "initrd_path"
804 HV_ROOT_PATH = "root_path"
805 HV_SERIAL_CONSOLE = "serial_console"
806 HV_SERIAL_SPEED = "serial_speed"
807 HV_USB_MOUSE = "usb_mouse"
809 HV_DEVICE_MODEL = "device_model"
810 HV_INIT_SCRIPT = "init_script"
811 HV_MIGRATION_PORT = "migration_port"
812 HV_MIGRATION_BANDWIDTH = "migration_bandwidth"
813 HV_MIGRATION_DOWNTIME = "migration_downtime"
814 HV_MIGRATION_MODE = "migration_mode"
815 HV_USE_LOCALTIME = "use_localtime"
816 HV_DISK_CACHE = "disk_cache"
817 HV_SECURITY_MODEL = "security_model"
818 HV_SECURITY_DOMAIN = "security_domain"
819 HV_KVM_FLAG = "kvm_flag"
820 HV_VHOST_NET = "vhost_net"
821 HV_KVM_USE_CHROOT = "use_chroot"
822 HV_CPU_MASK = "cpu_mask"
823 HV_MEM_PATH = "mem_path"
824 HV_PASSTHROUGH = "pci_pass"
825 HV_BLOCKDEV_PREFIX = "blockdev_prefix"
826 HV_REBOOT_BEHAVIOR = "reboot_behavior"
827 HV_CPU_TYPE = "cpu_type"
828 HV_CPU_CAP = "cpu_cap"
829 HV_CPU_WEIGHT = "cpu_weight"
830 HV_CPU_CORES = "cpu_cores"
831 HV_CPU_THREADS = "cpu_threads"
832 HV_CPU_SOCKETS = "cpu_sockets"
833 HV_SOUNDHW = "soundhw"
834 HV_USB_DEVICES = "usb_devices"
836 HV_KVM_EXTRA = "kvm_extra"
837 HV_KVM_MACHINE_VERSION = "machine_version"
838 HV_KVM_PATH = "kvm_path"
841 HVS_PARAMETER_TYPES = {
842 HV_KVM_PATH: VTYPE_STRING,
843 HV_BOOT_ORDER: VTYPE_STRING,
844 HV_KVM_FLOPPY_IMAGE_PATH: VTYPE_STRING,
845 HV_CDROM_IMAGE_PATH: VTYPE_STRING,
846 HV_KVM_CDROM2_IMAGE_PATH: VTYPE_STRING,
847 HV_NIC_TYPE: VTYPE_STRING,
848 HV_DISK_TYPE: VTYPE_STRING,
849 HV_KVM_CDROM_DISK_TYPE: VTYPE_STRING,
850 HV_VNC_PASSWORD_FILE: VTYPE_STRING,
851 HV_VNC_BIND_ADDRESS: VTYPE_STRING,
852 HV_VNC_TLS: VTYPE_BOOL,
853 HV_VNC_X509: VTYPE_STRING,
854 HV_VNC_X509_VERIFY: VTYPE_BOOL,
855 HV_KVM_SPICE_BIND: VTYPE_STRING,
856 HV_KVM_SPICE_IP_VERSION: VTYPE_INT,
857 HV_KVM_SPICE_PASSWORD_FILE: VTYPE_STRING,
858 HV_KVM_SPICE_LOSSLESS_IMG_COMPR: VTYPE_STRING,
859 HV_KVM_SPICE_JPEG_IMG_COMPR: VTYPE_STRING,
860 HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR: VTYPE_STRING,
861 HV_KVM_SPICE_STREAMING_VIDEO_DETECTION: VTYPE_STRING,
862 HV_KVM_SPICE_AUDIO_COMPR: VTYPE_BOOL,
863 HV_KVM_SPICE_USE_TLS: VTYPE_BOOL,
864 HV_KVM_SPICE_TLS_CIPHERS: VTYPE_STRING,
865 HV_KVM_SPICE_USE_VDAGENT: VTYPE_BOOL,
868 HV_USE_BOOTLOADER: VTYPE_BOOL,
869 HV_BOOTLOADER_PATH: VTYPE_STRING,
870 HV_BOOTLOADER_ARGS: VTYPE_STRING,
871 HV_KERNEL_PATH: VTYPE_STRING,
872 HV_KERNEL_ARGS: VTYPE_STRING,
873 HV_INITRD_PATH: VTYPE_STRING,
874 HV_ROOT_PATH: VTYPE_MAYBE_STRING,
875 HV_SERIAL_CONSOLE: VTYPE_BOOL,
876 HV_SERIAL_SPEED: VTYPE_INT,
877 HV_USB_MOUSE: VTYPE_STRING,
878 HV_KEYMAP: VTYPE_STRING,
879 HV_DEVICE_MODEL: VTYPE_STRING,
880 HV_INIT_SCRIPT: VTYPE_STRING,
881 HV_MIGRATION_PORT: VTYPE_INT,
882 HV_MIGRATION_BANDWIDTH: VTYPE_INT,
883 HV_MIGRATION_DOWNTIME: VTYPE_INT,
884 HV_MIGRATION_MODE: VTYPE_STRING,
885 HV_USE_LOCALTIME: VTYPE_BOOL,
886 HV_DISK_CACHE: VTYPE_STRING,
887 HV_SECURITY_MODEL: VTYPE_STRING,
888 HV_SECURITY_DOMAIN: VTYPE_STRING,
889 HV_KVM_FLAG: VTYPE_STRING,
890 HV_VHOST_NET: VTYPE_BOOL,
891 HV_KVM_USE_CHROOT: VTYPE_BOOL,
892 HV_CPU_MASK: VTYPE_STRING,
893 HV_MEM_PATH: VTYPE_STRING,
894 HV_PASSTHROUGH: VTYPE_STRING,
895 HV_BLOCKDEV_PREFIX: VTYPE_STRING,
896 HV_REBOOT_BEHAVIOR: VTYPE_STRING,
897 HV_CPU_TYPE: VTYPE_STRING,
898 HV_CPU_CAP: VTYPE_INT,
899 HV_CPU_WEIGHT: VTYPE_INT,
900 HV_CPU_CORES: VTYPE_INT,
901 HV_CPU_THREADS: VTYPE_INT,
902 HV_CPU_SOCKETS: VTYPE_INT,
903 HV_SOUNDHW: VTYPE_STRING,
904 HV_USB_DEVICES: VTYPE_STRING,
905 HV_VGA: VTYPE_STRING,
906 HV_KVM_EXTRA: VTYPE_STRING,
907 HV_KVM_MACHINE_VERSION: VTYPE_STRING,
910 HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
912 HVS_PARAMETER_TITLES = {
914 HV_BOOT_ORDER: "Boot_order",
915 HV_CDROM_IMAGE_PATH: "CDROM_image_path",
916 HV_DISK_TYPE: "Disk_type",
917 HV_INITRD_PATH: "Initrd_path",
918 HV_KERNEL_PATH: "Kernel_path",
919 HV_NIC_TYPE: "NIC_type",
921 HV_VNC_BIND_ADDRESS: "VNC_bind_address",
922 HV_PASSTHROUGH: "pci_pass",
923 HV_CPU_TYPE: "cpu_type",
927 HV_MIGRATION_COMPLETED = "completed"
928 HV_MIGRATION_ACTIVE = "active"
929 HV_MIGRATION_FAILED = "failed"
930 HV_MIGRATION_CANCELLED = "cancelled"
932 HV_MIGRATION_VALID_STATUSES = compat.UniqueFrozenset([
933 HV_MIGRATION_COMPLETED,
936 HV_MIGRATION_CANCELLED,
939 HV_MIGRATION_FAILED_STATUSES = compat.UniqueFrozenset([
941 HV_MIGRATION_CANCELLED,
944 # KVM-specific statuses
945 HV_KVM_MIGRATION_VALID_STATUSES = HV_MIGRATION_VALID_STATUSES
948 HV_NODEINFO_KEY_VERSION = "hv_version"
951 HVST_MEMORY_TOTAL = "mem_total"
952 HVST_MEMORY_NODE = "mem_node"
953 HVST_MEMORY_HV = "mem_hv"
954 HVST_CPU_TOTAL = "cpu_total"
955 HVST_CPU_NODE = "cpu_node"
958 HVST_MEMORY_TOTAL: 0,
965 HVSTS_PARAMETER_TYPES = {
966 HVST_MEMORY_TOTAL: VTYPE_INT,
967 HVST_MEMORY_NODE: VTYPE_INT,
968 HVST_MEMORY_HV: VTYPE_INT,
969 HVST_CPU_TOTAL: VTYPE_INT,
970 HVST_CPU_NODE: VTYPE_INT,
973 HVSTS_PARAMETERS = frozenset(HVSTS_PARAMETER_TYPES.keys())
976 DS_DISK_TOTAL = "disk_total"
977 DS_DISK_RESERVED = "disk_reserved"
978 DS_DISK_OVERHEAD = "disk_overhead"
986 DSS_PARAMETER_TYPES = {
987 DS_DISK_TOTAL: VTYPE_INT,
988 DS_DISK_RESERVED: VTYPE_INT,
989 DS_DISK_OVERHEAD: VTYPE_INT,
992 DSS_PARAMETERS = frozenset(DSS_PARAMETER_TYPES.keys())
993 DS_VALID_TYPES = compat.UniqueFrozenset([LD_LV])
995 # Backend parameter names
996 BE_MEMORY = "memory" # deprecated and replaced by max and min mem
1000 BE_AUTO_BALANCE = "auto_balance"
1001 BE_ALWAYS_FAILOVER = "always_failover"
1002 BE_SPINDLE_USE = "spindle_use"
1004 BES_PARAMETER_TYPES = {
1005 BE_MAXMEM: VTYPE_SIZE,
1006 BE_MINMEM: VTYPE_SIZE,
1007 BE_VCPUS: VTYPE_INT,
1008 BE_AUTO_BALANCE: VTYPE_BOOL,
1009 BE_ALWAYS_FAILOVER: VTYPE_BOOL,
1010 BE_SPINDLE_USE: VTYPE_INT,
1013 BES_PARAMETER_TITLES = {
1014 BE_AUTO_BALANCE: "Auto_balance",
1015 BE_MAXMEM: "ConfigMaxMem",
1016 BE_MINMEM: "ConfigMinMem",
1017 BE_VCPUS: "ConfigVCPUs",
1020 BES_PARAMETER_COMPAT = {
1021 BE_MEMORY: VTYPE_SIZE,
1023 BES_PARAMETER_COMPAT.update(BES_PARAMETER_TYPES)
1025 BES_PARAMETERS = frozenset(BES_PARAMETER_TYPES.keys())
1028 ISPEC_MEM_SIZE = "memory-size"
1029 ISPEC_CPU_COUNT = "cpu-count"
1030 ISPEC_DISK_COUNT = "disk-count"
1031 ISPEC_DISK_SIZE = "disk-size"
1032 ISPEC_NIC_COUNT = "nic-count"
1033 ISPEC_SPINDLE_USE = "spindle-use"
1035 ISPECS_PARAMETER_TYPES = {
1036 ISPEC_MEM_SIZE: VTYPE_INT,
1037 ISPEC_CPU_COUNT: VTYPE_INT,
1038 ISPEC_DISK_COUNT: VTYPE_INT,
1039 ISPEC_DISK_SIZE: VTYPE_INT,
1040 ISPEC_NIC_COUNT: VTYPE_INT,
1041 ISPEC_SPINDLE_USE: VTYPE_INT,
1044 ISPECS_PARAMETERS = frozenset(ISPECS_PARAMETER_TYPES.keys())
1049 IPOLICY_DTS = "disk-templates"
1050 IPOLICY_VCPU_RATIO = "vcpu-ratio"
1051 IPOLICY_SPINDLE_RATIO = "spindle-ratio"
1053 IPOLICY_ISPECS = compat.UniqueFrozenset([
1059 IPOLICY_PARAMETERS = compat.UniqueFrozenset([
1061 IPOLICY_SPINDLE_RATIO,
1064 IPOLICY_ALL_KEYS = (IPOLICY_ISPECS |
1065 IPOLICY_PARAMETERS |
1066 frozenset([IPOLICY_DTS]))
1068 # Node parameter names
1069 ND_OOB_PROGRAM = "oob_program"
1070 ND_SPINDLE_COUNT = "spindle_count"
1071 ND_EXCLUSIVE_STORAGE = "exclusive_storage"
1073 NDS_PARAMETER_TYPES = {
1074 ND_OOB_PROGRAM: VTYPE_STRING,
1075 ND_SPINDLE_COUNT: VTYPE_INT,
1076 ND_EXCLUSIVE_STORAGE: VTYPE_BOOL,
1079 NDS_PARAMETERS = frozenset(NDS_PARAMETER_TYPES.keys())
1081 NDS_PARAMETER_TITLES = {
1082 ND_OOB_PROGRAM: "OutOfBandProgram",
1083 ND_SPINDLE_COUNT: "SpindleCount",
1084 ND_EXCLUSIVE_STORAGE: "ExclusiveStorage",
1087 # Logical Disks parameters
1088 LDP_RESYNC_RATE = "resync-rate"
1089 LDP_STRIPES = "stripes"
1090 LDP_BARRIERS = "disabled-barriers"
1091 LDP_NO_META_FLUSH = "disable-meta-flush"
1092 LDP_DEFAULT_METAVG = "default-metavg"
1093 LDP_DISK_CUSTOM = "disk-custom"
1094 LDP_NET_CUSTOM = "net-custom"
1095 LDP_DYNAMIC_RESYNC = "dynamic-resync"
1096 LDP_PLAN_AHEAD = "c-plan-ahead"
1097 LDP_FILL_TARGET = "c-fill-target"
1098 LDP_DELAY_TARGET = "c-delay-target"
1099 LDP_MAX_RATE = "c-max-rate"
1100 LDP_MIN_RATE = "c-min-rate"
1103 LDP_RESYNC_RATE: VTYPE_INT,
1104 LDP_STRIPES: VTYPE_INT,
1105 LDP_BARRIERS: VTYPE_STRING,
1106 LDP_NO_META_FLUSH: VTYPE_BOOL,
1107 LDP_DEFAULT_METAVG: VTYPE_STRING,
1108 LDP_DISK_CUSTOM: VTYPE_STRING,
1109 LDP_NET_CUSTOM: VTYPE_STRING,
1110 LDP_DYNAMIC_RESYNC: VTYPE_BOOL,
1111 LDP_PLAN_AHEAD: VTYPE_INT,
1112 LDP_FILL_TARGET: VTYPE_INT,
1113 LDP_DELAY_TARGET: VTYPE_INT,
1114 LDP_MAX_RATE: VTYPE_INT,
1115 LDP_MIN_RATE: VTYPE_INT,
1116 LDP_POOL: VTYPE_STRING,
1118 DISK_LD_PARAMETERS = frozenset(DISK_LD_TYPES.keys())
1120 # Disk template parameters (can be set/changed by the user via gnt-cluster and
1122 DRBD_RESYNC_RATE = "resync-rate"
1123 DRBD_DATA_STRIPES = "data-stripes"
1124 DRBD_META_STRIPES = "meta-stripes"
1125 DRBD_DISK_BARRIERS = "disk-barriers"
1126 DRBD_META_BARRIERS = "meta-barriers"
1127 DRBD_DEFAULT_METAVG = "metavg"
1128 DRBD_DISK_CUSTOM = "disk-custom"
1129 DRBD_NET_CUSTOM = "net-custom"
1130 DRBD_DYNAMIC_RESYNC = "dynamic-resync"
1131 DRBD_PLAN_AHEAD = "c-plan-ahead"
1132 DRBD_FILL_TARGET = "c-fill-target"
1133 DRBD_DELAY_TARGET = "c-delay-target"
1134 DRBD_MAX_RATE = "c-max-rate"
1135 DRBD_MIN_RATE = "c-min-rate"
1136 LV_STRIPES = "stripes"
1139 DRBD_RESYNC_RATE: VTYPE_INT,
1140 DRBD_DATA_STRIPES: VTYPE_INT,
1141 DRBD_META_STRIPES: VTYPE_INT,
1142 DRBD_DISK_BARRIERS: VTYPE_STRING,
1143 DRBD_META_BARRIERS: VTYPE_BOOL,
1144 DRBD_DEFAULT_METAVG: VTYPE_STRING,
1145 DRBD_DISK_CUSTOM: VTYPE_STRING,
1146 DRBD_NET_CUSTOM: VTYPE_STRING,
1147 DRBD_DYNAMIC_RESYNC: VTYPE_BOOL,
1148 DRBD_PLAN_AHEAD: VTYPE_INT,
1149 DRBD_FILL_TARGET: VTYPE_INT,
1150 DRBD_DELAY_TARGET: VTYPE_INT,
1151 DRBD_MAX_RATE: VTYPE_INT,
1152 DRBD_MIN_RATE: VTYPE_INT,
1153 LV_STRIPES: VTYPE_INT,
1154 RBD_POOL: VTYPE_STRING,
1157 DISK_DT_PARAMETERS = frozenset(DISK_DT_TYPES.keys())
1159 # OOB supported commands
1160 OOB_POWER_ON = "power-on"
1161 OOB_POWER_OFF = "power-off"
1162 OOB_POWER_CYCLE = "power-cycle"
1163 OOB_POWER_STATUS = "power-status"
1164 OOB_HEALTH = "health"
1166 OOB_COMMANDS = compat.UniqueFrozenset([
1174 OOB_POWER_STATUS_POWERED = "powered"
1176 OOB_TIMEOUT = 60 # 60 seconds
1177 OOB_POWER_DELAY = 2.0 # 2 seconds
1179 OOB_STATUS_OK = "OK"
1180 OOB_STATUS_WARNING = "WARNING"
1181 OOB_STATUS_CRITICAL = "CRITICAL"
1182 OOB_STATUS_UNKNOWN = "UNKNOWN"
1184 OOB_STATUSES = compat.UniqueFrozenset([
1187 OOB_STATUS_CRITICAL,
1191 # Instance Parameters Profile
1192 PP_DEFAULT = "default"
1194 # NIC_* constants are used inside the ganeti config
1198 NIC_MODE_BRIDGED = "bridged"
1199 NIC_MODE_ROUTED = "routed"
1200 NIC_MODE_OVS = "openvswitch"
1201 NIC_IP_POOL = "pool"
1203 NIC_VALID_MODES = compat.UniqueFrozenset([
1209 RESERVE_ACTION = "reserve"
1210 RELEASE_ACTION = "release"
1212 # An extra description of the network.
1213 # Can be used by hooks/kvm-vif-bridge to apply different rules
1214 NETWORK_TYPE_PRIVATE = "private"
1215 NETWORK_TYPE_PUBLIC = "public"
1217 NETWORK_VALID_TYPES = compat.UniqueFrozenset([
1218 NETWORK_TYPE_PRIVATE,
1219 NETWORK_TYPE_PUBLIC,
1222 NICS_PARAMETER_TYPES = {
1223 NIC_MODE: VTYPE_STRING,
1224 NIC_LINK: VTYPE_STRING,
1227 NICS_PARAMETERS = frozenset(NICS_PARAMETER_TYPES.keys())
1229 # IDISK_* constants are used in opcodes, to create/change disks
1232 IDISK_ADOPT = "adopt"
1234 IDISK_METAVG = "metavg"
1235 IDISK_PROVIDER = "provider"
1236 IDISK_PARAMS_TYPES = {
1237 IDISK_SIZE: VTYPE_SIZE,
1238 IDISK_MODE: VTYPE_STRING,
1239 IDISK_ADOPT: VTYPE_STRING,
1240 IDISK_VG: VTYPE_STRING,
1241 IDISK_METAVG: VTYPE_STRING,
1242 IDISK_PROVIDER: VTYPE_STRING,
1244 IDISK_PARAMS = frozenset(IDISK_PARAMS_TYPES.keys())
1246 # INIC_* constants are used in opcodes, to create/change nics
1251 INIC_NETWORK = "network"
1252 INIC_PARAMS_TYPES = {
1253 INIC_IP: VTYPE_MAYBE_STRING,
1254 INIC_LINK: VTYPE_STRING,
1255 INIC_MAC: VTYPE_STRING,
1256 INIC_MODE: VTYPE_STRING,
1257 INIC_NETWORK: VTYPE_MAYBE_STRING,
1259 INIC_PARAMS = frozenset(INIC_PARAMS_TYPES.keys())
1261 # Hypervisor constants
1262 HT_XEN_PVM = "xen-pvm"
1264 HT_XEN_HVM = "xen-hvm"
1266 HT_CHROOT = "chroot"
1268 HYPER_TYPES = compat.UniqueFrozenset([
1276 HTS_REQ_PORT = compat.UniqueFrozenset([HT_XEN_HVM, HT_KVM])
1278 VNC_BASE_PORT = 5900
1279 VNC_DEFAULT_BIND_ADDRESS = IP4_ADDRESS_ANY
1282 HT_NIC_RTL8139 = "rtl8139"
1283 HT_NIC_NE2K_PCI = "ne2k_pci"
1284 HT_NIC_NE2K_ISA = "ne2k_isa"
1285 HT_NIC_I82551 = "i82551"
1286 HT_NIC_I85557B = "i82557b"
1287 HT_NIC_I8259ER = "i82559er"
1288 HT_NIC_PCNET = "pcnet"
1289 HT_NIC_E1000 = "e1000"
1290 HT_NIC_PARAVIRTUAL = HT_DISK_PARAVIRTUAL = "paravirtual"
1292 HT_HVM_VALID_NIC_TYPES = compat.UniqueFrozenset([
1299 HT_KVM_VALID_NIC_TYPES = compat.UniqueFrozenset([
1312 HT_DISK_IOEMU = "ioemu"
1314 HT_DISK_SCSI = "scsi"
1317 HT_DISK_PFLASH = "pflash"
1319 HT_CACHE_DEFAULT = "default"
1320 HT_CACHE_NONE = "none"
1321 HT_CACHE_WTHROUGH = "writethrough"
1322 HT_CACHE_WBACK = "writeback"
1323 HT_VALID_CACHE_TYPES = compat.UniqueFrozenset([
1330 HT_HVM_VALID_DISK_TYPES = compat.UniqueFrozenset([
1331 HT_DISK_PARAVIRTUAL,
1334 HT_KVM_VALID_DISK_TYPES = compat.UniqueFrozenset([
1335 HT_DISK_PARAVIRTUAL,
1344 HT_MOUSE_MOUSE = "mouse"
1345 HT_MOUSE_TABLET = "tablet"
1347 HT_KVM_VALID_MOUSE_TYPES = compat.UniqueFrozenset([
1353 HT_BO_FLOPPY = "floppy"
1354 HT_BO_CDROM = "cdrom"
1356 HT_BO_NETWORK = "network"
1358 HT_KVM_VALID_BO_TYPES = compat.UniqueFrozenset([
1365 # SPICE lossless image compression options
1366 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ = "auto_glz"
1367 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ = "auto_lz"
1368 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC = "quic"
1369 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ = "glz"
1370 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ = "lz"
1371 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF = "off"
1373 HT_KVM_SPICE_VALID_LOSSLESS_IMG_COMPR_OPTIONS = compat.UniqueFrozenset([
1374 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ,
1375 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ,
1376 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC,
1377 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ,
1378 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ,
1379 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF,
1382 # SPICE lossy image compression options (valid for both jpeg and zlib-glz)
1383 HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO = "auto"
1384 HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER = "never"
1385 HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS = "always"
1387 HT_KVM_SPICE_VALID_LOSSY_IMG_COMPR_OPTIONS = compat.UniqueFrozenset([
1388 HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO,
1389 HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER,
1390 HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS,
1393 # SPICE video stream detection
1394 HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF = "off"
1395 HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL = "all"
1396 HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER = "filter"
1398 HT_KVM_SPICE_VALID_VIDEO_STREAM_DETECTION_OPTIONS = compat.UniqueFrozenset([
1399 HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF,
1400 HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL,
1401 HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER,
1409 HT_KVM_VALID_SM_TYPES = compat.UniqueFrozenset([
1416 HT_KVM_ENABLED = "enabled"
1417 HT_KVM_DISABLED = "disabled"
1419 HT_KVM_FLAG_VALUES = compat.UniqueFrozenset([HT_KVM_ENABLED, HT_KVM_DISABLED])
1422 HT_MIGRATION_LIVE = "live"
1423 HT_MIGRATION_NONLIVE = "non-live"
1424 HT_MIGRATION_MODES = compat.UniqueFrozenset([
1426 HT_MIGRATION_NONLIVE,
1429 # Cluster Verify steps
1430 VERIFY_NPLUSONE_MEM = "nplusone_mem"
1431 VERIFY_OPTIONAL_CHECKS = compat.UniqueFrozenset([VERIFY_NPLUSONE_MEM])
1433 # Cluster Verify error classes
1434 CV_TCLUSTER = "cluster"
1437 CV_TINSTANCE = "instance"
1439 # Cluster Verify error codes and documentation
1441 (CV_TCLUSTER, "ECLUSTERCFG", "Cluster configuration verification failure")
1443 (CV_TCLUSTER, "ECLUSTERCERT",
1444 "Cluster certificate files verification failure")
1445 CV_ECLUSTERFILECHECK = \
1446 (CV_TCLUSTER, "ECLUSTERFILECHECK",
1447 "Cluster configuration verification failure")
1448 CV_ECLUSTERDANGLINGNODES = \
1449 (CV_TNODE, "ECLUSTERDANGLINGNODES",
1450 "Some nodes belong to non-existing groups")
1451 CV_ECLUSTERDANGLINGINST = \
1452 (CV_TNODE, "ECLUSTERDANGLINGINST",
1453 "Some instances have a non-existing primary node")
1454 CV_EGROUPMIXEDESFLAG = \
1455 (CV_TGROUP, "EGROUPMIXEDESFLAG",
1456 "exclusive_storage flag is not uniform within the group")
1457 CV_EINSTANCEBADNODE = \
1458 (CV_TINSTANCE, "EINSTANCEBADNODE",
1459 "Instance marked as running lives on an offline node")
1460 CV_EINSTANCEDOWN = \
1461 (CV_TINSTANCE, "EINSTANCEDOWN", "Instance not running on its primary node")
1462 CV_EINSTANCELAYOUT = \
1463 (CV_TINSTANCE, "EINSTANCELAYOUT", "Instance has multiple secondary nodes")
1464 CV_EINSTANCEMISSINGDISK = \
1465 (CV_TINSTANCE, "EINSTANCEMISSINGDISK", "Missing volume on an instance")
1466 CV_EINSTANCEFAULTYDISK = \
1467 (CV_TINSTANCE, "EINSTANCEFAULTYDISK",
1468 "Impossible to retrieve status for a disk")
1469 CV_EINSTANCEWRONGNODE = \
1470 (CV_TINSTANCE, "EINSTANCEWRONGNODE", "Instance running on the wrong node")
1471 CV_EINSTANCESPLITGROUPS = \
1472 (CV_TINSTANCE, "EINSTANCESPLITGROUPS",
1473 "Instance with primary and secondary nodes in different groups")
1474 CV_EINSTANCEPOLICY = \
1475 (CV_TINSTANCE, "EINSTANCEPOLICY",
1476 "Instance does not meet policy")
1478 (CV_TNODE, "ENODEDRBD", "Error parsing the DRBD status file")
1479 CV_ENODEDRBDHELPER = \
1480 (CV_TNODE, "ENODEDRBDHELPER", "Error caused by the DRBD helper")
1481 CV_ENODEFILECHECK = \
1482 (CV_TNODE, "ENODEFILECHECK",
1483 "Error retrieving the checksum of the node files")
1485 (CV_TNODE, "ENODEHOOKS", "Communication failure in hooks execution")
1487 (CV_TNODE, "ENODEHV", "Hypervisor parameters verification failure")
1489 (CV_TNODE, "ENODELVM", "LVM-related node error")
1491 (CV_TNODE, "ENODEN1", "Not enough memory to accommodate instance failovers")
1493 (CV_TNODE, "ENODENET", "Network-related node error")
1495 (CV_TNODE, "ENODEOS", "OS-related node error")
1496 CV_ENODEORPHANINSTANCE = \
1497 (CV_TNODE, "ENODEORPHANINSTANCE", "Unknown intance running on a node")
1498 CV_ENODEORPHANLV = \
1499 (CV_TNODE, "ENODEORPHANLV", "Unknown LVM logical volume")
1501 (CV_TNODE, "ENODERPC",
1502 "Error during connection to the primary node of an instance")
1504 (CV_TNODE, "ENODESSH", "SSH-related node error")
1506 (CV_TNODE, "ENODEVERSION",
1507 "Protocol version mismatch or Ganeti version mismatch")
1509 (CV_TNODE, "ENODESETUP", "Node setup error")
1511 (CV_TNODE, "ENODETIME", "Node returned invalid time")
1513 (CV_TNODE, "ENODEOOBPATH", "Invalid Out Of Band path")
1514 CV_ENODEUSERSCRIPTS = \
1515 (CV_TNODE, "ENODEUSERSCRIPTS", "User scripts not present or not executable")
1516 CV_ENODEFILESTORAGEPATHS = \
1517 (CV_TNODE, "ENODEFILESTORAGEPATHS", "Detected bad file storage paths")
1519 CV_ALL_ECODES = compat.UniqueFrozenset([
1522 CV_ECLUSTERFILECHECK,
1523 CV_ECLUSTERDANGLINGNODES,
1524 CV_ECLUSTERDANGLINGINST,
1525 CV_EINSTANCEBADNODE,
1528 CV_EINSTANCEMISSINGDISK,
1529 CV_EINSTANCEFAULTYDISK,
1530 CV_EINSTANCEWRONGNODE,
1531 CV_EINSTANCESPLITGROUPS,
1542 CV_ENODEORPHANINSTANCE,
1550 CV_ENODEUSERSCRIPTS,
1551 CV_ENODEFILESTORAGEPATHS,
1554 CV_ALL_ECODES_STRINGS = \
1555 compat.UniqueFrozenset(estr for (_, estr, _) in CV_ALL_ECODES)
1557 # Node verify constants
1558 NV_BRIDGES = "bridges"
1559 NV_DRBDHELPER = "drbd-helper"
1560 NV_DRBDLIST = "drbd-list"
1561 NV_FILELIST = "filelist"
1562 NV_FILE_STORAGE_PATHS = "file-storage-paths"
1563 NV_HVINFO = "hvinfo"
1564 NV_HVPARAMS = "hvparms"
1565 NV_HYPERVISOR = "hypervisor"
1566 NV_INSTANCELIST = "instancelist"
1567 NV_LVLIST = "lvlist"
1568 NV_MASTERIP = "master-ip"
1569 NV_NODELIST = "nodelist"
1570 NV_NODENETTEST = "node-net-test"
1571 NV_NODESETUP = "nodesetup"
1572 NV_OOB_PATHS = "oob-paths"
1573 NV_OSLIST = "oslist"
1574 NV_PVLIST = "pvlist"
1576 NV_USERSCRIPTS = "user-scripts"
1577 NV_VERSION = "version"
1578 NV_VGLIST = "vglist"
1579 NV_VMNODES = "vmnodes"
1582 INSTST_RUNNING = "running"
1583 INSTST_ADMINDOWN = "ADMIN_down"
1584 INSTST_ADMINOFFLINE = "ADMIN_offline"
1585 INSTST_NODEOFFLINE = "ERROR_nodeoffline"
1586 INSTST_NODEDOWN = "ERROR_nodedown"
1587 INSTST_WRONGNODE = "ERROR_wrongnode"
1588 INSTST_ERRORUP = "ERROR_up"
1589 INSTST_ERRORDOWN = "ERROR_down"
1590 INSTST_ALL = compat.UniqueFrozenset([
1593 INSTST_ADMINOFFLINE,
1603 ADMINST_DOWN = "down"
1604 ADMINST_OFFLINE = "offline"
1605 ADMINST_ALL = compat.UniqueFrozenset([
1617 NR_ALL = compat.UniqueFrozenset([
1625 # SSL certificate check constants (in days)
1626 SSL_CERT_EXPIRATION_WARN = 30
1627 SSL_CERT_EXPIRATION_ERROR = 7
1629 # Allocator framework constants
1630 IALLOCATOR_VERSION = 2
1631 IALLOCATOR_DIR_IN = "in"
1632 IALLOCATOR_DIR_OUT = "out"
1633 VALID_IALLOCATOR_DIRECTIONS = compat.UniqueFrozenset([
1637 IALLOCATOR_MODE_ALLOC = "allocate"
1638 IALLOCATOR_MODE_RELOC = "relocate"
1639 IALLOCATOR_MODE_CHG_GROUP = "change-group"
1640 IALLOCATOR_MODE_NODE_EVAC = "node-evacuate"
1641 IALLOCATOR_MODE_MULTI_ALLOC = "multi-allocate"
1642 VALID_IALLOCATOR_MODES = compat.UniqueFrozenset([
1643 IALLOCATOR_MODE_ALLOC,
1644 IALLOCATOR_MODE_RELOC,
1645 IALLOCATOR_MODE_CHG_GROUP,
1646 IALLOCATOR_MODE_NODE_EVAC,
1647 IALLOCATOR_MODE_MULTI_ALLOC,
1649 IALLOCATOR_SEARCH_PATH = _autoconf.IALLOCATOR_SEARCH_PATH
1650 DEFAULT_IALLOCATOR_SHORTCUT = "."
1652 IALLOCATOR_NEVAC_PRI = "primary-only"
1653 IALLOCATOR_NEVAC_SEC = "secondary-only"
1654 IALLOCATOR_NEVAC_ALL = "all"
1655 IALLOCATOR_NEVAC_MODES = compat.UniqueFrozenset([
1656 IALLOCATOR_NEVAC_PRI,
1657 IALLOCATOR_NEVAC_SEC,
1658 IALLOCATOR_NEVAC_ALL,
1662 NODE_EVAC_PRI = "primary-only"
1663 NODE_EVAC_SEC = "secondary-only"
1664 NODE_EVAC_ALL = "all"
1665 NODE_EVAC_MODES = compat.UniqueFrozenset([
1672 JOB_QUEUE_VERSION = 1
1673 JOB_QUEUE_SIZE_HARD_LIMIT = 5000
1675 JOB_ID_TEMPLATE = r"\d+"
1676 JOB_FILE_RE = re.compile(r"^job-(%s)$" % JOB_ID_TEMPLATE)
1678 # unchanged job return
1679 JOB_NOTCHANGED = "nochange"
1682 JOB_STATUS_QUEUED = "queued"
1683 JOB_STATUS_WAITING = "waiting"
1684 JOB_STATUS_CANCELING = "canceling"
1685 JOB_STATUS_RUNNING = "running"
1686 JOB_STATUS_CANCELED = "canceled"
1687 JOB_STATUS_SUCCESS = "success"
1688 JOB_STATUS_ERROR = "error"
1689 JOBS_PENDING = compat.UniqueFrozenset([
1692 JOB_STATUS_CANCELING,
1694 JOBS_FINALIZED = compat.UniqueFrozenset([
1695 JOB_STATUS_CANCELED,
1699 JOB_STATUS_ALL = compat.UniqueFrozenset([
1701 ]) | JOBS_PENDING | JOBS_FINALIZED
1705 OP_STATUS_QUEUED = "queued"
1706 OP_STATUS_WAITING = "waiting"
1707 OP_STATUS_CANCELING = "canceling"
1708 OP_STATUS_RUNNING = "running"
1710 OP_STATUS_CANCELED = "canceled"
1711 OP_STATUS_SUCCESS = "success"
1712 OP_STATUS_ERROR = "error"
1713 OPS_FINALIZED = compat.UniqueFrozenset([
1720 OP_PRIO_LOWEST = +19
1721 OP_PRIO_HIGHEST = -20
1727 OP_PRIO_SUBMIT_VALID = compat.UniqueFrozenset([
1733 OP_PRIO_DEFAULT = OP_PRIO_NORMAL
1735 # Lock recalculate mode
1736 LOCKS_REPLACE = "replace"
1737 LOCKS_APPEND = "append"
1739 # Lock timeout (sum) before we should go into blocking acquire (still
1740 # can be reset by priority change); computed as max time (10 hours)
1741 # before we should actually go into blocking acquire given that we
1742 # start from default priority level; in seconds
1744 LOCK_ATTEMPTS_TIMEOUT = 10 * 3600 / (OP_PRIO_DEFAULT - OP_PRIO_HIGHEST)
1745 LOCK_ATTEMPTS_MAXWAIT = 15.0
1746 LOCK_ATTEMPTS_MINWAIT = 1.0
1748 # Execution log types
1749 ELOG_MESSAGE = "message"
1750 ELOG_REMOTE_IMPORT = "remote-import"
1751 ELOG_JQUEUE_TEST = "jqueue-test"
1753 # /etc/hosts modification
1754 ETC_HOSTS_ADD = "add"
1755 ETC_HOSTS_REMOVE = "remove"
1758 JQT_MSGPREFIX = "TESTMSG="
1759 JQT_EXPANDNAMES = "expandnames"
1761 JQT_LOGMSG = "logmsg"
1762 JQT_STARTMSG = "startmsg"
1763 JQT_ALL = compat.UniqueFrozenset([
1771 QR_CLUSTER = "cluster"
1772 QR_INSTANCE = "instance"
1778 QR_EXPORT = "export"
1779 QR_NETWORK = "network"
1780 QR_EXTSTORAGE = "extstorage"
1782 #: List of resources which can be queried using L{opcodes.OpQuery}
1783 QR_VIA_OP = compat.UniqueFrozenset([
1794 #: List of resources which can be queried using Local UniX Interface
1795 QR_VIA_LUXI = QR_VIA_OP.union([
1800 #: List of resources which can be queried using RAPI
1801 QR_VIA_RAPI = QR_VIA_LUXI
1804 QFT_UNKNOWN = "unknown"
1807 QFT_NUMBER = "number"
1809 QFT_TIMESTAMP = "timestamp"
1812 #: All query field types
1813 QFT_ALL = compat.UniqueFrozenset([
1823 # Query result field status (don't change or reuse values as they're used by
1825 #: Normal field status
1829 #: No data (e.g. RPC error), can be used instead of L{RS_OFFLINE}
1831 #: Value unavailable/unsupported for item; if this field is supported
1832 #: but we cannot get the data for the moment, RS_NODATA or
1833 #: RS_OFFLINE should be used
1835 #: Resource marked offline
1838 RS_ALL = compat.UniqueFrozenset([
1846 #: Dictionary with special field cases and their verbose/terse formatting
1848 RS_UNKNOWN: ("(unknown)", "??"),
1849 RS_NODATA: ("(nodata)", "?"),
1850 RS_OFFLINE: ("(offline)", "*"),
1851 RS_UNAVAIL: ("(unavail)", "-"),
1854 # max dynamic devices
1858 # SSCONF file prefix
1859 SSCONF_FILEPREFIX = "ssconf_"
1861 SS_CLUSTER_NAME = "cluster_name"
1862 SS_CLUSTER_TAGS = "cluster_tags"
1863 SS_FILE_STORAGE_DIR = "file_storage_dir"
1864 SS_SHARED_FILE_STORAGE_DIR = "shared_file_storage_dir"
1865 SS_MASTER_CANDIDATES = "master_candidates"
1866 SS_MASTER_CANDIDATES_IPS = "master_candidates_ips"
1867 SS_MASTER_IP = "master_ip"
1868 SS_MASTER_NETDEV = "master_netdev"
1869 SS_MASTER_NETMASK = "master_netmask"
1870 SS_MASTER_NODE = "master_node"
1871 SS_NODE_LIST = "node_list"
1872 SS_NODE_PRIMARY_IPS = "node_primary_ips"
1873 SS_NODE_SECONDARY_IPS = "node_secondary_ips"
1874 SS_OFFLINE_NODES = "offline_nodes"
1875 SS_ONLINE_NODES = "online_nodes"
1876 SS_PRIMARY_IP_FAMILY = "primary_ip_family"
1877 SS_INSTANCE_LIST = "instance_list"
1878 SS_RELEASE_VERSION = "release_version"
1879 SS_HYPERVISOR_LIST = "hypervisor_list"
1880 SS_MAINTAIN_NODE_HEALTH = "maintain_node_health"
1881 SS_UID_POOL = "uid_pool"
1882 SS_NODEGROUPS = "nodegroups"
1883 SS_NETWORKS = "networks"
1885 SS_FILE_PERMS = 0444
1887 # cluster wide default parameters
1888 DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM
1892 HV_USE_BOOTLOADER: False,
1893 HV_BOOTLOADER_PATH: XEN_BOOTLOADER,
1894 HV_BOOTLOADER_ARGS: "",
1895 HV_KERNEL_PATH: XEN_KERNEL,
1897 HV_ROOT_PATH: "/dev/sda1",
1898 HV_KERNEL_ARGS: "ro",
1899 HV_MIGRATION_PORT: 8002,
1900 HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1901 HV_BLOCKDEV_PREFIX: "sd",
1902 HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1903 HV_CPU_MASK: CPU_PINNING_ALL,
1908 HV_BOOT_ORDER: "cd",
1909 HV_CDROM_IMAGE_PATH: "",
1910 HV_NIC_TYPE: HT_NIC_RTL8139,
1911 HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
1912 HV_VNC_BIND_ADDRESS: IP4_ADDRESS_ANY,
1913 HV_VNC_PASSWORD_FILE: pathutils.VNC_PASSWORD_FILE,
1916 HV_KERNEL_PATH: "/usr/lib/xen/boot/hvmloader",
1917 HV_DEVICE_MODEL: "/usr/lib/xen/bin/qemu-dm",
1918 HV_MIGRATION_PORT: 8002,
1919 HV_MIGRATION_MODE: HT_MIGRATION_NONLIVE,
1920 HV_USE_LOCALTIME: False,
1921 HV_BLOCKDEV_PREFIX: "hd",
1923 HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1924 HV_CPU_MASK: CPU_PINNING_ALL,
1929 HV_KVM_PATH: KVM_PATH,
1930 HV_KERNEL_PATH: KVM_KERNEL,
1932 HV_KERNEL_ARGS: "ro",
1933 HV_ROOT_PATH: "/dev/vda1",
1935 HV_SERIAL_CONSOLE: True,
1936 HV_SERIAL_SPEED: 38400,
1937 HV_VNC_BIND_ADDRESS: "",
1940 HV_VNC_X509_VERIFY: False,
1941 HV_VNC_PASSWORD_FILE: "",
1942 HV_KVM_SPICE_BIND: "",
1943 HV_KVM_SPICE_IP_VERSION: IFACE_NO_IP_VERSION_SPECIFIED,
1944 HV_KVM_SPICE_PASSWORD_FILE: "",
1945 HV_KVM_SPICE_LOSSLESS_IMG_COMPR: "",
1946 HV_KVM_SPICE_JPEG_IMG_COMPR: "",
1947 HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR: "",
1948 HV_KVM_SPICE_STREAMING_VIDEO_DETECTION: "",
1949 HV_KVM_SPICE_AUDIO_COMPR: True,
1950 HV_KVM_SPICE_USE_TLS: False,
1951 HV_KVM_SPICE_TLS_CIPHERS: OPENSSL_CIPHERS,
1952 HV_KVM_SPICE_USE_VDAGENT: True,
1953 HV_KVM_FLOPPY_IMAGE_PATH: "",
1954 HV_CDROM_IMAGE_PATH: "",
1955 HV_KVM_CDROM2_IMAGE_PATH: "",
1956 HV_BOOT_ORDER: HT_BO_DISK,
1957 HV_NIC_TYPE: HT_NIC_PARAVIRTUAL,
1958 HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
1959 HV_KVM_CDROM_DISK_TYPE: "",
1962 HV_MIGRATION_PORT: 8102,
1963 HV_MIGRATION_BANDWIDTH: 32, # MiB/s
1964 HV_MIGRATION_DOWNTIME: 30, # ms
1965 HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1966 HV_USE_LOCALTIME: False,
1967 HV_DISK_CACHE: HT_CACHE_DEFAULT,
1968 HV_SECURITY_MODEL: HT_SM_NONE,
1969 HV_SECURITY_DOMAIN: "",
1971 HV_VHOST_NET: False,
1972 HV_KVM_USE_CHROOT: False,
1974 HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1975 HV_CPU_MASK: CPU_PINNING_ALL,
1984 HV_KVM_MACHINE_VERSION: "",
1988 HV_INIT_SCRIPT: "/ganeti-chroot",
1995 HVC_GLOBALS = compat.UniqueFrozenset([
1997 HV_MIGRATION_BANDWIDTH,
2005 BE_AUTO_BALANCE: True,
2006 BE_ALWAYS_FAILOVER: False,
2012 ND_SPINDLE_COUNT: 1,
2013 ND_EXCLUSIVE_STORAGE: False,
2016 DISK_LD_DEFAULTS = {
2018 LDP_RESYNC_RATE: CLASSIC_DRBD_SYNC_SPEED,
2019 LDP_BARRIERS: _autoconf.DRBD_BARRIERS,
2020 LDP_NO_META_FLUSH: _autoconf.DRBD_NO_META_FLUSH,
2021 LDP_DEFAULT_METAVG: DEFAULT_VG,
2022 LDP_DISK_CUSTOM: "",
2024 LDP_DYNAMIC_RESYNC: False,
2026 # The default values for the DRBD dynamic resync speed algorithm are taken
2027 # from the drbsetup 8.3.11 man page, except for c-plan-ahead (that we
2028 # don't need to set to 0, because we have a separate option to enable it)
2029 # and for c-max-rate, that we cap to the default value for the static resync
2031 LDP_PLAN_AHEAD: 20, # ds
2032 LDP_FILL_TARGET: 0, # sectors
2033 LDP_DELAY_TARGET: 1, # ds
2034 LDP_MAX_RATE: CLASSIC_DRBD_SYNC_SPEED, # KiB/s
2035 LDP_MIN_RATE: 4 * 1024, # KiB/s
2038 LDP_STRIPES: _autoconf.LVM_STRIPECOUNT
2048 # readability shortcuts
2049 _LV_DEFAULTS = DISK_LD_DEFAULTS[LD_LV]
2050 _DRBD_DEFAULTS = DISK_LD_DEFAULTS[LD_DRBD8]
2052 DISK_DT_DEFAULTS = {
2054 LV_STRIPES: DISK_LD_DEFAULTS[LD_LV][LDP_STRIPES],
2057 DRBD_RESYNC_RATE: _DRBD_DEFAULTS[LDP_RESYNC_RATE],
2058 DRBD_DATA_STRIPES: _LV_DEFAULTS[LDP_STRIPES],
2059 DRBD_META_STRIPES: _LV_DEFAULTS[LDP_STRIPES],
2060 DRBD_DISK_BARRIERS: _DRBD_DEFAULTS[LDP_BARRIERS],
2061 DRBD_META_BARRIERS: _DRBD_DEFAULTS[LDP_NO_META_FLUSH],
2062 DRBD_DEFAULT_METAVG: _DRBD_DEFAULTS[LDP_DEFAULT_METAVG],
2063 DRBD_DISK_CUSTOM: _DRBD_DEFAULTS[LDP_DISK_CUSTOM],
2064 DRBD_NET_CUSTOM: _DRBD_DEFAULTS[LDP_NET_CUSTOM],
2065 DRBD_DYNAMIC_RESYNC: _DRBD_DEFAULTS[LDP_DYNAMIC_RESYNC],
2066 DRBD_PLAN_AHEAD: _DRBD_DEFAULTS[LDP_PLAN_AHEAD],
2067 DRBD_FILL_TARGET: _DRBD_DEFAULTS[LDP_FILL_TARGET],
2068 DRBD_DELAY_TARGET: _DRBD_DEFAULTS[LDP_DELAY_TARGET],
2069 DRBD_MAX_RATE: _DRBD_DEFAULTS[LDP_MAX_RATE],
2070 DRBD_MIN_RATE: _DRBD_DEFAULTS[LDP_MIN_RATE],
2077 RBD_POOL: DISK_LD_DEFAULTS[LD_RBD][LDP_POOL]
2082 # we don't want to export the shortcuts
2083 del _LV_DEFAULTS, _DRBD_DEFAULTS
2086 NIC_MODE: NIC_MODE_BRIDGED,
2087 NIC_LINK: DEFAULT_BRIDGE,
2090 # All of the following values are quite arbitrarily - there are no
2091 # "good" defaults, these must be customised per-site
2092 IPOLICY_DEFAULTS = {
2094 ISPEC_MEM_SIZE: 128,
2096 ISPEC_DISK_COUNT: 1,
2097 ISPEC_DISK_SIZE: 1024,
2099 ISPEC_SPINDLE_USE: 1,
2102 ISPEC_MEM_SIZE: 32768,
2104 ISPEC_DISK_COUNT: MAX_DISKS,
2105 ISPEC_DISK_SIZE: 1024 * 1024,
2106 ISPEC_NIC_COUNT: MAX_NICS,
2107 ISPEC_SPINDLE_USE: 12,
2110 ISPEC_MEM_SIZE: 128,
2112 ISPEC_DISK_COUNT: 1,
2113 ISPEC_DISK_SIZE: 1024,
2115 ISPEC_SPINDLE_USE: 1,
2117 IPOLICY_DTS: DISK_TEMPLATES,
2118 IPOLICY_VCPU_RATIO: 4.0,
2119 IPOLICY_SPINDLE_RATIO: 32.0,
2122 MASTER_POOL_SIZE_DEFAULT = 10
2124 # Exclusive storage:
2125 # Error margin used to compare physical disks
2127 # Space reserved when creating instance disks
2130 CONFD_PROTOCOL_VERSION = 1
2133 CONFD_REQ_NODE_ROLE_BYNAME = 1
2134 CONFD_REQ_NODE_PIP_BY_INSTANCE_IP = 2
2135 CONFD_REQ_CLUSTER_MASTER = 3
2136 CONFD_REQ_NODE_PIP_LIST = 4
2137 CONFD_REQ_MC_PIP_LIST = 5
2138 CONFD_REQ_INSTANCES_IPS_LIST = 6
2139 CONFD_REQ_NODE_DRBD = 7
2141 # Confd request query fields. These are used to narrow down queries.
2142 # These must be strings rather than integers, because json-encoding
2143 # converts them to strings anyway, as they're used as dict-keys.
2144 CONFD_REQQ_LINK = "0"
2146 CONFD_REQQ_IPLIST = "2"
2147 CONFD_REQQ_FIELDS = "3"
2149 CONFD_REQFIELD_NAME = "0"
2150 CONFD_REQFIELD_IP = "1"
2151 CONFD_REQFIELD_MNODE_PIP = "2"
2153 CONFD_REQS = compat.UniqueFrozenset([
2155 CONFD_REQ_NODE_ROLE_BYNAME,
2156 CONFD_REQ_NODE_PIP_BY_INSTANCE_IP,
2157 CONFD_REQ_CLUSTER_MASTER,
2158 CONFD_REQ_NODE_PIP_LIST,
2159 CONFD_REQ_MC_PIP_LIST,
2160 CONFD_REQ_INSTANCES_IPS_LIST,
2161 CONFD_REQ_NODE_DRBD,
2164 CONFD_REPL_STATUS_OK = 0
2165 CONFD_REPL_STATUS_ERROR = 1
2166 CONFD_REPL_STATUS_NOTIMPLEMENTED = 2
2168 CONFD_REPL_STATUSES = compat.UniqueFrozenset([
2169 CONFD_REPL_STATUS_OK,
2170 CONFD_REPL_STATUS_ERROR,
2171 CONFD_REPL_STATUS_NOTIMPLEMENTED,
2174 (CONFD_NODE_ROLE_MASTER,
2175 CONFD_NODE_ROLE_CANDIDATE,
2176 CONFD_NODE_ROLE_OFFLINE,
2177 CONFD_NODE_ROLE_DRAINED,
2178 CONFD_NODE_ROLE_REGULAR,
2181 # A few common errors for confd
2182 CONFD_ERROR_UNKNOWN_ENTRY = 1
2183 CONFD_ERROR_INTERNAL = 2
2184 CONFD_ERROR_ARGUMENT = 3
2186 # Each request is "salted" by the current timestamp.
2187 # This constants decides how many seconds of skew to accept.
2188 # TODO: make this a default and allow the value to be more configurable
2189 CONFD_MAX_CLOCK_SKEW = 2 * NODE_MAX_CLOCK_SKEW
2191 # When we haven't reloaded the config for more than this amount of seconds, we
2192 # force a test to see if inotify is betraying us.
2193 CONFD_CONFIG_RELOAD_TIMEOUT = 60
2195 # If we receive more than one update in this amount of seconds, we move to
2196 # polling every RATELIMIT seconds, rather than relying on inotify, to be able
2197 # to serve more requests.
2198 CONFD_CONFIG_RELOAD_RATELIMIT = 2
2200 # Magic number prepended to all confd queries.
2201 # This allows us to distinguish different types of confd protocols and handle
2202 # them. For example by changing this we can move the whole payload to be
2203 # compressed, or move away from json.
2204 CONFD_MAGIC_FOURCC = "plj0"
2206 # By default a confd request is sent to the minimum between this number and all
2207 # MCs. 6 was chosen because even in the case of a disastrous 50% response rate,
2208 # we should have enough answers to be able to compare more than one.
2209 CONFD_DEFAULT_REQ_COVERAGE = 6
2211 # Timeout in seconds to expire pending query request in the confd client
2212 # library. We don't actually expect any answer more than 10 seconds after we
2214 CONFD_CLIENT_EXPIRE_TIMEOUT = 10
2216 # Maximum UDP datagram size.
2217 # On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
2218 # On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
2219 # (assuming we can't use jumbo frames)
2220 # We just set this to 60K, which should be enough
2221 MAX_UDP_DATA_SIZE = 61440
2223 # User-id pool minimum/maximum acceptable user-ids.
2225 UIDPOOL_UID_MAX = 2 ** 32 - 1 # Assuming 32 bit user-ids
2227 # Name or path of the pgrep command
2230 # Name of the node group that gets created at cluster init or upgrade
2231 INITIAL_NODE_GROUP_NAME = "default"
2233 # Possible values for NodeGroup.alloc_policy
2234 ALLOC_POLICY_PREFERRED = "preferred"
2235 ALLOC_POLICY_LAST_RESORT = "last_resort"
2236 ALLOC_POLICY_UNALLOCABLE = "unallocable"
2237 VALID_ALLOC_POLICIES = [
2238 ALLOC_POLICY_PREFERRED,
2239 ALLOC_POLICY_LAST_RESORT,
2240 ALLOC_POLICY_UNALLOCABLE,
2243 # Temporary external/shared storage parameters
2244 BLOCKDEV_DRIVER_MANUAL = "manual"
2246 # qemu-img path, required for ovfconverter
2247 QEMUIMG_PATH = _autoconf.QEMUIMG_PATH
2249 # Whether htools was enabled at compilation time
2250 HTOOLS = _autoconf.HTOOLS
2251 # The hail iallocator
2252 IALLOC_HAIL = "hail"
2254 # Fake opcodes for functions that have hooks attached to them via
2255 # backend.RunLocalHooks
2256 FAKE_OP_MASTER_TURNUP = "OP_CLUSTER_IP_TURNUP"
2257 FAKE_OP_MASTER_TURNDOWN = "OP_CLUSTER_IP_TURNDOWN"
2262 SSHK_ALL = compat.UniqueFrozenset([SSHK_RSA, SSHK_DSA])
2264 # SSH authorized key types
2265 SSHAK_RSA = "ssh-rsa"
2266 SSHAK_DSS = "ssh-dss"
2267 SSHAK_ALL = compat.UniqueFrozenset([SSHAK_RSA, SSHAK_DSS])
2270 SSHS_CLUSTER_NAME = "cluster_name"
2271 SSHS_SSH_HOST_KEY = "ssh_host_key"
2272 SSHS_SSH_ROOT_KEY = "ssh_root_key"
2273 SSHS_NODE_DAEMON_CERTIFICATE = "node_daemon_certificate"
2275 #: Key files for SSH daemon
2276 SSH_DAEMON_KEYFILES = {
2277 SSHK_RSA: (pathutils.SSH_HOST_RSA_PRIV, pathutils.SSH_HOST_RSA_PUB),
2278 SSHK_DSA: (pathutils.SSH_HOST_DSA_PRIV, pathutils.SSH_HOST_DSA_PUB),
2282 NDS_CLUSTER_NAME = "cluster_name"
2283 NDS_NODE_DAEMON_CERTIFICATE = "node_daemon_certificate"
2284 NDS_SSCONF = "ssconf"
2285 NDS_START_NODE_DAEMON = "start_node_daemon"
2287 # Path generating random UUID
2288 RANDOM_UUID_FILE = "/proc/sys/kernel/random/uuid"
2290 # Regex string for verifying a UUID
2291 UUID_REGEX = "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
2293 # Auto-repair tag prefixes
2294 AUTO_REPAIR_TAG_PREFIX = "ganeti:watcher:autorepair:"
2295 AUTO_REPAIR_TAG_ENABLED = AUTO_REPAIR_TAG_PREFIX
2296 AUTO_REPAIR_TAG_SUSPENDED = AUTO_REPAIR_TAG_ENABLED + "suspend:"
2297 AUTO_REPAIR_TAG_PENDING = AUTO_REPAIR_TAG_PREFIX + "pending:"
2298 AUTO_REPAIR_TAG_RESULT = AUTO_REPAIR_TAG_PREFIX + "result:"
2300 # Auto-repair levels
2301 AUTO_REPAIR_FIX_STORAGE = "fix-storage"
2302 AUTO_REPAIR_MIGRATE = "migrate"
2303 AUTO_REPAIR_FAILOVER = "failover"
2304 AUTO_REPAIR_REINSTALL = "reinstall"
2305 AUTO_REPAIR_ALL_TYPES = [
2306 AUTO_REPAIR_FIX_STORAGE,
2307 AUTO_REPAIR_MIGRATE,
2308 AUTO_REPAIR_FAILOVER,
2309 AUTO_REPAIR_REINSTALL,
2312 # Auto-repair results
2313 AUTO_REPAIR_SUCCESS = "success"
2314 AUTO_REPAIR_FAILURE = "failure"
2315 AUTO_REPAIR_ENOPERM = "enoperm"
2316 AUTO_REPAIR_ALL_RESULTS = frozenset([
2317 AUTO_REPAIR_SUCCESS,
2318 AUTO_REPAIR_FAILURE,
2319 AUTO_REPAIR_ENOPERM,
2322 # The version identifier for builtin data collectors
2323 BUILTIN_DATA_COLLECTOR_VERSION = "B"
2325 # Do not re-export imported modules
2326 del re, _vcsversion, _autoconf, socket, pathutils, compat