Statistics
| Branch: | Tag: | Revision:

root / lib / constants.py @ 57fb6fcb

History | View | Annotate | Download (55 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 pathutils
30

    
31

    
32
# various versions
33
RELEASE_VERSION = _autoconf.PACKAGE_VERSION
34
OS_API_V10 = 10
35
OS_API_V15 = 15
36
OS_API_V20 = 20
37
OS_API_VERSIONS = frozenset([OS_API_V10, OS_API_V15, OS_API_V20])
38
VCS_VERSION = _vcsversion.VCS_VERSION
39
EXPORT_VERSION = 0
40
RAPI_VERSION = 2
41

    
42

    
43
# Format for CONFIG_VERSION:
44
#   01 03 0123 = 01030123
45
#   ^^ ^^ ^^^^
46
#   |  |  + Configuration version/revision
47
#   |  + Minor version
48
#   + Major version
49
#
50
# It is stored as an integer. Make sure not to write an octal number.
51

    
52
# BuildVersion and SplitVersion must be in here because we can't import other
53
# modules. The cfgupgrade tool must be able to read and write version numbers
54
# and thus requires these functions. To avoid code duplication, they're kept in
55
# here.
56

    
57
def BuildVersion(major, minor, revision):
58
  """Calculates int version number from major, minor and revision numbers.
59

60
  Returns: int representing version number
61

62
  """
63
  assert isinstance(major, int)
64
  assert isinstance(minor, int)
65
  assert isinstance(revision, int)
66
  return (1000000 * major +
67
            10000 * minor +
68
                1 * revision)
69

    
70

    
71
def SplitVersion(version):
72
  """Splits version number stored in an int.
73

74
  Returns: tuple; (major, minor, revision)
75

76
  """
77
  assert isinstance(version, int)
78

    
79
  (major, remainder) = divmod(version, 1000000)
80
  (minor, revision) = divmod(remainder, 10000)
81

    
82
  return (major, minor, revision)
83

    
84

    
85
CONFIG_MAJOR = int(_autoconf.VERSION_MAJOR)
86
CONFIG_MINOR = int(_autoconf.VERSION_MINOR)
87
CONFIG_REVISION = 0
88
CONFIG_VERSION = BuildVersion(CONFIG_MAJOR, CONFIG_MINOR, CONFIG_REVISION)
89

    
90
#: RPC protocol version
91
PROTOCOL_VERSION = BuildVersion(CONFIG_MAJOR, CONFIG_MINOR, 0)
92

    
93
# user separation
94
DAEMONS_GROUP = _autoconf.DAEMONS_GROUP
95
ADMIN_GROUP = _autoconf.ADMIN_GROUP
96
MASTERD_USER = _autoconf.MASTERD_USER
97
MASTERD_GROUP = _autoconf.MASTERD_GROUP
98
RAPI_USER = _autoconf.RAPI_USER
99
RAPI_GROUP = _autoconf.RAPI_GROUP
100
CONFD_USER = _autoconf.CONFD_USER
101
CONFD_GROUP = _autoconf.CONFD_GROUP
102
NODED_USER = _autoconf.NODED_USER
103
NODED_GROUP = _autoconf.NODED_GROUP
104
SSH_LOGIN_USER = _autoconf.SSH_LOGIN_USER
105
SSH_CONSOLE_USER = _autoconf.SSH_CONSOLE_USER
106

    
107
# cpu pinning separators and constants
108
CPU_PINNING_SEP = ":"
109
CPU_PINNING_ALL = "all"
110
# internal representation of "all"
111
CPU_PINNING_ALL_VAL = -1
112
# one "all" entry in a CPU list means CPU pinning is off
113
CPU_PINNING_OFF = [CPU_PINNING_ALL_VAL]
114

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

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

    
130
# Wipe
131
DD_CMD = "dd"
132
MAX_WIPE_CHUNK = 1024 # 1GB
133
MIN_WIPE_CHUNK_PERCENT = 10
134

    
135
RUN_DIRS_MODE = 0775
136
SECURE_DIR_MODE = 0700
137
SECURE_FILE_MODE = 0600
138
ADOPTABLE_BLOCKDEV_ROOT = "/dev/disk/"
139
ENABLE_FILE_STORAGE = _autoconf.ENABLE_FILE_STORAGE
140
ENABLE_SHARED_FILE_STORAGE = _autoconf.ENABLE_SHARED_FILE_STORAGE
141
ENABLE_CONFD = _autoconf.ENABLE_CONFD
142
ENABLE_SPLIT_QUERY = _autoconf.ENABLE_SPLIT_QUERY
143
ENABLE_RESTRICTED_COMMANDS = _autoconf.ENABLE_RESTRICTED_COMMANDS
144

    
145
NODED = "ganeti-noded"
146
CONFD = "ganeti-confd"
147
RAPI = "ganeti-rapi"
148
MASTERD = "ganeti-masterd"
149
# used in the ganeti-nbma project
150
NLD = "ganeti-nld"
151

    
152
DAEMONS_PORTS = {
153
  # daemon-name: ("proto", "default-port")
154
  NODED: ("tcp", 1811),
155
  CONFD: ("udp", 1814),
156
  RAPI: ("tcp", 5080),
157
  "ssh": ("tcp", 22),
158
  # used in the ganeti-nbma project
159
  NLD: ("udp", 1816),
160
}
161
DEFAULT_NODED_PORT = DAEMONS_PORTS[NODED][1]
162
DEFAULT_CONFD_PORT = DAEMONS_PORTS[CONFD][1]
163
DEFAULT_RAPI_PORT = DAEMONS_PORTS[RAPI][1]
164
# used in the ganeti-nbma project
165
DEFAULT_NLD_PORT = DAEMONS_PORTS[NLD][1]
166

    
167
FIRST_DRBD_PORT = 11000
168
LAST_DRBD_PORT = 14999
169

    
170
DAEMONS_LOGFILES = {
171
  NODED: pathutils.GetLogFilename("node-daemon"),
172
  CONFD: pathutils.GetLogFilename("conf-daemon"),
173
  RAPI: pathutils.GetLogFilename("rapi-daemon"),
174
  MASTERD: pathutils.GetLogFilename("master-daemon"),
175
  }
176

    
177
DEV_CONSOLE = "/dev/console"
178

    
179
PROC_MOUNTS = "/proc/mounts"
180

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

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

    
192
EXPORT_CONF_FILE = "config.ini"
193

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

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

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

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

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

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

    
231
#: All console types
232
CONS_ALL = frozenset([CONS_SSH, CONS_VNC, CONS_SPICE, CONS_MESSAGE])
233

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

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

    
247
# Digest used to sign certificates ("openssl x509" uses SHA1 by default)
248
X509_CERT_SIGN_DIGEST = "SHA1"
249

    
250
# Default validity of certificates in days
251
X509_CERT_DEFAULT_VALIDITY = 365 * 5
252

    
253
# commonName (CN) used in certificates
254
X509_CERT_CN = "ganeti.example.com"
255

    
256
X509_CERT_SIGNATURE_HEADER = "X-Ganeti-Signature"
257

    
258
# Import/export daemon mode
259
IEM_IMPORT = "import"
260
IEM_EXPORT = "export"
261

    
262
# Import/export transport compression
263
IEC_NONE = "none"
264
IEC_GZIP = "gzip"
265
IEC_ALL = frozenset([
266
  IEC_NONE,
267
  IEC_GZIP,
268
  ])
269

    
270
IE_CUSTOM_SIZE = "fd"
271

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

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

    
282
VALUE_DEFAULT = "default"
283
VALUE_AUTO = "auto"
284
VALUE_GENERATE = "generate"
285
VALUE_NONE = "none"
286
VALUE_TRUE = "true"
287
VALUE_FALSE = "false"
288

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

    
292
# hooks-related constants
293
HOOKS_PHASE_PRE = "pre"
294
HOOKS_PHASE_POST = "post"
295
HOOKS_NAME_CFGUPDATE = "config-update"
296
HOOKS_NAME_WATCHER = "watcher"
297
HOOKS_VERSION = 2
298
HOOKS_PATH = "/sbin:/bin:/usr/sbin:/usr/bin"
299

    
300
# hooks subject type (what object type does the LU deal with)
301
HTYPE_CLUSTER = "CLUSTER"
302
HTYPE_NODE = "NODE"
303
HTYPE_GROUP = "GROUP"
304
HTYPE_INSTANCE = "INSTANCE"
305
HTYPE_NETWORK = "NETWORK"
306

    
307
HKR_SKIP = 0
308
HKR_FAIL = 1
309
HKR_SUCCESS = 2
310

    
311
# Storage types
312
ST_FILE = "file"
313
ST_LVM_PV = "lvm-pv"
314
ST_LVM_VG = "lvm-vg"
315

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

    
327
# Storage operations
328
SO_FIX_CONSISTENCY = "fix-consistency"
329

    
330
# Available fields per storage type
331
VALID_STORAGE_FIELDS = frozenset([
332
  SF_NAME,
333
  SF_TYPE,
334
  SF_SIZE,
335
  SF_USED,
336
  SF_FREE,
337
  SF_ALLOCATABLE,
338
  ])
339

    
340
VALID_STORAGE_TYPES = frozenset([ST_FILE, ST_LVM_PV, ST_LVM_VG])
341

    
342
MODIFIABLE_STORAGE_FIELDS = {
343
  ST_LVM_PV: frozenset([SF_ALLOCATABLE]),
344
  }
345

    
346
VALID_STORAGE_OPERATIONS = {
347
  ST_LVM_VG: frozenset([SO_FIX_CONSISTENCY]),
348
  }
349

    
350
# Local disk status
351
# Note: Code depends on LDS_OKAY < LDS_UNKNOWN < LDS_FAULTY
352
(LDS_OKAY,
353
 LDS_UNKNOWN,
354
 LDS_FAULTY) = range(1, 4)
355

    
356
# disk template types
357
DT_DISKLESS = "diskless"
358
DT_PLAIN = "plain"
359
DT_DRBD8 = "drbd"
360
DT_FILE = "file"
361
DT_SHARED_FILE = "sharedfile"
362
DT_BLOCK = "blockdev"
363
DT_RBD = "rbd"
364

    
365
# the set of network-mirrored disk templates
366
DTS_INT_MIRROR = frozenset([DT_DRBD8])
367

    
368
# the set of externally-mirrored disk templates (e.g. SAN, NAS)
369
DTS_EXT_MIRROR = frozenset([DT_SHARED_FILE, DT_BLOCK, DT_RBD])
370

    
371
# the set of non-lvm-based disk templates
372
DTS_NOT_LVM = frozenset([DT_DISKLESS, DT_FILE, DT_SHARED_FILE,
373
                         DT_BLOCK, DT_RBD])
374

    
375
# the set of disk templates which can be grown
376
DTS_GROWABLE = frozenset([DT_PLAIN, DT_DRBD8, DT_FILE, DT_SHARED_FILE, DT_RBD])
377

    
378
# the set of disk templates that allow adoption
379
DTS_MAY_ADOPT = frozenset([DT_PLAIN, DT_BLOCK])
380

    
381
# the set of disk templates that *must* use adoption
382
DTS_MUST_ADOPT = frozenset([DT_BLOCK])
383

    
384
# the set of disk templates that allow migrations
385
DTS_MIRRORED = frozenset.union(DTS_INT_MIRROR, DTS_EXT_MIRROR)
386

    
387
# the set of file based disk templates
388
DTS_FILEBASED = frozenset([DT_FILE, DT_SHARED_FILE])
389

    
390
# logical disk types
391
LD_LV = "lvm"
392
LD_DRBD8 = "drbd8"
393
LD_FILE = "file"
394
LD_BLOCKDEV = "blockdev"
395
LD_RBD = "rbd"
396
LOGICAL_DISK_TYPES = frozenset([
397
  LD_LV,
398
  LD_DRBD8,
399
  LD_FILE,
400
  LD_BLOCKDEV,
401
  LD_RBD,
402
  ])
403

    
404
LDS_BLOCK = frozenset([LD_LV, LD_DRBD8, LD_BLOCKDEV, LD_RBD])
405

    
406
# drbd constants
407
DRBD_HMAC_ALG = "md5"
408
DRBD_NET_PROTOCOL = "C"
409
DRBD_STATUS_FILE = "/proc/drbd"
410

    
411
#: Size of DRBD meta block device
412
DRBD_META_SIZE = 128
413

    
414
# drbd barrier types
415
DRBD_B_NONE = "n"
416
DRBD_B_DISK_BARRIERS = "b"
417
DRBD_B_DISK_DRAIN = "d"
418
DRBD_B_DISK_FLUSH = "f"
419

    
420
# Valid barrier combinations: "n" or any non-null subset of "bfd"
421
DRBD_VALID_BARRIER_OPT = frozenset([
422
  frozenset([DRBD_B_NONE]),
423
  frozenset([DRBD_B_DISK_BARRIERS]),
424
  frozenset([DRBD_B_DISK_DRAIN]),
425
  frozenset([DRBD_B_DISK_FLUSH]),
426
  frozenset([DRBD_B_DISK_DRAIN, DRBD_B_DISK_FLUSH]),
427
  frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_DRAIN]),
428
  frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_FLUSH]),
