Statistics
| Branch: | Tag: | Revision:

root / lib / constants.py @ fd3e6a69

History | View | Annotate | Download (55.9 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_PUBLIC = "public"
1099
NETWORK_TYPE_PUBLIC_ROUTED = "public-routed"
1100
NETWORK_TYPE_PRIVATE = "private"
1101
NETWORK_TYPE_PRIVATE_FILTERED = "private-filtered"
1102
NETWORK_TYPE_PRIVATE_VLAN = "private-vlan"
1103

    
1104
NETWORK_VALID_TYPES = frozenset([NETWORK_TYPE_PUBLIC,
1105
                                 NETWORK_TYPE_PUBLIC_ROUTED,
1106
                                 NETWORK_TYPE_PRIVATE,
1107
                                 NETWORK_TYPE_PRIVATE_VLAN,
1108
                                 NETWORK_TYPE_PRIVATE_FILTERED])
1109

    
1110
NICS_PARAMETER_TYPES = {
1111
  NIC_MODE: VTYPE_STRING,
1112
  NIC_LINK: VTYPE_STRING,
1113
  }
1114

    
1115
NICS_PARAMETERS = frozenset(NICS_PARAMETER_TYPES.keys())
1116

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

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

    
1147
PCI = "pci"
1148
PCI_DOMAIN = "domain"
1149
PCI_BUS = "bus"
1150
PCI_SLOT = "slot"
1151
PCI_FUNCTION = "function"
1152
PCI_PARAMS_TYPES = {
1153
  PCI_DOMAIN: VTYPE_STRING,
1154
  PCI_BUS: VTYPE_STRING,
1155
  PCI_SLOT: VTYPE_STRING,
1156
  PCI_FUNCTION: VTYPE_STRING,
1157
  }
1158
PCI_PARAMS = frozenset(PCI_PARAMS_TYPES.keys())
1159

    
1160

    
1161
# Hypervisor constants
1162
HT_XEN_PVM = "xen-pvm"
1163
HT_FAKE = "fake"
1164
HT_XEN_HVM = "xen-hvm"
1165
HT_KVM = "kvm"
1166
HT_CHROOT = "chroot"
1167
HT_LXC = "lxc"
1168
HYPER_TYPES = frozenset([
1169
  HT_XEN_PVM,
1170
  HT_FAKE,
1171
  HT_XEN_HVM,
1172
  HT_KVM,
1173
  HT_CHROOT,
1174
  HT_LXC,
1175
  ])
1176
HTS_REQ_PORT = frozenset([HT_XEN_HVM, HT_KVM])
1177

    
1178
VNC_BASE_PORT = 5900
1179
VNC_PASSWORD_FILE = CONF_DIR + "/vnc-cluster-password"
1180
VNC_DEFAULT_BIND_ADDRESS = IP4_ADDRESS_ANY
1181

    
1182
# NIC types
1183
HT_NIC_RTL8139 = "rtl8139"
1184
HT_NIC_NE2K_PCI = "ne2k_pci"
1185
HT_NIC_NE2K_ISA = "ne2k_isa"
1186
HT_NIC_I82551 = "i82551"
1187
HT_NIC_I85557B = "i82557b"
1188
HT_NIC_I8259ER = "i82559er"
1189
HT_NIC_PCNET = "pcnet"
1190
HT_NIC_E1000 = "e1000"
1191
HT_NIC_PARAVIRTUAL = HT_DISK_PARAVIRTUAL = "paravirtual"
1192

    
1193
HT_HVM_VALID_NIC_TYPES = frozenset([
1194
  HT_NIC_RTL8139,
1195
  HT_NIC_NE2K_PCI,
1196
  HT_NIC_E1000,
1197
  HT_NIC_NE2K_ISA,
1198
  HT_NIC_PARAVIRTUAL
1199
  ])
1200
HT_KVM_VALID_NIC_TYPES = frozenset([
1201
  HT_NIC_RTL8139,
1202
  HT_NIC_NE2K_PCI,
1203
  HT_NIC_NE2K_ISA,
1204
  HT_NIC_I82551,
1205
  HT_NIC_I85557B,
1206
  HT_NIC_I8259ER,
1207
  HT_NIC_PCNET,
1208
  HT_NIC_E1000,
1209
  HT_NIC_PARAVIRTUAL
1210
  ])
1211

    
1212
# Disk types
1213
HT_DISK_IOEMU = "ioemu"
1214
HT_DISK_IDE = "ide"
1215
HT_DISK_SCSI = "scsi"
1216
HT_DISK_SD = "sd"
1217
HT_DISK_MTD = "mtd"
1218
HT_DISK_PFLASH = "pflash"
1219

    
1220
HT_CACHE_DEFAULT = "default"
1221
HT_CACHE_NONE = "none"
1222
HT_CACHE_WTHROUGH = "writethrough"
1223
HT_CACHE_WBACK = "writeback"
1224
HT_VALID_CACHE_TYPES = frozenset([
1225
  HT_CACHE_DEFAULT,
1226
  HT_CACHE_NONE,
1227
  HT_CACHE_WTHROUGH,
1228
  HT_CACHE_WBACK
1229
  ])
1230

    
1231
HT_HVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IOEMU])
1232
HT_KVM_VALID_DISK_TYPES = frozenset([
1233
  HT_DISK_PARAVIRTUAL,
1234
  HT_DISK_IDE,
1235
  HT_DISK_SCSI,
1236
  HT_DISK_SD,
1237
  HT_DISK_MTD,
1238
  HT_DISK_PFLASH
1239
  ])
