Statistics
| Branch: | Tag: | Revision:

root / lib / constants.py @ b8203e1e

History | View | Annotate | Download (55 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
CPU_PINNING_ALL_KVM = 0xFFFFFFFF
124

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

    
131

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

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

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

    
194
#: File for per-group instance status, merged into L{INSTANCE_STATUS_FILE} by
195
#: per-group processes
196
WATCHER_GROUP_INSTANCE_STATUS_FILE = DATA_DIR + "/watcher.%s.instance-status"
197

    
198
#: File containing Unix timestamp until which watcher should be paused
199
WATCHER_PAUSEFILE = DATA_DIR + "/watcher.pause"
200

    
201
# Master IP address setup scripts paths (default and user-provided)
202
DEFAULT_MASTER_SETUP_SCRIPT = TOOLSDIR + "/master-ip-setup"
203
EXTERNAL_MASTER_SETUP_SCRIPT = USER_SCRIPTS_DIR + "/master-ip-setup"
204

    
205
ALL_CERT_FILES = frozenset([
206
  NODED_CERT_FILE,
207
  RAPI_CERT_FILE,
208
  SPICE_CERT_FILE,
209
  SPICE_CACERT_FILE,
210
  ])
211

    
212
MASTER_SOCKET = SOCKET_DIR + "/ganeti-master"
213

    
214
NODED = "ganeti-noded"
215
CONFD = "ganeti-confd"
216
RAPI = "ganeti-rapi"
217
MASTERD = "ganeti-masterd"
218
# used in the ganeti-nbma project
219
NLD = "ganeti-nld"
220

    
221
DAEMONS_PORTS = {
222
  # daemon-name: ("proto", "default-port")
223
  NODED: ("tcp", 1811),
224
  CONFD: ("udp", 1814),
225
  RAPI: ("tcp", 5080),
226
  "ssh": ("tcp", 22),
227
  # used in the ganeti-nbma project
228
  NLD: ("udp", 1816),
229
}
230
DEFAULT_NODED_PORT = DAEMONS_PORTS[NODED][1]
231
DEFAULT_CONFD_PORT = DAEMONS_PORTS[CONFD][1]
232
DEFAULT_RAPI_PORT = DAEMONS_PORTS[RAPI][1]
233
# used in the ganeti-nbma project
234
DEFAULT_NLD_PORT = DAEMONS_PORTS[NLD][1]
235

    
236
FIRST_DRBD_PORT = 11000
237
LAST_DRBD_PORT = 14999
238
MASTER_SCRIPT = "ganeti-master"
239

    
240
LOG_DIR = _autoconf.LOCALSTATEDIR + "/log/ganeti/"
241
DAEMONS_LOGFILES = {
242
  # "daemon-name": "logfile"
243
  NODED: LOG_DIR + "node-daemon.log",
244
  CONFD: LOG_DIR + "conf-daemon.log",
245
  RAPI: LOG_DIR + "rapi-daemon.log",
246
  MASTERD: LOG_DIR + "master-daemon.log",
247
  # used in the ganeti-nbma project
248
  NLD: LOG_DIR + "nl-daemon.log",
249
  }
250

    
251
LOG_OS_DIR = LOG_DIR + "os"
252
LOG_WATCHER = LOG_DIR + "watcher.log"
253
LOG_COMMANDS = LOG_DIR + "commands.log"
254
LOG_BURNIN = LOG_DIR + "burnin.log"
255
LOG_SETUP_SSH = LOG_DIR + "setup-ssh.log"
256

    
257
DEV_CONSOLE = "/dev/console"
258

    
259
PROC_MOUNTS = "/proc/mounts"
260

    
261
# Local UniX Interface related constants
262
LUXI_EOM = "\3"
263
LUXI_VERSION = CONFIG_VERSION
264

    
265
# one of "no", "yes", "only"
266
SYSLOG_USAGE = _autoconf.SYSLOG_USAGE
267
SYSLOG_NO = "no"
268
SYSLOG_YES = "yes"
269
SYSLOG_ONLY = "only"
270
SYSLOG_SOCKET = "/dev/log"
271

    
272
OS_SEARCH_PATH = _autoconf.OS_SEARCH_PATH
273
EXPORT_DIR = _autoconf.EXPORT_DIR
274

    
275
EXPORT_CONF_FILE = "config.ini"
276

    
277
XEN_BOOTLOADER = _autoconf.XEN_BOOTLOADER
278
XEN_KERNEL = _autoconf.XEN_KERNEL
279
XEN_INITRD = _autoconf.XEN_INITRD
280
XEN_CMD = "xm"
281

    
282
KVM_PATH = _autoconf.KVM_PATH
283
KVM_KERNEL = _autoconf.KVM_KERNEL
284
SOCAT_PATH = _autoconf.SOCAT_PATH
285
SOCAT_USE_ESCAPE = _autoconf.SOCAT_USE_ESCAPE
286
SOCAT_USE_COMPRESS = _autoconf.SOCAT_USE_COMPRESS
287
SOCAT_ESCAPE_CODE = "0x1d"
288

    
289
#: Console as SSH command
290
CONS_SSH = "ssh"
291

    
292
#: Console as VNC server
293
CONS_VNC = "vnc"
294

    
295
#: Console as SPICE server
296
CONS_SPICE = "spice"
297

    
298
#: Display a message for console access
299
CONS_MESSAGE = "msg"
300

    
301
#: All console types
302
CONS_ALL = frozenset([CONS_SSH, CONS_VNC, CONS_SPICE, CONS_MESSAGE])
303

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

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

    
317
# Digest used to sign certificates ("openssl x509" uses SHA1 by default)
318
X509_CERT_SIGN_DIGEST = "SHA1"
319

    
320
# Default validity of certificates in days
321
X509_CERT_DEFAULT_VALIDITY = 365 * 5
322

    
323
# commonName (CN) used in certificates
324
X509_CERT_CN = "ganeti.example.com"
325

    
326
X509_CERT_SIGNATURE_HEADER = "X-Ganeti-Signature"
327

    
328
IMPORT_EXPORT_DAEMON = _autoconf.PKGLIBDIR + "/import-export"
329

    
330
# Import/export daemon mode
331
IEM_IMPORT = "import"
332
IEM_EXPORT = "export"
333

    
334
# Import/export transport compression
335
IEC_NONE = "none"
336
IEC_GZIP = "gzip"
337
IEC_ALL = frozenset([
338
  IEC_NONE,
339
  IEC_GZIP,
340
  ])
341

    
342
IE_CUSTOM_SIZE = "fd"
343

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

    
346
# Import/export I/O
347
# Direct file I/O, equivalent to a shell's I/O redirection using '<' or '>'
348
IEIO_FILE = "file"
349
# Raw block device I/O using "dd"
350
IEIO_RAW_DISK = "raw"
351
# OS definition import/export script
352
IEIO_SCRIPT = "script"
353

    
354
VALUE_DEFAULT = "default"
355
VALUE_AUTO = "auto"
356
VALUE_GENERATE = "generate"
357
VALUE_NONE = "none"
358
VALUE_TRUE = "true"
359
VALUE_FALSE = "false"
360

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

    
364
# hooks-related constants
365
HOOKS_BASE_DIR = CONF_DIR + "/hooks"
366
HOOKS_PHASE_PRE = "pre"
367
HOOKS_PHASE_POST = "post"
368
HOOKS_NAME_CFGUPDATE = "config-update"
369
HOOKS_NAME_WATCHER = "watcher"
370
HOOKS_VERSION = 2
371
HOOKS_PATH = "/sbin:/bin:/usr/sbin:/usr/bin"
372

    
373
# hooks subject type (what object type does the LU deal with)
374
HTYPE_CLUSTER = "CLUSTER"
375
HTYPE_NODE = "NODE"
376
HTYPE_GROUP = "GROUP"
377
HTYPE_INSTANCE = "INSTANCE"
378

    
379
HKR_SKIP = 0
380
HKR_FAIL = 1
381
HKR_SUCCESS = 2
382

    
383
# Storage types
384
ST_FILE = "file"
385
ST_LVM_PV = "lvm-pv"
386
ST_LVM_VG = "lvm-vg"
387

    
388
# Storage fields
389
# first two are valid in LU context only, not passed to backend
390
SF_NODE = "node"
391
SF_TYPE = "type"
392
# and the rest are valid in backend
393
SF_NAME = "name"
394
SF_SIZE = "size"
395
SF_FREE = "free"
396
SF_USED = "used"
397
SF_ALLOCATABLE = "allocatable"
398

    
399
# Storage operations
400
SO_FIX_CONSISTENCY = "fix-consistency"
401

    
402
# Available fields per storage type
403
VALID_STORAGE_FIELDS = frozenset([
404
  SF_NAME,
405
  SF_TYPE,
406
  SF_SIZE,
407
  SF_USED,
408
  SF_FREE,
409
  SF_ALLOCATABLE
410
  ])
411

    
412
VALID_STORAGE_TYPES = frozenset([ST_FILE, ST_LVM_PV, ST_LVM_VG])
413

    
414
MODIFIABLE_STORAGE_FIELDS = {
415
  ST_LVM_PV: frozenset([SF_ALLOCATABLE]),
416
  }
417

    
418
VALID_STORAGE_OPERATIONS = {
419
  ST_LVM_VG: frozenset([SO_FIX_CONSISTENCY]),
420
  }
421

    
422
# Local disk status
423
# Note: Code depends on LDS_OKAY < LDS_UNKNOWN < LDS_FAULTY
424
(LDS_OKAY,
425
 LDS_UNKNOWN,
426
 LDS_FAULTY) = range(1, 4)
427

    
428
# disk template types
429
DT_DISKLESS = "diskless"
430
DT_PLAIN = "plain"
431
DT_DRBD8 = "drbd"
432
DT_FILE = "file"
433
DT_SHARED_FILE = "sharedfile"
434
DT_BLOCK = "blockdev"
435
DT_RBD = "rbd"
436

    
437
# the set of network-mirrored disk templates
438
DTS_INT_MIRROR = frozenset([DT_DRBD8])
439

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

    
443
# the set of non-lvm-based disk templates
444
DTS_NOT_LVM = frozenset([DT_DISKLESS, DT_FILE, DT_SHARED_FILE,
445
                         DT_BLOCK, DT_RBD])
446

    
447
# the set of disk templates which can be grown
448
DTS_GROWABLE = frozenset([DT_PLAIN, DT_DRBD8, DT_FILE, DT_SHARED_FILE, DT_RBD])
449

    
450
# the set of disk templates that allow adoption
451
DTS_MAY_ADOPT = frozenset([DT_PLAIN, DT_BLOCK])
452

    
453
# the set of disk templates that *must* use adoption
454
DTS_MUST_ADOPT = frozenset([DT_BLOCK])
455

    
456
# the set of disk templates that allow migrations
457
DTS_MIRRORED = frozenset.union(DTS_INT_MIRROR, DTS_EXT_MIRROR)
458

    
459
# the set of file based disk templates
460
DTS_FILEBASED = frozenset([DT_FILE, DT_SHARED_FILE])
461

    
462
# logical disk types
463
LD_LV = "lvm"
464
LD_DRBD8 = "drbd8"
465
LD_FILE = "file"
466
LD_BLOCKDEV = "blockdev"
467
LD_RBD = "rbd"
468
LOGICAL_DISK_TYPES = frozenset([
469
  LD_LV,
470
  LD_DRBD8,
471
  LD_FILE,
472
  LD_BLOCKDEV,
473
  LD_RBD,
474
  ])
475

    
476
LDS_BLOCK = frozenset([LD_LV, LD_DRBD8, LD_BLOCKDEV, LD_RBD])
477

    
478
# drbd constants
479
DRBD_HMAC_ALG = "md5"
480
DRBD_NET_PROTOCOL = "C"
481

    
482
# drbd barrier types
483
DRBD_B_NONE = "n"
484
DRBD_B_DISK_BARRIERS = "b"
485
DRBD_B_DISK_DRAIN = "d"
486
DRBD_B_DISK_FLUSH = "f"
487

    
488
# Valid barrier combinations: "n" or any non-null subset of "bfd"
489
DRBD_VALID_BARRIER_OPT = frozenset([
490
  frozenset([DRBD_B_NONE]),
491
  frozenset([DRBD_B_DISK_BARRIERS]),
492
  frozenset([DRBD_B_DISK_DRAIN]),
493
  frozenset([DRBD_B_DISK_FLUSH]),
494
  frozenset([DRBD_B_DISK_DRAIN, DRBD_B_DISK_FLUSH]),
495
  frozenset([DRBD_B_DISK_DRAIN, DRBD_B_DISK_FLUSH]),
496
  frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_DRAIN]),
497
  frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_FLUSH]),
