Statistics
| Branch: | Tag: | Revision:

root / lib / constants.py @ 11dc66f3

History | View | Annotate | Download (50 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
USER_SCRIPTS_DIR = CONF_DIR + "/scripts"
184
ENABLE_CONFD = _autoconf.ENABLE_CONFD
185

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

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

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

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

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

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

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

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

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

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

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

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

    
256
DEV_CONSOLE = "/dev/console"
257

    
258
PROC_MOUNTS = "/proc/mounts"
259

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

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

    
271
OS_SEARCH_PATH = _autoconf.OS_SEARCH_PATH
272
EXPORT_DIR = _autoconf.EXPORT_DIR
273

    
274
EXPORT_CONF_FILE = "config.ini"
275

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

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

    
287
#: Console as SSH command
288
CONS_SSH = "ssh"
289

    
290
#: Console as VNC server
291
CONS_VNC = "vnc"
292

    
293
#: Console as SPICE server
294
CONS_SPICE = "spice"
295

    
296
#: Display a message for console access
297
CONS_MESSAGE = "msg"
298

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

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

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

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

    
318
# Default validity of certificates in days
319
X509_CERT_DEFAULT_VALIDITY = 365 * 5
320

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

    
324
X509_CERT_SIGNATURE_HEADER = "X-Ganeti-Signature"
325

    
326
IMPORT_EXPORT_DAEMON = _autoconf.PKGLIBDIR + "/import-export"
327

    
328
# Import/export daemon mode
329
IEM_IMPORT = "import"
330
IEM_EXPORT = "export"
331

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

    
340
IE_CUSTOM_SIZE = "fd"
341

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

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

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

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

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

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

    
377
HKR_SKIP = 0
378
HKR_FAIL = 1
379
HKR_SUCCESS = 2
380

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

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

    
397
# Storage operations
398
SO_FIX_CONSISTENCY = "fix-consistency"
399

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

    
410
VALID_STORAGE_TYPES = frozenset([ST_FILE, ST_LVM_PV, ST_LVM_VG])
411

    
412
MODIFIABLE_STORAGE_FIELDS = {
413
  ST_LVM_PV: frozenset([SF_ALLOCATABLE]),
414
  }
415

    
416
VALID_STORAGE_OPERATIONS = {
417
  ST_LVM_VG: frozenset([SO_FIX_CONSISTENCY]),
418
  }
419

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

    
426
# disk template types
427
DT_DISKLESS = "diskless"
428
DT_PLAIN = "plain"
429
DT_DRBD8 = "drbd"
430
DT_FILE = "file"
431
DT_SHARED_FILE = "sharedfile"
432
DT_BLOCK = "blockdev"
433

    
434
# the set of network-mirrored disk templates
435
DTS_INT_MIRROR = frozenset([DT_DRBD8])
436

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

    
440
# the set of non-lvm-based disk templates
441
DTS_NOT_LVM = frozenset([DT_DISKLESS, DT_FILE, DT_SHARED_FILE, DT_BLOCK])
442

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

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

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

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

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

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

    
470
LDS_BLOCK = frozenset([LD_LV, LD_DRBD8, LD_BLOCKDEV])
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
# file backend driver
496
FD_LOOP = "loop"
497
FD_BLKTAP = "blktap"
498

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

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

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

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

    
527
# Lock recalculate mode
528
LOCKS_REPLACE = "replace"
529
LOCKS_APPEND = "append"
530

    
531
# Lock timeout (sum) before we should go into blocking acquire (still
532
# can be reset by priority change); computed as max time (10 hours)
533
# before we should actually go into blocking acquire given that we
534
# start from default priority level; in seconds
535
LOCK_ATTEMPTS_TIMEOUT = 10 * 3600 / 20.0
536
LOCK_ATTEMPTS_MAXWAIT = 15.0
537
LOCK_ATTEMPTS_MINWAIT = 1.0
538

    
539
# instance creation modes
540
INSTANCE_CREATE = "create"
541
INSTANCE_IMPORT = "import"
542
INSTANCE_REMOTE_IMPORT = "remote-import"
543
INSTANCE_CREATE_MODES = frozenset([
544
  INSTANCE_CREATE,
545
  INSTANCE_IMPORT,
546
  INSTANCE_REMOTE_IMPORT,
547
  ])
548

    
549
# Remote import/export handshake message and version
550
RIE_VERSION = 0
551
RIE_HANDSHAKE = "Hi, I'm Ganeti"
552

    
553
# Remote import/export certificate validity in seconds
554
RIE_CERT_VALIDITY = 24 * 60 * 60
555

    
556
# Overall timeout for establishing connection
557
RIE_CONNECT_TIMEOUT = 180
558

    
559
# Export only: how long to wait per connection attempt (seconds)
560
RIE_CONNECT_ATTEMPT_TIMEOUT = 20
561

    
562
# Export only: number of attempts to connect
563
RIE_CONNECT_RETRIES = 10
564

    
565
#: Give child process up to 5 seconds to exit after sending a signal
566
CHILD_LINGER_TIMEOUT = 5.0
567

    
568
DISK_TEMPLATES = frozenset([
569
  DT_DISKLESS,
570
  DT_PLAIN,
571
  DT_DRBD8,
572
  DT_FILE,
573
  DT_SHARED_FILE,
574
  DT_BLOCK
575
  ])
576

    
577
FILE_DRIVER = frozenset([FD_LOOP, FD_BLKTAP])
578

    
579
# import/export config options
580
INISECT_EXP = "export"
581
INISECT_INS = "instance"
582
INISECT_HYP = "hypervisor"
583
INISECT_BEP = "backend"
584
INISECT_OSP = "os"
585

    
586
# dynamic device modification
587
DDM_ADD = "add"
588
DDM_REMOVE = "remove"
589
DDMS_VALUES = frozenset([DDM_ADD, DDM_REMOVE])
590

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

    
599
#: Exit code for query operations with unknown fields
600
EXIT_UNKNOWN_FIELD = 14
601

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

    
616
# others
617
DEFAULT_BRIDGE = "xen-br0"
618
CLASSIC_DRBD_SYNC_SPEED = 60 * 1024  # 60 MiB, expressed in KiB
619
IP4_ADDRESS_LOCALHOST = "127.0.0.1"
620
IP4_ADDRESS_ANY = "0.0.0.0"
621
IP6_ADDRESS_LOCALHOST = "::1"
622
IP6_ADDRESS_ANY = "::"
623
IP4_VERSION = 4
624
IP6_VERSION = 6
625
VALID_IP_VERSIONS = frozenset([IP4_VERSION, IP6_VERSION])
626
TCP_PING_TIMEOUT = 10
627
GANETI_RUNAS = "root"
628
DEFAULT_VG = "xenvg"
629
DEFAULT_DRBD_HELPER = "/bin/true"
630
MIN_VG_SIZE = 20480
631
DEFAULT_MAC_PREFIX = "aa:00:00"
632
# default maximum instance wait time, in seconds.
633
DEFAULT_SHUTDOWN_TIMEOUT = 120
634
NODE_MAX_CLOCK_SKEW = 150
635
# Time for an intra-cluster disk transfer to wait for a connection
636
DISK_TRANSFER_CONNECT_TIMEOUT = 60
637
# Disk index separator
638
DISK_SEPARATOR = _autoconf.DISK_SEPARATOR
639
IP_COMMAND_PATH = _autoconf.IP_PATH
640

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
830
HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
831

    
832
# Migration statuses
833
HV_MIGRATION_COMPLETED = "completed"
834
HV_MIGRATION_ACTIVE = "active"
835
HV_MIGRATION_FAILED = "failed"
836
HV_MIGRATION_CANCELLED = "cancelled"
837

    
838
HV_MIGRATION_VALID_STATUSES = frozenset([
839
  HV_MIGRATION_COMPLETED,
840
  HV_MIGRATION_ACTIVE,
841
  HV_MIGRATION_FAILED,
842
  HV_MIGRATION_CANCELLED,
843
  ])
844

    
845
HV_MIGRATION_FAILED_STATUSES = frozenset([
846
  HV_MIGRATION_FAILED,
847
  HV_MIGRATION_CANCELLED,
848
  ])
849

    
850
# KVM-specific statuses
851
HV_KVM_MIGRATION_VALID_STATUSES = HV_MIGRATION_VALID_STATUSES
852

    
853
# Node info keys
854
HV_NODEINFO_KEY_VERSION = "hv_version"
855

    
856
# Hypervisor state
857
HVST_MEMORY_TOTAL = "mem_total"
858
HVST_MEMORY_NODE = "mem_node"
859
HVST_MEMORY_HV = "mem_hv"
860
HVST_CPU_TOTAL = "cpu_total"
861
HVST_CPU_NODE = "cpu_node"
862

    
863
HVST_DEFAULTS = {
864
  HVST_MEMORY_TOTAL: 0,
865
  HVST_MEMORY_NODE: 0,
866
  HVST_MEMORY_HV: 0,
867
  HVST_CPU_TOTAL: 1,
868
  HVST_CPU_NODE: 1,
869
  }
870

    
871
HVSTS_PARAMETER_TYPES = {
872
  HVST_MEMORY_TOTAL: VTYPE_INT,
873
  HVST_MEMORY_NODE: VTYPE_INT,
874
  HVST_MEMORY_HV: VTYPE_INT,
875
  HVST_CPU_TOTAL: VTYPE_INT,
876
  HVST_CPU_NODE: VTYPE_INT,
877
  }
878

    
879
HVSTS_PARAMETERS = frozenset(HVSTS_PARAMETER_TYPES.keys())
880

    
881
# Disk state
882
DS_DISK_TOTAL = "disk_total"
883
DS_DISK_RESERVED = "disk_reserved"
884
DS_DISK_OVERHEAD = "disk_overhead"
885

    
886
DS_DEFAULTS = {
887
  DS_DISK_TOTAL: 0,
888
  DS_DISK_RESERVED: 0,
889
  DS_DISK_OVERHEAD: 0,
890
  }
891

    
892
DSS_PARAMETER_TYPES = {
893
  DS_DISK_TOTAL: VTYPE_INT,
894
  DS_DISK_RESERVED: VTYPE_INT,
895
  DS_DISK_OVERHEAD: VTYPE_INT,
896
  }
897

    
898
DSS_PARAMETERS = frozenset(DSS_PARAMETER_TYPES.keys())
899
DS_VALID_TYPES = frozenset([LD_LV])
900

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

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

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

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

    
924
# Node parameter names
925
ND_OOB_PROGRAM = "oob_program"
926

    
927
NDS_PARAMETER_TYPES = {
928
  ND_OOB_PROGRAM: VTYPE_MAYBE_STRING,
929
  }
930

    
931
NDS_PARAMETERS = frozenset(NDS_PARAMETER_TYPES.keys())
932

    
933
# Logical Disks parameters
934
RESYNC_RATE = "resync-rate"
935
STRIPES = "stripes"
936
BARRIERS = "disabled-barriers"
937
NO_META_FLUSH = "disable-meta-flush"
938
DISK_LD_TYPES = {
939
  RESYNC_RATE: VTYPE_INT,
940
  STRIPES: VTYPE_INT,
941
  BARRIERS: VTYPE_STRING,
942
  NO_META_FLUSH: VTYPE_BOOL,
943
  }
944
DISK_LD_PARAMETERS = frozenset(DISK_LD_TYPES.keys())
945

    
946
# Disk template parameters
947
DRBD_RESYNC_RATE = "resync-rate"
948
DRBD_DATA_STRIPES = "data-stripes"
949
DRBD_META_STRIPES = "meta-stripes"
950
DRBD_DISK_BARRIERS = "disk-barriers"
951
DRBD_META_BARRIERS = "meta-barriers"
952
LV_STRIPES = "stripes"
953
DISK_DT_TYPES = {
954
  DRBD_RESYNC_RATE: VTYPE_INT,
955
  DRBD_DATA_STRIPES: VTYPE_INT,
956
  DRBD_META_STRIPES: VTYPE_INT,
957
  DRBD_DISK_BARRIERS: VTYPE_STRING,
958
  DRBD_META_BARRIERS: VTYPE_BOOL,
959
  LV_STRIPES: VTYPE_INT,
960
  }
961

    
962
DISK_DT_PARAMETERS = frozenset(DISK_DT_TYPES.keys())
963

    
964
# OOB supported commands
965
OOB_POWER_ON = "power-on"
966
OOB_POWER_OFF = "power-off"
967
OOB_POWER_CYCLE = "power-cycle"
968
OOB_POWER_STATUS = "power-status"
969
OOB_HEALTH = "health"
970

    
971
OOB_COMMANDS = frozenset([
972
  OOB_POWER_ON,
973
  OOB_POWER_OFF,
974
  OOB_POWER_CYCLE,
975
  OOB_POWER_STATUS,
976
  OOB_HEALTH
977
  ])
978

    
979
OOB_POWER_STATUS_POWERED = "powered"
980

    
981
OOB_TIMEOUT = 60 # 60 seconds
982
OOB_POWER_DELAY = 2.0 # 2 seconds
983

    
984
OOB_STATUS_OK = "OK"
985
OOB_STATUS_WARNING = "WARNING"
986
OOB_STATUS_CRITICAL = "CRITICAL"
987
OOB_STATUS_UNKNOWN = "UNKNOWN"
988

    
989
OOB_STATUSES = frozenset([
990
  OOB_STATUS_OK,
991
  OOB_STATUS_WARNING,
992
  OOB_STATUS_CRITICAL,
993
  OOB_STATUS_UNKNOWN,
994
  ])
995

    
996
# Instance Parameters Profile
997
PP_DEFAULT = "default"
998

    
999
# NIC_* constants are used inside the ganeti config
1000
NIC_MODE = "mode"
1001
NIC_LINK = "link"
1002

    
1003
NIC_MODE_BRIDGED = "bridged"
1004
NIC_MODE_ROUTED = "routed"
1005

    
1006
NIC_VALID_MODES = frozenset([NIC_MODE_BRIDGED, NIC_MODE_ROUTED])
1007

    
1008
NICS_PARAMETER_TYPES = {
1009
  NIC_MODE: VTYPE_STRING,
1010
  NIC_LINK: VTYPE_STRING,
1011
  }
1012

    
1013
NICS_PARAMETERS = frozenset(NICS_PARAMETER_TYPES.keys())
1014

    
1015
# IDISK_* constants are used in opcodes, to create/change disks
1016
IDISK_SIZE = "size"
1017
IDISK_MODE = "mode"
1018
IDISK_ADOPT = "adopt"
1019
IDISK_VG = "vg"
1020
IDISK_METAVG = "metavg"
1021
IDISK_PARAMS_TYPES = {
1022
  IDISK_SIZE: VTYPE_SIZE,
1023
  IDISK_MODE: VTYPE_STRING,
1024
  IDISK_ADOPT: VTYPE_STRING,
1025
  IDISK_VG: VTYPE_STRING,
1026
  IDISK_METAVG: VTYPE_STRING,
1027
  }
1028
IDISK_PARAMS = frozenset(IDISK_PARAMS_TYPES.keys())
1029

    
1030
# INIC_* constants are used in opcodes, to create/change nics
1031
INIC_MAC = "mac"
1032
INIC_IP = "ip"
1033
INIC_MODE = "mode"
1034
INIC_LINK = "link"
1035
INIC_PARAMS_TYPES = {
1036
  INIC_IP: VTYPE_MAYBE_STRING,
1037
  INIC_LINK: VTYPE_STRING,
1038
  INIC_MAC: VTYPE_STRING,
1039
  INIC_MODE: VTYPE_STRING,
1040
  }
1041
INIC_PARAMS = frozenset(INIC_PARAMS_TYPES.keys())
1042

    
1043
# Hypervisor constants
1044
HT_XEN_PVM = "xen-pvm"
1045
HT_FAKE = "fake"
1046
HT_XEN_HVM = "xen-hvm"
1047
HT_KVM = "kvm"
1048
HT_CHROOT = "chroot"
1049
HT_LXC = "lxc"
1050
HYPER_TYPES = frozenset([
1051
  HT_XEN_PVM,
1052
  HT_FAKE,
1053
  HT_XEN_HVM,
1054
  HT_KVM,
1055
  HT_CHROOT,
1056
  HT_LXC,
1057
  ])
1058
HTS_REQ_PORT = frozenset([HT_XEN_HVM, HT_KVM])
1059

    
1060
VNC_BASE_PORT = 5900
1061
VNC_PASSWORD_FILE = CONF_DIR + "/vnc-cluster-password"
1062
VNC_DEFAULT_BIND_ADDRESS = IP4_ADDRESS_ANY
1063

    
1064
# NIC types
1065
HT_NIC_RTL8139 = "rtl8139"
1066
HT_NIC_NE2K_PCI = "ne2k_pci"
1067
HT_NIC_NE2K_ISA = "ne2k_isa"
1068
HT_NIC_I82551 = "i82551"
1069
HT_NIC_I85557B = "i82557b"
1070
HT_NIC_I8259ER = "i82559er"
1071
HT_NIC_PCNET = "pcnet"
1072
HT_NIC_E1000 = "e1000"
1073
HT_NIC_PARAVIRTUAL = HT_DISK_PARAVIRTUAL = "paravirtual"
1074

    
1075
HT_HVM_VALID_NIC_TYPES = frozenset([
1076
  HT_NIC_RTL8139,
1077
  HT_NIC_NE2K_PCI,
1078
  HT_NIC_E1000,
1079
  HT_NIC_NE2K_ISA,
1080
  HT_NIC_PARAVIRTUAL
1081
  ])
1082
HT_KVM_VALID_NIC_TYPES = frozenset([
1083
  HT_NIC_RTL8139,
1084
  HT_NIC_NE2K_PCI,
1085
  HT_NIC_NE2K_ISA,
1086
  HT_NIC_I82551,
1087
  HT_NIC_I85557B,
1088
  HT_NIC_I8259ER,
1089
  HT_NIC_PCNET,
1090
  HT_NIC_E1000,
1091
  HT_NIC_PARAVIRTUAL
1092
  ])
1093

    
1094
# Disk types
1095
HT_DISK_IOEMU = "ioemu"
1096
HT_DISK_IDE = "ide"
1097
HT_DISK_SCSI = "scsi"
1098
HT_DISK_SD = "sd"
1099
HT_DISK_MTD = "mtd"
1100
HT_DISK_PFLASH = "pflash"
1101

    
1102
HT_CACHE_DEFAULT = "default"
1103
HT_CACHE_NONE = "none"
1104
HT_CACHE_WTHROUGH = "writethrough"
1105
HT_CACHE_WBACK = "writeback"
1106
HT_VALID_CACHE_TYPES = frozenset([
1107
  HT_CACHE_DEFAULT,
1108
  HT_CACHE_NONE,
1109
  HT_CACHE_WTHROUGH,
1110
  HT_CACHE_WBACK
1111
  ])
1112

    
1113
HT_HVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IOEMU])
1114
HT_KVM_VALID_DISK_TYPES = frozenset([
1115
  HT_DISK_PARAVIRTUAL,
1116
  HT_DISK_IDE,
1117
  HT_DISK_SCSI,
1118
  HT_DISK_SD,
1119
  HT_DISK_MTD,
1120
  HT_DISK_PFLASH
1121
  ])
