Statistics
| Branch: | Tag: | Revision:

root / lib / constants.py @ fbab083b

History | View | Annotate | Download (65.5 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 _vcsversion
29
from ganeti import compat
30
from ganeti import pathutils
31

    
32

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

    
47

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

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

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

65
  Returns: int representing version number
66

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

    
75

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

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

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

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

    
87
  return (major, minor, revision)
88

    
89

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

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

    
98
# user separation
99
DAEMONS_GROUP = _autoconf.DAEMONS_GROUP
100
ADMIN_GROUP = _autoconf.ADMIN_GROUP
101
MASTERD_USER = _autoconf.MASTERD_USER
102
MASTERD_GROUP = _autoconf.MASTERD_GROUP
103
RAPI_USER = _autoconf.RAPI_USER
104
RAPI_GROUP = _autoconf.RAPI_GROUP
105
CONFD_USER = _autoconf.CONFD_USER
106
CONFD_GROUP = _autoconf.CONFD_GROUP
107
LUXID_USER = _autoconf.LUXID_USER
108
LUXID_GROUP = _autoconf.LUXID_GROUP
109
NODED_USER = _autoconf.NODED_USER
110
NODED_GROUP = _autoconf.NODED_GROUP
111
MOND_USER = _autoconf.MOND_USER
112
MOND_GROUP = _autoconf.MOND_GROUP
113
SSH_LOGIN_USER = _autoconf.SSH_LOGIN_USER
114
SSH_CONSOLE_USER = _autoconf.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_SHARED_FILE_STORAGE = _autoconf.ENABLE_SHARED_FILE_STORAGE
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 = "ssh"
156
SCP = "scp"
157

    
158
NODED = "ganeti-noded"
159
CONFD = "ganeti-confd"
160
LUXID = "ganeti-luxid"
161
RAPI = "ganeti-rapi"
162
MASTERD = "ganeti-masterd"
163
MOND = "ganeti-mond"
164

    
165
DAEMONS = compat.UniqueFrozenset([
166
  NODED,
167
  CONFD,
168
  LUXID,
169
  RAPI,
170
  MASTERD,
171
  MOND,
172
  ])
173

    
174
DAEMONS_PORTS = {
175
  # daemon-name: ("proto", "default-port")
176
  NODED: ("tcp", 1811),
177
  CONFD: ("udp", 1814),
178
  MOND: ("tcp", 1815),
179
  RAPI: ("tcp", 5080),
180
  SSH: ("tcp", 22),
181
}
182

    
183
DEFAULT_NODED_PORT = DAEMONS_PORTS[NODED][1]
184
DEFAULT_CONFD_PORT = DAEMONS_PORTS[CONFD][1]
185
DEFAULT_MOND_PORT = DAEMONS_PORTS[MOND][1]
186
DEFAULT_RAPI_PORT = DAEMONS_PORTS[RAPI][1]
187

    
188
FIRST_DRBD_PORT = 11000
189
LAST_DRBD_PORT = 14999
190

    
191
DAEMONS_LOGBASE = {
192
  NODED: "node-daemon",
193
  CONFD: "conf-daemon",
194
  LUXID: "query-daemon",
195
  RAPI: "rapi-daemon",
196
  MASTERD: "master-daemon",
197
  MOND: "monitoring-daemon",
198
  }
199

    
200
DAEMONS_LOGFILES = \
201
    dict((daemon, pathutils.GetLogFilename(DAEMONS_LOGBASE[daemon]))
202
         for daemon in DAEMONS_LOGBASE)
203

    
204
# Some daemons might require more than one logfile.
205
# Specifically, right now only the Haskell http library "snap", used by the
206
# monitoring daemon, requires multiple log files.
207

    
208
# These are the only valid reasons for having an extra logfile
209
EXTRA_LOGREASON_ACCESS = "access"
210
EXTRA_LOGREASON_ERROR = "error"
211

    
212
VALID_EXTRA_LOGREASONS = compat.UniqueFrozenset([
213
  EXTRA_LOGREASON_ACCESS,
214
  EXTRA_LOGREASON_ERROR,
215
  ])
216

    
217
# These are the extra logfiles, grouped by daemon
218
DAEMONS_EXTRA_LOGBASE = {
219
  MOND: {
220
    EXTRA_LOGREASON_ACCESS: "monitoring-daemon-access",
221
    EXTRA_LOGREASON_ERROR: "monitoring-daemon-error",
222
    }
223
  }
224

    
225
DAEMONS_EXTRA_LOGFILES = \
226
  dict((daemon, dict((extra,
227
       pathutils.GetLogFilename(DAEMONS_EXTRA_LOGBASE[daemon][extra]))
228
       for extra in DAEMONS_EXTRA_LOGBASE[daemon]))
229
         for daemon in DAEMONS_EXTRA_LOGBASE)
230

    
231
DEV_CONSOLE = "/dev/console"
232

    
233
PROC_MOUNTS = "/proc/mounts"
234

    
235
# Local UniX Interface related constants
236
LUXI_EOM = "\3"
237
LUXI_VERSION = CONFIG_VERSION
238
#: Environment variable for the luxi override socket
239
LUXI_OVERRIDE = "FORCE_LUXI_SOCKET"
240
LUXI_OVERRIDE_MASTER = "master"
241
LUXI_OVERRIDE_QUERY = "query"
242

    
243
# one of "no", "yes", "only"
244
SYSLOG_USAGE = _autoconf.SYSLOG_USAGE
245
SYSLOG_NO = "no"
246
SYSLOG_YES = "yes"
247
SYSLOG_ONLY = "only"
248
SYSLOG_SOCKET = "/dev/log"
249

    
250
EXPORT_CONF_FILE = "config.ini"
251

    
252
XEN_BOOTLOADER = _autoconf.XEN_BOOTLOADER
253
XEN_KERNEL = _autoconf.XEN_KERNEL
254
XEN_INITRD = _autoconf.XEN_INITRD
255
XEN_CMD_XM = "xm"
256
XEN_CMD_XL = "xl"
257

    
258
KNOWN_XEN_COMMANDS = compat.UniqueFrozenset([
259
  XEN_CMD_XM,
260
  XEN_CMD_XL,
261
  ])
262

    
263
# When the Xen toolstack used is "xl", live migration requires the source host
264
# to connect to the target host via ssh (xl runs this command). We need to pass
265
# the command xl runs some extra info so that it can use Ganeti's key
266
# verification and not fail. Note that this string is incomplete: it must be
267
# filled with the cluster name before being used.
268
XL_SSH_CMD = ("ssh -l %s -oGlobalKnownHostsFile=%s"
269
              " -oUserKnownHostsFile=/dev/null"
270
              " -oCheckHostIp=no -oStrictHostKeyChecking=yes"
271
              " -oHostKeyAlias=%%s") % (SSH_LOGIN_USER,
272
                                        pathutils.SSH_KNOWN_HOSTS_FILE)
273

    
274
KVM_PATH = _autoconf.KVM_PATH
275
KVM_KERNEL = _autoconf.KVM_KERNEL
276
SOCAT_PATH = _autoconf.SOCAT_PATH
277
SOCAT_USE_ESCAPE = _autoconf.SOCAT_USE_ESCAPE
278
SOCAT_USE_COMPRESS = _autoconf.SOCAT_USE_COMPRESS
279
SOCAT_ESCAPE_CODE = "0x1d"
280

    
281
#: Console as SSH command
282
CONS_SSH = "ssh"
283

    
284
#: Console as VNC server
285
CONS_VNC = "vnc"
286

    
287
#: Console as SPICE server
288
CONS_SPICE = "spice"
289

    
290
#: Display a message for console access
291
CONS_MESSAGE = "msg"
292

    
293
#: All console types
294
CONS_ALL = compat.UniqueFrozenset([
295
  CONS_SSH,
296
  CONS_VNC,
297
  CONS_SPICE,
298
  CONS_MESSAGE,
299
  ])
300

    
301
# For RSA keys more bits are better, but they also make operations more
302
# expensive. NIST SP 800-131 recommends a minimum of 2048 bits from the year
303
# 2010 on.
304
RSA_KEY_BITS = 2048
305

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

    
314
# Digest used to sign certificates ("openssl x509" uses SHA1 by default)
315
X509_CERT_SIGN_DIGEST = "SHA1"
316

    
317
# Default validity of certificates in days
318
X509_CERT_DEFAULT_VALIDITY = 365 * 5
319

    
320
# commonName (CN) used in certificates
321
X509_CERT_CN = "ganeti.example.com"
322

    
323
X509_CERT_SIGNATURE_HEADER = "X-Ganeti-Signature"
324

    
325
# Import/export daemon mode
326
IEM_IMPORT = "import"
327
IEM_EXPORT = "export"
328

    
329
# Import/export transport compression
330
IEC_NONE = "none"
331
IEC_GZIP = "gzip"
332
IEC_ALL = compat.UniqueFrozenset([
333
  IEC_NONE,
334
  IEC_GZIP,
335
  ])
336

    
337
IE_CUSTOM_SIZE = "fd"
338

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

    
341
# Import/export I/O
342
# Direct file I/O, equivalent to a shell's I/O redirection using '<' or '>'
343
IEIO_FILE = "file"
344
# Raw block device I/O using "dd"
345
IEIO_RAW_DISK = "raw"
346
# OS definition import/export script
347
IEIO_SCRIPT = "script"
348

    
349
VALUE_DEFAULT = "default"
350
VALUE_AUTO = "auto"
351
VALUE_GENERATE = "generate"
352
VALUE_NONE = "none"
353
VALUE_TRUE = "true"
354
VALUE_FALSE = "false"
355
VALUE_HS_NOTHING = {"Nothing": None}
356

    
357

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

    
361
# hooks-related constants
362
HOOKS_PHASE_PRE = "pre"
363
HOOKS_PHASE_POST = "post"
364
HOOKS_NAME_CFGUPDATE = "config-update"
365
HOOKS_NAME_WATCHER = "watcher"
366
HOOKS_VERSION = 2
367
HOOKS_PATH = "/sbin:/bin:/usr/sbin:/usr/bin"
368

    
369
# hooks subject type (what object type does the LU deal with)
370
HTYPE_CLUSTER = "CLUSTER"
371
HTYPE_NODE = "NODE"
372
HTYPE_GROUP = "GROUP"
373
HTYPE_INSTANCE = "INSTANCE"
374
HTYPE_NETWORK = "NETWORK"
375

    
376
HKR_SKIP = 0
377
HKR_FAIL = 1
378
HKR_SUCCESS = 2
379

    
380
# Storage types
381
ST_BLOCK = "blockdev"
382
ST_DISKLESS = "diskless"
383
ST_EXT = "ext"
384
ST_FILE = "file"
385
ST_LVM_PV = "lvm-pv"
386
ST_LVM_VG = "lvm-vg"
387
ST_RADOS = "rados"
388

    
389
VALID_STORAGE_TYPES = compat.UniqueFrozenset([
390
  ST_BLOCK,
391
  ST_DISKLESS,
392
  ST_EXT,
393
  ST_FILE,
394
  ST_LVM_PV,
395
  ST_LVM_VG,
396
  ST_RADOS,
397
  ])
398

    
399
# Storage fields
400
# first two are valid in LU context only, not passed to backend
401
SF_NODE = "node"
402
SF_TYPE = "type"
403
# and the rest are valid in backend
404
SF_NAME = "name"
405
SF_SIZE = "size"
406
SF_FREE = "free"
407
SF_USED = "used"
408
SF_ALLOCATABLE = "allocatable"
409

    
410
# Storage operations
411
SO_FIX_CONSISTENCY = "fix-consistency"
412

    
413
# Available fields per storage type
414
VALID_STORAGE_FIELDS = compat.UniqueFrozenset([
415
  SF_NAME,
416
  SF_TYPE,
417
  SF_SIZE,
418
  SF_USED,
419
  SF_FREE,
420
  SF_ALLOCATABLE,
421
  ])
422

    
423
MODIFIABLE_STORAGE_FIELDS = {
424
  ST_LVM_PV: frozenset([SF_ALLOCATABLE]),
425
  }
426

    
427
VALID_STORAGE_OPERATIONS = {
428
  ST_LVM_VG: frozenset([SO_FIX_CONSISTENCY]),
429
  }
430

    
431
# Local disk status
432
# Note: Code depends on LDS_OKAY < LDS_UNKNOWN < LDS_FAULTY
433
(LDS_OKAY,
434
 LDS_UNKNOWN,
435
 LDS_FAULTY) = range(1, 4)
436

    
437
LDS_NAMES = {
438
  LDS_OKAY: "ok",
439
  LDS_UNKNOWN: "unknown",
440
  LDS_FAULTY: "faulty",
441
}
442

    
443
# disk template types
444
DT_BLOCK = "blockdev"
445
DT_DISKLESS = "diskless"
446
DT_DRBD8 = "drbd"
447
DT_EXT = "ext"
448
DT_FILE = "file"
449
DT_PLAIN = "plain"
450
DT_RBD = "rbd"
451
DT_SHARED_FILE = "sharedfile"
452

    
453
# This is used to order determine the default disk template when the list
454
# of enabled disk templates is inferred from the current state of the cluster.
455
# This only happens on an upgrade from a version of Ganeti that did not
456
# support the 'enabled_disk_templates' so far.
457
DISK_TEMPLATE_PREFERENCE = [
458
  DT_DRBD8,
459
  DT_PLAIN,
460
  DT_FILE,
461
  DT_SHARED_FILE,
462
  DT_RBD,
463
  DT_BLOCK,
464
  DT_DISKLESS,
465
  DT_EXT
466
  ]
467

    
468
DISK_TEMPLATES = compat.UniqueFrozenset([
469
  DT_DISKLESS,
470
  DT_PLAIN,
471
  DT_DRBD8,
472
  DT_FILE,
473
  DT_SHARED_FILE,
474
  DT_BLOCK,
475
  DT_RBD,
476
  DT_EXT
477
  ])
478

    
479
# disk templates that are enabled by default
480
DEFAULT_ENABLED_DISK_TEMPLATES = [
481
  DT_DRBD8,
482
  DT_PLAIN,
483
  ]
484

    
485
# mapping of disk templates to storage types
486
DISK_TEMPLATES_STORAGE_TYPE = {
487
  DT_BLOCK: ST_BLOCK,
488
  DT_DISKLESS: ST_DISKLESS,
489
  DT_DRBD8: ST_LVM_VG,
490
  DT_EXT: ST_EXT,
491
  DT_FILE: ST_FILE,
492
  DT_PLAIN: ST_LVM_VG,
493
  DT_RBD: ST_RADOS,
494
  DT_SHARED_FILE: ST_FILE,
495
  }
496

    
497
# the set of network-mirrored disk templates
498
DTS_INT_MIRROR = compat.UniqueFrozenset([DT_DRBD8])
499

    
500
# the set of externally-mirrored disk templates (e.g. SAN, NAS)
501
DTS_EXT_MIRROR = compat.UniqueFrozenset([
502
  DT_DISKLESS, # 'trivially' externally mirrored
503
  DT_SHARED_FILE,
504
  DT_BLOCK,
505
  DT_RBD,
506
  DT_EXT,
507
  ])
508

    
509
# the set of non-lvm-based disk templates
510
DTS_NOT_LVM = compat.UniqueFrozenset([
511
  DT_DISKLESS,
512
  DT_FILE,
513
  DT_SHARED_FILE,
514
  DT_BLOCK,
515
  DT_RBD,
516
  DT_EXT,
517
  ])
518

    
519
# the set of disk templates which can be grown
520
DTS_GROWABLE = compat.UniqueFrozenset([
521
  DT_PLAIN,
522
  DT_DRBD8,
523
  DT_FILE,
524
  DT_SHARED_FILE,
525
  DT_RBD,
526
  DT_EXT,
527
  ])
528

    
529
# the set of disk templates that allow adoption
530
DTS_MAY_ADOPT = compat.UniqueFrozenset([
531
  DT_PLAIN,
532
  DT_BLOCK,
533
  ])
534

    
535
# the set of disk templates that *must* use adoption
536
DTS_MUST_ADOPT = compat.UniqueFrozenset([DT_BLOCK])
537

    
538
# the set of disk templates that allow migrations
539
DTS_MIRRORED = frozenset.union(DTS_INT_MIRROR, DTS_EXT_MIRROR)
540

    
541
# the set of file based disk templates
542
DTS_FILEBASED = compat.UniqueFrozenset([
543
  DT_FILE,
544
  DT_SHARED_FILE,
545
  ])
546

    
547
# the set of disk templates that can be moved by copying
548
# Note: a requirement is that they're not accessed externally or shared between
549
# nodes; in particular, sharedfile is not suitable.
550
DTS_COPYABLE = compat.UniqueFrozenset([
551
  DT_FILE,
552
  DT_PLAIN,
553
  ])
554

    
555
# the set of disk templates that are supported by exclusive_storage
556
DTS_EXCL_STORAGE = compat.UniqueFrozenset([DT_PLAIN])
557

    
558
# templates for which we don't perform checks on free space
559
DTS_NO_FREE_SPACE_CHECK = compat.UniqueFrozenset([
560
  DT_FILE,
561
  DT_SHARED_FILE,
562
  DT_RBD,
563
  DT_EXT,
564
  ])
565

    
566
# logical disk types
567
LD_LV = "lvm"
568
LD_DRBD8 = "drbd8"
569
LD_FILE = "file"
570
LD_BLOCKDEV = "blockdev"
571
LD_RBD = "rbd"
572
LD_EXT = "ext"
573
LOGICAL_DISK_TYPES = compat.UniqueFrozenset([
574
  LD_LV,
575
  LD_DRBD8,
576
  LD_FILE,
577
  LD_BLOCKDEV,
578
  LD_RBD,
579
  LD_EXT,
580
  ])
581

    
582
LDS_BLOCK = compat.UniqueFrozenset([
583
  LD_LV,
584
  LD_DRBD8,
585
  LD_BLOCKDEV,
586
  LD_RBD,
587
  LD_EXT,
588
  ])
589

    
590
# drbd constants
591
DRBD_HMAC_ALG = "md5"
592
DRBD_DEFAULT_NET_PROTOCOL = "C"
593
DRBD_MIGRATION_NET_PROTOCOL = "C"
594
DRBD_STATUS_FILE = "/proc/drbd"
595

    
596
#: Size of DRBD meta block device
597
DRBD_META_SIZE = 128
598

    
599
# drbd barrier types
600
DRBD_B_NONE = "n"
601
DRBD_B_DISK_BARRIERS = "b"
602
DRBD_B_DISK_DRAIN = "d"
603
DRBD_B_DISK_FLUSH = "f"
604

    
605
# Valid barrier combinations: "n" or any non-null subset of "bfd"
606
DRBD_VALID_BARRIER_OPT = compat.UniqueFrozenset([
607
  frozenset([DRBD_B_NONE]),
608
  frozenset([DRBD_B_DISK_BARRIERS]),
609
  frozenset([DRBD_B_DISK_DRAIN]),
610
  frozenset([DRBD_B_DISK_FLUSH]),
611
  frozenset([DRBD_B_DISK_DRAIN, DRBD_B_DISK_FLUSH]),
612
  frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_DRAIN]),
613
  frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_FLUSH]),
