Statistics
| Branch: | Tag: | Revision:

root / lib / constants.py @ 6a1434d7

History | View | Annotate | Download (41.7 kB)

1
#
2
#
3

    
4
# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 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

    
26
from ganeti import _autoconf
27
from ganeti import _vcsversion
28

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

    
39

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

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

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

57
  Returns: int representing version number
58

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

    
67

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

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

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

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

    
79
  return (major, minor, revision)
80

    
81

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

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

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

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

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

    
119
# A KVM-specific implementation detail - the following value is used
120
# to set CPU affinity to all processors (#0 through #31), per taskset
121
# man page.
122
CPU_PINNING_ALL_KVM = 0xFFFFFFFF
123

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

    
130

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

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

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

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

    
195
#: File containing Unix timestamp until which watcher should be paused
196
WATCHER_PAUSEFILE = DATA_DIR + "/watcher.pause"
197

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

    
205
MASTER_SOCKET = SOCKET_DIR + "/ganeti-master"
206

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

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

    
229
FIRST_DRBD_PORT = 11000
230
LAST_DRBD_PORT = 14999
231
MASTER_SCRIPT = "ganeti-master"
232

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

    
244
LOG_OS_DIR = LOG_DIR + "os"
245
LOG_WATCHER = LOG_DIR + "watcher.log"
246
LOG_COMMANDS = LOG_DIR + "commands.log"
247
LOG_BURNIN = LOG_DIR + "burnin.log"
248
LOG_SETUP_SSH = LOG_DIR + "setup-ssh.log"
249

    
250
DEV_CONSOLE = "/dev/console"
251

    
252
PROC_MOUNTS = "/proc/mounts"
253

    
254
# Local UniX Interface related constants
255
LUXI_EOM = "\3"
256
LUXI_VERSION = CONFIG_VERSION
257

    
258
# one of "no", "yes", "only"
259
SYSLOG_USAGE = _autoconf.SYSLOG_USAGE
260
SYSLOG_NO = "no"
261
SYSLOG_YES = "yes"
262
SYSLOG_ONLY = "only"
263
SYSLOG_SOCKET = "/dev/log"
264

    
265
OS_SEARCH_PATH = _autoconf.OS_SEARCH_PATH
266
EXPORT_DIR = _autoconf.EXPORT_DIR
267

    
268
EXPORT_CONF_FILE = "config.ini"
269

    
270
XEN_BOOTLOADER = _autoconf.XEN_BOOTLOADER
271
XEN_KERNEL = _autoconf.XEN_KERNEL
272
XEN_INITRD = _autoconf.XEN_INITRD
273

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

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

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

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

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

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

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

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

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

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

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

    
317
X509_CERT_SIGNATURE_HEADER = "X-Ganeti-Signature"
318

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

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

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

    
333
IE_CUSTOM_SIZE = "fd"
334

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
450
# logical disk types
451
LD_LV = "lvm"
452
LD_DRBD8 = "drbd8"
453
LD_FILE = "file"
454
LD_BLOCKDEV = "blockdev"
455
LDS_BLOCK = frozenset([LD_LV, LD_DRBD8, LD_BLOCKDEV])
456

    
457
# drbd constants
458
DRBD_HMAC_ALG = "md5"
459
DRBD_NET_PROTOCOL = "C"
460
DRBD_BARRIERS = _autoconf.DRBD_BARRIERS
461

    
462
# file backend driver
463
FD_LOOP = "loop"
464
FD_BLKTAP = "blktap"
465

    
466
# the set of drbd-like disk types
467
LDS_DRBD = frozenset([LD_DRBD8])
468

    
469
# disk access mode
470
DISK_RDONLY = "ro"
471
DISK_RDWR = "rw"
472
DISK_ACCESS_SET = frozenset([DISK_RDONLY, DISK_RDWR])
473

    
474
# disk replacement mode
475
REPLACE_DISK_PRI = "replace_on_primary"    # replace disks on primary
476
REPLACE_DISK_SEC = "replace_on_secondary"  # replace disks on secondary
477
REPLACE_DISK_CHG = "replace_new_secondary" # change secondary node
478
REPLACE_DISK_AUTO = "replace_auto"
479
REPLACE_MODES = frozenset([
480
  REPLACE_DISK_PRI,
481
  REPLACE_DISK_SEC,
482
  REPLACE_DISK_CHG,
483
  REPLACE_DISK_AUTO,
484
  ])
485

    
486
# Instance export mode
487
EXPORT_MODE_LOCAL = "local"
488
EXPORT_MODE_REMOTE = "remote"
489
EXPORT_MODES = frozenset([
490
  EXPORT_MODE_LOCAL,
491
  EXPORT_MODE_REMOTE,
492
  ])
493

    
494
# Lock recalculate mode
495
LOCKS_REPLACE = "replace"
496
LOCKS_APPEND = "append"
497

    
498
# Lock timeout (sum) before we should go into blocking acquire (still
499
# can be reset by priority change); computed as max time (10 hours)
500
# before we should actually go into blocking acquire given that we
501
# start from default priority level; in seconds
502
LOCK_ATTEMPTS_TIMEOUT = 10 * 3600 / 20.0
503
LOCK_ATTEMPTS_MAXWAIT = 15.0
504
LOCK_ATTEMPTS_MINWAIT = 1.0
505

    
506
# instance creation modes
507
INSTANCE_CREATE = "create"
508
INSTANCE_IMPORT = "import"
509
INSTANCE_REMOTE_IMPORT = "remote-import"
510
INSTANCE_CREATE_MODES = frozenset([
511
  INSTANCE_CREATE,
512
  INSTANCE_IMPORT,
513
  INSTANCE_REMOTE_IMPORT,
514
  ])
515

    
516
# Remote import/export handshake message and version
517
RIE_VERSION = 0
518
RIE_HANDSHAKE = "Hi, I'm Ganeti"
519

    
520
# Remote import/export certificate validity in seconds
521
RIE_CERT_VALIDITY = 24 * 60 * 60
522

    
523
# Overall timeout for establishing connection
524
RIE_CONNECT_TIMEOUT = 180
525

    
526
# Export only: how long to wait per connection attempt (seconds)
527
RIE_CONNECT_ATTEMPT_TIMEOUT = 20
528

    
529
# Export only: number of attempts to connect
530
RIE_CONNECT_RETRIES = 10
531

    
532
#: Give child process up to 5 seconds to exit after sending a signal
533
CHILD_LINGER_TIMEOUT = 5.0
534

    
535
DISK_TEMPLATES = frozenset([
536
  DT_DISKLESS,
537
  DT_PLAIN,
538
  DT_DRBD8,
539
  DT_FILE,
540
  DT_SHARED_FILE,
541
  DT_BLOCK
542
  ])
