Statistics
| Branch: | Tag: | Revision:

root / lib / constants.py @ 23cfbaab

History | View | Annotate | Download (36.2 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

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

    
38

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

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

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

56
  Returns: int representing version number
57

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

    
66

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

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

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

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

    
78
  return (major, minor, revision)
79

    
80

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

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

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

    
100

    
101
# Wipe
102
DD_CMD = "dd"
103
WIPE_BLOCK_SIZE = 1024**2
104
MAX_WIPE_CHUNK = 1024 # 1GB
105
MIN_WIPE_CHUNK_PERCENT = 10
106

    
107

    
108
# file paths
109
DATA_DIR = _autoconf.LOCALSTATEDIR + "/lib/ganeti"
110
RUN_DIR = _autoconf.LOCALSTATEDIR + "/run"
111
RUN_GANETI_DIR = RUN_DIR + "/ganeti"
112
BDEV_CACHE_DIR = RUN_GANETI_DIR + "/bdev-cache"
113
DISK_LINKS_DIR = RUN_GANETI_DIR + "/instance-disks"
114
RUN_DIRS_MODE = 0775
115
SOCKET_DIR = RUN_GANETI_DIR + "/socket"
116
SECURE_DIR_MODE = 0700
117
SECURE_FILE_MODE = 0600
118
SOCKET_DIR_MODE = 0750
119
CRYPTO_KEYS_DIR = RUN_GANETI_DIR + "/crypto"
120
CRYPTO_KEYS_DIR_MODE = SECURE_DIR_MODE
121
IMPORT_EXPORT_DIR = RUN_GANETI_DIR + "/import-export"
122
IMPORT_EXPORT_DIR_MODE = 0755
123
ADOPTABLE_BLOCKDEV_ROOT = "/dev/disk/"
124
# keep RUN_GANETI_DIR first here, to make sure all get created when the node
125
# daemon is started (this takes care of RUN_DIR being tmpfs)
126
SUB_RUN_DIRS = [ RUN_GANETI_DIR, BDEV_CACHE_DIR, DISK_LINKS_DIR ]
127
LOCK_DIR = _autoconf.LOCALSTATEDIR + "/lock"
128
SSCONF_LOCK_FILE = LOCK_DIR + "/ganeti-ssconf.lock"
129
# User-id pool lock directory
130
# The user-ids that are in use have a corresponding lock file in this directory
131
UIDPOOL_LOCKDIR = RUN_GANETI_DIR + "/uid-pool"
132
CLUSTER_CONF_FILE = DATA_DIR + "/config.data"
133
NODED_CERT_FILE = DATA_DIR + "/server.pem"
134
RAPI_CERT_FILE = DATA_DIR + "/rapi.pem"
135
CONFD_HMAC_KEY = DATA_DIR + "/hmac.key"
136
CLUSTER_DOMAIN_SECRET_FILE = DATA_DIR + "/cluster-domain-secret"
137
WATCHER_STATEFILE = DATA_DIR + "/watcher.data"
138
WATCHER_PAUSEFILE = DATA_DIR + "/watcher.pause"
139
INSTANCE_UPFILE = RUN_GANETI_DIR + "/instance-status"
140
SSH_KNOWN_HOSTS_FILE = DATA_DIR + "/known_hosts"
141
RAPI_USERS_FILE = DATA_DIR + "/rapi/users"
142
QUEUE_DIR = DATA_DIR + "/queue"
143
DAEMON_UTIL = _autoconf.PKGLIBDIR + "/daemon-util"
144
SETUP_SSH = _autoconf.TOOLSDIR + "/setup-ssh"
145
KVM_IFUP = _autoconf.PKGLIBDIR + "/kvm-ifup"
146
ETC_HOSTS = "/etc/hosts"
147
DEFAULT_FILE_STORAGE_DIR = _autoconf.FILE_STORAGE_DIR
148
DEFAULT_SHARED_FILE_STORAGE_DIR = _autoconf.SHARED_FILE_STORAGE_DIR
149
ENABLE_FILE_STORAGE = _autoconf.ENABLE_FILE_STORAGE
150
ENABLE_SHARED_FILE_STORAGE = _autoconf.ENABLE_SHARED_FILE_STORAGE
151
SYSCONFDIR = _autoconf.SYSCONFDIR
152
TOOLSDIR = _autoconf.TOOLSDIR
153
CONF_DIR = SYSCONFDIR + "/ganeti"
154

    
155
ALL_CERT_FILES = frozenset([NODED_CERT_FILE, RAPI_CERT_FILE])
156

    
157
MASTER_SOCKET = SOCKET_DIR + "/ganeti-master"
158

    
159
NODED = "ganeti-noded"
160
CONFD = "ganeti-confd"
161
RAPI = "ganeti-rapi"
162
MASTERD = "ganeti-masterd"
163
# used in the ganeti-nbma project
164
NLD = "ganeti-nld"
165

    
166
DAEMONS_PORTS = {
167
  # daemon-name: ("proto", "default-port")
168
  NODED: ("tcp", 1811),
169
  CONFD: ("udp", 1814),
170
  RAPI: ("tcp", 5080),
171
  "ssh": ("tcp", 22),
172
  # used in the ganeti-nbma project
173
  NLD: ("udp", 1816),
174
}
175
DEFAULT_NODED_PORT = DAEMONS_PORTS[NODED][1]
176
DEFAULT_CONFD_PORT = DAEMONS_PORTS[CONFD][1]
177
DEFAULT_RAPI_PORT = DAEMONS_PORTS[RAPI][1]
178
# used in the ganeti-nbma project
179
DEFAULT_NLD_PORT = DAEMONS_PORTS[NLD][1]
180

    
181
FIRST_DRBD_PORT = 11000
182
LAST_DRBD_PORT = 14999
183
MASTER_SCRIPT = "ganeti-master"
184

    
185
LOG_DIR = _autoconf.LOCALSTATEDIR + "/log/ganeti/"
186
DAEMONS_LOGFILES = {
187
  # "daemon-name": "logfile"
188
  NODED: LOG_DIR + "node-daemon.log",
189
  CONFD: LOG_DIR + "conf-daemon.log",
190
  RAPI: LOG_DIR + "rapi-daemon.log",
191
  MASTERD: LOG_DIR + "master-daemon.log",
192
  # used in the ganeti-nbma project
193
  NLD: LOG_DIR + "nl-daemon.log",
194
  }
195

    
196
LOG_OS_DIR = LOG_DIR + "os"
197
LOG_WATCHER = LOG_DIR + "watcher.log"
198
LOG_COMMANDS = LOG_DIR + "commands.log"
199
LOG_BURNIN = LOG_DIR + "burnin.log"
200
LOG_SETUP_SSH = LOG_DIR + "setup-ssh.log"
201

    
202
DEV_CONSOLE = "/dev/console"
203

    
204
PROC_MOUNTS = "/proc/mounts"
205

    
206
# Local UniX Interface related constants
207
LUXI_EOM = "\3"
208
LUXI_VERSION = CONFIG_VERSION
209

    
210
# one of 'no', 'yes', 'only'
211
SYSLOG_USAGE = _autoconf.SYSLOG_USAGE
212
SYSLOG_NO = "no"
213
SYSLOG_YES = "yes"
214
SYSLOG_ONLY = "only"
215
SYSLOG_SOCKET = "/dev/log"
216

    
217
OS_SEARCH_PATH = _autoconf.OS_SEARCH_PATH
218
EXPORT_DIR = _autoconf.EXPORT_DIR
219

    
220
EXPORT_CONF_FILE = "config.ini"
221

    
222
XEN_BOOTLOADER = _autoconf.XEN_BOOTLOADER
223
XEN_KERNEL = _autoconf.XEN_KERNEL
224
XEN_INITRD = _autoconf.XEN_INITRD
225

    
226
KVM_PATH = _autoconf.KVM_PATH
227
SOCAT_PATH = _autoconf.SOCAT_PATH
228
SOCAT_USE_ESCAPE = _autoconf.SOCAT_USE_ESCAPE
229
SOCAT_USE_COMPRESS = _autoconf.SOCAT_USE_COMPRESS
230
SOCAT_ESCAPE_CODE = "0x1d"
231

    
232
#: Console as SSH command
233
CONS_SSH = "ssh"
234

    
235
#: Console as VNC server
236
CONS_VNC = "vnc"
237

    
238
#: Display a message for console access
239
CONS_MESSAGE = "msg"
240

    
241
#: All console types
242
CONS_ALL = frozenset([CONS_SSH, CONS_VNC, CONS_MESSAGE])
243

    
244
# For RSA keys more bits are better, but they also make operations more
245
# expensive. NIST SP 800-131 recommends a minimum of 2048 bits from the year
246
# 2010 on.
247
RSA_KEY_BITS = 2048
248

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

    
257
# Digest used to sign certificates ("openssl x509" uses SHA1 by default)
258
X509_CERT_SIGN_DIGEST = "SHA1"
259

    
260
# Default validity of certificates in days
261
X509_CERT_DEFAULT_VALIDITY = 365 * 5
262

    
263
# commonName (CN) used in certificates
264
X509_CERT_CN = "ganeti.example.com"
265

    
266
X509_CERT_SIGNATURE_HEADER = "X-Ganeti-Signature"
267

    
268
IMPORT_EXPORT_DAEMON = _autoconf.PKGLIBDIR + "/import-export"
269

    
270
# Import/export daemon mode
271
IEM_IMPORT = "import"
272
IEM_EXPORT = "export"
273

    
274
# Import/export transport compression
275
IEC_NONE = "none"
276
IEC_GZIP = "gzip"
277
IEC_ALL = frozenset([
278
  IEC_NONE,
279
  IEC_GZIP,
280
  ])
281

    
282
IE_CUSTOM_SIZE = "fd"
283

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

    
286
# Import/export I/O
287
# Direct file I/O, equivalent to a shell's I/O redirection using '<' or '>'
288
IEIO_FILE = "file"
289
# Raw block device I/O using "dd"
290
IEIO_RAW_DISK = "raw"
291
# OS definition import/export script
292
IEIO_SCRIPT = "script"
293

    
294
VALUE_DEFAULT = "default"
295
VALUE_AUTO = "auto"
296
VALUE_GENERATE = "generate"
297
VALUE_NONE = "none"
298
VALUE_TRUE = "true"
299
VALUE_FALSE = "false"
300

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

    
304
# hooks-related constants
305
HOOKS_BASE_DIR = CONF_DIR + "/hooks"
306
HOOKS_PHASE_PRE = "pre"
307
HOOKS_PHASE_POST = "post"
308
HOOKS_NAME_CFGUPDATE = "config-update"
309
HOOKS_NAME_WATCHER = "watcher"
310
HOOKS_VERSION = 2
311

    
312
# hooks subject type (what object type does the LU deal with)
313
HTYPE_CLUSTER = "CLUSTER"
314
HTYPE_NODE = "NODE"
315
HTYPE_GROUP = "GROUP"
316
HTYPE_INSTANCE = "INSTANCE"
317

    
318
HKR_SKIP = 0
319
HKR_FAIL = 1
320
HKR_SUCCESS = 2
321

    
322
# Storage types
323
ST_FILE = "file"
324
ST_LVM_PV = "lvm-pv"
325
ST_LVM_VG = "lvm-vg"
326

    
327
# Storage fields
328
# first two are valid in LU context only, not passed to backend
329
SF_NODE = "node"
330
SF_TYPE = "type"
331
# and the rest are valid in backend
332
SF_NAME = "name"
333
SF_SIZE = "size"
334
SF_FREE = "free"
335
SF_USED = "used"
336
SF_ALLOCATABLE = "allocatable"
337

    
338
# Storage operations
339
SO_FIX_CONSISTENCY = "fix-consistency"
340

    
341
# Available fields per storage type
342
VALID_STORAGE_FIELDS = frozenset([SF_NAME, SF_TYPE, SF_SIZE,
343
                                  SF_USED, SF_FREE, SF_ALLOCATABLE])
344

    
345
VALID_STORAGE_TYPES = frozenset([ST_FILE, ST_LVM_PV, ST_LVM_VG])
346

    
347
MODIFIABLE_STORAGE_FIELDS = {
348
  ST_LVM_PV: frozenset([SF_ALLOCATABLE]),
349
  }
350

    
351
VALID_STORAGE_OPERATIONS = {
352
  ST_LVM_VG: frozenset([SO_FIX_CONSISTENCY]),
353
  }
354

    
355
# Local disk status
356
# Note: Code depends on LDS_OKAY < LDS_UNKNOWN < LDS_FAULTY
357
(LDS_OKAY,
358
 LDS_UNKNOWN,
359
 LDS_FAULTY) = range(1, 4)
360

    
361
# disk template types
362
DT_DISKLESS = "diskless"
363
DT_PLAIN = "plain"
364
DT_DRBD8 = "drbd"
365
DT_FILE = "file"
366
DT_SHARED_FILE = "sharedfile"
367
DT_BLOCK = "blockdev"
368

    
369
# the set of network-mirrored disk templates
370
DTS_INT_MIRROR = frozenset([DT_DRBD8])
371

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

    
375
# the set of non-lvm-based disk templates
376
DTS_NOT_LVM = frozenset([DT_DISKLESS, DT_FILE, DT_SHARED_FILE, DT_BLOCK])
377

    
378
# the set of disk templates which can be grown
379
DTS_GROWABLE = frozenset([DT_PLAIN, DT_DRBD8, DT_FILE, DT_SHARED_FILE])
380

    
381
# the set of disk templates that allow adoption
382
DTS_MAY_ADOPT = frozenset([DT_PLAIN, DT_BLOCK])
383

    
384
# the set of disk templates that *must* use adoption
385
DTS_MUST_ADOPT = frozenset([DT_BLOCK])
386

    
387
# the set of disk templates that allow migrations
388
DTS_MIRRORED = frozenset.union(DTS_INT_MIRROR, DTS_EXT_MIRROR)
389

    
390

    
391
# logical disk types
392
LD_LV = "lvm"
393
LD_DRBD8 = "drbd8"
394
LD_FILE = "file"
395
LD_BLOCKDEV = "blockdev"
396
LDS_BLOCK = frozenset([LD_LV, LD_DRBD8, LD_BLOCKDEV])
397

    
398
# drbd constants
399
DRBD_HMAC_ALG = "md5"
400
DRBD_NET_PROTOCOL = "C"
401
DRBD_BARRIERS = _autoconf.DRBD_BARRIERS
402

    
403
# file backend driver
404
FD_LOOP = "loop"
405
FD_BLKTAP = "blktap"
406

    
407
# the set of drbd-like disk types
408
LDS_DRBD = frozenset([LD_DRBD8])
409

    
410
# disk access mode
411
DISK_RDONLY = "ro"
412
DISK_RDWR = "rw"
413
DISK_ACCESS_SET = frozenset([DISK_RDONLY, DISK_RDWR])
414

    
415
# disk replacement mode
416
REPLACE_DISK_PRI = "replace_on_primary"    # replace disks on primary
417
REPLACE_DISK_SEC = "replace_on_secondary"  # replace disks on secondary
418
REPLACE_DISK_CHG = "replace_new_secondary" # change secondary node
419
REPLACE_DISK_AUTO = "replace_auto"
420
REPLACE_MODES = frozenset([
421
  REPLACE_DISK_PRI,
422
  REPLACE_DISK_SEC,
423
  REPLACE_DISK_CHG,
424
  REPLACE_DISK_AUTO,
425
  ])
426

    
427
# Instance export mode
428
EXPORT_MODE_LOCAL = "local"
429
EXPORT_MODE_REMOTE = "remote"
430
EXPORT_MODES = frozenset([
431
  EXPORT_MODE_LOCAL,
432
  EXPORT_MODE_REMOTE,
433
  ])
434

    
435
# Lock recalculate mode
436
LOCKS_REPLACE = 'replace'
437
LOCKS_APPEND = 'append'
438

    
439
# Lock timeout (sum) before we should go into blocking acquire (still
440
# can be reset by priority change); computed as max time (10 hours)
441
# before we should actually go into blocking acquire given that we
442
# start from default priority level; in seconds
443
LOCK_ATTEMPTS_TIMEOUT = 10 * 3600 / 20.0
444
LOCK_ATTEMPTS_MAXWAIT = 15.0
445
LOCK_ATTEMPTS_MINWAIT = 1.0
446

    
447
# instance creation modes
448
INSTANCE_CREATE = "create"
449
INSTANCE_IMPORT = "import"
450
INSTANCE_REMOTE_IMPORT = "remote-import"
451
INSTANCE_CREATE_MODES = frozenset([
452
  INSTANCE_CREATE,
453
  INSTANCE_IMPORT,
454
  INSTANCE_REMOTE_IMPORT,
455
  ])
456

    
457
# Remote import/export handshake message and version
458
RIE_VERSION = 0
459
RIE_HANDSHAKE = "Hi, I'm Ganeti"
460

    
461
# Remote import/export certificate validity in seconds
462
RIE_CERT_VALIDITY = 24 * 60 * 60
463

    
464
# Overall timeout for establishing connection
465
RIE_CONNECT_TIMEOUT = 180
466

    
467
# Export only: how long to wait per connection attempt (seconds)
468
RIE_CONNECT_ATTEMPT_TIMEOUT = 20
469

    
470
# Export only: number of attempts to connect
471
RIE_CONNECT_RETRIES = 10
472

    
473
#: Give child process up to 5 seconds to exit after sending a signal
474
CHILD_LINGER_TIMEOUT = 5.0
475

    
476
DISK_TEMPLATES = frozenset([DT_DISKLESS, DT_PLAIN, DT_DRBD8,
477
                            DT_FILE, DT_SHARED_FILE, DT_BLOCK])
478

    
479
FILE_DRIVER = frozenset([FD_LOOP, FD_BLKTAP])
480

    
481
# import/export config options
482
INISECT_EXP = "export"
483
INISECT_INS = "instance"
484
INISECT_HYP = "hypervisor"
485
INISECT_BEP = "backend"
486
INISECT_OSP = "os"
487

    
488
# dynamic device modification
489
DDM_ADD = "add"
490
DDM_REMOVE = "remove"
491
DDMS_VALUES = frozenset([DDM_ADD, DDM_REMOVE])
492

    
493
# common exit codes
494
EXIT_SUCCESS = 0
495
EXIT_FAILURE = 1
496
EXIT_NOTCLUSTER = 5
497
EXIT_NOTMASTER = 11
498
EXIT_NODESETUP_ERROR = 12
499
EXIT_CONFIRMATION = 13 # need user confirmation
500

    
501
#: Exit code for query operations with unknown fields
502
EXIT_UNKNOWN_FIELD = 14
503

    
504
# tags
505
TAG_CLUSTER = "cluster"
506
TAG_NODEGROUP = "nodegroup"
507
TAG_NODE = "node"
508
TAG_INSTANCE = "instance"
509
VALID_TAG_TYPES = frozenset([
510
  TAG_CLUSTER,
511
  TAG_NODEGROUP,
512
  TAG_NODE,
513
  TAG_INSTANCE,
514
  ])
515
MAX_TAG_LEN = 128
516
MAX_TAGS_PER_OBJ = 4096
517

    
518
# others
519
DEFAULT_BRIDGE = "xen-br0"
520
SYNC_SPEED = 60 * 1024
521
IP4_ADDRESS_LOCALHOST = "127.0.0.1"
522
IP4_ADDRESS_ANY = "0.0.0.0"
523
IP6_ADDRESS_LOCALHOST = "::1"
524
IP6_ADDRESS_ANY = "::"
525
IP4_VERSION = 4
526
IP6_VERSION = 6
527
TCP_PING_TIMEOUT = 10
528
GANETI_RUNAS = "root"
529
DEFAULT_VG = "xenvg"
530
DEFAULT_DRBD_HELPER = "/bin/true"
531
MIN_VG_SIZE = 20480
532
DEFAULT_MAC_PREFIX = "aa:00:00"
533
LVM_STRIPECOUNT = _autoconf.LVM_STRIPECOUNT
534
# default maximum instance wait time, in seconds.
535
DEFAULT_SHUTDOWN_TIMEOUT = 120
536
NODE_MAX_CLOCK_SKEW = 150
537
# Time for an intra-cluster disk transfer to wait for a connection
538
DISK_TRANSFER_CONNECT_TIMEOUT = 60
539
# Disk index separator
540
DISK_SEPARATOR = _autoconf.DISK_SEPARATOR
541

    
542
#: Key for job IDs in opcode result
543
JOB_IDS_KEY = "jobs"
544

    
545
# runparts results
546
(RUNPARTS_SKIP,
547
 RUNPARTS_RUN,
548
 RUNPARTS_ERR) = range(3)
549

    
550
RUNPARTS_STATUS = frozenset([RUNPARTS_SKIP, RUNPARTS_RUN, RUNPARTS_ERR])
551

    
552
# RPC constants
553
(RPC_ENCODING_NONE,
554
 RPC_ENCODING_ZLIB_BASE64) = range(2)
555

    
556
# os related constants
557
OS_SCRIPT_CREATE = 'create'
558
OS_SCRIPT_IMPORT = 'import'
559
OS_SCRIPT_EXPORT = 'export'
560
OS_SCRIPT_RENAME = 'rename'
561
OS_SCRIPT_VERIFY = 'verify'
562
OS_SCRIPTS = frozenset([OS_SCRIPT_CREATE, OS_SCRIPT_IMPORT,
563
                        OS_SCRIPT_EXPORT, OS_SCRIPT_RENAME,
564
                        OS_SCRIPT_VERIFY])
565

    
566
OS_API_FILE = 'ganeti_api_version'
567
OS_VARIANTS_FILE = 'variants.list'
568
OS_PARAMETERS_FILE = 'parameters.list'
569

    
570
OS_VALIDATE_PARAMETERS = 'parameters'
571
OS_VALIDATE_CALLS = frozenset([OS_VALIDATE_PARAMETERS])
572

    
573
# ssh constants
574
SSH_CONFIG_DIR = _autoconf.SSH_CONFIG_DIR
575
SSH_HOST_DSA_PRIV = SSH_CONFIG_DIR + "/ssh_host_dsa_key"
576
SSH_HOST_DSA_PUB = SSH_HOST_DSA_PRIV + ".pub"
577
SSH_HOST_RSA_PRIV = SSH_CONFIG_DIR + "/ssh_host_rsa_key"
578
SSH_HOST_RSA_PUB = SSH_HOST_RSA_PRIV + ".pub"
579
SSH = "ssh"
580
SCP = "scp"
581

    
582
# reboot types
583
INSTANCE_REBOOT_SOFT = "soft"
584
INSTANCE_REBOOT_HARD = "hard"
585
INSTANCE_REBOOT_FULL = "full"
586

    
587
REBOOT_TYPES = frozenset([INSTANCE_REBOOT_SOFT,
588
                          INSTANCE_REBOOT_HARD,
589
                          INSTANCE_REBOOT_FULL])
590

    
591
VTYPE_STRING = 'string'
592
VTYPE_MAYBE_STRING = "maybe-string"
593
VTYPE_BOOL = 'bool'
594
VTYPE_SIZE = 'size' # size, in MiBs
595
VTYPE_INT = 'int'
596
ENFORCEABLE_TYPES = frozenset([
597
                      VTYPE_STRING,
598
                      VTYPE_MAYBE_STRING,
599
                      VTYPE_BOOL,
600
                      VTYPE_SIZE,
601
                      VTYPE_INT,
602
                      ])
603

    
604
# HV parameter names (global namespace)
605
HV_BOOT_ORDER = "boot_order"
606
HV_CDROM_IMAGE_PATH = "cdrom_image_path"
607
HV_KVM_CDROM2_IMAGE_PATH = "cdrom2_image_path"
608
HV_KVM_FLOPPY_IMAGE_PATH = "floppy_image_path"
609
HV_NIC_TYPE = "nic_type"
610
HV_DISK_TYPE = "disk_type"
611
HV_KVM_CDROM_DISK_TYPE = "cdrom_disk_type"
612
HV_VNC_BIND_ADDRESS = "vnc_bind_address"
613
HV_VNC_PASSWORD_FILE = "vnc_password_file"
614
HV_VNC_TLS = "vnc_tls"
615
HV_VNC_X509 = "vnc_x509_path"
616
HV_VNC_X509_VERIFY = "vnc_x509_verify"
617
HV_ACPI = "acpi"
618
HV_PAE = "pae"
619
HV_USE_BOOTLOADER = "use_bootloader"
620
HV_BOOTLOADER_ARGS = "bootloader_args"
621
HV_BOOTLOADER_PATH = "bootloader_path"
622
HV_KERNEL_ARGS = "kernel_args"
623
HV_KERNEL_PATH = "kernel_path"
624
HV_INITRD_PATH = "initrd_path"
625
HV_ROOT_PATH = "root_path"
626
HV_SERIAL_CONSOLE = "serial_console"
627
HV_USB_MOUSE = "usb_mouse"
628
HV_DEVICE_MODEL = "device_model"
629
HV_INIT_SCRIPT = "init_script"
630
HV_MIGRATION_PORT = "migration_port"
631
HV_MIGRATION_BANDWIDTH = "migration_bandwidth"
632
HV_MIGRATION_DOWNTIME = "migration_downtime"
633
HV_MIGRATION_MODE = "migration_mode"
634
HV_USE_LOCALTIME = "use_localtime"
635
HV_DISK_CACHE = "disk_cache"
636
HV_SECURITY_MODEL = "security_model"
637
HV_SECURITY_DOMAIN = "security_domain"
638
HV_KVM_FLAG = "kvm_flag"
639
HV_VHOST_NET = "vhost_net"
640
HV_KVM_USE_CHROOT = "use_chroot"
641
HV_CPU_MASK = "cpu_mask"
642
HV_MEM_PATH = "mem_path"
643
HV_BLOCKDEV_PREFIX = "blockdev_prefix"
644

    
645
HVS_PARAMETER_TYPES = {
646
  HV_BOOT_ORDER: VTYPE_STRING,
647
  HV_KVM_FLOPPY_IMAGE_PATH: VTYPE_STRING,
648
  HV_CDROM_IMAGE_PATH: VTYPE_STRING,
649
  HV_KVM_CDROM2_IMAGE_PATH: VTYPE_STRING,
650
  HV_NIC_TYPE: VTYPE_STRING,
651
  HV_DISK_TYPE: VTYPE_STRING,
652
  HV_KVM_CDROM_DISK_TYPE: VTYPE_STRING,
653
  HV_VNC_PASSWORD_FILE: VTYPE_STRING,
654
  HV_VNC_BIND_ADDRESS: VTYPE_STRING,
655
  HV_VNC_TLS: VTYPE_BOOL,
656
  HV_VNC_X509: VTYPE_STRING,
657
  HV_VNC_X509_VERIFY: VTYPE_BOOL,
658
  HV_ACPI: VTYPE_BOOL,
659
  HV_PAE: VTYPE_BOOL,
660
  HV_USE_BOOTLOADER: VTYPE_BOOL,
661
  HV_BOOTLOADER_PATH: VTYPE_STRING,
662
  HV_BOOTLOADER_ARGS: VTYPE_STRING,
663
  HV_KERNEL_PATH: VTYPE_STRING,
664
  HV_KERNEL_ARGS: VTYPE_STRING,
665
  HV_INITRD_PATH: VTYPE_STRING,
666
  HV_ROOT_PATH: VTYPE_MAYBE_STRING,
667
  HV_SERIAL_CONSOLE: VTYPE_BOOL,
668
  HV_USB_MOUSE: VTYPE_STRING,
669
  HV_DEVICE_MODEL: VTYPE_STRING,
670
  HV_INIT_SCRIPT: VTYPE_STRING,
671
  HV_MIGRATION_PORT: VTYPE_INT,
672
  HV_MIGRATION_BANDWIDTH: VTYPE_INT,
673
  HV_MIGRATION_DOWNTIME: VTYPE_INT,
674
  HV_MIGRATION_MODE: VTYPE_STRING,
675
  HV_USE_LOCALTIME: VTYPE_BOOL,
676
  HV_DISK_CACHE: VTYPE_STRING,
677
  HV_SECURITY_MODEL: VTYPE_STRING,
678
  HV_SECURITY_DOMAIN: VTYPE_STRING,
679
  HV_KVM_FLAG: VTYPE_STRING,
680
  HV_VHOST_NET: VTYPE_BOOL,
681
  HV_KVM_USE_CHROOT: VTYPE_BOOL,
682
  HV_CPU_MASK: VTYPE_STRING,
683
  HV_MEM_PATH: VTYPE_STRING,
684
  HV_BLOCKDEV_PREFIX: VTYPE_STRING,
685
  }
686

    
687
HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
688

    
689
# Backend parameter names
690
BE_MEMORY = "memory"
691
BE_VCPUS = "vcpus"
692
BE_AUTO_BALANCE = "auto_balance"
693

    
694
BES_PARAMETER_TYPES = {
695
    BE_MEMORY: VTYPE_SIZE,
696
    BE_VCPUS: VTYPE_INT,
697
    BE_AUTO_BALANCE: VTYPE_BOOL,
698
    }
699

    
700
BES_PARAMETERS = frozenset(BES_PARAMETER_TYPES.keys())
701

    
702
# Node parameter names
703
ND_OOB_PROGRAM = "oob_program"
704

    
705
NDS_PARAMETER_TYPES = {
706
    ND_OOB_PROGRAM: VTYPE_MAYBE_STRING,
707
    }
708

    
709
NDS_PARAMETERS = frozenset(NDS_PARAMETER_TYPES.keys())
710

    
711
# OOB supported commands
712
OOB_POWER_ON = "power-on"
713
OOB_POWER_OFF = "power-off"
714
OOB_POWER_CYCLE = "power-cycle"
715
OOB_POWER_STATUS = "power-status"
716
OOB_HEALTH = "health"
717

    
718
OOB_COMMANDS = frozenset([OOB_POWER_ON, OOB_POWER_OFF, OOB_POWER_CYCLE,
719
                          OOB_POWER_STATUS, OOB_HEALTH])
720

    
721
OOB_POWER_STATUS_POWERED = "powered"
722

    
723
OOB_TIMEOUT = 60 # 60 seconds
724
OOB_POWER_DELAY = 2.0 # 2 seconds
725

    
726
OOB_STATUS_OK = "OK"
727
OOB_STATUS_WARNING = "WARNING"
728
OOB_STATUS_CRITICAL = "CRITICAL"
729
OOB_STATUS_UNKNOWN = "UNKNOWN"
730

    
731
OOB_STATUSES = frozenset([
732
  OOB_STATUS_OK,
733
  OOB_STATUS_WARNING,
734
  OOB_STATUS_CRITICAL,
735
  OOB_STATUS_UNKNOWN,
736
  ])
737

    
738
# Instance Parameters Profile
739
PP_DEFAULT = "default"
740

    
741
# NIC_* constants are used inside the ganeti config
742
NIC_MODE = "mode"
743
NIC_LINK = "link"
744

    
745
NIC_MODE_BRIDGED = "bridged"
746
NIC_MODE_ROUTED = "routed"
747

    
748
NIC_VALID_MODES = frozenset([NIC_MODE_BRIDGED, NIC_MODE_ROUTED])
749

    
750
NICS_PARAMETER_TYPES = {
751
    NIC_MODE: VTYPE_STRING,
752
    NIC_LINK: VTYPE_STRING,
753
    }
754

    
755
NICS_PARAMETERS = frozenset(NICS_PARAMETER_TYPES.keys())
756

    
757
# IDISK_* constants are used in opcodes, to create/change disks
758
IDISK_SIZE = "size"
759
IDISK_MODE = "mode"
760
IDISK_ADOPT = "adopt"
761
IDISK_VG = "vg"
762
IDISK_METAVG = "metavg"
763
IDISK_PARAMS_TYPES = {
764
  IDISK_SIZE: VTYPE_SIZE,
765
  IDISK_MODE: VTYPE_STRING,
766
  IDISK_ADOPT: VTYPE_STRING,
767
  IDISK_VG: VTYPE_STRING,
768
  IDISK_METAVG: VTYPE_STRING,
769
  }
770
IDISK_PARAMS = frozenset(IDISK_PARAMS_TYPES.keys())
771

    
772
# INIC_* constants are used in opcodes, to create/change nics
773
INIC_MAC = "mac"
774
INIC_IP = "ip"
775
INIC_MODE = "mode"
776
INIC_LINK = "link"
777
INIC_PARAMS_TYPES = {
778
  INIC_IP: VTYPE_MAYBE_STRING,
779
  INIC_LINK: VTYPE_STRING,
780
  INIC_MAC: VTYPE_STRING,
781
  INIC_MODE: VTYPE_STRING,
782
  }
783
INIC_PARAMS = frozenset(INIC_PARAMS_TYPES.keys())
784

    
785
# Hypervisor constants
786
HT_XEN_PVM = "xen-pvm"
787
HT_FAKE = "fake"
788
HT_XEN_HVM = "xen-hvm"
789
HT_KVM = "kvm"
790
HT_CHROOT = "chroot"
791
HT_LXC = "lxc"
792
HYPER_TYPES = frozenset([
793
  HT_XEN_PVM,
794
  HT_FAKE,
795
  HT_XEN_HVM,
796
  HT_KVM,
797
  HT_CHROOT,
798
  HT_LXC,
799
  ])
800
HTS_REQ_PORT = frozenset([HT_XEN_HVM, HT_KVM])
801

    
802
VNC_BASE_PORT = 5900
803
VNC_PASSWORD_FILE = CONF_DIR + "/vnc-cluster-password"
804
VNC_DEFAULT_BIND_ADDRESS = IP4_ADDRESS_ANY
805

    
806
# NIC types
807
HT_NIC_RTL8139 = "rtl8139"
808
HT_NIC_NE2K_PCI = "ne2k_pci"
809
HT_NIC_NE2K_ISA = "ne2k_isa"
810
HT_NIC_I82551 = "i82551"
811
HT_NIC_I85557B = "i82557b"
812
HT_NIC_I8259ER = "i82559er"
813
HT_NIC_PCNET = "pcnet"
814
HT_NIC_E1000 = "e1000"
815
HT_NIC_PARAVIRTUAL = HT_DISK_PARAVIRTUAL = "paravirtual"
816

    
817
HT_HVM_VALID_NIC_TYPES = frozenset([HT_NIC_RTL8139, HT_NIC_NE2K_PCI,
818
                                    HT_NIC_E1000, HT_NIC_NE2K_ISA,
819
                                    HT_NIC_PARAVIRTUAL])
820
HT_KVM_VALID_NIC_TYPES = frozenset([HT_NIC_RTL8139, HT_NIC_NE2K_PCI,
821
                                    HT_NIC_NE2K_ISA, HT_NIC_I82551,
822
                                    HT_NIC_I85557B, HT_NIC_I8259ER,
823
                                    HT_NIC_PCNET, HT_NIC_E1000,
824
                                    HT_NIC_PARAVIRTUAL])
825
# Disk types
826
HT_DISK_IOEMU = "ioemu"
827
HT_DISK_IDE = "ide"
828
HT_DISK_SCSI = "scsi"
829
HT_DISK_SD = "sd"
830
HT_DISK_MTD = "mtd"
831
HT_DISK_PFLASH = "pflash"
832

    
833
HT_CACHE_DEFAULT = "default"
834
HT_CACHE_NONE = "none"
835
HT_CACHE_WTHROUGH = "writethrough"
836
HT_CACHE_WBACK = "writeback"
837
HT_VALID_CACHE_TYPES = frozenset([HT_CACHE_DEFAULT,
838
                                  HT_CACHE_NONE,
839
                                  HT_CACHE_WTHROUGH,
840
                                  HT_CACHE_WBACK])
841

    
842
HT_HVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IOEMU])
843
HT_KVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IDE,
844
                                     HT_DISK_SCSI, HT_DISK_SD, HT_DISK_MTD,
