Statistics
| Branch: | Tag: | Revision:

root / lib / constants.py @ 3697def0

History | View | Annotate | Download (60.1 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
# When the Xen toolstack used is "xl", live migration requires the source host
205
# to connect to the target host via ssh (xl runs this command). We need to pass
206
# the command xl runs some extra info so that it can use Ganeti's key
207
# verification and not fail. Note that this string is incomplete: it must be
208
# filled with the cluster name before being used.
209
XL_SSH_CMD = ("ssh -l %s -oGlobalKnownHostsFile=%s"
210
              " -oUserKnownHostsFile=/dev/null"
211
              " -oCheckHostIp=no -oStrictHostKeyChecking=yes"
212
              " -oHostKeyAlias=%%s") % (SSH_LOGIN_USER,
213
                                        pathutils.SSH_KNOWN_HOSTS_FILE)
214

    
215
KVM_PATH = _autoconf.KVM_PATH
216
KVM_KERNEL = _autoconf.KVM_KERNEL
217
SOCAT_PATH = _autoconf.SOCAT_PATH
218
SOCAT_USE_ESCAPE = _autoconf.SOCAT_USE_ESCAPE
219
SOCAT_USE_COMPRESS = _autoconf.SOCAT_USE_COMPRESS
220
SOCAT_ESCAPE_CODE = "0x1d"
221

    
222
#: Console as SSH command
223
CONS_SSH = "ssh"
224

    
225
#: Console as VNC server
226
CONS_VNC = "vnc"
227

    
228
#: Console as SPICE server
229
CONS_SPICE = "spice"
230

    
231
#: Display a message for console access
232
CONS_MESSAGE = "msg"
233

    
234
#: All console types
235
CONS_ALL = compat.UniqueFrozenset([
236
  CONS_SSH,
237
  CONS_VNC,
238
  CONS_SPICE,
239
  CONS_MESSAGE,
240
  ])
241

    
242
# For RSA keys more bits are better, but they also make operations more
243
# expensive. NIST SP 800-131 recommends a minimum of 2048 bits from the year
244
# 2010 on.
245
RSA_KEY_BITS = 2048
246

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

    
255
# Digest used to sign certificates ("openssl x509" uses SHA1 by default)
256
X509_CERT_SIGN_DIGEST = "SHA1"
257

    
258
# Default validity of certificates in days
259
X509_CERT_DEFAULT_VALIDITY = 365 * 5
260

    
261
# commonName (CN) used in certificates
262
X509_CERT_CN = "ganeti.example.com"
263

    
264
X509_CERT_SIGNATURE_HEADER = "X-Ganeti-Signature"
265

    
266
# Import/export daemon mode
267
IEM_IMPORT = "import"
268
IEM_EXPORT = "export"
269

    
270
# Import/export transport compression
271
IEC_NONE = "none"
272
IEC_GZIP = "gzip"
273
IEC_ALL = compat.UniqueFrozenset([
274
  IEC_NONE,
275
  IEC_GZIP,
276
  ])
277

    
278
IE_CUSTOM_SIZE = "fd"
279

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

    
282
# Import/export I/O
283
# Direct file I/O, equivalent to a shell's I/O redirection using '<' or '>'
284
IEIO_FILE = "file"
285
# Raw block device I/O using "dd"
286
IEIO_RAW_DISK = "raw"
287
# OS definition import/export script
288
IEIO_SCRIPT = "script"
289

    
290
VALUE_DEFAULT = "default"
291
VALUE_AUTO = "auto"
292
VALUE_GENERATE = "generate"
293
VALUE_NONE = "none"
294
VALUE_TRUE = "true"
295
VALUE_FALSE = "false"
296

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

    
300
# hooks-related constants
301
HOOKS_PHASE_PRE = "pre"
302
HOOKS_PHASE_POST = "post"
303
HOOKS_NAME_CFGUPDATE = "config-update"
304
HOOKS_NAME_WATCHER = "watcher"
305
HOOKS_VERSION = 2
306
HOOKS_PATH = "/sbin:/bin:/usr/sbin:/usr/bin"
307

    
308
# hooks subject type (what object type does the LU deal with)
309
HTYPE_CLUSTER = "CLUSTER"
310
HTYPE_NODE = "NODE"
311
HTYPE_GROUP = "GROUP"
312
HTYPE_INSTANCE = "INSTANCE"
313
HTYPE_NETWORK = "NETWORK"
314

    
315
HKR_SKIP = 0
316
HKR_FAIL = 1
317
HKR_SUCCESS = 2
318

    
319
# Storage types
320
ST_FILE = "file"
321
ST_LVM_PV = "lvm-pv"
322
ST_LVM_VG = "lvm-vg"
323

    
324
# Storage fields
325
# first two are valid in LU context only, not passed to backend
326
SF_NODE = "node"
327
SF_TYPE = "type"
328
# and the rest are valid in backend
329
SF_NAME = "name"
330
SF_SIZE = "size"
331
SF_FREE = "free"
332
SF_USED = "used"
333
SF_ALLOCATABLE = "allocatable"
334

    
335
# Storage operations
336
SO_FIX_CONSISTENCY = "fix-consistency"
337

    
338
# Available fields per storage type
339
VALID_STORAGE_FIELDS = compat.UniqueFrozenset([
340
  SF_NAME,
341
  SF_TYPE,
342
  SF_SIZE,
343
  SF_USED,
344
  SF_FREE,
345
  SF_ALLOCATABLE,
346
  ])
347

    
348
VALID_STORAGE_TYPES = compat.UniqueFrozenset([
349
  ST_FILE,
350
  ST_LVM_PV,
351
  ST_LVM_VG,
352
  ])
353

    
354
MODIFIABLE_STORAGE_FIELDS = {
355
  ST_LVM_PV: frozenset([SF_ALLOCATABLE]),
356
  }
357

    
358
VALID_STORAGE_OPERATIONS = {
359
  ST_LVM_VG: frozenset([SO_FIX_CONSISTENCY]),
360
  }
361

    
362
# Local disk status
363
# Note: Code depends on LDS_OKAY < LDS_UNKNOWN < LDS_FAULTY
364
(LDS_OKAY,
365
 LDS_UNKNOWN,
366
 LDS_FAULTY) = range(1, 4)
367

    
368
# disk template types
369
DT_DISKLESS = "diskless"
370
DT_PLAIN = "plain"
371
DT_DRBD8 = "drbd"
372
DT_FILE = "file"
373
DT_SHARED_FILE = "sharedfile"
374
DT_BLOCK = "blockdev"
375
DT_RBD = "rbd"
376
DT_EXT = "ext"
377

    
378
# the set of network-mirrored disk templates
379
DTS_INT_MIRROR = compat.UniqueFrozenset([DT_DRBD8])
380

    
381
# the set of externally-mirrored disk templates (e.g. SAN, NAS)
382
DTS_EXT_MIRROR = compat.UniqueFrozenset([
383
  DT_SHARED_FILE,
384
  DT_BLOCK,
385
  DT_RBD,
386
  DT_EXT,
387
  ])
388

    
389
# the set of non-lvm-based disk templates
390
DTS_NOT_LVM = compat.UniqueFrozenset([
391
  DT_DISKLESS,
392
  DT_FILE,
393
  DT_SHARED_FILE,
394
  DT_BLOCK,
395
  DT_RBD,
396
  DT_EXT,
397
  ])
398

    
399
# the set of disk templates which can be grown
400
DTS_GROWABLE = compat.UniqueFrozenset([
401
  DT_PLAIN,
402
  DT_DRBD8,
403
  DT_FILE,
404
  DT_SHARED_FILE,
405
  DT_RBD,
406
  DT_EXT,
407
  ])
408

    
409
# the set of disk templates that allow adoption
410
DTS_MAY_ADOPT = compat.UniqueFrozenset([
411
  DT_PLAIN,
412
  DT_BLOCK,
413
  ])
414

    
415
# the set of disk templates that *must* use adoption
416
DTS_MUST_ADOPT = compat.UniqueFrozenset([DT_BLOCK])
417

    
418
# the set of disk templates that allow migrations
419
DTS_MIRRORED = frozenset.union(DTS_INT_MIRROR, DTS_EXT_MIRROR)
420

    
421
# the set of file based disk templates
422
DTS_FILEBASED = compat.UniqueFrozenset([
423
  DT_FILE,
424
  DT_SHARED_FILE,
425
  ])
426

    
427
# the set of disk templates that are supported by exclusive_storage
428
DTS_EXCL_STORAGE = compat.UniqueFrozenset([DT_PLAIN])
429

    
430
# templates for which we don't perform checks on free space
431
DTS_NO_FREE_SPACE_CHECK = compat.UniqueFrozenset([
432
  DT_FILE,
433
  DT_SHARED_FILE,
434
  DT_RBD,
435
  DT_EXT,
436
  ])
437

    
438
# logical disk types
439
LD_LV = "lvm"
440
LD_DRBD8 = "drbd8"
441
LD_FILE = "file"
442
LD_BLOCKDEV = "blockdev"
443
LD_RBD = "rbd"
444
LD_EXT = "ext"
445
LOGICAL_DISK_TYPES = compat.UniqueFrozenset([
446
  LD_LV,
447
  LD_DRBD8,
448
  LD_FILE,
449
  LD_BLOCKDEV,
450
  LD_RBD,
451
  LD_EXT,
452
  ])
453

    
454
LDS_BLOCK = compat.UniqueFrozenset([
455
  LD_LV,
456
  LD_DRBD8,
457
  LD_BLOCKDEV,
458
  LD_RBD,
459
  LD_EXT,
460
  ])
461

    
462
# drbd constants
463
DRBD_HMAC_ALG = "md5"
464
DRBD_NET_PROTOCOL = "C"
465
DRBD_STATUS_FILE = "/proc/drbd"
466

    
467
#: Size of DRBD meta block device
468
DRBD_META_SIZE = 128
469

    
470
# drbd barrier types
471
DRBD_B_NONE = "n"
472
DRBD_B_DISK_BARRIERS = "b"
473
DRBD_B_DISK_DRAIN = "d"
474
DRBD_B_DISK_FLUSH = "f"
475

    
476
# Valid barrier combinations: "n" or any non-null subset of "bfd"
477
DRBD_VALID_BARRIER_OPT = compat.UniqueFrozenset([
478
  frozenset([DRBD_B_NONE]),
479
  frozenset([DRBD_B_DISK_BARRIERS]),
480
  frozenset([DRBD_B_DISK_DRAIN]),
481
  frozenset([DRBD_B_DISK_FLUSH]),
482
  frozenset([DRBD_B_DISK_DRAIN, DRBD_B_DISK_FLUSH]),
483
  frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_DRAIN]),
484
  frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_FLUSH]),
