Statistics
| Branch: | Tag: | Revision:

root / lib / constants.py @ 08208574

History | View | Annotate | Download (55.3 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 = "xm"
271
XEN_CMD_XL = "xl"
272
# FIXME: This will be made configurable using hvparams in Ganeti 2.7
273
XEN_CMD = _autoconf.XEN_CMD
274

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

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

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

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

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

    
294
#: All console types
295
CONS_ALL = frozenset([CONS_SSH, CONS_VNC, CONS_SPICE, CONS_MESSAGE])
296

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

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

    
310
# Digest used to sign certificates ("openssl x509" uses SHA1 by default)
311
X509_CERT_SIGN_DIGEST = "SHA1"
312

    
313
# Default validity of certificates in days
314
X509_CERT_DEFAULT_VALIDITY = 365 * 5
315

    
316
# commonName (CN) used in certificates
317
X509_CERT_CN = "ganeti.example.com"
318

    
319
X509_CERT_SIGNATURE_HEADER = "X-Ganeti-Signature"
320

    
321
IMPORT_EXPORT_DAEMON = _autoconf.PKGLIBDIR + "/import-export"
322

    
323
# Import/export daemon mode
324
IEM_IMPORT = "import"
325
IEM_EXPORT = "export"
326

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

    
335
IE_CUSTOM_SIZE = "fd"
336

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

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

    
347
VALUE_DEFAULT = "default"
348
VALUE_AUTO = "auto"
349
VALUE_GENERATE = "generate"
350
VALUE_NONE = "none"
351
VALUE_TRUE = "true"
352
VALUE_FALSE = "false"
353

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

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

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

    
373
HKR_SKIP = 0
374
HKR_FAIL = 1
375
HKR_SUCCESS = 2
376

    
377
# Storage types
378
ST_FILE = "file"
379
ST_LVM_PV = "lvm-pv"
380
ST_LVM_VG = "lvm-vg"
381

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

    
393
# Storage operations
394
SO_FIX_CONSISTENCY = "fix-consistency"
395

    
396
# Available fields per storage type
397
VALID_STORAGE_FIELDS = frozenset([
398
  SF_NAME,
399
  SF_TYPE,
400
  SF_SIZE,
401
  SF_USED,
402
  SF_FREE,
403
  SF_ALLOCATABLE
404
  ])
405

    
406
VALID_STORAGE_TYPES = frozenset([ST_FILE, ST_LVM_PV, ST_LVM_VG])
407

    
408
MODIFIABLE_STORAGE_FIELDS = {
409
  ST_LVM_PV: frozenset([SF_ALLOCATABLE]),
410
  }
411

    
412
VALID_STORAGE_OPERATIONS = {
413
  ST_LVM_VG: frozenset([SO_FIX_CONSISTENCY]),
414
  }
415

    
416
# Local disk status
417
# Note: Code depends on LDS_OKAY < LDS_UNKNOWN < LDS_FAULTY
418
(LDS_OKAY,
419
 LDS_UNKNOWN,
420
 LDS_FAULTY) = range(1, 4)
421

    
422
# disk template types
423
DT_DISKLESS = "diskless"
424
DT_PLAIN = "plain"
425
DT_DRBD8 = "drbd"
426
DT_FILE = "file"
427
DT_SHARED_FILE = "sharedfile"
428
DT_BLOCK = "blockdev"
429
DT_RBD = "rbd"
430

    
431
# the set of network-mirrored disk templates
432
DTS_INT_MIRROR = frozenset([DT_DRBD8])
433

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

    
437
# the set of non-lvm-based disk templates
438
DTS_NOT_LVM = frozenset([DT_DISKLESS, DT_FILE, DT_SHARED_FILE,
439
                         DT_BLOCK, DT_RBD])
440

    
441
# the set of disk templates which can be grown
442
DTS_GROWABLE = frozenset([DT_PLAIN, DT_DRBD8, DT_FILE, DT_SHARED_FILE, DT_RBD])
443

    
444
# the set of disk templates that allow adoption
445
DTS_MAY_ADOPT = frozenset([DT_PLAIN, DT_BLOCK])
446

    
447
# the set of disk templates that *must* use adoption
448
DTS_MUST_ADOPT = frozenset([DT_BLOCK])
449

    
450
# the set of disk templates that allow migrations
451
DTS_MIRRORED = frozenset.union(DTS_INT_MIRROR, DTS_EXT_MIRROR)
452

    
453
# the set of file based disk templates
454
DTS_FILEBASED = frozenset([DT_FILE, DT_SHARED_FILE])
455

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

    
470
LDS_BLOCK = frozenset([LD_LV, LD_DRBD8, LD_BLOCKDEV, LD_RBD])
471

    
472
# drbd constants
473
DRBD_HMAC_ALG = "md5"
474
DRBD_NET_PROTOCOL = "C"
475

    
476
# drbd barrier types
477
DRBD_B_NONE = "n"
478
DRBD_B_DISK_BARRIERS = "b"
479
DRBD_B_DISK_DRAIN = "d"
480
DRBD_B_DISK_FLUSH = "f"
481

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

    
495
# rbd tool command
496
RBD_CMD = "rbd"
497

    
498
# file backend driver
499
FD_LOOP = "loop"
500
FD_BLKTAP = "blktap"
501

    
502
# the set of drbd-like disk types
503
LDS_DRBD = frozenset([LD_DRBD8])
504

    
505
# disk access mode
506
DISK_RDONLY = "ro"
507
DISK_RDWR = "rw"
508
DISK_ACCESS_SET = frozenset([DISK_RDONLY, DISK_RDWR])
509

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

    
522
# Instance export mode
523
EXPORT_MODE_LOCAL = "local"
524
EXPORT_MODE_REMOTE = "remote"
525
EXPORT_MODES = frozenset([
526
  EXPORT_MODE_LOCAL,
527
  EXPORT_MODE_REMOTE,
528
  ])
529

    
530
# instance creation modes
531
INSTANCE_CREATE = "create"
532
INSTANCE_IMPORT = "import"
533
INSTANCE_REMOTE_IMPORT = "remote-import"
534
INSTANCE_CREATE_MODES = frozenset([
535
  INSTANCE_CREATE,
536
  INSTANCE_IMPORT,
537
  INSTANCE_REMOTE_IMPORT,
538
  ])
539

    
540
# Remote import/export handshake message and version
541
RIE_VERSION = 0
542
RIE_HANDSHAKE = "Hi, I'm Ganeti"
543

    
544
# Remote import/export certificate validity in seconds
545
RIE_CERT_VALIDITY = 24 * 60 * 60
546

    
547
# Overall timeout for establishing connection
548
RIE_CONNECT_TIMEOUT = 180
549

    
550
# Export only: how long to wait per connection attempt (seconds)
551
RIE_CONNECT_ATTEMPT_TIMEOUT = 20
552

    
553
# Export only: number of attempts to connect
554
RIE_CONNECT_RETRIES = 10
555

    
556
#: Give child process up to 5 seconds to exit after sending a signal
557
CHILD_LINGER_TIMEOUT = 5.0
558

    
559
DISK_TEMPLATES = frozenset([
560
  DT_DISKLESS,
561
  DT_PLAIN,
562
  DT_DRBD8,
563
  DT_FILE,
564
  DT_SHARED_FILE,
565
  DT_BLOCK,
566
  DT_RBD
567
  ])
568

    
569
FILE_DRIVER = frozenset([FD_LOOP, FD_BLKTAP])
570

    
571
# import/export config options
572
INISECT_EXP = "export"
573
INISECT_INS = "instance"
574
INISECT_HYP = "hypervisor"
575
INISECT_BEP = "backend"
576
INISECT_OSP = "os"
577

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

    
588
# common exit codes
589
EXIT_SUCCESS = 0
590
EXIT_FAILURE = 1
591
EXIT_NOTCLUSTER = 5
592
EXIT_NOTMASTER = 11
593
EXIT_NODESETUP_ERROR = 12
594
EXIT_CONFIRMATION = 13 # need user confirmation
595

    
596
#: Exit code for query operations with unknown fields
597
EXIT_UNKNOWN_FIELD = 14
598

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

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

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

    
642
#: Key for job IDs in opcode result
643
JOB_IDS_KEY = "jobs"
644

    
645
# runparts results
646
(RUNPARTS_SKIP,
647
 RUNPARTS_RUN,
648
 RUNPARTS_ERR) = range(3)
649

    
650
RUNPARTS_STATUS = frozenset([RUNPARTS_SKIP, RUNPARTS_RUN, RUNPARTS_ERR])
651

    
652
# RPC constants
653
(RPC_ENCODING_NONE,
654
 RPC_ENCODING_ZLIB_BASE64) = range(2)
655

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

    
670
OS_API_FILE = "ganeti_api_version"
671
OS_VARIANTS_FILE = "variants.list"
672
OS_PARAMETERS_FILE = "parameters.list"
673

    
674
OS_VALIDATE_PARAMETERS = "parameters"
675
OS_VALIDATE_CALLS = frozenset([OS_VALIDATE_PARAMETERS])
676

    
677
# ssh constants
678
SSH_CONFIG_DIR = _autoconf.SSH_CONFIG_DIR
679
SSH_HOST_DSA_PRIV = SSH_CONFIG_DIR + "/ssh_host_dsa_key"
680
SSH_HOST_DSA_PUB = SSH_HOST_DSA_PRIV + ".pub"
681
SSH_HOST_RSA_PRIV = SSH_CONFIG_DIR + "/ssh_host_rsa_key"
682
SSH_HOST_RSA_PUB = SSH_HOST_RSA_PRIV + ".pub"
683
SSH = "ssh"
684
SCP = "scp"
685

    
686
# reboot types
687
INSTANCE_REBOOT_SOFT = "soft"
688
INSTANCE_REBOOT_HARD = "hard"
689
INSTANCE_REBOOT_FULL = "full"
690

    
691
REBOOT_TYPES = frozenset([
692
  INSTANCE_REBOOT_SOFT,
693
  INSTANCE_REBOOT_HARD,
694
  INSTANCE_REBOOT_FULL
695
  ])
696

    
697
# instance reboot behaviors
698
INSTANCE_REBOOT_ALLOWED = "reboot"
699
INSTANCE_REBOOT_EXIT = "exit"
700

    
701
REBOOT_BEHAVIORS = frozenset([
702
  INSTANCE_REBOOT_ALLOWED,
703
  INSTANCE_REBOOT_EXIT
704
  ])
705

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

    
719
# Constant representing that the user does not specify any IP version
720
IFACE_NO_IP_VERSION_SPECIFIED = 0
721

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

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

    
833
HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
834

    
835
# Migration statuses
836
HV_MIGRATION_COMPLETED = "completed"
837
HV_MIGRATION_ACTIVE = "active"
838
HV_MIGRATION_FAILED = "failed"
839
HV_MIGRATION_CANCELLED = "cancelled"
840

    
841
HV_MIGRATION_VALID_STATUSES = frozenset([
842
  HV_MIGRATION_COMPLETED,
843
  HV_MIGRATION_ACTIVE,
844
  HV_MIGRATION_FAILED,
845
  HV_MIGRATION_CANCELLED,
846
  ])
847

    
848
HV_MIGRATION_FAILED_STATUSES = frozenset([
849
  HV_MIGRATION_FAILED,
850
  HV_MIGRATION_CANCELLED,
851
  ])
852

    
853
# KVM-specific statuses
854
HV_KVM_MIGRATION_VALID_STATUSES = HV_MIGRATION_VALID_STATUSES
855

    
856
# Node info keys
857
HV_NODEINFO_KEY_VERSION = "hv_version"
858

    
859
# Hypervisor state
860
HVST_MEMORY_TOTAL = "mem_total"
861
HVST_MEMORY_NODE = "mem_node"
862
HVST_MEMORY_HV = "mem_hv"
863
HVST_CPU_TOTAL = "cpu_total"
864
HVST_CPU_NODE = "cpu_node"
865

    
866
HVST_DEFAULTS = {
867
  HVST_MEMORY_TOTAL: 0,
868
  HVST_MEMORY_NODE: 0,
869
  HVST_MEMORY_HV: 0,
870
  HVST_CPU_TOTAL: 1,
871
  HVST_CPU_NODE: 1,
872
  }
873

    
874
HVSTS_PARAMETER_TYPES = {
875
  HVST_MEMORY_TOTAL: VTYPE_INT,
876
  HVST_MEMORY_NODE: VTYPE_INT,
877
  HVST_MEMORY_HV: VTYPE_INT,
878
  HVST_CPU_TOTAL: VTYPE_INT,
879
  HVST_CPU_NODE: VTYPE_INT,
880
  }
881

    
882
HVSTS_PARAMETERS = frozenset(HVSTS_PARAMETER_TYPES.keys())
883

    
884
# Disk state
885
DS_DISK_TOTAL = "disk_total"
886
DS_DISK_RESERVED = "disk_reserved"
887
DS_DISK_OVERHEAD = "disk_overhead"
888

    
889
DS_DEFAULTS = {
890
  DS_DISK_TOTAL: 0,
891
  DS_DISK_RESERVED: 0,
892
  DS_DISK_OVERHEAD: 0,
893
  }
894

    
895
DSS_PARAMETER_TYPES = {
896
  DS_DISK_TOTAL: VTYPE_INT,
897
  DS_DISK_RESERVED: VTYPE_INT,
898
  DS_DISK_OVERHEAD: VTYPE_INT,
899
  }
900

    
901
DSS_PARAMETERS = frozenset(DSS_PARAMETER_TYPES.keys())
902
DS_VALID_TYPES = frozenset([LD_LV])
903

    
904
# Backend parameter names
905
BE_MEMORY = "memory" # deprecated and replaced by max and min mem
906
BE_MAXMEM = "maxmem"
907
BE_MINMEM = "minmem"
908
BE_VCPUS = "vcpus"
909
BE_AUTO_BALANCE = "auto_balance"
910
BE_ALWAYS_FAILOVER = "always_failover"
911
BE_SPINDLE_USE = "spindle_use"
912

    
913
BES_PARAMETER_TYPES = {
914
  BE_MAXMEM: VTYPE_SIZE,
915
  BE_MINMEM: VTYPE_SIZE,
916
  BE_VCPUS: VTYPE_INT,
917
  BE_AUTO_BALANCE: VTYPE_BOOL,
918
  BE_ALWAYS_FAILOVER: VTYPE_BOOL,
919
  BE_SPINDLE_USE: VTYPE_INT,
920
  }
921

    
922
BES_PARAMETER_COMPAT = {
923
  BE_MEMORY: VTYPE_SIZE,
924
  }
925
BES_PARAMETER_COMPAT.update(BES_PARAMETER_TYPES)
926

    
927
BES_PARAMETERS = frozenset(BES_PARAMETER_TYPES.keys())
928

    
929
# instance specs
930
ISPEC_MEM_SIZE = "memory-size"
931
ISPEC_CPU_COUNT = "cpu-count"
932
ISPEC_DISK_COUNT = "disk-count"
933
ISPEC_DISK_SIZE = "disk-size"
934
ISPEC_NIC_COUNT = "nic-count"
935
ISPEC_SPINDLE_USE = "spindle-use"
936

    
937
ISPECS_PARAMETER_TYPES = {
938
  ISPEC_MEM_SIZE: VTYPE_INT,
939
  ISPEC_CPU_COUNT: VTYPE_INT,
940
  ISPEC_DISK_COUNT: VTYPE_INT,
941
  ISPEC_DISK_SIZE: VTYPE_INT,
942
  ISPEC_NIC_COUNT: VTYPE_INT,
943
  ISPEC_SPINDLE_USE: VTYPE_INT,
944
  }
945

    
946
ISPECS_PARAMETERS = frozenset(ISPECS_PARAMETER_TYPES.keys())
947

    
948
ISPECS_MIN = "min"
949
ISPECS_MAX = "max"
950
ISPECS_STD = "std"
951
IPOLICY_DTS = "disk-templates"
952
IPOLICY_VCPU_RATIO = "vcpu-ratio"
953
IPOLICY_SPINDLE_RATIO = "spindle-ratio"
954

    
955
IPOLICY_ISPECS = frozenset([
956
  ISPECS_MIN,
957
  ISPECS_MAX,
958
  ISPECS_STD,
959
  ])
960

    
961
IPOLICY_PARAMETERS = frozenset([
962
  IPOLICY_VCPU_RATIO,
963
  IPOLICY_SPINDLE_RATIO,
964
  ])
965

    
966
IPOLICY_ALL_KEYS = (IPOLICY_ISPECS |
967
                    IPOLICY_PARAMETERS |
968
                    frozenset([IPOLICY_DTS]))
969

    
970
# Node parameter names
971
ND_OOB_PROGRAM = "oob_program"
972
ND_SPINDLE_COUNT = "spindle_count"
973

    
974
NDS_PARAMETER_TYPES = {
975
  ND_OOB_PROGRAM: VTYPE_MAYBE_STRING,
976
  ND_SPINDLE_COUNT: VTYPE_INT,
977
  }
978

    
979
NDS_PARAMETERS = frozenset(NDS_PARAMETER_TYPES.keys())
980

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

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

    
1051
DISK_DT_PARAMETERS = frozenset(DISK_DT_TYPES.keys())
1052

    
1053
# OOB supported commands
1054
OOB_POWER_ON = "power-on"
1055
OOB_POWER_OFF = "power-off"
1056
OOB_POWER_CYCLE = "power-cycle"
1057
OOB_POWER_STATUS = "power-status"
1058
OOB_HEALTH = "health"
1059

    
1060
OOB_COMMANDS = frozenset([
1061
  OOB_POWER_ON,
1062
  OOB_POWER_OFF,
1063
  OOB_POWER_CYCLE,
1064
  OOB_POWER_STATUS,
1065
  OOB_HEALTH
1066
  ])
1067

    
1068
OOB_POWER_STATUS_POWERED = "powered"
1069

    
1070
OOB_TIMEOUT = 60 # 60 seconds
1071
OOB_POWER_DELAY = 2.0 # 2 seconds
1072

    
1073
OOB_STATUS_OK = "OK"
1074
OOB_STATUS_WARNING = "WARNING"
1075
OOB_STATUS_CRITICAL = "CRITICAL"
1076
OOB_STATUS_UNKNOWN = "UNKNOWN"
1077

    
1078
OOB_STATUSES = frozenset([
1079
  OOB_STATUS_OK,
1080
  OOB_STATUS_WARNING,
1081
  OOB_STATUS_CRITICAL,
1082
  OOB_STATUS_UNKNOWN,
1083
  ])
1084

    
1085
# Instance Parameters Profile
1086
PP_DEFAULT = "default"
1087

    
1088
# NIC_* constants are used inside the ganeti config
1089
NIC_MODE = "mode"
1090
NIC_LINK = "link"
1091

    
1092
NIC_MODE_BRIDGED = "bridged"
1093
NIC_MODE_ROUTED = "routed"
1094
NIC_IP_POOL = "pool"
1095

    
1096
NIC_VALID_MODES = frozenset([NIC_MODE_BRIDGED, NIC_MODE_ROUTED])
1097

    
1098
NETWORK_TYPE_PRIVATE = "private"
1099
NETWORK_TYPE_PUBLIC = "public"
1100

    
1101
NETWORK_VALID_TYPES = frozenset([NETWORK_TYPE_PRIVATE, NETWORK_TYPE_PUBLIC])
1102

    
1103
NICS_PARAMETER_TYPES = {
1104
  NIC_MODE: VTYPE_STRING,
1105
  NIC_LINK: VTYPE_STRING,
1106
  }
1107

    
1108
NICS_PARAMETERS = frozenset(NICS_PARAMETER_TYPES.keys())
1109

    
1110
# IDISK_* constants are used in opcodes, to create/change disks
1111
IDISK_SIZE = "size"
1112
IDISK_MODE = "mode"
1113
IDISK_ADOPT = "adopt"
1114
IDISK_VG = "vg"
1115
IDISK_METAVG = "metavg"
1116
IDISK_PARAMS_TYPES = {
1117
  IDISK_SIZE: VTYPE_SIZE,
1118
  IDISK_MODE: VTYPE_STRING,
1119
  IDISK_ADOPT: VTYPE_STRING,
1120
  IDISK_VG: VTYPE_STRING,
1121
  IDISK_METAVG: VTYPE_STRING,
1122
  }
1123
IDISK_PARAMS = frozenset(IDISK_PARAMS_TYPES.keys())
1124

    
1125
# INIC_* constants are used in opcodes, to create/change nics
1126
INIC_MAC = "mac"
1127
INIC_IP = "ip"
1128
INIC_MODE = "mode"
1129
INIC_LINK = "link"
1130
INIC_NETWORK = "network"
1131
INIC_PARAMS_TYPES = {
1132
  INIC_IP: VTYPE_MAYBE_STRING,
1133
  INIC_LINK: VTYPE_STRING,
1134
  INIC_MAC: VTYPE_STRING,
1135
  INIC_MODE: VTYPE_STRING,
1136
  INIC_NETWORK: VTYPE_MAYBE_STRING,
1137
  }
1138
INIC_PARAMS = frozenset(INIC_PARAMS_TYPES.keys())
1139

    
1140
# Hypervisor constants
1141
HT_XEN_PVM = "xen-pvm"
1142
HT_FAKE = "fake"
1143
HT_XEN_HVM = "xen-hvm"
1144
HT_KVM = "kvm"
1145
HT_CHROOT = "chroot"
1146
HT_LXC = "lxc"
1147
HYPER_TYPES = frozenset([
1148
  HT_XEN_PVM,
1149
  HT_FAKE,
1150
  HT_XEN_HVM,
1151
  HT_KVM,
1152
  HT_CHROOT,
1153
  HT_LXC,
1154
  ])
1155
HTS_REQ_PORT = frozenset([HT_XEN_HVM, HT_KVM])
1156

    
1157
VNC_BASE_PORT = 5900
1158
VNC_PASSWORD_FILE = CONF_DIR + "/vnc-cluster-password"
1159
VNC_DEFAULT_BIND_ADDRESS = IP4_ADDRESS_ANY
1160

    
1161
# NIC types
1162
HT_NIC_RTL8139 = "rtl8139"
1163
HT_NIC_NE2K_PCI = "ne2k_pci"
1164
HT_NIC_NE2K_ISA = "ne2k_isa"
1165
HT_NIC_I82551 = "i82551"
1166
HT_NIC_I85557B = "i82557b"
1167
HT_NIC_I8259ER = "i82559er"
1168
HT_NIC_PCNET = "pcnet"
1169
HT_NIC_E1000 = "e1000"
1170
HT_NIC_PARAVIRTUAL = HT_DISK_PARAVIRTUAL = "paravirtual"
1171

    
1172
HT_HVM_VALID_NIC_TYPES = frozenset([
1173
  HT_NIC_RTL8139,
1174
  HT_NIC_NE2K_PCI,
1175
  HT_NIC_E1000,
1176
  HT_NIC_NE2K_ISA,
1177
  HT_NIC_PARAVIRTUAL
1178
  ])
1179
HT_KVM_VALID_NIC_TYPES = frozenset([
1180
  HT_NIC_RTL8139,
1181
  HT_NIC_NE2K_PCI,
1182
  HT_NIC_NE2K_ISA,
1183
  HT_NIC_I82551,
1184
  HT_NIC_I85557B,
1185
  HT_NIC_I8259ER,
1186
  HT_NIC_PCNET,
1187
  HT_NIC_E1000,
1188
  HT_NIC_PARAVIRTUAL
1189
  ])
1190

    
1191
# Disk types
1192
HT_DISK_IOEMU = "ioemu"
1193
HT_DISK_IDE = "ide"
1194
HT_DISK_SCSI = "scsi"
1195
HT_DISK_SD = "sd"
1196
HT_DISK_MTD = "mtd"
1197
HT_DISK_PFLASH = "pflash"
1198

    
1199
HT_CACHE_DEFAULT = "default"
1200
HT_CACHE_NONE = "none"
1201
HT_CACHE_WTHROUGH = "writethrough"
1202
HT_CACHE_WBACK = "writeback"
1203
HT_VALID_CACHE_TYPES = frozenset([
1204
  HT_CACHE_DEFAULT,
1205
  HT_CACHE_NONE,
1206
  HT_CACHE_WTHROUGH,
1207
  HT_CACHE_WBACK
1208
  ])
1209

    
1210
HT_HVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IOEMU])
1211
HT_KVM_VALID_DISK_TYPES = frozenset([
1212
  HT_DISK_PARAVIRTUAL,
1213
  HT_DISK_IDE,
1214
  HT_DISK_SCSI,
1215
  HT_DISK_SD,
1216
  HT_DISK_MTD,
1217
  HT_DISK_PFLASH
1218
  ])
