Statistics
| Branch: | Tag: | Revision:

root / lib / constants.py @ c87440f5

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

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

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

    
201
KVM_PATH = _autoconf.KVM_PATH
202
KVM_KERNEL = _autoconf.KVM_KERNEL
203
SOCAT_PATH = _autoconf.SOCAT_PATH
204
SOCAT_USE_ESCAPE = _autoconf.SOCAT_USE_ESCAPE
205
SOCAT_USE_COMPRESS = _autoconf.SOCAT_USE_COMPRESS
206
SOCAT_ESCAPE_CODE = "0x1d"
207

    
208
#: Console as SSH command
209
CONS_SSH = "ssh"
210

    
211
#: Console as VNC server
212
CONS_VNC = "vnc"
213

    
214
#: Console as SPICE server
215
CONS_SPICE = "spice"
216

    
217
#: Display a message for console access
218
CONS_MESSAGE = "msg"
219

    
220
#: All console types
221
CONS_ALL = frozenset([CONS_SSH, CONS_VNC, CONS_SPICE, CONS_MESSAGE])
222

    
223
# For RSA keys more bits are better, but they also make operations more
224
# expensive. NIST SP 800-131 recommends a minimum of 2048 bits from the year
225
# 2010 on.
226
RSA_KEY_BITS = 2048
227

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

    
236
# Digest used to sign certificates ("openssl x509" uses SHA1 by default)
237
X509_CERT_SIGN_DIGEST = "SHA1"
238

    
239
# Default validity of certificates in days
240
X509_CERT_DEFAULT_VALIDITY = 365 * 5
241

    
242
# commonName (CN) used in certificates
243
X509_CERT_CN = "ganeti.example.com"
244

    
245
X509_CERT_SIGNATURE_HEADER = "X-Ganeti-Signature"
246

    
247
# Import/export daemon mode
248
IEM_IMPORT = "import"
249
IEM_EXPORT = "export"
250

    
251
# Import/export transport compression
252
IEC_NONE = "none"
253
IEC_GZIP = "gzip"
254
IEC_ALL = frozenset([
255
  IEC_NONE,
256
  IEC_GZIP,
257
  ])
258

    
259
IE_CUSTOM_SIZE = "fd"
260

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

    
263
# Import/export I/O
264
# Direct file I/O, equivalent to a shell's I/O redirection using '<' or '>'
265
IEIO_FILE = "file"
266
# Raw block device I/O using "dd"
267
IEIO_RAW_DISK = "raw"
268
# OS definition import/export script
269
IEIO_SCRIPT = "script"
270

    
271
VALUE_DEFAULT = "default"
272
VALUE_AUTO = "auto"
273
VALUE_GENERATE = "generate"
274
VALUE_NONE = "none"
275
VALUE_TRUE = "true"
276
VALUE_FALSE = "false"
277

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

    
281
# hooks-related constants
282
HOOKS_PHASE_PRE = "pre"
283
HOOKS_PHASE_POST = "post"
284
HOOKS_NAME_CFGUPDATE = "config-update"
285
HOOKS_NAME_WATCHER = "watcher"
286
HOOKS_VERSION = 2
287
HOOKS_PATH = "/sbin:/bin:/usr/sbin:/usr/bin"
288

    
289
# hooks subject type (what object type does the LU deal with)
290
HTYPE_CLUSTER = "CLUSTER"
291
HTYPE_NODE = "NODE"
292
HTYPE_GROUP = "GROUP"
293
HTYPE_INSTANCE = "INSTANCE"
294

    
295
HKR_SKIP = 0
296
HKR_FAIL = 1
297
HKR_SUCCESS = 2
298

    
299
# Storage types
300
ST_FILE = "file"
301
ST_LVM_PV = "lvm-pv"
302
ST_LVM_VG = "lvm-vg"
303

    
304
# Storage fields
305
# first two are valid in LU context only, not passed to backend
306
SF_NODE = "node"
307
SF_TYPE = "type"
308
# and the rest are valid in backend
309
SF_NAME = "name"
310
SF_SIZE = "size"
311
SF_FREE = "free"
312
SF_USED = "used"
313
SF_ALLOCATABLE = "allocatable"
314

    
315
# Storage operations
316
SO_FIX_CONSISTENCY = "fix-consistency"
317

    
318
# Available fields per storage type
319
VALID_STORAGE_FIELDS = frozenset([
320
  SF_NAME,
321
  SF_TYPE,
322
  SF_SIZE,
323
  SF_USED,
324
  SF_FREE,
325
  SF_ALLOCATABLE
326
  ])
327

    
328
VALID_STORAGE_TYPES = frozenset([ST_FILE, ST_LVM_PV, ST_LVM_VG])
329

    
330
MODIFIABLE_STORAGE_FIELDS = {
331
  ST_LVM_PV: frozenset([SF_ALLOCATABLE]),
332
  }
333

    
334
VALID_STORAGE_OPERATIONS = {
335
  ST_LVM_VG: frozenset([SO_FIX_CONSISTENCY]),
336
  }
337

    
338
# Local disk status
339
# Note: Code depends on LDS_OKAY < LDS_UNKNOWN < LDS_FAULTY
340
(LDS_OKAY,
341
 LDS_UNKNOWN,
342
 LDS_FAULTY) = range(1, 4)
343

    
344
# disk template types
345
DT_DISKLESS = "diskless"
346
DT_PLAIN = "plain"
347
DT_DRBD8 = "drbd"
348
DT_FILE = "file"
349
DT_SHARED_FILE = "sharedfile"
350
DT_BLOCK = "blockdev"
351
DT_RBD = "rbd"
352

    
353
# the set of network-mirrored disk templates
354
DTS_INT_MIRROR = frozenset([DT_DRBD8])
355

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

    
359
# the set of non-lvm-based disk templates
360
DTS_NOT_LVM = frozenset([DT_DISKLESS, DT_FILE, DT_SHARED_FILE,
361
                         DT_BLOCK, DT_RBD])
362

    
363
# the set of disk templates which can be grown
364
DTS_GROWABLE = frozenset([DT_PLAIN, DT_DRBD8, DT_FILE, DT_SHARED_FILE, DT_RBD])
365

    
366
# the set of disk templates that allow adoption
367
DTS_MAY_ADOPT = frozenset([DT_PLAIN, DT_BLOCK])
368

    
369
# the set of disk templates that *must* use adoption
370
DTS_MUST_ADOPT = frozenset([DT_BLOCK])
371

    
372
# the set of disk templates that allow migrations
373
DTS_MIRRORED = frozenset.union(DTS_INT_MIRROR, DTS_EXT_MIRROR)
374

    
375
# the set of file based disk templates
376
DTS_FILEBASED = frozenset([DT_FILE, DT_SHARED_FILE])
377

    
378
# logical disk types
379
LD_LV = "lvm"
380
LD_DRBD8 = "drbd8"
381
LD_FILE = "file"
382
LD_BLOCKDEV = "blockdev"
383
LD_RBD = "rbd"
384
LOGICAL_DISK_TYPES = frozenset([
385
  LD_LV,
386
  LD_DRBD8,
387
  LD_FILE,
388
  LD_BLOCKDEV,
389
  LD_RBD,
390
  ])
391

    
392
LDS_BLOCK = frozenset([LD_LV, LD_DRBD8, LD_BLOCKDEV, LD_RBD])
393

    
394
# drbd constants
395
DRBD_HMAC_ALG = "md5"
396
DRBD_NET_PROTOCOL = "C"
397

    
398
#: Size of DRBD meta block device
399
DRBD_META_SIZE = 128
400

    
401
# drbd barrier types
402
DRBD_B_NONE = "n"
403
DRBD_B_DISK_BARRIERS = "b"
404
DRBD_B_DISK_DRAIN = "d"
405
DRBD_B_DISK_FLUSH = "f"
406

    
407
# Valid barrier combinations: "n" or any non-null subset of "bfd"
408
DRBD_VALID_BARRIER_OPT = frozenset([
409
  frozenset([DRBD_B_NONE]),
410
  frozenset([DRBD_B_DISK_BARRIERS]),
411
  frozenset([DRBD_B_DISK_DRAIN]),
412
  frozenset([DRBD_B_DISK_FLUSH]),
413
  frozenset([DRBD_B_DISK_DRAIN, DRBD_B_DISK_FLUSH]),
414
  frozenset([DRBD_B_DISK_DRAIN, DRBD_B_DISK_FLUSH]),
415
  frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_DRAIN]),
416
  frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_FLUSH]),
417
  frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_FLUSH, DRBD_B_DISK_DRAIN]),
418
  ])
419

    
420
# rbd tool command
421
RBD_CMD = "rbd"
422

    
423
# file backend driver
424
FD_LOOP = "loop"
425
FD_BLKTAP = "blktap"
426

    
427
# the set of drbd-like disk types
428
LDS_DRBD = frozenset([LD_DRBD8])
429

    
430
# disk access mode
431
DISK_RDONLY = "ro"
432
DISK_RDWR = "rw"
433
DISK_ACCESS_SET = frozenset([DISK_RDONLY, DISK_RDWR])
434

    
435
# disk replacement mode
436
REPLACE_DISK_PRI = "replace_on_primary"    # replace disks on primary
437
REPLACE_DISK_SEC = "replace_on_secondary"  # replace disks on secondary
438
REPLACE_DISK_CHG = "replace_new_secondary" # change secondary node
439
REPLACE_DISK_AUTO = "replace_auto"
440
REPLACE_MODES = frozenset([
441
  REPLACE_DISK_PRI,
442
  REPLACE_DISK_SEC,
443
  REPLACE_DISK_CHG,
444
  REPLACE_DISK_AUTO,
445
  ])
446

    
447
# Instance export mode
448
EXPORT_MODE_LOCAL = "local"
449
EXPORT_MODE_REMOTE = "remote"
450
EXPORT_MODES = frozenset([
451
  EXPORT_MODE_LOCAL,
452
  EXPORT_MODE_REMOTE,
453
  ])
454

    
455
# instance creation modes
456
INSTANCE_CREATE = "create"
457
INSTANCE_IMPORT = "import"
458
INSTANCE_REMOTE_IMPORT = "remote-import"
459
INSTANCE_CREATE_MODES = frozenset([
460
  INSTANCE_CREATE,
461
  INSTANCE_IMPORT,
462
  INSTANCE_REMOTE_IMPORT,
463
  ])
