Statistics
| Branch: | Tag: | Revision:

root / lib / constants.py @ 38ef0c2c

History | View | Annotate | Download (54.7 kB)

1
#
2
#
3

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

    
21

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

    
24
import re
25
import socket
26

    
27
from ganeti import _autoconf
28
from ganeti import _vcsversion
29

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

    
40

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

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

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

58
  Returns: int representing version number
59

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

    
68

    
69
def SplitVersion(version):
70
  """Splits version number stored in an int.
71

72
  Returns: tuple; (major, minor, revision)
73

74
  """
75
  assert isinstance(version, int)
76

    
77
  (major, remainder) = divmod(version, 1000000)
78
  (minor, revision) = divmod(remainder, 10000)
79

    
80
  return (major, minor, revision)
81

    
82

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

    
88
#: RPC protocol version
89
PROTOCOL_VERSION = BuildVersion(CONFIG_MAJOR, CONFIG_MINOR, 0)
90

    
91
# user separation
92
DAEMONS_GROUP = _autoconf.DAEMONS_GROUP
93
ADMIN_GROUP = _autoconf.ADMIN_GROUP
94
MASTERD_USER = _autoconf.MASTERD_USER
95
MASTERD_GROUP = _autoconf.MASTERD_GROUP
96
RAPI_USER = _autoconf.RAPI_USER
97
RAPI_GROUP = _autoconf.RAPI_GROUP
98
CONFD_USER = _autoconf.CONFD_USER
99
CONFD_GROUP = _autoconf.CONFD_GROUP
100
NODED_USER = _autoconf.NODED_USER
101
NODED_GROUP = _autoconf.NODED_GROUP
102

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

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

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

    
126
# Wipe
127
DD_CMD = "dd"
128
WIPE_BLOCK_SIZE = 1024 ** 2
129
MAX_WIPE_CHUNK = 1024 # 1GB
130
MIN_WIPE_CHUNK_PERCENT = 10
131

    
132

    
133
# file paths
134
DATA_DIR = _autoconf.LOCALSTATEDIR + "/lib/ganeti"
135
RUN_DIR = _autoconf.LOCALSTATEDIR + "/run"
136
RUN_GANETI_DIR = RUN_DIR + "/ganeti"
137
BDEV_CACHE_DIR = RUN_GANETI_DIR + "/bdev-cache"
138
DISK_LINKS_DIR = RUN_GANETI_DIR + "/instance-disks"
139
RUN_DIRS_MODE = 0775
140
SOCKET_DIR = RUN_GANETI_DIR + "/socket"
141
SECURE_DIR_MODE = 0700
142
SECURE_FILE_MODE = 0600
143
CRYPTO_KEYS_DIR = RUN_GANETI_DIR + "/crypto"
144
IMPORT_EXPORT_DIR = RUN_GANETI_DIR + "/import-export"
145
ADOPTABLE_BLOCKDEV_ROOT = "/dev/disk/"
146
LOCK_DIR = _autoconf.LOCALSTATEDIR + "/lock"
147
SSCONF_LOCK_FILE = LOCK_DIR + "/ganeti-ssconf.lock"
148
# User-id pool lock directory
149
# The user-ids that are in use have a corresponding lock file in this directory
150
UIDPOOL_LOCKDIR = RUN_GANETI_DIR + "/uid-pool"
151
CLUSTER_CONF_FILE = DATA_DIR + "/config.data"
152
NODED_CERT_FILE = DATA_DIR + "/server.pem"
153
RAPI_CERT_FILE = DATA_DIR + "/rapi.pem"
154
CONFD_HMAC_KEY = DATA_DIR + "/hmac.key"
155
SPICE_CERT_FILE = DATA_DIR + "/spice.pem"
156
SPICE_CACERT_FILE = DATA_DIR + "/spice-ca.pem"
157
CLUSTER_DOMAIN_SECRET_FILE = DATA_DIR + "/cluster-domain-secret"
158
INSTANCE_STATUS_FILE = RUN_GANETI_DIR + "/instance-status"
159
SSH_KNOWN_HOSTS_FILE = DATA_DIR + "/known_hosts"
160
RAPI_USERS_FILE = DATA_DIR + "/rapi/users"
161
QUEUE_DIR = DATA_DIR + "/queue"
162
DAEMON_UTIL = _autoconf.PKGLIBDIR + "/daemon-util"
163
SETUP_SSH = _autoconf.TOOLSDIR + "/setup-ssh"
164
KVM_IFUP = _autoconf.PKGLIBDIR + "/kvm-ifup"
165
KVM_CONSOLE_WRAPPER = _autoconf.PKGLIBDIR + "/tools/kvm-console-wrapper"
166
XM_CONSOLE_WRAPPER = _autoconf.PKGLIBDIR + "/tools/xm-console-wrapper"
167
ETC_HOSTS = "/etc/hosts"
168
DEFAULT_FILE_STORAGE_DIR = _autoconf.FILE_STORAGE_DIR
169
DEFAULT_SHARED_FILE_STORAGE_DIR = _autoconf.SHARED_FILE_STORAGE_DIR
170
ENABLE_FILE_STORAGE = _autoconf.ENABLE_FILE_STORAGE
171
ENABLE_SHARED_FILE_STORAGE = _autoconf.ENABLE_SHARED_FILE_STORAGE
172
SYSCONFDIR = _autoconf.SYSCONFDIR
173
TOOLSDIR = _autoconf.TOOLSDIR
174
CONF_DIR = SYSCONFDIR + "/ganeti"
175
USER_SCRIPTS_DIR = CONF_DIR + "/scripts"
176
ENABLE_CONFD = _autoconf.ENABLE_CONFD
177

    
178
#: Lock file for watcher, locked in shared mode by watcher; lock in exclusive
179
# mode to block watcher (see L{cli._RunWhileClusterStoppedHelper.Call}
180
WATCHER_LOCK_FILE = LOCK_DIR + "/ganeti-watcher.lock"
181

    
182
#: Status file for per-group watcher, locked in exclusive mode by watcher
183
WATCHER_GROUP_STATE_FILE = DATA_DIR + "/watcher.%s.data"
184

    
185
#: File for per-group instance status, merged into L{INSTANCE_STATUS_FILE} by
186
#: per-group processes
187
WATCHER_GROUP_INSTANCE_STATUS_FILE = DATA_DIR + "/watcher.%s.instance-status"
188

    
189
#: File containing Unix timestamp until which watcher should be paused
190
WATCHER_PAUSEFILE = DATA_DIR + "/watcher.pause"
191

    
192
# Master IP address setup scripts paths (default and user-provided)
193
DEFAULT_MASTER_SETUP_SCRIPT = TOOLSDIR + "/master-ip-setup"
194
EXTERNAL_MASTER_SETUP_SCRIPT = USER_SCRIPTS_DIR + "/master-ip-setup"
195

    
196
ALL_CERT_FILES = frozenset([
197
  NODED_CERT_FILE,
198
  RAPI_CERT_FILE,
199
  SPICE_CERT_FILE,
200
  SPICE_CACERT_FILE,
201
  ])
202

    
203
MASTER_SOCKET = SOCKET_DIR + "/ganeti-master"
204

    
205
NODED = "ganeti-noded"
206
CONFD = "ganeti-confd"
207
RAPI = "ganeti-rapi"
208
MASTERD = "ganeti-masterd"
209
# used in the ganeti-nbma project
210
NLD = "ganeti-nld"
211

    
212
DAEMONS_PORTS = {
213
  # daemon-name: ("proto", "default-port")
214
  NODED: ("tcp", 1811),
215
  CONFD: ("udp", 1814),
216
  RAPI: ("tcp", 5080),
217
  "ssh": ("tcp", 22),
218
  # used in the ganeti-nbma project
219
  NLD: ("udp", 1816),
220
}
221
DEFAULT_NODED_PORT = DAEMONS_PORTS[NODED][1]
222
DEFAULT_CONFD_PORT = DAEMONS_PORTS[CONFD][1]
223
DEFAULT_RAPI_PORT = DAEMONS_PORTS[RAPI][1]
224
# used in the ganeti-nbma project
225
DEFAULT_NLD_PORT = DAEMONS_PORTS[NLD][1]
226

    
227
FIRST_DRBD_PORT = 11000
228
LAST_DRBD_PORT = 14999
229

    
230
LOG_DIR = _autoconf.LOCALSTATEDIR + "/log/ganeti/"
231
DAEMONS_LOGFILES = {
232
  # "daemon-name": "logfile"
233
  NODED: LOG_DIR + "node-daemon.log",
234
  CONFD: LOG_DIR + "conf-daemon.log",
235
  RAPI: LOG_DIR + "rapi-daemon.log",
236
  MASTERD: LOG_DIR + "master-daemon.log",
237
  # used in the ganeti-nbma project
238
  NLD: LOG_DIR + "nl-daemon.log",
239
  }
