Statistics
| Branch: | Tag: | Revision:

root / lib / constants.py @ a59d5fa1

History | View | Annotate | Download (60.3 kB)

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
SSH_LOGIN_USER = _autoconf.SSH_LOGIN_USER
110
SSH_CONSOLE_USER = _autoconf.SSH_CONSOLE_USER
111

    
112
# cpu pinning separators and constants
113
CPU_PINNING_SEP = ":"
114
CPU_PINNING_ALL = "all"
115
# internal representation of "all"
116
CPU_PINNING_ALL_VAL = -1
117
# one "all" entry in a CPU list means CPU pinning is off
118
CPU_PINNING_OFF = [CPU_PINNING_ALL_VAL]
119

    
120
# A Xen-specific implementation detail - there is no way to actually say
121
# "use any cpu for pinning" in a Xen configuration file, as opposed to the
122
# command line, where you can say "xm vcpu-pin <domain> <vcpu> all".
123
# The workaround used in Xen is "0-63" (see source code function
124
# xm_vcpu_pin in <xen-source>/tools/python/xen/xm/main.py).
125
# To support future changes, the following constant is treated as a
126
# blackbox string that simply means use-any-cpu-for-pinning-under-xen.
127
CPU_PINNING_ALL_XEN = "0-63"
128

    
129
# A KVM-specific implementation detail - the following value is used
130
# to set CPU affinity to all processors (#0 through #31), per taskset
131
# man page.
132
# FIXME: This only works for machines with up to 32 CPU cores
133
CPU_PINNING_ALL_KVM = 0xFFFFFFFF
134

    
135
# Wipe
136
DD_CMD = "dd"
137
MAX_WIPE_CHUNK = 1024 # 1GB
138
MIN_WIPE_CHUNK_PERCENT = 10
139

    
140
RUN_DIRS_MODE = 0775
141
SECURE_DIR_MODE = 0700
142
SECURE_FILE_MODE = 0600
143
ADOPTABLE_BLOCKDEV_ROOT = "/dev/disk/"
144
ENABLE_FILE_STORAGE = _autoconf.ENABLE_FILE_STORAGE
145
ENABLE_SHARED_FILE_STORAGE = _autoconf.ENABLE_SHARED_FILE_STORAGE
146
ENABLE_CONFD = _autoconf.ENABLE_CONFD
147
ENABLE_SPLIT_QUERY = _autoconf.ENABLE_SPLIT_QUERY
148
ENABLE_RESTRICTED_COMMANDS = _autoconf.ENABLE_RESTRICTED_COMMANDS
149

    
150
NODED = "ganeti-noded"
151
CONFD = "ganeti-confd"
152
RAPI = "ganeti-rapi"
153
MASTERD = "ganeti-masterd"
154

    
155
DAEMONS_PORTS = {
156
  # daemon-name: ("proto", "default-port")
157
  NODED: ("tcp", 1811),
158
  CONFD: ("udp", 1814),
159
  RAPI: ("tcp", 5080),
160
  "ssh": ("tcp", 22),
161
}
162
DEFAULT_NODED_PORT = DAEMONS_PORTS[NODED][1]
163
DEFAULT_CONFD_PORT = DAEMONS_PORTS[CONFD][1]
164
DEFAULT_RAPI_PORT = DAEMONS_PORTS[RAPI][1]
165

    
166
FIRST_DRBD_PORT = 11000
167
LAST_DRBD_PORT = 14999
168

    
169
DAEMONS_LOGBASE = {
170
  NODED: "node-daemon",
171
  CONFD: "conf-daemon",
172
  RAPI: "rapi-daemon",
173
  MASTERD: "master-daemon",
174
  }
175

    
176
DAEMONS_LOGFILES = \
177
    dict((daemon, pathutils.GetLogFilename(DAEMONS_LOGBASE[daemon]))
178
         for daemon in DAEMONS_LOGBASE)
179

    
180
DEV_CONSOLE = "/dev/console"
181

    
182
PROC_MOUNTS = "/proc/mounts"
183

    
184
# Local UniX Interface related constants
185
LUXI_EOM = "\3"
186
LUXI_VERSION = CONFIG_VERSION
187

    
188
# one of "no", "yes", "only"
189
SYSLOG_USAGE = _autoconf.SYSLOG_USAGE
190
SYSLOG_NO = "no"
191
SYSLOG_YES = "yes"
192
SYSLOG_ONLY = "only"
193
SYSLOG_SOCKET = "/dev/log"
194

    
195
EXPORT_CONF_FILE = "config.ini"
196

    
197
XEN_BOOTLOADER = _autoconf.XEN_BOOTLOADER
198
XEN_KERNEL = _autoconf.XEN_KERNEL
199
XEN_INITRD = _autoconf.XEN_INITRD
200
XEN_CMD_XM = "xm"
201
XEN_CMD_XL = "xl"
202
# FIXME: This will be made configurable using hvparams in Ganeti 2.7
203
XEN_CMD = _autoconf.XEN_CMD
204

    
205
KNOWN_XEN_COMMANDS = compat.UniqueFrozenset([
206
  XEN_CMD_XM,
207
  XEN_CMD_XL,
208
  ])
209

    
210
# When the Xen toolstack used is "xl", live migration requires the source host
211
# to connect to the target host via ssh (xl runs this command). We need to pass
212
# the command xl runs some extra info so that it can use Ganeti's key
213
# verification and not fail. Note that this string is incomplete: it must be
214
# filled with the cluster name before being used.
215
XL_SSH_CMD = ("ssh -l %s -oGlobalKnownHostsFile=%s"
216
              " -oUserKnownHostsFile=/dev/null"
217
              " -oCheckHostIp=no -oStrictHostKeyChecking=yes"
218
              " -oHostKeyAlias=%%s") % (SSH_LOGIN_USER,
219
                                        pathutils.SSH_KNOWN_HOSTS_FILE)
220

    
221
KVM_PATH = _autoconf.KVM_PATH
222
KVM_KERNEL = _autoconf.KVM_KERNEL
223
SOCAT_PATH = _autoconf.SOCAT_PATH
224
SOCAT_USE_ESCAPE = _autoconf.SOCAT_USE_ESCAPE
225
SOCAT_USE_COMPRESS = _autoconf.SOCAT_USE_COMPRESS
226
SOCAT_ESCAPE_CODE = "0x1d"
227

    
228
#: Console as SSH command
229
CONS_SSH = "ssh"
230

    
231
#: Console as VNC server
232
CONS_VNC = "vnc"
233

    
234
#: Console as SPICE server
235
CONS_SPICE = "spice"
236

    
237
#: Display a message for console access
238
CONS_MESSAGE = "msg"
239

    
240
#: All console types
241
CONS_ALL = compat.UniqueFrozenset([
242
  CONS_SSH,
243
  CONS_VNC,
244
  CONS_SPICE,
245
  CONS_MESSAGE,
246
  ])
247

    
248
# For RSA keys more bits are better, but they also make operations more
249
# expensive. NIST SP 800-131 recommends a minimum of 2048 bits from the year
250
# 2010 on.
251
RSA_KEY_BITS = 2048
252

    
253
# Ciphers allowed for SSL connections. For the format, see ciphers(1). A better
254
# way to disable ciphers would be to use the exclamation mark (!), but socat
255
# versions below 1.5 can't parse exclamation marks in options properly. When
256
# modifying the ciphers, ensure not to accidentially add something after it's
257
# been removed. Use the "openssl" utility to check the allowed ciphers, e.g.
258
# "openssl ciphers -v HIGH:-DES".
259
OPENSSL_CIPHERS = "HIGH:-DES:-3DES:-EXPORT:-ADH"
260

    
261
# Digest used to sign certificates ("openssl x509" uses SHA1 by default)
262
X509_CERT_SIGN_DIGEST = "SHA1"
263

    
264
# Default validity of certificates in days
265
X509_CERT_DEFAULT_VALIDITY = 365 * 5
266

    
267
# commonName (CN) used in certificates
268
X509_CERT_CN = "ganeti.example.com"
269

    
270
X509_CERT_SIGNATURE_HEADER = "X-Ganeti-Signature"
271

    
272
# Import/export daemon mode
273
IEM_IMPORT = "import"
274
IEM_EXPORT = "export"
275

    
276
# Import/export transport compression
277
IEC_NONE = "none"
278
IEC_GZIP = "gzip"
279
IEC_ALL = compat.UniqueFrozenset([
280
  IEC_NONE,
281
  IEC_GZIP,
282
  ])
283

    
284
IE_CUSTOM_SIZE = "fd"
285

    
286
IE_MAGIC_RE = re.compile(r"^[-_.a-zA-Z0-9]{5,100}$")
287

    
288
# Import/export I/O
289
# Direct file I/O, equivalent to a shell's I/O redirection using '<' or '>'
290
IEIO_FILE = "file"
291
# Raw block device I/O using "dd"
292
IEIO_RAW_DISK = "raw"
293
# OS definition import/export script
294
IEIO_SCRIPT = "script"
295

    
296
VALUE_DEFAULT = "default"
297
VALUE_AUTO = "auto"
298
VALUE_GENERATE = "generate"
299
VALUE_NONE = "none"
300
VALUE_TRUE = "true"
301
VALUE_FALSE = "false"
302

    
303
# External script validation mask
304
EXT_PLUGIN_MASK = re.compile("^[a-zA-Z0-9_-]+$")
305

    
306
# hooks-related constants
307
HOOKS_PHASE_PRE = "pre"
308
HOOKS_PHASE_POST = "post"
309
HOOKS_NAME_CFGUPDATE = "config-update"
310
HOOKS_NAME_WATCHER = "watcher"
311
HOOKS_VERSION = 2
312
HOOKS_PATH = "/sbin:/bin:/usr/sbin:/usr/bin"
313

    
314
# hooks subject type (what object type does the LU deal with)
315
HTYPE_CLUSTER = "CLUSTER"
316
HTYPE_NODE = "NODE"
317
HTYPE_GROUP = "GROUP"
318
HTYPE_INSTANCE = "INSTANCE"
319
HTYPE_NETWORK = "NETWORK"
320

    
321
HKR_SKIP = 0
322
HKR_FAIL = 1
323
HKR_SUCCESS = 2
324

    
325
# Storage types
326
ST_FILE = "file"
327
ST_LVM_PV = "lvm-pv"
328
ST_LVM_VG = "lvm-vg"
329

    
330
# Storage fields
331
# first two are valid in LU context only, not passed to backend
332
SF_NODE = "node"
333
SF_TYPE = "type"
334
# and the rest are valid in backend
335
SF_NAME = "name"
336
SF_SIZE = "size"
337
SF_FREE = "free"
338
SF_USED = "used"
339
SF_ALLOCATABLE = "allocatable"
340

    
341
# Storage operations
342
SO_FIX_CONSISTENCY = "fix-consistency"
343

    
344
# Available fields per storage type
345
VALID_STORAGE_FIELDS = compat.UniqueFrozenset([
346
  SF_NAME,
347
  SF_TYPE,
348
  SF_SIZE,
349
  SF_USED,
350
  SF_FREE,
351
  SF_ALLOCATABLE,
352
  ])
353

    
354
VALID_STORAGE_TYPES = compat.UniqueFrozenset([
355
  ST_FILE,
356
  ST_LVM_PV,
357
  ST_LVM_VG,
358
  ])
359

    
360
MODIFIABLE_STORAGE_FIELDS = {
361
  ST_LVM_PV: frozenset([SF_ALLOCATABLE]),
362
  }
363

    
364
VALID_STORAGE_OPERATIONS = {
365
  ST_LVM_VG: frozenset([SO_FIX_CONSISTENCY]),
366
  }
367

    
368
# Local disk status
369
# Note: Code depends on LDS_OKAY < LDS_UNKNOWN < LDS_FAULTY
370
(LDS_OKAY,
371
 LDS_UNKNOWN,
372
 LDS_FAULTY) = range(1, 4)
373

    
374
# disk template types
375
DT_DISKLESS = "diskless"
376
DT_PLAIN = "plain"
377
DT_DRBD8 = "drbd"
378
DT_FILE = "file"
379
DT_SHARED_FILE = "sharedfile"
380
DT_BLOCK = "blockdev"
381
DT_RBD = "rbd"
382
DT_EXT = "ext"
383

    
384
# the set of network-mirrored disk templates
385
DTS_INT_MIRROR = compat.UniqueFrozenset([DT_DRBD8])
386

    
387
# the set of externally-mirrored disk templates (e.g. SAN, NAS)
388
DTS_EXT_MIRROR = compat.UniqueFrozenset([
389
  DT_SHARED_FILE,
390
  DT_BLOCK,
391
  DT_RBD,
392
  DT_EXT,
393
  ])
394

    
395
# the set of non-lvm-based disk templates
396
DTS_NOT_LVM = compat.UniqueFrozenset([
397
  DT_DISKLESS,
398
  DT_FILE,
399
  DT_SHARED_FILE,
400
  DT_BLOCK,
401
  DT_RBD,
402
  DT_EXT,
403
  ])
404

    
405
# the set of disk templates which can be grown
406
DTS_GROWABLE = compat.UniqueFrozenset([
407
  DT_PLAIN,
408
  DT_DRBD8,
409
  DT_FILE,
410
  DT_SHARED_FILE,
411
  DT_RBD,
412
  DT_EXT,
413
  ])
414

    
415
# the set of disk templates that allow adoption
416
DTS_MAY_ADOPT = compat.UniqueFrozenset([
417
  DT_PLAIN,
418
  DT_BLOCK,
419
  ])
