Statistics
| Branch: | Tag: | Revision:

root / lib / constants.py @ e0d672fa

History | View | Annotate | Download (64.3 kB)

1
#
2
#
3

    
4
# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Google Inc.
5
#
6
# This program is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 2 of the License, or
9
# (at your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful, but
12
# WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
# General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
# 02110-1301, USA.
20

    
21

    
22
"""Module holding different constants."""
23

    
24
import re
25
import socket
26

    
27
from ganeti import _constants
28
from ganeti import _vcsversion
29
from ganeti import compat
30
from ganeti import pathutils
31

    
32

    
33
# various versions
34
RELEASE_VERSION = _constants.RELEASE_VERSION
35
OS_API_V10 = 10
36
OS_API_V15 = 15
37
OS_API_V20 = 20
38
OS_API_VERSIONS = compat.UniqueFrozenset([
39
  OS_API_V10,
40
  OS_API_V15,
41
  OS_API_V20,
42
  ])
43
VCS_VERSION = _vcsversion.VCS_VERSION
44
EXPORT_VERSION = 0
45
RAPI_VERSION = 2
46

    
47

    
48
# Format for CONFIG_VERSION:
49
#   01 03 0123 = 01030123
50
#   ^^ ^^ ^^^^
51
#   |  |  + Configuration version/revision
52
#   |  + Minor version
53
#   + Major version
54
#
55
# It is stored as an integer. Make sure not to write an octal number.
56

    
57
# BuildVersion and SplitVersion must be in here because we can't import other
58
# modules. The cfgupgrade tool must be able to read and write version numbers
59
# and thus requires these functions. To avoid code duplication, they're kept in
60
# here.
61

    
62
def BuildVersion(major, minor, revision):
63
  """Calculates int version number from major, minor and revision numbers.
64

65
  Returns: int representing version number
66

67
  """
68
  assert isinstance(major, int)
69
  assert isinstance(minor, int)
70
  assert isinstance(revision, int)
71
  return (1000000 * major +
72
            10000 * minor +
73
                1 * revision)
74

    
75

    
76
def SplitVersion(version):
77
  """Splits version number stored in an int.
78

79
  Returns: tuple; (major, minor, revision)
80

81
  """
82
  assert isinstance(version, int)
83

    
84
  (major, remainder) = divmod(version, 1000000)
85
  (minor, revision) = divmod(remainder, 10000)
86

    
87
  return (major, minor, revision)
88

    
89

    
90
CONFIG_MAJOR = _constants.CONFIG_MAJOR
91
CONFIG_MINOR = _constants.CONFIG_MINOR
92
CONFIG_REVISION = _constants.CONFIG_REVISION
93
CONFIG_VERSION = _constants.CONFIG_VERSION
94

    
95
#: RPC protocol version
96
PROTOCOL_VERSION = _constants.PROTOCOL_VERSION
97

    
98
# user separation
99
DAEMONS_GROUP = _constants.DAEMONS_GROUP
100
ADMIN_GROUP = _constants.ADMIN_GROUP
101
MASTERD_USER = _constants.MASTERD_USER
102
MASTERD_GROUP = _constants.MASTERD_GROUP
103
RAPI_USER = _constants.RAPI_USER
104
RAPI_GROUP = _constants.RAPI_GROUP
105
CONFD_USER = _constants.CONFD_USER
106
CONFD_GROUP = _constants.CONFD_GROUP
107
LUXID_USER = _constants.LUXID_USER
108
LUXID_GROUP = _constants.LUXID_GROUP
109
NODED_USER = _constants.NODED_USER
110
NODED_GROUP = _constants.NODED_GROUP
111
MOND_USER = _constants.MOND_USER
112
MOND_GROUP = _constants.MOND_GROUP
113
SSH_LOGIN_USER = _constants.SSH_LOGIN_USER
114
SSH_CONSOLE_USER = _constants.SSH_CONSOLE_USER
115

    
116
# cpu pinning separators and constants
117
CPU_PINNING_SEP = ":"
118
CPU_PINNING_ALL = "all"
119
# internal representation of "all"
120
CPU_PINNING_ALL_VAL = -1
121
# one "all" entry in a CPU list means CPU pinning is off
122
CPU_PINNING_OFF = [CPU_PINNING_ALL_VAL]
123

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

    
133
# A KVM-specific implementation detail - the following value is used
134
# to set CPU affinity to all processors (#0 through #31), per taskset
135
# man page.
136
# FIXME: This only works for machines with up to 32 CPU cores
137
CPU_PINNING_ALL_KVM = 0xFFFFFFFF
138

    
139
# Wipe
140
DD_CMD = "dd"
141
MAX_WIPE_CHUNK = 1024 # 1GB
142
MIN_WIPE_CHUNK_PERCENT = 10
143

    
144
RUN_DIRS_MODE = 0775
145
SECURE_DIR_MODE = 0700
146
SECURE_FILE_MODE = 0600
147
ADOPTABLE_BLOCKDEV_ROOT = "/dev/disk/"
148
ENABLE_CONFD = _constants.ENABLE_CONFD
149
ENABLE_MOND = _constants.ENABLE_MOND
150
ENABLE_SPLIT_QUERY = _constants.ENABLE_SPLIT_QUERY
151
ENABLE_RESTRICTED_COMMANDS = _constants.ENABLE_RESTRICTED_COMMANDS
152

    
153
# SSH constants
154
SSH = _constants.SSH
155
SCP = _constants.SCP
156

    
157
NODED = _constants.NODED
158
CONFD = _constants.CONFD
159
LUXID = _constants.LUXID
160
RAPI = _constants.RAPI
161
MASTERD = _constants.MASTERD
162
MOND = _constants.MOND
163

    
164
DAEMONS = _constants.DAEMONS
165

    
166
DAEMONS_PORTS = _constants.DAEMONS_PORTS
167

    
168
DEFAULT_NODED_PORT = _constants.DEFAULT_NODED_PORT
169
DEFAULT_CONFD_PORT = _constants.DEFAULT_CONFD_PORT
170
DEFAULT_MOND_PORT = _constants.DEFAULT_MOND_PORT
171
DEFAULT_RAPI_PORT = _constants.DEFAULT_RAPI_PORT
172

    
173
FIRST_DRBD_PORT = 11000
174
LAST_DRBD_PORT = 14999
175

    
176
DAEMONS_LOGBASE = _constants.DAEMONS_LOGBASE
177

    
178
DAEMONS_LOGFILES = \
179
    dict((daemon, pathutils.GetLogFilename(DAEMONS_LOGBASE[daemon]))
180
         for daemon in DAEMONS_LOGBASE)
181

    
182
# Some daemons might require more than one logfile.
183
# Specifically, right now only the Haskell http library "snap", used by the
184
# monitoring daemon, requires multiple log files.
185

    
186
# These are the only valid reasons for having an extra logfile
187
EXTRA_LOGREASON_ACCESS = "access"
188
EXTRA_LOGREASON_ERROR = "error"
189

    
190
VALID_EXTRA_LOGREASONS = compat.UniqueFrozenset([
191
  EXTRA_LOGREASON_ACCESS,
192
  EXTRA_LOGREASON_ERROR,
193
  ])
194

    
195
# These are the extra logfiles, grouped by daemon
196
DAEMONS_EXTRA_LOGBASE = {
197
  MOND: {
198
    EXTRA_LOGREASON_ACCESS: _constants.EXTRA_LOGREASON_ACCESS,
199
    EXTRA_LOGREASON_ERROR: _constants.EXTRA_LOGREASON_ERROR,
200
    }
201
  }
202

    
203
DAEMONS_EXTRA_LOGFILES = \
204
  dict((daemon, dict((extra,
205
       pathutils.GetLogFilename(DAEMONS_EXTRA_LOGBASE[daemon][extra]))
206
       for extra in DAEMONS_EXTRA_LOGBASE[daemon]))
207
         for daemon in DAEMONS_EXTRA_LOGBASE)
208

    
209
DEV_CONSOLE = _constants.DEV_CONSOLE
210

    
211
PROC_MOUNTS = "/proc/mounts"
212

    
213
# Local UniX Interface related constants
214
LUXI_EOM = chr(3)
215
LUXI_VERSION = CONFIG_VERSION
216
#: Environment variable for the luxi override socket
217
LUXI_OVERRIDE = "FORCE_LUXI_SOCKET"
218
LUXI_OVERRIDE_MASTER = "master"
219
LUXI_OVERRIDE_QUERY = "query"
220

    
221
# one of "no", "yes", "only"
222
SYSLOG_USAGE = _constants.SYSLOG_USAGE
223
SYSLOG_NO = _constants.SYSLOG_NO
224
SYSLOG_YES = _constants.SYSLOG_YES
225
SYSLOG_ONLY = _constants.SYSLOG_ONLY
226
SYSLOG_SOCKET = _constants.SYSLOG_SOCKET
227

    
228
EXPORT_CONF_FILE = "config.ini"
229

    
230
XEN_BOOTLOADER = _constants.XEN_BOOTLOADER
231
XEN_KERNEL = _constants.XEN_KERNEL
232
XEN_INITRD = _constants.XEN_INITRD
233
XEN_CMD_XM = _constants.XEN_CMD_XM
234
XEN_CMD_XL = _constants.XEN_CMD_XL
235
KNOWN_XEN_COMMANDS = _constants.KNOWN_XEN_COMMANDS
236

    
237
# When the Xen toolstack used is "xl", live migration requires the source host
238
# to connect to the target host via ssh (xl runs this command). We need to pass
239
# the command xl runs some extra info so that it can use Ganeti's key
240
# verification and not fail. Note that this string is incomplete: it must be
241
# filled with the cluster name before being used.
242
XL_SSH_CMD = ("ssh -l %s -oGlobalKnownHostsFile=%s"
243
              " -oUserKnownHostsFile=/dev/null"
244
              " -oCheckHostIp=no -oStrictHostKeyChecking=yes"
245
              " -oHostKeyAlias=%%s") % (SSH_LOGIN_USER,
246
                                        pathutils.SSH_KNOWN_HOSTS_FILE)
247

    
248
KVM_PATH = _constants.KVM_PATH
249
KVM_KERNEL = _constants.KVM_KERNEL
250
SOCAT_PATH = _constants.SOCAT_PATH
251
SOCAT_USE_ESCAPE = _constants.SOCAT_USE_ESCAPE
252
SOCAT_USE_COMPRESS = _constants.SOCAT_USE_COMPRESS
253
SOCAT_ESCAPE_CODE = "0x1d"
254

    
255
#: Console as SSH command
256
CONS_SSH = "ssh"
257

    
258
#: Console as VNC server
259
CONS_VNC = "vnc"
260

    
261
#: Console as SPICE server
262
CONS_SPICE = "spice"
263

    
264
#: Display a message for console access
265
CONS_MESSAGE = "msg"
266

    
267
#: All console types
268
CONS_ALL = compat.UniqueFrozenset([
269
  CONS_SSH,
270
  CONS_VNC,
271
  CONS_SPICE,
272
  CONS_MESSAGE,
273
  ])
274

    
275
# For RSA keys more bits are better, but they also make operations more
276
# expensive. NIST SP 800-131 recommends a minimum of 2048 bits from the year
277
# 2010 on.
278
RSA_KEY_BITS = 2048
279

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

    
288
# Digest used to sign certificates ("openssl x509" uses SHA1 by default)
289
X509_CERT_SIGN_DIGEST = "SHA1"
290

    
291
# Default validity of certificates in days
292
X509_CERT_DEFAULT_VALIDITY = 365 * 5
293

    
294
# commonName (CN) used in certificates
295
X509_CERT_CN = "ganeti.example.com"
296

    
297
X509_CERT_SIGNATURE_HEADER = "X-Ganeti-Signature"
298

    
299
# Import/export daemon mode
300
IEM_IMPORT = "import"
301
IEM_EXPORT = "export"
302

    
303
# Import/export transport compression
304
IEC_NONE = "none"
305
IEC_GZIP = "gzip"
306
IEC_ALL = compat.UniqueFrozenset([
307
  IEC_NONE,
308
  IEC_GZIP,
309
  ])
310

    
311
IE_CUSTOM_SIZE = "fd"
312

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

    
315
# Import/export I/O
316
# Direct file I/O, equivalent to a shell's I/O redirection using '<' or '>'
317
IEIO_FILE = "file"
318
# Raw block device I/O using "dd"
319
IEIO_RAW_DISK = "raw"
320
# OS definition import/export script
321
IEIO_SCRIPT = "script"
322

    
323
VALUE_DEFAULT = "default"
324
VALUE_AUTO = "auto"
325
VALUE_GENERATE = "generate"
326
VALUE_NONE = "none"
327
VALUE_TRUE = "true"
328
VALUE_FALSE = "false"
329
VALUE_HS_NOTHING = {"Nothing": None}
330

    
331

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

    
335
# hooks-related constants
336
HOOKS_PHASE_PRE = "pre"
337
HOOKS_PHASE_POST = "post"
338
HOOKS_NAME_CFGUPDATE = "config-update"
339
HOOKS_NAME_WATCHER = "watcher"
340
HOOKS_VERSION = 2
341
HOOKS_PATH = "/sbin:/bin:/usr/sbin:/usr/bin"
342

    
343
# hooks subject type (what object type does the LU deal with)
344
HTYPE_CLUSTER = "CLUSTER"
345
HTYPE_NODE = "NODE"
346
HTYPE_GROUP = "GROUP"
347
HTYPE_INSTANCE = "INSTANCE"
348
HTYPE_NETWORK = "NETWORK"
349

    
350
HKR_SKIP = 0
351
HKR_FAIL = 1
352
HKR_SUCCESS = 2
353

    
354
# Storage types
355
ST_BLOCK = _constants.ST_BLOCK
356
ST_DISKLESS = _constants.ST_DISKLESS
357
ST_EXT = _constants.ST_EXT
358
ST_FILE = _constants.ST_FILE
359
ST_LVM_PV = _constants.ST_LVM_PV
360
ST_LVM_VG = _constants.ST_LVM_VG
361
ST_RADOS = _constants.ST_RADOS
362
STORAGE_TYPES = _constants.STORAGE_TYPES
363

    
364
# the set of storage types for which storage reporting is available
365
# FIXME: Remove this, once storage reporting is available for all types.
366
STS_REPORT = compat.UniqueFrozenset([ST_FILE, ST_LVM_PV, ST_LVM_VG])
367

    
368
# Storage fields
369
# first two are valid in LU context only, not passed to backend
370
SF_NODE = _constants.SF_NODE
371
SF_TYPE = _constants.SF_TYPE
372
# and the rest are valid in backend
373
SF_NAME = _constants.SF_NAME
374
SF_SIZE = _constants.SF_SIZE
375
SF_FREE = _constants.SF_FREE
376
SF_USED = _constants.SF_USED
377
SF_ALLOCATABLE = _constants.SF_ALLOCATABLE
378

    
379
# Storage operations
380
SO_FIX_CONSISTENCY = "fix-consistency"
381

    
382
# Available fields per storage type
383
VALID_STORAGE_FIELDS = compat.UniqueFrozenset([
384
  SF_NODE,
385
  SF_NAME,
386
  SF_TYPE,
387
  SF_SIZE,
388
  SF_USED,
389
  SF_FREE,
390
  SF_ALLOCATABLE,
391
  ])