614
  frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_FLUSH, DRBD_B_DISK_DRAIN]),
615
  ])
616

    
617
# rbd tool command
618
RBD_CMD = "rbd"
619

    
620
# file backend driver
621
FD_LOOP = "loop"
622
FD_BLKTAP = "blktap"
623

    
624
# the set of drbd-like disk types
625
LDS_DRBD = compat.UniqueFrozenset([LD_DRBD8])
626

    
627
# disk access mode
628
DISK_RDONLY = "ro"
629
DISK_RDWR = "rw"
630
DISK_ACCESS_SET = compat.UniqueFrozenset([DISK_RDONLY, DISK_RDWR])
631

    
632
# disk replacement mode
633
REPLACE_DISK_PRI = "replace_on_primary"    # replace disks on primary
634
REPLACE_DISK_SEC = "replace_on_secondary"  # replace disks on secondary
635
REPLACE_DISK_CHG = "replace_new_secondary" # change secondary node
636
REPLACE_DISK_AUTO = "replace_auto"
637
REPLACE_MODES = compat.UniqueFrozenset([
638
  REPLACE_DISK_PRI,
639
  REPLACE_DISK_SEC,
640
  REPLACE_DISK_CHG,
641
  REPLACE_DISK_AUTO,
642
  ])
643

    
644
# Instance export mode
645
EXPORT_MODE_LOCAL = "local"
646
EXPORT_MODE_REMOTE = "remote"
647
EXPORT_MODES = compat.UniqueFrozenset([
648
  EXPORT_MODE_LOCAL,
649
  EXPORT_MODE_REMOTE,
650
  ])
651

    
652
# instance creation modes
653
INSTANCE_CREATE = "create"
654
INSTANCE_IMPORT = "import"
655
INSTANCE_REMOTE_IMPORT = "remote-import"
656
INSTANCE_CREATE_MODES = compat.UniqueFrozenset([
657
  INSTANCE_CREATE,
658
  INSTANCE_IMPORT,
659
  INSTANCE_REMOTE_IMPORT,
660
  ])
661

    
662
# Remote import/export handshake message and version
663
RIE_VERSION = 0
664
RIE_HANDSHAKE = "Hi, I'm Ganeti"
665

    
666
# Remote import/export certificate validity in seconds
667
RIE_CERT_VALIDITY = 24 * 60 * 60
668

    
669
# Overall timeout for establishing connection
670
RIE_CONNECT_TIMEOUT = 180
671

    
672
# Export only: how long to wait per connection attempt (seconds)
673
RIE_CONNECT_ATTEMPT_TIMEOUT = 20
674

    
675
# Export only: number of attempts to connect
676
RIE_CONNECT_RETRIES = 10
677

    
678
#: Give child process up to 5 seconds to exit after sending a signal
679
CHILD_LINGER_TIMEOUT = 5.0
680

    
681
FILE_DRIVER = compat.UniqueFrozenset([FD_LOOP, FD_BLKTAP])
682

    
683
# import/export config options
684
INISECT_EXP = "export"
685
INISECT_INS = "instance"
686
INISECT_HYP = "hypervisor"
687
INISECT_BEP = "backend"
688
INISECT_OSP = "os"
689

    
690
# dynamic device modification
691
DDM_ADD = "add"
692
DDM_MODIFY = "modify"
693
DDM_REMOVE = "remove"
694
DDMS_VALUES = compat.UniqueFrozenset([DDM_ADD, DDM_REMOVE])
695
DDMS_VALUES_WITH_MODIFY = (DDMS_VALUES | frozenset([
696
  DDM_MODIFY,
697
  ]))
698
# TODO: DDM_SWAP, DDM_MOVE?
699

    
700
# hotplug
701
HOTPLUG_DISK = "hotdisk"
702
HOTPLUG_NIC = "hotnic"
703
HOTPLUG_ADD = "hotadd"
704
HOTPLUG_REMOVE = "hotremove"
705

    
706
# common exit codes
707
EXIT_SUCCESS = 0
708
EXIT_FAILURE = 1
709
EXIT_NOTCLUSTER = 5
710
EXIT_NOTMASTER = 11
711
EXIT_NODESETUP_ERROR = 12
712
EXIT_CONFIRMATION = 13 # need user confirmation
713

    
714
#: Exit code for query operations with unknown fields
715
EXIT_UNKNOWN_FIELD = 14
716

    
717
# tags
718
TAG_CLUSTER = "cluster"
719
TAG_NODEGROUP = "nodegroup"
720
TAG_NODE = "node"
721
TAG_INSTANCE = "instance"
722
TAG_NETWORK = "network"
723
VALID_TAG_TYPES = compat.UniqueFrozenset([
724
  TAG_CLUSTER,
725
  TAG_NODEGROUP,
726
  TAG_NODE,
727
  TAG_INSTANCE,
728
  TAG_NETWORK,
729
  ])
730
MAX_TAG_LEN = 128
731
MAX_TAGS_PER_OBJ = 4096
732

    
733
# others
734
DEFAULT_BRIDGE = "xen-br0"
735
DEFAULT_OVS = "switch1"
736
CLASSIC_DRBD_SYNC_SPEED = 60 * 1024  # 60 MiB, expressed in KiB
737
IP4_ADDRESS_LOCALHOST = "127.0.0.1"
738
IP4_ADDRESS_ANY = "0.0.0.0"
739
IP6_ADDRESS_LOCALHOST = "::1"
740
IP6_ADDRESS_ANY = "::"
741
IP4_VERSION = 4
742
IP6_VERSION = 6
743
VALID_IP_VERSIONS = compat.UniqueFrozenset([IP4_VERSION, IP6_VERSION])
744
# for export to htools
745
IP4_FAMILY = socket.AF_INET
746
IP6_FAMILY = socket.AF_INET6
747

    
748
TCP_PING_TIMEOUT = 10
749
DEFAULT_VG = "xenvg"
750
DEFAULT_DRBD_HELPER = "/bin/true"
751
MIN_VG_SIZE = 20480
752
DEFAULT_MAC_PREFIX = "aa:00:00"
753
# default maximum instance wait time, in seconds.
754
DEFAULT_SHUTDOWN_TIMEOUT = 120
755
NODE_MAX_CLOCK_SKEW = 150
756
# Time for an intra-cluster disk transfer to wait for a connection
757
DISK_TRANSFER_CONNECT_TIMEOUT = 60
758
# Disk index separator
759
DISK_SEPARATOR = _autoconf.DISK_SEPARATOR
760
IP_COMMAND_PATH = _autoconf.IP_PATH
761

    
762
#: Key for job IDs in opcode result
763
JOB_IDS_KEY = "jobs"
764

    
765
# runparts results
766
(RUNPARTS_SKIP,
767
 RUNPARTS_RUN,
768
 RUNPARTS_ERR) = range(3)
769

    
770
RUNPARTS_STATUS = compat.UniqueFrozenset([
771
  RUNPARTS_SKIP,
772
  RUNPARTS_RUN,
773
  RUNPARTS_ERR,
774
  ])
775

    
776
# RPC constants
777
(RPC_ENCODING_NONE,
778
 RPC_ENCODING_ZLIB_BASE64) = range(2)
779

    
780
# Various time constants for the timeout table
781
RPC_TMO_URGENT = 60 # one minute
782
RPC_TMO_FAST = 5 * 60 # five minutes
783
RPC_TMO_NORMAL = 15 * 60 # 15 minutes
784
RPC_TMO_SLOW = 3600 # one hour
785
RPC_TMO_4HRS = 4 * 3600
786
RPC_TMO_1DAY = 86400
787

    
788
# Timeout for connecting to nodes (seconds)
789
RPC_CONNECT_TIMEOUT = 5
790

    
791
# os related constants
792
OS_SCRIPT_CREATE = "create"
793
OS_SCRIPT_IMPORT = "import"
794
OS_SCRIPT_EXPORT = "export"
795
OS_SCRIPT_RENAME = "rename"
796
OS_SCRIPT_VERIFY = "verify"
797
OS_SCRIPTS = compat.UniqueFrozenset([
798
  OS_SCRIPT_CREATE,
799
  OS_SCRIPT_IMPORT,
800
  OS_SCRIPT_EXPORT,
801
  OS_SCRIPT_RENAME,
802
  OS_SCRIPT_VERIFY,
803
  ])
804

    
805
OS_API_FILE = "ganeti_api_version"
806
OS_VARIANTS_FILE = "variants.list"
807
OS_PARAMETERS_FILE = "parameters.list"
808

    
809
OS_VALIDATE_PARAMETERS = "parameters"
810
OS_VALIDATE_CALLS = compat.UniqueFrozenset([OS_VALIDATE_PARAMETERS])
811

    
812
# External Storage (ES) related constants
813
ES_ACTION_CREATE = "create"
814
ES_ACTION_REMOVE = "remove"
815
ES_ACTION_GROW = "grow"
816
ES_ACTION_ATTACH = "attach"
817
ES_ACTION_DETACH = "detach"
818
ES_ACTION_SETINFO = "setinfo"
819
ES_ACTION_VERIFY = "verify"
820

    
821
ES_SCRIPT_CREATE = ES_ACTION_CREATE
822
ES_SCRIPT_REMOVE = ES_ACTION_REMOVE
823
ES_SCRIPT_GROW = ES_ACTION_GROW
824
ES_SCRIPT_ATTACH = ES_ACTION_ATTACH
825
ES_SCRIPT_DETACH = ES_ACTION_DETACH
826
ES_SCRIPT_SETINFO = ES_ACTION_SETINFO
827
ES_SCRIPT_VERIFY = ES_ACTION_VERIFY
828
ES_SCRIPTS = frozenset([
829
  ES_SCRIPT_CREATE,
830
  ES_SCRIPT_REMOVE,
831
  ES_SCRIPT_GROW,
832
  ES_SCRIPT_ATTACH,
833
  ES_SCRIPT_DETACH,
834
  ES_SCRIPT_SETINFO,
835
  ES_SCRIPT_VERIFY
836
  ])
