Statistics
| Branch: | Tag: | Revision:

root / lib / constants.py @ 61a980a9

History | View | Annotate | Download (33.6 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
# keep RUN_GANETI_DIR first here, to make sure all get created when the node
124
# daemon is started (this takes care of RUN_DIR being tmpfs)
125
SUB_RUN_DIRS = [ RUN_GANETI_DIR, BDEV_CACHE_DIR, DISK_LINKS_DIR ]
126
LOCK_DIR = _autoconf.LOCALSTATEDIR + "/lock"
127
SSCONF_LOCK_FILE = LOCK_DIR + "/ganeti-ssconf.lock"
128
# User-id pool lock directory
129
# The user-ids that are in use have a corresponding lock file in this directory
130
UIDPOOL_LOCKDIR = RUN_GANETI_DIR + "/uid-pool"
131
CLUSTER_CONF_FILE = DATA_DIR + "/config.data"
132
NODED_CERT_FILE = DATA_DIR + "/server.pem"
133
RAPI_CERT_FILE = DATA_DIR + "/rapi.pem"
134
CONFD_HMAC_KEY = DATA_DIR + "/hmac.key"
135
CLUSTER_DOMAIN_SECRET_FILE = DATA_DIR + "/cluster-domain-secret"
136
WATCHER_STATEFILE = DATA_DIR + "/watcher.data"
137
WATCHER_PAUSEFILE = DATA_DIR + "/watcher.pause"
138
INSTANCE_UPFILE = RUN_GANETI_DIR + "/instance-status"
139
SSH_KNOWN_HOSTS_FILE = DATA_DIR + "/known_hosts"
140
RAPI_USERS_FILE = DATA_DIR + "/rapi/users"
141
QUEUE_DIR = DATA_DIR + "/queue"
142
DAEMON_UTIL = _autoconf.PKGLIBDIR + "/daemon-util"
143
SETUP_SSH = _autoconf.TOOLSDIR + "/setup-ssh"
144
KVM_IFUP = _autoconf.PKGLIBDIR + "/kvm-ifup"
145
ETC_HOSTS = "/etc/hosts"
146
DEFAULT_FILE_STORAGE_DIR = _autoconf.FILE_STORAGE_DIR
147
ENABLE_FILE_STORAGE = _autoconf.ENABLE_FILE_STORAGE
148
SYSCONFDIR = _autoconf.SYSCONFDIR
149
TOOLSDIR = _autoconf.TOOLSDIR
150
CONF_DIR = SYSCONFDIR + "/ganeti"
151

    
152
ALL_CERT_FILES = frozenset([NODED_CERT_FILE, RAPI_CERT_FILE])
153

    
154
MASTER_SOCKET = SOCKET_DIR + "/ganeti-master"
155

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

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

    
178
FIRST_DRBD_PORT = 11000
179
LAST_DRBD_PORT = 14999
180
MASTER_SCRIPT = "ganeti-master"
181

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

    
193
LOG_OS_DIR = LOG_DIR + "os"
194
LOG_WATCHER = LOG_DIR + "watcher.log"
195
LOG_COMMANDS = LOG_DIR + "commands.log"
196
LOG_BURNIN = LOG_DIR + "burnin.log"
197
LOG_SETUP_SSH = LOG_DIR + "setup-ssh.log"
198

    
199
DEV_CONSOLE = "/dev/console"
200

    
201
PROC_MOUNTS = "/proc/mounts"
202

    
203
# luxi related constants
204
LUXI_EOM = "\3"
205
LUXI_VERSION = CONFIG_VERSION
206

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

    
214
OS_SEARCH_PATH = _autoconf.OS_SEARCH_PATH
215
EXPORT_DIR = _autoconf.EXPORT_DIR
216

    
217
EXPORT_CONF_FILE = "config.ini"
218

    
219
XEN_BOOTLOADER = _autoconf.XEN_BOOTLOADER
220
XEN_KERNEL = _autoconf.XEN_KERNEL
221
XEN_INITRD = _autoconf.XEN_INITRD
222

    
223
KVM_PATH = _autoconf.KVM_PATH
224
SOCAT_PATH = _autoconf.SOCAT_PATH
225
SOCAT_USE_ESCAPE = _autoconf.SOCAT_USE_ESCAPE
226
SOCAT_USE_COMPRESS = _autoconf.SOCAT_USE_COMPRESS
227
SOCAT_ESCAPE_CODE = "0x1d"
228

    
229
#: Console as SSH command
230
CONS_SSH = "ssh"
231

    
232
#: Console as VNC server
233
CONS_VNC = "vnc"
234

    
235
#: Display a message for console access
236
CONS_MESSAGE = "msg"
237

    
238
#: All console types
239
CONS_ALL = frozenset([CONS_SSH, CONS_VNC, CONS_MESSAGE])
240

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

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

    
254
# Digest used to sign certificates ("openssl x509" uses SHA1 by default)
255
X509_CERT_SIGN_DIGEST = "SHA1"
256

    
257
# Default validity of certificates in days
258
X509_CERT_DEFAULT_VALIDITY = 365 * 5
259

    
260
# commonName (CN) used in certificates
261
X509_CERT_CN = "ganeti.example.com"
262

    
263
X509_CERT_SIGNATURE_HEADER = "X-Ganeti-Signature"
264

    
265
IMPORT_EXPORT_DAEMON = _autoconf.PKGLIBDIR + "/import-export"
266

    
267
# Import/export daemon mode
268
IEM_IMPORT = "import"
269
IEM_EXPORT = "export"
270

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

    
279
IE_CUSTOM_SIZE = "fd"
280

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

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

    
291
VALUE_DEFAULT = "default"
292
VALUE_AUTO = "auto"
293
VALUE_GENERATE = "generate"
294
VALUE_NONE = "none"
295
VALUE_TRUE = "true"
296
VALUE_FALSE = "false"
297

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

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

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

    
315
HKR_SKIP = 0
316
HKR_FAIL = 1
317
HKR_SUCCESS = 2
318

    
319
# Storage types
320
ST_FILE = "file"
321
ST_LVM_PV = "lvm-pv"
322
ST_LVM_VG = "lvm-vg"
323

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

    
335
# Storage operations
336
SO_FIX_CONSISTENCY = "fix-consistency"
337

    
338
# Available fields per storage type
339
VALID_STORAGE_FIELDS = frozenset([SF_NAME, SF_TYPE, SF_SIZE,
340
                                  SF_USED, SF_FREE, SF_ALLOCATABLE])
341

    
342
VALID_STORAGE_TYPES = frozenset([ST_FILE, ST_LVM_PV, ST_LVM_VG])
343

    
344
MODIFIABLE_STORAGE_FIELDS = {
345
  ST_LVM_PV: frozenset([SF_ALLOCATABLE]),
346
  }
347

    
348
VALID_STORAGE_OPERATIONS = {
349
  ST_LVM_VG: frozenset([SO_FIX_CONSISTENCY]),
350
  }
351

    
352
# Local disk status
353
# Note: Code depends on LDS_OKAY < LDS_UNKNOWN < LDS_FAULTY
354
(LDS_OKAY,
355
 LDS_UNKNOWN,
356
 LDS_FAULTY) = range(1, 4)
357

    
358
# disk template types
359
DT_DISKLESS = "diskless"
360
DT_PLAIN = "plain"
361
DT_DRBD8 = "drbd"
362
DT_FILE = "file"
363

    
364
# the set of network-mirrored disk templates
365
DTS_NET_MIRROR = frozenset([DT_DRBD8])
366

    
367
# the set of non-lvm-based disk templates
368
DTS_NOT_LVM = frozenset([DT_DISKLESS, DT_FILE])
369

    
370
# the set of disk templates which can be grown
371
DTS_GROWABLE = frozenset([DT_PLAIN, DT_DRBD8, DT_FILE])
372

    
373
# the set of disk templates that allow adoption
374
DTS_MAY_ADOPT = frozenset([DT_PLAIN])
375

    
376
# logical disk types
377
LD_LV = "lvm"
378
LD_DRBD8 = "drbd8"
379
LD_FILE = "file"
380
LDS_BLOCK = frozenset([LD_LV, LD_DRBD8])
381

    
382
# drbd constants
383
DRBD_HMAC_ALG = "md5"
384
DRBD_NET_PROTOCOL = "C"
385
DRBD_BARRIERS = _autoconf.DRBD_BARRIERS
386

    
387
# file backend driver
388
FD_LOOP = "loop"
389
FD_BLKTAP = "blktap"
390

    
391
# the set of drbd-like disk types
392
LDS_DRBD = frozenset([LD_DRBD8])
393

    
394
# disk access mode
395
DISK_RDONLY = "ro"
396
DISK_RDWR = "rw"
397
DISK_ACCESS_SET = frozenset([DISK_RDONLY, DISK_RDWR])
398

    
399
# disk replacement mode
400
REPLACE_DISK_PRI = "replace_on_primary"    # replace disks on primary
401
REPLACE_DISK_SEC = "replace_on_secondary"  # replace disks on secondary
402
REPLACE_DISK_CHG = "replace_new_secondary" # change secondary node
403
REPLACE_DISK_AUTO = "replace_auto"
404
REPLACE_MODES = frozenset([
405
  REPLACE_DISK_PRI,
406
  REPLACE_DISK_SEC,
407
  REPLACE_DISK_CHG,
408
  REPLACE_DISK_AUTO,
409
  ])
410

    
411
# Instance export mode
412
EXPORT_MODE_LOCAL = "local"
413
EXPORT_MODE_REMOTE = "remote"
414
EXPORT_MODES = frozenset([
415
  EXPORT_MODE_LOCAL,
416
  EXPORT_MODE_REMOTE,
417
  ])
418

    
419
# lock recalculate mode
420
LOCKS_REPLACE = 'replace'
421
LOCKS_APPEND = 'append'
422

    
423
# instance creation modes
424
INSTANCE_CREATE = "create"
425
INSTANCE_IMPORT = "import"
426
INSTANCE_REMOTE_IMPORT = "remote-import"
427
INSTANCE_CREATE_MODES = frozenset([
428
  INSTANCE_CREATE,
429
  INSTANCE_IMPORT,
430
  INSTANCE_REMOTE_IMPORT,
431
  ])
432

    
433
# Remote import/export handshake message and version
434
RIE_VERSION = 0
435
RIE_HANDSHAKE = "Hi, I'm Ganeti"
436

    
437
# Remote import/export certificate validity in seconds
438
RIE_CERT_VALIDITY = 24 * 60 * 60
439

    
440
# Overall timeout for establishing connection
441
RIE_CONNECT_TIMEOUT = 180
442

    
443
# Export only: how long to wait per connection attempt (seconds)
444
RIE_CONNECT_ATTEMPT_TIMEOUT = 20
445

    
446
# Export only: number of attempts to connect
447
RIE_CONNECT_RETRIES = 10
448

    
449
#: Give child process up to 5 seconds to exit after sending a signal
450
CHILD_LINGER_TIMEOUT = 5.0
451

    
452
DISK_TEMPLATES = frozenset([DT_DISKLESS, DT_PLAIN,
453
                            DT_DRBD8, DT_FILE])
454

    
455
FILE_DRIVER = frozenset([FD_LOOP, FD_BLKTAP])
456

    
457
# import/export config options
458
INISECT_EXP = "export"
459
INISECT_INS = "instance"
460
INISECT_HYP = "hypervisor"
461
INISECT_BEP = "backend"
462
INISECT_OSP = "os"
463

    
464
# dynamic device modification
465
DDM_ADD = "add"
466
DDM_REMOVE = "remove"
467
DDMS_VALUES = frozenset([DDM_ADD, DDM_REMOVE])
468

    
469
# common exit codes
470
EXIT_SUCCESS = 0
471
EXIT_FAILURE = 1
472
EXIT_NOTCLUSTER = 5
473
EXIT_NOTMASTER = 11
474
EXIT_NODESETUP_ERROR = 12
475
EXIT_CONFIRMATION = 13 # need user confirmation
476

    
477
#: Exit code for query operations with unknown fields
478
EXIT_UNKNOWN_FIELD = 14
479

    
480
# tags
481
TAG_CLUSTER = "cluster"
482
TAG_NODE = "node"
483
TAG_INSTANCE = "instance"
484
VALID_TAG_TYPES = frozenset([
485
  TAG_CLUSTER,
486
  TAG_NODE,
487
  TAG_INSTANCE,
488
  ])
489
MAX_TAG_LEN = 128
490
MAX_TAGS_PER_OBJ = 4096
491

    
492
# others
493
DEFAULT_BRIDGE = "xen-br0"
494
SYNC_SPEED = 60 * 1024
495
IP4_ADDRESS_LOCALHOST = "127.0.0.1"
496
IP4_ADDRESS_ANY = "0.0.0.0"
497
IP6_ADDRESS_LOCALHOST = "::1"
498
IP6_ADDRESS_ANY = "::"
499
IP4_VERSION = 4
500
IP6_VERSION = 6
501
TCP_PING_TIMEOUT = 10
502
GANETI_RUNAS = "root"
503
DEFAULT_VG = "xenvg"
504
DEFAULT_DRBD_HELPER = "/bin/true"
505
MIN_VG_SIZE = 20480
506
DEFAULT_MAC_PREFIX = "aa:00:00"
507
LVM_STRIPECOUNT = _autoconf.LVM_STRIPECOUNT
508
# default maximum instance wait time, in seconds.
509
DEFAULT_SHUTDOWN_TIMEOUT = 120
510
NODE_MAX_CLOCK_SKEW = 150
511
# Time for an intra-cluster disk transfer to wait for a connection
512
DISK_TRANSFER_CONNECT_TIMEOUT = 60
513
# Disk index separator
514
DISK_SEPARATOR = _autoconf.DISK_SEPARATOR
515

    
516
# runparts results
517
(RUNPARTS_SKIP,
518
 RUNPARTS_RUN,
519
 RUNPARTS_ERR) = range(3)
520

    
521
RUNPARTS_STATUS = frozenset([RUNPARTS_SKIP, RUNPARTS_RUN, RUNPARTS_ERR])
522

    
523
# RPC constants
524
(RPC_ENCODING_NONE,
525
 RPC_ENCODING_ZLIB_BASE64) = range(2)
526

    
527
# os related constants
528
OS_SCRIPT_CREATE = 'create'
529
OS_SCRIPT_IMPORT = 'import'
530
OS_SCRIPT_EXPORT = 'export'
531
OS_SCRIPT_RENAME = 'rename'
532
OS_SCRIPT_VERIFY = 'verify'
533
OS_SCRIPTS = frozenset([OS_SCRIPT_CREATE, OS_SCRIPT_IMPORT,
534
                        OS_SCRIPT_EXPORT, OS_SCRIPT_RENAME,
535
                        OS_SCRIPT_VERIFY])
536

    
537
OS_API_FILE = 'ganeti_api_version'
538
OS_VARIANTS_FILE = 'variants.list'
539
OS_PARAMETERS_FILE = 'parameters.list'
540

    
541
OS_VALIDATE_PARAMETERS = 'parameters'
542
OS_VALIDATE_CALLS = frozenset([OS_VALIDATE_PARAMETERS])
543

    
544
# ssh constants
545
SSH_CONFIG_DIR = _autoconf.SSH_CONFIG_DIR
546
SSH_HOST_DSA_PRIV = SSH_CONFIG_DIR + "/ssh_host_dsa_key"
547
SSH_HOST_DSA_PUB = SSH_HOST_DSA_PRIV + ".pub"
548
SSH_HOST_RSA_PRIV = SSH_CONFIG_DIR + "/ssh_host_rsa_key"
549
SSH_HOST_RSA_PUB = SSH_HOST_RSA_PRIV + ".pub"
550
SSH = "ssh"
551
SCP = "scp"
552

    
553
# reboot types
554
INSTANCE_REBOOT_SOFT = "soft"
555
INSTANCE_REBOOT_HARD = "hard"
556
INSTANCE_REBOOT_FULL = "full"
557

    
558
REBOOT_TYPES = frozenset([INSTANCE_REBOOT_SOFT,
559
                          INSTANCE_REBOOT_HARD,
560
                          INSTANCE_REBOOT_FULL])
561

    
562
VTYPE_STRING = 'string'
563
VTYPE_MAYBE_STRING = "maybe-string"
564
VTYPE_BOOL = 'bool'
565
VTYPE_SIZE = 'size' # size, in MiBs
566
VTYPE_INT = 'int'
567
ENFORCEABLE_TYPES = frozenset([
568
                      VTYPE_STRING,
569
                      VTYPE_MAYBE_STRING,
570
                      VTYPE_BOOL,
571
                      VTYPE_SIZE,
572
                      VTYPE_INT,
573
                      ])
574

    
575
# HV parameter names (global namespace)
576
HV_BOOT_ORDER = "boot_order"
577
HV_CDROM_IMAGE_PATH = "cdrom_image_path"
578
HV_NIC_TYPE = "nic_type"
579
HV_DISK_TYPE = "disk_type"
580
HV_VNC_BIND_ADDRESS = "vnc_bind_address"
581
HV_VNC_PASSWORD_FILE = "vnc_password_file"
582
HV_VNC_TLS = "vnc_tls"
583
HV_VNC_X509 = "vnc_x509_path"
584
HV_VNC_X509_VERIFY = "vnc_x509_verify"
585
HV_ACPI = "acpi"
586
HV_PAE = "pae"
587
HV_USE_BOOTLOADER = "use_bootloader"
588
HV_BOOTLOADER_ARGS = "bootloader_args"
589
HV_BOOTLOADER_PATH = "bootloader_path"
590
HV_KERNEL_ARGS = "kernel_args"
591
HV_KERNEL_PATH = "kernel_path"
592
HV_INITRD_PATH = "initrd_path"
593
HV_ROOT_PATH = "root_path"
594
HV_SERIAL_CONSOLE = "serial_console"
595
HV_USB_MOUSE = "usb_mouse"
596
HV_DEVICE_MODEL = "device_model"
597
HV_INIT_SCRIPT = "init_script"
598
HV_MIGRATION_PORT = "migration_port"
599
HV_MIGRATION_BANDWIDTH = "migration_bandwidth"
600
HV_MIGRATION_DOWNTIME = "migration_downtime"
601
HV_MIGRATION_MODE = "migration_mode"
602
HV_USE_LOCALTIME = "use_localtime"
603
HV_DISK_CACHE = "disk_cache"
604
HV_SECURITY_MODEL = "security_model"
605
HV_SECURITY_DOMAIN = "security_domain"
606
HV_KVM_FLAG = "kvm_flag"
607
HV_VHOST_NET = "vhost_net"
608
HV_KVM_USE_CHROOT = "use_chroot"
609
HV_CPU_MASK = "cpu_mask"
610
HV_MEM_PATH = "mem_path"
611
HV_BLOCKDEV_PREFIX = "blockdev_prefix"
612

    
613
HVS_PARAMETER_TYPES = {
614
  HV_BOOT_ORDER: VTYPE_STRING,
615
  HV_CDROM_IMAGE_PATH: VTYPE_STRING,
616
  HV_NIC_TYPE: VTYPE_STRING,
617
  HV_DISK_TYPE: VTYPE_STRING,
618
  HV_VNC_PASSWORD_FILE: VTYPE_STRING,
619
  HV_VNC_BIND_ADDRESS: VTYPE_STRING,
620
  HV_VNC_TLS: VTYPE_BOOL,
621
  HV_VNC_X509: VTYPE_STRING,
622
  HV_VNC_X509_VERIFY: VTYPE_BOOL,
623
  HV_ACPI: VTYPE_BOOL,
624
  HV_PAE: VTYPE_BOOL,
625
  HV_USE_BOOTLOADER: VTYPE_BOOL,
626
  HV_BOOTLOADER_PATH: VTYPE_STRING,
627
  HV_BOOTLOADER_ARGS: VTYPE_STRING,
628
  HV_KERNEL_PATH: VTYPE_STRING,
629
  HV_KERNEL_ARGS: VTYPE_STRING,
630
  HV_INITRD_PATH: VTYPE_STRING,
631
  HV_ROOT_PATH: VTYPE_STRING,
632
  HV_SERIAL_CONSOLE: VTYPE_BOOL,
633
  HV_USB_MOUSE: VTYPE_STRING,
634
  HV_DEVICE_MODEL: VTYPE_STRING,
635
  HV_INIT_SCRIPT: VTYPE_STRING,
636
  HV_MIGRATION_PORT: VTYPE_INT,
637
  HV_MIGRATION_BANDWIDTH: VTYPE_INT,
638
  HV_MIGRATION_DOWNTIME: VTYPE_INT,
639
  HV_MIGRATION_MODE: VTYPE_STRING,
640
  HV_USE_LOCALTIME: VTYPE_BOOL,
641
  HV_DISK_CACHE: VTYPE_STRING,
642
  HV_SECURITY_MODEL: VTYPE_STRING,
643
  HV_SECURITY_DOMAIN: VTYPE_STRING,
644
  HV_KVM_FLAG: VTYPE_STRING,
645
  HV_VHOST_NET: VTYPE_BOOL,
646
  HV_KVM_USE_CHROOT: VTYPE_BOOL,
647
  HV_CPU_MASK: VTYPE_STRING,
648
  HV_MEM_PATH: VTYPE_STRING,
649
  HV_BLOCKDEV_PREFIX: VTYPE_STRING,
650
  }
651

    
652
HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
653

    
654
# BE parameter names
655
BE_MEMORY = "memory"
656
BE_VCPUS = "vcpus"
657
BE_AUTO_BALANCE = "auto_balance"
658

    
659
BES_PARAMETER_TYPES = {
660
    BE_MEMORY: VTYPE_SIZE,
661
    BE_VCPUS: VTYPE_INT,
662
    BE_AUTO_BALANCE: VTYPE_BOOL,
663
    }
664

    
665
BES_PARAMETERS = frozenset(BES_PARAMETER_TYPES.keys())
666

    
667
# Node parameter names
668
ND_OOB_PROGRAM = "oob_program"
669

    
670
NDS_PARAMETER_TYPES = {
671
    ND_OOB_PROGRAM: VTYPE_MAYBE_STRING,
672
    }
673

    
674
NDS_PARAMETERS = frozenset(NDS_PARAMETER_TYPES.keys())
675

    
676
# OOB supported commands
677
OOB_POWER_ON = "power-on"
678
OOB_POWER_OFF = "power-off"
679
OOB_POWER_CYCLE = "power-cycle"
680
OOB_POWER_STATUS = "power-status"
681
OOB_HEALTH = "health"
682

    
683
OOB_COMMANDS = frozenset([OOB_POWER_ON, OOB_POWER_OFF, OOB_POWER_CYCLE,
684
                          OOB_POWER_STATUS, OOB_HEALTH])
685

    
686
OOB_POWER_STATUS_POWERED = "powered"
687

    
688
OOB_TIMEOUT = 60 # 60 seconds
689

    
690
OOB_STATUS_OK = "OK"
691
OOB_STATUS_WARNING = "WARNING"
692
OOB_STATUS_CRITICAL = "CRITICAL"
693
OOB_STATUS_UNKNOWN = "UNKNOWN"
694

    
695
OOB_STATUSES = frozenset([
696
  OOB_STATUS_OK,
697
  OOB_STATUS_WARNING,
698
  OOB_STATUS_CRITICAL,
699
  OOB_STATUS_UNKNOWN,
700
  ])
701

    
702
# Instance Parameters Profile
703
PP_DEFAULT = "default"
704

    
705
NIC_MODE = "mode"
706
NIC_LINK = "link"
707

    
708
NIC_MODE_BRIDGED = "bridged"
709
NIC_MODE_ROUTED = "routed"
710

    
711
NIC_VALID_MODES = frozenset([NIC_MODE_BRIDGED, NIC_MODE_ROUTED])
712

    
713
NICS_PARAMETER_TYPES = {
714
    NIC_MODE: VTYPE_STRING,
715
    NIC_LINK: VTYPE_STRING,
716
    }
717

    
718
NICS_PARAMETERS = frozenset(NICS_PARAMETER_TYPES.keys())
719

    
720
IDISK_SIZE = "size"
721
IDISK_MODE = "mode"
722
IDISK_ADOPT = "adopt"
723
IDISK_VG = "vg"
724
IDISK_PARAMS_TYPES = {
725
  IDISK_SIZE: VTYPE_SIZE,
726
  IDISK_MODE: VTYPE_STRING,
727
  IDISK_ADOPT: VTYPE_STRING,
728
  IDISK_VG: VTYPE_STRING,
729
  }
730
IDISK_PARAMS = frozenset(IDISK_PARAMS_TYPES.keys())
731

    
732
INIC_MAC = "mac"
733
INIC_IP = "ip"
734
INIC_MODE = "mode"
735
INIC_LINK = "link"
736
INIC_BRIDGE = "bridge"
737
INIC_PARAMS_TYPES = {
738
  INIC_BRIDGE: VTYPE_STRING,
739
  INIC_IP: VTYPE_MAYBE_STRING,
740
  INIC_LINK: VTYPE_STRING,
741
  INIC_MAC: VTYPE_STRING,
742
  INIC_MODE: VTYPE_STRING,
743
  }
744
INIC_PARAMS = frozenset(INIC_PARAMS_TYPES.keys())
745

    
746
# Hypervisor constants
747
HT_XEN_PVM = "xen-pvm"
748
HT_FAKE = "fake"
749
HT_XEN_HVM = "xen-hvm"
750
HT_KVM = "kvm"
751
HT_CHROOT = "chroot"
752
HT_LXC = "lxc"
753
HYPER_TYPES = frozenset([
754
  HT_XEN_PVM,
755
  HT_FAKE,
756
  HT_XEN_HVM,
757
  HT_KVM,
758
  HT_CHROOT,
759
  HT_LXC,
760
  ])
761
HTS_REQ_PORT = frozenset([HT_XEN_HVM, HT_KVM])
762

    
763
VNC_BASE_PORT = 5900
764
VNC_PASSWORD_FILE = CONF_DIR + "/vnc-cluster-password"
765
VNC_DEFAULT_BIND_ADDRESS = IP4_ADDRESS_ANY
766

    
767
# NIC types
768
HT_NIC_RTL8139 = "rtl8139"
769
HT_NIC_NE2K_PCI = "ne2k_pci"
770
HT_NIC_NE2K_ISA = "ne2k_isa"
771
HT_NIC_I82551 = "i82551"
772
HT_NIC_I85557B = "i82557b"
773
HT_NIC_I8259ER = "i82559er"
774
HT_NIC_PCNET = "pcnet"
775
HT_NIC_E1000 = "e1000"
776
HT_NIC_PARAVIRTUAL = HT_DISK_PARAVIRTUAL = "paravirtual"
777

    
778
HT_HVM_VALID_NIC_TYPES = frozenset([HT_NIC_RTL8139, HT_NIC_NE2K_PCI,
779
                                    HT_NIC_E1000, HT_NIC_NE2K_ISA,
780
                                    HT_NIC_PARAVIRTUAL])
781
HT_KVM_VALID_NIC_TYPES = frozenset([HT_NIC_RTL8139, HT_NIC_NE2K_PCI,
782
                                    HT_NIC_NE2K_ISA, HT_NIC_I82551,
783
                                    HT_NIC_I85557B, HT_NIC_I8259ER,
784
                                    HT_NIC_PCNET, HT_NIC_E1000,
785
                                    HT_NIC_PARAVIRTUAL])
786
# Disk types
787
HT_DISK_IOEMU = "ioemu"
788
HT_DISK_IDE = "ide"
789
HT_DISK_SCSI = "scsi"
790
HT_DISK_SD = "sd"
791
HT_DISK_MTD = "mtd"
792
HT_DISK_PFLASH = "pflash"
793

    
794
HT_CACHE_DEFAULT = "default"
795
HT_CACHE_NONE = "none"
796
HT_CACHE_WTHROUGH = "writethrough"
797
HT_CACHE_WBACK = "writeback"
798
HT_VALID_CACHE_TYPES = frozenset([HT_CACHE_DEFAULT,
799
                                  HT_CACHE_NONE,
800
                                  HT_CACHE_WTHROUGH,
801
                                  HT_CACHE_WBACK])
802

    
803
HT_HVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IOEMU])
804
HT_KVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IDE,
805
                                     HT_DISK_SCSI, HT_DISK_SD, HT_DISK_MTD,
