Statistics
| Branch: | Tag: | Revision:

root / lib / constants.py @ b2f29800

History | View | Annotate | Download (31 kB)

1
#
2
#
3

    
4
# Copyright (C) 2006, 2007, 2008, 2009, 2010 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
PROTOCOL_VERSION = 40
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 = _autoconf.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
# user separation
88
DAEMONS_GROUP = _autoconf.DAEMONS_GROUP
89
ADMIN_GROUP = _autoconf.ADMIN_GROUP
90
MASTERD_USER = _autoconf.MASTERD_USER
91
MASTERD_GROUP = _autoconf.MASTERD_GROUP
92
RAPI_USER = _autoconf.RAPI_USER
93
RAPI_GROUP = _autoconf.RAPI_GROUP
94
CONFD_USER = _autoconf.CONFD_USER
95
CONFD_GROUP = _autoconf.CONFD_GROUP
96
NODED_USER = _autoconf.NODED_USER
97

    
98

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

    
105

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

    
149
ALL_CERT_FILES = frozenset([NODED_CERT_FILE, RAPI_CERT_FILE])
150

    
151
MASTER_SOCKET = SOCKET_DIR + "/ganeti-master"
152

    
153
NODED = "ganeti-noded"
154
CONFD = "ganeti-confd"
155
RAPI = "ganeti-rapi"
156
MASTERD = "ganeti-masterd"
157
# used in the ganeti-nbma project
158
NLD = "ganeti-nld"
159

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

    
175
FIRST_DRBD_PORT = 11000
176
LAST_DRBD_PORT = 14999
177
MASTER_SCRIPT = "ganeti-master"
178

    
179
LOG_DIR = _autoconf.LOCALSTATEDIR + "/log/ganeti/"
180
DAEMONS_LOGFILES = {
181
  # "daemon-name": "logfile"
182
  NODED: LOG_DIR + "node-daemon.log",
183
  CONFD: LOG_DIR + "conf-daemon.log",
184
  RAPI: LOG_DIR + "rapi-daemon.log",
185
  MASTERD: LOG_DIR + "master-daemon.log",
186
  # used in the ganeti-nbma project
187
  NLD: LOG_DIR + "nl-daemon.log",
188
  }
189

    
190
LOG_OS_DIR = LOG_DIR + "os"
191
LOG_WATCHER = LOG_DIR + "watcher.log"
192
LOG_COMMANDS = LOG_DIR + "commands.log"
193
LOG_BURNIN = LOG_DIR + "burnin.log"
194
LOG_SETUP_SSH = LOG_DIR + "setup-ssh.log"
195

    
196
DEV_CONSOLE = "/dev/console"
197

    
198
PROC_MOUNTS = "/proc/mounts"
199

    
200
# luxi related constants
201
LUXI_EOM = "\3"
202
LUXI_VERSION = CONFIG_VERSION
203

    
204
# one of 'no', 'yes', 'only'
205
SYSLOG_USAGE = _autoconf.SYSLOG_USAGE
206
SYSLOG_NO = "no"
207
SYSLOG_YES = "yes"
208
SYSLOG_ONLY = "only"
209
SYSLOG_SOCKET = "/dev/log"
210

    
211
OS_SEARCH_PATH = _autoconf.OS_SEARCH_PATH
212
EXPORT_DIR = _autoconf.EXPORT_DIR
213

    
214
EXPORT_CONF_FILE = "config.ini"
215

    
216
XEN_BOOTLOADER = _autoconf.XEN_BOOTLOADER
217
XEN_KERNEL = _autoconf.XEN_KERNEL
218
XEN_INITRD = _autoconf.XEN_INITRD
219

    
220
KVM_PATH = _autoconf.KVM_PATH
221
SOCAT_PATH = _autoconf.SOCAT_PATH
222
SOCAT_USE_ESCAPE = _autoconf.SOCAT_USE_ESCAPE
223
SOCAT_USE_COMPRESS = _autoconf.SOCAT_USE_COMPRESS
224
SOCAT_ESCAPE_CODE = "0x1d"
225

    
226
# For RSA keys more bits are better, but they also make operations more
227
# expensive. NIST SP 800-131 recommends a minimum of 2048 bits from the year
228
# 2010 on.
229
RSA_KEY_BITS = 2048
230

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

    
239
# Digest used to sign certificates ("openssl x509" uses SHA1 by default)
240
X509_CERT_SIGN_DIGEST = "SHA1"
241

    
242
# Default validity of certificates in days
243
X509_CERT_DEFAULT_VALIDITY = 365 * 5
244

    
245
# commonName (CN) used in certificates
246
X509_CERT_CN = "ganeti.example.com"
247

    
248
X509_CERT_SIGNATURE_HEADER = "X-Ganeti-Signature"
249

    
250
IMPORT_EXPORT_DAEMON = _autoconf.PKGLIBDIR + "/import-export"
251

    
252
# Import/export daemon mode
253
IEM_IMPORT = "import"
254
IEM_EXPORT = "export"
255

    
256
# Import/export transport compression
257
IEC_NONE = "none"
258
IEC_GZIP = "gzip"
259
IEC_ALL = frozenset([
260
  IEC_NONE,
261
  IEC_GZIP,
262
  ])