837

    
838
ES_PARAMETERS_FILE = "parameters.list"
839

    
840
# reboot types
841
INSTANCE_REBOOT_SOFT = "soft"
842
INSTANCE_REBOOT_HARD = "hard"
843
INSTANCE_REBOOT_FULL = "full"
844

    
845
REBOOT_TYPES = compat.UniqueFrozenset([
846
  INSTANCE_REBOOT_SOFT,
847
  INSTANCE_REBOOT_HARD,
848
  INSTANCE_REBOOT_FULL,
849
  ])
850

    
851
# instance reboot behaviors
852
INSTANCE_REBOOT_ALLOWED = "reboot"
853
INSTANCE_REBOOT_EXIT = "exit"
854

    
855
REBOOT_BEHAVIORS = compat.UniqueFrozenset([
856
  INSTANCE_REBOOT_ALLOWED,
857
  INSTANCE_REBOOT_EXIT,
858
  ])
859

    
860
VTYPE_STRING = "string"
861
VTYPE_MAYBE_STRING = "maybe-string"
862
VTYPE_BOOL = "bool"
863
VTYPE_SIZE = "size" # size, in MiBs
864
VTYPE_INT = "int"
865
ENFORCEABLE_TYPES = compat.UniqueFrozenset([
866
  VTYPE_STRING,
867
  VTYPE_MAYBE_STRING,
868
  VTYPE_BOOL,
869
  VTYPE_SIZE,
870
  VTYPE_INT,
871
  ])
872

    
873
# Constant representing that the user does not specify any IP version
874
IFACE_NO_IP_VERSION_SPECIFIED = 0
875

    
876
VALID_SERIAL_SPEEDS = compat.UniqueFrozenset([
877
  75,
878
  110,
879
  300,
880
  600,
881
  1200,
882
  1800,
883
  2400,
884
  4800,
885
  9600,
886
  14400,
887
  19200,
888
  28800,
889
  38400,
890
  57600,
891
  115200,
892
  230400,
893
  345600,
894
  460800,
895
  ])
896

    
897
# HV parameter names (global namespace)
898
HV_BOOT_ORDER = "boot_order"
899
HV_CDROM_IMAGE_PATH = "cdrom_image_path"
900
HV_KVM_CDROM2_IMAGE_PATH = "cdrom2_image_path"
901
HV_KVM_FLOPPY_IMAGE_PATH = "floppy_image_path"
902
HV_NIC_TYPE = "nic_type"
903
HV_DISK_TYPE = "disk_type"
904
HV_KVM_CDROM_DISK_TYPE = "cdrom_disk_type"
905
HV_VNC_BIND_ADDRESS = "vnc_bind_address"
906
HV_VNC_PASSWORD_FILE = "vnc_password_file"
907
HV_VNC_TLS = "vnc_tls"
908
HV_VNC_X509 = "vnc_x509_path"
909
HV_VNC_X509_VERIFY = "vnc_x509_verify"
910
HV_KVM_SPICE_BIND = "spice_bind"
911
HV_KVM_SPICE_IP_VERSION = "spice_ip_version"
912
HV_KVM_SPICE_PASSWORD_FILE = "spice_password_file"
913
HV_KVM_SPICE_LOSSLESS_IMG_COMPR = "spice_image_compression"
914
HV_KVM_SPICE_JPEG_IMG_COMPR = "spice_jpeg_wan_compression"
915
HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR = "spice_zlib_glz_wan_compression"
916
HV_KVM_SPICE_STREAMING_VIDEO_DETECTION = "spice_streaming_video"
917
HV_KVM_SPICE_AUDIO_COMPR = "spice_playback_compression"
918
HV_KVM_SPICE_USE_TLS = "spice_use_tls"
919
HV_KVM_SPICE_TLS_CIPHERS = "spice_tls_ciphers"
920
HV_KVM_SPICE_USE_VDAGENT = "spice_use_vdagent"
921
HV_ACPI = "acpi"
922
HV_PAE = "pae"
923
HV_USE_BOOTLOADER = "use_bootloader"
924
HV_BOOTLOADER_ARGS = "bootloader_args"
925
HV_BOOTLOADER_PATH = "bootloader_path"
926
HV_KERNEL_ARGS = "kernel_args"
927
HV_KERNEL_PATH = "kernel_path"
928
HV_INITRD_PATH = "initrd_path"
929
HV_ROOT_PATH = "root_path"
930
HV_SERIAL_CONSOLE = "serial_console"
931
HV_SERIAL_SPEED = "serial_speed"
932
HV_USB_MOUSE = "usb_mouse"
933
HV_KEYMAP = "keymap"
934
HV_DEVICE_MODEL = "device_model"
935
HV_INIT_SCRIPT = "init_script"
936
HV_MIGRATION_PORT = "migration_port"
937
HV_MIGRATION_BANDWIDTH = "migration_bandwidth"
938
HV_MIGRATION_DOWNTIME = "migration_downtime"
939
HV_MIGRATION_MODE = "migration_mode"
940
HV_USE_LOCALTIME = "use_localtime"
941
HV_DISK_CACHE = "disk_cache"
942
HV_SECURITY_MODEL = "security_model"
943
HV_SECURITY_DOMAIN = "security_domain"
944
HV_KVM_FLAG = "kvm_flag"
945
HV_VHOST_NET = "vhost_net"
946
HV_KVM_USE_CHROOT = "use_chroot"
947
HV_CPU_MASK = "cpu_mask"
948
HV_MEM_PATH = "mem_path"
949
HV_PASSTHROUGH = "pci_pass"
950
HV_BLOCKDEV_PREFIX = "blockdev_prefix"
951
HV_REBOOT_BEHAVIOR = "reboot_behavior"
952
HV_CPU_TYPE = "cpu_type"
953
HV_CPU_CAP = "cpu_cap"
954
HV_CPU_WEIGHT = "cpu_weight"
955
HV_CPU_CORES = "cpu_cores"
956
HV_CPU_THREADS = "cpu_threads"
957
HV_CPU_SOCKETS = "cpu_sockets"
958
HV_SOUNDHW = "soundhw"
959
HV_USB_DEVICES = "usb_devices"
960
HV_VGA = "vga"
961
HV_KVM_EXTRA = "kvm_extra"
962
HV_KVM_MACHINE_VERSION = "machine_version"
963
HV_KVM_PATH = "kvm_path"
964
HV_VIF_TYPE = "vif_type"
965
HV_VIF_SCRIPT = "vif_script"
966
HV_XEN_CMD = "xen_cmd"
967

    
968

    
969
HVS_PARAMETER_TYPES = {
970
  HV_KVM_PATH: VTYPE_STRING,
971
  HV_BOOT_ORDER: VTYPE_STRING,
972
  HV_KVM_FLOPPY_IMAGE_PATH: VTYPE_STRING,
973
  HV_CDROM_IMAGE_PATH: VTYPE_STRING,
974
  HV_KVM_CDROM2_IMAGE_PATH: VTYPE_STRING,
975
  HV_NIC_TYPE: VTYPE_STRING,
976
  HV_DISK_TYPE: VTYPE_STRING,
977
  HV_KVM_CDROM_DISK_TYPE: VTYPE_STRING,
978
  HV_VNC_PASSWORD_FILE: VTYPE_STRING,
979
  HV_VNC_BIND_ADDRESS: VTYPE_STRING,
980
  HV_VNC_TLS: VTYPE_BOOL,
981
  HV_VNC_X509: VTYPE_STRING,
982
  HV_VNC_X509_VERIFY: VTYPE_BOOL,
983
  HV_KVM_SPICE_BIND: VTYPE_STRING,
984
  HV_KVM_SPICE_IP_VERSION: VTYPE_INT,
985
  HV_KVM_SPICE_PASSWORD_FILE: VTYPE_STRING,
986
  HV_KVM_SPICE_LOSSLESS_IMG_COMPR: VTYPE_STRING,
987
  HV_KVM_SPICE_JPEG_IMG_COMPR: VTYPE_STRING,
988
  HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR: VTYPE_STRING,
989
  HV_KVM_SPICE_STREAMING_VIDEO_DETECTION: VTYPE_STRING,
990
  HV_KVM_SPICE_AUDIO_COMPR: VTYPE_BOOL,
991
  HV_KVM_SPICE_USE_TLS: VTYPE_BOOL,
992
  HV_KVM_SPICE_TLS_CIPHERS: VTYPE_STRING,
993
  HV_KVM_SPICE_USE_VDAGENT: VTYPE_BOOL,
994
  HV_ACPI: VTYPE_BOOL,
995
  HV_PAE: VTYPE_BOOL,
996
  HV_USE_BOOTLOADER: VTYPE_BOOL,
997
  HV_BOOTLOADER_PATH: VTYPE_STRING,
998
  HV_BOOTLOADER_ARGS: VTYPE_STRING,
999
  HV_KERNEL_PATH: VTYPE_STRING,
1000
  HV_KERNEL_ARGS: VTYPE_STRING,
1001
  HV_INITRD_PATH: VTYPE_STRING,
1002
  HV_ROOT_PATH: VTYPE_MAYBE_STRING,
1003
  HV_SERIAL_CONSOLE: VTYPE_BOOL,
1004
  HV_SERIAL_SPEED: VTYPE_INT,
1005
  HV_USB_MOUSE: VTYPE_STRING,
1006
  HV_KEYMAP: VTYPE_STRING,
1007
  HV_DEVICE_MODEL: VTYPE_STRING,
1008
  HV_INIT_SCRIPT: VTYPE_STRING,
1009
  HV_MIGRATION_PORT: VTYPE_INT,
1010
  HV_MIGRATION_BANDWIDTH: VTYPE_INT,
1011
  HV_MIGRATION_DOWNTIME: VTYPE_INT,
1012
  HV_MIGRATION_MODE: VTYPE_STRING,
1013
  HV_USE_LOCALTIME: VTYPE_BOOL,
1014
  HV_DISK_CACHE: VTYPE_STRING,
1015
  HV_SECURITY_MODEL: VTYPE_STRING,
1016
  HV_SECURITY_DOMAIN: VTYPE_STRING,
1017
  HV_KVM_FLAG: VTYPE_STRING,
1018
  HV_VHOST_NET: VTYPE_BOOL,
1019
  HV_KVM_USE_CHROOT: VTYPE_BOOL,
1020
  HV_CPU_MASK: VTYPE_STRING,
1021
  HV_MEM_PATH: VTYPE_STRING,
1022
  HV_PASSTHROUGH: VTYPE_STRING,
1023
  HV_BLOCKDEV_PREFIX: VTYPE_STRING,
1024
  HV_REBOOT_BEHAVIOR: VTYPE_STRING,
1025
  HV_CPU_TYPE: VTYPE_STRING,
1026
  HV_CPU_CAP: VTYPE_INT,
1027
  HV_CPU_WEIGHT: VTYPE_INT,
1028
  HV_CPU_CORES: VTYPE_INT,
1029
  HV_CPU_THREADS: VTYPE_INT,
1030
  HV_CPU_SOCKETS: VTYPE_INT,
1031
  HV_SOUNDHW: VTYPE_STRING,
1032
  HV_USB_DEVICES: VTYPE_STRING,
1033
  HV_VGA: VTYPE_STRING,
1034
  HV_KVM_EXTRA: VTYPE_STRING,
1035
  HV_KVM_MACHINE_VERSION: VTYPE_STRING,
1036
  HV_VIF_TYPE: VTYPE_STRING,
1037
  HV_VIF_SCRIPT: VTYPE_STRING,
1038
  HV_XEN_CMD: VTYPE_STRING,
1039
  }
1040

    
1041
HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
1042

    
1043
HVS_PARAMETER_TITLES = {
1044
  HV_ACPI: "ACPI",
1045
  HV_BOOT_ORDER: "Boot_order",
1046
  HV_CDROM_IMAGE_PATH: "CDROM_image_path",
1047
  HV_DISK_TYPE: "Disk_type",
1048
  HV_INITRD_PATH: "Initrd_path",
1049
  HV_KERNEL_PATH: "Kernel_path",
1050
  HV_NIC_TYPE: "NIC_type",
1051
  HV_PAE: "PAE",
1052
  HV_VNC_BIND_ADDRESS: "VNC_bind_address",
1053
  HV_PASSTHROUGH: "pci_pass",
1054
  HV_CPU_TYPE: "cpu_type",
1055
  }
1056

    
1057
# Migration statuses
1058
HV_MIGRATION_COMPLETED = "completed"
1059
HV_MIGRATION_ACTIVE = "active"
1060
HV_MIGRATION_FAILED = "failed"
1061
HV_MIGRATION_CANCELLED = "cancelled"
1062

    
1063
HV_MIGRATION_VALID_STATUSES = compat.UniqueFrozenset([
1064
  HV_MIGRATION_COMPLETED,
1065
  HV_MIGRATION_ACTIVE,
1066
  HV_MIGRATION_FAILED,
1067
  HV_MIGRATION_CANCELLED,
1068
  ])
1069

    
1070
HV_MIGRATION_FAILED_STATUSES = compat.UniqueFrozenset([
1071
  HV_MIGRATION_FAILED,
1072
  HV_MIGRATION_CANCELLED,
1073
  ])
1074

    
1075
# KVM-specific statuses
1076
HV_KVM_MIGRATION_VALID_STATUSES = HV_MIGRATION_VALID_STATUSES
1077

    
1078
# Node info keys
1079
HV_NODEINFO_KEY_VERSION = "hv_version"
1080

    
1081
# Hypervisor state
1082
HVST_MEMORY_TOTAL = "mem_total"
1083
HVST_MEMORY_NODE = "mem_node"
1084
HVST_MEMORY_HV = "mem_hv"
1085
HVST_CPU_TOTAL = "cpu_total"
1086
HVST_CPU_NODE = "cpu_node"
1087

    
1088
HVST_DEFAULTS = {
1089
  HVST_MEMORY_TOTAL: 0,
1090
  HVST_MEMORY_NODE: 0,
1091
  HVST_MEMORY_HV: 0,
1092
  HVST_CPU_TOTAL: 1,
1093
  HVST_CPU_NODE: 1,
1094
  }
1095

    
1096
HVSTS_PARAMETER_TYPES = {
1097
  HVST_MEMORY_TOTAL: VTYPE_INT,
1098
  HVST_MEMORY_NODE: VTYPE_INT,
1099
  HVST_MEMORY_HV: VTYPE_INT,
1100
  HVST_CPU_TOTAL: VTYPE_INT,
1101
  HVST_CPU_NODE: VTYPE_INT,
1102
  }