1219

    
1220
# Mouse types:
1221
HT_MOUSE_MOUSE = "mouse"
1222
HT_MOUSE_TABLET = "tablet"
1223

    
1224
HT_KVM_VALID_MOUSE_TYPES = frozenset([HT_MOUSE_MOUSE, HT_MOUSE_TABLET])
1225

    
1226
# Boot order
1227
HT_BO_FLOPPY = "floppy"
1228
HT_BO_CDROM = "cdrom"
1229
HT_BO_DISK = "disk"
1230
HT_BO_NETWORK = "network"
1231

    
1232
HT_KVM_VALID_BO_TYPES = frozenset([
1233
  HT_BO_FLOPPY,
1234
  HT_BO_CDROM,
1235
  HT_BO_DISK,
1236
  HT_BO_NETWORK
1237
  ])
1238

    
1239
# SPICE lossless image compression options
1240
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ = "auto_glz"
1241
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ = "auto_lz"
1242
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC = "quic"
1243
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ = "glz"
1244
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ = "lz"
1245
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF = "off"
1246

    
1247
HT_KVM_SPICE_VALID_LOSSLESS_IMG_COMPR_OPTIONS = frozenset([
1248
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ,
1249
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ,
1250
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC,
1251
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ,
1252
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ,
1253
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF,
1254
  ])