420

    
421
# the set of disk templates that *must* use adoption
422
DTS_MUST_ADOPT = compat.UniqueFrozenset([DT_BLOCK])
423

    
424
# the set of disk templates that allow migrations
425
DTS_MIRRORED = frozenset.union(DTS_INT_MIRROR, DTS_EXT_MIRROR)
426

    
427
# the set of file based disk templates
428
DTS_FILEBASED = compat.UniqueFrozenset([
429
  DT_FILE,
430
  DT_SHARED_FILE,
431
  ])
432

    
433
# the set of disk templates that are supported by exclusive_storage
434
DTS_EXCL_STORAGE = compat.UniqueFrozenset([DT_PLAIN])
435

    
436
# templates for which we don't perform checks on free space
437
DTS_NO_FREE_SPACE_CHECK = compat.UniqueFrozenset([
438
  DT_FILE,
439
  DT_SHARED_FILE,
440
  DT_RBD,
441
  DT_EXT,
442
  ])
443

    
444
# logical disk types
445
LD_LV = "lvm"
446
LD_DRBD8 = "drbd8"
447
LD_FILE = "file"
448
LD_BLOCKDEV = "blockdev"
449
LD_RBD = "rbd"
450
LD_EXT = "ext"
451
LOGICAL_DISK_TYPES = compat.UniqueFrozenset([
452
  LD_LV,
453
  LD_DRBD8,
454
  LD_FILE,
455
  LD_BLOCKDEV,
456
  LD_RBD,
457
  LD_EXT,
458
  ])
459

    
460
LDS_BLOCK = compat.UniqueFrozenset([
461
  LD_LV,
462
  LD_DRBD8,
463
  LD_BLOCKDEV,
464
  LD_RBD,
465
  LD_EXT,
466
  ])
467

    
468
# drbd constants
469
DRBD_HMAC_ALG = "md5"
470
DRBD_NET_PROTOCOL = "C"
471
DRBD_STATUS_FILE = "/proc/drbd"
472

    
473
#: Size of DRBD meta block device
474
DRBD_META_SIZE = 128
475

    
476
# drbd barrier types
477
DRBD_B_NONE = "n"
478
DRBD_B_DISK_BARRIERS = "b"
479
DRBD_B_DISK_DRAIN = "d"
480
DRBD_B_DISK_FLUSH = "f"
481

    
482
# Valid barrier combinations: "n" or any non-null subset of "bfd"
483
DRBD_VALID_BARRIER_OPT = compat.UniqueFrozenset([
484
  frozenset([DRBD_B_NONE]),
485
  frozenset([DRBD_B_DISK_BARRIERS]),
486
  frozenset([DRBD_B_DISK_DRAIN]),
487
  frozenset([DRBD_B_DISK_FLUSH]),
488
  frozenset([DRBD_B_DISK_DRAIN, DRBD_B_DISK_FLUSH]),
489
  frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_DRAIN]),
490
  frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_FLUSH]),
491
  frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_FLUSH, DRBD_B_DISK_DRAIN]),
492
  ])
493

    
494
# rbd tool command
495
RBD_CMD = "rbd"
496

    
497
# file backend driver
498
FD_LOOP = "loop"
499
FD_BLKTAP = "blktap"
500

    
501
# the set of drbd-like disk types
502
LDS_DRBD = compat.UniqueFrozenset([LD_DRBD8])
503

    
504
# disk access mode
505
DISK_RDONLY = "ro"
506
DISK_RDWR = "rw"
507
DISK_ACCESS_SET = compat.UniqueFrozenset([DISK_RDONLY, DISK_RDWR])
508

    
509
# disk replacement mode
510
REPLACE_DISK_PRI = "replace_on_primary"    # replace disks on primary
511
REPLACE_DISK_SEC = "replace_on_secondary"  # replace disks on secondary
512
REPLACE_DISK_CHG = "replace_new_secondary" # change secondary node
513
REPLACE_DISK_AUTO = "replace_auto"
514
REPLACE_MODES = compat.UniqueFrozenset([
515
  REPLACE_DISK_PRI,
516
  REPLACE_DISK_SEC,
517
  REPLACE_DISK_CHG,
518
  REPLACE_DISK_AUTO,
519
  ])
520

    
521
# Instance export mode
522
EXPORT_MODE_LOCAL = "local"
523
EXPORT_MODE_REMOTE = "remote"
524
EXPORT_MODES = compat.UniqueFrozenset([
525
  EXPORT_MODE_LOCAL,
526
  EXPORT_MODE_REMOTE,
527
  ])
528

    
529
# instance creation modes
530
INSTANCE_CREATE = "create"
531
INSTANCE_IMPORT = "import"
532
INSTANCE_REMOTE_IMPORT = "remote-import"
533
INSTANCE_CREATE_MODES = compat.UniqueFrozenset([
534
  INSTANCE_CREATE,
535
  INSTANCE_IMPORT,
536
  INSTANCE_REMOTE_IMPORT,
537
  ])
538

    
539
# Remote import/export handshake message and version
540
RIE_VERSION = 0
541
RIE_HANDSHAKE = "Hi, I'm Ganeti"
542

    
543
# Remote import/export certificate validity in seconds
544
RIE_CERT_VALIDITY = 24 * 60 * 60
545

    
546
# Overall timeout for establishing connection
547
RIE_CONNECT_TIMEOUT = 180
548

    
549
# Export only: how long to wait per connection attempt (seconds)
550
RIE_CONNECT_ATTEMPT_TIMEOUT = 20
551

    
552
# Export only: number of attempts to connect
553
RIE_CONNECT_RETRIES = 10
554

    
555
#: Give child process up to 5 seconds to exit after sending a signal
556
CHILD_LINGER_TIMEOUT = 5.0
557

    
558
DISK_TEMPLATES = compat.UniqueFrozenset([
559
  DT_DISKLESS,
560
  DT_PLAIN,
561
  DT_DRBD8,
562
  DT_FILE,
563
  DT_SHARED_FILE,
564
  DT_BLOCK,
565
  DT_RBD,
566
  DT_EXT
567
  ])
568

    
569
FILE_DRIVER = compat.UniqueFrozenset([FD_LOOP, FD_BLKTAP])
570

    
571
# import/export config options
572
INISECT_EXP = "export"
573
INISECT_INS = "instance"
574
INISECT_HYP = "hypervisor"
575
INISECT_BEP = "backend"
576
INISECT_OSP = "os"
577

    
578
# dynamic device modification
579
DDM_ADD = "add"
580
DDM_MODIFY = "modify"
581
DDM_REMOVE = "remove"
582
DDMS_VALUES = compat.UniqueFrozenset([DDM_ADD, DDM_REMOVE])
583
DDMS_VALUES_WITH_MODIFY = (DDMS_VALUES | frozenset([
584
  DDM_MODIFY,
585
  ]))
586
# TODO: DDM_SWAP, DDM_MOVE?
587

    
588
# common exit codes
589
EXIT_SUCCESS = 0
590
EXIT_FAILURE = 1
591
EXIT_NOTCLUSTER = 5
592
EXIT_NOTMASTER = 11
593
EXIT_NODESETUP_ERROR = 12
594
EXIT_CONFIRMATION = 13 # need user confirmation
595

    
596
#: Exit code for query operations with unknown fields
597
EXIT_UNKNOWN_FIELD = 14
598

    
599
# tags
600
TAG_CLUSTER = "cluster"
601
TAG_NODEGROUP = "nodegroup"
602
TAG_NODE = "node"
603
TAG_INSTANCE = "instance"
604
TAG_NETWORK = "network"
605
VALID_TAG_TYPES = compat.UniqueFrozenset([
606
  TAG_CLUSTER,
607
  TAG_NODEGROUP,
608
  TAG_NODE,
609
  TAG_INSTANCE,
610
  TAG_NETWORK,
611
  ])
612
MAX_TAG_LEN = 128
613
MAX_TAGS_PER_OBJ = 4096
614

    
615
# others
616
DEFAULT_BRIDGE = "xen-br0"
617
CLASSIC_DRBD_SYNC_SPEED = 60 * 1024  # 60 MiB, expressed in KiB
618
IP4_ADDRESS_LOCALHOST = "127.0.0.1"
619
IP4_ADDRESS_ANY = "0.0.0.0"
620
IP6_ADDRESS_LOCALHOST = "::1"
621
IP6_ADDRESS_ANY = "::"
622
IP4_VERSION = 4
623
IP6_VERSION = 6
624
VALID_IP_VERSIONS = compat.UniqueFrozenset([IP4_VERSION, IP6_VERSION])
625
# for export to htools
626
IP4_FAMILY = socket.AF_INET
627
IP6_FAMILY = socket.AF_INET6
628

    
629
TCP_PING_TIMEOUT = 10
630
DEFAULT_VG = "xenvg"
631
DEFAULT_DRBD_HELPER = "/bin/true"
632
MIN_VG_SIZE = 20480
633
DEFAULT_MAC_PREFIX = "aa:00:00"
634
# default maximum instance wait time, in seconds.
635
DEFAULT_SHUTDOWN_TIMEOUT = 120
636
NODE_MAX_CLOCK_SKEW = 150
637
# Time for an intra-cluster disk transfer to wait for a connection
638
DISK_TRANSFER_CONNECT_TIMEOUT = 60
639
# Disk index separator
640
DISK_SEPARATOR = _autoconf.DISK_SEPARATOR
641
IP_COMMAND_PATH = _autoconf.IP_PATH
642

    
643
#: Key for job IDs in opcode result
644
JOB_IDS_KEY = "jobs"
645

    
646
# runparts results
647
(RUNPARTS_SKIP,
648
 RUNPARTS_RUN,
649
 RUNPARTS_ERR) = range(3)
650

    
651
RUNPARTS_STATUS = compat.UniqueFrozenset([
652
  RUNPARTS_SKIP,
653
  RUNPARTS_RUN,
654
  RUNPARTS_ERR,
655
  ])
656

    
657
# RPC constants
658
(RPC_ENCODING_NONE,
659
 RPC_ENCODING_ZLIB_BASE64) = range(2)
660

    
661
# Various time constants for the timeout table
662
RPC_TMO_URGENT = 60 # one minute
663
RPC_TMO_FAST = 5 * 60 # five minutes
664
RPC_TMO_NORMAL = 15 * 60 # 15 minutes
665
RPC_TMO_SLOW = 3600 # one hour
666
RPC_TMO_4HRS = 4 * 3600
667
RPC_TMO_1DAY = 86400
668

    
669
# Timeout for connecting to nodes (seconds)
670
RPC_CONNECT_TIMEOUT = 5
671

    
672
# os related constants
673
OS_SCRIPT_CREATE = "create"
674
OS_SCRIPT_IMPORT = "import"
675
OS_SCRIPT_EXPORT = "export"
676
OS_SCRIPT_RENAME = "rename"
677
OS_SCRIPT_VERIFY = "verify"
678
OS_SCRIPTS = compat.UniqueFrozenset([
679
  OS_SCRIPT_CREATE,
680
  OS_SCRIPT_IMPORT,
681
  OS_SCRIPT_EXPORT,
682
  OS_SCRIPT_RENAME,
683
  OS_SCRIPT_VERIFY,
684
  ])
685

    
686
OS_API_FILE = "ganeti_api_version"
687
OS_VARIANTS_FILE = "variants.list"
688
OS_PARAMETERS_FILE = "parameters.list"
689

    
690
OS_VALIDATE_PARAMETERS = "parameters"
691
OS_VALIDATE_CALLS = compat.UniqueFrozenset([OS_VALIDATE_PARAMETERS])
692

    
693
# External Storage (ES) related constants
694
ES_ACTION_CREATE = "create"
695
ES_ACTION_REMOVE = "remove"
696
ES_ACTION_GROW = "grow"
697
ES_ACTION_ATTACH = "attach"
698
ES_ACTION_DETACH = "detach"
699
ES_ACTION_SETINFO = "setinfo"
700
ES_ACTION_VERIFY = "verify"
701

    
702
ES_SCRIPT_CREATE = ES_ACTION_CREATE
703
ES_SCRIPT_REMOVE = ES_ACTION_REMOVE
704
ES_SCRIPT_GROW = ES_ACTION_GROW
705
ES_SCRIPT_ATTACH = ES_ACTION_ATTACH
706
ES_SCRIPT_DETACH = ES_ACTION_DETACH
707
ES_SCRIPT_SETINFO = ES_ACTION_SETINFO
708
ES_SCRIPT_VERIFY = ES_ACTION_VERIFY
709
ES_SCRIPTS = frozenset([
710
  ES_SCRIPT_CREATE,
711
  ES_SCRIPT_REMOVE,
712
  ES_SCRIPT_GROW,
713
  ES_SCRIPT_ATTACH,
714
  ES_SCRIPT_DETACH,
715
  ES_SCRIPT_SETINFO,
716
  ES_SCRIPT_VERIFY
717
  ])
718

    
719
ES_PARAMETERS_FILE = "parameters.list"
720

    
721
# ssh constants
722
SSH = "ssh"
723
SCP = "scp"
724

    
725
# reboot types
726
INSTANCE_REBOOT_SOFT = "soft"
727
INSTANCE_REBOOT_HARD = "hard"
728
INSTANCE_REBOOT_FULL = "full"
729

    
730
REBOOT_TYPES = compat.UniqueFrozenset([
731
  INSTANCE_REBOOT_SOFT,
732
  INSTANCE_REBOOT_HARD,
733
  INSTANCE_REBOOT_FULL,
734
  ])