498
  frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_FLUSH, DRBD_B_DISK_DRAIN]),
499
  ])
500

    
501
# rbd tool command
502
RBD_CMD = "rbd"
503

    
504
# file backend driver
505
FD_LOOP = "loop"
506
FD_BLKTAP = "blktap"
507

    
508
# the set of drbd-like disk types
509
LDS_DRBD = frozenset([LD_DRBD8])
510

    
511
# disk access mode
512
DISK_RDONLY = "ro"
513
DISK_RDWR = "rw"
514
DISK_ACCESS_SET = frozenset([DISK_RDONLY, DISK_RDWR])
515

    
516
# disk replacement mode
517
REPLACE_DISK_PRI = "replace_on_primary"    # replace disks on primary
518
REPLACE_DISK_SEC = "replace_on_secondary"  # replace disks on secondary
519
REPLACE_DISK_CHG = "replace_new_secondary" # change secondary node
520
REPLACE_DISK_AUTO = "replace_auto"
521
REPLACE_MODES = frozenset([
522
  REPLACE_DISK_PRI,
523
  REPLACE_DISK_SEC,
524
  REPLACE_DISK_CHG,
525
  REPLACE_DISK_AUTO,
526
  ])
527

    
528
# Instance export mode
529
EXPORT_MODE_LOCAL = "local"
530
EXPORT_MODE_REMOTE = "remote"
531
EXPORT_MODES = frozenset([
532
  EXPORT_MODE_LOCAL,
533
  EXPORT_MODE_REMOTE,
534
  ])
535

    
536
# Lock recalculate mode
537
LOCKS_REPLACE = "replace"
538
LOCKS_APPEND = "append"
539

    
540
# Lock timeout (sum) before we should go into blocking acquire (still
541
# can be reset by priority change); computed as max time (10 hours)
542
# before we should actually go into blocking acquire given that we
543
# start from default priority level; in seconds
544
LOCK_ATTEMPTS_TIMEOUT = 10 * 3600 / 20.0
545
LOCK_ATTEMPTS_MAXWAIT = 15.0
546
LOCK_ATTEMPTS_MINWAIT = 1.0
547

    
548
# instance creation modes
549
INSTANCE_CREATE = "create"
550
INSTANCE_IMPORT = "import"
551
INSTANCE_REMOTE_IMPORT = "remote-import"
552
INSTANCE_CREATE_MODES = frozenset([
553
  INSTANCE_CREATE,
554
  INSTANCE_IMPORT,
555
  INSTANCE_REMOTE_IMPORT,
556
  ])
557

    
558
# Remote import/export handshake message and version
559
RIE_VERSION = 0
560
RIE_HANDSHAKE = "Hi, I'm Ganeti"
561

    
562
# Remote import/export certificate validity in seconds
563
RIE_CERT_VALIDITY = 24 * 60 * 60
564

    
565
# Overall timeout for establishing connection
566
RIE_CONNECT_TIMEOUT = 180
567

    
568
# Export only: how long to wait per connection attempt (seconds)
569
RIE_CONNECT_ATTEMPT_TIMEOUT = 20
570

    
571
# Export only: number of attempts to connect
572
RIE_CONNECT_RETRIES = 10
573

    
574
#: Give child process up to 5 seconds to exit after sending a signal
575
CHILD_LINGER_TIMEOUT = 5.0
576

    
577
DISK_TEMPLATES = frozenset([
578
  DT_DISKLESS,
579
  DT_PLAIN,
580
  DT_DRBD8,
581
  DT_FILE,
582
  DT_SHARED_FILE,
583
  DT_BLOCK,
584
  DT_RBD
585
  ])