240

    
241
LOG_OS_DIR = LOG_DIR + "os"
242
LOG_WATCHER = LOG_DIR + "watcher.log"
243
LOG_COMMANDS = LOG_DIR + "commands.log"
244
LOG_BURNIN = LOG_DIR + "burnin.log"
245
LOG_SETUP_SSH = LOG_DIR + "setup-ssh.log"
246

    
247
DEV_CONSOLE = "/dev/console"
248

    
249
PROC_MOUNTS = "/proc/mounts"
250

    
251
# Local UniX Interface related constants
252
LUXI_EOM = "\3"
253
LUXI_VERSION = CONFIG_VERSION
254

    
255
# one of "no", "yes", "only"
256
SYSLOG_USAGE = _autoconf.SYSLOG_USAGE
257
SYSLOG_NO = "no"
258
SYSLOG_YES = "yes"
259
SYSLOG_ONLY = "only"
260
SYSLOG_SOCKET = "/dev/log"
261

    
262
OS_SEARCH_PATH = _autoconf.OS_SEARCH_PATH
263
EXPORT_DIR = _autoconf.EXPORT_DIR
264

    
265
EXPORT_CONF_FILE = "config.ini"
266

    
267
XEN_BOOTLOADER = _autoconf.XEN_BOOTLOADER
268
XEN_KERNEL = _autoconf.XEN_KERNEL
269
XEN_INITRD = _autoconf.XEN_INITRD
270
XEN_CMD = "xm"
271

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

    
279
#: Console as SSH command
280
CONS_SSH = "ssh"
281

    
282
#: Console as VNC server
283
CONS_VNC = "vnc"
284

    
285
#: Console as SPICE server
286
CONS_SPICE = "spice"
287

    
288
#: Display a message for console access
289
CONS_MESSAGE = "msg"
290

    
291
#: All console types
292
CONS_ALL = frozenset([CONS_SSH, CONS_VNC, CONS_SPICE, CONS_MESSAGE])
293

    
294
# For RSA keys more bits are better, but they also make operations more
295
# expensive. NIST SP 800-131 recommends a minimum of 2048 bits from the year
296
# 2010 on.
297
RSA_KEY_BITS = 2048
298

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

    
307
# Digest used to sign certificates ("openssl x509" uses SHA1 by default)
308
X509_CERT_SIGN_DIGEST = "SHA1"
309

    
310
# Default validity of certificates in days
311
X509_CERT_DEFAULT_VALIDITY = 365 * 5
312

    
313
# commonName (CN) used in certificates
314
X509_CERT_CN = "ganeti.example.com"
315

    
316
X509_CERT_SIGNATURE_HEADER = "X-Ganeti-Signature"
317

    
318
IMPORT_EXPORT_DAEMON = _autoconf.PKGLIBDIR + "/import-export"
319

    
320
# Import/export daemon mode
321
IEM_IMPORT = "import"
322
IEM_EXPORT = "export"
323

    
324
# Import/export transport compression
325
IEC_NONE = "none"
326
IEC_GZIP = "gzip"
327
IEC_ALL = frozenset([
328
  IEC_NONE,
329
  IEC_GZIP,
330
  ])
331

    
332
IE_CUSTOM_SIZE = "fd"
333

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

    
336
# Import/export I/O
337
# Direct file I/O, equivalent to a shell's I/O redirection using '<' or '>'
338
IEIO_FILE = "file"
339
# Raw block device I/O using "dd"
340
IEIO_RAW_DISK = "raw"
341
# OS definition import/export script
342
IEIO_SCRIPT = "script"
343

    
344
VALUE_DEFAULT = "default"
345
VALUE_AUTO = "auto"
346
VALUE_GENERATE = "generate"
347
VALUE_NONE = "none"
348
VALUE_TRUE = "true"
349
VALUE_FALSE = "false"
350

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

    
354
# hooks-related constants
355
HOOKS_BASE_DIR = CONF_DIR + "/hooks"
356
HOOKS_PHASE_PRE = "pre"
357
HOOKS_PHASE_POST = "post"
358
HOOKS_NAME_CFGUPDATE = "config-update"
359
HOOKS_NAME_WATCHER = "watcher"
360
HOOKS_VERSION = 2
361
HOOKS_PATH = "/sbin:/bin:/usr/sbin:/usr/bin"
362

    
363
# hooks subject type (what object type does the LU deal with)
364
HTYPE_CLUSTER = "CLUSTER"
365
HTYPE_NODE = "NODE"
366
HTYPE_GROUP = "GROUP"
367
HTYPE_INSTANCE = "INSTANCE"
368

    
369
HKR_SKIP = 0
370
HKR_FAIL = 1
371
HKR_SUCCESS = 2
372

    
373
# Storage types
374
ST_FILE = "file"
375
ST_LVM_PV = "lvm-pv"
376
ST_LVM_VG = "lvm-vg"
377

    
378
# Storage fields
379
# first two are valid in LU context only, not passed to backend
380
SF_NODE = "node"
381
SF_TYPE = "type"
382
# and the rest are valid in backend
383
SF_NAME = "name"
384
SF_SIZE = "size"
385
SF_FREE = "free"
386
SF_USED = "used"
387
SF_ALLOCATABLE = "allocatable"
388

    
389
# Storage operations
390
SO_FIX_CONSISTENCY = "fix-consistency"
391

    
392
# Available fields per storage type
393
VALID_STORAGE_FIELDS = frozenset([
394
  SF_NAME,
395
  SF_TYPE,
396
  SF_SIZE,
397
  SF_USED,
398
  SF_FREE,
399
  SF_ALLOCATABLE
400
  ])
401

    
402
VALID_STORAGE_TYPES = frozenset([ST_FILE, ST_LVM_PV, ST_LVM_VG])
403

    
404
MODIFIABLE_STORAGE_FIELDS = {
405
  ST_LVM_PV: frozenset([SF_ALLOCATABLE]),
406
  }
407

    
408
VALID_STORAGE_OPERATIONS = {
409
  ST_LVM_VG: frozenset([SO_FIX_CONSISTENCY]),
410
  }
411

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

    
418
# disk template types
419
DT_DISKLESS = "diskless"
420
DT_PLAIN = "plain"
421
DT_DRBD8 = "drbd"
422
DT_FILE = "file"
423
DT_SHARED_FILE = "sharedfile"
424
DT_BLOCK = "blockdev"
425
DT_RBD = "rbd"
426

    
427
# the set of network-mirrored disk templates
428
DTS_INT_MIRROR = frozenset([DT_DRBD8])
429

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

    
433
# the set of non-lvm-based disk templates
434
DTS_NOT_LVM = frozenset([DT_DISKLESS, DT_FILE, DT_SHARED_FILE,
435
                         DT_BLOCK, DT_RBD])
