Statistics
| Branch: | Tag: | Revision:

root / lib / constants.py @ 3e77a36c

History | View | Annotate | Download (59.3 kB)

1
#
2
#
3

    
4
# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 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_LOGFILES = {
170
  NODED: pathutils.GetLogFilename("node-daemon"),
171
  CONFD: pathutils.GetLogFilename("conf-daemon"),
172
  RAPI: pathutils.GetLogFilename("rapi-daemon"),
173
  MASTERD: pathutils.GetLogFilename("master-daemon"),
174
  }
175

    
176
DEV_CONSOLE = "/dev/console"
177

    
178
PROC_MOUNTS = "/proc/mounts"
179

    
180
# Local UniX Interface related constants
181
LUXI_EOM = "\3"
182
LUXI_VERSION = CONFIG_VERSION
183

    
184
# one of "no", "yes", "only"
185
SYSLOG_USAGE = _autoconf.SYSLOG_USAGE
186
SYSLOG_NO = "no"
187
SYSLOG_YES = "yes"
188
SYSLOG_ONLY = "only"
189
SYSLOG_SOCKET = "/dev/log"
190

    
191
EXPORT_CONF_FILE = "config.ini"
192

    
193
XEN_BOOTLOADER = _autoconf.XEN_BOOTLOADER
194
XEN_KERNEL = _autoconf.XEN_KERNEL
195
XEN_INITRD = _autoconf.XEN_INITRD
196
XEN_CMD_XM = "xm"
197
XEN_CMD_XL = "xl"
198
# FIXME: This will be made configurable using hvparams in Ganeti 2.7
199
XEN_CMD = _autoconf.XEN_CMD
200
# When the Xen toolstack used is "xl", live migration requires the source host
201
# to connect to the target host via ssh (xl runs this command). We need to pass
202
# the command xl runs some extra info so that it can use Ganeti's key
203
# verification and not fail. Note that this string is incomplete: it must be
204
# filled with the cluster name before being used.
205
XL_SSH_CMD = ("ssh -l %s -oGlobalKnownHostsFile=%s"
206
              " -oUserKnownHostsFile=/dev/null"
207
              " -oCheckHostIp=no -oStrictHostKeyChecking=yes"
208
              " -oHostKeyAlias=%%s") % (SSH_LOGIN_USER,
209
                                        pathutils.SSH_KNOWN_HOSTS_FILE)
210

    
211
KVM_PATH = _autoconf.KVM_PATH
212
KVM_KERNEL = _autoconf.KVM_KERNEL
213
SOCAT_PATH = _autoconf.SOCAT_PATH
214
SOCAT_USE_ESCAPE = _autoconf.SOCAT_USE_ESCAPE
215
SOCAT_USE_COMPRESS = _autoconf.SOCAT_USE_COMPRESS
216
SOCAT_ESCAPE_CODE = "0x1d"
217

    
218
#: Console as SSH command
219
CONS_SSH = "ssh"
220

    
221
#: Console as VNC server
222
CONS_VNC = "vnc"
223

    
224
#: Console as SPICE server
225
CONS_SPICE = "spice"
226

    
227
#: Display a message for console access
228
CONS_MESSAGE = "msg"
229

    
230
#: All console types
231
CONS_ALL = compat.UniqueFrozenset([
232
  CONS_SSH,
233
  CONS_VNC,
234
  CONS_SPICE,
235
  CONS_MESSAGE,
236
  ])
237

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

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

    
251
# Digest used to sign certificates ("openssl x509" uses SHA1 by default)
252
X509_CERT_SIGN_DIGEST = "SHA1"
253

    
254
# Default validity of certificates in days
255
X509_CERT_DEFAULT_VALIDITY = 365 * 5
256

    
257
# commonName (CN) used in certificates
258
X509_CERT_CN = "ganeti.example.com"
259

    
260
X509_CERT_SIGNATURE_HEADER = "X-Ganeti-Signature"
261

    
262
# Import/export daemon mode
263
IEM_IMPORT = "import"
264
IEM_EXPORT = "export"
265

    
266
# Import/export transport compression
267
IEC_NONE = "none"
268
IEC_GZIP = "gzip"
269
IEC_ALL = compat.UniqueFrozenset([
270
  IEC_NONE,
271
  IEC_GZIP,
272
  ])
273

    
274
IE_CUSTOM_SIZE = "fd"
275

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

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

    
286
VALUE_DEFAULT = "default"
287
VALUE_AUTO = "auto"
288
VALUE_GENERATE = "generate"
289
VALUE_NONE = "none"
290
VALUE_TRUE = "true"
291
VALUE_FALSE = "false"
292

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

    
296
# hooks-related constants
297
HOOKS_PHASE_PRE = "pre"
298
HOOKS_PHASE_POST = "post"
299
HOOKS_NAME_CFGUPDATE = "config-update"
300
HOOKS_NAME_WATCHER = "watcher"
301
HOOKS_VERSION = 2
302
HOOKS_PATH = "/sbin:/bin:/usr/sbin:/usr/bin"
303

    
304
# hooks subject type (what object type does the LU deal with)
305
HTYPE_CLUSTER = "CLUSTER"
306
HTYPE_NODE = "NODE"
307
HTYPE_GROUP = "GROUP"
308
HTYPE_INSTANCE = "INSTANCE"
309
HTYPE_NETWORK = "NETWORK"
310

    
311
HKR_SKIP = 0
312
HKR_FAIL = 1
313
HKR_SUCCESS = 2
314

    
315
# Storage types
316
ST_FILE = "file"
317
ST_LVM_PV = "lvm-pv"
318
ST_LVM_VG = "lvm-vg"
319

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

    
331
# Storage operations
332
SO_FIX_CONSISTENCY = "fix-consistency"
333

    
334
# Available fields per storage type
335
VALID_STORAGE_FIELDS = compat.UniqueFrozenset([
336
  SF_NAME,
337
  SF_TYPE,
338
  SF_SIZE,
339
  SF_USED,
340
  SF_FREE,
341
  SF_ALLOCATABLE,
342
  ])
343

    
344
VALID_STORAGE_TYPES = compat.UniqueFrozenset([
345
  ST_FILE,
346
  ST_LVM_PV,
347
  ST_LVM_VG,
348
  ])
349

    
350
MODIFIABLE_STORAGE_FIELDS = {
351
  ST_LVM_PV: frozenset([SF_ALLOCATABLE]),
352
  }
353

    
354
VALID_STORAGE_OPERATIONS = {
355
  ST_LVM_VG: frozenset([SO_FIX_CONSISTENCY]),
356
  }
357

    
358
# Local disk status
359
# Note: Code depends on LDS_OKAY < LDS_UNKNOWN < LDS_FAULTY
360
(LDS_OKAY,
361
 LDS_UNKNOWN,
362
 LDS_FAULTY) = range(1, 4)
363

    
364
# disk template types
365
DT_DISKLESS = "diskless"
366
DT_PLAIN = "plain"
367
DT_DRBD8 = "drbd"
368
DT_FILE = "file"
369
DT_SHARED_FILE = "sharedfile"
370
DT_BLOCK = "blockdev"
371
DT_RBD = "rbd"
372
DT_EXT = "ext"
373

    
374
# the set of network-mirrored disk templates
375
DTS_INT_MIRROR = compat.UniqueFrozenset([DT_DRBD8])
376

    
377
# the set of externally-mirrored disk templates (e.g. SAN, NAS)
378
DTS_EXT_MIRROR = compat.UniqueFrozenset([
379
  DT_SHARED_FILE,
380
  DT_BLOCK,
381
  DT_RBD,
382
  DT_EXT,
383
  ])
384

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

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

    
405
# the set of disk templates that allow adoption
406
DTS_MAY_ADOPT = compat.UniqueFrozenset([
407
  DT_PLAIN,
408
  DT_BLOCK,
409
  ])
410

    
411
# the set of disk templates that *must* use adoption
412
DTS_MUST_ADOPT = compat.UniqueFrozenset([DT_BLOCK])
413

    
414
# the set of disk templates that allow migrations
415
DTS_MIRRORED = frozenset.union(DTS_INT_MIRROR, DTS_EXT_MIRROR)
416

    
417
# the set of file based disk templates
418
DTS_FILEBASED = compat.UniqueFrozenset([
419
  DT_FILE,
420
  DT_SHARED_FILE,
421
  ])
