Statistics
| Branch: | Tag: | Revision:

root / lib / constants.py @ f5bfed26

History | View | Annotate | Download (64.4 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 _autoconf
28
from ganeti import _constants
29
from ganeti import _vcsversion
30
from ganeti import compat
31
from ganeti import pathutils
32

    
33

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

    
48

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

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

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

66
  Returns: int representing version number
67

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

    
76

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

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

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

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

    
88
  return (major, minor, revision)
89

    
90

    
91
CONFIG_MAJOR = int(_autoconf.VERSION_MAJOR)
92
CONFIG_MINOR = int(_autoconf.VERSION_MINOR)
93
CONFIG_REVISION = 0
94
CONFIG_VERSION = BuildVersion(CONFIG_MAJOR, CONFIG_MINOR, CONFIG_REVISION)
95

    
96
#: RPC protocol version
97
PROTOCOL_VERSION = BuildVersion(CONFIG_MAJOR, CONFIG_MINOR, 0)
98

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

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

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

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

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

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

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

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

    
165
DAEMONS = _constants.DAEMONS
166

    
167
DAEMONS_PORTS = _constants.DAEMONS_PORTS
168

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

    
174
FIRST_DRBD_PORT = 11000
175
LAST_DRBD_PORT = 14999
176

    
177
DAEMONS_LOGBASE = _constants.DAEMONS_LOGBASE
178

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

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

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

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

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

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

    
210
DEV_CONSOLE = _constants.DEV_CONSOLE
211

    
212
PROC_MOUNTS = "/proc/mounts"
213

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

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

    
229
EXPORT_CONF_FILE = "config.ini"
230

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

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

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

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

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

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

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

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

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

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

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

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

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

    
298
X509_CERT_SIGNATURE_HEADER = "X-Ganeti-Signature"
299

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

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

    
312
IE_CUSTOM_SIZE = "fd"
313

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

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

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

    
332

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
645
MAX_TAG_LEN = _constants.MAX_TAG_LEN
646
MAX_TAGS_PER_OBJ = _constants.MAX_TAGS_PER_OBJ
647

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

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

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

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

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

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

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

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

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

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

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

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

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

    
753
ES_PARAMETERS_FILE = "parameters.list"
754

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

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

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

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

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

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

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

    
874

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

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

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

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

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

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

    
983
# KVM-specific statuses
984
HV_KVM_MIGRATION_VALID_STATUSES = HV_MIGRATION_VALID_STATUSES
985

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1225
OOB_POWER_STATUS_POWERED = _constants.OOB_POWER_STATUS_POWERED
1226

    
1227
OOB_TIMEOUT = _constants.OOB_TIMEOUT
1228
OOB_POWER_DELAY = _constants.OOB_POWER_DELAY
1229

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

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

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

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

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

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

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

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

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

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

    
1313
VNC_BASE_PORT = 5900
1314
VNC_DEFAULT_BIND_ADDRESS = IP4_ADDRESS_ANY
1315

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1521
CV_ALL_ECODES = _constants.CV_ALL_ECODES
1522
CV_ALL_ECODES_STRINGS = _constants.CV_ALL_ECODES_STRINGS
1523

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

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

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

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

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

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

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

    
1594
IALLOCATOR_SEARCH_PATH = _constants.IALLOCATOR_SEARCH_PATH
1595
DEFAULT_IALLOCATOR_SHORTCUT = _constants.DEFAULT_IALLOCATOR_SHORTCUT
1596

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1822
SS_FILE_PERMS = 0444
1823

    
1824
# cluster wide default parameters
1825
DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM
1826

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

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

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

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

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

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

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

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

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

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

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

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

    
2083
MASTER_POOL_SIZE_DEFAULT = 10
2084

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

    
2091
CONFD_PROTOCOL_VERSION = 1
2092

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2206
# qemu-img path, required for ovfconverter
2207
QEMUIMG_PATH = _autoconf.QEMUIMG_PATH
2208

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2294
DISKSTATS_FILE = _constants.DISKSTATS_FILE
2295

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

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

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

    
2307

    
2308
ALLOCATABLE_KEY = "allocatable"
2309
FAILED_KEY = "failed"