1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 """Module holding different constants."""
23
24 import re
25
26 from ganeti import _autoconf
27
28
29 PROTOCOL_VERSION = 40
30 RELEASE_VERSION = _autoconf.PACKAGE_VERSION
31 OS_API_V10 = 10
32 OS_API_V15 = 15
33 OS_API_V20 = 20
34 OS_API_VERSIONS = frozenset([OS_API_V10, OS_API_V15, OS_API_V20])
35 VCS_VERSION = _autoconf.VCS_VERSION
36 EXPORT_VERSION = 0
37 RAPI_VERSION = 2
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
55 """Calculates int version number from major, minor and revision numbers.
56
57 Returns: int representing version number
58
59 """
60 assert isinstance(major, int)
61 assert isinstance(minor, int)
62 assert isinstance(revision, int)
63 return (1000000 * major +
64 10000 * minor +
65 1 * revision)
66
67
69 """Splits version number stored in an int.
70
71 Returns: tuple; (major, minor, revision)
72
73 """
74 assert isinstance(version, int)
75
76 (major, remainder) = divmod(version, 1000000)
77 (minor, revision) = divmod(remainder, 10000)
78
79 return (major, minor, revision)
80
81
82 CONFIG_MAJOR = int(_autoconf.VERSION_MAJOR)
83 CONFIG_MINOR = int(_autoconf.VERSION_MINOR)
84 CONFIG_REVISION = 0
85 CONFIG_VERSION = BuildVersion(CONFIG_MAJOR, CONFIG_MINOR, CONFIG_REVISION)
86
87
88 DAEMONS_GROUP = _autoconf.DAEMONS_GROUP
89 MASTERD_USER = _autoconf.MASTERD_USER
90 RAPI_USER = _autoconf.RAPI_USER
91
92
93 DATA_DIR = _autoconf.LOCALSTATEDIR + "/lib/ganeti"
94 RUN_DIR = _autoconf.LOCALSTATEDIR + "/run"
95 RUN_GANETI_DIR = RUN_DIR + "/ganeti"
96 BDEV_CACHE_DIR = RUN_GANETI_DIR + "/bdev-cache"
97 DISK_LINKS_DIR = RUN_GANETI_DIR + "/instance-disks"
98 RUN_DIRS_MODE = 0775
99 SOCKET_DIR = RUN_GANETI_DIR + "/socket"
100 SECURE_DIR_MODE = 0700
101 SECURE_FILE_MODE = 0600
102 SOCKET_DIR_MODE = 0750
103 CRYPTO_KEYS_DIR = RUN_GANETI_DIR + "/crypto"
104 CRYPTO_KEYS_DIR_MODE = SECURE_DIR_MODE
105 IMPORT_EXPORT_DIR = RUN_GANETI_DIR + "/import-export"
106 IMPORT_EXPORT_DIR_MODE = 0755
107
108
109 SUB_RUN_DIRS = [ RUN_GANETI_DIR, BDEV_CACHE_DIR, DISK_LINKS_DIR ]
110 LOCK_DIR = _autoconf.LOCALSTATEDIR + "/lock"
111 SSCONF_LOCK_FILE = LOCK_DIR + "/ganeti-ssconf.lock"
112
113
114 UIDPOOL_LOCKDIR = RUN_GANETI_DIR + "/uid-pool"
115 CLUSTER_CONF_FILE = DATA_DIR + "/config.data"
116 NODED_CERT_FILE = DATA_DIR + "/server.pem"
117 RAPI_CERT_FILE = DATA_DIR + "/rapi.pem"
118 CONFD_HMAC_KEY = DATA_DIR + "/hmac.key"
119 CLUSTER_DOMAIN_SECRET_FILE = DATA_DIR + "/cluster-domain-secret"
120 WATCHER_STATEFILE = DATA_DIR + "/watcher.data"
121 WATCHER_PAUSEFILE = DATA_DIR + "/watcher.pause"
122 INSTANCE_UPFILE = RUN_GANETI_DIR + "/instance-status"
123 SSH_KNOWN_HOSTS_FILE = DATA_DIR + "/known_hosts"
124 RAPI_USERS_FILE = DATA_DIR + "/rapi_users"
125 QUEUE_DIR = DATA_DIR + "/queue"
126 DAEMON_UTIL = _autoconf.PKGLIBDIR + "/daemon-util"
127 ETC_HOSTS = "/etc/hosts"
128 DEFAULT_FILE_STORAGE_DIR = _autoconf.FILE_STORAGE_DIR
129 ENABLE_FILE_STORAGE = _autoconf.ENABLE_FILE_STORAGE
130 SYSCONFDIR = _autoconf.SYSCONFDIR
131 TOOLSDIR = _autoconf.TOOLSDIR
132 CONF_DIR = SYSCONFDIR + "/ganeti"
133
134 ALL_CERT_FILES = frozenset([NODED_CERT_FILE, RAPI_CERT_FILE])
135
136 MASTER_SOCKET = SOCKET_DIR + "/ganeti-master"
137
138 NODED = "ganeti-noded"
139 CONFD = "ganeti-confd"
140 RAPI = "ganeti-rapi"
141 MASTERD = "ganeti-masterd"
142
143 NLD = "ganeti-nld"
144
145 DAEMONS_PORTS = {
146
147 NODED: ("tcp", 1811),
148 CONFD: ("udp", 1814),
149 RAPI: ("tcp", 5080),
150 "ssh": ("tcp", 22),
151
152 NLD: ("udp", 1816),
153 }
154 DEFAULT_NODED_PORT = DAEMONS_PORTS[NODED][1]
155 DEFAULT_CONFD_PORT = DAEMONS_PORTS[CONFD][1]
156 DEFAULT_RAPI_PORT = DAEMONS_PORTS[RAPI][1]
157
158 DEFAULT_NLD_PORT = DAEMONS_PORTS[NLD][1]
159
160 FIRST_DRBD_PORT = 11000
161 LAST_DRBD_PORT = 14999
162 MASTER_SCRIPT = "ganeti-master"
163
164 LOG_DIR = _autoconf.LOCALSTATEDIR + "/log/ganeti/"
165 DAEMONS_LOGFILES = {
166
167 NODED: LOG_DIR + "node-daemon.log",
168 CONFD: LOG_DIR + "conf-daemon.log",
169 RAPI: LOG_DIR + "rapi-daemon.log",
170 MASTERD: LOG_DIR + "master-daemon.log",
171
172 NLD: LOG_DIR + "nl-daemon.log",
173 }
174
175 LOG_OS_DIR = LOG_DIR + "os"
176 LOG_WATCHER = LOG_DIR + "watcher.log"
177 LOG_COMMANDS = LOG_DIR + "commands.log"
178 LOG_BURNIN = LOG_DIR + "burnin.log"
179 LOG_SETUP_SSH = LOG_DIR + "setup-ssh.log"
180
181 DEV_CONSOLE = "/dev/console"
182
183 PROC_MOUNTS = "/proc/mounts"
184
185
186 LUXI_EOM = "\3"
187
188
189 SYSLOG_USAGE = _autoconf.SYSLOG_USAGE
190 SYSLOG_NO = "no"
191 SYSLOG_YES = "yes"
192 SYSLOG_ONLY = "only"
193 SYSLOG_SOCKET = "/dev/log"
194
195 OS_SEARCH_PATH = _autoconf.OS_SEARCH_PATH
196 EXPORT_DIR = _autoconf.EXPORT_DIR
197
198 EXPORT_CONF_FILE = "config.ini"
199
200 XEN_BOOTLOADER = _autoconf.XEN_BOOTLOADER
201 XEN_KERNEL = _autoconf.XEN_KERNEL
202 XEN_INITRD = _autoconf.XEN_INITRD
203
204 KVM_PATH = _autoconf.KVM_PATH
205 SOCAT_PATH = _autoconf.SOCAT_PATH
206 SOCAT_USE_ESCAPE = _autoconf.SOCAT_USE_ESCAPE
207 SOCAT_ESCAPE_CODE = "0x1d"
208
209
210
211
212 RSA_KEY_BITS = 2048
213
214
215
216
217
218
219
220 OPENSSL_CIPHERS = "HIGH:-DES:-3DES:-EXPORT:-ADH"
221
222
223 X509_CERT_SIGN_DIGEST = "SHA1"
224
225
226 X509_CERT_DEFAULT_VALIDITY = 365 * 5
227
228
229 X509_CERT_CN = "ganeti.example.com"
230
231 X509_CERT_SIGNATURE_HEADER = "X-Ganeti-Signature"
232
233 IMPORT_EXPORT_DAEMON = _autoconf.PKGLIBDIR + "/import-export"
234
235
236 IEM_IMPORT = "import"
237 IEM_EXPORT = "export"
238
239
240 IEC_NONE = "none"
241 IEC_GZIP = "gzip"
242 IEC_ALL = frozenset([
243 IEC_NONE,
244 IEC_GZIP,
245 ])
246
247 IE_CUSTOM_SIZE = "fd"
248
249 IE_MAGIC_RE = re.compile(r"^[-_.a-zA-Z0-9]{5,100}$")
250
251
252
253 IEIO_FILE = "file"
254
255 IEIO_RAW_DISK = "raw"
256
257 IEIO_SCRIPT = "script"
258
259 VALUE_DEFAULT = "default"
260 VALUE_AUTO = "auto"
261 VALUE_GENERATE = "generate"
262 VALUE_NONE = "none"
263 VALUE_TRUE = "true"
264 VALUE_FALSE = "false"
265
266
267 EXT_PLUGIN_MASK = re.compile("^[a-zA-Z0-9_-]+$")
268
269
270 HOOKS_BASE_DIR = CONF_DIR + "/hooks"
271 HOOKS_PHASE_PRE = "pre"
272 HOOKS_PHASE_POST = "post"
273 HOOKS_NAME_CFGUPDATE = "config-update"
274 HOOKS_NAME_WATCHER = "watcher"
275 HOOKS_VERSION = 2
276
277
278 HTYPE_CLUSTER = "CLUSTER"
279 HTYPE_NODE = "NODE"
280 HTYPE_INSTANCE = "INSTANCE"
281
282 HKR_SKIP = 0
283 HKR_FAIL = 1
284 HKR_SUCCESS = 2
285
286
287 ST_FILE = "file"
288 ST_LVM_PV = "lvm-pv"
289 ST_LVM_VG = "lvm-vg"
290
291
292
293 SF_NODE = "node"
294 SF_TYPE = "type"
295
296 SF_NAME = "name"
297 SF_SIZE = "size"
298 SF_FREE = "free"
299 SF_USED = "used"
300 SF_ALLOCATABLE = "allocatable"
301
302
303 SO_FIX_CONSISTENCY = "fix-consistency"
304
305
306 VALID_STORAGE_FIELDS = frozenset([SF_NAME, SF_TYPE, SF_SIZE,
307 SF_USED, SF_FREE, SF_ALLOCATABLE])
308
309 VALID_STORAGE_TYPES = frozenset([ST_FILE, ST_LVM_PV, ST_LVM_VG])
310
311 MODIFIABLE_STORAGE_FIELDS = {
312 ST_LVM_PV: frozenset([SF_ALLOCATABLE]),
313 }
314
315 VALID_STORAGE_OPERATIONS = {
316 ST_LVM_VG: frozenset([SO_FIX_CONSISTENCY]),
317 }
318
319
320
321 (LDS_OKAY,
322 LDS_UNKNOWN,
323 LDS_FAULTY) = range(1, 4)
324
325
326 DT_DISKLESS = "diskless"
327 DT_PLAIN = "plain"
328 DT_DRBD8 = "drbd"
329 DT_FILE = "file"
330
331
332 DTS_NET_MIRROR = frozenset([DT_DRBD8])
333
334
335 DTS_NOT_LVM = frozenset([DT_DISKLESS, DT_FILE])
336
337
338 DTS_GROWABLE = frozenset([DT_PLAIN, DT_DRBD8, DT_FILE])
339
340
341 DTS_MAY_ADOPT = frozenset([DT_PLAIN])
342
343
344 LD_LV = "lvm"
345 LD_DRBD8 = "drbd8"
346 LD_FILE = "file"
347 LDS_BLOCK = frozenset([LD_LV, LD_DRBD8])
348
349
350 DRBD_HMAC_ALG = "md5"
351 DRBD_NET_PROTOCOL = "C"
352 DRBD_BARRIERS = _autoconf.DRBD_BARRIERS
353
354
355 FD_LOOP = "loop"
356 FD_BLKTAP = "blktap"
357
358
359 LDS_DRBD = frozenset([LD_DRBD8])
360
361
362 DISK_RDONLY = "ro"
363 DISK_RDWR = "rw"
364 DISK_ACCESS_SET = frozenset([DISK_RDONLY, DISK_RDWR])
365
366
367 REPLACE_DISK_PRI = "replace_on_primary"
368 REPLACE_DISK_SEC = "replace_on_secondary"
369 REPLACE_DISK_CHG = "replace_new_secondary"
370 REPLACE_DISK_AUTO = "replace_auto"
371 REPLACE_MODES = frozenset([
372 REPLACE_DISK_PRI,
373 REPLACE_DISK_SEC,
374 REPLACE_DISK_CHG,
375 REPLACE_DISK_AUTO,
376 ])
377
378
379 EXPORT_MODE_LOCAL = "local"
380 EXPORT_MODE_REMOTE = "remote"
381 EXPORT_MODES = frozenset([
382 EXPORT_MODE_LOCAL,
383 EXPORT_MODE_REMOTE,
384 ])
385
386
387 LOCKS_REPLACE = 'replace'
388 LOCKS_APPEND = 'append'
389
390
391 INSTANCE_CREATE = "create"
392 INSTANCE_IMPORT = "import"
393 INSTANCE_REMOTE_IMPORT = "remote-import"
394 INSTANCE_CREATE_MODES = frozenset([
395 INSTANCE_CREATE,
396 INSTANCE_IMPORT,
397 INSTANCE_REMOTE_IMPORT,
398 ])
399
400
401 RIE_VERSION = 0
402 RIE_HANDSHAKE = "Hi, I'm Ganeti"
403
404
405 RIE_CERT_VALIDITY = 24 * 60 * 60
406
407
408 RIE_CONNECT_TIMEOUT = 60
409
410 DISK_TEMPLATES = frozenset([DT_DISKLESS, DT_PLAIN,
411 DT_DRBD8, DT_FILE])
412
413 FILE_DRIVER = frozenset([FD_LOOP, FD_BLKTAP])
414
415
416 INISECT_EXP = "export"
417 INISECT_INS = "instance"
418 INISECT_HYP = "hypervisor"
419 INISECT_BEP = "backend"
420 INISECT_OSP = "os"
421
422
423 DDM_ADD = "add"
424 DDM_REMOVE = "remove"
425 DDMS_VALUES = frozenset([DDM_ADD, DDM_REMOVE])
426
427
428 EXIT_SUCCESS = 0
429 EXIT_FAILURE = 1
430 EXIT_NOTCLUSTER = 5
431 EXIT_NOTMASTER = 11
432 EXIT_NODESETUP_ERROR = 12
433 EXIT_CONFIRMATION = 13
434
435
436 TAG_CLUSTER = "cluster"
437 TAG_NODE = "node"
438 TAG_INSTANCE = "instance"
439 VALID_TAG_TYPES = frozenset([
440 TAG_CLUSTER,
441 TAG_NODE,
442 TAG_INSTANCE,
443 ])
444 MAX_TAG_LEN = 128
445 MAX_TAGS_PER_OBJ = 4096
446
447
448 DEFAULT_BRIDGE = "xen-br0"
449 SYNC_SPEED = 60 * 1024
450 IP4_ADDRESS_LOCALHOST = "127.0.0.1"
451 IP4_ADDRESS_ANY = "0.0.0.0"
452 IP6_ADDRESS_LOCALHOST = "::1"
453 IP6_ADDRESS_ANY = "::"
454 TCP_PING_TIMEOUT = 10
455 GANETI_RUNAS = "root"
456 DEFAULT_VG = "xenvg"
457 DEFAULT_DRBD_HELPER = "/bin/true"
458 MIN_VG_SIZE = 20480
459 DEFAULT_MAC_PREFIX = "aa:00:00"
460 LVM_STRIPECOUNT = _autoconf.LVM_STRIPECOUNT
461
462 DEFAULT_SHUTDOWN_TIMEOUT = 120
463 NODE_MAX_CLOCK_SKEW = 150
464
465 DISK_TRANSFER_CONNECT_TIMEOUT = 30
466
467
468 (RUNPARTS_SKIP,
469 RUNPARTS_RUN,
470 RUNPARTS_ERR) = range(3)
471
472 RUNPARTS_STATUS = frozenset([RUNPARTS_SKIP, RUNPARTS_RUN, RUNPARTS_ERR])
473
474
475 (RPC_ENCODING_NONE,
476 RPC_ENCODING_ZLIB_BASE64) = range(2)
477
478
479 OS_SCRIPT_CREATE = 'create'
480 OS_SCRIPT_IMPORT = 'import'
481 OS_SCRIPT_EXPORT = 'export'
482 OS_SCRIPT_RENAME = 'rename'
483 OS_SCRIPT_VERIFY = 'verify'
484 OS_SCRIPTS = frozenset([OS_SCRIPT_CREATE, OS_SCRIPT_IMPORT,
485 OS_SCRIPT_EXPORT, OS_SCRIPT_RENAME,
486 OS_SCRIPT_VERIFY])
487
488 OS_API_FILE = 'ganeti_api_version'
489 OS_VARIANTS_FILE = 'variants.list'
490 OS_PARAMETERS_FILE = 'parameters.list'
491
492 OS_VALIDATE_PARAMETERS = 'parameters'
493 OS_VALIDATE_CALLS = frozenset([OS_VALIDATE_PARAMETERS])
494
495
496 SSH_CONFIG_DIR = _autoconf.SSH_CONFIG_DIR
497 SSH_HOST_DSA_PRIV = SSH_CONFIG_DIR + "/ssh_host_dsa_key"
498 SSH_HOST_DSA_PUB = SSH_HOST_DSA_PRIV + ".pub"
499 SSH_HOST_RSA_PRIV = SSH_CONFIG_DIR + "/ssh_host_rsa_key"
500 SSH_HOST_RSA_PUB = SSH_HOST_RSA_PRIV + ".pub"
501 SSH = "ssh"
502 SCP = "scp"
503
504
505 INSTANCE_REBOOT_SOFT = "soft"
506 INSTANCE_REBOOT_HARD = "hard"
507 INSTANCE_REBOOT_FULL = "full"
508
509 REBOOT_TYPES = frozenset([INSTANCE_REBOOT_SOFT,
510 INSTANCE_REBOOT_HARD,
511 INSTANCE_REBOOT_FULL])
512
513 VTYPE_STRING = 'string'
514 VTYPE_MAYBE_STRING = "maybe-string"
515 VTYPE_BOOL = 'bool'
516 VTYPE_SIZE = 'size'
517 VTYPE_INT = 'int'
518 ENFORCEABLE_TYPES = frozenset([
519 VTYPE_STRING,
520 VTYPE_MAYBE_STRING,
521 VTYPE_BOOL,
522 VTYPE_SIZE,
523 VTYPE_INT,
524 ])
525
526
527 HV_BOOT_ORDER = "boot_order"
528 HV_CDROM_IMAGE_PATH = "cdrom_image_path"
529 HV_NIC_TYPE = "nic_type"
530 HV_DISK_TYPE = "disk_type"
531 HV_VNC_BIND_ADDRESS = "vnc_bind_address"
532 HV_VNC_PASSWORD_FILE = "vnc_password_file"
533 HV_VNC_TLS = "vnc_tls"
534 HV_VNC_X509 = "vnc_x509_path"
535 HV_VNC_X509_VERIFY = "vnc_x509_verify"
536 HV_ACPI = "acpi"
537 HV_PAE = "pae"
538 HV_USE_BOOTLOADER = "use_bootloader"
539 HV_BOOTLOADER_ARGS = "bootloader_args"
540 HV_BOOTLOADER_PATH = "bootloader_path"
541 HV_KERNEL_ARGS = "kernel_args"
542 HV_KERNEL_PATH = "kernel_path"
543 HV_INITRD_PATH = "initrd_path"
544 HV_ROOT_PATH = "root_path"
545 HV_SERIAL_CONSOLE = "serial_console"
546 HV_USB_MOUSE = "usb_mouse"
547 HV_DEVICE_MODEL = "device_model"
548 HV_INIT_SCRIPT = "init_script"
549 HV_MIGRATION_PORT = "migration_port"
550 HV_MIGRATION_BANDWIDTH = "migration_bandwidth"
551 HV_MIGRATION_DOWNTIME = "migration_downtime"
552 HV_MIGRATION_MODE = "migration_mode"
553 HV_USE_LOCALTIME = "use_localtime"
554 HV_DISK_CACHE = "disk_cache"
555 HV_SECURITY_MODEL = "security_model"
556 HV_SECURITY_DOMAIN = "security_domain"
557 HV_KVM_FLAG = "kvm_flag"
558 HV_VHOST_NET = "vhost_net"
559 HV_KVM_USE_CHROOT = "use_chroot"
560 HV_CPU_MASK = "cpu_mask"
561 HV_MEM_PATH = "mem_path"
562
563 HVS_PARAMETER_TYPES = {
564 HV_BOOT_ORDER: VTYPE_STRING,
565 HV_CDROM_IMAGE_PATH: VTYPE_STRING,
566 HV_NIC_TYPE: VTYPE_STRING,
567 HV_DISK_TYPE: VTYPE_STRING,
568 HV_VNC_PASSWORD_FILE: VTYPE_STRING,
569 HV_VNC_BIND_ADDRESS: VTYPE_STRING,
570 HV_VNC_TLS: VTYPE_BOOL,
571 HV_VNC_X509: VTYPE_STRING,
572 HV_VNC_X509_VERIFY: VTYPE_BOOL,
573 HV_ACPI: VTYPE_BOOL,
574 HV_PAE: VTYPE_BOOL,
575 HV_USE_BOOTLOADER: VTYPE_BOOL,
576 HV_BOOTLOADER_PATH: VTYPE_STRING,
577 HV_BOOTLOADER_ARGS: VTYPE_STRING,
578 HV_KERNEL_PATH: VTYPE_STRING,
579 HV_KERNEL_ARGS: VTYPE_STRING,
580 HV_INITRD_PATH: VTYPE_STRING,
581 HV_ROOT_PATH: VTYPE_STRING,
582 HV_SERIAL_CONSOLE: VTYPE_BOOL,
583 HV_USB_MOUSE: VTYPE_STRING,
584 HV_DEVICE_MODEL: VTYPE_STRING,
585 HV_INIT_SCRIPT: VTYPE_STRING,
586 HV_MIGRATION_PORT: VTYPE_INT,
587 HV_MIGRATION_BANDWIDTH: VTYPE_INT,
588 HV_MIGRATION_DOWNTIME: VTYPE_INT,
589 HV_MIGRATION_MODE: VTYPE_STRING,
590 HV_USE_LOCALTIME: VTYPE_BOOL,
591 HV_DISK_CACHE: VTYPE_STRING,
592 HV_SECURITY_MODEL: VTYPE_STRING,
593 HV_SECURITY_DOMAIN: VTYPE_STRING,
594 HV_KVM_FLAG: VTYPE_STRING,
595 HV_VHOST_NET: VTYPE_BOOL,
596 HV_KVM_USE_CHROOT: VTYPE_BOOL,
597 HV_CPU_MASK: VTYPE_STRING,
598 HV_MEM_PATH: VTYPE_STRING,
599 }
600
601 HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
602
603
604 BE_MEMORY = "memory"
605 BE_VCPUS = "vcpus"
606 BE_AUTO_BALANCE = "auto_balance"
607
608 BES_PARAMETER_TYPES = {
609 BE_MEMORY: VTYPE_SIZE,
610 BE_VCPUS: VTYPE_INT,
611 BE_AUTO_BALANCE: VTYPE_BOOL,
612 }
613
614 BES_PARAMETERS = frozenset(BES_PARAMETER_TYPES.keys())
615
616
617 PP_DEFAULT = "default"
618
619 NIC_MODE = "mode"
620 NIC_LINK = "link"
621
622 NIC_MODE_BRIDGED = "bridged"
623 NIC_MODE_ROUTED = "routed"
624
625 NIC_VALID_MODES = frozenset([NIC_MODE_BRIDGED, NIC_MODE_ROUTED])
626
627 NICS_PARAMETER_TYPES = {
628 NIC_MODE: VTYPE_STRING,
629 NIC_LINK: VTYPE_STRING,
630 }
631
632 NICS_PARAMETERS = frozenset(NICS_PARAMETER_TYPES.keys())
633
634 IDISK_SIZE = "size"
635 IDISK_MODE = "mode"
636 IDISK_ADOPT = "adopt"
637 IDISK_PARAMS_TYPES = {
638 IDISK_SIZE: VTYPE_SIZE,
639 IDISK_MODE: VTYPE_STRING,
640 IDISK_ADOPT: VTYPE_STRING,
641 }
642 IDISK_PARAMS = frozenset(IDISK_PARAMS_TYPES.keys())
643
644 INIC_MAC = "mac"
645 INIC_IP = "ip"
646 INIC_MODE = "mode"
647 INIC_LINK = "link"
648 INIC_BRIDGE = "bridge"
649 INIC_PARAMS_TYPES = {
650 INIC_BRIDGE: VTYPE_STRING,
651 INIC_IP: VTYPE_MAYBE_STRING,
652 INIC_LINK: VTYPE_STRING,
653 INIC_MAC: VTYPE_STRING,
654 INIC_MODE: VTYPE_STRING,
655 }
656 INIC_PARAMS = frozenset(INIC_PARAMS_TYPES.keys())
657
658
659 HT_XEN_PVM = "xen-pvm"
660 HT_FAKE = "fake"
661 HT_XEN_HVM = "xen-hvm"
662 HT_KVM = "kvm"
663 HT_CHROOT = "chroot"
664 HT_LXC = "lxc"
665 HYPER_TYPES = frozenset([
666 HT_XEN_PVM,
667 HT_FAKE,
668 HT_XEN_HVM,
669 HT_KVM,
670 HT_CHROOT,
671 HT_LXC,
672 ])
673 HTS_REQ_PORT = frozenset([HT_XEN_HVM, HT_KVM])
674
675 VNC_BASE_PORT = 5900
676 VNC_PASSWORD_FILE = CONF_DIR + "/vnc-cluster-password"
677 VNC_DEFAULT_BIND_ADDRESS = IP4_ADDRESS_ANY
678
679
680 HT_NIC_RTL8139 = "rtl8139"
681 HT_NIC_NE2K_PCI = "ne2k_pci"
682 HT_NIC_NE2K_ISA = "ne2k_isa"
683 HT_NIC_I82551 = "i82551"
684 HT_NIC_I85557B = "i82557b"
685 HT_NIC_I8259ER = "i82559er"
686 HT_NIC_PCNET = "pcnet"
687 HT_NIC_E1000 = "e1000"
688 HT_NIC_PARAVIRTUAL = HT_DISK_PARAVIRTUAL = "paravirtual"
689
690 HT_HVM_VALID_NIC_TYPES = frozenset([HT_NIC_RTL8139, HT_NIC_NE2K_PCI,
691 HT_NIC_NE2K_ISA, HT_NIC_PARAVIRTUAL])
692 HT_KVM_VALID_NIC_TYPES = frozenset([HT_NIC_RTL8139, HT_NIC_NE2K_PCI,
693 HT_NIC_NE2K_ISA, HT_NIC_I82551,
694 HT_NIC_I85557B, HT_NIC_I8259ER,
695 HT_NIC_PCNET, HT_NIC_E1000,
696 HT_NIC_PARAVIRTUAL])
697
698 HT_DISK_IOEMU = "ioemu"
699 HT_DISK_IDE = "ide"
700 HT_DISK_SCSI = "scsi"
701 HT_DISK_SD = "sd"
702 HT_DISK_MTD = "mtd"
703 HT_DISK_PFLASH = "pflash"
704
705 HT_CACHE_DEFAULT = "default"
706 HT_CACHE_NONE = "none"
707 HT_CACHE_WTHROUGH = "writethrough"
708 HT_CACHE_WBACK = "writeback"
709 HT_VALID_CACHE_TYPES = frozenset([HT_CACHE_DEFAULT,
710 HT_CACHE_NONE,
711 HT_CACHE_WTHROUGH,
712 HT_CACHE_WBACK])
713
714 HT_HVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IOEMU])
715 HT_KVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IDE,
716 HT_DISK_SCSI, HT_DISK_SD, HT_DISK_MTD,
717 HT_DISK_PFLASH])
718
719
720 HT_MOUSE_MOUSE = "mouse"
721 HT_MOUSE_TABLET = "tablet"
722
723 HT_KVM_VALID_MOUSE_TYPES = frozenset([HT_MOUSE_MOUSE, HT_MOUSE_TABLET])
724
725
726 HT_BO_CDROM = "cdrom"
727 HT_BO_DISK = "disk"
728 HT_BO_NETWORK = "network"
729
730 HT_KVM_VALID_BO_TYPES = frozenset([HT_BO_CDROM, HT_BO_DISK, HT_BO_NETWORK])
731
732
733 HT_SM_NONE = "none"
734 HT_SM_USER = "user"
735 HT_SM_POOL = "pool"
736
737 HT_KVM_VALID_SM_TYPES = frozenset([HT_SM_NONE, HT_SM_USER, HT_SM_POOL])
738
739
740 HT_KVM_ENABLED = "enabled"
741 HT_KVM_DISABLED = "disabled"
742
743 HT_KVM_FLAG_VALUES = frozenset([HT_KVM_ENABLED, HT_KVM_DISABLED])
744
745
746 HT_MIGRATION_LIVE = "live"
747 HT_MIGRATION_NONLIVE = "non-live"
748 HT_MIGRATION_MODES = frozenset([HT_MIGRATION_LIVE, HT_MIGRATION_NONLIVE])
749
750
751 VERIFY_NPLUSONE_MEM = 'nplusone_mem'
752 VERIFY_OPTIONAL_CHECKS = frozenset([VERIFY_NPLUSONE_MEM])
753
754
755 NV_DRBDHELPER = "drbd-helper"
756 NV_DRBDLIST = "drbd-list"
757 NV_FILELIST = "filelist"
758 NV_HVINFO = "hvinfo"
759 NV_HYPERVISOR = "hypervisor"
760 NV_INSTANCELIST = "instancelist"
761 NV_LVLIST = "lvlist"
762 NV_MASTERIP = "master-ip"
763 NV_NODELIST = "nodelist"
764 NV_NODENETTEST = "node-net-test"
765 NV_NODESETUP = "nodesetup"
766 NV_OSLIST = "oslist"
767 NV_PVLIST = "pvlist"
768 NV_TIME = "time"
769 NV_VERSION = "version"
770 NV_VGLIST = "vglist"
771
772
773 SSL_CERT_EXPIRATION_WARN = 30
774 SSL_CERT_EXPIRATION_ERROR = 7
775
776
777 IALLOCATOR_VERSION = 2
778 IALLOCATOR_DIR_IN = "in"
779 IALLOCATOR_DIR_OUT = "out"
780 VALID_IALLOCATOR_DIRECTIONS = frozenset([
781 IALLOCATOR_DIR_IN,
782 IALLOCATOR_DIR_OUT,
783 ])
784 IALLOCATOR_MODE_ALLOC = "allocate"
785 IALLOCATOR_MODE_RELOC = "relocate"
786 IALLOCATOR_MODE_MEVAC = "multi-evacuate"
787 VALID_IALLOCATOR_MODES = frozenset([
788 IALLOCATOR_MODE_ALLOC,
789 IALLOCATOR_MODE_RELOC,
790 IALLOCATOR_MODE_MEVAC,
791 ])
792 IALLOCATOR_SEARCH_PATH = _autoconf.IALLOCATOR_SEARCH_PATH
793
794
795 JOB_QUEUE_VERSION = 1
796 JOB_QUEUE_LOCK_FILE = QUEUE_DIR + "/lock"
797 JOB_QUEUE_VERSION_FILE = QUEUE_DIR + "/version"
798 JOB_QUEUE_SERIAL_FILE = QUEUE_DIR + "/serial"
799 JOB_QUEUE_ARCHIVE_DIR = QUEUE_DIR + "/archive"
800 JOB_QUEUE_DRAIN_FILE = QUEUE_DIR + "/drain"
801 JOB_QUEUE_SIZE_HARD_LIMIT = 5000
802 JOB_QUEUE_DIRS = [QUEUE_DIR, JOB_QUEUE_ARCHIVE_DIR]
803 JOB_QUEUE_DIRS_MODE = SECURE_DIR_MODE
804
805 JOB_ID_TEMPLATE = r"\d+"
806
807
808 JOB_NOTCHANGED = "nochange"
809
810
811 JOB_STATUS_QUEUED = "queued"
812 JOB_STATUS_WAITLOCK = "waiting"
813 JOB_STATUS_CANCELING = "canceling"
814 JOB_STATUS_RUNNING = "running"
815 JOB_STATUS_CANCELED = "canceled"
816 JOB_STATUS_SUCCESS = "success"
817 JOB_STATUS_ERROR = "error"
818 JOBS_FINALIZED = frozenset([
819 JOB_STATUS_CANCELED,
820 JOB_STATUS_SUCCESS,
821 JOB_STATUS_ERROR,
822 ])
823
824
825
826 OP_STATUS_QUEUED = "queued"
827 OP_STATUS_WAITLOCK = "waiting"
828 OP_STATUS_CANCELING = "canceling"
829 OP_STATUS_RUNNING = "running"
830
831 OP_STATUS_CANCELED = "canceled"
832 OP_STATUS_SUCCESS = "success"
833 OP_STATUS_ERROR = "error"
834 OPS_FINALIZED = frozenset([OP_STATUS_CANCELED,
835 OP_STATUS_SUCCESS,
836 OP_STATUS_ERROR])
837
838
839 ELOG_MESSAGE = "message"
840 ELOG_PROGRESS = "progress"
841 ELOG_REMOTE_IMPORT = "remote-import"
842 ELOG_JQUEUE_TEST = "jqueue-test"
843
844
845 JQT_MSGPREFIX = "TESTMSG="
846 JQT_EXPANDNAMES = "expandnames"
847 JQT_EXEC = "exec"
848 JQT_LOGMSG = "logmsg"
849 JQT_STARTMSG = "startmsg"
850 JQT_ALL = frozenset([
851 JQT_EXPANDNAMES,
852 JQT_EXEC,
853 JQT_LOGMSG,
854 JQT_STARTMSG,
855 ])
856
857
858 MAX_NICS = 8
859 MAX_DISKS = 16
860
861
862 SS_CLUSTER_NAME = "cluster_name"
863 SS_CLUSTER_TAGS = "cluster_tags"
864 SS_FILE_STORAGE_DIR = "file_storage_dir"
865 SS_MASTER_CANDIDATES = "master_candidates"
866 SS_MASTER_CANDIDATES_IPS = "master_candidates_ips"
867 SS_MASTER_IP = "master_ip"
868 SS_MASTER_NETDEV = "master_netdev"
869 SS_MASTER_NODE = "master_node"
870 SS_NODE_LIST = "node_list"
871 SS_NODE_PRIMARY_IPS = "node_primary_ips"
872 SS_NODE_SECONDARY_IPS = "node_secondary_ips"
873 SS_OFFLINE_NODES = "offline_nodes"
874 SS_ONLINE_NODES = "online_nodes"
875 SS_INSTANCE_LIST = "instance_list"
876 SS_RELEASE_VERSION = "release_version"
877 SS_HYPERVISOR_LIST = "hypervisor_list"
878 SS_MAINTAIN_NODE_HEALTH = "maintain_node_health"
879 SS_UID_POOL = "uid_pool"
880
881
882 DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM
883
884 HVC_DEFAULTS = {
885 HT_XEN_PVM: {
886 HV_USE_BOOTLOADER: False,
887 HV_BOOTLOADER_PATH: XEN_BOOTLOADER,
888 HV_BOOTLOADER_ARGS: '',
889 HV_KERNEL_PATH: "/boot/vmlinuz-2.6-xenU",
890 HV_INITRD_PATH: '',
891 HV_ROOT_PATH: '/dev/sda1',
892 HV_KERNEL_ARGS: 'ro',
893 HV_MIGRATION_PORT: 8002,
894 HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
895 },
896 HT_XEN_HVM: {
897 HV_BOOT_ORDER: "cd",
898 HV_CDROM_IMAGE_PATH: '',
899 HV_NIC_TYPE: HT_NIC_RTL8139,
900 HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
901 HV_VNC_BIND_ADDRESS: IP4_ADDRESS_ANY,
902 HV_VNC_PASSWORD_FILE: VNC_PASSWORD_FILE,
903 HV_ACPI: True,
904 HV_PAE: True,
905 HV_KERNEL_PATH: "/usr/lib/xen/boot/hvmloader",
906 HV_DEVICE_MODEL: "/usr/lib/xen/bin/qemu-dm",
907 HV_MIGRATION_PORT: 8002,
908 HV_MIGRATION_MODE: HT_MIGRATION_NONLIVE,
909 HV_USE_LOCALTIME: False,
910 },
911 HT_KVM: {
912 HV_KERNEL_PATH: "/boot/vmlinuz-2.6-kvmU",
913 HV_INITRD_PATH: '',
914 HV_KERNEL_ARGS: 'ro',
915 HV_ROOT_PATH: '/dev/vda1',
916 HV_ACPI: True,
917 HV_SERIAL_CONSOLE: True,
918 HV_VNC_BIND_ADDRESS: '',
919 HV_VNC_TLS: False,
920 HV_VNC_X509: '',
921 HV_VNC_X509_VERIFY: False,
922 HV_VNC_PASSWORD_FILE: '',
923 HV_CDROM_IMAGE_PATH: '',
924 HV_BOOT_ORDER: HT_BO_DISK,
925 HV_NIC_TYPE: HT_NIC_PARAVIRTUAL,
926 HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
927 HV_USB_MOUSE: '',
928 HV_MIGRATION_PORT: 8102,
929 HV_MIGRATION_BANDWIDTH: 32,
930 HV_MIGRATION_DOWNTIME: 30,
931 HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
932 HV_USE_LOCALTIME: False,
933 HV_DISK_CACHE: HT_CACHE_DEFAULT,
934 HV_SECURITY_MODEL: HT_SM_NONE,
935 HV_SECURITY_DOMAIN: '',
936 HV_KVM_FLAG: "",
937 HV_VHOST_NET: False,
938 HV_KVM_USE_CHROOT: False,
939 HV_MEM_PATH: "",
940 },
941 HT_FAKE: {
942 },
943 HT_CHROOT: {
944 HV_INIT_SCRIPT: "/ganeti-chroot",
945 },
946 HT_LXC: {
947 HV_CPU_MASK: "",
948 },
949 }
950
951 HVC_GLOBALS = frozenset([
952 HV_MIGRATION_PORT,
953 HV_MIGRATION_BANDWIDTH,
954 HV_MIGRATION_MODE,
955 ])
956
957 BEC_DEFAULTS = {
958 BE_MEMORY: 128,
959 BE_VCPUS: 1,
960 BE_AUTO_BALANCE: True,
961 }
962
963 NICC_DEFAULTS = {
964 NIC_MODE: NIC_MODE_BRIDGED,
965 NIC_LINK: DEFAULT_BRIDGE,
966 }
967
968 MASTER_POOL_SIZE_DEFAULT = 10
969
970 CONFD_PROTOCOL_VERSION = 1
971
972 CONFD_REQ_PING = 0
973 CONFD_REQ_NODE_ROLE_BYNAME = 1
974 CONFD_REQ_NODE_PIP_BY_INSTANCE_IP = 2
975 CONFD_REQ_CLUSTER_MASTER = 3
976 CONFD_REQ_NODE_PIP_LIST = 4
977 CONFD_REQ_MC_PIP_LIST = 5
978 CONFD_REQ_INSTANCES_IPS_LIST = 6
979
980
981
982
983 CONFD_REQQ_LINK = "0"
984 CONFD_REQQ_IP = "1"
985 CONFD_REQQ_IPLIST = "2"
986 CONFD_REQQ_FIELDS = "3"
987
988 CONFD_REQFIELD_NAME = "0"
989 CONFD_REQFIELD_IP = "1"
990 CONFD_REQFIELD_MNODE_PIP = "2"
991
992 CONFD_REQS = frozenset([
993 CONFD_REQ_PING,
994 CONFD_REQ_NODE_ROLE_BYNAME,
995 CONFD_REQ_NODE_PIP_BY_INSTANCE_IP,
996 CONFD_REQ_CLUSTER_MASTER,
997 CONFD_REQ_NODE_PIP_LIST,
998 CONFD_REQ_MC_PIP_LIST,
999 CONFD_REQ_INSTANCES_IPS_LIST,
1000 ])
1001
1002 CONFD_REPL_STATUS_OK = 0
1003 CONFD_REPL_STATUS_ERROR = 1
1004 CONFD_REPL_STATUS_NOTIMPLEMENTED = 2
1005
1006 CONFD_REPL_STATUSES = frozenset([
1007 CONFD_REPL_STATUS_OK,
1008 CONFD_REPL_STATUS_ERROR,
1009 CONFD_REPL_STATUS_NOTIMPLEMENTED,
1010 ])
1011
1012 (CONFD_NODE_ROLE_MASTER,
1013 CONFD_NODE_ROLE_CANDIDATE,
1014 CONFD_NODE_ROLE_OFFLINE,
1015 CONFD_NODE_ROLE_DRAINED,
1016 CONFD_NODE_ROLE_REGULAR,
1017 ) = range(5)
1018
1019
1020 CONFD_ERROR_UNKNOWN_ENTRY = 1
1021 CONFD_ERROR_INTERNAL = 2
1022 CONFD_ERROR_ARGUMENT = 3
1023
1024
1025
1026
1027 CONFD_MAX_CLOCK_SKEW = 2 * NODE_MAX_CLOCK_SKEW
1028
1029
1030
1031 CONFD_CONFIG_RELOAD_TIMEOUT = 60
1032
1033
1034
1035
1036 CONFD_CONFIG_RELOAD_RATELIMIT = 2
1037
1038
1039
1040
1041
1042 CONFD_MAGIC_FOURCC = 'plj0'
1043
1044
1045
1046
1047 CONFD_DEFAULT_REQ_COVERAGE = 6
1048
1049
1050
1051
1052 CONFD_CLIENT_EXPIRE_TIMEOUT = 10
1053
1054
1055
1056
1057
1058
1059 MAX_UDP_DATA_SIZE = 61440
1060
1061
1062 UIDPOOL_UID_MIN = 0
1063 UIDPOOL_UID_MAX = 2**32-1
1064
1065
1066 PGREP = "pgrep"
1067