392

    
393
MODIFIABLE_STORAGE_FIELDS = {
394
  ST_LVM_PV: frozenset([SF_ALLOCATABLE]),
395
  }
396

    
397
VALID_STORAGE_OPERATIONS = {
398
  ST_LVM_VG: frozenset([SO_FIX_CONSISTENCY]),
399
  }
400

    
401
# Volume fields
402
VF_DEV = "dev"
403
VF_INSTANCE = "instance"
404
VF_NAME = "name"
405
VF_NODE = "node"
406
VF_PHYS = "phys"
407
VF_SIZE = "size"
408
VF_VG = "vg"
409

    
410
# Local disk status
411
# Note: Code depends on LDS_OKAY < LDS_UNKNOWN < LDS_FAULTY
412
(LDS_OKAY,
413
 LDS_UNKNOWN,
414
 LDS_FAULTY) = range(1, 4)
415

    
416
LDS_NAMES = {
417
  LDS_OKAY: "ok",
418
  LDS_UNKNOWN: "unknown",
419
  LDS_FAULTY: "faulty",
420
}
421

    
422
# disk template types
423
DT_BLOCK = _constants.DT_BLOCK
424
DT_DISKLESS = _constants.DT_DISKLESS
425
DT_DRBD8 = _constants.DT_DRBD8
426
DT_EXT = _constants.DT_EXT
427
DT_FILE = _constants.DT_FILE
428
DT_PLAIN = _constants.DT_PLAIN
429
DT_RBD = _constants.DT_RBD
430
DT_SHARED_FILE = _constants.DT_SHARED_FILE
431
DISK_TEMPLATE_PREFERENCE = _constants.DISK_TEMPLATE_PREFERENCE
432
DISK_TEMPLATES = _constants.DISK_TEMPLATES
433
DEFAULT_ENABLED_DISK_TEMPLATES = _constants.DEFAULT_ENABLED_DISK_TEMPLATES
434

    
435
# mapping of disk templates to storage types
436
MAP_DISK_TEMPLATE_STORAGE_TYPE = {
437
  DT_BLOCK: ST_BLOCK,
438
  DT_DISKLESS: ST_DISKLESS,
439
  DT_DRBD8: ST_LVM_VG,
440
  DT_EXT: ST_EXT,
441
  DT_FILE: ST_FILE,
442
  DT_PLAIN: ST_LVM_VG,
443
  DT_RBD: ST_RADOS,
444
  DT_SHARED_FILE: ST_FILE,
445
  }
446

    
447
# the set of network-mirrored disk templates
448
DTS_INT_MIRROR = compat.UniqueFrozenset([DT_DRBD8])
449

    
450
# the set of externally-mirrored disk templates (e.g. SAN, NAS)
451
DTS_EXT_MIRROR = compat.UniqueFrozenset([
452
  DT_DISKLESS, # 'trivially' externally mirrored
453
  DT_SHARED_FILE,
454
  DT_BLOCK,
455
  DT_RBD,
456
  DT_EXT,
457
  ])
458

    
459
# the set of non-lvm-based disk templates
460
DTS_NOT_LVM = compat.UniqueFrozenset([
461
  DT_DISKLESS,
462
  DT_FILE,
463
  DT_SHARED_FILE,
464
  DT_BLOCK,
465
  DT_RBD,
466
  DT_EXT,
467
  ])
468

    
469
# the set of disk templates which can be grown
470
DTS_GROWABLE = compat.UniqueFrozenset([
471
  DT_PLAIN,
472
  DT_DRBD8,
473
  DT_FILE,
474
  DT_SHARED_FILE,
475
  DT_RBD,
476
  DT_EXT,
477
  ])
478

    
479
# the set of disk templates that allow adoption
480
DTS_MAY_ADOPT = compat.UniqueFrozenset([
481
  DT_PLAIN,
482
  DT_BLOCK,
483
  ])
484

    
485
# the set of disk templates that *must* use adoption
486
DTS_MUST_ADOPT = compat.UniqueFrozenset([DT_BLOCK])
487

    
488
# the set of disk templates that allow migrations
489
DTS_MIRRORED = frozenset.union(DTS_INT_MIRROR, DTS_EXT_MIRROR)
490

    
491
# the set of file based disk templates
492
DTS_FILEBASED = compat.UniqueFrozenset([
493
  DT_FILE,
494
  DT_SHARED_FILE,
495
  ])
496

    
497
# the set of disk templates that can be moved by copying
498
# Note: a requirement is that they're not accessed externally or shared between
499
# nodes; in particular, sharedfile is not suitable.
500
DTS_COPYABLE = compat.UniqueFrozenset([
501
  DT_FILE,
502
  DT_PLAIN,
503
  ])
504

    
505
# the set of disk templates that are supported by exclusive_storage
506
DTS_EXCL_STORAGE = compat.UniqueFrozenset([DT_PLAIN])
507

    
508
# templates for which we don't perform checks on free space
509
DTS_NO_FREE_SPACE_CHECK = compat.UniqueFrozenset([
510
  DT_FILE,
511
  DT_SHARED_FILE,
512
  DT_RBD,
513
  DT_EXT,
514
  ])
515

    
516
DTS_BLOCK = compat.UniqueFrozenset([
517
  DT_PLAIN,
518
  DT_DRBD8,
519
  DT_BLOCK,
520
  DT_RBD,
521
  DT_EXT,
522
  ])
523

    
524
# drbd constants
525
DRBD_HMAC_ALG = "md5"
526
DRBD_DEFAULT_NET_PROTOCOL = "C"
527
DRBD_MIGRATION_NET_PROTOCOL = "C"
528
DRBD_STATUS_FILE = "/proc/drbd"
529

    
530
#: Size of DRBD meta block device
531
DRBD_META_SIZE = 128
532

    
533
# drbd barrier types
534
DRBD_B_NONE = "n"
535
DRBD_B_DISK_BARRIERS = "b"
536
DRBD_B_DISK_DRAIN = "d"
537
DRBD_B_DISK_FLUSH = "f"
538

    
539
# Valid barrier combinations: "n" or any non-null subset of "bfd"
540
DRBD_VALID_BARRIER_OPT = compat.UniqueFrozenset([
541
  frozenset([DRBD_B_NONE]),
542
  frozenset([DRBD_B_DISK_BARRIERS]),
543
  frozenset([DRBD_B_DISK_DRAIN]),
544
  frozenset([DRBD_B_DISK_FLUSH]),
545
  frozenset([DRBD_B_DISK_DRAIN, DRBD_B_DISK_FLUSH]),
546
  frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_DRAIN]),
547
  frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_FLUSH]),
548
  frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_FLUSH, DRBD_B_DISK_DRAIN]),
549
  ])
550

    
551
# rbd tool command
552
RBD_CMD = "rbd"
553

    
554
# file backend driver
555
FD_BLKTAP = _constants.FD_BLKTAP
556
FD_LOOP = _constants.FD_LOOP
557

    
558
# the set of drbd-like disk types
559
LDS_DRBD = compat.UniqueFrozenset([DT_DRBD8])
560

    
561
# disk access mode
562
DISK_RDONLY = _constants.DISK_RDONLY
563
DISK_RDWR = _constants.DISK_RDWR
564
DISK_ACCESS_SET = _constants.DISK_ACCESS_SET
565

    
566
# disk replacement mode
567
REPLACE_DISK_PRI = "replace_on_primary"    # replace disks on primary
568
REPLACE_DISK_SEC = "replace_on_secondary"  # replace disks on secondary
569
REPLACE_DISK_CHG = "replace_new_secondary" # change secondary node
570
REPLACE_DISK_AUTO = "replace_auto"
571
REPLACE_MODES = compat.UniqueFrozenset([
572
  REPLACE_DISK_PRI,
573
  REPLACE_DISK_SEC,
574
  REPLACE_DISK_CHG,
575
  REPLACE_DISK_AUTO,
576
  ])
577

    
578
# Instance export mode
579
EXPORT_MODE_LOCAL = _constants.EXPORT_MODE_LOCAL
580
EXPORT_MODE_REMOTE = _constants.EXPORT_MODE_REMOTE
581
EXPORT_MODES = _constants.EXPORT_MODES
582

    
583
# instance creation modes
584
INSTANCE_CREATE = _constants.INSTANCE_CREATE
585
INSTANCE_IMPORT = _constants.INSTANCE_IMPORT
586
INSTANCE_REMOTE_IMPORT = _constants.INSTANCE_REMOTE_IMPORT
587
INSTANCE_CREATE_MODES = _constants.INSTANCE_CREATE_MODES
588

    
589
# Remote import/export handshake message and version
590
RIE_VERSION = 0
591
RIE_HANDSHAKE = "Hi, I'm Ganeti"
592

    
593
# Remote import/export certificate validity in seconds
594
RIE_CERT_VALIDITY = 24 * 60 * 60
595

    
596
# Overall timeout for establishing connection
597
RIE_CONNECT_TIMEOUT = 180
598

    
599
# Export only: how long to wait per connection attempt (seconds)
600
RIE_CONNECT_ATTEMPT_TIMEOUT = 20
601

    
602
# Export only: number of attempts to connect
603
RIE_CONNECT_RETRIES = 10
604

    
605
#: Give child process up to 5 seconds to exit after sending a signal
606
CHILD_LINGER_TIMEOUT = 5.0
607

    
608
FILE_DRIVER = compat.UniqueFrozenset([FD_LOOP, FD_BLKTAP])
609

    
610
# import/export config options
611
INISECT_EXP = "export"
612
INISECT_INS = "instance"
613
INISECT_HYP = "hypervisor"
614
INISECT_BEP = "backend"
615
INISECT_OSP = "os"
616

    
617
# dynamic device modification
618
DDM_ADD = _constants.DDM_ADD
619
DDM_MODIFY = _constants.DDM_MODIFY
620
DDM_REMOVE = _constants.DDM_REMOVE
621
DDMS_VALUES = _constants.DDMS_VALUES
622
DDMS_VALUES_WITH_MODIFY = _constants.DDMS_VALUES_WITH_MODIFY
623
# TODO: DDM_SWAP, DDM_MOVE?
624

    
625
# common exit codes
626
EXIT_SUCCESS = _constants.EXIT_SUCCESS
627
EXIT_FAILURE = _constants.EXIT_FAILURE
628
EXIT_NOTCLUSTER = _constants.EXIT_NOTCLUSTER
629
EXIT_NOTMASTER = _constants.EXIT_NOTMASTER
630
EXIT_NODESETUP_ERROR = _constants.EXIT_NODESETUP_ERROR
631
EXIT_CONFIRMATION = _constants.EXIT_CONFIRMATION # need user confirmation
632

    
633
#: Exit code for query operations with unknown fields
634
EXIT_UNKNOWN_FIELD = _constants.EXIT_UNKNOWN_FIELD
635

    
636
# tags
637
TAG_CLUSTER = _constants.TAG_CLUSTER
638
TAG_NODEGROUP = _constants.TAG_NODEGROUP
639
TAG_NODE = _constants.TAG_NODE
640
TAG_INSTANCE = _constants.TAG_INSTANCE
641
TAG_NETWORK = _constants.TAG_NETWORK
642
VALID_TAG_TYPES = _constants.VALID_TAG_TYPES
643

    
644
MAX_TAG_LEN = _constants.MAX_TAG_LEN
645
MAX_TAGS_PER_OBJ = _constants.MAX_TAGS_PER_OBJ
646

    
647
# others
648
DEFAULT_BRIDGE = "xen-br0"
649
DEFAULT_OVS = "switch1"
650
CLASSIC_DRBD_SYNC_SPEED = 60 * 1024  # 60 MiB, expressed in KiB
651
IP4_ADDRESS_LOCALHOST = "127.0.0.1"
652
IP4_ADDRESS_ANY = "0.0.0.0"
653
IP6_ADDRESS_LOCALHOST = "::1"
654
IP6_ADDRESS_ANY = "::"
655
IP4_VERSION = 4
656
IP6_VERSION = 6
657
VALID_IP_VERSIONS = compat.UniqueFrozenset([IP4_VERSION, IP6_VERSION])
658
# for export to htools
659
IP4_FAMILY = socket.AF_INET
660
IP6_FAMILY = socket.AF_INET6
661

    
662
TCP_PING_TIMEOUT = 10
663
DEFAULT_VG = "xenvg"
664
DEFAULT_DRBD_HELPER = "/bin/true"
665
MIN_VG_SIZE = 20480
666
DEFAULT_MAC_PREFIX = "aa:00:00"
667
# default maximum instance wait time, in seconds.
668
DEFAULT_SHUTDOWN_TIMEOUT = 120
669
NODE_MAX_CLOCK_SKEW = _constants.NODE_MAX_CLOCK_SKEW
670
# Time for an intra-cluster disk transfer to wait for a connection
671
DISK_TRANSFER_CONNECT_TIMEOUT = 60
672
# Disk index separator
673
DISK_SEPARATOR = _constants.DISK_SEPARATOR
674
IP_COMMAND_PATH = _constants.IP_COMMAND_PATH
675

    
676
#: Key for job IDs in opcode result
677
JOB_IDS_KEY = "jobs"
678

    
679
# runparts results
680
(RUNPARTS_SKIP,
681
 RUNPARTS_RUN,
682
 RUNPARTS_ERR) = range(3)
683

    
684
RUNPARTS_STATUS = compat.UniqueFrozenset([
685
  RUNPARTS_SKIP,
686
  RUNPARTS_RUN,
687
  RUNPARTS_ERR,
688
  ])
689

    
690
# RPC constants
691
(RPC_ENCODING_NONE,
692
 RPC_ENCODING_ZLIB_BASE64) = range(2)