735

    
736
# instance reboot behaviors
737
INSTANCE_REBOOT_ALLOWED = "reboot"
738
INSTANCE_REBOOT_EXIT = "exit"
739

    
740
REBOOT_BEHAVIORS = compat.UniqueFrozenset([
741
  INSTANCE_REBOOT_ALLOWED,
742
  INSTANCE_REBOOT_EXIT,
743
  ])
744

    
745
VTYPE_STRING = "string"
746
VTYPE_MAYBE_STRING = "maybe-string"
747
VTYPE_BOOL = "bool"
748
VTYPE_SIZE = "size" # size, in MiBs
749
VTYPE_INT = "int"
750
ENFORCEABLE_TYPES = compat.UniqueFrozenset([
751
  VTYPE_STRING,
752
  VTYPE_MAYBE_STRING,
753
  VTYPE_BOOL,
754
  VTYPE_SIZE,
755
  VTYPE_INT,
756
  ])
757

    
758
# Constant representing that the user does not specify any IP version
759
IFACE_NO_IP_VERSION_SPECIFIED = 0
760

    
761
VALID_SERIAL_SPEEDS = compat.UniqueFrozenset([
762
  75,
763
  110,
764
  300,
765
  600,
766
  1200,
767
  1800,
768
  2400,
769
  4800,
770
  9600,
771
  14400,
772
  19200,
773
  28800,
774
  38400,
775
  57600,
776
  115200,
777
  230400,
778
  345600,
779
  460800,
780
  ])
781

    
782
# HV parameter names (global namespace)
783
HV_BOOT_ORDER = "boot_order"
784
HV_CDROM_IMAGE_PATH = "cdrom_image_path"
785
HV_KVM_CDROM2_IMAGE_PATH = "cdrom2_image_path"
786
HV_KVM_FLOPPY_IMAGE_PATH = "floppy_image_path"
787
HV_NIC_TYPE = "nic_type"
788
HV_DISK_TYPE = "disk_type"
789
HV_KVM_CDROM_DISK_TYPE = "cdrom_disk_type"
790
HV_VNC_BIND_ADDRESS = "vnc_bind_address"
791
HV_VNC_PASSWORD_FILE = "vnc_password_file"
792
HV_VNC_TLS = "vnc_tls"
793
HV_VNC_X509 = "vnc_x509_path"
794
HV_VNC_X509_VERIFY = "vnc_x509_verify"
795
HV_KVM_SPICE_BIND = "spice_bind"
796
HV_KVM_SPICE_IP_VERSION = "spice_ip_version"
797
HV_KVM_SPICE_PASSWORD_FILE = "spice_password_file"
798
HV_KVM_SPICE_LOSSLESS_IMG_COMPR = "spice_image_compression"
799
HV_KVM_SPICE_JPEG_IMG_COMPR = "spice_jpeg_wan_compression"
800
HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR = "spice_zlib_glz_wan_compression"
801
HV_KVM_SPICE_STREAMING_VIDEO_DETECTION = "spice_streaming_video"
802
HV_KVM_SPICE_AUDIO_COMPR = "spice_playback_compression"
803
HV_KVM_SPICE_USE_TLS = "spice_use_tls"
804
HV_KVM_SPICE_TLS_CIPHERS = "spice_tls_ciphers"
805
HV_KVM_SPICE_USE_VDAGENT = "spice_use_vdagent"
806
HV_ACPI = "acpi"
807
HV_PAE = "pae"
808
HV_USE_BOOTLOADER = "use_bootloader"
809
HV_BOOTLOADER_ARGS = "bootloader_args"
810
HV_BOOTLOADER_PATH = "bootloader_path"
811
HV_KERNEL_ARGS = "kernel_args"
812
HV_KERNEL_PATH = "kernel_path"
813
HV_INITRD_PATH = "initrd_path"
814
HV_ROOT_PATH = "root_path"
815
HV_SERIAL_CONSOLE = "serial_console"
816
HV_SERIAL_SPEED = "serial_speed"
817
HV_USB_MOUSE = "usb_mouse"
818
HV_KEYMAP = "keymap"
819
HV_DEVICE_MODEL = "device_model"
820
HV_INIT_SCRIPT = "init_script"
821
HV_MIGRATION_PORT = "migration_port"
822
HV_MIGRATION_BANDWIDTH = "migration_bandwidth"
823
HV_MIGRATION_DOWNTIME = "migration_downtime"
824
HV_MIGRATION_MODE = "migration_mode"
825
HV_USE_LOCALTIME = "use_localtime"
826
HV_DISK_CACHE = "disk_cache"
827
HV_SECURITY_MODEL = "security_model"
828
HV_SECURITY_DOMAIN = "security_domain"
829
HV_KVM_FLAG = "kvm_flag"
830
HV_VHOST_NET = "vhost_net"
831
HV_KVM_USE_CHROOT = "use_chroot"
832
HV_CPU_MASK = "cpu_mask"
833
HV_MEM_PATH = "mem_path"
834
HV_PASSTHROUGH = "pci_pass"
835
HV_BLOCKDEV_PREFIX = "blockdev_prefix"
836
HV_REBOOT_BEHAVIOR = "reboot_behavior"
837
HV_CPU_TYPE = "cpu_type"
838
HV_CPU_CAP = "cpu_cap"
839
HV_CPU_WEIGHT = "cpu_weight"
840
HV_CPU_CORES = "cpu_cores"
841
HV_CPU_THREADS = "cpu_threads"
842
HV_CPU_SOCKETS = "cpu_sockets"
843
HV_SOUNDHW = "soundhw"
844
HV_USB_DEVICES = "usb_devices"
845
HV_VGA = "vga"
846
HV_KVM_EXTRA = "kvm_extra"
847
HV_KVM_MACHINE_VERSION = "machine_version"
848
HV_KVM_PATH = "kvm_path"
849

    
850

    
851
HVS_PARAMETER_TYPES = {
852
  HV_KVM_PATH: VTYPE_STRING,
853
  HV_BOOT_ORDER: VTYPE_STRING,
854
  HV_KVM_FLOPPY_IMAGE_PATH: VTYPE_STRING,
855
  HV_CDROM_IMAGE_PATH: VTYPE_STRING,
856
  HV_KVM_CDROM2_IMAGE_PATH: VTYPE_STRING,
857
  HV_NIC_TYPE: VTYPE_STRING,
858
  HV_DISK_TYPE: VTYPE_STRING,
859
  HV_KVM_CDROM_DISK_TYPE: VTYPE_STRING,
860
  HV_VNC_PASSWORD_FILE: VTYPE_STRING,
861
  HV_VNC_BIND_ADDRESS: VTYPE_STRING,
862
  HV_VNC_TLS: VTYPE_BOOL,
863
  HV_VNC_X509: VTYPE_STRING,
864
  HV_VNC_X509_VERIFY: VTYPE_BOOL,
865
  HV_KVM_SPICE_BIND: VTYPE_STRING,
866
  HV_KVM_SPICE_IP_VERSION: VTYPE_INT,
867
  HV_KVM_SPICE_PASSWORD_FILE: VTYPE_STRING,
868
  HV_KVM_SPICE_LOSSLESS_IMG_COMPR: VTYPE_STRING,
869
  HV_KVM_SPICE_JPEG_IMG_COMPR: VTYPE_STRING,
870
  HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR: VTYPE_STRING,
871
  HV_KVM_SPICE_STREAMING_VIDEO_DETECTION: VTYPE_STRING,
872
  HV_KVM_SPICE_AUDIO_COMPR: VTYPE_BOOL,
873
  HV_KVM_SPICE_USE_TLS: VTYPE_BOOL,
874
  HV_KVM_SPICE_TLS_CIPHERS: VTYPE_STRING,
875
  HV_KVM_SPICE_USE_VDAGENT: VTYPE_BOOL,
876
  HV_ACPI: VTYPE_BOOL,
877
  HV_PAE: VTYPE_BOOL,
878
  HV_USE_BOOTLOADER: VTYPE_BOOL,
879
  HV_BOOTLOADER_PATH: VTYPE_STRING,
880
  HV_BOOTLOADER_ARGS: VTYPE_STRING,
881
  HV_KERNEL_PATH: VTYPE_STRING,
882
  HV_KERNEL_ARGS: VTYPE_STRING,
883
  HV_INITRD_PATH: VTYPE_STRING,
884
  HV_ROOT_PATH: VTYPE_MAYBE_STRING,
885
  HV_SERIAL_CONSOLE: VTYPE_BOOL,
886
  HV_SERIAL_SPEED: VTYPE_INT,
887
  HV_USB_MOUSE: VTYPE_STRING,
888
  HV_KEYMAP: VTYPE_STRING,
889
  HV_DEVICE_MODEL: VTYPE_STRING,
890
  HV_INIT_SCRIPT: VTYPE_STRING,
891
  HV_MIGRATION_PORT: VTYPE_INT,
892
  HV_MIGRATION_BANDWIDTH: VTYPE_INT,
893
  HV_MIGRATION_DOWNTIME: VTYPE_INT,
894
  HV_MIGRATION_MODE: VTYPE_STRING,
895
  HV_USE_LOCALTIME: VTYPE_BOOL,
896
  HV_DISK_CACHE: VTYPE_STRING,
897
  HV_SECURITY_MODEL: VTYPE_STRING,
898
  HV_SECURITY_DOMAIN: VTYPE_STRING,
899
  HV_KVM_FLAG: VTYPE_STRING,
900
  HV_VHOST_NET: VTYPE_BOOL,
901
  HV_KVM_USE_CHROOT: VTYPE_BOOL,
902
  HV_CPU_MASK: VTYPE_STRING,
903
  HV_MEM_PATH: VTYPE_STRING,
904
  HV_PASSTHROUGH: VTYPE_STRING,
905
  HV_BLOCKDEV_PREFIX: VTYPE_STRING,
906
  HV_REBOOT_BEHAVIOR: VTYPE_STRING,
907
  HV_CPU_TYPE: VTYPE_STRING,
908
  HV_CPU_CAP: VTYPE_INT,
909
  HV_CPU_WEIGHT: VTYPE_INT,
910
  HV_CPU_CORES: VTYPE_INT,
911
  HV_CPU_THREADS: VTYPE_INT,
912
  HV_CPU_SOCKETS: VTYPE_INT,
913
  HV_SOUNDHW: VTYPE_STRING,
914
  HV_USB_DEVICES: VTYPE_STRING,
915
  HV_VGA: VTYPE_STRING,
916
  HV_KVM_EXTRA: VTYPE_STRING,
917
  HV_KVM_MACHINE_VERSION: VTYPE_STRING,
918
  }
919

    
920
HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
921

    
922
HVS_PARAMETER_TITLES = {
923
  HV_ACPI: "ACPI",
924
  HV_BOOT_ORDER: "Boot_order",
925
  HV_CDROM_IMAGE_PATH: "CDROM_image_path",
926
  HV_DISK_TYPE: "Disk_type",
927
  HV_INITRD_PATH: "Initrd_path",
928
  HV_KERNEL_PATH: "Kernel_path",
929
  HV_NIC_TYPE: "NIC_type",
930
  HV_PAE: "PAE",
931
  HV_VNC_BIND_ADDRESS: "VNC_bind_address",
932
  HV_PASSTHROUGH: "pci_pass",
933
  HV_CPU_TYPE: "cpu_type",
934
  }
935

    
936
# Migration statuses
937
HV_MIGRATION_COMPLETED = "completed"
938
HV_MIGRATION_ACTIVE = "active"
939
HV_MIGRATION_FAILED = "failed"
940
HV_MIGRATION_CANCELLED = "cancelled"
941

    
942
HV_MIGRATION_VALID_STATUSES = compat.UniqueFrozenset([
943
  HV_MIGRATION_COMPLETED,
944
  HV_MIGRATION_ACTIVE,
945
  HV_MIGRATION_FAILED,
946
  HV_MIGRATION_CANCELLED,
947
  ])
948

    
949
HV_MIGRATION_FAILED_STATUSES = compat.UniqueFrozenset([
950
  HV_MIGRATION_FAILED,
951
  HV_MIGRATION_CANCELLED,
952
  ])
953

    
954
# KVM-specific statuses
955
HV_KVM_MIGRATION_VALID_STATUSES = HV_MIGRATION_VALID_STATUSES
956

    
957
# Node info keys
958
HV_NODEINFO_KEY_VERSION = "hv_version"
959

    
960
# Hypervisor state
961
HVST_MEMORY_TOTAL = "mem_total"
962
HVST_MEMORY_NODE = "mem_node"
963
HVST_MEMORY_HV = "mem_hv"
964
HVST_CPU_TOTAL = "cpu_total"
965
HVST_CPU_NODE = "cpu_node"
966

    
967
HVST_DEFAULTS = {
968
  HVST_MEMORY_TOTAL: 0,
969
  HVST_MEMORY_NODE: 0,
970
  HVST_MEMORY_HV: 0,
971
  HVST_CPU_TOTAL: 1,
972
  HVST_CPU_NODE: 1,
973
  }
974

    
975
HVSTS_PARAMETER_TYPES = {
976
  HVST_MEMORY_TOTAL: VTYPE_INT,
977
  HVST_MEMORY_NODE: VTYPE_INT,
978
  HVST_MEMORY_HV: VTYPE_INT,
979
  HVST_CPU_TOTAL: VTYPE_INT,
980
  HVST_CPU_NODE: VTYPE_INT,
981
  }
982

    
983
HVSTS_PARAMETERS = frozenset(HVSTS_PARAMETER_TYPES.keys())
984

    
985
# Disk state
986
DS_DISK_TOTAL = "disk_total"
987
DS_DISK_RESERVED = "disk_reserved"
988
DS_DISK_OVERHEAD = "disk_overhead"
989

    
990
DS_DEFAULTS = {
991
  DS_DISK_TOTAL: 0,
992
  DS_DISK_RESERVED: 0,
993
  DS_DISK_OVERHEAD: 0,
994
  }