1255

    
1256
# SPICE lossy image compression options (valid for both jpeg and zlib-glz)
1257
HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO = "auto"
1258
HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER = "never"
1259
HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS = "always"
1260

    
1261
HT_KVM_SPICE_VALID_LOSSY_IMG_COMPR_OPTIONS = frozenset([
1262
  HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO,
1263
  HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER,
1264
  HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS,
1265
  ])
1266

    
1267
# SPICE video stream detection
1268
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF = "off"
1269
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL = "all"
1270
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER = "filter"
1271

    
1272
HT_KVM_SPICE_VALID_VIDEO_STREAM_DETECTION_OPTIONS = frozenset([
1273
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF,
1274
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL,
1275
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER,
1276
  ])
1277

    
1278
# Security models
1279
HT_SM_NONE = "none"
1280
HT_SM_USER = "user"
1281
HT_SM_POOL = "pool"
1282

    
1283
HT_KVM_VALID_SM_TYPES = frozenset([HT_SM_NONE, HT_SM_USER, HT_SM_POOL])
1284

    
1285
# Kvm flag values
1286
HT_KVM_ENABLED = "enabled"
1287
HT_KVM_DISABLED = "disabled"
1288

    
1289
HT_KVM_FLAG_VALUES = frozenset([HT_KVM_ENABLED, HT_KVM_DISABLED])
1290

    
1291
# Migration type
1292
HT_MIGRATION_LIVE = "live"
1293
HT_MIGRATION_NONLIVE = "non-live"
1294
HT_MIGRATION_MODES = frozenset([HT_MIGRATION_LIVE, HT_MIGRATION_NONLIVE])
1295

    
1296
# Cluster Verify steps
1297
VERIFY_NPLUSONE_MEM = "nplusone_mem"
1298
VERIFY_OPTIONAL_CHECKS = frozenset([VERIFY_NPLUSONE_MEM])
1299

    
1300
# Cluster Verify error classes
1301
CV_TCLUSTER = "cluster"
1302
CV_TNODE = "node"
1303
CV_TINSTANCE = "instance"
1304

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

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

    
1414
CV_ALL_ECODES_STRINGS = frozenset(estr for (_, estr, _) in CV_ALL_ECODES)
1415

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

    
1439
# Instance status
1440
INSTST_RUNNING = "running"
1441
INSTST_ADMINDOWN = "ADMIN_down"
1442
INSTST_ADMINOFFLINE = "ADMIN_offline"
1443
INSTST_NODEOFFLINE = "ERROR_nodeoffline"
1444
INSTST_NODEDOWN = "ERROR_nodedown"
1445
INSTST_WRONGNODE = "ERROR_wrongnode"
1446
INSTST_ERRORUP = "ERROR_up"
1447
INSTST_ERRORDOWN = "ERROR_down"
1448
INSTST_ALL = frozenset([
1449
  INSTST_RUNNING,
1450
  INSTST_ADMINDOWN,
1451
  INSTST_ADMINOFFLINE,
1452
  INSTST_NODEOFFLINE,
1453
  INSTST_NODEDOWN,
1454
  INSTST_WRONGNODE,
1455
  INSTST_ERRORUP,
1456
  INSTST_ERRORDOWN,
1457
  ])