1240

    
1241
# Mouse types:
1242
HT_MOUSE_MOUSE = "mouse"
1243
HT_MOUSE_TABLET = "tablet"
1244

    
1245
HT_KVM_VALID_MOUSE_TYPES = frozenset([HT_MOUSE_MOUSE, HT_MOUSE_TABLET])
1246

    
1247
# Boot order
1248
HT_BO_FLOPPY = "floppy"
1249
HT_BO_CDROM = "cdrom"
1250
HT_BO_DISK = "disk"
1251
HT_BO_NETWORK = "network"
1252

    
1253
HT_KVM_VALID_BO_TYPES = frozenset([
1254
  HT_BO_FLOPPY,
1255
  HT_BO_CDROM,
1256
  HT_BO_DISK,
1257
  HT_BO_NETWORK
1258
  ])
1259

    
1260
# SPICE lossless image compression options
1261
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ = "auto_glz"
1262
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ = "auto_lz"
1263
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC = "quic"
1264
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ = "glz"
1265
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ = "lz"
1266
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF = "off"
1267

    
1268
HT_KVM_SPICE_VALID_LOSSLESS_IMG_COMPR_OPTIONS = frozenset([
1269
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ,
1270
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ,
1271
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC,
1272
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ,
1273
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ,
1274
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF,
1275
  ])
1276

    
1277
# SPICE lossy image compression options (valid for both jpeg and zlib-glz)
1278
HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO = "auto"
1279
HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER = "never"
1280
HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS = "always"
1281

    
1282
HT_KVM_SPICE_VALID_LOSSY_IMG_COMPR_OPTIONS = frozenset([
1283
  HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO,
1284
  HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER,
1285
  HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS,
1286
  ])
1287

    
1288
# SPICE video stream detection
1289
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF = "off"
1290
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL = "all"
1291
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER = "filter"
1292

    
1293
HT_KVM_SPICE_VALID_VIDEO_STREAM_DETECTION_OPTIONS = frozenset([
1294
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF,
1295
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL,
1296
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER,
1297
  ])
1298

    
1299
# Security models
1300
HT_SM_NONE = "none"
1301
HT_SM_USER = "user"
1302
HT_SM_POOL = "pool"
1303

    
1304
HT_KVM_VALID_SM_TYPES = frozenset([HT_SM_NONE, HT_SM_USER, HT_SM_POOL])
1305

    
1306
# Kvm flag values
1307
HT_KVM_ENABLED = "enabled"
1308
HT_KVM_DISABLED = "disabled"
1309

    
1310
HT_KVM_FLAG_VALUES = frozenset([HT_KVM_ENABLED, HT_KVM_DISABLED])
1311

    
1312
# Migration type
1313
HT_MIGRATION_LIVE = "live"
1314
HT_MIGRATION_NONLIVE = "non-live"
1315
HT_MIGRATION_MODES = frozenset([HT_MIGRATION_LIVE, HT_MIGRATION_NONLIVE])
1316

    
1317
# Cluster Verify steps
1318
VERIFY_NPLUSONE_MEM = "nplusone_mem"
1319
VERIFY_OPTIONAL_CHECKS = frozenset([VERIFY_NPLUSONE_MEM])
1320

    
1321
# Cluster Verify error classes
1322
CV_TCLUSTER = "cluster"
1323
CV_TNODE = "node"
1324
CV_TINSTANCE = "instance"
1325

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

    
1401
CV_ALL_ECODES = frozenset([
1402
  CV_ECLUSTERCFG,
1403
  CV_ECLUSTERCERT,
1404
  CV_ECLUSTERFILECHECK,
1405
  CV_ECLUSTERDANGLINGNODES,
1406
  CV_ECLUSTERDANGLINGINST,
1407
  CV_EINSTANCEBADNODE,
1408
  CV_EINSTANCEDOWN,
1409
  CV_EINSTANCELAYOUT,
1410
  CV_EINSTANCEMISSINGDISK,
1411
  CV_EINSTANCEFAULTYDISK,
1412
  CV_EINSTANCEWRONGNODE,
1413
  CV_EINSTANCESPLITGROUPS,
1414
  CV_EINSTANCEPOLICY,
1415
  CV_ENODEDRBD,
1416
  CV_ENODEDRBDHELPER,
1417
  CV_ENODEFILECHECK,
1418
  CV_ENODEHOOKS,
1419
  CV_ENODEHV,
1420
  CV_ENODELVM,
1421
  CV_ENODEN1,
1422
  CV_ENODENET,
1423
  CV_ENODEOS,
1424
  CV_ENODEORPHANINSTANCE,
1425
  CV_ENODEORPHANLV,
1426
  CV_ENODERPC,
1427
  CV_ENODESSH,
1428
  CV_ENODEVERSION,
1429
  CV_ENODESETUP,
1430
  CV_ENODETIME,
1431
  CV_ENODEOOBPATH,
1432
  CV_ENODEUSERSCRIPTS,
1433
  ])