485
  frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_FLUSH, DRBD_B_DISK_DRAIN]),
486
  ])
487

    
488
# rbd tool command
489
RBD_CMD = "rbd"
490

    
491
# file backend driver
492
FD_LOOP = "loop"
493
FD_BLKTAP = "blktap"
494

    
495
# the set of drbd-like disk types
496
LDS_DRBD = compat.UniqueFrozenset([LD_DRBD8])
497

    
498
# disk access mode
499
DISK_RDONLY = "ro"
500
DISK_RDWR = "rw"
501
DISK_ACCESS_SET = compat.UniqueFrozenset([DISK_RDONLY, DISK_RDWR])
502

    
503
# disk replacement mode
504
REPLACE_DISK_PRI = "replace_on_primary"    # replace disks on primary
505
REPLACE_DISK_SEC = "replace_on_secondary"  # replace disks on secondary
506
REPLACE_DISK_CHG = "replace_new_secondary" # change secondary node
507
REPLACE_DISK_AUTO = "replace_auto"
508
REPLACE_MODES = compat.UniqueFrozenset([
509
  REPLACE_DISK_PRI,
510
  REPLACE_DISK_SEC,
511
  REPLACE_DISK_CHG,
512
  REPLACE_DISK_AUTO,
513
  ])
514

    
515
# Instance export mode
516
EXPORT_MODE_LOCAL = "local"
517
EXPORT_MODE_REMOTE = "remote"
518
EXPORT_MODES = compat.UniqueFrozenset([
519
  EXPORT_MODE_LOCAL,
520
  EXPORT_MODE_REMOTE,
521
  ])
522

    
523
# instance creation modes
524
INSTANCE_CREATE = "create"
525
INSTANCE_IMPORT = "import"
526
INSTANCE_REMOTE_IMPORT = "remote-import"
527
INSTANCE_CREATE_MODES = compat.UniqueFrozenset([
528
  INSTANCE_CREATE,
529
  INSTANCE_IMPORT,
530
  INSTANCE_REMOTE_IMPORT,
531
  ])