1458

    
1459
# Admin states
1460
ADMINST_UP = "up"
1461
ADMINST_DOWN = "down"
1462
ADMINST_OFFLINE = "offline"
1463
ADMINST_ALL = frozenset([
1464
  ADMINST_UP,
1465
  ADMINST_DOWN,
1466
  ADMINST_OFFLINE,
1467
  ])
1468

    
1469
# Node roles
1470
NR_REGULAR = "R"
1471
NR_MASTER = "M"
1472
NR_MCANDIDATE = "C"
1473
NR_DRAINED = "D"
1474
NR_OFFLINE = "O"
1475
NR_ALL = frozenset([
1476
  NR_REGULAR,
1477
  NR_MASTER,
1478
  NR_MCANDIDATE,
1479
  NR_DRAINED,
1480
  NR_OFFLINE,
1481
  ])
1482

    
1483
# SSL certificate check constants (in days)
1484
SSL_CERT_EXPIRATION_WARN = 30
1485
SSL_CERT_EXPIRATION_ERROR = 7
1486

    
1487
# Allocator framework constants
1488
IALLOCATOR_VERSION = 2
1489
IALLOCATOR_DIR_IN = "in"
1490
IALLOCATOR_DIR_OUT = "out"
1491
VALID_IALLOCATOR_DIRECTIONS = frozenset([
1492
  IALLOCATOR_DIR_IN,
1493
  IALLOCATOR_DIR_OUT,
1494
  ])