806
                                     HT_DISK_PFLASH])
807

    
808
# Mouse types:
809
HT_MOUSE_MOUSE = "mouse"
810
HT_MOUSE_TABLET = "tablet"
811

    
812
HT_KVM_VALID_MOUSE_TYPES = frozenset([HT_MOUSE_MOUSE, HT_MOUSE_TABLET])
813

    
814
# Boot order
815
HT_BO_CDROM = "cdrom"
816
HT_BO_DISK = "disk"
817
HT_BO_NETWORK = "network"
818

    
819
HT_KVM_VALID_BO_TYPES = frozenset([HT_BO_CDROM, HT_BO_DISK, HT_BO_NETWORK])
820

    
821
# Security models
822
HT_SM_NONE = "none"
823
HT_SM_USER = "user"
824
HT_SM_POOL = "pool"
825

    
826
HT_KVM_VALID_SM_TYPES = frozenset([HT_SM_NONE, HT_SM_USER, HT_SM_POOL])
827

    
828
# Kvm flag values
829
HT_KVM_ENABLED = "enabled"
830
HT_KVM_DISABLED = "disabled"
831

    
832
HT_KVM_FLAG_VALUES = frozenset([HT_KVM_ENABLED, HT_KVM_DISABLED])
833

    
834
# Migration type
835
HT_MIGRATION_LIVE = "live"
836
HT_MIGRATION_NONLIVE = "non-live"
837
HT_MIGRATION_MODES = frozenset([HT_MIGRATION_LIVE, HT_MIGRATION_NONLIVE])
838

    
839
# Cluster Verify steps
840
VERIFY_NPLUSONE_MEM = 'nplusone_mem'
841
VERIFY_OPTIONAL_CHECKS = frozenset([VERIFY_NPLUSONE_MEM])
842

    
843
# Node verify constants
844
NV_DRBDHELPER = "drbd-helper"
845
NV_DRBDLIST = "drbd-list"
846
NV_FILELIST = "filelist"
847
NV_HVINFO = "hvinfo"
848
NV_HYPERVISOR = "hypervisor"
849
NV_HVPARAMS = "hvparms"
850
NV_INSTANCELIST = "instancelist"
851
NV_LVLIST = "lvlist"
852
NV_MASTERIP = "master-ip"
853
NV_NODELIST = "nodelist"
854
NV_NODENETTEST = "node-net-test"
855
NV_NODESETUP = "nodesetup"
856
NV_OSLIST = "oslist"
857
NV_PVLIST = "pvlist"
858
NV_TIME = "time"
859
NV_VERSION = "version"
860
NV_VGLIST = "vglist"
861
NV_VMNODES = "vmnodes"
862
NV_OOB_PATHS = "oob-paths"
863

    
864
# Instance status
865
INSTST_RUNNING = "running"
866
INSTST_ADMINDOWN = "ADMIN_down"
867
INSTST_NODEOFFLINE = "ERROR_nodeoffline"
868
INSTST_NODEDOWN = "ERROR_nodedown"
869
INSTST_WRONGNODE = "ERROR_wrongnode"
870
INSTST_ERRORUP = "ERROR_up"
871
INSTST_ERRORDOWN = "ERROR_down"
872
INSTST_ALL = frozenset([
873
  INSTST_RUNNING,
874
  INSTST_ADMINDOWN,
875
  INSTST_NODEOFFLINE,
876
  INSTST_NODEDOWN,
877
  INSTST_WRONGNODE,
878
  INSTST_ERRORUP,
879
  INSTST_ERRORDOWN,
880
  ])