422

    
423
# the set of disk templates that are supported by exclusive_storage
424
DTS_EXCL_STORAGE = frozenset([DT_PLAIN])
425

    
426
# templates for which we don't perform checks on free space
427
DTS_NO_FREE_SPACE_CHECK = compat.UniqueFrozenset([
428
  DT_FILE,
429
  DT_SHARED_FILE,
430
  DT_RBD,
431
  DT_EXT,
432
  ])
433

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

    
450
LDS_BLOCK = compat.UniqueFrozenset([
451
  LD_LV,
452
  LD_DRBD8,
453
  LD_BLOCKDEV,
454
  LD_RBD,
455
  LD_EXT,
456
  ])
457

    
458
# drbd constants
459
DRBD_HMAC_ALG = "md5"
460
DRBD_NET_PROTOCOL = "C"
461
DRBD_STATUS_FILE = "/proc/drbd"
462

    
463
#: Size of DRBD meta block device
464
DRBD_META_SIZE = 128
465

    
466
# drbd barrier types
467
DRBD_B_NONE = "n"
468
DRBD_B_DISK_BARRIERS = "b"
469
DRBD_B_DISK_DRAIN = "d"
470
DRBD_B_DISK_FLUSH = "f"
471

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

    
484
# rbd tool command
485
RBD_CMD = "rbd"
486

    
487
# file backend driver
488
FD_LOOP = "loop"
489
FD_BLKTAP = "blktap"
490

    
491
# the set of drbd-like disk types
492
LDS_DRBD = compat.UniqueFrozenset([LD_DRBD8])
493

    
494
# disk access mode
495
DISK_RDONLY = "ro"
496
DISK_RDWR = "rw"
497
DISK_ACCESS_SET = compat.UniqueFrozenset([DISK_RDONLY, DISK_RDWR])
498

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

    
511
# Instance export mode
512
EXPORT_MODE_LOCAL = "local"
513
EXPORT_MODE_REMOTE = "remote"
514
EXPORT_MODES = compat.UniqueFrozenset([
515
  EXPORT_MODE_LOCAL,
516
  EXPORT_MODE_REMOTE,
517
  ])
518

    
519
# instance creation modes
520
INSTANCE_CREATE = "create"
521
INSTANCE_IMPORT = "import"
522
INSTANCE_REMOTE_IMPORT = "remote-import"
523
INSTANCE_CREATE_MODES = compat.UniqueFrozenset([
524
  INSTANCE_CREATE,
525
  INSTANCE_IMPORT,
526
  INSTANCE_REMOTE_IMPORT,
527
  ])
528

    
529
# Remote import/export handshake message and version
530
RIE_VERSION = 0
531
RIE_HANDSHAKE = "Hi, I'm Ganeti"
532

    
533
# Remote import/export certificate validity in seconds
534
RIE_CERT_VALIDITY = 24 * 60 * 60
535

    
536
# Overall timeout for establishing connection
537
RIE_CONNECT_TIMEOUT = 180
538

    
539
# Export only: how long to wait per connection attempt (seconds)
540
RIE_CONNECT_ATTEMPT_TIMEOUT = 20
541

    
542
# Export only: number of attempts to connect
543
RIE_CONNECT_RETRIES = 10
544

    
545
#: Give child process up to 5 seconds to exit after sending a signal
546
CHILD_LINGER_TIMEOUT = 5.0
547

    
548
DISK_TEMPLATES = compat.UniqueFrozenset([
549
  DT_DISKLESS,
550
  DT_PLAIN,
551
  DT_DRBD8,
552
  DT_FILE,
553
  DT_SHARED_FILE,
554
  DT_BLOCK,
555
  DT_RBD,
556
  DT_EXT
557
  ])
558

    
559
FILE_DRIVER = compat.UniqueFrozenset([FD_LOOP, FD_BLKTAP])
560

    
561
# import/export config options
562
INISECT_EXP = "export"
563
INISECT_INS = "instance"
564
INISECT_HYP = "hypervisor"
565
INISECT_BEP = "backend"
566
INISECT_OSP = "os"
567

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

    
578
# common exit codes
579
EXIT_SUCCESS = 0
580
EXIT_FAILURE = 1
581
EXIT_NOTCLUSTER = 5
582
EXIT_NOTMASTER = 11
583
EXIT_NODESETUP_ERROR = 12
584
EXIT_CONFIRMATION = 13 # need user confirmation
585

    
586
#: Exit code for query operations with unknown fields
587
EXIT_UNKNOWN_FIELD = 14
588

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

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

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

    
633
#: Key for job IDs in opcode result
634
JOB_IDS_KEY = "jobs"
635

    
636
# runparts results
637
(RUNPARTS_SKIP,
638
 RUNPARTS_RUN,
639
 RUNPARTS_ERR) = range(3)
640

    
641
RUNPARTS_STATUS = compat.UniqueFrozenset([
642
  RUNPARTS_SKIP,
643
  RUNPARTS_RUN,
644
  RUNPARTS_ERR,
645
  ])
646

    
647
# RPC constants
648
(RPC_ENCODING_NONE,
649
 RPC_ENCODING_ZLIB_BASE64) = range(2)
650

    
651
# Various time constants for the timeout table
652
RPC_TMO_URGENT = 60 # one minute
653
RPC_TMO_FAST = 5 * 60 # five minutes
654
RPC_TMO_NORMAL = 15 * 60 # 15 minutes
655
RPC_TMO_SLOW = 3600 # one hour
656
RPC_TMO_4HRS = 4 * 3600
657
RPC_TMO_1DAY = 86400
658

    
659
# Timeout for connecting to nodes (seconds)
660
RPC_CONNECT_TIMEOUT = 5
661

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

    
676
OS_API_FILE = "ganeti_api_version"
677
OS_VARIANTS_FILE = "variants.list"
678
OS_PARAMETERS_FILE = "parameters.list"
679

    
680
OS_VALIDATE_PARAMETERS = "parameters"
681
OS_VALIDATE_CALLS = compat.UniqueFrozenset([OS_VALIDATE_PARAMETERS])
682

    
683
# External Storage (ES) related constants
684
ES_ACTION_CREATE = "create"
685
ES_ACTION_REMOVE = "remove"
686
ES_ACTION_GROW = "grow"
687
ES_ACTION_ATTACH = "attach"
688
ES_ACTION_DETACH = "detach"
689
ES_ACTION_SETINFO = "setinfo"
690
ES_ACTION_VERIFY = "verify"
691

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

    
709
ES_PARAMETERS_FILE = "parameters.list"
710

    
711
# ssh constants
712
SSH = "ssh"
713
SCP = "scp"
714

    
715
# reboot types
716
INSTANCE_REBOOT_SOFT = "soft"
717
INSTANCE_REBOOT_HARD = "hard"
718
INSTANCE_REBOOT_FULL = "full"
719

    
720
REBOOT_TYPES = compat.UniqueFrozenset([
721
  INSTANCE_REBOOT_SOFT,
722
  INSTANCE_REBOOT_HARD,
723
  INSTANCE_REBOOT_FULL,
724
  ])
725

    
726
# instance reboot behaviors
727
INSTANCE_REBOOT_ALLOWED = "reboot"
728
INSTANCE_REBOOT_EXIT = "exit"
729

    
730
REBOOT_BEHAVIORS = compat.UniqueFrozenset([
731
  INSTANCE_REBOOT_ALLOWED,
732
  INSTANCE_REBOOT_EXIT,
733
  ])
734

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

    
748
# Constant representing that the user does not specify any IP version
749
IFACE_NO_IP_VERSION_SPECIFIED = 0
750

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

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

    
838

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

    
906
HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
907

    
908
HVS_PARAMETER_TITLES = {
909
  HV_ACPI: "ACPI",
910
  HV_BOOT_ORDER: "Boot_order",
911
  HV_CDROM_IMAGE_PATH: "CDROM_image_path",
912
  HV_DISK_TYPE: "Disk_type",
913
  HV_INITRD_PATH: "Initrd_path",
914
  HV_KERNEL_PATH: "Kernel_path",
915
  HV_NIC_TYPE: "NIC_type",
916
  HV_PAE: "PAE",
917
  HV_VNC_BIND_ADDRESS: "VNC_bind_address",
918
  HV_PASSTHROUGH: "pci_pass",
919
  HV_CPU_TYPE: "cpu_type",
920
  }