436

    
437
# the set of disk templates which can be grown
438
DTS_GROWABLE = frozenset([DT_PLAIN, DT_DRBD8, DT_FILE, DT_SHARED_FILE, DT_RBD])
439

    
440
# the set of disk templates that allow adoption
441
DTS_MAY_ADOPT = frozenset([DT_PLAIN, DT_BLOCK])
442

    
443
# the set of disk templates that *must* use adoption
444
DTS_MUST_ADOPT = frozenset([DT_BLOCK])
445

    
446
# the set of disk templates that allow migrations
447
DTS_MIRRORED = frozenset.union(DTS_INT_MIRROR, DTS_EXT_MIRROR)
448

    
449
# the set of file based disk templates
450
DTS_FILEBASED = frozenset([DT_FILE, DT_SHARED_FILE])
451

    
452
# logical disk types
453
LD_LV = "lvm"
454
LD_DRBD8 = "drbd8"
455
LD_FILE = "file"
456
LD_BLOCKDEV = "blockdev"
457
LD_RBD = "rbd"
458
LOGICAL_DISK_TYPES = frozenset([
459
  LD_LV,
460
  LD_DRBD8,
461
  LD_FILE,
462
  LD_BLOCKDEV,
463
  LD_RBD,
464
  ])
465

    
466
LDS_BLOCK = frozenset([LD_LV, LD_DRBD8, LD_BLOCKDEV, LD_RBD])
467

    
468
# drbd constants
469
DRBD_HMAC_ALG = "md5"
470
DRBD_NET_PROTOCOL = "C"
471

    
472
# drbd barrier types
473
DRBD_B_NONE = "n"
474
DRBD_B_DISK_BARRIERS = "b"
475
DRBD_B_DISK_DRAIN = "d"
476
DRBD_B_DISK_FLUSH = "f"
477

    
478
# Valid barrier combinations: "n" or any non-null subset of "bfd"
479
DRBD_VALID_BARRIER_OPT = frozenset([
480
  frozenset([DRBD_B_NONE]),
481
  frozenset([DRBD_B_DISK_BARRIERS]),
482
  frozenset([DRBD_B_DISK_DRAIN]),
483
  frozenset([DRBD_B_DISK_FLUSH]),
484
  frozenset([DRBD_B_DISK_DRAIN, DRBD_B_DISK_FLUSH]),
485
  frozenset([DRBD_B_DISK_DRAIN, DRBD_B_DISK_FLUSH]),
486
  frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_DRAIN]),
487
  frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_FLUSH]),
488
  frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_FLUSH, DRBD_B_DISK_DRAIN]),
489
  ])
490

    
491
# rbd tool command
492
RBD_CMD = "rbd"
493

    
494
# file backend driver
495
FD_LOOP = "loop"
496
FD_BLKTAP = "blktap"
497

    
498
# the set of drbd-like disk types
499
LDS_DRBD = frozenset([LD_DRBD8])
500

    
501
# disk access mode
502
DISK_RDONLY = "ro"
503
DISK_RDWR = "rw"
504
DISK_ACCESS_SET = frozenset([DISK_RDONLY, DISK_RDWR])
505

    
506
# disk replacement mode
507
REPLACE_DISK_PRI = "replace_on_primary"    # replace disks on primary
508
REPLACE_DISK_SEC = "replace_on_secondary"  # replace disks on secondary
509
REPLACE_DISK_CHG = "replace_new_secondary" # change secondary node
510
REPLACE_DISK_AUTO = "replace_auto"
511
REPLACE_MODES = frozenset([
512
  REPLACE_DISK_PRI,
513
  REPLACE_DISK_SEC,
514
  REPLACE_DISK_CHG,
515
  REPLACE_DISK_AUTO,
516
  ])
517

    
518
# Instance export mode
519
EXPORT_MODE_LOCAL = "local"
520
EXPORT_MODE_REMOTE = "remote"
521
EXPORT_MODES = frozenset([
522
  EXPORT_MODE_LOCAL,
523
  EXPORT_MODE_REMOTE,
524
  ])
525

    
526
# instance creation modes
527
INSTANCE_CREATE = "create"
528
INSTANCE_IMPORT = "import"
529
INSTANCE_REMOTE_IMPORT = "remote-import"
530
INSTANCE_CREATE_MODES = frozenset([
531
  INSTANCE_CREATE,
532
  INSTANCE_IMPORT,
533
  INSTANCE_REMOTE_IMPORT,
534
  ])
535

    
536
# Remote import/export handshake message and version
537
RIE_VERSION = 0
538
RIE_HANDSHAKE = "Hi, I'm Ganeti"
539

    
540
# Remote import/export certificate validity in seconds
541
RIE_CERT_VALIDITY = 24 * 60 * 60
542

    
543
# Overall timeout for establishing connection
544
RIE_CONNECT_TIMEOUT = 180
545

    
546
# Export only: how long to wait per connection attempt (seconds)
547
RIE_CONNECT_ATTEMPT_TIMEOUT = 20
548

    
549
# Export only: number of attempts to connect
550
RIE_CONNECT_RETRIES = 10
551

    
552
#: Give child process up to 5 seconds to exit after sending a signal
553
CHILD_LINGER_TIMEOUT = 5.0
554

    
555
DISK_TEMPLATES = frozenset([
556
  DT_DISKLESS,
557
  DT_PLAIN,
558
  DT_DRBD8,
559
  DT_FILE,
560
  DT_SHARED_FILE,
561
  DT_BLOCK,
562
  DT_RBD
563
  ])
564

    
565
FILE_DRIVER = frozenset([FD_LOOP, FD_BLKTAP])
566

    
567
# import/export config options
568
INISECT_EXP = "export"
569
INISECT_INS = "instance"
570
INISECT_HYP = "hypervisor"
571
INISECT_BEP = "backend"
572
INISECT_OSP = "os"
573

    
574
# dynamic device modification
575
DDM_ADD = "add"
576
DDM_MODIFY = "modify"
577
DDM_REMOVE = "remove"
578
DDMS_VALUES = frozenset([DDM_ADD, DDM_REMOVE])
579
DDMS_VALUES_WITH_MODIFY = (DDMS_VALUES | frozenset([
580
  DDM_MODIFY,
581
  ]))
582
# TODO: DDM_SWAP, DDM_MOVE?
583

    
584
# common exit codes
585
EXIT_SUCCESS = 0
586
EXIT_FAILURE = 1
587
EXIT_NOTCLUSTER = 5
588
EXIT_NOTMASTER = 11
589
EXIT_NODESETUP_ERROR = 12
590
EXIT_CONFIRMATION = 13 # need user confirmation
591

    
592
#: Exit code for query operations with unknown fields
593
EXIT_UNKNOWN_FIELD = 14
594

    
595
# tags
596
TAG_CLUSTER = "cluster"
597
TAG_NODEGROUP = "nodegroup"
598
TAG_NODE = "node"
599
TAG_INSTANCE = "instance"
600
VALID_TAG_TYPES = frozenset([
601
  TAG_CLUSTER,
602
  TAG_NODEGROUP,
603
  TAG_NODE,
604
  TAG_INSTANCE,
605
  ])
606
MAX_TAG_LEN = 128
607
MAX_TAGS_PER_OBJ = 4096
608

    
609
# others
610
DEFAULT_BRIDGE = "xen-br0"
611
CLASSIC_DRBD_SYNC_SPEED = 60 * 1024  # 60 MiB, expressed in KiB
612
IP4_ADDRESS_LOCALHOST = "127.0.0.1"
613
IP4_ADDRESS_ANY = "0.0.0.0"
614
IP6_ADDRESS_LOCALHOST = "::1"
615
IP6_ADDRESS_ANY = "::"
616
IP4_VERSION = 4
617
IP6_VERSION = 6
618
VALID_IP_VERSIONS = frozenset([IP4_VERSION, IP6_VERSION])
619
# for export to htools
620
IP4_FAMILY = socket.AF_INET
621
IP6_FAMILY = socket.AF_INET6
622

    
623
TCP_PING_TIMEOUT = 10
624
GANETI_RUNAS = "root"
625
DEFAULT_VG = "xenvg"
626
DEFAULT_DRBD_HELPER = "/bin/true"
627
MIN_VG_SIZE = 20480
628
DEFAULT_MAC_PREFIX = "aa:00:00"
629
# default maximum instance wait time, in seconds.
630
DEFAULT_SHUTDOWN_TIMEOUT = 120
631
NODE_MAX_CLOCK_SKEW = 150
632
# Time for an intra-cluster disk transfer to wait for a connection
633
DISK_TRANSFER_CONNECT_TIMEOUT = 60
634
# Disk index separator
635
DISK_SEPARATOR = _autoconf.DISK_SEPARATOR
636
IP_COMMAND_PATH = _autoconf.IP_PATH
637

    
638
#: Key for job IDs in opcode result
639
JOB_IDS_KEY = "jobs"
640

    
641
# runparts results
642
(RUNPARTS_SKIP,
643
 RUNPARTS_RUN,
644
 RUNPARTS_ERR) = range(3)