845
                                     HT_DISK_PFLASH])
846

    
847
# Mouse types:
848
HT_MOUSE_MOUSE = "mouse"
849
HT_MOUSE_TABLET = "tablet"
850

    
851
HT_KVM_VALID_MOUSE_TYPES = frozenset([HT_MOUSE_MOUSE, HT_MOUSE_TABLET])
852

    
853
# Boot order
854
HT_BO_FLOPPY = "floppy"
855
HT_BO_CDROM = "cdrom"
856
HT_BO_DISK = "disk"
857
HT_BO_NETWORK = "network"
858

    
859
HT_KVM_VALID_BO_TYPES = frozenset([HT_BO_FLOPPY, HT_BO_CDROM,
860
                                   HT_BO_DISK, HT_BO_NETWORK])
861

    
862
# Security models
863
HT_SM_NONE = "none"
864
HT_SM_USER = "user"
865
HT_SM_POOL = "pool"
866

    
867
HT_KVM_VALID_SM_TYPES = frozenset([HT_SM_NONE, HT_SM_USER, HT_SM_POOL])
868

    
869
# Kvm flag values
870
HT_KVM_ENABLED = "enabled"
871
HT_KVM_DISABLED = "disabled"
872

    
873
HT_KVM_FLAG_VALUES = frozenset([HT_KVM_ENABLED, HT_KVM_DISABLED])
874

    
875
# Migration type
876
HT_MIGRATION_LIVE = "live"
877
HT_MIGRATION_NONLIVE = "non-live"
878
HT_MIGRATION_MODES = frozenset([HT_MIGRATION_LIVE, HT_MIGRATION_NONLIVE])
879

    
880
# Cluster Verify steps
881
VERIFY_NPLUSONE_MEM = 'nplusone_mem'
882
VERIFY_OPTIONAL_CHECKS = frozenset([VERIFY_NPLUSONE_MEM])
883

    
884
# Node verify constants
885
NV_DRBDHELPER = "drbd-helper"
886
NV_DRBDLIST = "drbd-list"
887
NV_FILELIST = "filelist"
888
NV_HVINFO = "hvinfo"
889
NV_HYPERVISOR = "hypervisor"
890
NV_HVPARAMS = "hvparms"
891
NV_INSTANCELIST = "instancelist"
892
NV_LVLIST = "lvlist"
893
NV_MASTERIP = "master-ip"
894
NV_NODELIST = "nodelist"
895
NV_NODENETTEST = "node-net-test"
896
NV_NODESETUP = "nodesetup"
897
NV_OSLIST = "oslist"
898
NV_PVLIST = "pvlist"
899
NV_TIME = "time"
900
NV_VERSION = "version"
901
NV_VGLIST = "vglist"
902
NV_VMNODES = "vmnodes"
903
NV_OOB_PATHS = "oob-paths"
904
NV_BRIDGES = "bridges"
905

    
906
# Instance status
907
INSTST_RUNNING = "running"
908
INSTST_ADMINDOWN = "ADMIN_down"
909
INSTST_NODEOFFLINE = "ERROR_nodeoffline"
910
INSTST_NODEDOWN = "ERROR_nodedown"
911
INSTST_WRONGNODE = "ERROR_wrongnode"
912
INSTST_ERRORUP = "ERROR_up"
913
INSTST_ERRORDOWN = "ERROR_down"
914
INSTST_ALL = frozenset([
915
  INSTST_RUNNING,
916
  INSTST_ADMINDOWN,
917
  INSTST_NODEOFFLINE,
918
  INSTST_NODEDOWN,
919
  INSTST_WRONGNODE,
920
  INSTST_ERRORUP,
921
  INSTST_ERRORDOWN,
922
  ])