263

    
264
IE_CUSTOM_SIZE = "fd"
265

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

    
268
# Import/export I/O
269
# Direct file I/O, equivalent to a shell's I/O redirection using '<' or '>'
270
IEIO_FILE = "file"
271
# Raw block device I/O using "dd"
272
IEIO_RAW_DISK = "raw"
273
# OS definition import/export script
274
IEIO_SCRIPT = "script"
275

    
276
VALUE_DEFAULT = "default"
277
VALUE_AUTO = "auto"
278
VALUE_GENERATE = "generate"
279
VALUE_NONE = "none"
280
VALUE_TRUE = "true"
281
VALUE_FALSE = "false"
282

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

    
286
# hooks-related constants
287
HOOKS_BASE_DIR = CONF_DIR + "/hooks"
288
HOOKS_PHASE_PRE = "pre"
289
HOOKS_PHASE_POST = "post"
290
HOOKS_NAME_CFGUPDATE = "config-update"
291
HOOKS_NAME_WATCHER = "watcher"
292
HOOKS_VERSION = 2
293

    
294
# hooks subject type (what object type does the LU deal with)
295
HTYPE_CLUSTER = "CLUSTER"
296
HTYPE_NODE = "NODE"
297
HTYPE_INSTANCE = "INSTANCE"
298

    
299
HKR_SKIP = 0
300
HKR_FAIL = 1
301
HKR_SUCCESS = 2
302

    
303
# Storage types
304
ST_FILE = "file"
305
ST_LVM_PV = "lvm-pv"
306
ST_LVM_VG = "lvm-vg"
307

    
308
# Storage fields
309
# first two are valid in LU context only, not passed to backend
310
SF_NODE = "node"
311
SF_TYPE = "type"
312
# and the rest are valid in backend
313
SF_NAME = "name"
314
SF_SIZE = "size"
315
SF_FREE = "free"
316
SF_USED = "used"
317
SF_ALLOCATABLE = "allocatable"
318

    
319
# Storage operations
320
SO_FIX_CONSISTENCY = "fix-consistency"
321

    
322
# Available fields per storage type
323
VALID_STORAGE_FIELDS = frozenset([SF_NAME, SF_TYPE, SF_SIZE,
324
                                  SF_USED, SF_FREE, SF_ALLOCATABLE])
325

    
326
VALID_STORAGE_TYPES = frozenset([ST_FILE, ST_LVM_PV, ST_LVM_VG])
327

    
328
MODIFIABLE_STORAGE_FIELDS = {
329
  ST_LVM_PV: frozenset([SF_ALLOCATABLE]),
330
  }
331

    
332
VALID_STORAGE_OPERATIONS = {
333
  ST_LVM_VG: frozenset([SO_FIX_CONSISTENCY]),
334
  }
335

    
336
# Local disk status
337
# Note: Code depends on LDS_OKAY < LDS_UNKNOWN < LDS_FAULTY
338
(LDS_OKAY,
339
 LDS_UNKNOWN,
340
 LDS_FAULTY) = range(1, 4)
341

    
342
# disk template types
343
DT_DISKLESS = "diskless"
344
DT_PLAIN = "plain"
345
DT_DRBD8 = "drbd"
346
DT_FILE = "file"
347

    
348
# the set of network-mirrored disk templates
349
DTS_NET_MIRROR = frozenset([DT_DRBD8])
350

    
351
# the set of non-lvm-based disk templates
352
DTS_NOT_LVM = frozenset([DT_DISKLESS, DT_FILE])
353

    
354
# the set of disk templates which can be grown
355
DTS_GROWABLE = frozenset([DT_PLAIN, DT_DRBD8, DT_FILE])
356

    
357
# the set of disk templates that allow adoption
358
DTS_MAY_ADOPT = frozenset([DT_PLAIN])
359

    
360
# logical disk types
361
LD_LV = "lvm"
362
LD_DRBD8 = "drbd8"
363
LD_FILE = "file"
364
LDS_BLOCK = frozenset([LD_LV, LD_DRBD8])
365

    
366
# drbd constants
367
DRBD_HMAC_ALG = "md5"
368
DRBD_NET_PROTOCOL = "C"
369
DRBD_BARRIERS = _autoconf.DRBD_BARRIERS
370

    
371
# file backend driver
372
FD_LOOP = "loop"
373
FD_BLKTAP = "blktap"
374

    
375
# the set of drbd-like disk types
376
LDS_DRBD = frozenset([LD_DRBD8])
377

    
378
# disk access mode
379
DISK_RDONLY = "ro"
380
DISK_RDWR = "rw"
381
DISK_ACCESS_SET = frozenset([DISK_RDONLY, DISK_RDWR])
382

    
383
# disk replacement mode
384
REPLACE_DISK_PRI = "replace_on_primary"    # replace disks on primary
385
REPLACE_DISK_SEC = "replace_on_secondary"  # replace disks on secondary
386
REPLACE_DISK_CHG = "replace_new_secondary" # change secondary node
387
REPLACE_DISK_AUTO = "replace_auto"
388
REPLACE_MODES = frozenset([
389
  REPLACE_DISK_PRI,
390
  REPLACE_DISK_SEC,
391
  REPLACE_DISK_CHG,
392
  REPLACE_DISK_AUTO,
393
  ])
394

    
395
# Instance export mode
396
EXPORT_MODE_LOCAL = "local"
397
EXPORT_MODE_REMOTE = "remote"
398
EXPORT_MODES = frozenset([
399
  EXPORT_MODE_LOCAL,
400
  EXPORT_MODE_REMOTE,
401
  ])
402

    
403
# lock recalculate mode
404
LOCKS_REPLACE = 'replace'
405
LOCKS_APPEND = 'append'
406

    
407
# instance creation modes
408
INSTANCE_CREATE = "create"
409
INSTANCE_IMPORT = "import"
410
INSTANCE_REMOTE_IMPORT = "remote-import"
411
INSTANCE_CREATE_MODES = frozenset([
412
  INSTANCE_CREATE,
413
  INSTANCE_IMPORT,
414
  INSTANCE_REMOTE_IMPORT,
415
  ])
416

    
417
# Remote import/export handshake message and version
418
RIE_VERSION = 0
419
RIE_HANDSHAKE = "Hi, I'm Ganeti"
420

    
421
# Remote import/export certificate validity in seconds
422
RIE_CERT_VALIDITY = 24 * 60 * 60
423

    
424
# Remote import/export connect timeout for socat
425
RIE_CONNECT_TIMEOUT = 60
426
#: Give child process up to 5 seconds to exit after sending a signal
427
CHILD_LINGER_TIMEOUT = 5.0
428

    
429
DISK_TEMPLATES = frozenset([DT_DISKLESS, DT_PLAIN,
430
                            DT_DRBD8, DT_FILE])