645

    
646
RUNPARTS_STATUS = frozenset([RUNPARTS_SKIP, RUNPARTS_RUN, RUNPARTS_ERR])
647

    
648
# RPC constants
649
(RPC_ENCODING_NONE,
650
 RPC_ENCODING_ZLIB_BASE64) = range(2)
651

    
652
# os related constants
653
OS_SCRIPT_CREATE = "create"
654
OS_SCRIPT_IMPORT = "import"
655
OS_SCRIPT_EXPORT = "export"
656
OS_SCRIPT_RENAME = "rename"
657
OS_SCRIPT_VERIFY = "verify"
658
OS_SCRIPTS = frozenset([
659
  OS_SCRIPT_CREATE,
660
  OS_SCRIPT_IMPORT,
661
  OS_SCRIPT_EXPORT,
662
  OS_SCRIPT_RENAME,
663
  OS_SCRIPT_VERIFY
664
  ])
665

    
666
OS_API_FILE = "ganeti_api_version"
667
OS_VARIANTS_FILE = "variants.list"
668
OS_PARAMETERS_FILE = "parameters.list"
669

    
670
OS_VALIDATE_PARAMETERS = "parameters"
671
OS_VALIDATE_CALLS = frozenset([OS_VALIDATE_PARAMETERS])
672

    
673
# ssh constants
674
SSH_CONFIG_DIR = _autoconf.SSH_CONFIG_DIR
675
SSH_HOST_DSA_PRIV = SSH_CONFIG_DIR + "/ssh_host_dsa_key"
676
SSH_HOST_DSA_PUB = SSH_HOST_DSA_PRIV + ".pub"
677
SSH_HOST_RSA_PRIV = SSH_CONFIG_DIR + "/ssh_host_rsa_key"
678
SSH_HOST_RSA_PUB = SSH_HOST_RSA_PRIV + ".pub"
679
SSH = "ssh"
680
SCP = "scp"
681

    
682
# reboot types
683
INSTANCE_REBOOT_SOFT = "soft"
684
INSTANCE_REBOOT_HARD = "hard"
685
INSTANCE_REBOOT_FULL = "full"
686

    
687
REBOOT_TYPES = frozenset([
688
  INSTANCE_REBOOT_SOFT,
689
  INSTANCE_REBOOT_HARD,
690
  INSTANCE_REBOOT_FULL
691
  ])
692

    
693
# instance reboot behaviors
694
INSTANCE_REBOOT_ALLOWED = "reboot"
695
INSTANCE_REBOOT_EXIT = "exit"
696

    
697
REBOOT_BEHAVIORS = frozenset([
698
  INSTANCE_REBOOT_ALLOWED,
699
  INSTANCE_REBOOT_EXIT
700
  ])
701

    
702
VTYPE_STRING = "string"
703
VTYPE_MAYBE_STRING = "maybe-string"
704
VTYPE_BOOL = "bool"
705
VTYPE_SIZE = "size" # size, in MiBs
706
VTYPE_INT = "int"
707
ENFORCEABLE_TYPES = frozenset([
708
  VTYPE_STRING,
709
  VTYPE_MAYBE_STRING,
710
  VTYPE_BOOL,
711
  VTYPE_SIZE,
712
  VTYPE_INT,
713
  ])
714

    
715
# Constant representing that the user does not specify any IP version
716
IFACE_NO_IP_VERSION_SPECIFIED = 0
717

    
718
# HV parameter names (global namespace)
719
HV_BOOT_ORDER = "boot_order"
720
HV_CDROM_IMAGE_PATH = "cdrom_image_path"
721
HV_KVM_CDROM2_IMAGE_PATH = "cdrom2_image_path"
722
HV_KVM_FLOPPY_IMAGE_PATH = "floppy_image_path"
723
HV_NIC_TYPE = "nic_type"
724
HV_DISK_TYPE = "disk_type"
725
HV_KVM_CDROM_DISK_TYPE = "cdrom_disk_type"
726
HV_VNC_BIND_ADDRESS = "vnc_bind_address"
727
HV_VNC_PASSWORD_FILE = "vnc_password_file"
728
HV_VNC_TLS = "vnc_tls"
729
HV_VNC_X509 = "vnc_x509_path"
730
HV_VNC_X509_VERIFY = "vnc_x509_verify"
731
HV_KVM_SPICE_BIND = "spice_bind"
732
HV_KVM_SPICE_IP_VERSION = "spice_ip_version"
733
HV_KVM_SPICE_PASSWORD_FILE = "spice_password_file"
734
HV_KVM_SPICE_LOSSLESS_IMG_COMPR = "spice_image_compression"
735
HV_KVM_SPICE_JPEG_IMG_COMPR = "spice_jpeg_wan_compression"
736
HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR = "spice_zlib_glz_wan_compression"
737
HV_KVM_SPICE_STREAMING_VIDEO_DETECTION = "spice_streaming_video"
738
HV_KVM_SPICE_AUDIO_COMPR = "spice_playback_compression"
739
HV_KVM_SPICE_USE_TLS = "spice_use_tls"
740
HV_KVM_SPICE_TLS_CIPHERS = "spice_tls_ciphers"
741
HV_KVM_SPICE_USE_VDAGENT = "spice_use_vdagent"
742
HV_ACPI = "acpi"
743
HV_PAE = "pae"
744
HV_USE_BOOTLOADER = "use_bootloader"
745
HV_BOOTLOADER_ARGS = "bootloader_args"
746
HV_BOOTLOADER_PATH = "bootloader_path"
747
HV_KERNEL_ARGS = "kernel_args"
748
HV_KERNEL_PATH = "kernel_path"
749
HV_INITRD_PATH = "initrd_path"
750
HV_ROOT_PATH = "root_path"
751
HV_SERIAL_CONSOLE = "serial_console"
752
HV_USB_MOUSE = "usb_mouse"
753
HV_KEYMAP = "keymap"
754
HV_DEVICE_MODEL = "device_model"
755
HV_INIT_SCRIPT = "init_script"
756
HV_MIGRATION_PORT = "migration_port"
757
HV_MIGRATION_BANDWIDTH = "migration_bandwidth"
758
HV_MIGRATION_DOWNTIME = "migration_downtime"
759
HV_MIGRATION_MODE = "migration_mode"
760
HV_USE_LOCALTIME = "use_localtime"
761
HV_DISK_CACHE = "disk_cache"
762
HV_SECURITY_MODEL = "security_model"
763
HV_SECURITY_DOMAIN = "security_domain"
764
HV_KVM_FLAG = "kvm_flag"
765
HV_VHOST_NET = "vhost_net"
766
HV_KVM_USE_CHROOT = "use_chroot"
767
HV_CPU_MASK = "cpu_mask"
768
HV_MEM_PATH = "mem_path"
769
HV_BLOCKDEV_PREFIX = "blockdev_prefix"
770
HV_REBOOT_BEHAVIOR = "reboot_behavior"
771

    
772
HVS_PARAMETER_TYPES = {
773
  HV_BOOT_ORDER: VTYPE_STRING,
774
  HV_KVM_FLOPPY_IMAGE_PATH: VTYPE_STRING,
775
  HV_CDROM_IMAGE_PATH: VTYPE_STRING,
776
  HV_KVM_CDROM2_IMAGE_PATH: VTYPE_STRING,
777
  HV_NIC_TYPE: VTYPE_STRING,
778
  HV_DISK_TYPE: VTYPE_STRING,
779
  HV_KVM_CDROM_DISK_TYPE: VTYPE_STRING,
780
  HV_VNC_PASSWORD_FILE: VTYPE_STRING,
781
  HV_VNC_BIND_ADDRESS: VTYPE_STRING,
782
  HV_VNC_TLS: VTYPE_BOOL,
783
  HV_VNC_X509: VTYPE_STRING,
784
  HV_VNC_X509_VERIFY: VTYPE_BOOL,
785
  HV_KVM_SPICE_BIND: VTYPE_STRING,
786
  HV_KVM_SPICE_IP_VERSION: VTYPE_INT,
787
  HV_KVM_SPICE_PASSWORD_FILE: VTYPE_STRING,
788
  HV_KVM_SPICE_LOSSLESS_IMG_COMPR: VTYPE_STRING,
789
  HV_KVM_SPICE_JPEG_IMG_COMPR: VTYPE_STRING,
790
  HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR: VTYPE_STRING,
791
  HV_KVM_SPICE_STREAMING_VIDEO_DETECTION: VTYPE_STRING,
792
  HV_KVM_SPICE_AUDIO_COMPR: VTYPE_BOOL,
793
  HV_KVM_SPICE_USE_TLS: VTYPE_BOOL,
794
  HV_KVM_SPICE_TLS_CIPHERS: VTYPE_STRING,
795
  HV_KVM_SPICE_USE_VDAGENT: VTYPE_BOOL,
796
  HV_ACPI: VTYPE_BOOL,
797
  HV_PAE: VTYPE_BOOL,
798
  HV_USE_BOOTLOADER: VTYPE_BOOL,
799
  HV_BOOTLOADER_PATH: VTYPE_STRING,
800
  HV_BOOTLOADER_ARGS: VTYPE_STRING,
801
  HV_KERNEL_PATH: VTYPE_STRING,
802
  HV_KERNEL_ARGS: VTYPE_STRING,
803
  HV_INITRD_PATH: VTYPE_STRING,
804
  HV_ROOT_PATH: VTYPE_MAYBE_STRING,
805
  HV_SERIAL_CONSOLE: VTYPE_BOOL,
806
  HV_USB_MOUSE: VTYPE_STRING,
807
  HV_KEYMAP: VTYPE_STRING,
808
  HV_DEVICE_MODEL: VTYPE_STRING,
809
  HV_INIT_SCRIPT: VTYPE_STRING,
810
  HV_MIGRATION_PORT: VTYPE_INT,
811
  HV_MIGRATION_BANDWIDTH: VTYPE_INT,
812
  HV_MIGRATION_DOWNTIME: VTYPE_INT,
813
  HV_MIGRATION_MODE: VTYPE_STRING,
814
  HV_USE_LOCALTIME: VTYPE_BOOL,
815
  HV_DISK_CACHE: VTYPE_STRING,
816
  HV_SECURITY_MODEL: VTYPE_STRING,
817
  HV_SECURITY_DOMAIN: VTYPE_STRING,
818
  HV_KVM_FLAG: VTYPE_STRING,
819
  HV_VHOST_NET: VTYPE_BOOL,
820
  HV_KVM_USE_CHROOT: VTYPE_BOOL,
821
  HV_CPU_MASK: VTYPE_STRING,
822
  HV_MEM_PATH: VTYPE_STRING,
823
  HV_BLOCKDEV_PREFIX: VTYPE_STRING,
824
  HV_REBOOT_BEHAVIOR: VTYPE_STRING,
825
  }