923

    
924
# Node roles
925
NR_REGULAR = "R"
926
NR_MASTER = "M"
927
NR_MCANDIDATE = "C"
928
NR_DRAINED = "D"
929
NR_OFFLINE = "O"
930
NR_ALL = frozenset([
931
  NR_REGULAR,
932
  NR_MASTER,
933
  NR_MCANDIDATE,
934
  NR_DRAINED,
935
  NR_OFFLINE,
936
  ])
937

    
938
# SSL certificate check constants (in days)
939
SSL_CERT_EXPIRATION_WARN = 30
940
SSL_CERT_EXPIRATION_ERROR = 7
941

    
942
# Allocator framework constants
943
IALLOCATOR_VERSION = 2
944
IALLOCATOR_DIR_IN = "in"
945
IALLOCATOR_DIR_OUT = "out"
946
VALID_IALLOCATOR_DIRECTIONS = frozenset([
947
  IALLOCATOR_DIR_IN,
948
  IALLOCATOR_DIR_OUT,
949
  ])
950
IALLOCATOR_MODE_ALLOC = "allocate"
951
IALLOCATOR_MODE_RELOC = "relocate"
952
IALLOCATOR_MODE_MEVAC = "multi-evacuate"
953
IALLOCATOR_MODE_MRELOC = "multi-relocate"
954
VALID_IALLOCATOR_MODES = frozenset([
955
  IALLOCATOR_MODE_ALLOC,
956
  IALLOCATOR_MODE_RELOC,
957
  IALLOCATOR_MODE_MEVAC,
958
  IALLOCATOR_MODE_MRELOC,
959
  ])