543

    
544
FILE_DRIVER = frozenset([FD_LOOP, FD_BLKTAP])
545

    
546
# import/export config options
547
INISECT_EXP = "export"
548
INISECT_INS = "instance"
549
INISECT_HYP = "hypervisor"
550
INISECT_BEP = "backend"
551
INISECT_OSP = "os"
552

    
553
# dynamic device modification
554
DDM_ADD = "add"
555
DDM_REMOVE = "remove"
556
DDMS_VALUES = frozenset([DDM_ADD, DDM_REMOVE])
557

    
558
# common exit codes
559
EXIT_SUCCESS = 0
560
EXIT_FAILURE = 1
561
EXIT_NOTCLUSTER = 5
562
EXIT_NOTMASTER = 11
563
EXIT_NODESETUP_ERROR = 12
564
EXIT_CONFIRMATION = 13 # need user confirmation
565

    
566
#: Exit code for query operations with unknown fields
567
EXIT_UNKNOWN_FIELD = 14
568

    
569
# tags
570
TAG_CLUSTER = "cluster"
571
TAG_NODEGROUP = "nodegroup"
572
TAG_NODE = "node"
573
TAG_INSTANCE = "instance"
574
VALID_TAG_TYPES = frozenset([
575
  TAG_CLUSTER,
576
  TAG_NODEGROUP,
577
  TAG_NODE,
578
  TAG_INSTANCE,
579
  ])
580
MAX_TAG_LEN = 128
581
MAX_TAGS_PER_OBJ = 4096
582

    
583
# others
584
DEFAULT_BRIDGE = "xen-br0"
585
SYNC_SPEED = 60 * 1024
586
IP4_ADDRESS_LOCALHOST = "127.0.0.1"
587
IP4_ADDRESS_ANY = "0.0.0.0"
588
IP6_ADDRESS_LOCALHOST = "::1"
589
IP6_ADDRESS_ANY = "::"
590
IP4_VERSION = 4
591
IP6_VERSION = 6
592
VALID_IP_VERSIONS = frozenset([IP4_VERSION, IP6_VERSION])
593
TCP_PING_TIMEOUT = 10
594
GANETI_RUNAS = "root"
595
DEFAULT_VG = "xenvg"
596
DEFAULT_DRBD_HELPER = "/bin/true"
597
MIN_VG_SIZE = 20480
598
DEFAULT_MAC_PREFIX = "aa:00:00"
599
LVM_STRIPECOUNT = _autoconf.LVM_STRIPECOUNT
600
# default maximum instance wait time, in seconds.
601
DEFAULT_SHUTDOWN_TIMEOUT = 120
602
NODE_MAX_CLOCK_SKEW = 150
603
# Time for an intra-cluster disk transfer to wait for a connection
604
DISK_TRANSFER_CONNECT_TIMEOUT = 60
605
# Disk index separator
606
DISK_SEPARATOR = _autoconf.DISK_SEPARATOR
607
IP_COMMAND_PATH = _autoconf.IP_PATH
608

    
609
#: Key for job IDs in opcode result
610
JOB_IDS_KEY = "jobs"
611

    
612
# runparts results
613
(RUNPARTS_SKIP,
614
 RUNPARTS_RUN,
615
 RUNPARTS_ERR) = range(3)
616

    
617
RUNPARTS_STATUS = frozenset([RUNPARTS_SKIP, RUNPARTS_RUN, RUNPARTS_ERR])
618

    
619
# RPC constants
620
(RPC_ENCODING_NONE,
621
 RPC_ENCODING_ZLIB_BASE64) = range(2)
622

    
623
# os related constants
624
OS_SCRIPT_CREATE = "create"
625
OS_SCRIPT_IMPORT = "import"
626
OS_SCRIPT_EXPORT = "export"
627
OS_SCRIPT_RENAME = "rename"
628
OS_SCRIPT_VERIFY = "verify"
629
OS_SCRIPTS = frozenset([
630
  OS_SCRIPT_CREATE,
631
  OS_SCRIPT_IMPORT,
632
  OS_SCRIPT_EXPORT,
633
  OS_SCRIPT_RENAME,
634
  OS_SCRIPT_VERIFY
635
  ])
636

    
637
OS_API_FILE = "ganeti_api_version"
638
OS_VARIANTS_FILE = "variants.list"
639
OS_PARAMETERS_FILE = "parameters.list"
640

    
641
OS_VALIDATE_PARAMETERS = "parameters"
642
OS_VALIDATE_CALLS = frozenset([OS_VALIDATE_PARAMETERS])
643

    
644
# ssh constants
645
SSH_CONFIG_DIR = _autoconf.SSH_CONFIG_DIR
646
SSH_HOST_DSA_PRIV = SSH_CONFIG_DIR + "/ssh_host_dsa_key"
647
SSH_HOST_DSA_PUB = SSH_HOST_DSA_PRIV + ".pub"
648
SSH_HOST_RSA_PRIV = SSH_CONFIG_DIR + "/ssh_host_rsa_key"
649
SSH_HOST_RSA_PUB = SSH_HOST_RSA_PRIV + ".pub"
650
SSH = "ssh"
651
SCP = "scp"
652

    
653
# reboot types
654
INSTANCE_REBOOT_SOFT = "soft"
655
INSTANCE_REBOOT_HARD = "hard"
656
INSTANCE_REBOOT_FULL = "full"
657

    
658
REBOOT_TYPES = frozenset([
659
  INSTANCE_REBOOT_SOFT,
660
  INSTANCE_REBOOT_HARD,
661
  INSTANCE_REBOOT_FULL
662
  ])
663

    
664
# instance reboot behaviors
665
INSTANCE_REBOOT_ALLOWED = "reboot"
666
INSTANCE_REBOOT_EXIT = "exit"
667

    
668
REBOOT_BEHAVIORS = frozenset([
669
  INSTANCE_REBOOT_ALLOWED,
670
  INSTANCE_REBOOT_EXIT
671
  ])
672

    
673
VTYPE_STRING = "string"
674
VTYPE_MAYBE_STRING = "maybe-string"
675
VTYPE_BOOL = "bool"
676
VTYPE_SIZE = "size" # size, in MiBs
677
VTYPE_INT = "int"
678
ENFORCEABLE_TYPES = frozenset([
679
  VTYPE_STRING,
680
  VTYPE_MAYBE_STRING,
681
  VTYPE_BOOL,
682
  VTYPE_SIZE,
683
  VTYPE_INT,
684
  ])