464

    
465
# Remote import/export handshake message and version
466
RIE_VERSION = 0
467
RIE_HANDSHAKE = "Hi, I'm Ganeti"
468

    
469
# Remote import/export certificate validity in seconds
470
RIE_CERT_VALIDITY = 24 * 60 * 60
471

    
472
# Overall timeout for establishing connection
473
RIE_CONNECT_TIMEOUT = 180
474

    
475
# Export only: how long to wait per connection attempt (seconds)
476
RIE_CONNECT_ATTEMPT_TIMEOUT = 20
477

    
478
# Export only: number of attempts to connect
479
RIE_CONNECT_RETRIES = 10
480

    
481
#: Give child process up to 5 seconds to exit after sending a signal
482
CHILD_LINGER_TIMEOUT = 5.0
483

    
484
DISK_TEMPLATES = frozenset([
485
  DT_DISKLESS,
486
  DT_PLAIN,
487
  DT_DRBD8,
488
  DT_FILE,
489
  DT_SHARED_FILE,
490
  DT_BLOCK,
491
  DT_RBD
492
  ])
493

    
494
FILE_DRIVER = frozenset([FD_LOOP, FD_BLKTAP])
495

    
496
# import/export config options
497
INISECT_EXP = "export"
498
INISECT_INS = "instance"
499
INISECT_HYP = "hypervisor"
500
INISECT_BEP = "backend"
501
INISECT_OSP = "os"
502

    
503
# dynamic device modification
504
DDM_ADD = "add"
505
DDM_MODIFY = "modify"
506
DDM_REMOVE = "remove"
507
DDMS_VALUES = frozenset([DDM_ADD, DDM_REMOVE])
508
DDMS_VALUES_WITH_MODIFY = (DDMS_VALUES | frozenset([
509
  DDM_MODIFY,
510
  ]))
511
# TODO: DDM_SWAP, DDM_MOVE?
512

    
513
# common exit codes
514
EXIT_SUCCESS = 0
515
EXIT_FAILURE = 1
516
EXIT_NOTCLUSTER = 5
517
EXIT_NOTMASTER = 11
518
EXIT_NODESETUP_ERROR = 12
519
EXIT_CONFIRMATION = 13 # need user confirmation
520

    
521
#: Exit code for query operations with unknown fields
522
EXIT_UNKNOWN_FIELD = 14
523

    
524
# tags
525
TAG_CLUSTER = "cluster"
526
TAG_NODEGROUP = "nodegroup"
527
TAG_NODE = "node"
528
TAG_INSTANCE = "instance"
529
VALID_TAG_TYPES = frozenset([
530
  TAG_CLUSTER,
531
  TAG_NODEGROUP,
532
  TAG_NODE,
533
  TAG_INSTANCE,
534
  ])
535
MAX_TAG_LEN = 128
536
MAX_TAGS_PER_OBJ = 4096
537

    
538
# others
539
DEFAULT_BRIDGE = "xen-br0"
540
CLASSIC_DRBD_SYNC_SPEED = 60 * 1024  # 60 MiB, expressed in KiB
541
IP4_ADDRESS_LOCALHOST = "127.0.0.1"
542
IP4_ADDRESS_ANY = "0.0.0.0"
543
IP6_ADDRESS_LOCALHOST = "::1"
544
IP6_ADDRESS_ANY = "::"
545
IP4_VERSION = 4
546
IP6_VERSION = 6
547
VALID_IP_VERSIONS = frozenset([IP4_VERSION, IP6_VERSION])
548
# for export to htools
549
IP4_FAMILY = socket.AF_INET
550
IP6_FAMILY = socket.AF_INET6
551

    
552
TCP_PING_TIMEOUT = 10
553
DEFAULT_VG = "xenvg"
554
DEFAULT_DRBD_HELPER = "/bin/true"
555
MIN_VG_SIZE = 20480
556
DEFAULT_MAC_PREFIX = "aa:00:00"
557
# default maximum instance wait time, in seconds.
558
DEFAULT_SHUTDOWN_TIMEOUT = 120
559
NODE_MAX_CLOCK_SKEW = 150
560
# Time for an intra-cluster disk transfer to wait for a connection
561
DISK_TRANSFER_CONNECT_TIMEOUT = 60
562
# Disk index separator
563
DISK_SEPARATOR = _autoconf.DISK_SEPARATOR
564
IP_COMMAND_PATH = _autoconf.IP_PATH
565

    
566
#: Key for job IDs in opcode result
567
JOB_IDS_KEY = "jobs"
568

    
569
# runparts results
570
(RUNPARTS_SKIP,
571
 RUNPARTS_RUN,
572
 RUNPARTS_ERR) = range(3)
573

    
574
RUNPARTS_STATUS = frozenset([RUNPARTS_SKIP, RUNPARTS_RUN, RUNPARTS_ERR])
575

    
576
# RPC constants
577
(RPC_ENCODING_NONE,
578
 RPC_ENCODING_ZLIB_BASE64) = range(2)
579

    
580
# Various time constants for the timeout table
581
RPC_TMO_URGENT = 60 # one minute
582
RPC_TMO_FAST = 5 * 60 # five minutes
583
RPC_TMO_NORMAL = 15 * 60 # 15 minutes
584
RPC_TMO_SLOW = 3600 # one hour
585
RPC_TMO_4HRS = 4 * 3600
586
RPC_TMO_1DAY = 86400
587

    
588
# Timeout for connecting to nodes (seconds)
589
RPC_CONNECT_TIMEOUT = 5
590

    
591
# os related constants
592
OS_SCRIPT_CREATE = "create"
593
OS_SCRIPT_IMPORT = "import"
594
OS_SCRIPT_EXPORT = "export"
595
OS_SCRIPT_RENAME = "rename"
596
OS_SCRIPT_VERIFY = "verify"
597
OS_SCRIPTS = frozenset([
598
  OS_SCRIPT_CREATE,
599
  OS_SCRIPT_IMPORT,
600
  OS_SCRIPT_EXPORT,
601
  OS_SCRIPT_RENAME,
602
  OS_SCRIPT_VERIFY
603
  ])
604

    
605
OS_API_FILE = "ganeti_api_version"
606
OS_VARIANTS_FILE = "variants.list"
607
OS_PARAMETERS_FILE = "parameters.list"
608

    
609
OS_VALIDATE_PARAMETERS = "parameters"
610
OS_VALIDATE_CALLS = frozenset([OS_VALIDATE_PARAMETERS])
611

    
612
# ssh constants
613
SSH = "ssh"
614
SCP = "scp"
615

    
616
# reboot types
617
INSTANCE_REBOOT_SOFT = "soft"
618
INSTANCE_REBOOT_HARD = "hard"
619
INSTANCE_REBOOT_FULL = "full"
620

    
621
REBOOT_TYPES = frozenset([
622
  INSTANCE_REBOOT_SOFT,
623
  INSTANCE_REBOOT_HARD,
624
  INSTANCE_REBOOT_FULL
625
  ])
626

    
627
# instance reboot behaviors
628
INSTANCE_REBOOT_ALLOWED = "reboot"
629
INSTANCE_REBOOT_EXIT = "exit"
630

    
631
REBOOT_BEHAVIORS = frozenset([
632
  INSTANCE_REBOOT_ALLOWED,
633
  INSTANCE_REBOOT_EXIT
634
  ])
635

    
636
VTYPE_STRING = "string"
637
VTYPE_MAYBE_STRING = "maybe-string"
638
VTYPE_BOOL = "bool"
639
VTYPE_SIZE = "size" # size, in MiBs
640
VTYPE_INT = "int"
641
ENFORCEABLE_TYPES = frozenset([
642
  VTYPE_STRING,
643
  VTYPE_MAYBE_STRING,
644
  VTYPE_BOOL,
645
  VTYPE_SIZE,
646
  VTYPE_INT,
647
  ])
648

    
649
# Constant representing that the user does not specify any IP version
650
IFACE_NO_IP_VERSION_SPECIFIED = 0
651

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

    
710

    
711
HVS_PARAMETER_TYPES = {
712
  HV_BOOT_ORDER: VTYPE_STRING,
713
  HV_KVM_FLOPPY_IMAGE_PATH: VTYPE_STRING,
714
  HV_CDROM_IMAGE_PATH: VTYPE_STRING,
715
  HV_KVM_CDROM2_IMAGE_PATH: VTYPE_STRING,
716
  HV_NIC_TYPE: VTYPE_STRING,
717
  HV_DISK_TYPE: VTYPE_STRING,
718
  HV_KVM_CDROM_DISK_TYPE: VTYPE_STRING,
719
  HV_VNC_PASSWORD_FILE: VTYPE_STRING,
720
  HV_VNC_BIND_ADDRESS: VTYPE_STRING,
721
  HV_VNC_TLS: VTYPE_BOOL,
722
  HV_VNC_X509: VTYPE_STRING,
723
  HV_VNC_X509_VERIFY: VTYPE_BOOL,
724
  HV_KVM_SPICE_BIND: VTYPE_STRING,
725
  HV_KVM_SPICE_IP_VERSION: VTYPE_INT,
726
  HV_KVM_SPICE_PASSWORD_FILE: VTYPE_STRING,
727
  HV_KVM_SPICE_LOSSLESS_IMG_COMPR: VTYPE_STRING,
728
  HV_KVM_SPICE_JPEG_IMG_COMPR: VTYPE_STRING,
729
  HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR: VTYPE_STRING,
730
  HV_KVM_SPICE_STREAMING_VIDEO_DETECTION: VTYPE_STRING,
731
  HV_KVM_SPICE_AUDIO_COMPR: VTYPE_BOOL,
732
  HV_KVM_SPICE_USE_TLS: VTYPE_BOOL,
733
  HV_KVM_SPICE_TLS_CIPHERS: VTYPE_STRING,
734
  HV_KVM_SPICE_USE_VDAGENT: VTYPE_BOOL,
735
  HV_ACPI: VTYPE_BOOL,
736
  HV_PAE: VTYPE_BOOL,
737
  HV_USE_BOOTLOADER: VTYPE_BOOL,
738
  HV_BOOTLOADER_PATH: VTYPE_STRING,
739
  HV_BOOTLOADER_ARGS: VTYPE_STRING,
740
  HV_KERNEL_PATH: VTYPE_STRING,
741
  HV_KERNEL_ARGS: VTYPE_STRING,
742
  HV_INITRD_PATH: VTYPE_STRING,
743
  HV_ROOT_PATH: VTYPE_MAYBE_STRING,
744
  HV_SERIAL_CONSOLE: VTYPE_BOOL,
745
  HV_USB_MOUSE: VTYPE_STRING,
746
  HV_KEYMAP: VTYPE_STRING,
747
  HV_DEVICE_MODEL: VTYPE_STRING,
748
  HV_INIT_SCRIPT: VTYPE_STRING,
749
  HV_MIGRATION_PORT: VTYPE_INT,
750
  HV_MIGRATION_BANDWIDTH: VTYPE_INT,
751
  HV_MIGRATION_DOWNTIME: VTYPE_INT,
752
  HV_MIGRATION_MODE: VTYPE_STRING,
753
  HV_USE_LOCALTIME: VTYPE_BOOL,
754
  HV_DISK_CACHE: VTYPE_STRING,
755
  HV_SECURITY_MODEL: VTYPE_STRING,
756
  HV_SECURITY_DOMAIN: VTYPE_STRING,
757
  HV_KVM_FLAG: VTYPE_STRING,
758
  HV_VHOST_NET: VTYPE_BOOL,
759
  HV_KVM_USE_CHROOT: VTYPE_BOOL,
760
  HV_CPU_MASK: VTYPE_STRING,
761
  HV_MEM_PATH: VTYPE_STRING,
762
  HV_PASSTHROUGH: VTYPE_STRING,
763
  HV_BLOCKDEV_PREFIX: VTYPE_STRING,
764
  HV_REBOOT_BEHAVIOR: VTYPE_STRING,
765
  HV_CPU_TYPE: VTYPE_STRING,
766
  HV_CPU_CAP: VTYPE_INT,
767
  HV_CPU_WEIGHT: VTYPE_INT,
768
  }