960
IALLOCATOR_SEARCH_PATH = _autoconf.IALLOCATOR_SEARCH_PATH
961

    
962
IALLOCATOR_MRELOC_ANY = "any_group"
963
IALLOCATOR_MRELOC_CHANGE = "change_group"
964
IALLOCATOR_MRELOC_KEEP = "keep_group"
965
IALLOCATOR_MRELOC_MODES = frozenset([
966
  IALLOCATOR_MRELOC_ANY,
967
  IALLOCATOR_MRELOC_CHANGE,
968
  IALLOCATOR_MRELOC_KEEP,
969
  ])
970

    
971
# Job queue
972
JOB_QUEUE_VERSION = 1
973
JOB_QUEUE_LOCK_FILE = QUEUE_DIR + "/lock"
974
JOB_QUEUE_VERSION_FILE = QUEUE_DIR + "/version"
975
JOB_QUEUE_SERIAL_FILE = QUEUE_DIR + "/serial"
976
JOB_QUEUE_ARCHIVE_DIR = QUEUE_DIR + "/archive"
977
JOB_QUEUE_DRAIN_FILE = QUEUE_DIR + "/drain"
978
JOB_QUEUE_SIZE_HARD_LIMIT = 5000
979
JOB_QUEUE_DIRS = [QUEUE_DIR, JOB_QUEUE_ARCHIVE_DIR]
980
JOB_QUEUE_DIRS_MODE = SECURE_DIR_MODE
981

    
982
JOB_ID_TEMPLATE = r"\d+"
983

    
984
# unchanged job return
985
JOB_NOTCHANGED = "nochange"
986

    
987
# Job status
988
JOB_STATUS_QUEUED = "queued"
989
JOB_STATUS_WAITLOCK = "waiting"
990
JOB_STATUS_CANCELING = "canceling"
991
JOB_STATUS_RUNNING = "running"
992
JOB_STATUS_CANCELED = "canceled"
993
JOB_STATUS_SUCCESS = "success"
994
JOB_STATUS_ERROR = "error"
995
JOBS_FINALIZED = frozenset([
996
  JOB_STATUS_CANCELED,
997
  JOB_STATUS_SUCCESS,
998
  JOB_STATUS_ERROR,
999
  ])