431

    
432
FILE_DRIVER = frozenset([FD_LOOP, FD_BLKTAP])
433

    
434
# import/export config options
435
INISECT_EXP = "export"
436
INISECT_INS = "instance"
437
INISECT_HYP = "hypervisor"
438
INISECT_BEP = "backend"
439
INISECT_OSP = "os"
440

    
441
# dynamic device modification
442
DDM_ADD = "add"
443
DDM_REMOVE = "remove"
444
DDMS_VALUES = frozenset([DDM_ADD, DDM_REMOVE])
445

    
446
# common exit codes
447
EXIT_SUCCESS = 0
448
EXIT_FAILURE = 1
449
EXIT_NOTCLUSTER = 5
450
EXIT_NOTMASTER = 11
451
EXIT_NODESETUP_ERROR = 12
452
EXIT_CONFIRMATION = 13 # need user confirmation
453

    
454
# tags
455
TAG_CLUSTER = "cluster"
456
TAG_NODE = "node"
457
TAG_INSTANCE = "instance"
458
VALID_TAG_TYPES = frozenset([
459
  TAG_CLUSTER,
460
  TAG_NODE,
461
  TAG_INSTANCE,
462
  ])
463
MAX_TAG_LEN = 128
464
MAX_TAGS_PER_OBJ = 4096
465

    
466
# others
467
DEFAULT_BRIDGE = "xen-br0"
468
SYNC_SPEED = 60 * 1024
469
IP4_ADDRESS_LOCALHOST = "127.0.0.1"
470
IP4_ADDRESS_ANY = "0.0.0.0"
471
IP6_ADDRESS_LOCALHOST = "::1"
472
IP6_ADDRESS_ANY = "::"
473
IP4_VERSION = 4
474
IP6_VERSION = 6
475
TCP_PING_TIMEOUT = 10
476
GANETI_RUNAS = "root"
477
DEFAULT_VG = "xenvg"
478
DEFAULT_DRBD_HELPER = "/bin/true"
479
MIN_VG_SIZE = 20480
480
DEFAULT_MAC_PREFIX = "aa:00:00"
481
LVM_STRIPECOUNT = _autoconf.LVM_STRIPECOUNT
482
# default maximum instance wait time, in seconds.
483
DEFAULT_SHUTDOWN_TIMEOUT = 120
484
NODE_MAX_CLOCK_SKEW = 150
485
# Time for an intra-cluster disk transfer to wait for a connection
486
DISK_TRANSFER_CONNECT_TIMEOUT = 30
487

    
488
# runparts results
489
(RUNPARTS_SKIP,
490
 RUNPARTS_RUN,
491
 RUNPARTS_ERR) = range(3)
492

    
493
RUNPARTS_STATUS = frozenset([RUNPARTS_SKIP, RUNPARTS_RUN, RUNPARTS_ERR])
494

    
495
# RPC constants
496
(RPC_ENCODING_NONE,
497
 RPC_ENCODING_ZLIB_BASE64) = range(2)
498

    
499
# os related constants
500
OS_SCRIPT_CREATE = 'create'
501
OS_SCRIPT_IMPORT = 'import'
502
OS_SCRIPT_EXPORT = 'export'
503
OS_SCRIPT_RENAME = 'rename'
504
OS_SCRIPT_VERIFY = 'verify'
505
OS_SCRIPTS = frozenset([OS_SCRIPT_CREATE, OS_SCRIPT_IMPORT,
506
                        OS_SCRIPT_EXPORT, OS_SCRIPT_RENAME,
507
                        OS_SCRIPT_VERIFY])
508

    
509
OS_API_FILE = 'ganeti_api_version'
510
OS_VARIANTS_FILE = 'variants.list'
511
OS_PARAMETERS_FILE = 'parameters.list'
512

    
513
OS_VALIDATE_PARAMETERS = 'parameters'
514
OS_VALIDATE_CALLS = frozenset([OS_VALIDATE_PARAMETERS])
515

    
516
# ssh constants
517
SSH_CONFIG_DIR = _autoconf.SSH_CONFIG_DIR
518
SSH_HOST_DSA_PRIV = SSH_CONFIG_DIR + "/ssh_host_dsa_key"
519
SSH_HOST_DSA_PUB = SSH_HOST_DSA_PRIV + ".pub"
520
SSH_HOST_RSA_PRIV = SSH_CONFIG_DIR + "/ssh_host_rsa_key"
521
SSH_HOST_RSA_PUB = SSH_HOST_RSA_PRIV + ".pub"
522
SSH = "ssh"
523
SCP = "scp"
524

    
525
# reboot types
526
INSTANCE_REBOOT_SOFT = "soft"
527
INSTANCE_REBOOT_HARD = "hard"
528
INSTANCE_REBOOT_FULL = "full"
529

    
530
REBOOT_TYPES = frozenset([INSTANCE_REBOOT_SOFT,
531
                          INSTANCE_REBOOT_HARD,
532
                          INSTANCE_REBOOT_FULL])
533

    
534
VTYPE_STRING = 'string'
535
VTYPE_MAYBE_STRING = "maybe-string"
536
VTYPE_BOOL = 'bool'
537
VTYPE_SIZE = 'size' # size, in MiBs
538
VTYPE_INT = 'int'
539
ENFORCEABLE_TYPES = frozenset([
540
                      VTYPE_STRING,
541
                      VTYPE_MAYBE_STRING,
542
                      VTYPE_BOOL,
543
                      VTYPE_SIZE,
544
                      VTYPE_INT,
545
                      ])