429
  frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_FLUSH, DRBD_B_DISK_DRAIN]),
430
  ])
431

    
432
# rbd tool command
433
RBD_CMD = "rbd"
434

    
435
# file backend driver
436
FD_LOOP = "loop"
437
FD_BLKTAP = "blktap"
438

    
439
# the set of drbd-like disk types
440
LDS_DRBD = frozenset([LD_DRBD8])
441

    
442
# disk access mode
443
DISK_RDONLY = "ro"
444
DISK_RDWR = "rw"
445
DISK_ACCESS_SET = frozenset([DISK_RDONLY, DISK_RDWR])
446

    
447
# disk replacement mode
448
REPLACE_DISK_PRI = "replace_on_primary"    # replace disks on primary
449
REPLACE_DISK_SEC = "replace_on_secondary"  # replace disks on secondary
450
REPLACE_DISK_CHG = "replace_new_secondary" # change secondary node
451
REPLACE_DISK_AUTO = "replace_auto"
452
REPLACE_MODES = frozenset([
453
  REPLACE_DISK_PRI,
454
  REPLACE_DISK_SEC,
455
  REPLACE_DISK_CHG,
456
  REPLACE_DISK_AUTO,
457
  ])
458

    
459
# Instance export mode
460
EXPORT_MODE_LOCAL = "local"
461
EXPORT_MODE_REMOTE = "remote"
462
EXPORT_MODES = frozenset([
463
  EXPORT_MODE_LOCAL,
464
  EXPORT_MODE_REMOTE,
465
  ])
466

    
467
# instance creation modes
468
INSTANCE_CREATE = "create"
469
INSTANCE_IMPORT = "import"
470
INSTANCE_REMOTE_IMPORT = "remote-import"
471
INSTANCE_CREATE_MODES = frozenset([
472
  INSTANCE_CREATE,
473
  INSTANCE_IMPORT,
474
  INSTANCE_REMOTE_IMPORT,
475
  ])
476

    
477
# Remote import/export handshake message and version
478
RIE_VERSION = 0
479
RIE_HANDSHAKE = "Hi, I'm Ganeti"
480

    
481
# Remote import/export certificate validity in seconds
482
RIE_CERT_VALIDITY = 24 * 60 * 60
483

    
484
# Overall timeout for establishing connection
485
RIE_CONNECT_TIMEOUT = 180
486

    
487
# Export only: how long to wait per connection attempt (seconds)
488
RIE_CONNECT_ATTEMPT_TIMEOUT = 20
489

    
490
# Export only: number of attempts to connect
491
RIE_CONNECT_RETRIES = 10
492

    
493
#: Give child process up to 5 seconds to exit after sending a signal
494
CHILD_LINGER_TIMEOUT = 5.0
495

    
496
DISK_TEMPLATES = frozenset([
497
  DT_DISKLESS,
498
  DT_PLAIN,
499
  DT_DRBD8,
500
  DT_FILE,
501
  DT_SHARED_FILE,
502
  DT_BLOCK,
503
  DT_RBD,
504
  ])
505

    
506
FILE_DRIVER = frozenset([FD_LOOP, FD_BLKTAP])
507

    
508
# import/export config options
509
INISECT_EXP = "export"
510
INISECT_INS = "instance"
511
INISECT_HYP = "hypervisor"
512
INISECT_BEP = "backend"
513
INISECT_OSP = "os"
514

    
515
# dynamic device modification
516
DDM_ADD = "add"
517
DDM_MODIFY = "modify"
518
DDM_REMOVE = "remove"
519
DDMS_VALUES = frozenset([DDM_ADD, DDM_REMOVE])
520
DDMS_VALUES_WITH_MODIFY = (DDMS_VALUES | frozenset([
521
  DDM_MODIFY,
522
  ]))
523
# TODO: DDM_SWAP, DDM_MOVE?
524

    
525
# common exit codes
526
EXIT_SUCCESS = 0
527
EXIT_FAILURE = 1
528
EXIT_NOTCLUSTER = 5
529
EXIT_NOTMASTER = 11
530
EXIT_NODESETUP_ERROR = 12
531
EXIT_CONFIRMATION = 13 # need user confirmation
532

    
533
#: Exit code for query operations with unknown fields
534
EXIT_UNKNOWN_FIELD = 14
535

    
536
# tags
537
TAG_CLUSTER = "cluster"
538
TAG_NODEGROUP = "nodegroup"
539
TAG_NODE = "node"
540
TAG_INSTANCE = "instance"
541
TAG_NETWORK = "network"
542
VALID_TAG_TYPES = frozenset([
543
  TAG_CLUSTER,
544
  TAG_NODEGROUP,
545
  TAG_NODE,
546
  TAG_INSTANCE,
547
  TAG_NETWORK,
548
  ])
549
MAX_TAG_LEN = 128
550
MAX_TAGS_PER_OBJ = 4096
551

    
552
# others
553
DEFAULT_BRIDGE = "xen-br0"
554
CLASSIC_DRBD_SYNC_SPEED = 60 * 1024  # 60 MiB, expressed in KiB
555
IP4_ADDRESS_LOCALHOST = "127.0.0.1"
556
IP4_ADDRESS_ANY = "0.0.0.0"
557
IP6_ADDRESS_LOCALHOST = "::1"
558
IP6_ADDRESS_ANY = "::"
559
IP4_VERSION = 4
560
IP6_VERSION = 6
561
VALID_IP_VERSIONS = frozenset([IP4_VERSION, IP6_VERSION])
562
# for export to htools
563
IP4_FAMILY = socket.AF_INET
564
IP6_FAMILY = socket.AF_INET6
565

    
566
TCP_PING_TIMEOUT = 10
567
DEFAULT_VG = "xenvg"
568
DEFAULT_DRBD_HELPER = "/bin/true"
569
MIN_VG_SIZE = 20480
570
DEFAULT_MAC_PREFIX = "aa:00:00"
571
# default maximum instance wait time, in seconds.
572
DEFAULT_SHUTDOWN_TIMEOUT = 120
573
NODE_MAX_CLOCK_SKEW = 150
574
# Time for an intra-cluster disk transfer to wait for a connection
575
DISK_TRANSFER_CONNECT_TIMEOUT = 60
576
# Disk index separator
577
DISK_SEPARATOR = _autoconf.DISK_SEPARATOR
578
IP_COMMAND_PATH = _autoconf.IP_PATH
579

    
580
#: Key for job IDs in opcode result
581
JOB_IDS_KEY = "jobs"
582

    
583
# runparts results
584
(RUNPARTS_SKIP,
585
 RUNPARTS_RUN,
586
 RUNPARTS_ERR) = range(3)
587

    
588
RUNPARTS_STATUS = frozenset([RUNPARTS_SKIP, RUNPARTS_RUN, RUNPARTS_ERR])
589

    
590
# RPC constants
591
(RPC_ENCODING_NONE,
592
 RPC_ENCODING_ZLIB_BASE64) = range(2)
593

    
594
# Various time constants for the timeout table
595
RPC_TMO_URGENT = 60 # one minute
596
RPC_TMO_FAST = 5 * 60 # five minutes
597
RPC_TMO_NORMAL = 15 * 60 # 15 minutes
598
RPC_TMO_SLOW = 3600 # one hour
599
RPC_TMO_4HRS = 4 * 3600
600
RPC_TMO_1DAY = 86400
601

    
602
# Timeout for connecting to nodes (seconds)
603
RPC_CONNECT_TIMEOUT = 5
604

    
605
# os related constants
606
OS_SCRIPT_CREATE = "create"
607
OS_SCRIPT_IMPORT = "import"
608
OS_SCRIPT_EXPORT = "export"
609
OS_SCRIPT_RENAME = "rename"
610
OS_SCRIPT_VERIFY = "verify"
611
OS_SCRIPTS = frozenset([
612
  OS_SCRIPT_CREATE,
613
  OS_SCRIPT_IMPORT,
614
  OS_SCRIPT_EXPORT,
615
  OS_SCRIPT_RENAME,
616
  OS_SCRIPT_VERIFY,
617
  ])
618

    
619
OS_API_FILE = "ganeti_api_version"
620
OS_VARIANTS_FILE = "variants.list"
621
OS_PARAMETERS_FILE = "parameters.list"
622

    
623
OS_VALIDATE_PARAMETERS = "parameters"
624
OS_VALIDATE_CALLS = frozenset([OS_VALIDATE_PARAMETERS])
625

    
626
# ssh constants
627
SSH = "ssh"
628
SCP = "scp"
629

    
630
# reboot types
631
INSTANCE_REBOOT_SOFT = "soft"
632
INSTANCE_REBOOT_HARD = "hard"
633
INSTANCE_REBOOT_FULL = "full"
634

    
635
REBOOT_TYPES = frozenset([
636
  INSTANCE_REBOOT_SOFT,
637
  INSTANCE_REBOOT_HARD,
638
  INSTANCE_REBOOT_FULL,
639
  ])
640

    
641
# instance reboot behaviors
642
INSTANCE_REBOOT_ALLOWED = "reboot"
643
INSTANCE_REBOOT_EXIT = "exit"
644

    
645
REBOOT_BEHAVIORS = frozenset([
646
  INSTANCE_REBOOT_ALLOWED,
647
  INSTANCE_REBOOT_EXIT,
648
  ])
649

    
650
VTYPE_STRING = "string"
651
VTYPE_MAYBE_STRING = "maybe-string"
652
VTYPE_BOOL = "bool"
653
VTYPE_SIZE = "size" # size, in MiBs
654
VTYPE_INT = "int"
655
ENFORCEABLE_TYPES = frozenset([
656
  VTYPE_STRING,
657
  VTYPE_MAYBE_STRING,
658
  VTYPE_BOOL,
659
  VTYPE_SIZE,
660
  VTYPE_INT,
661
  ])