1434

    
1435
CV_ALL_ECODES_STRINGS = frozenset(estr for (_, estr, _) in CV_ALL_ECODES)
1436

    
1437
# Node verify constants
1438
NV_DRBDHELPER = "drbd-helper"
1439
NV_DRBDLIST = "drbd-list"
1440
NV_FILELIST = "filelist"
1441
NV_HVINFO = "hvinfo"
1442
NV_HYPERVISOR = "hypervisor"
1443
NV_HVPARAMS = "hvparms"
1444
NV_INSTANCELIST = "instancelist"
1445
NV_LVLIST = "lvlist"
1446
NV_MASTERIP = "master-ip"
1447
NV_NODELIST = "nodelist"
1448
NV_NODENETTEST = "node-net-test"
1449
NV_NODESETUP = "nodesetup"
1450
NV_OSLIST = "oslist"
1451
NV_PVLIST = "pvlist"
1452
NV_TIME = "time"
1453
NV_VERSION = "version"
1454
NV_VGLIST = "vglist"
1455
NV_VMNODES = "vmnodes"
1456
NV_OOB_PATHS = "oob-paths"
1457
NV_BRIDGES = "bridges"
1458
NV_USERSCRIPTS = "user-scripts"
1459

    
1460
# Instance status
1461
INSTST_RUNNING = "running"
1462
INSTST_ADMINDOWN = "ADMIN_down"
1463
INSTST_ADMINOFFLINE = "ADMIN_offline"
1464
INSTST_NODEOFFLINE = "ERROR_nodeoffline"
1465
INSTST_NODEDOWN = "ERROR_nodedown"
1466
INSTST_WRONGNODE = "ERROR_wrongnode"
1467
INSTST_ERRORUP = "ERROR_up"
1468
INSTST_ERRORDOWN = "ERROR_down"
1469
INSTST_ALL = frozenset([
1470
  INSTST_RUNNING,
1471
  INSTST_ADMINDOWN,
1472
  INSTST_ADMINOFFLINE,
1473
  INSTST_NODEOFFLINE,
1474
  INSTST_NODEDOWN,
1475
  INSTST_WRONGNODE,
1476
  INSTST_ERRORUP,
1477
  INSTST_ERRORDOWN,
1478
  ])
1479

    
1480
# Admin states
1481
ADMINST_UP = "up"
1482
ADMINST_DOWN = "down"
1483
ADMINST_OFFLINE = "offline"
1484
ADMINST_ALL = frozenset([
1485
  ADMINST_UP,
1486
  ADMINST_DOWN,
1487
  ADMINST_OFFLINE,
1488
  ])
1489

    
1490
# Node roles
1491
NR_REGULAR = "R"
1492
NR_MASTER = "M"
1493
NR_MCANDIDATE = "C"
1494
NR_DRAINED = "D"
1495
NR_OFFLINE = "O"
1496
NR_ALL = frozenset([
1497
  NR_REGULAR,
1498
  NR_MASTER,
1499
  NR_MCANDIDATE,
1500
  NR_DRAINED,
1501
  NR_OFFLINE,
1502
  ])
1503

    
1504
# SSL certificate check constants (in days)
1505
SSL_CERT_EXPIRATION_WARN = 30
1506
SSL_CERT_EXPIRATION_ERROR = 7
1507

    
1508
# Allocator framework constants
1509
IALLOCATOR_VERSION = 2
1510
IALLOCATOR_DIR_IN = "in"
1511
IALLOCATOR_DIR_OUT = "out"
1512
VALID_IALLOCATOR_DIRECTIONS = frozenset([
1513
  IALLOCATOR_DIR_IN,
1514
  IALLOCATOR_DIR_OUT,
1515
  ])
1516
IALLOCATOR_MODE_ALLOC = "allocate"
1517
IALLOCATOR_MODE_RELOC = "relocate"
1518
IALLOCATOR_MODE_CHG_GROUP = "change-group"
1519
IALLOCATOR_MODE_NODE_EVAC = "node-evacuate"
1520
VALID_IALLOCATOR_MODES = frozenset([
1521
  IALLOCATOR_MODE_ALLOC,
1522
  IALLOCATOR_MODE_RELOC,
1523
  IALLOCATOR_MODE_CHG_GROUP,
1524
  IALLOCATOR_MODE_NODE_EVAC,
1525
  ])