532

    
533
# Remote import/export handshake message and version
534
RIE_VERSION = 0
535
RIE_HANDSHAKE = "Hi, I'm Ganeti"
536

    
537
# Remote import/export certificate validity in seconds
538
RIE_CERT_VALIDITY = 24 * 60 * 60
539

    
540
# Overall timeout for establishing connection
541
RIE_CONNECT_TIMEOUT = 180
542

    
543
# Export only: how long to wait per connection attempt (seconds)
544
RIE_CONNECT_ATTEMPT_TIMEOUT = 20
545

    
546
# Export only: number of attempts to connect
547
RIE_CONNECT_RETRIES = 10
548

    
549
#: Give child process up to 5 seconds to exit after sending a signal
550
CHILD_LINGER_TIMEOUT = 5.0
551

    
552
DISK_TEMPLATES = compat.UniqueFrozenset([
553
  DT_DISKLESS,
554
  DT_PLAIN,
555
  DT_DRBD8,
556
  DT_FILE,
557
  DT_SHARED_FILE,
558
  DT_BLOCK,
559
  DT_RBD,
560
  DT_EXT
561
  ])
562

    
563
FILE_DRIVER = compat.UniqueFrozenset([FD_LOOP, FD_BLKTAP])
564

    
565
# import/export config options
566
INISECT_EXP = "export"
567
INISECT_INS = "instance"
568
INISECT_HYP = "hypervisor"
569
INISECT_BEP = "backend"
570
INISECT_OSP = "os"
571

    
572
# dynamic device modification
573
DDM_ADD = "add"
574
DDM_MODIFY = "modify"
575
DDM_REMOVE = "remove"
576
DDMS_VALUES = compat.UniqueFrozenset([DDM_ADD, DDM_REMOVE])
577
DDMS_VALUES_WITH_MODIFY = (DDMS_VALUES | frozenset([
578
  DDM_MODIFY,
579
  ]))
580
# TODO: DDM_SWAP, DDM_MOVE?
581

    
582
# common exit codes
583
EXIT_SUCCESS = 0
584
EXIT_FAILURE = 1
585
EXIT_NOTCLUSTER = 5
586
EXIT_NOTMASTER = 11
587
EXIT_NODESETUP_ERROR = 12
588
EXIT_CONFIRMATION = 13 # need user confirmation
589

    
590
#: Exit code for query operations with unknown fields
591
EXIT_UNKNOWN_FIELD = 14
592

    
593
# tags
594
TAG_CLUSTER = "cluster"
595
TAG_NODEGROUP = "nodegroup"
596
TAG_NODE = "node"
597
TAG_INSTANCE = "instance"
598
TAG_NETWORK = "network"
599
VALID_TAG_TYPES = compat.UniqueFrozenset([
600
  TAG_CLUSTER,
601
  TAG_NODEGROUP,
602
  TAG_NODE,
603
  TAG_INSTANCE,
604
  TAG_NETWORK,
605
  ])
606
MAX_TAG_LEN = 128
607
MAX_TAGS_PER_OBJ = 4096
608

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

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

    
637
#: Key for job IDs in opcode result
638
JOB_IDS_KEY = "jobs"
639

    
640
# runparts results
641
(RUNPARTS_SKIP,
642
 RUNPARTS_RUN,
643
 RUNPARTS_ERR) = range(3)
644

    
645
RUNPARTS_STATUS = compat.UniqueFrozenset([
646
  RUNPARTS_SKIP,
647
  RUNPARTS_RUN,
648
  RUNPARTS_ERR,
649
  ])
650

    
651
# RPC constants
652
(RPC_ENCODING_NONE,
653
 RPC_ENCODING_ZLIB_BASE64) = range(2)
654

    
655
# Various time constants for the timeout table
656
RPC_TMO_URGENT = 60 # one minute
657
RPC_TMO_FAST = 5 * 60 # five minutes
658
RPC_TMO_NORMAL = 15 * 60 # 15 minutes
659
RPC_TMO_SLOW = 3600 # one hour
660
RPC_TMO_4HRS = 4 * 3600
661
RPC_TMO_1DAY = 86400
662

    
663
# Timeout for connecting to nodes (seconds)
664
RPC_CONNECT_TIMEOUT = 5
665

    
666
# os related constants
667
OS_SCRIPT_CREATE = "create"
668
OS_SCRIPT_IMPORT = "import"
669
OS_SCRIPT_EXPORT = "export"
670
OS_SCRIPT_RENAME = "rename"
671
OS_SCRIPT_VERIFY = "verify"
672
OS_SCRIPTS = compat.UniqueFrozenset([
673
  OS_SCRIPT_CREATE,
674
  OS_SCRIPT_IMPORT,
675
  OS_SCRIPT_EXPORT,
676
  OS_SCRIPT_RENAME,
677
  OS_SCRIPT_VERIFY,
678
  ])
679

    
680
OS_API_FILE = "ganeti_api_version"
681
OS_VARIANTS_FILE = "variants.list"
682
OS_PARAMETERS_FILE = "parameters.list"
683

    
684
OS_VALIDATE_PARAMETERS = "parameters"
685
OS_VALIDATE_CALLS = compat.UniqueFrozenset([OS_VALIDATE_PARAMETERS])
686

    
687
# External Storage (ES) related constants
688
ES_ACTION_CREATE = "create"
689
ES_ACTION_REMOVE = "remove"
690
ES_ACTION_GROW = "grow"
691
ES_ACTION_ATTACH = "attach"
692
ES_ACTION_DETACH = "detach"
693
ES_ACTION_SETINFO = "setinfo"
694
ES_ACTION_VERIFY = "verify"
695

    
696
ES_SCRIPT_CREATE = ES_ACTION_CREATE
697
ES_SCRIPT_REMOVE = ES_ACTION_REMOVE
698
ES_SCRIPT_GROW = ES_ACTION_GROW
699
ES_SCRIPT_ATTACH = ES_ACTION_ATTACH
700
ES_SCRIPT_DETACH = ES_ACTION_DETACH
701
ES_SCRIPT_SETINFO = ES_ACTION_SETINFO
702
ES_SCRIPT_VERIFY = ES_ACTION_VERIFY
703
ES_SCRIPTS = frozenset([
704
  ES_SCRIPT_CREATE,
705
  ES_SCRIPT_REMOVE,
706
  ES_SCRIPT_GROW,
707
  ES_SCRIPT_ATTACH,
708
  ES_SCRIPT_DETACH,
709
  ES_SCRIPT_SETINFO,
710
  ES_SCRIPT_VERIFY
711
  ])