921

    
922
# Migration statuses
923
HV_MIGRATION_COMPLETED = "completed"
924
HV_MIGRATION_ACTIVE = "active"
925
HV_MIGRATION_FAILED = "failed"
926
HV_MIGRATION_CANCELLED = "cancelled"
927

    
928
HV_MIGRATION_VALID_STATUSES = compat.UniqueFrozenset([
929
  HV_MIGRATION_COMPLETED,
930
  HV_MIGRATION_ACTIVE,
931
  HV_MIGRATION_FAILED,
932
  HV_MIGRATION_CANCELLED,
933
  ])
934

    
935
HV_MIGRATION_FAILED_STATUSES = compat.UniqueFrozenset([
936
  HV_MIGRATION_FAILED,
937
  HV_MIGRATION_CANCELLED,
938
  ])
939

    
940
# KVM-specific statuses
941
HV_KVM_MIGRATION_VALID_STATUSES = HV_MIGRATION_VALID_STATUSES
942

    
943
# Node info keys
944
HV_NODEINFO_KEY_VERSION = "hv_version"
945

    
946
# Hypervisor state
947
HVST_MEMORY_TOTAL = "mem_total"
948
HVST_MEMORY_NODE = "mem_node"
949
HVST_MEMORY_HV = "mem_hv"
950
HVST_CPU_TOTAL = "cpu_total"
951
HVST_CPU_NODE = "cpu_node"
952

    
953
HVST_DEFAULTS = {
954
  HVST_MEMORY_TOTAL: 0,
955
  HVST_MEMORY_NODE: 0,
956
  HVST_MEMORY_HV: 0,
957
  HVST_CPU_TOTAL: 1,
958
  HVST_CPU_NODE: 1,
959
  }
960

    
961
HVSTS_PARAMETER_TYPES = {
962
  HVST_MEMORY_TOTAL: VTYPE_INT,
963
  HVST_MEMORY_NODE: VTYPE_INT,
964
  HVST_MEMORY_HV: VTYPE_INT,
965
  HVST_CPU_TOTAL: VTYPE_INT,
966
  HVST_CPU_NODE: VTYPE_INT,
967
  }
968

    
969
HVSTS_PARAMETERS = frozenset(HVSTS_PARAMETER_TYPES.keys())
970

    
971
# Disk state
972
DS_DISK_TOTAL = "disk_total"
973
DS_DISK_RESERVED = "disk_reserved"
974
DS_DISK_OVERHEAD = "disk_overhead"
975

    
976
DS_DEFAULTS = {
977
  DS_DISK_TOTAL: 0,
978
  DS_DISK_RESERVED: 0,
979
  DS_DISK_OVERHEAD: 0,
980
  }
981

    
982
DSS_PARAMETER_TYPES = {
983
  DS_DISK_TOTAL: VTYPE_INT,
984
  DS_DISK_RESERVED: VTYPE_INT,
985
  DS_DISK_OVERHEAD: VTYPE_INT,
986
  }
987

    
988
DSS_PARAMETERS = frozenset(DSS_PARAMETER_TYPES.keys())
989
DS_VALID_TYPES = compat.UniqueFrozenset([LD_LV])
990

    
991
# Backend parameter names
992
BE_MEMORY = "memory" # deprecated and replaced by max and min mem
993
BE_MAXMEM = "maxmem"
994
BE_MINMEM = "minmem"
995
BE_VCPUS = "vcpus"
996
BE_AUTO_BALANCE = "auto_balance"
997
BE_ALWAYS_FAILOVER = "always_failover"
998
BE_SPINDLE_USE = "spindle_use"
999

    
1000
BES_PARAMETER_TYPES = {
1001
  BE_MAXMEM: VTYPE_SIZE,
1002
  BE_MINMEM: VTYPE_SIZE,
1003
  BE_VCPUS: VTYPE_INT,
1004
  BE_AUTO_BALANCE: VTYPE_BOOL,
1005
  BE_ALWAYS_FAILOVER: VTYPE_BOOL,
1006
  BE_SPINDLE_USE: VTYPE_INT,
1007
  }
1008

    
1009
BES_PARAMETER_TITLES = {
1010
  BE_AUTO_BALANCE: "Auto_balance",
1011
  BE_MAXMEM: "ConfigMaxMem",
1012
  BE_MINMEM: "ConfigMinMem",
1013
  BE_VCPUS: "ConfigVCPUs",
1014
  }
1015

    
1016
BES_PARAMETER_COMPAT = {
1017
  BE_MEMORY: VTYPE_SIZE,
1018
  }
1019
BES_PARAMETER_COMPAT.update(BES_PARAMETER_TYPES)
1020

    
1021
BES_PARAMETERS = frozenset(BES_PARAMETER_TYPES.keys())
1022

    
1023
# instance specs
1024
ISPEC_MEM_SIZE = "memory-size"
1025
ISPEC_CPU_COUNT = "cpu-count"
1026
ISPEC_DISK_COUNT = "disk-count"
1027
ISPEC_DISK_SIZE = "disk-size"
1028
ISPEC_NIC_COUNT = "nic-count"
1029
ISPEC_SPINDLE_USE = "spindle-use"
1030

    
1031
ISPECS_PARAMETER_TYPES = {
1032
  ISPEC_MEM_SIZE: VTYPE_INT,
1033
  ISPEC_CPU_COUNT: VTYPE_INT,
1034
  ISPEC_DISK_COUNT: VTYPE_INT,
1035
  ISPEC_DISK_SIZE: VTYPE_INT,
1036
  ISPEC_NIC_COUNT: VTYPE_INT,
1037
  ISPEC_SPINDLE_USE: VTYPE_INT,
1038
  }
1039

    
1040
ISPECS_PARAMETERS = frozenset(ISPECS_PARAMETER_TYPES.keys())
1041

    
1042
ISPECS_MIN = "min"
1043
ISPECS_MAX = "max"
1044
ISPECS_STD = "std"
1045
IPOLICY_DTS = "disk-templates"
1046
IPOLICY_VCPU_RATIO = "vcpu-ratio"
1047
IPOLICY_SPINDLE_RATIO = "spindle-ratio"
1048

    
1049
IPOLICY_ISPECS = compat.UniqueFrozenset([
1050
  ISPECS_MIN,
1051
  ISPECS_MAX,
1052
  ISPECS_STD,
1053
  ])
1054

    
1055
IPOLICY_PARAMETERS = compat.UniqueFrozenset([
1056
  IPOLICY_VCPU_RATIO,
1057
  IPOLICY_SPINDLE_RATIO,
1058
  ])
1059

    
1060
IPOLICY_ALL_KEYS = (IPOLICY_ISPECS |
1061
                    IPOLICY_PARAMETERS |
1062
                    frozenset([IPOLICY_DTS]))
1063

    
1064
# Node parameter names
1065
ND_OOB_PROGRAM = "oob_program"
1066
ND_SPINDLE_COUNT = "spindle_count"
1067
ND_EXCLUSIVE_STORAGE = "exclusive_storage"
1068

    
1069
NDS_PARAMETER_TYPES = {
1070
  ND_OOB_PROGRAM: VTYPE_STRING,
1071
  ND_SPINDLE_COUNT: VTYPE_INT,
1072
  ND_EXCLUSIVE_STORAGE: VTYPE_BOOL,
1073
  }
1074

    
1075
NDS_PARAMETERS = frozenset(NDS_PARAMETER_TYPES.keys())
1076

    
1077
NDS_PARAMETER_TITLES = {
1078
  ND_OOB_PROGRAM: "OutOfBandProgram",
1079
  ND_SPINDLE_COUNT: "SpindleCount",
1080
  ND_EXCLUSIVE_STORAGE: "ExclusiveStorage",
1081
  }
1082

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

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

    
1153
DISK_DT_PARAMETERS = frozenset(DISK_DT_TYPES.keys())
1154

    
1155
# OOB supported commands
1156
OOB_POWER_ON = "power-on"
1157
OOB_POWER_OFF = "power-off"
1158
OOB_POWER_CYCLE = "power-cycle"
1159
OOB_POWER_STATUS = "power-status"
1160
OOB_HEALTH = "health"
1161

    
1162
OOB_COMMANDS = compat.UniqueFrozenset([
1163
  OOB_POWER_ON,
1164
  OOB_POWER_OFF,
1165
  OOB_POWER_CYCLE,
1166
  OOB_POWER_STATUS,
1167
  OOB_HEALTH,
1168
  ])