1495
IALLOCATOR_MODE_ALLOC = "allocate"
1496
IALLOCATOR_MODE_RELOC = "relocate"
1497
IALLOCATOR_MODE_CHG_GROUP = "change-group"
1498
IALLOCATOR_MODE_NODE_EVAC = "node-evacuate"
1499
VALID_IALLOCATOR_MODES = frozenset([
1500
  IALLOCATOR_MODE_ALLOC,
1501
  IALLOCATOR_MODE_RELOC,
1502
  IALLOCATOR_MODE_CHG_GROUP,
1503
  IALLOCATOR_MODE_NODE_EVAC,
1504
  ])
1505
IALLOCATOR_SEARCH_PATH = _autoconf.IALLOCATOR_SEARCH_PATH
1506

    
1507
IALLOCATOR_NEVAC_PRI = "primary-only"
1508
IALLOCATOR_NEVAC_SEC = "secondary-only"
1509
IALLOCATOR_NEVAC_ALL = "all"
1510
IALLOCATOR_NEVAC_MODES = frozenset([
1511
  IALLOCATOR_NEVAC_PRI,
1512
  IALLOCATOR_NEVAC_SEC,
1513
  IALLOCATOR_NEVAC_ALL,
1514
  ])
1515

    
1516
# Node evacuation
1517
NODE_EVAC_PRI = "primary-only"
1518
NODE_EVAC_SEC = "secondary-only"
1519
NODE_EVAC_ALL = "all"
1520
NODE_EVAC_MODES = frozenset([
1521
  NODE_EVAC_PRI,
1522
  NODE_EVAC_SEC,
1523
  NODE_EVAC_ALL,
1524
  ])
1525

    
1526
# Job queue
1527
JOB_QUEUE_VERSION = 1
1528
JOB_QUEUE_LOCK_FILE = QUEUE_DIR + "/lock"
1529
JOB_QUEUE_VERSION_FILE = QUEUE_DIR + "/version"
1530
JOB_QUEUE_SERIAL_FILE = QUEUE_DIR + "/serial"
1531
JOB_QUEUE_ARCHIVE_DIR = QUEUE_DIR + "/archive"
1532
JOB_QUEUE_DRAIN_FILE = QUEUE_DIR + "/drain"
1533
JOB_QUEUE_SIZE_HARD_LIMIT = 5000
1534

    
1535
JOB_ID_TEMPLATE = r"\d+"
1536
JOB_FILE_RE = re.compile(r"^job-(%s)$" % JOB_ID_TEMPLATE)
1537

    
1538
# unchanged job return
1539
JOB_NOTCHANGED = "nochange"
1540

    
1541
# Job status
1542
JOB_STATUS_QUEUED = "queued"
1543
JOB_STATUS_WAITING = "waiting"
1544
JOB_STATUS_CANCELING = "canceling"
1545
JOB_STATUS_RUNNING = "running"
1546
JOB_STATUS_CANCELED = "canceled"
1547
JOB_STATUS_SUCCESS = "success"
1548
JOB_STATUS_ERROR = "error"
1549
JOBS_FINALIZED = frozenset([
1550
  JOB_STATUS_CANCELED,
1551
  JOB_STATUS_SUCCESS,
1552
  JOB_STATUS_ERROR,
1553
  ])
1554
JOB_STATUS_ALL = frozenset([
1555
  JOB_STATUS_QUEUED,
1556
  JOB_STATUS_WAITING,
1557
  JOB_STATUS_CANCELING,
1558
  JOB_STATUS_RUNNING,
1559
  ]) | JOBS_FINALIZED