881

    
882
# SSL certificate check constants (in days)
883
SSL_CERT_EXPIRATION_WARN = 30
884
SSL_CERT_EXPIRATION_ERROR = 7
885

    
886
# Allocator framework constants
887
IALLOCATOR_VERSION = 2
888
IALLOCATOR_DIR_IN = "in"
889
IALLOCATOR_DIR_OUT = "out"
890
VALID_IALLOCATOR_DIRECTIONS = frozenset([
891
  IALLOCATOR_DIR_IN,
892
  IALLOCATOR_DIR_OUT,
893
  ])
894
IALLOCATOR_MODE_ALLOC = "allocate"
895
IALLOCATOR_MODE_RELOC = "relocate"
896
IALLOCATOR_MODE_MEVAC = "multi-evacuate"
897
VALID_IALLOCATOR_MODES = frozenset([
898
  IALLOCATOR_MODE_ALLOC,
899
  IALLOCATOR_MODE_RELOC,
900
  IALLOCATOR_MODE_MEVAC,
901
  ])
902
IALLOCATOR_SEARCH_PATH = _autoconf.IALLOCATOR_SEARCH_PATH
903

    
904
# Job queue
905
JOB_QUEUE_VERSION = 1
906
JOB_QUEUE_LOCK_FILE = QUEUE_DIR + "/lock"
907
JOB_QUEUE_VERSION_FILE = QUEUE_DIR + "/version"
908
JOB_QUEUE_SERIAL_FILE = QUEUE_DIR + "/serial"
909
JOB_QUEUE_ARCHIVE_DIR = QUEUE_DIR + "/archive"
910
JOB_QUEUE_DRAIN_FILE = QUEUE_DIR + "/drain"
911
JOB_QUEUE_SIZE_HARD_LIMIT = 5000
912
JOB_QUEUE_DIRS = [QUEUE_DIR, JOB_QUEUE_ARCHIVE_DIR]
913
JOB_QUEUE_DIRS_MODE = SECURE_DIR_MODE
914

    
915
JOB_ID_TEMPLATE = r"\d+"
916

    
917
# unchanged job return
918
JOB_NOTCHANGED = "nochange"
919

    
920
# Job status
921
JOB_STATUS_QUEUED = "queued"
922
JOB_STATUS_WAITLOCK = "waiting"
923
JOB_STATUS_CANCELING = "canceling"
924
JOB_STATUS_RUNNING = "running"
925
JOB_STATUS_CANCELED = "canceled"
926
JOB_STATUS_SUCCESS = "success"
927
JOB_STATUS_ERROR = "error"
928
JOBS_FINALIZED = frozenset([
929
  JOB_STATUS_CANCELED,
930
  JOB_STATUS_SUCCESS,
931
  JOB_STATUS_ERROR,
932
  ])