1169

    
1170
OOB_POWER_STATUS_POWERED = "powered"
1171

    
1172
OOB_TIMEOUT = 60 # 60 seconds
1173
OOB_POWER_DELAY = 2.0 # 2 seconds
1174

    
1175
OOB_STATUS_OK = "OK"
1176
OOB_STATUS_WARNING = "WARNING"
1177
OOB_STATUS_CRITICAL = "CRITICAL"
1178
OOB_STATUS_UNKNOWN = "UNKNOWN"
1179

    
1180
OOB_STATUSES = compat.UniqueFrozenset([
1181
  OOB_STATUS_OK,
1182
  OOB_STATUS_WARNING,
1183
  OOB_STATUS_CRITICAL,
1184
  OOB_STATUS_UNKNOWN,
1185
  ])
1186

    
1187
# Instance Parameters Profile
1188
PP_DEFAULT = "default"
1189

    
1190
# NIC_* constants are used inside the ganeti config
1191
NIC_MODE = "mode"
1192
NIC_LINK = "link"
1193

    
1194
NIC_MODE_BRIDGED = "bridged"
1195
NIC_MODE_ROUTED = "routed"
1196
NIC_MODE_OVS = "openvswitch"
1197
NIC_IP_POOL = "pool"
1198

    
1199
NIC_VALID_MODES = compat.UniqueFrozenset([
1200
  NIC_MODE_BRIDGED,
1201
  NIC_MODE_ROUTED,
1202
  NIC_MODE_OVS,
1203
  ])
1204

    
1205
RESERVE_ACTION = "reserve"
1206
RELEASE_ACTION = "release"
1207

    
1208
# An extra description of the network.
1209
# Can be used by hooks/kvm-vif-bridge to apply different rules
1210
NETWORK_TYPE_PRIVATE = "private"
1211
NETWORK_TYPE_PUBLIC = "public"
1212

    
1213
NETWORK_VALID_TYPES = compat.UniqueFrozenset([
1214
  NETWORK_TYPE_PRIVATE,
1215
  NETWORK_TYPE_PUBLIC,
1216
  ])
1217

    
1218
NICS_PARAMETER_TYPES = {
1219
  NIC_MODE: VTYPE_STRING,
1220
  NIC_LINK: VTYPE_STRING,
1221
  }
1222

    
1223
NICS_PARAMETERS = frozenset(NICS_PARAMETER_TYPES.keys())
1224

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

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

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

    
1274
VNC_BASE_PORT = 5900
1275
VNC_DEFAULT_BIND_ADDRESS = IP4_ADDRESS_ANY
1276

    
1277
# NIC types
1278
HT_NIC_RTL8139 = "rtl8139"
1279
HT_NIC_NE2K_PCI = "ne2k_pci"
1280
HT_NIC_NE2K_ISA = "ne2k_isa"
1281
HT_NIC_I82551 = "i82551"
1282
HT_NIC_I85557B = "i82557b"
1283
HT_NIC_I8259ER = "i82559er"
1284
HT_NIC_PCNET = "pcnet"
1285
HT_NIC_E1000 = "e1000"
1286
HT_NIC_PARAVIRTUAL = HT_DISK_PARAVIRTUAL = "paravirtual"
1287

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

    
1307
# Disk types
1308
HT_DISK_IOEMU = "ioemu"
1309
HT_DISK_IDE = "ide"
1310
HT_DISK_SCSI = "scsi"
1311
HT_DISK_SD = "sd"
1312
HT_DISK_MTD = "mtd"
1313
HT_DISK_PFLASH = "pflash"
1314

    
1315
HT_CACHE_DEFAULT = "default"
1316
HT_CACHE_NONE = "none"
1317
HT_CACHE_WTHROUGH = "writethrough"
1318
HT_CACHE_WBACK = "writeback"
1319
HT_VALID_CACHE_TYPES = compat.UniqueFrozenset([
1320
  HT_CACHE_DEFAULT,
1321
  HT_CACHE_NONE,
1322
  HT_CACHE_WTHROUGH,
1323
  HT_CACHE_WBACK,
1324
  ])
1325

    
1326
HT_HVM_VALID_DISK_TYPES = compat.UniqueFrozenset([
1327
  HT_DISK_PARAVIRTUAL,
1328
  HT_DISK_IOEMU,
1329
  ])
1330
HT_KVM_VALID_DISK_TYPES = compat.UniqueFrozenset([
1331
  HT_DISK_PARAVIRTUAL,
1332
  HT_DISK_IDE,
1333
  HT_DISK_SCSI,
1334
  HT_DISK_SD,
1335
  HT_DISK_MTD,
1336
  HT_DISK_PFLASH,
1337
  ])
1338

    
1339
# Mouse types:
1340
HT_MOUSE_MOUSE = "mouse"
1341
HT_MOUSE_TABLET = "tablet"
1342

    
1343
HT_KVM_VALID_MOUSE_TYPES = compat.UniqueFrozenset([
1344
  HT_MOUSE_MOUSE,
1345
  HT_MOUSE_TABLET,
1346
  ])
1347

    
1348
# Boot order
1349
HT_BO_FLOPPY = "floppy"
1350
HT_BO_CDROM = "cdrom"
1351
HT_BO_DISK = "disk"
1352
HT_BO_NETWORK = "network"
1353

    
1354
HT_KVM_VALID_BO_TYPES = compat.UniqueFrozenset([
1355
  HT_BO_FLOPPY,
1356
  HT_BO_CDROM,
1357
  HT_BO_DISK,
1358
  HT_BO_NETWORK,
1359
  ])
1360

    
1361
# SPICE lossless image compression options
1362
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ = "auto_glz"
1363
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ = "auto_lz"
1364
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC = "quic"
1365
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ = "glz"
1366
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ = "lz"
1367
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF = "off"
1368

    
1369
HT_KVM_SPICE_VALID_LOSSLESS_IMG_COMPR_OPTIONS = compat.UniqueFrozenset([
1370
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ,
1371
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ,
1372
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC,
1373
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ,
1374
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ,
1375
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF,
1376
  ])
1377

    
1378
# SPICE lossy image compression options (valid for both jpeg and zlib-glz)
1379
HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO = "auto"
1380
HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER = "never"
1381
HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS = "always"
1382

    
1383
HT_KVM_SPICE_VALID_LOSSY_IMG_COMPR_OPTIONS = compat.UniqueFrozenset([
1384
  HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO,
1385
  HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER,
1386
  HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS,
1387
  ])
1388

    
1389
# SPICE video stream detection
1390
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF = "off"
1391
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL = "all"
1392
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER = "filter"
1393

    
1394
HT_KVM_SPICE_VALID_VIDEO_STREAM_DETECTION_OPTIONS = compat.UniqueFrozenset([
1395
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF,
1396
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL,
1397
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER,
1398
  ])
1399

    
1400
# Security models
1401
HT_SM_NONE = "none"
1402
HT_SM_USER = "user"
1403
HT_SM_POOL = "pool"
1404

    
1405
HT_KVM_VALID_SM_TYPES = compat.UniqueFrozenset([
1406
  HT_SM_NONE,
1407
  HT_SM_USER,
1408
  HT_SM_POOL,
1409
  ])
1410

    
1411
# Kvm flag values
1412
HT_KVM_ENABLED = "enabled"
1413
HT_KVM_DISABLED = "disabled"
1414

    
1415
HT_KVM_FLAG_VALUES = compat.UniqueFrozenset([HT_KVM_ENABLED, HT_KVM_DISABLED])
1416

    
1417
# Migration type
1418
HT_MIGRATION_LIVE = "live"
1419
HT_MIGRATION_NONLIVE = "non-live"
1420
HT_MIGRATION_MODES = compat.UniqueFrozenset([
1421
  HT_MIGRATION_LIVE,
1422
  HT_MIGRATION_NONLIVE,
1423
  ])