1560

    
1561
# OpCode status
1562
# not yet finalized
1563
OP_STATUS_QUEUED = "queued"
1564
OP_STATUS_WAITING = "waiting"
1565
OP_STATUS_CANCELING = "canceling"
1566
OP_STATUS_RUNNING = "running"
1567
# finalized
1568
OP_STATUS_CANCELED = "canceled"
1569
OP_STATUS_SUCCESS = "success"
1570
OP_STATUS_ERROR = "error"
1571
OPS_FINALIZED = frozenset([
1572
  OP_STATUS_CANCELED,
1573
  OP_STATUS_SUCCESS,
1574
  OP_STATUS_ERROR
1575
  ])
1576

    
1577
# OpCode priority
1578
OP_PRIO_LOWEST = +19
1579
OP_PRIO_HIGHEST = -20
1580

    
1581
OP_PRIO_LOW = +10
1582
OP_PRIO_NORMAL = 0
1583
OP_PRIO_HIGH = -10
1584

    
1585
OP_PRIO_SUBMIT_VALID = frozenset([
1586
  OP_PRIO_LOW,
1587
  OP_PRIO_NORMAL,
1588
  OP_PRIO_HIGH,
1589
  ])
1590

    
1591
OP_PRIO_DEFAULT = OP_PRIO_NORMAL
1592

    
1593
# Lock recalculate mode
1594
LOCKS_REPLACE = "replace"
1595
LOCKS_APPEND = "append"
1596

    
1597
# Lock timeout (sum) before we should go into blocking acquire (still
1598
# can be reset by priority change); computed as max time (10 hours)
1599
# before we should actually go into blocking acquire given that we
1600
# start from default priority level; in seconds
1601
# TODO
1602
LOCK_ATTEMPTS_TIMEOUT = 10 * 3600 / (OP_PRIO_DEFAULT - OP_PRIO_HIGHEST)
1603
LOCK_ATTEMPTS_MAXWAIT = 15.0
1604
LOCK_ATTEMPTS_MINWAIT = 1.0
1605

    
1606
# Execution log types
1607
ELOG_MESSAGE = "message"
1608
ELOG_REMOTE_IMPORT = "remote-import"
1609
ELOG_JQUEUE_TEST = "jqueue-test"
1610

    
1611
# /etc/hosts modification
1612
ETC_HOSTS_ADD = "add"
1613
ETC_HOSTS_REMOVE = "remove"
1614

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

    
1628
# Query resources
1629
QR_CLUSTER = "cluster"
1630
QR_INSTANCE = "instance"
1631
QR_NODE = "node"
1632
QR_LOCK = "lock"
1633
QR_GROUP = "group"
1634
QR_OS = "os"
1635
QR_JOB = "job"
1636
QR_EXPORT = "export"
1637
QR_NETWORK = "network"
1638

    
1639
#: List of resources which can be queried using L{opcodes.OpQuery}
1640
QR_VIA_OP = frozenset([
1641
  QR_CLUSTER,
1642
  QR_INSTANCE,
1643
  QR_NODE,
1644
  QR_GROUP,
1645
  QR_OS,
1646
  QR_EXPORT,
1647
  QR_NETWORK,
1648
  ])
1649

    
1650
#: List of resources which can be queried using Local UniX Interface
1651
QR_VIA_LUXI = QR_VIA_OP.union([
1652
  QR_LOCK,
1653
  QR_JOB,
1654
  ])
1655

    
1656
#: List of resources which can be queried using RAPI
1657
QR_VIA_RAPI = QR_VIA_LUXI
1658

    
1659
# Query field types
1660
QFT_UNKNOWN = "unknown"
1661
QFT_TEXT = "text"
1662
QFT_BOOL = "bool"
1663
QFT_NUMBER = "number"
1664
QFT_UNIT = "unit"
1665
QFT_TIMESTAMP = "timestamp"
1666
QFT_OTHER = "other"
1667

    
1668
#: All query field types
1669
QFT_ALL = frozenset([
1670
  QFT_UNKNOWN,
1671
  QFT_TEXT,
1672
  QFT_BOOL,
1673
  QFT_NUMBER,
1674
  QFT_UNIT,
1675
  QFT_TIMESTAMP,
1676
  QFT_OTHER,
1677
  ])
1678

    
1679
# Query result field status (don't change or reuse values as they're used by
1680
# clients)
1681
#: Normal field status
1682
RS_NORMAL = 0
1683
#: Unknown field
1684
RS_UNKNOWN = 1
1685
#: No data (e.g. RPC error), can be used instead of L{RS_OFFLINE}
1686
RS_NODATA = 2
1687
#: Value unavailable/unsupported for item; if this field is supported
1688
#: but we cannot get the data for the moment, RS_NODATA or
1689
#: RS_OFFLINE should be used
1690
RS_UNAVAIL = 3
1691
#: Resource marked offline
1692
RS_OFFLINE = 4
1693

    
1694
RS_ALL = frozenset([
1695
  RS_NORMAL,
1696
  RS_UNKNOWN,
1697
  RS_NODATA,
1698
  RS_UNAVAIL,
1699
  RS_OFFLINE,
1700
  ])
1701

    
1702
#: Dictionary with special field cases and their verbose/terse formatting
1703
RSS_DESCRIPTION = {
1704
  RS_UNKNOWN: ("(unknown)", "??"),
1705
  RS_NODATA: ("(nodata)", "?"),
1706
  RS_OFFLINE: ("(offline)", "*"),
1707
  RS_UNAVAIL: ("(unavail)", "-"),
1708
  }
1709

    
1710
# max dynamic devices
1711
MAX_NICS = 8
1712
MAX_DISKS = 16
1713

    
1714
# SSCONF file prefix
1715
SSCONF_FILEPREFIX = "ssconf_"
1716
# SSCONF keys
1717
SS_CLUSTER_NAME = "cluster_name"
1718
SS_CLUSTER_TAGS = "cluster_tags"
1719
SS_FILE_STORAGE_DIR = "file_storage_dir"
1720
SS_SHARED_FILE_STORAGE_DIR = "shared_file_storage_dir"
1721
SS_MASTER_CANDIDATES = "master_candidates"
1722
SS_MASTER_CANDIDATES_IPS = "master_candidates_ips"
1723
SS_MASTER_IP = "master_ip"
1724
SS_MASTER_NETDEV = "master_netdev"
1725
SS_MASTER_NETMASK = "master_netmask"
1726
SS_MASTER_NODE = "master_node"
1727
SS_NODE_LIST = "node_list"
1728
SS_NODE_PRIMARY_IPS = "node_primary_ips"
1729
SS_NODE_SECONDARY_IPS = "node_secondary_ips"
1730
SS_OFFLINE_NODES = "offline_nodes"
1731
SS_ONLINE_NODES = "online_nodes"
1732
SS_PRIMARY_IP_FAMILY = "primary_ip_family"
1733
SS_INSTANCE_LIST = "instance_list"
1734
SS_RELEASE_VERSION = "release_version"
1735
SS_HYPERVISOR_LIST = "hypervisor_list"
1736
SS_MAINTAIN_NODE_HEALTH = "maintain_node_health"
1737
SS_UID_POOL = "uid_pool"
1738
SS_NODEGROUPS = "nodegroups"
1739
SS_NETWORKS = "networks"
1740

    
1741
SS_FILE_PERMS = 0444
1742

    
1743
# cluster wide default parameters
1744
DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM
1745

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

    
1837
HVC_GLOBALS = frozenset([
1838
  HV_MIGRATION_PORT,
1839
  HV_MIGRATION_BANDWIDTH,
1840
  HV_MIGRATION_MODE,
1841
  ])