933
JOB_STATUS_ALL = frozenset([
934
  JOB_STATUS_QUEUED,
935
  JOB_STATUS_WAITLOCK,
936
  JOB_STATUS_CANCELING,
937
  JOB_STATUS_RUNNING,
938
  ]) | JOBS_FINALIZED
939

    
940
# OpCode status
941
# not yet finalized
942
OP_STATUS_QUEUED = "queued"
943
OP_STATUS_WAITLOCK = "waiting"
944
OP_STATUS_CANCELING = "canceling"
945
OP_STATUS_RUNNING = "running"
946
# finalized
947
OP_STATUS_CANCELED = "canceled"
948
OP_STATUS_SUCCESS = "success"
949
OP_STATUS_ERROR = "error"
950
OPS_FINALIZED = frozenset([OP_STATUS_CANCELED,
951
                           OP_STATUS_SUCCESS,
952
                           OP_STATUS_ERROR])
953

    
954
# OpCode priority
955
OP_PRIO_LOWEST = +19
956
OP_PRIO_HIGHEST = -20
957

    
958
OP_PRIO_LOW = +10
959
OP_PRIO_NORMAL = 0
960
OP_PRIO_HIGH = -10
961

    
962
OP_PRIO_SUBMIT_VALID = frozenset([
963
  OP_PRIO_LOW,
964
  OP_PRIO_NORMAL,
965
  OP_PRIO_HIGH,
966
  ])
