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