1526
IALLOCATOR_SEARCH_PATH = _autoconf.IALLOCATOR_SEARCH_PATH
1527

    
1528
IALLOCATOR_NEVAC_PRI = "primary-only"
1529
IALLOCATOR_NEVAC_SEC = "secondary-only"
1530
IALLOCATOR_NEVAC_ALL = "all"
1531
IALLOCATOR_NEVAC_MODES = frozenset([
1532
  IALLOCATOR_NEVAC_PRI,
1533
  IALLOCATOR_NEVAC_SEC,
1534
  IALLOCATOR_NEVAC_ALL,
1535
  ])
1536

    
1537
# Node evacuation
1538
NODE_EVAC_PRI = "primary-only"
1539
NODE_EVAC_SEC = "secondary-only"
1540
NODE_EVAC_ALL = "all"
1541
NODE_EVAC_MODES = frozenset([
1542
  NODE_EVAC_PRI,
1543
  NODE_EVAC_SEC,
1544
  NODE_EVAC_ALL,
1545
  ])
1546

    
1547
# Job queue
1548
JOB_QUEUE_VERSION = 1
1549
JOB_QUEUE_LOCK_FILE = QUEUE_DIR + "/lock"
1550
JOB_QUEUE_VERSION_FILE = QUEUE_DIR + "/version"
1551
JOB_QUEUE_SERIAL_FILE = QUEUE_DIR + "/serial"
1552
JOB_QUEUE_ARCHIVE_DIR = QUEUE_DIR + "/archive"
1553
JOB_QUEUE_DRAIN_FILE = QUEUE_DIR + "/drain"
1554
JOB_QUEUE_SIZE_HARD_LIMIT = 5000
1555

    
1556
JOB_ID_TEMPLATE = r"\d+"
1557
JOB_FILE_RE = re.compile(r"^job-(%s)$" % JOB_ID_TEMPLATE)
1558

    
1559
# unchanged job return
1560
JOB_NOTCHANGED = "nochange"
1561

    
1562
# Job status
1563
JOB_STATUS_QUEUED = "queued"
1564
JOB_STATUS_WAITING = "waiting"
1565
JOB_STATUS_CANCELING = "canceling"
1566
JOB_STATUS_RUNNING = "running"
1567
JOB_STATUS_CANCELED = "canceled"
1568
JOB_STATUS_SUCCESS = "success"
1569
JOB_STATUS_ERROR = "error"
1570
JOBS_FINALIZED = frozenset([
1571
  JOB_STATUS_CANCELED,
1572
  JOB_STATUS_SUCCESS,
1573
  JOB_STATUS_ERROR,
1574
  ])
1575
JOB_STATUS_ALL = frozenset([
1576
  JOB_STATUS_QUEUED,
1577
  JOB_STATUS_WAITING,
1578
  JOB_STATUS_CANCELING,
1579
  JOB_STATUS_RUNNING,
1580
  ]) | JOBS_FINALIZED
1581

    
1582
# OpCode status
1583
# not yet finalized
1584
OP_STATUS_QUEUED = "queued"
1585
OP_STATUS_WAITING = "waiting"
1586
OP_STATUS_CANCELING = "canceling"
1587
OP_STATUS_RUNNING = "running"
1588
# finalized
1589
OP_STATUS_CANCELED = "canceled"
1590
OP_STATUS_SUCCESS = "success"
1591
OP_STATUS_ERROR = "error"
1592
OPS_FINALIZED = frozenset([
1593
  OP_STATUS_CANCELED,
1594
  OP_STATUS_SUCCESS,
1595
  OP_STATUS_ERROR
1596
  ])
1597

    
1598
# OpCode priority
1599
OP_PRIO_LOWEST = +19
1600
OP_PRIO_HIGHEST = -20
1601

    
1602
OP_PRIO_LOW = +10
1603
OP_PRIO_NORMAL = 0
1604
OP_PRIO_HIGH = -10
1605

    
1606
OP_PRIO_SUBMIT_VALID = frozenset([
1607
  OP_PRIO_LOW,
1608
  OP_PRIO_NORMAL,
1609
  OP_PRIO_HIGH,
1610
  ])