586

    
587
FILE_DRIVER = frozenset([FD_LOOP, FD_BLKTAP])
588

    
589
# import/export config options
590
INISECT_EXP = "export"
591
INISECT_INS = "instance"
592
INISECT_HYP = "hypervisor"
593
INISECT_BEP = "backend"
594
INISECT_OSP = "os"
595

    
596
# dynamic device modification
597
DDM_ADD = "add"
598
DDM_MODIFY = "modify"
599
DDM_REMOVE = "remove"
600
DDMS_VALUES = frozenset([DDM_ADD, DDM_REMOVE])
601
DDMS_VALUES_WITH_MODIFY = (DDMS_VALUES | frozenset([
602
  DDM_MODIFY,
603
  ]))
604
# TODO: DDM_SWAP, DDM_MOVE?
605

    
606
# common exit codes
607
EXIT_SUCCESS = 0
608
EXIT_FAILURE = 1
609
EXIT_NOTCLUSTER = 5
610
EXIT_NOTMASTER = 11
611
EXIT_NODESETUP_ERROR = 12
612
EXIT_CONFIRMATION = 13 # need user confirmation
613

    
614
#: Exit code for query operations with unknown fields
615
EXIT_UNKNOWN_FIELD = 14
616

    
617
# tags
618
TAG_CLUSTER = "cluster"
619
TAG_NODEGROUP = "nodegroup"
620
TAG_NODE = "node"
621
TAG_INSTANCE = "instance"
622
VALID_TAG_TYPES = frozenset([
623
  TAG_CLUSTER,
624
  TAG_NODEGROUP,
625
  TAG_NODE,
626
  TAG_INSTANCE,
627
  ])
628
MAX_TAG_LEN = 128
629
MAX_TAGS_PER_OBJ = 4096
630

    
631
# others
632
DEFAULT_BRIDGE = "xen-br0"
633
CLASSIC_DRBD_SYNC_SPEED = 60 * 1024  # 60 MiB, expressed in KiB
634
IP4_ADDRESS_LOCALHOST = "127.0.0.1"
635
IP4_ADDRESS_ANY = "0.0.0.0"
636
IP6_ADDRESS_LOCALHOST = "::1"
637
IP6_ADDRESS_ANY = "::"
638
IP4_VERSION = 4
639
IP6_VERSION = 6
640
VALID_IP_VERSIONS = frozenset([IP4_VERSION, IP6_VERSION])
641
# for export to htools
642
IP4_FAMILY = socket.AF_INET
643
IP6_FAMILY = socket.AF_INET6
644

    
645
TCP_PING_TIMEOUT = 10
646
GANETI_RUNAS = "root"
647
DEFAULT_VG = "xenvg"
648
DEFAULT_DRBD_HELPER = "/bin/true"
649
MIN_VG_SIZE = 20480
650
DEFAULT_MAC_PREFIX = "aa:00:00"
651
# default maximum instance wait time, in seconds.
652
DEFAULT_SHUTDOWN_TIMEOUT = 120
653
NODE_MAX_CLOCK_SKEW = 150
654
# Time for an intra-cluster disk transfer to wait for a connection
655
DISK_TRANSFER_CONNECT_TIMEOUT = 60
656
# Disk index separator
657
DISK_SEPARATOR = _autoconf.DISK_SEPARATOR
658
IP_COMMAND_PATH = _autoconf.IP_PATH
659

    
660
#: Key for job IDs in opcode result
661
JOB_IDS_KEY = "jobs"
662

    
663
# runparts results
664
(RUNPARTS_SKIP,
665
 RUNPARTS_RUN,
666
 RUNPARTS_ERR) = range(3)
667

    
668
RUNPARTS_STATUS = frozenset([RUNPARTS_SKIP, RUNPARTS_RUN, RUNPARTS_ERR])
669

    
670
# RPC constants
671
(RPC_ENCODING_NONE,
672
 RPC_ENCODING_ZLIB_BASE64) = range(2)
673

    
674
# os related constants
675
OS_SCRIPT_CREATE = "create"
676
OS_SCRIPT_IMPORT = "import"
677
OS_SCRIPT_EXPORT = "export"
678
OS_SCRIPT_RENAME = "rename"
679
OS_SCRIPT_VERIFY = "verify"
680
OS_SCRIPTS = frozenset([
681
  OS_SCRIPT_CREATE,
682
  OS_SCRIPT_IMPORT,
683
  OS_SCRIPT_EXPORT,
684
  OS_SCRIPT_RENAME,
685
  OS_SCRIPT_VERIFY
686
  ])
687

    
688
OS_API_FILE = "ganeti_api_version"
689
OS_VARIANTS_FILE = "variants.list"
690
OS_PARAMETERS_FILE = "parameters.list"
691

    
692
OS_VALIDATE_PARAMETERS = "parameters"
693
OS_VALIDATE_CALLS = frozenset([OS_VALIDATE_PARAMETERS])
694

    
695
# ssh constants
696
SSH_CONFIG_DIR = _autoconf.SSH_CONFIG_DIR
697
SSH_HOST_DSA_PRIV = SSH_CONFIG_DIR + "/ssh_host_dsa_key"
698
SSH_HOST_DSA_PUB = SSH_HOST_DSA_PRIV + ".pub"
699
SSH_HOST_RSA_PRIV = SSH_CONFIG_DIR + "/ssh_host_rsa_key"
700
SSH_HOST_RSA_PUB = SSH_HOST_RSA_PRIV + ".pub"
701
SSH = "ssh"
702
SCP = "scp"
703

    
704
# reboot types
705
INSTANCE_REBOOT_SOFT = "soft"
706
INSTANCE_REBOOT_HARD = "hard"
707
INSTANCE_REBOOT_FULL = "full"
708

    
709
REBOOT_TYPES = frozenset([
710
  INSTANCE_REBOOT_SOFT,
711
  INSTANCE_REBOOT_HARD,
712
  INSTANCE_REBOOT_FULL
713
  ])
714

    
715
# instance reboot behaviors
716
INSTANCE_REBOOT_ALLOWED = "reboot"
717
INSTANCE_REBOOT_EXIT = "exit"
718

    
719
REBOOT_BEHAVIORS = frozenset([
720
  INSTANCE_REBOOT_ALLOWED,
721
  INSTANCE_REBOOT_EXIT
722
  ])
723

    
724
VTYPE_STRING = "string"
725
VTYPE_MAYBE_STRING = "maybe-string"
726
VTYPE_BOOL = "bool"
727
VTYPE_SIZE = "size" # size, in MiBs
728
VTYPE_INT = "int"
729
ENFORCEABLE_TYPES = frozenset([
730
  VTYPE_STRING,
731
  VTYPE_MAYBE_STRING,
732
  VTYPE_BOOL,
733
  VTYPE_SIZE,
734
  VTYPE_INT,
735
  ])