685

    
686
# Constant representing that the user does not specify any IP version
687
IFACE_NO_IP_VERSION_SPECIFIED = 0
688

    
689
# HV parameter names (global namespace)
690
HV_BOOT_ORDER = "boot_order"
691
HV_CDROM_IMAGE_PATH = "cdrom_image_path"
692
HV_KVM_CDROM2_IMAGE_PATH = "cdrom2_image_path"
693
HV_KVM_FLOPPY_IMAGE_PATH = "floppy_image_path"
694
HV_NIC_TYPE = "nic_type"
695
HV_DISK_TYPE = "disk_type"
696
HV_KVM_CDROM_DISK_TYPE = "cdrom_disk_type"
697
HV_VNC_BIND_ADDRESS = "vnc_bind_address"
698
HV_VNC_PASSWORD_FILE = "vnc_password_file"
699
HV_VNC_TLS = "vnc_tls"
700
HV_VNC_X509 = "vnc_x509_path"
701
HV_VNC_X509_VERIFY = "vnc_x509_verify"
702
HV_KVM_SPICE_BIND = "spice_bind"
703
HV_KVM_SPICE_IP_VERSION = "spice_ip_version"
704
HV_KVM_SPICE_PASSWORD_FILE = "spice_password_file"
705
HV_KVM_SPICE_LOSSLESS_IMG_COMPR = "spice_image_compression"
706
HV_KVM_SPICE_JPEG_IMG_COMPR = "spice_jpeg_wan_compression"
707
HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR = "spice_zlib_glz_wan_compression"
708
HV_KVM_SPICE_STREAMING_VIDEO_DETECTION = "spice_streaming_video"
709
HV_KVM_SPICE_AUDIO_COMPR = "spice_playback_compression"
710
HV_KVM_SPICE_USE_TLS = "spice_use_tls"
711
HV_KVM_SPICE_TLS_CIPHERS = "spice_tls_ciphers"
712
HV_KVM_SPICE_USE_VDAGENT = "spice_use_vdagent"
713
HV_ACPI = "acpi"
714
HV_PAE = "pae"
715
HV_USE_BOOTLOADER = "use_bootloader"
716
HV_BOOTLOADER_ARGS = "bootloader_args"
717
HV_BOOTLOADER_PATH = "bootloader_path"
718
HV_KERNEL_ARGS = "kernel_args"
719
HV_KERNEL_PATH = "kernel_path"
720
HV_INITRD_PATH = "initrd_path"
721
HV_ROOT_PATH = "root_path"
722
HV_SERIAL_CONSOLE = "serial_console"
723
HV_USB_MOUSE = "usb_mouse"
724
HV_KEYMAP = "keymap"
725
HV_DEVICE_MODEL = "device_model"
726
HV_INIT_SCRIPT = "init_script"
727
HV_MIGRATION_PORT = "migration_port"
728
HV_MIGRATION_BANDWIDTH = "migration_bandwidth"
729
HV_MIGRATION_DOWNTIME = "migration_downtime"
730
HV_MIGRATION_MODE = "migration_mode"
731
HV_USE_LOCALTIME = "use_localtime"
732
HV_DISK_CACHE = "disk_cache"
733
HV_SECURITY_MODEL = "security_model"
734
HV_SECURITY_DOMAIN = "security_domain"
735
HV_KVM_FLAG = "kvm_flag"
736
HV_VHOST_NET = "vhost_net"
737
HV_KVM_USE_CHROOT = "use_chroot"
738
HV_CPU_MASK = "cpu_mask"
739
HV_MEM_PATH = "mem_path"
740
HV_BLOCKDEV_PREFIX = "blockdev_prefix"
741
HV_REBOOT_BEHAVIOR = "reboot_behavior"
742

    
743
HVS_PARAMETER_TYPES = {
744
  HV_BOOT_ORDER: VTYPE_STRING,
745
  HV_KVM_FLOPPY_IMAGE_PATH: VTYPE_STRING,
746
  HV_CDROM_IMAGE_PATH: VTYPE_STRING,
747
  HV_KVM_CDROM2_IMAGE_PATH: VTYPE_STRING,
748
  HV_NIC_TYPE: VTYPE_STRING,
749
  HV_DISK_TYPE: VTYPE_STRING,
750
  HV_KVM_CDROM_DISK_TYPE: VTYPE_STRING,
751
  HV_VNC_PASSWORD_FILE: VTYPE_STRING,
752
  HV_VNC_BIND_ADDRESS: VTYPE_STRING,
753
  HV_VNC_TLS: VTYPE_BOOL,
754
  HV_VNC_X509: VTYPE_STRING,
755
  HV_VNC_X509_VERIFY: VTYPE_BOOL,
756
  HV_KVM_SPICE_BIND: VTYPE_STRING,
757
  HV_KVM_SPICE_IP_VERSION: VTYPE_INT,
758
  HV_KVM_SPICE_PASSWORD_FILE: VTYPE_STRING,
759
  HV_KVM_SPICE_LOSSLESS_IMG_COMPR: VTYPE_STRING,
760
  HV_KVM_SPICE_JPEG_IMG_COMPR: VTYPE_STRING,
761
  HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR: VTYPE_STRING,
762
  HV_KVM_SPICE_STREAMING_VIDEO_DETECTION: VTYPE_STRING,
763
  HV_KVM_SPICE_AUDIO_COMPR: VTYPE_BOOL,
764
  HV_KVM_SPICE_USE_TLS: VTYPE_BOOL,
765
  HV_KVM_SPICE_TLS_CIPHERS: VTYPE_STRING,
766
  HV_KVM_SPICE_USE_VDAGENT: VTYPE_BOOL,
767
  HV_ACPI: VTYPE_BOOL,
768
  HV_PAE: VTYPE_BOOL,
769
  HV_USE_BOOTLOADER: VTYPE_BOOL,
770
  HV_BOOTLOADER_PATH: VTYPE_STRING,
771
  HV_BOOTLOADER_ARGS: VTYPE_STRING,
772
  HV_KERNEL_PATH: VTYPE_STRING,
773
  HV_KERNEL_ARGS: VTYPE_STRING,
774
  HV_INITRD_PATH: VTYPE_STRING,
775
  HV_ROOT_PATH: VTYPE_MAYBE_STRING,
776
  HV_SERIAL_CONSOLE: VTYPE_BOOL,
777
  HV_USB_MOUSE: VTYPE_STRING,
778
  HV_KEYMAP: VTYPE_STRING,
779
  HV_DEVICE_MODEL: VTYPE_STRING,
780
  HV_INIT_SCRIPT: VTYPE_STRING,
781
  HV_MIGRATION_PORT: VTYPE_INT,
782
  HV_MIGRATION_BANDWIDTH: VTYPE_INT,
783
  HV_MIGRATION_DOWNTIME: VTYPE_INT,
784
  HV_MIGRATION_MODE: VTYPE_STRING,
785
  HV_USE_LOCALTIME: VTYPE_BOOL,
786
  HV_DISK_CACHE: VTYPE_STRING,
787
  HV_SECURITY_MODEL: VTYPE_STRING,
788
  HV_SECURITY_DOMAIN: VTYPE_STRING,
789
  HV_KVM_FLAG: VTYPE_STRING,
790
  HV_VHOST_NET: VTYPE_BOOL,
791
  HV_KVM_USE_CHROOT: VTYPE_BOOL,
792
  HV_CPU_MASK: VTYPE_STRING,
793
  HV_MEM_PATH: VTYPE_STRING,
794
  HV_BLOCKDEV_PREFIX: VTYPE_STRING,
795
  HV_REBOOT_BEHAVIOR: VTYPE_STRING,
796
  }
797

    
798
HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
799

    
800
# Migration statuses
801
HV_MIGRATION_COMPLETED = "completed"
802
HV_MIGRATION_ACTIVE = "active"
803
HV_MIGRATION_FAILED = "failed"
804
HV_MIGRATION_CANCELLED = "cancelled"
805

    
806
HV_MIGRATION_VALID_STATUSES = frozenset([
807
  HV_MIGRATION_COMPLETED,
808
  HV_MIGRATION_ACTIVE,
809
  HV_MIGRATION_FAILED,
810
  HV_MIGRATION_CANCELLED,
811
  ])