1611

    
1612
OP_PRIO_DEFAULT = OP_PRIO_NORMAL
1613

    
1614
# Lock recalculate mode
1615
LOCKS_REPLACE = "replace"
1616
LOCKS_APPEND = "append"
1617

    
1618
# Lock timeout (sum) before we should go into blocking acquire (still
1619
# can be reset by priority change); computed as max time (10 hours)
1620
# before we should actually go into blocking acquire given that we
1621
# start from default priority level; in seconds
1622
# TODO
1623
LOCK_ATTEMPTS_TIMEOUT = 10 * 3600 / (OP_PRIO_DEFAULT - OP_PRIO_HIGHEST)
1624
LOCK_ATTEMPTS_MAXWAIT = 15.0
1625
LOCK_ATTEMPTS_MINWAIT = 1.0
1626

    
1627
# Execution log types
1628
ELOG_MESSAGE = "message"
1629
ELOG_REMOTE_IMPORT = "remote-import"
1630
ELOG_JQUEUE_TEST = "jqueue-test"
1631

    
1632
# /etc/hosts modification
1633
ETC_HOSTS_ADD = "add"
1634
ETC_HOSTS_REMOVE = "remove"
1635

    
1636
# Job queue test
1637
JQT_MSGPREFIX = "TESTMSG="
1638
JQT_EXPANDNAMES = "expandnames"
1639
JQT_EXEC = "exec"
1640
JQT_LOGMSG = "logmsg"
1641
JQT_STARTMSG = "startmsg"
1642
JQT_ALL = frozenset([
1643
  JQT_EXPANDNAMES,
1644
  JQT_EXEC,
1645
  JQT_LOGMSG,
1646
  JQT_STARTMSG,
1647
  ])
1648

    
1649
# Query resources
1650
QR_CLUSTER = "cluster"
1651
QR_INSTANCE = "instance"
1652
QR_NODE = "node"
1653
QR_LOCK = "lock"
1654
QR_GROUP = "group"
1655
QR_OS = "os"
1656
QR_JOB = "job"
1657
QR_EXPORT = "export"
1658
QR_NETWORK = "network"
1659

    
1660
#: List of resources which can be queried using L{opcodes.OpQuery}
1661
QR_VIA_OP = frozenset([
1662
  QR_CLUSTER,
1663
  QR_INSTANCE,
1664
  QR_NODE,
1665
  QR_GROUP,
1666
  QR_OS,
1667
  QR_EXPORT,
1668
  QR_NETWORK,
1669
  ])
1670

    
1671
#: List of resources which can be queried using Local UniX Interface
1672
QR_VIA_LUXI = QR_VIA_OP.union([
1673
  QR_LOCK,
1674
  QR_JOB,
1675
  ])
1676

    
1677
#: List of resources which can be queried using RAPI
1678
QR_VIA_RAPI = QR_VIA_LUXI
1679

    
1680
# Query field types
1681
QFT_UNKNOWN = "unknown"
1682
QFT_TEXT = "text"
1683
QFT_BOOL = "bool"
1684
QFT_NUMBER = "number"
1685
QFT_UNIT = "unit"
1686
QFT_TIMESTAMP = "timestamp"
1687
QFT_OTHER = "other"
1688

    
1689
#: All query field types
1690
QFT_ALL = frozenset([
1691
  QFT_UNKNOWN,
1692
  QFT_TEXT,
1693
  QFT_BOOL,
1694
  QFT_NUMBER,
1695
  QFT_UNIT,
1696
  QFT_TIMESTAMP,
1697
  QFT_OTHER,
1698
  ])
1699

    
1700
# Query result field status (don't change or reuse values as they're used by
1701
# clients)
1702
#: Normal field status
1703
RS_NORMAL = 0
1704
#: Unknown field
1705
RS_UNKNOWN = 1
1706
#: No data (e.g. RPC error), can be used instead of L{RS_OFFLINE}
1707
RS_NODATA = 2
1708
#: Value unavailable/unsupported for item; if this field is supported
1709
#: but we cannot get the data for the moment, RS_NODATA or
1710
#: RS_OFFLINE should be used
1711
RS_UNAVAIL = 3
1712
#: Resource marked offline
1713
RS_OFFLINE = 4
1714

    
1715
RS_ALL = frozenset([
1716
  RS_NORMAL,
1717
  RS_UNKNOWN,
1718
  RS_NODATA,
1719
  RS_UNAVAIL,
1720
  RS_OFFLINE,
1721
  ])
1722

    
1723
#: Dictionary with special field cases and their verbose/terse formatting
1724
RSS_DESCRIPTION = {
1725
  RS_UNKNOWN: ("(unknown)", "??"),
1726
  RS_NODATA: ("(nodata)", "?"),
1727
  RS_OFFLINE: ("(offline)", "*"),
1728
  RS_UNAVAIL: ("(unavail)", "-"),
1729
  }