1103

    
1104
HVSTS_PARAMETERS = frozenset(HVSTS_PARAMETER_TYPES.keys())
1105

    
1106
# Disk state
1107
DS_DISK_TOTAL = "disk_total"
1108
DS_DISK_RESERVED = "disk_reserved"
1109
DS_DISK_OVERHEAD = "disk_overhead"
1110

    
1111
DS_DEFAULTS = {
1112
  DS_DISK_TOTAL: 0,
1113
  DS_DISK_RESERVED: 0,
1114
  DS_DISK_OVERHEAD: 0,
1115
  }
1116

    
1117
DSS_PARAMETER_TYPES = {
1118
  DS_DISK_TOTAL: VTYPE_INT,
1119
  DS_DISK_RESERVED: VTYPE_INT,
1120
  DS_DISK_OVERHEAD: VTYPE_INT,
1121
  }
1122

    
1123
DSS_PARAMETERS = frozenset(DSS_PARAMETER_TYPES.keys())
1124
DS_VALID_TYPES = compat.UniqueFrozenset([LD_LV])
1125

    
1126
# Backend parameter names
1127
BE_MEMORY = "memory" # deprecated and replaced by max and min mem
1128
BE_MAXMEM = "maxmem"
1129
BE_MINMEM = "minmem"
1130
BE_VCPUS = "vcpus"
1131
BE_AUTO_BALANCE = "auto_balance"
1132
BE_ALWAYS_FAILOVER = "always_failover"
1133
BE_SPINDLE_USE = "spindle_use"
1134

    
1135
BES_PARAMETER_TYPES = {
1136
  BE_MAXMEM: VTYPE_SIZE,
1137
  BE_MINMEM: VTYPE_SIZE,
1138
  BE_VCPUS: VTYPE_INT,
1139
  BE_AUTO_BALANCE: VTYPE_BOOL,
1140
  BE_ALWAYS_FAILOVER: VTYPE_BOOL,
1141
  BE_SPINDLE_USE: VTYPE_INT,
1142
  }
1143

    
1144
BES_PARAMETER_TITLES = {
1145
  BE_AUTO_BALANCE: "Auto_balance",
1146
  BE_MAXMEM: "ConfigMaxMem",
1147
  BE_MINMEM: "ConfigMinMem",
1148
  BE_VCPUS: "ConfigVCPUs",
1149
  }
1150

    
1151
BES_PARAMETER_COMPAT = {
1152
  BE_MEMORY: VTYPE_SIZE,
1153
  }
1154
BES_PARAMETER_COMPAT.update(BES_PARAMETER_TYPES)
1155

    
1156
BES_PARAMETERS = frozenset(BES_PARAMETER_TYPES.keys())
1157

    
1158
# instance specs
1159
ISPEC_MEM_SIZE = "memory-size"
1160
ISPEC_CPU_COUNT = "cpu-count"
1161
ISPEC_DISK_COUNT = "disk-count"
1162
ISPEC_DISK_SIZE = "disk-size"
1163
ISPEC_NIC_COUNT = "nic-count"
1164
ISPEC_SPINDLE_USE = "spindle-use"
1165

    
1166
ISPECS_PARAMETER_TYPES = {
1167
  ISPEC_MEM_SIZE: VTYPE_INT,
1168
  ISPEC_CPU_COUNT: VTYPE_INT,
1169
  ISPEC_DISK_COUNT: VTYPE_INT,
1170
  ISPEC_DISK_SIZE: VTYPE_INT,
1171
  ISPEC_NIC_COUNT: VTYPE_INT,
1172
  ISPEC_SPINDLE_USE: VTYPE_INT,
1173
  }
1174

    
1175
ISPECS_PARAMETERS = frozenset(ISPECS_PARAMETER_TYPES.keys())
1176

    
1177
ISPECS_MINMAX = "minmax"
1178
ISPECS_MIN = "min"
1179
ISPECS_MAX = "max"
1180
ISPECS_STD = "std"
1181
IPOLICY_DTS = "disk-templates"
1182
IPOLICY_VCPU_RATIO = "vcpu-ratio"
1183
IPOLICY_SPINDLE_RATIO = "spindle-ratio"
1184

    
1185
ISPECS_MINMAX_KEYS = compat.UniqueFrozenset([
1186
  ISPECS_MIN,
1187
  ISPECS_MAX,
1188
  ])
1189

    
1190
IPOLICY_PARAMETERS = compat.UniqueFrozenset([
1191
  IPOLICY_VCPU_RATIO,
1192
  IPOLICY_SPINDLE_RATIO,
1193
  ])
1194

    
1195
IPOLICY_ALL_KEYS = (IPOLICY_PARAMETERS |
1196
                    frozenset([ISPECS_MINMAX, ISPECS_STD, IPOLICY_DTS]))
1197

    
1198
# Node parameter names
1199
ND_OOB_PROGRAM = "oob_program"
1200
ND_SPINDLE_COUNT = "spindle_count"
1201
ND_EXCLUSIVE_STORAGE = "exclusive_storage"
1202

    
1203
NDS_PARAMETER_TYPES = {
1204
  ND_OOB_PROGRAM: VTYPE_STRING,
1205
  ND_SPINDLE_COUNT: VTYPE_INT,
1206
  ND_EXCLUSIVE_STORAGE: VTYPE_BOOL,
1207
  }
1208

    
1209
NDS_PARAMETERS = frozenset(NDS_PARAMETER_TYPES.keys())
1210

    
1211
NDS_PARAMETER_TITLES = {
1212
  ND_OOB_PROGRAM: "OutOfBandProgram",
1213
  ND_SPINDLE_COUNT: "SpindleCount",
1214
  ND_EXCLUSIVE_STORAGE: "ExclusiveStorage",
1215
  }
1216

    
1217
# Logical Disks parameters
1218
LDP_RESYNC_RATE = "resync-rate"
1219
LDP_STRIPES = "stripes"
1220
LDP_BARRIERS = "disabled-barriers"
1221
LDP_NO_META_FLUSH = "disable-meta-flush"
1222
LDP_DEFAULT_METAVG = "default-metavg"
1223
LDP_DISK_CUSTOM = "disk-custom"
1224
LDP_NET_CUSTOM = "net-custom"
1225
LDP_PROTOCOL = "protocol"
1226
LDP_DYNAMIC_RESYNC = "dynamic-resync"
1227
LDP_PLAN_AHEAD = "c-plan-ahead"
1228
LDP_FILL_TARGET = "c-fill-target"
1229
LDP_DELAY_TARGET = "c-delay-target"
1230
LDP_MAX_RATE = "c-max-rate"
1231
LDP_MIN_RATE = "c-min-rate"
1232
LDP_POOL = "pool"
1233
DISK_LD_TYPES = {
1234
  LDP_RESYNC_RATE: VTYPE_INT,
1235
  LDP_STRIPES: VTYPE_INT,
1236
  LDP_BARRIERS: VTYPE_STRING,
1237
  LDP_NO_META_FLUSH: VTYPE_BOOL,
1238
  LDP_DEFAULT_METAVG: VTYPE_STRING,
1239
  LDP_DISK_CUSTOM: VTYPE_STRING,
1240
  LDP_NET_CUSTOM: VTYPE_STRING,
1241
  LDP_PROTOCOL: VTYPE_STRING,
1242
  LDP_DYNAMIC_RESYNC: VTYPE_BOOL,
1243
  LDP_PLAN_AHEAD: VTYPE_INT,
1244
  LDP_FILL_TARGET: VTYPE_INT,
1245
  LDP_DELAY_TARGET: VTYPE_INT,
1246
  LDP_MAX_RATE: VTYPE_INT,
1247
  LDP_MIN_RATE: VTYPE_INT,
1248
  LDP_POOL: VTYPE_STRING,
1249
  }
1250
DISK_LD_PARAMETERS = frozenset(DISK_LD_TYPES.keys())
1251

    
1252
# Disk template parameters (can be set/changed by the user via gnt-cluster and
1253
# gnt-group)
1254
DRBD_RESYNC_RATE = "resync-rate"
1255
DRBD_DATA_STRIPES = "data-stripes"
1256
DRBD_META_STRIPES = "meta-stripes"
1257
DRBD_DISK_BARRIERS = "disk-barriers"
1258
DRBD_META_BARRIERS = "meta-barriers"
1259
DRBD_DEFAULT_METAVG = "metavg"
1260
DRBD_DISK_CUSTOM = "disk-custom"
1261
DRBD_NET_CUSTOM = "net-custom"
1262
DRBD_PROTOCOL = "protocol"
1263
DRBD_DYNAMIC_RESYNC = "dynamic-resync"
1264
DRBD_PLAN_AHEAD = "c-plan-ahead"
1265
DRBD_FILL_TARGET = "c-fill-target"
1266
DRBD_DELAY_TARGET = "c-delay-target"
1267
DRBD_MAX_RATE = "c-max-rate"
1268
DRBD_MIN_RATE = "c-min-rate"
1269
LV_STRIPES = "stripes"
1270
RBD_POOL = "pool"
1271
DISK_DT_TYPES = {
1272
  DRBD_RESYNC_RATE: VTYPE_INT,
1273
  DRBD_DATA_STRIPES: VTYPE_INT,
1274
  DRBD_META_STRIPES: VTYPE_INT,
1275
  DRBD_DISK_BARRIERS: VTYPE_STRING,
1276
  DRBD_META_BARRIERS: VTYPE_BOOL,
1277
  DRBD_DEFAULT_METAVG: VTYPE_STRING,
1278
  DRBD_DISK_CUSTOM: VTYPE_STRING,
1279
  DRBD_NET_CUSTOM: VTYPE_STRING,
1280
  DRBD_PROTOCOL: VTYPE_STRING,
1281
  DRBD_DYNAMIC_RESYNC: VTYPE_BOOL,
1282
  DRBD_PLAN_AHEAD: VTYPE_INT,
1283
  DRBD_FILL_TARGET: VTYPE_INT,
1284
  DRBD_DELAY_TARGET: VTYPE_INT,
1285
  DRBD_MAX_RATE: VTYPE_INT,
1286
  DRBD_MIN_RATE: VTYPE_INT,
1287
  LV_STRIPES: VTYPE_INT,
1288
  RBD_POOL: VTYPE_STRING,
1289
  }
1290

    
1291
DISK_DT_PARAMETERS = frozenset(DISK_DT_TYPES.keys())
1292

    
1293
# OOB supported commands
1294
OOB_POWER_ON = "power-on"
1295
OOB_POWER_OFF = "power-off"
1296
OOB_POWER_CYCLE = "power-cycle"
1297
OOB_POWER_STATUS = "power-status"
1298
OOB_HEALTH = "health"
1299

    
1300
OOB_COMMANDS = compat.UniqueFrozenset([
1301
  OOB_POWER_ON,
1302
  OOB_POWER_OFF,
1303
  OOB_POWER_CYCLE,
1304
  OOB_POWER_STATUS,
1305
  OOB_HEALTH,
1306
  ])
1307

    
1308
OOB_POWER_STATUS_POWERED = "powered"
1309

    
1310
OOB_TIMEOUT = 60 # 60 seconds
1311
OOB_POWER_DELAY = 2.0 # 2 seconds
1312

    
1313
OOB_STATUS_OK = "OK"
1314
OOB_STATUS_WARNING = "WARNING"
1315
OOB_STATUS_CRITICAL = "CRITICAL"
1316
OOB_STATUS_UNKNOWN = "UNKNOWN"
1317

    
1318
OOB_STATUSES = compat.UniqueFrozenset([
1319
  OOB_STATUS_OK,
1320
  OOB_STATUS_WARNING,
1321
  OOB_STATUS_CRITICAL,
1322
  OOB_STATUS_UNKNOWN,
1323
  ])
1324

    
1325
# Instance Parameters Profile
1326
PP_DEFAULT = "default"
1327

    
1328
# NIC_* constants are used inside the ganeti config
1329
NIC_MODE = "mode"
1330
NIC_LINK = "link"
1331
NIC_VLAN = "vlan"
1332

    
1333
NIC_MODE_BRIDGED = "bridged"
1334
NIC_MODE_ROUTED = "routed"
1335
NIC_MODE_OVS = "openvswitch"
1336
NIC_IP_POOL = "pool"
1337

    
1338
NIC_VALID_MODES = compat.UniqueFrozenset([
1339
  NIC_MODE_BRIDGED,
1340
  NIC_MODE_ROUTED,
1341
  NIC_MODE_OVS,
1342
  ])
1343

    
1344
RESERVE_ACTION = "reserve"
1345
RELEASE_ACTION = "release"
1346

    
1347
NICS_PARAMETER_TYPES = {
1348
  NIC_MODE: VTYPE_STRING,
1349
  NIC_LINK: VTYPE_STRING,
1350
  NIC_VLAN: VTYPE_MAYBE_STRING,
1351
  }
1352

    
1353
NICS_PARAMETERS = frozenset(NICS_PARAMETER_TYPES.keys())
1354

    
1355
# IDISK_* constants are used in opcodes, to create/change disks
1356
IDISK_SIZE = "size"
1357
IDISK_SPINDLES = "spindles"
1358
IDISK_MODE = "mode"
1359
IDISK_ADOPT = "adopt"
1360
IDISK_VG = "vg"
1361
IDISK_METAVG = "metavg"
1362
IDISK_PROVIDER = "provider"
1363
IDISK_NAME = "name"
1364
IDISK_PARAMS_TYPES = {
1365
  IDISK_SIZE: VTYPE_SIZE,
1366
  IDISK_SPINDLES: VTYPE_INT,
1367
  IDISK_MODE: VTYPE_STRING,
1368
  IDISK_ADOPT: VTYPE_STRING,
1369
  IDISK_VG: VTYPE_STRING,
1370
  IDISK_METAVG: VTYPE_STRING,
1371
  IDISK_PROVIDER: VTYPE_STRING,
1372
  IDISK_NAME: VTYPE_MAYBE_STRING,
1373
  }
1374
IDISK_PARAMS = frozenset(IDISK_PARAMS_TYPES.keys())
1375

    
1376
# INIC_* constants are used in opcodes, to create/change nics
1377
INIC_MAC = "mac"
1378
INIC_IP = "ip"
1379
INIC_MODE = "mode"
1380
INIC_LINK = "link"
1381
INIC_NETWORK = "network"
1382
INIC_NAME = "name"
1383
INIC_VLAN = "vlan"
1384
INIC_PARAMS_TYPES = {
1385
  INIC_IP: VTYPE_MAYBE_STRING,
1386
  INIC_LINK: VTYPE_STRING,
1387
  INIC_MAC: VTYPE_STRING,
1388
  INIC_MODE: VTYPE_STRING,
1389
  INIC_NETWORK: VTYPE_MAYBE_STRING,
1390
  INIC_NAME: VTYPE_MAYBE_STRING,
1391
  INIC_VLAN: VTYPE_MAYBE_STRING,
1392
  }