1122

    
1123
# Mouse types:
1124
HT_MOUSE_MOUSE = "mouse"
1125
HT_MOUSE_TABLET = "tablet"
1126

    
1127
HT_KVM_VALID_MOUSE_TYPES = frozenset([HT_MOUSE_MOUSE, HT_MOUSE_TABLET])
1128

    
1129
# Boot order
1130
HT_BO_FLOPPY = "floppy"
1131
HT_BO_CDROM = "cdrom"
1132
HT_BO_DISK = "disk"
1133
HT_BO_NETWORK = "network"
1134

    
1135
HT_KVM_VALID_BO_TYPES = frozenset([
1136
  HT_BO_FLOPPY,
1137
  HT_BO_CDROM,
1138
  HT_BO_DISK,
1139
  HT_BO_NETWORK
1140
  ])
1141

    
1142
# SPICE lossless image compression options
1143
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ = "auto_glz"
1144
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ = "auto_lz"
1145
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC = "quic"
1146
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ = "glz"
1147
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ = "lz"
1148
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF = "off"
1149

    
1150
HT_KVM_SPICE_VALID_LOSSLESS_IMG_COMPR_OPTIONS = frozenset([
1151
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ,
1152
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ,
1153
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC,
1154
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ,
1155
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ,
1156
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF,
1157
  ])