1000
JOB_STATUS_ALL = frozenset([
1001
  JOB_STATUS_QUEUED,
1002
  JOB_STATUS_WAITLOCK,
1003
  JOB_STATUS_CANCELING,
1004
  JOB_STATUS_RUNNING,
1005
  ]) | JOBS_FINALIZED
1006

    
1007
# OpCode status
1008
# not yet finalized
1009
OP_STATUS_QUEUED = "queued"
1010
OP_STATUS_WAITLOCK = "waiting"
1011
OP_STATUS_CANCELING = "canceling"
1012
OP_STATUS_RUNNING = "running"
1013
# finalized
1014
OP_STATUS_CANCELED = "canceled"
1015
OP_STATUS_SUCCESS = "success"
1016
OP_STATUS_ERROR = "error"
1017
OPS_FINALIZED = frozenset([OP_STATUS_CANCELED,
1018
                           OP_STATUS_SUCCESS,
1019
                           OP_STATUS_ERROR])
1020

    
1021
# OpCode priority
1022
OP_PRIO_LOWEST = +19
1023
OP_PRIO_HIGHEST = -20
1024

    
1025
OP_PRIO_LOW = +10
1026
OP_PRIO_NORMAL = 0
1027
OP_PRIO_HIGH = -10
1028

    
1029
OP_PRIO_SUBMIT_VALID = frozenset([
1030
  OP_PRIO_LOW,
1031
  OP_PRIO_NORMAL,
1032
  OP_PRIO_HIGH,
1033
  ])