693

    
694
# Various time constants for the timeout table
695
RPC_TMO_URGENT = 60 # one minute
696
RPC_TMO_FAST = 5 * 60 # five minutes
697
RPC_TMO_NORMAL = 15 * 60 # 15 minutes
698
RPC_TMO_SLOW = 3600 # one hour
699
RPC_TMO_4HRS = 4 * 3600
700
RPC_TMO_1DAY = 86400
701

    
702
# Timeout for connecting to nodes (seconds)
703
RPC_CONNECT_TIMEOUT = 5
704

    
705
# os related constants
706
OS_SCRIPT_CREATE = "create"
707
OS_SCRIPT_IMPORT = "import"
708
OS_SCRIPT_EXPORT = "export"
709
OS_SCRIPT_RENAME = "rename"
710
OS_SCRIPT_VERIFY = "verify"
711
OS_SCRIPTS = compat.UniqueFrozenset([
712
  OS_SCRIPT_CREATE,
713
  OS_SCRIPT_IMPORT,
714
  OS_SCRIPT_EXPORT,
715
  OS_SCRIPT_RENAME,
716
  OS_SCRIPT_VERIFY,
717
  ])
718

    
719
OS_API_FILE = "ganeti_api_version"
720
OS_VARIANTS_FILE = "variants.list"
721
OS_PARAMETERS_FILE = "parameters.list"
722

    
723
OS_VALIDATE_PARAMETERS = "parameters"
724
OS_VALIDATE_CALLS = compat.UniqueFrozenset([OS_VALIDATE_PARAMETERS])
725

    
726
# External Storage (ES) related constants
727
ES_ACTION_CREATE = "create"
728
ES_ACTION_REMOVE = "remove"
729
ES_ACTION_GROW = "grow"
730
ES_ACTION_ATTACH = "attach"
731
ES_ACTION_DETACH = "detach"
732
ES_ACTION_SETINFO = "setinfo"
733
ES_ACTION_VERIFY = "verify"
734

    
735
ES_SCRIPT_CREATE = ES_ACTION_CREATE
736
ES_SCRIPT_REMOVE = ES_ACTION_REMOVE
737
ES_SCRIPT_GROW = ES_ACTION_GROW
738
ES_SCRIPT_ATTACH = ES_ACTION_ATTACH
739
ES_SCRIPT_DETACH = ES_ACTION_DETACH
740
ES_SCRIPT_SETINFO = ES_ACTION_SETINFO
741
ES_SCRIPT_VERIFY = ES_ACTION_VERIFY
742
ES_SCRIPTS = frozenset([
743
  ES_SCRIPT_CREATE,
744
  ES_SCRIPT_REMOVE,
745
  ES_SCRIPT_GROW,
746
  ES_SCRIPT_ATTACH,
747
  ES_SCRIPT_DETACH,
748
  ES_SCRIPT_SETINFO,
749
  ES_SCRIPT_VERIFY
750
  ])
751

    
752
ES_PARAMETERS_FILE = "parameters.list"
753

    
754
# reboot types
755
INSTANCE_REBOOT_SOFT = _constants.INSTANCE_REBOOT_SOFT
756
INSTANCE_REBOOT_HARD = _constants.INSTANCE_REBOOT_HARD
757
INSTANCE_REBOOT_FULL = _constants.INSTANCE_REBOOT_FULL
758
REBOOT_TYPES = _constants.REBOOT_TYPES
759

    
760
# instance reboot behaviors
761
INSTANCE_REBOOT_ALLOWED = "reboot"
762
INSTANCE_REBOOT_EXIT = "exit"
763

    
764
REBOOT_BEHAVIORS = compat.UniqueFrozenset([
765
  INSTANCE_REBOOT_ALLOWED,
766
  INSTANCE_REBOOT_EXIT,
767
  ])
768

    
769
VTYPE_STRING = _constants.VTYPE_STRING
770
VTYPE_MAYBE_STRING = _constants.VTYPE_MAYBE_STRING
771
VTYPE_BOOL = _constants.VTYPE_BOOL
772
VTYPE_SIZE = _constants.VTYPE_SIZE
773
VTYPE_INT = _constants.VTYPE_INT
774
ENFORCEABLE_TYPES = _constants.ENFORCEABLE_TYPES
775

    
776
# Constant representing that the user does not specify any IP version
777
IFACE_NO_IP_VERSION_SPECIFIED = 0
778

    
779
VALID_SERIAL_SPEEDS = compat.UniqueFrozenset([
780
  75,
781
  110,
782
  300,
783
  600,
784
  1200,
785
  1800,
786
  2400,
787
  4800,
788
  9600,
789
  14400,
790
  19200,
791
  28800,
792
  38400,
793
  57600,
794
  115200,
795
  230400,
796
  345600,
797
  460800,
798
  ])
799

    
800
# HV parameter names (global namespace)
801
HV_BOOT_ORDER = "boot_order"
802
HV_CDROM_IMAGE_PATH = "cdrom_image_path"
803
HV_KVM_CDROM2_IMAGE_PATH = "cdrom2_image_path"
804
HV_KVM_FLOPPY_IMAGE_PATH = "floppy_image_path"
805
HV_NIC_TYPE = "nic_type"
806
HV_DISK_TYPE = "disk_type"
807
HV_KVM_CDROM_DISK_TYPE = "cdrom_disk_type"
808
HV_VNC_BIND_ADDRESS = "vnc_bind_address"
809
HV_VNC_PASSWORD_FILE = "vnc_password_file"
810
HV_VNC_TLS = "vnc_tls"
811
HV_VNC_X509 = "vnc_x509_path"
812
HV_VNC_X509_VERIFY = "vnc_x509_verify"
813
HV_KVM_SPICE_BIND = "spice_bind"
814
HV_KVM_SPICE_IP_VERSION = "spice_ip_version"
815
HV_KVM_SPICE_PASSWORD_FILE = "spice_password_file"
816
HV_KVM_SPICE_LOSSLESS_IMG_COMPR = "spice_image_compression"
817
HV_KVM_SPICE_JPEG_IMG_COMPR = "spice_jpeg_wan_compression"
818
HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR = "spice_zlib_glz_wan_compression"
819
HV_KVM_SPICE_STREAMING_VIDEO_DETECTION = "spice_streaming_video"
820
HV_KVM_SPICE_AUDIO_COMPR = "spice_playback_compression"
821
HV_KVM_SPICE_USE_TLS = "spice_use_tls"
822
HV_KVM_SPICE_TLS_CIPHERS = "spice_tls_ciphers"
823
HV_KVM_SPICE_USE_VDAGENT = "spice_use_vdagent"
824
HV_ACPI = "acpi"
825
HV_PAE = "pae"
826
HV_USE_BOOTLOADER = "use_bootloader"
827
HV_BOOTLOADER_ARGS = "bootloader_args"
828
HV_BOOTLOADER_PATH = "bootloader_path"
829
HV_KERNEL_ARGS = "kernel_args"
830
HV_KERNEL_PATH = "kernel_path"
831
HV_INITRD_PATH = "initrd_path"
832
HV_ROOT_PATH = "root_path"
833
HV_SERIAL_CONSOLE = "serial_console"
834
HV_SERIAL_SPEED = "serial_speed"
835
HV_USB_MOUSE = "usb_mouse"
836
HV_KEYMAP = "keymap"
837
HV_DEVICE_MODEL = "device_model"
838
HV_INIT_SCRIPT = "init_script"
839
HV_MIGRATION_PORT = "migration_port"
840
HV_MIGRATION_BANDWIDTH = "migration_bandwidth"
841
HV_MIGRATION_DOWNTIME = "migration_downtime"
842
HV_MIGRATION_MODE = "migration_mode"
843
HV_USE_LOCALTIME = "use_localtime"
844
HV_DISK_CACHE = "disk_cache"
845
HV_SECURITY_MODEL = "security_model"
846
HV_SECURITY_DOMAIN = "security_domain"
847
HV_KVM_FLAG = "kvm_flag"
848
HV_VHOST_NET = "vhost_net"
849
HV_KVM_USE_CHROOT = "use_chroot"
850
HV_CPU_MASK = "cpu_mask"
851
HV_MEM_PATH = "mem_path"
852
HV_PASSTHROUGH = "pci_pass"
853
HV_BLOCKDEV_PREFIX = "blockdev_prefix"
854
HV_REBOOT_BEHAVIOR = "reboot_behavior"
855
HV_CPU_TYPE = "cpu_type"
856
HV_CPU_CAP = "cpu_cap"
857
HV_CPU_WEIGHT = "cpu_weight"
858
HV_CPU_CORES = "cpu_cores"
859
HV_CPU_THREADS = "cpu_threads"
860
HV_CPU_SOCKETS = "cpu_sockets"
861
HV_SOUNDHW = "soundhw"
862
HV_USB_DEVICES = "usb_devices"
863
HV_VGA = "vga"
864
HV_KVM_EXTRA = "kvm_extra"
865
HV_KVM_MACHINE_VERSION = "machine_version"
866
HV_KVM_PATH = "kvm_path"
867
HV_VIF_TYPE = "vif_type"
868
HV_VIF_SCRIPT = "vif_script"
869
HV_XEN_CMD = "xen_cmd"
870
HV_VNET_HDR = "vnet_hdr"
871
HV_VIRIDIAN = "viridian"
872

    
873

    
874
HVS_PARAMETER_TYPES = {
875
  HV_KVM_PATH: VTYPE_STRING,
876
  HV_BOOT_ORDER: VTYPE_STRING,
877
  HV_KVM_FLOPPY_IMAGE_PATH: VTYPE_STRING,
878
  HV_CDROM_IMAGE_PATH: VTYPE_STRING,
879
  HV_KVM_CDROM2_IMAGE_PATH: VTYPE_STRING,
880
  HV_NIC_TYPE: VTYPE_STRING,
881
  HV_DISK_TYPE: VTYPE_STRING,
882
  HV_KVM_CDROM_DISK_TYPE: VTYPE_STRING,
883
  HV_VNC_PASSWORD_FILE: VTYPE_STRING,
884
  HV_VNC_BIND_ADDRESS: VTYPE_STRING,
885
  HV_VNC_TLS: VTYPE_BOOL,
886
  HV_VNC_X509: VTYPE_STRING,
887
  HV_VNC_X509_VERIFY: VTYPE_BOOL,
888
  HV_KVM_SPICE_BIND: VTYPE_STRING,
889
  HV_KVM_SPICE_IP_VERSION: VTYPE_INT,
890
  HV_KVM_SPICE_PASSWORD_FILE: VTYPE_STRING,
891
  HV_KVM_SPICE_LOSSLESS_IMG_COMPR: VTYPE_STRING,
892
  HV_KVM_SPICE_JPEG_IMG_COMPR: VTYPE_STRING,
893
  HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR: VTYPE_STRING,
894
  HV_KVM_SPICE_STREAMING_VIDEO_DETECTION: VTYPE_STRING,
895
  HV_KVM_SPICE_AUDIO_COMPR: VTYPE_BOOL,
896
  HV_KVM_SPICE_USE_TLS: VTYPE_BOOL,
897
  HV_KVM_SPICE_TLS_CIPHERS: VTYPE_STRING,
898
  HV_KVM_SPICE_USE_VDAGENT: VTYPE_BOOL,
899
  HV_ACPI: VTYPE_BOOL,
900
  HV_PAE: VTYPE_BOOL,
901
  HV_USE_BOOTLOADER: VTYPE_BOOL,
902
  HV_BOOTLOADER_PATH: VTYPE_STRING,
903
  HV_BOOTLOADER_ARGS: VTYPE_STRING,
904
  HV_KERNEL_PATH: VTYPE_STRING,
905
  HV_KERNEL_ARGS: VTYPE_STRING,
906
  HV_INITRD_PATH: VTYPE_STRING,
907
  HV_ROOT_PATH: VTYPE_MAYBE_STRING,
908
  HV_SERIAL_CONSOLE: VTYPE_BOOL,
909
  HV_SERIAL_SPEED: VTYPE_INT,
910
  HV_USB_MOUSE: VTYPE_STRING,
911
  HV_KEYMAP: VTYPE_STRING,
912
  HV_DEVICE_MODEL: VTYPE_STRING,
913
  HV_INIT_SCRIPT: VTYPE_STRING,
914
  HV_MIGRATION_PORT: VTYPE_INT,
915
  HV_MIGRATION_BANDWIDTH: VTYPE_INT,
916
  HV_MIGRATION_DOWNTIME: VTYPE_INT,
917
  HV_MIGRATION_MODE: VTYPE_STRING,
918
  HV_USE_LOCALTIME: VTYPE_BOOL,
919
  HV_DISK_CACHE: VTYPE_STRING,
920
  HV_SECURITY_MODEL: VTYPE_STRING,
921
  HV_SECURITY_DOMAIN: VTYPE_STRING,
922
  HV_KVM_FLAG: VTYPE_STRING,
923
  HV_VHOST_NET: VTYPE_BOOL,
924
  HV_KVM_USE_CHROOT: VTYPE_BOOL,
925
  HV_CPU_MASK: VTYPE_STRING,
926
  HV_MEM_PATH: VTYPE_STRING,
927
  HV_PASSTHROUGH: VTYPE_STRING,
928
  HV_BLOCKDEV_PREFIX: VTYPE_STRING,
929
  HV_REBOOT_BEHAVIOR: VTYPE_STRING,
930
  HV_CPU_TYPE: VTYPE_STRING,
931
  HV_CPU_CAP: VTYPE_INT,
932
  HV_CPU_WEIGHT: VTYPE_INT,
933
  HV_CPU_CORES: VTYPE_INT,
934
  HV_CPU_THREADS: VTYPE_INT,
935
  HV_CPU_SOCKETS: VTYPE_INT,
936
  HV_SOUNDHW: VTYPE_STRING,
937
  HV_USB_DEVICES: VTYPE_STRING,
938
  HV_VGA: VTYPE_STRING,
939
  HV_KVM_EXTRA: VTYPE_STRING,
940
  HV_KVM_MACHINE_VERSION: VTYPE_STRING,
941
  HV_VIF_TYPE: VTYPE_STRING,
942
  HV_VIF_SCRIPT: VTYPE_STRING,
943
  HV_XEN_CMD: VTYPE_STRING,
944
  HV_VNET_HDR: VTYPE_BOOL,
945
  HV_VIRIDIAN: VTYPE_BOOL,
946
  }