812

    
813
HV_MIGRATION_FAILED_STATUSES = frozenset([
814
  HV_MIGRATION_FAILED,
815
  HV_MIGRATION_CANCELLED,
816
  ])
817

    
818
# KVM-specific statuses
819
HV_KVM_MIGRATION_VALID_STATUSES = HV_MIGRATION_VALID_STATUSES
820

    
821
# Backend parameter names
822
BE_MEMORY = "memory"
823
BE_VCPUS = "vcpus"
824
BE_AUTO_BALANCE = "auto_balance"
825

    
826
BES_PARAMETER_TYPES = {
827
    BE_MEMORY: VTYPE_SIZE,
828
    BE_VCPUS: VTYPE_INT,
829
    BE_AUTO_BALANCE: VTYPE_BOOL,
830
    }
831

    
832
BES_PARAMETERS = frozenset(BES_PARAMETER_TYPES.keys())
833

    
834
# Node parameter names
835
ND_OOB_PROGRAM = "oob_program"
836

    
837
NDS_PARAMETER_TYPES = {
838
    ND_OOB_PROGRAM: VTYPE_MAYBE_STRING,
839
    }
840

    
841
NDS_PARAMETERS = frozenset(NDS_PARAMETER_TYPES.keys())
842

    
843
# OOB supported commands
844
OOB_POWER_ON = "power-on"
845
OOB_POWER_OFF = "power-off"
846
OOB_POWER_CYCLE = "power-cycle"
847
OOB_POWER_STATUS = "power-status"
848
OOB_HEALTH = "health"
849

    
850
OOB_COMMANDS = frozenset([
851
  OOB_POWER_ON,
852
  OOB_POWER_OFF,
853
  OOB_POWER_CYCLE,
854
  OOB_POWER_STATUS,
855
  OOB_HEALTH
856
  ])
857

    
858
OOB_POWER_STATUS_POWERED = "powered"
859

    
860
OOB_TIMEOUT = 60 # 60 seconds
861
OOB_POWER_DELAY = 2.0 # 2 seconds
862

    
863
OOB_STATUS_OK = "OK"
864
OOB_STATUS_WARNING = "WARNING"
865
OOB_STATUS_CRITICAL = "CRITICAL"
866
OOB_STATUS_UNKNOWN = "UNKNOWN"
867

    
868
OOB_STATUSES = frozenset([
869
  OOB_STATUS_OK,
870
  OOB_STATUS_WARNING,
871
  OOB_STATUS_CRITICAL,
872
  OOB_STATUS_UNKNOWN,
873
  ])
874

    
875
# Instance Parameters Profile
876
PP_DEFAULT = "default"
877

    
878
# NIC_* constants are used inside the ganeti config
879
NIC_MODE = "mode"
880
NIC_LINK = "link"
881

    
882
NIC_MODE_BRIDGED = "bridged"
883
NIC_MODE_ROUTED = "routed"
884

    
885
NIC_VALID_MODES = frozenset([NIC_MODE_BRIDGED, NIC_MODE_ROUTED])
886

    
887
NICS_PARAMETER_TYPES = {
888
    NIC_MODE: VTYPE_STRING,
889
    NIC_LINK: VTYPE_STRING,
890
    }
891

    
892
NICS_PARAMETERS = frozenset(NICS_PARAMETER_TYPES.keys())
893

    
894
# IDISK_* constants are used in opcodes, to create/change disks
895
IDISK_SIZE = "size"
896
IDISK_MODE = "mode"
897
IDISK_ADOPT = "adopt"
898
IDISK_VG = "vg"
899
IDISK_METAVG = "metavg"
900
IDISK_PARAMS_TYPES = {
901
  IDISK_SIZE: VTYPE_SIZE,
902
  IDISK_MODE: VTYPE_STRING,
903
  IDISK_ADOPT: VTYPE_STRING,
904
  IDISK_VG: VTYPE_STRING,
905
  IDISK_METAVG: VTYPE_STRING,
906
  }
907
IDISK_PARAMS = frozenset(IDISK_PARAMS_TYPES.keys())
908

    
909
# INIC_* constants are used in opcodes, to create/change nics
910
INIC_MAC = "mac"
911
INIC_IP = "ip"
912
INIC_MODE = "mode"
913
INIC_LINK = "link"
914
INIC_PARAMS_TYPES = {
915
  INIC_IP: VTYPE_MAYBE_STRING,
916
  INIC_LINK: VTYPE_STRING,
917
  INIC_MAC: VTYPE_STRING,
918
  INIC_MODE: VTYPE_STRING,
919
  }
920
INIC_PARAMS = frozenset(INIC_PARAMS_TYPES.keys())
921

    
922
# Hypervisor constants
923
HT_XEN_PVM = "xen-pvm"
924
HT_FAKE = "fake"
925
HT_XEN_HVM = "xen-hvm"
926
HT_KVM = "kvm"
927
HT_CHROOT = "chroot"
928
HT_LXC = "lxc"
929
HYPER_TYPES = frozenset([
930
  HT_XEN_PVM,
931
  HT_FAKE,
932
  HT_XEN_HVM,
933
  HT_KVM,
934
  HT_CHROOT,
935
  HT_LXC,
936
  ])
937
HTS_REQ_PORT = frozenset([HT_XEN_HVM, HT_KVM])
938

    
939
VNC_BASE_PORT = 5900
940
VNC_PASSWORD_FILE = CONF_DIR + "/vnc-cluster-password"
941
VNC_DEFAULT_BIND_ADDRESS = IP4_ADDRESS_ANY
942

    
943
# NIC types
944
HT_NIC_RTL8139 = "rtl8139"
945
HT_NIC_NE2K_PCI = "ne2k_pci"
946
HT_NIC_NE2K_ISA = "ne2k_isa"
947
HT_NIC_I82551 = "i82551"
948
HT_NIC_I85557B = "i82557b"
949
HT_NIC_I8259ER = "i82559er"
950
HT_NIC_PCNET = "pcnet"
951
HT_NIC_E1000 = "e1000"
952
HT_NIC_PARAVIRTUAL = HT_DISK_PARAVIRTUAL = "paravirtual"
953

    
954
HT_HVM_VALID_NIC_TYPES = frozenset([
955
  HT_NIC_RTL8139,
956
  HT_NIC_NE2K_PCI,
957
  HT_NIC_E1000,
958
  HT_NIC_NE2K_ISA,
959
  HT_NIC_PARAVIRTUAL
960
  ])
961
HT_KVM_VALID_NIC_TYPES = frozenset([
962
  HT_NIC_RTL8139,
963
  HT_NIC_NE2K_PCI,
964
  HT_NIC_NE2K_ISA,
965
  HT_NIC_I82551,
966
  HT_NIC_I85557B,
967
  HT_NIC_I8259ER,
968
  HT_NIC_PCNET,
969
  HT_NIC_E1000,
970
  HT_NIC_PARAVIRTUAL
971
  ])