1842

    
1843
BEC_DEFAULTS = {
1844
  BE_MINMEM: 128,
1845
  BE_MAXMEM: 128,
1846
  BE_VCPUS: 1,
1847
  BE_AUTO_BALANCE: True,
1848
  BE_ALWAYS_FAILOVER: False,
1849
  BE_SPINDLE_USE: 1,
1850
  }
1851

    
1852
NDC_DEFAULTS = {
1853
  ND_OOB_PROGRAM: None,
1854
  ND_SPINDLE_COUNT: 1,
1855
  }
1856

    
1857
DISK_LD_DEFAULTS = {
1858
  LD_DRBD8: {
1859
    LDP_RESYNC_RATE: CLASSIC_DRBD_SYNC_SPEED,
1860
    LDP_BARRIERS: _autoconf.DRBD_BARRIERS,
1861
    LDP_NO_META_FLUSH: _autoconf.DRBD_NO_META_FLUSH,
1862
    LDP_DEFAULT_METAVG: DEFAULT_VG,
1863
    LDP_DISK_CUSTOM: "",
1864
    LDP_NET_CUSTOM: "",
1865
    LDP_DYNAMIC_RESYNC: False,
1866

    
1867
    # The default values for the DRBD dynamic resync speed algorithm are taken
1868
    # from the drbsetup 8.3.11 man page, except for c-plan-ahead (that we
1869
    # don't need to set to 0, because we have a separate option to enable it)
1870
    # and for c-max-rate, that we cap to the default value for the static resync
1871
    # rate.
1872
    LDP_PLAN_AHEAD: 20, # ds
1873
    LDP_FILL_TARGET: 0, # sectors
1874
    LDP_DELAY_TARGET: 1, # ds
1875
    LDP_MAX_RATE: CLASSIC_DRBD_SYNC_SPEED, # KiB/s
1876
    LDP_MIN_RATE: 4 * 1024, # KiB/s
1877
    },
1878
  LD_LV: {
1879
    LDP_STRIPES: _autoconf.LVM_STRIPECOUNT
1880
    },
1881
  LD_FILE: {
1882
    },
1883
  LD_BLOCKDEV: {
1884
    },
1885
  LD_RBD: {
1886
    LDP_POOL: "rbd"
1887
    },
1888
  }
1889

    
1890
# readability shortcuts
1891
_LV_DEFAULTS = DISK_LD_DEFAULTS[LD_LV]
1892
_DRBD_DEFAULTS = DISK_LD_DEFAULTS[LD_DRBD8]
1893

    
1894
DISK_DT_DEFAULTS = {
1895
  DT_PLAIN: {
1896
    LV_STRIPES: DISK_LD_DEFAULTS[LD_LV][LDP_STRIPES],
1897
    },
1898
  DT_DRBD8: {
1899
    DRBD_RESYNC_RATE: _DRBD_DEFAULTS[LDP_RESYNC_RATE],
1900
    DRBD_DATA_STRIPES: _LV_DEFAULTS[LDP_STRIPES],
1901
    DRBD_META_STRIPES: _LV_DEFAULTS[LDP_STRIPES],
1902
    DRBD_DISK_BARRIERS: _DRBD_DEFAULTS[LDP_BARRIERS],
1903
    DRBD_META_BARRIERS: _DRBD_DEFAULTS[LDP_NO_META_FLUSH],
1904
    DRBD_DEFAULT_METAVG: _DRBD_DEFAULTS[LDP_DEFAULT_METAVG],
1905
    DRBD_DISK_CUSTOM: _DRBD_DEFAULTS[LDP_DISK_CUSTOM],
1906
    DRBD_NET_CUSTOM: _DRBD_DEFAULTS[LDP_NET_CUSTOM],
1907
    DRBD_DYNAMIC_RESYNC: _DRBD_DEFAULTS[LDP_DYNAMIC_RESYNC],
1908
    DRBD_PLAN_AHEAD: _DRBD_DEFAULTS[LDP_PLAN_AHEAD],
1909
    DRBD_FILL_TARGET: _DRBD_DEFAULTS[LDP_FILL_TARGET],
1910
    DRBD_DELAY_TARGET: _DRBD_DEFAULTS[LDP_DELAY_TARGET],
1911
    DRBD_MAX_RATE: _DRBD_DEFAULTS[LDP_MAX_RATE],
1912
    DRBD_MIN_RATE: _DRBD_DEFAULTS[LDP_MIN_RATE],
1913
    },
1914
  DT_DISKLESS: {
1915
    },
1916
  DT_FILE: {
1917
    },
1918
  DT_SHARED_FILE: {
1919
    },
1920
  DT_BLOCK: {
1921
    },
1922
  DT_RBD: {
1923
    RBD_POOL: DISK_LD_DEFAULTS[LD_RBD][LDP_POOL]
1924
    },
1925
  }
1926

    
1927
# we don't want to export the shortcuts
1928
del _LV_DEFAULTS, _DRBD_DEFAULTS
1929

    
1930
NICC_DEFAULTS = {
1931
  NIC_MODE: NIC_MODE_BRIDGED,
1932
  NIC_LINK: DEFAULT_BRIDGE,
1933
  }
1934

    
1935
# All of the following values are quite arbitrarily - there are no
1936
# "good" defaults, these must be customised per-site
1937
IPOLICY_DEFAULTS = {
1938
  ISPECS_MIN: {
1939
    ISPEC_MEM_SIZE: 128,
1940
    ISPEC_CPU_COUNT: 1,
1941
    ISPEC_DISK_COUNT: 1,
1942
    ISPEC_DISK_SIZE: 1024,
1943
    ISPEC_NIC_COUNT: 1,
1944
    ISPEC_SPINDLE_USE: 1,
1945
    },
1946
  ISPECS_MAX: {
1947
    ISPEC_MEM_SIZE: 32768,
1948
    ISPEC_CPU_COUNT: 8,
1949
    ISPEC_DISK_COUNT: MAX_DISKS,
1950
    ISPEC_DISK_SIZE: 1024 * 1024,
1951
    ISPEC_NIC_COUNT: MAX_NICS,
1952
    ISPEC_SPINDLE_USE: 12,
1953
    },
1954
  ISPECS_STD: {
1955
    ISPEC_MEM_SIZE: 128,
1956
    ISPEC_CPU_COUNT: 1,
1957
    ISPEC_DISK_COUNT: 1,
1958
    ISPEC_DISK_SIZE: 1024,
1959
    ISPEC_NIC_COUNT: 1,
1960
    ISPEC_SPINDLE_USE: 1,
1961
    },
1962
  IPOLICY_DTS: DISK_TEMPLATES,
1963
  IPOLICY_VCPU_RATIO: 4.0,
1964
  IPOLICY_SPINDLE_RATIO: 32.0,
1965
  }