967

    
968
OP_PRIO_DEFAULT = OP_PRIO_NORMAL
969

    
970
# Execution log types
971
ELOG_MESSAGE = "message"
972
ELOG_PROGRESS = "progress"
973
ELOG_REMOTE_IMPORT = "remote-import"
974
ELOG_JQUEUE_TEST = "jqueue-test"
975

    
976
# /etc/hosts modification
977
ETC_HOSTS_ADD = "add"
978
ETC_HOSTS_REMOVE = "remove"
979

    
980
# Job queue test
981
JQT_MSGPREFIX = "TESTMSG="
982
JQT_EXPANDNAMES = "expandnames"
983
JQT_EXEC = "exec"
984
JQT_LOGMSG = "logmsg"
985
JQT_STARTMSG = "startmsg"
986
JQT_ALL = frozenset([
987
  JQT_EXPANDNAMES,
988
  JQT_EXEC,
989
  JQT_LOGMSG,
990
  JQT_STARTMSG,
991
  ])
992

    
993
# Query resources
994
QR_INSTANCE = "instance"
995
QR_NODE = "node"
996
QR_LOCK = "lock"
997
QR_GROUP = "group"
998

    
999
#: List of resources which can be queried using L{opcodes.OpQuery}
1000
QR_OP_QUERY = frozenset([QR_INSTANCE, QR_NODE, QR_GROUP])
1001

    
1002
#: List of resources which can be queried using LUXI
1003
QR_OP_LUXI = QR_OP_QUERY.union([
1004
  QR_LOCK,
1005
  ])