995

    
996
DSS_PARAMETER_TYPES = {
997
  DS_DISK_TOTAL: VTYPE_INT,
998
  DS_DISK_RESERVED: VTYPE_INT,
999
  DS_DISK_OVERHEAD: VTYPE_INT,
1000
  }
1001

    
1002
DSS_PARAMETERS = frozenset(DSS_PARAMETER_TYPES.keys())
1003
DS_VALID_TYPES = compat.UniqueFrozenset([LD_LV])
1004

    
1005
# Backend parameter names
1006
BE_MEMORY = "memory" # deprecated and replaced by max and min mem
1007
BE_MAXMEM = "maxmem"
1008
BE_MINMEM = "minmem"
1009
BE_VCPUS = "vcpus"
1010
BE_AUTO_BALANCE = "auto_balance"
1011
BE_ALWAYS_FAILOVER = "always_failover"
1012
BE_SPINDLE_USE = "spindle_use"
1013

    
1014
BES_PARAMETER_TYPES = {
1015
  BE_MAXMEM: VTYPE_SIZE,
1016
  BE_MINMEM: VTYPE_SIZE,
1017
  BE_VCPUS: VTYPE_INT,
1018
  BE_AUTO_BALANCE: VTYPE_BOOL,
1019
  BE_ALWAYS_FAILOVER: VTYPE_BOOL,
1020
  BE_SPINDLE_USE: VTYPE_INT,
1021
  }
1022

    
1023
BES_PARAMETER_TITLES = {
1024
  BE_AUTO_BALANCE: "Auto_balance",
1025
  BE_MAXMEM: "ConfigMaxMem",
1026
  BE_MINMEM: "ConfigMinMem",
1027
  BE_VCPUS: "ConfigVCPUs",
1028
  }
1029

    
1030
BES_PARAMETER_COMPAT = {
1031
  BE_MEMORY: VTYPE_SIZE,
1032
  }
1033
BES_PARAMETER_COMPAT.update(BES_PARAMETER_TYPES)
1034

    
1035
BES_PARAMETERS = frozenset(BES_PARAMETER_TYPES.keys())
1036

    
1037
# instance specs
1038
ISPEC_MEM_SIZE = "memory-size"
1039
ISPEC_CPU_COUNT = "cpu-count"
1040
ISPEC_DISK_COUNT = "disk-count"
1041
ISPEC_DISK_SIZE = "disk-size"
1042
ISPEC_NIC_COUNT = "nic-count"
1043
ISPEC_SPINDLE_USE = "spindle-use"
1044

    
1045
ISPECS_PARAMETER_TYPES = {
1046
  ISPEC_MEM_SIZE: VTYPE_INT,
1047
  ISPEC_CPU_COUNT: VTYPE_INT,
1048
  ISPEC_DISK_COUNT: VTYPE_INT,
1049
  ISPEC_DISK_SIZE: VTYPE_INT,
1050
  ISPEC_NIC_COUNT: VTYPE_INT,
1051
  ISPEC_SPINDLE_USE: VTYPE_INT,
1052
  }
1053

    
1054
ISPECS_PARAMETERS = frozenset(ISPECS_PARAMETER_TYPES.keys())
1055

    
1056
ISPECS_MIN = "min"
1057
ISPECS_MAX = "max"
1058
ISPECS_STD = "std"
1059
IPOLICY_DTS = "disk-templates"
1060
IPOLICY_VCPU_RATIO = "vcpu-ratio"
1061
IPOLICY_SPINDLE_RATIO = "spindle-ratio"
1062

    
1063
IPOLICY_ISPECS = compat.UniqueFrozenset([
1064
  ISPECS_MIN,
1065
  ISPECS_MAX,
1066
  ISPECS_STD,
1067
  ])
1068

    
1069
IPOLICY_PARAMETERS = compat.UniqueFrozenset([
1070
  IPOLICY_VCPU_RATIO,
1071
  IPOLICY_SPINDLE_RATIO,
1072
  ])
1073

    
1074
IPOLICY_ALL_KEYS = (IPOLICY_ISPECS |
1075
                    IPOLICY_PARAMETERS |
1076
                    frozenset([IPOLICY_DTS]))
1077

    
1078
# Node parameter names
1079
ND_OOB_PROGRAM = "oob_program"
1080
ND_SPINDLE_COUNT = "spindle_count"
1081
ND_EXCLUSIVE_STORAGE = "exclusive_storage"
1082

    
1083
NDS_PARAMETER_TYPES = {
1084
  ND_OOB_PROGRAM: VTYPE_STRING,
1085
  ND_SPINDLE_COUNT: VTYPE_INT,
1086
  ND_EXCLUSIVE_STORAGE: VTYPE_BOOL,
1087
  }
1088

    
1089
NDS_PARAMETERS = frozenset(NDS_PARAMETER_TYPES.keys())
1090

    
1091
NDS_PARAMETER_TITLES = {
1092
  ND_OOB_PROGRAM: "OutOfBandProgram",
1093
  ND_SPINDLE_COUNT: "SpindleCount",
1094
  ND_EXCLUSIVE_STORAGE: "ExclusiveStorage",
1095
  }
1096

    
1097
# Logical Disks parameters
1098
LDP_RESYNC_RATE = "resync-rate"
1099
LDP_STRIPES = "stripes"
1100
LDP_BARRIERS = "disabled-barriers"
1101
LDP_NO_META_FLUSH = "disable-meta-flush"
1102
LDP_DEFAULT_METAVG = "default-metavg"
1103
LDP_DISK_CUSTOM = "disk-custom"
1104
LDP_NET_CUSTOM = "net-custom"
1105
LDP_DYNAMIC_RESYNC = "dynamic-resync"
1106
LDP_PLAN_AHEAD = "c-plan-ahead"
1107
LDP_FILL_TARGET = "c-fill-target"
1108
LDP_DELAY_TARGET = "c-delay-target"
1109
LDP_MAX_RATE = "c-max-rate"
1110
LDP_MIN_RATE = "c-min-rate"
1111
LDP_POOL = "pool"
1112
DISK_LD_TYPES = {
1113
  LDP_RESYNC_RATE: VTYPE_INT,
1114
  LDP_STRIPES: VTYPE_INT,
1115
  LDP_BARRIERS: VTYPE_STRING,
1116
  LDP_NO_META_FLUSH: VTYPE_BOOL,
1117
  LDP_DEFAULT_METAVG: VTYPE_STRING,
1118
  LDP_DISK_CUSTOM: VTYPE_STRING,
1119
  LDP_NET_CUSTOM: VTYPE_STRING,
1120
  LDP_DYNAMIC_RESYNC: VTYPE_BOOL,
1121
  LDP_PLAN_AHEAD: VTYPE_INT,
1122
  LDP_FILL_TARGET: VTYPE_INT,
1123
  LDP_DELAY_TARGET: VTYPE_INT,
1124
  LDP_MAX_RATE: VTYPE_INT,
1125
  LDP_MIN_RATE: VTYPE_INT,
1126
  LDP_POOL: VTYPE_STRING,
1127
  }
1128
DISK_LD_PARAMETERS = frozenset(DISK_LD_TYPES.keys())
1129

    
1130
# Disk template parameters (can be set/changed by the user via gnt-cluster and
1131
# gnt-group)
1132
DRBD_RESYNC_RATE = "resync-rate"
1133
DRBD_DATA_STRIPES = "data-stripes"
1134
DRBD_META_STRIPES = "meta-stripes"
1135
DRBD_DISK_BARRIERS = "disk-barriers"
1136
DRBD_META_BARRIERS = "meta-barriers"
1137
DRBD_DEFAULT_METAVG = "metavg"
1138
DRBD_DISK_CUSTOM = "disk-custom"
1139
DRBD_NET_CUSTOM = "net-custom"
1140
DRBD_DYNAMIC_RESYNC = "dynamic-resync"
1141
DRBD_PLAN_AHEAD = "c-plan-ahead"
1142
DRBD_FILL_TARGET = "c-fill-target"
1143
DRBD_DELAY_TARGET = "c-delay-target"
1144
DRBD_MAX_RATE = "c-max-rate"
1145
DRBD_MIN_RATE = "c-min-rate"
1146
LV_STRIPES = "stripes"
1147
RBD_POOL = "pool"
1148
DISK_DT_TYPES = {
1149
  DRBD_RESYNC_RATE: VTYPE_INT,
1150
  DRBD_DATA_STRIPES: VTYPE_INT,
1151
  DRBD_META_STRIPES: VTYPE_INT,
1152
  DRBD_DISK_BARRIERS: VTYPE_STRING,
1153
  DRBD_META_BARRIERS: VTYPE_BOOL,
1154
  DRBD_DEFAULT_METAVG: VTYPE_STRING,
1155
  DRBD_DISK_CUSTOM: VTYPE_STRING,
1156
  DRBD_NET_CUSTOM: VTYPE_STRING,
1157
  DRBD_DYNAMIC_RESYNC: VTYPE_BOOL,
1158
  DRBD_PLAN_AHEAD: VTYPE_INT,
1159
  DRBD_FILL_TARGET: VTYPE_INT,
1160
  DRBD_DELAY_TARGET: VTYPE_INT,
1161
  DRBD_MAX_RATE: VTYPE_INT,
1162
  DRBD_MIN_RATE: VTYPE_INT,
1163
  LV_STRIPES: VTYPE_INT,
1164
  RBD_POOL: VTYPE_STRING,
1165
  }
1166

    
1167
DISK_DT_PARAMETERS = frozenset(DISK_DT_TYPES.keys())
1168

    
1169
# OOB supported commands
1170
OOB_POWER_ON = "power-on"
1171
OOB_POWER_OFF = "power-off"
1172
OOB_POWER_CYCLE = "power-cycle"
1173
OOB_POWER_STATUS = "power-status"
1174
OOB_HEALTH = "health"
1175

    
1176
OOB_COMMANDS = compat.UniqueFrozenset([
1177
  OOB_POWER_ON,
1178
  OOB_POWER_OFF,
1179
  OOB_POWER_CYCLE,
1180
  OOB_POWER_STATUS,
1181
  OOB_HEALTH,
1182
  ])
1183

    
1184
OOB_POWER_STATUS_POWERED = "powered"
1185

    
1186
OOB_TIMEOUT = 60 # 60 seconds
1187
OOB_POWER_DELAY = 2.0 # 2 seconds
1188

    
1189
OOB_STATUS_OK = "OK"
1190
OOB_STATUS_WARNING = "WARNING"
1191
OOB_STATUS_CRITICAL = "CRITICAL"
1192
OOB_STATUS_UNKNOWN = "UNKNOWN"
1193

    
1194
OOB_STATUSES = compat.UniqueFrozenset([
1195
  OOB_STATUS_OK,
1196
  OOB_STATUS_WARNING,
1197
  OOB_STATUS_CRITICAL,
1198
  OOB_STATUS_UNKNOWN,
1199
  ])
1200

    
1201
# Instance Parameters Profile
1202
PP_DEFAULT = "default"
1203

    
1204
# NIC_* constants are used inside the ganeti config
1205
NIC_MODE = "mode"
1206
NIC_LINK = "link"
1207

    
1208
NIC_MODE_BRIDGED = "bridged"
1209
NIC_MODE_ROUTED = "routed"
1210
NIC_MODE_OVS = "openvswitch"
1211
NIC_IP_POOL = "pool"
1212

    
1213
NIC_VALID_MODES = compat.UniqueFrozenset([
1214
  NIC_MODE_BRIDGED,
1215
  NIC_MODE_ROUTED,
1216
  NIC_MODE_OVS,
1217
  ])
1218

    
1219
RESERVE_ACTION = "reserve"
1220
RELEASE_ACTION = "release"
1221

    
1222
NICS_PARAMETER_TYPES = {
1223
  NIC_MODE: VTYPE_STRING,
1224
  NIC_LINK: VTYPE_STRING,
1225
  }
1226

    
1227
NICS_PARAMETERS = frozenset(NICS_PARAMETER_TYPES.keys())
1228

    
1229
# IDISK_* constants are used in opcodes, to create/change disks
1230
IDISK_SIZE = "size"
1231
IDISK_MODE = "mode"
1232
IDISK_ADOPT = "adopt"
1233
IDISK_VG = "vg"
1234
IDISK_METAVG = "metavg"
1235
IDISK_PROVIDER = "provider"
1236
IDISK_PARAMS_TYPES = {
1237
  IDISK_SIZE: VTYPE_SIZE,
1238
  IDISK_MODE: VTYPE_STRING,
1239
  IDISK_ADOPT: VTYPE_STRING,
1240
  IDISK_VG: VTYPE_STRING,
1241
  IDISK_METAVG: VTYPE_STRING,
1242
  IDISK_PROVIDER: VTYPE_STRING,
1243
  }
1244
IDISK_PARAMS = frozenset(IDISK_PARAMS_TYPES.keys())
1245

    
1246
# INIC_* constants are used in opcodes, to create/change nics
1247
INIC_MAC = "mac"
1248
INIC_IP = "ip"
1249
INIC_MODE = "mode"
1250
INIC_LINK = "link"
1251
INIC_NETWORK = "network"
1252
INIC_PARAMS_TYPES = {
1253
  INIC_IP: VTYPE_MAYBE_STRING,
1254
  INIC_LINK: VTYPE_STRING,
1255
  INIC_MAC: VTYPE_STRING,
1256
  INIC_MODE: VTYPE_STRING,
1257
  INIC_NETWORK: VTYPE_MAYBE_STRING,
1258
  }