1034

    
1035
OP_PRIO_DEFAULT = OP_PRIO_NORMAL
1036

    
1037
# Execution log types
1038
ELOG_MESSAGE = "message"
1039
ELOG_PROGRESS = "progress"
1040
ELOG_REMOTE_IMPORT = "remote-import"
1041
ELOG_JQUEUE_TEST = "jqueue-test"
1042

    
1043
# /etc/hosts modification
1044
ETC_HOSTS_ADD = "add"
1045
ETC_HOSTS_REMOVE = "remove"
1046

    
1047
# Job queue test
1048
JQT_MSGPREFIX = "TESTMSG="
1049
JQT_EXPANDNAMES = "expandnames"
1050
JQT_EXEC = "exec"
1051
JQT_LOGMSG = "logmsg"
1052
JQT_STARTMSG = "startmsg"
1053
JQT_ALL = frozenset([
1054
  JQT_EXPANDNAMES,
1055
  JQT_EXEC,
1056
  JQT_LOGMSG,
1057
  JQT_STARTMSG,
1058
  ])
1059

    
1060
# Query resources
1061
QR_INSTANCE = "instance"
1062
QR_NODE = "node"
1063
QR_LOCK = "lock"
1064
QR_GROUP = "group"
1065
QR_OS = "os"
1066

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

    
1070
#: List of resources which can be queried using Local UniX Interface
1071
QR_VIA_LUXI = QR_VIA_OP.union([
1072
  QR_LOCK,
1073
  ])