1006

    
1007
# Query field types
1008
QFT_UNKNOWN = "unknown"
1009
QFT_TEXT = "text"
1010
QFT_BOOL = "bool"
1011
QFT_NUMBER = "number"
1012
QFT_UNIT = "unit"
1013
QFT_TIMESTAMP = "timestamp"
1014
QFT_OTHER = "other"
1015

    
1016
#: All query field types
1017
QFT_ALL = frozenset([
1018
  QFT_UNKNOWN,
1019
  QFT_TEXT,
1020
  QFT_BOOL,
1021
  QFT_NUMBER,
1022
  QFT_UNIT,
1023
  QFT_TIMESTAMP,
1024
  QFT_OTHER,
1025
  ])
1026

    
1027
# Query result field status (don't change or reuse values as they're used by
1028
# clients)
1029
#: Normal field status
1030
RS_NORMAL = 0
1031
#: Unknown field
1032
RS_UNKNOWN = 1
1033
#: No data (e.g. RPC error), can be used instead of L{RS_OFFLINE}
1034
RS_NODATA = 2
1035
#: Value unavailable/unsupported for item; if this field is supported
1036
#: but we cannot get the data for the moment, RS_NODATA or
1037
#: RS_OFFLINE should be used
1038
RS_UNAVAIL = 3
1039
#: Resource marked offline
1040
RS_OFFLINE = 4
1041

    
1042
RS_ALL = frozenset([
1043
  RS_NORMAL,
1044
  RS_UNKNOWN,
1045
  RS_NODATA,
1046
  RS_UNAVAIL,
1047
  RS_OFFLINE,
1048
  ])