769

    
770
HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
771

    
772
HVS_PARAMETER_TITLES = {
773
  HV_ACPI: "ACPI",
774
  HV_BOOT_ORDER: "Boot_order",
775
  HV_CDROM_IMAGE_PATH: "CDROM_image_path",
776
  HV_DISK_TYPE: "Disk_type",
777
  HV_INITRD_PATH: "Initrd_path",
778
  HV_KERNEL_PATH: "Kernel_path",
779
  HV_NIC_TYPE: "NIC_type",
780
  HV_PAE: "PAE",
781
  HV_VNC_BIND_ADDRESS: "VNC_bind_address",
782
  HV_PASSTHROUGH: "pci_pass",
783
  HV_CPU_TYPE: "cpu_type",
784
  }
785

    
786
# Migration statuses
787
HV_MIGRATION_COMPLETED = "completed"
788
HV_MIGRATION_ACTIVE = "active"
789
HV_MIGRATION_FAILED = "failed"
790
HV_MIGRATION_CANCELLED = "cancelled"
791

    
792
HV_MIGRATION_VALID_STATUSES = frozenset([
793
  HV_MIGRATION_COMPLETED,
794
  HV_MIGRATION_ACTIVE,
795
  HV_MIGRATION_FAILED,
796
  HV_MIGRATION_CANCELLED,
797
  ])
798

    
799
HV_MIGRATION_FAILED_STATUSES = frozenset([
800
  HV_MIGRATION_FAILED,
801
  HV_MIGRATION_CANCELLED,
802
  ])
803

    
804
# KVM-specific statuses
805
HV_KVM_MIGRATION_VALID_STATUSES = HV_MIGRATION_VALID_STATUSES
806

    
807
# Node info keys
808
HV_NODEINFO_KEY_VERSION = "hv_version"
809

    
810
# Hypervisor state
811
HVST_MEMORY_TOTAL = "mem_total"
812
HVST_MEMORY_NODE = "mem_node"
813
HVST_MEMORY_HV = "mem_hv"
814
HVST_CPU_TOTAL = "cpu_total"
815
HVST_CPU_NODE = "cpu_node"
816

    
817
HVST_DEFAULTS = {
818
  HVST_MEMORY_TOTAL: 0,
819
  HVST_MEMORY_NODE: 0,
820
  HVST_MEMORY_HV: 0,
821
  HVST_CPU_TOTAL: 1,
822
  HVST_CPU_NODE: 1,
823
  }
824

    
825
HVSTS_PARAMETER_TYPES = {
826
  HVST_MEMORY_TOTAL: VTYPE_INT,
827
  HVST_MEMORY_NODE: VTYPE_INT,
828
  HVST_MEMORY_HV: VTYPE_INT,
829
  HVST_CPU_TOTAL: VTYPE_INT,
830
  HVST_CPU_NODE: VTYPE_INT,
831
  }
832

    
833
HVSTS_PARAMETERS = frozenset(HVSTS_PARAMETER_TYPES.keys())
834

    
835
# Disk state
836
DS_DISK_TOTAL = "disk_total"
837
DS_DISK_RESERVED = "disk_reserved"
838
DS_DISK_OVERHEAD = "disk_overhead"
839

    
840
DS_DEFAULTS = {
841
  DS_DISK_TOTAL: 0,
842
  DS_DISK_RESERVED: 0,
843
  DS_DISK_OVERHEAD: 0,
844
  }
845

    
846
DSS_PARAMETER_TYPES = {
847
  DS_DISK_TOTAL: VTYPE_INT,
848
  DS_DISK_RESERVED: VTYPE_INT,
849
  DS_DISK_OVERHEAD: VTYPE_INT,
850
  }
851

    
852
DSS_PARAMETERS = frozenset(DSS_PARAMETER_TYPES.keys())
853
DS_VALID_TYPES = frozenset([LD_LV])
854

    
855
# Backend parameter names
856
BE_MEMORY = "memory" # deprecated and replaced by max and min mem
857
BE_MAXMEM = "maxmem"
858
BE_MINMEM = "minmem"
859
BE_VCPUS = "vcpus"
860
BE_AUTO_BALANCE = "auto_balance"
861
BE_ALWAYS_FAILOVER = "always_failover"
862
BE_SPINDLE_USE = "spindle_use"
863

    
864
BES_PARAMETER_TYPES = {
865
  BE_MAXMEM: VTYPE_SIZE,
866
  BE_MINMEM: VTYPE_SIZE,
867
  BE_VCPUS: VTYPE_INT,
868
  BE_AUTO_BALANCE: VTYPE_BOOL,
869
  BE_ALWAYS_FAILOVER: VTYPE_BOOL,
870
  BE_SPINDLE_USE: VTYPE_INT,
871
  }
872

    
873
BES_PARAMETER_TITLES = {
874
  BE_AUTO_BALANCE: "Auto_balance",
875
  BE_MAXMEM: "ConfigMaxMem",
876
  BE_MINMEM: "ConfigMinMem",
877
  BE_VCPUS: "ConfigVCPUs",
878
  }
879

    
880
BES_PARAMETER_COMPAT = {
881
  BE_MEMORY: VTYPE_SIZE,
882
  }
883
BES_PARAMETER_COMPAT.update(BES_PARAMETER_TYPES)
884

    
885
BES_PARAMETERS = frozenset(BES_PARAMETER_TYPES.keys())
886

    
887
# instance specs
888
ISPEC_MEM_SIZE = "memory-size"
889
ISPEC_CPU_COUNT = "cpu-count"
890
ISPEC_DISK_COUNT = "disk-count"
891
ISPEC_DISK_SIZE = "disk-size"
892
ISPEC_NIC_COUNT = "nic-count"
893
ISPEC_SPINDLE_USE = "spindle-use"
894

    
895
ISPECS_PARAMETER_TYPES = {
896
  ISPEC_MEM_SIZE: VTYPE_INT,
897
  ISPEC_CPU_COUNT: VTYPE_INT,
898
  ISPEC_DISK_COUNT: VTYPE_INT,
899
  ISPEC_DISK_SIZE: VTYPE_INT,
900
  ISPEC_NIC_COUNT: VTYPE_INT,
901
  ISPEC_SPINDLE_USE: VTYPE_INT,
902
  }
903

    
904
ISPECS_PARAMETERS = frozenset(ISPECS_PARAMETER_TYPES.keys())
905

    
906
ISPECS_MIN = "min"
907
ISPECS_MAX = "max"
908
ISPECS_STD = "std"
909
IPOLICY_DTS = "disk-templates"
910
IPOLICY_VCPU_RATIO = "vcpu-ratio"
911
IPOLICY_SPINDLE_RATIO = "spindle-ratio"
912

    
913
IPOLICY_ISPECS = frozenset([
914
  ISPECS_MIN,
915
  ISPECS_MAX,
916
  ISPECS_STD,
917
  ])
918

    
919
IPOLICY_PARAMETERS = frozenset([
920
  IPOLICY_VCPU_RATIO,
921
  IPOLICY_SPINDLE_RATIO,
922
  ])
923

    
924
IPOLICY_ALL_KEYS = (IPOLICY_ISPECS |
925
                    IPOLICY_PARAMETERS |
926
                    frozenset([IPOLICY_DTS]))
927

    
928
# Node parameter names
929
ND_OOB_PROGRAM = "oob_program"
930
ND_SPINDLE_COUNT = "spindle_count"
931

    
932
NDS_PARAMETER_TYPES = {
933
  ND_OOB_PROGRAM: VTYPE_STRING,
934
  ND_SPINDLE_COUNT: VTYPE_INT,
935
  }
936

    
937
NDS_PARAMETERS = frozenset(NDS_PARAMETER_TYPES.keys())
938

    
939
NDS_PARAMETER_TITLES = {
940
  ND_OOB_PROGRAM: "OutOfBandProgram",
941
  ND_SPINDLE_COUNT: "SpindleCount",
942
  }
943

    
944
# Logical Disks parameters
945
LDP_RESYNC_RATE = "resync-rate"
946
LDP_STRIPES = "stripes"
947
LDP_BARRIERS = "disabled-barriers"
948
LDP_NO_META_FLUSH = "disable-meta-flush"
949
LDP_DEFAULT_METAVG = "default-metavg"
950
LDP_DISK_CUSTOM = "disk-custom"
951
LDP_NET_CUSTOM = "net-custom"
952
LDP_DYNAMIC_RESYNC = "dynamic-resync"
953
LDP_PLAN_AHEAD = "c-plan-ahead"
954
LDP_FILL_TARGET = "c-fill-target"
955
LDP_DELAY_TARGET = "c-delay-target"
956
LDP_MAX_RATE = "c-max-rate"
957
LDP_MIN_RATE = "c-min-rate"
958
LDP_POOL = "pool"
959
DISK_LD_TYPES = {
960
  LDP_RESYNC_RATE: VTYPE_INT,
961
  LDP_STRIPES: VTYPE_INT,
962
  LDP_BARRIERS: VTYPE_STRING,
963
  LDP_NO_META_FLUSH: VTYPE_BOOL,
964
  LDP_DEFAULT_METAVG: VTYPE_STRING,
965
  LDP_DISK_CUSTOM: VTYPE_STRING,
966
  LDP_NET_CUSTOM: VTYPE_STRING,
967
  LDP_DYNAMIC_RESYNC: VTYPE_BOOL,
968
  LDP_PLAN_AHEAD: VTYPE_INT,
969
  LDP_FILL_TARGET: VTYPE_INT,
970
  LDP_DELAY_TARGET: VTYPE_INT,
971
  LDP_MAX_RATE: VTYPE_INT,
972
  LDP_MIN_RATE: VTYPE_INT,
973
  LDP_POOL: VTYPE_STRING,
974
  }