712

    
713
ES_PARAMETERS_FILE = "parameters.list"
714

    
715
# ssh constants
716
SSH = "ssh"
717
SCP = "scp"
718

    
719
# reboot types
720
INSTANCE_REBOOT_SOFT = "soft"
721
INSTANCE_REBOOT_HARD = "hard"
722
INSTANCE_REBOOT_FULL = "full"
723

    
724
REBOOT_TYPES = compat.UniqueFrozenset([
725
  INSTANCE_REBOOT_SOFT,
726
  INSTANCE_REBOOT_HARD,
727
  INSTANCE_REBOOT_FULL,
728
  ])
729

    
730
# instance reboot behaviors
731
INSTANCE_REBOOT_ALLOWED = "reboot"
732
INSTANCE_REBOOT_EXIT = "exit"
733

    
734
REBOOT_BEHAVIORS = compat.UniqueFrozenset([
735
  INSTANCE_REBOOT_ALLOWED,
736
  INSTANCE_REBOOT_EXIT,
737
  ])
738

    
739
VTYPE_STRING = "string"
740
VTYPE_MAYBE_STRING = "maybe-string"
741
VTYPE_BOOL = "bool"
742
VTYPE_SIZE = "size" # size, in MiBs
743
VTYPE_INT = "int"
744
ENFORCEABLE_TYPES = compat.UniqueFrozenset([
745
  VTYPE_STRING,
746
  VTYPE_MAYBE_STRING,
747
  VTYPE_BOOL,
748
  VTYPE_SIZE,
749
  VTYPE_INT,
750
  ])
751

    
752
# Constant representing that the user does not specify any IP version
753
IFACE_NO_IP_VERSION_SPECIFIED = 0
754

    
755
VALID_SERIAL_SPEEDS = compat.UniqueFrozenset([
756
  75,
757
  110,
758
  300,
759
  600,
760
  1200,
761
  1800,
762
  2400,
763
  4800,
764
  9600,
765
  14400,
766
  19200,
767
  28800,
768
  38400,
769
  57600,
770
  115200,
771
  230400,
772
  345600,
773
  460800,
774
  ])
775

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

    
844

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

    
914
HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
915

    
916
HVS_PARAMETER_TITLES = {
917
  HV_ACPI: "ACPI",
918
  HV_BOOT_ORDER: "Boot_order",
919
  HV_CDROM_IMAGE_PATH: "CDROM_image_path",
920
  HV_DISK_TYPE: "Disk_type",
921
  HV_INITRD_PATH: "Initrd_path",
922
  HV_KERNEL_PATH: "Kernel_path",
923
  HV_NIC_TYPE: "NIC_type",
924
  HV_PAE: "PAE",
925
  HV_VNC_BIND_ADDRESS: "VNC_bind_address",
926
  HV_PASSTHROUGH: "pci_pass",
927
  HV_CPU_TYPE: "cpu_type",
928
  }
929

    
930
# Migration statuses
931
HV_MIGRATION_COMPLETED = "completed"
932
HV_MIGRATION_ACTIVE = "active"
933
HV_MIGRATION_FAILED = "failed"
934
HV_MIGRATION_CANCELLED = "cancelled"
935

    
936
HV_MIGRATION_VALID_STATUSES = compat.UniqueFrozenset([
937
  HV_MIGRATION_COMPLETED,
938
  HV_MIGRATION_ACTIVE,
939
  HV_MIGRATION_FAILED,
940
  HV_MIGRATION_CANCELLED,
941
  ])
942

    
943
HV_MIGRATION_FAILED_STATUSES = compat.UniqueFrozenset([
944
  HV_MIGRATION_FAILED,
945
  HV_MIGRATION_CANCELLED,
946
  ])
947

    
948
# KVM-specific statuses
949
HV_KVM_MIGRATION_VALID_STATUSES = HV_MIGRATION_VALID_STATUSES
950

    
951
# Node info keys
952
HV_NODEINFO_KEY_VERSION = "hv_version"
953

    
954
# Hypervisor state
955
HVST_MEMORY_TOTAL = "mem_total"
956
HVST_MEMORY_NODE = "mem_node"
957
HVST_MEMORY_HV = "mem_hv"
958
HVST_CPU_TOTAL = "cpu_total"
959
HVST_CPU_NODE = "cpu_node"
960

    
961
HVST_DEFAULTS = {
962
  HVST_MEMORY_TOTAL: 0,
963
  HVST_MEMORY_NODE: 0,
964
  HVST_MEMORY_HV: 0,
965
  HVST_CPU_TOTAL: 1,
966
  HVST_CPU_NODE: 1,
967
  }
968

    
969
HVSTS_PARAMETER_TYPES = {
970
  HVST_MEMORY_TOTAL: VTYPE_INT,
971
  HVST_MEMORY_NODE: VTYPE_INT,
972
  HVST_MEMORY_HV: VTYPE_INT,
973
  HVST_CPU_TOTAL: VTYPE_INT,
974
  HVST_CPU_NODE: VTYPE_INT,
975
  }
976

    
977
HVSTS_PARAMETERS = frozenset(HVSTS_PARAMETER_TYPES.keys())
978

    
979
# Disk state
980
DS_DISK_TOTAL = "disk_total"
981
DS_DISK_RESERVED = "disk_reserved"
982
DS_DISK_OVERHEAD = "disk_overhead"
983

    
984
DS_DEFAULTS = {
985
  DS_DISK_TOTAL: 0,
986
  DS_DISK_RESERVED: 0,
987
  DS_DISK_OVERHEAD: 0,
988
  }
989

    
990
DSS_PARAMETER_TYPES = {
991
  DS_DISK_TOTAL: VTYPE_INT,
992
  DS_DISK_RESERVED: VTYPE_INT,
993
  DS_DISK_OVERHEAD: VTYPE_INT,
994
  }