1049

    
1050
#: Dictionary with special field cases and their verbose/terse formatting
1051
RSS_DESCRIPTION = {
1052
  RS_UNKNOWN: ("(unknown)", "??"),
1053
  RS_NODATA:  ("(nodata)",  "?"),
1054
  RS_OFFLINE: ("(offline)", "*"),
1055
  RS_UNAVAIL: ("(unavail)", "-"),
1056
  }
1057

    
1058
# max dynamic devices
1059
MAX_NICS = 8
1060
MAX_DISKS = 16
1061

    
1062
# SSCONF keys
1063
SS_CLUSTER_NAME = "cluster_name"
1064
SS_CLUSTER_TAGS = "cluster_tags"
1065
SS_FILE_STORAGE_DIR = "file_storage_dir"
1066
SS_MASTER_CANDIDATES = "master_candidates"
1067
SS_MASTER_CANDIDATES_IPS = "master_candidates_ips"
1068
SS_MASTER_IP = "master_ip"
1069
SS_MASTER_NETDEV = "master_netdev"
1070
SS_MASTER_NODE = "master_node"
1071
SS_NODE_LIST = "node_list"
1072
SS_NODE_PRIMARY_IPS = "node_primary_ips"
1073
SS_NODE_SECONDARY_IPS = "node_secondary_ips"
1074
SS_OFFLINE_NODES = "offline_nodes"
1075
SS_ONLINE_NODES = "online_nodes"
1076
SS_PRIMARY_IP_FAMILY = "primary_ip_family"
1077
SS_INSTANCE_LIST = "instance_list"
1078
SS_RELEASE_VERSION = "release_version"
1079
SS_HYPERVISOR_LIST = "hypervisor_list"
1080
SS_MAINTAIN_NODE_HEALTH = "maintain_node_health"
1081
SS_UID_POOL = "uid_pool"
1082
SS_NODEGROUPS = "nodegroups"
1083

    
1084
# cluster wide default parameters
1085
DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM
1086

    
1087
HVC_DEFAULTS = {
1088
  HT_XEN_PVM: {
1089
    HV_USE_BOOTLOADER: False,
1090
    HV_BOOTLOADER_PATH: XEN_BOOTLOADER,
1091
    HV_BOOTLOADER_ARGS: '',
1092
    HV_KERNEL_PATH: "/boot/vmlinuz-2.6-xenU",
1093
    HV_INITRD_PATH: '',
1094
    HV_ROOT_PATH: '/dev/sda1',
1095
    HV_KERNEL_ARGS: 'ro',
1096
    HV_MIGRATION_PORT: 8002,
1097
    HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1098
    HV_BLOCKDEV_PREFIX: "sd",
1099
    },
1100
  HT_XEN_HVM: {
1101
    HV_BOOT_ORDER: "cd",
1102
    HV_CDROM_IMAGE_PATH: '',
1103
    HV_NIC_TYPE: HT_NIC_RTL8139,
1104
    HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
1105
    HV_VNC_BIND_ADDRESS: IP4_ADDRESS_ANY,
1106
    HV_VNC_PASSWORD_FILE: VNC_PASSWORD_FILE,
1107
    HV_ACPI: True,
1108
    HV_PAE: True,
1109
    HV_KERNEL_PATH: "/usr/lib/xen/boot/hvmloader",
1110
    HV_DEVICE_MODEL: "/usr/lib/xen/bin/qemu-dm",
1111
    HV_MIGRATION_PORT: 8002,
1112
    HV_MIGRATION_MODE: HT_MIGRATION_NONLIVE,
1113
    HV_USE_LOCALTIME: False,
1114
    HV_BLOCKDEV_PREFIX: "hd",
1115
    },
1116
  HT_KVM: {
1117
    HV_KERNEL_PATH: "/boot/vmlinuz-2.6-kvmU",
1118
    HV_INITRD_PATH: '',
1119
    HV_KERNEL_ARGS: 'ro',
1120
    HV_ROOT_PATH: '/dev/vda1',
1121
    HV_ACPI: True,
1122
    HV_SERIAL_CONSOLE: True,
1123
    HV_VNC_BIND_ADDRESS: '',
1124
    HV_VNC_TLS: False,
1125
    HV_VNC_X509: '',
1126
    HV_VNC_X509_VERIFY: False,
1127
    HV_VNC_PASSWORD_FILE: '',
1128
    HV_CDROM_IMAGE_PATH: '',
1129
    HV_BOOT_ORDER: HT_BO_DISK,
1130
    HV_NIC_TYPE: HT_NIC_PARAVIRTUAL,
1131
    HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
1132
    HV_USB_MOUSE: '',
1133
    HV_MIGRATION_PORT: 8102,
1134
    HV_MIGRATION_BANDWIDTH: 32, # MiB/s
1135
    HV_MIGRATION_DOWNTIME: 30,  # ms
1136
    HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1137
    HV_USE_LOCALTIME: False,
1138
    HV_DISK_CACHE: HT_CACHE_DEFAULT,
1139
    HV_SECURITY_MODEL: HT_SM_NONE,
1140
    HV_SECURITY_DOMAIN: '',
1141
    HV_KVM_FLAG: "",
1142
    HV_VHOST_NET: False,
1143
    HV_KVM_USE_CHROOT: False,
1144
    HV_MEM_PATH: "",
1145
    },
1146
  HT_FAKE: {
1147
    },
1148
  HT_CHROOT: {
1149
    HV_INIT_SCRIPT: "/ganeti-chroot",
1150
    },
1151
  HT_LXC: {
1152
    HV_CPU_MASK: "",
1153
    },
1154
  }