975
DISK_LD_PARAMETERS = frozenset(DISK_LD_TYPES.keys())
976

    
977
# Disk template parameters (can be set/changed by the user via gnt-cluster and
978
# gnt-group)
979
DRBD_RESYNC_RATE = "resync-rate"
980
DRBD_DATA_STRIPES = "data-stripes"
981
DRBD_META_STRIPES = "meta-stripes"
982
DRBD_DISK_BARRIERS = "disk-barriers"
983
DRBD_META_BARRIERS = "meta-barriers"
984
DRBD_DEFAULT_METAVG = "metavg"
985
DRBD_DISK_CUSTOM = "disk-custom"
986
DRBD_NET_CUSTOM = "net-custom"
987
DRBD_DYNAMIC_RESYNC = "dynamic-resync"
988
DRBD_PLAN_AHEAD = "c-plan-ahead"
989
DRBD_FILL_TARGET = "c-fill-target"
990
DRBD_DELAY_TARGET = "c-delay-target"
991
DRBD_MAX_RATE = "c-max-rate"
992
DRBD_MIN_RATE = "c-min-rate"
993
LV_STRIPES = "stripes"
994
RBD_POOL = "pool"
995
DISK_DT_TYPES = {
996
  DRBD_RESYNC_RATE: VTYPE_INT,
997
  DRBD_DATA_STRIPES: VTYPE_INT,
998
  DRBD_META_STRIPES: VTYPE_INT,
999
  DRBD_DISK_BARRIERS: VTYPE_STRING,
1000
  DRBD_META_BARRIERS: VTYPE_BOOL,
1001
  DRBD_DEFAULT_METAVG: VTYPE_STRING,
1002
  DRBD_DISK_CUSTOM: VTYPE_STRING,
1003
  DRBD_NET_CUSTOM: VTYPE_STRING,
1004
  DRBD_DYNAMIC_RESYNC: VTYPE_BOOL,
1005
  DRBD_PLAN_AHEAD: VTYPE_INT,
1006
  DRBD_FILL_TARGET: VTYPE_INT,
1007
  DRBD_DELAY_TARGET: VTYPE_INT,
1008
  DRBD_MAX_RATE: VTYPE_INT,
1009
  DRBD_MIN_RATE: VTYPE_INT,
1010
  LV_STRIPES: VTYPE_INT,
1011
  RBD_POOL: VTYPE_STRING,
1012
  }
1013

    
1014
DISK_DT_PARAMETERS = frozenset(DISK_DT_TYPES.keys())
1015

    
1016
# OOB supported commands
1017
OOB_POWER_ON = "power-on"
1018
OOB_POWER_OFF = "power-off"
1019
OOB_POWER_CYCLE = "power-cycle"
1020
OOB_POWER_STATUS = "power-status"
1021
OOB_HEALTH = "health"
1022

    
1023
OOB_COMMANDS = frozenset([
1024
  OOB_POWER_ON,
1025
  OOB_POWER_OFF,
1026
  OOB_POWER_CYCLE,
1027
  OOB_POWER_STATUS,
1028
  OOB_HEALTH
1029
  ])
1030

    
1031
OOB_POWER_STATUS_POWERED = "powered"
1032

    
1033
OOB_TIMEOUT = 60 # 60 seconds
1034
OOB_POWER_DELAY = 2.0 # 2 seconds
1035

    
1036
OOB_STATUS_OK = "OK"
1037
OOB_STATUS_WARNING = "WARNING"
1038
OOB_STATUS_CRITICAL = "CRITICAL"
1039
OOB_STATUS_UNKNOWN = "UNKNOWN"
1040

    
1041
OOB_STATUSES = frozenset([
1042
  OOB_STATUS_OK,
1043
  OOB_STATUS_WARNING,
1044
  OOB_STATUS_CRITICAL,
1045
  OOB_STATUS_UNKNOWN,
1046
  ])
1047

    
1048
# Instance Parameters Profile
1049
PP_DEFAULT = "default"
1050

    
1051
# NIC_* constants are used inside the ganeti config
1052
NIC_MODE = "mode"
1053
NIC_LINK = "link"
1054

    
1055
NIC_MODE_BRIDGED = "bridged"
1056
NIC_MODE_ROUTED = "routed"
1057

    
1058
NIC_VALID_MODES = frozenset([NIC_MODE_BRIDGED, NIC_MODE_ROUTED])
1059

    
1060
NICS_PARAMETER_TYPES = {
1061
  NIC_MODE: VTYPE_STRING,
1062
  NIC_LINK: VTYPE_STRING,
1063
  }
1064

    
1065
NICS_PARAMETERS = frozenset(NICS_PARAMETER_TYPES.keys())
1066

    
1067
# IDISK_* constants are used in opcodes, to create/change disks
1068
IDISK_SIZE = "size"
1069
IDISK_MODE = "mode"
1070
IDISK_ADOPT = "adopt"
1071
IDISK_VG = "vg"
1072
IDISK_METAVG = "metavg"
1073
IDISK_PARAMS_TYPES = {
1074
  IDISK_SIZE: VTYPE_SIZE,
1075
  IDISK_MODE: VTYPE_STRING,
1076
  IDISK_ADOPT: VTYPE_STRING,
1077
  IDISK_VG: VTYPE_STRING,
1078
  IDISK_METAVG: VTYPE_STRING,
1079
  }
1080
IDISK_PARAMS = frozenset(IDISK_PARAMS_TYPES.keys())
1081

    
1082
# INIC_* constants are used in opcodes, to create/change nics
1083
INIC_MAC = "mac"
1084
INIC_IP = "ip"
1085
INIC_MODE = "mode"
1086
INIC_LINK = "link"
1087
INIC_PARAMS_TYPES = {
1088
  INIC_IP: VTYPE_MAYBE_STRING,
1089
  INIC_LINK: VTYPE_STRING,
1090
  INIC_MAC: VTYPE_STRING,
1091
  INIC_MODE: VTYPE_STRING,
1092
  }
1093
INIC_PARAMS = frozenset(INIC_PARAMS_TYPES.keys())
1094

    
1095
# Hypervisor constants
1096
HT_XEN_PVM = "xen-pvm"
1097
HT_FAKE = "fake"
1098
HT_XEN_HVM = "xen-hvm"
1099
HT_KVM = "kvm"
1100
HT_CHROOT = "chroot"
1101
HT_LXC = "lxc"
1102
HYPER_TYPES = frozenset([
1103
  HT_XEN_PVM,
1104
  HT_FAKE,
1105
  HT_XEN_HVM,
1106
  HT_KVM,
1107
  HT_CHROOT,
1108
  HT_LXC,
1109
  ])
1110
HTS_REQ_PORT = frozenset([HT_XEN_HVM, HT_KVM])
1111

    
1112
VNC_BASE_PORT = 5900
1113
VNC_DEFAULT_BIND_ADDRESS = IP4_ADDRESS_ANY
1114

    
1115
# NIC types
1116
HT_NIC_RTL8139 = "rtl8139"
1117
HT_NIC_NE2K_PCI = "ne2k_pci"
1118
HT_NIC_NE2K_ISA = "ne2k_isa"
1119
HT_NIC_I82551 = "i82551"
1120
HT_NIC_I85557B = "i82557b"
1121
HT_NIC_I8259ER = "i82559er"
1122
HT_NIC_PCNET = "pcnet"
1123
HT_NIC_E1000 = "e1000"
1124
HT_NIC_PARAVIRTUAL = HT_DISK_PARAVIRTUAL = "paravirtual"
1125

    
1126
HT_HVM_VALID_NIC_TYPES = frozenset([
1127
  HT_NIC_RTL8139,
1128
  HT_NIC_NE2K_PCI,
1129
  HT_NIC_E1000,
1130
  HT_NIC_NE2K_ISA,
1131
  HT_NIC_PARAVIRTUAL
1132
  ])
1133
HT_KVM_VALID_NIC_TYPES = frozenset([
1134
  HT_NIC_RTL8139,
1135
  HT_NIC_NE2K_PCI,
1136
  HT_NIC_NE2K_ISA,
1137
  HT_NIC_I82551,
1138
  HT_NIC_I85557B,
1139
  HT_NIC_I8259ER,
1140
  HT_NIC_PCNET,
1141
  HT_NIC_E1000,
1142
  HT_NIC_PARAVIRTUAL
1143
  ])
1144

    
1145
# Disk types
1146
HT_DISK_IOEMU = "ioemu"
1147
HT_DISK_IDE = "ide"
1148
HT_DISK_SCSI = "scsi"
1149
HT_DISK_SD = "sd"
1150
HT_DISK_MTD = "mtd"
1151
HT_DISK_PFLASH = "pflash"
1152

    
1153
HT_CACHE_DEFAULT = "default"
1154
HT_CACHE_NONE = "none"
1155
HT_CACHE_WTHROUGH = "writethrough"
1156
HT_CACHE_WBACK = "writeback"
1157
HT_VALID_CACHE_TYPES = frozenset([
1158
  HT_CACHE_DEFAULT,
1159
  HT_CACHE_NONE,
1160
  HT_CACHE_WTHROUGH,
1161
  HT_CACHE_WBACK
1162
  ])
1163

    
1164
HT_HVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IOEMU])
1165
HT_KVM_VALID_DISK_TYPES = frozenset([
1166
  HT_DISK_PARAVIRTUAL,
1167
  HT_DISK_IDE,
1168
  HT_DISK_SCSI,
1169
  HT_DISK_SD,
1170
  HT_DISK_MTD,
1171
  HT_DISK_PFLASH
1172
  ])
1173

    
1174
# Mouse types:
1175
HT_MOUSE_MOUSE = "mouse"
1176
HT_MOUSE_TABLET = "tablet"
1177

    
1178
HT_KVM_VALID_MOUSE_TYPES = frozenset([HT_MOUSE_MOUSE, HT_MOUSE_TABLET])
1179

    
1180
# Boot order
1181
HT_BO_FLOPPY = "floppy"
1182
HT_BO_CDROM = "cdrom"
1183
HT_BO_DISK = "disk"
1184
HT_BO_NETWORK = "network"
1185

    
1186
HT_KVM_VALID_BO_TYPES = frozenset([
1187
  HT_BO_FLOPPY,
1188
  HT_BO_CDROM,
1189
  HT_BO_DISK,
1190
  HT_BO_NETWORK
1191
  ])