736

    
737
# Constant representing that the user does not specify any IP version
738
IFACE_NO_IP_VERSION_SPECIFIED = 0
739

    
740
# HV parameter names (global namespace)
741
HV_BOOT_ORDER = "boot_order"
742
HV_CDROM_IMAGE_PATH = "cdrom_image_path"
743
HV_KVM_CDROM2_IMAGE_PATH = "cdrom2_image_path"
744
HV_KVM_FLOPPY_IMAGE_PATH = "floppy_image_path"
745
HV_NIC_TYPE = "nic_type"
746
HV_DISK_TYPE = "disk_type"
747
HV_KVM_CDROM_DISK_TYPE = "cdrom_disk_type"
748
HV_VNC_BIND_ADDRESS = "vnc_bind_address"
749
HV_VNC_PASSWORD_FILE = "vnc_password_file"
750
HV_VNC_TLS = "vnc_tls"
751
HV_VNC_X509 = "vnc_x509_path"
752
HV_VNC_X509_VERIFY = "vnc_x509_verify"
753
HV_KVM_SPICE_BIND = "spice_bind"
754
HV_KVM_SPICE_IP_VERSION = "spice_ip_version"
755
HV_KVM_SPICE_PASSWORD_FILE = "spice_password_file"
756
HV_KVM_SPICE_LOSSLESS_IMG_COMPR = "spice_image_compression"
757
HV_KVM_SPICE_JPEG_IMG_COMPR = "spice_jpeg_wan_compression"
758
HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR = "spice_zlib_glz_wan_compression"
759
HV_KVM_SPICE_STREAMING_VIDEO_DETECTION = "spice_streaming_video"
760
HV_KVM_SPICE_AUDIO_COMPR = "spice_playback_compression"
761
HV_KVM_SPICE_USE_TLS = "spice_use_tls"
762
HV_KVM_SPICE_TLS_CIPHERS = "spice_tls_ciphers"
763
HV_KVM_SPICE_USE_VDAGENT = "spice_use_vdagent"
764
HV_ACPI = "acpi"
765
HV_PAE = "pae"
766
HV_USE_BOOTLOADER = "use_bootloader"
767
HV_BOOTLOADER_ARGS = "bootloader_args"
768
HV_BOOTLOADER_PATH = "bootloader_path"
769
HV_KERNEL_ARGS = "kernel_args"
770
HV_KERNEL_PATH = "kernel_path"
771
HV_INITRD_PATH = "initrd_path"
772
HV_ROOT_PATH = "root_path"
773
HV_SERIAL_CONSOLE = "serial_console"
774
HV_USB_MOUSE = "usb_mouse"
775
HV_KEYMAP = "keymap"
776
HV_DEVICE_MODEL = "device_model"
777
HV_INIT_SCRIPT = "init_script"
778
HV_MIGRATION_PORT = "migration_port"
779
HV_MIGRATION_BANDWIDTH = "migration_bandwidth"
780
HV_MIGRATION_DOWNTIME = "migration_downtime"
781
HV_MIGRATION_MODE = "migration_mode"
782
HV_USE_LOCALTIME = "use_localtime"
783
HV_DISK_CACHE = "disk_cache"
784
HV_SECURITY_MODEL = "security_model"
785
HV_SECURITY_DOMAIN = "security_domain"
786
HV_KVM_FLAG = "kvm_flag"
787
HV_VHOST_NET = "vhost_net"
788
HV_KVM_USE_CHROOT = "use_chroot"
789
HV_CPU_MASK = "cpu_mask"
790
HV_MEM_PATH = "mem_path"
791
HV_BLOCKDEV_PREFIX = "blockdev_prefix"
792
HV_REBOOT_BEHAVIOR = "reboot_behavior"
793

    
794
HVS_PARAMETER_TYPES = {
795
  HV_BOOT_ORDER: VTYPE_STRING,
796
  HV_KVM_FLOPPY_IMAGE_PATH: VTYPE_STRING,
797
  HV_CDROM_IMAGE_PATH: VTYPE_STRING,
798
  HV_KVM_CDROM2_IMAGE_PATH: VTYPE_STRING,
799
  HV_NIC_TYPE: VTYPE_STRING,
800
  HV_DISK_TYPE: VTYPE_STRING,
801
  HV_KVM_CDROM_DISK_TYPE: VTYPE_STRING,
802
  HV_VNC_PASSWORD_FILE: VTYPE_STRING,
803
  HV_VNC_BIND_ADDRESS: VTYPE_STRING,
804
  HV_VNC_TLS: VTYPE_BOOL,
805
  HV_VNC_X509: VTYPE_STRING,
806
  HV_VNC_X509_VERIFY: VTYPE_BOOL,
807
  HV_KVM_SPICE_BIND: VTYPE_STRING,
808
  HV_KVM_SPICE_IP_VERSION: VTYPE_INT,
809
  HV_KVM_SPICE_PASSWORD_FILE: VTYPE_STRING,
810
  HV_KVM_SPICE_LOSSLESS_IMG_COMPR: VTYPE_STRING,
811
  HV_KVM_SPICE_JPEG_IMG_COMPR: VTYPE_STRING,
812
  HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR: VTYPE_STRING,
813
  HV_KVM_SPICE_STREAMING_VIDEO_DETECTION: VTYPE_STRING,
814
  HV_KVM_SPICE_AUDIO_COMPR: VTYPE_BOOL,
815
  HV_KVM_SPICE_USE_TLS: VTYPE_BOOL,
816
  HV_KVM_SPICE_TLS_CIPHERS: VTYPE_STRING,
817
  HV_KVM_SPICE_USE_VDAGENT: VTYPE_BOOL,
818
  HV_ACPI: VTYPE_BOOL,
819
  HV_PAE: VTYPE_BOOL,
820
  HV_USE_BOOTLOADER: VTYPE_BOOL,
821
  HV_BOOTLOADER_PATH: VTYPE_STRING,
822
  HV_BOOTLOADER_ARGS: VTYPE_STRING,
823
  HV_KERNEL_PATH: VTYPE_STRING,
824
  HV_KERNEL_ARGS: VTYPE_STRING,
825
  HV_INITRD_PATH: VTYPE_STRING,
826
  HV_ROOT_PATH: VTYPE_MAYBE_STRING,
827
  HV_SERIAL_CONSOLE: VTYPE_BOOL,
828
  HV_USB_MOUSE: VTYPE_STRING,
829
  HV_KEYMAP: VTYPE_STRING,
830
  HV_DEVICE_MODEL: VTYPE_STRING,
831
  HV_INIT_SCRIPT: VTYPE_STRING,
832
  HV_MIGRATION_PORT: VTYPE_INT,
833
  HV_MIGRATION_BANDWIDTH: VTYPE_INT,
834
  HV_MIGRATION_DOWNTIME: VTYPE_INT,
835
  HV_MIGRATION_MODE: VTYPE_STRING,
836
  HV_USE_LOCALTIME: VTYPE_BOOL,
837
  HV_DISK_CACHE: VTYPE_STRING,
838
  HV_SECURITY_MODEL: VTYPE_STRING,
839
  HV_SECURITY_DOMAIN: VTYPE_STRING,
840
  HV_KVM_FLAG: VTYPE_STRING,
841
  HV_VHOST_NET: VTYPE_BOOL,
842
  HV_KVM_USE_CHROOT: VTYPE_BOOL,
843
  HV_CPU_MASK: VTYPE_STRING,
844
  HV_MEM_PATH: VTYPE_STRING,
845
  HV_BLOCKDEV_PREFIX: VTYPE_STRING,
846
  HV_REBOOT_BEHAVIOR: VTYPE_STRING,
847
  }
848

    
849
HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
850

    
851
# Migration statuses
852
HV_MIGRATION_COMPLETED = "completed"
853
HV_MIGRATION_ACTIVE = "active"
854
HV_MIGRATION_FAILED = "failed"
855
HV_MIGRATION_CANCELLED = "cancelled"
856

    
857
HV_MIGRATION_VALID_STATUSES = frozenset([
858
  HV_MIGRATION_COMPLETED,
859
  HV_MIGRATION_ACTIVE,
860
  HV_MIGRATION_FAILED,
861
  HV_MIGRATION_CANCELLED,
862
  ])
863

    
864
HV_MIGRATION_FAILED_STATUSES = frozenset([
865
  HV_MIGRATION_FAILED,
866
  HV_MIGRATION_CANCELLED,
867
  ])
868

    
869
# KVM-specific statuses
870
HV_KVM_MIGRATION_VALID_STATUSES = HV_MIGRATION_VALID_STATUSES
871

    
872
# Node info keys
873
HV_NODEINFO_KEY_VERSION = "hv_version"
874

    
875
# Hypervisor state
876
HVST_MEMORY_TOTAL = "mem_total"
877
HVST_MEMORY_NODE = "mem_node"
878
HVST_MEMORY_HV = "mem_hv"
879
HVST_CPU_TOTAL = "cpu_total"
880
HVST_CPU_NODE = "cpu_node"
881

    
882
HVST_DEFAULTS = {
883
  HVST_MEMORY_TOTAL: 0,
884
  HVST_MEMORY_NODE: 0,
885
  HVST_MEMORY_HV: 0,
886
  HVST_CPU_TOTAL: 1,
887
  HVST_CPU_NODE: 1,
888
  }