1155

    
1156
HVC_GLOBALS = frozenset([
1157
  HV_MIGRATION_PORT,
1158
  HV_MIGRATION_BANDWIDTH,
1159
  HV_MIGRATION_MODE,
1160
  ])
1161

    
1162
BEC_DEFAULTS = {
1163
  BE_MEMORY: 128,
1164
  BE_VCPUS: 1,
1165
  BE_AUTO_BALANCE: True,
1166
  }
1167

    
1168
NDC_DEFAULTS = {
1169
  ND_OOB_PROGRAM: None,
1170
  }
1171

    
1172
NICC_DEFAULTS = {
1173
  NIC_MODE: NIC_MODE_BRIDGED,
1174
  NIC_LINK: DEFAULT_BRIDGE,
1175
  }
1176

    
1177
MASTER_POOL_SIZE_DEFAULT = 10
1178

    
1179
CONFD_PROTOCOL_VERSION = 1
1180

    
1181
CONFD_REQ_PING = 0
1182
CONFD_REQ_NODE_ROLE_BYNAME = 1
1183
CONFD_REQ_NODE_PIP_BY_INSTANCE_IP = 2
1184
CONFD_REQ_CLUSTER_MASTER = 3
1185
CONFD_REQ_NODE_PIP_LIST = 4
1186
CONFD_REQ_MC_PIP_LIST = 5
1187
CONFD_REQ_INSTANCES_IPS_LIST = 6
1188

    
1189
# Confd request query fields. These are used to narrow down queries.
1190
# These must be strings rather than integers, because json-encoding
1191
# converts them to strings anyway, as they're used as dict-keys.
1192
CONFD_REQQ_LINK = "0"
1193
CONFD_REQQ_IP = "1"
1194
CONFD_REQQ_IPLIST = "2"
1195
CONFD_REQQ_FIELDS = "3"
1196

    
1197
CONFD_REQFIELD_NAME = "0"
1198
CONFD_REQFIELD_IP = "1"
1199
CONFD_REQFIELD_MNODE_PIP = "2"
1200

    
1201
CONFD_REQS = frozenset([
1202
  CONFD_REQ_PING,
1203
  CONFD_REQ_NODE_ROLE_BYNAME,
1204
  CONFD_REQ_NODE_PIP_BY_INSTANCE_IP,
1205
  CONFD_REQ_CLUSTER_MASTER,
1206
  CONFD_REQ_NODE_PIP_LIST,
1207
  CONFD_REQ_MC_PIP_LIST,
1208
  CONFD_REQ_INSTANCES_IPS_LIST,
1209
  ])
1210

    
1211
CONFD_REPL_STATUS_OK = 0
1212
CONFD_REPL_STATUS_ERROR = 1
1213
CONFD_REPL_STATUS_NOTIMPLEMENTED = 2
1214

    
1215
CONFD_REPL_STATUSES = frozenset([
1216
  CONFD_REPL_STATUS_OK,
1217
  CONFD_REPL_STATUS_ERROR,
1218
  CONFD_REPL_STATUS_NOTIMPLEMENTED,
1219
  ])
1220

    
1221
(CONFD_NODE_ROLE_MASTER,
1222
 CONFD_NODE_ROLE_CANDIDATE,
1223
 CONFD_NODE_ROLE_OFFLINE,
1224
 CONFD_NODE_ROLE_DRAINED,
1225
 CONFD_NODE_ROLE_REGULAR,
1226
 ) = range(5)
1227

    
1228
# A few common errors for confd
1229
CONFD_ERROR_UNKNOWN_ENTRY = 1
1230
CONFD_ERROR_INTERNAL = 2
1231
CONFD_ERROR_ARGUMENT = 3
1232

    
1233
# Each request is "salted" by the current timestamp.
1234
# This constants decides how many seconds of skew to accept.
1235
# TODO: make this a default and allow the value to be more configurable
1236
CONFD_MAX_CLOCK_SKEW = 2 * NODE_MAX_CLOCK_SKEW
1237

    
1238
# When we haven't reloaded the config for more than this amount of seconds, we
1239
# force a test to see if inotify is betraying us.
1240
CONFD_CONFIG_RELOAD_TIMEOUT = 60
1241

    
1242
# If we receive more than one update in this amount of seconds, we move to
1243
# polling every RATELIMIT seconds, rather than relying on inotify, to be able
1244
# to serve more requests.
1245
CONFD_CONFIG_RELOAD_RATELIMIT = 2
1246

    
1247
# Magic number prepended to all confd queries.
1248
# This allows us to distinguish different types of confd protocols and handle
1249
# them. For example by changing this we can move the whole payload to be
1250
# compressed, or move away from json.
1251
CONFD_MAGIC_FOURCC = 'plj0'
1252

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

    
1258
# Timeout in seconds to expire pending query request in the confd client
1259
# library. We don't actually expect any answer more than 10 seconds after we
1260
# sent a request.
1261
CONFD_CLIENT_EXPIRE_TIMEOUT = 10
1262

    
1263
# Maximum UDP datagram size.
1264
# On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
1265
# On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
1266
#   (assuming we can't use jumbo frames)
1267
# We just set this to 60K, which should be enough
1268
MAX_UDP_DATA_SIZE = 61440
1269

    
1270
# User-id pool minimum/maximum acceptable user-ids.
1271
UIDPOOL_UID_MIN = 0
1272
UIDPOOL_UID_MAX = 2**32-1 # Assuming 32 bit user-ids
1273

    
1274
# Name or path of the pgrep command
1275
PGREP = "pgrep"
1276

    
1277
# Name of the node group that gets created at cluster init or upgrade
1278
INITIAL_NODE_GROUP_NAME = "default"
1279

    
1280
# Possible values for NodeGroup.alloc_policy
1281
ALLOC_POLICY_PREFERRED = "preferred"
1282
ALLOC_POLICY_LAST_RESORT = "last_resort"
1283
ALLOC_POLICY_UNALLOCABLE = "unallocable"
1284
VALID_ALLOC_POLICIES = [
1285
  ALLOC_POLICY_PREFERRED,
1286
  ALLOC_POLICY_LAST_RESORT,
1287
  ALLOC_POLICY_UNALLOCABLE,
1288
  ]