1259
INIC_PARAMS = frozenset(INIC_PARAMS_TYPES.keys())
1260

    
1261
# Hypervisor constants
1262
HT_XEN_PVM = "xen-pvm"
1263
HT_FAKE = "fake"
1264
HT_XEN_HVM = "xen-hvm"
1265
HT_KVM = "kvm"
1266
HT_CHROOT = "chroot"
1267
HT_LXC = "lxc"
1268
HYPER_TYPES = compat.UniqueFrozenset([
1269
  HT_XEN_PVM,
1270
  HT_FAKE,
1271
  HT_XEN_HVM,
1272
  HT_KVM,
1273
  HT_CHROOT,
1274
  HT_LXC,
1275
  ])
1276
HTS_REQ_PORT = compat.UniqueFrozenset([HT_XEN_HVM, HT_KVM])
1277

    
1278
VNC_BASE_PORT = 5900
1279
VNC_DEFAULT_BIND_ADDRESS = IP4_ADDRESS_ANY
1280

    
1281
# NIC types
1282
HT_NIC_RTL8139 = "rtl8139"
1283
HT_NIC_NE2K_PCI = "ne2k_pci"
1284
HT_NIC_NE2K_ISA = "ne2k_isa"
1285
HT_NIC_I82551 = "i82551"
1286
HT_NIC_I85557B = "i82557b"
1287
HT_NIC_I8259ER = "i82559er"
1288
HT_NIC_PCNET = "pcnet"
1289
HT_NIC_E1000 = "e1000"
1290
HT_NIC_PARAVIRTUAL = HT_DISK_PARAVIRTUAL = "paravirtual"
1291

    
1292
HT_HVM_VALID_NIC_TYPES = compat.UniqueFrozenset([
1293
  HT_NIC_RTL8139,
1294
  HT_NIC_NE2K_PCI,
1295
  HT_NIC_E1000,
1296
  HT_NIC_NE2K_ISA,
1297
  HT_NIC_PARAVIRTUAL,
1298
  ])
1299
HT_KVM_VALID_NIC_TYPES = compat.UniqueFrozenset([
1300
  HT_NIC_RTL8139,
1301
  HT_NIC_NE2K_PCI,
1302
  HT_NIC_NE2K_ISA,
1303
  HT_NIC_I82551,
1304
  HT_NIC_I85557B,
1305
  HT_NIC_I8259ER,
1306
  HT_NIC_PCNET,
1307
  HT_NIC_E1000,
1308
  HT_NIC_PARAVIRTUAL,
1309
  ])
1310

    
1311
# Disk types
1312
HT_DISK_IOEMU = "ioemu"
1313
HT_DISK_IDE = "ide"
1314
HT_DISK_SCSI = "scsi"
1315
HT_DISK_SD = "sd"
1316
HT_DISK_MTD = "mtd"
1317
HT_DISK_PFLASH = "pflash"
1318

    
1319
HT_CACHE_DEFAULT = "default"
1320
HT_CACHE_NONE = "none"
1321
HT_CACHE_WTHROUGH = "writethrough"
1322
HT_CACHE_WBACK = "writeback"
1323
HT_VALID_CACHE_TYPES = compat.UniqueFrozenset([
1324
  HT_CACHE_DEFAULT,
1325
  HT_CACHE_NONE,
1326
  HT_CACHE_WTHROUGH,
1327
  HT_CACHE_WBACK,
1328
  ])
1329

    
1330
HT_HVM_VALID_DISK_TYPES = compat.UniqueFrozenset([
1331
  HT_DISK_PARAVIRTUAL,
1332
  HT_DISK_IOEMU,
1333
  ])
1334
HT_KVM_VALID_DISK_TYPES = compat.UniqueFrozenset([
1335
  HT_DISK_PARAVIRTUAL,
1336
  HT_DISK_IDE,
1337
  HT_DISK_SCSI,
1338
  HT_DISK_SD,
1339
  HT_DISK_MTD,
1340
  HT_DISK_PFLASH,
1341
  ])
1342

    
1343
# Mouse types:
1344
HT_MOUSE_MOUSE = "mouse"
1345
HT_MOUSE_TABLET = "tablet"
1346

    
1347
HT_KVM_VALID_MOUSE_TYPES = compat.UniqueFrozenset([
1348
  HT_MOUSE_MOUSE,
1349
  HT_MOUSE_TABLET,
1350
  ])
1351

    
1352
# Boot order
1353
HT_BO_FLOPPY = "floppy"
1354
HT_BO_CDROM = "cdrom"
1355
HT_BO_DISK = "disk"
1356
HT_BO_NETWORK = "network"
1357

    
1358
HT_KVM_VALID_BO_TYPES = compat.UniqueFrozenset([
1359
  HT_BO_FLOPPY,
1360
  HT_BO_CDROM,
1361
  HT_BO_DISK,
1362
  HT_BO_NETWORK,
1363
  ])
1364

    
1365
# SPICE lossless image compression options
1366
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ = "auto_glz"
1367
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ = "auto_lz"
1368
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC = "quic"
1369
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ = "glz"
1370
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ = "lz"
1371
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF = "off"
1372

    
1373
HT_KVM_SPICE_VALID_LOSSLESS_IMG_COMPR_OPTIONS = compat.UniqueFrozenset([
1374
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ,
1375
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ,
1376
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC,
1377
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ,
1378
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ,
1379
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF,
1380
  ])
1381

    
1382
# SPICE lossy image compression options (valid for both jpeg and zlib-glz)
1383
HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO = "auto"
1384
HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER = "never"
1385
HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS = "always"
1386

    
1387
HT_KVM_SPICE_VALID_LOSSY_IMG_COMPR_OPTIONS = compat.UniqueFrozenset([
1388
  HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO,
1389
  HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER,
1390
  HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS,
1391
  ])
1392

    
1393
# SPICE video stream detection
1394
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF = "off"
1395
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL = "all"
1396
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER = "filter"
1397

    
1398
HT_KVM_SPICE_VALID_VIDEO_STREAM_DETECTION_OPTIONS = compat.UniqueFrozenset([
1399
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF,
1400
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL,
1401
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER,
1402
  ])
1403

    
1404
# Security models
1405
HT_SM_NONE = "none"
1406
HT_SM_USER = "user"
1407
HT_SM_POOL = "pool"
1408

    
1409
HT_KVM_VALID_SM_TYPES = compat.UniqueFrozenset([
1410
  HT_SM_NONE,
1411
  HT_SM_USER,
1412
  HT_SM_POOL,
1413
  ])
1414

    
1415
# Kvm flag values
1416
HT_KVM_ENABLED = "enabled"
1417
HT_KVM_DISABLED = "disabled"
1418

    
1419
HT_KVM_FLAG_VALUES = compat.UniqueFrozenset([HT_KVM_ENABLED, HT_KVM_DISABLED])
1420

    
1421
# Migration type
1422
HT_MIGRATION_LIVE = "live"
1423
HT_MIGRATION_NONLIVE = "non-live"
1424
HT_MIGRATION_MODES = compat.UniqueFrozenset([
1425
  HT_MIGRATION_LIVE,
1426
  HT_MIGRATION_NONLIVE,
1427
  ])
1428

    
1429
# Cluster Verify steps
1430
VERIFY_NPLUSONE_MEM = "nplusone_mem"
1431
VERIFY_OPTIONAL_CHECKS = compat.UniqueFrozenset([VERIFY_NPLUSONE_MEM])
1432

    
1433
# Cluster Verify error classes
1434
CV_TCLUSTER = "cluster"
1435
CV_TGROUP = "group"
1436
CV_TNODE = "node"
1437
CV_TINSTANCE = "instance"
1438

    
1439
# Cluster Verify error codes and documentation
1440
CV_ECLUSTERCFG = \
1441
  (CV_TCLUSTER, "ECLUSTERCFG", "Cluster configuration verification failure")
1442
CV_ECLUSTERCERT = \
1443
  (CV_TCLUSTER, "ECLUSTERCERT",
1444
   "Cluster certificate files verification failure")
1445
CV_ECLUSTERFILECHECK = \
1446
  (CV_TCLUSTER, "ECLUSTERFILECHECK",
1447
   "Cluster configuration verification failure")
1448
CV_ECLUSTERDANGLINGNODES = \
1449
  (CV_TNODE, "ECLUSTERDANGLINGNODES",
1450
   "Some nodes belong to non-existing groups")
1451
CV_ECLUSTERDANGLINGINST = \
1452
  (CV_TNODE, "ECLUSTERDANGLINGINST",
1453
   "Some instances have a non-existing primary node")
1454
CV_EGROUPDIFFERENTPVSIZE = \
1455
  (CV_TGROUP, "EGROUPDIFFERENTPVSIZE", "PVs in the group have different sizes")
1456
CV_EINSTANCEBADNODE = \
1457
  (CV_TINSTANCE, "EINSTANCEBADNODE",
1458
   "Instance marked as running lives on an offline node")
1459
CV_EINSTANCEDOWN = \
1460
  (CV_TINSTANCE, "EINSTANCEDOWN", "Instance not running on its primary node")
1461
CV_EINSTANCELAYOUT = \
1462
  (CV_TINSTANCE, "EINSTANCELAYOUT", "Instance has multiple secondary nodes")
1463
CV_EINSTANCEMISSINGDISK = \
1464
  (CV_TINSTANCE, "EINSTANCEMISSINGDISK", "Missing volume on an instance")
1465
CV_EINSTANCEFAULTYDISK = \
1466
  (CV_TINSTANCE, "EINSTANCEFAULTYDISK",
1467
   "Impossible to retrieve status for a disk")
1468
CV_EINSTANCEWRONGNODE = \
1469
  (CV_TINSTANCE, "EINSTANCEWRONGNODE", "Instance running on the wrong node")
1470
CV_EINSTANCESPLITGROUPS = \
1471
  (CV_TINSTANCE, "EINSTANCESPLITGROUPS",
1472
   "Instance with primary and secondary nodes in different groups")
1473
CV_EINSTANCEPOLICY = \
1474
  (CV_TINSTANCE, "EINSTANCEPOLICY",
1475
   "Instance does not meet policy")
1476
CV_EINSTANCEUNSUITABLENODE = \
1477
  (CV_TINSTANCE, "EINSTANCEUNSUITABLENODE",
1478
   "Instance running on nodes that are not suitable for it")
1479
CV_ENODEDRBD = \
1480
  (CV_TNODE, "ENODEDRBD", "Error parsing the DRBD status file")
1481
CV_ENODEDRBDHELPER = \
1482
  (CV_TNODE, "ENODEDRBDHELPER", "Error caused by the DRBD helper")
1483
CV_ENODEFILECHECK = \
1484
  (CV_TNODE, "ENODEFILECHECK",
1485
   "Error retrieving the checksum of the node files")
1486
CV_ENODEHOOKS = \
1487
  (CV_TNODE, "ENODEHOOKS", "Communication failure in hooks execution")
1488
CV_ENODEHV = \
1489
  (CV_TNODE, "ENODEHV", "Hypervisor parameters verification failure")
1490
CV_ENODELVM = \
1491
  (CV_TNODE, "ENODELVM", "LVM-related node error")
1492
CV_ENODEN1 = \
1493
  (CV_TNODE, "ENODEN1", "Not enough memory to accommodate instance failovers")
1494
CV_ENODENET = \
1495
  (CV_TNODE, "ENODENET", "Network-related node error")
1496
CV_ENODEOS = \
1497
  (CV_TNODE, "ENODEOS", "OS-related node error")
1498
CV_ENODEORPHANINSTANCE = \
1499
  (CV_TNODE, "ENODEORPHANINSTANCE", "Unknown intance running on a node")
1500
CV_ENODEORPHANLV = \
1501
  (CV_TNODE, "ENODEORPHANLV", "Unknown LVM logical volume")
1502
CV_ENODERPC = \
1503
  (CV_TNODE, "ENODERPC",
1504
   "Error during connection to the primary node of an instance")
1505
CV_ENODESSH = \
1506
  (CV_TNODE, "ENODESSH", "SSH-related node error")
1507
CV_ENODEVERSION = \
1508
  (CV_TNODE, "ENODEVERSION",
1509
   "Protocol version mismatch or Ganeti version mismatch")
1510
CV_ENODESETUP = \
1511
  (CV_TNODE, "ENODESETUP", "Node setup error")
1512
CV_ENODETIME = \
1513
  (CV_TNODE, "ENODETIME", "Node returned invalid time")
1514
CV_ENODEOOBPATH = \
1515
  (CV_TNODE, "ENODEOOBPATH", "Invalid Out Of Band path")
1516
CV_ENODEUSERSCRIPTS = \
1517
  (CV_TNODE, "ENODEUSERSCRIPTS", "User scripts not present or not executable")
1518
CV_ENODEFILESTORAGEPATHS = \
1519
  (CV_TNODE, "ENODEFILESTORAGEPATHS", "Detected bad file storage paths")