972

    
973
# Disk types
974
HT_DISK_IOEMU = "ioemu"
975
HT_DISK_IDE = "ide"
976
HT_DISK_SCSI = "scsi"
977
HT_DISK_SD = "sd"
978
HT_DISK_MTD = "mtd"
979
HT_DISK_PFLASH = "pflash"
980

    
981
HT_CACHE_DEFAULT = "default"
982
HT_CACHE_NONE = "none"
983
HT_CACHE_WTHROUGH = "writethrough"
984
HT_CACHE_WBACK = "writeback"
985
HT_VALID_CACHE_TYPES = frozenset([
986
  HT_CACHE_DEFAULT,
987
  HT_CACHE_NONE,
988
  HT_CACHE_WTHROUGH,
989
  HT_CACHE_WBACK
990
  ])
991

    
992
HT_HVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IOEMU])
993
HT_KVM_VALID_DISK_TYPES = frozenset([
994
  HT_DISK_PARAVIRTUAL,
995
  HT_DISK_IDE,
996
  HT_DISK_SCSI,
997
  HT_DISK_SD,
998
  HT_DISK_MTD,
999
  HT_DISK_PFLASH
1000
  ])
1001

    
1002
# Mouse types:
1003
HT_MOUSE_MOUSE = "mouse"
1004
HT_MOUSE_TABLET = "tablet"
1005

    
1006
HT_KVM_VALID_MOUSE_TYPES = frozenset([HT_MOUSE_MOUSE, HT_MOUSE_TABLET])
1007

    
1008
# Boot order
1009
HT_BO_FLOPPY = "floppy"
1010
HT_BO_CDROM = "cdrom"
1011
HT_BO_DISK = "disk"
1012
HT_BO_NETWORK = "network"
1013

    
1014
HT_KVM_VALID_BO_TYPES = frozenset([
1015
  HT_BO_FLOPPY,
1016
  HT_BO_CDROM,
1017
  HT_BO_DISK,
1018
  HT_BO_NETWORK
1019
  ])
1020

    
1021
# SPICE lossless image compression options
1022
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ = "auto_glz"
1023
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ = "auto_lz"
1024
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC = "quic"
1025
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ = "glz"
1026
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ = "lz"
1027
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF = "off"
1028

    
1029
HT_KVM_SPICE_VALID_LOSSLESS_IMG_COMPR_OPTIONS = frozenset([
1030
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ,
1031
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ,
1032
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC,
1033
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ,
1034
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ,
1035
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF,
1036
  ])
1037

    
1038
# SPICE lossy image compression options (valid for both jpeg and zlib-glz)
1039
HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO = "auto"
1040
HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER = "never"
1041
HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS = "always"
1042

    
1043
HT_KVM_SPICE_VALID_LOSSY_IMG_COMPR_OPTIONS = frozenset([
1044
  HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO,
1045
  HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER,
1046
  HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS,
1047
  ])
1048

    
1049
# SPICE video stream detection
1050
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF = "off"
1051
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL = "all"
1052
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER = "filter"
1053

    
1054
HT_KVM_SPICE_VALID_VIDEO_STREAM_DETECTION_OPTIONS = frozenset([
1055
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF,
1056
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL,
1057
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER,
1058
  ])
1059

    
1060
# Security models
1061
HT_SM_NONE = "none"
1062
HT_SM_USER = "user"
1063
HT_SM_POOL = "pool"
1064

    
1065
HT_KVM_VALID_SM_TYPES = frozenset([HT_SM_NONE, HT_SM_USER, HT_SM_POOL])
1066

    
1067
# Kvm flag values
1068
HT_KVM_ENABLED = "enabled"
1069
HT_KVM_DISABLED = "disabled"
1070

    
1071
HT_KVM_FLAG_VALUES = frozenset([HT_KVM_ENABLED, HT_KVM_DISABLED])
1072

    
1073
# Migration type
1074
HT_MIGRATION_LIVE = "live"
1075
HT_MIGRATION_NONLIVE = "non-live"
1076
HT_MIGRATION_MODES = frozenset([HT_MIGRATION_LIVE, HT_MIGRATION_NONLIVE])
1077

    
1078
# Cluster Verify steps
1079
VERIFY_NPLUSONE_MEM = "nplusone_mem"
1080
VERIFY_OPTIONAL_CHECKS = frozenset([VERIFY_NPLUSONE_MEM])
1081

    
1082
# Node verify constants
1083
NV_DRBDHELPER = "drbd-helper"
1084
NV_DRBDLIST = "drbd-list"
1085
NV_FILELIST = "filelist"
1086
NV_HVINFO = "hvinfo"
1087
NV_HYPERVISOR = "hypervisor"
1088
NV_HVPARAMS = "hvparms"
1089
NV_INSTANCELIST = "instancelist"
1090
NV_LVLIST = "lvlist"
1091
NV_MASTERIP = "master-ip"
1092
NV_NODELIST = "nodelist"
1093
NV_NODENETTEST = "node-net-test"
1094
NV_NODESETUP = "nodesetup"
1095
NV_OSLIST = "oslist"
1096
NV_PVLIST = "pvlist"
1097
NV_TIME = "time"
1098
NV_VERSION = "version"
1099
NV_VGLIST = "vglist"
1100
NV_VMNODES = "vmnodes"
1101
NV_OOB_PATHS = "oob-paths"
1102
NV_BRIDGES = "bridges"
1103

    
1104
# Instance status
1105
INSTST_RUNNING = "running"
1106
INSTST_ADMINDOWN = "ADMIN_down"
1107
INSTST_NODEOFFLINE = "ERROR_nodeoffline"
1108
INSTST_NODEDOWN = "ERROR_nodedown"
1109
INSTST_WRONGNODE = "ERROR_wrongnode"
1110
INSTST_ERRORUP = "ERROR_up"
1111
INSTST_ERRORDOWN = "ERROR_down"
1112
INSTST_ALL = frozenset([
1113
  INSTST_RUNNING,
1114
  INSTST_ADMINDOWN,
1115
  INSTST_NODEOFFLINE,
1116
  INSTST_NODEDOWN,
1117
  INSTST_WRONGNODE,
1118
  INSTST_ERRORUP,
1119
  INSTST_ERRORDOWN,
1120
  ])
1121

    
1122
# Node roles
1123
NR_REGULAR = "R"
1124
NR_MASTER = "M"
1125
NR_MCANDIDATE = "C"
1126
NR_DRAINED = "D"
1127
NR_OFFLINE = "O"
1128
NR_ALL = frozenset([
1129
  NR_REGULAR,
1130
  NR_MASTER,
1131
  NR_MCANDIDATE,
1132
  NR_DRAINED,
1133
  NR_OFFLINE,
1134
  ])
1135

    
1136
# SSL certificate check constants (in days)
1137
SSL_CERT_EXPIRATION_WARN = 30
1138
SSL_CERT_EXPIRATION_ERROR = 7
1139

    
1140
# Allocator framework constants
1141
IALLOCATOR_VERSION = 2
1142
IALLOCATOR_DIR_IN = "in"
1143
IALLOCATOR_DIR_OUT = "out"
1144
VALID_IALLOCATOR_DIRECTIONS = frozenset([
1145
  IALLOCATOR_DIR_IN,
1146
  IALLOCATOR_DIR_OUT,
1147
  ])