1393
INIC_PARAMS = frozenset(INIC_PARAMS_TYPES.keys())
1394

    
1395
# Hypervisor constants
1396
HT_XEN_PVM = "xen-pvm"
1397
HT_FAKE = "fake"
1398
HT_XEN_HVM = "xen-hvm"
1399
HT_KVM = "kvm"
1400
HT_CHROOT = "chroot"
1401
HT_LXC = "lxc"
1402
HYPER_TYPES = compat.UniqueFrozenset([
1403
  HT_XEN_PVM,
1404
  HT_FAKE,
1405
  HT_XEN_HVM,
1406
  HT_KVM,
1407
  HT_CHROOT,
1408
  HT_LXC,
1409
  ])
1410
HTS_REQ_PORT = compat.UniqueFrozenset([HT_XEN_HVM, HT_KVM])
1411

    
1412
VNC_BASE_PORT = 5900
1413
VNC_DEFAULT_BIND_ADDRESS = IP4_ADDRESS_ANY
1414

    
1415
# NIC types
1416
HT_NIC_RTL8139 = "rtl8139"
1417
HT_NIC_NE2K_PCI = "ne2k_pci"
1418
HT_NIC_NE2K_ISA = "ne2k_isa"
1419
HT_NIC_I82551 = "i82551"
1420
HT_NIC_I85557B = "i82557b"
1421
HT_NIC_I8259ER = "i82559er"
1422
HT_NIC_PCNET = "pcnet"
1423
HT_NIC_E1000 = "e1000"
1424
HT_NIC_PARAVIRTUAL = HT_DISK_PARAVIRTUAL = "paravirtual"
1425

    
1426
HT_HVM_VALID_NIC_TYPES = compat.UniqueFrozenset([
1427
  HT_NIC_RTL8139,
1428
  HT_NIC_NE2K_PCI,
1429
  HT_NIC_E1000,
1430
  HT_NIC_NE2K_ISA,
1431
  HT_NIC_PARAVIRTUAL,
1432
  ])
1433
HT_KVM_VALID_NIC_TYPES = compat.UniqueFrozenset([
1434
  HT_NIC_RTL8139,
1435
  HT_NIC_NE2K_PCI,
1436
  HT_NIC_NE2K_ISA,
1437
  HT_NIC_I82551,
1438
  HT_NIC_I85557B,
1439
  HT_NIC_I8259ER,
1440
  HT_NIC_PCNET,
1441
  HT_NIC_E1000,
1442
  HT_NIC_PARAVIRTUAL,
1443
  ])
1444

    
1445
# Vif types
1446
# default vif type in xen-hvm
1447
HT_HVM_VIF_IOEMU = "ioemu"
1448
HT_HVM_VIF_VIF = "vif"
1449
HT_HVM_VALID_VIF_TYPES = compat.UniqueFrozenset([
1450
  HT_HVM_VIF_IOEMU,
1451
  HT_HVM_VIF_VIF,
1452
  ])
1453

    
1454
# Disk types
1455
HT_DISK_IOEMU = "ioemu"
1456
HT_DISK_IDE = "ide"
1457
HT_DISK_SCSI = "scsi"
1458
HT_DISK_SD = "sd"
1459
HT_DISK_MTD = "mtd"
1460
HT_DISK_PFLASH = "pflash"
1461

    
1462
HT_CACHE_DEFAULT = "default"
1463
HT_CACHE_NONE = "none"
1464
HT_CACHE_WTHROUGH = "writethrough"
1465
HT_CACHE_WBACK = "writeback"
1466
HT_VALID_CACHE_TYPES = compat.UniqueFrozenset([
1467
  HT_CACHE_DEFAULT,
1468
  HT_CACHE_NONE,
1469
  HT_CACHE_WTHROUGH,
1470
  HT_CACHE_WBACK,
1471
  ])
1472

    
1473
HT_HVM_VALID_DISK_TYPES = compat.UniqueFrozenset([
1474
  HT_DISK_PARAVIRTUAL,
1475
  HT_DISK_IOEMU,
1476
  ])
1477
HT_KVM_VALID_DISK_TYPES = compat.UniqueFrozenset([
1478
  HT_DISK_PARAVIRTUAL,
1479
  HT_DISK_IDE,
1480
  HT_DISK_SCSI,
1481
  HT_DISK_SD,
1482
  HT_DISK_MTD,
1483
  HT_DISK_PFLASH,
1484
  ])
1485

    
1486
# Mouse types:
1487
HT_MOUSE_MOUSE = "mouse"
1488
HT_MOUSE_TABLET = "tablet"
1489

    
1490
HT_KVM_VALID_MOUSE_TYPES = compat.UniqueFrozenset([
1491
  HT_MOUSE_MOUSE,
1492
  HT_MOUSE_TABLET,
1493
  ])
1494

    
1495
# Boot order
1496
HT_BO_FLOPPY = "floppy"
1497
HT_BO_CDROM = "cdrom"
1498
HT_BO_DISK = "disk"
1499
HT_BO_NETWORK = "network"
1500

    
1501
HT_KVM_VALID_BO_TYPES = compat.UniqueFrozenset([
1502
  HT_BO_FLOPPY,
1503
  HT_BO_CDROM,
1504
  HT_BO_DISK,
1505
  HT_BO_NETWORK,
1506
  ])
1507

    
1508
# SPICE lossless image compression options
1509
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ = "auto_glz"
1510
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ = "auto_lz"
1511
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC = "quic"
1512
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ = "glz"
1513
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ = "lz"
1514
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF = "off"
1515

    
1516
HT_KVM_SPICE_VALID_LOSSLESS_IMG_COMPR_OPTIONS = compat.UniqueFrozenset([
1517
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ,
1518
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ,
1519
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC,
1520
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ,
1521
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ,
1522
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF,
1523
  ])
1524

    
1525
# SPICE lossy image compression options (valid for both jpeg and zlib-glz)
1526
HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO = "auto"
1527
HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER = "never"
1528
HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS = "always"
1529

    
1530
HT_KVM_SPICE_VALID_LOSSY_IMG_COMPR_OPTIONS = compat.UniqueFrozenset([
1531
  HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO,
1532
  HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER,
1533
  HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS,
1534
  ])
1535

    
1536
# SPICE video stream detection
1537
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF = "off"
1538
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL = "all"
1539
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER = "filter"
1540

    
1541
HT_KVM_SPICE_VALID_VIDEO_STREAM_DETECTION_OPTIONS = compat.UniqueFrozenset([
1542
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF,
1543
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL,
1544
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER,
1545
  ])
1546

    
1547
# Security models
1548
HT_SM_NONE = "none"
1549
HT_SM_USER = "user"
1550
HT_SM_POOL = "pool"
1551

    
1552
HT_KVM_VALID_SM_TYPES = compat.UniqueFrozenset([
1553
  HT_SM_NONE,
1554
  HT_SM_USER,
1555
  HT_SM_POOL,
1556
  ])
1557

    
1558
# Kvm flag values
1559
HT_KVM_ENABLED = "enabled"
1560
HT_KVM_DISABLED = "disabled"
1561

    
1562
HT_KVM_FLAG_VALUES = compat.UniqueFrozenset([HT_KVM_ENABLED, HT_KVM_DISABLED])
1563

    
1564
# Migration type
1565
HT_MIGRATION_LIVE = "live"
1566
HT_MIGRATION_NONLIVE = "non-live"
1567
HT_MIGRATION_MODES = compat.UniqueFrozenset([
1568
  HT_MIGRATION_LIVE,
1569
  HT_MIGRATION_NONLIVE,
1570
  ])
1571

    
1572
# Cluster Verify steps
1573
VERIFY_NPLUSONE_MEM = "nplusone_mem"
1574
VERIFY_OPTIONAL_CHECKS = compat.UniqueFrozenset([VERIFY_NPLUSONE_MEM])
1575

    
1576
# Cluster Verify error classes
1577
CV_TCLUSTER = "cluster"
1578
CV_TGROUP = "group"
1579
CV_TNODE = "node"
1580
CV_TINSTANCE = "instance"
1581

    
1582
# Cluster Verify error codes and documentation
1583
CV_ECLUSTERCFG = \
1584
  (CV_TCLUSTER, "ECLUSTERCFG", "Cluster configuration verification failure")
1585
CV_ECLUSTERCERT = \
1586
  (CV_TCLUSTER, "ECLUSTERCERT",
1587
   "Cluster certificate files verification failure")
1588
CV_ECLUSTERFILECHECK = \
1589
  (CV_TCLUSTER, "ECLUSTERFILECHECK",
1590
   "Cluster configuration verification failure")
1591
CV_ECLUSTERDANGLINGNODES = \
1592
  (CV_TNODE, "ECLUSTERDANGLINGNODES",
1593
   "Some nodes belong to non-existing groups")
1594
CV_ECLUSTERDANGLINGINST = \
1595
  (CV_TNODE, "ECLUSTERDANGLINGINST",
1596
   "Some instances have a non-existing primary node")
1597
CV_EGROUPDIFFERENTPVSIZE = \
1598
  (CV_TGROUP, "EGROUPDIFFERENTPVSIZE", "PVs in the group have different sizes")
1599
CV_EINSTANCEBADNODE = \
1600
  (CV_TINSTANCE, "EINSTANCEBADNODE",
1601
   "Instance marked as running lives on an offline node")
1602
CV_EINSTANCEDOWN = \
1603
  (CV_TINSTANCE, "EINSTANCEDOWN", "Instance not running on its primary node")
1604
CV_EINSTANCELAYOUT = \
1605
  (CV_TINSTANCE, "EINSTANCELAYOUT", "Instance has multiple secondary nodes")
1606
CV_EINSTANCEMISSINGDISK = \
1607
  (CV_TINSTANCE, "EINSTANCEMISSINGDISK", "Missing volume on an instance")
1608
CV_EINSTANCEFAULTYDISK = \
1609
  (CV_TINSTANCE, "EINSTANCEFAULTYDISK",
1610
   "Impossible to retrieve status for a disk")
1611
CV_EINSTANCEWRONGNODE = \
1612
  (CV_TINSTANCE, "EINSTANCEWRONGNODE", "Instance running on the wrong node")
1613
CV_EINSTANCESPLITGROUPS = \
1614
  (CV_TINSTANCE, "EINSTANCESPLITGROUPS",
1615
   "Instance with primary and secondary nodes in different groups")
1616
CV_EINSTANCEPOLICY = \
1617
  (CV_TINSTANCE, "EINSTANCEPOLICY",
1618
   "Instance does not meet policy")
1619
CV_EINSTANCEUNSUITABLENODE = \
1620
  (CV_TINSTANCE, "EINSTANCEUNSUITABLENODE",
1621
   "Instance running on nodes that are not suitable for it")
1622
CV_EINSTANCEMISSINGCFGPARAMETER = \
1623
  (CV_TINSTANCE, "EINSTANCEMISSINGCFGPARAMETER",
1624
   "A configuration parameter for an instance is missing")
1625
CV_ENODEDRBD = \
1626
  (CV_TNODE, "ENODEDRBD", "Error parsing the DRBD status file")
1627
CV_ENODEDRBDVERSION = \
1628
  (CV_TNODE, "ENODEDRBDVERSION", "DRBD version mismatch within a node group")
1629
CV_ENODEDRBDHELPER = \
1630
  (CV_TNODE, "ENODEDRBDHELPER", "Error caused by the DRBD helper")
1631
CV_ENODEFILECHECK = \
1632
  (CV_TNODE, "ENODEFILECHECK",
1633
   "Error retrieving the checksum of the node files")
1634
CV_ENODEHOOKS = \
1635
  (CV_TNODE, "ENODEHOOKS", "Communication failure in hooks execution")
1636
CV_ENODEHV = \
1637
  (CV_TNODE, "ENODEHV", "Hypervisor parameters verification failure")
1638
CV_ENODELVM = \
1639
  (CV_TNODE, "ENODELVM", "LVM-related node error")
1640
CV_ENODEN1 = \
1641
  (CV_TNODE, "ENODEN1", "Not enough memory to accommodate instance failovers")
1642
CV_ENODENET = \
1643
  (CV_TNODE, "ENODENET", "Network-related node error")
1644
CV_ENODEOS = \
1645
  (CV_TNODE, "ENODEOS", "OS-related node error")
1646
CV_ENODEORPHANINSTANCE = \
1647
  (CV_TNODE, "ENODEORPHANINSTANCE", "Unknown intance running on a node")
1648
CV_ENODEORPHANLV = \
1649
  (CV_TNODE, "ENODEORPHANLV", "Unknown LVM logical volume")
1650
CV_ENODERPC = \
1651
  (CV_TNODE, "ENODERPC",
1652
   "Error during connection to the primary node of an instance")
1653
CV_ENODESSH = \
1654
  (CV_TNODE, "ENODESSH", "SSH-related node error")
1655
CV_ENODEVERSION = \
1656
  (CV_TNODE, "ENODEVERSION",
1657
   "Protocol version mismatch or Ganeti version mismatch")
1658
CV_ENODESETUP = \
1659
  (CV_TNODE, "ENODESETUP", "Node setup error")
1660
CV_ENODETIME = \
1661
  (CV_TNODE, "ENODETIME", "Node returned invalid time")
1662
CV_ENODEOOBPATH = \
1663
  (CV_TNODE, "ENODEOOBPATH", "Invalid Out Of Band path")
1664
CV_ENODEUSERSCRIPTS = \
1665
  (CV_TNODE, "ENODEUSERSCRIPTS", "User scripts not present or not executable")
1666
CV_ENODEFILESTORAGEPATHS = \
1667
  (CV_TNODE, "ENODEFILESTORAGEPATHS", "Detected bad file storage paths")
1668
CV_ENODEFILESTORAGEPATHUNUSABLE = \
1669
  (CV_TNODE, "ENODEFILESTORAGEPATHUNUSABLE", "File storage path unusable")