546

    
547
# HV parameter names (global namespace)
548
HV_BOOT_ORDER = "boot_order"
549
HV_CDROM_IMAGE_PATH = "cdrom_image_path"
550
HV_NIC_TYPE = "nic_type"
551
HV_DISK_TYPE = "disk_type"
552
HV_VNC_BIND_ADDRESS = "vnc_bind_address"
553
HV_VNC_PASSWORD_FILE = "vnc_password_file"
554
HV_VNC_TLS = "vnc_tls"
555
HV_VNC_X509 = "vnc_x509_path"
556
HV_VNC_X509_VERIFY = "vnc_x509_verify"
557
HV_ACPI = "acpi"
558
HV_PAE = "pae"
559
HV_USE_BOOTLOADER = "use_bootloader"
560
HV_BOOTLOADER_ARGS = "bootloader_args"
561
HV_BOOTLOADER_PATH = "bootloader_path"
562
HV_KERNEL_ARGS = "kernel_args"
563
HV_KERNEL_PATH = "kernel_path"
564
HV_INITRD_PATH = "initrd_path"
565
HV_ROOT_PATH = "root_path"
566
HV_SERIAL_CONSOLE = "serial_console"
567
HV_USB_MOUSE = "usb_mouse"
568
HV_DEVICE_MODEL = "device_model"
569
HV_INIT_SCRIPT = "init_script"
570
HV_MIGRATION_PORT = "migration_port"
571
HV_MIGRATION_BANDWIDTH = "migration_bandwidth"
572
HV_MIGRATION_DOWNTIME = "migration_downtime"
573
HV_MIGRATION_MODE = "migration_mode"
574
HV_USE_LOCALTIME = "use_localtime"
575
HV_DISK_CACHE = "disk_cache"
576
HV_SECURITY_MODEL = "security_model"
577
HV_SECURITY_DOMAIN = "security_domain"
578
HV_KVM_FLAG = "kvm_flag"
579
HV_VHOST_NET = "vhost_net"
580
HV_KVM_USE_CHROOT = "use_chroot"
581
HV_CPU_MASK = "cpu_mask"
582
HV_MEM_PATH = "mem_path"
583
HV_BLOCKDEV_PREFIX = "blockdev_prefix"
584

    
585
HVS_PARAMETER_TYPES = {
586
  HV_BOOT_ORDER: VTYPE_STRING,
587
  HV_CDROM_IMAGE_PATH: VTYPE_STRING,
588
  HV_NIC_TYPE: VTYPE_STRING,
589
  HV_DISK_TYPE: VTYPE_STRING,
590
  HV_VNC_PASSWORD_FILE: VTYPE_STRING,
591
  HV_VNC_BIND_ADDRESS: VTYPE_STRING,
592
  HV_VNC_TLS: VTYPE_BOOL,
593
  HV_VNC_X509: VTYPE_STRING,
594
  HV_VNC_X509_VERIFY: VTYPE_BOOL,
595
  HV_ACPI: VTYPE_BOOL,
596
  HV_PAE: VTYPE_BOOL,
597
  HV_USE_BOOTLOADER: VTYPE_BOOL,
598
  HV_BOOTLOADER_PATH: VTYPE_STRING,
599
  HV_BOOTLOADER_ARGS: VTYPE_STRING,
600
  HV_KERNEL_PATH: VTYPE_STRING,
601
  HV_KERNEL_ARGS: VTYPE_STRING,
602
  HV_INITRD_PATH: VTYPE_STRING,
603
  HV_ROOT_PATH: VTYPE_STRING,
604
  HV_SERIAL_CONSOLE: VTYPE_BOOL,
605
  HV_USB_MOUSE: VTYPE_STRING,
606
  HV_DEVICE_MODEL: VTYPE_STRING,
607
  HV_INIT_SCRIPT: VTYPE_STRING,
608
  HV_MIGRATION_PORT: VTYPE_INT,
609
  HV_MIGRATION_BANDWIDTH: VTYPE_INT,
610
  HV_MIGRATION_DOWNTIME: VTYPE_INT,
611
  HV_MIGRATION_MODE: VTYPE_STRING,
612
  HV_USE_LOCALTIME: VTYPE_BOOL,
613
  HV_DISK_CACHE: VTYPE_STRING,
614
  HV_SECURITY_MODEL: VTYPE_STRING,
615
  HV_SECURITY_DOMAIN: VTYPE_STRING,
616
  HV_KVM_FLAG: VTYPE_STRING,
617
  HV_VHOST_NET: VTYPE_BOOL,
618
  HV_KVM_USE_CHROOT: VTYPE_BOOL,
619
  HV_CPU_MASK: VTYPE_STRING,
620
  HV_MEM_PATH: VTYPE_STRING,
621
  HV_BLOCKDEV_PREFIX: VTYPE_STRING,
622
  }
623

    
624
HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
625

    
626
# BE parameter names
627
BE_MEMORY = "memory"
628
BE_VCPUS = "vcpus"
629
BE_AUTO_BALANCE = "auto_balance"
630

    
631
BES_PARAMETER_TYPES = {
632
    BE_MEMORY: VTYPE_SIZE,
633
    BE_VCPUS: VTYPE_INT,
634
    BE_AUTO_BALANCE: VTYPE_BOOL,
635
    }
636

    
637
BES_PARAMETERS = frozenset(BES_PARAMETER_TYPES.keys())
638

    
639
# Node parameter names
640
ND_OOB_PROGRAM = "oob_program"
641

    
642
NDS_PARAMETER_TYPES = {
643
    ND_OOB_PROGRAM: VTYPE_MAYBE_STRING,
644
    }
645

    
646
NDS_PARAMETERS = frozenset(NDS_PARAMETER_TYPES.keys())
647

    
648
# OOB supported commands
649
OOB_POWER_ON = "power-on"
650
OOB_POWER_OFF = "power-off"
651
OOB_POWER_CYCLE = "power-cycle"
652
OOB_POWER_STATUS = "power-status"
653
OOB_HEALTH = "health"
654

    
655
OOB_COMMANDS = frozenset([OOB_POWER_ON, OOB_POWER_OFF, OOB_POWER_CYCLE,
656
                          OOB_POWER_STATUS, OOB_HEALTH])
657

    
658
# Instance Parameters Profile
659
PP_DEFAULT = "default"
660

    
661
NIC_MODE = "mode"
662
NIC_LINK = "link"
663

    
664
NIC_MODE_BRIDGED = "bridged"
665
NIC_MODE_ROUTED = "routed"
666

    
667
NIC_VALID_MODES = frozenset([NIC_MODE_BRIDGED, NIC_MODE_ROUTED])
668

    
669
NICS_PARAMETER_TYPES = {
670
    NIC_MODE: VTYPE_STRING,
671
    NIC_LINK: VTYPE_STRING,
672
    }