662

    
663
# Constant representing that the user does not specify any IP version
664
IFACE_NO_IP_VERSION_SPECIFIED = 0
665

    
666
# HV parameter names (global namespace)
667
HV_BOOT_ORDER = "boot_order"
668
HV_CDROM_IMAGE_PATH = "cdrom_image_path"
669
HV_KVM_CDROM2_IMAGE_PATH = "cdrom2_image_path"
670
HV_KVM_FLOPPY_IMAGE_PATH = "floppy_image_path"
671
HV_NIC_TYPE = "nic_type"
672
HV_DISK_TYPE = "disk_type"
673
HV_KVM_CDROM_DISK_TYPE = "cdrom_disk_type"
674
HV_VNC_BIND_ADDRESS = "vnc_bind_address"
675
HV_VNC_PASSWORD_FILE = "vnc_password_file"
676
HV_VNC_TLS = "vnc_tls"
677
HV_VNC_X509 = "vnc_x509_path"
678
HV_VNC_X509_VERIFY = "vnc_x509_verify"
679
HV_KVM_SPICE_BIND = "spice_bind"
680
HV_KVM_SPICE_IP_VERSION = "spice_ip_version"
681
HV_KVM_SPICE_PASSWORD_FILE = "spice_password_file"
682
HV_KVM_SPICE_LOSSLESS_IMG_COMPR = "spice_image_compression"
683
HV_KVM_SPICE_JPEG_IMG_COMPR = "spice_jpeg_wan_compression"
684
HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR = "spice_zlib_glz_wan_compression"
685
HV_KVM_SPICE_STREAMING_VIDEO_DETECTION = "spice_streaming_video"
686
HV_KVM_SPICE_AUDIO_COMPR = "spice_playback_compression"
687
HV_KVM_SPICE_USE_TLS = "spice_use_tls"
688
HV_KVM_SPICE_TLS_CIPHERS = "spice_tls_ciphers"
689
HV_KVM_SPICE_USE_VDAGENT = "spice_use_vdagent"
690
HV_ACPI = "acpi"
691
HV_PAE = "pae"
692
HV_USE_BOOTLOADER = "use_bootloader"
693
HV_BOOTLOADER_ARGS = "bootloader_args"
694
HV_BOOTLOADER_PATH = "bootloader_path"
695
HV_KERNEL_ARGS = "kernel_args"
696
HV_KERNEL_PATH = "kernel_path"
697
HV_INITRD_PATH = "initrd_path"
698
HV_ROOT_PATH = "root_path"
699
HV_SERIAL_CONSOLE = "serial_console"
700
HV_USB_MOUSE = "usb_mouse"
701
HV_KEYMAP = "keymap"
702
HV_DEVICE_MODEL = "device_model"
703
HV_INIT_SCRIPT = "init_script"
704
HV_MIGRATION_PORT = "migration_port"
705
HV_MIGRATION_BANDWIDTH = "migration_bandwidth"
706
HV_MIGRATION_DOWNTIME = "migration_downtime"
707
HV_MIGRATION_MODE = "migration_mode"
708
HV_USE_LOCALTIME = "use_localtime"
709
HV_DISK_CACHE = "disk_cache"
710
HV_SECURITY_MODEL = "security_model"
711
HV_SECURITY_DOMAIN = "security_domain"
712
HV_KVM_FLAG = "kvm_flag"
713
HV_VHOST_NET = "vhost_net"
714
HV_KVM_USE_CHROOT = "use_chroot"
715
HV_CPU_MASK = "cpu_mask"
716
HV_MEM_PATH = "mem_path"
717
HV_PASSTHROUGH = "pci_pass"
718
HV_BLOCKDEV_PREFIX = "blockdev_prefix"
719
HV_REBOOT_BEHAVIOR = "reboot_behavior"
720
HV_CPU_TYPE = "cpu_type"
721
HV_CPU_CAP = "cpu_cap"
722
HV_CPU_WEIGHT = "cpu_weight"
723

    
724

    
725
HVS_PARAMETER_TYPES = {
726
  HV_BOOT_ORDER: VTYPE_STRING,
727
  HV_KVM_FLOPPY_IMAGE_PATH: VTYPE_STRING,
728
  HV_CDROM_IMAGE_PATH: VTYPE_STRING,
729
  HV_KVM_CDROM2_IMAGE_PATH: VTYPE_STRING,
730
  HV_NIC_TYPE: VTYPE_STRING,
731
  HV_DISK_TYPE: VTYPE_STRING,
732
  HV_KVM_CDROM_DISK_TYPE: VTYPE_STRING,
733
  HV_VNC_PASSWORD_FILE: VTYPE_STRING,
734
  HV_VNC_BIND_ADDRESS: VTYPE_STRING,
735
  HV_VNC_TLS: VTYPE_BOOL,
736
  HV_VNC_X509: VTYPE_STRING,
737
  HV_VNC_X509_VERIFY: VTYPE_BOOL,
738
  HV_KVM_SPICE_BIND: VTYPE_STRING,
739
  HV_KVM_SPICE_IP_VERSION: VTYPE_INT,
740
  HV_KVM_SPICE_PASSWORD_FILE: VTYPE_STRING,
741
  HV_KVM_SPICE_LOSSLESS_IMG_COMPR: VTYPE_STRING,
742
  HV_KVM_SPICE_JPEG_IMG_COMPR: VTYPE_STRING,
743
  HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR: VTYPE_STRING,
744
  HV_KVM_SPICE_STREAMING_VIDEO_DETECTION: VTYPE_STRING,
745
  HV_KVM_SPICE_AUDIO_COMPR: VTYPE_BOOL,
746
  HV_KVM_SPICE_USE_TLS: VTYPE_BOOL,
747
  HV_KVM_SPICE_TLS_CIPHERS: VTYPE_STRING,
748
  HV_KVM_SPICE_USE_VDAGENT: VTYPE_BOOL,
749
  HV_ACPI: VTYPE_BOOL,
750
  HV_PAE: VTYPE_BOOL,
751
  HV_USE_BOOTLOADER: VTYPE_BOOL,
752
  HV_BOOTLOADER_PATH: VTYPE_STRING,
753
  HV_BOOTLOADER_ARGS: VTYPE_STRING,
754
  HV_KERNEL_PATH: VTYPE_STRING,
755
  HV_KERNEL_ARGS: VTYPE_STRING,
756
  HV_INITRD_PATH: VTYPE_STRING,
757
  HV_ROOT_PATH: VTYPE_MAYBE_STRING,
758
  HV_SERIAL_CONSOLE: VTYPE_BOOL,
759
  HV_USB_MOUSE: VTYPE_STRING,
760
  HV_KEYMAP: VTYPE_STRING,
761
  HV_DEVICE_MODEL: VTYPE_STRING,
762
  HV_INIT_SCRIPT: VTYPE_STRING,
763
  HV_MIGRATION_PORT: VTYPE_INT,
764
  HV_MIGRATION_BANDWIDTH: VTYPE_INT,
765
  HV_MIGRATION_DOWNTIME: VTYPE_INT,
766
  HV_MIGRATION_MODE: VTYPE_STRING,
767
  HV_USE_LOCALTIME: VTYPE_BOOL,
768
  HV_DISK_CACHE: VTYPE_STRING,
769
  HV_SECURITY_MODEL: VTYPE_STRING,
770
  HV_SECURITY_DOMAIN: VTYPE_STRING,
771
  HV_KVM_FLAG: VTYPE_STRING,
772
  HV_VHOST_NET: VTYPE_BOOL,
773
  HV_KVM_USE_CHROOT: VTYPE_BOOL,
774
  HV_CPU_MASK: VTYPE_STRING,
775
  HV_MEM_PATH: VTYPE_STRING,
776
  HV_PASSTHROUGH: VTYPE_STRING,
777
  HV_BLOCKDEV_PREFIX: VTYPE_STRING,
778
  HV_REBOOT_BEHAVIOR: VTYPE_STRING,
779
  HV_CPU_TYPE: VTYPE_STRING,
780
  HV_CPU_CAP: VTYPE_INT,
781
  HV_CPU_WEIGHT: VTYPE_INT,
782
  }
783

    
784
HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
785

    
786
HVS_PARAMETER_TITLES = {
787
  HV_ACPI: "ACPI",
788
  HV_BOOT_ORDER: "Boot_order",
789
  HV_CDROM_IMAGE_PATH: "CDROM_image_path",
790
  HV_DISK_TYPE: "Disk_type",
791
  HV_INITRD_PATH: "Initrd_path",
792
  HV_KERNEL_PATH: "Kernel_path",
793
  HV_NIC_TYPE: "NIC_type",
794
  HV_PAE: "PAE",
795
  HV_VNC_BIND_ADDRESS: "VNC_bind_address",
796
  HV_PASSTHROUGH: "pci_pass",
797
  HV_CPU_TYPE: "cpu_type",
798
  }
799

    
800
# Migration statuses
801
HV_MIGRATION_COMPLETED = "completed"
802
HV_MIGRATION_ACTIVE = "active"
803
HV_MIGRATION_FAILED = "failed"
804
HV_MIGRATION_CANCELLED = "cancelled"
805

    
806
HV_MIGRATION_VALID_STATUSES = frozenset([
807
  HV_MIGRATION_COMPLETED,
808
  HV_MIGRATION_ACTIVE,
809
  HV_MIGRATION_FAILED,
810
  HV_MIGRATION_CANCELLED,
811
  ])
812

    
813
HV_MIGRATION_FAILED_STATUSES = frozenset([
814
  HV_MIGRATION_FAILED,
815
  HV_MIGRATION_CANCELLED,
816
  ])
817

    
818
# KVM-specific statuses
819
HV_KVM_MIGRATION_VALID_STATUSES = HV_MIGRATION_VALID_STATUSES
820

    
821
# Node info keys
822
HV_NODEINFO_KEY_VERSION = "hv_version"
823

    
824
# Hypervisor state
825
HVST_MEMORY_TOTAL = "mem_total"
826
HVST_MEMORY_NODE = "mem_node"
827
HVST_MEMORY_HV = "mem_hv"
828
HVST_CPU_TOTAL = "cpu_total"
829
HVST_CPU_NODE = "cpu_node"
830

    
831
HVST_DEFAULTS = {
832
  HVST_MEMORY_TOTAL: 0,
833
  HVST_MEMORY_NODE: 0,
834
  HVST_MEMORY_HV: 0,
835
  HVST_CPU_TOTAL: 1,
836
  HVST_CPU_NODE: 1,
837
  }
838

    
839
HVSTS_PARAMETER_TYPES = {
840
  HVST_MEMORY_TOTAL: VTYPE_INT,
841
  HVST_MEMORY_NODE: VTYPE_INT,
842
  HVST_MEMORY_HV: VTYPE_INT,
843
  HVST_CPU_TOTAL: VTYPE_INT,
844
  HVST_CPU_NODE: VTYPE_INT,
845
  }
846

    
847
HVSTS_PARAMETERS = frozenset(HVSTS_PARAMETER_TYPES.keys())
848

    
849
# Disk state
850
DS_DISK_TOTAL = "disk_total"
851
DS_DISK_RESERVED = "disk_reserved"
852
DS_DISK_OVERHEAD = "disk_overhead"
853

    
854
DS_DEFAULTS = {
855
  DS_DISK_TOTAL: 0,
856
  DS_DISK_RESERVED: 0,
857
  DS_DISK_OVERHEAD: 0,
858
  }
859

    
860
DSS_PARAMETER_TYPES = {
861
  DS_DISK_TOTAL: VTYPE_INT,
862
  DS_DISK_RESERVED: VTYPE_INT,
863
  DS_DISK_OVERHEAD: VTYPE_INT,
864
  }
865

    
866
DSS_PARAMETERS = frozenset(DSS_PARAMETER_TYPES.keys())
867
DS_VALID_TYPES = frozenset([LD_LV])
868

    
869
# Backend parameter names
870
BE_MEMORY = "memory" # deprecated and replaced by max and min mem
871
BE_MAXMEM = "maxmem"
872
BE_MINMEM = "minmem"
873
BE_VCPUS = "vcpus"
874
BE_AUTO_BALANCE = "auto_balance"
875
BE_ALWAYS_FAILOVER = "always_failover"
876
BE_SPINDLE_USE = "spindle_use"
877

    
878
BES_PARAMETER_TYPES = {
879
  BE_MAXMEM: VTYPE_SIZE,
880
  BE_MINMEM: VTYPE_SIZE,
881
  BE_VCPUS: VTYPE_INT,
882
  BE_AUTO_BALANCE: VTYPE_BOOL,
883
  BE_ALWAYS_FAILOVER: VTYPE_BOOL,
884
  BE_SPINDLE_USE: VTYPE_INT,
885
  }
886

    
887
BES_PARAMETER_TITLES = {
888
  BE_AUTO_BALANCE: "Auto_balance",
889
  BE_MAXMEM: "ConfigMaxMem",
890
  BE_MINMEM: "ConfigMinMem",
891
  BE_VCPUS: "ConfigVCPUs",
892
  }