826

    
827
HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
828

    
829
# Migration statuses
830
HV_MIGRATION_COMPLETED = "completed"
831
HV_MIGRATION_ACTIVE = "active"
832
HV_MIGRATION_FAILED = "failed"
833
HV_MIGRATION_CANCELLED = "cancelled"
834

    
835
HV_MIGRATION_VALID_STATUSES = frozenset([
836
  HV_MIGRATION_COMPLETED,
837
  HV_MIGRATION_ACTIVE,
838
  HV_MIGRATION_FAILED,
839
  HV_MIGRATION_CANCELLED,
840
  ])
841

    
842
HV_MIGRATION_FAILED_STATUSES = frozenset([
843
  HV_MIGRATION_FAILED,
844
  HV_MIGRATION_CANCELLED,
845
  ])
846

    
847
# KVM-specific statuses
848
HV_KVM_MIGRATION_VALID_STATUSES = HV_MIGRATION_VALID_STATUSES
849

    
850
# Node info keys
851
HV_NODEINFO_KEY_VERSION = "hv_version"
852

    
853
# Hypervisor state
854
HVST_MEMORY_TOTAL = "mem_total"
855
HVST_MEMORY_NODE = "mem_node"
856
HVST_MEMORY_HV = "mem_hv"
857
HVST_CPU_TOTAL = "cpu_total"
858
HVST_CPU_NODE = "cpu_node"
859

    
860
HVST_DEFAULTS = {
861
  HVST_MEMORY_TOTAL: 0,
862
  HVST_MEMORY_NODE: 0,
863
  HVST_MEMORY_HV: 0,
864
  HVST_CPU_TOTAL: 1,
865
  HVST_CPU_NODE: 1,
866
  }
867

    
868
HVSTS_PARAMETER_TYPES = {
869
  HVST_MEMORY_TOTAL: VTYPE_INT,
870
  HVST_MEMORY_NODE: VTYPE_INT,
871
  HVST_MEMORY_HV: VTYPE_INT,
872
  HVST_CPU_TOTAL: VTYPE_INT,
873
  HVST_CPU_NODE: VTYPE_INT,
874
  }
875

    
876
HVSTS_PARAMETERS = frozenset(HVSTS_PARAMETER_TYPES.keys())
877

    
878
# Disk state
879
DS_DISK_TOTAL = "disk_total"
880
DS_DISK_RESERVED = "disk_reserved"
881
DS_DISK_OVERHEAD = "disk_overhead"
882

    
883
DS_DEFAULTS = {
884
  DS_DISK_TOTAL: 0,
885
  DS_DISK_RESERVED: 0,
886
  DS_DISK_OVERHEAD: 0,
887
  }
888

    
889
DSS_PARAMETER_TYPES = {
890
  DS_DISK_TOTAL: VTYPE_INT,
891
  DS_DISK_RESERVED: VTYPE_INT,
892
  DS_DISK_OVERHEAD: VTYPE_INT,
893
  }
894

    
895
DSS_PARAMETERS = frozenset(DSS_PARAMETER_TYPES.keys())
896
DS_VALID_TYPES = frozenset([LD_LV])
897

    
898
# Backend parameter names
899
BE_MEMORY = "memory" # deprecated and replaced by max and min mem
900
BE_MAXMEM = "maxmem"
901
BE_MINMEM = "minmem"
902
BE_VCPUS = "vcpus"
903
BE_AUTO_BALANCE = "auto_balance"
904
BE_ALWAYS_FAILOVER = "always_failover"
905
BE_SPINDLE_USE = "spindle_use"
906

    
907
BES_PARAMETER_TYPES = {
908
  BE_MAXMEM: VTYPE_SIZE,
909
  BE_MINMEM: VTYPE_SIZE,
910
  BE_VCPUS: VTYPE_INT,
911
  BE_AUTO_BALANCE: VTYPE_BOOL,
912
  BE_ALWAYS_FAILOVER: VTYPE_BOOL,
913
  BE_SPINDLE_USE: VTYPE_INT,
914
  }
915

    
916
BES_PARAMETER_COMPAT = {
917
  BE_MEMORY: VTYPE_SIZE,
918
  }