673

    
674
NICS_PARAMETERS = frozenset(NICS_PARAMETER_TYPES.keys())
675

    
676
IDISK_SIZE = "size"
677
IDISK_MODE = "mode"
678
IDISK_ADOPT = "adopt"
679
IDISK_VG = "vg"
680
IDISK_PARAMS_TYPES = {
681
  IDISK_SIZE: VTYPE_SIZE,
682
  IDISK_MODE: VTYPE_STRING,
683
  IDISK_ADOPT: VTYPE_STRING,
684
  IDISK_VG: VTYPE_STRING,
685
  }
686
IDISK_PARAMS = frozenset(IDISK_PARAMS_TYPES.keys())
687

    
688
INIC_MAC = "mac"
689
INIC_IP = "ip"
690
INIC_MODE = "mode"
691
INIC_LINK = "link"
692
INIC_BRIDGE = "bridge"
693
INIC_PARAMS_TYPES = {
694
  INIC_BRIDGE: VTYPE_STRING,
695
  INIC_IP: VTYPE_MAYBE_STRING,
696
  INIC_LINK: VTYPE_STRING,
697
  INIC_MAC: VTYPE_STRING,
698
  INIC_MODE: VTYPE_STRING,
699
  }
700
INIC_PARAMS = frozenset(INIC_PARAMS_TYPES.keys())
701

    
702
# Hypervisor constants
703
HT_XEN_PVM = "xen-pvm"
704
HT_FAKE = "fake"
705
HT_XEN_HVM = "xen-hvm"
706
HT_KVM = "kvm"
707
HT_CHROOT = "chroot"
708
HT_LXC = "lxc"
709
HYPER_TYPES = frozenset([
710
  HT_XEN_PVM,
711
  HT_FAKE,
712
  HT_XEN_HVM,
713
  HT_KVM,
714
  HT_CHROOT,
715
  HT_LXC,
716
  ])
717
HTS_REQ_PORT = frozenset([HT_XEN_HVM, HT_KVM])
718

    
719
VNC_BASE_PORT = 5900
720
VNC_PASSWORD_FILE = CONF_DIR + "/vnc-cluster-password"
721
VNC_DEFAULT_BIND_ADDRESS = IP4_ADDRESS_ANY
722

    
723
# NIC types
724
HT_NIC_RTL8139 = "rtl8139"
725
HT_NIC_NE2K_PCI = "ne2k_pci"
726
HT_NIC_NE2K_ISA = "ne2k_isa"
727
HT_NIC_I82551 = "i82551"
728
HT_NIC_I85557B = "i82557b"
729
HT_NIC_I8259ER = "i82559er"
730
HT_NIC_PCNET = "pcnet"
731
HT_NIC_E1000 = "e1000"
732
HT_NIC_PARAVIRTUAL = HT_DISK_PARAVIRTUAL = "paravirtual"
733

    
734
HT_HVM_VALID_NIC_TYPES = frozenset([HT_NIC_RTL8139, HT_NIC_NE2K_PCI,
735
                                    HT_NIC_NE2K_ISA, HT_NIC_PARAVIRTUAL])
736
HT_KVM_VALID_NIC_TYPES = frozenset([HT_NIC_RTL8139, HT_NIC_NE2K_PCI,
737
                                    HT_NIC_NE2K_ISA, HT_NIC_I82551,
738
                                    HT_NIC_I85557B, HT_NIC_I8259ER,
739
                                    HT_NIC_PCNET, HT_NIC_E1000,
740
                                    HT_NIC_PARAVIRTUAL])
741
# Disk types
742
HT_DISK_IOEMU = "ioemu"
743
HT_DISK_IDE = "ide"
744
HT_DISK_SCSI = "scsi"
745
HT_DISK_SD = "sd"
746
HT_DISK_MTD = "mtd"
747
HT_DISK_PFLASH = "pflash"
748

    
749
HT_CACHE_DEFAULT = "default"
750
HT_CACHE_NONE = "none"
751
HT_CACHE_WTHROUGH = "writethrough"
752
HT_CACHE_WBACK = "writeback"
753
HT_VALID_CACHE_TYPES = frozenset([HT_CACHE_DEFAULT,
754
                                  HT_CACHE_NONE,
755
                                  HT_CACHE_WTHROUGH,
756
                                  HT_CACHE_WBACK])
757

    
758
HT_HVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IOEMU])
759
HT_KVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IDE,
760
                                     HT_DISK_SCSI, HT_DISK_SD, HT_DISK_MTD,
761
                                     HT_DISK_PFLASH])