1730

    
1731
# max dynamic devices
1732
MAX_NICS = 8
1733
MAX_DISKS = 16
1734

    
1735
# SSCONF file prefix
1736
SSCONF_FILEPREFIX = "ssconf_"
1737
# SSCONF keys
1738
SS_CLUSTER_NAME = "cluster_name"
1739
SS_CLUSTER_TAGS = "cluster_tags"
1740
SS_FILE_STORAGE_DIR = "file_storage_dir"
1741
SS_SHARED_FILE_STORAGE_DIR = "shared_file_storage_dir"
1742
SS_MASTER_CANDIDATES = "master_candidates"
1743
SS_MASTER_CANDIDATES_IPS = "master_candidates_ips"
1744
SS_MASTER_IP = "master_ip"
1745
SS_MASTER_NETDEV = "master_netdev"
1746
SS_MASTER_NETMASK = "master_netmask"
1747
SS_MASTER_NODE = "master_node"
1748
SS_NODE_LIST = "node_list"
1749
SS_NODE_PRIMARY_IPS = "node_primary_ips"
1750
SS_NODE_SECONDARY_IPS = "node_secondary_ips"
1751
SS_OFFLINE_NODES = "offline_nodes"
1752
SS_ONLINE_NODES = "online_nodes"
1753
SS_PRIMARY_IP_FAMILY = "primary_ip_family"
1754
SS_INSTANCE_LIST = "instance_list"
1755
SS_RELEASE_VERSION = "release_version"
1756
SS_HYPERVISOR_LIST = "hypervisor_list"
1757
SS_MAINTAIN_NODE_HEALTH = "maintain_node_health"
1758
SS_UID_POOL = "uid_pool"
1759
SS_NODEGROUPS = "nodegroups"
1760
SS_NETWORKS = "networks"
1761

    
1762
SS_FILE_PERMS = 0444
1763

    
1764
# cluster wide default parameters
1765
DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM
1766

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

    
1858
HVC_GLOBALS = frozenset([
1859
  HV_MIGRATION_PORT,
1860
  HV_MIGRATION_BANDWIDTH,
1861
  HV_MIGRATION_MODE,
1862
  ])
1863

    
1864
BEC_DEFAULTS = {
1865
  BE_MINMEM: 128,
1866
  BE_MAXMEM: 128,
1867
  BE_VCPUS: 1,
1868
  BE_AUTO_BALANCE: True,
1869
  BE_ALWAYS_FAILOVER: False,
1870
  BE_SPINDLE_USE: 1,
1871
  }
1872

    
1873
NDC_DEFAULTS = {
1874
  ND_OOB_PROGRAM: None,
1875
  ND_SPINDLE_COUNT: 1,
1876
  }
1877

    
1878
DISK_LD_DEFAULTS = {
1879
  LD_DRBD8: {
1880
    LDP_RESYNC_RATE: CLASSIC_DRBD_SYNC_SPEED,
1881
    LDP_BARRIERS: _autoconf.DRBD_BARRIERS,
1882
    LDP_NO_META_FLUSH: _autoconf.DRBD_NO_META_FLUSH,
1883
    LDP_DEFAULT_METAVG: DEFAULT_VG,
1884
    LDP_DISK_CUSTOM: "",
1885
    LDP_NET_CUSTOM: "",
1886
    LDP_DYNAMIC_RESYNC: False,
1887

    
1888
    # The default values for the DRBD dynamic resync speed algorithm are taken
1889
    # from the drbsetup 8.3.11 man page, except for c-plan-ahead (that we
1890
    # don't need to set to 0, because we have a separate option to enable it)
1891
    # and for c-max-rate, that we cap to the default value for the static resync
1892
    # rate.
1893
    LDP_PLAN_AHEAD: 20, # ds
1894
    LDP_FILL_TARGET: 0, # sectors
1895
    LDP_DELAY_TARGET: 1, # ds
1896
    LDP_MAX_RATE: CLASSIC_DRBD_SYNC_SPEED, # KiB/s
1897
    LDP_MIN_RATE: 4 * 1024, # KiB/s
1898
    },
1899
  LD_LV: {
1900
    LDP_STRIPES: _autoconf.LVM_STRIPECOUNT
1901
    },
1902
  LD_FILE: {
1903
    },
1904
  LD_BLOCKDEV: {
1905
    },
1906
  LD_RBD: {
1907
    LDP_POOL: "rbd"
1908
    },
1909
  }