1192

    
1193
# SPICE lossless image compression options
1194
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ = "auto_glz"
1195
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ = "auto_lz"
1196
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC = "quic"
1197
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ = "glz"
1198
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ = "lz"
1199
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF = "off"
1200

    
1201
HT_KVM_SPICE_VALID_LOSSLESS_IMG_COMPR_OPTIONS = frozenset([
1202
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ,
1203
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ,
1204
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC,
1205
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ,
1206
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ,
1207
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF,
1208
  ])
1209

    
1210
# SPICE lossy image compression options (valid for both jpeg and zlib-glz)
1211
HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO = "auto"
1212
HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER = "never"
1213
HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS = "always"
1214

    
1215
HT_KVM_SPICE_VALID_LOSSY_IMG_COMPR_OPTIONS = frozenset([
1216
  HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO,
1217
  HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER,
1218
  HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS,
1219
  ])
1220

    
1221
# SPICE video stream detection
1222
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF = "off"
1223
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL = "all"
1224
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER = "filter"
1225

    
1226
HT_KVM_SPICE_VALID_VIDEO_STREAM_DETECTION_OPTIONS = frozenset([
1227
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF,
1228
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL,
1229
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER,
1230
  ])
1231

    
1232
# Security models
1233
HT_SM_NONE = "none"
1234
HT_SM_USER = "user"
1235
HT_SM_POOL = "pool"
1236

    
1237
HT_KVM_VALID_SM_TYPES = frozenset([HT_SM_NONE, HT_SM_USER, HT_SM_POOL])
1238

    
1239
# Kvm flag values
1240
HT_KVM_ENABLED = "enabled"
1241
HT_KVM_DISABLED = "disabled"
1242

    
1243
HT_KVM_FLAG_VALUES = frozenset([HT_KVM_ENABLED, HT_KVM_DISABLED])
1244

    
1245
# Migration type
1246
HT_MIGRATION_LIVE = "live"
1247
HT_MIGRATION_NONLIVE = "non-live"
1248
HT_MIGRATION_MODES = frozenset([HT_MIGRATION_LIVE, HT_MIGRATION_NONLIVE])
1249

    
1250
# Cluster Verify steps
1251
VERIFY_NPLUSONE_MEM = "nplusone_mem"
1252
VERIFY_OPTIONAL_CHECKS = frozenset([VERIFY_NPLUSONE_MEM])
1253

    
1254
# Cluster Verify error classes
1255
CV_TCLUSTER = "cluster"
1256
CV_TNODE = "node"
1257
CV_TINSTANCE = "instance"
1258

    
1259
# Cluster Verify error codes and documentation
1260
CV_ECLUSTERCFG = \
1261
  (CV_TCLUSTER, "ECLUSTERCFG", "Cluster configuration verification failure")
1262
CV_ECLUSTERCERT = \
1263
  (CV_TCLUSTER, "ECLUSTERCERT",
1264
   "Cluster certificate files verification failure")
1265
CV_ECLUSTERFILECHECK = \
1266
  (CV_TCLUSTER, "ECLUSTERFILECHECK",
1267
   "Cluster configuration verification failure")
1268
CV_ECLUSTERDANGLINGNODES = \
1269
  (CV_TNODE, "ECLUSTERDANGLINGNODES",
1270
   "Some nodes belong to non-existing groups")
1271
CV_ECLUSTERDANGLINGINST = \
1272
  (CV_TNODE, "ECLUSTERDANGLINGINST",
1273
   "Some instances have a non-existing primary node")
1274
CV_EINSTANCEBADNODE = \
1275
  (CV_TINSTANCE, "EINSTANCEBADNODE",
1276
   "Instance marked as running lives on an offline node")
1277
CV_EINSTANCEDOWN = \
1278
  (CV_TINSTANCE, "EINSTANCEDOWN", "Instance not running on its primary node")
1279
CV_EINSTANCELAYOUT = \
1280
  (CV_TINSTANCE, "EINSTANCELAYOUT", "Instance has multiple secondary nodes")
1281
CV_EINSTANCEMISSINGDISK = \
1282
  (CV_TINSTANCE, "EINSTANCEMISSINGDISK", "Missing volume on an instance")
1283
CV_EINSTANCEFAULTYDISK = \
1284
  (CV_TINSTANCE, "EINSTANCEFAULTYDISK",
1285
   "Impossible to retrieve status for a disk")
1286
CV_EINSTANCEWRONGNODE = \
1287
  (CV_TINSTANCE, "EINSTANCEWRONGNODE", "Instance running on the wrong node")
1288
CV_EINSTANCESPLITGROUPS = \
1289
  (CV_TINSTANCE, "EINSTANCESPLITGROUPS",
1290
   "Instance with primary and secondary nodes in different groups")
1291
CV_EINSTANCEPOLICY = \
1292
  (CV_TINSTANCE, "EINSTANCEPOLICY",
1293
   "Instance does not meet policy")
1294
CV_ENODEDRBD = \
1295
  (CV_TNODE, "ENODEDRBD", "Error parsing the DRBD status file")
1296
CV_ENODEDRBDHELPER = \
1297
  (CV_TNODE, "ENODEDRBDHELPER", "Error caused by the DRBD helper")
1298
CV_ENODEFILECHECK = \
1299
  (CV_TNODE, "ENODEFILECHECK",
1300
   "Error retrieving the checksum of the node files")
1301
CV_ENODEHOOKS = \
1302
  (CV_TNODE, "ENODEHOOKS", "Communication failure in hooks execution")
1303
CV_ENODEHV = \
1304
  (CV_TNODE, "ENODEHV", "Hypervisor parameters verification failure")
1305
CV_ENODELVM = \
1306
  (CV_TNODE, "ENODELVM", "LVM-related node error")
1307
CV_ENODEN1 = \
1308
  (CV_TNODE, "ENODEN1", "Not enough memory to accommodate instance failovers")
1309
CV_ENODENET = \
1310
  (CV_TNODE, "ENODENET", "Network-related node error")
1311
CV_ENODEOS = \
1312
  (CV_TNODE, "ENODEOS", "OS-related node error")
1313
CV_ENODEORPHANINSTANCE = \
1314
  (CV_TNODE, "ENODEORPHANINSTANCE", "Unknown intance running on a node")
1315
CV_ENODEORPHANLV = \
1316
  (CV_TNODE, "ENODEORPHANLV", "Unknown LVM logical volume")
1317
CV_ENODERPC = \
1318
  (CV_TNODE, "ENODERPC",
1319
   "Error during connection to the primary node of an instance")
1320
CV_ENODESSH = \
1321
  (CV_TNODE, "ENODESSH", "SSH-related node error")
1322
CV_ENODEVERSION = \
1323
  (CV_TNODE, "ENODEVERSION",
1324
   "Protocol version mismatch or Ganeti version mismatch")
1325
CV_ENODESETUP = \
1326
  (CV_TNODE, "ENODESETUP", "Node setup error")
1327
CV_ENODETIME = \
1328
  (CV_TNODE, "ENODETIME", "Node returned invalid time")
1329
CV_ENODEOOBPATH = \
1330
  (CV_TNODE, "ENODEOOBPATH", "Invalid Out Of Band path")
1331
CV_ENODEUSERSCRIPTS = \
1332
  (CV_TNODE, "ENODEUSERSCRIPTS", "User scripts not present or not executable")
1333

    
1334
CV_ALL_ECODES = frozenset([
1335
  CV_ECLUSTERCFG,
1336
  CV_ECLUSTERCERT,
1337
  CV_ECLUSTERFILECHECK,
1338
  CV_ECLUSTERDANGLINGNODES,
1339
  CV_ECLUSTERDANGLINGINST,
1340
  CV_EINSTANCEBADNODE,
1341
  CV_EINSTANCEDOWN,
1342
  CV_EINSTANCELAYOUT,
1343
  CV_EINSTANCEMISSINGDISK,
1344
  CV_EINSTANCEFAULTYDISK,
1345
  CV_EINSTANCEWRONGNODE,
1346
  CV_EINSTANCESPLITGROUPS,
1347
  CV_EINSTANCEPOLICY,
1348
  CV_ENODEDRBD,
1349
  CV_ENODEDRBDHELPER,
1350
  CV_ENODEFILECHECK,
1351
  CV_ENODEHOOKS,
1352
  CV_ENODEHV,
1353
  CV_ENODELVM,
1354
  CV_ENODEN1,
1355
  CV_ENODENET,
1356
  CV_ENODEOS,
1357
  CV_ENODEORPHANINSTANCE,
1358
  CV_ENODEORPHANLV,
1359
  CV_ENODERPC,
1360
  CV_ENODESSH,
1361
  CV_ENODEVERSION,
1362
  CV_ENODESETUP,
1363
  CV_ENODETIME,
1364
  CV_ENODEOOBPATH,
1365
  CV_ENODEUSERSCRIPTS,
1366
  ])
1367

    
1368
CV_ALL_ECODES_STRINGS = frozenset(estr for (_, estr, _) in CV_ALL_ECODES)
1369

    
1370
# Node verify constants
1371
NV_DRBDHELPER = "drbd-helper"
1372
NV_DRBDLIST = "drbd-list"
1373
NV_FILELIST = "filelist"
1374
NV_HVINFO = "hvinfo"
1375
NV_HYPERVISOR = "hypervisor"
1376
NV_HVPARAMS = "hvparms"
1377
NV_INSTANCELIST = "instancelist"
1378
NV_LVLIST = "lvlist"
1379
NV_MASTERIP = "master-ip"
1380
NV_NODELIST = "nodelist"
1381
NV_NODENETTEST = "node-net-test"
1382
NV_NODESETUP = "nodesetup"
1383
NV_OSLIST = "oslist"
1384
NV_PVLIST = "pvlist"
1385
NV_TIME = "time"
1386
NV_VERSION = "version"
1387
NV_VGLIST = "vglist"
1388
NV_VMNODES = "vmnodes"
1389
NV_OOB_PATHS = "oob-paths"
1390
NV_BRIDGES = "bridges"
1391
NV_USERSCRIPTS = "user-scripts"
1392

    
1393
# Instance status
1394
INSTST_RUNNING = "running"
1395
INSTST_ADMINDOWN = "ADMIN_down"
1396
INSTST_ADMINOFFLINE = "ADMIN_offline"
1397
INSTST_NODEOFFLINE = "ERROR_nodeoffline"
1398
INSTST_NODEDOWN = "ERROR_nodedown"
1399
INSTST_WRONGNODE = "ERROR_wrongnode"
1400
INSTST_ERRORUP = "ERROR_up"
1401
INSTST_ERRORDOWN = "ERROR_down"
1402
INSTST_ALL = frozenset([
1403
  INSTST_RUNNING,
1404
  INSTST_ADMINDOWN,
1405
  INSTST_ADMINOFFLINE,
1406
  INSTST_NODEOFFLINE,
1407
  INSTST_NODEDOWN,
1408
  INSTST_WRONGNODE,
1409
  INSTST_ERRORUP,
1410
  INSTST_ERRORDOWN,
1411
  ])