762

    
763
# Mouse types:
764
HT_MOUSE_MOUSE = "mouse"
765
HT_MOUSE_TABLET = "tablet"
766

    
767
HT_KVM_VALID_MOUSE_TYPES = frozenset([HT_MOUSE_MOUSE, HT_MOUSE_TABLET])
768

    
769
# Boot order
770
HT_BO_CDROM = "cdrom"
771
HT_BO_DISK = "disk"
772
HT_BO_NETWORK = "network"
773

    
774
HT_KVM_VALID_BO_TYPES = frozenset([HT_BO_CDROM, HT_BO_DISK, HT_BO_NETWORK])
775

    
776
# Security models
777
HT_SM_NONE = "none"
778
HT_SM_USER = "user"
779
HT_SM_POOL = "pool"
780

    
781
HT_KVM_VALID_SM_TYPES = frozenset([HT_SM_NONE, HT_SM_USER, HT_SM_POOL])
782

    
783
# Kvm flag values
784
HT_KVM_ENABLED = "enabled"
785
HT_KVM_DISABLED = "disabled"
786

    
787
HT_KVM_FLAG_VALUES = frozenset([HT_KVM_ENABLED, HT_KVM_DISABLED])
788

    
789
# Migration type
790
HT_MIGRATION_LIVE = "live"
791
HT_MIGRATION_NONLIVE = "non-live"
792
HT_MIGRATION_MODES = frozenset([HT_MIGRATION_LIVE, HT_MIGRATION_NONLIVE])
793

    
794
# Cluster Verify steps
795
VERIFY_NPLUSONE_MEM = 'nplusone_mem'
796
VERIFY_OPTIONAL_CHECKS = frozenset([VERIFY_NPLUSONE_MEM])
797

    
798
# Node verify constants
799
NV_DRBDHELPER = "drbd-helper"
800
NV_DRBDLIST = "drbd-list"
801
NV_FILELIST = "filelist"
802
NV_HVINFO = "hvinfo"
803
NV_HYPERVISOR = "hypervisor"
804
NV_INSTANCELIST = "instancelist"
805
NV_LVLIST = "lvlist"
806
NV_MASTERIP = "master-ip"
807
NV_NODELIST = "nodelist"
808
NV_NODENETTEST = "node-net-test"
809
NV_NODESETUP = "nodesetup"
810
NV_OSLIST = "oslist"
811
NV_PVLIST = "pvlist"
812
NV_TIME = "time"
813
NV_VERSION = "version"
814
NV_VGLIST = "vglist"
815
NV_VMNODES = "vmnodes"
816

    
817
# SSL certificate check constants (in days)
818
SSL_CERT_EXPIRATION_WARN = 30
819
SSL_CERT_EXPIRATION_ERROR = 7
820

    
821
# Allocator framework constants
822
IALLOCATOR_VERSION = 2
823
IALLOCATOR_DIR_IN = "in"
824
IALLOCATOR_DIR_OUT = "out"
825
VALID_IALLOCATOR_DIRECTIONS = frozenset([
826
  IALLOCATOR_DIR_IN,
827
  IALLOCATOR_DIR_OUT,
828
  ])
829
IALLOCATOR_MODE_ALLOC = "allocate"
830
IALLOCATOR_MODE_RELOC = "relocate"
831
IALLOCATOR_MODE_MEVAC = "multi-evacuate"
832
VALID_IALLOCATOR_MODES = frozenset([
833
  IALLOCATOR_MODE_ALLOC,
834
  IALLOCATOR_MODE_RELOC,
835
  IALLOCATOR_MODE_MEVAC,
836
  ])
837
IALLOCATOR_SEARCH_PATH = _autoconf.IALLOCATOR_SEARCH_PATH
838

    
839
# Job queue
840
JOB_QUEUE_VERSION = 1
841
JOB_QUEUE_LOCK_FILE = QUEUE_DIR + "/lock"
842
JOB_QUEUE_VERSION_FILE = QUEUE_DIR + "/version"
843
JOB_QUEUE_SERIAL_FILE = QUEUE_DIR + "/serial"
844
JOB_QUEUE_ARCHIVE_DIR = QUEUE_DIR + "/archive"
845
JOB_QUEUE_DRAIN_FILE = QUEUE_DIR + "/drain"
846
JOB_QUEUE_SIZE_HARD_LIMIT = 5000
847
JOB_QUEUE_DIRS = [QUEUE_DIR, JOB_QUEUE_ARCHIVE_DIR]
848
JOB_QUEUE_DIRS_MODE = SECURE_DIR_MODE
849

    
850
JOB_ID_TEMPLATE = r"\d+"
851

    
852
# unchanged job return
853
JOB_NOTCHANGED = "nochange"
854

    
855
# Job status
856
JOB_STATUS_QUEUED = "queued"
857
JOB_STATUS_WAITLOCK = "waiting"
858
JOB_STATUS_CANCELING = "canceling"
859
JOB_STATUS_RUNNING = "running"
860
JOB_STATUS_CANCELED = "canceled"
861
JOB_STATUS_SUCCESS = "success"
862
JOB_STATUS_ERROR = "error"
863
JOBS_FINALIZED = frozenset([
864
  JOB_STATUS_CANCELED,
865
  JOB_STATUS_SUCCESS,
866
  JOB_STATUS_ERROR,
867
  ])
868
JOB_STATUS_ALL = frozenset([
869
  JOB_STATUS_QUEUED,
870
  JOB_STATUS_WAITLOCK,
871
  JOB_STATUS_CANCELING,
872
  JOB_STATUS_RUNNING,
873
  ]) | JOBS_FINALIZED
874

    
875
# OpCode status
876
# not yet finalized
877
OP_STATUS_QUEUED = "queued"
878
OP_STATUS_WAITLOCK = "waiting"
879
OP_STATUS_CANCELING = "canceling"
880
OP_STATUS_RUNNING = "running"
881
# finalized
882
OP_STATUS_CANCELED = "canceled"
883
OP_STATUS_SUCCESS = "success"
884
OP_STATUS_ERROR = "error"
885
OPS_FINALIZED = frozenset([OP_STATUS_CANCELED,
886
                           OP_STATUS_SUCCESS,
887
                           OP_STATUS_ERROR])
888

    
889
# OpCode priority
890
OP_PRIO_LOWEST = +19
891
OP_PRIO_HIGHEST = -20
892

    
893
OP_PRIO_LOW = +10
894
OP_PRIO_NORMAL = 0
895
OP_PRIO_HIGH = -10
896

    
897
OP_PRIO_SUBMIT_VALID = frozenset([
898
  OP_PRIO_LOW,
899
  OP_PRIO_NORMAL,
900
  OP_PRIO_HIGH,
901
  ])
902

    
903
OP_PRIO_DEFAULT = OP_PRIO_NORMAL
904

    
905
# Execution log types
906
ELOG_MESSAGE = "message"
907
ELOG_PROGRESS = "progress"
908
ELOG_REMOTE_IMPORT = "remote-import"
909
ELOG_JQUEUE_TEST = "jqueue-test"
910

    
911
# /etc/hosts modification
912
ETC_HOSTS_ADD = "add"
913
ETC_HOSTS_REMOVE = "remove"
914

    
915
# Job queue test
916
JQT_MSGPREFIX = "TESTMSG="
917
JQT_EXPANDNAMES = "expandnames"
918
JQT_EXEC = "exec"
919
JQT_LOGMSG = "logmsg"
920
JQT_STARTMSG = "startmsg"
921
JQT_ALL = frozenset([
922
  JQT_EXPANDNAMES,
923
  JQT_EXEC,
924
  JQT_LOGMSG,
925
  JQT_STARTMSG,
926
  ])