995

    
996
DSS_PARAMETERS = frozenset(DSS_PARAMETER_TYPES.keys())
997
DS_VALID_TYPES = compat.UniqueFrozenset([LD_LV])
998

    
999
# Backend parameter names
1000
BE_MEMORY = "memory" # deprecated and replaced by max and min mem
1001
BE_MAXMEM = "maxmem"
1002
BE_MINMEM = "minmem"
1003
BE_VCPUS = "vcpus"
1004
BE_AUTO_BALANCE = "auto_balance"
1005
BE_ALWAYS_FAILOVER = "always_failover"
1006
BE_SPINDLE_USE = "spindle_use"
1007

    
1008
BES_PARAMETER_TYPES = {
1009
  BE_MAXMEM: VTYPE_SIZE,
1010
  BE_MINMEM: VTYPE_SIZE,
1011
  BE_VCPUS: VTYPE_INT,
1012
  BE_AUTO_BALANCE: VTYPE_BOOL,
1013
  BE_ALWAYS_FAILOVER: VTYPE_BOOL,
1014
  BE_SPINDLE_USE: VTYPE_INT,
1015
  }
1016

    
1017
BES_PARAMETER_TITLES = {
1018
  BE_AUTO_BALANCE: "Auto_balance",
1019
  BE_MAXMEM: "ConfigMaxMem",
1020
  BE_MINMEM: "ConfigMinMem",
1021
  BE_VCPUS: "ConfigVCPUs",
1022
  }
1023

    
1024
BES_PARAMETER_COMPAT = {
1025
  BE_MEMORY: VTYPE_SIZE,
1026
  }
1027
BES_PARAMETER_COMPAT.update(BES_PARAMETER_TYPES)
1028

    
1029
BES_PARAMETERS = frozenset(BES_PARAMETER_TYPES.keys())
1030

    
1031
# instance specs
1032
ISPEC_MEM_SIZE = "memory-size"
1033
ISPEC_CPU_COUNT = "cpu-count"
1034
ISPEC_DISK_COUNT = "disk-count"
1035
ISPEC_DISK_SIZE = "disk-size"
1036
ISPEC_NIC_COUNT = "nic-count"
1037
ISPEC_SPINDLE_USE = "spindle-use"
1038

    
1039
ISPECS_PARAMETER_TYPES = {
1040
  ISPEC_MEM_SIZE: VTYPE_INT,
1041
  ISPEC_CPU_COUNT: VTYPE_INT,
1042
  ISPEC_DISK_COUNT: VTYPE_INT,
1043
  ISPEC_DISK_SIZE: VTYPE_INT,
1044
  ISPEC_NIC_COUNT: VTYPE_INT,
1045
  ISPEC_SPINDLE_USE: VTYPE_INT,
1046
  }
1047

    
1048
ISPECS_PARAMETERS = frozenset(ISPECS_PARAMETER_TYPES.keys())
1049

    
1050
ISPECS_MIN = "min"
1051
ISPECS_MAX = "max"
1052
ISPECS_STD = "std"
1053
IPOLICY_DTS = "disk-templates"
1054
IPOLICY_VCPU_RATIO = "vcpu-ratio"
1055
IPOLICY_SPINDLE_RATIO = "spindle-ratio"
1056

    
1057
IPOLICY_ISPECS = compat.UniqueFrozenset([
1058
  ISPECS_MIN,
1059
  ISPECS_MAX,
1060
  ISPECS_STD,
1061
  ])
1062

    
1063
IPOLICY_PARAMETERS = compat.UniqueFrozenset([
1064
  IPOLICY_VCPU_RATIO,
1065
  IPOLICY_SPINDLE_RATIO,
1066
  ])
1067

    
1068
IPOLICY_ALL_KEYS = (IPOLICY_ISPECS |
1069
                    IPOLICY_PARAMETERS |
1070
                    frozenset([IPOLICY_DTS]))
1071

    
1072
# Node parameter names
1073
ND_OOB_PROGRAM = "oob_program"
1074
ND_SPINDLE_COUNT = "spindle_count"
1075
ND_EXCLUSIVE_STORAGE = "exclusive_storage"
1076

    
1077
NDS_PARAMETER_TYPES = {
1078
  ND_OOB_PROGRAM: VTYPE_STRING,
1079
  ND_SPINDLE_COUNT: VTYPE_INT,
1080
  ND_EXCLUSIVE_STORAGE: VTYPE_BOOL,
1081
  }
1082

    
1083
NDS_PARAMETERS = frozenset(NDS_PARAMETER_TYPES.keys())
1084

    
1085
NDS_PARAMETER_TITLES = {
1086
  ND_OOB_PROGRAM: "OutOfBandProgram",
1087
  ND_SPINDLE_COUNT: "SpindleCount",
1088
  ND_EXCLUSIVE_STORAGE: "ExclusiveStorage",
1089
  }
1090

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

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

    
1161
DISK_DT_PARAMETERS = frozenset(DISK_DT_TYPES.keys())
1162

    
1163
# OOB supported commands
1164
OOB_POWER_ON = "power-on"
1165
OOB_POWER_OFF = "power-off"
1166
OOB_POWER_CYCLE = "power-cycle"
1167
OOB_POWER_STATUS = "power-status"
1168
OOB_HEALTH = "health"
1169

    
1170
OOB_COMMANDS = compat.UniqueFrozenset([
1171
  OOB_POWER_ON,
1172
  OOB_POWER_OFF,
1173
  OOB_POWER_CYCLE,
1174
  OOB_POWER_STATUS,
1175
  OOB_HEALTH,
1176
  ])
1177

    
1178
OOB_POWER_STATUS_POWERED = "powered"
1179

    
1180
OOB_TIMEOUT = 60 # 60 seconds
1181
OOB_POWER_DELAY = 2.0 # 2 seconds
1182

    
1183
OOB_STATUS_OK = "OK"
1184
OOB_STATUS_WARNING = "WARNING"
1185
OOB_STATUS_CRITICAL = "CRITICAL"
1186
OOB_STATUS_UNKNOWN = "UNKNOWN"
1187

    
1188
OOB_STATUSES = compat.UniqueFrozenset([
1189
  OOB_STATUS_OK,
1190
  OOB_STATUS_WARNING,
1191
  OOB_STATUS_CRITICAL,
1192
  OOB_STATUS_UNKNOWN,
1193
  ])
1194

    
1195
# Instance Parameters Profile
1196
PP_DEFAULT = "default"
1197

    
1198
# NIC_* constants are used inside the ganeti config
1199
NIC_MODE = "mode"
1200
NIC_LINK = "link"
1201

    
1202
NIC_MODE_BRIDGED = "bridged"
1203
NIC_MODE_ROUTED = "routed"
1204
NIC_MODE_OVS = "openvswitch"
1205
NIC_IP_POOL = "pool"
1206

    
1207
NIC_VALID_MODES = compat.UniqueFrozenset([
1208
  NIC_MODE_BRIDGED,
1209
  NIC_MODE_ROUTED,
1210
  NIC_MODE_OVS,
1211
  ])