1148
IALLOCATOR_MODE_ALLOC = "allocate"
1149
IALLOCATOR_MODE_RELOC = "relocate"
1150
IALLOCATOR_MODE_CHG_GROUP = "change-group"
1151
IALLOCATOR_MODE_NODE_EVAC = "node-evacuate"
1152
VALID_IALLOCATOR_MODES = frozenset([
1153
  IALLOCATOR_MODE_ALLOC,
1154
  IALLOCATOR_MODE_RELOC,
1155
  IALLOCATOR_MODE_CHG_GROUP,
1156
  IALLOCATOR_MODE_NODE_EVAC,
1157
  ])
1158
IALLOCATOR_SEARCH_PATH = _autoconf.IALLOCATOR_SEARCH_PATH
1159

    
1160
IALLOCATOR_NEVAC_PRI = "primary-only"
1161
IALLOCATOR_NEVAC_SEC = "secondary-only"
1162
IALLOCATOR_NEVAC_ALL = "all"
1163
IALLOCATOR_NEVAC_MODES = frozenset([
1164
  IALLOCATOR_NEVAC_PRI,
1165
  IALLOCATOR_NEVAC_SEC,
1166
  IALLOCATOR_NEVAC_ALL,
1167
  ])
1168

    
1169
# Job queue
1170
JOB_QUEUE_VERSION = 1
1171
JOB_QUEUE_LOCK_FILE = QUEUE_DIR + "/lock"
1172
JOB_QUEUE_VERSION_FILE = QUEUE_DIR + "/version"
1173
JOB_QUEUE_SERIAL_FILE = QUEUE_DIR + "/serial"
1174
JOB_QUEUE_ARCHIVE_DIR = QUEUE_DIR + "/archive"
1175
JOB_QUEUE_DRAIN_FILE = QUEUE_DIR + "/drain"
1176
JOB_QUEUE_SIZE_HARD_LIMIT = 5000
1177
JOB_QUEUE_DIRS = [QUEUE_DIR, JOB_QUEUE_ARCHIVE_DIR]
1178
JOB_QUEUE_DIRS_MODE = SECURE_DIR_MODE
1179

    
1180
JOB_ID_TEMPLATE = r"\d+"
1181
JOB_FILE_RE = re.compile(r"^job-(%s)$" % JOB_ID_TEMPLATE)
1182

    
1183
# unchanged job return
1184
JOB_NOTCHANGED = "nochange"
1185

    
1186
# Job status
1187
JOB_STATUS_QUEUED = "queued"
1188
JOB_STATUS_WAITING = "waiting"
1189
JOB_STATUS_CANCELING = "canceling"
1190
JOB_STATUS_RUNNING = "running"
1191
JOB_STATUS_CANCELED = "canceled"
1192
JOB_STATUS_SUCCESS = "success"
1193
JOB_STATUS_ERROR = "error"
1194
JOBS_FINALIZED = frozenset([
1195
  JOB_STATUS_CANCELED,
1196
  JOB_STATUS_SUCCESS,
1197
  JOB_STATUS_ERROR,
1198
  ])
1199
JOB_STATUS_ALL = frozenset([
1200
  JOB_STATUS_QUEUED,
1201
  JOB_STATUS_WAITING,
1202
  JOB_STATUS_CANCELING,
1203
  JOB_STATUS_RUNNING,
1204
  ]) | JOBS_FINALIZED
1205

    
1206
# OpCode status
1207
# not yet finalized
1208
OP_STATUS_QUEUED = "queued"
1209
OP_STATUS_WAITING = "waiting"
1210
OP_STATUS_CANCELING = "canceling"
1211
OP_STATUS_RUNNING = "running"
1212
# finalized
1213
OP_STATUS_CANCELED = "canceled"
1214
OP_STATUS_SUCCESS = "success"
1215
OP_STATUS_ERROR = "error"
1216
OPS_FINALIZED = frozenset([
1217
  OP_STATUS_CANCELED,
1218
  OP_STATUS_SUCCESS,
1219
  OP_STATUS_ERROR
1220
  ])
1221

    
1222
# OpCode priority
1223
OP_PRIO_LOWEST = +19
1224
OP_PRIO_HIGHEST = -20
1225

    
1226
OP_PRIO_LOW = +10
1227
OP_PRIO_NORMAL = 0
1228
OP_PRIO_HIGH = -10
1229

    
1230
OP_PRIO_SUBMIT_VALID = frozenset([
1231
  OP_PRIO_LOW,
1232
  OP_PRIO_NORMAL,
1233
  OP_PRIO_HIGH,
1234
  ])
1235

    
1236
OP_PRIO_DEFAULT = OP_PRIO_NORMAL
1237

    
1238
# Execution log types
1239
ELOG_MESSAGE = "message"
1240
ELOG_PROGRESS = "progress"
1241
ELOG_REMOTE_IMPORT = "remote-import"
1242
ELOG_JQUEUE_TEST = "jqueue-test"
1243

    
1244
# /etc/hosts modification
1245
ETC_HOSTS_ADD = "add"
1246
ETC_HOSTS_REMOVE = "remove"
1247

    
1248
# Job queue test
1249
JQT_MSGPREFIX = "TESTMSG="
1250
JQT_EXPANDNAMES = "expandnames"
1251
JQT_EXEC = "exec"
1252
JQT_LOGMSG = "logmsg"
1253
JQT_STARTMSG = "startmsg"
1254
JQT_ALL = frozenset([
1255
  JQT_EXPANDNAMES,
1256
  JQT_EXEC,
1257
  JQT_LOGMSG,
1258
  JQT_STARTMSG,
1259
  ])
1260

    
1261
# Query resources
1262
QR_INSTANCE = "instance"
1263
QR_NODE = "node"
1264
QR_LOCK = "lock"
1265
QR_GROUP = "group"
1266
QR_OS = "os"
1267

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

    
1271
#: List of resources which can be queried using Local UniX Interface
1272
QR_VIA_LUXI = QR_VIA_OP.union([
1273
  QR_LOCK,
1274
  ])
1275

    
1276
#: List of resources which can be queried using RAPI
1277
QR_VIA_RAPI = QR_VIA_LUXI
1278

    
1279
# Query field types
1280
QFT_UNKNOWN = "unknown"
1281
QFT_TEXT = "text"
1282
QFT_BOOL = "bool"
1283
QFT_NUMBER = "number"
1284
QFT_UNIT = "unit"
1285
QFT_TIMESTAMP = "timestamp"
1286
QFT_OTHER = "other"
1287

    
1288
#: All query field types
1289
QFT_ALL = frozenset([
1290
  QFT_UNKNOWN,
1291
  QFT_TEXT,
1292
  QFT_BOOL,
1293
  QFT_NUMBER,
1294
  QFT_UNIT,
1295
  QFT_TIMESTAMP,
1296
  QFT_OTHER,
1297
  ])