919
BES_PARAMETER_COMPAT.update(BES_PARAMETER_TYPES)
920

    
921
BES_PARAMETERS = frozenset(BES_PARAMETER_TYPES.keys())
922

    
923
# instance specs
924
ISPEC_MEM_SIZE = "memory-size"
925
ISPEC_CPU_COUNT = "cpu-count"
926
ISPEC_DISK_COUNT = "disk-count"
927
ISPEC_DISK_SIZE = "disk-size"
928
ISPEC_NIC_COUNT = "nic-count"
929
ISPEC_SPINDLE_USE = "spindle-use"
930

    
931
ISPECS_PARAMETER_TYPES = {
932
  ISPEC_MEM_SIZE: VTYPE_INT,
933
  ISPEC_CPU_COUNT: VTYPE_INT,
934
  ISPEC_DISK_COUNT: VTYPE_INT,
935
  ISPEC_DISK_SIZE: VTYPE_INT,
936
  ISPEC_NIC_COUNT: VTYPE_INT,
937
  ISPEC_SPINDLE_USE: VTYPE_INT,
938
  }
939

    
940
ISPECS_PARAMETERS = frozenset(ISPECS_PARAMETER_TYPES.keys())
941

    
942
ISPECS_MIN = "min"
943
ISPECS_MAX = "max"
944
ISPECS_STD = "std"
945
IPOLICY_DTS = "disk-templates"
946
IPOLICY_VCPU_RATIO = "vcpu-ratio"
947
IPOLICY_SPINDLE_RATIO = "spindle-ratio"
948

    
949
IPOLICY_ISPECS = frozenset([
950
  ISPECS_MIN,
951
  ISPECS_MAX,
952
  ISPECS_STD,
953
  ])
954

    
955
IPOLICY_PARAMETERS = frozenset([
956
  IPOLICY_VCPU_RATIO,
957
  IPOLICY_SPINDLE_RATIO,
958
  ])
959

    
960
IPOLICY_ALL_KEYS = (IPOLICY_ISPECS |
961
                    IPOLICY_PARAMETERS |
962
                    frozenset([IPOLICY_DTS]))
963

    
964
# Node parameter names
965
ND_OOB_PROGRAM = "oob_program"
966
ND_SPINDLE_COUNT = "spindle_count"
967

    
968
NDS_PARAMETER_TYPES = {
969
  ND_OOB_PROGRAM: VTYPE_MAYBE_STRING,
970
  ND_SPINDLE_COUNT: VTYPE_INT,
971
  }
972

    
973
NDS_PARAMETERS = frozenset(NDS_PARAMETER_TYPES.keys())
974

    
975
# Logical Disks parameters
976
LDP_RESYNC_RATE = "resync-rate"
977
LDP_STRIPES = "stripes"
978
LDP_BARRIERS = "disabled-barriers"
979
LDP_NO_META_FLUSH = "disable-meta-flush"
980
LDP_DEFAULT_METAVG = "default-metavg"
981
LDP_DISK_CUSTOM = "disk-custom"
982
LDP_NET_CUSTOM = "net-custom"
983
LDP_DYNAMIC_RESYNC = "dynamic-resync"
984
LDP_PLAN_AHEAD = "c-plan-ahead"
985
LDP_FILL_TARGET = "c-fill-target"
986
LDP_DELAY_TARGET = "c-delay-target"
987
LDP_MAX_RATE = "c-max-rate"
988
LDP_MIN_RATE = "c-min-rate"
989
LDP_POOL = "pool"
990
DISK_LD_TYPES = {
991
  LDP_RESYNC_RATE: VTYPE_INT,
992
  LDP_STRIPES: VTYPE_INT,
993
  LDP_BARRIERS: VTYPE_STRING,
994
  LDP_NO_META_FLUSH: VTYPE_BOOL,
995
  LDP_DEFAULT_METAVG: VTYPE_STRING,
996
  LDP_DISK_CUSTOM: VTYPE_STRING,
997
  LDP_NET_CUSTOM: VTYPE_STRING,
998
  LDP_DYNAMIC_RESYNC: VTYPE_BOOL,
999
  LDP_PLAN_AHEAD: VTYPE_INT,
1000
  LDP_FILL_TARGET: VTYPE_INT,
1001
  LDP_DELAY_TARGET: VTYPE_INT,
1002
  LDP_MAX_RATE: VTYPE_INT,
1003
  LDP_MIN_RATE: VTYPE_INT,
1004
  LDP_POOL: VTYPE_STRING,
1005
  }
1006
DISK_LD_PARAMETERS = frozenset(DISK_LD_TYPES.keys())
1007

    
1008
# Disk template parameters (can be set/changed by the user via gnt-cluster and
1009
# gnt-group)
1010
DRBD_RESYNC_RATE = "resync-rate"
1011
DRBD_DATA_STRIPES = "data-stripes"
1012
DRBD_META_STRIPES = "meta-stripes"
1013
DRBD_DISK_BARRIERS = "disk-barriers"
1014
DRBD_META_BARRIERS = "meta-barriers"
1015
DRBD_DEFAULT_METAVG = "metavg"
1016
DRBD_DISK_CUSTOM = "disk-custom"
1017
DRBD_NET_CUSTOM = "net-custom"
1018
DRBD_DYNAMIC_RESYNC = "dynamic-resync"
1019
DRBD_PLAN_AHEAD = "c-plan-ahead"
1020
DRBD_FILL_TARGET = "c-fill-target"
1021
DRBD_DELAY_TARGET = "c-delay-target"
1022
DRBD_MAX_RATE = "c-max-rate"
1023
DRBD_MIN_RATE = "c-min-rate"
1024
LV_STRIPES = "stripes"
1025
RBD_POOL = "pool"
1026
DISK_DT_TYPES = {
1027
  DRBD_RESYNC_RATE: VTYPE_INT,
1028
  DRBD_DATA_STRIPES: VTYPE_INT,
1029
  DRBD_META_STRIPES: VTYPE_INT,
1030
  DRBD_DISK_BARRIERS: VTYPE_STRING,
1031
  DRBD_META_BARRIERS: VTYPE_BOOL,
1032
  DRBD_DEFAULT_METAVG: VTYPE_STRING,
1033
  DRBD_DISK_CUSTOM: VTYPE_STRING,
1034
  DRBD_NET_CUSTOM: VTYPE_STRING,
1035
  DRBD_DYNAMIC_RESYNC: VTYPE_BOOL,
1036
  DRBD_PLAN_AHEAD: VTYPE_INT,
1037
  DRBD_FILL_TARGET: VTYPE_INT,
1038
  DRBD_DELAY_TARGET: VTYPE_INT,
1039
  DRBD_MAX_RATE: VTYPE_INT,
1040
  DRBD_MIN_RATE: VTYPE_INT,
1041
  LV_STRIPES: VTYPE_INT,
1042
  RBD_POOL: VTYPE_STRING,
1043
  }
1044

    
1045
DISK_DT_PARAMETERS = frozenset(DISK_DT_TYPES.keys())
1046

    
1047
# OOB supported commands
1048
OOB_POWER_ON = "power-on"
1049
OOB_POWER_OFF = "power-off"
1050
OOB_POWER_CYCLE = "power-cycle"
1051
OOB_POWER_STATUS = "power-status"
1052
OOB_HEALTH = "health"
1053

    
1054
OOB_COMMANDS = frozenset([
1055
  OOB_POWER_ON,
1056
  OOB_POWER_OFF,
1057
  OOB_POWER_CYCLE,
1058
  OOB_POWER_STATUS,
1059
  OOB_HEALTH
1060
  ])
1061

    
1062
OOB_POWER_STATUS_POWERED = "powered"
1063

    
1064
OOB_TIMEOUT = 60 # 60 seconds
1065
OOB_POWER_DELAY = 2.0 # 2 seconds
1066

    
1067
OOB_STATUS_OK = "OK"
1068
OOB_STATUS_WARNING = "WARNING"
1069
OOB_STATUS_CRITICAL = "CRITICAL"
1070
OOB_STATUS_UNKNOWN = "UNKNOWN"
1071

    
1072
OOB_STATUSES = frozenset([
1073
  OOB_STATUS_OK,
1074
  OOB_STATUS_WARNING,
1075
  OOB_STATUS_CRITICAL,
1076
  OOB_STATUS_UNKNOWN,
1077
  ])