889

    
890
HVSTS_PARAMETER_TYPES = {
891
  HVST_MEMORY_TOTAL: VTYPE_INT,
892
  HVST_MEMORY_NODE: VTYPE_INT,
893
  HVST_MEMORY_HV: VTYPE_INT,
894
  HVST_CPU_TOTAL: VTYPE_INT,
895
  HVST_CPU_NODE: VTYPE_INT,
896
  }
897

    
898
HVSTS_PARAMETERS = frozenset(HVSTS_PARAMETER_TYPES.keys())
899

    
900
# Disk state
901
DS_DISK_TOTAL = "disk_total"
902
DS_DISK_RESERVED = "disk_reserved"
903
DS_DISK_OVERHEAD = "disk_overhead"
904

    
905
DS_DEFAULTS = {
906
  DS_DISK_TOTAL: 0,
907
  DS_DISK_RESERVED: 0,
908
  DS_DISK_OVERHEAD: 0,
909
  }
910

    
911
DSS_PARAMETER_TYPES = {
912
  DS_DISK_TOTAL: VTYPE_INT,
913
  DS_DISK_RESERVED: VTYPE_INT,
914
  DS_DISK_OVERHEAD: VTYPE_INT,
915
  }
916

    
917
DSS_PARAMETERS = frozenset(DSS_PARAMETER_TYPES.keys())
918
DS_VALID_TYPES = frozenset([LD_LV])
919

    
920
# Backend parameter names
921
BE_MEMORY = "memory" # deprecated and replaced by max and min mem
922
BE_MAXMEM = "maxmem"
923
BE_MINMEM = "minmem"
924
BE_VCPUS = "vcpus"
925
BE_AUTO_BALANCE = "auto_balance"
926
BE_ALWAYS_FAILOVER = "always_failover"
927
BE_SPINDLE_USE = "spindle_use"
928

    
929
BES_PARAMETER_TYPES = {
930
  BE_MAXMEM: VTYPE_SIZE,
931
  BE_MINMEM: VTYPE_SIZE,
932
  BE_VCPUS: VTYPE_INT,
933
  BE_AUTO_BALANCE: VTYPE_BOOL,
934
  BE_ALWAYS_FAILOVER: VTYPE_BOOL,
935
  BE_SPINDLE_USE: VTYPE_INT,
936
  }
937

    
938
BES_PARAMETER_COMPAT = {
939
  BE_MEMORY: VTYPE_SIZE,
940
  }
941
BES_PARAMETER_COMPAT.update(BES_PARAMETER_TYPES)
942

    
943
BES_PARAMETERS = frozenset(BES_PARAMETER_TYPES.keys())
944

    
945
# instance specs
946
ISPEC_MEM_SIZE = "memory-size"
947
ISPEC_CPU_COUNT = "cpu-count"
948
ISPEC_DISK_COUNT = "disk-count"
949
ISPEC_DISK_SIZE = "disk-size"
950
ISPEC_NIC_COUNT = "nic-count"
951
ISPEC_SPINDLE_USE = "spindle-use"
952

    
953
ISPECS_PARAMETER_TYPES = {
954
  ISPEC_MEM_SIZE: VTYPE_INT,
955
  ISPEC_CPU_COUNT: VTYPE_INT,
956
  ISPEC_DISK_COUNT: VTYPE_INT,
957
  ISPEC_DISK_SIZE: VTYPE_INT,
958
  ISPEC_NIC_COUNT: VTYPE_INT,
959
  ISPEC_SPINDLE_USE: VTYPE_INT,
960
  }
961

    
962
ISPECS_PARAMETERS = frozenset(ISPECS_PARAMETER_TYPES.keys())
963

    
964
ISPECS_MIN = "min"
965
ISPECS_MAX = "max"
966
ISPECS_STD = "std"
967
IPOLICY_DTS = "disk-templates"
968
IPOLICY_VCPU_RATIO = "vcpu-ratio"
969
IPOLICY_SPINDLE_RATIO = "spindle-ratio"
970

    
971
IPOLICY_ISPECS = frozenset([
972
  ISPECS_MIN,
973
  ISPECS_MAX,
974
  ISPECS_STD,
975
  ])
976

    
977
IPOLICY_PARAMETERS = frozenset([
978
  IPOLICY_VCPU_RATIO,
979
  IPOLICY_SPINDLE_RATIO,
980
  ])
981

    
982
IPOLICY_ALL_KEYS = (IPOLICY_ISPECS |
983
                    IPOLICY_PARAMETERS |
984
                    frozenset([IPOLICY_DTS]))
985

    
986
# Node parameter names
987
ND_OOB_PROGRAM = "oob_program"
988
ND_SPINDLE_COUNT = "spindle_count"
989

    
990
NDS_PARAMETER_TYPES = {
991
  ND_OOB_PROGRAM: VTYPE_MAYBE_STRING,
992
  ND_SPINDLE_COUNT: VTYPE_INT,
993
  }
994

    
995
NDS_PARAMETERS = frozenset(NDS_PARAMETER_TYPES.keys())
996

    
997
# Logical Disks parameters
998
LDP_RESYNC_RATE = "resync-rate"
999
LDP_STRIPES = "stripes"
1000
LDP_BARRIERS = "disabled-barriers"
1001
LDP_NO_META_FLUSH = "disable-meta-flush"
1002
LDP_DEFAULT_METAVG = "default-metavg"
1003
LDP_DISK_CUSTOM = "disk-custom"
1004
LDP_NET_CUSTOM = "net-custom"
1005
LDP_DYNAMIC_RESYNC = "dynamic-resync"
1006
LDP_PLAN_AHEAD = "c-plan-ahead"
1007
LDP_FILL_TARGET = "c-fill-target"
1008
LDP_DELAY_TARGET = "c-delay-target"
1009
LDP_MAX_RATE = "c-max-rate"
1010
LDP_MIN_RATE = "c-min-rate"
1011
LDP_POOL = "pool"
1012
DISK_LD_TYPES = {
1013
  LDP_RESYNC_RATE: VTYPE_INT,
1014
  LDP_STRIPES: VTYPE_INT,
1015
  LDP_BARRIERS: VTYPE_STRING,
1016
  LDP_NO_META_FLUSH: VTYPE_BOOL,
1017
  LDP_DEFAULT_METAVG: VTYPE_STRING,
1018
  LDP_DISK_CUSTOM: VTYPE_STRING,
1019
  LDP_NET_CUSTOM: VTYPE_STRING,
1020
  LDP_DYNAMIC_RESYNC: VTYPE_BOOL,
1021
  LDP_PLAN_AHEAD: VTYPE_INT,
1022
  LDP_FILL_TARGET: VTYPE_INT,
1023
  LDP_DELAY_TARGET: VTYPE_INT,
1024
  LDP_MAX_RATE: VTYPE_INT,
1025
  LDP_MIN_RATE: VTYPE_INT,
1026
  LDP_POOL: VTYPE_STRING,
1027
  }