1074

    
1075
#: List of resources which can be queried using RAPI
1076
QR_VIA_RAPI = QR_VIA_LUXI
1077

    
1078
# Query field types
1079
QFT_UNKNOWN = "unknown"
1080
QFT_TEXT = "text"
1081
QFT_BOOL = "bool"
1082
QFT_NUMBER = "number"
1083
QFT_UNIT = "unit"
1084
QFT_TIMESTAMP = "timestamp"
1085
QFT_OTHER = "other"
1086

    
1087
#: All query field types
1088
QFT_ALL = frozenset([
1089
  QFT_UNKNOWN,
1090
  QFT_TEXT,
1091
  QFT_BOOL,
1092
  QFT_NUMBER,
1093
  QFT_UNIT,
1094
  QFT_TIMESTAMP,
1095
  QFT_OTHER,
1096
  ])
1097

    
1098
# Query result field status (don't change or reuse values as they're used by
1099
# clients)
1100
#: Normal field status
1101
RS_NORMAL = 0
1102
#: Unknown field
1103
RS_UNKNOWN = 1
1104
#: No data (e.g. RPC error), can be used instead of L{RS_OFFLINE}
1105
RS_NODATA = 2
1106
#: Value unavailable/unsupported for item; if this field is supported
1107
#: but we cannot get the data for the moment, RS_NODATA or
1108
#: RS_OFFLINE should be used
1109
RS_UNAVAIL = 3
1110
#: Resource marked offline
1111
RS_OFFLINE = 4
1112

    
1113
RS_ALL = frozenset([
1114
  RS_NORMAL,
1115
  RS_UNKNOWN,
1116
  RS_NODATA,
1117
  RS_UNAVAIL,
1118
  RS_OFFLINE,
1119
  ])
1120

    
1121
#: Dictionary with special field cases and their verbose/terse formatting
1122
RSS_DESCRIPTION = {
1123
  RS_UNKNOWN: ("(unknown)", "??"),
1124
  RS_NODATA:  ("(nodata)",  "?"),
1125
  RS_OFFLINE: ("(offline)", "*"),
1126
  RS_UNAVAIL: ("(unavail)", "-"),
1127
  }
1128

    
1129
# max dynamic devices
1130
MAX_NICS = 8
1131
MAX_DISKS = 16
1132

    
1133
# SSCONF keys
1134
SS_CLUSTER_NAME = "cluster_name"
1135
SS_CLUSTER_TAGS = "cluster_tags"
1136
SS_FILE_STORAGE_DIR = "file_storage_dir"
1137
SS_SHARED_FILE_STORAGE_DIR = "shared_file_storage_dir"
1138
SS_MASTER_CANDIDATES = "master_candidates"
1139
SS_MASTER_CANDIDATES_IPS = "master_candidates_ips"
1140
SS_MASTER_IP = "master_ip"
1141
SS_MASTER_NETDEV = "master_netdev"
1142
SS_MASTER_NODE = "master_node"
1143
SS_NODE_LIST = "node_list"
1144
SS_NODE_PRIMARY_IPS = "node_primary_ips"
1145
SS_NODE_SECONDARY_IPS = "node_secondary_ips"
1146
SS_OFFLINE_NODES = "offline_nodes"
1147
SS_ONLINE_NODES = "online_nodes"
1148
SS_PRIMARY_IP_FAMILY = "primary_ip_family"
1149
SS_INSTANCE_LIST = "instance_list"
1150
SS_RELEASE_VERSION = "release_version"
1151
SS_HYPERVISOR_LIST = "hypervisor_list"
1152
SS_MAINTAIN_NODE_HEALTH = "maintain_node_health"
1153
SS_UID_POOL = "uid_pool"
1154
SS_NODEGROUPS = "nodegroups"
1155

    
1156
# cluster wide default parameters
1157
DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM
1158

    
1159
HVC_DEFAULTS = {
1160
  HT_XEN_PVM: {
1161
    HV_USE_BOOTLOADER: False,
1162
    HV_BOOTLOADER_PATH: XEN_BOOTLOADER,
1163
    HV_BOOTLOADER_ARGS: '',
1164
    HV_KERNEL_PATH: "/boot/vmlinuz-2.6-xenU",
1165
    HV_INITRD_PATH: '',
1166
    HV_ROOT_PATH: '/dev/sda1',
1167
    HV_KERNEL_ARGS: 'ro',
1168
    HV_MIGRATION_PORT: 8002,
1169
    HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1170
    HV_BLOCKDEV_PREFIX: "sd",
1171
    },
1172
  HT_XEN_HVM: {
1173
    HV_BOOT_ORDER: "cd",
1174
    HV_CDROM_IMAGE_PATH: '',
1175
    HV_NIC_TYPE: HT_NIC_RTL8139,
1176
    HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
1177
    HV_VNC_BIND_ADDRESS: IP4_ADDRESS_ANY,
1178
    HV_VNC_PASSWORD_FILE: VNC_PASSWORD_FILE,
1179
    HV_ACPI: True,
1180
    HV_PAE: True,
1181
    HV_KERNEL_PATH: "/usr/lib/xen/boot/hvmloader",
1182
    HV_DEVICE_MODEL: "/usr/lib/xen/bin/qemu-dm",
1183
    HV_MIGRATION_PORT: 8002,
1184
    HV_MIGRATION_MODE: HT_MIGRATION_NONLIVE,
1185
    HV_USE_LOCALTIME: False,
1186
    HV_BLOCKDEV_PREFIX: "hd",
1187
    },
1188
  HT_KVM: {
1189
    HV_KERNEL_PATH: "/boot/vmlinuz-2.6-kvmU",
1190
    HV_INITRD_PATH: '',
1191
    HV_KERNEL_ARGS: 'ro',
1192
    HV_ROOT_PATH: '/dev/vda1',
1193
    HV_ACPI: True,
1194
    HV_SERIAL_CONSOLE: True,
1195
    HV_VNC_BIND_ADDRESS: '',
1196
    HV_VNC_TLS: False,
1197
    HV_VNC_X509: '',
1198
    HV_VNC_X509_VERIFY: False,
1199
    HV_VNC_PASSWORD_FILE: '',
1200
    HV_KVM_FLOPPY_IMAGE_PATH: '',
1201
    HV_CDROM_IMAGE_PATH: '',
1202
    HV_KVM_CDROM2_IMAGE_PATH: '',
1203
    HV_BOOT_ORDER: HT_BO_DISK,
1204
    HV_NIC_TYPE: HT_NIC_PARAVIRTUAL,
1205
    HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
1206
    HV_KVM_CDROM_DISK_TYPE: '',
1207
    HV_USB_MOUSE: '',
1208
    HV_MIGRATION_PORT: 8102,
1209
    HV_MIGRATION_BANDWIDTH: 32, # MiB/s
1210
    HV_MIGRATION_DOWNTIME: 30,  # ms
1211
    HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1212
    HV_USE_LOCALTIME: False,
1213
    HV_DISK_CACHE: HT_CACHE_DEFAULT,
1214
    HV_SECURITY_MODEL: HT_SM_NONE,
1215
    HV_SECURITY_DOMAIN: '',
1216
    HV_KVM_FLAG: "",
1217
    HV_VHOST_NET: False,
1218
    HV_KVM_USE_CHROOT: False,
1219
    HV_MEM_PATH: "",
1220
    },
1221
  HT_FAKE: {
1222
    },
1223
  HT_CHROOT: {
1224
    HV_INIT_SCRIPT: "/ganeti-chroot",
1225
    },
1226
  HT_LXC: {
1227
    HV_CPU_MASK: "",
1228
    },
1229
  }