1424

    
1425
# Cluster Verify steps
1426
VERIFY_NPLUSONE_MEM = "nplusone_mem"
1427
VERIFY_OPTIONAL_CHECKS = compat.UniqueFrozenset([VERIFY_NPLUSONE_MEM])
1428

    
1429
# Cluster Verify error classes
1430
CV_TCLUSTER = "cluster"
1431
CV_TNODE = "node"
1432
CV_TINSTANCE = "instance"
1433

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

    
1511
CV_ALL_ECODES = compat.UniqueFrozenset([
1512
  CV_ECLUSTERCFG,
1513
  CV_ECLUSTERCERT,
1514
  CV_ECLUSTERFILECHECK,
1515
  CV_ECLUSTERDANGLINGNODES,
1516
  CV_ECLUSTERDANGLINGINST,
1517
  CV_EINSTANCEBADNODE,
1518
  CV_EINSTANCEDOWN,
1519
  CV_EINSTANCELAYOUT,
1520
  CV_EINSTANCEMISSINGDISK,
1521
  CV_EINSTANCEFAULTYDISK,
1522
  CV_EINSTANCEWRONGNODE,
1523
  CV_EINSTANCESPLITGROUPS,
1524
  CV_EINSTANCEPOLICY,
1525
  CV_ENODEDRBD,
1526
  CV_ENODEDRBDHELPER,
1527
  CV_ENODEFILECHECK,
1528
  CV_ENODEHOOKS,
1529
  CV_ENODEHV,
1530
  CV_ENODELVM,
1531
  CV_ENODEN1,
1532
  CV_ENODENET,
1533
  CV_ENODEOS,
1534
  CV_ENODEORPHANINSTANCE,
1535
  CV_ENODEORPHANLV,
1536
  CV_ENODERPC,
1537
  CV_ENODESSH,
1538
  CV_ENODEVERSION,
1539
  CV_ENODESETUP,
1540
  CV_ENODETIME,
1541
  CV_ENODEOOBPATH,
1542
  CV_ENODEUSERSCRIPTS,
1543
  CV_ENODEFILESTORAGEPATHS,
1544
  ])
1545

    
1546
CV_ALL_ECODES_STRINGS = \
1547
  compat.UniqueFrozenset(estr for (_, estr, _) in CV_ALL_ECODES)
1548

    
1549
# Node verify constants
1550
NV_DRBDHELPER = "drbd-helper"
1551
NV_DRBDLIST = "drbd-list"
1552
NV_FILELIST = "filelist"
1553
NV_HVINFO = "hvinfo"
1554
NV_HYPERVISOR = "hypervisor"
1555
NV_HVPARAMS = "hvparms"
1556
NV_INSTANCELIST = "instancelist"
1557
NV_LVLIST = "lvlist"
1558
NV_MASTERIP = "master-ip"
1559
NV_NODELIST = "nodelist"
1560
NV_NODENETTEST = "node-net-test"
1561
NV_NODESETUP = "nodesetup"
1562
NV_OSLIST = "oslist"
1563
NV_PVLIST = "pvlist"
1564
NV_TIME = "time"
1565
NV_VERSION = "version"
1566
NV_VGLIST = "vglist"
1567
NV_VMNODES = "vmnodes"
1568
NV_OOB_PATHS = "oob-paths"
1569
NV_BRIDGES = "bridges"
1570
NV_USERSCRIPTS = "user-scripts"
1571
NV_FILE_STORAGE_PATHS = "file-storage-paths"
1572

    
1573
# Instance status
1574
INSTST_RUNNING = "running"
1575
INSTST_ADMINDOWN = "ADMIN_down"
1576
INSTST_ADMINOFFLINE = "ADMIN_offline"
1577
INSTST_NODEOFFLINE = "ERROR_nodeoffline"
1578
INSTST_NODEDOWN = "ERROR_nodedown"
1579
INSTST_WRONGNODE = "ERROR_wrongnode"
1580
INSTST_ERRORUP = "ERROR_up"
1581
INSTST_ERRORDOWN = "ERROR_down"
1582
INSTST_ALL = compat.UniqueFrozenset([
1583
  INSTST_RUNNING,
1584
  INSTST_ADMINDOWN,
1585
  INSTST_ADMINOFFLINE,
1586
  INSTST_NODEOFFLINE,
1587
  INSTST_NODEDOWN,
1588
  INSTST_WRONGNODE,
1589
  INSTST_ERRORUP,
1590
  INSTST_ERRORDOWN,
1591
  ])
1592

    
1593
# Admin states
1594
ADMINST_UP = "up"
1595
ADMINST_DOWN = "down"
1596
ADMINST_OFFLINE = "offline"
1597
ADMINST_ALL = compat.UniqueFrozenset([
1598
  ADMINST_UP,
1599
  ADMINST_DOWN,
1600
  ADMINST_OFFLINE,
1601
  ])
1602

    
1603
# Node roles
1604
NR_REGULAR = "R"
1605
NR_MASTER = "M"
1606
NR_MCANDIDATE = "C"
1607
NR_DRAINED = "D"
1608
NR_OFFLINE = "O"
1609
NR_ALL = compat.UniqueFrozenset([
1610
  NR_REGULAR,
1611
  NR_MASTER,
1612
  NR_MCANDIDATE,
1613
  NR_DRAINED,
1614
  NR_OFFLINE,
1615
  ])
1616

    
1617
# SSL certificate check constants (in days)
1618
SSL_CERT_EXPIRATION_WARN = 30
1619
SSL_CERT_EXPIRATION_ERROR = 7
1620

    
1621
# Allocator framework constants
1622
IALLOCATOR_VERSION = 2
1623
IALLOCATOR_DIR_IN = "in"
1624
IALLOCATOR_DIR_OUT = "out"
1625
VALID_IALLOCATOR_DIRECTIONS = compat.UniqueFrozenset([
1626
  IALLOCATOR_DIR_IN,
1627
  IALLOCATOR_DIR_OUT,
1628
  ])
1629
IALLOCATOR_MODE_ALLOC = "allocate"
1630
IALLOCATOR_MODE_RELOC = "relocate"
1631
IALLOCATOR_MODE_CHG_GROUP = "change-group"
1632
IALLOCATOR_MODE_NODE_EVAC = "node-evacuate"
1633
IALLOCATOR_MODE_MULTI_ALLOC = "multi-allocate"
1634
VALID_IALLOCATOR_MODES = compat.UniqueFrozenset([
1635
  IALLOCATOR_MODE_ALLOC,
1636
  IALLOCATOR_MODE_RELOC,
1637
  IALLOCATOR_MODE_CHG_GROUP,
1638
  IALLOCATOR_MODE_NODE_EVAC,
1639
  IALLOCATOR_MODE_MULTI_ALLOC,
1640
  ])
1641
IALLOCATOR_SEARCH_PATH = _autoconf.IALLOCATOR_SEARCH_PATH
1642
DEFAULT_IALLOCATOR_SHORTCUT = "."
1643

    
1644
IALLOCATOR_NEVAC_PRI = "primary-only"
1645
IALLOCATOR_NEVAC_SEC = "secondary-only"
1646
IALLOCATOR_NEVAC_ALL = "all"
1647
IALLOCATOR_NEVAC_MODES = compat.UniqueFrozenset([
1648
  IALLOCATOR_NEVAC_PRI,
1649
  IALLOCATOR_NEVAC_SEC,
1650
  IALLOCATOR_NEVAC_ALL,
1651
  ])
1652

    
1653
# Node evacuation
1654
NODE_EVAC_PRI = "primary-only"
1655
NODE_EVAC_SEC = "secondary-only"
1656
NODE_EVAC_ALL = "all"
1657
NODE_EVAC_MODES = compat.UniqueFrozenset([
1658
  NODE_EVAC_PRI,
1659
  NODE_EVAC_SEC,
1660
  NODE_EVAC_ALL,
1661
  ])
1662

    
1663
# Job queue
1664
JOB_QUEUE_VERSION = 1
1665
JOB_QUEUE_SIZE_HARD_LIMIT = 5000
1666

    
1667
JOB_ID_TEMPLATE = r"\d+"
1668
JOB_FILE_RE = re.compile(r"^job-(%s)$" % JOB_ID_TEMPLATE)
1669

    
1670
# unchanged job return
1671
JOB_NOTCHANGED = "nochange"
1672

    
1673
# Job status
1674
JOB_STATUS_QUEUED = "queued"
1675
JOB_STATUS_WAITING = "waiting"
1676
JOB_STATUS_CANCELING = "canceling"
1677
JOB_STATUS_RUNNING = "running"
1678
JOB_STATUS_CANCELED = "canceled"
1679
JOB_STATUS_SUCCESS = "success"
1680
JOB_STATUS_ERROR = "error"
1681
JOBS_PENDING = compat.UniqueFrozenset([
1682
  JOB_STATUS_QUEUED,
1683
  JOB_STATUS_WAITING,
1684
  JOB_STATUS_CANCELING,
1685
  ])
1686
JOBS_FINALIZED = compat.UniqueFrozenset([
1687
  JOB_STATUS_CANCELED,
1688
  JOB_STATUS_SUCCESS,
1689
  JOB_STATUS_ERROR,
1690
  ])
1691
JOB_STATUS_ALL = compat.UniqueFrozenset([
1692
  JOB_STATUS_RUNNING,
1693
  ]) | JOBS_PENDING | JOBS_FINALIZED