1412

    
1413
# Admin states
1414
ADMINST_UP = "up"
1415
ADMINST_DOWN = "down"
1416
ADMINST_OFFLINE = "offline"
1417
ADMINST_ALL = frozenset([
1418
  ADMINST_UP,
1419
  ADMINST_DOWN,
1420
  ADMINST_OFFLINE,
1421
  ])
1422

    
1423
# Node roles
1424
NR_REGULAR = "R"
1425
NR_MASTER = "M"
1426
NR_MCANDIDATE = "C"
1427
NR_DRAINED = "D"
1428
NR_OFFLINE = "O"
1429
NR_ALL = frozenset([
1430
  NR_REGULAR,
1431
  NR_MASTER,
1432
  NR_MCANDIDATE,
1433
  NR_DRAINED,
1434
  NR_OFFLINE,
1435
  ])
1436

    
1437
# SSL certificate check constants (in days)
1438
SSL_CERT_EXPIRATION_WARN = 30
1439
SSL_CERT_EXPIRATION_ERROR = 7
1440

    
1441
# Allocator framework constants
1442
IALLOCATOR_VERSION = 2
1443
IALLOCATOR_DIR_IN = "in"
1444
IALLOCATOR_DIR_OUT = "out"
1445
VALID_IALLOCATOR_DIRECTIONS = frozenset([
1446
  IALLOCATOR_DIR_IN,
1447
  IALLOCATOR_DIR_OUT,
1448
  ])
1449
IALLOCATOR_MODE_ALLOC = "allocate"
1450
IALLOCATOR_MODE_RELOC = "relocate"
1451
IALLOCATOR_MODE_CHG_GROUP = "change-group"
1452
IALLOCATOR_MODE_NODE_EVAC = "node-evacuate"
1453
IALLOCATOR_MODE_MULTI_ALLOC = "multi-allocate"
1454
VALID_IALLOCATOR_MODES = frozenset([
1455
  IALLOCATOR_MODE_ALLOC,
1456
  IALLOCATOR_MODE_RELOC,
1457
  IALLOCATOR_MODE_CHG_GROUP,
1458
  IALLOCATOR_MODE_NODE_EVAC,
1459
  IALLOCATOR_MODE_MULTI_ALLOC,
1460
  ])
1461
IALLOCATOR_SEARCH_PATH = _autoconf.IALLOCATOR_SEARCH_PATH
1462
DEFAULT_IALLOCATOR_SHORTCUT = "."
1463

    
1464
IALLOCATOR_NEVAC_PRI = "primary-only"
1465
IALLOCATOR_NEVAC_SEC = "secondary-only"
1466
IALLOCATOR_NEVAC_ALL = "all"
1467
IALLOCATOR_NEVAC_MODES = frozenset([
1468
  IALLOCATOR_NEVAC_PRI,
1469
  IALLOCATOR_NEVAC_SEC,
1470
  IALLOCATOR_NEVAC_ALL,
1471
  ])
1472

    
1473
# Node evacuation
1474
NODE_EVAC_PRI = "primary-only"
1475
NODE_EVAC_SEC = "secondary-only"
1476
NODE_EVAC_ALL = "all"
1477
NODE_EVAC_MODES = frozenset([
1478
  NODE_EVAC_PRI,
1479
  NODE_EVAC_SEC,
1480
  NODE_EVAC_ALL,
1481
  ])
1482

    
1483
# Job queue
1484
JOB_QUEUE_VERSION = 1
1485
JOB_QUEUE_SIZE_HARD_LIMIT = 5000
1486

    
1487
JOB_ID_TEMPLATE = r"\d+"
1488
JOB_FILE_RE = re.compile(r"^job-(%s)$" % JOB_ID_TEMPLATE)
1489

    
1490
# unchanged job return
1491
JOB_NOTCHANGED = "nochange"
1492

    
1493
# Job status
1494
JOB_STATUS_QUEUED = "queued"
1495
JOB_STATUS_WAITING = "waiting"
1496
JOB_STATUS_CANCELING = "canceling"
1497
JOB_STATUS_RUNNING = "running"
1498
JOB_STATUS_CANCELED = "canceled"
1499
JOB_STATUS_SUCCESS = "success"
1500
JOB_STATUS_ERROR = "error"
1501
JOBS_PENDING = frozenset([
1502
  JOB_STATUS_QUEUED,
1503
  JOB_STATUS_WAITING,
1504
  JOB_STATUS_CANCELING,
1505
  ])
1506
JOBS_FINALIZED = frozenset([
1507
  JOB_STATUS_CANCELED,
1508
  JOB_STATUS_SUCCESS,
1509
  JOB_STATUS_ERROR,
1510
  ])
1511
JOB_STATUS_ALL = frozenset([
1512
  JOB_STATUS_RUNNING,
1513
  ]) | JOBS_PENDING | JOBS_FINALIZED
1514

    
1515
# OpCode status
1516
# not yet finalized
1517
OP_STATUS_QUEUED = "queued"
1518
OP_STATUS_WAITING = "waiting"
1519
OP_STATUS_CANCELING = "canceling"
1520
OP_STATUS_RUNNING = "running"
1521
# finalized
1522
OP_STATUS_CANCELED = "canceled"
1523
OP_STATUS_SUCCESS = "success"
1524
OP_STATUS_ERROR = "error"
1525
OPS_FINALIZED = frozenset([
1526
  OP_STATUS_CANCELED,
1527
  OP_STATUS_SUCCESS,
1528
  OP_STATUS_ERROR
1529
  ])
1530

    
1531
# OpCode priority
1532
OP_PRIO_LOWEST = +19
1533
OP_PRIO_HIGHEST = -20
1534

    
1535
OP_PRIO_LOW = +10
1536
OP_PRIO_NORMAL = 0
1537
OP_PRIO_HIGH = -10
1538

    
1539
OP_PRIO_SUBMIT_VALID = frozenset([
1540
  OP_PRIO_LOW,
1541
  OP_PRIO_NORMAL,
1542
  OP_PRIO_HIGH,
1543
  ])
1544

    
1545
OP_PRIO_DEFAULT = OP_PRIO_NORMAL
1546

    
1547
# Lock recalculate mode
1548
LOCKS_REPLACE = "replace"
1549
LOCKS_APPEND = "append"
1550

    
1551
# Lock timeout (sum) before we should go into blocking acquire (still
1552
# can be reset by priority change); computed as max time (10 hours)
1553
# before we should actually go into blocking acquire given that we
1554
# start from default priority level; in seconds
1555
# TODO
1556
LOCK_ATTEMPTS_TIMEOUT = 10 * 3600 / (OP_PRIO_DEFAULT - OP_PRIO_HIGHEST)
1557
LOCK_ATTEMPTS_MAXWAIT = 15.0
1558
LOCK_ATTEMPTS_MINWAIT = 1.0
1559

    
1560
# Execution log types
1561
ELOG_MESSAGE = "message"
1562
ELOG_REMOTE_IMPORT = "remote-import"
1563
ELOG_JQUEUE_TEST = "jqueue-test"
1564

    
1565
# /etc/hosts modification
1566
ETC_HOSTS_ADD = "add"
1567
ETC_HOSTS_REMOVE = "remove"
1568

    
1569
# Job queue test
1570
JQT_MSGPREFIX = "TESTMSG="
1571
JQT_EXPANDNAMES = "expandnames"
1572
JQT_EXEC = "exec"
1573
JQT_LOGMSG = "logmsg"
1574
JQT_STARTMSG = "startmsg"
1575
JQT_ALL = frozenset([
1576
  JQT_EXPANDNAMES,
1577
  JQT_EXEC,
1578
  JQT_LOGMSG,
1579
  JQT_STARTMSG,
1580
  ])
1581

    
1582
# Query resources
1583
QR_CLUSTER = "cluster"
1584
QR_INSTANCE = "instance"
1585
QR_NODE = "node"
1586
QR_LOCK = "lock"
1587
QR_GROUP = "group"
1588
QR_OS = "os"
1589
QR_JOB = "job"
1590
QR_EXPORT = "export"
1591

    
1592
#: List of resources which can be queried using L{opcodes.OpQuery}
1593
QR_VIA_OP = frozenset([
1594
  QR_CLUSTER,
1595
  QR_INSTANCE,
1596
  QR_NODE,
1597
  QR_GROUP,
1598
  QR_OS,
1599
  QR_EXPORT,
1600
  ])
1601

    
1602
#: List of resources which can be queried using Local UniX Interface
1603
QR_VIA_LUXI = QR_VIA_OP.union([
1604
  QR_LOCK,
1605
  QR_JOB,
1606
  ])
1607

    
1608
#: List of resources which can be queried using RAPI
1609
QR_VIA_RAPI = QR_VIA_LUXI
1610

    
1611
# Query field types
1612
QFT_UNKNOWN = "unknown"
1613
QFT_TEXT = "text"
1614
QFT_BOOL = "bool"
1615
QFT_NUMBER = "number"
1616
QFT_UNIT = "unit"
1617
QFT_TIMESTAMP = "timestamp"
1618
QFT_OTHER = "other"
1619

    
1620
#: All query field types
1621
QFT_ALL = frozenset([
1622
  QFT_UNKNOWN,
1623
  QFT_TEXT,
1624
  QFT_BOOL,
1625
  QFT_NUMBER,
1626
  QFT_UNIT,
1627
  QFT_TIMESTAMP,
1628
  QFT_OTHER,
1629
  ])
1630

    
1631
# Query result field status (don't change or reuse values as they're used by
1632
# clients)
1633
#: Normal field status
1634
RS_NORMAL = 0
1635
#: Unknown field
1636
RS_UNKNOWN = 1
1637
#: No data (e.g. RPC error), can be used instead of L{RS_OFFLINE}
1638
RS_NODATA = 2
1639
#: Value unavailable/unsupported for item; if this field is supported
1640
#: but we cannot get the data for the moment, RS_NODATA or
1641
#: RS_OFFLINE should be used
1642
RS_UNAVAIL = 3
1643
#: Resource marked offline
1644
RS_OFFLINE = 4
1645

    
1646
RS_ALL = frozenset([
1647
  RS_NORMAL,
1648
  RS_UNKNOWN,
1649
  RS_NODATA,
1650
  RS_UNAVAIL,
1651
  RS_OFFLINE,
1652
  ])