947

    
948
HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
949

    
950
HVS_PARAMETER_TITLES = {
951
  HV_ACPI: "ACPI",
952
  HV_BOOT_ORDER: "Boot_order",
953
  HV_CDROM_IMAGE_PATH: "CDROM_image_path",
954
  HV_DISK_TYPE: "Disk_type",
955
  HV_INITRD_PATH: "Initrd_path",
956
  HV_KERNEL_PATH: "Kernel_path",
957
  HV_NIC_TYPE: "NIC_type",
958
  HV_PAE: "PAE",
959
  HV_VNC_BIND_ADDRESS: "VNC_bind_address",
960
  HV_PASSTHROUGH: "pci_pass",
961
  HV_CPU_TYPE: "cpu_type",
962
  }
963

    
964
# Migration statuses
965
HV_MIGRATION_COMPLETED = "completed"
966
HV_MIGRATION_ACTIVE = "active"
967
HV_MIGRATION_FAILED = "failed"
968
HV_MIGRATION_CANCELLED = "cancelled"
969

    
970
HV_MIGRATION_VALID_STATUSES = compat.UniqueFrozenset([
971
  HV_MIGRATION_COMPLETED,
972
  HV_MIGRATION_ACTIVE,
973
  HV_MIGRATION_FAILED,
974
  HV_MIGRATION_CANCELLED,
975
  ])
976

    
977
HV_MIGRATION_FAILED_STATUSES = compat.UniqueFrozenset([
978
  HV_MIGRATION_FAILED,
979
  HV_MIGRATION_CANCELLED,
980
  ])
981

    
982
# KVM-specific statuses
983
HV_KVM_MIGRATION_VALID_STATUSES = HV_MIGRATION_VALID_STATUSES
984

    
985
# Node info keys
986
HV_NODEINFO_KEY_VERSION = "hv_version"
987

    
988
# Hypervisor state
989
HVST_MEMORY_TOTAL = "mem_total"
990
HVST_MEMORY_NODE = "mem_node"
991
HVST_MEMORY_HV = "mem_hv"
992
HVST_CPU_TOTAL = "cpu_total"
993
HVST_CPU_NODE = "cpu_node"
994

    
995
HVST_DEFAULTS = {
996
  HVST_MEMORY_TOTAL: 0,
997
  HVST_MEMORY_NODE: 0,
998
  HVST_MEMORY_HV: 0,
999
  HVST_CPU_TOTAL: 1,
1000
  HVST_CPU_NODE: 1,
1001
  }
1002

    
1003
HVSTS_PARAMETER_TYPES = {
1004
  HVST_MEMORY_TOTAL: VTYPE_INT,
1005
  HVST_MEMORY_NODE: VTYPE_INT,
1006
  HVST_MEMORY_HV: VTYPE_INT,
1007
  HVST_CPU_TOTAL: VTYPE_INT,
1008
  HVST_CPU_NODE: VTYPE_INT,
1009
  }
1010

    
1011
HVSTS_PARAMETERS = frozenset(HVSTS_PARAMETER_TYPES.keys())
1012

    
1013
# Disk state
1014
DS_DISK_TOTAL = "disk_total"
1015
DS_DISK_RESERVED = "disk_reserved"
1016
DS_DISK_OVERHEAD = "disk_overhead"
1017

    
1018
DS_DEFAULTS = {
1019
  DS_DISK_TOTAL: 0,
1020
  DS_DISK_RESERVED: 0,
1021
  DS_DISK_OVERHEAD: 0,
1022
  }
1023

    
1024
DSS_PARAMETER_TYPES = {
1025
  DS_DISK_TOTAL: VTYPE_INT,
1026
  DS_DISK_RESERVED: VTYPE_INT,
1027
  DS_DISK_OVERHEAD: VTYPE_INT,
1028
  }
1029

    
1030
DSS_PARAMETERS = frozenset(DSS_PARAMETER_TYPES.keys())
1031
DS_VALID_TYPES = compat.UniqueFrozenset([DT_PLAIN])
1032

    
1033
# Backend parameter names
1034
BE_MEMORY = "memory" # deprecated and replaced by max and min mem
1035
BE_MAXMEM = "maxmem"
1036
BE_MINMEM = "minmem"
1037
BE_VCPUS = "vcpus"
1038
BE_AUTO_BALANCE = "auto_balance"
1039
BE_ALWAYS_FAILOVER = "always_failover"
1040
BE_SPINDLE_USE = "spindle_use"
1041

    
1042
BES_PARAMETER_TYPES = {
1043
  BE_MAXMEM: VTYPE_SIZE,
1044
  BE_MINMEM: VTYPE_SIZE,
1045
  BE_VCPUS: VTYPE_INT,
1046
  BE_AUTO_BALANCE: VTYPE_BOOL,
1047
  BE_ALWAYS_FAILOVER: VTYPE_BOOL,
1048
  BE_SPINDLE_USE: VTYPE_INT,
1049
  }
1050

    
1051
BES_PARAMETER_TITLES = {
1052
  BE_AUTO_BALANCE: "Auto_balance",
1053
  BE_MAXMEM: "ConfigMaxMem",
1054
  BE_MINMEM: "ConfigMinMem",
1055
  BE_VCPUS: "ConfigVCPUs",
1056
  }
1057

    
1058
BES_PARAMETER_COMPAT = {
1059
  BE_MEMORY: VTYPE_SIZE,
1060
  }
1061
BES_PARAMETER_COMPAT.update(BES_PARAMETER_TYPES)
1062

    
1063
BES_PARAMETERS = frozenset(BES_PARAMETER_TYPES.keys())
1064

    
1065
# instance specs
1066
ISPEC_MEM_SIZE = "memory-size"
1067
ISPEC_CPU_COUNT = "cpu-count"
1068
ISPEC_DISK_COUNT = "disk-count"
1069
ISPEC_DISK_SIZE = "disk-size"
1070
ISPEC_NIC_COUNT = "nic-count"
1071
ISPEC_SPINDLE_USE = "spindle-use"
1072

    
1073
ISPECS_PARAMETER_TYPES = {
1074
  ISPEC_MEM_SIZE: VTYPE_INT,
1075
  ISPEC_CPU_COUNT: VTYPE_INT,
1076
  ISPEC_DISK_COUNT: VTYPE_INT,
1077
  ISPEC_DISK_SIZE: VTYPE_INT,
1078
  ISPEC_NIC_COUNT: VTYPE_INT,
1079
  ISPEC_SPINDLE_USE: VTYPE_INT,
1080
  }
1081

    
1082
ISPECS_PARAMETERS = frozenset(ISPECS_PARAMETER_TYPES.keys())
1083

    
1084
ISPECS_MINMAX = "minmax"
1085
ISPECS_MIN = "min"
1086
ISPECS_MAX = "max"
1087
ISPECS_STD = "std"
1088
IPOLICY_DTS = "disk-templates"
1089
IPOLICY_VCPU_RATIO = "vcpu-ratio"
1090
IPOLICY_SPINDLE_RATIO = "spindle-ratio"
1091

    
1092
ISPECS_MINMAX_KEYS = compat.UniqueFrozenset([
1093
  ISPECS_MIN,
1094
  ISPECS_MAX,
1095
  ])
1096

    
1097
IPOLICY_PARAMETERS = compat.UniqueFrozenset([
1098
  IPOLICY_VCPU_RATIO,
1099
  IPOLICY_SPINDLE_RATIO,
1100
  ])
1101

    
1102
IPOLICY_ALL_KEYS = (IPOLICY_PARAMETERS |
1103
                    frozenset([ISPECS_MINMAX, ISPECS_STD, IPOLICY_DTS]))
1104

    
1105
# Node parameter names
1106
ND_OOB_PROGRAM = "oob_program"
1107
ND_SPINDLE_COUNT = "spindle_count"
1108
ND_EXCLUSIVE_STORAGE = "exclusive_storage"
1109
ND_OVS = "ovs"
1110
ND_OVS_NAME = "ovs_name"
1111
ND_OVS_LINK = "ovs_link"
1112

    
1113
NDS_PARAMETER_TYPES = {
1114
  ND_OOB_PROGRAM: VTYPE_STRING,
1115
  ND_SPINDLE_COUNT: VTYPE_INT,
1116
  ND_EXCLUSIVE_STORAGE: VTYPE_BOOL,
1117
  ND_OVS: VTYPE_BOOL,
1118
  ND_OVS_NAME: VTYPE_MAYBE_STRING,
1119
  ND_OVS_LINK: VTYPE_MAYBE_STRING,
1120
  }
1121

    
1122
NDS_PARAMETERS = frozenset(NDS_PARAMETER_TYPES.keys())
1123

    
1124
NDS_PARAMETER_TITLES = {
1125
  ND_OOB_PROGRAM: "OutOfBandProgram",
1126
  ND_SPINDLE_COUNT: "SpindleCount",
1127
  ND_EXCLUSIVE_STORAGE: "ExclusiveStorage",
1128
  ND_OVS: "OpenvSwitch",
1129
  ND_OVS_NAME: "OpenvSwitchName",
1130
  ND_OVS_LINK: "OpenvSwitchLink",
1131
  }
1132

    
1133
# Logical Disks parameters
1134
LDP_RESYNC_RATE = "resync-rate"
1135
LDP_STRIPES = "stripes"
1136
LDP_BARRIERS = "disabled-barriers"
1137
LDP_NO_META_FLUSH = "disable-meta-flush"
1138
LDP_DEFAULT_METAVG = "default-metavg"
1139
LDP_DISK_CUSTOM = "disk-custom"
1140
LDP_NET_CUSTOM = "net-custom"
1141
LDP_PROTOCOL = "protocol"
1142
LDP_DYNAMIC_RESYNC = "dynamic-resync"
1143
LDP_PLAN_AHEAD = "c-plan-ahead"
1144
LDP_FILL_TARGET = "c-fill-target"
1145
LDP_DELAY_TARGET = "c-delay-target"
1146
LDP_MAX_RATE = "c-max-rate"
1147
LDP_MIN_RATE = "c-min-rate"
1148
LDP_POOL = "pool"
1149
DISK_LD_TYPES = {
1150
  LDP_RESYNC_RATE: VTYPE_INT,
1151
  LDP_STRIPES: VTYPE_INT,
1152
  LDP_BARRIERS: VTYPE_STRING,
1153
  LDP_NO_META_FLUSH: VTYPE_BOOL,
1154
  LDP_DEFAULT_METAVG: VTYPE_STRING,
1155
  LDP_DISK_CUSTOM: VTYPE_STRING,
1156
  LDP_NET_CUSTOM: VTYPE_STRING,
1157
  LDP_PROTOCOL: VTYPE_STRING,
1158
  LDP_DYNAMIC_RESYNC: VTYPE_BOOL,
1159
  LDP_PLAN_AHEAD: VTYPE_INT,
1160
  LDP_FILL_TARGET: VTYPE_INT,
1161
  LDP_DELAY_TARGET: VTYPE_INT,
1162
  LDP_MAX_RATE: VTYPE_INT,
1163
  LDP_MIN_RATE: VTYPE_INT,
1164
  LDP_POOL: VTYPE_STRING,
1165
  }
1166
DISK_LD_PARAMETERS = frozenset(DISK_LD_TYPES.keys())
1167

    
1168
# Disk template parameters (can be set/changed by the user via gnt-cluster and
1169
# gnt-group)
1170
DRBD_RESYNC_RATE = "resync-rate"
1171
DRBD_DATA_STRIPES = "data-stripes"
1172
DRBD_META_STRIPES = "meta-stripes"
1173
DRBD_DISK_BARRIERS = "disk-barriers"
1174
DRBD_META_BARRIERS = "meta-barriers"
1175
DRBD_DEFAULT_METAVG = "metavg"
1176
DRBD_DISK_CUSTOM = "disk-custom"
1177
DRBD_NET_CUSTOM = "net-custom"
1178
DRBD_PROTOCOL = "protocol"
1179
DRBD_DYNAMIC_RESYNC = "dynamic-resync"
1180
DRBD_PLAN_AHEAD = "c-plan-ahead"
1181
DRBD_FILL_TARGET = "c-fill-target"
1182
DRBD_DELAY_TARGET = "c-delay-target"
1183
DRBD_MAX_RATE = "c-max-rate"
1184
DRBD_MIN_RATE = "c-min-rate"
1185
LV_STRIPES = "stripes"
1186
RBD_POOL = "pool"
1187
DISK_DT_TYPES = {
1188
  DRBD_RESYNC_RATE: VTYPE_INT,
1189
  DRBD_DATA_STRIPES: VTYPE_INT,
1190
  DRBD_META_STRIPES: VTYPE_INT,
1191
  DRBD_DISK_BARRIERS: VTYPE_STRING,
1192
  DRBD_META_BARRIERS: VTYPE_BOOL,
1193
  DRBD_DEFAULT_METAVG: VTYPE_STRING,
1194
  DRBD_DISK_CUSTOM: VTYPE_STRING,
1195
  DRBD_NET_CUSTOM: VTYPE_STRING,
1196
  DRBD_PROTOCOL: VTYPE_STRING,
1197
  DRBD_DYNAMIC_RESYNC: VTYPE_BOOL,
1198
  DRBD_PLAN_AHEAD: VTYPE_INT,
1199
  DRBD_FILL_TARGET: VTYPE_INT,
1200
  DRBD_DELAY_TARGET: VTYPE_INT,
1201
  DRBD_MAX_RATE: VTYPE_INT,
1202
  DRBD_MIN_RATE: VTYPE_INT,
1203
  LV_STRIPES: VTYPE_INT,
1204
  RBD_POOL: VTYPE_STRING,
1205
  }
