Add constants for storage types to constants.py
[ganeti-github.git] / lib / constants.py
1 #
2 #
3
4 # Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 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 import socket
26
27 from ganeti import _autoconf
28 from ganeti import _vcsversion
29 from ganeti import compat
30 from ganeti import pathutils
31
32
33 # various versions
34 RELEASE_VERSION = _autoconf.PACKAGE_VERSION
35 OS_API_V10 = 10
36 OS_API_V15 = 15
37 OS_API_V20 = 20
38 OS_API_VERSIONS = compat.UniqueFrozenset([
39 OS_API_V10,
40 OS_API_V15,
41 OS_API_V20,
42 ])
43 VCS_VERSION = _vcsversion.VCS_VERSION
44 EXPORT_VERSION = 0
45 RAPI_VERSION = 2
46
47
48 # Format for CONFIG_VERSION:
49 # 01 03 0123 = 01030123
50 # ^^ ^^ ^^^^
51 # | | + Configuration version/revision
52 # | + Minor version
53 # + Major version
54 #
55 # It is stored as an integer. Make sure not to write an octal number.
56
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
60 # here.
61
62 def BuildVersion(major, minor, revision):
63 """Calculates int version number from major, minor and revision numbers.
64
65 Returns: int representing version number
66
67 """
68 assert isinstance(major, int)
69 assert isinstance(minor, int)
70 assert isinstance(revision, int)
71 return (1000000 * major +
72 10000 * minor +
73 1 * revision)
74
75
76 def SplitVersion(version):
77 """Splits version number stored in an int.
78
79 Returns: tuple; (major, minor, revision)
80
81 """
82 assert isinstance(version, int)
83
84 (major, remainder) = divmod(version, 1000000)
85 (minor, revision) = divmod(remainder, 10000)
86
87 return (major, minor, revision)
88
89
90 CONFIG_MAJOR = int(_autoconf.VERSION_MAJOR)
91 CONFIG_MINOR = int(_autoconf.VERSION_MINOR)
92 CONFIG_REVISION = 0
93 CONFIG_VERSION = BuildVersion(CONFIG_MAJOR, CONFIG_MINOR, CONFIG_REVISION)
94
95 #: RPC protocol version
96 PROTOCOL_VERSION = BuildVersion(CONFIG_MAJOR, CONFIG_MINOR, 0)
97
98 # user separation
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 MOND_USER = _autoconf.MOND_USER
110 MOND_GROUP = _autoconf.MOND_GROUP
111 SSH_LOGIN_USER = _autoconf.SSH_LOGIN_USER
112 SSH_CONSOLE_USER = _autoconf.SSH_CONSOLE_USER
113
114 # cpu pinning separators and constants
115 CPU_PINNING_SEP = ":"
116 CPU_PINNING_ALL = "all"
117 # internal representation of "all"
118 CPU_PINNING_ALL_VAL = -1
119 # one "all" entry in a CPU list means CPU pinning is off
120 CPU_PINNING_OFF = [CPU_PINNING_ALL_VAL]
121
122 # A Xen-specific implementation detail - there is no way to actually say
123 # "use any cpu for pinning" in a Xen configuration file, as opposed to the
124 # command line, where you can say "xm vcpu-pin <domain> <vcpu> all".
125 # The workaround used in Xen is "0-63" (see source code function
126 # xm_vcpu_pin in <xen-source>/tools/python/xen/xm/main.py).
127 # To support future changes, the following constant is treated as a
128 # blackbox string that simply means use-any-cpu-for-pinning-under-xen.
129 CPU_PINNING_ALL_XEN = "0-63"
130
131 # A KVM-specific implementation detail - the following value is used
132 # to set CPU affinity to all processors (#0 through #31), per taskset
133 # man page.
134 # FIXME: This only works for machines with up to 32 CPU cores
135 CPU_PINNING_ALL_KVM = 0xFFFFFFFF
136
137 # Wipe
138 DD_CMD = "dd"
139 MAX_WIPE_CHUNK = 1024 # 1GB
140 MIN_WIPE_CHUNK_PERCENT = 10
141
142 RUN_DIRS_MODE = 0775
143 SECURE_DIR_MODE = 0700
144 SECURE_FILE_MODE = 0600
145 ADOPTABLE_BLOCKDEV_ROOT = "/dev/disk/"
146 ENABLE_FILE_STORAGE = _autoconf.ENABLE_FILE_STORAGE
147 ENABLE_SHARED_FILE_STORAGE = _autoconf.ENABLE_SHARED_FILE_STORAGE
148 ENABLE_CONFD = _autoconf.ENABLE_CONFD
149 ENABLE_SPLIT_QUERY = _autoconf.ENABLE_SPLIT_QUERY
150 ENABLE_RESTRICTED_COMMANDS = _autoconf.ENABLE_RESTRICTED_COMMANDS
151
152 # SSH constants
153 SSH = "ssh"
154 SCP = "scp"
155
156 NODED = "ganeti-noded"
157 CONFD = "ganeti-confd"
158 RAPI = "ganeti-rapi"
159 MASTERD = "ganeti-masterd"
160 MOND = "ganeti-mond"
161
162 DAEMONS = compat.UniqueFrozenset([
163 NODED,
164 CONFD,
165 RAPI,
166 MASTERD,
167 MOND,
168 ])
169
170 DAEMONS_PORTS = {
171 # daemon-name: ("proto", "default-port")
172 NODED: ("tcp", 1811),
173 CONFD: ("udp", 1814),
174 MOND: ("tcp", 1815),
175 RAPI: ("tcp", 5080),
176 SSH: ("tcp", 22),
177 }
178
179 DEFAULT_NODED_PORT = DAEMONS_PORTS[NODED][1]
180 DEFAULT_CONFD_PORT = DAEMONS_PORTS[CONFD][1]
181 DEFAULT_MOND_PORT = DAEMONS_PORTS[MOND][1]
182 DEFAULT_RAPI_PORT = DAEMONS_PORTS[RAPI][1]
183
184 FIRST_DRBD_PORT = 11000
185 LAST_DRBD_PORT = 14999
186
187 DAEMONS_LOGBASE = {
188 NODED: "node-daemon",
189 CONFD: "conf-daemon",
190 RAPI: "rapi-daemon",
191 MASTERD: "master-daemon",
192 MOND: "monitoring-daemon",
193 }
194
195 DAEMONS_LOGFILES = \
196 dict((daemon, pathutils.GetLogFilename(DAEMONS_LOGBASE[daemon]))
197 for daemon in DAEMONS_LOGBASE)
198
199 # Some daemons might require more than one logfile.
200 # Specifically, right now only the Haskell http library "snap", used by the
201 # monitoring daemon, requires multiple log files.
202
203 # These are the only valid reasons for having an extra logfile
204 EXTRA_LOGREASON_ACCESS = "access"
205 EXTRA_LOGREASON_ERROR = "error"
206
207 VALID_EXTRA_LOGREASONS = compat.UniqueFrozenset([
208 EXTRA_LOGREASON_ACCESS,
209 EXTRA_LOGREASON_ERROR,
210 ])
211
212 # These are the extra logfiles, grouped by daemon
213 DAEMONS_EXTRA_LOGBASE = {
214 MOND: {
215 EXTRA_LOGREASON_ACCESS: "monitoring-daemon-access",
216 EXTRA_LOGREASON_ERROR: "monitoring-daemon-error",
217 }
218 }
219
220 DAEMONS_EXTRA_LOGFILES = \
221 dict((daemon, dict((extra,
222 pathutils.GetLogFilename(DAEMONS_EXTRA_LOGBASE[daemon][extra]))
223 for extra in DAEMONS_EXTRA_LOGBASE[daemon]))
224 for daemon in DAEMONS_EXTRA_LOGBASE)
225
226 DEV_CONSOLE = "/dev/console"
227
228 PROC_MOUNTS = "/proc/mounts"
229
230 # Local UniX Interface related constants
231 LUXI_EOM = "\3"
232 LUXI_VERSION = CONFIG_VERSION
233 #: Environment variable for the luxi override socket
234 LUXI_OVERRIDE = "FORCE_LUXI_SOCKET"
235 LUXI_OVERRIDE_MASTER = "master"
236 LUXI_OVERRIDE_QUERY = "query"
237
238 # one of "no", "yes", "only"
239 SYSLOG_USAGE = _autoconf.SYSLOG_USAGE
240 SYSLOG_NO = "no"
241 SYSLOG_YES = "yes"
242 SYSLOG_ONLY = "only"
243 SYSLOG_SOCKET = "/dev/log"
244
245 EXPORT_CONF_FILE = "config.ini"
246
247 XEN_BOOTLOADER = _autoconf.XEN_BOOTLOADER
248 XEN_KERNEL = _autoconf.XEN_KERNEL
249 XEN_INITRD = _autoconf.XEN_INITRD
250 XEN_CMD_XM = "xm"
251 XEN_CMD_XL = "xl"
252 # FIXME: This will be made configurable using hvparams in Ganeti 2.7
253 XEN_CMD = _autoconf.XEN_CMD
254
255 KNOWN_XEN_COMMANDS = compat.UniqueFrozenset([
256 XEN_CMD_XM,
257 XEN_CMD_XL,
258 ])
259
260 # When the Xen toolstack used is "xl", live migration requires the source host
261 # to connect to the target host via ssh (xl runs this command). We need to pass
262 # the command xl runs some extra info so that it can use Ganeti's key
263 # verification and not fail. Note that this string is incomplete: it must be
264 # filled with the cluster name before being used.
265 XL_SSH_CMD = ("ssh -l %s -oGlobalKnownHostsFile=%s"
266 " -oUserKnownHostsFile=/dev/null"
267 " -oCheckHostIp=no -oStrictHostKeyChecking=yes"
268 " -oHostKeyAlias=%%s") % (SSH_LOGIN_USER,
269 pathutils.SSH_KNOWN_HOSTS_FILE)
270
271 KVM_PATH = _autoconf.KVM_PATH
272 KVM_KERNEL = _autoconf.KVM_KERNEL
273 SOCAT_PATH = _autoconf.SOCAT_PATH
274 SOCAT_USE_ESCAPE = _autoconf.SOCAT_USE_ESCAPE
275 SOCAT_USE_COMPRESS = _autoconf.SOCAT_USE_COMPRESS
276 SOCAT_ESCAPE_CODE = "0x1d"
277
278 #: Console as SSH command
279 CONS_SSH = "ssh"
280
281 #: Console as VNC server
282 CONS_VNC = "vnc"
283
284 #: Console as SPICE server
285 CONS_SPICE = "spice"
286
287 #: Display a message for console access
288 CONS_MESSAGE = "msg"
289
290 #: All console types
291 CONS_ALL = compat.UniqueFrozenset([
292 CONS_SSH,
293 CONS_VNC,
294 CONS_SPICE,
295 CONS_MESSAGE,
296 ])
297
298 # For RSA keys more bits are better, but they also make operations more
299 # expensive. NIST SP 800-131 recommends a minimum of 2048 bits from the year
300 # 2010 on.
301 RSA_KEY_BITS = 2048
302
303 # Ciphers allowed for SSL connections. For the format, see ciphers(1). A better
304 # way to disable ciphers would be to use the exclamation mark (!), but socat
305 # versions below 1.5 can't parse exclamation marks in options properly. When
306 # modifying the ciphers, ensure not to accidentially add something after it's
307 # been removed. Use the "openssl" utility to check the allowed ciphers, e.g.
308 # "openssl ciphers -v HIGH:-DES".
309 OPENSSL_CIPHERS = "HIGH:-DES:-3DES:-EXPORT:-ADH"
310
311 # Digest used to sign certificates ("openssl x509" uses SHA1 by default)
312 X509_CERT_SIGN_DIGEST = "SHA1"
313
314 # Default validity of certificates in days
315 X509_CERT_DEFAULT_VALIDITY = 365 * 5
316
317 # commonName (CN) used in certificates
318 X509_CERT_CN = "ganeti.example.com"
319
320 X509_CERT_SIGNATURE_HEADER = "X-Ganeti-Signature"
321
322 # Import/export daemon mode
323 IEM_IMPORT = "import"
324 IEM_EXPORT = "export"
325
326 # Import/export transport compression
327 IEC_NONE = "none"
328 IEC_GZIP = "gzip"
329 IEC_ALL = compat.UniqueFrozenset([
330 IEC_NONE,
331 IEC_GZIP,
332 ])
333
334 IE_CUSTOM_SIZE = "fd"
335
336 IE_MAGIC_RE = re.compile(r"^[-_.a-zA-Z0-9]{5,100}$")
337
338 # Import/export I/O
339 # Direct file I/O, equivalent to a shell's I/O redirection using '<' or '>'
340 IEIO_FILE = "file"
341 # Raw block device I/O using "dd"
342 IEIO_RAW_DISK = "raw"
343 # OS definition import/export script
344 IEIO_SCRIPT = "script"
345
346 VALUE_DEFAULT = "default"
347 VALUE_AUTO = "auto"
348 VALUE_GENERATE = "generate"
349 VALUE_NONE = "none"
350 VALUE_TRUE = "true"
351 VALUE_FALSE = "false"
352
353 # External script validation mask
354 EXT_PLUGIN_MASK = re.compile("^[a-zA-Z0-9_-]+$")
355
356 # hooks-related constants
357 HOOKS_PHASE_PRE = "pre"
358 HOOKS_PHASE_POST = "post"
359 HOOKS_NAME_CFGUPDATE = "config-update"
360 HOOKS_NAME_WATCHER = "watcher"
361 HOOKS_VERSION = 2
362 HOOKS_PATH = "/sbin:/bin:/usr/sbin:/usr/bin"
363
364 # hooks subject type (what object type does the LU deal with)
365 HTYPE_CLUSTER = "CLUSTER"
366 HTYPE_NODE = "NODE"
367 HTYPE_GROUP = "GROUP"
368 HTYPE_INSTANCE = "INSTANCE"
369 HTYPE_NETWORK = "NETWORK"
370
371 HKR_SKIP = 0
372 HKR_FAIL = 1
373 HKR_SUCCESS = 2
374
375 # Storage types
376 ST_FILE = "file"
377 ST_LVM_PV = "lvm-pv"
378 ST_LVM_VG = "lvm-vg"
379 ST_DISKLESS = "diskless"
380 ST_SHARED_FILE = "sharedfile"
381 ST_BLOCK = "blockdev"
382 ST_RADOS = "rados"
383 ST_EXT = "ext"
384
385 VALID_STORAGE_TYPES = compat.UniqueFrozenset([
386 ST_FILE,
387 ST_LVM_PV,
388 ST_LVM_VG,
389 ST_DISKLESS,
390 ST_SHARED_FILE,
391 ST_BLOCK,
392 ST_RADOS,
393 ST_EXT,
394 ])
395
396 # Per default, only lvm is enabled.
397 DEFAULT_ENABLED_STORAGE_TYPES = compat.UniqueFrozenset([
398 ST_LVM_VG,
399 ])
400
401 # Storage fields
402 # first two are valid in LU context only, not passed to backend
403 SF_NODE = "node"
404 SF_TYPE = "type"
405 # and the rest are valid in backend
406 SF_NAME = "name"
407 SF_SIZE = "size"
408 SF_FREE = "free"
409 SF_USED = "used"
410 SF_ALLOCATABLE = "allocatable"
411
412 # Storage operations
413 SO_FIX_CONSISTENCY = "fix-consistency"
414
415 # Available fields per storage type
416 VALID_STORAGE_FIELDS = compat.UniqueFrozenset([
417 SF_NAME,
418 SF_TYPE,
419 SF_SIZE,
420 SF_USED,
421 SF_FREE,
422 SF_ALLOCATABLE,
423 ])
424
425 MODIFIABLE_STORAGE_FIELDS = {
426 ST_LVM_PV: frozenset([SF_ALLOCATABLE]),
427 }
428
429 VALID_STORAGE_OPERATIONS = {
430 ST_LVM_VG: frozenset([SO_FIX_CONSISTENCY]),
431 }
432
433 # Local disk status
434 # Note: Code depends on LDS_OKAY < LDS_UNKNOWN < LDS_FAULTY
435 (LDS_OKAY,
436 LDS_UNKNOWN,
437 LDS_FAULTY) = range(1, 4)
438
439 # disk template types
440 DT_DISKLESS = "diskless"
441 DT_PLAIN = "plain"
442 DT_DRBD8 = "drbd"
443 DT_FILE = "file"
444 DT_SHARED_FILE = "sharedfile"
445 DT_BLOCK = "blockdev"
446 DT_RBD = "rbd"
447 DT_EXT = "ext"
448
449 # the set of network-mirrored disk templates
450 DTS_INT_MIRROR = compat.UniqueFrozenset([DT_DRBD8])
451
452 # the set of externally-mirrored disk templates (e.g. SAN, NAS)
453 DTS_EXT_MIRROR = compat.UniqueFrozenset([
454 DT_DISKLESS, # 'trivially' externally mirrored
455 DT_SHARED_FILE,
456 DT_BLOCK,
457 DT_RBD,
458 DT_EXT,
459 ])
460
461 # the set of non-lvm-based disk templates
462 DTS_NOT_LVM = compat.UniqueFrozenset([
463 DT_DISKLESS,
464 DT_FILE,
465 DT_SHARED_FILE,
466 DT_BLOCK,
467 DT_RBD,
468 DT_EXT,
469 ])
470
471 # the set of disk templates which can be grown
472 DTS_GROWABLE = compat.UniqueFrozenset([
473 DT_PLAIN,
474 DT_DRBD8,
475 DT_FILE,
476 DT_SHARED_FILE,
477 DT_RBD,
478 DT_EXT,
479 ])
480
481 # the set of disk templates that allow adoption
482 DTS_MAY_ADOPT = compat.UniqueFrozenset([
483 DT_PLAIN,
484 DT_BLOCK,
485 ])
486
487 # the set of disk templates that *must* use adoption
488 DTS_MUST_ADOPT = compat.UniqueFrozenset([DT_BLOCK])
489
490 # the set of disk templates that allow migrations
491 DTS_MIRRORED = frozenset.union(DTS_INT_MIRROR, DTS_EXT_MIRROR)
492
493 # the set of file based disk templates
494 DTS_FILEBASED = compat.UniqueFrozenset([
495 DT_FILE,
496 DT_SHARED_FILE,
497 ])
498
499 # the set of disk templates that are supported by exclusive_storage
500 DTS_EXCL_STORAGE = compat.UniqueFrozenset([DT_PLAIN])
501
502 # templates for which we don't perform checks on free space
503 DTS_NO_FREE_SPACE_CHECK = compat.UniqueFrozenset([
504 DT_FILE,
505 DT_SHARED_FILE,
506 DT_RBD,
507 DT_EXT,
508 ])
509
510 # logical disk types
511 LD_LV = "lvm"
512 LD_DRBD8 = "drbd8"
513 LD_FILE = "file"
514 LD_BLOCKDEV = "blockdev"
515 LD_RBD = "rbd"
516 LD_EXT = "ext"
517 LOGICAL_DISK_TYPES = compat.UniqueFrozenset([
518 LD_LV,
519 LD_DRBD8,
520 LD_FILE,
521 LD_BLOCKDEV,
522 LD_RBD,
523 LD_EXT,
524 ])
525
526 LDS_BLOCK = compat.UniqueFrozenset([
527 LD_LV,
528 LD_DRBD8,
529 LD_BLOCKDEV,
530 LD_RBD,
531 LD_EXT,
532 ])
533
534 # drbd constants
535 DRBD_HMAC_ALG = "md5"
536 DRBD_NET_PROTOCOL = "C"
537 DRBD_STATUS_FILE = "/proc/drbd"
538
539 #: Size of DRBD meta block device
540 DRBD_META_SIZE = 128
541
542 # drbd barrier types
543 DRBD_B_NONE = "n"
544 DRBD_B_DISK_BARRIERS = "b"
545 DRBD_B_DISK_DRAIN = "d"
546 DRBD_B_DISK_FLUSH = "f"
547
548 # Valid barrier combinations: "n" or any non-null subset of "bfd"
549 DRBD_VALID_BARRIER_OPT = compat.UniqueFrozenset([
550 frozenset([DRBD_B_NONE]),
551 frozenset([DRBD_B_DISK_BARRIERS]),
552 frozenset([DRBD_B_DISK_DRAIN]),
553 frozenset([DRBD_B_DISK_FLUSH]),
554 frozenset([DRBD_B_DISK_DRAIN, DRBD_B_DISK_FLUSH]),
555 frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_DRAIN]),
556 frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_FLUSH]),
557 frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_FLUSH, DRBD_B_DISK_DRAIN]),
558 ])
559
560 # rbd tool command
561 RBD_CMD = "rbd"
562
563 # file backend driver
564 FD_LOOP = "loop"
565 FD_BLKTAP = "blktap"
566
567 # the set of drbd-like disk types
568 LDS_DRBD = compat.UniqueFrozenset([LD_DRBD8])
569
570 # disk access mode
571 DISK_RDONLY = "ro"
572 DISK_RDWR = "rw"
573 DISK_ACCESS_SET = compat.UniqueFrozenset([DISK_RDONLY, DISK_RDWR])
574
575 # disk replacement mode
576 REPLACE_DISK_PRI = "replace_on_primary" # replace disks on primary
577 REPLACE_DISK_SEC = "replace_on_secondary" # replace disks on secondary
578 REPLACE_DISK_CHG = "replace_new_secondary" # change secondary node
579 REPLACE_DISK_AUTO = "replace_auto"
580 REPLACE_MODES = compat.UniqueFrozenset([
581 REPLACE_DISK_PRI,
582 REPLACE_DISK_SEC,
583 REPLACE_DISK_CHG,
584 REPLACE_DISK_AUTO,
585 ])
586
587 # Instance export mode
588 EXPORT_MODE_LOCAL = "local"
589 EXPORT_MODE_REMOTE = "remote"
590 EXPORT_MODES = compat.UniqueFrozenset([
591 EXPORT_MODE_LOCAL,
592 EXPORT_MODE_REMOTE,
593 ])
594
595 # instance creation modes
596 INSTANCE_CREATE = "create"
597 INSTANCE_IMPORT = "import"
598 INSTANCE_REMOTE_IMPORT = "remote-import"
599 INSTANCE_CREATE_MODES = compat.UniqueFrozenset([
600 INSTANCE_CREATE,
601 INSTANCE_IMPORT,
602 INSTANCE_REMOTE_IMPORT,
603 ])
604
605 # Remote import/export handshake message and version
606 RIE_VERSION = 0
607 RIE_HANDSHAKE = "Hi, I'm Ganeti"
608
609 # Remote import/export certificate validity in seconds
610 RIE_CERT_VALIDITY = 24 * 60 * 60
611
612 # Overall timeout for establishing connection
613 RIE_CONNECT_TIMEOUT = 180
614
615 # Export only: how long to wait per connection attempt (seconds)
616 RIE_CONNECT_ATTEMPT_TIMEOUT = 20
617
618 # Export only: number of attempts to connect
619 RIE_CONNECT_RETRIES = 10
620
621 #: Give child process up to 5 seconds to exit after sending a signal
622 CHILD_LINGER_TIMEOUT = 5.0
623
624 DISK_TEMPLATES = compat.UniqueFrozenset([
625 DT_DISKLESS,
626 DT_PLAIN,
627 DT_DRBD8,
628 DT_FILE,
629 DT_SHARED_FILE,
630 DT_BLOCK,
631 DT_RBD,
632 DT_EXT
633 ])
634
635 FILE_DRIVER = compat.UniqueFrozenset([FD_LOOP, FD_BLKTAP])
636
637 # import/export config options
638 INISECT_EXP = "export"
639 INISECT_INS = "instance"
640 INISECT_HYP = "hypervisor"
641 INISECT_BEP = "backend"
642 INISECT_OSP = "os"
643
644 # dynamic device modification
645 DDM_ADD = "add"
646 DDM_MODIFY = "modify"
647 DDM_REMOVE = "remove"
648 DDMS_VALUES = compat.UniqueFrozenset([DDM_ADD, DDM_REMOVE])
649 DDMS_VALUES_WITH_MODIFY = (DDMS_VALUES | frozenset([
650 DDM_MODIFY,
651 ]))
652 # TODO: DDM_SWAP, DDM_MOVE?
653
654 # common exit codes
655 EXIT_SUCCESS = 0
656 EXIT_FAILURE = 1
657 EXIT_NOTCLUSTER = 5
658 EXIT_NOTMASTER = 11
659 EXIT_NODESETUP_ERROR = 12
660 EXIT_CONFIRMATION = 13 # need user confirmation
661
662 #: Exit code for query operations with unknown fields
663 EXIT_UNKNOWN_FIELD = 14
664
665 # tags
666 TAG_CLUSTER = "cluster"
667 TAG_NODEGROUP = "nodegroup"
668 TAG_NODE = "node"
669 TAG_INSTANCE = "instance"
670 TAG_NETWORK = "network"
671 VALID_TAG_TYPES = compat.UniqueFrozenset([
672 TAG_CLUSTER,
673 TAG_NODEGROUP,
674 TAG_NODE,
675 TAG_INSTANCE,
676 TAG_NETWORK,
677 ])
678 MAX_TAG_LEN = 128
679 MAX_TAGS_PER_OBJ = 4096
680
681 # others
682 DEFAULT_BRIDGE = "xen-br0"
683 CLASSIC_DRBD_SYNC_SPEED = 60 * 1024 # 60 MiB, expressed in KiB
684 IP4_ADDRESS_LOCALHOST = "127.0.0.1"
685 IP4_ADDRESS_ANY = "0.0.0.0"
686 IP6_ADDRESS_LOCALHOST = "::1"
687 IP6_ADDRESS_ANY = "::"
688 IP4_VERSION = 4
689 IP6_VERSION = 6
690 VALID_IP_VERSIONS = compat.UniqueFrozenset([IP4_VERSION, IP6_VERSION])
691 # for export to htools
692 IP4_FAMILY = socket.AF_INET
693 IP6_FAMILY = socket.AF_INET6
694
695 TCP_PING_TIMEOUT = 10
696 DEFAULT_VG = "xenvg"
697 DEFAULT_DRBD_HELPER = "/bin/true"
698 MIN_VG_SIZE = 20480
699 DEFAULT_MAC_PREFIX = "aa:00:00"
700 # default maximum instance wait time, in seconds.
701 DEFAULT_SHUTDOWN_TIMEOUT = 120
702 NODE_MAX_CLOCK_SKEW = 150
703 # Time for an intra-cluster disk transfer to wait for a connection
704 DISK_TRANSFER_CONNECT_TIMEOUT = 60
705 # Disk index separator
706 DISK_SEPARATOR = _autoconf.DISK_SEPARATOR
707 IP_COMMAND_PATH = _autoconf.IP_PATH
708
709 #: Key for job IDs in opcode result
710 JOB_IDS_KEY = "jobs"
711
712 # runparts results
713 (RUNPARTS_SKIP,
714 RUNPARTS_RUN,
715 RUNPARTS_ERR) = range(3)
716
717 RUNPARTS_STATUS = compat.UniqueFrozenset([
718 RUNPARTS_SKIP,
719 RUNPARTS_RUN,
720 RUNPARTS_ERR,
721 ])
722
723 # RPC constants
724 (RPC_ENCODING_NONE,
725 RPC_ENCODING_ZLIB_BASE64) = range(2)
726
727 # Various time constants for the timeout table
728 RPC_TMO_URGENT = 60 # one minute
729 RPC_TMO_FAST = 5 * 60 # five minutes
730 RPC_TMO_NORMAL = 15 * 60 # 15 minutes
731 RPC_TMO_SLOW = 3600 # one hour
732 RPC_TMO_4HRS = 4 * 3600
733 RPC_TMO_1DAY = 86400
734
735 # Timeout for connecting to nodes (seconds)
736 RPC_CONNECT_TIMEOUT = 5
737
738 # os related constants
739 OS_SCRIPT_CREATE = "create"
740 OS_SCRIPT_IMPORT = "import"
741 OS_SCRIPT_EXPORT = "export"
742 OS_SCRIPT_RENAME = "rename"
743 OS_SCRIPT_VERIFY = "verify"
744 OS_SCRIPTS = compat.UniqueFrozenset([
745 OS_SCRIPT_CREATE,
746 OS_SCRIPT_IMPORT,
747 OS_SCRIPT_EXPORT,
748 OS_SCRIPT_RENAME,
749 OS_SCRIPT_VERIFY,
750 ])
751
752 OS_API_FILE = "ganeti_api_version"
753 OS_VARIANTS_FILE = "variants.list"
754 OS_PARAMETERS_FILE = "parameters.list"
755
756 OS_VALIDATE_PARAMETERS = "parameters"
757 OS_VALIDATE_CALLS = compat.UniqueFrozenset([OS_VALIDATE_PARAMETERS])
758
759 # External Storage (ES) related constants
760 ES_ACTION_CREATE = "create"
761 ES_ACTION_REMOVE = "remove"
762 ES_ACTION_GROW = "grow"
763 ES_ACTION_ATTACH = "attach"
764 ES_ACTION_DETACH = "detach"
765 ES_ACTION_SETINFO = "setinfo"
766 ES_ACTION_VERIFY = "verify"
767
768 ES_SCRIPT_CREATE = ES_ACTION_CREATE
769 ES_SCRIPT_REMOVE = ES_ACTION_REMOVE
770 ES_SCRIPT_GROW = ES_ACTION_GROW
771 ES_SCRIPT_ATTACH = ES_ACTION_ATTACH
772 ES_SCRIPT_DETACH = ES_ACTION_DETACH
773 ES_SCRIPT_SETINFO = ES_ACTION_SETINFO
774 ES_SCRIPT_VERIFY = ES_ACTION_VERIFY
775 ES_SCRIPTS = frozenset([
776 ES_SCRIPT_CREATE,
777 ES_SCRIPT_REMOVE,
778 ES_SCRIPT_GROW,
779 ES_SCRIPT_ATTACH,
780 ES_SCRIPT_DETACH,
781 ES_SCRIPT_SETINFO,
782 ES_SCRIPT_VERIFY
783 ])
784
785 ES_PARAMETERS_FILE = "parameters.list"
786
787 # reboot types
788 INSTANCE_REBOOT_SOFT = "soft"
789 INSTANCE_REBOOT_HARD = "hard"
790 INSTANCE_REBOOT_FULL = "full"
791
792 REBOOT_TYPES = compat.UniqueFrozenset([
793 INSTANCE_REBOOT_SOFT,
794 INSTANCE_REBOOT_HARD,
795 INSTANCE_REBOOT_FULL,
796 ])
797
798 # instance reboot behaviors
799 INSTANCE_REBOOT_ALLOWED = "reboot"
800 INSTANCE_REBOOT_EXIT = "exit"
801
802 REBOOT_BEHAVIORS = compat.UniqueFrozenset([
803 INSTANCE_REBOOT_ALLOWED,
804 INSTANCE_REBOOT_EXIT,
805 ])
806
807 VTYPE_STRING = "string"
808 VTYPE_MAYBE_STRING = "maybe-string"
809 VTYPE_BOOL = "bool"
810 VTYPE_SIZE = "size" # size, in MiBs
811 VTYPE_INT = "int"
812 ENFORCEABLE_TYPES = compat.UniqueFrozenset([
813 VTYPE_STRING,
814 VTYPE_MAYBE_STRING,
815 VTYPE_BOOL,
816 VTYPE_SIZE,
817 VTYPE_INT,
818 ])
819
820 # Constant representing that the user does not specify any IP version
821 IFACE_NO_IP_VERSION_SPECIFIED = 0
822
823 VALID_SERIAL_SPEEDS = compat.UniqueFrozenset([
824 75,
825 110,
826 300,
827 600,
828 1200,
829 1800,
830 2400,
831 4800,
832 9600,
833 14400,
834 19200,
835 28800,
836 38400,
837 57600,
838 115200,
839 230400,
840 345600,
841 460800,
842 ])
843
844 # HV parameter names (global namespace)
845 HV_BOOT_ORDER = "boot_order"
846 HV_CDROM_IMAGE_PATH = "cdrom_image_path"
847 HV_KVM_CDROM2_IMAGE_PATH = "cdrom2_image_path"
848 HV_KVM_FLOPPY_IMAGE_PATH = "floppy_image_path"
849 HV_NIC_TYPE = "nic_type"
850 HV_DISK_TYPE = "disk_type"
851 HV_KVM_CDROM_DISK_TYPE = "cdrom_disk_type"
852 HV_VNC_BIND_ADDRESS = "vnc_bind_address"
853 HV_VNC_PASSWORD_FILE = "vnc_password_file"
854 HV_VNC_TLS = "vnc_tls"
855 HV_VNC_X509 = "vnc_x509_path"
856 HV_VNC_X509_VERIFY = "vnc_x509_verify"
857 HV_KVM_SPICE_BIND = "spice_bind"
858 HV_KVM_SPICE_IP_VERSION = "spice_ip_version"
859 HV_KVM_SPICE_PASSWORD_FILE = "spice_password_file"
860 HV_KVM_SPICE_LOSSLESS_IMG_COMPR = "spice_image_compression"
861 HV_KVM_SPICE_JPEG_IMG_COMPR = "spice_jpeg_wan_compression"
862 HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR = "spice_zlib_glz_wan_compression"
863 HV_KVM_SPICE_STREAMING_VIDEO_DETECTION = "spice_streaming_video"
864 HV_KVM_SPICE_AUDIO_COMPR = "spice_playback_compression"
865 HV_KVM_SPICE_USE_TLS = "spice_use_tls"
866 HV_KVM_SPICE_TLS_CIPHERS = "spice_tls_ciphers"
867 HV_KVM_SPICE_USE_VDAGENT = "spice_use_vdagent"
868 HV_ACPI = "acpi"
869 HV_PAE = "pae"
870 HV_USE_BOOTLOADER = "use_bootloader"
871 HV_BOOTLOADER_ARGS = "bootloader_args"
872 HV_BOOTLOADER_PATH = "bootloader_path"
873 HV_KERNEL_ARGS = "kernel_args"
874 HV_KERNEL_PATH = "kernel_path"
875 HV_INITRD_PATH = "initrd_path"
876 HV_ROOT_PATH = "root_path"
877 HV_SERIAL_CONSOLE = "serial_console"
878 HV_SERIAL_SPEED = "serial_speed"
879 HV_USB_MOUSE = "usb_mouse"
880 HV_KEYMAP = "keymap"
881 HV_DEVICE_MODEL = "device_model"
882 HV_INIT_SCRIPT = "init_script"
883 HV_MIGRATION_PORT = "migration_port"
884 HV_MIGRATION_BANDWIDTH = "migration_bandwidth"
885 HV_MIGRATION_DOWNTIME = "migration_downtime"
886 HV_MIGRATION_MODE = "migration_mode"
887 HV_USE_LOCALTIME = "use_localtime"
888 HV_DISK_CACHE = "disk_cache"
889 HV_SECURITY_MODEL = "security_model"
890 HV_SECURITY_DOMAIN = "security_domain"
891 HV_KVM_FLAG = "kvm_flag"
892 HV_VHOST_NET = "vhost_net"
893 HV_KVM_USE_CHROOT = "use_chroot"
894 HV_CPU_MASK = "cpu_mask"
895 HV_MEM_PATH = "mem_path"
896 HV_PASSTHROUGH = "pci_pass"
897 HV_BLOCKDEV_PREFIX = "blockdev_prefix"
898 HV_REBOOT_BEHAVIOR = "reboot_behavior"
899 HV_CPU_TYPE = "cpu_type"
900 HV_CPU_CAP = "cpu_cap"
901 HV_CPU_WEIGHT = "cpu_weight"
902 HV_CPU_CORES = "cpu_cores"
903 HV_CPU_THREADS = "cpu_threads"
904 HV_CPU_SOCKETS = "cpu_sockets"
905 HV_SOUNDHW = "soundhw"
906 HV_USB_DEVICES = "usb_devices"
907 HV_VGA = "vga"
908 HV_KVM_EXTRA = "kvm_extra"
909 HV_KVM_MACHINE_VERSION = "machine_version"
910 HV_KVM_PATH = "kvm_path"
911
912
913 HVS_PARAMETER_TYPES = {
914 HV_KVM_PATH: VTYPE_STRING,
915 HV_BOOT_ORDER: VTYPE_STRING,
916 HV_KVM_FLOPPY_IMAGE_PATH: VTYPE_STRING,
917 HV_CDROM_IMAGE_PATH: VTYPE_STRING,
918 HV_KVM_CDROM2_IMAGE_PATH: VTYPE_STRING,
919 HV_NIC_TYPE: VTYPE_STRING,
920 HV_DISK_TYPE: VTYPE_STRING,
921 HV_KVM_CDROM_DISK_TYPE: VTYPE_STRING,
922 HV_VNC_PASSWORD_FILE: VTYPE_STRING,
923 HV_VNC_BIND_ADDRESS: VTYPE_STRING,
924 HV_VNC_TLS: VTYPE_BOOL,
925 HV_VNC_X509: VTYPE_STRING,
926 HV_VNC_X509_VERIFY: VTYPE_BOOL,
927 HV_KVM_SPICE_BIND: VTYPE_STRING,
928 HV_KVM_SPICE_IP_VERSION: VTYPE_INT,
929 HV_KVM_SPICE_PASSWORD_FILE: VTYPE_STRING,
930 HV_KVM_SPICE_LOSSLESS_IMG_COMPR: VTYPE_STRING,
931 HV_KVM_SPICE_JPEG_IMG_COMPR: VTYPE_STRING,
932 HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR: VTYPE_STRING,
933 HV_KVM_SPICE_STREAMING_VIDEO_DETECTION: VTYPE_STRING,
934 HV_KVM_SPICE_AUDIO_COMPR: VTYPE_BOOL,
935 HV_KVM_SPICE_USE_TLS: VTYPE_BOOL,
936 HV_KVM_SPICE_TLS_CIPHERS: VTYPE_STRING,
937 HV_KVM_SPICE_USE_VDAGENT: VTYPE_BOOL,
938 HV_ACPI: VTYPE_BOOL,
939 HV_PAE: VTYPE_BOOL,
940 HV_USE_BOOTLOADER: VTYPE_BOOL,
941 HV_BOOTLOADER_PATH: VTYPE_STRING,
942 HV_BOOTLOADER_ARGS: VTYPE_STRING,
943 HV_KERNEL_PATH: VTYPE_STRING,
944 HV_KERNEL_ARGS: VTYPE_STRING,
945 HV_INITRD_PATH: VTYPE_STRING,
946 HV_ROOT_PATH: VTYPE_MAYBE_STRING,
947 HV_SERIAL_CONSOLE: VTYPE_BOOL,
948 HV_SERIAL_SPEED: VTYPE_INT,
949 HV_USB_MOUSE: VTYPE_STRING,
950 HV_KEYMAP: VTYPE_STRING,
951 HV_DEVICE_MODEL: VTYPE_STRING,
952 HV_INIT_SCRIPT: VTYPE_STRING,
953 HV_MIGRATION_PORT: VTYPE_INT,
954 HV_MIGRATION_BANDWIDTH: VTYPE_INT,
955 HV_MIGRATION_DOWNTIME: VTYPE_INT,
956 HV_MIGRATION_MODE: VTYPE_STRING,
957 HV_USE_LOCALTIME: VTYPE_BOOL,
958 HV_DISK_CACHE: VTYPE_STRING,
959 HV_SECURITY_MODEL: VTYPE_STRING,
960 HV_SECURITY_DOMAIN: VTYPE_STRING,
961 HV_KVM_FLAG: VTYPE_STRING,
962 HV_VHOST_NET: VTYPE_BOOL,
963 HV_KVM_USE_CHROOT: VTYPE_BOOL,
964 HV_CPU_MASK: VTYPE_STRING,
965 HV_MEM_PATH: VTYPE_STRING,
966 HV_PASSTHROUGH: VTYPE_STRING,
967 HV_BLOCKDEV_PREFIX: VTYPE_STRING,
968 HV_REBOOT_BEHAVIOR: VTYPE_STRING,
969 HV_CPU_TYPE: VTYPE_STRING,
970 HV_CPU_CAP: VTYPE_INT,
971 HV_CPU_WEIGHT: VTYPE_INT,
972 HV_CPU_CORES: VTYPE_INT,
973 HV_CPU_THREADS: VTYPE_INT,
974 HV_CPU_SOCKETS: VTYPE_INT,
975 HV_SOUNDHW: VTYPE_STRING,
976 HV_USB_DEVICES: VTYPE_STRING,
977 HV_VGA: VTYPE_STRING,
978 HV_KVM_EXTRA: VTYPE_STRING,
979 HV_KVM_MACHINE_VERSION: VTYPE_STRING,
980 }
981
982 HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
983
984 HVS_PARAMETER_TITLES = {
985 HV_ACPI: "ACPI",
986 HV_BOOT_ORDER: "Boot_order",
987 HV_CDROM_IMAGE_PATH: "CDROM_image_path",
988 HV_DISK_TYPE: "Disk_type",
989 HV_INITRD_PATH: "Initrd_path",
990 HV_KERNEL_PATH: "Kernel_path",
991 HV_NIC_TYPE: "NIC_type",
992 HV_PAE: "PAE",
993 HV_VNC_BIND_ADDRESS: "VNC_bind_address",
994 HV_PASSTHROUGH: "pci_pass",
995 HV_CPU_TYPE: "cpu_type",
996 }
997
998 # Migration statuses
999 HV_MIGRATION_COMPLETED = "completed"
1000 HV_MIGRATION_ACTIVE = "active"
1001 HV_MIGRATION_FAILED = "failed"
1002 HV_MIGRATION_CANCELLED = "cancelled"
1003
1004 HV_MIGRATION_VALID_STATUSES = compat.UniqueFrozenset([
1005 HV_MIGRATION_COMPLETED,
1006 HV_MIGRATION_ACTIVE,
1007 HV_MIGRATION_FAILED,
1008 HV_MIGRATION_CANCELLED,
1009 ])
1010
1011 HV_MIGRATION_FAILED_STATUSES = compat.UniqueFrozenset([
1012 HV_MIGRATION_FAILED,
1013 HV_MIGRATION_CANCELLED,
1014 ])
1015
1016 # KVM-specific statuses
1017 HV_KVM_MIGRATION_VALID_STATUSES = HV_MIGRATION_VALID_STATUSES
1018
1019 # Node info keys
1020 HV_NODEINFO_KEY_VERSION = "hv_version"
1021
1022 # Hypervisor state
1023 HVST_MEMORY_TOTAL = "mem_total"
1024 HVST_MEMORY_NODE = "mem_node"
1025 HVST_MEMORY_HV = "mem_hv"
1026 HVST_CPU_TOTAL = "cpu_total"
1027 HVST_CPU_NODE = "cpu_node"
1028
1029 HVST_DEFAULTS = {
1030 HVST_MEMORY_TOTAL: 0,
1031 HVST_MEMORY_NODE: 0,
1032 HVST_MEMORY_HV: 0,
1033 HVST_CPU_TOTAL: 1,
1034 HVST_CPU_NODE: 1,
1035 }
1036
1037 HVSTS_PARAMETER_TYPES = {
1038 HVST_MEMORY_TOTAL: VTYPE_INT,
1039 HVST_MEMORY_NODE: VTYPE_INT,
1040 HVST_MEMORY_HV: VTYPE_INT,
1041 HVST_CPU_TOTAL: VTYPE_INT,
1042 HVST_CPU_NODE: VTYPE_INT,
1043 }
1044
1045 HVSTS_PARAMETERS = frozenset(HVSTS_PARAMETER_TYPES.keys())
1046
1047 # Disk state
1048 DS_DISK_TOTAL = "disk_total"
1049 DS_DISK_RESERVED = "disk_reserved"
1050 DS_DISK_OVERHEAD = "disk_overhead"
1051
1052 DS_DEFAULTS = {
1053 DS_DISK_TOTAL: 0,
1054 DS_DISK_RESERVED: 0,
1055 DS_DISK_OVERHEAD: 0,
1056 }
1057
1058 DSS_PARAMETER_TYPES = {
1059 DS_DISK_TOTAL: VTYPE_INT,
1060 DS_DISK_RESERVED: VTYPE_INT,
1061 DS_DISK_OVERHEAD: VTYPE_INT,
1062 }
1063
1064 DSS_PARAMETERS = frozenset(DSS_PARAMETER_TYPES.keys())
1065 DS_VALID_TYPES = compat.UniqueFrozenset([LD_LV])
1066
1067 # Backend parameter names
1068 BE_MEMORY = "memory" # deprecated and replaced by max and min mem
1069 BE_MAXMEM = "maxmem"
1070 BE_MINMEM = "minmem"
1071 BE_VCPUS = "vcpus"
1072 BE_AUTO_BALANCE = "auto_balance"
1073 BE_ALWAYS_FAILOVER = "always_failover"
1074 BE_SPINDLE_USE = "spindle_use"
1075
1076 BES_PARAMETER_TYPES = {
1077 BE_MAXMEM: VTYPE_SIZE,
1078 BE_MINMEM: VTYPE_SIZE,
1079 BE_VCPUS: VTYPE_INT,
1080 BE_AUTO_BALANCE: VTYPE_BOOL,
1081 BE_ALWAYS_FAILOVER: VTYPE_BOOL,
1082 BE_SPINDLE_USE: VTYPE_INT,
1083 }
1084
1085 BES_PARAMETER_TITLES = {
1086 BE_AUTO_BALANCE: "Auto_balance",
1087 BE_MAXMEM: "ConfigMaxMem",
1088 BE_MINMEM: "ConfigMinMem",
1089 BE_VCPUS: "ConfigVCPUs",
1090 }
1091
1092 BES_PARAMETER_COMPAT = {
1093 BE_MEMORY: VTYPE_SIZE,
1094 }
1095 BES_PARAMETER_COMPAT.update(BES_PARAMETER_TYPES)
1096
1097 BES_PARAMETERS = frozenset(BES_PARAMETER_TYPES.keys())
1098
1099 # instance specs
1100 ISPEC_MEM_SIZE = "memory-size"
1101 ISPEC_CPU_COUNT = "cpu-count"
1102 ISPEC_DISK_COUNT = "disk-count"
1103 ISPEC_DISK_SIZE = "disk-size"
1104 ISPEC_NIC_COUNT = "nic-count"
1105 ISPEC_SPINDLE_USE = "spindle-use"
1106
1107 ISPECS_PARAMETER_TYPES = {
1108 ISPEC_MEM_SIZE: VTYPE_INT,
1109 ISPEC_CPU_COUNT: VTYPE_INT,
1110 ISPEC_DISK_COUNT: VTYPE_INT,
1111 ISPEC_DISK_SIZE: VTYPE_INT,
1112 ISPEC_NIC_COUNT: VTYPE_INT,
1113 ISPEC_SPINDLE_USE: VTYPE_INT,
1114 }
1115
1116 ISPECS_PARAMETERS = frozenset(ISPECS_PARAMETER_TYPES.keys())
1117
1118 ISPECS_MIN = "min"
1119 ISPECS_MAX = "max"
1120 ISPECS_STD = "std"
1121 IPOLICY_DTS = "disk-templates"
1122 IPOLICY_VCPU_RATIO = "vcpu-ratio"
1123 IPOLICY_SPINDLE_RATIO = "spindle-ratio"
1124
1125 IPOLICY_ISPECS = compat.UniqueFrozenset([
1126 ISPECS_MIN,
1127 ISPECS_MAX,
1128 ISPECS_STD,
1129 ])
1130
1131 IPOLICY_PARAMETERS = compat.UniqueFrozenset([
1132 IPOLICY_VCPU_RATIO,
1133 IPOLICY_SPINDLE_RATIO,
1134 ])
1135
1136 IPOLICY_ALL_KEYS = (IPOLICY_ISPECS |
1137 IPOLICY_PARAMETERS |
1138 frozenset([IPOLICY_DTS]))
1139
1140 # Node parameter names
1141 ND_OOB_PROGRAM = "oob_program"
1142 ND_SPINDLE_COUNT = "spindle_count"
1143 ND_EXCLUSIVE_STORAGE = "exclusive_storage"
1144
1145 NDS_PARAMETER_TYPES = {
1146 ND_OOB_PROGRAM: VTYPE_STRING,
1147 ND_SPINDLE_COUNT: VTYPE_INT,
1148 ND_EXCLUSIVE_STORAGE: VTYPE_BOOL,
1149 }
1150
1151 NDS_PARAMETERS = frozenset(NDS_PARAMETER_TYPES.keys())
1152
1153 NDS_PARAMETER_TITLES = {
1154 ND_OOB_PROGRAM: "OutOfBandProgram",
1155 ND_SPINDLE_COUNT: "SpindleCount",
1156 ND_EXCLUSIVE_STORAGE: "ExclusiveStorage",
1157 }
1158
1159 # Logical Disks parameters
1160 LDP_RESYNC_RATE = "resync-rate"
1161 LDP_STRIPES = "stripes"
1162 LDP_BARRIERS = "disabled-barriers"
1163 LDP_NO_META_FLUSH = "disable-meta-flush"
1164 LDP_DEFAULT_METAVG = "default-metavg"
1165 LDP_DISK_CUSTOM = "disk-custom"
1166 LDP_NET_CUSTOM = "net-custom"
1167 LDP_DYNAMIC_RESYNC = "dynamic-resync"
1168 LDP_PLAN_AHEAD = "c-plan-ahead"
1169 LDP_FILL_TARGET = "c-fill-target"
1170 LDP_DELAY_TARGET = "c-delay-target"
1171 LDP_MAX_RATE = "c-max-rate"
1172 LDP_MIN_RATE = "c-min-rate"
1173 LDP_POOL = "pool"
1174 DISK_LD_TYPES = {
1175 LDP_RESYNC_RATE: VTYPE_INT,
1176 LDP_STRIPES: VTYPE_INT,
1177 LDP_BARRIERS: VTYPE_STRING,
1178 LDP_NO_META_FLUSH: VTYPE_BOOL,
1179 LDP_DEFAULT_METAVG: VTYPE_STRING,
1180 LDP_DISK_CUSTOM: VTYPE_STRING,
1181 LDP_NET_CUSTOM: VTYPE_STRING,
1182 LDP_DYNAMIC_RESYNC: VTYPE_BOOL,
1183 LDP_PLAN_AHEAD: VTYPE_INT,
1184 LDP_FILL_TARGET: VTYPE_INT,
1185 LDP_DELAY_TARGET: VTYPE_INT,
1186 LDP_MAX_RATE: VTYPE_INT,
1187 LDP_MIN_RATE: VTYPE_INT,
1188 LDP_POOL: VTYPE_STRING,
1189 }
1190 DISK_LD_PARAMETERS = frozenset(DISK_LD_TYPES.keys())
1191
1192 # Disk template parameters (can be set/changed by the user via gnt-cluster and
1193 # gnt-group)
1194 DRBD_RESYNC_RATE = "resync-rate"
1195 DRBD_DATA_STRIPES = "data-stripes"
1196 DRBD_META_STRIPES = "meta-stripes"
1197 DRBD_DISK_BARRIERS = "disk-barriers"
1198 DRBD_META_BARRIERS = "meta-barriers"
1199 DRBD_DEFAULT_METAVG = "metavg"
1200 DRBD_DISK_CUSTOM = "disk-custom"
1201 DRBD_NET_CUSTOM = "net-custom"
1202 DRBD_DYNAMIC_RESYNC = "dynamic-resync"
1203 DRBD_PLAN_AHEAD = "c-plan-ahead"
1204 DRBD_FILL_TARGET = "c-fill-target"
1205 DRBD_DELAY_TARGET = "c-delay-target"
1206 DRBD_MAX_RATE = "c-max-rate"
1207 DRBD_MIN_RATE = "c-min-rate"
1208 LV_STRIPES = "stripes"
1209 RBD_POOL = "pool"
1210 DISK_DT_TYPES = {
1211 DRBD_RESYNC_RATE: VTYPE_INT,
1212 DRBD_DATA_STRIPES: VTYPE_INT,
1213 DRBD_META_STRIPES: VTYPE_INT,
1214 DRBD_DISK_BARRIERS: VTYPE_STRING,
1215 DRBD_META_BARRIERS: VTYPE_BOOL,
1216 DRBD_DEFAULT_METAVG: VTYPE_STRING,
1217 DRBD_DISK_CUSTOM: VTYPE_STRING,
1218 DRBD_NET_CUSTOM: VTYPE_STRING,
1219 DRBD_DYNAMIC_RESYNC: VTYPE_BOOL,
1220 DRBD_PLAN_AHEAD: VTYPE_INT,
1221 DRBD_FILL_TARGET: VTYPE_INT,
1222 DRBD_DELAY_TARGET: VTYPE_INT,
1223 DRBD_MAX_RATE: VTYPE_INT,
1224 DRBD_MIN_RATE: VTYPE_INT,
1225 LV_STRIPES: VTYPE_INT,
1226 RBD_POOL: VTYPE_STRING,
1227 }
1228
1229 DISK_DT_PARAMETERS = frozenset(DISK_DT_TYPES.keys())
1230
1231 # OOB supported commands
1232 OOB_POWER_ON = "power-on"
1233 OOB_POWER_OFF = "power-off"
1234 OOB_POWER_CYCLE = "power-cycle"
1235 OOB_POWER_STATUS = "power-status"
1236 OOB_HEALTH = "health"
1237
1238 OOB_COMMANDS = compat.UniqueFrozenset([
1239 OOB_POWER_ON,
1240 OOB_POWER_OFF,
1241 OOB_POWER_CYCLE,
1242 OOB_POWER_STATUS,
1243 OOB_HEALTH,
1244 ])
1245
1246 OOB_POWER_STATUS_POWERED = "powered"
1247
1248 OOB_TIMEOUT = 60 # 60 seconds
1249 OOB_POWER_DELAY = 2.0 # 2 seconds
1250
1251 OOB_STATUS_OK = "OK"
1252 OOB_STATUS_WARNING = "WARNING"
1253 OOB_STATUS_CRITICAL = "CRITICAL"
1254 OOB_STATUS_UNKNOWN = "UNKNOWN"
1255
1256 OOB_STATUSES = compat.UniqueFrozenset([
1257 OOB_STATUS_OK,
1258 OOB_STATUS_WARNING,
1259 OOB_STATUS_CRITICAL,
1260 OOB_STATUS_UNKNOWN,
1261 ])
1262
1263 # Instance Parameters Profile
1264 PP_DEFAULT = "default"
1265
1266 # NIC_* constants are used inside the ganeti config
1267 NIC_MODE = "mode"
1268 NIC_LINK = "link"
1269
1270 NIC_MODE_BRIDGED = "bridged"
1271 NIC_MODE_ROUTED = "routed"
1272 NIC_MODE_OVS = "openvswitch"
1273 NIC_IP_POOL = "pool"
1274
1275 NIC_VALID_MODES = compat.UniqueFrozenset([
1276 NIC_MODE_BRIDGED,
1277 NIC_MODE_ROUTED,
1278 NIC_MODE_OVS,
1279 ])
1280
1281 RESERVE_ACTION = "reserve"
1282 RELEASE_ACTION = "release"
1283
1284 NICS_PARAMETER_TYPES = {
1285 NIC_MODE: VTYPE_STRING,
1286 NIC_LINK: VTYPE_STRING,
1287 }
1288
1289 NICS_PARAMETERS = frozenset(NICS_PARAMETER_TYPES.keys())
1290
1291 # IDISK_* constants are used in opcodes, to create/change disks
1292 IDISK_SIZE = "size"
1293 IDISK_MODE = "mode"
1294 IDISK_ADOPT = "adopt"
1295 IDISK_VG = "vg"
1296 IDISK_METAVG = "metavg"
1297 IDISK_PROVIDER = "provider"
1298 IDISK_PARAMS_TYPES = {
1299 IDISK_SIZE: VTYPE_SIZE,
1300 IDISK_MODE: VTYPE_STRING,
1301 IDISK_ADOPT: VTYPE_STRING,
1302 IDISK_VG: VTYPE_STRING,
1303 IDISK_METAVG: VTYPE_STRING,
1304 IDISK_PROVIDER: VTYPE_STRING,
1305 }
1306 IDISK_PARAMS = frozenset(IDISK_PARAMS_TYPES.keys())
1307
1308 # INIC_* constants are used in opcodes, to create/change nics
1309 INIC_MAC = "mac"
1310 INIC_IP = "ip"
1311 INIC_MODE = "mode"
1312 INIC_LINK = "link"
1313 INIC_NETWORK = "network"
1314 INIC_PARAMS_TYPES = {
1315 INIC_IP: VTYPE_MAYBE_STRING,
1316 INIC_LINK: VTYPE_STRING,
1317 INIC_MAC: VTYPE_STRING,
1318 INIC_MODE: VTYPE_STRING,
1319 INIC_NETWORK: VTYPE_MAYBE_STRING,
1320 }
1321 INIC_PARAMS = frozenset(INIC_PARAMS_TYPES.keys())
1322
1323 # Hypervisor constants
1324 HT_XEN_PVM = "xen-pvm"
1325 HT_FAKE = "fake"
1326 HT_XEN_HVM = "xen-hvm"
1327 HT_KVM = "kvm"
1328 HT_CHROOT = "chroot"
1329 HT_LXC = "lxc"
1330 HYPER_TYPES = compat.UniqueFrozenset([
1331 HT_XEN_PVM,
1332 HT_FAKE,
1333 HT_XEN_HVM,
1334 HT_KVM,
1335 HT_CHROOT,
1336 HT_LXC,
1337 ])
1338 HTS_REQ_PORT = compat.UniqueFrozenset([HT_XEN_HVM, HT_KVM])
1339
1340 VNC_BASE_PORT = 5900
1341 VNC_DEFAULT_BIND_ADDRESS = IP4_ADDRESS_ANY
1342
1343 # NIC types
1344 HT_NIC_RTL8139 = "rtl8139"
1345 HT_NIC_NE2K_PCI = "ne2k_pci"
1346 HT_NIC_NE2K_ISA = "ne2k_isa"
1347 HT_NIC_I82551 = "i82551"
1348 HT_NIC_I85557B = "i82557b"
1349 HT_NIC_I8259ER = "i82559er"
1350 HT_NIC_PCNET = "pcnet"
1351 HT_NIC_E1000 = "e1000"
1352 HT_NIC_PARAVIRTUAL = HT_DISK_PARAVIRTUAL = "paravirtual"
1353
1354 HT_HVM_VALID_NIC_TYPES = compat.UniqueFrozenset([
1355 HT_NIC_RTL8139,
1356 HT_NIC_NE2K_PCI,
1357 HT_NIC_E1000,
1358 HT_NIC_NE2K_ISA,
1359 HT_NIC_PARAVIRTUAL,
1360 ])
1361 HT_KVM_VALID_NIC_TYPES = compat.UniqueFrozenset([
1362 HT_NIC_RTL8139,
1363 HT_NIC_NE2K_PCI,
1364 HT_NIC_NE2K_ISA,
1365 HT_NIC_I82551,
1366 HT_NIC_I85557B,
1367 HT_NIC_I8259ER,
1368 HT_NIC_PCNET,
1369 HT_NIC_E1000,
1370 HT_NIC_PARAVIRTUAL,
1371 ])
1372
1373 # Disk types
1374 HT_DISK_IOEMU = "ioemu"
1375 HT_DISK_IDE = "ide"
1376 HT_DISK_SCSI = "scsi"
1377 HT_DISK_SD = "sd"
1378 HT_DISK_MTD = "mtd"
1379 HT_DISK_PFLASH = "pflash"
1380
1381 HT_CACHE_DEFAULT = "default"
1382 HT_CACHE_NONE = "none"
1383 HT_CACHE_WTHROUGH = "writethrough"
1384 HT_CACHE_WBACK = "writeback"
1385 HT_VALID_CACHE_TYPES = compat.UniqueFrozenset([
1386 HT_CACHE_DEFAULT,
1387 HT_CACHE_NONE,
1388 HT_CACHE_WTHROUGH,
1389 HT_CACHE_WBACK,
1390 ])
1391
1392 HT_HVM_VALID_DISK_TYPES = compat.UniqueFrozenset([
1393 HT_DISK_PARAVIRTUAL,
1394 HT_DISK_IOEMU,
1395 ])
1396 HT_KVM_VALID_DISK_TYPES = compat.UniqueFrozenset([
1397 HT_DISK_PARAVIRTUAL,
1398 HT_DISK_IDE,
1399 HT_DISK_SCSI,
1400 HT_DISK_SD,
1401 HT_DISK_MTD,
1402 HT_DISK_PFLASH,
1403 ])
1404
1405 # Mouse types:
1406 HT_MOUSE_MOUSE = "mouse"
1407 HT_MOUSE_TABLET = "tablet"
1408
1409 HT_KVM_VALID_MOUSE_TYPES = compat.UniqueFrozenset([
1410 HT_MOUSE_MOUSE,
1411 HT_MOUSE_TABLET,
1412 ])
1413
1414 # Boot order
1415 HT_BO_FLOPPY = "floppy"
1416 HT_BO_CDROM = "cdrom"
1417 HT_BO_DISK = "disk"
1418 HT_BO_NETWORK = "network"
1419
1420 HT_KVM_VALID_BO_TYPES = compat.UniqueFrozenset([
1421 HT_BO_FLOPPY,
1422 HT_BO_CDROM,
1423 HT_BO_DISK,
1424 HT_BO_NETWORK,
1425 ])
1426
1427 # SPICE lossless image compression options
1428 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ = "auto_glz"
1429 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ = "auto_lz"
1430 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC = "quic"
1431 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ = "glz"
1432 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ = "lz"
1433 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF = "off"
1434
1435 HT_KVM_SPICE_VALID_LOSSLESS_IMG_COMPR_OPTIONS = compat.UniqueFrozenset([
1436 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ,
1437 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ,
1438 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC,
1439 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ,
1440 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ,
1441 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF,
1442 ])
1443
1444 # SPICE lossy image compression options (valid for both jpeg and zlib-glz)
1445 HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO = "auto"
1446 HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER = "never"
1447 HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS = "always"
1448
1449 HT_KVM_SPICE_VALID_LOSSY_IMG_COMPR_OPTIONS = compat.UniqueFrozenset([
1450 HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO,
1451 HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER,
1452 HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS,
1453 ])
1454
1455 # SPICE video stream detection
1456 HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF = "off"
1457 HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL = "all"
1458 HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER = "filter"
1459
1460 HT_KVM_SPICE_VALID_VIDEO_STREAM_DETECTION_OPTIONS = compat.UniqueFrozenset([
1461 HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF,
1462 HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL,
1463 HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER,
1464 ])
1465
1466 # Security models
1467 HT_SM_NONE = "none"
1468 HT_SM_USER = "user"
1469 HT_SM_POOL = "pool"
1470
1471 HT_KVM_VALID_SM_TYPES = compat.UniqueFrozenset([
1472 HT_SM_NONE,
1473 HT_SM_USER,
1474 HT_SM_POOL,
1475 ])
1476
1477 # Kvm flag values
1478 HT_KVM_ENABLED = "enabled"
1479 HT_KVM_DISABLED = "disabled"
1480
1481 HT_KVM_FLAG_VALUES = compat.UniqueFrozenset([HT_KVM_ENABLED, HT_KVM_DISABLED])
1482
1483 # Migration type
1484 HT_MIGRATION_LIVE = "live"
1485 HT_MIGRATION_NONLIVE = "non-live"
1486 HT_MIGRATION_MODES = compat.UniqueFrozenset([
1487 HT_MIGRATION_LIVE,
1488 HT_MIGRATION_NONLIVE,
1489 ])
1490
1491 # Cluster Verify steps
1492 VERIFY_NPLUSONE_MEM = "nplusone_mem"
1493 VERIFY_OPTIONAL_CHECKS = compat.UniqueFrozenset([VERIFY_NPLUSONE_MEM])
1494
1495 # Cluster Verify error classes
1496 CV_TCLUSTER = "cluster"
1497 CV_TGROUP = "group"
1498 CV_TNODE = "node"
1499 CV_TINSTANCE = "instance"
1500
1501 # Cluster Verify error codes and documentation
1502 CV_ECLUSTERCFG = \
1503 (CV_TCLUSTER, "ECLUSTERCFG", "Cluster configuration verification failure")
1504 CV_ECLUSTERCERT = \
1505 (CV_TCLUSTER, "ECLUSTERCERT",
1506 "Cluster certificate files verification failure")
1507 CV_ECLUSTERFILECHECK = \
1508 (CV_TCLUSTER, "ECLUSTERFILECHECK",
1509 "Cluster configuration verification failure")
1510 CV_ECLUSTERDANGLINGNODES = \
1511 (CV_TNODE, "ECLUSTERDANGLINGNODES",
1512 "Some nodes belong to non-existing groups")
1513 CV_ECLUSTERDANGLINGINST = \
1514 (CV_TNODE, "ECLUSTERDANGLINGINST",
1515 "Some instances have a non-existing primary node")
1516 CV_EGROUPDIFFERENTPVSIZE = \
1517 (CV_TGROUP, "EGROUPDIFFERENTPVSIZE", "PVs in the group have different sizes")
1518 CV_EINSTANCEBADNODE = \
1519 (CV_TINSTANCE, "EINSTANCEBADNODE",
1520 "Instance marked as running lives on an offline node")
1521 CV_EINSTANCEDOWN = \
1522 (CV_TINSTANCE, "EINSTANCEDOWN", "Instance not running on its primary node")
1523 CV_EINSTANCELAYOUT = \
1524 (CV_TINSTANCE, "EINSTANCELAYOUT", "Instance has multiple secondary nodes")
1525 CV_EINSTANCEMISSINGDISK = \
1526 (CV_TINSTANCE, "EINSTANCEMISSINGDISK", "Missing volume on an instance")
1527 CV_EINSTANCEFAULTYDISK = \
1528 (CV_TINSTANCE, "EINSTANCEFAULTYDISK",
1529 "Impossible to retrieve status for a disk")
1530 CV_EINSTANCEWRONGNODE = \
1531 (CV_TINSTANCE, "EINSTANCEWRONGNODE", "Instance running on the wrong node")
1532 CV_EINSTANCESPLITGROUPS = \
1533 (CV_TINSTANCE, "EINSTANCESPLITGROUPS",
1534 "Instance with primary and secondary nodes in different groups")
1535 CV_EINSTANCEPOLICY = \
1536 (CV_TINSTANCE, "EINSTANCEPOLICY",
1537 "Instance does not meet policy")
1538 CV_EINSTANCEUNSUITABLENODE = \
1539 (CV_TINSTANCE, "EINSTANCEUNSUITABLENODE",
1540 "Instance running on nodes that are not suitable for it")
1541 CV_ENODEDRBD = \
1542 (CV_TNODE, "ENODEDRBD", "Error parsing the DRBD status file")
1543 CV_ENODEDRBDHELPER = \
1544 (CV_TNODE, "ENODEDRBDHELPER", "Error caused by the DRBD helper")
1545 CV_ENODEFILECHECK = \
1546 (CV_TNODE, "ENODEFILECHECK",
1547 "Error retrieving the checksum of the node files")
1548 CV_ENODEHOOKS = \
1549 (CV_TNODE, "ENODEHOOKS", "Communication failure in hooks execution")
1550 CV_ENODEHV = \
1551 (CV_TNODE, "ENODEHV", "Hypervisor parameters verification failure")
1552 CV_ENODELVM = \
1553 (CV_TNODE, "ENODELVM", "LVM-related node error")
1554 CV_ENODEN1 = \
1555 (CV_TNODE, "ENODEN1", "Not enough memory to accommodate instance failovers")
1556 CV_ENODENET = \
1557 (CV_TNODE, "ENODENET", "Network-related node error")
1558 CV_ENODEOS = \
1559 (CV_TNODE, "ENODEOS", "OS-related node error")
1560 CV_ENODEORPHANINSTANCE = \
1561 (CV_TNODE, "ENODEORPHANINSTANCE", "Unknown intance running on a node")
1562 CV_ENODEORPHANLV = \
1563 (CV_TNODE, "ENODEORPHANLV", "Unknown LVM logical volume")
1564 CV_ENODERPC = \
1565 (CV_TNODE, "ENODERPC",
1566 "Error during connection to the primary node of an instance")
1567 CV_ENODESSH = \
1568 (CV_TNODE, "ENODESSH", "SSH-related node error")
1569 CV_ENODEVERSION = \
1570 (CV_TNODE, "ENODEVERSION",
1571 "Protocol version mismatch or Ganeti version mismatch")
1572 CV_ENODESETUP = \
1573 (CV_TNODE, "ENODESETUP", "Node setup error")
1574 CV_ENODETIME = \
1575 (CV_TNODE, "ENODETIME", "Node returned invalid time")
1576 CV_ENODEOOBPATH = \
1577 (CV_TNODE, "ENODEOOBPATH", "Invalid Out Of Band path")
1578 CV_ENODEUSERSCRIPTS = \
1579 (CV_TNODE, "ENODEUSERSCRIPTS", "User scripts not present or not executable")
1580 CV_ENODEFILESTORAGEPATHS = \
1581 (CV_TNODE, "ENODEFILESTORAGEPATHS", "Detected bad file storage paths")
1582
1583 CV_ALL_ECODES = compat.UniqueFrozenset([
1584 CV_ECLUSTERCFG,
1585 CV_ECLUSTERCERT,
1586 CV_ECLUSTERFILECHECK,
1587 CV_ECLUSTERDANGLINGNODES,
1588 CV_ECLUSTERDANGLINGINST,
1589 CV_EINSTANCEBADNODE,
1590 CV_EINSTANCEDOWN,
1591 CV_EINSTANCELAYOUT,
1592 CV_EINSTANCEMISSINGDISK,
1593 CV_EINSTANCEFAULTYDISK,
1594 CV_EINSTANCEWRONGNODE,
1595 CV_EINSTANCESPLITGROUPS,
1596 CV_EINSTANCEPOLICY,
1597 CV_ENODEDRBD,
1598 CV_ENODEDRBDHELPER,
1599 CV_ENODEFILECHECK,
1600 CV_ENODEHOOKS,
1601 CV_ENODEHV,
1602 CV_ENODELVM,
1603 CV_ENODEN1,
1604 CV_ENODENET,
1605 CV_ENODEOS,
1606 CV_ENODEORPHANINSTANCE,
1607 CV_ENODEORPHANLV,
1608 CV_ENODERPC,
1609 CV_ENODESSH,
1610 CV_ENODEVERSION,
1611 CV_ENODESETUP,
1612 CV_ENODETIME,
1613 CV_ENODEOOBPATH,
1614 CV_ENODEUSERSCRIPTS,
1615 CV_ENODEFILESTORAGEPATHS,
1616 ])
1617
1618 CV_ALL_ECODES_STRINGS = \
1619 compat.UniqueFrozenset(estr for (_, estr, _) in CV_ALL_ECODES)
1620
1621 # Node verify constants
1622 NV_BRIDGES = "bridges"
1623 NV_DRBDHELPER = "drbd-helper"
1624 NV_DRBDLIST = "drbd-list"
1625 NV_EXCLUSIVEPVS = "exclusive-pvs"
1626 NV_FILELIST = "filelist"
1627 NV_FILE_STORAGE_PATHS = "file-storage-paths"
1628 NV_HVINFO = "hvinfo"
1629 NV_HVPARAMS = "hvparms"
1630 NV_HYPERVISOR = "hypervisor"
1631 NV_INSTANCELIST = "instancelist"
1632 NV_LVLIST = "lvlist"
1633 NV_MASTERIP = "master-ip"
1634 NV_NODELIST = "nodelist"
1635 NV_NODENETTEST = "node-net-test"
1636 NV_NODESETUP = "nodesetup"
1637 NV_OOB_PATHS = "oob-paths"
1638 NV_OSLIST = "oslist"
1639 NV_PVLIST = "pvlist"
1640 NV_TIME = "time"
1641 NV_USERSCRIPTS = "user-scripts"
1642 NV_VERSION = "version"
1643 NV_VGLIST = "vglist"
1644 NV_VMNODES = "vmnodes"
1645
1646 # Instance status
1647 INSTST_RUNNING = "running"
1648 INSTST_ADMINDOWN = "ADMIN_down"
1649 INSTST_ADMINOFFLINE = "ADMIN_offline"
1650 INSTST_NODEOFFLINE = "ERROR_nodeoffline"
1651 INSTST_NODEDOWN = "ERROR_nodedown"
1652 INSTST_WRONGNODE = "ERROR_wrongnode"
1653 INSTST_ERRORUP = "ERROR_up"
1654 INSTST_ERRORDOWN = "ERROR_down"
1655 INSTST_ALL = compat.UniqueFrozenset([
1656 INSTST_RUNNING,
1657 INSTST_ADMINDOWN,
1658 INSTST_ADMINOFFLINE,
1659 INSTST_NODEOFFLINE,
1660 INSTST_NODEDOWN,
1661 INSTST_WRONGNODE,
1662 INSTST_ERRORUP,
1663 INSTST_ERRORDOWN,
1664 ])
1665
1666 # Admin states
1667 ADMINST_UP = "up"
1668 ADMINST_DOWN = "down"
1669 ADMINST_OFFLINE = "offline"
1670 ADMINST_ALL = compat.UniqueFrozenset([
1671 ADMINST_UP,
1672 ADMINST_DOWN,
1673 ADMINST_OFFLINE,
1674 ])
1675
1676 # Node roles
1677 NR_REGULAR = "R"
1678 NR_MASTER = "M"
1679 NR_MCANDIDATE = "C"
1680 NR_DRAINED = "D"
1681 NR_OFFLINE = "O"
1682 NR_ALL = compat.UniqueFrozenset([
1683 NR_REGULAR,
1684 NR_MASTER,
1685 NR_MCANDIDATE,
1686 NR_DRAINED,
1687 NR_OFFLINE,
1688 ])
1689
1690 # SSL certificate check constants (in days)
1691 SSL_CERT_EXPIRATION_WARN = 30
1692 SSL_CERT_EXPIRATION_ERROR = 7
1693
1694 # Allocator framework constants
1695 IALLOCATOR_VERSION = 2
1696 IALLOCATOR_DIR_IN = "in"
1697 IALLOCATOR_DIR_OUT = "out"
1698 VALID_IALLOCATOR_DIRECTIONS = compat.UniqueFrozenset([
1699 IALLOCATOR_DIR_IN,
1700 IALLOCATOR_DIR_OUT,
1701 ])
1702 IALLOCATOR_MODE_ALLOC = "allocate"
1703 IALLOCATOR_MODE_RELOC = "relocate"
1704 IALLOCATOR_MODE_CHG_GROUP = "change-group"
1705 IALLOCATOR_MODE_NODE_EVAC = "node-evacuate"
1706 IALLOCATOR_MODE_MULTI_ALLOC = "multi-allocate"
1707 VALID_IALLOCATOR_MODES = compat.UniqueFrozenset([
1708 IALLOCATOR_MODE_ALLOC,
1709 IALLOCATOR_MODE_RELOC,
1710 IALLOCATOR_MODE_CHG_GROUP,
1711 IALLOCATOR_MODE_NODE_EVAC,
1712 IALLOCATOR_MODE_MULTI_ALLOC,
1713 ])
1714 IALLOCATOR_SEARCH_PATH = _autoconf.IALLOCATOR_SEARCH_PATH
1715 DEFAULT_IALLOCATOR_SHORTCUT = "."
1716
1717 IALLOCATOR_NEVAC_PRI = "primary-only"
1718 IALLOCATOR_NEVAC_SEC = "secondary-only"
1719 IALLOCATOR_NEVAC_ALL = "all"
1720 IALLOCATOR_NEVAC_MODES = compat.UniqueFrozenset([
1721 IALLOCATOR_NEVAC_PRI,
1722 IALLOCATOR_NEVAC_SEC,
1723 IALLOCATOR_NEVAC_ALL,
1724 ])
1725
1726 # Node evacuation
1727 NODE_EVAC_PRI = "primary-only"
1728 NODE_EVAC_SEC = "secondary-only"
1729 NODE_EVAC_ALL = "all"
1730 NODE_EVAC_MODES = compat.UniqueFrozenset([
1731 NODE_EVAC_PRI,
1732 NODE_EVAC_SEC,
1733 NODE_EVAC_ALL,
1734 ])
1735
1736 # Job queue
1737 JOB_QUEUE_VERSION = 1
1738 JOB_QUEUE_SIZE_HARD_LIMIT = 5000
1739
1740 JOB_ID_TEMPLATE = r"\d+"
1741 JOB_FILE_RE = re.compile(r"^job-(%s)$" % JOB_ID_TEMPLATE)
1742
1743 # unchanged job return
1744 JOB_NOTCHANGED = "nochange"
1745
1746 # Job status
1747 JOB_STATUS_QUEUED = "queued"
1748 JOB_STATUS_WAITING = "waiting"
1749 JOB_STATUS_CANCELING = "canceling"
1750 JOB_STATUS_RUNNING = "running"
1751 JOB_STATUS_CANCELED = "canceled"
1752 JOB_STATUS_SUCCESS = "success"
1753 JOB_STATUS_ERROR = "error"
1754 JOBS_PENDING = compat.UniqueFrozenset([
1755 JOB_STATUS_QUEUED,
1756 JOB_STATUS_WAITING,
1757 JOB_STATUS_CANCELING,
1758 ])
1759 JOBS_FINALIZED = compat.UniqueFrozenset([
1760 JOB_STATUS_CANCELED,
1761 JOB_STATUS_SUCCESS,
1762 JOB_STATUS_ERROR,
1763 ])
1764 JOB_STATUS_ALL = compat.UniqueFrozenset([
1765 JOB_STATUS_RUNNING,
1766 ]) | JOBS_PENDING | JOBS_FINALIZED
1767
1768 # OpCode status
1769 # not yet finalized
1770 OP_STATUS_QUEUED = "queued"
1771 OP_STATUS_WAITING = "waiting"
1772 OP_STATUS_CANCELING = "canceling"
1773 OP_STATUS_RUNNING = "running"
1774 # finalized
1775 OP_STATUS_CANCELED = "canceled"
1776 OP_STATUS_SUCCESS = "success"
1777 OP_STATUS_ERROR = "error"
1778 OPS_FINALIZED = compat.UniqueFrozenset([
1779 OP_STATUS_CANCELED,
1780 OP_STATUS_SUCCESS,
1781 OP_STATUS_ERROR,
1782 ])
1783
1784 # OpCode priority
1785 OP_PRIO_LOWEST = +19
1786 OP_PRIO_HIGHEST = -20
1787
1788 OP_PRIO_LOW = +10
1789 OP_PRIO_NORMAL = 0
1790 OP_PRIO_HIGH = -10
1791
1792 OP_PRIO_SUBMIT_VALID = compat.UniqueFrozenset([
1793 OP_PRIO_LOW,
1794 OP_PRIO_NORMAL,
1795 OP_PRIO_HIGH,
1796 ])
1797
1798 OP_PRIO_DEFAULT = OP_PRIO_NORMAL
1799
1800 # Lock recalculate mode
1801 LOCKS_REPLACE = "replace"
1802 LOCKS_APPEND = "append"
1803
1804 # Lock timeout (sum) before we should go into blocking acquire (still
1805 # can be reset by priority change); computed as max time (10 hours)
1806 # before we should actually go into blocking acquire given that we
1807 # start from default priority level; in seconds
1808 # TODO
1809 LOCK_ATTEMPTS_TIMEOUT = 10 * 3600 / (OP_PRIO_DEFAULT - OP_PRIO_HIGHEST)
1810 LOCK_ATTEMPTS_MAXWAIT = 15.0
1811 LOCK_ATTEMPTS_MINWAIT = 1.0
1812
1813 # Execution log types
1814 ELOG_MESSAGE = "message"
1815 ELOG_REMOTE_IMPORT = "remote-import"
1816 ELOG_JQUEUE_TEST = "jqueue-test"
1817
1818 # /etc/hosts modification
1819 ETC_HOSTS_ADD = "add"
1820 ETC_HOSTS_REMOVE = "remove"
1821
1822 # Job queue test
1823 JQT_MSGPREFIX = "TESTMSG="
1824 JQT_EXPANDNAMES = "expandnames"
1825 JQT_EXEC = "exec"
1826 JQT_LOGMSG = "logmsg"
1827 JQT_STARTMSG = "startmsg"
1828 JQT_ALL = compat.UniqueFrozenset([
1829 JQT_EXPANDNAMES,
1830 JQT_EXEC,
1831 JQT_LOGMSG,
1832 JQT_STARTMSG,
1833 ])
1834
1835 # Query resources
1836 QR_CLUSTER = "cluster"
1837 QR_INSTANCE = "instance"
1838 QR_NODE = "node"
1839 QR_LOCK = "lock"
1840 QR_GROUP = "group"
1841 QR_OS = "os"
1842 QR_JOB = "job"
1843 QR_EXPORT = "export"
1844 QR_NETWORK = "network"
1845 QR_EXTSTORAGE = "extstorage"
1846
1847 #: List of resources which can be queried using L{opcodes.OpQuery}
1848 QR_VIA_OP = compat.UniqueFrozenset([
1849 QR_CLUSTER,
1850 QR_INSTANCE,
1851 QR_NODE,
1852 QR_GROUP,
1853 QR_OS,
1854 QR_EXPORT,
1855 QR_NETWORK,
1856 QR_EXTSTORAGE,
1857 ])
1858
1859 #: List of resources which can be queried using Local UniX Interface
1860 QR_VIA_LUXI = QR_VIA_OP.union([
1861 QR_LOCK,
1862 QR_JOB,
1863 ])
1864
1865 #: List of resources which can be queried using RAPI
1866 QR_VIA_RAPI = QR_VIA_LUXI
1867
1868 # Query field types
1869 QFT_UNKNOWN = "unknown"
1870 QFT_TEXT = "text"
1871 QFT_BOOL = "bool"
1872 QFT_NUMBER = "number"
1873 QFT_UNIT = "unit"
1874 QFT_TIMESTAMP = "timestamp"
1875 QFT_OTHER = "other"
1876
1877 #: All query field types
1878 QFT_ALL = compat.UniqueFrozenset([
1879 QFT_UNKNOWN,
1880 QFT_TEXT,
1881 QFT_BOOL,
1882 QFT_NUMBER,
1883 QFT_UNIT,
1884 QFT_TIMESTAMP,
1885 QFT_OTHER,
1886 ])
1887
1888 # Query result field status (don't change or reuse values as they're used by
1889 # clients)
1890 #: Normal field status
1891 RS_NORMAL = 0
1892 #: Unknown field
1893 RS_UNKNOWN = 1
1894 #: No data (e.g. RPC error), can be used instead of L{RS_OFFLINE}
1895 RS_NODATA = 2
1896 #: Value unavailable/unsupported for item; if this field is supported
1897 #: but we cannot get the data for the moment, RS_NODATA or
1898 #: RS_OFFLINE should be used
1899 RS_UNAVAIL = 3
1900 #: Resource marked offline
1901 RS_OFFLINE = 4
1902
1903 RS_ALL = compat.UniqueFrozenset([
1904 RS_NORMAL,
1905 RS_UNKNOWN,
1906 RS_NODATA,
1907 RS_UNAVAIL,
1908 RS_OFFLINE,
1909 ])
1910
1911 #: Dictionary with special field cases and their verbose/terse formatting
1912 RSS_DESCRIPTION = {
1913 RS_UNKNOWN: ("(unknown)", "??"),
1914 RS_NODATA: ("(nodata)", "?"),
1915 RS_OFFLINE: ("(offline)", "*"),
1916 RS_UNAVAIL: ("(unavail)", "-"),
1917 }
1918
1919 # max dynamic devices
1920 MAX_NICS = 8
1921 MAX_DISKS = 16
1922
1923 # SSCONF file prefix
1924 SSCONF_FILEPREFIX = "ssconf_"
1925 # SSCONF keys
1926 SS_CLUSTER_NAME = "cluster_name"
1927 SS_CLUSTER_TAGS = "cluster_tags"
1928 SS_FILE_STORAGE_DIR = "file_storage_dir"
1929 SS_SHARED_FILE_STORAGE_DIR = "shared_file_storage_dir"
1930 SS_MASTER_CANDIDATES = "master_candidates"
1931 SS_MASTER_CANDIDATES_IPS = "master_candidates_ips"
1932 SS_MASTER_IP = "master_ip"
1933 SS_MASTER_NETDEV = "master_netdev"
1934 SS_MASTER_NETMASK = "master_netmask"
1935 SS_MASTER_NODE = "master_node"
1936 SS_NODE_LIST = "node_list"
1937 SS_NODE_PRIMARY_IPS = "node_primary_ips"
1938 SS_NODE_SECONDARY_IPS = "node_secondary_ips"
1939 SS_OFFLINE_NODES = "offline_nodes"
1940 SS_ONLINE_NODES = "online_nodes"
1941 SS_PRIMARY_IP_FAMILY = "primary_ip_family"
1942 SS_INSTANCE_LIST = "instance_list"
1943 SS_RELEASE_VERSION = "release_version"
1944 SS_HYPERVISOR_LIST = "hypervisor_list"
1945 SS_MAINTAIN_NODE_HEALTH = "maintain_node_health"
1946 SS_UID_POOL = "uid_pool"
1947 SS_NODEGROUPS = "nodegroups"
1948 SS_NETWORKS = "networks"
1949
1950 SS_FILE_PERMS = 0444
1951
1952 # cluster wide default parameters
1953 DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM
1954
1955 HVC_DEFAULTS = {
1956 HT_XEN_PVM: {
1957 HV_USE_BOOTLOADER: False,
1958 HV_BOOTLOADER_PATH: XEN_BOOTLOADER,
1959 HV_BOOTLOADER_ARGS: "",
1960 HV_KERNEL_PATH: XEN_KERNEL,
1961 HV_INITRD_PATH: "",
1962 HV_ROOT_PATH: "/dev/xvda1",
1963 HV_KERNEL_ARGS: "ro",
1964 HV_MIGRATION_PORT: 8002,
1965 HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1966 HV_BLOCKDEV_PREFIX: "sd",
1967 HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1968 HV_CPU_MASK: CPU_PINNING_ALL,
1969 HV_CPU_CAP: 0,
1970 HV_CPU_WEIGHT: 256,
1971 },
1972 HT_XEN_HVM: {
1973 HV_BOOT_ORDER: "cd",
1974 HV_CDROM_IMAGE_PATH: "",
1975 HV_NIC_TYPE: HT_NIC_RTL8139,
1976 HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
1977 HV_VNC_BIND_ADDRESS: IP4_ADDRESS_ANY,
1978 HV_VNC_PASSWORD_FILE: pathutils.VNC_PASSWORD_FILE,
1979 HV_ACPI: True,
1980 HV_PAE: True,
1981 HV_KERNEL_PATH: "/usr/lib/xen/boot/hvmloader",
1982 HV_DEVICE_MODEL: "/usr/lib/xen/bin/qemu-dm",
1983 HV_MIGRATION_PORT: 8002,
1984 HV_MIGRATION_MODE: HT_MIGRATION_NONLIVE,
1985 HV_USE_LOCALTIME: False,
1986 HV_BLOCKDEV_PREFIX: "hd",
1987 HV_PASSTHROUGH: "",
1988 HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1989 HV_CPU_MASK: CPU_PINNING_ALL,
1990 HV_CPU_CAP: 0,
1991 HV_CPU_WEIGHT: 256,
1992 },
1993 HT_KVM: {
1994 HV_KVM_PATH: KVM_PATH,
1995 HV_KERNEL_PATH: KVM_KERNEL,
1996 HV_INITRD_PATH: "",
1997 HV_KERNEL_ARGS: "ro",
1998 HV_ROOT_PATH: "/dev/vda1",
1999 HV_ACPI: True,
2000 HV_SERIAL_CONSOLE: True,
2001 HV_SERIAL_SPEED: 38400,
2002 HV_VNC_BIND_ADDRESS: "",
2003 HV_VNC_TLS: False,
2004 HV_VNC_X509: "",
2005 HV_VNC_X509_VERIFY: False,
2006 HV_VNC_PASSWORD_FILE: "",
2007 HV_KVM_SPICE_BIND: "",
2008 HV_KVM_SPICE_IP_VERSION: IFACE_NO_IP_VERSION_SPECIFIED,
2009 HV_KVM_SPICE_PASSWORD_FILE: "",
2010 HV_KVM_SPICE_LOSSLESS_IMG_COMPR: "",
2011 HV_KVM_SPICE_JPEG_IMG_COMPR: "",
2012 HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR: "",
2013 HV_KVM_SPICE_STREAMING_VIDEO_DETECTION: "",
2014 HV_KVM_SPICE_AUDIO_COMPR: True,
2015 HV_KVM_SPICE_USE_TLS: False,
2016 HV_KVM_SPICE_TLS_CIPHERS: OPENSSL_CIPHERS,
2017 HV_KVM_SPICE_USE_VDAGENT: True,
2018 HV_KVM_FLOPPY_IMAGE_PATH: "",
2019 HV_CDROM_IMAGE_PATH: "",
2020 HV_KVM_CDROM2_IMAGE_PATH: "",
2021 HV_BOOT_ORDER: HT_BO_DISK,
2022 HV_NIC_TYPE: HT_NIC_PARAVIRTUAL,
2023 HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
2024 HV_KVM_CDROM_DISK_TYPE: "",
2025 HV_USB_MOUSE: "",
2026 HV_KEYMAP: "",
2027 HV_MIGRATION_PORT: 8102,
2028 HV_MIGRATION_BANDWIDTH: 32, # MiB/s
2029 HV_MIGRATION_DOWNTIME: 30, # ms
2030 HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
2031 HV_USE_LOCALTIME: False,
2032 HV_DISK_CACHE: HT_CACHE_DEFAULT,
2033 HV_SECURITY_MODEL: HT_SM_NONE,
2034 HV_SECURITY_DOMAIN: "",
2035 HV_KVM_FLAG: "",
2036 HV_VHOST_NET: False,
2037 HV_KVM_USE_CHROOT: False,
2038 HV_MEM_PATH: "",
2039 HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
2040 HV_CPU_MASK: CPU_PINNING_ALL,
2041 HV_CPU_TYPE: "",
2042 HV_CPU_CORES: 0,
2043 HV_CPU_THREADS: 0,
2044 HV_CPU_SOCKETS: 0,
2045 HV_SOUNDHW: "",
2046 HV_USB_DEVICES: "",
2047 HV_VGA: "",
2048 HV_KVM_EXTRA: "",
2049 HV_KVM_MACHINE_VERSION: "",
2050 },
2051 HT_FAKE: {},
2052 HT_CHROOT: {
2053 HV_INIT_SCRIPT: "/ganeti-chroot",
2054 },
2055 HT_LXC: {
2056 HV_CPU_MASK: "",
2057 },
2058 }
2059
2060 HVC_GLOBALS = compat.UniqueFrozenset([
2061 HV_MIGRATION_PORT,
2062 HV_MIGRATION_BANDWIDTH,
2063 HV_MIGRATION_MODE,
2064 ])
2065
2066 BEC_DEFAULTS = {
2067 BE_MINMEM: 128,
2068 BE_MAXMEM: 128,
2069 BE_VCPUS: 1,
2070 BE_AUTO_BALANCE: True,
2071 BE_ALWAYS_FAILOVER: False,
2072 BE_SPINDLE_USE: 1,
2073 }
2074
2075 NDC_DEFAULTS = {
2076 ND_OOB_PROGRAM: "",
2077 ND_SPINDLE_COUNT: 1,
2078 ND_EXCLUSIVE_STORAGE: False,
2079 }
2080
2081 NDC_GLOBALS = compat.UniqueFrozenset([
2082 ND_EXCLUSIVE_STORAGE,
2083 ])
2084
2085 DISK_LD_DEFAULTS = {
2086 LD_DRBD8: {
2087 LDP_RESYNC_RATE: CLASSIC_DRBD_SYNC_SPEED,
2088 LDP_BARRIERS: _autoconf.DRBD_BARRIERS,
2089 LDP_NO_META_FLUSH: _autoconf.DRBD_NO_META_FLUSH,
2090 LDP_DEFAULT_METAVG: DEFAULT_VG,
2091 LDP_DISK_CUSTOM: "",
2092 LDP_NET_CUSTOM: "",
2093 LDP_DYNAMIC_RESYNC: False,
2094
2095 # The default values for the DRBD dynamic resync speed algorithm
2096 # are taken from the drbsetup 8.3.11 man page, except for
2097 # c-plan-ahead (that we don't need to set to 0, because we have a
2098 # separate option to enable it) and for c-max-rate, that we cap to
2099 # the default value for the static resync rate.
2100 LDP_PLAN_AHEAD: 20, # ds
2101 LDP_FILL_TARGET: 0, # sectors
2102 LDP_DELAY_TARGET: 1, # ds
2103 LDP_MAX_RATE: CLASSIC_DRBD_SYNC_SPEED, # KiB/s
2104 LDP_MIN_RATE: 4 * 1024, # KiB/s
2105 },
2106 LD_LV: {
2107 LDP_STRIPES: _autoconf.LVM_STRIPECOUNT
2108 },
2109 LD_FILE: {},
2110 LD_BLOCKDEV: {},
2111 LD_RBD: {
2112 LDP_POOL: "rbd"
2113 },
2114 LD_EXT: {},
2115 }
2116
2117 # readability shortcuts
2118 _LV_DEFAULTS = DISK_LD_DEFAULTS[LD_LV]
2119 _DRBD_DEFAULTS = DISK_LD_DEFAULTS[LD_DRBD8]
2120
2121 DISK_DT_DEFAULTS = {
2122 DT_PLAIN: {
2123 LV_STRIPES: DISK_LD_DEFAULTS[LD_LV][LDP_STRIPES],
2124 },
2125 DT_DRBD8: {
2126 DRBD_RESYNC_RATE: _DRBD_DEFAULTS[LDP_RESYNC_RATE],
2127 DRBD_DATA_STRIPES: _LV_DEFAULTS[LDP_STRIPES],
2128 DRBD_META_STRIPES: _LV_DEFAULTS[LDP_STRIPES],
2129 DRBD_DISK_BARRIERS: _DRBD_DEFAULTS[LDP_BARRIERS],
2130 DRBD_META_BARRIERS: _DRBD_DEFAULTS[LDP_NO_META_FLUSH],
2131 DRBD_DEFAULT_METAVG: _DRBD_DEFAULTS[LDP_DEFAULT_METAVG],
2132 DRBD_DISK_CUSTOM: _DRBD_DEFAULTS[LDP_DISK_CUSTOM],
2133 DRBD_NET_CUSTOM: _DRBD_DEFAULTS[LDP_NET_CUSTOM],
2134 DRBD_DYNAMIC_RESYNC: _DRBD_DEFAULTS[LDP_DYNAMIC_RESYNC],
2135 DRBD_PLAN_AHEAD: _DRBD_DEFAULTS[LDP_PLAN_AHEAD],
2136 DRBD_FILL_TARGET: _DRBD_DEFAULTS[LDP_FILL_TARGET],
2137 DRBD_DELAY_TARGET: _DRBD_DEFAULTS[LDP_DELAY_TARGET],
2138 DRBD_MAX_RATE: _DRBD_DEFAULTS[LDP_MAX_RATE],
2139 DRBD_MIN_RATE: _DRBD_DEFAULTS[LDP_MIN_RATE],
2140 },
2141 DT_DISKLESS: {},
2142 DT_FILE: {},
2143 DT_SHARED_FILE: {},
2144 DT_BLOCK: {},
2145 DT_RBD: {
2146 RBD_POOL: DISK_LD_DEFAULTS[LD_RBD][LDP_POOL]
2147 },
2148 DT_EXT: {},
2149 }
2150
2151 # we don't want to export the shortcuts
2152 del _LV_DEFAULTS, _DRBD_DEFAULTS
2153
2154 NICC_DEFAULTS = {
2155 NIC_MODE: NIC_MODE_BRIDGED,
2156 NIC_LINK: DEFAULT_BRIDGE,
2157 }
2158
2159 # All of the following values are quite arbitrarily - there are no
2160 # "good" defaults, these must be customised per-site
2161 IPOLICY_DEFAULTS = {
2162 ISPECS_MIN: {
2163 ISPEC_MEM_SIZE: 128,
2164 ISPEC_CPU_COUNT: 1,
2165 ISPEC_DISK_COUNT: 1,
2166 ISPEC_DISK_SIZE: 1024,
2167 ISPEC_NIC_COUNT: 1,
2168 ISPEC_SPINDLE_USE: 1,
2169 },
2170 ISPECS_MAX: {
2171 ISPEC_MEM_SIZE: 32768,
2172 ISPEC_CPU_COUNT: 8,
2173 ISPEC_DISK_COUNT: MAX_DISKS,
2174 ISPEC_DISK_SIZE: 1024 * 1024,
2175 ISPEC_NIC_COUNT: MAX_NICS,
2176 ISPEC_SPINDLE_USE: 12,
2177 },
2178 ISPECS_STD: {
2179 ISPEC_MEM_SIZE: 128,
2180 ISPEC_CPU_COUNT: 1,
2181 ISPEC_DISK_COUNT: 1,
2182 ISPEC_DISK_SIZE: 1024,
2183 ISPEC_NIC_COUNT: 1,
2184 ISPEC_SPINDLE_USE: 1,
2185 },
2186 IPOLICY_DTS: list(DISK_TEMPLATES),
2187 IPOLICY_VCPU_RATIO: 4.0,
2188 IPOLICY_SPINDLE_RATIO: 32.0,
2189 }
2190
2191 MASTER_POOL_SIZE_DEFAULT = 10
2192
2193 # Exclusive storage:
2194 # Error margin used to compare physical disks
2195 PART_MARGIN = .01
2196 # Space reserved when creating instance disks
2197 PART_RESERVED = .02
2198
2199 CONFD_PROTOCOL_VERSION = 1
2200
2201 CONFD_REQ_PING = 0
2202 CONFD_REQ_NODE_ROLE_BYNAME = 1
2203 CONFD_REQ_NODE_PIP_BY_INSTANCE_IP = 2
2204 CONFD_REQ_CLUSTER_MASTER = 3
2205 CONFD_REQ_NODE_PIP_LIST = 4
2206 CONFD_REQ_MC_PIP_LIST = 5
2207 CONFD_REQ_INSTANCES_IPS_LIST = 6
2208 CONFD_REQ_NODE_DRBD = 7
2209 CONFD_REQ_NODE_INSTANCES = 8
2210
2211 # Confd request query fields. These are used to narrow down queries.
2212 # These must be strings rather than integers, because json-encoding
2213 # converts them to strings anyway, as they're used as dict-keys.
2214 CONFD_REQQ_LINK = "0"
2215 CONFD_REQQ_IP = "1"
2216 CONFD_REQQ_IPLIST = "2"
2217 CONFD_REQQ_FIELDS = "3"
2218
2219 CONFD_REQFIELD_NAME = "0"
2220 CONFD_REQFIELD_IP = "1"
2221 CONFD_REQFIELD_MNODE_PIP = "2"
2222
2223 CONFD_REQS = compat.UniqueFrozenset([
2224 CONFD_REQ_PING,
2225 CONFD_REQ_NODE_ROLE_BYNAME,
2226 CONFD_REQ_NODE_PIP_BY_INSTANCE_IP,
2227 CONFD_REQ_CLUSTER_MASTER,
2228 CONFD_REQ_NODE_PIP_LIST,
2229 CONFD_REQ_MC_PIP_LIST,
2230 CONFD_REQ_INSTANCES_IPS_LIST,
2231 CONFD_REQ_NODE_DRBD,
2232 ])
2233
2234 CONFD_REPL_STATUS_OK = 0
2235 CONFD_REPL_STATUS_ERROR = 1
2236 CONFD_REPL_STATUS_NOTIMPLEMENTED = 2
2237
2238 CONFD_REPL_STATUSES = compat.UniqueFrozenset([
2239 CONFD_REPL_STATUS_OK,
2240 CONFD_REPL_STATUS_ERROR,
2241 CONFD_REPL_STATUS_NOTIMPLEMENTED,
2242 ])
2243
2244 (CONFD_NODE_ROLE_MASTER,
2245 CONFD_NODE_ROLE_CANDIDATE,
2246 CONFD_NODE_ROLE_OFFLINE,
2247 CONFD_NODE_ROLE_DRAINED,
2248 CONFD_NODE_ROLE_REGULAR,
2249 ) = range(5)
2250
2251 # A few common errors for confd
2252 CONFD_ERROR_UNKNOWN_ENTRY = 1
2253 CONFD_ERROR_INTERNAL = 2
2254 CONFD_ERROR_ARGUMENT = 3
2255
2256 # Each request is "salted" by the current timestamp.
2257 # This constants decides how many seconds of skew to accept.
2258 # TODO: make this a default and allow the value to be more configurable
2259 CONFD_MAX_CLOCK_SKEW = 2 * NODE_MAX_CLOCK_SKEW
2260
2261 # When we haven't reloaded the config for more than this amount of
2262 # seconds, we force a test to see if inotify is betraying us. Using a
2263 # prime number to ensure we get less chance of 'same wakeup' with
2264 # other processes.
2265 CONFD_CONFIG_RELOAD_TIMEOUT = 17
2266
2267 # If we receive more than one update in this amount of microseconds,
2268 # we move to polling every RATELIMIT seconds, rather than relying on
2269 # inotify, to be able to serve more requests.
2270 CONFD_CONFIG_RELOAD_RATELIMIT = 250000
2271
2272 # Magic number prepended to all confd queries.
2273 # This allows us to distinguish different types of confd protocols and handle
2274 # them. For example by changing this we can move the whole payload to be
2275 # compressed, or move away from json.
2276 CONFD_MAGIC_FOURCC = "plj0"
2277
2278 # By default a confd request is sent to the minimum between this number and all
2279 # MCs. 6 was chosen because even in the case of a disastrous 50% response rate,
2280 # we should have enough answers to be able to compare more than one.
2281 CONFD_DEFAULT_REQ_COVERAGE = 6
2282
2283 # Timeout in seconds to expire pending query request in the confd client
2284 # library. We don't actually expect any answer more than 10 seconds after we
2285 # sent a request.
2286 CONFD_CLIENT_EXPIRE_TIMEOUT = 10
2287
2288 # Maximum UDP datagram size.
2289 # On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
2290 # On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
2291 # (assuming we can't use jumbo frames)
2292 # We just set this to 60K, which should be enough
2293 MAX_UDP_DATA_SIZE = 61440
2294
2295 # User-id pool minimum/maximum acceptable user-ids.
2296 UIDPOOL_UID_MIN = 0
2297 UIDPOOL_UID_MAX = 2 ** 32 - 1 # Assuming 32 bit user-ids
2298
2299 # Name or path of the pgrep command
2300 PGREP = "pgrep"
2301
2302 # Name of the node group that gets created at cluster init or upgrade
2303 INITIAL_NODE_GROUP_NAME = "default"
2304
2305 # Possible values for NodeGroup.alloc_policy
2306 ALLOC_POLICY_PREFERRED = "preferred"
2307 ALLOC_POLICY_LAST_RESORT = "last_resort"
2308 ALLOC_POLICY_UNALLOCABLE = "unallocable"
2309 VALID_ALLOC_POLICIES = [
2310 ALLOC_POLICY_PREFERRED,
2311 ALLOC_POLICY_LAST_RESORT,
2312 ALLOC_POLICY_UNALLOCABLE,
2313 ]
2314
2315 # Temporary external/shared storage parameters
2316 BLOCKDEV_DRIVER_MANUAL = "manual"
2317
2318 # qemu-img path, required for ovfconverter
2319 QEMUIMG_PATH = _autoconf.QEMUIMG_PATH
2320
2321 # Whether htools was enabled at compilation time
2322 HTOOLS = _autoconf.HTOOLS
2323 # The hail iallocator
2324 IALLOC_HAIL = "hail"
2325
2326 # Fake opcodes for functions that have hooks attached to them via
2327 # backend.RunLocalHooks
2328 FAKE_OP_MASTER_TURNUP = "OP_CLUSTER_IP_TURNUP"
2329 FAKE_OP_MASTER_TURNDOWN = "OP_CLUSTER_IP_TURNDOWN"
2330
2331 # SSH key types
2332 SSHK_RSA = "rsa"
2333 SSHK_DSA = "dsa"
2334 SSHK_ALL = compat.UniqueFrozenset([SSHK_RSA, SSHK_DSA])
2335
2336 # SSH authorized key types
2337 SSHAK_RSA = "ssh-rsa"
2338 SSHAK_DSS = "ssh-dss"
2339 SSHAK_ALL = compat.UniqueFrozenset([SSHAK_RSA, SSHAK_DSS])
2340
2341 # SSH setup
2342 SSHS_CLUSTER_NAME = "cluster_name"
2343 SSHS_SSH_HOST_KEY = "ssh_host_key"
2344 SSHS_SSH_ROOT_KEY = "ssh_root_key"
2345 SSHS_NODE_DAEMON_CERTIFICATE = "node_daemon_certificate"
2346
2347 #: Key files for SSH daemon
2348 SSH_DAEMON_KEYFILES = {
2349 SSHK_RSA: (pathutils.SSH_HOST_RSA_PRIV, pathutils.SSH_HOST_RSA_PUB),
2350 SSHK_DSA: (pathutils.SSH_HOST_DSA_PRIV, pathutils.SSH_HOST_DSA_PUB),
2351 }
2352
2353 # Node daemon setup
2354 NDS_CLUSTER_NAME = "cluster_name"
2355 NDS_NODE_DAEMON_CERTIFICATE = "node_daemon_certificate"
2356 NDS_SSCONF = "ssconf"
2357 NDS_START_NODE_DAEMON = "start_node_daemon"
2358
2359 # Path generating random UUID
2360 RANDOM_UUID_FILE = "/proc/sys/kernel/random/uuid"
2361
2362 # Regex string for verifying a UUID
2363 UUID_REGEX = "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
2364
2365 # Auto-repair tag prefixes
2366 AUTO_REPAIR_TAG_PREFIX = "ganeti:watcher:autorepair:"
2367 AUTO_REPAIR_TAG_ENABLED = AUTO_REPAIR_TAG_PREFIX
2368 AUTO_REPAIR_TAG_SUSPENDED = AUTO_REPAIR_TAG_ENABLED + "suspend:"
2369 AUTO_REPAIR_TAG_PENDING = AUTO_REPAIR_TAG_PREFIX + "pending:"
2370 AUTO_REPAIR_TAG_RESULT = AUTO_REPAIR_TAG_PREFIX + "result:"
2371
2372 # Auto-repair levels
2373 AUTO_REPAIR_FIX_STORAGE = "fix-storage"
2374 AUTO_REPAIR_MIGRATE = "migrate"
2375 AUTO_REPAIR_FAILOVER = "failover"
2376 AUTO_REPAIR_REINSTALL = "reinstall"
2377 AUTO_REPAIR_ALL_TYPES = [
2378 AUTO_REPAIR_FIX_STORAGE,
2379 AUTO_REPAIR_MIGRATE,
2380 AUTO_REPAIR_FAILOVER,
2381 AUTO_REPAIR_REINSTALL,
2382 ]
2383
2384 # Auto-repair results
2385 AUTO_REPAIR_SUCCESS = "success"
2386 AUTO_REPAIR_FAILURE = "failure"
2387 AUTO_REPAIR_ENOPERM = "enoperm"
2388 AUTO_REPAIR_ALL_RESULTS = frozenset([
2389 AUTO_REPAIR_SUCCESS,
2390 AUTO_REPAIR_FAILURE,
2391 AUTO_REPAIR_ENOPERM,
2392 ])
2393
2394 # The version identifier for builtin data collectors
2395 BUILTIN_DATA_COLLECTOR_VERSION = "B"
2396
2397 # The source reasons for the change of state of an instance
2398 INSTANCE_REASON_SOURCE_CLI = "cli"
2399 INSTANCE_REASON_SOURCE_RAPI = "rapi"
2400 INSTANCE_REASON_SOURCE_UNKNOWN = "unknown"
2401
2402 INSTANCE_REASON_SOURCES = compat.UniqueFrozenset([
2403 INSTANCE_REASON_SOURCE_CLI,
2404 INSTANCE_REASON_SOURCE_RAPI,
2405 INSTANCE_REASON_SOURCE_UNKNOWN,
2406 ])
2407
2408 # The default reasons for the change of state of an instance
2409 INSTANCE_REASON_REBOOT = "reboot"
2410
2411 # Do not re-export imported modules
2412 del re, _vcsversion, _autoconf, socket, pathutils, compat