1910

    
1911
# readability shortcuts
1912
_LV_DEFAULTS = DISK_LD_DEFAULTS[LD_LV]
1913
_DRBD_DEFAULTS = DISK_LD_DEFAULTS[LD_DRBD8]
1914

    
1915
DISK_DT_DEFAULTS = {
1916
  DT_PLAIN: {
1917
    LV_STRIPES: DISK_LD_DEFAULTS[LD_LV][LDP_STRIPES],
1918
    },
1919
  DT_DRBD8: {
1920
    DRBD_RESYNC_RATE: _DRBD_DEFAULTS[LDP_RESYNC_RATE],
1921
    DRBD_DATA_STRIPES: _LV_DEFAULTS[LDP_STRIPES],
1922
    DRBD_META_STRIPES: _LV_DEFAULTS[LDP_STRIPES],
1923
    DRBD_DISK_BARRIERS: _DRBD_DEFAULTS[LDP_BARRIERS],
1924
    DRBD_META_BARRIERS: _DRBD_DEFAULTS[LDP_NO_META_FLUSH],
1925
    DRBD_DEFAULT_METAVG: _DRBD_DEFAULTS[LDP_DEFAULT_METAVG],
1926
    DRBD_DISK_CUSTOM: _DRBD_DEFAULTS[LDP_DISK_CUSTOM],
1927
    DRBD_NET_CUSTOM: _DRBD_DEFAULTS[LDP_NET_CUSTOM],
1928
    DRBD_DYNAMIC_RESYNC: _DRBD_DEFAULTS[LDP_DYNAMIC_RESYNC],
1929
    DRBD_PLAN_AHEAD: _DRBD_DEFAULTS[LDP_PLAN_AHEAD],
1930
    DRBD_FILL_TARGET: _DRBD_DEFAULTS[LDP_FILL_TARGET],
1931
    DRBD_DELAY_TARGET: _DRBD_DEFAULTS[LDP_DELAY_TARGET],
1932
    DRBD_MAX_RATE: _DRBD_DEFAULTS[LDP_MAX_RATE],
1933
    DRBD_MIN_RATE: _DRBD_DEFAULTS[LDP_MIN_RATE],
1934
    },
1935
  DT_DISKLESS: {
1936
    },
1937
  DT_FILE: {
1938
    },
1939
  DT_SHARED_FILE: {
1940
    },
1941
  DT_BLOCK: {
1942
    },
1943
  DT_RBD: {
1944
    RBD_POOL: DISK_LD_DEFAULTS[LD_RBD][LDP_POOL]
1945
    },
1946
  }
1947

    
1948
# we don't want to export the shortcuts
1949
del _LV_DEFAULTS, _DRBD_DEFAULTS
1950

    
1951
NICC_DEFAULTS = {
1952
  NIC_MODE: NIC_MODE_BRIDGED,
1953
  NIC_LINK: DEFAULT_BRIDGE,
1954
  }
1955

    
1956
# All of the following values are quite arbitrarily - there are no
1957
# "good" defaults, these must be customised per-site
1958
IPOLICY_DEFAULTS = {
1959
  ISPECS_MIN: {
1960
    ISPEC_MEM_SIZE: 128,
1961
    ISPEC_CPU_COUNT: 1,
1962
    ISPEC_DISK_COUNT: 1,
1963
    ISPEC_DISK_SIZE: 1024,
1964
    ISPEC_NIC_COUNT: 1,
1965
    ISPEC_SPINDLE_USE: 1,
1966
    },
1967
  ISPECS_MAX: {
1968
    ISPEC_MEM_SIZE: 32768,
1969
    ISPEC_CPU_COUNT: 8,
1970
    ISPEC_DISK_COUNT: MAX_DISKS,
1971
    ISPEC_DISK_SIZE: 1024 * 1024,
1972
    ISPEC_NIC_COUNT: MAX_NICS,
1973
    ISPEC_SPINDLE_USE: 12,
1974
    },
1975
  ISPECS_STD: {
1976
    ISPEC_MEM_SIZE: 128,
1977
    ISPEC_CPU_COUNT: 1,
1978
    ISPEC_DISK_COUNT: 1,
1979
    ISPEC_DISK_SIZE: 1024,
1980
    ISPEC_NIC_COUNT: 1,
1981
    ISPEC_SPINDLE_USE: 1,
1982
    },
1983
  IPOLICY_DTS: DISK_TEMPLATES,
1984
  IPOLICY_VCPU_RATIO: 4.0,
1985
  IPOLICY_SPINDLE_RATIO: 32.0,
1986
  }
1987

    
1988
MASTER_POOL_SIZE_DEFAULT = 10
1989

    
1990
CONFD_PROTOCOL_VERSION = 1
1991

    
1992
CONFD_REQ_PING = 0
1993
CONFD_REQ_NODE_ROLE_BYNAME = 1
1994
CONFD_REQ_NODE_PIP_BY_INSTANCE_IP = 2
1995
CONFD_REQ_CLUSTER_MASTER = 3
1996
CONFD_REQ_NODE_PIP_LIST = 4
1997
CONFD_REQ_MC_PIP_LIST = 5
1998
CONFD_REQ_INSTANCES_IPS_LIST = 6
1999

    
2000
# Confd request query fields. These are used to narrow down queries.
2001
# These must be strings rather than integers, because json-encoding
2002
# converts them to strings anyway, as they're used as dict-keys.
2003
CONFD_REQQ_LINK = "0"
2004
CONFD_REQQ_IP = "1"
2005
CONFD_REQQ_IPLIST = "2"
2006
CONFD_REQQ_FIELDS = "3"
2007

    
2008
CONFD_REQFIELD_NAME = "0"
2009
CONFD_REQFIELD_IP = "1"
2010
CONFD_REQFIELD_MNODE_PIP = "2"
2011

    
2012
CONFD_REQS = frozenset([
2013
  CONFD_REQ_PING,
2014
  CONFD_REQ_NODE_ROLE_BYNAME,
2015
  CONFD_REQ_NODE_PIP_BY_INSTANCE_IP,
2016
  CONFD_REQ_CLUSTER_MASTER,
2017
  CONFD_REQ_NODE_PIP_LIST,
2018
  CONFD_REQ_MC_PIP_LIST,
2019
  CONFD_REQ_INSTANCES_IPS_LIST,
2020
  ])