1206

    
1207
DISK_DT_PARAMETERS = frozenset(DISK_DT_TYPES.keys())
1208

    
1209
# dynamic disk parameters
1210
DDP_LOCAL_IP = "local-ip"
1211
DDP_REMOTE_IP = "remote-ip"
1212
DDP_PORT = "port"
1213
DDP_LOCAL_MINOR = "local-minor"
1214
DDP_REMOTE_MINOR = "remote-minor"
1215

    
1216
# OOB supported commands
1217
OOB_POWER_ON = _constants.OOB_POWER_ON
1218
OOB_POWER_OFF = _constants.OOB_POWER_OFF
1219
OOB_POWER_CYCLE = _constants.OOB_POWER_CYCLE
1220
OOB_POWER_STATUS = _constants.OOB_POWER_STATUS
1221
OOB_HEALTH = _constants.OOB_HEALTH
1222
OOB_COMMANDS = _constants.OOB_COMMANDS
1223

    
1224
OOB_POWER_STATUS_POWERED = _constants.OOB_POWER_STATUS_POWERED
1225

    
1226
OOB_TIMEOUT = _constants.OOB_TIMEOUT
1227
OOB_POWER_DELAY = _constants.OOB_POWER_DELAY
1228

    
1229
OOB_STATUS_OK = _constants.OOB_STATUS_OK
1230
OOB_STATUS_WARNING = _constants.OOB_STATUS_WARNING
1231
OOB_STATUS_CRITICAL = _constants.OOB_STATUS_CRITICAL
1232
OOB_STATUS_UNKNOWN = _constants.OOB_STATUS_UNKNOWN
1233
OOB_STATUSES = _constants.OOB_STATUSES
1234

    
1235
# Instance Parameters Profile
1236
PP_DEFAULT = "default"
1237

    
1238
# NIC_* constants are used inside the ganeti config
1239
NIC_MODE = _constants.NIC_MODE
1240
NIC_LINK = _constants.NIC_LINK
1241
NIC_VLAN = _constants.NIC_VLAN
1242

    
1243
NIC_MODE_BRIDGED = _constants.NIC_MODE_BRIDGED
1244
NIC_MODE_ROUTED = _constants.NIC_MODE_ROUTED
1245
NIC_MODE_OVS = _constants.NIC_MODE_OVS
1246
NIC_IP_POOL = _constants.NIC_IP_POOL
1247
NIC_VALID_MODES = _constants.NIC_VALID_MODES
1248

    
1249
RESERVE_ACTION = "reserve"
1250
RELEASE_ACTION = "release"
1251

    
1252
NICS_PARAMETER_TYPES = {
1253
  NIC_MODE: VTYPE_STRING,
1254
  NIC_LINK: VTYPE_STRING,
1255
  NIC_VLAN: VTYPE_MAYBE_STRING,
1256
  }
1257

    
1258
NICS_PARAMETERS = frozenset(NICS_PARAMETER_TYPES.keys())
1259

    
1260
# IDISK_* constants are used in opcodes, to create/change disks
1261
IDISK_SIZE = "size"
1262
IDISK_SPINDLES = "spindles"
1263
IDISK_MODE = "mode"
1264
IDISK_ADOPT = "adopt"
1265
IDISK_VG = "vg"
1266
IDISK_METAVG = "metavg"
1267
IDISK_PROVIDER = "provider"
1268
IDISK_NAME = "name"
1269
IDISK_PARAMS_TYPES = {
1270
  IDISK_SIZE: VTYPE_SIZE,
1271
  IDISK_SPINDLES: VTYPE_INT,
1272
  IDISK_MODE: VTYPE_STRING,
1273
  IDISK_ADOPT: VTYPE_STRING,
1274
  IDISK_VG: VTYPE_STRING,
1275
  IDISK_METAVG: VTYPE_STRING,
1276
  IDISK_PROVIDER: VTYPE_STRING,
1277
  IDISK_NAME: VTYPE_MAYBE_STRING,
1278
  }
1279
IDISK_PARAMS = frozenset(IDISK_PARAMS_TYPES.keys())
1280

    
1281
# INIC_* constants are used in opcodes, to create/change nics
1282
INIC_MAC = "mac"
1283
INIC_IP = "ip"
1284
INIC_MODE = "mode"
1285
INIC_LINK = "link"
1286
INIC_NETWORK = "network"
1287
INIC_NAME = "name"
1288
INIC_VLAN = "vlan"
1289
INIC_BRIDGE = "bridge"
1290
INIC_PARAMS_TYPES = {
1291
  INIC_IP: VTYPE_MAYBE_STRING,
1292
  INIC_LINK: VTYPE_STRING,
1293
  INIC_MAC: VTYPE_STRING,
1294
  INIC_MODE: VTYPE_STRING,
1295
  INIC_NETWORK: VTYPE_MAYBE_STRING,
1296
  INIC_NAME: VTYPE_MAYBE_STRING,
1297
  INIC_VLAN: VTYPE_MAYBE_STRING,
1298
  INIC_BRIDGE: VTYPE_MAYBE_STRING
1299
  }
1300
INIC_PARAMS = frozenset(INIC_PARAMS_TYPES.keys())
1301

    
1302
# Hypervisor constants
1303
HT_XEN_PVM = _constants.HT_XEN_PVM
1304
HT_FAKE = _constants.HT_FAKE
1305
HT_XEN_HVM = _constants.HT_XEN_HVM
1306
HT_KVM = _constants.HT_KVM
1307
HT_CHROOT = _constants.HT_CHROOT
1308
HT_LXC = _constants.HT_LXC
1309
HYPER_TYPES = _constants.HYPER_TYPES
1310
HTS_REQ_PORT = _constants.HTS_REQ_PORT
1311

    
1312
VNC_BASE_PORT = 5900
1313
VNC_DEFAULT_BIND_ADDRESS = IP4_ADDRESS_ANY
1314

    
1315
# NIC types
1316
HT_NIC_RTL8139 = "rtl8139"
1317
HT_NIC_NE2K_PCI = "ne2k_pci"
1318
HT_NIC_NE2K_ISA = "ne2k_isa"
1319
HT_NIC_I82551 = "i82551"
1320
HT_NIC_I85557B = "i82557b"
1321
HT_NIC_I8259ER = "i82559er"
1322
HT_NIC_PCNET = "pcnet"
1323
HT_NIC_E1000 = "e1000"
1324
HT_NIC_PARAVIRTUAL = HT_DISK_PARAVIRTUAL = "paravirtual"
1325

    
1326
HT_HVM_VALID_NIC_TYPES = compat.UniqueFrozenset([
1327
  HT_NIC_RTL8139,
1328
  HT_NIC_NE2K_PCI,
1329
  HT_NIC_E1000,
1330
  HT_NIC_NE2K_ISA,
1331
  HT_NIC_PARAVIRTUAL,
1332
  ])
1333
HT_KVM_VALID_NIC_TYPES = compat.UniqueFrozenset([
1334
  HT_NIC_RTL8139,
1335
  HT_NIC_NE2K_PCI,
1336
  HT_NIC_NE2K_ISA,
1337
  HT_NIC_I82551,
1338
  HT_NIC_I85557B,
1339
  HT_NIC_I8259ER,
1340
  HT_NIC_PCNET,
1341
  HT_NIC_E1000,
1342
  HT_NIC_PARAVIRTUAL,
1343
  ])
1344

    
1345
# Vif types
1346
# default vif type in xen-hvm
1347
HT_HVM_VIF_IOEMU = "ioemu"
1348
HT_HVM_VIF_VIF = "vif"
1349
HT_HVM_VALID_VIF_TYPES = compat.UniqueFrozenset([
1350
  HT_HVM_VIF_IOEMU,
1351
  HT_HVM_VIF_VIF,
1352
  ])
1353

    
1354
# Disk types
1355
HT_DISK_IOEMU = "ioemu"
1356
HT_DISK_IDE = "ide"
1357
HT_DISK_SCSI = "scsi"
1358
HT_DISK_SD = "sd"
1359
HT_DISK_MTD = "mtd"
1360
HT_DISK_PFLASH = "pflash"
1361

    
1362
HT_CACHE_DEFAULT = "default"
1363
HT_CACHE_NONE = "none"
1364
HT_CACHE_WTHROUGH = "writethrough"
1365
HT_CACHE_WBACK = "writeback"
1366
HT_VALID_CACHE_TYPES = compat.UniqueFrozenset([
1367
  HT_CACHE_DEFAULT,
1368
  HT_CACHE_NONE,
1369
  HT_CACHE_WTHROUGH,
1370
  HT_CACHE_WBACK,
1371
  ])
1372

    
1373
HT_HVM_VALID_DISK_TYPES = compat.UniqueFrozenset([
1374
  HT_DISK_PARAVIRTUAL,
1375
  HT_DISK_IOEMU,
1376
  ])
1377
HT_KVM_VALID_DISK_TYPES = compat.UniqueFrozenset([
1378
  HT_DISK_PARAVIRTUAL,
1379
  HT_DISK_IDE,
1380
  HT_DISK_SCSI,
1381
  HT_DISK_SD,
1382
  HT_DISK_MTD,
1383
  HT_DISK_PFLASH,
1384
  ])
1385

    
1386
# Mouse types:
1387
HT_MOUSE_MOUSE = "mouse"
1388
HT_MOUSE_TABLET = "tablet"
1389

    
1390
HT_KVM_VALID_MOUSE_TYPES = compat.UniqueFrozenset([
1391
  HT_MOUSE_MOUSE,
1392
  HT_MOUSE_TABLET,
1393
  ])
1394

    
1395
# Boot order
1396
HT_BO_FLOPPY = "floppy"
1397
HT_BO_CDROM = "cdrom"
1398
HT_BO_DISK = "disk"
1399
HT_BO_NETWORK = "network"
1400

    
1401
HT_KVM_VALID_BO_TYPES = compat.UniqueFrozenset([
1402
  HT_BO_FLOPPY,
1403
  HT_BO_CDROM,
1404
  HT_BO_DISK,
1405
  HT_BO_NETWORK,
1406
  ])
1407

    
1408
# SPICE lossless image compression options
1409
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ = "auto_glz"
1410
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ = "auto_lz"
1411
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC = "quic"
1412
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ = "glz"
1413
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ = "lz"
1414
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF = "off"
1415

    
1416
HT_KVM_SPICE_VALID_LOSSLESS_IMG_COMPR_OPTIONS = compat.UniqueFrozenset([
1417
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ,
1418
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ,
1419
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC,
1420
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ,
1421
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ,
1422
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF,
1423
  ])
1424

    
1425
# SPICE lossy image compression options (valid for both jpeg and zlib-glz)
1426
HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO = "auto"
1427
HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER = "never"
1428
HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS = "always"
1429

    
1430
HT_KVM_SPICE_VALID_LOSSY_IMG_COMPR_OPTIONS = compat.UniqueFrozenset([
1431
  HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO,
1432
  HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER,
1433
  HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS,
1434
  ])
1435

    
1436
# SPICE video stream detection
1437
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF = "off"
1438
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL = "all"
1439
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER = "filter"
1440

    
1441
HT_KVM_SPICE_VALID_VIDEO_STREAM_DETECTION_OPTIONS = compat.UniqueFrozenset([
1442
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF,
1443
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL,
1444
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER,
1445
  ])
1446

    
1447
# Security models
1448
HT_SM_NONE = "none"
1449
HT_SM_USER = "user"
1450
HT_SM_POOL = "pool"
1451

    
1452
HT_KVM_VALID_SM_TYPES = compat.UniqueFrozenset([
1453
  HT_SM_NONE,
1454
  HT_SM_USER,
1455
  HT_SM_POOL,
1456
  ])
1457

    
1458
# Kvm flag values
1459
HT_KVM_ENABLED = "enabled"
1460
HT_KVM_DISABLED = "disabled"
1461

    
1462
HT_KVM_FLAG_VALUES = compat.UniqueFrozenset([HT_KVM_ENABLED, HT_KVM_DISABLED])
1463

    
1464
# Migration type
1465
HT_MIGRATION_LIVE = _constants.HT_MIGRATION_LIVE
1466
HT_MIGRATION_NONLIVE = _constants.HT_MIGRATION_NONLIVE
1467
HT_MIGRATION_MODES = _constants.HT_MIGRATION_MODES
1468

    
1469
# Cluster Verify steps
1470
VERIFY_NPLUSONE_MEM = _constants.VERIFY_NPLUSONE_MEM
1471
VERIFY_OPTIONAL_CHECKS = _constants.VERIFY_OPTIONAL_CHECKS
1472

    
1473
# Cluster Verify error classes
1474
CV_TCLUSTER = _constants.CV_TCLUSTER
1475
CV_TGROUP = _constants.CV_TGROUP
1476
CV_TNODE = _constants.CV_TNODE
1477
CV_TINSTANCE = _constants.CV_TINSTANCE
1478

    
1479
# Cluster Verify error codes and documentation
1480
CV_ECLUSTERCFG = _constants.CV_ECLUSTERCFG
1481
CV_ECLUSTERCERT = _constants.CV_ECLUSTERCERT
1482
CV_ECLUSTERFILECHECK = _constants.CV_ECLUSTERFILECHECK
1483
CV_ECLUSTERDANGLINGNODES = _constants.CV_ECLUSTERDANGLINGNODES
1484
CV_ECLUSTERDANGLINGINST = _constants.CV_ECLUSTERDANGLINGINST
1485
CV_EGROUPDIFFERENTPVSIZE = _constants.CV_EGROUPDIFFERENTPVSIZE
1486
CV_EINSTANCEBADNODE = _constants.CV_EINSTANCEBADNODE
1487
CV_EINSTANCEDOWN = _constants.CV_EINSTANCEDOWN
1488
CV_EINSTANCELAYOUT = _constants.CV_EINSTANCELAYOUT
1489
CV_EINSTANCEMISSINGDISK = _constants.CV_EINSTANCEMISSINGDISK
1490
CV_EINSTANCEFAULTYDISK = _constants.CV_EINSTANCEFAULTYDISK
1491
CV_EINSTANCEWRONGNODE = _constants.CV_EINSTANCEWRONGNODE
1492
CV_EINSTANCESPLITGROUPS = _constants.CV_EINSTANCESPLITGROUPS
1493
CV_EINSTANCEPOLICY = _constants.CV_EINSTANCEPOLICY
1494
CV_EINSTANCEUNSUITABLENODE = _constants.CV_EINSTANCEUNSUITABLENODE
1495
CV_EINSTANCEMISSINGCFGPARAMETER = _constants.CV_EINSTANCEMISSINGCFGPARAMETER
1496
CV_ENODEDRBD = _constants.CV_ENODEDRBD
1497
CV_ENODEDRBDVERSION = _constants.CV_ENODEDRBDVERSION
1498
CV_ENODEDRBDHELPER = _constants.CV_ENODEDRBDHELPER
1499
CV_ENODEFILECHECK = _constants.CV_ENODEFILECHECK
1500
CV_ENODEHOOKS = _constants.CV_ENODEHOOKS
1501
CV_ENODEHV = _constants.CV_ENODEHV
1502
CV_ENODELVM = _constants.CV_ENODELVM
1503
CV_ENODEN1 = _constants.CV_ENODEN1
1504
CV_ENODENET = _constants.CV_ENODENET
1505
CV_ENODEOS = _constants.CV_ENODEOS
1506
CV_ENODEORPHANINSTANCE = _constants.CV_ENODEORPHANINSTANCE
1507
CV_ENODEORPHANLV = _constants.CV_ENODEORPHANLV
1508
CV_ENODERPC = _constants.CV_ENODERPC
1509
CV_ENODESSH = _constants.CV_ENODESSH
1510
CV_ENODEVERSION = _constants.CV_ENODEVERSION
1511
CV_ENODESETUP = _constants.CV_ENODESETUP
1512
CV_ENODETIME = _constants.CV_ENODETIME
1513
CV_ENODEOOBPATH = _constants.CV_ENODEOOBPATH
1514
CV_ENODEUSERSCRIPTS = _constants.CV_ENODEUSERSCRIPTS
1515
CV_ENODEFILESTORAGEPATHS = _constants.CV_ENODEFILESTORAGEPATHS
1516
CV_ENODEFILESTORAGEPATHUNUSABLE = _constants.CV_ENODEFILESTORAGEPATHUNUSABLE
1517
CV_ENODESHAREDFILESTORAGEPATHUNUSABLE = \
1518
  _constants.CV_ENODESHAREDFILESTORAGEPATHUNUSABLE