1158

    
1159
# SPICE lossy image compression options (valid for both jpeg and zlib-glz)
1160
HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO = "auto"
1161
HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER = "never"
1162
HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS = "always"
1163

    
1164
HT_KVM_SPICE_VALID_LOSSY_IMG_COMPR_OPTIONS = frozenset([
1165
  HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO,
1166
  HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER,
1167
  HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS,
1168
  ])
1169

    
1170
# SPICE video stream detection
1171
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF = "off"
1172
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL = "all"
1173
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER = "filter"
1174

    
1175
HT_KVM_SPICE_VALID_VIDEO_STREAM_DETECTION_OPTIONS = frozenset([
1176
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF,
1177
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL,
1178
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER,
1179
  ])
1180

    
1181
# Security models
1182
HT_SM_NONE = "none"
1183
HT_SM_USER = "user"
1184
HT_SM_POOL = "pool"
1185

    
1186
HT_KVM_VALID_SM_TYPES = frozenset([HT_SM_NONE, HT_SM_USER, HT_SM_POOL])
1187

    
1188
# Kvm flag values
1189
HT_KVM_ENABLED = "enabled"
1190
HT_KVM_DISABLED = "disabled"
1191

    
1192
HT_KVM_FLAG_VALUES = frozenset([HT_KVM_ENABLED, HT_KVM_DISABLED])
1193

    
1194
# Migration type
1195
HT_MIGRATION_LIVE = "live"
1196
HT_MIGRATION_NONLIVE = "non-live"
1197
HT_MIGRATION_MODES = frozenset([HT_MIGRATION_LIVE, HT_MIGRATION_NONLIVE])
1198

    
1199
# Cluster Verify steps
1200
VERIFY_NPLUSONE_MEM = "nplusone_mem"
1201
VERIFY_OPTIONAL_CHECKS = frozenset([VERIFY_NPLUSONE_MEM])
1202

    
1203
# Cluster Verify error classes
1204
CV_TCLUSTER = "cluster"
1205
CV_TNODE = "node"
1206
CV_TINSTANCE = "instance"
1207

    
1208
# Cluster Verify error codes and documentation
1209
CV_ECLUSTERCFG = \
1210
  (CV_TCLUSTER, "ECLUSTERCFG", "Cluster configuration verification failure")