1298

    
1299
# Query result field status (don't change or reuse values as they're used by
1300
# clients)
1301
#: Normal field status
1302
RS_NORMAL = 0
1303
#: Unknown field
1304
RS_UNKNOWN = 1
1305
#: No data (e.g. RPC error), can be used instead of L{RS_OFFLINE}
1306
RS_NODATA = 2
1307
#: Value unavailable/unsupported for item; if this field is supported
1308
#: but we cannot get the data for the moment, RS_NODATA or
1309
#: RS_OFFLINE should be used
1310
RS_UNAVAIL = 3
1311
#: Resource marked offline
1312
RS_OFFLINE = 4
1313

    
1314
RS_ALL = frozenset([
1315
  RS_NORMAL,
1316
  RS_UNKNOWN,
1317
  RS_NODATA,
1318
  RS_UNAVAIL,
1319
  RS_OFFLINE,
1320
  ])
1321

    
1322
#: Dictionary with special field cases and their verbose/terse formatting
1323
RSS_DESCRIPTION = {
1324
  RS_UNKNOWN: ("(unknown)", "??"),
1325
  RS_NODATA: ("(nodata)", "?"),
1326
  RS_OFFLINE: ("(offline)", "*"),
1327
  RS_UNAVAIL: ("(unavail)", "-"),
1328
  }
1329

    
1330
# max dynamic devices
1331
MAX_NICS = 8
1332
MAX_DISKS = 16
1333

    
1334
# SSCONF keys
1335
SS_CLUSTER_NAME = "cluster_name"
1336
SS_CLUSTER_TAGS = "cluster_tags"
1337
SS_FILE_STORAGE_DIR = "file_storage_dir"
1338
SS_SHARED_FILE_STORAGE_DIR = "shared_file_storage_dir"
1339
SS_MASTER_CANDIDATES = "master_candidates"
1340
SS_MASTER_CANDIDATES_IPS = "master_candidates_ips"
1341
SS_MASTER_IP = "master_ip"
1342
SS_MASTER_NETDEV = "master_netdev"
1343
SS_MASTER_NODE = "master_node"
1344
SS_NODE_LIST = "node_list"
1345
SS_NODE_PRIMARY_IPS = "node_primary_ips"
1346
SS_NODE_SECONDARY_IPS = "node_secondary_ips"
1347
SS_OFFLINE_NODES = "offline_nodes"
1348
SS_ONLINE_NODES = "online_nodes"
1349
SS_PRIMARY_IP_FAMILY = "primary_ip_family"
1350
SS_INSTANCE_LIST = "instance_list"
1351
SS_RELEASE_VERSION = "release_version"
1352
SS_HYPERVISOR_LIST = "hypervisor_list"
1353
SS_MAINTAIN_NODE_HEALTH = "maintain_node_health"
1354
SS_UID_POOL = "uid_pool"
1355
SS_NODEGROUPS = "nodegroups"
1356

    
1357
SS_FILE_PERMS = 0444
1358

    
1359
# cluster wide default parameters
1360
DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM
1361

    
1362
HVC_DEFAULTS = {
1363
  HT_XEN_PVM: {
1364
    HV_USE_BOOTLOADER: False,
1365
    HV_BOOTLOADER_PATH: XEN_BOOTLOADER,
1366
    HV_BOOTLOADER_ARGS: "",
1367
    HV_KERNEL_PATH: "/boot/vmlinuz-2.6-xenU",
1368
    HV_INITRD_PATH: "",
1369
    HV_ROOT_PATH: "/dev/sda1",
1370
    HV_KERNEL_ARGS: "ro",
1371
    HV_MIGRATION_PORT: 8002,
1372
    HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1373
    HV_BLOCKDEV_PREFIX: "sd",
1374
    HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1375
    HV_CPU_MASK: CPU_PINNING_ALL,
1376
    },
1377
  HT_XEN_HVM: {
1378
    HV_BOOT_ORDER: "cd",
1379
    HV_CDROM_IMAGE_PATH: "",
1380
    HV_NIC_TYPE: HT_NIC_RTL8139,
1381
    HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
1382
    HV_VNC_BIND_ADDRESS: IP4_ADDRESS_ANY,
1383
    HV_VNC_PASSWORD_FILE: VNC_PASSWORD_FILE,
1384
    HV_ACPI: True,
1385
    HV_PAE: True,
1386
    HV_KERNEL_PATH: "/usr/lib/xen/boot/hvmloader",
1387
    HV_DEVICE_MODEL: "/usr/lib/xen/bin/qemu-dm",
1388
    HV_MIGRATION_PORT: 8002,
1389
    HV_MIGRATION_MODE: HT_MIGRATION_NONLIVE,
1390
    HV_USE_LOCALTIME: False,
1391
    HV_BLOCKDEV_PREFIX: "hd",
1392
    HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1393
    HV_CPU_MASK: CPU_PINNING_ALL,
1394
    },
1395
  HT_KVM: {
1396
    HV_KERNEL_PATH: "/boot/vmlinuz-2.6-kvmU",
1397
    HV_INITRD_PATH: "",
1398
    HV_KERNEL_ARGS: "ro",
1399
    HV_ROOT_PATH: "/dev/vda1",
1400
    HV_ACPI: True,
1401
    HV_SERIAL_CONSOLE: True,
1402
    HV_VNC_BIND_ADDRESS: "",
1403
    HV_VNC_TLS: False,
1404
    HV_VNC_X509: "",
1405
    HV_VNC_X509_VERIFY: False,
1406
    HV_VNC_PASSWORD_FILE: "",
1407
    HV_KVM_SPICE_BIND: "",
1408
    HV_KVM_SPICE_IP_VERSION: IFACE_NO_IP_VERSION_SPECIFIED,
1409
    HV_KVM_SPICE_PASSWORD_FILE: "",
1410
    HV_KVM_SPICE_LOSSLESS_IMG_COMPR: "",
1411
    HV_KVM_SPICE_JPEG_IMG_COMPR: "",
1412
    HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR: "",
1413
    HV_KVM_SPICE_STREAMING_VIDEO_DETECTION: "",
1414
    HV_KVM_SPICE_AUDIO_COMPR: True,
1415
    HV_KVM_SPICE_USE_TLS: False,
1416
    HV_KVM_SPICE_TLS_CIPHERS: OPENSSL_CIPHERS,
1417
    HV_KVM_SPICE_USE_VDAGENT: True,
1418
    HV_KVM_FLOPPY_IMAGE_PATH: "",
1419
    HV_CDROM_IMAGE_PATH: "",
1420
    HV_KVM_CDROM2_IMAGE_PATH: "",
1421
    HV_BOOT_ORDER: HT_BO_DISK,
1422
    HV_NIC_TYPE: HT_NIC_PARAVIRTUAL,
1423
    HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
1424
    HV_KVM_CDROM_DISK_TYPE: "",
1425
    HV_USB_MOUSE: "",
1426
    HV_KEYMAP: "",
1427
    HV_MIGRATION_PORT: 8102,
1428
    HV_MIGRATION_BANDWIDTH: 32, # MiB/s
1429
    HV_MIGRATION_DOWNTIME: 30,  # ms
1430
    HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1431
    HV_USE_LOCALTIME: False,
1432
    HV_DISK_CACHE: HT_CACHE_DEFAULT,
1433
    HV_SECURITY_MODEL: HT_SM_NONE,
1434
    HV_SECURITY_DOMAIN: "",
1435
    HV_KVM_FLAG: "",
1436
    HV_VHOST_NET: False,
1437
    HV_KVM_USE_CHROOT: False,
1438
    HV_MEM_PATH: "",
1439
    HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1440
    HV_CPU_MASK: CPU_PINNING_ALL,
1441
    },
1442
  HT_FAKE: {
1443
    },
1444
  HT_CHROOT: {
1445
    HV_INIT_SCRIPT: "/ganeti-chroot",
1446
    },
1447
  HT_LXC: {
1448
    HV_CPU_MASK: "",
1449
    },
1450
  }