1212

    
1213
RESERVE_ACTION = "reserve"
1214
RELEASE_ACTION = "release"
1215

    
1216
# An extra description of the network.
1217
# Can be used by hooks/kvm-vif-bridge to apply different rules
1218
NETWORK_TYPE_PRIVATE = "private"
1219
NETWORK_TYPE_PUBLIC = "public"
1220

    
1221
NETWORK_VALID_TYPES = compat.UniqueFrozenset([
1222
  NETWORK_TYPE_PRIVATE,
1223
  NETWORK_TYPE_PUBLIC,
1224
  ])
1225

    
1226
NICS_PARAMETER_TYPES = {
1227
  NIC_MODE: VTYPE_STRING,
1228
  NIC_LINK: VTYPE_STRING,
1229
  }
1230

    
1231
NICS_PARAMETERS = frozenset(NICS_PARAMETER_TYPES.keys())
1232

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

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

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

    
1282
VNC_BASE_PORT = 5900
1283
VNC_DEFAULT_BIND_ADDRESS = IP4_ADDRESS_ANY
1284

    
1285
# NIC types
1286
HT_NIC_RTL8139 = "rtl8139"
1287
HT_NIC_NE2K_PCI = "ne2k_pci"
1288
HT_NIC_NE2K_ISA = "ne2k_isa"
1289
HT_NIC_I82551 = "i82551"
1290
HT_NIC_I85557B = "i82557b"
1291
HT_NIC_I8259ER = "i82559er"
1292
HT_NIC_PCNET = "pcnet"
1293
HT_NIC_E1000 = "e1000"
1294
HT_NIC_PARAVIRTUAL = HT_DISK_PARAVIRTUAL = "paravirtual"
1295

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

    
1315
# Disk types
1316
HT_DISK_IOEMU = "ioemu"
1317
HT_DISK_IDE = "ide"
1318
HT_DISK_SCSI = "scsi"
1319
HT_DISK_SD = "sd"
1320
HT_DISK_MTD = "mtd"
1321
HT_DISK_PFLASH = "pflash"
1322

    
1323
HT_CACHE_DEFAULT = "default"
1324
HT_CACHE_NONE = "none"
1325
HT_CACHE_WTHROUGH = "writethrough"
1326
HT_CACHE_WBACK = "writeback"
1327
HT_VALID_CACHE_TYPES = compat.UniqueFrozenset([
1328
  HT_CACHE_DEFAULT,
1329
  HT_CACHE_NONE,
1330
  HT_CACHE_WTHROUGH,
1331
  HT_CACHE_WBACK,
1332
  ])
1333

    
1334
HT_HVM_VALID_DISK_TYPES = compat.UniqueFrozenset([
1335
  HT_DISK_PARAVIRTUAL,
1336
  HT_DISK_IOEMU,
1337
  ])
1338
HT_KVM_VALID_DISK_TYPES = compat.UniqueFrozenset([
1339
  HT_DISK_PARAVIRTUAL,
1340
  HT_DISK_IDE,
1341
  HT_DISK_SCSI,
1342
  HT_DISK_SD,
1343
  HT_DISK_MTD,
1344
  HT_DISK_PFLASH,
1345
  ])
1346

    
1347
# Mouse types:
1348
HT_MOUSE_MOUSE = "mouse"
1349
HT_MOUSE_TABLET = "tablet"
1350

    
1351
HT_KVM_VALID_MOUSE_TYPES = compat.UniqueFrozenset([
1352
  HT_MOUSE_MOUSE,
1353
  HT_MOUSE_TABLET,
1354
  ])
1355

    
1356
# Boot order
1357
HT_BO_FLOPPY = "floppy"
1358
HT_BO_CDROM = "cdrom"
1359
HT_BO_DISK = "disk"
1360
HT_BO_NETWORK = "network"
1361

    
1362
HT_KVM_VALID_BO_TYPES = compat.UniqueFrozenset([
1363
  HT_BO_FLOPPY,
1364
  HT_BO_CDROM,
1365
  HT_BO_DISK,
1366
  HT_BO_NETWORK,
1367
  ])
1368

    
1369
# SPICE lossless image compression options
1370
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ = "auto_glz"
1371
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ = "auto_lz"
1372
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC = "quic"
1373
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ = "glz"
1374
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ = "lz"
1375
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF = "off"
1376

    
1377
HT_KVM_SPICE_VALID_LOSSLESS_IMG_COMPR_OPTIONS = compat.UniqueFrozenset([
1378
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ,
1379
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ,
1380
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC,
1381
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ,
1382
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ,
1383
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF,
1384
  ])
1385

    
1386
# SPICE lossy image compression options (valid for both jpeg and zlib-glz)
1387
HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO = "auto"
1388
HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER = "never"
1389
HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS = "always"
1390

    
1391
HT_KVM_SPICE_VALID_LOSSY_IMG_COMPR_OPTIONS = compat.UniqueFrozenset([
1392
  HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO,
1393
  HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER,
1394
  HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS,
1395
  ])
1396

    
1397
# SPICE video stream detection
1398
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF = "off"
1399
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL = "all"
1400
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER = "filter"
1401

    
1402
HT_KVM_SPICE_VALID_VIDEO_STREAM_DETECTION_OPTIONS = compat.UniqueFrozenset([
1403
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF,
1404
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL,
1405
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER,
1406
  ])
1407

    
1408
# Security models
1409
HT_SM_NONE = "none"
1410
HT_SM_USER = "user"
1411
HT_SM_POOL = "pool"
1412

    
1413
HT_KVM_VALID_SM_TYPES = compat.UniqueFrozenset([
1414
  HT_SM_NONE,
1415
  HT_SM_USER,
1416
  HT_SM_POOL,
1417
  ])
1418

    
1419
# Kvm flag values
1420
HT_KVM_ENABLED = "enabled"
1421
HT_KVM_DISABLED = "disabled"
1422

    
1423
HT_KVM_FLAG_VALUES = compat.UniqueFrozenset([HT_KVM_ENABLED, HT_KVM_DISABLED])
1424

    
1425
# Migration type
1426
HT_MIGRATION_LIVE = "live"
1427
HT_MIGRATION_NONLIVE = "non-live"
1428
HT_MIGRATION_MODES = compat.UniqueFrozenset([
1429
  HT_MIGRATION_LIVE,
1430
  HT_MIGRATION_NONLIVE,
1431
  ])