1211
CV_ECLUSTERCERT = \
1212
  (CV_TCLUSTER, "ECLUSTERCERT",
1213
   "Cluster certificate files verification failure")
1214
CV_ECLUSTERFILECHECK = \
1215
  (CV_TCLUSTER, "ECLUSTERFILECHECK",
1216
   "Cluster configuration verification failure")
1217
CV_ECLUSTERDANGLINGNODES = \
1218
  (CV_TNODE, "ECLUSTERDANGLINGNODES",
1219
   "Some nodes belong to non-existing groups")
1220
CV_ECLUSTERDANGLINGINST = \
1221
  (CV_TNODE, "ECLUSTERDANGLINGINST",
1222
   "Some instances have a non-existing primary node")
1223
CV_EINSTANCEBADNODE = \
1224
  (CV_TINSTANCE, "EINSTANCEBADNODE",
1225
   "Instance marked as running lives on an offline node")
1226
CV_EINSTANCEDOWN = \
1227
  (CV_TINSTANCE, "EINSTANCEDOWN", "Instance not running on its primary node")
1228
CV_EINSTANCELAYOUT = \
1229
  (CV_TINSTANCE, "EINSTANCELAYOUT", "Instance has multiple secondary nodes")
1230
CV_EINSTANCEMISSINGDISK = \
1231
  (CV_TINSTANCE, "EINSTANCEMISSINGDISK", "Missing volume on an instance")
1232
CV_EINSTANCEFAULTYDISK = \
1233
  (CV_TINSTANCE, "EINSTANCEFAULTYDISK",
1234
   "Impossible to retrieve status for a disk")
1235
CV_EINSTANCEWRONGNODE = \
1236
  (CV_TINSTANCE, "EINSTANCEWRONGNODE", "Instance running on the wrong node")
1237
CV_EINSTANCESPLITGROUPS = \
1238
  (CV_TINSTANCE, "EINSTANCESPLITGROUPS",
1239
   "Instance with primary and secondary nodes in different groups")
1240
CV_ENODEDRBD = \
1241
  (CV_TNODE, "ENODEDRBD", "Error parsing the DRBD status file")
1242
CV_ENODEDRBDHELPER = \
1243
  (CV_TNODE, "ENODEDRBDHELPER", "Error caused by the DRBD helper")
1244
CV_ENODEFILECHECK = \
1245
  (CV_TNODE, "ENODEFILECHECK",
1246
   "Error retrieving the checksum of the node files")
1247
CV_ENODEHOOKS = \
1248
  (CV_TNODE, "ENODEHOOKS", "Communication failure in hooks execution")
1249
CV_ENODEHV = \
1250
  (CV_TNODE, "ENODEHV", "Hypervisor parameters verification failure")
1251
CV_ENODELVM = \
1252
  (CV_TNODE, "ENODELVM", "LVM-related node error")
1253
CV_ENODEN1 = \
1254
  (CV_TNODE, "ENODEN1", "Not enough memory to accommodate instance failovers")
1255
CV_ENODENET = \
1256
  (CV_TNODE, "ENODENET", "Network-related node error")
1257
CV_ENODEOS = \
1258
  (CV_TNODE, "ENODEOS", "OS-related node error")
1259
CV_ENODEORPHANINSTANCE = \
1260
  (CV_TNODE, "ENODEORPHANINSTANCE", "Unknown intance running on a node")
1261
CV_ENODEORPHANLV = \
1262
  (CV_TNODE, "ENODEORPHANLV", "Unknown LVM logical volume")
1263
CV_ENODERPC = \
1264
  (CV_TNODE, "ENODERPC",
1265
   "Error during connection to the primary node of an instance")
1266
CV_ENODESSH = \
1267
  (CV_TNODE, "ENODESSH", "SSH-related node error")
1268
CV_ENODEVERSION = \
1269
  (CV_TNODE, "ENODEVERSION",
1270
   "Protocol version mismatch or Ganeti version mismatch")
1271
CV_ENODESETUP = \
1272
  (CV_TNODE, "ENODESETUP", "Node setup error")
1273
CV_ENODETIME = \
1274
  (CV_TNODE, "ENODETIME", "Node returned invalid time")
1275
CV_ENODEOOBPATH = \
1276
  (CV_TNODE, "ENODEOOBPATH", "Invalid Out Of Band path")
1277
CV_ENODEUSERSCRIPTS = \
1278
  (CV_TNODE, "ENODEUSERSCRIPTS", "User scripts not present or not executable")
1279

    
1280
CV_ALL_ECODES = frozenset([
1281
  CV_ECLUSTERCFG,
1282
  CV_ECLUSTERCERT,
1283
  CV_ECLUSTERFILECHECK,
1284
  CV_ECLUSTERDANGLINGNODES,
1285
  CV_ECLUSTERDANGLINGINST,
1286
  CV_EINSTANCEBADNODE,
1287
  CV_EINSTANCEDOWN,
1288
  CV_EINSTANCELAYOUT,
1289
  CV_EINSTANCEMISSINGDISK,
1290
  CV_EINSTANCEFAULTYDISK,
1291
  CV_EINSTANCEWRONGNODE,
1292
  CV_EINSTANCESPLITGROUPS,
1293
  CV_ENODEDRBD,
1294
  CV_ENODEDRBDHELPER,
1295
  CV_ENODEFILECHECK,
1296
  CV_ENODEHOOKS,
1297
  CV_ENODEHV,
1298
  CV_ENODELVM,
1299
  CV_ENODEN1,
1300
  CV_ENODENET,
1301
  CV_ENODEOS,
1302
  CV_ENODEORPHANINSTANCE,
1303
  CV_ENODEORPHANLV,
1304
  CV_ENODERPC,
1305
  CV_ENODESSH,
1306
  CV_ENODEVERSION,
1307
  CV_ENODESETUP,
1308
  CV_ENODETIME,
1309
  CV_ENODEOOBPATH,
1310
  CV_ENODEUSERSCRIPTS,
1311
  ])