1653

    
1654
#: Dictionary with special field cases and their verbose/terse formatting
1655
RSS_DESCRIPTION = {
1656
  RS_UNKNOWN: ("(unknown)", "??"),
1657
  RS_NODATA: ("(nodata)", "?"),
1658
  RS_OFFLINE: ("(offline)", "*"),
1659
  RS_UNAVAIL: ("(unavail)", "-"),
1660
  }
1661

    
1662
# max dynamic devices
1663
MAX_NICS = 8
1664
MAX_DISKS = 16
1665

    
1666
# SSCONF file prefix
1667
SSCONF_FILEPREFIX = "ssconf_"
1668
# SSCONF keys
1669
SS_CLUSTER_NAME = "cluster_name"
1670
SS_CLUSTER_TAGS = "cluster_tags"
1671
SS_FILE_STORAGE_DIR = "file_storage_dir"
1672
SS_SHARED_FILE_STORAGE_DIR = "shared_file_storage_dir"
1673
SS_MASTER_CANDIDATES = "master_candidates"
1674
SS_MASTER_CANDIDATES_IPS = "master_candidates_ips"
1675
SS_MASTER_IP = "master_ip"
1676
SS_MASTER_NETDEV = "master_netdev"
1677
SS_MASTER_NETMASK = "master_netmask"
1678
SS_MASTER_NODE = "master_node"
1679
SS_NODE_LIST = "node_list"
1680
SS_NODE_PRIMARY_IPS = "node_primary_ips"
1681
SS_NODE_SECONDARY_IPS = "node_secondary_ips"
1682
SS_OFFLINE_NODES = "offline_nodes"
1683
SS_ONLINE_NODES = "online_nodes"
1684
SS_PRIMARY_IP_FAMILY = "primary_ip_family"
1685
SS_INSTANCE_LIST = "instance_list"
1686
SS_RELEASE_VERSION = "release_version"
1687
SS_HYPERVISOR_LIST = "hypervisor_list"
1688
SS_MAINTAIN_NODE_HEALTH = "maintain_node_health"
1689
SS_UID_POOL = "uid_pool"
1690
SS_NODEGROUPS = "nodegroups"
1691

    
1692
SS_FILE_PERMS = 0444
1693

    
1694
# cluster wide default parameters
1695
DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM
1696

    
1697
HVC_DEFAULTS = {
1698
  HT_XEN_PVM: {
1699
    HV_USE_BOOTLOADER: False,
1700
    HV_BOOTLOADER_PATH: XEN_BOOTLOADER,
1701
    HV_BOOTLOADER_ARGS: "",
1702
    HV_KERNEL_PATH: XEN_KERNEL,
1703
    HV_INITRD_PATH: "",
1704
    HV_ROOT_PATH: "/dev/sda1",
1705
    HV_KERNEL_ARGS: "ro",
1706
    HV_MIGRATION_PORT: 8002,
1707
    HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1708
    HV_BLOCKDEV_PREFIX: "sd",
1709
    HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1710
    HV_CPU_MASK: CPU_PINNING_ALL,
1711
    HV_CPU_CAP: 0,
1712
    HV_CPU_WEIGHT: 256,
1713
    },
1714
  HT_XEN_HVM: {
1715
    HV_BOOT_ORDER: "cd",
1716
    HV_CDROM_IMAGE_PATH: "",
1717
    HV_NIC_TYPE: HT_NIC_RTL8139,
1718
    HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
1719
    HV_VNC_BIND_ADDRESS: IP4_ADDRESS_ANY,
1720
    HV_VNC_PASSWORD_FILE: pathutils.VNC_PASSWORD_FILE,
1721
    HV_ACPI: True,
1722
    HV_PAE: True,
1723
    HV_KERNEL_PATH: "/usr/lib/xen/boot/hvmloader",
1724
    HV_DEVICE_MODEL: "/usr/lib/xen/bin/qemu-dm",
1725
    HV_MIGRATION_PORT: 8002,
1726
    HV_MIGRATION_MODE: HT_MIGRATION_NONLIVE,
1727
    HV_USE_LOCALTIME: False,
1728
    HV_BLOCKDEV_PREFIX: "hd",
1729
    HV_PASSTHROUGH: "",
1730
    HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1731
    HV_CPU_MASK: CPU_PINNING_ALL,
1732
    HV_CPU_CAP: 0,
1733
    HV_CPU_WEIGHT: 256,
1734
    },
1735
  HT_KVM: {
1736
    HV_KERNEL_PATH: KVM_KERNEL,
1737
    HV_INITRD_PATH: "",
1738
    HV_KERNEL_ARGS: "ro",
1739
    HV_ROOT_PATH: "/dev/vda1",
1740
    HV_ACPI: True,
1741
    HV_SERIAL_CONSOLE: True,
1742
    HV_VNC_BIND_ADDRESS: "",
1743
    HV_VNC_TLS: False,
1744
    HV_VNC_X509: "",
1745
    HV_VNC_X509_VERIFY: False,
1746
    HV_VNC_PASSWORD_FILE: "",
1747
    HV_KVM_SPICE_BIND: "",
1748
    HV_KVM_SPICE_IP_VERSION: IFACE_NO_IP_VERSION_SPECIFIED,
1749
    HV_KVM_SPICE_PASSWORD_FILE: "",
1750
    HV_KVM_SPICE_LOSSLESS_IMG_COMPR: "",
1751
    HV_KVM_SPICE_JPEG_IMG_COMPR: "",
1752
    HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR: "",
1753
    HV_KVM_SPICE_STREAMING_VIDEO_DETECTION: "",
1754
    HV_KVM_SPICE_AUDIO_COMPR: True,
1755
    HV_KVM_SPICE_USE_TLS: False,
1756
    HV_KVM_SPICE_TLS_CIPHERS: OPENSSL_CIPHERS,
1757
    HV_KVM_SPICE_USE_VDAGENT: True,
1758
    HV_KVM_FLOPPY_IMAGE_PATH: "",
1759
    HV_CDROM_IMAGE_PATH: "",
1760
    HV_KVM_CDROM2_IMAGE_PATH: "",
1761
    HV_BOOT_ORDER: HT_BO_DISK,
1762
    HV_NIC_TYPE: HT_NIC_PARAVIRTUAL,
1763
    HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
1764
    HV_KVM_CDROM_DISK_TYPE: "",
1765
    HV_USB_MOUSE: "",
1766
    HV_KEYMAP: "",
1767
    HV_MIGRATION_PORT: 8102,
1768
    HV_MIGRATION_BANDWIDTH: 32, # MiB/s
1769
    HV_MIGRATION_DOWNTIME: 30,  # ms
1770
    HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1771
    HV_USE_LOCALTIME: False,
1772
    HV_DISK_CACHE: HT_CACHE_DEFAULT,
1773
    HV_SECURITY_MODEL: HT_SM_NONE,
1774
    HV_SECURITY_DOMAIN: "",
1775
    HV_KVM_FLAG: "",
1776
    HV_VHOST_NET: False,
1777
    HV_KVM_USE_CHROOT: False,
1778
    HV_MEM_PATH: "",
1779
    HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1780
    HV_CPU_MASK: CPU_PINNING_ALL,
1781
    HV_CPU_TYPE: "",
1782
    },
1783
  HT_FAKE: {},
1784
  HT_CHROOT: {
1785
    HV_INIT_SCRIPT: "/ganeti-chroot",
1786
    },
1787
  HT_LXC: {
1788
    HV_CPU_MASK: "",
1789
    },
1790
  }
1791

    
1792
HVC_GLOBALS = frozenset([
1793
  HV_MIGRATION_PORT,
1794
  HV_MIGRATION_BANDWIDTH,
1795
  HV_MIGRATION_MODE,
1796
  ])
1797

    
1798
BEC_DEFAULTS = {
1799
  BE_MINMEM: 128,
1800
  BE_MAXMEM: 128,
1801
  BE_VCPUS: 1,
1802
  BE_AUTO_BALANCE: True,
1803
  BE_ALWAYS_FAILOVER: False,
1804
  BE_SPINDLE_USE: 1,
1805
  }
1806

    
1807
NDC_DEFAULTS = {
1808
  ND_OOB_PROGRAM: "",
1809
  ND_SPINDLE_COUNT: 1,
1810
  }
1811

    
1812
DISK_LD_DEFAULTS = {
1813
  LD_DRBD8: {
1814
    LDP_RESYNC_RATE: CLASSIC_DRBD_SYNC_SPEED,
1815
    LDP_BARRIERS: _autoconf.DRBD_BARRIERS,
1816
    LDP_NO_META_FLUSH: _autoconf.DRBD_NO_META_FLUSH,
1817
    LDP_DEFAULT_METAVG: DEFAULT_VG,
1818
    LDP_DISK_CUSTOM: "",
1819
    LDP_NET_CUSTOM: "",
1820
    LDP_DYNAMIC_RESYNC: False,
1821

    
1822
    # The default values for the DRBD dynamic resync speed algorithm are taken
1823
    # from the drbsetup 8.3.11 man page, except for c-plan-ahead (that we
1824
    # don't need to set to 0, because we have a separate option to enable it)
1825
    # and for c-max-rate, that we cap to the default value for the static resync
1826
    # rate.
1827
    LDP_PLAN_AHEAD: 20, # ds
1828
    LDP_FILL_TARGET: 0, # sectors
1829
    LDP_DELAY_TARGET: 1, # ds
1830
    LDP_MAX_RATE: CLASSIC_DRBD_SYNC_SPEED, # KiB/s
1831
    LDP_MIN_RATE: 4 * 1024, # KiB/s
1832
    },
1833
  LD_LV: {
1834
    LDP_STRIPES: _autoconf.LVM_STRIPECOUNT
1835
    },
1836
  LD_FILE: {},
1837
  LD_BLOCKDEV: {},
1838
  LD_RBD: {
1839
    LDP_POOL: "rbd"
1840
    },
1841
  }