1028
DISK_LD_PARAMETERS = frozenset(DISK_LD_TYPES.keys())
1029

    
1030
# Disk template parameters (can be set/changed by the user via gnt-cluster and
1031
# gnt-group)
1032
DRBD_RESYNC_RATE = "resync-rate"
1033
DRBD_DATA_STRIPES = "data-stripes"
1034
DRBD_META_STRIPES = "meta-stripes"
1035
DRBD_DISK_BARRIERS = "disk-barriers"
1036
DRBD_META_BARRIERS = "meta-barriers"
1037
DRBD_DEFAULT_METAVG = "metavg"
1038
DRBD_DISK_CUSTOM = "disk-custom"
1039
DRBD_NET_CUSTOM = "net-custom"
1040
DRBD_DYNAMIC_RESYNC = "dynamic-resync"
1041
DRBD_PLAN_AHEAD = "c-plan-ahead"
1042
DRBD_FILL_TARGET = "c-fill-target"
1043
DRBD_DELAY_TARGET = "c-delay-target"
1044
DRBD_MAX_RATE = "c-max-rate"
1045
DRBD_MIN_RATE = "c-min-rate"
1046
LV_STRIPES = "stripes"
1047
RBD_POOL = "pool"
1048
DISK_DT_TYPES = {
1049
  DRBD_RESYNC_RATE: VTYPE_INT,
1050
  DRBD_DATA_STRIPES: VTYPE_INT,
1051
  DRBD_META_STRIPES: VTYPE_INT,
1052
  DRBD_DISK_BARRIERS: VTYPE_STRING,
1053
  DRBD_META_BARRIERS: VTYPE_BOOL,
1054
  DRBD_DEFAULT_METAVG: VTYPE_STRING,
1055
  DRBD_DISK_CUSTOM: VTYPE_STRING,
1056
  DRBD_NET_CUSTOM: VTYPE_STRING,
1057
  DRBD_DYNAMIC_RESYNC: VTYPE_BOOL,
1058
  DRBD_PLAN_AHEAD: VTYPE_INT,
1059
  DRBD_FILL_TARGET: VTYPE_INT,
1060
  DRBD_DELAY_TARGET: VTYPE_INT,
1061
  DRBD_MAX_RATE: VTYPE_INT,
1062
  DRBD_MIN_RATE: VTYPE_INT,
1063
  LV_STRIPES: VTYPE_INT,
1064
  RBD_POOL: VTYPE_STRING,
1065
  }
1066

    
1067
DISK_DT_PARAMETERS = frozenset(DISK_DT_TYPES.keys())
1068

    
1069
# OOB supported commands
1070
OOB_POWER_ON = "power-on"
1071
OOB_POWER_OFF = "power-off"
1072
OOB_POWER_CYCLE = "power-cycle"
1073
OOB_POWER_STATUS = "power-status"
1074
OOB_HEALTH = "health"
1075

    
1076
OOB_COMMANDS = frozenset([
1077
  OOB_POWER_ON,
1078
  OOB_POWER_OFF,
1079
  OOB_POWER_CYCLE,
1080
  OOB_POWER_STATUS,
1081
  OOB_HEALTH
1082
  ])
1083

    
1084
OOB_POWER_STATUS_POWERED = "powered"
1085

    
1086
OOB_TIMEOUT = 60 # 60 seconds
1087
OOB_POWER_DELAY = 2.0 # 2 seconds
1088

    
1089
OOB_STATUS_OK = "OK"
1090
OOB_STATUS_WARNING = "WARNING"
1091
OOB_STATUS_CRITICAL = "CRITICAL"
1092
OOB_STATUS_UNKNOWN = "UNKNOWN"
1093

    
1094
OOB_STATUSES = frozenset([
1095
  OOB_STATUS_OK,
1096
  OOB_STATUS_WARNING,
1097
  OOB_STATUS_CRITICAL,
1098
  OOB_STATUS_UNKNOWN,
1099
  ])
1100

    
1101
# Instance Parameters Profile
1102
PP_DEFAULT = "default"
1103

    
1104
# NIC_* constants are used inside the ganeti config
1105
NIC_MODE = "mode"
1106
NIC_LINK = "link"
1107

    
1108
NIC_MODE_BRIDGED = "bridged"
1109
NIC_MODE_ROUTED = "routed"
1110

    
1111
NIC_VALID_MODES = frozenset([NIC_MODE_BRIDGED, NIC_MODE_ROUTED])
1112

    
1113
NICS_PARAMETER_TYPES = {
1114
  NIC_MODE: VTYPE_STRING,
1115
  NIC_LINK: VTYPE_STRING,
1116
  }
1117

    
1118
NICS_PARAMETERS = frozenset(NICS_PARAMETER_TYPES.keys())
1119

    
1120
# IDISK_* constants are used in opcodes, to create/change disks
1121
IDISK_SIZE = "size"
1122
IDISK_MODE = "mode"
1123
IDISK_ADOPT = "adopt"
1124
IDISK_VG = "vg"
1125
IDISK_METAVG = "metavg"
1126
IDISK_PARAMS_TYPES = {
1127
  IDISK_SIZE: VTYPE_SIZE,
1128
  IDISK_MODE: VTYPE_STRING,
1129
  IDISK_ADOPT: VTYPE_STRING,
1130
  IDISK_VG: VTYPE_STRING,
1131
  IDISK_METAVG: VTYPE_STRING,
1132
  }
1133
IDISK_PARAMS = frozenset(IDISK_PARAMS_TYPES.keys())
1134

    
1135
# INIC_* constants are used in opcodes, to create/change nics
1136
INIC_MAC = "mac"
1137
INIC_IP = "ip"
1138
INIC_MODE = "mode"
1139
INIC_LINK = "link"
1140
INIC_PARAMS_TYPES = {
1141
  INIC_IP: VTYPE_MAYBE_STRING,
1142
  INIC_LINK: VTYPE_STRING,
1143
  INIC_MAC: VTYPE_STRING,
1144
  INIC_MODE: VTYPE_STRING,
1145
  }
1146
INIC_PARAMS = frozenset(INIC_PARAMS_TYPES.keys())
1147

    
1148
# Hypervisor constants
1149
HT_XEN_PVM = "xen-pvm"
1150
HT_FAKE = "fake"
1151
HT_XEN_HVM = "xen-hvm"
1152
HT_KVM = "kvm"
1153
HT_CHROOT = "chroot"
1154
HT_LXC = "lxc"
1155
HYPER_TYPES = frozenset([
1156
  HT_XEN_PVM,
1157
  HT_FAKE,
1158
  HT_XEN_HVM,
1159
  HT_KVM,
1160
  HT_CHROOT,
1161
  HT_LXC,
1162
  ])
1163
HTS_REQ_PORT = frozenset([HT_XEN_HVM, HT_KVM])
1164

    
1165
VNC_BASE_PORT = 5900
1166
VNC_PASSWORD_FILE = CONF_DIR + "/vnc-cluster-password"
1167
VNC_DEFAULT_BIND_ADDRESS = IP4_ADDRESS_ANY
1168

    
1169
# NIC types
1170
HT_NIC_RTL8139 = "rtl8139"
1171
HT_NIC_NE2K_PCI = "ne2k_pci"
1172
HT_NIC_NE2K_ISA = "ne2k_isa"
1173
HT_NIC_I82551 = "i82551"
1174
HT_NIC_I85557B = "i82557b"
1175
HT_NIC_I8259ER = "i82559er"
1176
HT_NIC_PCNET = "pcnet"
1177
HT_NIC_E1000 = "e1000"
1178
HT_NIC_PARAVIRTUAL = HT_DISK_PARAVIRTUAL = "paravirtual"
1179

    
1180
HT_HVM_VALID_NIC_TYPES = frozenset([
1181
  HT_NIC_RTL8139,
1182
  HT_NIC_NE2K_PCI,
1183
  HT_NIC_E1000,
1184
  HT_NIC_NE2K_ISA,
1185
  HT_NIC_PARAVIRTUAL
1186
  ])
1187
HT_KVM_VALID_NIC_TYPES = frozenset([
1188
  HT_NIC_RTL8139,
1189
  HT_NIC_NE2K_PCI,
1190
  HT_NIC_NE2K_ISA,
1191
  HT_NIC_I82551,
1192
  HT_NIC_I85557B,
1193
  HT_NIC_I8259ER,
1194
  HT_NIC_PCNET,
1195
  HT_NIC_E1000,
1196
  HT_NIC_PARAVIRTUAL
1197
  ])
1198

    
1199
# Disk types
1200
HT_DISK_IOEMU = "ioemu"
1201
HT_DISK_IDE = "ide"
1202
HT_DISK_SCSI = "scsi"
1203
HT_DISK_SD = "sd"
1204
HT_DISK_MTD = "mtd"
1205
HT_DISK_PFLASH = "pflash"
1206

    
1207
HT_CACHE_DEFAULT = "default"
1208
HT_CACHE_NONE = "none"
1209
HT_CACHE_WTHROUGH = "writethrough"
1210
HT_CACHE_WBACK = "writeback"
1211
HT_VALID_CACHE_TYPES = frozenset([
1212
  HT_CACHE_DEFAULT,
1213
  HT_CACHE_NONE,
1214
  HT_CACHE_WTHROUGH,
1215
  HT_CACHE_WBACK
1216
  ])