2021

    
2022
CONFD_REPL_STATUS_OK = 0
2023
CONFD_REPL_STATUS_ERROR = 1
2024
CONFD_REPL_STATUS_NOTIMPLEMENTED = 2
2025

    
2026
CONFD_REPL_STATUSES = frozenset([
2027
  CONFD_REPL_STATUS_OK,
2028
  CONFD_REPL_STATUS_ERROR,
2029
  CONFD_REPL_STATUS_NOTIMPLEMENTED,
2030
  ])
2031

    
2032
(CONFD_NODE_ROLE_MASTER,
2033
 CONFD_NODE_ROLE_CANDIDATE,
2034
 CONFD_NODE_ROLE_OFFLINE,
2035
 CONFD_NODE_ROLE_DRAINED,
2036
 CONFD_NODE_ROLE_REGULAR,
2037
 ) = range(5)
2038

    
2039
# A few common errors for confd
2040
CONFD_ERROR_UNKNOWN_ENTRY = 1
2041
CONFD_ERROR_INTERNAL = 2
2042
CONFD_ERROR_ARGUMENT = 3
2043

    
2044
# Each request is "salted" by the current timestamp.
2045
# This constants decides how many seconds of skew to accept.
2046
# TODO: make this a default and allow the value to be more configurable
2047
CONFD_MAX_CLOCK_SKEW = 2 * NODE_MAX_CLOCK_SKEW
2048

    
2049
# When we haven't reloaded the config for more than this amount of seconds, we
2050
# force a test to see if inotify is betraying us.
2051
CONFD_CONFIG_RELOAD_TIMEOUT = 60
2052

    
2053
# If we receive more than one update in this amount of seconds, we move to
2054
# polling every RATELIMIT seconds, rather than relying on inotify, to be able
2055
# to serve more requests.
2056
CONFD_CONFIG_RELOAD_RATELIMIT = 2
2057

    
2058
# Magic number prepended to all confd queries.
2059
# This allows us to distinguish different types of confd protocols and handle
2060
# them. For example by changing this we can move the whole payload to be
2061
# compressed, or move away from json.
2062
CONFD_MAGIC_FOURCC = "plj0"
2063

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

    
2069
# Timeout in seconds to expire pending query request in the confd client
2070
# library. We don't actually expect any answer more than 10 seconds after we
2071
# sent a request.
2072
CONFD_CLIENT_EXPIRE_TIMEOUT = 10
2073

    
2074
# Maximum UDP datagram size.
2075
# On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
2076
# On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
2077
#   (assuming we can't use jumbo frames)
2078
# We just set this to 60K, which should be enough
2079
MAX_UDP_DATA_SIZE = 61440
2080

    
2081
# User-id pool minimum/maximum acceptable user-ids.
2082
UIDPOOL_UID_MIN = 0
2083
UIDPOOL_UID_MAX = 2 ** 32 - 1 # Assuming 32 bit user-ids
2084

    
2085
# Name or path of the pgrep command
2086
PGREP = "pgrep"
2087

    
2088
# Name of the node group that gets created at cluster init or upgrade
2089
INITIAL_NODE_GROUP_NAME = "default"
2090

    
2091
# Possible values for NodeGroup.alloc_policy
2092
ALLOC_POLICY_PREFERRED = "preferred"
2093
ALLOC_POLICY_LAST_RESORT = "last_resort"
2094
ALLOC_POLICY_UNALLOCABLE = "unallocable"
2095
VALID_ALLOC_POLICIES = [
2096
  ALLOC_POLICY_PREFERRED,
2097
  ALLOC_POLICY_LAST_RESORT,
2098
  ALLOC_POLICY_UNALLOCABLE,
2099
  ]
2100

    
2101
# Temporary external/shared storage parameters
2102
BLOCKDEV_DRIVER_MANUAL = "manual"
2103

    
2104
# qemu-img path, required for ovfconverter
2105
QEMUIMG_PATH = _autoconf.QEMUIMG_PATH
2106

    
2107
# Whether htools was enabled at compilation time
2108
HTOOLS = _autoconf.HTOOLS
2109
# The hail iallocator
2110
IALLOC_HAIL = "hail"
2111

    
2112
# Fake opcodes for functions that have hooks attached to them via
2113
# backend.RunLocalHooks
2114
FAKE_OP_MASTER_TURNUP = "OP_CLUSTER_IP_TURNUP"
2115
FAKE_OP_MASTER_TURNDOWN = "OP_CLUSTER_IP_TURNDOWN"
2116

    
2117
# Do not re-export imported modules
2118
del re, _vcsversion, _autoconf, socket