1694

    
1695
# OpCode status
1696
# not yet finalized
1697
OP_STATUS_QUEUED = "queued"
1698
OP_STATUS_WAITING = "waiting"
1699
OP_STATUS_CANCELING = "canceling"
1700
OP_STATUS_RUNNING = "running"
1701
# finalized
1702
OP_STATUS_CANCELED = "canceled"
1703
OP_STATUS_SUCCESS = "success"
1704
OP_STATUS_ERROR = "error"
1705
OPS_FINALIZED = compat.UniqueFrozenset([
1706
  OP_STATUS_CANCELED,
1707
  OP_STATUS_SUCCESS,
1708
  OP_STATUS_ERROR,
1709
  ])
1710

    
1711
# OpCode priority
1712
OP_PRIO_LOWEST = +19
1713
OP_PRIO_HIGHEST = -20
1714

    
1715
OP_PRIO_LOW = +10
1716
OP_PRIO_NORMAL = 0
1717
OP_PRIO_HIGH = -10
1718

    
1719
OP_PRIO_SUBMIT_VALID = compat.UniqueFrozenset([
1720
  OP_PRIO_LOW,
1721
  OP_PRIO_NORMAL,
1722
  OP_PRIO_HIGH,
1723
  ])
1724

    
1725
OP_PRIO_DEFAULT = OP_PRIO_NORMAL
1726

    
1727
# Lock recalculate mode
1728
LOCKS_REPLACE = "replace"
1729
LOCKS_APPEND = "append"
1730

    
1731
# Lock timeout (sum) before we should go into blocking acquire (still
1732
# can be reset by priority change); computed as max time (10 hours)
1733
# before we should actually go into blocking acquire given that we
1734
# start from default priority level; in seconds
1735
# TODO
1736
LOCK_ATTEMPTS_TIMEOUT = 10 * 3600 / (OP_PRIO_DEFAULT - OP_PRIO_HIGHEST)
1737
LOCK_ATTEMPTS_MAXWAIT = 15.0
1738
LOCK_ATTEMPTS_MINWAIT = 1.0
1739

    
1740
# Execution log types
1741
ELOG_MESSAGE = "message"
1742
ELOG_REMOTE_IMPORT = "remote-import"
1743
ELOG_JQUEUE_TEST = "jqueue-test"
1744

    
1745
# /etc/hosts modification
1746
ETC_HOSTS_ADD = "add"
1747
ETC_HOSTS_REMOVE = "remove"
1748

    
1749
# Job queue test
1750
JQT_MSGPREFIX = "TESTMSG="
1751
JQT_EXPANDNAMES = "expandnames"
1752
JQT_EXEC = "exec"
1753
JQT_LOGMSG = "logmsg"
1754
JQT_STARTMSG = "startmsg"
1755
JQT_ALL = compat.UniqueFrozenset([
1756
  JQT_EXPANDNAMES,
1757
  JQT_EXEC,
1758
  JQT_LOGMSG,
1759
  JQT_STARTMSG,
1760
  ])
1761

    
1762
# Query resources
1763
QR_CLUSTER = "cluster"
1764
QR_INSTANCE = "instance"
1765
QR_NODE = "node"
1766
QR_LOCK = "lock"
1767
QR_GROUP = "group"
1768
QR_OS = "os"
1769
QR_JOB = "job"
1770
QR_EXPORT = "export"
1771
QR_NETWORK = "network"
1772
QR_EXTSTORAGE = "extstorage"
1773

    
1774
#: List of resources which can be queried using L{opcodes.OpQuery}
1775
QR_VIA_OP = compat.UniqueFrozenset([
1776
  QR_CLUSTER,
1777
  QR_INSTANCE,
1778
  QR_NODE,
1779
  QR_GROUP,
1780
  QR_OS,
1781
  QR_EXPORT,
1782
  QR_NETWORK,
1783
  QR_EXTSTORAGE,
1784
  ])
1785

    
1786
#: List of resources which can be queried using Local UniX Interface
1787
QR_VIA_LUXI = QR_VIA_OP.union([
1788
  QR_LOCK,
1789
  QR_JOB,
1790
  ])
1791

    
1792
#: List of resources which can be queried using RAPI
1793
QR_VIA_RAPI = QR_VIA_LUXI
1794

    
1795
# Query field types
1796
QFT_UNKNOWN = "unknown"
1797
QFT_TEXT = "text"
1798
QFT_BOOL = "bool"
1799
QFT_NUMBER = "number"
1800
QFT_UNIT = "unit"
1801
QFT_TIMESTAMP = "timestamp"
1802
QFT_OTHER = "other"
1803

    
1804
#: All query field types
1805
QFT_ALL = compat.UniqueFrozenset([
1806
  QFT_UNKNOWN,
1807
  QFT_TEXT,
1808
  QFT_BOOL,
1809
  QFT_NUMBER,
1810
  QFT_UNIT,
1811
  QFT_TIMESTAMP,
1812
  QFT_OTHER,
1813
  ])
1814

    
1815
# Query result field status (don't change or reuse values as they're used by
1816
# clients)
1817
#: Normal field status
1818
RS_NORMAL = 0
1819
#: Unknown field
1820
RS_UNKNOWN = 1
1821
#: No data (e.g. RPC error), can be used instead of L{RS_OFFLINE}
1822
RS_NODATA = 2
1823
#: Value unavailable/unsupported for item; if this field is supported
1824
#: but we cannot get the data for the moment, RS_NODATA or
1825
#: RS_OFFLINE should be used
1826
RS_UNAVAIL = 3
1827
#: Resource marked offline
1828
RS_OFFLINE = 4
1829

    
1830
RS_ALL = compat.UniqueFrozenset([
1831
  RS_NORMAL,
1832
  RS_UNKNOWN,
1833
  RS_NODATA,
1834
  RS_UNAVAIL,
1835
  RS_OFFLINE,
1836
  ])
1837

    
1838
#: Dictionary with special field cases and their verbose/terse formatting
1839
RSS_DESCRIPTION = {
1840
  RS_UNKNOWN: ("(unknown)", "??"),
1841
  RS_NODATA: ("(nodata)", "?"),
1842
  RS_OFFLINE: ("(offline)", "*"),
1843
  RS_UNAVAIL: ("(unavail)", "-"),
1844
  }
1845

    
1846
# max dynamic devices
1847
MAX_NICS = 8
1848
MAX_DISKS = 16
1849

    
1850
# SSCONF file prefix
1851
SSCONF_FILEPREFIX = "ssconf_"
1852
# SSCONF keys
1853
SS_CLUSTER_NAME = "cluster_name"
1854
SS_CLUSTER_TAGS = "cluster_tags"
1855
SS_FILE_STORAGE_DIR = "file_storage_dir"
1856
SS_SHARED_FILE_STORAGE_DIR = "shared_file_storage_dir"
1857
SS_MASTER_CANDIDATES = "master_candidates"
1858
SS_MASTER_CANDIDATES_IPS = "master_candidates_ips"
1859
SS_MASTER_IP = "master_ip"
1860
SS_MASTER_NETDEV = "master_netdev"
1861
SS_MASTER_NETMASK = "master_netmask"
1862
SS_MASTER_NODE = "master_node"
1863
SS_NODE_LIST = "node_list"
1864
SS_NODE_PRIMARY_IPS = "node_primary_ips"
1865
SS_NODE_SECONDARY_IPS = "node_secondary_ips"
1866
SS_OFFLINE_NODES = "offline_nodes"
1867
SS_ONLINE_NODES = "online_nodes"
1868
SS_PRIMARY_IP_FAMILY = "primary_ip_family"
1869
SS_INSTANCE_LIST = "instance_list"
1870
SS_RELEASE_VERSION = "release_version"
1871
SS_HYPERVISOR_LIST = "hypervisor_list"
1872
SS_MAINTAIN_NODE_HEALTH = "maintain_node_health"
1873
SS_UID_POOL = "uid_pool"
1874
SS_NODEGROUPS = "nodegroups"
1875
SS_NETWORKS = "networks"
1876

    
1877
SS_FILE_PERMS = 0444
1878

    
1879
# cluster wide default parameters
1880
DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM
1881

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

    
1985
HVC_GLOBALS = compat.UniqueFrozenset([
1986
  HV_MIGRATION_PORT,
1987
  HV_MIGRATION_BANDWIDTH,
1988
  HV_MIGRATION_MODE,
1989
  ])