1217

    
1218
HT_HVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IOEMU])
1219
HT_KVM_VALID_DISK_TYPES = frozenset([
1220
  HT_DISK_PARAVIRTUAL,
1221
  HT_DISK_IDE,
1222
  HT_DISK_SCSI,
1223
  HT_DISK_SD,
1224
  HT_DISK_MTD,
1225
  HT_DISK_PFLASH
1226
  ])
1227

    
1228
# Mouse types:
1229
HT_MOUSE_MOUSE = "mouse"
1230
HT_MOUSE_TABLET = "tablet"
1231

    
1232
HT_KVM_VALID_MOUSE_TYPES = frozenset([HT_MOUSE_MOUSE, HT_MOUSE_TABLET])
1233

    
1234
# Boot order
1235
HT_BO_FLOPPY = "floppy"
1236
HT_BO_CDROM = "cdrom"
1237
HT_BO_DISK = "disk"
1238
HT_BO_NETWORK = "network"
1239

    
1240
HT_KVM_VALID_BO_TYPES = frozenset([
1241
  HT_BO_FLOPPY,
1242
  HT_BO_CDROM,
1243
  HT_BO_DISK,
1244
  HT_BO_NETWORK
1245
  ])
1246

    
1247
# SPICE lossless image compression options
1248
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ = "auto_glz"
1249
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ = "auto_lz"
1250
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC = "quic"
1251
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ = "glz"
1252
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ = "lz"
1253
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF = "off"
1254

    
1255
HT_KVM_SPICE_VALID_LOSSLESS_IMG_COMPR_OPTIONS = frozenset([
1256
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ,
1257
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ,
1258
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC,
1259
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ,
1260
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ,
1261
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF,
1262
  ])
1263

    
1264
# SPICE lossy image compression options (valid for both jpeg and zlib-glz)
1265
HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO = "auto"
1266
HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER = "never"
1267
HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS = "always"
1268

    
1269
HT_KVM_SPICE_VALID_LOSSY_IMG_COMPR_OPTIONS = frozenset([
1270
  HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO,
1271
  HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER,
1272
  HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS,
1273
  ])
1274

    
1275
# SPICE video stream detection
1276
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF = "off"
1277
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL = "all"
1278
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER = "filter"
1279

    
1280
HT_KVM_SPICE_VALID_VIDEO_STREAM_DETECTION_OPTIONS = frozenset([
1281
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF,
1282
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL,
1283
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER,
1284
  ])
1285

    
1286
# Security models
1287
HT_SM_NONE = "none"
1288
HT_SM_USER = "user"
1289
HT_SM_POOL = "pool"
1290

    
1291
HT_KVM_VALID_SM_TYPES = frozenset([HT_SM_NONE, HT_SM_USER, HT_SM_POOL])
1292

    
1293
# Kvm flag values
1294
HT_KVM_ENABLED = "enabled"
1295
HT_KVM_DISABLED = "disabled"
1296

    
1297
HT_KVM_FLAG_VALUES = frozenset([HT_KVM_ENABLED, HT_KVM_DISABLED])
1298

    
1299
# Migration type
1300
HT_MIGRATION_LIVE = "live"
1301
HT_MIGRATION_NONLIVE = "non-live"
1302
HT_MIGRATION_MODES = frozenset([HT_MIGRATION_LIVE, HT_MIGRATION_NONLIVE])
1303

    
1304
# Cluster Verify steps
1305
VERIFY_NPLUSONE_MEM = "nplusone_mem"
1306
VERIFY_OPTIONAL_CHECKS = frozenset([VERIFY_NPLUSONE_MEM])
1307

    
1308
# Cluster Verify error classes
1309
CV_TCLUSTER = "cluster"
1310
CV_TNODE = "node"
1311
CV_TINSTANCE = "instance"
1312

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

    
1388
CV_ALL_ECODES = frozenset([
1389
  CV_ECLUSTERCFG,
1390
  CV_ECLUSTERCERT,
1391
  CV_ECLUSTERFILECHECK,
1392
  CV_ECLUSTERDANGLINGNODES,
1393
  CV_ECLUSTERDANGLINGINST,
1394
  CV_EINSTANCEBADNODE,
1395
  CV_EINSTANCEDOWN,
1396
  CV_EINSTANCELAYOUT,
1397
  CV_EINSTANCEMISSINGDISK,
1398
  CV_EINSTANCEFAULTYDISK,
1399
  CV_EINSTANCEWRONGNODE,
1400
  CV_EINSTANCESPLITGROUPS,
1401
  CV_EINSTANCEPOLICY,
1402
  CV_ENODEDRBD,
1403
  CV_ENODEDRBDHELPER,
1404
  CV_ENODEFILECHECK,
1405
  CV_ENODEHOOKS,
1406
  CV_ENODEHV,
1407
  CV_ENODELVM,
1408
  CV_ENODEN1,
1409
  CV_ENODENET,
1410
  CV_ENODEOS,
1411
  CV_ENODEORPHANINSTANCE,
1412
  CV_ENODEORPHANLV,
1413
  CV_ENODERPC,
1414
  CV_ENODESSH,
1415
  CV_ENODEVERSION,
1416
  CV_ENODESETUP,
1417
  CV_ENODETIME,
1418
  CV_ENODEOOBPATH,
1419
  CV_ENODEUSERSCRIPTS,
1420
  ])
1421

    
1422
CV_ALL_ECODES_STRINGS = frozenset(estr for (_, estr, _) in CV_ALL_ECODES)
1423

    
1424
# Node verify constants
1425
NV_DRBDHELPER = "drbd-helper"
1426
NV_DRBDLIST = "drbd-list"
1427
NV_FILELIST = "filelist"
1428
NV_HVINFO = "hvinfo"
1429
NV_HYPERVISOR = "hypervisor"
1430
NV_HVPARAMS = "hvparms"
1431
NV_INSTANCELIST = "instancelist"
1432
NV_LVLIST = "lvlist"
1433
NV_MASTERIP = "master-ip"
1434
NV_NODELIST = "nodelist"
1435
NV_NODENETTEST = "node-net-test"
1436
NV_NODESETUP = "nodesetup"
1437
NV_OSLIST = "oslist"
1438
NV_PVLIST = "pvlist"
1439
NV_TIME = "time"
1440
NV_VERSION = "version"
1441
NV_VGLIST = "vglist"
1442
NV_VMNODES = "vmnodes"
1443
NV_OOB_PATHS = "oob-paths"
1444
NV_BRIDGES = "bridges"
1445
NV_USERSCRIPTS = "user-scripts"
1446

    
1447
# Instance status
1448
INSTST_RUNNING = "running"
1449
INSTST_ADMINDOWN = "ADMIN_down"
1450
INSTST_ADMINOFFLINE = "ADMIN_offline"
1451
INSTST_NODEOFFLINE = "ERROR_nodeoffline"
1452
INSTST_NODEDOWN = "ERROR_nodedown"
1453
INSTST_WRONGNODE = "ERROR_wrongnode"
1454
INSTST_ERRORUP = "ERROR_up"
1455
INSTST_ERRORDOWN = "ERROR_down"
1456
INSTST_ALL = frozenset([
1457
  INSTST_RUNNING,
1458
  INSTST_ADMINDOWN,
1459
  INSTST_ADMINOFFLINE,
1460
  INSTST_NODEOFFLINE,
1461
  INSTST_NODEDOWN,
1462
  INSTST_WRONGNODE,
1463
  INSTST_ERRORUP,
1464
  INSTST_ERRORDOWN,
1465
  ])