1520

    
1521
CV_ALL_ECODES = compat.UniqueFrozenset([
1522
  CV_ECLUSTERCFG,
1523
  CV_ECLUSTERCERT,
1524
  CV_ECLUSTERFILECHECK,
1525
  CV_ECLUSTERDANGLINGNODES,
1526
  CV_ECLUSTERDANGLINGINST,
1527
  CV_EINSTANCEBADNODE,
1528
  CV_EINSTANCEDOWN,
1529
  CV_EINSTANCELAYOUT,
1530
  CV_EINSTANCEMISSINGDISK,
1531
  CV_EINSTANCEFAULTYDISK,
1532
  CV_EINSTANCEWRONGNODE,
1533
  CV_EINSTANCESPLITGROUPS,
1534
  CV_EINSTANCEPOLICY,
1535
  CV_ENODEDRBD,
1536
  CV_ENODEDRBDHELPER,
1537
  CV_ENODEFILECHECK,
1538
  CV_ENODEHOOKS,
1539
  CV_ENODEHV,
1540
  CV_ENODELVM,
1541
  CV_ENODEN1,
1542
  CV_ENODENET,
1543
  CV_ENODEOS,
1544
  CV_ENODEORPHANINSTANCE,
1545
  CV_ENODEORPHANLV,
1546
  CV_ENODERPC,
1547
  CV_ENODESSH,
1548
  CV_ENODEVERSION,
1549
  CV_ENODESETUP,
1550
  CV_ENODETIME,
1551
  CV_ENODEOOBPATH,
1552
  CV_ENODEUSERSCRIPTS,
1553
  CV_ENODEFILESTORAGEPATHS,
1554
  ])
1555

    
1556
CV_ALL_ECODES_STRINGS = \
1557
  compat.UniqueFrozenset(estr for (_, estr, _) in CV_ALL_ECODES)
1558

    
1559
# Node verify constants
1560
NV_BRIDGES = "bridges"
1561
NV_DRBDHELPER = "drbd-helper"
1562
NV_DRBDLIST = "drbd-list"
1563
NV_EXCLUSIVEPVS = "exclusive-pvs"
1564
NV_FILELIST = "filelist"
1565
NV_FILE_STORAGE_PATHS = "file-storage-paths"
1566
NV_HVINFO = "hvinfo"
1567
NV_HVPARAMS = "hvparms"
1568
NV_HYPERVISOR = "hypervisor"
1569
NV_INSTANCELIST = "instancelist"
1570
NV_LVLIST = "lvlist"
1571
NV_MASTERIP = "master-ip"
1572
NV_NODELIST = "nodelist"
1573
NV_NODENETTEST = "node-net-test"
1574
NV_NODESETUP = "nodesetup"
1575
NV_OOB_PATHS = "oob-paths"
1576
NV_OSLIST = "oslist"
1577
NV_PVLIST = "pvlist"
1578
NV_TIME = "time"
1579
NV_USERSCRIPTS = "user-scripts"
1580
NV_VERSION = "version"
1581
NV_VGLIST = "vglist"
1582
NV_VMNODES = "vmnodes"
1583

    
1584
# Instance status
1585
INSTST_RUNNING = "running"
1586
INSTST_ADMINDOWN = "ADMIN_down"
1587
INSTST_ADMINOFFLINE = "ADMIN_offline"
1588
INSTST_NODEOFFLINE = "ERROR_nodeoffline"
1589
INSTST_NODEDOWN = "ERROR_nodedown"
1590
INSTST_WRONGNODE = "ERROR_wrongnode"
1591
INSTST_ERRORUP = "ERROR_up"
1592
INSTST_ERRORDOWN = "ERROR_down"
1593
INSTST_ALL = compat.UniqueFrozenset([
1594
  INSTST_RUNNING,
1595
  INSTST_ADMINDOWN,
1596
  INSTST_ADMINOFFLINE,
1597
  INSTST_NODEOFFLINE,
1598
  INSTST_NODEDOWN,
1599
  INSTST_WRONGNODE,
1600
  INSTST_ERRORUP,
1601
  INSTST_ERRORDOWN,
1602
  ])
1603

    
1604
# Admin states
1605
ADMINST_UP = "up"
1606
ADMINST_DOWN = "down"
1607
ADMINST_OFFLINE = "offline"
1608
ADMINST_ALL = compat.UniqueFrozenset([
1609
  ADMINST_UP,
1610
  ADMINST_DOWN,
1611
  ADMINST_OFFLINE,
1612
  ])
1613

    
1614
# Node roles
1615
NR_REGULAR = "R"
1616
NR_MASTER = "M"
1617
NR_MCANDIDATE = "C"
1618
NR_DRAINED = "D"
1619
NR_OFFLINE = "O"
1620
NR_ALL = compat.UniqueFrozenset([
1621
  NR_REGULAR,
1622
  NR_MASTER,
1623
  NR_MCANDIDATE,
1624
  NR_DRAINED,
1625
  NR_OFFLINE,
1626
  ])
1627

    
1628
# SSL certificate check constants (in days)
1629
SSL_CERT_EXPIRATION_WARN = 30
1630
SSL_CERT_EXPIRATION_ERROR = 7
1631

    
1632
# Allocator framework constants
1633
IALLOCATOR_VERSION = 2
1634
IALLOCATOR_DIR_IN = "in"
1635
IALLOCATOR_DIR_OUT = "out"
1636
VALID_IALLOCATOR_DIRECTIONS = compat.UniqueFrozenset([
1637
  IALLOCATOR_DIR_IN,
1638
  IALLOCATOR_DIR_OUT,
1639
  ])
1640
IALLOCATOR_MODE_ALLOC = "allocate"
1641
IALLOCATOR_MODE_RELOC = "relocate"
1642
IALLOCATOR_MODE_CHG_GROUP = "change-group"
1643
IALLOCATOR_MODE_NODE_EVAC = "node-evacuate"
1644
IALLOCATOR_MODE_MULTI_ALLOC = "multi-allocate"
1645
VALID_IALLOCATOR_MODES = compat.UniqueFrozenset([
1646
  IALLOCATOR_MODE_ALLOC,
1647
  IALLOCATOR_MODE_RELOC,
1648
  IALLOCATOR_MODE_CHG_GROUP,
1649
  IALLOCATOR_MODE_NODE_EVAC,
1650
  IALLOCATOR_MODE_MULTI_ALLOC,
1651
  ])
1652
IALLOCATOR_SEARCH_PATH = _autoconf.IALLOCATOR_SEARCH_PATH
1653
DEFAULT_IALLOCATOR_SHORTCUT = "."
1654

    
1655
IALLOCATOR_NEVAC_PRI = "primary-only"
1656
IALLOCATOR_NEVAC_SEC = "secondary-only"
1657
IALLOCATOR_NEVAC_ALL = "all"
1658
IALLOCATOR_NEVAC_MODES = compat.UniqueFrozenset([
1659
  IALLOCATOR_NEVAC_PRI,
1660
  IALLOCATOR_NEVAC_SEC,
1661
  IALLOCATOR_NEVAC_ALL,
1662
  ])
1663

    
1664
# Node evacuation
1665
NODE_EVAC_PRI = "primary-only"
1666
NODE_EVAC_SEC = "secondary-only"
1667
NODE_EVAC_ALL = "all"
1668
NODE_EVAC_MODES = compat.UniqueFrozenset([
1669
  NODE_EVAC_PRI,
1670
  NODE_EVAC_SEC,
1671
  NODE_EVAC_ALL,
1672
  ])
1673

    
1674
# Job queue
1675
JOB_QUEUE_VERSION = 1
1676
JOB_QUEUE_SIZE_HARD_LIMIT = 5000
1677

    
1678
JOB_ID_TEMPLATE = r"\d+"
1679
JOB_FILE_RE = re.compile(r"^job-(%s)$" % JOB_ID_TEMPLATE)
1680

    
1681
# unchanged job return
1682
JOB_NOTCHANGED = "nochange"
1683

    
1684
# Job status
1685
JOB_STATUS_QUEUED = "queued"
1686
JOB_STATUS_WAITING = "waiting"
1687
JOB_STATUS_CANCELING = "canceling"
1688
JOB_STATUS_RUNNING = "running"
1689
JOB_STATUS_CANCELED = "canceled"
1690
JOB_STATUS_SUCCESS = "success"
1691
JOB_STATUS_ERROR = "error"
1692
JOBS_PENDING = compat.UniqueFrozenset([
1693
  JOB_STATUS_QUEUED,
1694
  JOB_STATUS_WAITING,
1695
  JOB_STATUS_CANCELING,
1696
  ])
1697
JOBS_FINALIZED = compat.UniqueFrozenset([
1698
  JOB_STATUS_CANCELED,
1699
  JOB_STATUS_SUCCESS,
1700
  JOB_STATUS_ERROR,
1701
  ])
1702
JOB_STATUS_ALL = compat.UniqueFrozenset([
1703
  JOB_STATUS_RUNNING,
1704
  ]) | JOBS_PENDING | JOBS_FINALIZED
1705

    
1706
# OpCode status
1707
# not yet finalized
1708
OP_STATUS_QUEUED = "queued"
1709
OP_STATUS_WAITING = "waiting"
1710
OP_STATUS_CANCELING = "canceling"
1711
OP_STATUS_RUNNING = "running"
1712
# finalized
1713
OP_STATUS_CANCELED = "canceled"
1714
OP_STATUS_SUCCESS = "success"
1715
OP_STATUS_ERROR = "error"
1716
OPS_FINALIZED = compat.UniqueFrozenset([
1717
  OP_STATUS_CANCELED,
1718
  OP_STATUS_SUCCESS,
1719
  OP_STATUS_ERROR,
1720
  ])
1721

    
1722
# OpCode priority
1723
OP_PRIO_LOWEST = +19
1724
OP_PRIO_HIGHEST = -20
1725

    
1726
OP_PRIO_LOW = +10
1727
OP_PRIO_NORMAL = 0
1728
OP_PRIO_HIGH = -10
1729

    
1730
OP_PRIO_SUBMIT_VALID = compat.UniqueFrozenset([
1731
  OP_PRIO_LOW,
1732
  OP_PRIO_NORMAL,
1733
  OP_PRIO_HIGH,
1734
  ])
1735

    
1736
OP_PRIO_DEFAULT = OP_PRIO_NORMAL
1737

    
1738
# Lock recalculate mode
1739
LOCKS_REPLACE = "replace"
1740
LOCKS_APPEND = "append"
1741

    
1742
# Lock timeout (sum) before we should go into blocking acquire (still
1743
# can be reset by priority change); computed as max time (10 hours)
1744
# before we should actually go into blocking acquire given that we
1745
# start from default priority level; in seconds
1746
# TODO
1747
LOCK_ATTEMPTS_TIMEOUT = 10 * 3600 / (OP_PRIO_DEFAULT - OP_PRIO_HIGHEST)
1748
LOCK_ATTEMPTS_MAXWAIT = 15.0
1749
LOCK_ATTEMPTS_MINWAIT = 1.0
1750

    
1751
# Execution log types
1752
ELOG_MESSAGE = "message"
1753
ELOG_REMOTE_IMPORT = "remote-import"
1754
ELOG_JQUEUE_TEST = "jqueue-test"
1755

    
1756
# /etc/hosts modification
1757
ETC_HOSTS_ADD = "add"
1758
ETC_HOSTS_REMOVE = "remove"
1759

    
1760
# Job queue test
1761
JQT_MSGPREFIX = "TESTMSG="
1762
JQT_EXPANDNAMES = "expandnames"
1763
JQT_EXEC = "exec"
1764
JQT_LOGMSG = "logmsg"
1765
JQT_STARTMSG = "startmsg"
1766
JQT_ALL = compat.UniqueFrozenset([
1767
  JQT_EXPANDNAMES,
1768
  JQT_EXEC,
1769
  JQT_LOGMSG,
1770
  JQT_STARTMSG,
1771
  ])
1772

    
1773
# Query resources
1774
QR_CLUSTER = "cluster"
1775
QR_INSTANCE = "instance"
1776
QR_NODE = "node"
1777
QR_LOCK = "lock"
1778
QR_GROUP = "group"
1779
QR_OS = "os"
1780
QR_JOB = "job"
1781
QR_EXPORT = "export"
1782
QR_NETWORK = "network"
1783
QR_EXTSTORAGE = "extstorage"
1784

    
1785
#: List of resources which can be queried using L{opcodes.OpQuery}
1786
QR_VIA_OP = compat.UniqueFrozenset([
1787
  QR_CLUSTER,
1788
  QR_INSTANCE,
1789
  QR_NODE,
1790
  QR_GROUP,
1791
  QR_OS,
1792
  QR_EXPORT,
1793
  QR_NETWORK,
1794
  QR_EXTSTORAGE,
1795
  ])
1796

    
1797
#: List of resources which can be queried using Local UniX Interface
1798
QR_VIA_LUXI = QR_VIA_OP.union([
1799
  QR_LOCK,
1800
  QR_JOB,
1801
  ])
1802

    
1803
#: List of resources which can be queried using RAPI
1804
QR_VIA_RAPI = QR_VIA_LUXI
1805

    
1806
# Query field types
1807
QFT_UNKNOWN = "unknown"
1808
QFT_TEXT = "text"
1809
QFT_BOOL = "bool"
1810
QFT_NUMBER = "number"
1811
QFT_UNIT = "unit"
1812
QFT_TIMESTAMP = "timestamp"
1813
QFT_OTHER = "other"
1814

    
1815
#: All query field types
1816
QFT_ALL = compat.UniqueFrozenset([
1817
  QFT_UNKNOWN,
1818
  QFT_TEXT,
1819
  QFT_BOOL,
1820
  QFT_NUMBER,
1821
  QFT_UNIT,
1822
  QFT_TIMESTAMP,
1823
  QFT_OTHER,
1824
  ])