1670

    
1671
CV_ALL_ECODES = compat.UniqueFrozenset([
1672
  CV_ECLUSTERCFG,
1673
  CV_ECLUSTERCERT,
1674
  CV_ECLUSTERFILECHECK,
1675
  CV_ECLUSTERDANGLINGNODES,
1676
  CV_ECLUSTERDANGLINGINST,
1677
  CV_EINSTANCEBADNODE,
1678
  CV_EINSTANCEDOWN,
1679
  CV_EINSTANCELAYOUT,
1680
  CV_EINSTANCEMISSINGDISK,
1681
  CV_EINSTANCEFAULTYDISK,
1682
  CV_EINSTANCEWRONGNODE,
1683
  CV_EINSTANCESPLITGROUPS,
1684
  CV_EINSTANCEPOLICY,
1685
  CV_ENODEDRBD,
1686
  CV_ENODEDRBDHELPER,
1687
  CV_ENODEFILECHECK,
1688
  CV_ENODEHOOKS,
1689
  CV_ENODEHV,
1690
  CV_ENODELVM,
1691
  CV_ENODEN1,
1692
  CV_ENODENET,
1693
  CV_ENODEOS,
1694
  CV_ENODEORPHANINSTANCE,
1695
  CV_ENODEORPHANLV,
1696
  CV_ENODERPC,
1697
  CV_ENODESSH,
1698
  CV_ENODEVERSION,
1699
  CV_ENODESETUP,
1700
  CV_ENODETIME,
1701
  CV_ENODEOOBPATH,
1702
  CV_ENODEUSERSCRIPTS,
1703
  CV_ENODEFILESTORAGEPATHS,
1704
  CV_ENODEFILESTORAGEPATHUNUSABLE,
1705
  ])
1706

    
1707
CV_ALL_ECODES_STRINGS = \
1708
  compat.UniqueFrozenset(estr for (_, estr, _) in CV_ALL_ECODES)
1709

    
1710
# Node verify constants
1711
NV_BRIDGES = "bridges"
1712
NV_DRBDHELPER = "drbd-helper"
1713
NV_DRBDVERSION = "drbd-version"
1714
NV_DRBDLIST = "drbd-list"
1715
NV_EXCLUSIVEPVS = "exclusive-pvs"
1716
NV_FILELIST = "filelist"
1717
NV_ACCEPTED_STORAGE_PATHS = "allowed-file-storage-paths"
1718
NV_FILE_STORAGE_PATH = "file-storage-path"
1719
NV_SHARED_FILE_STORAGE_PATH = "shared-file-storage-path"
1720
NV_HVINFO = "hvinfo"
1721
NV_HVPARAMS = "hvparms"
1722
NV_HYPERVISOR = "hypervisor"
1723
NV_INSTANCELIST = "instancelist"
1724
NV_LVLIST = "lvlist"
1725
NV_MASTERIP = "master-ip"
1726
NV_NODELIST = "nodelist"
1727
NV_NODENETTEST = "node-net-test"
1728
NV_NODESETUP = "nodesetup"
1729
NV_OOB_PATHS = "oob-paths"
1730
NV_OSLIST = "oslist"
1731
NV_PVLIST = "pvlist"
1732
NV_TIME = "time"
1733
NV_USERSCRIPTS = "user-scripts"
1734
NV_VERSION = "version"
1735
NV_VGLIST = "vglist"
1736
NV_VMNODES = "vmnodes"
1737

    
1738
# Instance status
1739
INSTST_RUNNING = "running"
1740
INSTST_ADMINDOWN = "ADMIN_down"
1741
INSTST_ADMINOFFLINE = "ADMIN_offline"
1742
INSTST_NODEOFFLINE = "ERROR_nodeoffline"
1743
INSTST_NODEDOWN = "ERROR_nodedown"
1744
INSTST_WRONGNODE = "ERROR_wrongnode"
1745
INSTST_ERRORUP = "ERROR_up"
1746
INSTST_ERRORDOWN = "ERROR_down"
1747
INSTST_ALL = compat.UniqueFrozenset([
1748
  INSTST_RUNNING,
1749
  INSTST_ADMINDOWN,
1750
  INSTST_ADMINOFFLINE,
1751
  INSTST_NODEOFFLINE,
1752
  INSTST_NODEDOWN,
1753
  INSTST_WRONGNODE,
1754
  INSTST_ERRORUP,
1755
  INSTST_ERRORDOWN,
1756
  ])
1757

    
1758
# Admin states
1759
ADMINST_UP = "up"
1760
ADMINST_DOWN = "down"
1761
ADMINST_OFFLINE = "offline"
1762
ADMINST_ALL = compat.UniqueFrozenset([
1763
  ADMINST_UP,
1764
  ADMINST_DOWN,
1765
  ADMINST_OFFLINE,
1766
  ])
1767

    
1768
# Node roles
1769
NR_REGULAR = "R"
1770
NR_MASTER = "M"
1771
NR_MCANDIDATE = "C"
1772
NR_DRAINED = "D"
1773
NR_OFFLINE = "O"
1774
NR_ALL = compat.UniqueFrozenset([
1775
  NR_REGULAR,
1776
  NR_MASTER,
1777
  NR_MCANDIDATE,
1778
  NR_DRAINED,
1779
  NR_OFFLINE,
1780
  ])
1781

    
1782
# SSL certificate check constants (in days)
1783
SSL_CERT_EXPIRATION_WARN = 30
1784
SSL_CERT_EXPIRATION_ERROR = 7
1785

    
1786
# Allocator framework constants
1787
IALLOCATOR_VERSION = 2
1788
IALLOCATOR_DIR_IN = "in"
1789
IALLOCATOR_DIR_OUT = "out"
1790
VALID_IALLOCATOR_DIRECTIONS = compat.UniqueFrozenset([
1791
  IALLOCATOR_DIR_IN,
1792
  IALLOCATOR_DIR_OUT,
1793
  ])
1794
IALLOCATOR_MODE_ALLOC = "allocate"
1795
IALLOCATOR_MODE_RELOC = "relocate"
1796
IALLOCATOR_MODE_CHG_GROUP = "change-group"
1797
IALLOCATOR_MODE_NODE_EVAC = "node-evacuate"
1798
IALLOCATOR_MODE_MULTI_ALLOC = "multi-allocate"
1799
VALID_IALLOCATOR_MODES = compat.UniqueFrozenset([
1800
  IALLOCATOR_MODE_ALLOC,
1801
  IALLOCATOR_MODE_RELOC,
1802
  IALLOCATOR_MODE_CHG_GROUP,
1803
  IALLOCATOR_MODE_NODE_EVAC,
1804
  IALLOCATOR_MODE_MULTI_ALLOC,
1805
  ])
1806
IALLOCATOR_SEARCH_PATH = _autoconf.IALLOCATOR_SEARCH_PATH
1807
DEFAULT_IALLOCATOR_SHORTCUT = "."
1808

    
1809
IALLOCATOR_NEVAC_PRI = "primary-only"
1810
IALLOCATOR_NEVAC_SEC = "secondary-only"
1811
IALLOCATOR_NEVAC_ALL = "all"
1812
IALLOCATOR_NEVAC_MODES = compat.UniqueFrozenset([
1813
  IALLOCATOR_NEVAC_PRI,
1814
  IALLOCATOR_NEVAC_SEC,
1815
  IALLOCATOR_NEVAC_ALL,
1816
  ])
1817

    
1818
# Node evacuation
1819
NODE_EVAC_PRI = "primary-only"
1820
NODE_EVAC_SEC = "secondary-only"
1821
NODE_EVAC_ALL = "all"
1822
NODE_EVAC_MODES = compat.UniqueFrozenset([
1823
  NODE_EVAC_PRI,
1824
  NODE_EVAC_SEC,
1825
  NODE_EVAC_ALL,
1826
  ])
1827

    
1828
# Job queue
1829
JOB_QUEUE_VERSION = 1
1830
JOB_QUEUE_SIZE_HARD_LIMIT = 5000
1831
JOB_QUEUE_FILES_PERMS = 0640
1832

    
1833
JOB_ID_TEMPLATE = r"\d+"
1834
JOB_FILE_RE = re.compile(r"^job-(%s)$" % JOB_ID_TEMPLATE)
1835

    
1836
# unchanged job return
1837
JOB_NOTCHANGED = "nochange"
1838

    
1839
# Job status
1840
JOB_STATUS_QUEUED = "queued"
1841
JOB_STATUS_WAITING = "waiting"
1842
JOB_STATUS_CANCELING = "canceling"
1843
JOB_STATUS_RUNNING = "running"
1844
JOB_STATUS_CANCELED = "canceled"
1845
JOB_STATUS_SUCCESS = "success"
1846
JOB_STATUS_ERROR = "error"
1847
JOBS_PENDING = compat.UniqueFrozenset([
1848
  JOB_STATUS_QUEUED,
1849
  JOB_STATUS_WAITING,
1850
  JOB_STATUS_CANCELING,
1851
  ])
1852
JOBS_FINALIZED = compat.UniqueFrozenset([
1853
  JOB_STATUS_CANCELED,
1854
  JOB_STATUS_SUCCESS,
1855
  JOB_STATUS_ERROR,
1856
  ])
1857
JOB_STATUS_ALL = compat.UniqueFrozenset([
1858
  JOB_STATUS_RUNNING,
1859
  ]) | JOBS_PENDING | JOBS_FINALIZED
1860

    
1861
# OpCode status
1862
# not yet finalized
1863
OP_STATUS_QUEUED = "queued"
1864
OP_STATUS_WAITING = "waiting"
1865
OP_STATUS_CANCELING = "canceling"
1866
OP_STATUS_RUNNING = "running"
1867
# finalized
1868
OP_STATUS_CANCELED = "canceled"
1869
OP_STATUS_SUCCESS = "success"
1870
OP_STATUS_ERROR = "error"
1871
OPS_FINALIZED = compat.UniqueFrozenset([
1872
  OP_STATUS_CANCELED,
1873
  OP_STATUS_SUCCESS,
1874
  OP_STATUS_ERROR,
1875
  ])
1876

    
1877
# OpCode priority
1878
OP_PRIO_LOWEST = +19
1879
OP_PRIO_HIGHEST = -20
1880

    
1881
OP_PRIO_LOW = +10
1882
OP_PRIO_NORMAL = 0
1883
OP_PRIO_HIGH = -10
1884

    
1885
OP_PRIO_SUBMIT_VALID = compat.UniqueFrozenset([
1886
  OP_PRIO_LOW,
1887
  OP_PRIO_NORMAL,
1888
  OP_PRIO_HIGH,
1889
  ])
1890

    
1891
OP_PRIO_DEFAULT = OP_PRIO_NORMAL
1892

    
1893
# Lock recalculate mode
1894
LOCKS_REPLACE = "replace"
1895
LOCKS_APPEND = "append"
1896

    
1897
# Lock timeout (sum) before we should go into blocking acquire (still
1898
# can be reset by priority change); computed as max time (10 hours)
1899
# before we should actually go into blocking acquire given that we
1900
# start from default priority level; in seconds
1901
# TODO
1902
LOCK_ATTEMPTS_TIMEOUT = 10 * 3600 / (OP_PRIO_DEFAULT - OP_PRIO_HIGHEST)
1903
LOCK_ATTEMPTS_MAXWAIT = 15.0
1904
LOCK_ATTEMPTS_MINWAIT = 1.0
1905

    
1906
# Execution log types
1907
ELOG_MESSAGE = "message"
1908
ELOG_REMOTE_IMPORT = "remote-import"
1909
ELOG_JQUEUE_TEST = "jqueue-test"
1910

    
1911
# /etc/hosts modification
1912
ETC_HOSTS_ADD = "add"
1913
ETC_HOSTS_REMOVE = "remove"
1914

    
1915
# Job queue test
1916
JQT_MSGPREFIX = "TESTMSG="
1917
JQT_EXPANDNAMES = "expandnames"
1918
JQT_EXEC = "exec"
1919
JQT_LOGMSG = "logmsg"
1920
JQT_STARTMSG = "startmsg"
1921
JQT_ALL = compat.UniqueFrozenset([
1922
  JQT_EXPANDNAMES,
1923
  JQT_EXEC,
1924
  JQT_LOGMSG,
1925
  JQT_STARTMSG,
1926
  ])
1927

    
1928
# Query resources
1929
QR_CLUSTER = "cluster"
1930
QR_INSTANCE = "instance"
1931
QR_NODE = "node"
1932
QR_LOCK = "lock"
1933
QR_GROUP = "group"
1934
QR_OS = "os"
1935
QR_JOB = "job"
1936
QR_EXPORT = "export"
1937
QR_NETWORK = "network"
1938
QR_EXTSTORAGE = "extstorage"
1939

    
1940
#: List of resources which can be queried using L{opcodes.OpQuery}
1941
QR_VIA_OP = compat.UniqueFrozenset([
1942
  QR_CLUSTER,
1943
  QR_INSTANCE,
1944
  QR_NODE,
1945
  QR_GROUP,
1946
  QR_OS,
1947
  QR_EXPORT,
1948
  QR_NETWORK,
1949
  QR_EXTSTORAGE,
1950
  ])
1951

    
1952
#: List of resources which can be queried using Local UniX Interface
1953
QR_VIA_LUXI = QR_VIA_OP.union([
1954
  QR_LOCK,
1955
  QR_JOB,
1956
  ])
1957

    
1958
#: List of resources which can be queried using RAPI
1959
QR_VIA_RAPI = QR_VIA_LUXI
1960

    
1961
# Query field types
1962
QFT_UNKNOWN = "unknown"
1963
QFT_TEXT = "text"
1964
QFT_BOOL = "bool"
1965
QFT_NUMBER = "number"
1966
QFT_UNIT = "unit"
1967
QFT_TIMESTAMP = "timestamp"
1968
QFT_OTHER = "other"
1969

    
1970
#: All query field types
1971
QFT_ALL = compat.UniqueFrozenset([
1972
  QFT_UNKNOWN,
1973
  QFT_TEXT,
1974
  QFT_BOOL,
1975
  QFT_NUMBER,
1976
  QFT_UNIT,
1977
  QFT_TIMESTAMP,
1978
  QFT_OTHER,
1979
  ])
1980

    
1981
# Query result field status (don't change or reuse values as they're used by
1982
# clients)
1983
#: Normal field status
1984
RS_NORMAL = 0
1985
#: Unknown field
1986
RS_UNKNOWN = 1
1987
#: No data (e.g. RPC error), can be used instead of L{RS_OFFLINE}
1988
RS_NODATA = 2
1989
#: Value unavailable/unsupported for item; if this field is supported
1990
#: but we cannot get the data for the moment, RS_NODATA or
1991
#: RS_OFFLINE should be used
1992
RS_UNAVAIL = 3
1993
#: Resource marked offline
1994
RS_OFFLINE = 4
1995

    
1996
RS_ALL = compat.UniqueFrozenset([
1997
  RS_NORMAL,
1998
  RS_UNKNOWN,
1999
  RS_NODATA,
2000
  RS_UNAVAIL,
2001
  RS_OFFLINE,
2002
  ])