1519

    
1520
CV_ALL_ECODES = _constants.CV_ALL_ECODES
1521
CV_ALL_ECODES_STRINGS = _constants.CV_ALL_ECODES_STRINGS
1522

    
1523
# Node verify constants
1524
NV_BRIDGES = "bridges"
1525
NV_DRBDHELPER = "drbd-helper"
1526
NV_DRBDVERSION = "drbd-version"
1527
NV_DRBDLIST = "drbd-list"
1528
NV_EXCLUSIVEPVS = "exclusive-pvs"
1529
NV_FILELIST = "filelist"
1530
NV_ACCEPTED_STORAGE_PATHS = "allowed-file-storage-paths"
1531
NV_FILE_STORAGE_PATH = "file-storage-path"
1532
NV_SHARED_FILE_STORAGE_PATH = "shared-file-storage-path"
1533
NV_HVINFO = "hvinfo"
1534
NV_HVPARAMS = "hvparms"
1535
NV_HYPERVISOR = "hypervisor"
1536
NV_INSTANCELIST = "instancelist"
1537
NV_LVLIST = "lvlist"
1538
NV_MASTERIP = "master-ip"
1539
NV_NODELIST = "nodelist"
1540
NV_NODENETTEST = "node-net-test"
1541
NV_NODESETUP = "nodesetup"
1542
NV_OOB_PATHS = "oob-paths"
1543
NV_OSLIST = "oslist"
1544
NV_PVLIST = "pvlist"
1545
NV_TIME = "time"
1546
NV_USERSCRIPTS = "user-scripts"
1547
NV_VERSION = "version"
1548
NV_VGLIST = "vglist"
1549
NV_VMNODES = "vmnodes"
1550

    
1551
# Instance status
1552
INSTST_RUNNING = _constants.INSTST_RUNNING
1553
INSTST_ADMINDOWN = _constants.INSTST_ADMINDOWN
1554
INSTST_ADMINOFFLINE = _constants.INSTST_ADMINOFFLINE
1555
INSTST_NODEOFFLINE = _constants.INSTST_NODEOFFLINE
1556
INSTST_NODEDOWN = _constants.INSTST_NODEDOWN
1557
INSTST_WRONGNODE = _constants.INSTST_WRONGNODE
1558
INSTST_ERRORUP = _constants.INSTST_ERRORUP
1559
INSTST_ERRORDOWN = _constants.INSTST_ERRORDOWN
1560
INSTST_ALL = _constants.INSTST_ALL
1561

    
1562
# Admin states
1563
ADMINST_UP = _constants.ADMINST_UP
1564
ADMINST_DOWN = _constants.ADMINST_DOWN
1565
ADMINST_OFFLINE = _constants.ADMINST_OFFLINE
1566
ADMINST_ALL = _constants.ADMINST_ALL
1567

    
1568
# Node roles
1569
NR_REGULAR = _constants.NR_REGULAR
1570
NR_MASTER = _constants.NR_MASTER
1571
NR_MCANDIDATE = _constants.NR_MCANDIDATE
1572
NR_DRAINED = _constants.NR_DRAINED
1573
NR_OFFLINE = _constants.NR_OFFLINE
1574
NR_ALL = _constants.NR_ALL
1575

    
1576
# SSL certificate check constants (in days)
1577
SSL_CERT_EXPIRATION_WARN = 30
1578
SSL_CERT_EXPIRATION_ERROR = 7
1579

    
1580
# Allocator framework constants
1581
IALLOCATOR_VERSION = _constants.IALLOCATOR_VERSION
1582
IALLOCATOR_DIR_IN = _constants.IALLOCATOR_DIR_IN
1583
IALLOCATOR_DIR_OUT = _constants.IALLOCATOR_DIR_OUT
1584
VALID_IALLOCATOR_DIRECTIONS = _constants.VALID_IALLOCATOR_DIRECTIONS
1585

    
1586
IALLOCATOR_MODE_ALLOC = _constants.IALLOCATOR_MODE_ALLOC
1587
IALLOCATOR_MODE_RELOC = _constants.IALLOCATOR_MODE_RELOC
1588
IALLOCATOR_MODE_CHG_GROUP = _constants.IALLOCATOR_MODE_CHG_GROUP
1589
IALLOCATOR_MODE_NODE_EVAC = _constants.IALLOCATOR_MODE_NODE_EVAC
1590
IALLOCATOR_MODE_MULTI_ALLOC = _constants.IALLOCATOR_MODE_MULTI_ALLOC
1591
VALID_IALLOCATOR_MODES = _constants.VALID_IALLOCATOR_MODES
1592

    
1593
IALLOCATOR_SEARCH_PATH = _constants.IALLOCATOR_SEARCH_PATH
1594
DEFAULT_IALLOCATOR_SHORTCUT = _constants.DEFAULT_IALLOCATOR_SHORTCUT
1595

    
1596
IALLOCATOR_NEVAC_PRI = _constants.IALLOCATOR_NEVAC_PRI
1597
IALLOCATOR_NEVAC_SEC = _constants.IALLOCATOR_NEVAC_SEC
1598
IALLOCATOR_NEVAC_ALL = _constants.IALLOCATOR_NEVAC_ALL
1599
IALLOCATOR_NEVAC_MODES = _constants.IALLOCATOR_NEVAC_MODES
1600

    
1601
# Node evacuation
1602
NODE_EVAC_PRI = _constants.NODE_EVAC_PRI
1603
NODE_EVAC_SEC = _constants.NODE_EVAC_SEC
1604
NODE_EVAC_ALL = _constants.NODE_EVAC_ALL
1605
NODE_EVAC_MODES = _constants.NODE_EVAC_MODES
1606

    
1607
# Job queue
1608
JOB_QUEUE_VERSION = 1
1609
JOB_QUEUE_SIZE_HARD_LIMIT = 5000
1610
JOB_QUEUE_FILES_PERMS = 0640
1611

    
1612
JOB_ID_TEMPLATE = r"\d+"
1613
JOB_FILE_RE = re.compile(r"^job-(%s)$" % JOB_ID_TEMPLATE)
1614

    
1615
# unchanged job return
1616
JOB_NOTCHANGED = "nochange"
1617

    
1618
# Job status
1619
JOB_STATUS_QUEUED = _constants.JOB_STATUS_QUEUED
1620
JOB_STATUS_WAITING = _constants.JOB_STATUS_WAITING
1621
JOB_STATUS_CANCELING = _constants.JOB_STATUS_CANCELING
1622
JOB_STATUS_RUNNING = _constants.JOB_STATUS_RUNNING
1623
JOB_STATUS_CANCELED = _constants.JOB_STATUS_CANCELED
1624
JOB_STATUS_SUCCESS = _constants.JOB_STATUS_SUCCESS
1625
JOB_STATUS_ERROR = _constants.JOB_STATUS_ERROR
1626
JOBS_PENDING = _constants.JOBS_PENDING
1627
JOBS_FINALIZED = _constants.JOBS_FINALIZED
1628
JOB_STATUS_ALL = _constants.JOB_STATUS_ALL
1629

    
1630
# OpCode status
1631
# not yet finalized
1632
OP_STATUS_QUEUED = _constants.OP_STATUS_QUEUED
1633
OP_STATUS_WAITING = _constants.OP_STATUS_WAITING
1634
OP_STATUS_CANCELING = _constants.OP_STATUS_CANCELING
1635
OP_STATUS_RUNNING = _constants.OP_STATUS_RUNNING
1636
# finalized
1637
OP_STATUS_CANCELED = _constants.OP_STATUS_CANCELED
1638
OP_STATUS_SUCCESS = _constants.OP_STATUS_SUCCESS
1639
OP_STATUS_ERROR = _constants.OP_STATUS_ERROR
1640
OPS_FINALIZED = _constants.OPS_FINALIZED
1641

    
1642
# OpCode priority
1643
OP_PRIO_LOWEST = _constants.OP_PRIO_LOWEST
1644
OP_PRIO_HIGHEST = _constants.OP_PRIO_HIGHEST
1645
OP_PRIO_LOW = _constants.OP_PRIO_LOW
1646
OP_PRIO_NORMAL = _constants.OP_PRIO_NORMAL
1647
OP_PRIO_HIGH = _constants.OP_PRIO_HIGH
1648
OP_PRIO_SUBMIT_VALID = _constants.OP_PRIO_SUBMIT_VALID
1649
OP_PRIO_DEFAULT = _constants.OP_PRIO_DEFAULT
1650

    
1651
# Lock recalculate mode
1652
LOCKS_REPLACE = "replace"
1653
LOCKS_APPEND = "append"
1654

    
1655
# Lock timeout (sum) before we should go into blocking acquire (still
1656
# can be reset by priority change); computed as max time (10 hours)
1657
# before we should actually go into blocking acquire given that we
1658
# start from default priority level; in seconds
1659
# TODO
1660
LOCK_ATTEMPTS_TIMEOUT = 10 * 3600 / (OP_PRIO_DEFAULT - OP_PRIO_HIGHEST)
1661
LOCK_ATTEMPTS_MAXWAIT = 15.0
1662
LOCK_ATTEMPTS_MINWAIT = 1.0
1663

    
1664
# Execution log types
1665
ELOG_MESSAGE = _constants.ELOG_MESSAGE
1666
ELOG_REMOTE_IMPORT = _constants.ELOG_REMOTE_IMPORT
1667
ELOG_JQUEUE_TEST = _constants.ELOG_JQUEUE_TEST
1668

    
1669
# /etc/hosts modification
1670
ETC_HOSTS_ADD = "add"
1671
ETC_HOSTS_REMOVE = "remove"
1672

    
1673
# Job queue test
1674
JQT_MSGPREFIX = "TESTMSG="
1675
JQT_EXPANDNAMES = "expandnames"
1676
JQT_EXEC = "exec"
1677
JQT_LOGMSG = "logmsg"
1678
JQT_STARTMSG = "startmsg"
1679
JQT_ALL = compat.UniqueFrozenset([
1680
  JQT_EXPANDNAMES,
1681
  JQT_EXEC,
1682
  JQT_LOGMSG,
1683
  JQT_STARTMSG,
1684
  ])
1685

    
1686
# Query resources
1687
QR_CLUSTER = "cluster"
1688
QR_INSTANCE = "instance"
1689
QR_NODE = "node"
1690
QR_LOCK = "lock"
1691
QR_GROUP = "group"
1692
QR_OS = "os"
1693
QR_JOB = "job"
1694
QR_EXPORT = "export"
1695
QR_NETWORK = "network"
1696
QR_EXTSTORAGE = "extstorage"
1697

    
1698
#: List of resources which can be queried using L{opcodes.OpQuery}
1699
QR_VIA_OP = compat.UniqueFrozenset([
1700
  QR_CLUSTER,
1701
  QR_INSTANCE,
1702
  QR_NODE,
1703
  QR_GROUP,
1704
  QR_OS,
1705
  QR_EXPORT,
1706
  QR_NETWORK,
1707
  QR_EXTSTORAGE,
1708
  ])
1709

    
1710
#: List of resources which can be queried using Local UniX Interface
1711
QR_VIA_LUXI = QR_VIA_OP.union([
1712
  QR_LOCK,
1713
  QR_JOB,
1714
  ])
1715

    
1716
#: List of resources which can be queried using RAPI
1717
QR_VIA_RAPI = QR_VIA_LUXI
1718

    
1719
# Query field types
1720
QFT_UNKNOWN = "unknown"
1721
QFT_TEXT = "text"
1722
QFT_BOOL = "bool"
1723
QFT_NUMBER = "number"
1724
QFT_UNIT = "unit"
1725
QFT_TIMESTAMP = "timestamp"
1726
QFT_OTHER = "other"
1727

    
1728
#: All query field types
1729
QFT_ALL = compat.UniqueFrozenset([
1730
  QFT_UNKNOWN,
1731
  QFT_TEXT,
1732
  QFT_BOOL,
1733
  QFT_NUMBER,
1734
  QFT_UNIT,
1735
  QFT_TIMESTAMP,
1736
  QFT_OTHER,
1737
  ])
1738

    
1739
# Query result field status (don't change or reuse values as they're used by
1740
# clients)
1741
#: Normal field status
1742
RS_NORMAL = 0
1743
#: Unknown field
1744
RS_UNKNOWN = 1
1745
#: No data (e.g. RPC error), can be used instead of L{RS_OFFLINE}
1746
RS_NODATA = 2
1747
#: Value unavailable/unsupported for item; if this field is supported
1748
#: but we cannot get the data for the moment, RS_NODATA or
1749
#: RS_OFFLINE should be used
1750
RS_UNAVAIL = 3
1751
#: Resource marked offline
1752
RS_OFFLINE = 4
1753

    
1754
RS_ALL = compat.UniqueFrozenset([
1755
  RS_NORMAL,
1756
  RS_UNKNOWN,
1757
  RS_NODATA,
1758
  RS_UNAVAIL,
1759
  RS_OFFLINE,
1760
  ])
1761

    
1762
#: Dictionary with special field cases and their verbose/terse formatting
1763
RSS_DESCRIPTION = {
1764
  RS_UNKNOWN: ("(unknown)", "??"),
1765
  RS_NODATA: ("(nodata)", "?"),
1766
  RS_OFFLINE: ("(offline)", "*"),
1767
  RS_UNAVAIL: ("(unavail)", "-"),
1768
  }