1825

    
1826
# Query result field status (don't change or reuse values as they're used by
1827
# clients)
1828
#: Normal field status
1829
RS_NORMAL = 0
1830
#: Unknown field
1831
RS_UNKNOWN = 1
1832
#: No data (e.g. RPC error), can be used instead of L{RS_OFFLINE}
1833
RS_NODATA = 2
1834
#: Value unavailable/unsupported for item; if this field is supported
1835
#: but we cannot get the data for the moment, RS_NODATA or
1836
#: RS_OFFLINE should be used
1837
RS_UNAVAIL = 3
1838
#: Resource marked offline
1839
RS_OFFLINE = 4
1840

    
1841
RS_ALL = compat.UniqueFrozenset([
1842
  RS_NORMAL,
1843
  RS_UNKNOWN,
1844
  RS_NODATA,
1845
  RS_UNAVAIL,
1846
  RS_OFFLINE,
1847
  ])
1848

    
1849
#: Dictionary with special field cases and their verbose/terse formatting
1850
RSS_DESCRIPTION = {
1851
  RS_UNKNOWN: ("(unknown)", "??"),
1852
  RS_NODATA: ("(nodata)", "?"),
1853
  RS_OFFLINE: ("(offline)", "*"),
1854
  RS_UNAVAIL: ("(unavail)", "-"),
1855
  }
1856

    
1857
# max dynamic devices
1858
MAX_NICS = 8
1859
MAX_DISKS = 16
1860

    
1861
# SSCONF file prefix
1862
SSCONF_FILEPREFIX = "ssconf_"
1863
# SSCONF keys
1864
SS_CLUSTER_NAME = "cluster_name"
1865
SS_CLUSTER_TAGS = "cluster_tags"
1866
SS_FILE_STORAGE_DIR = "file_storage_dir"
1867
SS_SHARED_FILE_STORAGE_DIR = "shared_file_storage_dir"
1868
SS_MASTER_CANDIDATES = "master_candidates"
1869
SS_MASTER_CANDIDATES_IPS = "master_candidates_ips"
1870
SS_MASTER_IP = "master_ip"
1871
SS_MASTER_NETDEV = "master_netdev"
1872
SS_MASTER_NETMASK = "master_netmask"
1873
SS_MASTER_NODE = "master_node"
1874
SS_NODE_LIST = "node_list"
1875
SS_NODE_PRIMARY_IPS = "node_primary_ips"
1876
SS_NODE_SECONDARY_IPS = "node_secondary_ips"
1877
SS_OFFLINE_NODES = "offline_nodes"
1878
SS_ONLINE_NODES = "online_nodes"
1879
SS_PRIMARY_IP_FAMILY = "primary_ip_family"
1880
SS_INSTANCE_LIST = "instance_list"
1881
SS_RELEASE_VERSION = "release_version"
1882
SS_HYPERVISOR_LIST = "hypervisor_list"
1883
SS_MAINTAIN_NODE_HEALTH = "maintain_node_health"
1884
SS_UID_POOL = "uid_pool"
1885
SS_NODEGROUPS = "nodegroups"
1886
SS_NETWORKS = "networks"
1887

    
1888
SS_FILE_PERMS = 0444
1889

    
1890
# cluster wide default parameters
1891
DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM
1892

    
1893
HVC_DEFAULTS = {
1894
  HT_XEN_PVM: {
1895
    HV_USE_BOOTLOADER: False,
1896
    HV_BOOTLOADER_PATH: XEN_BOOTLOADER,
1897
    HV_BOOTLOADER_ARGS: "",
1898
    HV_KERNEL_PATH: XEN_KERNEL,
1899
    HV_INITRD_PATH: "",
1900
    HV_ROOT_PATH: "/dev/xvda1",
1901
    HV_KERNEL_ARGS: "ro",
1902
    HV_MIGRATION_PORT: 8002,
1903
    HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1904
    HV_BLOCKDEV_PREFIX: "sd",
1905
    HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1906
    HV_CPU_MASK: CPU_PINNING_ALL,
1907
    HV_CPU_CAP: 0,
1908
    HV_CPU_WEIGHT: 256,
1909
    },
1910
  HT_XEN_HVM: {
1911
    HV_BOOT_ORDER: "cd",
1912
    HV_CDROM_IMAGE_PATH: "",
1913
    HV_NIC_TYPE: HT_NIC_RTL8139,
1914
    HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
1915
    HV_VNC_BIND_ADDRESS: IP4_ADDRESS_ANY,
1916
    HV_VNC_PASSWORD_FILE: pathutils.VNC_PASSWORD_FILE,
1917
    HV_ACPI: True,
1918
    HV_PAE: True,
1919
    HV_KERNEL_PATH: "/usr/lib/xen/boot/hvmloader",
1920
    HV_DEVICE_MODEL: "/usr/lib/xen/bin/qemu-dm",
1921
    HV_MIGRATION_PORT: 8002,
1922
    HV_MIGRATION_MODE: HT_MIGRATION_NONLIVE,
1923
    HV_USE_LOCALTIME: False,
1924
    HV_BLOCKDEV_PREFIX: "hd",
1925
    HV_PASSTHROUGH: "",
1926
    HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1927
    HV_CPU_MASK: CPU_PINNING_ALL,
1928
    HV_CPU_CAP: 0,
1929
    HV_CPU_WEIGHT: 256,
1930
    },
1931
  HT_KVM: {
1932
    HV_KVM_PATH: KVM_PATH,
1933
    HV_KERNEL_PATH: KVM_KERNEL,
1934
    HV_INITRD_PATH: "",
1935
    HV_KERNEL_ARGS: "ro",
1936
    HV_ROOT_PATH: "/dev/vda1",
1937
    HV_ACPI: True,
1938
    HV_SERIAL_CONSOLE: True,
1939
    HV_SERIAL_SPEED: 38400,
1940
    HV_VNC_BIND_ADDRESS: "",
1941
    HV_VNC_TLS: False,
1942
    HV_VNC_X509: "",
1943
    HV_VNC_X509_VERIFY: False,
1944
    HV_VNC_PASSWORD_FILE: "",
1945
    HV_KVM_SPICE_BIND: "",
1946
    HV_KVM_SPICE_IP_VERSION: IFACE_NO_IP_VERSION_SPECIFIED,
1947
    HV_KVM_SPICE_PASSWORD_FILE: "",
1948
    HV_KVM_SPICE_LOSSLESS_IMG_COMPR: "",
1949
    HV_KVM_SPICE_JPEG_IMG_COMPR: "",
1950
    HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR: "",
1951
    HV_KVM_SPICE_STREAMING_VIDEO_DETECTION: "",
1952
    HV_KVM_SPICE_AUDIO_COMPR: True,
1953
    HV_KVM_SPICE_USE_TLS: False,
1954
    HV_KVM_SPICE_TLS_CIPHERS: OPENSSL_CIPHERS,
1955
    HV_KVM_SPICE_USE_VDAGENT: True,
1956
    HV_KVM_FLOPPY_IMAGE_PATH: "",
1957
    HV_CDROM_IMAGE_PATH: "",
1958
    HV_KVM_CDROM2_IMAGE_PATH: "",
1959
    HV_BOOT_ORDER: HT_BO_DISK,
1960
    HV_NIC_TYPE: HT_NIC_PARAVIRTUAL,
1961
    HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
1962
    HV_KVM_CDROM_DISK_TYPE: "",
1963
    HV_USB_MOUSE: "",
1964
    HV_KEYMAP: "",
1965
    HV_MIGRATION_PORT: 8102,
1966
    HV_MIGRATION_BANDWIDTH: 32, # MiB/s
1967
    HV_MIGRATION_DOWNTIME: 30,  # ms
1968
    HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1969
    HV_USE_LOCALTIME: False,
1970
    HV_DISK_CACHE: HT_CACHE_DEFAULT,
1971
    HV_SECURITY_MODEL: HT_SM_NONE,
1972
    HV_SECURITY_DOMAIN: "",
1973
    HV_KVM_FLAG: "",
1974
    HV_VHOST_NET: False,
1975
    HV_KVM_USE_CHROOT: False,
1976
    HV_MEM_PATH: "",
1977
    HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1978
    HV_CPU_MASK: CPU_PINNING_ALL,
1979
    HV_CPU_TYPE: "",
1980
    HV_CPU_CORES: 0,
1981
    HV_CPU_THREADS: 0,
1982
    HV_CPU_SOCKETS: 0,
1983
    HV_SOUNDHW: "",
1984
    HV_USB_DEVICES: "",
1985
    HV_VGA: "",
1986
    HV_KVM_EXTRA: "",
1987
    HV_KVM_MACHINE_VERSION: "",
1988
    },
1989
  HT_FAKE: {},
1990
  HT_CHROOT: {
1991
    HV_INIT_SCRIPT: "/ganeti-chroot",
1992
    },
1993
  HT_LXC: {
1994
    HV_CPU_MASK: "",
1995
    },
1996
  }
1997

    
1998
HVC_GLOBALS = compat.UniqueFrozenset([
1999
  HV_MIGRATION_PORT,
2000
  HV_MIGRATION_BANDWIDTH,
2001
  HV_MIGRATION_MODE,
2002
  ])
2003

    
2004
BEC_DEFAULTS = {
2005
  BE_MINMEM: 128,
2006
  BE_MAXMEM: 128,
2007
  BE_VCPUS: 1,
2008
  BE_AUTO_BALANCE: True,
2009
  BE_ALWAYS_FAILOVER: False,
2010
  BE_SPINDLE_USE: 1,
2011
  }
2012

    
2013
NDC_DEFAULTS = {
2014
  ND_OOB_PROGRAM: "",
2015
  ND_SPINDLE_COUNT: 1,
2016
  ND_EXCLUSIVE_STORAGE: False,
2017
  }
2018

    
2019
NDC_GLOBALS = compat.UniqueFrozenset([
2020
  ND_EXCLUSIVE_STORAGE,
2021
  ])
2022

    
2023
DISK_LD_DEFAULTS = {
2024
  LD_DRBD8: {
2025
    LDP_RESYNC_RATE: CLASSIC_DRBD_SYNC_SPEED,
2026
    LDP_BARRIERS: _autoconf.DRBD_BARRIERS,
2027
    LDP_NO_META_FLUSH: _autoconf.DRBD_NO_META_FLUSH,
2028
    LDP_DEFAULT_METAVG: DEFAULT_VG,
2029
    LDP_DISK_CUSTOM: "",
2030
    LDP_NET_CUSTOM: "",
2031
    LDP_DYNAMIC_RESYNC: False,
2032

    
2033
    # The default values for the DRBD dynamic resync speed algorithm are taken
2034
    # from the drbsetup 8.3.11 man page, except for c-plan-ahead (that we
2035
    # don't need to set to 0, because we have a separate option to enable it)
2036
    # and for c-max-rate, that we cap to the default value for the static resync
2037
    # rate.
2038
    LDP_PLAN_AHEAD: 20, # ds
2039
    LDP_FILL_TARGET: 0, # sectors
2040
    LDP_DELAY_TARGET: 1, # ds
2041
    LDP_MAX_RATE: CLASSIC_DRBD_SYNC_SPEED, # KiB/s
2042
    LDP_MIN_RATE: 4 * 1024, # KiB/s
2043
    },
2044
  LD_LV: {
2045
    LDP_STRIPES: _autoconf.LVM_STRIPECOUNT
2046
    },
2047
  LD_FILE: {},
2048
  LD_BLOCKDEV: {},
2049
  LD_RBD: {
2050
    LDP_POOL: "rbd"
2051
    },
2052
  LD_EXT: {},
2053
  }
2054

    
2055
# readability shortcuts
2056
_LV_DEFAULTS = DISK_LD_DEFAULTS[LD_LV]
2057
_DRBD_DEFAULTS = DISK_LD_DEFAULTS[LD_DRBD8]
2058

    
2059
DISK_DT_DEFAULTS = {
2060
  DT_PLAIN: {
2061
    LV_STRIPES: DISK_LD_DEFAULTS[LD_LV][LDP_STRIPES],
2062
    },
2063
  DT_DRBD8: {
2064
    DRBD_RESYNC_RATE: _DRBD_DEFAULTS[LDP_RESYNC_RATE],
2065
    DRBD_DATA_STRIPES: _LV_DEFAULTS[LDP_STRIPES],
2066
    DRBD_META_STRIPES: _LV_DEFAULTS[LDP_STRIPES],
2067
    DRBD_DISK_BARRIERS: _DRBD_DEFAULTS[LDP_BARRIERS],
2068
    DRBD_META_BARRIERS: _DRBD_DEFAULTS[LDP_NO_META_FLUSH],
2069
    DRBD_DEFAULT_METAVG: _DRBD_DEFAULTS[LDP_DEFAULT_METAVG],
2070
    DRBD_DISK_CUSTOM: _DRBD_DEFAULTS[LDP_DISK_CUSTOM],
2071
    DRBD_NET_CUSTOM: _DRBD_DEFAULTS[LDP_NET_CUSTOM],
2072
    DRBD_DYNAMIC_RESYNC: _DRBD_DEFAULTS[LDP_DYNAMIC_RESYNC],
2073
    DRBD_PLAN_AHEAD: _DRBD_DEFAULTS[LDP_PLAN_AHEAD],
2074
    DRBD_FILL_TARGET: _DRBD_DEFAULTS[LDP_FILL_TARGET],
2075
    DRBD_DELAY_TARGET: _DRBD_DEFAULTS[LDP_DELAY_TARGET],
2076
    DRBD_MAX_RATE: _DRBD_DEFAULTS[LDP_MAX_RATE],
2077
    DRBD_MIN_RATE: _DRBD_DEFAULTS[LDP_MIN_RATE],
2078
    },
2079
  DT_DISKLESS: {},
2080
  DT_FILE: {},
2081
  DT_SHARED_FILE: {},
2082
  DT_BLOCK: {},
2083
  DT_RBD: {
2084
    RBD_POOL: DISK_LD_DEFAULTS[LD_RBD][LDP_POOL]
2085
    },
2086
  DT_EXT: {},
2087
  }