1466

    
1467
# Admin states
1468
ADMINST_UP = "up"
1469
ADMINST_DOWN = "down"
1470
ADMINST_OFFLINE = "offline"
1471
ADMINST_ALL = frozenset([
1472
  ADMINST_UP,
1473
  ADMINST_DOWN,
1474
  ADMINST_OFFLINE,
1475
  ])
1476

    
1477
# Node roles
1478
NR_REGULAR = "R"
1479
NR_MASTER = "M"
1480
NR_MCANDIDATE = "C"
1481
NR_DRAINED = "D"
1482
NR_OFFLINE = "O"
1483
NR_ALL = frozenset([
1484
  NR_REGULAR,
1485
  NR_MASTER,
1486
  NR_MCANDIDATE,
1487
  NR_DRAINED,
1488
  NR_OFFLINE,
1489
  ])
1490

    
1491
# SSL certificate check constants (in days)
1492
SSL_CERT_EXPIRATION_WARN = 30
1493
SSL_CERT_EXPIRATION_ERROR = 7
1494

    
1495
# Allocator framework constants
1496
IALLOCATOR_VERSION = 2
1497
IALLOCATOR_DIR_IN = "in"
1498
IALLOCATOR_DIR_OUT = "out"
1499
VALID_IALLOCATOR_DIRECTIONS = frozenset([
1500
  IALLOCATOR_DIR_IN,
1501
  IALLOCATOR_DIR_OUT,
1502
  ])
1503
IALLOCATOR_MODE_ALLOC = "allocate"
1504
IALLOCATOR_MODE_RELOC = "relocate"
1505
IALLOCATOR_MODE_CHG_GROUP = "change-group"
1506
IALLOCATOR_MODE_NODE_EVAC = "node-evacuate"
1507
VALID_IALLOCATOR_MODES = frozenset([
1508
  IALLOCATOR_MODE_ALLOC,
1509
  IALLOCATOR_MODE_RELOC,
1510
  IALLOCATOR_MODE_CHG_GROUP,
1511
  IALLOCATOR_MODE_NODE_EVAC,
1512
  ])
1513
IALLOCATOR_SEARCH_PATH = _autoconf.IALLOCATOR_SEARCH_PATH
1514

    
1515
IALLOCATOR_NEVAC_PRI = "primary-only"
1516
IALLOCATOR_NEVAC_SEC = "secondary-only"
1517
IALLOCATOR_NEVAC_ALL = "all"
1518
IALLOCATOR_NEVAC_MODES = frozenset([
1519
  IALLOCATOR_NEVAC_PRI,
1520
  IALLOCATOR_NEVAC_SEC,
1521
  IALLOCATOR_NEVAC_ALL,
1522
  ])
1523

    
1524
# Node evacuation
1525
NODE_EVAC_PRI = "primary-only"
1526
NODE_EVAC_SEC = "secondary-only"
1527
NODE_EVAC_ALL = "all"
1528
NODE_EVAC_MODES = frozenset([
1529
  NODE_EVAC_PRI,
1530
  NODE_EVAC_SEC,
1531
  NODE_EVAC_ALL,
1532
  ])
1533

    
1534
# Job queue
1535
JOB_QUEUE_VERSION = 1
1536
JOB_QUEUE_LOCK_FILE = QUEUE_DIR + "/lock"
1537
JOB_QUEUE_VERSION_FILE = QUEUE_DIR + "/version"
1538
JOB_QUEUE_SERIAL_FILE = QUEUE_DIR + "/serial"
1539
JOB_QUEUE_ARCHIVE_DIR = QUEUE_DIR + "/archive"
1540
JOB_QUEUE_DRAIN_FILE = QUEUE_DIR + "/drain"
1541
JOB_QUEUE_SIZE_HARD_LIMIT = 5000
1542
JOB_QUEUE_DIRS = [QUEUE_DIR, JOB_QUEUE_ARCHIVE_DIR]
1543
JOB_QUEUE_DIRS_MODE = SECURE_DIR_MODE
1544

    
1545
JOB_ID_TEMPLATE = r"\d+"
1546
JOB_FILE_RE = re.compile(r"^job-(%s)$" % JOB_ID_TEMPLATE)
1547

    
1548
# unchanged job return
1549
JOB_NOTCHANGED = "nochange"
1550

    
1551
# Job status
1552
JOB_STATUS_QUEUED = "queued"
1553
JOB_STATUS_WAITING = "waiting"
1554
JOB_STATUS_CANCELING = "canceling"
1555
JOB_STATUS_RUNNING = "running"
1556
JOB_STATUS_CANCELED = "canceled"
1557
JOB_STATUS_SUCCESS = "success"
1558
JOB_STATUS_ERROR = "error"
1559
JOBS_FINALIZED = frozenset([
1560
  JOB_STATUS_CANCELED,
1561
  JOB_STATUS_SUCCESS,
1562
  JOB_STATUS_ERROR,
1563
  ])
1564
JOB_STATUS_ALL = frozenset([
1565
  JOB_STATUS_QUEUED,
1566
  JOB_STATUS_WAITING,
1567
  JOB_STATUS_CANCELING,
1568
  JOB_STATUS_RUNNING,
1569
  ]) | JOBS_FINALIZED
1570

    
1571
# OpCode status
1572
# not yet finalized
1573
OP_STATUS_QUEUED = "queued"
1574
OP_STATUS_WAITING = "waiting"
1575
OP_STATUS_CANCELING = "canceling"
1576
OP_STATUS_RUNNING = "running"
1577
# finalized
1578
OP_STATUS_CANCELED = "canceled"
1579
OP_STATUS_SUCCESS = "success"
1580
OP_STATUS_ERROR = "error"
1581
OPS_FINALIZED = frozenset([
1582
  OP_STATUS_CANCELED,
1583
  OP_STATUS_SUCCESS,
1584
  OP_STATUS_ERROR
1585
  ])
1586

    
1587
# OpCode priority
1588
OP_PRIO_LOWEST = +19
1589
OP_PRIO_HIGHEST = -20
1590

    
1591
OP_PRIO_LOW = +10
1592
OP_PRIO_NORMAL = 0
1593
OP_PRIO_HIGH = -10
1594

    
1595
OP_PRIO_SUBMIT_VALID = frozenset([
1596
  OP_PRIO_LOW,
1597
  OP_PRIO_NORMAL,
1598
  OP_PRIO_HIGH,
1599
  ])
1600

    
1601
OP_PRIO_DEFAULT = OP_PRIO_NORMAL
1602

    
1603
# Execution log types
1604
ELOG_MESSAGE = "message"
1605
ELOG_PROGRESS = "progress"
1606
ELOG_REMOTE_IMPORT = "remote-import"
1607
ELOG_JQUEUE_TEST = "jqueue-test"
1608

    
1609
# /etc/hosts modification
1610
ETC_HOSTS_ADD = "add"
1611
ETC_HOSTS_REMOVE = "remove"
1612

    
1613
# Job queue test
1614
JQT_MSGPREFIX = "TESTMSG="
1615
JQT_EXPANDNAMES = "expandnames"
1616
JQT_EXEC = "exec"
1617
JQT_LOGMSG = "logmsg"
1618
JQT_STARTMSG = "startmsg"
1619
JQT_ALL = frozenset([
1620
  JQT_EXPANDNAMES,
1621
  JQT_EXEC,
1622
  JQT_LOGMSG,
1623
  JQT_STARTMSG,
1624
  ])
1625

    
1626
# Query resources
1627
QR_INSTANCE = "instance"
1628
QR_NODE = "node"
1629
QR_LOCK = "lock"
1630
QR_GROUP = "group"
1631
QR_OS = "os"
1632

    
1633
#: List of resources which can be queried using L{opcodes.OpQuery}
1634
QR_VIA_OP = frozenset([QR_INSTANCE, QR_NODE, QR_GROUP, QR_OS])
1635

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

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

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

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

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

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

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

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

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

    
1723
SS_FILE_PERMS = 0444
1724

    
1725
# cluster wide default parameters
1726
DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM
1727

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

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

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

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

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

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

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

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

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

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

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

    
1948
MASTER_POOL_SIZE_DEFAULT = 10
1949

    
1950
CONFD_PROTOCOL_VERSION = 1
1951

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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