1769

    
1770
# max dynamic devices
1771
MAX_NICS = 8
1772
MAX_DISKS = 16
1773

    
1774
# SSCONF file prefix
1775
SSCONF_FILEPREFIX = "ssconf_"
1776
# SSCONF keys
1777
SS_CLUSTER_NAME = "cluster_name"
1778
SS_CLUSTER_TAGS = "cluster_tags"
1779
SS_FILE_STORAGE_DIR = "file_storage_dir"
1780
SS_SHARED_FILE_STORAGE_DIR = "shared_file_storage_dir"
1781
SS_MASTER_CANDIDATES = "master_candidates"
1782
SS_MASTER_CANDIDATES_IPS = "master_candidates_ips"
1783
SS_MASTER_IP = "master_ip"
1784
SS_MASTER_NETDEV = "master_netdev"
1785
SS_MASTER_NETMASK = "master_netmask"
1786
SS_MASTER_NODE = "master_node"
1787
SS_NODE_LIST = "node_list"
1788
SS_NODE_PRIMARY_IPS = "node_primary_ips"
1789
SS_NODE_SECONDARY_IPS = "node_secondary_ips"
1790
SS_OFFLINE_NODES = "offline_nodes"
1791
SS_ONLINE_NODES = "online_nodes"
1792
SS_PRIMARY_IP_FAMILY = "primary_ip_family"
1793
SS_INSTANCE_LIST = "instance_list"
1794
SS_RELEASE_VERSION = "release_version"
1795
SS_HYPERVISOR_LIST = "hypervisor_list"
1796
SS_MAINTAIN_NODE_HEALTH = "maintain_node_health"
1797
SS_UID_POOL = "uid_pool"
1798
SS_NODEGROUPS = "nodegroups"
1799
SS_NETWORKS = "networks"
1800

    
1801
# This is not a complete SSCONF key, but the prefix for the hypervisor keys
1802
SS_HVPARAMS_PREF = "hvparams_"
1803

    
1804
# Hvparams keys:
1805
SS_HVPARAMS_XEN_PVM = SS_HVPARAMS_PREF + HT_XEN_PVM
1806
SS_HVPARAMS_XEN_FAKE = SS_HVPARAMS_PREF + HT_FAKE
1807
SS_HVPARAMS_XEN_HVM = SS_HVPARAMS_PREF + HT_XEN_HVM
1808
SS_HVPARAMS_XEN_KVM = SS_HVPARAMS_PREF + HT_KVM
1809
SS_HVPARAMS_XEN_CHROOT = SS_HVPARAMS_PREF + HT_CHROOT
1810
SS_HVPARAMS_XEN_LXC = SS_HVPARAMS_PREF + HT_LXC
1811

    
1812
VALID_SS_HVPARAMS_KEYS = compat.UniqueFrozenset([
1813
  SS_HVPARAMS_XEN_PVM,
1814
  SS_HVPARAMS_XEN_FAKE,
1815
  SS_HVPARAMS_XEN_HVM,
1816
  SS_HVPARAMS_XEN_KVM,
1817
  SS_HVPARAMS_XEN_CHROOT,
1818
  SS_HVPARAMS_XEN_LXC,
1819
  ])
1820

    
1821
SS_FILE_PERMS = 0444
1822

    
1823
# cluster wide default parameters
1824
DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM
1825

    
1826
HVC_DEFAULTS = {
1827
  HT_XEN_PVM: {
1828
    HV_USE_BOOTLOADER: False,
1829
    HV_BOOTLOADER_PATH: XEN_BOOTLOADER,
1830
    HV_BOOTLOADER_ARGS: "",
1831
    HV_KERNEL_PATH: XEN_KERNEL,
1832
    HV_INITRD_PATH: "",
1833
    HV_ROOT_PATH: "/dev/xvda1",
1834
    HV_KERNEL_ARGS: "ro",
1835
    HV_MIGRATION_PORT: 8002,
1836
    HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1837
    HV_BLOCKDEV_PREFIX: "sd",
1838
    HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1839
    HV_CPU_MASK: CPU_PINNING_ALL,
1840
    HV_CPU_CAP: 0,
1841
    HV_CPU_WEIGHT: 256,
1842
    HV_VIF_SCRIPT: "",
1843
    HV_XEN_CMD: XEN_CMD_XM,
1844
    },
1845
  HT_XEN_HVM: {
1846
    HV_BOOT_ORDER: "cd",
1847
    HV_CDROM_IMAGE_PATH: "",
1848
    HV_NIC_TYPE: HT_NIC_RTL8139,
1849
    HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
1850
    HV_VNC_BIND_ADDRESS: IP4_ADDRESS_ANY,
1851
    HV_VNC_PASSWORD_FILE: pathutils.VNC_PASSWORD_FILE,
1852
    HV_ACPI: True,
1853
    HV_PAE: True,
1854
    HV_KERNEL_PATH: "/usr/lib/xen/boot/hvmloader",
1855
    HV_DEVICE_MODEL: "/usr/lib/xen/bin/qemu-dm",
1856
    HV_MIGRATION_PORT: 8002,
1857
    HV_MIGRATION_MODE: HT_MIGRATION_NONLIVE,
1858
    HV_USE_LOCALTIME: False,
1859
    HV_BLOCKDEV_PREFIX: "hd",
1860
    HV_PASSTHROUGH: "",
1861
    HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1862
    HV_CPU_MASK: CPU_PINNING_ALL,
1863
    HV_CPU_CAP: 0,
1864
    HV_CPU_WEIGHT: 256,
1865
    HV_VIF_TYPE: HT_HVM_VIF_IOEMU,
1866
    HV_VIF_SCRIPT: "",
1867
    HV_VIRIDIAN: False,
1868
    HV_XEN_CMD: XEN_CMD_XM,
1869
    },
1870
  HT_KVM: {
1871
    HV_KVM_PATH: KVM_PATH,
1872
    HV_KERNEL_PATH: KVM_KERNEL,
1873
    HV_INITRD_PATH: "",
1874
    HV_KERNEL_ARGS: "ro",
1875
    HV_ROOT_PATH: "/dev/vda1",
1876
    HV_ACPI: True,
1877
    HV_SERIAL_CONSOLE: True,
1878
    HV_SERIAL_SPEED: 38400,
1879
    HV_VNC_BIND_ADDRESS: "",
1880
    HV_VNC_TLS: False,
1881
    HV_VNC_X509: "",
1882
    HV_VNC_X509_VERIFY: False,
1883
    HV_VNC_PASSWORD_FILE: "",
1884
    HV_KVM_SPICE_BIND: "",
1885
    HV_KVM_SPICE_IP_VERSION: IFACE_NO_IP_VERSION_SPECIFIED,
1886
    HV_KVM_SPICE_PASSWORD_FILE: "",
1887
    HV_KVM_SPICE_LOSSLESS_IMG_COMPR: "",
1888
    HV_KVM_SPICE_JPEG_IMG_COMPR: "",
1889
    HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR: "",
1890
    HV_KVM_SPICE_STREAMING_VIDEO_DETECTION: "",
1891
    HV_KVM_SPICE_AUDIO_COMPR: True,
1892
    HV_KVM_SPICE_USE_TLS: False,
1893
    HV_KVM_SPICE_TLS_CIPHERS: OPENSSL_CIPHERS,
1894
    HV_KVM_SPICE_USE_VDAGENT: True,
1895
    HV_KVM_FLOPPY_IMAGE_PATH: "",
1896
    HV_CDROM_IMAGE_PATH: "",
1897
    HV_KVM_CDROM2_IMAGE_PATH: "",
1898
    HV_BOOT_ORDER: HT_BO_DISK,
1899
    HV_NIC_TYPE: HT_NIC_PARAVIRTUAL,
1900
    HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
1901
    HV_KVM_CDROM_DISK_TYPE: "",
1902
    HV_USB_MOUSE: "",
1903
    HV_KEYMAP: "",
1904
    HV_MIGRATION_PORT: 8102,
1905
    HV_MIGRATION_BANDWIDTH: 32, # MiB/s
1906
    HV_MIGRATION_DOWNTIME: 30,  # ms
1907
    HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1908
    HV_USE_LOCALTIME: False,
1909
    HV_DISK_CACHE: HT_CACHE_DEFAULT,
1910
    HV_SECURITY_MODEL: HT_SM_NONE,
1911
    HV_SECURITY_DOMAIN: "",
1912
    HV_KVM_FLAG: "",
1913
    HV_VHOST_NET: False,
1914
    HV_KVM_USE_CHROOT: False,
1915
    HV_MEM_PATH: "",
1916
    HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1917
    HV_CPU_MASK: CPU_PINNING_ALL,
1918
    HV_CPU_TYPE: "",
1919
    HV_CPU_CORES: 0,
1920
    HV_CPU_THREADS: 0,
1921
    HV_CPU_SOCKETS: 0,
1922
    HV_SOUNDHW: "",
1923
    HV_USB_DEVICES: "",
1924
    HV_VGA: "",
1925
    HV_KVM_EXTRA: "",
1926
    HV_KVM_MACHINE_VERSION: "",
1927
    HV_VNET_HDR: True,
1928
    },
1929
  HT_FAKE: {
1930
    HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1931
  },
1932
  HT_CHROOT: {
1933
    HV_INIT_SCRIPT: "/ganeti-chroot",
1934
    },
1935
  HT_LXC: {
1936
    HV_CPU_MASK: "",
1937
    },
1938
  }
1939

    
1940
HVC_GLOBALS = compat.UniqueFrozenset([
1941
  HV_MIGRATION_PORT,
1942
  HV_MIGRATION_BANDWIDTH,
1943
  HV_MIGRATION_MODE,
1944
  HV_XEN_CMD,
1945
  ])
1946

    
1947
BEC_DEFAULTS = {
1948
  BE_MINMEM: 128,
1949
  BE_MAXMEM: 128,
1950
  BE_VCPUS: 1,
1951
  BE_AUTO_BALANCE: True,
1952
  BE_ALWAYS_FAILOVER: False,
1953
  BE_SPINDLE_USE: 1,
1954
  }
1955

    
1956
NDC_DEFAULTS = {
1957
  ND_OOB_PROGRAM: "",
1958
  ND_SPINDLE_COUNT: 1,
1959
  ND_EXCLUSIVE_STORAGE: False,
1960
  ND_OVS: False,
1961
  ND_OVS_NAME: DEFAULT_OVS,
1962
  ND_OVS_LINK: ""
1963
  }
1964

    
1965
NDC_GLOBALS = compat.UniqueFrozenset([
1966
  ND_EXCLUSIVE_STORAGE,
1967
  ])
1968

    
1969
DISK_LD_DEFAULTS = {
1970
  DT_DRBD8: {
1971
    LDP_RESYNC_RATE: CLASSIC_DRBD_SYNC_SPEED,
1972
    LDP_BARRIERS: _constants.DRBD_BARRIERS,
1973
    LDP_NO_META_FLUSH: _constants.DRBD_NO_META_FLUSH,
1974
    LDP_DEFAULT_METAVG: DEFAULT_VG,
1975
    LDP_DISK_CUSTOM: "",
1976
    LDP_NET_CUSTOM: "",
1977
    LDP_PROTOCOL: DRBD_DEFAULT_NET_PROTOCOL,
1978
    LDP_DYNAMIC_RESYNC: False,
1979

    
1980
    # The default values for the DRBD dynamic resync speed algorithm
1981
    # are taken from the drbsetup 8.3.11 man page, except for
1982
    # c-plan-ahead (that we don't need to set to 0, because we have a
1983
    # separate option to enable it) and for c-max-rate, that we cap to
1984
    # the default value for the static resync rate.
1985
    LDP_PLAN_AHEAD: 20, # ds
1986
    LDP_FILL_TARGET: 0, # sectors
1987
    LDP_DELAY_TARGET: 1, # ds
1988
    LDP_MAX_RATE: CLASSIC_DRBD_SYNC_SPEED, # KiB/s
1989
    LDP_MIN_RATE: 4 * 1024, # KiB/s
1990
    },
1991
  DT_PLAIN: {
1992
    LDP_STRIPES: _constants.LVM_STRIPECOUNT
1993
    },
1994
  DT_FILE: {},
1995
  DT_SHARED_FILE: {},
1996
  DT_BLOCK: {},
1997
  DT_RBD: {
1998
    LDP_POOL: "rbd"
1999
    },
2000
  DT_EXT: {},
2001
  }
2002

    
2003
# readability shortcuts
2004
_LV_DEFAULTS = DISK_LD_DEFAULTS[DT_PLAIN]
2005
_DRBD_DEFAULTS = DISK_LD_DEFAULTS[DT_DRBD8]
2006

    
2007
DISK_DT_DEFAULTS = {
2008
  DT_PLAIN: {
2009
    LV_STRIPES: DISK_LD_DEFAULTS[DT_PLAIN][LDP_STRIPES],
2010
    },
2011
  DT_DRBD8: {
2012
    DRBD_RESYNC_RATE: _DRBD_DEFAULTS[LDP_RESYNC_RATE],
2013
    DRBD_DATA_STRIPES: _LV_DEFAULTS[LDP_STRIPES],
2014
    DRBD_META_STRIPES: _LV_DEFAULTS[LDP_STRIPES],
2015
    DRBD_DISK_BARRIERS: _DRBD_DEFAULTS[LDP_BARRIERS],
2016
    DRBD_META_BARRIERS: _DRBD_DEFAULTS[LDP_NO_META_FLUSH],
2017
    DRBD_DEFAULT_METAVG: _DRBD_DEFAULTS[LDP_DEFAULT_METAVG],
2018
    DRBD_DISK_CUSTOM: _DRBD_DEFAULTS[LDP_DISK_CUSTOM],
2019
    DRBD_NET_CUSTOM: _DRBD_DEFAULTS[LDP_NET_CUSTOM],
2020
    DRBD_PROTOCOL: _DRBD_DEFAULTS[LDP_PROTOCOL],
2021
    DRBD_DYNAMIC_RESYNC: _DRBD_DEFAULTS[LDP_DYNAMIC_RESYNC],
2022
    DRBD_PLAN_AHEAD: _DRBD_DEFAULTS[LDP_PLAN_AHEAD],
2023
    DRBD_FILL_TARGET: _DRBD_DEFAULTS[LDP_FILL_TARGET],
2024
    DRBD_DELAY_TARGET: _DRBD_DEFAULTS[LDP_DELAY_TARGET],
2025
    DRBD_MAX_RATE: _DRBD_DEFAULTS[LDP_MAX_RATE],
2026
    DRBD_MIN_RATE: _DRBD_DEFAULTS[LDP_MIN_RATE],
2027
    },
2028
  DT_DISKLESS: {},
2029
  DT_FILE: {},
2030
  DT_SHARED_FILE: {},
2031
  DT_BLOCK: {},
2032
  DT_RBD: {
2033
    RBD_POOL: DISK_LD_DEFAULTS[DT_RBD][LDP_POOL]
2034
    },
2035
  DT_EXT: {},
2036
  }
