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