1078

    
1079
# Instance Parameters Profile
1080
PP_DEFAULT = "default"
1081

    
1082
# NIC_* constants are used inside the ganeti config
1083
NIC_MODE = "mode"
1084
NIC_LINK = "link"
1085

    
1086
NIC_MODE_BRIDGED = "bridged"
1087
NIC_MODE_ROUTED = "routed"
1088

    
1089
NIC_VALID_MODES = frozenset([NIC_MODE_BRIDGED, NIC_MODE_ROUTED])
1090

    
1091
NICS_PARAMETER_TYPES = {
1092
  NIC_MODE: VTYPE_STRING,
1093
  NIC_LINK: VTYPE_STRING,
1094
  }
1095

    
1096
NICS_PARAMETERS = frozenset(NICS_PARAMETER_TYPES.keys())
1097

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

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

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

    
1143
VNC_BASE_PORT = 5900
1144
VNC_PASSWORD_FILE = CONF_DIR + "/vnc-cluster-password"
1145
VNC_DEFAULT_BIND_ADDRESS = IP4_ADDRESS_ANY
1146

    
1147
# NIC types
1148
HT_NIC_RTL8139 = "rtl8139"
1149
HT_NIC_NE2K_PCI = "ne2k_pci"
1150
HT_NIC_NE2K_ISA = "ne2k_isa"
1151
HT_NIC_I82551 = "i82551"
1152
HT_NIC_I85557B = "i82557b"
1153
HT_NIC_I8259ER = "i82559er"
1154
HT_NIC_PCNET = "pcnet"
1155
HT_NIC_E1000 = "e1000"
1156
HT_NIC_PARAVIRTUAL = HT_DISK_PARAVIRTUAL = "paravirtual"
1157

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

    
1177
# Disk types
1178
HT_DISK_IOEMU = "ioemu"
1179
HT_DISK_IDE = "ide"
1180
HT_DISK_SCSI = "scsi"
1181
HT_DISK_SD = "sd"
1182
HT_DISK_MTD = "mtd"
1183
HT_DISK_PFLASH = "pflash"
1184

    
1185
HT_CACHE_DEFAULT = "default"
1186
HT_CACHE_NONE = "none"
1187
HT_CACHE_WTHROUGH = "writethrough"
1188
HT_CACHE_WBACK = "writeback"
1189
HT_VALID_CACHE_TYPES = frozenset([
1190
  HT_CACHE_DEFAULT,
1191
  HT_CACHE_NONE,
1192
  HT_CACHE_WTHROUGH,
1193
  HT_CACHE_WBACK
1194
  ])
1195

    
1196
HT_HVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IOEMU])
1197
HT_KVM_VALID_DISK_TYPES = frozenset([
1198
  HT_DISK_PARAVIRTUAL,
1199
  HT_DISK_IDE,
1200
  HT_DISK_SCSI,
1201
  HT_DISK_SD,
1202
  HT_DISK_MTD,
1203
  HT_DISK_PFLASH
1204
  ])
1205

    
1206
# Mouse types:
1207
HT_MOUSE_MOUSE = "mouse"
1208
HT_MOUSE_TABLET = "tablet"
1209

    
1210
HT_KVM_VALID_MOUSE_TYPES = frozenset([HT_MOUSE_MOUSE, HT_MOUSE_TABLET])
1211

    
1212
# Boot order
1213
HT_BO_FLOPPY = "floppy"
1214
HT_BO_CDROM = "cdrom"
1215
HT_BO_DISK = "disk"
1216
HT_BO_NETWORK = "network"
1217

    
1218
HT_KVM_VALID_BO_TYPES = frozenset([
1219
  HT_BO_FLOPPY,
1220
  HT_BO_CDROM,
1221
  HT_BO_DISK,
1222
  HT_BO_NETWORK
1223
  ])
1224

    
1225
# SPICE lossless image compression options
1226
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ = "auto_glz"
1227
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ = "auto_lz"
1228
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC = "quic"
1229
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ = "glz"
1230
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ = "lz"
1231
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF = "off"
1232

    
1233
HT_KVM_SPICE_VALID_LOSSLESS_IMG_COMPR_OPTIONS = frozenset([
1234
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ,
1235
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ,
1236
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC,
1237
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ,
1238
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ,
1239
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF,
1240
  ])
1241

    
1242
# SPICE lossy image compression options (valid for both jpeg and zlib-glz)
1243
HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO = "auto"
1244
HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER = "never"
1245
HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS = "always"
1246

    
1247
HT_KVM_SPICE_VALID_LOSSY_IMG_COMPR_OPTIONS = frozenset([
1248
  HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO,
1249
  HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER,
1250
  HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS,
1251
  ])
1252

    
1253
# SPICE video stream detection
1254
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF = "off"
1255
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL = "all"
1256
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER = "filter"
1257

    
1258
HT_KVM_SPICE_VALID_VIDEO_STREAM_DETECTION_OPTIONS = frozenset([
1259
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF,
1260
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL,
1261
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER,
1262
  ])
1263

    
1264
# Security models
1265
HT_SM_NONE = "none"
1266
HT_SM_USER = "user"
1267
HT_SM_POOL = "pool"
1268

    
1269
HT_KVM_VALID_SM_TYPES = frozenset([HT_SM_NONE, HT_SM_USER, HT_SM_POOL])
1270

    
1271
# Kvm flag values
1272
HT_KVM_ENABLED = "enabled"
1273
HT_KVM_DISABLED = "disabled"
1274

    
1275
HT_KVM_FLAG_VALUES = frozenset([HT_KVM_ENABLED, HT_KVM_DISABLED])
1276

    
1277
# Migration type
1278
HT_MIGRATION_LIVE = "live"
1279
HT_MIGRATION_NONLIVE = "non-live"
1280
HT_MIGRATION_MODES = frozenset([HT_MIGRATION_LIVE, HT_MIGRATION_NONLIVE])
1281

    
1282
# Cluster Verify steps
1283
VERIFY_NPLUSONE_MEM = "nplusone_mem"
1284
VERIFY_OPTIONAL_CHECKS = frozenset([VERIFY_NPLUSONE_MEM])
1285

    
1286
# Cluster Verify error classes
1287
CV_TCLUSTER = "cluster"
1288
CV_TNODE = "node"
1289
CV_TINSTANCE = "instance"
1290

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

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

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

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

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

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

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

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

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

    
1493
IALLOCATOR_NEVAC_PRI = "primary-only"
1494
IALLOCATOR_NEVAC_SEC = "secondary-only"
1495
IALLOCATOR_NEVAC_ALL = "all"
1496
IALLOCATOR_NEVAC_MODES = frozenset([
1497
  IALLOCATOR_NEVAC_PRI,
1498
  IALLOCATOR_NEVAC_SEC,
1499
  IALLOCATOR_NEVAC_ALL,
1500
  ])
1501

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

    
1512
# Job queue
1513
JOB_QUEUE_VERSION = 1
1514
JOB_QUEUE_LOCK_FILE = QUEUE_DIR + "/lock"
1515
JOB_QUEUE_VERSION_FILE = QUEUE_DIR + "/version"
1516
JOB_QUEUE_SERIAL_FILE = QUEUE_DIR + "/serial"
1517
JOB_QUEUE_ARCHIVE_DIR = QUEUE_DIR + "/archive"
1518
JOB_QUEUE_DRAIN_FILE = QUEUE_DIR + "/drain"
1519
JOB_QUEUE_SIZE_HARD_LIMIT = 5000
1520

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

    
1524
# unchanged job return
1525
JOB_NOTCHANGED = "nochange"
1526

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

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

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

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

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

    
1577
OP_PRIO_DEFAULT = OP_PRIO_NORMAL
1578

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

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

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

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

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

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

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

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

    
1640
#: List of resources which can be queried using RAPI
1641
QR_VIA_RAPI = QR_VIA_LUXI
1642

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

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

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

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

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

    
1694
# max dynamic devices
1695
MAX_NICS = 8
1696
MAX_DISKS = 16
1697

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

    
1722
SS_FILE_PERMS = 0444
1723

    
1724
# cluster wide default parameters
1725
DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM
1726

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

    
1817
HVC_GLOBALS = frozenset([
1818
  HV_MIGRATION_PORT,
1819
  HV_MIGRATION_BANDWIDTH,
1820
  HV_MIGRATION_MODE,
1821
  ])