893

    
894
BES_PARAMETER_COMPAT = {
895
  BE_MEMORY: VTYPE_SIZE,
896
  }
897
BES_PARAMETER_COMPAT.update(BES_PARAMETER_TYPES)
898

    
899
BES_PARAMETERS = frozenset(BES_PARAMETER_TYPES.keys())
900

    
901
# instance specs
902
ISPEC_MEM_SIZE = "memory-size"
903
ISPEC_CPU_COUNT = "cpu-count"
904
ISPEC_DISK_COUNT = "disk-count"
905
ISPEC_DISK_SIZE = "disk-size"
906
ISPEC_NIC_COUNT = "nic-count"
907
ISPEC_SPINDLE_USE = "spindle-use"
908

    
909
ISPECS_PARAMETER_TYPES = {
910
  ISPEC_MEM_SIZE: VTYPE_INT,
911
  ISPEC_CPU_COUNT: VTYPE_INT,
912
  ISPEC_DISK_COUNT: VTYPE_INT,
913
  ISPEC_DISK_SIZE: VTYPE_INT,
914
  ISPEC_NIC_COUNT: VTYPE_INT,
915
  ISPEC_SPINDLE_USE: VTYPE_INT,
916
  }
917

    
918
ISPECS_PARAMETERS = frozenset(ISPECS_PARAMETER_TYPES.keys())
919

    
920
ISPECS_MIN = "min"
921
ISPECS_MAX = "max"
922
ISPECS_STD = "std"
923
IPOLICY_DTS = "disk-templates"
924
IPOLICY_VCPU_RATIO = "vcpu-ratio"
925
IPOLICY_SPINDLE_RATIO = "spindle-ratio"
926

    
927
IPOLICY_ISPECS = frozenset([
928
  ISPECS_MIN,
929
  ISPECS_MAX,
930
  ISPECS_STD,
931
  ])
932

    
933
IPOLICY_PARAMETERS = frozenset([
934
  IPOLICY_VCPU_RATIO,
935
  IPOLICY_SPINDLE_RATIO,
936
  ])
937

    
938
IPOLICY_ALL_KEYS = (IPOLICY_ISPECS |
939
                    IPOLICY_PARAMETERS |
940
                    frozenset([IPOLICY_DTS]))
941

    
942
# Node parameter names
943
ND_OOB_PROGRAM = "oob_program"
944
ND_SPINDLE_COUNT = "spindle_count"
945

    
946
NDS_PARAMETER_TYPES = {
947
  ND_OOB_PROGRAM: VTYPE_STRING,
948
  ND_SPINDLE_COUNT: VTYPE_INT,
949
  }
950

    
951
NDS_PARAMETERS = frozenset(NDS_PARAMETER_TYPES.keys())
952

    
953
NDS_PARAMETER_TITLES = {
954
  ND_OOB_PROGRAM: "OutOfBandProgram",
955
  ND_SPINDLE_COUNT: "SpindleCount",
956
  }
957

    
958
# Logical Disks parameters
959
LDP_RESYNC_RATE = "resync-rate"
960
LDP_STRIPES = "stripes"
961
LDP_BARRIERS = "disabled-barriers"
962
LDP_NO_META_FLUSH = "disable-meta-flush"
963
LDP_DEFAULT_METAVG = "default-metavg"
964
LDP_DISK_CUSTOM = "disk-custom"
965
LDP_NET_CUSTOM = "net-custom"
966
LDP_DYNAMIC_RESYNC = "dynamic-resync"
967
LDP_PLAN_AHEAD = "c-plan-ahead"
968
LDP_FILL_TARGET = "c-fill-target"
969
LDP_DELAY_TARGET = "c-delay-target"
970
LDP_MAX_RATE = "c-max-rate"
971
LDP_MIN_RATE = "c-min-rate"
972
LDP_POOL = "pool"
973
DISK_LD_TYPES = {
974
  LDP_RESYNC_RATE: VTYPE_INT,
975
  LDP_STRIPES: VTYPE_INT,
976
  LDP_BARRIERS: VTYPE_STRING,
977
  LDP_NO_META_FLUSH: VTYPE_BOOL,
978
  LDP_DEFAULT_METAVG: VTYPE_STRING,
979
  LDP_DISK_CUSTOM: VTYPE_STRING,
980
  LDP_NET_CUSTOM: VTYPE_STRING,
981
  LDP_DYNAMIC_RESYNC: VTYPE_BOOL,
982
  LDP_PLAN_AHEAD: VTYPE_INT,
983
  LDP_FILL_TARGET: VTYPE_INT,
984
  LDP_DELAY_TARGET: VTYPE_INT,
985
  LDP_MAX_RATE: VTYPE_INT,
986
  LDP_MIN_RATE: VTYPE_INT,
987
  LDP_POOL: VTYPE_STRING,
988
  }
989
DISK_LD_PARAMETERS = frozenset(DISK_LD_TYPES.keys())
990

    
991
# Disk template parameters (can be set/changed by the user via gnt-cluster and
992
# gnt-group)
993
DRBD_RESYNC_RATE = "resync-rate"
994
DRBD_DATA_STRIPES = "data-stripes"
995
DRBD_META_STRIPES = "meta-stripes"
996
DRBD_DISK_BARRIERS = "disk-barriers"
997
DRBD_META_BARRIERS = "meta-barriers"
998
DRBD_DEFAULT_METAVG = "metavg"
999
DRBD_DISK_CUSTOM = "disk-custom"
1000
DRBD_NET_CUSTOM = "net-custom"
1001
DRBD_DYNAMIC_RESYNC = "dynamic-resync"
1002
DRBD_PLAN_AHEAD = "c-plan-ahead"
1003
DRBD_FILL_TARGET = "c-fill-target"
1004
DRBD_DELAY_TARGET = "c-delay-target"
1005
DRBD_MAX_RATE = "c-max-rate"
1006
DRBD_MIN_RATE = "c-min-rate"
1007
LV_STRIPES = "stripes"
1008
RBD_POOL = "pool"
1009
DISK_DT_TYPES = {
1010
  DRBD_RESYNC_RATE: VTYPE_INT,
1011
  DRBD_DATA_STRIPES: VTYPE_INT,
1012
  DRBD_META_STRIPES: VTYPE_INT,
1013
  DRBD_DISK_BARRIERS: VTYPE_STRING,
1014
  DRBD_META_BARRIERS: VTYPE_BOOL,
1015
  DRBD_DEFAULT_METAVG: VTYPE_STRING,
1016
  DRBD_DISK_CUSTOM: VTYPE_STRING,
1017
  DRBD_NET_CUSTOM: VTYPE_STRING,
1018
  DRBD_DYNAMIC_RESYNC: VTYPE_BOOL,
1019
  DRBD_PLAN_AHEAD: VTYPE_INT,
1020
  DRBD_FILL_TARGET: VTYPE_INT,
1021
  DRBD_DELAY_TARGET: VTYPE_INT,
1022
  DRBD_MAX_RATE: VTYPE_INT,
1023
  DRBD_MIN_RATE: VTYPE_INT,
1024
  LV_STRIPES: VTYPE_INT,
1025
  RBD_POOL: VTYPE_STRING,
1026
  }
1027

    
1028
DISK_DT_PARAMETERS = frozenset(DISK_DT_TYPES.keys())
1029

    
1030
# OOB supported commands
1031
OOB_POWER_ON = "power-on"
1032
OOB_POWER_OFF = "power-off"
1033
OOB_POWER_CYCLE = "power-cycle"
1034
OOB_POWER_STATUS = "power-status"
1035
OOB_HEALTH = "health"
1036

    
1037
OOB_COMMANDS = frozenset([
1038
  OOB_POWER_ON,
1039
  OOB_POWER_OFF,
1040
  OOB_POWER_CYCLE,
1041
  OOB_POWER_STATUS,
1042
  OOB_HEALTH,
1043
  ])
1044

    
1045
OOB_POWER_STATUS_POWERED = "powered"
1046

    
1047
OOB_TIMEOUT = 60 # 60 seconds
1048
OOB_POWER_DELAY = 2.0 # 2 seconds
1049

    
1050
OOB_STATUS_OK = "OK"
1051
OOB_STATUS_WARNING = "WARNING"
1052
OOB_STATUS_CRITICAL = "CRITICAL"
1053
OOB_STATUS_UNKNOWN = "UNKNOWN"
1054

    
1055
OOB_STATUSES = frozenset([
1056
  OOB_STATUS_OK,
1057
  OOB_STATUS_WARNING,
1058
  OOB_STATUS_CRITICAL,
1059
  OOB_STATUS_UNKNOWN,
1060
  ])
1061

    
1062
# Instance Parameters Profile
1063
PP_DEFAULT = "default"
1064

    
1065
# NIC_* constants are used inside the ganeti config
1066
NIC_MODE = "mode"
1067
NIC_LINK = "link"
1068

    
1069
NIC_MODE_BRIDGED = "bridged"
1070
NIC_MODE_ROUTED = "routed"
1071
NIC_MODE_OVS = "openvswitch"
1072
NIC_IP_POOL = "pool"
1073

    
1074
NIC_VALID_MODES = frozenset([NIC_MODE_BRIDGED, NIC_MODE_ROUTED, NIC_MODE_OVS])
1075

    
1076
RESERVE_ACTION = "reserve"
1077
RELEASE_ACTION = "release"
1078

    
1079
# An extra description of the network.
1080
# Can be used by hooks/kvm-vif-bridge to apply different rules
1081
NETWORK_TYPE_PRIVATE = "private"
1082
NETWORK_TYPE_PUBLIC = "public"
1083

    
1084
NETWORK_VALID_TYPES = frozenset([NETWORK_TYPE_PRIVATE, NETWORK_TYPE_PUBLIC])
1085

    
1086
NICS_PARAMETER_TYPES = {
1087
  NIC_MODE: VTYPE_STRING,
1088
  NIC_LINK: VTYPE_STRING,
1089
  }
1090

    
1091
NICS_PARAMETERS = frozenset(NICS_PARAMETER_TYPES.keys())
1092

    
1093
# IDISK_* constants are used in opcodes, to create/change disks
1094
IDISK_SIZE = "size"
1095
IDISK_MODE = "mode"
1096
IDISK_ADOPT = "adopt"
1097
IDISK_VG = "vg"
1098
IDISK_METAVG = "metavg"
1099
IDISK_PARAMS_TYPES = {
1100
  IDISK_SIZE: VTYPE_SIZE,
1101
  IDISK_MODE: VTYPE_STRING,
1102
  IDISK_ADOPT: VTYPE_STRING,
1103
  IDISK_VG: VTYPE_STRING,
1104
  IDISK_METAVG: VTYPE_STRING,
1105
  }
1106
IDISK_PARAMS = frozenset(IDISK_PARAMS_TYPES.keys())
1107

    
1108
# INIC_* constants are used in opcodes, to create/change nics
1109
INIC_MAC = "mac"
1110
INIC_IP = "ip"
1111
INIC_MODE = "mode"
1112
INIC_LINK = "link"
1113
INIC_NETWORK = "network"
1114
INIC_PARAMS_TYPES = {
1115
  INIC_IP: VTYPE_MAYBE_STRING,
1116
  INIC_LINK: VTYPE_STRING,
1117
  INIC_MAC: VTYPE_STRING,
1118
  INIC_MODE: VTYPE_STRING,
1119
  INIC_NETWORK: VTYPE_MAYBE_STRING,
1120
  }
1121
INIC_PARAMS = frozenset(INIC_PARAMS_TYPES.keys())
1122

    
1123
# Hypervisor constants
1124
HT_XEN_PVM = "xen-pvm"
1125
HT_FAKE = "fake"
1126
HT_XEN_HVM = "xen-hvm"
1127
HT_KVM = "kvm"
1128
HT_CHROOT = "chroot"
1129
HT_LXC = "lxc"
1130
HYPER_TYPES = frozenset([
1131
  HT_XEN_PVM,
1132
  HT_FAKE,
1133
  HT_XEN_HVM,
1134
  HT_KVM,
1135
  HT_CHROOT,
1136
  HT_LXC,
1137
  ])