1312

    
1313
CV_ALL_ECODES_STRINGS = frozenset(estr for (_, estr, _) in CV_ALL_ECODES)
1314

    
1315
# Node verify constants
1316
NV_DRBDHELPER = "drbd-helper"
1317
NV_DRBDLIST = "drbd-list"
1318
NV_FILELIST = "filelist"
1319
NV_HVINFO = "hvinfo"
1320
NV_HYPERVISOR = "hypervisor"
1321
NV_HVPARAMS = "hvparms"
1322
NV_INSTANCELIST = "instancelist"
1323
NV_LVLIST = "lvlist"
1324
NV_MASTERIP = "master-ip"
1325
NV_NODELIST = "nodelist"
1326
NV_NODENETTEST = "node-net-test"
1327
NV_NODESETUP = "nodesetup"
1328
NV_OSLIST = "oslist"
1329
NV_PVLIST = "pvlist"
1330
NV_TIME = "time"
1331
NV_VERSION = "version"
1332
NV_VGLIST = "vglist"
1333
NV_VMNODES = "vmnodes"
1334
NV_OOB_PATHS = "oob-paths"
1335
NV_BRIDGES = "bridges"
1336
NV_USERSCRIPTS = "user-scripts"
1337

    
1338
# Instance status
1339
INSTST_RUNNING = "running"
1340
INSTST_ADMINDOWN = "ADMIN_down"
1341
INSTST_ADMINOFFLINE = "ADMIN_offline"
1342
INSTST_NODEOFFLINE = "ERROR_nodeoffline"
1343
INSTST_NODEDOWN = "ERROR_nodedown"
1344
INSTST_WRONGNODE = "ERROR_wrongnode"
1345
INSTST_ERRORUP = "ERROR_up"
1346
INSTST_ERRORDOWN = "ERROR_down"
1347
INSTST_ALL = frozenset([
1348
  INSTST_RUNNING,
1349
  INSTST_ADMINDOWN,
1350
  INSTST_ADMINOFFLINE,
1351
  INSTST_NODEOFFLINE,
1352
  INSTST_NODEDOWN,
1353
  INSTST_WRONGNODE,
1354
  INSTST_ERRORUP,
1355
  INSTST_ERRORDOWN,
1356
  ])
1357

    
1358
# Admin states
1359
ADMINST_UP = "up"
1360
ADMINST_DOWN = "down"
1361
ADMINST_OFFLINE = "offline"
1362
ADMINST_ALL = frozenset([
1363
  ADMINST_UP,
1364
  ADMINST_DOWN,
1365
  ADMINST_OFFLINE,
1366
  ])
1367

    
1368
# Node roles
1369
NR_REGULAR = "R"
1370
NR_MASTER = "M"
1371
NR_MCANDIDATE = "C"
1372
NR_DRAINED = "D"
1373
NR_OFFLINE = "O"
1374
NR_ALL = frozenset([
1375
  NR_REGULAR,
1376
  NR_MASTER,
1377
  NR_MCANDIDATE,
1378
  NR_DRAINED,
1379
  NR_OFFLINE,
1380
  ])
1381

    
1382
# SSL certificate check constants (in days)
1383
SSL_CERT_EXPIRATION_WARN = 30
1384
SSL_CERT_EXPIRATION_ERROR = 7
1385

    
1386
# Allocator framework constants
1387
IALLOCATOR_VERSION = 2
1388
IALLOCATOR_DIR_IN = "in"
1389
IALLOCATOR_DIR_OUT = "out"
1390
VALID_IALLOCATOR_DIRECTIONS = frozenset([
1391
  IALLOCATOR_DIR_IN,
1392
  IALLOCATOR_DIR_OUT,
1393
  ])
1394
IALLOCATOR_MODE_ALLOC = "allocate"
1395
IALLOCATOR_MODE_RELOC = "relocate"
1396
IALLOCATOR_MODE_CHG_GROUP = "change-group"
1397
IALLOCATOR_MODE_NODE_EVAC = "node-evacuate"
1398
VALID_IALLOCATOR_MODES = frozenset([
1399
  IALLOCATOR_MODE_ALLOC,
1400
  IALLOCATOR_MODE_RELOC,
1401
  IALLOCATOR_MODE_CHG_GROUP,
1402
  IALLOCATOR_MODE_NODE_EVAC,
1403
  ])
1404
IALLOCATOR_SEARCH_PATH = _autoconf.IALLOCATOR_SEARCH_PATH
1405

    
1406
IALLOCATOR_NEVAC_PRI = "primary-only"
1407
IALLOCATOR_NEVAC_SEC = "secondary-only"
1408
IALLOCATOR_NEVAC_ALL = "all"
1409
IALLOCATOR_NEVAC_MODES = frozenset([
1410
  IALLOCATOR_NEVAC_PRI,
1411
  IALLOCATOR_NEVAC_SEC,
1412
  IALLOCATOR_NEVAC_ALL,
1413
  ])
1414

    
1415
# Node evacuation
1416
NODE_EVAC_PRI = "primary-only"
1417
NODE_EVAC_SEC = "secondary-only"
1418
NODE_EVAC_ALL = "all"
1419
NODE_EVAC_MODES = frozenset([
1420
  NODE_EVAC_PRI,
1421
  NODE_EVAC_SEC,
1422
  NODE_EVAC_ALL,
1423
  ])
1424

    
1425
# Job queue
1426
JOB_QUEUE_VERSION = 1
1427
JOB_QUEUE_LOCK_FILE = QUEUE_DIR + "/lock"
1428
JOB_QUEUE_VERSION_FILE = QUEUE_DIR + "/version"
1429
JOB_QUEUE_SERIAL_FILE = QUEUE_DIR + "/serial"
1430
JOB_QUEUE_ARCHIVE_DIR = QUEUE_DIR + "/archive"
1431
JOB_QUEUE_DRAIN_FILE = QUEUE_DIR + "/drain"
1432
JOB_QUEUE_SIZE_HARD_LIMIT = 5000
1433
JOB_QUEUE_DIRS = [QUEUE_DIR, JOB_QUEUE_ARCHIVE_DIR]
1434
JOB_QUEUE_DIRS_MODE = SECURE_DIR_MODE
1435

    
1436
JOB_ID_TEMPLATE = r"\d+"
1437
JOB_FILE_RE = re.compile(r"^job-(%s)$" % JOB_ID_TEMPLATE)
1438

    
1439
# unchanged job return
1440
JOB_NOTCHANGED = "nochange"
1441

    
1442
# Job status
1443
JOB_STATUS_QUEUED = "queued"
1444
JOB_STATUS_WAITING = "waiting"
1445
JOB_STATUS_CANCELING = "canceling"
1446
JOB_STATUS_RUNNING = "running"
1447
JOB_STATUS_CANCELED = "canceled"
1448
JOB_STATUS_SUCCESS = "success"
1449
JOB_STATUS_ERROR = "error"
1450
JOBS_FINALIZED = frozenset([
1451
  JOB_STATUS_CANCELED,
1452
  JOB_STATUS_SUCCESS,
1453
  JOB_STATUS_ERROR,
1454
  ])
