Statistics
| Branch: | Tag: | Revision:

root / lib / constants.py @ 2fddb144

History | View | Annotate | Download (58.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

    
835

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

    
900
HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
901

    
902
HVS_PARAMETER_TITLES = {
903
  HV_ACPI: "ACPI",
904
  HV_BOOT_ORDER: "Boot_order",
905
  HV_CDROM_IMAGE_PATH: "CDROM_image_path",
906
  HV_DISK_TYPE: "Disk_type",
907
  HV_INITRD_PATH: "Initrd_path",
908
  HV_KERNEL_PATH: "Kernel_path",
909
  HV_NIC_TYPE: "NIC_type",
910
  HV_PAE: "PAE",
911
  HV_VNC_BIND_ADDRESS: "VNC_bind_address",
912
  HV_PASSTHROUGH: "pci_pass",
913
  HV_CPU_TYPE: "cpu_type",
914
  }
915

    
916
# Migration statuses
917
HV_MIGRATION_COMPLETED = "completed"
918
HV_MIGRATION_ACTIVE = "active"
919
HV_MIGRATION_FAILED = "failed"
920
HV_MIGRATION_CANCELLED = "cancelled"
921

    
922
HV_MIGRATION_VALID_STATUSES = compat.UniqueFrozenset([
923
  HV_MIGRATION_COMPLETED,
924
  HV_MIGRATION_ACTIVE,
925
  HV_MIGRATION_FAILED,
926
  HV_MIGRATION_CANCELLED,
927
  ])
928

    
929
HV_MIGRATION_FAILED_STATUSES = compat.UniqueFrozenset([
930
  HV_MIGRATION_FAILED,
931
  HV_MIGRATION_CANCELLED,
932
  ])
933

    
934
# KVM-specific statuses
935
HV_KVM_MIGRATION_VALID_STATUSES = HV_MIGRATION_VALID_STATUSES
936

    
937
# Node info keys
938
HV_NODEINFO_KEY_VERSION = "hv_version"
939

    
940
# Hypervisor state
941
HVST_MEMORY_TOTAL = "mem_total"
942
HVST_MEMORY_NODE = "mem_node"
943
HVST_MEMORY_HV = "mem_hv"
944
HVST_CPU_TOTAL = "cpu_total"
945
HVST_CPU_NODE = "cpu_node"
946

    
947
HVST_DEFAULTS = {
948
  HVST_MEMORY_TOTAL: 0,
949
  HVST_MEMORY_NODE: 0,
950
  HVST_MEMORY_HV: 0,
951
  HVST_CPU_TOTAL: 1,
952
  HVST_CPU_NODE: 1,
953
  }
954

    
955
HVSTS_PARAMETER_TYPES = {
956
  HVST_MEMORY_TOTAL: VTYPE_INT,
957
  HVST_MEMORY_NODE: VTYPE_INT,
958
  HVST_MEMORY_HV: VTYPE_INT,
959
  HVST_CPU_TOTAL: VTYPE_INT,
960
  HVST_CPU_NODE: VTYPE_INT,
961
  }
962

    
963
HVSTS_PARAMETERS = frozenset(HVSTS_PARAMETER_TYPES.keys())
964

    
965
# Disk state
966
DS_DISK_TOTAL = "disk_total"
967
DS_DISK_RESERVED = "disk_reserved"
968
DS_DISK_OVERHEAD = "disk_overhead"
969

    
970
DS_DEFAULTS = {
971
  DS_DISK_TOTAL: 0,
972
  DS_DISK_RESERVED: 0,
973
  DS_DISK_OVERHEAD: 0,
974
  }
975

    
976
DSS_PARAMETER_TYPES = {
977
  DS_DISK_TOTAL: VTYPE_INT,
978
  DS_DISK_RESERVED: VTYPE_INT,
979
  DS_DISK_OVERHEAD: VTYPE_INT,
980
  }
981

    
982
DSS_PARAMETERS = frozenset(DSS_PARAMETER_TYPES.keys())
983
DS_VALID_TYPES = compat.UniqueFrozenset([LD_LV])
984

    
985
# Backend parameter names
986
BE_MEMORY = "memory" # deprecated and replaced by max and min mem
987
BE_MAXMEM = "maxmem"
988
BE_MINMEM = "minmem"
989
BE_VCPUS = "vcpus"
990
BE_AUTO_BALANCE = "auto_balance"
991
BE_ALWAYS_FAILOVER = "always_failover"
992
BE_SPINDLE_USE = "spindle_use"
993

    
994
BES_PARAMETER_TYPES = {
995
  BE_MAXMEM: VTYPE_SIZE,
996
  BE_MINMEM: VTYPE_SIZE,
997
  BE_VCPUS: VTYPE_INT,
998
  BE_AUTO_BALANCE: VTYPE_BOOL,
999
  BE_ALWAYS_FAILOVER: VTYPE_BOOL,
1000
  BE_SPINDLE_USE: VTYPE_INT,
1001
  }
1002

    
1003
BES_PARAMETER_TITLES = {
1004
  BE_AUTO_BALANCE: "Auto_balance",
1005
  BE_MAXMEM: "ConfigMaxMem",
1006
  BE_MINMEM: "ConfigMinMem",
1007
  BE_VCPUS: "ConfigVCPUs",
1008
  }
1009

    
1010
BES_PARAMETER_COMPAT = {
1011
  BE_MEMORY: VTYPE_SIZE,
1012
  }
1013
BES_PARAMETER_COMPAT.update(BES_PARAMETER_TYPES)
1014

    
1015
BES_PARAMETERS = frozenset(BES_PARAMETER_TYPES.keys())
1016

    
1017
# instance specs
1018
ISPEC_MEM_SIZE = "memory-size"
1019
ISPEC_CPU_COUNT = "cpu-count"
1020
ISPEC_DISK_COUNT = "disk-count"
1021
ISPEC_DISK_SIZE = "disk-size"
1022
ISPEC_NIC_COUNT = "nic-count"
1023
ISPEC_SPINDLE_USE = "spindle-use"
1024

    
1025
ISPECS_PARAMETER_TYPES = {
1026
  ISPEC_MEM_SIZE: VTYPE_INT,
1027
  ISPEC_CPU_COUNT: VTYPE_INT,
1028
  ISPEC_DISK_COUNT: VTYPE_INT,
1029
  ISPEC_DISK_SIZE: VTYPE_INT,
1030
  ISPEC_NIC_COUNT: VTYPE_INT,
1031
  ISPEC_SPINDLE_USE: VTYPE_INT,
1032
  }
1033

    
1034
ISPECS_PARAMETERS = frozenset(ISPECS_PARAMETER_TYPES.keys())
1035

    
1036
ISPECS_MIN = "min"
1037
ISPECS_MAX = "max"
1038
ISPECS_STD = "std"
1039
IPOLICY_DTS = "disk-templates"
1040
IPOLICY_VCPU_RATIO = "vcpu-ratio"
1041
IPOLICY_SPINDLE_RATIO = "spindle-ratio"
1042

    
1043
IPOLICY_ISPECS = compat.UniqueFrozenset([
1044
  ISPECS_MIN,
1045
  ISPECS_MAX,
1046
  ISPECS_STD,
1047
  ])
1048

    
1049
IPOLICY_PARAMETERS = compat.UniqueFrozenset([
1050
  IPOLICY_VCPU_RATIO,
1051
  IPOLICY_SPINDLE_RATIO,
1052
  ])
1053

    
1054
IPOLICY_ALL_KEYS = (IPOLICY_ISPECS |
1055
                    IPOLICY_PARAMETERS |
1056
                    frozenset([IPOLICY_DTS]))
1057

    
1058
# Node parameter names
1059
ND_OOB_PROGRAM = "oob_program"
1060
ND_SPINDLE_COUNT = "spindle_count"
1061
ND_EXCLUSIVE_STORAGE = "exclusive_storage"
1062

    
1063
NDS_PARAMETER_TYPES = {
1064
  ND_OOB_PROGRAM: VTYPE_STRING,
1065
  ND_SPINDLE_COUNT: VTYPE_INT,
1066
  ND_EXCLUSIVE_STORAGE: VTYPE_BOOL,
1067
  }
1068

    
1069
NDS_PARAMETERS = frozenset(NDS_PARAMETER_TYPES.keys())
1070

    
1071
NDS_PARAMETER_TITLES = {
1072
  ND_OOB_PROGRAM: "OutOfBandProgram",
1073
  ND_SPINDLE_COUNT: "SpindleCount",
1074
  ND_EXCLUSIVE_STORAGE: "ExclusiveStorage",
1075
  }
1076

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

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

    
1147
DISK_DT_PARAMETERS = frozenset(DISK_DT_TYPES.keys())
1148

    
1149
# OOB supported commands
1150
OOB_POWER_ON = "power-on"
1151
OOB_POWER_OFF = "power-off"
1152
OOB_POWER_CYCLE = "power-cycle"
1153
OOB_POWER_STATUS = "power-status"
1154
OOB_HEALTH = "health"
1155

    
1156
OOB_COMMANDS = compat.UniqueFrozenset([
1157
  OOB_POWER_ON,
1158
  OOB_POWER_OFF,
1159
  OOB_POWER_CYCLE,
1160
  OOB_POWER_STATUS,
1161
  OOB_HEALTH,
1162
  ])
1163

    
1164
OOB_POWER_STATUS_POWERED = "powered"
1165

    
1166
OOB_TIMEOUT = 60 # 60 seconds
1167
OOB_POWER_DELAY = 2.0 # 2 seconds
1168

    
1169
OOB_STATUS_OK = "OK"
1170
OOB_STATUS_WARNING = "WARNING"
1171
OOB_STATUS_CRITICAL = "CRITICAL"
1172
OOB_STATUS_UNKNOWN = "UNKNOWN"
1173

    
1174
OOB_STATUSES = compat.UniqueFrozenset([
1175
  OOB_STATUS_OK,
1176
  OOB_STATUS_WARNING,
1177
  OOB_STATUS_CRITICAL,
1178
  OOB_STATUS_UNKNOWN,
1179
  ])
1180

    
1181
# Instance Parameters Profile
1182
PP_DEFAULT = "default"
1183

    
1184
# NIC_* constants are used inside the ganeti config
1185
NIC_MODE = "mode"
1186
NIC_LINK = "link"
1187

    
1188
NIC_MODE_BRIDGED = "bridged"
1189
NIC_MODE_ROUTED = "routed"
1190
NIC_MODE_OVS = "openvswitch"
1191
NIC_IP_POOL = "pool"
1192

    
1193
NIC_VALID_MODES = compat.UniqueFrozenset([
1194
  NIC_MODE_BRIDGED,
1195
  NIC_MODE_ROUTED,
1196
  NIC_MODE_OVS,
1197
  ])
1198

    
1199
RESERVE_ACTION = "reserve"
1200
RELEASE_ACTION = "release"
1201

    
1202
# An extra description of the network.
1203
# Can be used by hooks/kvm-vif-bridge to apply different rules
1204
NETWORK_TYPE_PRIVATE = "private"
1205
NETWORK_TYPE_PUBLIC = "public"
1206

    
1207
NETWORK_VALID_TYPES = compat.UniqueFrozenset([
1208
  NETWORK_TYPE_PRIVATE,
1209
  NETWORK_TYPE_PUBLIC,
1210
  ])
1211

    
1212
NICS_PARAMETER_TYPES = {
1213
  NIC_MODE: VTYPE_STRING,
1214
  NIC_LINK: VTYPE_STRING,
1215
  }
1216

    
1217
NICS_PARAMETERS = frozenset(NICS_PARAMETER_TYPES.keys())
1218

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

    
1236
# INIC_* constants are used in opcodes, to create/change nics
1237
INIC_MAC = "mac"
1238
INIC_IP = "ip"
1239
INIC_MODE = "mode"
1240
INIC_LINK = "link"
1241
INIC_NETWORK = "network"
1242
INIC_PARAMS_TYPES = {
1243
  INIC_IP: VTYPE_MAYBE_STRING,
1244
  INIC_LINK: VTYPE_STRING,
1245
  INIC_MAC: VTYPE_STRING,
1246
  INIC_MODE: VTYPE_STRING,
1247
  INIC_NETWORK: VTYPE_MAYBE_STRING,
1248
  }
1249
INIC_PARAMS = frozenset(INIC_PARAMS_TYPES.keys())
1250

    
1251
# Hypervisor constants
1252
HT_XEN_PVM = "xen-pvm"
1253
HT_FAKE = "fake"
1254
HT_XEN_HVM = "xen-hvm"
1255
HT_KVM = "kvm"
1256
HT_CHROOT = "chroot"
1257
HT_LXC = "lxc"
1258
HYPER_TYPES = compat.UniqueFrozenset([
1259
  HT_XEN_PVM,
1260
  HT_FAKE,
1261
  HT_XEN_HVM,
1262
  HT_KVM,
1263
  HT_CHROOT,
1264
  HT_LXC,
1265
  ])
1266
HTS_REQ_PORT = compat.UniqueFrozenset([HT_XEN_HVM, HT_KVM])
1267

    
1268
VNC_BASE_PORT = 5900
1269
VNC_DEFAULT_BIND_ADDRESS = IP4_ADDRESS_ANY
1270

    
1271
# NIC types
1272
HT_NIC_RTL8139 = "rtl8139"
1273
HT_NIC_NE2K_PCI = "ne2k_pci"
1274
HT_NIC_NE2K_ISA = "ne2k_isa"
1275
HT_NIC_I82551 = "i82551"
1276
HT_NIC_I85557B = "i82557b"
1277
HT_NIC_I8259ER = "i82559er"
1278
HT_NIC_PCNET = "pcnet"
1279
HT_NIC_E1000 = "e1000"
1280
HT_NIC_PARAVIRTUAL = HT_DISK_PARAVIRTUAL = "paravirtual"
1281

    
1282
HT_HVM_VALID_NIC_TYPES = compat.UniqueFrozenset([
1283
  HT_NIC_RTL8139,
1284
  HT_NIC_NE2K_PCI,
1285
  HT_NIC_E1000,
1286
  HT_NIC_NE2K_ISA,
1287
  HT_NIC_PARAVIRTUAL,
1288
  ])
1289
HT_KVM_VALID_NIC_TYPES = compat.UniqueFrozenset([
1290
  HT_NIC_RTL8139,
1291
  HT_NIC_NE2K_PCI,
1292
  HT_NIC_NE2K_ISA,
1293
  HT_NIC_I82551,
1294
  HT_NIC_I85557B,
1295
  HT_NIC_I8259ER,
1296
  HT_NIC_PCNET,
1297
  HT_NIC_E1000,
1298
  HT_NIC_PARAVIRTUAL,
1299
  ])
1300

    
1301
# Disk types
1302
HT_DISK_IOEMU = "ioemu"
1303
HT_DISK_IDE = "ide"
1304
HT_DISK_SCSI = "scsi"
1305
HT_DISK_SD = "sd"
1306
HT_DISK_MTD = "mtd"
1307
HT_DISK_PFLASH = "pflash"
1308

    
1309
HT_CACHE_DEFAULT = "default"
1310
HT_CACHE_NONE = "none"
1311
HT_CACHE_WTHROUGH = "writethrough"
1312
HT_CACHE_WBACK = "writeback"
1313
HT_VALID_CACHE_TYPES = compat.UniqueFrozenset([
1314
  HT_CACHE_DEFAULT,
1315
  HT_CACHE_NONE,
1316
  HT_CACHE_WTHROUGH,
1317
  HT_CACHE_WBACK,
1318
  ])
1319

    
1320
HT_HVM_VALID_DISK_TYPES = compat.UniqueFrozenset([
1321
  HT_DISK_PARAVIRTUAL,
1322
  HT_DISK_IOEMU,
1323
  ])
1324
HT_KVM_VALID_DISK_TYPES = compat.UniqueFrozenset([
1325
  HT_DISK_PARAVIRTUAL,
1326
  HT_DISK_IDE,
1327
  HT_DISK_SCSI,
1328
  HT_DISK_SD,
1329
  HT_DISK_MTD,
1330
  HT_DISK_PFLASH,
1331
  ])
1332

    
1333
# Mouse types:
1334
HT_MOUSE_MOUSE = "mouse"
1335
HT_MOUSE_TABLET = "tablet"
1336

    
1337
HT_KVM_VALID_MOUSE_TYPES = compat.UniqueFrozenset([
1338
  HT_MOUSE_MOUSE,
1339
  HT_MOUSE_TABLET,
1340
  ])
1341

    
1342
# Boot order
1343
HT_BO_FLOPPY = "floppy"
1344
HT_BO_CDROM = "cdrom"
1345
HT_BO_DISK = "disk"
1346
HT_BO_NETWORK = "network"
1347

    
1348
HT_KVM_VALID_BO_TYPES = compat.UniqueFrozenset([
1349
  HT_BO_FLOPPY,
1350
  HT_BO_CDROM,
1351
  HT_BO_DISK,
1352
  HT_BO_NETWORK,
1353
  ])
1354

    
1355
# SPICE lossless image compression options
1356
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ = "auto_glz"
1357
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ = "auto_lz"
1358
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC = "quic"
1359
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ = "glz"
1360
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ = "lz"
1361
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF = "off"
1362

    
1363
HT_KVM_SPICE_VALID_LOSSLESS_IMG_COMPR_OPTIONS = compat.UniqueFrozenset([
1364
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ,
1365
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ,
1366
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC,
1367
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ,
1368
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ,
1369
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF,
1370
  ])
1371

    
1372
# SPICE lossy image compression options (valid for both jpeg and zlib-glz)
1373
HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO = "auto"
1374
HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER = "never"
1375
HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS = "always"
1376

    
1377
HT_KVM_SPICE_VALID_LOSSY_IMG_COMPR_OPTIONS = compat.UniqueFrozenset([
1378
  HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO,
1379
  HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER,
1380
  HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS,
1381
  ])
1382

    
1383
# SPICE video stream detection
1384
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF = "off"
1385
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL = "all"
1386
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER = "filter"
1387

    
1388
HT_KVM_SPICE_VALID_VIDEO_STREAM_DETECTION_OPTIONS = compat.UniqueFrozenset([
1389
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF,
1390
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL,
1391
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER,
1392
  ])
1393

    
1394
# Security models
1395
HT_SM_NONE = "none"
1396
HT_SM_USER = "user"
1397
HT_SM_POOL = "pool"
1398

    
1399
HT_KVM_VALID_SM_TYPES = compat.UniqueFrozenset([
1400
  HT_SM_NONE,
1401
  HT_SM_USER,
1402
  HT_SM_POOL,
1403
  ])
1404

    
1405
# Kvm flag values
1406
HT_KVM_ENABLED = "enabled"
1407
HT_KVM_DISABLED = "disabled"
1408

    
1409
HT_KVM_FLAG_VALUES = compat.UniqueFrozenset([HT_KVM_ENABLED, HT_KVM_DISABLED])
1410

    
1411
# Migration type
1412
HT_MIGRATION_LIVE = "live"
1413
HT_MIGRATION_NONLIVE = "non-live"
1414
HT_MIGRATION_MODES = compat.UniqueFrozenset([
1415
  HT_MIGRATION_LIVE,
1416
  HT_MIGRATION_NONLIVE,
1417
  ])
1418

    
1419
# Cluster Verify steps
1420
VERIFY_NPLUSONE_MEM = "nplusone_mem"
1421
VERIFY_OPTIONAL_CHECKS = compat.UniqueFrozenset([VERIFY_NPLUSONE_MEM])
1422

    
1423
# Cluster Verify error classes
1424
CV_TCLUSTER = "cluster"
1425
CV_TNODE = "node"
1426
CV_TINSTANCE = "instance"
1427

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

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

    
1540
CV_ALL_ECODES_STRINGS = \
1541
  compat.UniqueFrozenset(estr for (_, estr, _) in CV_ALL_ECODES)
1542

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

    
1567
# Instance status
1568
INSTST_RUNNING = "running"
1569
INSTST_ADMINDOWN = "ADMIN_down"
1570
INSTST_ADMINOFFLINE = "ADMIN_offline"
1571
INSTST_NODEOFFLINE = "ERROR_nodeoffline"
1572
INSTST_NODEDOWN = "ERROR_nodedown"
1573
INSTST_WRONGNODE = "ERROR_wrongnode"
1574
INSTST_ERRORUP = "ERROR_up"
1575
INSTST_ERRORDOWN = "ERROR_down"
1576
INSTST_ALL = compat.UniqueFrozenset([
1577
  INSTST_RUNNING,
1578
  INSTST_ADMINDOWN,
1579
  INSTST_ADMINOFFLINE,
1580
  INSTST_NODEOFFLINE,
1581
  INSTST_NODEDOWN,
1582
  INSTST_WRONGNODE,
1583
  INSTST_ERRORUP,
1584
  INSTST_ERRORDOWN,
1585
  ])
1586

    
1587
# Admin states
1588
ADMINST_UP = "up"
1589
ADMINST_DOWN = "down"
1590
ADMINST_OFFLINE = "offline"
1591
ADMINST_ALL = compat.UniqueFrozenset([
1592
  ADMINST_UP,
1593
  ADMINST_DOWN,
1594
  ADMINST_OFFLINE,
1595
  ])
1596

    
1597
# Node roles
1598
NR_REGULAR = "R"
1599
NR_MASTER = "M"
1600
NR_MCANDIDATE = "C"
1601
NR_DRAINED = "D"
1602
NR_OFFLINE = "O"
1603
NR_ALL = compat.UniqueFrozenset([
1604
  NR_REGULAR,
1605
  NR_MASTER,
1606
  NR_MCANDIDATE,
1607
  NR_DRAINED,
1608
  NR_OFFLINE,
1609
  ])
1610

    
1611
# SSL certificate check constants (in days)
1612
SSL_CERT_EXPIRATION_WARN = 30
1613
SSL_CERT_EXPIRATION_ERROR = 7
1614

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

    
1638
IALLOCATOR_NEVAC_PRI = "primary-only"
1639
IALLOCATOR_NEVAC_SEC = "secondary-only"
1640
IALLOCATOR_NEVAC_ALL = "all"
1641
IALLOCATOR_NEVAC_MODES = compat.UniqueFrozenset([
1642
  IALLOCATOR_NEVAC_PRI,
1643
  IALLOCATOR_NEVAC_SEC,
1644
  IALLOCATOR_NEVAC_ALL,
1645
  ])
1646

    
1647
# Node evacuation
1648
NODE_EVAC_PRI = "primary-only"
1649
NODE_EVAC_SEC = "secondary-only"
1650
NODE_EVAC_ALL = "all"
1651
NODE_EVAC_MODES = compat.UniqueFrozenset([
1652
  NODE_EVAC_PRI,
1653
  NODE_EVAC_SEC,
1654
  NODE_EVAC_ALL,
1655
  ])
1656

    
1657
# Job queue
1658
JOB_QUEUE_VERSION = 1
1659
JOB_QUEUE_SIZE_HARD_LIMIT = 5000
1660

    
1661
JOB_ID_TEMPLATE = r"\d+"
1662
JOB_FILE_RE = re.compile(r"^job-(%s)$" % JOB_ID_TEMPLATE)
1663

    
1664
# unchanged job return
1665
JOB_NOTCHANGED = "nochange"
1666

    
1667
# Job status
1668
JOB_STATUS_QUEUED = "queued"
1669
JOB_STATUS_WAITING = "waiting"
1670
JOB_STATUS_CANCELING = "canceling"
1671
JOB_STATUS_RUNNING = "running"
1672
JOB_STATUS_CANCELED = "canceled"
1673
JOB_STATUS_SUCCESS = "success"
1674
JOB_STATUS_ERROR = "error"
1675
JOBS_PENDING = compat.UniqueFrozenset([
1676
  JOB_STATUS_QUEUED,
1677
  JOB_STATUS_WAITING,
1678
  JOB_STATUS_CANCELING,
1679
  ])
1680
JOBS_FINALIZED = compat.UniqueFrozenset([
1681
  JOB_STATUS_CANCELED,
1682
  JOB_STATUS_SUCCESS,
1683
  JOB_STATUS_ERROR,
1684
  ])
1685
JOB_STATUS_ALL = compat.UniqueFrozenset([
1686
  JOB_STATUS_RUNNING,
1687
  ]) | JOBS_PENDING | JOBS_FINALIZED
1688

    
1689
# OpCode status
1690
# not yet finalized
1691
OP_STATUS_QUEUED = "queued"
1692
OP_STATUS_WAITING = "waiting"
1693
OP_STATUS_CANCELING = "canceling"
1694
OP_STATUS_RUNNING = "running"
1695
# finalized
1696
OP_STATUS_CANCELED = "canceled"
1697
OP_STATUS_SUCCESS = "success"
1698
OP_STATUS_ERROR = "error"
1699
OPS_FINALIZED = compat.UniqueFrozenset([
1700
  OP_STATUS_CANCELED,
1701
  OP_STATUS_SUCCESS,
1702
  OP_STATUS_ERROR,
1703
  ])
1704

    
1705
# OpCode priority
1706
OP_PRIO_LOWEST = +19
1707
OP_PRIO_HIGHEST = -20
1708

    
1709
OP_PRIO_LOW = +10
1710
OP_PRIO_NORMAL = 0
1711
OP_PRIO_HIGH = -10
1712

    
1713
OP_PRIO_SUBMIT_VALID = compat.UniqueFrozenset([
1714
  OP_PRIO_LOW,
1715
  OP_PRIO_NORMAL,
1716
  OP_PRIO_HIGH,
1717
  ])
1718

    
1719
OP_PRIO_DEFAULT = OP_PRIO_NORMAL
1720

    
1721
# Lock recalculate mode
1722
LOCKS_REPLACE = "replace"
1723
LOCKS_APPEND = "append"
1724

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

    
1734
# Execution log types
1735
ELOG_MESSAGE = "message"
1736
ELOG_REMOTE_IMPORT = "remote-import"
1737
ELOG_JQUEUE_TEST = "jqueue-test"
1738

    
1739
# /etc/hosts modification
1740
ETC_HOSTS_ADD = "add"
1741
ETC_HOSTS_REMOVE = "remove"
1742

    
1743
# Job queue test
1744
JQT_MSGPREFIX = "TESTMSG="
1745
JQT_EXPANDNAMES = "expandnames"
1746
JQT_EXEC = "exec"
1747
JQT_LOGMSG = "logmsg"
1748
JQT_STARTMSG = "startmsg"
1749
JQT_ALL = compat.UniqueFrozenset([
1750
  JQT_EXPANDNAMES,
1751
  JQT_EXEC,
1752
  JQT_LOGMSG,
1753
  JQT_STARTMSG,
1754
  ])
1755

    
1756
# Query resources
1757
QR_CLUSTER = "cluster"
1758
QR_INSTANCE = "instance"
1759
QR_NODE = "node"
1760
QR_LOCK = "lock"
1761
QR_GROUP = "group"
1762
QR_OS = "os"
1763
QR_JOB = "job"
1764
QR_EXPORT = "export"
1765
QR_NETWORK = "network"
1766
QR_EXTSTORAGE = "extstorage"
1767

    
1768
#: List of resources which can be queried using L{opcodes.OpQuery}
1769
QR_VIA_OP = compat.UniqueFrozenset([
1770
  QR_CLUSTER,
1771
  QR_INSTANCE,
1772
  QR_NODE,
1773
  QR_GROUP,
1774
  QR_OS,
1775
  QR_EXPORT,
1776
  QR_NETWORK,
1777
  QR_EXTSTORAGE,
1778
  ])
1779

    
1780
#: List of resources which can be queried using Local UniX Interface
1781
QR_VIA_LUXI = QR_VIA_OP.union([
1782
  QR_LOCK,
1783
  QR_JOB,
1784
  ])
1785

    
1786
#: List of resources which can be queried using RAPI
1787
QR_VIA_RAPI = QR_VIA_LUXI
1788

    
1789
# Query field types
1790
QFT_UNKNOWN = "unknown"
1791
QFT_TEXT = "text"
1792
QFT_BOOL = "bool"
1793
QFT_NUMBER = "number"
1794
QFT_UNIT = "unit"
1795
QFT_TIMESTAMP = "timestamp"
1796
QFT_OTHER = "other"
1797

    
1798
#: All query field types
1799
QFT_ALL = compat.UniqueFrozenset([
1800
  QFT_UNKNOWN,
1801
  QFT_TEXT,
1802
  QFT_BOOL,
1803
  QFT_NUMBER,
1804
  QFT_UNIT,
1805
  QFT_TIMESTAMP,
1806
  QFT_OTHER,
1807
  ])
1808

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

    
1824
RS_ALL = compat.UniqueFrozenset([
1825
  RS_NORMAL,
1826
  RS_UNKNOWN,
1827
  RS_NODATA,
1828
  RS_UNAVAIL,
1829
  RS_OFFLINE,
1830
  ])
1831

    
1832
#: Dictionary with special field cases and their verbose/terse formatting
1833
RSS_DESCRIPTION = {
1834
  RS_UNKNOWN: ("(unknown)", "??"),
1835
  RS_NODATA: ("(nodata)", "?"),
1836
  RS_OFFLINE: ("(offline)", "*"),
1837
  RS_UNAVAIL: ("(unavail)", "-"),
1838
  }
1839

    
1840
# max dynamic devices
1841
MAX_NICS = 8
1842
MAX_DISKS = 16
1843

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

    
1871
SS_FILE_PERMS = 0444
1872

    
1873
# cluster wide default parameters
1874
DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM
1875

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

    
1976
HVC_GLOBALS = compat.UniqueFrozenset([
1977
  HV_MIGRATION_PORT,
1978
  HV_MIGRATION_BANDWIDTH,
1979
  HV_MIGRATION_MODE,
1980
  ])
1981

    
1982
BEC_DEFAULTS = {
1983
  BE_MINMEM: 128,
1984
  BE_MAXMEM: 128,
1985
  BE_VCPUS: 1,
1986
  BE_AUTO_BALANCE: True,
1987
  BE_ALWAYS_FAILOVER: False,
1988
  BE_SPINDLE_USE: 1,
1989
  }
1990

    
1991
NDC_DEFAULTS = {
1992
  ND_OOB_PROGRAM: "",
1993
  ND_SPINDLE_COUNT: 1,
1994
  ND_EXCLUSIVE_STORAGE: False,
1995
  }
1996

    
1997
DISK_LD_DEFAULTS = {
1998
  LD_DRBD8: {
1999
    LDP_RESYNC_RATE: CLASSIC_DRBD_SYNC_SPEED,
2000
    LDP_BARRIERS: _autoconf.DRBD_BARRIERS,
2001
    LDP_NO_META_FLUSH: _autoconf.DRBD_NO_META_FLUSH,
2002
    LDP_DEFAULT_METAVG: DEFAULT_VG,
2003
    LDP_DISK_CUSTOM: "",
2004
    LDP_NET_CUSTOM: "",
2005
    LDP_DYNAMIC_RESYNC: False,
2006

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

    
2029
# readability shortcuts
2030
_LV_DEFAULTS = DISK_LD_DEFAULTS[LD_LV]
2031
_DRBD_DEFAULTS = DISK_LD_DEFAULTS[LD_DRBD8]
2032

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

    
2063
# we don't want to export the shortcuts
2064
del _LV_DEFAULTS, _DRBD_DEFAULTS
2065

    
2066
NICC_DEFAULTS = {
2067
  NIC_MODE: NIC_MODE_BRIDGED,
2068
  NIC_LINK: DEFAULT_BRIDGE,
2069
  }
2070

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

    
2103
MASTER_POOL_SIZE_DEFAULT = 10
2104

    
2105
# Exclusive storage:
2106
# Error margin used to compare physical disks
2107
PART_MARGIN = .01
2108
# Space reserved when creating instance disks
2109
PART_RESERVED = .02
2110

    
2111
CONFD_PROTOCOL_VERSION = 1
2112

    
2113
CONFD_REQ_PING = 0
2114
CONFD_REQ_NODE_ROLE_BYNAME = 1
2115
CONFD_REQ_NODE_PIP_BY_INSTANCE_IP = 2
2116
CONFD_REQ_CLUSTER_MASTER = 3
2117
CONFD_REQ_NODE_PIP_LIST = 4
2118
CONFD_REQ_MC_PIP_LIST = 5
2119
CONFD_REQ_INSTANCES_IPS_LIST = 6
2120
CONFD_REQ_NODE_DRBD = 7
2121

    
2122
# Confd request query fields. These are used to narrow down queries.
2123
# These must be strings rather than integers, because json-encoding
2124
# converts them to strings anyway, as they're used as dict-keys.
2125
CONFD_REQQ_LINK = "0"
2126
CONFD_REQQ_IP = "1"
2127
CONFD_REQQ_IPLIST = "2"
2128
CONFD_REQQ_FIELDS = "3"
2129

    
2130
CONFD_REQFIELD_NAME = "0"
2131
CONFD_REQFIELD_IP = "1"
2132
CONFD_REQFIELD_MNODE_PIP = "2"
2133

    
2134
CONFD_REQS = compat.UniqueFrozenset([
2135
  CONFD_REQ_PING,
2136
  CONFD_REQ_NODE_ROLE_BYNAME,
2137
  CONFD_REQ_NODE_PIP_BY_INSTANCE_IP,
2138
  CONFD_REQ_CLUSTER_MASTER,
2139
  CONFD_REQ_NODE_PIP_LIST,
2140
  CONFD_REQ_MC_PIP_LIST,
2141
  CONFD_REQ_INSTANCES_IPS_LIST,
2142
  CONFD_REQ_NODE_DRBD,
2143
  ])
2144

    
2145
CONFD_REPL_STATUS_OK = 0
2146
CONFD_REPL_STATUS_ERROR = 1
2147
CONFD_REPL_STATUS_NOTIMPLEMENTED = 2
2148

    
2149
CONFD_REPL_STATUSES = compat.UniqueFrozenset([
2150
  CONFD_REPL_STATUS_OK,
2151
  CONFD_REPL_STATUS_ERROR,
2152
  CONFD_REPL_STATUS_NOTIMPLEMENTED,
2153
  ])
2154

    
2155
(CONFD_NODE_ROLE_MASTER,
2156
 CONFD_NODE_ROLE_CANDIDATE,
2157
 CONFD_NODE_ROLE_OFFLINE,
2158
 CONFD_NODE_ROLE_DRAINED,
2159
 CONFD_NODE_ROLE_REGULAR,
2160
 ) = range(5)
2161

    
2162
# A few common errors for confd
2163
CONFD_ERROR_UNKNOWN_ENTRY = 1
2164
CONFD_ERROR_INTERNAL = 2
2165
CONFD_ERROR_ARGUMENT = 3
2166

    
2167
# Each request is "salted" by the current timestamp.
2168
# This constants decides how many seconds of skew to accept.
2169
# TODO: make this a default and allow the value to be more configurable
2170
CONFD_MAX_CLOCK_SKEW = 2 * NODE_MAX_CLOCK_SKEW
2171

    
2172
# When we haven't reloaded the config for more than this amount of seconds, we
2173
# force a test to see if inotify is betraying us.
2174
CONFD_CONFIG_RELOAD_TIMEOUT = 60
2175

    
2176
# If we receive more than one update in this amount of seconds, we move to
2177
# polling every RATELIMIT seconds, rather than relying on inotify, to be able
2178
# to serve more requests.
2179
CONFD_CONFIG_RELOAD_RATELIMIT = 2
2180

    
2181
# Magic number prepended to all confd queries.
2182
# This allows us to distinguish different types of confd protocols and handle
2183
# them. For example by changing this we can move the whole payload to be
2184
# compressed, or move away from json.
2185
CONFD_MAGIC_FOURCC = "plj0"
2186

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

    
2192
# Timeout in seconds to expire pending query request in the confd client
2193
# library. We don't actually expect any answer more than 10 seconds after we
2194
# sent a request.
2195
CONFD_CLIENT_EXPIRE_TIMEOUT = 10
2196

    
2197
# Maximum UDP datagram size.
2198
# On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
2199
# On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
2200
#   (assuming we can't use jumbo frames)
2201
# We just set this to 60K, which should be enough
2202
MAX_UDP_DATA_SIZE = 61440
2203

    
2204
# User-id pool minimum/maximum acceptable user-ids.
2205
UIDPOOL_UID_MIN = 0
2206
UIDPOOL_UID_MAX = 2 ** 32 - 1 # Assuming 32 bit user-ids
2207

    
2208
# Name or path of the pgrep command
2209
PGREP = "pgrep"
2210

    
2211
# Name of the node group that gets created at cluster init or upgrade
2212
INITIAL_NODE_GROUP_NAME = "default"
2213

    
2214
# Possible values for NodeGroup.alloc_policy
2215
ALLOC_POLICY_PREFERRED = "preferred"
2216
ALLOC_POLICY_LAST_RESORT = "last_resort"
2217
ALLOC_POLICY_UNALLOCABLE = "unallocable"
2218
VALID_ALLOC_POLICIES = [
2219
  ALLOC_POLICY_PREFERRED,
2220
  ALLOC_POLICY_LAST_RESORT,
2221
  ALLOC_POLICY_UNALLOCABLE,
2222
  ]
2223

    
2224
# Temporary external/shared storage parameters
2225
BLOCKDEV_DRIVER_MANUAL = "manual"
2226

    
2227
# qemu-img path, required for ovfconverter
2228
QEMUIMG_PATH = _autoconf.QEMUIMG_PATH
2229

    
2230
# Whether htools was enabled at compilation time
2231
HTOOLS = _autoconf.HTOOLS
2232
# The hail iallocator
2233
IALLOC_HAIL = "hail"
2234

    
2235
# Fake opcodes for functions that have hooks attached to them via
2236
# backend.RunLocalHooks
2237
FAKE_OP_MASTER_TURNUP = "OP_CLUSTER_IP_TURNUP"
2238
FAKE_OP_MASTER_TURNDOWN = "OP_CLUSTER_IP_TURNDOWN"
2239

    
2240
# SSH key types
2241
SSHK_RSA = "rsa"
2242
SSHK_DSA = "dsa"
2243
SSHK_ALL = compat.UniqueFrozenset([SSHK_RSA, SSHK_DSA])
2244

    
2245
# SSH authorized key types
2246
SSHAK_RSA = "ssh-rsa"
2247
SSHAK_DSS = "ssh-dss"
2248
SSHAK_ALL = compat.UniqueFrozenset([SSHAK_RSA, SSHAK_DSS])
2249

    
2250
# SSH setup
2251
SSHS_CLUSTER_NAME = "cluster_name"
2252
SSHS_SSH_HOST_KEY = "ssh_host_key"
2253
SSHS_SSH_ROOT_KEY = "ssh_root_key"
2254
SSHS_NODE_DAEMON_CERTIFICATE = "node_daemon_certificate"
2255

    
2256
#: Key files for SSH daemon
2257
SSH_DAEMON_KEYFILES = {
2258
  SSHK_RSA: (pathutils.SSH_HOST_RSA_PRIV, pathutils.SSH_HOST_RSA_PUB),
2259
  SSHK_DSA: (pathutils.SSH_HOST_DSA_PRIV, pathutils.SSH_HOST_DSA_PUB),
2260
  }
2261

    
2262
# Node daemon setup
2263
NDS_CLUSTER_NAME = "cluster_name"
2264
NDS_NODE_DAEMON_CERTIFICATE = "node_daemon_certificate"
2265
NDS_SSCONF = "ssconf"
2266
NDS_START_NODE_DAEMON = "start_node_daemon"
2267

    
2268
# Path generating random UUID
2269
RANDOM_UUID_FILE = "/proc/sys/kernel/random/uuid"
2270

    
2271
# Regex string for verifying a UUID
2272
UUID_REGEX = "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
2273

    
2274
# Do not re-export imported modules
2275
del re, _vcsversion, _autoconf, socket, pathutils, compat