1842

    
1843
# readability shortcuts
1844
_LV_DEFAULTS = DISK_LD_DEFAULTS[LD_LV]
1845
_DRBD_DEFAULTS = DISK_LD_DEFAULTS[LD_DRBD8]
1846

    
1847
DISK_DT_DEFAULTS = {
1848
  DT_PLAIN: {
1849
    LV_STRIPES: DISK_LD_DEFAULTS[LD_LV][LDP_STRIPES],
1850
    },
1851
  DT_DRBD8: {
1852
    DRBD_RESYNC_RATE: _DRBD_DEFAULTS[LDP_RESYNC_RATE],
1853
    DRBD_DATA_STRIPES: _LV_DEFAULTS[LDP_STRIPES],
1854
    DRBD_META_STRIPES: _LV_DEFAULTS[LDP_STRIPES],
1855
    DRBD_DISK_BARRIERS: _DRBD_DEFAULTS[LDP_BARRIERS],
1856
    DRBD_META_BARRIERS: _DRBD_DEFAULTS[LDP_NO_META_FLUSH],
1857
    DRBD_DEFAULT_METAVG: _DRBD_DEFAULTS[LDP_DEFAULT_METAVG],
1858
    DRBD_DISK_CUSTOM: _DRBD_DEFAULTS[LDP_DISK_CUSTOM],
1859
    DRBD_NET_CUSTOM: _DRBD_DEFAULTS[LDP_NET_CUSTOM],
1860
    DRBD_DYNAMIC_RESYNC: _DRBD_DEFAULTS[LDP_DYNAMIC_RESYNC],
1861
    DRBD_PLAN_AHEAD: _DRBD_DEFAULTS[LDP_PLAN_AHEAD],
1862
    DRBD_FILL_TARGET: _DRBD_DEFAULTS[LDP_FILL_TARGET],
1863
    DRBD_DELAY_TARGET: _DRBD_DEFAULTS[LDP_DELAY_TARGET],
1864
    DRBD_MAX_RATE: _DRBD_DEFAULTS[LDP_MAX_RATE],
1865
    DRBD_MIN_RATE: _DRBD_DEFAULTS[LDP_MIN_RATE],
1866
    },
1867
  DT_DISKLESS: {},
1868
  DT_FILE: {},
1869
  DT_SHARED_FILE: {},
1870
  DT_BLOCK: {},
1871
  DT_RBD: {
1872
    RBD_POOL: DISK_LD_DEFAULTS[LD_RBD][LDP_POOL]
1873
    },
1874
  }
1875

    
1876
# we don't want to export the shortcuts
1877
del _LV_DEFAULTS, _DRBD_DEFAULTS
1878

    
1879
NICC_DEFAULTS = {
1880
  NIC_MODE: NIC_MODE_BRIDGED,
1881
  NIC_LINK: DEFAULT_BRIDGE,
1882
  }
1883

    
1884
# All of the following values are quite arbitrarily - there are no
1885
# "good" defaults, these must be customised per-site
1886
IPOLICY_DEFAULTS = {
1887
  ISPECS_MIN: {
1888
    ISPEC_MEM_SIZE: 128,
1889
    ISPEC_CPU_COUNT: 1,
1890
    ISPEC_DISK_COUNT: 1,
1891
    ISPEC_DISK_SIZE: 1024,
1892
    ISPEC_NIC_COUNT: 1,
1893
    ISPEC_SPINDLE_USE: 1,
1894
    },
1895
  ISPECS_MAX: {
1896
    ISPEC_MEM_SIZE: 32768,
1897
    ISPEC_CPU_COUNT: 8,
1898
    ISPEC_DISK_COUNT: MAX_DISKS,
1899
    ISPEC_DISK_SIZE: 1024 * 1024,
1900
    ISPEC_NIC_COUNT: MAX_NICS,
1901
    ISPEC_SPINDLE_USE: 12,
1902
    },
1903
  ISPECS_STD: {
1904
    ISPEC_MEM_SIZE: 128,
1905
    ISPEC_CPU_COUNT: 1,
1906
    ISPEC_DISK_COUNT: 1,
1907
    ISPEC_DISK_SIZE: 1024,
1908
    ISPEC_NIC_COUNT: 1,
1909
    ISPEC_SPINDLE_USE: 1,
1910
    },
1911
  IPOLICY_DTS: DISK_TEMPLATES,
1912
  IPOLICY_VCPU_RATIO: 4.0,
1913
  IPOLICY_SPINDLE_RATIO: 32.0,
1914
  }
1915

    
1916
MASTER_POOL_SIZE_DEFAULT = 10
1917

    
1918
CONFD_PROTOCOL_VERSION = 1
1919

    
1920
CONFD_REQ_PING = 0
1921
CONFD_REQ_NODE_ROLE_BYNAME = 1
1922
CONFD_REQ_NODE_PIP_BY_INSTANCE_IP = 2
1923
CONFD_REQ_CLUSTER_MASTER = 3
1924
CONFD_REQ_NODE_PIP_LIST = 4
1925
CONFD_REQ_MC_PIP_LIST = 5
1926
CONFD_REQ_INSTANCES_IPS_LIST = 6
1927
CONFD_REQ_NODE_DRBD = 7
1928

    
1929
# Confd request query fields. These are used to narrow down queries.
1930
# These must be strings rather than integers, because json-encoding
1931
# converts them to strings anyway, as they're used as dict-keys.
1932
CONFD_REQQ_LINK = "0"
1933
CONFD_REQQ_IP = "1"
1934
CONFD_REQQ_IPLIST = "2"
1935
CONFD_REQQ_FIELDS = "3"
1936

    
1937
CONFD_REQFIELD_NAME = "0"
1938
CONFD_REQFIELD_IP = "1"
1939
CONFD_REQFIELD_MNODE_PIP = "2"
1940

    
1941
CONFD_REQS = frozenset([
1942
  CONFD_REQ_PING,
1943
  CONFD_REQ_NODE_ROLE_BYNAME,
1944
  CONFD_REQ_NODE_PIP_BY_INSTANCE_IP,
1945
  CONFD_REQ_CLUSTER_MASTER,
1946
  CONFD_REQ_NODE_PIP_LIST,
1947
  CONFD_REQ_MC_PIP_LIST,
1948
  CONFD_REQ_INSTANCES_IPS_LIST,
1949
  CONFD_REQ_NODE_DRBD,
1950
  ])
1951

    
1952
CONFD_REPL_STATUS_OK = 0
1953
CONFD_REPL_STATUS_ERROR = 1
1954
CONFD_REPL_STATUS_NOTIMPLEMENTED = 2
1955

    
1956
CONFD_REPL_STATUSES = frozenset([
1957
  CONFD_REPL_STATUS_OK,
1958
  CONFD_REPL_STATUS_ERROR,
1959
  CONFD_REPL_STATUS_NOTIMPLEMENTED,
1960
  ])
1961

    
1962
(CONFD_NODE_ROLE_MASTER,
1963
 CONFD_NODE_ROLE_CANDIDATE,
1964
 CONFD_NODE_ROLE_OFFLINE,
1965
 CONFD_NODE_ROLE_DRAINED,
1966
 CONFD_NODE_ROLE_REGULAR,
1967
 ) = range(5)
1968

    
1969
# A few common errors for confd
1970
CONFD_ERROR_UNKNOWN_ENTRY = 1
1971
CONFD_ERROR_INTERNAL = 2
1972
CONFD_ERROR_ARGUMENT = 3
1973

    
1974
# Each request is "salted" by the current timestamp.
1975
# This constants decides how many seconds of skew to accept.
1976
# TODO: make this a default and allow the value to be more configurable
1977
CONFD_MAX_CLOCK_SKEW = 2 * NODE_MAX_CLOCK_SKEW
1978

    
1979
# When we haven't reloaded the config for more than this amount of seconds, we
1980
# force a test to see if inotify is betraying us.
1981
CONFD_CONFIG_RELOAD_TIMEOUT = 60
1982

    
1983
# If we receive more than one update in this amount of seconds, we move to
1984
# polling every RATELIMIT seconds, rather than relying on inotify, to be able
1985
# to serve more requests.
1986
CONFD_CONFIG_RELOAD_RATELIMIT = 2
1987

    
1988
# Magic number prepended to all confd queries.
1989
# This allows us to distinguish different types of confd protocols and handle
1990
# them. For example by changing this we can move the whole payload to be
1991
# compressed, or move away from json.
1992
CONFD_MAGIC_FOURCC = "plj0"
1993

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

    
1999
# Timeout in seconds to expire pending query request in the confd client
2000
# library. We don't actually expect any answer more than 10 seconds after we
2001
# sent a request.
2002
CONFD_CLIENT_EXPIRE_TIMEOUT = 10
2003

    
2004
# Maximum UDP datagram size.
2005
# On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
2006
# On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
2007
#   (assuming we can't use jumbo frames)
2008
# We just set this to 60K, which should be enough
2009
MAX_UDP_DATA_SIZE = 61440
2010

    
2011
# User-id pool minimum/maximum acceptable user-ids.
2012
UIDPOOL_UID_MIN = 0
2013
UIDPOOL_UID_MAX = 2 ** 32 - 1 # Assuming 32 bit user-ids
2014

    
2015
# Name or path of the pgrep command
2016
PGREP = "pgrep"
2017

    
2018
# Name of the node group that gets created at cluster init or upgrade
2019
INITIAL_NODE_GROUP_NAME = "default"
2020

    
2021
# Possible values for NodeGroup.alloc_policy
2022
ALLOC_POLICY_PREFERRED = "preferred"
2023
ALLOC_POLICY_LAST_RESORT = "last_resort"
2024
ALLOC_POLICY_UNALLOCABLE = "unallocable"
2025
VALID_ALLOC_POLICIES = [
2026
  ALLOC_POLICY_PREFERRED,
2027
  ALLOC_POLICY_LAST_RESORT,
2028
  ALLOC_POLICY_UNALLOCABLE,
2029
  ]
2030

    
2031
# Temporary external/shared storage parameters
2032
BLOCKDEV_DRIVER_MANUAL = "manual"
2033

    
2034
# qemu-img path, required for ovfconverter
2035
QEMUIMG_PATH = _autoconf.QEMUIMG_PATH
2036

    
2037
# Whether htools was enabled at compilation time
2038
HTOOLS = _autoconf.HTOOLS
2039
# The hail iallocator
2040
IALLOC_HAIL = "hail"
2041

    
2042
# Fake opcodes for functions that have hooks attached to them via
2043
# backend.RunLocalHooks
2044
FAKE_OP_MASTER_TURNUP = "OP_CLUSTER_IP_TURNUP"
2045
FAKE_OP_MASTER_TURNDOWN = "OP_CLUSTER_IP_TURNDOWN"
2046

    
2047
# SSH key types
2048
SSHK_RSA = "rsa"
2049
SSHK_DSA = "dsa"
2050
SSHK_ALL = frozenset([SSHK_RSA, SSHK_DSA])
2051

    
2052
# SSH authorized key types
2053
SSHAK_RSA = "ssh-rsa"
2054
SSHAK_DSS = "ssh-dss"
2055
SSHAK_ALL = frozenset([SSHAK_RSA, SSHAK_DSS])
2056

    
2057
# SSH setup
2058
SSHS_CLUSTER_NAME = "cluster_name"
2059
SSHS_SSH_HOST_KEY = "ssh_host_key"
2060
SSHS_SSH_ROOT_KEY = "ssh_root_key"
2061
SSHS_NODE_DAEMON_CERTIFICATE = "node_daemon_certificate"
2062

    
2063
# Do not re-export imported modules
2064
del re, _vcsversion, _autoconf, socket, pathutils