1455
JOB_STATUS_ALL = frozenset([
1456
  JOB_STATUS_QUEUED,
1457
  JOB_STATUS_WAITING,
1458
  JOB_STATUS_CANCELING,
1459
  JOB_STATUS_RUNNING,
1460
  ]) | JOBS_FINALIZED
1461

    
1462
# OpCode status
1463
# not yet finalized
1464
OP_STATUS_QUEUED = "queued"
1465
OP_STATUS_WAITING = "waiting"
1466
OP_STATUS_CANCELING = "canceling"
1467
OP_STATUS_RUNNING = "running"
1468
# finalized
1469
OP_STATUS_CANCELED = "canceled"
1470
OP_STATUS_SUCCESS = "success"
1471
OP_STATUS_ERROR = "error"
1472
OPS_FINALIZED = frozenset([
1473
  OP_STATUS_CANCELED,
1474
  OP_STATUS_SUCCESS,
1475
  OP_STATUS_ERROR
1476
  ])
1477

    
1478
# OpCode priority
1479
OP_PRIO_LOWEST = +19
1480
OP_PRIO_HIGHEST = -20
1481

    
1482
OP_PRIO_LOW = +10
1483
OP_PRIO_NORMAL = 0
1484
OP_PRIO_HIGH = -10
1485

    
1486
OP_PRIO_SUBMIT_VALID = frozenset([
1487
  OP_PRIO_LOW,
1488
  OP_PRIO_NORMAL,
1489
  OP_PRIO_HIGH,
1490
  ])
1491

    
1492
OP_PRIO_DEFAULT = OP_PRIO_NORMAL
1493

    
1494
# Execution log types
1495
ELOG_MESSAGE = "message"
1496
ELOG_PROGRESS = "progress"
1497
ELOG_REMOTE_IMPORT = "remote-import"
1498
ELOG_JQUEUE_TEST = "jqueue-test"
1499

    
1500
# /etc/hosts modification
1501
ETC_HOSTS_ADD = "add"
1502
ETC_HOSTS_REMOVE = "remove"
1503

    
1504
# Job queue test
1505
JQT_MSGPREFIX = "TESTMSG="
1506
JQT_EXPANDNAMES = "expandnames"
1507
JQT_EXEC = "exec"
1508
JQT_LOGMSG = "logmsg"
1509
JQT_STARTMSG = "startmsg"
1510
JQT_ALL = frozenset([
1511
  JQT_EXPANDNAMES,
1512
  JQT_EXEC,
1513
  JQT_LOGMSG,
1514
  JQT_STARTMSG,
1515
  ])
1516

    
1517
# Query resources
1518
QR_INSTANCE = "instance"
1519
QR_NODE = "node"
1520
QR_LOCK = "lock"
1521
QR_GROUP = "group"
1522
QR_OS = "os"
1523

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

    
1527
#: List of resources which can be queried using Local UniX Interface
1528
QR_VIA_LUXI = QR_VIA_OP.union([
1529
  QR_LOCK,
1530
  ])
1531

    
1532
#: List of resources which can be queried using RAPI
1533
QR_VIA_RAPI = QR_VIA_LUXI
1534

    
1535
# Query field types
1536
QFT_UNKNOWN = "unknown"
1537
QFT_TEXT = "text"
1538
QFT_BOOL = "bool"
1539
QFT_NUMBER = "number"
1540
QFT_UNIT = "unit"
1541
QFT_TIMESTAMP = "timestamp"
1542
QFT_OTHER = "other"
1543

    
1544
#: All query field types
1545
QFT_ALL = frozenset([
1546
  QFT_UNKNOWN,
1547
  QFT_TEXT,
1548
  QFT_BOOL,
1549
  QFT_NUMBER,
1550
  QFT_UNIT,
1551
  QFT_TIMESTAMP,
1552
  QFT_OTHER,
1553
  ])
1554

    
1555
# Query result field status (don't change or reuse values as they're used by
1556
# clients)
1557
#: Normal field status
1558
RS_NORMAL = 0
1559
#: Unknown field
1560
RS_UNKNOWN = 1
1561
#: No data (e.g. RPC error), can be used instead of L{RS_OFFLINE}
1562
RS_NODATA = 2
1563
#: Value unavailable/unsupported for item; if this field is supported
1564
#: but we cannot get the data for the moment, RS_NODATA or
1565
#: RS_OFFLINE should be used
1566
RS_UNAVAIL = 3
1567
#: Resource marked offline
1568
RS_OFFLINE = 4
1569

    
1570
RS_ALL = frozenset([
1571
  RS_NORMAL,
1572
  RS_UNKNOWN,
1573
  RS_NODATA,
1574
  RS_UNAVAIL,
1575
  RS_OFFLINE,
1576
  ])
1577

    
1578
#: Dictionary with special field cases and their verbose/terse formatting
1579
RSS_DESCRIPTION = {
1580
  RS_UNKNOWN: ("(unknown)", "??"),
1581
  RS_NODATA: ("(nodata)", "?"),
1582
  RS_OFFLINE: ("(offline)", "*"),
1583
  RS_UNAVAIL: ("(unavail)", "-"),
1584
  }