1990

    
1991
BEC_DEFAULTS = {
1992
  BE_MINMEM: 128,
1993
  BE_MAXMEM: 128,
1994
  BE_VCPUS: 1,
1995
  BE_AUTO_BALANCE: True,
1996
  BE_ALWAYS_FAILOVER: False,
1997
  BE_SPINDLE_USE: 1,
1998
  }
1999

    
2000
NDC_DEFAULTS = {
2001
  ND_OOB_PROGRAM: "",
2002
  ND_SPINDLE_COUNT: 1,
2003
  ND_EXCLUSIVE_STORAGE: False,
2004
  }
2005

    
2006
DISK_LD_DEFAULTS = {
2007
  LD_DRBD8: {
2008
    LDP_RESYNC_RATE: CLASSIC_DRBD_SYNC_SPEED,
2009
    LDP_BARRIERS: _autoconf.DRBD_BARRIERS,
2010
    LDP_NO_META_FLUSH: _autoconf.DRBD_NO_META_FLUSH,
2011
    LDP_DEFAULT_METAVG: DEFAULT_VG,
2012
    LDP_DISK_CUSTOM: "",
2013
    LDP_NET_CUSTOM: "",
2014
    LDP_DYNAMIC_RESYNC: False,
2015

    
2016
    # The default values for the DRBD dynamic resync speed algorithm are taken
2017
    # from the drbsetup 8.3.11 man page, except for c-plan-ahead (that we
2018
    # don't need to set to 0, because we have a separate option to enable it)
2019
    # and for c-max-rate, that we cap to the default value for the static resync
2020
    # rate.
2021
    LDP_PLAN_AHEAD: 20, # ds
2022
    LDP_FILL_TARGET: 0, # sectors
2023
    LDP_DELAY_TARGET: 1, # ds
2024
    LDP_MAX_RATE: CLASSIC_DRBD_SYNC_SPEED, # KiB/s
2025
    LDP_MIN_RATE: 4 * 1024, # KiB/s
2026
    },
2027
  LD_LV: {
2028
    LDP_STRIPES: _autoconf.LVM_STRIPECOUNT
2029
    },
2030
  LD_FILE: {},
2031
  LD_BLOCKDEV: {},
2032
  LD_RBD: {
2033
    LDP_POOL: "rbd"
2034
    },
2035
  LD_EXT: {},
2036
  }
2037

    
2038
# readability shortcuts
2039
_LV_DEFAULTS = DISK_LD_DEFAULTS[LD_LV]
2040
_DRBD_DEFAULTS = DISK_LD_DEFAULTS[LD_DRBD8]
2041

    
2042
DISK_DT_DEFAULTS = {
2043
  DT_PLAIN: {
2044
    LV_STRIPES: DISK_LD_DEFAULTS[LD_LV][LDP_STRIPES],
2045
    },
2046
  DT_DRBD8: {
2047
    DRBD_RESYNC_RATE: _DRBD_DEFAULTS[LDP_RESYNC_RATE],
2048
    DRBD_DATA_STRIPES: _LV_DEFAULTS[LDP_STRIPES],
2049
    DRBD_META_STRIPES: _LV_DEFAULTS[LDP_STRIPES],
2050
    DRBD_DISK_BARRIERS: _DRBD_DEFAULTS[LDP_BARRIERS],
2051
    DRBD_META_BARRIERS: _DRBD_DEFAULTS[LDP_NO_META_FLUSH],
2052
    DRBD_DEFAULT_METAVG: _DRBD_DEFAULTS[LDP_DEFAULT_METAVG],
2053
    DRBD_DISK_CUSTOM: _DRBD_DEFAULTS[LDP_DISK_CUSTOM],
2054
    DRBD_NET_CUSTOM: _DRBD_DEFAULTS[LDP_NET_CUSTOM],
2055
    DRBD_DYNAMIC_RESYNC: _DRBD_DEFAULTS[LDP_DYNAMIC_RESYNC],
2056
    DRBD_PLAN_AHEAD: _DRBD_DEFAULTS[LDP_PLAN_AHEAD],
2057
    DRBD_FILL_TARGET: _DRBD_DEFAULTS[LDP_FILL_TARGET],
2058
    DRBD_DELAY_TARGET: _DRBD_DEFAULTS[LDP_DELAY_TARGET],
2059
    DRBD_MAX_RATE: _DRBD_DEFAULTS[LDP_MAX_RATE],
2060
    DRBD_MIN_RATE: _DRBD_DEFAULTS[LDP_MIN_RATE],
2061
    },
2062
  DT_DISKLESS: {},
2063
  DT_FILE: {},
2064
  DT_SHARED_FILE: {},
2065
  DT_BLOCK: {},
2066
  DT_RBD: {
2067
    RBD_POOL: DISK_LD_DEFAULTS[LD_RBD][LDP_POOL]
2068
    },
2069
  DT_EXT: {},
2070
  }
2071

    
2072
# we don't want to export the shortcuts
2073
del _LV_DEFAULTS, _DRBD_DEFAULTS
2074

    
2075
NICC_DEFAULTS = {
2076
  NIC_MODE: NIC_MODE_BRIDGED,
2077
  NIC_LINK: DEFAULT_BRIDGE,
2078
  }
2079

    
2080
# All of the following values are quite arbitrarily - there are no
2081
# "good" defaults, these must be customised per-site
2082
IPOLICY_DEFAULTS = {
2083
  ISPECS_MIN: {
2084
    ISPEC_MEM_SIZE: 128,
2085
    ISPEC_CPU_COUNT: 1,
2086
    ISPEC_DISK_COUNT: 1,
2087
    ISPEC_DISK_SIZE: 1024,
2088
    ISPEC_NIC_COUNT: 1,
2089
    ISPEC_SPINDLE_USE: 1,
2090
    },
2091
  ISPECS_MAX: {
2092
    ISPEC_MEM_SIZE: 32768,
2093
    ISPEC_CPU_COUNT: 8,
2094
    ISPEC_DISK_COUNT: MAX_DISKS,
2095
    ISPEC_DISK_SIZE: 1024 * 1024,
2096
    ISPEC_NIC_COUNT: MAX_NICS,
2097
    ISPEC_SPINDLE_USE: 12,
2098
    },
2099
  ISPECS_STD: {
2100
    ISPEC_MEM_SIZE: 128,
2101
    ISPEC_CPU_COUNT: 1,
2102
    ISPEC_DISK_COUNT: 1,
2103
    ISPEC_DISK_SIZE: 1024,
2104
    ISPEC_NIC_COUNT: 1,
2105
    ISPEC_SPINDLE_USE: 1,
2106
    },
2107
  IPOLICY_DTS: DISK_TEMPLATES,
2108
  IPOLICY_VCPU_RATIO: 4.0,
2109
  IPOLICY_SPINDLE_RATIO: 32.0,
2110
  }
2111

    
2112
MASTER_POOL_SIZE_DEFAULT = 10
2113

    
2114
# Exclusive storage:
2115
# Error margin used to compare physical disks
2116
PART_MARGIN = .01
2117
# Space reserved when creating instance disks
2118
PART_RESERVED = .02
2119

    
2120
CONFD_PROTOCOL_VERSION = 1
2121

    
2122
CONFD_REQ_PING = 0
2123
CONFD_REQ_NODE_ROLE_BYNAME = 1
2124
CONFD_REQ_NODE_PIP_BY_INSTANCE_IP = 2
2125
CONFD_REQ_CLUSTER_MASTER = 3
2126
CONFD_REQ_NODE_PIP_LIST = 4
2127
CONFD_REQ_MC_PIP_LIST = 5
2128
CONFD_REQ_INSTANCES_IPS_LIST = 6
2129
CONFD_REQ_NODE_DRBD = 7
2130

    
2131
# Confd request query fields. These are used to narrow down queries.
2132
# These must be strings rather than integers, because json-encoding
2133
# converts them to strings anyway, as they're used as dict-keys.
2134
CONFD_REQQ_LINK = "0"
2135
CONFD_REQQ_IP = "1"
2136
CONFD_REQQ_IPLIST = "2"
2137
CONFD_REQQ_FIELDS = "3"
2138

    
2139
CONFD_REQFIELD_NAME = "0"
2140
CONFD_REQFIELD_IP = "1"
2141
CONFD_REQFIELD_MNODE_PIP = "2"
2142

    
2143
CONFD_REQS = compat.UniqueFrozenset([
2144
  CONFD_REQ_PING,
2145
  CONFD_REQ_NODE_ROLE_BYNAME,
2146
  CONFD_REQ_NODE_PIP_BY_INSTANCE_IP,
2147
  CONFD_REQ_CLUSTER_MASTER,
2148
  CONFD_REQ_NODE_PIP_LIST,
2149
  CONFD_REQ_MC_PIP_LIST,
2150
  CONFD_REQ_INSTANCES_IPS_LIST,
2151
  CONFD_REQ_NODE_DRBD,
2152
  ])