1432

    
1433
# Cluster Verify steps
1434
VERIFY_NPLUSONE_MEM = "nplusone_mem"
1435
VERIFY_OPTIONAL_CHECKS = compat.UniqueFrozenset([VERIFY_NPLUSONE_MEM])
1436

    
1437
# Cluster Verify error classes
1438
CV_TCLUSTER = "cluster"
1439
CV_TGROUP = "group"
1440
CV_TNODE = "node"
1441
CV_TINSTANCE = "instance"
1442

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

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

    
1560
CV_ALL_ECODES_STRINGS = \
1561
  compat.UniqueFrozenset(estr for (_, estr, _) in CV_ALL_ECODES)
1562

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

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

    
1608
# Admin states
1609
ADMINST_UP = "up"
1610
ADMINST_DOWN = "down"
1611
ADMINST_OFFLINE = "offline"
1612
ADMINST_ALL = compat.UniqueFrozenset([
1613
  ADMINST_UP,
1614
  ADMINST_DOWN,
1615
  ADMINST_OFFLINE,
1616
  ])
1617

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

    
1632
# SSL certificate check constants (in days)
1633
SSL_CERT_EXPIRATION_WARN = 30
1634
SSL_CERT_EXPIRATION_ERROR = 7
1635

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

    
1659
IALLOCATOR_NEVAC_PRI = "primary-only"
1660
IALLOCATOR_NEVAC_SEC = "secondary-only"
1661
IALLOCATOR_NEVAC_ALL = "all"
1662
IALLOCATOR_NEVAC_MODES = compat.UniqueFrozenset([
1663
  IALLOCATOR_NEVAC_PRI,
1664
  IALLOCATOR_NEVAC_SEC,
1665
  IALLOCATOR_NEVAC_ALL,
1666
  ])
1667

    
1668
# Node evacuation
1669
NODE_EVAC_PRI = "primary-only"
1670
NODE_EVAC_SEC = "secondary-only"
1671
NODE_EVAC_ALL = "all"
1672
NODE_EVAC_MODES = compat.UniqueFrozenset([
1673
  NODE_EVAC_PRI,
1674
  NODE_EVAC_SEC,
1675
  NODE_EVAC_ALL,
1676
  ])
1677

    
1678
# Job queue
1679
JOB_QUEUE_VERSION = 1
1680
JOB_QUEUE_SIZE_HARD_LIMIT = 5000
1681

    
1682
JOB_ID_TEMPLATE = r"\d+"
1683
JOB_FILE_RE = re.compile(r"^job-(%s)$" % JOB_ID_TEMPLATE)
1684

    
1685
# unchanged job return
1686
JOB_NOTCHANGED = "nochange"
1687

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

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

    
1726
# OpCode priority
1727
OP_PRIO_LOWEST = +19
1728
OP_PRIO_HIGHEST = -20
1729

    
1730
OP_PRIO_LOW = +10
1731
OP_PRIO_NORMAL = 0
1732
OP_PRIO_HIGH = -10
1733

    
1734
OP_PRIO_SUBMIT_VALID = compat.UniqueFrozenset([
1735
  OP_PRIO_LOW,
1736
  OP_PRIO_NORMAL,
1737
  OP_PRIO_HIGH,
1738
  ])
1739

    
1740
OP_PRIO_DEFAULT = OP_PRIO_NORMAL
1741

    
1742
# Lock recalculate mode
1743
LOCKS_REPLACE = "replace"
1744
LOCKS_APPEND = "append"
1745

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

    
1755
# Execution log types
1756
ELOG_MESSAGE = "message"
1757
ELOG_REMOTE_IMPORT = "remote-import"
1758
ELOG_JQUEUE_TEST = "jqueue-test"
1759

    
1760
# /etc/hosts modification
1761
ETC_HOSTS_ADD = "add"
1762
ETC_HOSTS_REMOVE = "remove"
1763

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

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

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

    
1801
#: List of resources which can be queried using Local UniX Interface
1802
QR_VIA_LUXI = QR_VIA_OP.union([
1803
  QR_LOCK,
1804
  QR_JOB,
1805
  ])
1806

    
1807
#: List of resources which can be queried using RAPI
1808
QR_VIA_RAPI = QR_VIA_LUXI
1809

    
1810
# Query field types
1811
QFT_UNKNOWN = "unknown"
1812
QFT_TEXT = "text"
1813
QFT_BOOL = "bool"
1814
QFT_NUMBER = "number"
1815
QFT_UNIT = "unit"
1816
QFT_TIMESTAMP = "timestamp"
1817
QFT_OTHER = "other"
1818

    
1819
#: All query field types
1820
QFT_ALL = compat.UniqueFrozenset([
1821
  QFT_UNKNOWN,
1822
  QFT_TEXT,
1823
  QFT_BOOL,
1824
  QFT_NUMBER,
1825
  QFT_UNIT,
1826
  QFT_TIMESTAMP,
1827
  QFT_OTHER,
1828
  ])
1829

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

    
1845
RS_ALL = compat.UniqueFrozenset([
1846
  RS_NORMAL,
1847
  RS_UNKNOWN,
1848
  RS_NODATA,
1849
  RS_UNAVAIL,
1850
  RS_OFFLINE,
1851
  ])
1852

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

    
1861
# max dynamic devices
1862
MAX_NICS = 8
1863
MAX_DISKS = 16
1864

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

    
1892
SS_FILE_PERMS = 0444
1893

    
1894
# cluster wide default parameters
1895
DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM
1896

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

    
2002
HVC_GLOBALS = compat.UniqueFrozenset([
2003
  HV_MIGRATION_PORT,
2004
  HV_MIGRATION_BANDWIDTH,
2005
  HV_MIGRATION_MODE,
2006
  ])
2007

    
2008
BEC_DEFAULTS = {
2009
  BE_MINMEM: 128,
2010
  BE_MAXMEM: 128,
2011
  BE_VCPUS: 1,
2012
  BE_AUTO_BALANCE: True,
2013
  BE_ALWAYS_FAILOVER: False,
2014
  BE_SPINDLE_USE: 1,
2015
  }
2016

    
2017
NDC_DEFAULTS = {
2018
  ND_OOB_PROGRAM: "",
2019
  ND_SPINDLE_COUNT: 1,
2020
  ND_EXCLUSIVE_STORAGE: False,
2021
  }