2088

    
2089
# we don't want to export the shortcuts
2090
del _LV_DEFAULTS, _DRBD_DEFAULTS
2091

    
2092
NICC_DEFAULTS = {
2093
  NIC_MODE: NIC_MODE_BRIDGED,
2094
  NIC_LINK: DEFAULT_BRIDGE,
2095
  }
2096

    
2097
# All of the following values are quite arbitrarily - there are no
2098
# "good" defaults, these must be customised per-site
2099
IPOLICY_DEFAULTS = {
2100
  ISPECS_MIN: {
2101
    ISPEC_MEM_SIZE: 128,
2102
    ISPEC_CPU_COUNT: 1,
2103
    ISPEC_DISK_COUNT: 1,
2104
    ISPEC_DISK_SIZE: 1024,
2105
    ISPEC_NIC_COUNT: 1,
2106
    ISPEC_SPINDLE_USE: 1,
2107
    },
2108
  ISPECS_MAX: {
2109
    ISPEC_MEM_SIZE: 32768,
2110
    ISPEC_CPU_COUNT: 8,
2111
    ISPEC_DISK_COUNT: MAX_DISKS,
2112
    ISPEC_DISK_SIZE: 1024 * 1024,
2113
    ISPEC_NIC_COUNT: MAX_NICS,
2114
    ISPEC_SPINDLE_USE: 12,
2115
    },
2116
  ISPECS_STD: {
2117
    ISPEC_MEM_SIZE: 128,
2118
    ISPEC_CPU_COUNT: 1,
2119
    ISPEC_DISK_COUNT: 1,
2120
    ISPEC_DISK_SIZE: 1024,
2121
    ISPEC_NIC_COUNT: 1,
2122
    ISPEC_SPINDLE_USE: 1,
2123
    },
2124
  IPOLICY_DTS: DISK_TEMPLATES,
2125
  IPOLICY_VCPU_RATIO: 4.0,
2126
  IPOLICY_SPINDLE_RATIO: 32.0,
2127
  }
2128

    
2129
MASTER_POOL_SIZE_DEFAULT = 10
2130

    
2131
# Exclusive storage:
2132
# Error margin used to compare physical disks
2133
PART_MARGIN = .01
2134
# Space reserved when creating instance disks
2135
PART_RESERVED = .02
2136

    
2137
CONFD_PROTOCOL_VERSION = 1
2138

    
2139
CONFD_REQ_PING = 0
2140
CONFD_REQ_NODE_ROLE_BYNAME = 1
2141
CONFD_REQ_NODE_PIP_BY_INSTANCE_IP = 2
2142
CONFD_REQ_CLUSTER_MASTER = 3
2143
CONFD_REQ_NODE_PIP_LIST = 4
2144
CONFD_REQ_MC_PIP_LIST = 5
2145
CONFD_REQ_INSTANCES_IPS_LIST = 6
2146
CONFD_REQ_NODE_DRBD = 7
2147
CONFD_REQ_NODE_INSTANCES = 8
2148

    
2149
# Confd request query fields. These are used to narrow down queries.
2150
# These must be strings rather than integers, because json-encoding
2151
# converts them to strings anyway, as they're used as dict-keys.
2152
CONFD_REQQ_LINK = "0"
2153
CONFD_REQQ_IP = "1"
2154
CONFD_REQQ_IPLIST = "2"
2155
CONFD_REQQ_FIELDS = "3"
2156

    
2157
CONFD_REQFIELD_NAME = "0"
2158
CONFD_REQFIELD_IP = "1"
2159
CONFD_REQFIELD_MNODE_PIP = "2"
2160

    
2161
CONFD_REQS = compat.UniqueFrozenset([
2162
  CONFD_REQ_PING,
2163
  CONFD_REQ_NODE_ROLE_BYNAME,
2164
  CONFD_REQ_NODE_PIP_BY_INSTANCE_IP,
2165
  CONFD_REQ_CLUSTER_MASTER,
2166
  CONFD_REQ_NODE_PIP_LIST,
2167
  CONFD_REQ_MC_PIP_LIST,
2168
  CONFD_REQ_INSTANCES_IPS_LIST,
2169
  CONFD_REQ_NODE_DRBD,
2170
  ])
2171

    
2172
CONFD_REPL_STATUS_OK = 0
2173
CONFD_REPL_STATUS_ERROR = 1
2174
CONFD_REPL_STATUS_NOTIMPLEMENTED = 2
2175

    
2176
CONFD_REPL_STATUSES = compat.UniqueFrozenset([
2177
  CONFD_REPL_STATUS_OK,
2178
  CONFD_REPL_STATUS_ERROR,
2179
  CONFD_REPL_STATUS_NOTIMPLEMENTED,
2180
  ])
2181

    
2182
(CONFD_NODE_ROLE_MASTER,
2183
 CONFD_NODE_ROLE_CANDIDATE,
2184
 CONFD_NODE_ROLE_OFFLINE,
2185
 CONFD_NODE_ROLE_DRAINED,
2186
 CONFD_NODE_ROLE_REGULAR,
2187
 ) = range(5)
2188

    
2189
# A few common errors for confd
2190
CONFD_ERROR_UNKNOWN_ENTRY = 1
2191
CONFD_ERROR_INTERNAL = 2
2192
CONFD_ERROR_ARGUMENT = 3
2193

    
2194
# Each request is "salted" by the current timestamp.
2195
# This constants decides how many seconds of skew to accept.
2196
# TODO: make this a default and allow the value to be more configurable
2197
CONFD_MAX_CLOCK_SKEW = 2 * NODE_MAX_CLOCK_SKEW
2198

    
2199
# When we haven't reloaded the config for more than this amount of
2200
# seconds, we force a test to see if inotify is betraying us. Using a
2201
# prime number to ensure we get less chance of 'same wakeup' with
2202
# other processes.
2203
CONFD_CONFIG_RELOAD_TIMEOUT = 17
2204

    
2205
# If we receive more than one update in this amount of microseconds,
2206
# we move to polling every RATELIMIT seconds, rather than relying on
2207
# inotify, to be able to serve more requests.
2208
CONFD_CONFIG_RELOAD_RATELIMIT = 250000
2209

    
2210
# Magic number prepended to all confd queries.
2211
# This allows us to distinguish different types of confd protocols and handle
2212
# them. For example by changing this we can move the whole payload to be
2213
# compressed, or move away from json.
2214
CONFD_MAGIC_FOURCC = "plj0"
2215

    
2216
# By default a confd request is sent to the minimum between this number and all
2217
# MCs. 6 was chosen because even in the case of a disastrous 50% response rate,
2218
# we should have enough answers to be able to compare more than one.
2219
CONFD_DEFAULT_REQ_COVERAGE = 6
2220

    
2221
# Timeout in seconds to expire pending query request in the confd client
2222
# library. We don't actually expect any answer more than 10 seconds after we
2223
# sent a request.
2224
CONFD_CLIENT_EXPIRE_TIMEOUT = 10
2225

    
2226
# Maximum UDP datagram size.
2227
# On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
2228
# On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
2229
#   (assuming we can't use jumbo frames)
2230
# We just set this to 60K, which should be enough
2231
MAX_UDP_DATA_SIZE = 61440
2232

    
2233
# User-id pool minimum/maximum acceptable user-ids.
2234
UIDPOOL_UID_MIN = 0
2235
UIDPOOL_UID_MAX = 2 ** 32 - 1 # Assuming 32 bit user-ids
2236

    
2237
# Name or path of the pgrep command
2238
PGREP = "pgrep"
2239

    
2240
# Name of the node group that gets created at cluster init or upgrade
2241
INITIAL_NODE_GROUP_NAME = "default"
2242

    
2243
# Possible values for NodeGroup.alloc_policy
2244
ALLOC_POLICY_PREFERRED = "preferred"
2245
ALLOC_POLICY_LAST_RESORT = "last_resort"
2246
ALLOC_POLICY_UNALLOCABLE = "unallocable"
2247
VALID_ALLOC_POLICIES = [
2248
  ALLOC_POLICY_PREFERRED,
2249
  ALLOC_POLICY_LAST_RESORT,
2250
  ALLOC_POLICY_UNALLOCABLE,
2251
  ]
2252

    
2253
# Temporary external/shared storage parameters
2254
BLOCKDEV_DRIVER_MANUAL = "manual"
2255

    
2256
# qemu-img path, required for ovfconverter
2257
QEMUIMG_PATH = _autoconf.QEMUIMG_PATH
2258

    
2259
# Whether htools was enabled at compilation time
2260
HTOOLS = _autoconf.HTOOLS
2261
# The hail iallocator
2262
IALLOC_HAIL = "hail"
2263

    
2264
# Fake opcodes for functions that have hooks attached to them via
2265
# backend.RunLocalHooks
2266
FAKE_OP_MASTER_TURNUP = "OP_CLUSTER_IP_TURNUP"
2267
FAKE_OP_MASTER_TURNDOWN = "OP_CLUSTER_IP_TURNDOWN"
2268

    
2269
# SSH key types
2270
SSHK_RSA = "rsa"
2271
SSHK_DSA = "dsa"
2272
SSHK_ALL = compat.UniqueFrozenset([SSHK_RSA, SSHK_DSA])
2273

    
2274
# SSH authorized key types
2275
SSHAK_RSA = "ssh-rsa"
2276
SSHAK_DSS = "ssh-dss"
2277
SSHAK_ALL = compat.UniqueFrozenset([SSHAK_RSA, SSHAK_DSS])
2278

    
2279
# SSH setup
2280
SSHS_CLUSTER_NAME = "cluster_name"
2281
SSHS_SSH_HOST_KEY = "ssh_host_key"
2282
SSHS_SSH_ROOT_KEY = "ssh_root_key"
2283
SSHS_NODE_DAEMON_CERTIFICATE = "node_daemon_certificate"
2284

    
2285
#: Key files for SSH daemon
2286
SSH_DAEMON_KEYFILES = {
2287
  SSHK_RSA: (pathutils.SSH_HOST_RSA_PRIV, pathutils.SSH_HOST_RSA_PUB),
2288
  SSHK_DSA: (pathutils.SSH_HOST_DSA_PRIV, pathutils.SSH_HOST_DSA_PUB),
2289
  }
2290

    
2291
# Node daemon setup
2292
NDS_CLUSTER_NAME = "cluster_name"
2293
NDS_NODE_DAEMON_CERTIFICATE = "node_daemon_certificate"
2294
NDS_SSCONF = "ssconf"
2295
NDS_START_NODE_DAEMON = "start_node_daemon"
2296

    
2297
# Path generating random UUID
2298
RANDOM_UUID_FILE = "/proc/sys/kernel/random/uuid"
2299

    
2300
# Regex string for verifying a UUID
2301
UUID_REGEX = "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
2302

    
2303
# Auto-repair tag prefixes
2304
AUTO_REPAIR_TAG_PREFIX = "ganeti:watcher:autorepair:"
2305
AUTO_REPAIR_TAG_ENABLED = AUTO_REPAIR_TAG_PREFIX
2306
AUTO_REPAIR_TAG_SUSPENDED = AUTO_REPAIR_TAG_ENABLED + "suspend:"
2307
AUTO_REPAIR_TAG_PENDING = AUTO_REPAIR_TAG_PREFIX + "pending:"
2308
AUTO_REPAIR_TAG_RESULT = AUTO_REPAIR_TAG_PREFIX + "result:"
2309

    
2310
# Auto-repair levels
2311
AUTO_REPAIR_FIX_STORAGE = "fix-storage"
2312
AUTO_REPAIR_MIGRATE = "migrate"
2313
AUTO_REPAIR_FAILOVER = "failover"
2314
AUTO_REPAIR_REINSTALL = "reinstall"
2315
AUTO_REPAIR_ALL_TYPES = [
2316
  AUTO_REPAIR_FIX_STORAGE,
2317
  AUTO_REPAIR_MIGRATE,
2318
  AUTO_REPAIR_FAILOVER,
2319
  AUTO_REPAIR_REINSTALL,
2320
]
2321

    
2322
# Auto-repair results
2323
AUTO_REPAIR_SUCCESS = "success"
2324
AUTO_REPAIR_FAILURE = "failure"
2325
AUTO_REPAIR_ENOPERM = "enoperm"
2326
AUTO_REPAIR_ALL_RESULTS = frozenset([
2327
    AUTO_REPAIR_SUCCESS,
2328
    AUTO_REPAIR_FAILURE,
2329
    AUTO_REPAIR_ENOPERM,
2330
])
2331

    
2332
# The version identifier for builtin data collectors
2333
BUILTIN_DATA_COLLECTOR_VERSION = "B"
2334

    
2335
# The source reasons for the change of state of an instance
2336
INSTANCE_REASON_SOURCE_CLI = "cli"
2337
INSTANCE_REASON_SOURCE_RAPI = "rapi"
2338
INSTANCE_REASON_SOURCE_UNKNOWN = "unknown"
2339

    
2340
INSTANCE_REASON_SOURCES = compat.UniqueFrozenset([
2341
  INSTANCE_REASON_SOURCE_CLI,
2342
  INSTANCE_REASON_SOURCE_RAPI,
2343
  INSTANCE_REASON_SOURCE_UNKNOWN,
2344
  ])
2345

    
2346
# Do not re-export imported modules
2347
del re, _vcsversion, _autoconf, socket, pathutils, compat