1451

    
1452
HVC_GLOBALS = frozenset([
1453
  HV_MIGRATION_PORT,
1454
  HV_MIGRATION_BANDWIDTH,
1455
  HV_MIGRATION_MODE,
1456
  ])
1457

    
1458
BEC_DEFAULTS = {
1459
  BE_MEMORY: 128,
1460
  BE_VCPUS: 1,
1461
  BE_AUTO_BALANCE: True,
1462
  }
1463

    
1464
NDC_DEFAULTS = {
1465
  ND_OOB_PROGRAM: None,
1466
  }
1467

    
1468
NICC_DEFAULTS = {
1469
  NIC_MODE: NIC_MODE_BRIDGED,
1470
  NIC_LINK: DEFAULT_BRIDGE,
1471
  }
1472

    
1473
MASTER_POOL_SIZE_DEFAULT = 10
1474

    
1475
CONFD_PROTOCOL_VERSION = 1
1476

    
1477
CONFD_REQ_PING = 0
1478
CONFD_REQ_NODE_ROLE_BYNAME = 1
1479
CONFD_REQ_NODE_PIP_BY_INSTANCE_IP = 2
1480
CONFD_REQ_CLUSTER_MASTER = 3
1481
CONFD_REQ_NODE_PIP_LIST = 4
1482
CONFD_REQ_MC_PIP_LIST = 5
1483
CONFD_REQ_INSTANCES_IPS_LIST = 6
1484

    
1485
# Confd request query fields. These are used to narrow down queries.
1486
# These must be strings rather than integers, because json-encoding
1487
# converts them to strings anyway, as they're used as dict-keys.
1488
CONFD_REQQ_LINK = "0"
1489
CONFD_REQQ_IP = "1"
1490
CONFD_REQQ_IPLIST = "2"
1491
CONFD_REQQ_FIELDS = "3"
1492

    
1493
CONFD_REQFIELD_NAME = "0"
1494
CONFD_REQFIELD_IP = "1"
1495
CONFD_REQFIELD_MNODE_PIP = "2"
1496

    
1497
CONFD_REQS = frozenset([
1498
  CONFD_REQ_PING,
1499
  CONFD_REQ_NODE_ROLE_BYNAME,
1500
  CONFD_REQ_NODE_PIP_BY_INSTANCE_IP,
1501
  CONFD_REQ_CLUSTER_MASTER,
1502
  CONFD_REQ_NODE_PIP_LIST,
1503
  CONFD_REQ_MC_PIP_LIST,
1504
  CONFD_REQ_INSTANCES_IPS_LIST,
1505
  ])
1506

    
1507
CONFD_REPL_STATUS_OK = 0
1508
CONFD_REPL_STATUS_ERROR = 1
1509
CONFD_REPL_STATUS_NOTIMPLEMENTED = 2
1510

    
1511
CONFD_REPL_STATUSES = frozenset([
1512
  CONFD_REPL_STATUS_OK,
1513
  CONFD_REPL_STATUS_ERROR,
1514
  CONFD_REPL_STATUS_NOTIMPLEMENTED,
1515
  ])
1516

    
1517
(CONFD_NODE_ROLE_MASTER,
1518
 CONFD_NODE_ROLE_CANDIDATE,
1519
 CONFD_NODE_ROLE_OFFLINE,
1520
 CONFD_NODE_ROLE_DRAINED,
1521
 CONFD_NODE_ROLE_REGULAR,
1522
 ) = range(5)
1523

    
1524
# A few common errors for confd
1525
CONFD_ERROR_UNKNOWN_ENTRY = 1
1526
CONFD_ERROR_INTERNAL = 2
1527
CONFD_ERROR_ARGUMENT = 3
1528

    
1529
# Each request is "salted" by the current timestamp.
1530
# This constants decides how many seconds of skew to accept.
1531
# TODO: make this a default and allow the value to be more configurable
1532
CONFD_MAX_CLOCK_SKEW = 2 * NODE_MAX_CLOCK_SKEW
1533

    
1534
# When we haven't reloaded the config for more than this amount of seconds, we
1535
# force a test to see if inotify is betraying us.
1536
CONFD_CONFIG_RELOAD_TIMEOUT = 60
1537

    
1538
# If we receive more than one update in this amount of seconds, we move to
1539
# polling every RATELIMIT seconds, rather than relying on inotify, to be able
1540
# to serve more requests.
1541
CONFD_CONFIG_RELOAD_RATELIMIT = 2
1542

    
1543
# Magic number prepended to all confd queries.
1544
# This allows us to distinguish different types of confd protocols and handle
1545
# them. For example by changing this we can move the whole payload to be
1546
# compressed, or move away from json.
1547
CONFD_MAGIC_FOURCC = "plj0"
1548

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

    
1554
# Timeout in seconds to expire pending query request in the confd client
1555
# library. We don't actually expect any answer more than 10 seconds after we
1556
# sent a request.
1557
CONFD_CLIENT_EXPIRE_TIMEOUT = 10
1558

    
1559
# Maximum UDP datagram size.
1560
# On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
1561
# On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
1562
#   (assuming we can't use jumbo frames)
1563
# We just set this to 60K, which should be enough
1564
MAX_UDP_DATA_SIZE = 61440
1565

    
1566
# User-id pool minimum/maximum acceptable user-ids.
1567
UIDPOOL_UID_MIN = 0
1568
UIDPOOL_UID_MAX = 2 ** 32 - 1 # Assuming 32 bit user-ids
1569

    
1570
# Name or path of the pgrep command
1571
PGREP = "pgrep"
1572

    
1573
# Name of the node group that gets created at cluster init or upgrade
1574
INITIAL_NODE_GROUP_NAME = "default"
1575

    
1576
# Possible values for NodeGroup.alloc_policy
1577
ALLOC_POLICY_PREFERRED = "preferred"
1578
ALLOC_POLICY_LAST_RESORT = "last_resort"
1579
ALLOC_POLICY_UNALLOCABLE = "unallocable"
1580
VALID_ALLOC_POLICIES = [
1581
  ALLOC_POLICY_PREFERRED,
1582
  ALLOC_POLICY_LAST_RESORT,
1583
  ALLOC_POLICY_UNALLOCABLE,
1584
  ]
1585

    
1586
# Temporary external/shared storage parameters
1587
BLOCKDEV_DRIVER_MANUAL = "manual"
1588

    
1589
# Whether htools was enabled at compilation time
1590
HTOOLS = _autoconf.HTOOLS
1591
# The hail iallocator
1592
IALLOC_HAIL = "hail"