Merge branch 'devel-2.4'
[ganeti-local] / lib / constants.py
1 #
2 #
3
4 # Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Google Inc.
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 # General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 # 02110-1301, USA.
20
21
22 """Module holding different constants."""
23
24 import re
25
26 from ganeti import _autoconf
27
28 # various versions
29 RELEASE_VERSION = _autoconf.PACKAGE_VERSION
30 OS_API_V10 = 10
31 OS_API_V15 = 15
32 OS_API_V20 = 20
33 OS_API_VERSIONS = frozenset([OS_API_V10, OS_API_V15, OS_API_V20])
34 VCS_VERSION = _autoconf.VCS_VERSION
35 EXPORT_VERSION = 0
36 RAPI_VERSION = 2
37
38
39 # Format for CONFIG_VERSION:
40 #   01 03 0123 = 01030123
41 #   ^^ ^^ ^^^^
42 #   |  |  + Configuration version/revision
43 #   |  + Minor version
44 #   + Major version
45 #
46 # It stored as an integer. Make sure not to write an octal number.
47
48 # BuildVersion and SplitVersion must be in here because we can't import other
49 # modules. The cfgupgrade tool must be able to read and write version numbers
50 # and thus requires these functions. To avoid code duplication, they're kept in
51 # here.
52
53 def BuildVersion(major, minor, revision):
54   """Calculates int version number from major, minor and revision numbers.
55
56   Returns: int representing version number
57
58   """
59   assert isinstance(major, int)
60   assert isinstance(minor, int)
61   assert isinstance(revision, int)
62   return (1000000 * major +
63             10000 * minor +
64                 1 * revision)
65
66
67 def SplitVersion(version):
68   """Splits version number stored in an int.
69
70   Returns: tuple; (major, minor, revision)
71
72   """
73   assert isinstance(version, int)
74
75   (major, remainder) = divmod(version, 1000000)
76   (minor, revision) = divmod(remainder, 10000)
77
78   return (major, minor, revision)
79
80
81 CONFIG_MAJOR = int(_autoconf.VERSION_MAJOR)
82 CONFIG_MINOR = int(_autoconf.VERSION_MINOR)
83 CONFIG_REVISION = 0
84 CONFIG_VERSION = BuildVersion(CONFIG_MAJOR, CONFIG_MINOR, CONFIG_REVISION)
85
86 #: RPC protocol version
87 PROTOCOL_VERSION = BuildVersion(CONFIG_MAJOR, CONFIG_MINOR, 0)
88
89 # user separation
90 DAEMONS_GROUP = _autoconf.DAEMONS_GROUP
91 ADMIN_GROUP = _autoconf.ADMIN_GROUP
92 MASTERD_USER = _autoconf.MASTERD_USER
93 MASTERD_GROUP = _autoconf.MASTERD_GROUP
94 RAPI_USER = _autoconf.RAPI_USER
95 RAPI_GROUP = _autoconf.RAPI_GROUP
96 CONFD_USER = _autoconf.CONFD_USER
97 CONFD_GROUP = _autoconf.CONFD_GROUP
98 NODED_USER = _autoconf.NODED_USER
99
100
101 # Wipe
102 DD_CMD = "dd"
103 WIPE_BLOCK_SIZE = 1024**2
104 MAX_WIPE_CHUNK = 1024 # 1GB
105 MIN_WIPE_CHUNK_PERCENT = 10
106
107
108 # file paths
109 DATA_DIR = _autoconf.LOCALSTATEDIR + "/lib/ganeti"
110 RUN_DIR = _autoconf.LOCALSTATEDIR + "/run"
111 RUN_GANETI_DIR = RUN_DIR + "/ganeti"
112 BDEV_CACHE_DIR = RUN_GANETI_DIR + "/bdev-cache"
113 DISK_LINKS_DIR = RUN_GANETI_DIR + "/instance-disks"
114 RUN_DIRS_MODE = 0775
115 SOCKET_DIR = RUN_GANETI_DIR + "/socket"
116 SECURE_DIR_MODE = 0700
117 SECURE_FILE_MODE = 0600
118 SOCKET_DIR_MODE = 0750
119 CRYPTO_KEYS_DIR = RUN_GANETI_DIR + "/crypto"
120 CRYPTO_KEYS_DIR_MODE = SECURE_DIR_MODE
121 IMPORT_EXPORT_DIR = RUN_GANETI_DIR + "/import-export"
122 IMPORT_EXPORT_DIR_MODE = 0755
123 # keep RUN_GANETI_DIR first here, to make sure all get created when the node
124 # daemon is started (this takes care of RUN_DIR being tmpfs)
125 SUB_RUN_DIRS = [ RUN_GANETI_DIR, BDEV_CACHE_DIR, DISK_LINKS_DIR ]
126 LOCK_DIR = _autoconf.LOCALSTATEDIR + "/lock"
127 SSCONF_LOCK_FILE = LOCK_DIR + "/ganeti-ssconf.lock"
128 # User-id pool lock directory
129 # The user-ids that are in use have a corresponding lock file in this directory
130 UIDPOOL_LOCKDIR = RUN_GANETI_DIR + "/uid-pool"
131 CLUSTER_CONF_FILE = DATA_DIR + "/config.data"
132 NODED_CERT_FILE = DATA_DIR + "/server.pem"
133 RAPI_CERT_FILE = DATA_DIR + "/rapi.pem"
134 CONFD_HMAC_KEY = DATA_DIR + "/hmac.key"
135 CLUSTER_DOMAIN_SECRET_FILE = DATA_DIR + "/cluster-domain-secret"
136 WATCHER_STATEFILE = DATA_DIR + "/watcher.data"
137 WATCHER_PAUSEFILE = DATA_DIR + "/watcher.pause"
138 INSTANCE_UPFILE = RUN_GANETI_DIR + "/instance-status"
139 SSH_KNOWN_HOSTS_FILE = DATA_DIR + "/known_hosts"
140 RAPI_USERS_FILE = DATA_DIR + "/rapi/users"
141 QUEUE_DIR = DATA_DIR + "/queue"
142 DAEMON_UTIL = _autoconf.PKGLIBDIR + "/daemon-util"
143 SETUP_SSH = _autoconf.TOOLSDIR + "/setup-ssh"
144 KVM_IFUP = _autoconf.PKGLIBDIR + "/kvm-ifup"
145 ETC_HOSTS = "/etc/hosts"
146 DEFAULT_FILE_STORAGE_DIR = _autoconf.FILE_STORAGE_DIR
147 ENABLE_FILE_STORAGE = _autoconf.ENABLE_FILE_STORAGE
148 SYSCONFDIR = _autoconf.SYSCONFDIR
149 TOOLSDIR = _autoconf.TOOLSDIR
150 CONF_DIR = SYSCONFDIR + "/ganeti"
151
152 ALL_CERT_FILES = frozenset([NODED_CERT_FILE, RAPI_CERT_FILE])
153
154 MASTER_SOCKET = SOCKET_DIR + "/ganeti-master"
155
156 NODED = "ganeti-noded"
157 CONFD = "ganeti-confd"
158 RAPI = "ganeti-rapi"
159 MASTERD = "ganeti-masterd"
160 # used in the ganeti-nbma project
161 NLD = "ganeti-nld"
162
163 DAEMONS_PORTS = {
164   # daemon-name: ("proto", "default-port")
165   NODED: ("tcp", 1811),
166   CONFD: ("udp", 1814),
167   RAPI: ("tcp", 5080),
168   "ssh": ("tcp", 22),
169   # used in the ganeti-nbma project
170   NLD: ("udp", 1816),
171 }
172 DEFAULT_NODED_PORT = DAEMONS_PORTS[NODED][1]
173 DEFAULT_CONFD_PORT = DAEMONS_PORTS[CONFD][1]
174 DEFAULT_RAPI_PORT = DAEMONS_PORTS[RAPI][1]
175 # used in the ganeti-nbma project
176 DEFAULT_NLD_PORT = DAEMONS_PORTS[NLD][1]
177
178 FIRST_DRBD_PORT = 11000
179 LAST_DRBD_PORT = 14999
180 MASTER_SCRIPT = "ganeti-master"
181
182 LOG_DIR = _autoconf.LOCALSTATEDIR + "/log/ganeti/"
183 DAEMONS_LOGFILES = {
184   # "daemon-name": "logfile"
185   NODED: LOG_DIR + "node-daemon.log",
186   CONFD: LOG_DIR + "conf-daemon.log",
187   RAPI: LOG_DIR + "rapi-daemon.log",
188   MASTERD: LOG_DIR + "master-daemon.log",
189   # used in the ganeti-nbma project
190   NLD: LOG_DIR + "nl-daemon.log",
191   }
192
193 LOG_OS_DIR = LOG_DIR + "os"
194 LOG_WATCHER = LOG_DIR + "watcher.log"
195 LOG_COMMANDS = LOG_DIR + "commands.log"
196 LOG_BURNIN = LOG_DIR + "burnin.log"
197 LOG_SETUP_SSH = LOG_DIR + "setup-ssh.log"
198
199 DEV_CONSOLE = "/dev/console"
200
201 PROC_MOUNTS = "/proc/mounts"
202
203 # luxi related constants
204 LUXI_EOM = "\3"
205 LUXI_VERSION = CONFIG_VERSION
206
207 # one of 'no', 'yes', 'only'
208 SYSLOG_USAGE = _autoconf.SYSLOG_USAGE
209 SYSLOG_NO = "no"
210 SYSLOG_YES = "yes"
211 SYSLOG_ONLY = "only"
212 SYSLOG_SOCKET = "/dev/log"
213
214 OS_SEARCH_PATH = _autoconf.OS_SEARCH_PATH
215 EXPORT_DIR = _autoconf.EXPORT_DIR
216
217 EXPORT_CONF_FILE = "config.ini"
218
219 XEN_BOOTLOADER = _autoconf.XEN_BOOTLOADER
220 XEN_KERNEL = _autoconf.XEN_KERNEL
221 XEN_INITRD = _autoconf.XEN_INITRD
222
223 KVM_PATH = _autoconf.KVM_PATH
224 SOCAT_PATH = _autoconf.SOCAT_PATH
225 SOCAT_USE_ESCAPE = _autoconf.SOCAT_USE_ESCAPE
226 SOCAT_USE_COMPRESS = _autoconf.SOCAT_USE_COMPRESS
227 SOCAT_ESCAPE_CODE = "0x1d"
228
229 #: Console as SSH command
230 CONS_SSH = "ssh"
231
232 #: Console as VNC server
233 CONS_VNC = "vnc"
234
235 #: Display a message for console access
236 CONS_MESSAGE = "msg"
237
238 #: All console types
239 CONS_ALL = frozenset([CONS_SSH, CONS_VNC, CONS_MESSAGE])
240
241 # For RSA keys more bits are better, but they also make operations more
242 # expensive. NIST SP 800-131 recommends a minimum of 2048 bits from the year
243 # 2010 on.
244 RSA_KEY_BITS = 2048
245
246 # Ciphers allowed for SSL connections. For the format, see ciphers(1). A better
247 # way to disable ciphers would be to use the exclamation mark (!), but socat
248 # versions below 1.5 can't parse exclamation marks in options properly. When
249 # modifying the ciphers, ensure not to accidentially add something after it's
250 # been removed. Use the "openssl" utility to check the allowed ciphers, e.g.
251 # "openssl ciphers -v HIGH:-DES".
252 OPENSSL_CIPHERS = "HIGH:-DES:-3DES:-EXPORT:-ADH"
253
254 # Digest used to sign certificates ("openssl x509" uses SHA1 by default)
255 X509_CERT_SIGN_DIGEST = "SHA1"
256
257 # Default validity of certificates in days
258 X509_CERT_DEFAULT_VALIDITY = 365 * 5
259
260 # commonName (CN) used in certificates
261 X509_CERT_CN = "ganeti.example.com"
262
263 X509_CERT_SIGNATURE_HEADER = "X-Ganeti-Signature"
264
265 IMPORT_EXPORT_DAEMON = _autoconf.PKGLIBDIR + "/import-export"
266
267 # Import/export daemon mode
268 IEM_IMPORT = "import"
269 IEM_EXPORT = "export"
270
271 # Import/export transport compression
272 IEC_NONE = "none"
273 IEC_GZIP = "gzip"
274 IEC_ALL = frozenset([
275   IEC_NONE,
276   IEC_GZIP,
277   ])
278
279 IE_CUSTOM_SIZE = "fd"
280
281 IE_MAGIC_RE = re.compile(r"^[-_.a-zA-Z0-9]{5,100}$")
282
283 # Import/export I/O
284 # Direct file I/O, equivalent to a shell's I/O redirection using '<' or '>'
285 IEIO_FILE = "file"
286 # Raw block device I/O using "dd"
287 IEIO_RAW_DISK = "raw"
288 # OS definition import/export script
289 IEIO_SCRIPT = "script"
290
291 VALUE_DEFAULT = "default"
292 VALUE_AUTO = "auto"
293 VALUE_GENERATE = "generate"
294 VALUE_NONE = "none"
295 VALUE_TRUE = "true"
296 VALUE_FALSE = "false"
297
298 # External script validation mask
299 EXT_PLUGIN_MASK = re.compile("^[a-zA-Z0-9_-]+$")
300
301 # hooks-related constants
302 HOOKS_BASE_DIR = CONF_DIR + "/hooks"
303 HOOKS_PHASE_PRE = "pre"
304 HOOKS_PHASE_POST = "post"
305 HOOKS_NAME_CFGUPDATE = "config-update"
306 HOOKS_NAME_WATCHER = "watcher"
307 HOOKS_VERSION = 2
308
309 # hooks subject type (what object type does the LU deal with)
310 HTYPE_CLUSTER = "CLUSTER"
311 HTYPE_NODE = "NODE"
312 HTYPE_GROUP = "GROUP"
313 HTYPE_INSTANCE = "INSTANCE"
314
315 HKR_SKIP = 0
316 HKR_FAIL = 1
317 HKR_SUCCESS = 2
318
319 # Storage types
320 ST_FILE = "file"
321 ST_LVM_PV = "lvm-pv"
322 ST_LVM_VG = "lvm-vg"
323
324 # Storage fields
325 # first two are valid in LU context only, not passed to backend
326 SF_NODE = "node"
327 SF_TYPE = "type"
328 # and the rest are valid in backend
329 SF_NAME = "name"
330 SF_SIZE = "size"
331 SF_FREE = "free"
332 SF_USED = "used"
333 SF_ALLOCATABLE = "allocatable"
334
335 # Storage operations
336 SO_FIX_CONSISTENCY = "fix-consistency"
337
338 # Available fields per storage type
339 VALID_STORAGE_FIELDS = frozenset([SF_NAME, SF_TYPE, SF_SIZE,
340                                   SF_USED, SF_FREE, SF_ALLOCATABLE])
341
342 VALID_STORAGE_TYPES = frozenset([ST_FILE, ST_LVM_PV, ST_LVM_VG])
343
344 MODIFIABLE_STORAGE_FIELDS = {
345   ST_LVM_PV: frozenset([SF_ALLOCATABLE]),
346   }
347
348 VALID_STORAGE_OPERATIONS = {
349   ST_LVM_VG: frozenset([SO_FIX_CONSISTENCY]),
350   }
351
352 # Local disk status
353 # Note: Code depends on LDS_OKAY < LDS_UNKNOWN < LDS_FAULTY
354 (LDS_OKAY,
355  LDS_UNKNOWN,
356  LDS_FAULTY) = range(1, 4)
357
358 # disk template types
359 DT_DISKLESS = "diskless"
360 DT_PLAIN = "plain"
361 DT_DRBD8 = "drbd"
362 DT_FILE = "file"
363
364 # the set of network-mirrored disk templates
365 DTS_NET_MIRROR = frozenset([DT_DRBD8])
366
367 # the set of non-lvm-based disk templates
368 DTS_NOT_LVM = frozenset([DT_DISKLESS, DT_FILE])
369
370 # the set of disk templates which can be grown
371 DTS_GROWABLE = frozenset([DT_PLAIN, DT_DRBD8, DT_FILE])
372
373 # the set of disk templates that allow adoption
374 DTS_MAY_ADOPT = frozenset([DT_PLAIN])
375
376 # logical disk types
377 LD_LV = "lvm"
378 LD_DRBD8 = "drbd8"
379 LD_FILE = "file"
380 LDS_BLOCK = frozenset([LD_LV, LD_DRBD8])
381
382 # drbd constants
383 DRBD_HMAC_ALG = "md5"
384 DRBD_NET_PROTOCOL = "C"
385 DRBD_BARRIERS = _autoconf.DRBD_BARRIERS
386
387 # file backend driver
388 FD_LOOP = "loop"
389 FD_BLKTAP = "blktap"
390
391 # the set of drbd-like disk types
392 LDS_DRBD = frozenset([LD_DRBD8])
393
394 # disk access mode
395 DISK_RDONLY = "ro"
396 DISK_RDWR = "rw"
397 DISK_ACCESS_SET = frozenset([DISK_RDONLY, DISK_RDWR])
398
399 # disk replacement mode
400 REPLACE_DISK_PRI = "replace_on_primary"    # replace disks on primary
401 REPLACE_DISK_SEC = "replace_on_secondary"  # replace disks on secondary
402 REPLACE_DISK_CHG = "replace_new_secondary" # change secondary node
403 REPLACE_DISK_AUTO = "replace_auto"
404 REPLACE_MODES = frozenset([
405   REPLACE_DISK_PRI,
406   REPLACE_DISK_SEC,
407   REPLACE_DISK_CHG,
408   REPLACE_DISK_AUTO,
409   ])
410
411 # Instance export mode
412 EXPORT_MODE_LOCAL = "local"
413 EXPORT_MODE_REMOTE = "remote"
414 EXPORT_MODES = frozenset([
415   EXPORT_MODE_LOCAL,
416   EXPORT_MODE_REMOTE,
417   ])
418
419 # lock recalculate mode
420 LOCKS_REPLACE = 'replace'
421 LOCKS_APPEND = 'append'
422
423 # instance creation modes
424 INSTANCE_CREATE = "create"
425 INSTANCE_IMPORT = "import"
426 INSTANCE_REMOTE_IMPORT = "remote-import"
427 INSTANCE_CREATE_MODES = frozenset([
428   INSTANCE_CREATE,
429   INSTANCE_IMPORT,
430   INSTANCE_REMOTE_IMPORT,
431   ])
432
433 # Remote import/export handshake message and version
434 RIE_VERSION = 0
435 RIE_HANDSHAKE = "Hi, I'm Ganeti"
436
437 # Remote import/export certificate validity in seconds
438 RIE_CERT_VALIDITY = 24 * 60 * 60
439
440 # Remote import/export connect timeout for socat
441 RIE_CONNECT_TIMEOUT = 60
442 #: Give child process up to 5 seconds to exit after sending a signal
443 CHILD_LINGER_TIMEOUT = 5.0
444
445 DISK_TEMPLATES = frozenset([DT_DISKLESS, DT_PLAIN,
446                             DT_DRBD8, DT_FILE])
447
448 FILE_DRIVER = frozenset([FD_LOOP, FD_BLKTAP])
449
450 # import/export config options
451 INISECT_EXP = "export"
452 INISECT_INS = "instance"
453 INISECT_HYP = "hypervisor"
454 INISECT_BEP = "backend"
455 INISECT_OSP = "os"
456
457 # dynamic device modification
458 DDM_ADD = "add"
459 DDM_REMOVE = "remove"
460 DDMS_VALUES = frozenset([DDM_ADD, DDM_REMOVE])
461
462 # common exit codes
463 EXIT_SUCCESS = 0
464 EXIT_FAILURE = 1
465 EXIT_NOTCLUSTER = 5
466 EXIT_NOTMASTER = 11
467 EXIT_NODESETUP_ERROR = 12
468 EXIT_CONFIRMATION = 13 # need user confirmation
469
470 #: Exit code for query operations with unknown fields
471 EXIT_UNKNOWN_FIELD = 14
472
473 # tags
474 TAG_CLUSTER = "cluster"
475 TAG_NODE = "node"
476 TAG_INSTANCE = "instance"
477 VALID_TAG_TYPES = frozenset([
478   TAG_CLUSTER,
479   TAG_NODE,
480   TAG_INSTANCE,
481   ])
482 MAX_TAG_LEN = 128
483 MAX_TAGS_PER_OBJ = 4096
484
485 # others
486 DEFAULT_BRIDGE = "xen-br0"
487 SYNC_SPEED = 60 * 1024
488 IP4_ADDRESS_LOCALHOST = "127.0.0.1"
489 IP4_ADDRESS_ANY = "0.0.0.0"
490 IP6_ADDRESS_LOCALHOST = "::1"
491 IP6_ADDRESS_ANY = "::"
492 IP4_VERSION = 4
493 IP6_VERSION = 6
494 TCP_PING_TIMEOUT = 10
495 GANETI_RUNAS = "root"
496 DEFAULT_VG = "xenvg"
497 DEFAULT_DRBD_HELPER = "/bin/true"
498 MIN_VG_SIZE = 20480
499 DEFAULT_MAC_PREFIX = "aa:00:00"
500 LVM_STRIPECOUNT = _autoconf.LVM_STRIPECOUNT
501 # default maximum instance wait time, in seconds.
502 DEFAULT_SHUTDOWN_TIMEOUT = 120
503 NODE_MAX_CLOCK_SKEW = 150
504 # Time for an intra-cluster disk transfer to wait for a connection
505 DISK_TRANSFER_CONNECT_TIMEOUT = 30
506 # Disk index separator
507 DISK_SEPARATOR = _autoconf.DISK_SEPARATOR
508
509 # runparts results
510 (RUNPARTS_SKIP,
511  RUNPARTS_RUN,
512  RUNPARTS_ERR) = range(3)
513
514 RUNPARTS_STATUS = frozenset([RUNPARTS_SKIP, RUNPARTS_RUN, RUNPARTS_ERR])
515
516 # RPC constants
517 (RPC_ENCODING_NONE,
518  RPC_ENCODING_ZLIB_BASE64) = range(2)
519
520 # os related constants
521 OS_SCRIPT_CREATE = 'create'
522 OS_SCRIPT_IMPORT = 'import'
523 OS_SCRIPT_EXPORT = 'export'
524 OS_SCRIPT_RENAME = 'rename'
525 OS_SCRIPT_VERIFY = 'verify'
526 OS_SCRIPTS = frozenset([OS_SCRIPT_CREATE, OS_SCRIPT_IMPORT,
527                         OS_SCRIPT_EXPORT, OS_SCRIPT_RENAME,
528                         OS_SCRIPT_VERIFY])
529
530 OS_API_FILE = 'ganeti_api_version'
531 OS_VARIANTS_FILE = 'variants.list'
532 OS_PARAMETERS_FILE = 'parameters.list'
533
534 OS_VALIDATE_PARAMETERS = 'parameters'
535 OS_VALIDATE_CALLS = frozenset([OS_VALIDATE_PARAMETERS])
536
537 # ssh constants
538 SSH_CONFIG_DIR = _autoconf.SSH_CONFIG_DIR
539 SSH_HOST_DSA_PRIV = SSH_CONFIG_DIR + "/ssh_host_dsa_key"
540 SSH_HOST_DSA_PUB = SSH_HOST_DSA_PRIV + ".pub"
541 SSH_HOST_RSA_PRIV = SSH_CONFIG_DIR + "/ssh_host_rsa_key"
542 SSH_HOST_RSA_PUB = SSH_HOST_RSA_PRIV + ".pub"
543 SSH = "ssh"
544 SCP = "scp"
545
546 # reboot types
547 INSTANCE_REBOOT_SOFT = "soft"
548 INSTANCE_REBOOT_HARD = "hard"
549 INSTANCE_REBOOT_FULL = "full"
550
551 REBOOT_TYPES = frozenset([INSTANCE_REBOOT_SOFT,
552                           INSTANCE_REBOOT_HARD,
553                           INSTANCE_REBOOT_FULL])
554
555 VTYPE_STRING = 'string'
556 VTYPE_MAYBE_STRING = "maybe-string"
557 VTYPE_BOOL = 'bool'
558 VTYPE_SIZE = 'size' # size, in MiBs
559 VTYPE_INT = 'int'
560 ENFORCEABLE_TYPES = frozenset([
561                       VTYPE_STRING,
562                       VTYPE_MAYBE_STRING,
563                       VTYPE_BOOL,
564                       VTYPE_SIZE,
565                       VTYPE_INT,
566                       ])
567
568 # HV parameter names (global namespace)
569 HV_BOOT_ORDER = "boot_order"
570 HV_CDROM_IMAGE_PATH = "cdrom_image_path"
571 HV_NIC_TYPE = "nic_type"
572 HV_DISK_TYPE = "disk_type"
573 HV_VNC_BIND_ADDRESS = "vnc_bind_address"
574 HV_VNC_PASSWORD_FILE = "vnc_password_file"
575 HV_VNC_TLS = "vnc_tls"
576 HV_VNC_X509 = "vnc_x509_path"
577 HV_VNC_X509_VERIFY = "vnc_x509_verify"
578 HV_ACPI = "acpi"
579 HV_PAE = "pae"
580 HV_USE_BOOTLOADER = "use_bootloader"
581 HV_BOOTLOADER_ARGS = "bootloader_args"
582 HV_BOOTLOADER_PATH = "bootloader_path"
583 HV_KERNEL_ARGS = "kernel_args"
584 HV_KERNEL_PATH = "kernel_path"
585 HV_INITRD_PATH = "initrd_path"
586 HV_ROOT_PATH = "root_path"
587 HV_SERIAL_CONSOLE = "serial_console"
588 HV_USB_MOUSE = "usb_mouse"
589 HV_DEVICE_MODEL = "device_model"
590 HV_INIT_SCRIPT = "init_script"
591 HV_MIGRATION_PORT = "migration_port"
592 HV_MIGRATION_BANDWIDTH = "migration_bandwidth"
593 HV_MIGRATION_DOWNTIME = "migration_downtime"
594 HV_MIGRATION_MODE = "migration_mode"
595 HV_USE_LOCALTIME = "use_localtime"
596 HV_DISK_CACHE = "disk_cache"
597 HV_SECURITY_MODEL = "security_model"
598 HV_SECURITY_DOMAIN = "security_domain"
599 HV_KVM_FLAG = "kvm_flag"
600 HV_VHOST_NET = "vhost_net"
601 HV_KVM_USE_CHROOT = "use_chroot"
602 HV_CPU_MASK = "cpu_mask"
603 HV_MEM_PATH = "mem_path"
604 HV_BLOCKDEV_PREFIX = "blockdev_prefix"
605
606 HVS_PARAMETER_TYPES = {
607   HV_BOOT_ORDER: VTYPE_STRING,
608   HV_CDROM_IMAGE_PATH: VTYPE_STRING,
609   HV_NIC_TYPE: VTYPE_STRING,
610   HV_DISK_TYPE: VTYPE_STRING,
611   HV_VNC_PASSWORD_FILE: VTYPE_STRING,
612   HV_VNC_BIND_ADDRESS: VTYPE_STRING,
613   HV_VNC_TLS: VTYPE_BOOL,
614   HV_VNC_X509: VTYPE_STRING,
615   HV_VNC_X509_VERIFY: VTYPE_BOOL,
616   HV_ACPI: VTYPE_BOOL,
617   HV_PAE: VTYPE_BOOL,
618   HV_USE_BOOTLOADER: VTYPE_BOOL,
619   HV_BOOTLOADER_PATH: VTYPE_STRING,
620   HV_BOOTLOADER_ARGS: VTYPE_STRING,
621   HV_KERNEL_PATH: VTYPE_STRING,
622   HV_KERNEL_ARGS: VTYPE_STRING,
623   HV_INITRD_PATH: VTYPE_STRING,
624   HV_ROOT_PATH: VTYPE_STRING,
625   HV_SERIAL_CONSOLE: VTYPE_BOOL,
626   HV_USB_MOUSE: VTYPE_STRING,
627   HV_DEVICE_MODEL: VTYPE_STRING,
628   HV_INIT_SCRIPT: VTYPE_STRING,
629   HV_MIGRATION_PORT: VTYPE_INT,
630   HV_MIGRATION_BANDWIDTH: VTYPE_INT,
631   HV_MIGRATION_DOWNTIME: VTYPE_INT,
632   HV_MIGRATION_MODE: VTYPE_STRING,
633   HV_USE_LOCALTIME: VTYPE_BOOL,
634   HV_DISK_CACHE: VTYPE_STRING,
635   HV_SECURITY_MODEL: VTYPE_STRING,
636   HV_SECURITY_DOMAIN: VTYPE_STRING,
637   HV_KVM_FLAG: VTYPE_STRING,
638   HV_VHOST_NET: VTYPE_BOOL,
639   HV_KVM_USE_CHROOT: VTYPE_BOOL,
640   HV_CPU_MASK: VTYPE_STRING,
641   HV_MEM_PATH: VTYPE_STRING,
642   HV_BLOCKDEV_PREFIX: VTYPE_STRING,
643   }
644
645 HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
646
647 # BE parameter names
648 BE_MEMORY = "memory"
649 BE_VCPUS = "vcpus"
650 BE_AUTO_BALANCE = "auto_balance"
651
652 BES_PARAMETER_TYPES = {
653     BE_MEMORY: VTYPE_SIZE,
654     BE_VCPUS: VTYPE_INT,
655     BE_AUTO_BALANCE: VTYPE_BOOL,
656     }
657
658 BES_PARAMETERS = frozenset(BES_PARAMETER_TYPES.keys())
659
660 # Node parameter names
661 ND_OOB_PROGRAM = "oob_program"
662
663 NDS_PARAMETER_TYPES = {
664     ND_OOB_PROGRAM: VTYPE_MAYBE_STRING,
665     }
666
667 NDS_PARAMETERS = frozenset(NDS_PARAMETER_TYPES.keys())
668
669 # OOB supported commands
670 OOB_POWER_ON = "power-on"
671 OOB_POWER_OFF = "power-off"
672 OOB_POWER_CYCLE = "power-cycle"
673 OOB_POWER_STATUS = "power-status"
674 OOB_HEALTH = "health"
675
676 OOB_COMMANDS = frozenset([OOB_POWER_ON, OOB_POWER_OFF, OOB_POWER_CYCLE,
677                           OOB_POWER_STATUS, OOB_HEALTH])
678
679 OOB_POWER_STATUS_POWERED = "powered"
680
681 OOB_TIMEOUT = 60 # 60 seconds
682
683 OOB_STATUS_OK = "OK"
684 OOB_STATUS_WARNING = "WARNING"
685 OOB_STATUS_CRITICAL = "CRITICAL"
686 OOB_STATUS_UNKNOWN = "UNKNOWN"
687
688 OOB_STATUSES = frozenset([
689   OOB_STATUS_OK,
690   OOB_STATUS_WARNING,
691   OOB_STATUS_CRITICAL,
692   OOB_STATUS_UNKNOWN,
693   ])
694
695 # Instance Parameters Profile
696 PP_DEFAULT = "default"
697
698 NIC_MODE = "mode"
699 NIC_LINK = "link"
700
701 NIC_MODE_BRIDGED = "bridged"
702 NIC_MODE_ROUTED = "routed"
703
704 NIC_VALID_MODES = frozenset([NIC_MODE_BRIDGED, NIC_MODE_ROUTED])
705
706 NICS_PARAMETER_TYPES = {
707     NIC_MODE: VTYPE_STRING,
708     NIC_LINK: VTYPE_STRING,
709     }
710
711 NICS_PARAMETERS = frozenset(NICS_PARAMETER_TYPES.keys())
712
713 IDISK_SIZE = "size"
714 IDISK_MODE = "mode"
715 IDISK_ADOPT = "adopt"
716 IDISK_VG = "vg"
717 IDISK_PARAMS_TYPES = {
718   IDISK_SIZE: VTYPE_SIZE,
719   IDISK_MODE: VTYPE_STRING,
720   IDISK_ADOPT: VTYPE_STRING,
721   IDISK_VG: VTYPE_STRING,
722   }
723 IDISK_PARAMS = frozenset(IDISK_PARAMS_TYPES.keys())
724
725 INIC_MAC = "mac"
726 INIC_IP = "ip"
727 INIC_MODE = "mode"
728 INIC_LINK = "link"
729 INIC_BRIDGE = "bridge"
730 INIC_PARAMS_TYPES = {
731   INIC_BRIDGE: VTYPE_STRING,
732   INIC_IP: VTYPE_MAYBE_STRING,
733   INIC_LINK: VTYPE_STRING,
734   INIC_MAC: VTYPE_STRING,
735   INIC_MODE: VTYPE_STRING,
736   }
737 INIC_PARAMS = frozenset(INIC_PARAMS_TYPES.keys())
738
739 # Hypervisor constants
740 HT_XEN_PVM = "xen-pvm"
741 HT_FAKE = "fake"
742 HT_XEN_HVM = "xen-hvm"
743 HT_KVM = "kvm"
744 HT_CHROOT = "chroot"
745 HT_LXC = "lxc"
746 HYPER_TYPES = frozenset([
747   HT_XEN_PVM,
748   HT_FAKE,
749   HT_XEN_HVM,
750   HT_KVM,
751   HT_CHROOT,
752   HT_LXC,
753   ])
754 HTS_REQ_PORT = frozenset([HT_XEN_HVM, HT_KVM])
755
756 VNC_BASE_PORT = 5900
757 VNC_PASSWORD_FILE = CONF_DIR + "/vnc-cluster-password"
758 VNC_DEFAULT_BIND_ADDRESS = IP4_ADDRESS_ANY
759
760 # NIC types
761 HT_NIC_RTL8139 = "rtl8139"
762 HT_NIC_NE2K_PCI = "ne2k_pci"
763 HT_NIC_NE2K_ISA = "ne2k_isa"
764 HT_NIC_I82551 = "i82551"
765 HT_NIC_I85557B = "i82557b"
766 HT_NIC_I8259ER = "i82559er"
767 HT_NIC_PCNET = "pcnet"
768 HT_NIC_E1000 = "e1000"
769 HT_NIC_PARAVIRTUAL = HT_DISK_PARAVIRTUAL = "paravirtual"
770
771 HT_HVM_VALID_NIC_TYPES = frozenset([HT_NIC_RTL8139, HT_NIC_NE2K_PCI,
772                                     HT_NIC_NE2K_ISA, HT_NIC_PARAVIRTUAL])
773 HT_KVM_VALID_NIC_TYPES = frozenset([HT_NIC_RTL8139, HT_NIC_NE2K_PCI,
774                                     HT_NIC_NE2K_ISA, HT_NIC_I82551,
775                                     HT_NIC_I85557B, HT_NIC_I8259ER,
776                                     HT_NIC_PCNET, HT_NIC_E1000,
777                                     HT_NIC_PARAVIRTUAL])
778 # Disk types
779 HT_DISK_IOEMU = "ioemu"
780 HT_DISK_IDE = "ide"
781 HT_DISK_SCSI = "scsi"
782 HT_DISK_SD = "sd"
783 HT_DISK_MTD = "mtd"
784 HT_DISK_PFLASH = "pflash"
785
786 HT_CACHE_DEFAULT = "default"
787 HT_CACHE_NONE = "none"
788 HT_CACHE_WTHROUGH = "writethrough"
789 HT_CACHE_WBACK = "writeback"
790 HT_VALID_CACHE_TYPES = frozenset([HT_CACHE_DEFAULT,
791                                   HT_CACHE_NONE,
792                                   HT_CACHE_WTHROUGH,
793                                   HT_CACHE_WBACK])
794
795 HT_HVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IOEMU])
796 HT_KVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IDE,
797                                      HT_DISK_SCSI, HT_DISK_SD, HT_DISK_MTD,
798                                      HT_DISK_PFLASH])
799
800 # Mouse types:
801 HT_MOUSE_MOUSE = "mouse"
802 HT_MOUSE_TABLET = "tablet"
803
804 HT_KVM_VALID_MOUSE_TYPES = frozenset([HT_MOUSE_MOUSE, HT_MOUSE_TABLET])
805
806 # Boot order
807 HT_BO_CDROM = "cdrom"
808 HT_BO_DISK = "disk"
809 HT_BO_NETWORK = "network"
810
811 HT_KVM_VALID_BO_TYPES = frozenset([HT_BO_CDROM, HT_BO_DISK, HT_BO_NETWORK])
812
813 # Security models
814 HT_SM_NONE = "none"
815 HT_SM_USER = "user"
816 HT_SM_POOL = "pool"
817
818 HT_KVM_VALID_SM_TYPES = frozenset([HT_SM_NONE, HT_SM_USER, HT_SM_POOL])
819
820 # Kvm flag values
821 HT_KVM_ENABLED = "enabled"
822 HT_KVM_DISABLED = "disabled"
823
824 HT_KVM_FLAG_VALUES = frozenset([HT_KVM_ENABLED, HT_KVM_DISABLED])
825
826 # Migration type
827 HT_MIGRATION_LIVE = "live"
828 HT_MIGRATION_NONLIVE = "non-live"
829 HT_MIGRATION_MODES = frozenset([HT_MIGRATION_LIVE, HT_MIGRATION_NONLIVE])
830
831 # Cluster Verify steps
832 VERIFY_NPLUSONE_MEM = 'nplusone_mem'
833 VERIFY_OPTIONAL_CHECKS = frozenset([VERIFY_NPLUSONE_MEM])
834
835 # Node verify constants
836 NV_DRBDHELPER = "drbd-helper"
837 NV_DRBDLIST = "drbd-list"
838 NV_FILELIST = "filelist"
839 NV_HVINFO = "hvinfo"
840 NV_HYPERVISOR = "hypervisor"
841 NV_INSTANCELIST = "instancelist"
842 NV_LVLIST = "lvlist"
843 NV_MASTERIP = "master-ip"
844 NV_NODELIST = "nodelist"
845 NV_NODENETTEST = "node-net-test"
846 NV_NODESETUP = "nodesetup"
847 NV_OSLIST = "oslist"
848 NV_PVLIST = "pvlist"
849 NV_TIME = "time"
850 NV_VERSION = "version"
851 NV_VGLIST = "vglist"
852 NV_VMNODES = "vmnodes"
853 NV_OOB_PATHS = "oob-paths"
854
855 # SSL certificate check constants (in days)
856 SSL_CERT_EXPIRATION_WARN = 30
857 SSL_CERT_EXPIRATION_ERROR = 7
858
859 # Allocator framework constants
860 IALLOCATOR_VERSION = 2
861 IALLOCATOR_DIR_IN = "in"
862 IALLOCATOR_DIR_OUT = "out"
863 VALID_IALLOCATOR_DIRECTIONS = frozenset([
864   IALLOCATOR_DIR_IN,
865   IALLOCATOR_DIR_OUT,
866   ])
867 IALLOCATOR_MODE_ALLOC = "allocate"
868 IALLOCATOR_MODE_RELOC = "relocate"
869 IALLOCATOR_MODE_MEVAC = "multi-evacuate"
870 VALID_IALLOCATOR_MODES = frozenset([
871   IALLOCATOR_MODE_ALLOC,
872   IALLOCATOR_MODE_RELOC,
873   IALLOCATOR_MODE_MEVAC,
874   ])
875 IALLOCATOR_SEARCH_PATH = _autoconf.IALLOCATOR_SEARCH_PATH
876
877 # Job queue
878 JOB_QUEUE_VERSION = 1
879 JOB_QUEUE_LOCK_FILE = QUEUE_DIR + "/lock"
880 JOB_QUEUE_VERSION_FILE = QUEUE_DIR + "/version"
881 JOB_QUEUE_SERIAL_FILE = QUEUE_DIR + "/serial"
882 JOB_QUEUE_ARCHIVE_DIR = QUEUE_DIR + "/archive"
883 JOB_QUEUE_DRAIN_FILE = QUEUE_DIR + "/drain"
884 JOB_QUEUE_SIZE_HARD_LIMIT = 5000
885 JOB_QUEUE_DIRS = [QUEUE_DIR, JOB_QUEUE_ARCHIVE_DIR]
886 JOB_QUEUE_DIRS_MODE = SECURE_DIR_MODE
887
888 JOB_ID_TEMPLATE = r"\d+"
889
890 # unchanged job return
891 JOB_NOTCHANGED = "nochange"
892
893 # Job status
894 JOB_STATUS_QUEUED = "queued"
895 JOB_STATUS_WAITLOCK = "waiting"
896 JOB_STATUS_CANCELING = "canceling"
897 JOB_STATUS_RUNNING = "running"
898 JOB_STATUS_CANCELED = "canceled"
899 JOB_STATUS_SUCCESS = "success"
900 JOB_STATUS_ERROR = "error"
901 JOBS_FINALIZED = frozenset([
902   JOB_STATUS_CANCELED,
903   JOB_STATUS_SUCCESS,
904   JOB_STATUS_ERROR,
905   ])
906 JOB_STATUS_ALL = frozenset([
907   JOB_STATUS_QUEUED,
908   JOB_STATUS_WAITLOCK,
909   JOB_STATUS_CANCELING,
910   JOB_STATUS_RUNNING,
911   ]) | JOBS_FINALIZED
912
913 # OpCode status
914 # not yet finalized
915 OP_STATUS_QUEUED = "queued"
916 OP_STATUS_WAITLOCK = "waiting"
917 OP_STATUS_CANCELING = "canceling"
918 OP_STATUS_RUNNING = "running"
919 # finalized
920 OP_STATUS_CANCELED = "canceled"
921 OP_STATUS_SUCCESS = "success"
922 OP_STATUS_ERROR = "error"
923 OPS_FINALIZED = frozenset([OP_STATUS_CANCELED,
924                            OP_STATUS_SUCCESS,
925                            OP_STATUS_ERROR])
926
927 # OpCode priority
928 OP_PRIO_LOWEST = +19
929 OP_PRIO_HIGHEST = -20
930
931 OP_PRIO_LOW = +10
932 OP_PRIO_NORMAL = 0
933 OP_PRIO_HIGH = -10
934
935 OP_PRIO_SUBMIT_VALID = frozenset([
936   OP_PRIO_LOW,
937   OP_PRIO_NORMAL,
938   OP_PRIO_HIGH,
939   ])
940
941 OP_PRIO_DEFAULT = OP_PRIO_NORMAL
942
943 # Execution log types
944 ELOG_MESSAGE = "message"
945 ELOG_PROGRESS = "progress"
946 ELOG_REMOTE_IMPORT = "remote-import"
947 ELOG_JQUEUE_TEST = "jqueue-test"
948
949 # /etc/hosts modification
950 ETC_HOSTS_ADD = "add"
951 ETC_HOSTS_REMOVE = "remove"
952
953 # Job queue test
954 JQT_MSGPREFIX = "TESTMSG="
955 JQT_EXPANDNAMES = "expandnames"
956 JQT_EXEC = "exec"
957 JQT_LOGMSG = "logmsg"
958 JQT_STARTMSG = "startmsg"
959 JQT_ALL = frozenset([
960   JQT_EXPANDNAMES,
961   JQT_EXEC,
962   JQT_LOGMSG,
963   JQT_STARTMSG,
964   ])
965
966 # Query resources
967 QR_INSTANCE = "instance"
968 QR_NODE = "node"
969 QR_LOCK = "lock"
970 QR_GROUP = "group"
971
972 #: List of resources which can be queried using L{opcodes.OpQuery}
973 QR_OP_QUERY = frozenset([QR_INSTANCE, QR_NODE, QR_GROUP])
974
975 #: List of resources which can be queried using LUXI
976 QR_OP_LUXI = QR_OP_QUERY.union([
977   QR_LOCK,
978   ])
979
980 # Query field types
981 QFT_UNKNOWN = "unknown"
982 QFT_TEXT = "text"
983 QFT_BOOL = "bool"
984 QFT_NUMBER = "number"
985 QFT_UNIT = "unit"
986 QFT_TIMESTAMP = "timestamp"
987 QFT_OTHER = "other"
988
989 #: All query field types
990 QFT_ALL = frozenset([
991   QFT_UNKNOWN,
992   QFT_TEXT,
993   QFT_BOOL,
994   QFT_NUMBER,
995   QFT_UNIT,
996   QFT_TIMESTAMP,
997   QFT_OTHER,
998   ])
999
1000 # Query result field status (don't change or reuse values as they're used by
1001 # clients)
1002 #: Normal field status
1003 RS_NORMAL = 0
1004 #: Unknown field
1005 RS_UNKNOWN = 1
1006 #: No data (e.g. RPC error), can be used instead of L{RS_OFFLINE}
1007 RS_NODATA = 2
1008 #: Value unavailable/unsupported for item; if this field is supported
1009 #: but we cannot get the data for the moment, RS_NODATA or
1010 #: RS_OFFLINE should be used
1011 RS_UNAVAIL = 3
1012 #: Resource marked offline
1013 RS_OFFLINE = 4
1014
1015 RS_ALL = frozenset([
1016   RS_NORMAL,
1017   RS_UNKNOWN,
1018   RS_NODATA,
1019   RS_UNAVAIL,
1020   RS_OFFLINE,
1021   ])
1022
1023 # max dynamic devices
1024 MAX_NICS = 8
1025 MAX_DISKS = 16
1026
1027 # SSCONF keys
1028 SS_CLUSTER_NAME = "cluster_name"
1029 SS_CLUSTER_TAGS = "cluster_tags"
1030 SS_FILE_STORAGE_DIR = "file_storage_dir"
1031 SS_MASTER_CANDIDATES = "master_candidates"
1032 SS_MASTER_CANDIDATES_IPS = "master_candidates_ips"
1033 SS_MASTER_IP = "master_ip"
1034 SS_MASTER_NETDEV = "master_netdev"
1035 SS_MASTER_NODE = "master_node"
1036 SS_NODE_LIST = "node_list"
1037 SS_NODE_PRIMARY_IPS = "node_primary_ips"
1038 SS_NODE_SECONDARY_IPS = "node_secondary_ips"
1039 SS_OFFLINE_NODES = "offline_nodes"
1040 SS_ONLINE_NODES = "online_nodes"
1041 SS_PRIMARY_IP_FAMILY = "primary_ip_family"
1042 SS_INSTANCE_LIST = "instance_list"
1043 SS_RELEASE_VERSION = "release_version"
1044 SS_HYPERVISOR_LIST = "hypervisor_list"
1045 SS_MAINTAIN_NODE_HEALTH = "maintain_node_health"
1046 SS_UID_POOL = "uid_pool"
1047 SS_NODEGROUPS = "nodegroups"
1048
1049 # cluster wide default parameters
1050 DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM
1051
1052 HVC_DEFAULTS = {
1053   HT_XEN_PVM: {
1054     HV_USE_BOOTLOADER: False,
1055     HV_BOOTLOADER_PATH: XEN_BOOTLOADER,
1056     HV_BOOTLOADER_ARGS: '',
1057     HV_KERNEL_PATH: "/boot/vmlinuz-2.6-xenU",
1058     HV_INITRD_PATH: '',
1059     HV_ROOT_PATH: '/dev/sda1',
1060     HV_KERNEL_ARGS: 'ro',
1061     HV_MIGRATION_PORT: 8002,
1062     HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1063     HV_BLOCKDEV_PREFIX: "sd",
1064     },
1065   HT_XEN_HVM: {
1066     HV_BOOT_ORDER: "cd",
1067     HV_CDROM_IMAGE_PATH: '',
1068     HV_NIC_TYPE: HT_NIC_RTL8139,
1069     HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
1070     HV_VNC_BIND_ADDRESS: IP4_ADDRESS_ANY,
1071     HV_VNC_PASSWORD_FILE: VNC_PASSWORD_FILE,
1072     HV_ACPI: True,
1073     HV_PAE: True,
1074     HV_KERNEL_PATH: "/usr/lib/xen/boot/hvmloader",
1075     HV_DEVICE_MODEL: "/usr/lib/xen/bin/qemu-dm",
1076     HV_MIGRATION_PORT: 8002,
1077     HV_MIGRATION_MODE: HT_MIGRATION_NONLIVE,
1078     HV_USE_LOCALTIME: False,
1079     HV_BLOCKDEV_PREFIX: "hd",
1080     },
1081   HT_KVM: {
1082     HV_KERNEL_PATH: "/boot/vmlinuz-2.6-kvmU",
1083     HV_INITRD_PATH: '',
1084     HV_KERNEL_ARGS: 'ro',
1085     HV_ROOT_PATH: '/dev/vda1',
1086     HV_ACPI: True,
1087     HV_SERIAL_CONSOLE: True,
1088     HV_VNC_BIND_ADDRESS: '',
1089     HV_VNC_TLS: False,
1090     HV_VNC_X509: '',
1091     HV_VNC_X509_VERIFY: False,
1092     HV_VNC_PASSWORD_FILE: '',
1093     HV_CDROM_IMAGE_PATH: '',
1094     HV_BOOT_ORDER: HT_BO_DISK,
1095     HV_NIC_TYPE: HT_NIC_PARAVIRTUAL,
1096     HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
1097     HV_USB_MOUSE: '',
1098     HV_MIGRATION_PORT: 8102,
1099     HV_MIGRATION_BANDWIDTH: 32, # MiB/s
1100     HV_MIGRATION_DOWNTIME: 30,  # ms
1101     HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1102     HV_USE_LOCALTIME: False,
1103     HV_DISK_CACHE: HT_CACHE_DEFAULT,
1104     HV_SECURITY_MODEL: HT_SM_NONE,
1105     HV_SECURITY_DOMAIN: '',
1106     HV_KVM_FLAG: "",
1107     HV_VHOST_NET: False,
1108     HV_KVM_USE_CHROOT: False,
1109     HV_MEM_PATH: "",
1110     },
1111   HT_FAKE: {
1112     },
1113   HT_CHROOT: {
1114     HV_INIT_SCRIPT: "/ganeti-chroot",
1115     },
1116   HT_LXC: {
1117     HV_CPU_MASK: "",
1118     },
1119   }
1120
1121 HVC_GLOBALS = frozenset([
1122   HV_MIGRATION_PORT,
1123   HV_MIGRATION_BANDWIDTH,
1124   HV_MIGRATION_MODE,
1125   ])
1126
1127 BEC_DEFAULTS = {
1128   BE_MEMORY: 128,
1129   BE_VCPUS: 1,
1130   BE_AUTO_BALANCE: True,
1131   }
1132
1133 NDC_DEFAULTS = {
1134   ND_OOB_PROGRAM: None,
1135   }
1136
1137 NICC_DEFAULTS = {
1138   NIC_MODE: NIC_MODE_BRIDGED,
1139   NIC_LINK: DEFAULT_BRIDGE,
1140   }
1141
1142 MASTER_POOL_SIZE_DEFAULT = 10
1143
1144 CONFD_PROTOCOL_VERSION = 1
1145
1146 CONFD_REQ_PING = 0
1147 CONFD_REQ_NODE_ROLE_BYNAME = 1
1148 CONFD_REQ_NODE_PIP_BY_INSTANCE_IP = 2
1149 CONFD_REQ_CLUSTER_MASTER = 3
1150 CONFD_REQ_NODE_PIP_LIST = 4
1151 CONFD_REQ_MC_PIP_LIST = 5
1152 CONFD_REQ_INSTANCES_IPS_LIST = 6
1153
1154 # Confd request query fields. These are used to narrow down queries.
1155 # These must be strings rather than integers, because json-encoding
1156 # converts them to strings anyway, as they're used as dict-keys.
1157 CONFD_REQQ_LINK = "0"
1158 CONFD_REQQ_IP = "1"
1159 CONFD_REQQ_IPLIST = "2"
1160 CONFD_REQQ_FIELDS = "3"
1161
1162 CONFD_REQFIELD_NAME = "0"
1163 CONFD_REQFIELD_IP = "1"
1164 CONFD_REQFIELD_MNODE_PIP = "2"
1165
1166 CONFD_REQS = frozenset([
1167   CONFD_REQ_PING,
1168   CONFD_REQ_NODE_ROLE_BYNAME,
1169   CONFD_REQ_NODE_PIP_BY_INSTANCE_IP,
1170   CONFD_REQ_CLUSTER_MASTER,
1171   CONFD_REQ_NODE_PIP_LIST,
1172   CONFD_REQ_MC_PIP_LIST,
1173   CONFD_REQ_INSTANCES_IPS_LIST,
1174   ])
1175
1176 CONFD_REPL_STATUS_OK = 0
1177 CONFD_REPL_STATUS_ERROR = 1
1178 CONFD_REPL_STATUS_NOTIMPLEMENTED = 2
1179
1180 CONFD_REPL_STATUSES = frozenset([
1181   CONFD_REPL_STATUS_OK,
1182   CONFD_REPL_STATUS_ERROR,
1183   CONFD_REPL_STATUS_NOTIMPLEMENTED,
1184   ])
1185
1186 (CONFD_NODE_ROLE_MASTER,
1187  CONFD_NODE_ROLE_CANDIDATE,
1188  CONFD_NODE_ROLE_OFFLINE,
1189  CONFD_NODE_ROLE_DRAINED,
1190  CONFD_NODE_ROLE_REGULAR,
1191  ) = range(5)
1192
1193 # A few common errors for confd
1194 CONFD_ERROR_UNKNOWN_ENTRY = 1
1195 CONFD_ERROR_INTERNAL = 2
1196 CONFD_ERROR_ARGUMENT = 3
1197
1198 # Each request is "salted" by the current timestamp.
1199 # This constants decides how many seconds of skew to accept.
1200 # TODO: make this a default and allow the value to be more configurable
1201 CONFD_MAX_CLOCK_SKEW = 2 * NODE_MAX_CLOCK_SKEW
1202
1203 # When we haven't reloaded the config for more than this amount of seconds, we
1204 # force a test to see if inotify is betraying us.
1205 CONFD_CONFIG_RELOAD_TIMEOUT = 60
1206
1207 # If we receive more than one update in this amount of seconds, we move to
1208 # polling every RATELIMIT seconds, rather than relying on inotify, to be able
1209 # to serve more requests.
1210 CONFD_CONFIG_RELOAD_RATELIMIT = 2
1211
1212 # Magic number prepended to all confd queries.
1213 # This allows us to distinguish different types of confd protocols and handle
1214 # them. For example by changing this we can move the whole payload to be
1215 # compressed, or move away from json.
1216 CONFD_MAGIC_FOURCC = 'plj0'
1217
1218 # By default a confd request is sent to the minimum between this number and all
1219 # MCs. 6 was chosen because even in the case of a disastrous 50% response rate,
1220 # we should have enough answers to be able to compare more than one.
1221 CONFD_DEFAULT_REQ_COVERAGE = 6
1222
1223 # Timeout in seconds to expire pending query request in the confd client
1224 # library. We don't actually expect any answer more than 10 seconds after we
1225 # sent a request.
1226 CONFD_CLIENT_EXPIRE_TIMEOUT = 10
1227
1228 # Maximum UDP datagram size.
1229 # On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
1230 # On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
1231 #   (assuming we can't use jumbo frames)
1232 # We just set this to 60K, which should be enough
1233 MAX_UDP_DATA_SIZE = 61440
1234
1235 # User-id pool minimum/maximum acceptable user-ids.
1236 UIDPOOL_UID_MIN = 0
1237 UIDPOOL_UID_MAX = 2**32-1 # Assuming 32 bit user-ids
1238
1239 # Name or path of the pgrep command
1240 PGREP = "pgrep"
1241
1242 # Name of the node group that gets created at cluster init or upgrade
1243 INITIAL_NODE_GROUP_NAME = "default"
1244
1245 # Possible values for NodeGroup.alloc_policy
1246 ALLOC_POLICY_PREFERRED = "preferred"
1247 ALLOC_POLICY_LAST_RESORT = "last_resort"
1248 ALLOC_POLICY_UNALLOCABLE = "unallocable"
1249 VALID_ALLOC_POLICIES = [
1250   ALLOC_POLICY_PREFERRED,
1251   ALLOC_POLICY_LAST_RESORT,
1252   ALLOC_POLICY_UNALLOCABLE,
1253   ]