1585

    
1586
# max dynamic devices
1587
MAX_NICS = 8
1588
MAX_DISKS = 16
1589

    
1590
# SSCONF keys
1591
SS_CLUSTER_NAME = "cluster_name"
1592
SS_CLUSTER_TAGS = "cluster_tags"
1593
SS_FILE_STORAGE_DIR = "file_storage_dir"
1594
SS_SHARED_FILE_STORAGE_DIR = "shared_file_storage_dir"
1595
SS_MASTER_CANDIDATES = "master_candidates"
1596
SS_MASTER_CANDIDATES_IPS = "master_candidates_ips"
1597
SS_MASTER_IP = "master_ip"
1598
SS_MASTER_NETDEV = "master_netdev"
1599
SS_MASTER_NETMASK = "master_netmask"
1600
SS_MASTER_NODE = "master_node"
1601
SS_NODE_LIST = "node_list"
1602
SS_NODE_PRIMARY_IPS = "node_primary_ips"
1603
SS_NODE_SECONDARY_IPS = "node_secondary_ips"
1604
SS_OFFLINE_NODES = "offline_nodes"
1605
SS_ONLINE_NODES = "online_nodes"
1606
SS_PRIMARY_IP_FAMILY = "primary_ip_family"
1607
SS_INSTANCE_LIST = "instance_list"
1608
SS_RELEASE_VERSION = "release_version"
1609
SS_HYPERVISOR_LIST = "hypervisor_list"
1610
SS_MAINTAIN_NODE_HEALTH = "maintain_node_health"
1611
SS_UID_POOL = "uid_pool"
1612
SS_NODEGROUPS = "nodegroups"
1613

    
1614
SS_FILE_PERMS = 0444
1615

    
1616
# cluster wide default parameters
1617
DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM
1618

    
1619
HVC_DEFAULTS = {
1620
  HT_XEN_PVM: {
1621
    HV_USE_BOOTLOADER: False,
1622
    HV_BOOTLOADER_PATH: XEN_BOOTLOADER,
1623
    HV_BOOTLOADER_ARGS: "",
1624
    HV_KERNEL_PATH: "/boot/vmlinuz-2.6-xenU",
1625
    HV_INITRD_PATH: "",
1626
    HV_ROOT_PATH: "/dev/sda1",
1627
    HV_KERNEL_ARGS: "ro",
1628
    HV_MIGRATION_PORT: 8002,
1629
    HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1630
    HV_BLOCKDEV_PREFIX: "sd",
1631
    HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1632
    HV_CPU_MASK: CPU_PINNING_ALL,
1633
    },
1634
  HT_XEN_HVM: {
1635
    HV_BOOT_ORDER: "cd",
1636
    HV_CDROM_IMAGE_PATH: "",
1637
    HV_NIC_TYPE: HT_NIC_RTL8139,
1638
    HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
1639
    HV_VNC_BIND_ADDRESS: IP4_ADDRESS_ANY,
1640
    HV_VNC_PASSWORD_FILE: VNC_PASSWORD_FILE,
1641
    HV_ACPI: True,
1642
    HV_PAE: True,
1643
    HV_KERNEL_PATH: "/usr/lib/xen/boot/hvmloader",
1644
    HV_DEVICE_MODEL: "/usr/lib/xen/bin/qemu-dm",
1645
    HV_MIGRATION_PORT: 8002,
1646
    HV_MIGRATION_MODE: HT_MIGRATION_NONLIVE,
1647
    HV_USE_LOCALTIME: False,
1648
    HV_BLOCKDEV_PREFIX: "hd",
1649
    HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1650
    HV_CPU_MASK: CPU_PINNING_ALL,
1651
    },
1652
  HT_KVM: {
1653
    HV_KERNEL_PATH: "/boot/vmlinuz-2.6-kvmU",
1654
    HV_INITRD_PATH: "",
1655
    HV_KERNEL_ARGS: "ro",
1656
    HV_ROOT_PATH: "/dev/vda1",
1657
    HV_ACPI: True,
1658
    HV_SERIAL_CONSOLE: True,
1659
    HV_VNC_BIND_ADDRESS: "",
1660
    HV_VNC_TLS: False,
1661
    HV_VNC_X509: "",
1662
    HV_VNC_X509_VERIFY: False,
1663
    HV_VNC_PASSWORD_FILE: "",
1664
    HV_KVM_SPICE_BIND: "",
1665
    HV_KVM_SPICE_IP_VERSION: IFACE_NO_IP_VERSION_SPECIFIED,
1666
    HV_KVM_SPICE_PASSWORD_FILE: "",
1667
    HV_KVM_SPICE_LOSSLESS_IMG_COMPR: "",
1668
    HV_KVM_SPICE_JPEG_IMG_COMPR: "",
1669
    HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR: "",
1670
    HV_KVM_SPICE_STREAMING_VIDEO_DETECTION: "",
1671
    HV_KVM_SPICE_AUDIO_COMPR: True,
1672
    HV_KVM_SPICE_USE_TLS: False,
1673
    HV_KVM_SPICE_TLS_CIPHERS: OPENSSL_CIPHERS,
1674
    HV_KVM_SPICE_USE_VDAGENT: True,
1675
    HV_KVM_FLOPPY_IMAGE_PATH: "",
1676
    HV_CDROM_IMAGE_PATH: "",
1677
    HV_KVM_CDROM2_IMAGE_PATH: "",
1678
    HV_BOOT_ORDER: HT_BO_DISK,
1679
    HV_NIC_TYPE: HT_NIC_PARAVIRTUAL,
1680
    HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
1681
    HV_KVM_CDROM_DISK_TYPE: "",
1682
    HV_USB_MOUSE: "",
1683
    HV_KEYMAP: "",
1684
    HV_MIGRATION_PORT: 8102,
1685
    HV_MIGRATION_BANDWIDTH: 32, # MiB/s
1686
    HV_MIGRATION_DOWNTIME: 30,  # ms
1687
    HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1688
    HV_USE_LOCALTIME: False,
1689
    HV_DISK_CACHE: HT_CACHE_DEFAULT,
1690
    HV_SECURITY_MODEL: HT_SM_NONE,
1691
    HV_SECURITY_DOMAIN: "",
1692
    HV_KVM_FLAG: "",
1693
    HV_VHOST_NET: False,
1694
    HV_KVM_USE_CHROOT: False,
1695
    HV_MEM_PATH: "",
1696
    HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1697
    HV_CPU_MASK: CPU_PINNING_ALL,
1698
    },
1699
  HT_FAKE: {
1700
    },
1701
  HT_CHROOT: {
1702
    HV_INIT_SCRIPT: "/ganeti-chroot",
1703
    },
1704
  HT_LXC: {
1705
    HV_CPU_MASK: "",
1706
    },
1707
  }
1708

    
1709
HVC_GLOBALS = frozenset([
1710
  HV_MIGRATION_PORT,
1711
  HV_MIGRATION_BANDWIDTH,
1712
  HV_MIGRATION_MODE,
1713
  ])
1714

    
1715
BEC_DEFAULTS = {
1716
  BE_MINMEM: 128,
1717
  BE_MAXMEM: 128,
1718
  BE_VCPUS: 1,
1719
  BE_AUTO_BALANCE: True,
1720
  BE_ALWAYS_FAILOVER: False,
1721
  }
1722

    
1723
NDC_DEFAULTS = {
1724
  ND_OOB_PROGRAM: None,
1725
  }
1726

    
1727
DISK_LD_DEFAULTS = {
1728
  LD_DRBD8: {
1729
    RESYNC_RATE: CLASSIC_DRBD_SYNC_SPEED,
1730
    BARRIERS: _autoconf.DRBD_BARRIERS,
1731
    NO_META_FLUSH: _autoconf.DRBD_NO_META_FLUSH,
1732
    },
1733
  LD_LV: {
1734
    STRIPES: _autoconf.LVM_STRIPECOUNT
1735
    },
1736
  LD_FILE: {
1737
    },
1738
  LD_BLOCKDEV: {
1739
    },
1740
  }