1230

    
1231
HVC_GLOBALS = frozenset([
1232
  HV_MIGRATION_PORT,
1233
  HV_MIGRATION_BANDWIDTH,
1234
  HV_MIGRATION_MODE,
1235
  ])
1236

    
1237
BEC_DEFAULTS = {
1238
  BE_MEMORY: 128,
1239
  BE_VCPUS: 1,
1240
  BE_AUTO_BALANCE: True,
1241
  }
1242

    
1243
NDC_DEFAULTS = {
1244
  ND_OOB_PROGRAM: None,
1245
  }
1246

    
1247
NICC_DEFAULTS = {
1248
  NIC_MODE: NIC_MODE_BRIDGED,
1249
  NIC_LINK: DEFAULT_BRIDGE,
1250
  }
1251

    
1252
MASTER_POOL_SIZE_DEFAULT = 10
1253

    
1254
CONFD_PROTOCOL_VERSION = 1
1255

    
1256
CONFD_REQ_PING = 0
1257
CONFD_REQ_NODE_ROLE_BYNAME = 1
1258
CONFD_REQ_NODE_PIP_BY_INSTANCE_IP = 2
1259
CONFD_REQ_CLUSTER_MASTER = 3
1260
CONFD_REQ_NODE_PIP_LIST = 4
1261
CONFD_REQ_MC_PIP_LIST = 5
1262
CONFD_REQ_INSTANCES_IPS_LIST = 6
1263

    
1264
# Confd request query fields. These are used to narrow down queries.
1265
# These must be strings rather than integers, because json-encoding
1266
# converts them to strings anyway, as they're used as dict-keys.
1267
CONFD_REQQ_LINK = "0"
1268
CONFD_REQQ_IP = "1"
1269
CONFD_REQQ_IPLIST = "2"
1270
CONFD_REQQ_FIELDS = "3"
1271

    
1272
CONFD_REQFIELD_NAME = "0"
1273
CONFD_REQFIELD_IP = "1"
1274
CONFD_REQFIELD_MNODE_PIP = "2"
1275

    
1276
CONFD_REQS = frozenset([
1277
  CONFD_REQ_PING,
1278
  CONFD_REQ_NODE_ROLE_BYNAME,
1279
  CONFD_REQ_NODE_PIP_BY_INSTANCE_IP,
1280
  CONFD_REQ_CLUSTER_MASTER,
1281
  CONFD_REQ_NODE_PIP_LIST,
1282
  CONFD_REQ_MC_PIP_LIST,
1283
  CONFD_REQ_INSTANCES_IPS_LIST,
1284
  ])
1285

    
1286
CONFD_REPL_STATUS_OK = 0
1287
CONFD_REPL_STATUS_ERROR = 1
1288
CONFD_REPL_STATUS_NOTIMPLEMENTED = 2
1289

    
1290
CONFD_REPL_STATUSES = frozenset([
1291
  CONFD_REPL_STATUS_OK,
1292
  CONFD_REPL_STATUS_ERROR,
1293
  CONFD_REPL_STATUS_NOTIMPLEMENTED,
1294
  ])
1295

    
1296
(CONFD_NODE_ROLE_MASTER,
1297
 CONFD_NODE_ROLE_CANDIDATE,
1298
 CONFD_NODE_ROLE_OFFLINE,
1299
 CONFD_NODE_ROLE_DRAINED,
1300
 CONFD_NODE_ROLE_REGULAR,
1301
 ) = range(5)
1302

    
1303
# A few common errors for confd
1304
CONFD_ERROR_UNKNOWN_ENTRY = 1
1305
CONFD_ERROR_INTERNAL = 2
1306
CONFD_ERROR_ARGUMENT = 3
1307

    
1308
# Each request is "salted" by the current timestamp.
1309
# This constants decides how many seconds of skew to accept.
1310
# TODO: make this a default and allow the value to be more configurable
1311
CONFD_MAX_CLOCK_SKEW = 2 * NODE_MAX_CLOCK_SKEW
1312

    
1313
# When we haven't reloaded the config for more than this amount of seconds, we
1314
# force a test to see if inotify is betraying us.
1315
CONFD_CONFIG_RELOAD_TIMEOUT = 60
1316

    
1317
# If we receive more than one update in this amount of seconds, we move to
1318
# polling every RATELIMIT seconds, rather than relying on inotify, to be able
1319
# to serve more requests.
1320
CONFD_CONFIG_RELOAD_RATELIMIT = 2
1321

    
1322
# Magic number prepended to all confd queries.
1323
# This allows us to distinguish different types of confd protocols and handle
1324
# them. For example by changing this we can move the whole payload to be
1325
# compressed, or move away from json.
1326
CONFD_MAGIC_FOURCC = 'plj0'
1327

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

    
1333
# Timeout in seconds to expire pending query request in the confd client
1334
# library. We don't actually expect any answer more than 10 seconds after we
1335
# sent a request.
1336
CONFD_CLIENT_EXPIRE_TIMEOUT = 10
1337

    
1338
# Maximum UDP datagram size.
1339
# On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
1340
# On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
1341
#   (assuming we can't use jumbo frames)
1342
# We just set this to 60K, which should be enough
1343
MAX_UDP_DATA_SIZE = 61440
1344

    
1345
# User-id pool minimum/maximum acceptable user-ids.
1346
UIDPOOL_UID_MIN = 0
1347
UIDPOOL_UID_MAX = 2**32-1 # Assuming 32 bit user-ids
1348

    
1349
# Name or path of the pgrep command
1350
PGREP = "pgrep"
1351

    
1352
# Name of the node group that gets created at cluster init or upgrade
1353
INITIAL_NODE_GROUP_NAME = "default"
1354

    
1355
# Possible values for NodeGroup.alloc_policy
1356
ALLOC_POLICY_PREFERRED = "preferred"
1357
ALLOC_POLICY_LAST_RESORT = "last_resort"
1358
ALLOC_POLICY_UNALLOCABLE = "unallocable"
1359
VALID_ALLOC_POLICIES = [
1360
  ALLOC_POLICY_PREFERRED,
1361
  ALLOC_POLICY_LAST_RESORT,
1362
  ALLOC_POLICY_UNALLOCABLE,
1363
  ]
1364

    
1365
# Temporary external/shared storage parameters
1366
BLOCKDEV_DRIVER_MANUAL = "manual"
1367

    
1368
# Whether htools was enabled at compilation time
1369
HTOOLS = _autoconf.HTOOLS
1370
# The hail iallocator
1371
IALLOC_HAIL = "hail"