1822

    
1823
BEC_DEFAULTS = {
1824
  BE_MINMEM: 128,
1825
  BE_MAXMEM: 128,
1826
  BE_VCPUS: 1,
1827
  BE_AUTO_BALANCE: True,
1828
  BE_ALWAYS_FAILOVER: False,
1829
  BE_SPINDLE_USE: 1,
1830
  }
1831

    
1832
NDC_DEFAULTS = {
1833
  ND_OOB_PROGRAM: None,
1834
  ND_SPINDLE_COUNT: 1,
1835
  }
1836

    
1837
DISK_LD_DEFAULTS = {
1838
  LD_DRBD8: {
1839
    LDP_RESYNC_RATE: CLASSIC_DRBD_SYNC_SPEED,
1840
    LDP_BARRIERS: _autoconf.DRBD_BARRIERS,
1841
    LDP_NO_META_FLUSH: _autoconf.DRBD_NO_META_FLUSH,
1842
    LDP_DEFAULT_METAVG: DEFAULT_VG,
1843
    LDP_DISK_CUSTOM: "",
1844
    LDP_NET_CUSTOM: "",
1845
    LDP_DYNAMIC_RESYNC: False,
1846

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

    
1870
# readability shortcuts
1871
_LV_DEFAULTS = DISK_LD_DEFAULTS[LD_LV]
1872
_DRBD_DEFAULTS = DISK_LD_DEFAULTS[LD_DRBD8]
1873

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

    
1907
# we don't want to export the shortcuts
1908
del _LV_DEFAULTS, _DRBD_DEFAULTS
1909

    
1910
NICC_DEFAULTS = {
1911
  NIC_MODE: NIC_MODE_BRIDGED,
1912
  NIC_LINK: DEFAULT_BRIDGE,
1913
  }
1914

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

    
1947
MASTER_POOL_SIZE_DEFAULT = 10
1948

    
1949
CONFD_PROTOCOL_VERSION = 1
1950

    
1951
CONFD_REQ_PING = 0
1952
CONFD_REQ_NODE_ROLE_BYNAME = 1
1953
CONFD_REQ_NODE_PIP_BY_INSTANCE_IP = 2
1954
CONFD_REQ_CLUSTER_MASTER = 3
1955
CONFD_REQ_NODE_PIP_LIST = 4
1956
CONFD_REQ_MC_PIP_LIST = 5
1957
CONFD_REQ_INSTANCES_IPS_LIST = 6
1958

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

    
1967
CONFD_REQFIELD_NAME = "0"
1968
CONFD_REQFIELD_IP = "1"
1969
CONFD_REQFIELD_MNODE_PIP = "2"
1970

    
1971
CONFD_REQS = frozenset([
1972
  CONFD_REQ_PING,
1973
  CONFD_REQ_NODE_ROLE_BYNAME,
1974
  CONFD_REQ_NODE_PIP_BY_INSTANCE_IP,
1975
  CONFD_REQ_CLUSTER_MASTER,
1976
  CONFD_REQ_NODE_PIP_LIST,
1977
  CONFD_REQ_MC_PIP_LIST,
1978
  CONFD_REQ_INSTANCES_IPS_LIST,
1979
  ])
1980

    
1981
CONFD_REPL_STATUS_OK = 0
1982
CONFD_REPL_STATUS_ERROR = 1
1983
CONFD_REPL_STATUS_NOTIMPLEMENTED = 2
1984

    
1985
CONFD_REPL_STATUSES = frozenset([
1986
  CONFD_REPL_STATUS_OK,
1987
  CONFD_REPL_STATUS_ERROR,
1988
  CONFD_REPL_STATUS_NOTIMPLEMENTED,
1989
  ])
1990

    
1991
(CONFD_NODE_ROLE_MASTER,
1992
 CONFD_NODE_ROLE_CANDIDATE,
1993
 CONFD_NODE_ROLE_OFFLINE,
1994
 CONFD_NODE_ROLE_DRAINED,
1995
 CONFD_NODE_ROLE_REGULAR,
1996
 ) = range(5)
1997

    
1998
# A few common errors for confd
1999
CONFD_ERROR_UNKNOWN_ENTRY = 1
2000
CONFD_ERROR_INTERNAL = 2
2001
CONFD_ERROR_ARGUMENT = 3
2002

    
2003
# Each request is "salted" by the current timestamp.
2004
# This constants decides how many seconds of skew to accept.
2005
# TODO: make this a default and allow the value to be more configurable
2006
CONFD_MAX_CLOCK_SKEW = 2 * NODE_MAX_CLOCK_SKEW
2007

    
2008
# When we haven't reloaded the config for more than this amount of seconds, we
2009
# force a test to see if inotify is betraying us.
2010
CONFD_CONFIG_RELOAD_TIMEOUT = 60
2011

    
2012
# If we receive more than one update in this amount of seconds, we move to
2013
# polling every RATELIMIT seconds, rather than relying on inotify, to be able
2014
# to serve more requests.
2015
CONFD_CONFIG_RELOAD_RATELIMIT = 2
2016

    
2017
# Magic number prepended to all confd queries.
2018
# This allows us to distinguish different types of confd protocols and handle
2019
# them. For example by changing this we can move the whole payload to be
2020
# compressed, or move away from json.
2021
CONFD_MAGIC_FOURCC = "plj0"
2022

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

    
2028
# Timeout in seconds to expire pending query request in the confd client
2029
# library. We don't actually expect any answer more than 10 seconds after we
2030
# sent a request.
2031
CONFD_CLIENT_EXPIRE_TIMEOUT = 10
2032

    
2033
# Maximum UDP datagram size.
2034
# On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
2035
# On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
2036
#   (assuming we can't use jumbo frames)
2037
# We just set this to 60K, which should be enough
2038
MAX_UDP_DATA_SIZE = 61440
2039

    
2040
# User-id pool minimum/maximum acceptable user-ids.
2041
UIDPOOL_UID_MIN = 0
2042
UIDPOOL_UID_MAX = 2 ** 32 - 1 # Assuming 32 bit user-ids
2043

    
2044
# Name or path of the pgrep command
2045
PGREP = "pgrep"
2046

    
2047
# Name of the node group that gets created at cluster init or upgrade
2048
INITIAL_NODE_GROUP_NAME = "default"
2049

    
2050
# Possible values for NodeGroup.alloc_policy
2051
ALLOC_POLICY_PREFERRED = "preferred"
2052
ALLOC_POLICY_LAST_RESORT = "last_resort"
2053
ALLOC_POLICY_UNALLOCABLE = "unallocable"
2054
VALID_ALLOC_POLICIES = [
2055
  ALLOC_POLICY_PREFERRED,
2056
  ALLOC_POLICY_LAST_RESORT,
2057
  ALLOC_POLICY_UNALLOCABLE,
2058
  ]
2059

    
2060
# Temporary external/shared storage parameters
2061
BLOCKDEV_DRIVER_MANUAL = "manual"
2062

    
2063
# qemu-img path, required for ovfconverter
2064
QEMUIMG_PATH = _autoconf.QEMUIMG_PATH
2065

    
2066
# Whether htools was enabled at compilation time
2067
HTOOLS = _autoconf.HTOOLS
2068
# The hail iallocator
2069
IALLOC_HAIL = "hail"
2070

    
2071
# Fake opcodes for functions that have hooks attached to them via
2072
# backend.RunLocalHooks
2073
FAKE_OP_MASTER_TURNUP = "OP_CLUSTER_IP_TURNUP"
2074
FAKE_OP_MASTER_TURNDOWN = "OP_CLUSTER_IP_TURNDOWN"
2075

    
2076
# Do not re-export imported modules
2077
del re, _vcsversion, _autoconf, socket