1138
HTS_REQ_PORT = frozenset([HT_XEN_HVM, HT_KVM])
1139

    
1140
VNC_BASE_PORT = 5900
1141
VNC_DEFAULT_BIND_ADDRESS = IP4_ADDRESS_ANY
1142

    
1143
# NIC types
1144
HT_NIC_RTL8139 = "rtl8139"
1145
HT_NIC_NE2K_PCI = "ne2k_pci"
1146
HT_NIC_NE2K_ISA = "ne2k_isa"
1147
HT_NIC_I82551 = "i82551"
1148
HT_NIC_I85557B = "i82557b"
1149
HT_NIC_I8259ER = "i82559er"
1150
HT_NIC_PCNET = "pcnet"
1151
HT_NIC_E1000 = "e1000"
1152
HT_NIC_PARAVIRTUAL = HT_DISK_PARAVIRTUAL = "paravirtual"
1153

    
1154
HT_HVM_VALID_NIC_TYPES = frozenset([
1155
  HT_NIC_RTL8139,
1156
  HT_NIC_NE2K_PCI,
1157
  HT_NIC_E1000,
1158
  HT_NIC_NE2K_ISA,
1159
  HT_NIC_PARAVIRTUAL,
1160
  ])
1161
HT_KVM_VALID_NIC_TYPES = frozenset([
1162
  HT_NIC_RTL8139,
1163
  HT_NIC_NE2K_PCI,
1164
  HT_NIC_NE2K_ISA,
1165
  HT_NIC_I82551,
1166
  HT_NIC_I85557B,
1167
  HT_NIC_I8259ER,
1168
  HT_NIC_PCNET,
1169
  HT_NIC_E1000,
1170
  HT_NIC_PARAVIRTUAL,
1171
  ])
1172

    
1173
# Disk types
1174
HT_DISK_IOEMU = "ioemu"
1175
HT_DISK_IDE = "ide"
1176
HT_DISK_SCSI = "scsi"
1177
HT_DISK_SD = "sd"
1178
HT_DISK_MTD = "mtd"
1179
HT_DISK_PFLASH = "pflash"
1180

    
1181
HT_CACHE_DEFAULT = "default"
1182
HT_CACHE_NONE = "none"
1183
HT_CACHE_WTHROUGH = "writethrough"
1184
HT_CACHE_WBACK = "writeback"
1185
HT_VALID_CACHE_TYPES = frozenset([
1186
  HT_CACHE_DEFAULT,
1187
  HT_CACHE_NONE,
1188
  HT_CACHE_WTHROUGH,
1189
  HT_CACHE_WBACK,
1190
  ])
1191

    
1192
HT_HVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IOEMU])
1193
HT_KVM_VALID_DISK_TYPES = frozenset([
1194
  HT_DISK_PARAVIRTUAL,
1195
  HT_DISK_IDE,
1196
  HT_DISK_SCSI,
1197
  HT_DISK_SD,
1198
  HT_DISK_MTD,
1199
  HT_DISK_PFLASH,
1200
  ])
1201

    
1202
# Mouse types:
1203
HT_MOUSE_MOUSE = "mouse"
1204
HT_MOUSE_TABLET = "tablet"
1205

    
1206
HT_KVM_VALID_MOUSE_TYPES = frozenset([HT_MOUSE_MOUSE, HT_MOUSE_TABLET])
1207

    
1208
# Boot order
1209
HT_BO_FLOPPY = "floppy"
1210
HT_BO_CDROM = "cdrom"
1211
HT_BO_DISK = "disk"
1212
HT_BO_NETWORK = "network"
1213

    
1214
HT_KVM_VALID_BO_TYPES = frozenset([
1215
  HT_BO_FLOPPY,
1216
  HT_BO_CDROM,
1217
  HT_BO_DISK,
1218
  HT_BO_NETWORK,
1219
  ])
1220

    
1221
# SPICE lossless image compression options
1222
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ = "auto_glz"
1223
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ = "auto_lz"
1224
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC = "quic"
1225
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ = "glz"
1226
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ = "lz"
1227
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF = "off"
1228

    
1229
HT_KVM_SPICE_VALID_LOSSLESS_IMG_COMPR_OPTIONS = frozenset([
1230
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ,
1231
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ,
1232
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC,
1233
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ,
1234
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ,
1235
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF,
1236
  ])
1237

    
1238
# SPICE lossy image compression options (valid for both jpeg and zlib-glz)
1239
HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO = "auto"
1240
HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER = "never"
1241
HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS = "always"
1242

    
1243
HT_KVM_SPICE_VALID_LOSSY_IMG_COMPR_OPTIONS = frozenset([
1244
  HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO,
1245
  HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER,
1246
  HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS,
1247
  ])
1248

    
1249
# SPICE video stream detection
1250
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF = "off"
1251
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL = "all"
1252
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER = "filter"
1253

    
1254
HT_KVM_SPICE_VALID_VIDEO_STREAM_DETECTION_OPTIONS = frozenset([
1255
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF,
1256
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL,
1257
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER,
1258
  ])
1259

    
1260
# Security models
1261
HT_SM_NONE = "none"
1262
HT_SM_USER = "user"
1263
HT_SM_POOL = "pool"
1264

    
1265
HT_KVM_VALID_SM_TYPES = frozenset([HT_SM_NONE, HT_SM_USER, HT_SM_POOL])
1266

    
1267
# Kvm flag values
1268
HT_KVM_ENABLED = "enabled"
1269
HT_KVM_DISABLED = "disabled"
1270

    
1271
HT_KVM_FLAG_VALUES = frozenset([HT_KVM_ENABLED, HT_KVM_DISABLED])
1272

    
1273
# Migration type
1274
HT_MIGRATION_LIVE = "live"
1275
HT_MIGRATION_NONLIVE = "non-live"
1276
HT_MIGRATION_MODES = frozenset([HT_MIGRATION_LIVE, HT_MIGRATION_NONLIVE])
1277

    
1278
# Cluster Verify steps
1279
VERIFY_NPLUSONE_MEM = "nplusone_mem"
1280
VERIFY_OPTIONAL_CHECKS = frozenset([VERIFY_NPLUSONE_MEM])
1281

    
1282
# Cluster Verify error classes
1283
CV_TCLUSTER = "cluster"
1284
CV_TNODE = "node"
1285
CV_TINSTANCE = "instance"
1286

    
1287
# Cluster Verify error codes and documentation
1288
CV_ECLUSTERCFG = \
1289
  (CV_TCLUSTER, "ECLUSTERCFG", "Cluster configuration verification failure")
1290
CV_ECLUSTERCERT = \
1291
  (CV_TCLUSTER, "ECLUSTERCERT",
1292
   "Cluster certificate files verification failure")
1293
CV_ECLUSTERFILECHECK = \
1294
  (CV_TCLUSTER, "ECLUSTERFILECHECK",
1295
   "Cluster configuration verification failure")
1296
CV_ECLUSTERDANGLINGNODES = \
1297
  (CV_TNODE, "ECLUSTERDANGLINGNODES",
1298
   "Some nodes belong to non-existing groups")
1299
CV_ECLUSTERDANGLINGINST = \
1300
  (CV_TNODE, "ECLUSTERDANGLINGINST",
1301
   "Some instances have a non-existing primary node")
1302
CV_EINSTANCEBADNODE = \
1303
  (CV_TINSTANCE, "EINSTANCEBADNODE",
1304
   "Instance marked as running lives on an offline node")
1305
CV_EINSTANCEDOWN = \
1306
  (CV_TINSTANCE, "EINSTANCEDOWN", "Instance not running on its primary node")
1307
CV_EINSTANCELAYOUT = \
1308
  (CV_TINSTANCE, "EINSTANCELAYOUT", "Instance has multiple secondary nodes")
1309
CV_EINSTANCEMISSINGDISK = \
1310
  (CV_TINSTANCE, "EINSTANCEMISSINGDISK", "Missing volume on an instance")
1311
CV_EINSTANCEFAULTYDISK = \
1312
  (CV_TINSTANCE, "EINSTANCEFAULTYDISK",
1313
   "Impossible to retrieve status for a disk")
1314
CV_EINSTANCEWRONGNODE = \
1315
  (CV_TINSTANCE, "EINSTANCEWRONGNODE", "Instance running on the wrong node")
1316
CV_EINSTANCESPLITGROUPS = \
1317
  (CV_TINSTANCE, "EINSTANCESPLITGROUPS",
1318
   "Instance with primary and secondary nodes in different groups")
1319
CV_EINSTANCEPOLICY = \
1320
  (CV_TINSTANCE, "EINSTANCEPOLICY",
1321
   "Instance does not meet policy")
1322
CV_ENODEDRBD = \
1323
  (CV_TNODE, "ENODEDRBD", "Error parsing the DRBD status file")
1324
CV_ENODEDRBDHELPER = \
1325
  (CV_TNODE, "ENODEDRBDHELPER", "Error caused by the DRBD helper")
1326
CV_ENODEFILECHECK = \
1327
  (CV_TNODE, "ENODEFILECHECK",
1328
   "Error retrieving the checksum of the node files")
1329
CV_ENODEHOOKS = \
1330
  (CV_TNODE, "ENODEHOOKS", "Communication failure in hooks execution")
1331
CV_ENODEHV = \
1332
  (CV_TNODE, "ENODEHV", "Hypervisor parameters verification failure")
1333
CV_ENODELVM = \
1334
  (CV_TNODE, "ENODELVM", "LVM-related node error")
1335
CV_ENODEN1 = \
1336
  (CV_TNODE, "ENODEN1", "Not enough memory to accommodate instance failovers")
1337
CV_ENODENET = \
1338
  (CV_TNODE, "ENODENET", "Network-related node error")
1339
CV_ENODEOS = \
1340
  (CV_TNODE, "ENODEOS", "OS-related node error")
1341
CV_ENODEORPHANINSTANCE = \
1342
  (CV_TNODE, "ENODEORPHANINSTANCE", "Unknown intance running on a node")
1343
CV_ENODEORPHANLV = \
1344
  (CV_TNODE, "ENODEORPHANLV", "Unknown LVM logical volume")
1345
CV_ENODERPC = \
1346
  (CV_TNODE, "ENODERPC",
1347
   "Error during connection to the primary node of an instance")
1348
CV_ENODESSH = \
1349
  (CV_TNODE, "ENODESSH", "SSH-related node error")
1350
CV_ENODEVERSION = \
1351
  (CV_TNODE, "ENODEVERSION",
1352
   "Protocol version mismatch or Ganeti version mismatch")
1353
CV_ENODESETUP = \
1354
  (CV_TNODE, "ENODESETUP", "Node setup error")
1355
CV_ENODETIME = \
1356
  (CV_TNODE, "ENODETIME", "Node returned invalid time")
1357
CV_ENODEOOBPATH = \
1358
  (CV_TNODE, "ENODEOOBPATH", "Invalid Out Of Band path")
1359
CV_ENODEUSERSCRIPTS = \
1360
  (CV_TNODE, "ENODEUSERSCRIPTS", "User scripts not present or not executable")
1361
CV_ENODEFILESTORAGEPATHS = \
1362
  (CV_TNODE, "ENODEFILESTORAGEPATHS", "Detected bad file storage paths")