2153

    
2154
CONFD_REPL_STATUS_OK = 0
2155
CONFD_REPL_STATUS_ERROR = 1
2156
CONFD_REPL_STATUS_NOTIMPLEMENTED = 2
2157

    
2158
CONFD_REPL_STATUSES = compat.UniqueFrozenset([
2159
  CONFD_REPL_STATUS_OK,
2160
  CONFD_REPL_STATUS_ERROR,
2161
  CONFD_REPL_STATUS_NOTIMPLEMENTED,
2162
  ])
2163

    
2164
(CONFD_NODE_ROLE_MASTER,
2165
 CONFD_NODE_ROLE_CANDIDATE,
2166
 CONFD_NODE_ROLE_OFFLINE,
2167
 CONFD_NODE_ROLE_DRAINED,
2168
 CONFD_NODE_ROLE_REGULAR,
2169
 ) = range(5)
2170

    
2171
# A few common errors for confd
2172
CONFD_ERROR_UNKNOWN_ENTRY = 1
2173
CONFD_ERROR_INTERNAL = 2
2174
CONFD_ERROR_ARGUMENT = 3
2175

    
2176
# Each request is "salted" by the current timestamp.
2177
# This constants decides how many seconds of skew to accept.
2178
# TODO: make this a default and allow the value to be more configurable
2179
CONFD_MAX_CLOCK_SKEW = 2 * NODE_MAX_CLOCK_SKEW
2180

    
2181
# When we haven't reloaded the config for more than this amount of seconds, we
2182
# force a test to see if inotify is betraying us.
2183
CONFD_CONFIG_RELOAD_TIMEOUT = 60
2184

    
2185
# If we receive more than one update in this amount of seconds, we move to
2186
# polling every RATELIMIT seconds, rather than relying on inotify, to be able
2187
# to serve more requests.
2188
CONFD_CONFIG_RELOAD_RATELIMIT = 2
2189

    
2190
# Magic number prepended to all confd queries.
2191
# This allows us to distinguish different types of confd protocols and handle
2192
# them. For example by changing this we can move the whole payload to be
2193
# compressed, or move away from json.
2194
CONFD_MAGIC_FOURCC = "plj0"
2195

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

    
2201
# Timeout in seconds to expire pending query request in the confd client
2202
# library. We don't actually expect any answer more than 10 seconds after we
2203
# sent a request.
2204
CONFD_CLIENT_EXPIRE_TIMEOUT = 10
2205

    
2206
# Maximum UDP datagram size.
2207
# On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
2208
# On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
2209
#   (assuming we can't use jumbo frames)
2210
# We just set this to 60K, which should be enough
2211
MAX_UDP_DATA_SIZE = 61440
2212

    
2213
# User-id pool minimum/maximum acceptable user-ids.
2214
UIDPOOL_UID_MIN = 0
2215
UIDPOOL_UID_MAX = 2 ** 32 - 1 # Assuming 32 bit user-ids
2216

    
2217
# Name or path of the pgrep command
2218
PGREP = "pgrep"
2219

    
2220
# Name of the node group that gets created at cluster init or upgrade
2221
INITIAL_NODE_GROUP_NAME = "default"
2222

    
2223
# Possible values for NodeGroup.alloc_policy
2224
ALLOC_POLICY_PREFERRED = "preferred"
2225
ALLOC_POLICY_LAST_RESORT = "last_resort"
2226
ALLOC_POLICY_UNALLOCABLE = "unallocable"
2227
VALID_ALLOC_POLICIES = [
2228
  ALLOC_POLICY_PREFERRED,
2229
  ALLOC_POLICY_LAST_RESORT,
2230
  ALLOC_POLICY_UNALLOCABLE,
2231
  ]
2232

    
2233
# Temporary external/shared storage parameters
2234
BLOCKDEV_DRIVER_MANUAL = "manual"
2235

    
2236
# qemu-img path, required for ovfconverter
2237
QEMUIMG_PATH = _autoconf.QEMUIMG_PATH
2238

    
2239
# Whether htools was enabled at compilation time
2240
HTOOLS = _autoconf.HTOOLS
2241
# The hail iallocator
2242
IALLOC_HAIL = "hail"
2243

    
2244
# Fake opcodes for functions that have hooks attached to them via
2245
# backend.RunLocalHooks
2246
FAKE_OP_MASTER_TURNUP = "OP_CLUSTER_IP_TURNUP"
2247
FAKE_OP_MASTER_TURNDOWN = "OP_CLUSTER_IP_TURNDOWN"
2248

    
2249
# SSH key types
2250
SSHK_RSA = "rsa"
2251
SSHK_DSA = "dsa"
2252
SSHK_ALL = compat.UniqueFrozenset([SSHK_RSA, SSHK_DSA])
2253

    
2254
# SSH authorized key types
2255
SSHAK_RSA = "ssh-rsa"
2256
SSHAK_DSS = "ssh-dss"
2257
SSHAK_ALL = compat.UniqueFrozenset([SSHAK_RSA, SSHAK_DSS])
2258

    
2259
# SSH setup
2260
SSHS_CLUSTER_NAME = "cluster_name"
2261
SSHS_SSH_HOST_KEY = "ssh_host_key"
2262
SSHS_SSH_ROOT_KEY = "ssh_root_key"
2263
SSHS_NODE_DAEMON_CERTIFICATE = "node_daemon_certificate"
2264

    
2265
#: Key files for SSH daemon
2266
SSH_DAEMON_KEYFILES = {
2267
  SSHK_RSA: (pathutils.SSH_HOST_RSA_PRIV, pathutils.SSH_HOST_RSA_PUB),
2268
  SSHK_DSA: (pathutils.SSH_HOST_DSA_PRIV, pathutils.SSH_HOST_DSA_PUB),
2269
  }
2270

    
2271
# Node daemon setup
2272
NDS_CLUSTER_NAME = "cluster_name"
2273
NDS_NODE_DAEMON_CERTIFICATE = "node_daemon_certificate"
2274
NDS_SSCONF = "ssconf"
2275
NDS_START_NODE_DAEMON = "start_node_daemon"
2276

    
2277
# Path generating random UUID
2278
RANDOM_UUID_FILE = "/proc/sys/kernel/random/uuid"
2279

    
2280
# Regex string for verifying a UUID
2281
UUID_REGEX = "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
2282

    
2283
# Auto-repair tag prefixes
2284
AUTO_REPAIR_TAG_PREFIX = "ganeti:watcher:autorepair:"
2285
AUTO_REPAIR_TAG_ENABLED = AUTO_REPAIR_TAG_PREFIX
2286
AUTO_REPAIR_TAG_SUSPENDED = AUTO_REPAIR_TAG_ENABLED + "suspend:"
2287
AUTO_REPAIR_TAG_PENDING = AUTO_REPAIR_TAG_PREFIX + "pending:"
2288
AUTO_REPAIR_TAG_RESULT = AUTO_REPAIR_TAG_PREFIX + "result:"
2289

    
2290
# Auto-repair levels
2291
AUTO_REPAIR_FIX_STORAGE = "fix-storage"
2292
AUTO_REPAIR_MIGRATE = "migrate"
2293
AUTO_REPAIR_FAILOVER = "failover"
2294
AUTO_REPAIR_REINSTALL = "reinstall"
2295
AUTO_REPAIR_ALL_TYPES = [
2296
  AUTO_REPAIR_FIX_STORAGE,
2297
  AUTO_REPAIR_MIGRATE,
2298
  AUTO_REPAIR_FAILOVER,
2299
  AUTO_REPAIR_REINSTALL,
2300
]
2301

    
2302
# Auto-repair results
2303
AUTO_REPAIR_SUCCESS = "success"
2304
AUTO_REPAIR_FAILURE = "failure"
2305
AUTO_REPAIR_ENOPERM = "enoperm"
2306
AUTO_REPAIR_ALL_RESULTS = frozenset([
2307
    AUTO_REPAIR_SUCCESS,
2308
    AUTO_REPAIR_FAILURE,
2309
    AUTO_REPAIR_ENOPERM,
2310
])
2311

    
2312
# Do not re-export imported modules
2313
del re, _vcsversion, _autoconf, socket, pathutils, compat