1741

    
1742
DISK_DT_DEFAULTS = {
1743
  DT_PLAIN: {
1744
    LV_STRIPES: DISK_LD_DEFAULTS[LD_LV][STRIPES],
1745
    },
1746
  DT_DRBD8: {
1747
    DRBD_RESYNC_RATE: DISK_LD_DEFAULTS[LD_DRBD8][RESYNC_RATE],
1748
    DRBD_DATA_STRIPES: DISK_LD_DEFAULTS[LD_LV][STRIPES],
1749
    DRBD_META_STRIPES: DISK_LD_DEFAULTS[LD_LV][STRIPES],
1750
    DRBD_DISK_BARRIERS: DISK_LD_DEFAULTS[LD_DRBD8][BARRIERS],
1751
    DRBD_META_BARRIERS: DISK_LD_DEFAULTS[LD_DRBD8][NO_META_FLUSH],
1752
    },
1753
  DT_DISKLESS: {
1754
    },
1755
  DT_FILE: {
1756
    },
1757
  DT_SHARED_FILE: {
1758
    },
1759
  DT_BLOCK: {
1760
    },
1761
  }
1762

    
1763
NICC_DEFAULTS = {
1764
  NIC_MODE: NIC_MODE_BRIDGED,
1765
  NIC_LINK: DEFAULT_BRIDGE,
1766
  }
1767

    
1768
MASTER_POOL_SIZE_DEFAULT = 10
1769

    
1770
CONFD_PROTOCOL_VERSION = 1
1771

    
1772
CONFD_REQ_PING = 0
1773
CONFD_REQ_NODE_ROLE_BYNAME = 1
1774
CONFD_REQ_NODE_PIP_BY_INSTANCE_IP = 2
1775
CONFD_REQ_CLUSTER_MASTER = 3
1776
CONFD_REQ_NODE_PIP_LIST = 4
1777
CONFD_REQ_MC_PIP_LIST = 5
1778
CONFD_REQ_INSTANCES_IPS_LIST = 6
1779

    
1780
# Confd request query fields. These are used to narrow down queries.
1781
# These must be strings rather than integers, because json-encoding
1782
# converts them to strings anyway, as they're used as dict-keys.
1783
CONFD_REQQ_LINK = "0"
1784
CONFD_REQQ_IP = "1"
1785
CONFD_REQQ_IPLIST = "2"
1786
CONFD_REQQ_FIELDS = "3"
1787

    
1788
CONFD_REQFIELD_NAME = "0"
1789
CONFD_REQFIELD_IP = "1"
1790
CONFD_REQFIELD_MNODE_PIP = "2"
1791

    
1792
CONFD_REQS = frozenset([
1793
  CONFD_REQ_PING,
1794
  CONFD_REQ_NODE_ROLE_BYNAME,
1795
  CONFD_REQ_NODE_PIP_BY_INSTANCE_IP,
1796
  CONFD_REQ_CLUSTER_MASTER,
1797
  CONFD_REQ_NODE_PIP_LIST,
1798
  CONFD_REQ_MC_PIP_LIST,
1799
  CONFD_REQ_INSTANCES_IPS_LIST,
1800
  ])
1801

    
1802
CONFD_REPL_STATUS_OK = 0
1803
CONFD_REPL_STATUS_ERROR = 1
1804
CONFD_REPL_STATUS_NOTIMPLEMENTED = 2
1805

    
1806
CONFD_REPL_STATUSES = frozenset([
1807
  CONFD_REPL_STATUS_OK,
1808
  CONFD_REPL_STATUS_ERROR,
1809
  CONFD_REPL_STATUS_NOTIMPLEMENTED,
1810
  ])
1811

    
1812
(CONFD_NODE_ROLE_MASTER,
1813
 CONFD_NODE_ROLE_CANDIDATE,
1814
 CONFD_NODE_ROLE_OFFLINE,
1815
 CONFD_NODE_ROLE_DRAINED,
1816
 CONFD_NODE_ROLE_REGULAR,
1817
 ) = range(5)
1818

    
1819
# A few common errors for confd
1820
CONFD_ERROR_UNKNOWN_ENTRY = 1
1821
CONFD_ERROR_INTERNAL = 2
1822
CONFD_ERROR_ARGUMENT = 3
1823

    
1824
# Each request is "salted" by the current timestamp.
1825
# This constants decides how many seconds of skew to accept.
1826
# TODO: make this a default and allow the value to be more configurable
1827
CONFD_MAX_CLOCK_SKEW = 2 * NODE_MAX_CLOCK_SKEW
1828

    
1829
# When we haven't reloaded the config for more than this amount of seconds, we
1830
# force a test to see if inotify is betraying us.
1831
CONFD_CONFIG_RELOAD_TIMEOUT = 60
1832

    
1833
# If we receive more than one update in this amount of seconds, we move to
1834
# polling every RATELIMIT seconds, rather than relying on inotify, to be able
1835
# to serve more requests.
1836
CONFD_CONFIG_RELOAD_RATELIMIT = 2
1837

    
1838
# Magic number prepended to all confd queries.
1839
# This allows us to distinguish different types of confd protocols and handle
1840
# them. For example by changing this we can move the whole payload to be
1841
# compressed, or move away from json.
1842
CONFD_MAGIC_FOURCC = "plj0"
1843

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

    
1849
# Timeout in seconds to expire pending query request in the confd client
1850
# library. We don't actually expect any answer more than 10 seconds after we
1851
# sent a request.
1852
CONFD_CLIENT_EXPIRE_TIMEOUT = 10
1853

    
1854
# Maximum UDP datagram size.
1855
# On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
1856
# On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
1857
#   (assuming we can't use jumbo frames)
1858
# We just set this to 60K, which should be enough
1859
MAX_UDP_DATA_SIZE = 61440
1860

    
1861
# User-id pool minimum/maximum acceptable user-ids.
1862
UIDPOOL_UID_MIN = 0
1863
UIDPOOL_UID_MAX = 2 ** 32 - 1 # Assuming 32 bit user-ids
1864

    
1865
# Name or path of the pgrep command
1866
PGREP = "pgrep"
1867

    
1868
# Name of the node group that gets created at cluster init or upgrade
1869
INITIAL_NODE_GROUP_NAME = "default"
1870

    
1871
# Possible values for NodeGroup.alloc_policy
1872
ALLOC_POLICY_PREFERRED = "preferred"
1873
ALLOC_POLICY_LAST_RESORT = "last_resort"
1874
ALLOC_POLICY_UNALLOCABLE = "unallocable"
1875
VALID_ALLOC_POLICIES = [
1876
  ALLOC_POLICY_PREFERRED,
1877
  ALLOC_POLICY_LAST_RESORT,
1878
  ALLOC_POLICY_UNALLOCABLE,
1879
  ]
1880

    
1881
# Temporary external/shared storage parameters
1882
BLOCKDEV_DRIVER_MANUAL = "manual"
1883

    
1884
# qemu-img path, required for ovfconverter
1885
QEMUIMG_PATH = _autoconf.QEMUIMG_PATH
1886

    
1887
# Whether htools was enabled at compilation time
1888
HTOOLS = _autoconf.HTOOLS
1889
# The hail iallocator
1890
IALLOC_HAIL = "hail"
1891

    
1892
# Fake opcodes for functions that have hooks attached to them via
1893
# backend.RunLocalHooks
1894
FAKE_OP_MASTER_TURNUP = "OP_CLUSTER_IP_TURNUP"
1895
FAKE_OP_MASTER_TURNDOWN = "OP_CLUSTER_IP_TURNDOWN"
1896

    
1897
# Do not re-export imported modules
1898
del re, _vcsversion, _autoconf