2022

    
2023
NDC_GLOBALS = compat.UniqueFrozenset([
2024
  ND_EXCLUSIVE_STORAGE,
2025
  ])
2026

    
2027
DISK_LD_DEFAULTS = {
2028
  LD_DRBD8: {
2029
    LDP_RESYNC_RATE: CLASSIC_DRBD_SYNC_SPEED,
2030
    LDP_BARRIERS: _autoconf.DRBD_BARRIERS,
2031
    LDP_NO_META_FLUSH: _autoconf.DRBD_NO_META_FLUSH,
2032
    LDP_DEFAULT_METAVG: DEFAULT_VG,
2033
    LDP_DISK_CUSTOM: "",
2034
    LDP_NET_CUSTOM: "",
2035
    LDP_DYNAMIC_RESYNC: False,
2036

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

    
2059
# readability shortcuts
2060
_LV_DEFAULTS = DISK_LD_DEFAULTS[LD_LV]
2061
_DRBD_DEFAULTS = DISK_LD_DEFAULTS[LD_DRBD8]
2062

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

    
2093
# we don't want to export the shortcuts
2094
del _LV_DEFAULTS, _DRBD_DEFAULTS
2095

    
2096
NICC_DEFAULTS = {
2097
  NIC_MODE: NIC_MODE_BRIDGED,
2098
  NIC_LINK: DEFAULT_BRIDGE,
2099
  }
2100

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

    
2133
MASTER_POOL_SIZE_DEFAULT = 10
2134

    
2135
# Exclusive storage:
2136
# Error margin used to compare physical disks
2137
PART_MARGIN = .01
2138
# Space reserved when creating instance disks
2139
PART_RESERVED = .02
2140

    
2141
CONFD_PROTOCOL_VERSION = 1
2142

    
2143
CONFD_REQ_PING = 0
2144
CONFD_REQ_NODE_ROLE_BYNAME = 1
2145
CONFD_REQ_NODE_PIP_BY_INSTANCE_IP = 2
2146
CONFD_REQ_CLUSTER_MASTER = 3
2147
CONFD_REQ_NODE_PIP_LIST = 4
2148
CONFD_REQ_MC_PIP_LIST = 5
2149
CONFD_REQ_INSTANCES_IPS_LIST = 6
2150
CONFD_REQ_NODE_DRBD = 7
2151

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

    
2160
CONFD_REQFIELD_NAME = "0"
2161
CONFD_REQFIELD_IP = "1"
2162
CONFD_REQFIELD_MNODE_PIP = "2"
2163

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

    
2175
CONFD_REPL_STATUS_OK = 0
2176
CONFD_REPL_STATUS_ERROR = 1
2177
CONFD_REPL_STATUS_NOTIMPLEMENTED = 2
2178

    
2179
CONFD_REPL_STATUSES = compat.UniqueFrozenset([
2180
  CONFD_REPL_STATUS_OK,
2181
  CONFD_REPL_STATUS_ERROR,
2182
  CONFD_REPL_STATUS_NOTIMPLEMENTED,
2183
  ])
2184

    
2185
(CONFD_NODE_ROLE_MASTER,
2186
 CONFD_NODE_ROLE_CANDIDATE,
2187
 CONFD_NODE_ROLE_OFFLINE,
2188
 CONFD_NODE_ROLE_DRAINED,
2189
 CONFD_NODE_ROLE_REGULAR,
2190
 ) = range(5)
2191

    
2192
# A few common errors for confd
2193
CONFD_ERROR_UNKNOWN_ENTRY = 1
2194
CONFD_ERROR_INTERNAL = 2
2195
CONFD_ERROR_ARGUMENT = 3
2196

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

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

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

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

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

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

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

    
2236
# User-id pool minimum/maximum acceptable user-ids.
2237
UIDPOOL_UID_MIN = 0
2238
UIDPOOL_UID_MAX = 2 ** 32 - 1 # Assuming 32 bit user-ids
2239

    
2240
# Name or path of the pgrep command
2241
PGREP = "pgrep"
2242

    
2243
# Name of the node group that gets created at cluster init or upgrade
2244
INITIAL_NODE_GROUP_NAME = "default"
2245

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

    
2256
# Temporary external/shared storage parameters
2257
BLOCKDEV_DRIVER_MANUAL = "manual"
2258

    
2259
# qemu-img path, required for ovfconverter
2260
QEMUIMG_PATH = _autoconf.QEMUIMG_PATH
2261

    
2262
# Whether htools was enabled at compilation time
2263
HTOOLS = _autoconf.HTOOLS
2264
# The hail iallocator
2265
IALLOC_HAIL = "hail"
2266

    
2267
# Fake opcodes for functions that have hooks attached to them via
2268
# backend.RunLocalHooks
2269
FAKE_OP_MASTER_TURNUP = "OP_CLUSTER_IP_TURNUP"
2270
FAKE_OP_MASTER_TURNDOWN = "OP_CLUSTER_IP_TURNDOWN"
2271

    
2272
# SSH key types
2273
SSHK_RSA = "rsa"
2274
SSHK_DSA = "dsa"
2275
SSHK_ALL = compat.UniqueFrozenset([SSHK_RSA, SSHK_DSA])
2276

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

    
2282
# SSH setup
2283
SSHS_CLUSTER_NAME = "cluster_name"
2284
SSHS_SSH_HOST_KEY = "ssh_host_key"
2285
SSHS_SSH_ROOT_KEY = "ssh_root_key"
2286
SSHS_NODE_DAEMON_CERTIFICATE = "node_daemon_certificate"
2287

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

    
2294
# Node daemon setup
2295
NDS_CLUSTER_NAME = "cluster_name"
2296
NDS_NODE_DAEMON_CERTIFICATE = "node_daemon_certificate"
2297
NDS_SSCONF = "ssconf"
2298
NDS_START_NODE_DAEMON = "start_node_daemon"
2299

    
2300
# Path generating random UUID
2301
RANDOM_UUID_FILE = "/proc/sys/kernel/random/uuid"
2302

    
2303
# Regex string for verifying a UUID
2304
UUID_REGEX = "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
2305

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

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

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

    
2335
# The version identifier for builtin data collectors
2336
BUILTIN_DATA_COLLECTOR_VERSION = "B"
2337

    
2338
# Do not re-export imported modules
2339
del re, _vcsversion, _autoconf, socket, pathutils, compat