2003

    
2004
#: Dictionary with special field cases and their verbose/terse formatting
2005
RSS_DESCRIPTION = {
2006
  RS_UNKNOWN: ("(unknown)", "??"),
2007
  RS_NODATA: ("(nodata)", "?"),
2008
  RS_OFFLINE: ("(offline)", "*"),
2009
  RS_UNAVAIL: ("(unavail)", "-"),
2010
  }
2011

    
2012
# max dynamic devices
2013
MAX_NICS = 8
2014
MAX_DISKS = 16
2015

    
2016
# SSCONF file prefix
2017
SSCONF_FILEPREFIX = "ssconf_"
2018
# SSCONF keys
2019
SS_CLUSTER_NAME = "cluster_name"
2020
SS_CLUSTER_TAGS = "cluster_tags"
2021
SS_FILE_STORAGE_DIR = "file_storage_dir"
2022
SS_SHARED_FILE_STORAGE_DIR = "shared_file_storage_dir"
2023
SS_MASTER_CANDIDATES = "master_candidates"
2024
SS_MASTER_CANDIDATES_IPS = "master_candidates_ips"
2025
SS_MASTER_IP = "master_ip"
2026
SS_MASTER_NETDEV = "master_netdev"
2027
SS_MASTER_NETMASK = "master_netmask"
2028
SS_MASTER_NODE = "master_node"
2029
SS_NODE_LIST = "node_list"
2030
SS_NODE_PRIMARY_IPS = "node_primary_ips"
2031
SS_NODE_SECONDARY_IPS = "node_secondary_ips"
2032
SS_OFFLINE_NODES = "offline_nodes"
2033
SS_ONLINE_NODES = "online_nodes"
2034
SS_PRIMARY_IP_FAMILY = "primary_ip_family"
2035
SS_INSTANCE_LIST = "instance_list"
2036
SS_RELEASE_VERSION = "release_version"
2037
SS_HYPERVISOR_LIST = "hypervisor_list"
2038
SS_MAINTAIN_NODE_HEALTH = "maintain_node_health"
2039
SS_UID_POOL = "uid_pool"
2040
SS_NODEGROUPS = "nodegroups"
2041
SS_NETWORKS = "networks"
2042

    
2043
# This is not a complete SSCONF key, but the prefix for the hypervisor keys
2044
SS_HVPARAMS_PREF = "hvparams_"
2045

    
2046
# Hvparams keys:
2047
SS_HVPARAMS_XEN_PVM = SS_HVPARAMS_PREF + HT_XEN_PVM
2048
SS_HVPARAMS_XEN_FAKE = SS_HVPARAMS_PREF + HT_FAKE
2049
SS_HVPARAMS_XEN_HVM = SS_HVPARAMS_PREF + HT_XEN_HVM
2050
SS_HVPARAMS_XEN_KVM = SS_HVPARAMS_PREF + HT_KVM
2051
SS_HVPARAMS_XEN_CHROOT = SS_HVPARAMS_PREF + HT_CHROOT
2052
SS_HVPARAMS_XEN_LXC = SS_HVPARAMS_PREF + HT_LXC
2053

    
2054
VALID_SS_HVPARAMS_KEYS = compat.UniqueFrozenset([
2055
  SS_HVPARAMS_XEN_PVM,
2056
  SS_HVPARAMS_XEN_FAKE,
2057
  SS_HVPARAMS_XEN_HVM,
2058
  SS_HVPARAMS_XEN_KVM,
2059
  SS_HVPARAMS_XEN_CHROOT,
2060
  SS_HVPARAMS_XEN_LXC,
2061
  ])
2062

    
2063
SS_FILE_PERMS = 0444
2064

    
2065
# cluster wide default parameters
2066
DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM
2067

    
2068
HVC_DEFAULTS = {
2069
  HT_XEN_PVM: {
2070
    HV_USE_BOOTLOADER: False,
2071
    HV_BOOTLOADER_PATH: XEN_BOOTLOADER,
2072
    HV_BOOTLOADER_ARGS: "",
2073
    HV_KERNEL_PATH: XEN_KERNEL,
2074
    HV_INITRD_PATH: "",
2075
    HV_ROOT_PATH: "/dev/xvda1",
2076
    HV_KERNEL_ARGS: "ro",
2077
    HV_MIGRATION_PORT: 8002,
2078
    HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
2079
    HV_BLOCKDEV_PREFIX: "sd",
2080
    HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
2081
    HV_CPU_MASK: CPU_PINNING_ALL,
2082
    HV_CPU_CAP: 0,
2083
    HV_CPU_WEIGHT: 256,
2084
    HV_VIF_SCRIPT: "",
2085
    HV_XEN_CMD: XEN_CMD_XM,
2086
    },
2087
  HT_XEN_HVM: {
2088
    HV_BOOT_ORDER: "cd",
2089
    HV_CDROM_IMAGE_PATH: "",
2090
    HV_NIC_TYPE: HT_NIC_RTL8139,
2091
    HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
2092
    HV_VNC_BIND_ADDRESS: IP4_ADDRESS_ANY,
2093
    HV_VNC_PASSWORD_FILE: pathutils.VNC_PASSWORD_FILE,
2094
    HV_ACPI: True,
2095
    HV_PAE: True,
2096
    HV_KERNEL_PATH: "/usr/lib/xen/boot/hvmloader",
2097
    HV_DEVICE_MODEL: "/usr/lib/xen/bin/qemu-dm",
2098
    HV_MIGRATION_PORT: 8002,
2099
    HV_MIGRATION_MODE: HT_MIGRATION_NONLIVE,
2100
    HV_USE_LOCALTIME: False,
2101
    HV_BLOCKDEV_PREFIX: "hd",
2102
    HV_PASSTHROUGH: "",
2103
    HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
2104
    HV_CPU_MASK: CPU_PINNING_ALL,
2105
    HV_CPU_CAP: 0,
2106
    HV_CPU_WEIGHT: 256,
2107
    HV_VIF_TYPE: HT_HVM_VIF_IOEMU,
2108
    HV_VIF_SCRIPT: "",
2109
    HV_XEN_CMD: XEN_CMD_XM,
2110
    },
2111
  HT_KVM: {
2112
    HV_KVM_PATH: KVM_PATH,
2113
    HV_KERNEL_PATH: KVM_KERNEL,
2114
    HV_INITRD_PATH: "",
2115
    HV_KERNEL_ARGS: "ro",
2116
    HV_ROOT_PATH: "/dev/vda1",
2117
    HV_ACPI: True,
2118
    HV_SERIAL_CONSOLE: True,
2119
    HV_SERIAL_SPEED: 38400,
2120
    HV_VNC_BIND_ADDRESS: "",
2121
    HV_VNC_TLS: False,
2122
    HV_VNC_X509: "",
2123
    HV_VNC_X509_VERIFY: False,
2124
    HV_VNC_PASSWORD_FILE: "",
2125
    HV_KVM_SPICE_BIND: "",
2126
    HV_KVM_SPICE_IP_VERSION: IFACE_NO_IP_VERSION_SPECIFIED,
2127
    HV_KVM_SPICE_PASSWORD_FILE: "",
2128
    HV_KVM_SPICE_LOSSLESS_IMG_COMPR: "",
2129
    HV_KVM_SPICE_JPEG_IMG_COMPR: "",
2130
    HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR: "",
2131
    HV_KVM_SPICE_STREAMING_VIDEO_DETECTION: "",
2132
    HV_KVM_SPICE_AUDIO_COMPR: True,
2133
    HV_KVM_SPICE_USE_TLS: False,
2134
    HV_KVM_SPICE_TLS_CIPHERS: OPENSSL_CIPHERS,
2135
    HV_KVM_SPICE_USE_VDAGENT: True,
2136
    HV_KVM_FLOPPY_IMAGE_PATH: "",
2137
    HV_CDROM_IMAGE_PATH: "",
2138
    HV_KVM_CDROM2_IMAGE_PATH: "",
2139
    HV_BOOT_ORDER: HT_BO_DISK,
2140
    HV_NIC_TYPE: HT_NIC_PARAVIRTUAL,
2141
    HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
2142
    HV_KVM_CDROM_DISK_TYPE: "",
2143
    HV_USB_MOUSE: "",
2144
    HV_KEYMAP: "",
2145
    HV_MIGRATION_PORT: 8102,
2146
    HV_MIGRATION_BANDWIDTH: 32, # MiB/s
2147
    HV_MIGRATION_DOWNTIME: 30,  # ms
2148
    HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
2149
    HV_USE_LOCALTIME: False,
2150
    HV_DISK_CACHE: HT_CACHE_DEFAULT,
2151
    HV_SECURITY_MODEL: HT_SM_NONE,
2152
    HV_SECURITY_DOMAIN: "",
2153
    HV_KVM_FLAG: "",
2154
    HV_VHOST_NET: False,
2155
    HV_KVM_USE_CHROOT: False,
2156
    HV_MEM_PATH: "",
2157
    HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
2158
    HV_CPU_MASK: CPU_PINNING_ALL,
2159
    HV_CPU_TYPE: "",
2160
    HV_CPU_CORES: 0,
2161
    HV_CPU_THREADS: 0,
2162
    HV_CPU_SOCKETS: 0,
2163
    HV_SOUNDHW: "",
2164
    HV_USB_DEVICES: "",
2165
    HV_VGA: "",
2166
    HV_KVM_EXTRA: "",
2167
    HV_KVM_MACHINE_VERSION: "",
2168
    },
2169
  HT_FAKE: {
2170
    HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
2171
  },
2172
  HT_CHROOT: {
2173
    HV_INIT_SCRIPT: "/ganeti-chroot",
2174
    },
2175
  HT_LXC: {
2176
    HV_CPU_MASK: "",
2177
    },
2178
  }
2179

    
2180
HVC_GLOBALS = compat.UniqueFrozenset([
2181
  HV_MIGRATION_PORT,
2182
  HV_MIGRATION_BANDWIDTH,
2183
  HV_MIGRATION_MODE,
2184
  HV_XEN_CMD,
2185
  ])
2186

    
2187
BEC_DEFAULTS = {
2188
  BE_MINMEM: 128,
2189
  BE_MAXMEM: 128,
2190
  BE_VCPUS: 1,
2191
  BE_AUTO_BALANCE: True,
2192
  BE_ALWAYS_FAILOVER: False,
2193
  BE_SPINDLE_USE: 1,
2194
  }
2195

    
2196
NDC_DEFAULTS = {
2197
  ND_OOB_PROGRAM: "",
2198
  ND_SPINDLE_COUNT: 1,
2199
  ND_EXCLUSIVE_STORAGE: False,
2200
  }
2201

    
2202
NDC_GLOBALS = compat.UniqueFrozenset([
2203
  ND_EXCLUSIVE_STORAGE,
2204
  ])
2205

    
2206
DISK_LD_DEFAULTS = {
2207
  LD_DRBD8: {
2208
    LDP_RESYNC_RATE: CLASSIC_DRBD_SYNC_SPEED,
2209
    LDP_BARRIERS: _autoconf.DRBD_BARRIERS,
2210
    LDP_NO_META_FLUSH: _autoconf.DRBD_NO_META_FLUSH,
2211
    LDP_DEFAULT_METAVG: DEFAULT_VG,
2212
    LDP_DISK_CUSTOM: "",
2213
    LDP_NET_CUSTOM: "",
2214
    LDP_PROTOCOL: DRBD_DEFAULT_NET_PROTOCOL,
2215
    LDP_DYNAMIC_RESYNC: False,
2216

    
2217
    # The default values for the DRBD dynamic resync speed algorithm
2218
    # are taken from the drbsetup 8.3.11 man page, except for
2219
    # c-plan-ahead (that we don't need to set to 0, because we have a
2220
    # separate option to enable it) and for c-max-rate, that we cap to
2221
    # the default value for the static resync rate.
2222
    LDP_PLAN_AHEAD: 20, # ds
2223
    LDP_FILL_TARGET: 0, # sectors
2224
    LDP_DELAY_TARGET: 1, # ds
2225
    LDP_MAX_RATE: CLASSIC_DRBD_SYNC_SPEED, # KiB/s
2226
    LDP_MIN_RATE: 4 * 1024, # KiB/s
2227
    },
2228
  LD_LV: {
2229
    LDP_STRIPES: _autoconf.LVM_STRIPECOUNT
2230
    },
2231
  LD_FILE: {},
2232
  LD_BLOCKDEV: {},
2233
  LD_RBD: {
2234
    LDP_POOL: "rbd"
2235
    },
2236
  LD_EXT: {},
2237
  }
2238

    
2239
# readability shortcuts
2240
_LV_DEFAULTS = DISK_LD_DEFAULTS[LD_LV]
2241
_DRBD_DEFAULTS = DISK_LD_DEFAULTS[LD_DRBD8]
2242

    
2243
DISK_DT_DEFAULTS = {
2244
  DT_PLAIN: {
2245
    LV_STRIPES: DISK_LD_DEFAULTS[LD_LV][LDP_STRIPES],
2246
    },
2247
  DT_DRBD8: {
2248
    DRBD_RESYNC_RATE: _DRBD_DEFAULTS[LDP_RESYNC_RATE],
2249
    DRBD_DATA_STRIPES: _LV_DEFAULTS[LDP_STRIPES],
2250
    DRBD_META_STRIPES: _LV_DEFAULTS[LDP_STRIPES],
2251
    DRBD_DISK_BARRIERS: _DRBD_DEFAULTS[LDP_BARRIERS],
2252
    DRBD_META_BARRIERS: _DRBD_DEFAULTS[LDP_NO_META_FLUSH],
2253
    DRBD_DEFAULT_METAVG: _DRBD_DEFAULTS[LDP_DEFAULT_METAVG],
2254
    DRBD_DISK_CUSTOM: _DRBD_DEFAULTS[LDP_DISK_CUSTOM],
2255
    DRBD_NET_CUSTOM: _DRBD_DEFAULTS[LDP_NET_CUSTOM],
2256
    DRBD_PROTOCOL: _DRBD_DEFAULTS[LDP_PROTOCOL],
2257
    DRBD_DYNAMIC_RESYNC: _DRBD_DEFAULTS[LDP_DYNAMIC_RESYNC],
2258
    DRBD_PLAN_AHEAD: _DRBD_DEFAULTS[LDP_PLAN_AHEAD],
2259
    DRBD_FILL_TARGET: _DRBD_DEFAULTS[LDP_FILL_TARGET],
2260
    DRBD_DELAY_TARGET: _DRBD_DEFAULTS[LDP_DELAY_TARGET],
2261
    DRBD_MAX_RATE: _DRBD_DEFAULTS[LDP_MAX_RATE],
2262
    DRBD_MIN_RATE: _DRBD_DEFAULTS[LDP_MIN_RATE],
2263
    },
2264
  DT_DISKLESS: {},
2265
  DT_FILE: {},
2266
  DT_SHARED_FILE: {},
2267
  DT_BLOCK: {},
2268
  DT_RBD: {
2269
    RBD_POOL: DISK_LD_DEFAULTS[LD_RBD][LDP_POOL]
2270
    },
2271
  DT_EXT: {},
2272
  }