1966

    
1967
MASTER_POOL_SIZE_DEFAULT = 10
1968

    
1969
CONFD_PROTOCOL_VERSION = 1
1970

    
1971
CONFD_REQ_PING = 0
1972
CONFD_REQ_NODE_ROLE_BYNAME = 1
1973
CONFD_REQ_NODE_PIP_BY_INSTANCE_IP = 2
1974
CONFD_REQ_CLUSTER_MASTER = 3
1975
CONFD_REQ_NODE_PIP_LIST = 4
1976
CONFD_REQ_MC_PIP_LIST = 5
1977
CONFD_REQ_INSTANCES_IPS_LIST = 6
1978

    
1979
# Confd request query fields. These are used to narrow down queries.
1980
# These must be strings rather than integers, because json-encoding
1981
# converts them to strings anyway, as they're used as dict-keys.
1982
CONFD_REQQ_LINK = "0"
1983
CONFD_REQQ_IP = "1"
1984
CONFD_REQQ_IPLIST = "2"
1985
CONFD_REQQ_FIELDS = "3"
1986

    
1987
CONFD_REQFIELD_NAME = "0"
1988
CONFD_REQFIELD_IP = "1"
1989
CONFD_REQFIELD_MNODE_PIP = "2"
1990

    
1991
CONFD_REQS = frozenset([
1992
  CONFD_REQ_PING,
1993
  CONFD_REQ_NODE_ROLE_BYNAME,
1994
  CONFD_REQ_NODE_PIP_BY_INSTANCE_IP,
1995
  CONFD_REQ_CLUSTER_MASTER,
1996
  CONFD_REQ_NODE_PIP_LIST,
1997
  CONFD_REQ_MC_PIP_LIST,
1998
  CONFD_REQ_INSTANCES_IPS_LIST,
1999
  ])
2000

    
2001
CONFD_REPL_STATUS_OK = 0
2002
CONFD_REPL_STATUS_ERROR = 1
2003
CONFD_REPL_STATUS_NOTIMPLEMENTED = 2
2004

    
2005
CONFD_REPL_STATUSES = frozenset([
2006
  CONFD_REPL_STATUS_OK,
2007
  CONFD_REPL_STATUS_ERROR,
2008
  CONFD_REPL_STATUS_NOTIMPLEMENTED,
2009
  ])
2010

    
2011
(CONFD_NODE_ROLE_MASTER,
2012
 CONFD_NODE_ROLE_CANDIDATE,
2013
 CONFD_NODE_ROLE_OFFLINE,
2014
 CONFD_NODE_ROLE_DRAINED,
2015
 CONFD_NODE_ROLE_REGULAR,
2016
 ) = range(5)
2017

    
2018
# A few common errors for confd
2019
CONFD_ERROR_UNKNOWN_ENTRY = 1
2020
CONFD_ERROR_INTERNAL = 2
2021
CONFD_ERROR_ARGUMENT = 3
2022

    
2023
# Each request is "salted" by the current timestamp.
2024
# This constants decides how many seconds of skew to accept.
2025
# TODO: make this a default and allow the value to be more configurable
2026
CONFD_MAX_CLOCK_SKEW = 2 * NODE_MAX_CLOCK_SKEW
2027

    
2028
# When we haven't reloaded the config for more than this amount of seconds, we
2029
# force a test to see if inotify is betraying us.
2030
CONFD_CONFIG_RELOAD_TIMEOUT = 60
2031

    
2032
# If we receive more than one update in this amount of seconds, we move to
2033
# polling every RATELIMIT seconds, rather than relying on inotify, to be able
2034
# to serve more requests.
2035
CONFD_CONFIG_RELOAD_RATELIMIT = 2
2036

    
2037
# Magic number prepended to all confd queries.
2038
# This allows us to distinguish different types of confd protocols and handle
2039
# them. For example by changing this we can move the whole payload to be
2040
# compressed, or move away from json.
2041
CONFD_MAGIC_FOURCC = "plj0"
2042

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

    
2048
# Timeout in seconds to expire pending query request in the confd client
2049
# library. We don't actually expect any answer more than 10 seconds after we
2050
# sent a request.
2051
CONFD_CLIENT_EXPIRE_TIMEOUT = 10
2052

    
2053
# Maximum UDP datagram size.
2054
# On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
2055
# On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
2056
#   (assuming we can't use jumbo frames)
2057
# We just set this to 60K, which should be enough
2058
MAX_UDP_DATA_SIZE = 61440
2059

    
2060
# User-id pool minimum/maximum acceptable user-ids.
2061
UIDPOOL_UID_MIN = 0
2062
UIDPOOL_UID_MAX = 2 ** 32 - 1 # Assuming 32 bit user-ids
2063

    
2064
# Name or path of the pgrep command
2065
PGREP = "pgrep"
2066

    
2067
# Name of the node group that gets created at cluster init or upgrade
2068
INITIAL_NODE_GROUP_NAME = "default"
2069

    
2070
# Possible values for NodeGroup.alloc_policy
2071
ALLOC_POLICY_PREFERRED = "preferred"
2072
ALLOC_POLICY_LAST_RESORT = "last_resort"
2073
ALLOC_POLICY_UNALLOCABLE = "unallocable"
2074
VALID_ALLOC_POLICIES = [
2075
  ALLOC_POLICY_PREFERRED,
2076
  ALLOC_POLICY_LAST_RESORT,
2077
  ALLOC_POLICY_UNALLOCABLE,
2078
  ]
2079

    
2080
# Temporary external/shared storage parameters
2081
BLOCKDEV_DRIVER_MANUAL = "manual"
2082

    
2083
# qemu-img path, required for ovfconverter
2084
QEMUIMG_PATH = _autoconf.QEMUIMG_PATH
2085

    
2086
# Whether htools was enabled at compilation time
2087
HTOOLS = _autoconf.HTOOLS
2088
# The hail iallocator
2089
IALLOC_HAIL = "hail"
2090

    
2091
# Fake opcodes for functions that have hooks attached to them via
2092
# backend.RunLocalHooks
2093
FAKE_OP_MASTER_TURNUP = "OP_CLUSTER_IP_TURNUP"
2094
FAKE_OP_MASTER_TURNDOWN = "OP_CLUSTER_IP_TURNDOWN"
2095

    
2096
# Do not re-export imported modules
2097
del re, _vcsversion, _autoconf, socket