927

    
928
# Query resources
929
QR_INSTANCE = "instance"
930
QR_NODE = "node"
931

    
932
#: List of resources which can be queried using L{opcodes.OpQuery}
933
QR_OP_QUERY = frozenset([QR_INSTANCE, QR_NODE])
934

    
935
# Query field types
936
QFT_UNKNOWN = "unknown"
937
QFT_TEXT = "text"
938
QFT_BOOL = "bool"
939
QFT_NUMBER = "number"
940
QFT_UNIT = "unit"
941
QFT_TIMESTAMP = "timestamp"
942
QFT_OTHER = "other"
943

    
944
#: All query field types
945
QFT_ALL = frozenset([
946
  QFT_UNKNOWN,
947
  QFT_TEXT,
948
  QFT_BOOL,
949
  QFT_NUMBER,
950
  QFT_UNIT,
951
  QFT_TIMESTAMP,
952
  QFT_OTHER,
953
  ])
954

    
955
# Query result field status (don't change values as they're used by clients)
956
#: Normal field status
957
QRFS_NORMAL = 0
958
#: Unknown field
959
QRFS_UNKNOWN = 1
960
#: No data
961
QRFS_NODATA = 2
962
#: Value unavailable for item
963
QRFS_UNAVAIL = 3
964

    
965
# max dynamic devices
966
MAX_NICS = 8
967
MAX_DISKS = 16
968

    
969
# SSCONF keys
970
SS_CLUSTER_NAME = "cluster_name"
971
SS_CLUSTER_TAGS = "cluster_tags"
972
SS_FILE_STORAGE_DIR = "file_storage_dir"
973
SS_MASTER_CANDIDATES = "master_candidates"
974
SS_MASTER_CANDIDATES_IPS = "master_candidates_ips"
975
SS_MASTER_IP = "master_ip"
976
SS_MASTER_NETDEV = "master_netdev"
977
SS_MASTER_NODE = "master_node"
978
SS_NODE_LIST = "node_list"
979
SS_NODE_PRIMARY_IPS = "node_primary_ips"
980
SS_NODE_SECONDARY_IPS = "node_secondary_ips"
981
SS_OFFLINE_NODES = "offline_nodes"
982
SS_ONLINE_NODES = "online_nodes"
983
SS_PRIMARY_IP_FAMILY = "primary_ip_family"
984
SS_INSTANCE_LIST = "instance_list"
985
SS_RELEASE_VERSION = "release_version"
986
SS_HYPERVISOR_LIST = "hypervisor_list"
987
SS_MAINTAIN_NODE_HEALTH = "maintain_node_health"
988
SS_UID_POOL = "uid_pool"
989
SS_NODEGROUPS = "nodegroups"
990

    
991
# cluster wide default parameters
992
DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM
993

    
994
HVC_DEFAULTS = {
995
  HT_XEN_PVM: {
996
    HV_USE_BOOTLOADER: False,
997
    HV_BOOTLOADER_PATH: XEN_BOOTLOADER,
998
    HV_BOOTLOADER_ARGS: '',
999
    HV_KERNEL_PATH: "/boot/vmlinuz-2.6-xenU",
1000
    HV_INITRD_PATH: '',
1001
    HV_ROOT_PATH: '/dev/sda1',
1002
    HV_KERNEL_ARGS: 'ro',
1003
    HV_MIGRATION_PORT: 8002,
1004
    HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1005
    HV_BLOCKDEV_PREFIX: "sd",
1006
    },
1007
  HT_XEN_HVM: {
1008
    HV_BOOT_ORDER: "cd",
1009
    HV_CDROM_IMAGE_PATH: '',
1010
    HV_NIC_TYPE: HT_NIC_RTL8139,
1011
    HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
1012
    HV_VNC_BIND_ADDRESS: IP4_ADDRESS_ANY,
1013
    HV_VNC_PASSWORD_FILE: VNC_PASSWORD_FILE,
1014
    HV_ACPI: True,
1015
    HV_PAE: True,
1016
    HV_KERNEL_PATH: "/usr/lib/xen/boot/hvmloader",
1017
    HV_DEVICE_MODEL: "/usr/lib/xen/bin/qemu-dm",
1018
    HV_MIGRATION_PORT: 8002,
1019
    HV_MIGRATION_MODE: HT_MIGRATION_NONLIVE,
1020
    HV_USE_LOCALTIME: False,
1021
    HV_BLOCKDEV_PREFIX: "hd",
1022
    },
1023
  HT_KVM: {
1024
    HV_KERNEL_PATH: "/boot/vmlinuz-2.6-kvmU",
1025
    HV_INITRD_PATH: '',
1026
    HV_KERNEL_ARGS: 'ro',
1027
    HV_ROOT_PATH: '/dev/vda1',
1028
    HV_ACPI: True,
1029
    HV_SERIAL_CONSOLE: True,
1030
    HV_VNC_BIND_ADDRESS: '',
1031
    HV_VNC_TLS: False,
1032
    HV_VNC_X509: '',
1033
    HV_VNC_X509_VERIFY: False,
1034
    HV_VNC_PASSWORD_FILE: '',
1035
    HV_CDROM_IMAGE_PATH: '',
1036
    HV_BOOT_ORDER: HT_BO_DISK,
1037
    HV_NIC_TYPE: HT_NIC_PARAVIRTUAL,
1038
    HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
1039
    HV_USB_MOUSE: '',
1040
    HV_MIGRATION_PORT: 8102,
1041
    HV_MIGRATION_BANDWIDTH: 32, # MiB/s
1042
    HV_MIGRATION_DOWNTIME: 30,  # ms
1043
    HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1044
    HV_USE_LOCALTIME: False,
1045
    HV_DISK_CACHE: HT_CACHE_DEFAULT,
1046
    HV_SECURITY_MODEL: HT_SM_NONE,
1047
    HV_SECURITY_DOMAIN: '',
1048
    HV_KVM_FLAG: "",
1049
    HV_VHOST_NET: False,
1050
    HV_KVM_USE_CHROOT: False,
1051
    HV_MEM_PATH: "",
1052
    },
1053
  HT_FAKE: {
1054
    },
1055
  HT_CHROOT: {
1056
    HV_INIT_SCRIPT: "/ganeti-chroot",
1057
    },
1058
  HT_LXC: {
1059
    HV_CPU_MASK: "",
1060
    },
1061
  }