1363

    
1364
CV_ALL_ECODES = frozenset([
1365
  CV_ECLUSTERCFG,
1366
  CV_ECLUSTERCERT,
1367
  CV_ECLUSTERFILECHECK,
1368
  CV_ECLUSTERDANGLINGNODES,
1369
  CV_ECLUSTERDANGLINGINST,
1370
  CV_EINSTANCEBADNODE,
1371
  CV_EINSTANCEDOWN,
1372
  CV_EINSTANCELAYOUT,
1373
  CV_EINSTANCEMISSINGDISK,
1374
  CV_EINSTANCEFAULTYDISK,
1375
  CV_EINSTANCEWRONGNODE,
1376
  CV_EINSTANCESPLITGROUPS,
1377
  CV_EINSTANCEPOLICY,
1378
  CV_ENODEDRBD,
1379
  CV_ENODEDRBDHELPER,
1380
  CV_ENODEFILECHECK,
1381
  CV_ENODEHOOKS,
1382
  CV_ENODEHV,
1383
  CV_ENODELVM,
1384
  CV_ENODEN1,
1385
  CV_ENODENET,
1386
  CV_ENODEOS,
1387
  CV_ENODEORPHANINSTANCE,
1388
  CV_ENODEORPHANLV,
1389
  CV_ENODERPC,
1390
  CV_ENODESSH,
1391
  CV_ENODEVERSION,
1392
  CV_ENODESETUP,
1393
  CV_ENODETIME,
1394
  CV_ENODEOOBPATH,
1395
  CV_ENODEUSERSCRIPTS,
1396
  CV_ENODEFILESTORAGEPATHS,
1397
  ])
1398

    
1399
CV_ALL_ECODES_STRINGS = frozenset(estr for (_, estr, _) in CV_ALL_ECODES)
1400

    
1401
# Node verify constants
1402
NV_DRBDHELPER = "drbd-helper"
1403
NV_DRBDLIST = "drbd-list"
1404
NV_FILELIST = "filelist"
1405
NV_HVINFO = "hvinfo"
1406
NV_HYPERVISOR = "hypervisor"
1407
NV_HVPARAMS = "hvparms"
1408
NV_INSTANCELIST = "instancelist"
1409
NV_LVLIST = "lvlist"
1410
NV_MASTERIP = "master-ip"
1411
NV_NODELIST = "nodelist"
1412
NV_NODENETTEST = "node-net-test"
1413
NV_NODESETUP = "nodesetup"
1414
NV_OSLIST = "oslist"
1415
NV_PVLIST = "pvlist"
1416
NV_TIME = "time"
1417
NV_VERSION = "version"
1418
NV_VGLIST = "vglist"
1419
NV_VMNODES = "vmnodes"
1420
NV_OOB_PATHS = "oob-paths"
1421
NV_BRIDGES = "bridges"
1422
NV_USERSCRIPTS = "user-scripts"
1423
NV_FILE_STORAGE_PATHS = "file-storage-paths"
1424

    
1425
# Instance status
1426
INSTST_RUNNING = "running"
1427
INSTST_ADMINDOWN = "ADMIN_down"
1428
INSTST_ADMINOFFLINE = "ADMIN_offline"
1429
INSTST_NODEOFFLINE = "ERROR_nodeoffline"
1430
INSTST_NODEDOWN = "ERROR_nodedown"
1431
INSTST_WRONGNODE = "ERROR_wrongnode"
1432
INSTST_ERRORUP = "ERROR_up"
1433
INSTST_ERRORDOWN = "ERROR_down"
1434
INSTST_ALL = frozenset([
1435
  INSTST_RUNNING,
1436
  INSTST_ADMINDOWN,
1437
  INSTST_ADMINOFFLINE,
1438
  INSTST_NODEOFFLINE,
1439
  INSTST_NODEDOWN,
1440
  INSTST_WRONGNODE,
1441
  INSTST_ERRORUP,
1442
  INSTST_ERRORDOWN,
1443
  ])
1444

    
1445
# Admin states
1446
ADMINST_UP = "up"
1447
ADMINST_DOWN = "down"
1448
ADMINST_OFFLINE = "offline"
1449
ADMINST_ALL = frozenset([
1450
  ADMINST_UP,
1451
  ADMINST_DOWN,
1452
  ADMINST_OFFLINE,
1453
  ])
1454

    
1455
# Node roles
1456
NR_REGULAR = "R"
1457
NR_MASTER = "M"
1458
NR_MCANDIDATE = "C"
1459
NR_DRAINED = "D"
1460
NR_OFFLINE = "O"
1461
NR_ALL = frozenset([
1462
  NR_REGULAR,
1463
  NR_MASTER,
1464
  NR_MCANDIDATE,
1465
  NR_DRAINED,
1466
  NR_OFFLINE,
1467
  ])
1468

    
1469
# SSL certificate check constants (in days)
1470
SSL_CERT_EXPIRATION_WARN = 30
1471
SSL_CERT_EXPIRATION_ERROR = 7
1472

    
1473
# Allocator framework constants
1474
IALLOCATOR_VERSION = 2
1475
IALLOCATOR_DIR_IN = "in"
1476
IALLOCATOR_DIR_OUT = "out"
1477
VALID_IALLOCATOR_DIRECTIONS = frozenset([
1478
  IALLOCATOR_DIR_IN,
1479
  IALLOCATOR_DIR_OUT,
1480
  ])
1481
IALLOCATOR_MODE_ALLOC = "allocate"
1482
IALLOCATOR_MODE_RELOC = "relocate"
1483
IALLOCATOR_MODE_CHG_GROUP = "change-group"
1484
IALLOCATOR_MODE_NODE_EVAC = "node-evacuate"
1485
IALLOCATOR_MODE_MULTI_ALLOC = "multi-allocate"
1486
VALID_IALLOCATOR_MODES = frozenset([
1487
  IALLOCATOR_MODE_ALLOC,
1488
  IALLOCATOR_MODE_RELOC,
1489
  IALLOCATOR_MODE_CHG_GROUP,
1490
  IALLOCATOR_MODE_NODE_EVAC,
1491
  IALLOCATOR_MODE_MULTI_ALLOC,
1492
  ])
1493
IALLOCATOR_SEARCH_PATH = _autoconf.IALLOCATOR_SEARCH_PATH
1494
DEFAULT_IALLOCATOR_SHORTCUT = "."
1495

    
1496
IALLOCATOR_NEVAC_PRI = "primary-only"
1497
IALLOCATOR_NEVAC_SEC = "secondary-only"
1498
IALLOCATOR_NEVAC_ALL = "all"
1499
IALLOCATOR_NEVAC_MODES = frozenset([
1500
  IALLOCATOR_NEVAC_PRI,
1501
  IALLOCATOR_NEVAC_SEC,
1502
  IALLOCATOR_NEVAC_ALL,
1503
  ])
1504

    
1505
# Node evacuation
1506
NODE_EVAC_PRI = "primary-only"
1507
NODE_EVAC_SEC = "secondary-only"
1508
NODE_EVAC_ALL = "all"
1509
NODE_EVAC_MODES = frozenset([
1510
  NODE_EVAC_PRI,
1511
  NODE_EVAC_SEC,
1512
  NODE_EVAC_ALL,
1513
  ])
1514

    
1515
# Job queue
1516
JOB_QUEUE_VERSION = 1
1517
JOB_QUEUE_SIZE_HARD_LIMIT = 5000
1518

    
1519
JOB_ID_TEMPLATE = r"\d+"
1520
JOB_FILE_RE = re.compile(r"^job-(%s)$" % JOB_ID_TEMPLATE)
1521

    
1522
# unchanged job return
1523
JOB_NOTCHANGED = "nochange"
1524

    
1525
# Job status
1526
JOB_STATUS_QUEUED = "queued"
1527
JOB_STATUS_WAITING = "waiting"
1528
JOB_STATUS_CANCELING = "canceling"
1529
JOB_STATUS_RUNNING = "running"
1530
JOB_STATUS_CANCELED = "canceled"
1531
JOB_STATUS_SUCCESS = "success"
1532
JOB_STATUS_ERROR = "error"
1533
JOBS_PENDING = frozenset([
1534
  JOB_STATUS_QUEUED,
1535
  JOB_STATUS_WAITING,
1536
  JOB_STATUS_CANCELING,
1537
  ])
1538
JOBS_FINALIZED = frozenset([
1539
  JOB_STATUS_CANCELED,
1540
  JOB_STATUS_SUCCESS,
1541
  JOB_STATUS_ERROR,
1542
  ])
1543
JOB_STATUS_ALL = frozenset([
1544
  JOB_STATUS_RUNNING,
1545
  ]) | JOBS_PENDING | JOBS_FINALIZED
1546

    
1547
# OpCode status
1548
# not yet finalized
1549
OP_STATUS_QUEUED = "queued"
1550
OP_STATUS_WAITING = "waiting"
1551
OP_STATUS_CANCELING = "canceling"
1552
OP_STATUS_RUNNING = "running"
1553
# finalized
1554
OP_STATUS_CANCELED = "canceled"
1555
OP_STATUS_SUCCESS = "success"
1556
OP_STATUS_ERROR = "error"
1557
OPS_FINALIZED = frozenset([
1558
  OP_STATUS_CANCELED,
1559
  OP_STATUS_SUCCESS,
1560
  OP_STATUS_ERROR,
1561
  ])
1562

    
1563
# OpCode priority
1564
OP_PRIO_LOWEST = +19
1565
OP_PRIO_HIGHEST = -20
1566

    
1567
OP_PRIO_LOW = +10
1568
OP_PRIO_NORMAL = 0
1569
OP_PRIO_HIGH = -10
1570

    
1571
OP_PRIO_SUBMIT_VALID = frozenset([
1572
  OP_PRIO_LOW,
1573
  OP_PRIO_NORMAL,
1574
  OP_PRIO_HIGH,
1575
  ])
1576

    
1577
OP_PRIO_DEFAULT = OP_PRIO_NORMAL
1578

    
1579
# Lock recalculate mode
1580
LOCKS_REPLACE = "replace"
1581
LOCKS_APPEND = "append"
1582

    
1583
# Lock timeout (sum) before we should go into blocking acquire (still
1584
# can be reset by priority change); computed as max time (10 hours)
1585
# before we should actually go into blocking acquire given that we
1586
# start from default priority level; in seconds
1587
# TODO
1588
LOCK_ATTEMPTS_TIMEOUT = 10 * 3600 / (OP_PRIO_DEFAULT - OP_PRIO_HIGHEST)
1589
LOCK_ATTEMPTS_MAXWAIT = 15.0
1590
LOCK_ATTEMPTS_MINWAIT = 1.0
1591

    
1592
# Execution log types
1593
ELOG_MESSAGE = "message"
1594
ELOG_REMOTE_IMPORT = "remote-import"
1595
ELOG_JQUEUE_TEST = "jqueue-test"
1596

    
1597
# /etc/hosts modification
1598
ETC_HOSTS_ADD = "add"
1599
ETC_HOSTS_REMOVE = "remove"
1600

    
1601
# Job queue test
1602
JQT_MSGPREFIX = "TESTMSG="
1603
JQT_EXPANDNAMES = "expandnames"
1604
JQT_EXEC = "exec"
1605
JQT_LOGMSG = "logmsg"
1606
JQT_STARTMSG = "startmsg"
1607
JQT_ALL = frozenset([
1608
  JQT_EXPANDNAMES,
1609
  JQT_EXEC,
1610
  JQT_LOGMSG,
1611
  JQT_STARTMSG,
1612
  ])
1613

    
1614
# Query resources
1615
QR_CLUSTER = "cluster"
1616
QR_INSTANCE = "instance"
1617
QR_NODE = "node"
1618
QR_LOCK = "lock"
1619
QR_GROUP = "group"
1620
QR_OS = "os"
1621
QR_JOB = "job"
1622
QR_EXPORT = "export"
1623
QR_NETWORK = "network"
1624

    
1625
#: List of resources which can be queried using L{opcodes.OpQuery}
1626
QR_VIA_OP = frozenset([
1627
  QR_CLUSTER,
1628
  QR_INSTANCE,
1629
  QR_NODE,
1630
  QR_GROUP,
1631
  QR_OS,
1632
  QR_EXPORT,
1633
  QR_NETWORK,
1634
  ])
1635

    
1636
#: List of resources which can be queried using Local UniX Interface
1637
QR_VIA_LUXI = QR_VIA_OP.union([
1638
  QR_LOCK,
1639
  QR_JOB,
1640
  ])