2273

    
2274
# we don't want to export the shortcuts
2275
del _LV_DEFAULTS, _DRBD_DEFAULTS
2276

    
2277
NICC_DEFAULTS = {
2278
  NIC_MODE: NIC_MODE_BRIDGED,
2279
  NIC_LINK: DEFAULT_BRIDGE,
2280
  NIC_VLAN: VALUE_HS_NOTHING,
2281
  }
2282

    
2283
# All of the following values are quite arbitrarily - there are no
2284
# "good" defaults, these must be customised per-site
2285
ISPECS_MINMAX_DEFAULTS = {
2286
  ISPECS_MIN: {
2287
    ISPEC_MEM_SIZE: 128,
2288
    ISPEC_CPU_COUNT: 1,
2289
    ISPEC_DISK_COUNT: 1,
2290
    ISPEC_DISK_SIZE: 1024,
2291
    ISPEC_NIC_COUNT: 1,
2292
    ISPEC_SPINDLE_USE: 1,
2293
    },
2294
  ISPECS_MAX: {
2295
    ISPEC_MEM_SIZE: 32768,
2296
    ISPEC_CPU_COUNT: 8,
2297
    ISPEC_DISK_COUNT: MAX_DISKS,
2298
    ISPEC_DISK_SIZE: 1024 * 1024,
2299
    ISPEC_NIC_COUNT: MAX_NICS,
2300
    ISPEC_SPINDLE_USE: 12,
2301
    },
2302
  }
2303
IPOLICY_DEFAULTS = {
2304
  ISPECS_MINMAX: [ISPECS_MINMAX_DEFAULTS],
2305
  ISPECS_STD: {
2306
    ISPEC_MEM_SIZE: 128,
2307
    ISPEC_CPU_COUNT: 1,
2308
    ISPEC_DISK_COUNT: 1,
2309
    ISPEC_DISK_SIZE: 1024,
2310
    ISPEC_NIC_COUNT: 1,
2311
    ISPEC_SPINDLE_USE: 1,
2312
    },
2313
  IPOLICY_DTS: list(DISK_TEMPLATES),
2314
  IPOLICY_VCPU_RATIO: 4.0,
2315
  IPOLICY_SPINDLE_RATIO: 32.0,
2316
  }
2317

    
2318
MASTER_POOL_SIZE_DEFAULT = 10
2319

    
2320
# Exclusive storage:
2321
# Error margin used to compare physical disks
2322
PART_MARGIN = .01
2323
# Space reserved when creating instance disks
2324
PART_RESERVED = .02
2325

    
2326
CONFD_PROTOCOL_VERSION = 1
2327

    
2328
CONFD_REQ_PING = 0
2329
CONFD_REQ_NODE_ROLE_BYNAME = 1
2330
CONFD_REQ_NODE_PIP_BY_INSTANCE_IP = 2
2331
CONFD_REQ_CLUSTER_MASTER = 3
2332
CONFD_REQ_NODE_PIP_LIST = 4
2333
CONFD_REQ_MC_PIP_LIST = 5
2334
CONFD_REQ_INSTANCES_IPS_LIST = 6
2335
CONFD_REQ_NODE_DRBD = 7
2336
CONFD_REQ_NODE_INSTANCES = 8
2337

    
2338
# Confd request query fields. These are used to narrow down queries.
2339
# These must be strings rather than integers, because json-encoding
2340
# converts them to strings anyway, as they're used as dict-keys.
2341
CONFD_REQQ_LINK = "0"
2342
CONFD_REQQ_IP = "1"
2343
CONFD_REQQ_IPLIST = "2"
2344
CONFD_REQQ_FIELDS = "3"
2345

    
2346
CONFD_REQFIELD_NAME = "0"
2347
CONFD_REQFIELD_IP = "1"
2348
CONFD_REQFIELD_MNODE_PIP = "2"
2349

    
2350
CONFD_REQS = compat.UniqueFrozenset([
2351
  CONFD_REQ_PING,
2352
  CONFD_REQ_NODE_ROLE_BYNAME,
2353
  CONFD_REQ_NODE_PIP_BY_INSTANCE_IP,
2354
  CONFD_REQ_CLUSTER_MASTER,
2355
  CONFD_REQ_NODE_PIP_LIST,
2356
  CONFD_REQ_MC_PIP_LIST,
2357
  CONFD_REQ_INSTANCES_IPS_LIST,
2358
  CONFD_REQ_NODE_DRBD,
2359
  ])
2360

    
2361
CONFD_REPL_STATUS_OK = 0
2362
CONFD_REPL_STATUS_ERROR = 1
2363
CONFD_REPL_STATUS_NOTIMPLEMENTED = 2
2364

    
2365
CONFD_REPL_STATUSES = compat.UniqueFrozenset([
2366
  CONFD_REPL_STATUS_OK,
2367
  CONFD_REPL_STATUS_ERROR,
2368
  CONFD_REPL_STATUS_NOTIMPLEMENTED,
2369
  ])
2370

    
2371
(CONFD_NODE_ROLE_MASTER,
2372
 CONFD_NODE_ROLE_CANDIDATE,
2373
 CONFD_NODE_ROLE_OFFLINE,
2374
 CONFD_NODE_ROLE_DRAINED,
2375
 CONFD_NODE_ROLE_REGULAR,
2376
 ) = range(5)
2377

    
2378
# A few common errors for confd
2379
CONFD_ERROR_UNKNOWN_ENTRY = 1
2380
CONFD_ERROR_INTERNAL = 2
2381
CONFD_ERROR_ARGUMENT = 3
2382

    
2383
# Each request is "salted" by the current timestamp.
2384
# This constants decides how many seconds of skew to accept.
2385
# TODO: make this a default and allow the value to be more configurable
2386
CONFD_MAX_CLOCK_SKEW = 2 * NODE_MAX_CLOCK_SKEW
2387

    
2388
# When we haven't reloaded the config for more than this amount of
2389
# seconds, we force a test to see if inotify is betraying us. Using a
2390
# prime number to ensure we get less chance of 'same wakeup' with
2391
# other processes.
2392
CONFD_CONFIG_RELOAD_TIMEOUT = 17
2393

    
2394
# If we receive more than one update in this amount of microseconds,
2395
# we move to polling every RATELIMIT seconds, rather than relying on
2396
# inotify, to be able to serve more requests.
2397
CONFD_CONFIG_RELOAD_RATELIMIT = 250000
2398

    
2399
# Magic number prepended to all confd queries.
2400
# This allows us to distinguish different types of confd protocols and handle
2401
# them. For example by changing this we can move the whole payload to be
2402
# compressed, or move away from json.
2403
CONFD_MAGIC_FOURCC = "plj0"
2404

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

    
2410
# Timeout in seconds to expire pending query request in the confd client
2411
# library. We don't actually expect any answer more than 10 seconds after we
2412
# sent a request.
2413
CONFD_CLIENT_EXPIRE_TIMEOUT = 10
2414

    
2415
# Maximum UDP datagram size.
2416
# On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
2417
# On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
2418
#   (assuming we can't use jumbo frames)
2419
# We just set this to 60K, which should be enough
2420
MAX_UDP_DATA_SIZE = 61440
2421

    
2422
# User-id pool minimum/maximum acceptable user-ids.
2423
UIDPOOL_UID_MIN = 0
2424
UIDPOOL_UID_MAX = 2 ** 32 - 1 # Assuming 32 bit user-ids
2425

    
2426
# Name or path of the pgrep command
2427
PGREP = "pgrep"
2428

    
2429
# Name of the node group that gets created at cluster init or upgrade
2430
INITIAL_NODE_GROUP_NAME = "default"
2431

    
2432
# Possible values for NodeGroup.alloc_policy
2433
ALLOC_POLICY_PREFERRED = "preferred"
2434
ALLOC_POLICY_LAST_RESORT = "last_resort"
2435
ALLOC_POLICY_UNALLOCABLE = "unallocable"
2436
VALID_ALLOC_POLICIES = [
2437
  ALLOC_POLICY_PREFERRED,
2438
  ALLOC_POLICY_LAST_RESORT,
2439
  ALLOC_POLICY_UNALLOCABLE,
2440
  ]
2441

    
2442
# Temporary external/shared storage parameters
2443
BLOCKDEV_DRIVER_MANUAL = "manual"
2444

    
2445
# qemu-img path, required for ovfconverter
2446
QEMUIMG_PATH = _autoconf.QEMUIMG_PATH
2447

    
2448
# Whether htools was enabled at compilation time
2449
HTOOLS = _autoconf.HTOOLS
2450
# The hail iallocator
2451
IALLOC_HAIL = "hail"
2452

    
2453
# Fake opcodes for functions that have hooks attached to them via
2454
# backend.RunLocalHooks
2455
FAKE_OP_MASTER_TURNUP = "OP_CLUSTER_IP_TURNUP"
2456
FAKE_OP_MASTER_TURNDOWN = "OP_CLUSTER_IP_TURNDOWN"
2457

    
2458
# SSH key types
2459
SSHK_RSA = "rsa"
2460
SSHK_DSA = "dsa"
2461
SSHK_ALL = compat.UniqueFrozenset([SSHK_RSA, SSHK_DSA])
2462

    
2463
# SSH authorized key types
2464
SSHAK_RSA = "ssh-rsa"
2465
SSHAK_DSS = "ssh-dss"
2466
SSHAK_ALL = compat.UniqueFrozenset([SSHAK_RSA, SSHAK_DSS])
2467

    
2468
# SSH setup
2469
SSHS_CLUSTER_NAME = "cluster_name"
2470
SSHS_SSH_HOST_KEY = "ssh_host_key"
2471
SSHS_SSH_ROOT_KEY = "ssh_root_key"
2472
SSHS_NODE_DAEMON_CERTIFICATE = "node_daemon_certificate"
2473

    
2474
#: Key files for SSH daemon
2475
SSH_DAEMON_KEYFILES = {
2476
  SSHK_RSA: (pathutils.SSH_HOST_RSA_PRIV, pathutils.SSH_HOST_RSA_PUB),
2477
  SSHK_DSA: (pathutils.SSH_HOST_DSA_PRIV, pathutils.SSH_HOST_DSA_PUB),
2478
  }
2479

    
2480
# Node daemon setup
2481
NDS_CLUSTER_NAME = "cluster_name"
2482
NDS_NODE_DAEMON_CERTIFICATE = "node_daemon_certificate"
2483
NDS_SSCONF = "ssconf"
2484
NDS_START_NODE_DAEMON = "start_node_daemon"
2485

    
2486
# Path generating random UUID
2487
RANDOM_UUID_FILE = "/proc/sys/kernel/random/uuid"
2488

    
2489
# Regex string for verifying a UUID
2490
UUID_REGEX = "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
2491

    
2492
# Auto-repair tag prefixes
2493
AUTO_REPAIR_TAG_PREFIX = "ganeti:watcher:autorepair:"
2494
AUTO_REPAIR_TAG_ENABLED = AUTO_REPAIR_TAG_PREFIX
2495
AUTO_REPAIR_TAG_SUSPENDED = AUTO_REPAIR_TAG_ENABLED + "suspend:"
2496
AUTO_REPAIR_TAG_PENDING = AUTO_REPAIR_TAG_PREFIX + "pending:"
2497
AUTO_REPAIR_TAG_RESULT = AUTO_REPAIR_TAG_PREFIX + "result:"
2498

    
2499
# Auto-repair levels
2500
AUTO_REPAIR_FIX_STORAGE = "fix-storage"
2501
AUTO_REPAIR_MIGRATE = "migrate"
2502
AUTO_REPAIR_FAILOVER = "failover"
2503
AUTO_REPAIR_REINSTALL = "reinstall"
2504
AUTO_REPAIR_ALL_TYPES = [
2505
  AUTO_REPAIR_FIX_STORAGE,
2506
  AUTO_REPAIR_MIGRATE,
2507
  AUTO_REPAIR_FAILOVER,
2508
  AUTO_REPAIR_REINSTALL,
2509
]
2510

    
2511
# Auto-repair results
2512
AUTO_REPAIR_SUCCESS = "success"
2513
AUTO_REPAIR_FAILURE = "failure"
2514
AUTO_REPAIR_ENOPERM = "enoperm"
2515
AUTO_REPAIR_ALL_RESULTS = frozenset([
2516
    AUTO_REPAIR_SUCCESS,
2517
    AUTO_REPAIR_FAILURE,
2518
    AUTO_REPAIR_ENOPERM,
2519
])
2520

    
2521
# The version identifier for builtin data collectors
2522
BUILTIN_DATA_COLLECTOR_VERSION = "B"
2523

    
2524
# The reason trail opcode parameter name
2525
OPCODE_REASON = "reason"
2526

    
2527
# The source reasons for the execution of an OpCode
2528
OPCODE_REASON_SRC_CLIENT = "gnt:client"
2529
OPCODE_REASON_SRC_NODED = "gnt:daemon:noded"
2530
OPCODE_REASON_SRC_OPCODE = "gnt:opcode"
2531
OPCODE_REASON_SRC_RLIB2 = "gnt:library:rlib2"
2532
OPCODE_REASON_SRC_USER = "gnt:user"
2533

    
2534
OPCODE_REASON_SOURCES = compat.UniqueFrozenset([
2535
  OPCODE_REASON_SRC_CLIENT,
2536
  OPCODE_REASON_SRC_NODED,
2537
  OPCODE_REASON_SRC_OPCODE,
2538
  OPCODE_REASON_SRC_RLIB2,
2539
  OPCODE_REASON_SRC_USER,
2540
  ])
2541

    
2542
DISKSTATS_FILE = "/proc/diskstats"
2543

    
2544
# Do not re-export imported modules
2545
del re, _vcsversion, _autoconf, socket, pathutils, compat