1062

    
1063
HVC_GLOBALS = frozenset([
1064
  HV_MIGRATION_PORT,
1065
  HV_MIGRATION_BANDWIDTH,
1066
  HV_MIGRATION_MODE,
1067
  ])
1068

    
1069
BEC_DEFAULTS = {
1070
  BE_MEMORY: 128,
1071
  BE_VCPUS: 1,
1072
  BE_AUTO_BALANCE: True,
1073
  }
1074

    
1075
NDC_DEFAULTS = {
1076
  ND_OOB_PROGRAM: None,
1077
  }
1078

    
1079
NICC_DEFAULTS = {
1080
  NIC_MODE: NIC_MODE_BRIDGED,
1081
  NIC_LINK: DEFAULT_BRIDGE,
1082
  }
1083

    
1084
MASTER_POOL_SIZE_DEFAULT = 10
1085

    
1086
CONFD_PROTOCOL_VERSION = 1
1087

    
1088
CONFD_REQ_PING = 0
1089
CONFD_REQ_NODE_ROLE_BYNAME = 1
1090
CONFD_REQ_NODE_PIP_BY_INSTANCE_IP = 2
1091
CONFD_REQ_CLUSTER_MASTER = 3
1092
CONFD_REQ_NODE_PIP_LIST = 4
1093
CONFD_REQ_MC_PIP_LIST = 5
1094
CONFD_REQ_INSTANCES_IPS_LIST = 6
1095

    
1096
# Confd request query fields. These are used to narrow down queries.
1097
# These must be strings rather than integers, because json-encoding
1098
# converts them to strings anyway, as they're used as dict-keys.
1099
CONFD_REQQ_LINK = "0"
1100
CONFD_REQQ_IP = "1"
1101
CONFD_REQQ_IPLIST = "2"
1102
CONFD_REQQ_FIELDS = "3"
1103

    
1104
CONFD_REQFIELD_NAME = "0"
1105
CONFD_REQFIELD_IP = "1"
1106
CONFD_REQFIELD_MNODE_PIP = "2"
1107

    
1108
CONFD_REQS = frozenset([
1109
  CONFD_REQ_PING,
1110
  CONFD_REQ_NODE_ROLE_BYNAME,
1111
  CONFD_REQ_NODE_PIP_BY_INSTANCE_IP,
1112
  CONFD_REQ_CLUSTER_MASTER,
1113
  CONFD_REQ_NODE_PIP_LIST,
1114
  CONFD_REQ_MC_PIP_LIST,
1115
  CONFD_REQ_INSTANCES_IPS_LIST,
1116
  ])
1117

    
1118
CONFD_REPL_STATUS_OK = 0
1119
CONFD_REPL_STATUS_ERROR = 1
1120
CONFD_REPL_STATUS_NOTIMPLEMENTED = 2
1121

    
1122
CONFD_REPL_STATUSES = frozenset([
1123
  CONFD_REPL_STATUS_OK,
1124
  CONFD_REPL_STATUS_ERROR,
1125
  CONFD_REPL_STATUS_NOTIMPLEMENTED,
1126
  ])
1127

    
1128
(CONFD_NODE_ROLE_MASTER,
1129
 CONFD_NODE_ROLE_CANDIDATE,
1130
 CONFD_NODE_ROLE_OFFLINE,
1131
 CONFD_NODE_ROLE_DRAINED,
1132
 CONFD_NODE_ROLE_REGULAR,
1133
 ) = range(5)
1134

    
1135
# A few common errors for confd
1136
CONFD_ERROR_UNKNOWN_ENTRY = 1
1137
CONFD_ERROR_INTERNAL = 2
1138
CONFD_ERROR_ARGUMENT = 3
1139

    
1140
# Each request is "salted" by the current timestamp.
1141
# This constants decides how many seconds of skew to accept.
1142
# TODO: make this a default and allow the value to be more configurable
1143
CONFD_MAX_CLOCK_SKEW = 2 * NODE_MAX_CLOCK_SKEW
1144

    
1145
# When we haven't reloaded the config for more than this amount of seconds, we
1146
# force a test to see if inotify is betraying us.
1147
CONFD_CONFIG_RELOAD_TIMEOUT = 60
1148

    
1149
# If we receive more than one update in this amount of seconds, we move to
1150
# polling every RATELIMIT seconds, rather than relying on inotify, to be able
1151
# to serve more requests.
1152
CONFD_CONFIG_RELOAD_RATELIMIT = 2
1153

    
1154
# Magic number prepended to all confd queries.
1155
# This allows us to distinguish different types of confd protocols and handle
1156
# them. For example by changing this we can move the whole payload to be
1157
# compressed, or move away from json.
1158
CONFD_MAGIC_FOURCC = 'plj0'
1159

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

    
1165
# Timeout in seconds to expire pending query request in the confd client
1166
# library. We don't actually expect any answer more than 10 seconds after we
1167
# sent a request.
1168
CONFD_CLIENT_EXPIRE_TIMEOUT = 10
1169

    
1170
# Maximum UDP datagram size.
1171
# On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
1172
# On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
1173
#   (assuming we can't use jumbo frames)
1174
# We just set this to 60K, which should be enough
1175
MAX_UDP_DATA_SIZE = 61440
1176

    
1177
# User-id pool minimum/maximum acceptable user-ids.
1178
UIDPOOL_UID_MIN = 0
1179
UIDPOOL_UID_MAX = 2**32-1 # Assuming 32 bit user-ids
1180

    
1181
# Name or path of the pgrep command
1182
PGREP = "pgrep"