1641

    
1642
#: List of resources which can be queried using RAPI
1643
QR_VIA_RAPI = QR_VIA_LUXI
1644

    
1645
# Query field types
1646
QFT_UNKNOWN = "unknown"
1647
QFT_TEXT = "text"
1648
QFT_BOOL = "bool"
1649
QFT_NUMBER = "number"
1650
QFT_UNIT = "unit"
1651
QFT_TIMESTAMP = "timestamp"
1652
QFT_OTHER = "other"
1653

    
1654
#: All query field types
1655
QFT_ALL = frozenset([
1656
  QFT_UNKNOWN,
1657
  QFT_TEXT,
1658
  QFT_BOOL,
1659
  QFT_NUMBER,
1660
  QFT_UNIT,
1661
  QFT_TIMESTAMP,
1662
  QFT_OTHER,
1663
  ])
1664

    
1665
# Query result field status (don't change or reuse values as they're used by
1666
# clients)
1667
#: Normal field status
1668
RS_NORMAL = 0
1669
#: Unknown field
1670
RS_UNKNOWN = 1
1671
#: No data (e.g. RPC error), can be used instead of L{RS_OFFLINE}
1672
RS_NODATA = 2
1673
#: Value unavailable/unsupported for item; if this field is supported
1674
#: but we cannot get the data for the moment, RS_NODATA or
1675
#: RS_OFFLINE should be used
1676
RS_UNAVAIL = 3
1677
#: Resource marked offline
1678
RS_OFFLINE = 4
1679

    
1680
RS_ALL = frozenset([
1681
  RS_NORMAL,
1682
  RS_UNKNOWN,
1683
  RS_NODATA,
1684
  RS_UNAVAIL,
1685
  RS_OFFLINE,
1686
  ])
1687

    
1688
#: Dictionary with special field cases and their verbose/terse formatting
1689
RSS_DESCRIPTION = {
1690
  RS_UNKNOWN: ("(unknown)", "??"),
1691
  RS_NODATA: ("(nodata)", "?"),
1692
  RS_OFFLINE: ("(offline)", "*"),
1693
  RS_UNAVAIL: ("(unavail)", "-"),
1694
  }
1695

    
1696
# max dynamic devices
1697
MAX_NICS = 8
1698
MAX_DISKS = 16
1699

    
1700
# SSCONF file prefix
1701
SSCONF_FILEPREFIX = "ssconf_"
1702
# SSCONF keys
1703
SS_CLUSTER_NAME = "cluster_name"
1704
SS_CLUSTER_TAGS = "cluster_tags"
1705
SS_FILE_STORAGE_DIR = "file_storage_dir"
1706
SS_SHARED_FILE_STORAGE_DIR = "shared_file_storage_dir"
1707
SS_MASTER_CANDIDATES = "master_candidates"
1708
SS_MASTER_CANDIDATES_IPS = "master_candidates_ips"
1709
SS_MASTER_IP = "master_ip"
1710
SS_MASTER_NETDEV = "master_netdev"
1711
SS_MASTER_NETMASK = "master_netmask"
1712
SS_MASTER_NODE = "master_node"
1713
SS_NODE_LIST = "node_list"
1714
SS_NODE_PRIMARY_IPS = "node_primary_ips"
1715
SS_NODE_SECONDARY_IPS = "node_secondary_ips"
1716
SS_OFFLINE_NODES = "offline_nodes"
1717
SS_ONLINE_NODES = "online_nodes"
1718
SS_PRIMARY_IP_FAMILY = "primary_ip_family"
1719
SS_INSTANCE_LIST = "instance_list"
1720
SS_RELEASE_VERSION = "release_version"
1721
SS_HYPERVISOR_LIST = "hypervisor_list"
1722
SS_MAINTAIN_NODE_HEALTH = "maintain_node_health"
1723
SS_UID_POOL = "uid_pool"
1724
SS_NODEGROUPS = "nodegroups"
1725
SS_NETWORKS = "networks"
1726

    
1727
SS_FILE_PERMS = 0444
1728

    
1729
# cluster wide default parameters
1730
DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM
1731

    
1732
HVC_DEFAULTS = {
1733
  HT_XEN_PVM: {
1734
    HV_USE_BOOTLOADER: False,
1735
    HV_BOOTLOADER_PATH: XEN_BOOTLOADER,
1736
    HV_BOOTLOADER_ARGS: "",
1737
    HV_KERNEL_PATH: XEN_KERNEL,
1738
    HV_INITRD_PATH: "",
1739
    HV_ROOT_PATH: "/dev/sda1",
1740
    HV_KERNEL_ARGS: "ro",
1741
    HV_MIGRATION_PORT: 8002,
1742
    HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1743
    HV_BLOCKDEV_PREFIX: "sd",
1744
    HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1745
    HV_CPU_MASK: CPU_PINNING_ALL,
1746
    HV_CPU_CAP: 0,
1747
    HV_CPU_WEIGHT: 256,
1748
    },
1749
  HT_XEN_HVM: {
1750
    HV_BOOT_ORDER: "cd",
1751
    HV_CDROM_IMAGE_PATH: "",
1752
    HV_NIC_TYPE: HT_NIC_RTL8139,
1753
    HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
1754
    HV_VNC_BIND_ADDRESS: IP4_ADDRESS_ANY,
1755
    HV_VNC_PASSWORD_FILE: pathutils.VNC_PASSWORD_FILE,
1756
    HV_ACPI: True,
1757
    HV_PAE: True,
1758
    HV_KERNEL_PATH: "/usr/lib/xen/boot/hvmloader",
1759
    HV_DEVICE_MODEL: "/usr/lib/xen/bin/qemu-dm",
1760
    HV_MIGRATION_PORT: 8002,
1761
    HV_MIGRATION_MODE: HT_MIGRATION_NONLIVE,
1762
    HV_USE_LOCALTIME: False,
1763
    HV_BLOCKDEV_PREFIX: "hd",
1764
    HV_PASSTHROUGH: "",
1765
    HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1766
    HV_CPU_MASK: CPU_PINNING_ALL,
1767
    HV_CPU_CAP: 0,
1768
    HV_CPU_WEIGHT: 256,
1769
    },
1770
  HT_KVM: {
1771
    HV_KERNEL_PATH: KVM_KERNEL,
1772
    HV_INITRD_PATH: "",
1773
    HV_KERNEL_ARGS: "ro",
1774
    HV_ROOT_PATH: "/dev/vda1",
1775
    HV_ACPI: True,
1776
    HV_SERIAL_CONSOLE: True,
1777
    HV_VNC_BIND_ADDRESS: "",
1778
    HV_VNC_TLS: False,
1779
    HV_VNC_X509: "",
1780
    HV_VNC_X509_VERIFY: False,
1781
    HV_VNC_PASSWORD_FILE: "",
1782
    HV_KVM_SPICE_BIND: "",
1783
    HV_KVM_SPICE_IP_VERSION: IFACE_NO_IP_VERSION_SPECIFIED,
1784
    HV_KVM_SPICE_PASSWORD_FILE: "",
1785
    HV_KVM_SPICE_LOSSLESS_IMG_COMPR: "",
1786
    HV_KVM_SPICE_JPEG_IMG_COMPR: "",
1787
    HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR: "",
1788
    HV_KVM_SPICE_STREAMING_VIDEO_DETECTION: "",
1789
    HV_KVM_SPICE_AUDIO_COMPR: True,
1790
    HV_KVM_SPICE_USE_TLS: False,
1791
    HV_KVM_SPICE_TLS_CIPHERS: OPENSSL_CIPHERS,
1792
    HV_KVM_SPICE_USE_VDAGENT: True,
1793
    HV_KVM_FLOPPY_IMAGE_PATH: "",
1794
    HV_CDROM_IMAGE_PATH: "",
1795
    HV_KVM_CDROM2_IMAGE_PATH: "",
1796
    HV_BOOT_ORDER: HT_BO_DISK,
1797
    HV_NIC_TYPE: HT_NIC_PARAVIRTUAL,
1798
    HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
1799
    HV_KVM_CDROM_DISK_TYPE: "",
1800
    HV_USB_MOUSE: "",
1801
    HV_KEYMAP: "",
1802
    HV_MIGRATION_PORT: 8102,
1803
    HV_MIGRATION_BANDWIDTH: 32, # MiB/s
1804
    HV_MIGRATION_DOWNTIME: 30,  # ms
1805
    HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1806
    HV_USE_LOCALTIME: False,
1807
    HV_DISK_CACHE: HT_CACHE_DEFAULT,
1808
    HV_SECURITY_MODEL: HT_SM_NONE,
1809
    HV_SECURITY_DOMAIN: "",
1810
    HV_KVM_FLAG: "",
1811
    HV_VHOST_NET: False,
1812
    HV_KVM_USE_CHROOT: False,
1813
    HV_MEM_PATH: "",
1814
    HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1815
    HV_CPU_MASK: CPU_PINNING_ALL,
1816
    HV_CPU_TYPE: "",
1817
    },
1818
  HT_FAKE: {},
1819
  HT_CHROOT: {
1820
    HV_INIT_SCRIPT: "/ganeti-chroot",
1821
    },
1822
  HT_LXC: {
1823
    HV_CPU_MASK: "",
1824
    },
1825
  }
1826

    
1827
HVC_GLOBALS = frozenset([
1828
  HV_MIGRATION_PORT,
1829
  HV_MIGRATION_BANDWIDTH,
1830
  HV_MIGRATION_MODE,
1831
  ])
1832

    
1833
BEC_DEFAULTS = {
1834
  BE_MINMEM: 128,
1835
  BE_MAXMEM: 128,
1836
  BE_VCPUS: 1,
1837
  BE_AUTO_BALANCE: True,
1838
  BE_ALWAYS_FAILOVER: False,
1839
  BE_SPINDLE_USE: 1,
1840
  }
1841

    
1842
NDC_DEFAULTS = {
1843
  ND_OOB_PROGRAM: "",
1844
  ND_SPINDLE_COUNT: 1,
1845
  }
1846

    
1847
DISK_LD_DEFAULTS = {
1848
  LD_DRBD8: {
1849
    LDP_RESYNC_RATE: CLASSIC_DRBD_SYNC_SPEED,
1850
    LDP_BARRIERS: _autoconf.DRBD_BARRIERS,
1851
    LDP_NO_META_FLUSH: _autoconf.DRBD_NO_META_FLUSH,
1852
    LDP_DEFAULT_METAVG: DEFAULT_VG,
1853
    LDP_DISK_CUSTOM: "",
1854
    LDP_NET_CUSTOM: "",
1855
    LDP_DYNAMIC_RESYNC: False,
1856

    
1857
    # The default values for the DRBD dynamic resync speed algorithm are taken
1858
    # from the drbsetup 8.3.11 man page, except for c-plan-ahead (that we
1859
    # don't need to set to 0, because we have a separate option to enable it)
1860
    # and for c-max-rate, that we cap to the default value for the static resync
1861
    # rate.
1862
    LDP_PLAN_AHEAD: 20, # ds
1863
    LDP_FILL_TARGET: 0, # sectors
1864
    LDP_DELAY_TARGET: 1, # ds
1865
    LDP_MAX_RATE: CLASSIC_DRBD_SYNC_SPEED, # KiB/s
1866
    LDP_MIN_RATE: 4 * 1024, # KiB/s
1867
    },
1868
  LD_LV: {
1869
    LDP_STRIPES: _autoconf.LVM_STRIPECOUNT
1870
    },
1871
  LD_FILE: {},
1872
  LD_BLOCKDEV: {},
1873
  LD_RBD: {
1874
    LDP_POOL: "rbd"
1875
    },
1876
  }