2037

    
2038
# we don't want to export the shortcuts
2039
del _LV_DEFAULTS, _DRBD_DEFAULTS
2040

    
2041
NICC_DEFAULTS = {
2042
  NIC_MODE: NIC_MODE_BRIDGED,
2043
  NIC_LINK: DEFAULT_BRIDGE,
2044
  NIC_VLAN: VALUE_HS_NOTHING,
2045
  }
2046

    
2047
# All of the following values are quite arbitrarily - there are no
2048
# "good" defaults, these must be customised per-site
2049
ISPECS_MINMAX_DEFAULTS = {
2050
  ISPECS_MIN: {
2051
    ISPEC_MEM_SIZE: 128,
2052
    ISPEC_CPU_COUNT: 1,
2053
    ISPEC_DISK_COUNT: 1,
2054
    ISPEC_DISK_SIZE: 1024,
2055
    ISPEC_NIC_COUNT: 1,
2056
    ISPEC_SPINDLE_USE: 1,
2057
    },
2058
  ISPECS_MAX: {
2059
    ISPEC_MEM_SIZE: 32768,
2060
    ISPEC_CPU_COUNT: 8,
2061
    ISPEC_DISK_COUNT: MAX_DISKS,
2062
    ISPEC_DISK_SIZE: 1024 * 1024,
2063
    ISPEC_NIC_COUNT: MAX_NICS,
2064
    ISPEC_SPINDLE_USE: 12,
2065
    },
2066
  }
2067
IPOLICY_DEFAULTS = {
2068
  ISPECS_MINMAX: [ISPECS_MINMAX_DEFAULTS],
2069
  ISPECS_STD: {
2070
    ISPEC_MEM_SIZE: 128,
2071
    ISPEC_CPU_COUNT: 1,
2072
    ISPEC_DISK_COUNT: 1,
2073
    ISPEC_DISK_SIZE: 1024,
2074
    ISPEC_NIC_COUNT: 1,
2075
    ISPEC_SPINDLE_USE: 1,
2076
    },
2077
  IPOLICY_DTS: list(DISK_TEMPLATES),
2078
  IPOLICY_VCPU_RATIO: 4.0,
2079
  IPOLICY_SPINDLE_RATIO: 32.0,
2080
  }
2081

    
2082
MASTER_POOL_SIZE_DEFAULT = 10
2083

    
2084
# Exclusive storage:
2085
# Error margin used to compare physical disks
2086
PART_MARGIN = .01
2087
# Space reserved when creating instance disks
2088
PART_RESERVED = .02
2089

    
2090
CONFD_PROTOCOL_VERSION = 1
2091

    
2092
CONFD_REQ_PING = 0
2093
CONFD_REQ_NODE_ROLE_BYNAME = 1
2094
CONFD_REQ_NODE_PIP_BY_INSTANCE_IP = 2
2095
CONFD_REQ_CLUSTER_MASTER = 3
2096
CONFD_REQ_NODE_PIP_LIST = 4
2097
CONFD_REQ_MC_PIP_LIST = 5
2098
CONFD_REQ_INSTANCES_IPS_LIST = 6
2099
CONFD_REQ_NODE_DRBD = 7
2100
CONFD_REQ_NODE_INSTANCES = 8
2101

    
2102
# Confd request query fields. These are used to narrow down queries.
2103
# These must be strings rather than integers, because json-encoding
2104
# converts them to strings anyway, as they're used as dict-keys.
2105
CONFD_REQQ_LINK = "0"
2106
CONFD_REQQ_IP = "1"
2107
CONFD_REQQ_IPLIST = "2"
2108
CONFD_REQQ_FIELDS = "3"
2109

    
2110
CONFD_REQFIELD_NAME = "0"
2111
CONFD_REQFIELD_IP = "1"
2112
CONFD_REQFIELD_MNODE_PIP = "2"
2113

    
2114
CONFD_REQS = compat.UniqueFrozenset([
2115
  CONFD_REQ_PING,
2116
  CONFD_REQ_NODE_ROLE_BYNAME,
2117
  CONFD_REQ_NODE_PIP_BY_INSTANCE_IP,
2118
  CONFD_REQ_CLUSTER_MASTER,
2119
  CONFD_REQ_NODE_PIP_LIST,
2120
  CONFD_REQ_MC_PIP_LIST,
2121
  CONFD_REQ_INSTANCES_IPS_LIST,
2122
  CONFD_REQ_NODE_DRBD,
2123
  ])
2124

    
2125
CONFD_REPL_STATUS_OK = 0
2126
CONFD_REPL_STATUS_ERROR = 1
2127
CONFD_REPL_STATUS_NOTIMPLEMENTED = 2
2128

    
2129
CONFD_REPL_STATUSES = compat.UniqueFrozenset([
2130
  CONFD_REPL_STATUS_OK,
2131
  CONFD_REPL_STATUS_ERROR,
2132
  CONFD_REPL_STATUS_NOTIMPLEMENTED,
2133
  ])
2134

    
2135
(CONFD_NODE_ROLE_MASTER,
2136
 CONFD_NODE_ROLE_CANDIDATE,
2137
 CONFD_NODE_ROLE_OFFLINE,
2138
 CONFD_NODE_ROLE_DRAINED,
2139
 CONFD_NODE_ROLE_REGULAR,
2140
 ) = range(5)
2141

    
2142
# A few common errors for confd
2143
CONFD_ERROR_UNKNOWN_ENTRY = _constants.CONFD_ERROR_UNKNOWN_ENTRY
2144
CONFD_ERROR_INTERNAL = _constants.CONFD_ERROR_INTERNAL
2145
CONFD_ERROR_ARGUMENT = _constants.CONFD_ERROR_ARGUMENT
2146

    
2147
# Each request is "salted" by the current timestamp.
2148
# This constants decides how many seconds of skew to accept.
2149
# TODO: make this a default and allow the value to be more configurable
2150
CONFD_MAX_CLOCK_SKEW = _constants.CONFD_MAX_CLOCK_SKEW
2151

    
2152
# When we haven't reloaded the config for more than this amount of
2153
# seconds, we force a test to see if inotify is betraying us. Using a
2154
# prime number to ensure we get less chance of 'same wakeup' with
2155
# other processes.
2156
CONFD_CONFIG_RELOAD_TIMEOUT = _constants.CONFD_CONFIG_RELOAD_TIMEOUT
2157

    
2158
# If we receive more than one update in this amount of microseconds,
2159
# we move to polling every RATELIMIT seconds, rather than relying on
2160
# inotify, to be able to serve more requests.
2161
CONFD_CONFIG_RELOAD_RATELIMIT = _constants.CONFD_CONFIG_RELOAD_RATELIMIT
2162

    
2163
# Magic number prepended to all confd queries.
2164
# This allows us to distinguish different types of confd protocols and handle
2165
# them. For example by changing this we can move the whole payload to be
2166
# compressed, or move away from json.
2167
CONFD_MAGIC_FOURCC = _constants.CONFD_MAGIC_FOURCC
2168

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

    
2174
# Timeout in seconds to expire pending query request in the confd client
2175
# library. We don't actually expect any answer more than 10 seconds after we
2176
# sent a request.
2177
CONFD_CLIENT_EXPIRE_TIMEOUT = _constants.CONFD_CLIENT_EXPIRE_TIMEOUT
2178

    
2179
# Maximum UDP datagram size.
2180
# On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
2181
# On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
2182
#   (assuming we can't use jumbo frames)
2183
# We just set this to 60K, which should be enough
2184
MAX_UDP_DATA_SIZE = 61440
2185

    
2186
# User-id pool minimum/maximum acceptable user-ids.
2187
UIDPOOL_UID_MIN = 0
2188
UIDPOOL_UID_MAX = 2 ** 32 - 1 # Assuming 32 bit user-ids
2189

    
2190
# Name or path of the pgrep command
2191
PGREP = "pgrep"
2192

    
2193
# Name of the node group that gets created at cluster init or upgrade
2194
INITIAL_NODE_GROUP_NAME = "default"
2195

    
2196
# Possible values for NodeGroup.alloc_policy
2197
ALLOC_POLICY_PREFERRED = _constants.ALLOC_POLICY_PREFERRED
2198
ALLOC_POLICY_LAST_RESORT = _constants.ALLOC_POLICY_LAST_RESORT
2199
ALLOC_POLICY_UNALLOCABLE = _constants.ALLOC_POLICY_UNALLOCABLE
2200
VALID_ALLOC_POLICIES = _constants.VALID_ALLOC_POLICIES
2201

    
2202
# Temporary external/shared storage parameters
2203
BLOCKDEV_DRIVER_MANUAL = _constants.BLOCKDEV_DRIVER_MANUAL
2204

    
2205
# qemu-img path, required for ovfconverter
2206
QEMUIMG_PATH = _constants.QEMUIMG_PATH
2207

    
2208
# Whether htools was enabled at compilation time
2209
HTOOLS = _constants.HTOOLS
2210
# The hail iallocator
2211
IALLOC_HAIL = "hail"
2212

    
2213
# Fake opcodes for functions that have hooks attached to them via
2214
# backend.RunLocalHooks
2215
FAKE_OP_MASTER_TURNUP = "OP_CLUSTER_IP_TURNUP"
2216
FAKE_OP_MASTER_TURNDOWN = "OP_CLUSTER_IP_TURNDOWN"
2217

    
2218
# SSH key types
2219
SSHK_RSA = "rsa"
2220
SSHK_DSA = "dsa"
2221
SSHK_ALL = compat.UniqueFrozenset([SSHK_RSA, SSHK_DSA])
2222

    
2223
# SSH authorized key types
2224
SSHAK_RSA = "ssh-rsa"
2225
SSHAK_DSS = "ssh-dss"
2226
SSHAK_ALL = compat.UniqueFrozenset([SSHAK_RSA, SSHAK_DSS])
2227

    
2228
# SSH setup
2229
SSHS_CLUSTER_NAME = "cluster_name"
2230
SSHS_SSH_HOST_KEY = "ssh_host_key"
2231
SSHS_SSH_ROOT_KEY = "ssh_root_key"
2232
SSHS_NODE_DAEMON_CERTIFICATE = "node_daemon_certificate"
2233

    
2234
#: Key files for SSH daemon
2235
SSH_DAEMON_KEYFILES = {
2236
  SSHK_RSA: (pathutils.SSH_HOST_RSA_PRIV, pathutils.SSH_HOST_RSA_PUB),
2237
  SSHK_DSA: (pathutils.SSH_HOST_DSA_PRIV, pathutils.SSH_HOST_DSA_PUB),
2238
  }
2239

    
2240
# Node daemon setup
2241
NDS_CLUSTER_NAME = "cluster_name"
2242
NDS_NODE_DAEMON_CERTIFICATE = "node_daemon_certificate"
2243
NDS_SSCONF = "ssconf"
2244
NDS_START_NODE_DAEMON = "start_node_daemon"
2245

    
2246
# Path generating random UUID
2247
RANDOM_UUID_FILE = _constants.RANDOM_UUID_FILE
2248

    
2249
# Regex string for verifying a UUID
2250
UUID_REGEX = "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
2251

    
2252
# Auto-repair tag prefixes
2253
AUTO_REPAIR_TAG_PREFIX = _constants.AUTO_REPAIR_TAG_PREFIX
2254
AUTO_REPAIR_TAG_ENABLED = _constants.AUTO_REPAIR_TAG_ENABLED
2255
AUTO_REPAIR_TAG_SUSPENDED = _constants.AUTO_REPAIR_TAG_SUSPENDED
2256
AUTO_REPAIR_TAG_PENDING = _constants.AUTO_REPAIR_TAG_PENDING
2257
AUTO_REPAIR_TAG_RESULT = _constants.AUTO_REPAIR_TAG_RESULT
2258

    
2259
# Auto-repair levels
2260
AUTO_REPAIR_FIX_STORAGE = _constants.AUTO_REPAIR_FIX_STORAGE
2261
AUTO_REPAIR_MIGRATE = _constants.AUTO_REPAIR_MIGRATE
2262
AUTO_REPAIR_FAILOVER = _constants.AUTO_REPAIR_FAILOVER
2263
AUTO_REPAIR_REINSTALL = _constants.AUTO_REPAIR_REINSTALL
2264
AUTO_REPAIR_ALL_TYPES = _constants.AUTO_REPAIR_ALL_TYPES
2265

    
2266
# Auto-repair results
2267
AUTO_REPAIR_SUCCESS = _constants.AUTO_REPAIR_SUCCESS
2268
AUTO_REPAIR_FAILURE = _constants.AUTO_REPAIR_FAILURE
2269
AUTO_REPAIR_ENOPERM = _constants.AUTO_REPAIR_ENOPERM
2270
AUTO_REPAIR_ALL_RESULTS = _constants.AUTO_REPAIR_ALL_RESULTS
2271

    
2272
# The version identifier for builtin data collectors
2273
BUILTIN_DATA_COLLECTOR_VERSION = _constants.BUILTIN_DATA_COLLECTOR_VERSION
2274

    
2275
# The reason trail opcode parameter name
2276
OPCODE_REASON = _constants.OPCODE_REASON
2277

    
2278
# The source reasons for the execution of an OpCode
2279
OPCODE_REASON_SRC_CLIENT = "gnt:client"
2280
OPCODE_REASON_SRC_NODED = "gnt:daemon:noded"
2281
OPCODE_REASON_SRC_OPCODE = "gnt:opcode"
2282
OPCODE_REASON_SRC_RLIB2 = "gnt:library:rlib2"
2283
OPCODE_REASON_SRC_USER = "gnt:user"
2284

    
2285
OPCODE_REASON_SOURCES = compat.UniqueFrozenset([
2286
  OPCODE_REASON_SRC_CLIENT,
2287
  OPCODE_REASON_SRC_NODED,
2288
  OPCODE_REASON_SRC_OPCODE,
2289
  OPCODE_REASON_SRC_RLIB2,
2290
  OPCODE_REASON_SRC_USER,
2291
  ])
2292

    
2293
DISKSTATS_FILE = _constants.DISKSTATS_FILE
2294

    
2295
# CPU load collector variables
2296
STAT_FILE = _constants.STAT_FILE
2297
CPUAVGLOAD_BUFFER_SIZE = 150
2298
CPUAVGLOAD_WINDOW_SIZE = 600
2299

    
2300
# Mond's variable for periodical data collection
2301
MOND_TIME_INTERVAL = _constants.MOND_TIME_INTERVAL
2302

    
2303
# Do not re-export imported modules
2304
del re, _vcsversion, _constants, socket, pathutils, compat
2305

    
2306

    
2307
ALLOCATABLE_KEY = "allocatable"
2308
FAILED_KEY = "failed"