1877

    
1878
# readability shortcuts
1879
_LV_DEFAULTS = DISK_LD_DEFAULTS[LD_LV]
1880
_DRBD_DEFAULTS = DISK_LD_DEFAULTS[LD_DRBD8]
1881

    
1882
DISK_DT_DEFAULTS = {
1883
  DT_PLAIN: {
1884
    LV_STRIPES: DISK_LD_DEFAULTS[LD_LV][LDP_STRIPES],
1885
    },
1886
  DT_DRBD8: {
1887
    DRBD_RESYNC_RATE: _DRBD_DEFAULTS[LDP_RESYNC_RATE],
1888
    DRBD_DATA_STRIPES: _LV_DEFAULTS[LDP_STRIPES],
1889
    DRBD_META_STRIPES: _LV_DEFAULTS[LDP_STRIPES],
1890
    DRBD_DISK_BARRIERS: _DRBD_DEFAULTS[LDP_BARRIERS],
1891
    DRBD_META_BARRIERS: _DRBD_DEFAULTS[LDP_NO_META_FLUSH],
1892
    DRBD_DEFAULT_METAVG: _DRBD_DEFAULTS[LDP_DEFAULT_METAVG],
1893
    DRBD_DISK_CUSTOM: _DRBD_DEFAULTS[LDP_DISK_CUSTOM],
1894
    DRBD_NET_CUSTOM: _DRBD_DEFAULTS[LDP_NET_CUSTOM],
1895
    DRBD_DYNAMIC_RESYNC: _DRBD_DEFAULTS[LDP_DYNAMIC_RESYNC],
1896
    DRBD_PLAN_AHEAD: _DRBD_DEFAULTS[LDP_PLAN_AHEAD],
1897
    DRBD_FILL_TARGET: _DRBD_DEFAULTS[LDP_FILL_TARGET],
1898
    DRBD_DELAY_TARGET: _DRBD_DEFAULTS[LDP_DELAY_TARGET],
1899
    DRBD_MAX_RATE: _DRBD_DEFAULTS[LDP_MAX_RATE],
1900
    DRBD_MIN_RATE: _DRBD_DEFAULTS[LDP_MIN_RATE],
1901
    },
1902
  DT_DISKLESS: {},
1903
  DT_FILE: {},
1904
  DT_SHARED_FILE: {},
1905
  DT_BLOCK: {},
1906
  DT_RBD: {
1907
    RBD_POOL: DISK_LD_DEFAULTS[LD_RBD][LDP_POOL]
1908
    },
1909
  }
1910

    
1911
# we don't want to export the shortcuts
1912
del _LV_DEFAULTS, _DRBD_DEFAULTS
1913

    
1914
NICC_DEFAULTS = {
1915
  NIC_MODE: NIC_MODE_BRIDGED,
1916
  NIC_LINK: DEFAULT_BRIDGE,
1917
  }
1918

    
1919
# All of the following values are quite arbitrarily - there are no
1920
# "good" defaults, these must be customised per-site
1921
IPOLICY_DEFAULTS = {
1922
  ISPECS_MIN: {
1923
    ISPEC_MEM_SIZE: 128,
1924
    ISPEC_CPU_COUNT: 1,
1925
    ISPEC_DISK_COUNT: 1,
1926
    ISPEC_DISK_SIZE: 1024,
1927
    ISPEC_NIC_COUNT: 1,
1928
    ISPEC_SPINDLE_USE: 1,
1929
    },
1930
  ISPECS_MAX: {
1931
    ISPEC_MEM_SIZE: 32768,
1932
    ISPEC_CPU_COUNT: 8,
1933
    ISPEC_DISK_COUNT: MAX_DISKS,
1934
    ISPEC_DISK_SIZE: 1024 * 1024,
1935
    ISPEC_NIC_COUNT: MAX_NICS,
1936
    ISPEC_SPINDLE_USE: 12,
1937
    },
1938
  ISPECS_STD: {
1939
    ISPEC_MEM_SIZE: 128,
1940
    ISPEC_CPU_COUNT: 1,
1941
    ISPEC_DISK_COUNT: 1,
1942
    ISPEC_DISK_SIZE: 1024,
1943
    ISPEC_NIC_COUNT: 1,
1944
    ISPEC_SPINDLE_USE: 1,
1945
    },
1946
  IPOLICY_DTS: DISK_TEMPLATES,
1947
  IPOLICY_VCPU_RATIO: 4.0,
1948
  IPOLICY_SPINDLE_RATIO: 32.0,
1949
  }
1950

    
1951
MASTER_POOL_SIZE_DEFAULT = 10
1952

    
1953
CONFD_PROTOCOL_VERSION = 1
1954

    
1955
CONFD_REQ_PING = 0
1956
CONFD_REQ_NODE_ROLE_BYNAME = 1
1957
CONFD_REQ_NODE_PIP_BY_INSTANCE_IP = 2
1958
CONFD_REQ_CLUSTER_MASTER = 3
1959
CONFD_REQ_NODE_PIP_LIST = 4
1960
CONFD_REQ_MC_PIP_LIST = 5
1961
CONFD_REQ_INSTANCES_IPS_LIST = 6
1962
CONFD_REQ_NODE_DRBD = 7
1963

    
1964
# Confd request query fields. These are used to narrow down queries.
1965
# These must be strings rather than integers, because json-encoding
1966
# converts them to strings anyway, as they're used as dict-keys.
1967
CONFD_REQQ_LINK = "0"
1968
CONFD_REQQ_IP = "1"
1969
CONFD_REQQ_IPLIST = "2"
1970
CONFD_REQQ_FIELDS = "3"
1971

    
1972
CONFD_REQFIELD_NAME = "0"
1973
CONFD_REQFIELD_IP = "1"
1974
CONFD_REQFIELD_MNODE_PIP = "2"
1975

    
1976
CONFD_REQS = frozenset([
1977
  CONFD_REQ_PING,
1978
  CONFD_REQ_NODE_ROLE_BYNAME,
1979
  CONFD_REQ_NODE_PIP_BY_INSTANCE_IP,
1980
  CONFD_REQ_CLUSTER_MASTER,
1981
  CONFD_REQ_NODE_PIP_LIST,
1982
  CONFD_REQ_MC_PIP_LIST,
1983
  CONFD_REQ_INSTANCES_IPS_LIST,
1984
  CONFD_REQ_NODE_DRBD,
1985
  ])
1986

    
1987
CONFD_REPL_STATUS_OK = 0
1988
CONFD_REPL_STATUS_ERROR = 1
1989
CONFD_REPL_STATUS_NOTIMPLEMENTED = 2
1990

    
1991
CONFD_REPL_STATUSES = frozenset([
1992
  CONFD_REPL_STATUS_OK,
1993
  CONFD_REPL_STATUS_ERROR,
1994
  CONFD_REPL_STATUS_NOTIMPLEMENTED,
1995
  ])
1996

    
1997
(CONFD_NODE_ROLE_MASTER,
1998
 CONFD_NODE_ROLE_CANDIDATE,
1999
 CONFD_NODE_ROLE_OFFLINE,
2000
 CONFD_NODE_ROLE_DRAINED,
2001
 CONFD_NODE_ROLE_REGULAR,
2002
 ) = range(5)
2003

    
2004
# A few common errors for confd
2005
CONFD_ERROR_UNKNOWN_ENTRY = 1
2006
CONFD_ERROR_INTERNAL = 2
2007
CONFD_ERROR_ARGUMENT = 3
2008

    
2009
# Each request is "salted" by the current timestamp.
2010
# This constants decides how many seconds of skew to accept.
2011
# TODO: make this a default and allow the value to be more configurable
2012
CONFD_MAX_CLOCK_SKEW = 2 * NODE_MAX_CLOCK_SKEW
2013

    
2014
# When we haven't reloaded the config for more than this amount of seconds, we
2015
# force a test to see if inotify is betraying us.
2016
CONFD_CONFIG_RELOAD_TIMEOUT = 60
2017

    
2018
# If we receive more than one update in this amount of seconds, we move to
2019
# polling every RATELIMIT seconds, rather than relying on inotify, to be able
2020
# to serve more requests.
2021
CONFD_CONFIG_RELOAD_RATELIMIT = 2
2022

    
2023
# Magic number prepended to all confd queries.
2024
# This allows us to distinguish different types of confd protocols and handle
2025
# them. For example by changing this we can move the whole payload to be
2026
# compressed, or move away from json.
2027
CONFD_MAGIC_FOURCC = "plj0"
2028

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

    
2034
# Timeout in seconds to expire pending query request in the confd client
2035
# library. We don't actually expect any answer more than 10 seconds after we
2036
# sent a request.
2037
CONFD_CLIENT_EXPIRE_TIMEOUT = 10
2038

    
2039
# Maximum UDP datagram size.
2040
# On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
2041
# On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
2042
#   (assuming we can't use jumbo frames)
2043
# We just set this to 60K, which should be enough
2044
MAX_UDP_DATA_SIZE = 61440
2045

    
2046
# User-id pool minimum/maximum acceptable user-ids.
2047
UIDPOOL_UID_MIN = 0
2048
UIDPOOL_UID_MAX = 2 ** 32 - 1 # Assuming 32 bit user-ids
2049

    
2050
# Name or path of the pgrep command
2051
PGREP = "pgrep"
2052

    
2053
# Name of the node group that gets created at cluster init or upgrade
2054
INITIAL_NODE_GROUP_NAME = "default"
2055

    
2056
# Possible values for NodeGroup.alloc_policy
2057
ALLOC_POLICY_PREFERRED = "preferred"
2058
ALLOC_POLICY_LAST_RESORT = "last_resort"
2059
ALLOC_POLICY_UNALLOCABLE = "unallocable"
2060
VALID_ALLOC_POLICIES = [
2061
  ALLOC_POLICY_PREFERRED,
2062
  ALLOC_POLICY_LAST_RESORT,
2063
  ALLOC_POLICY_UNALLOCABLE,
2064
  ]
2065

    
2066
# Temporary external/shared storage parameters
2067
BLOCKDEV_DRIVER_MANUAL = "manual"
2068

    
2069
# qemu-img path, required for ovfconverter
2070
QEMUIMG_PATH = _autoconf.QEMUIMG_PATH
2071

    
2072
# Whether htools was enabled at compilation time
2073
HTOOLS = _autoconf.HTOOLS
2074
# The hail iallocator
2075
IALLOC_HAIL = "hail"
2076

    
2077
# Fake opcodes for functions that have hooks attached to them via
2078
# backend.RunLocalHooks
2079
FAKE_OP_MASTER_TURNUP = "OP_CLUSTER_IP_TURNUP"
2080
FAKE_OP_MASTER_TURNDOWN = "OP_CLUSTER_IP_TURNDOWN"
2081

    
2082
# SSH key types
2083
SSHK_RSA = "rsa"
2084
SSHK_DSA = "dsa"
2085
SSHK_ALL = frozenset([SSHK_RSA, SSHK_DSA])
2086

    
2087
# SSH authorized key types
2088
SSHAK_RSA = "ssh-rsa"
2089
SSHAK_DSS = "ssh-dss"
2090
SSHAK_ALL = frozenset([SSHAK_RSA, SSHAK_DSS])
2091

    
2092
# SSH setup
2093
SSHS_CLUSTER_NAME = "cluster_name"
2094
SSHS_SSH_HOST_KEY = "ssh_host_key"
2095
SSHS_SSH_ROOT_KEY = "ssh_root_key"
2096
SSHS_NODE_DAEMON_CERTIFICATE = "node_daemon_certificate"
2097

    
2098
#: Key files for SSH daemon
2099
SSH_DAEMON_KEYFILES = {
2100
  SSHK_RSA: (pathutils.SSH_HOST_RSA_PRIV, pathutils.SSH_HOST_RSA_PUB),
2101
  SSHK_DSA: (pathutils.SSH_HOST_DSA_PRIV, pathutils.SSH_HOST_DSA_PUB),
2102
  }
2103

    
2104
# Node daemon setup
2105
NDS_CLUSTER_NAME = "cluster_name"
2106
NDS_NODE_DAEMON_CERTIFICATE = "node_daemon_certificate"
2107
NDS_SSCONF = "ssconf"
2108
NDS_START_NODE_DAEMON = "start_node_daemon"
2109

    
2110
# Do not re-export imported modules
2111
del re, _vcsversion, _autoconf, socket, pathutils