Statistics
| Branch: | Tag: | Revision:

root / lib / constants.py @ 59bcd180

History | View | Annotate | Download (63.9 kB)

1
#
2
#
3

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

    
27
from ganeti import _constants
28
from ganeti import _vcsversion
29
from ganeti import compat
30
from ganeti import pathutils
31

    
32

    
33
# various versions
34
RELEASE_VERSION = _constants.RELEASE_VERSION
35
OS_API_V10 = _constants.OS_API_V10
36
OS_API_V15 = _constants.OS_API_V15
37
OS_API_V20 = _constants.OS_API_V20
38
OS_API_VERSIONS = _constants.OS_API_VERSIONS
39
VCS_VERSION = _vcsversion.VCS_VERSION
40
EXPORT_VERSION = 0
41
RAPI_VERSION = 2
42

    
43
VERSION_MAJOR = _constants.VERSION_MAJOR
44
VERSION_MINOR = _constants.VERSION_MINOR
45
VERSION_REVISION = _constants.VERSION_REVISION
46

    
47
DIR_VERSION = _constants.DIR_VERSION
48

    
49
CONFIG_MAJOR = _constants.CONFIG_MAJOR
50
CONFIG_MINOR = _constants.CONFIG_MINOR
51
CONFIG_REVISION = _constants.CONFIG_REVISION
52
CONFIG_VERSION = _constants.CONFIG_VERSION
53

    
54
#: RPC protocol version
55
PROTOCOL_VERSION = _constants.PROTOCOL_VERSION
56

    
57
# user separation
58
DAEMONS_GROUP = _constants.DAEMONS_GROUP
59
ADMIN_GROUP = _constants.ADMIN_GROUP
60
MASTERD_USER = _constants.MASTERD_USER
61
MASTERD_GROUP = _constants.MASTERD_GROUP
62
RAPI_USER = _constants.RAPI_USER
63
RAPI_GROUP = _constants.RAPI_GROUP
64
CONFD_USER = _constants.CONFD_USER
65
CONFD_GROUP = _constants.CONFD_GROUP
66
LUXID_USER = _constants.LUXID_USER
67
LUXID_GROUP = _constants.LUXID_GROUP
68
NODED_USER = _constants.NODED_USER
69
NODED_GROUP = _constants.NODED_GROUP
70
MOND_USER = _constants.MOND_USER
71
MOND_GROUP = _constants.MOND_GROUP
72
SSH_LOGIN_USER = _constants.SSH_LOGIN_USER
73
SSH_CONSOLE_USER = _constants.SSH_CONSOLE_USER
74

    
75
# cpu pinning separators and constants
76
CPU_PINNING_SEP = ":"
77
CPU_PINNING_ALL = "all"
78
# internal representation of "all"
79
CPU_PINNING_ALL_VAL = -1
80
# one "all" entry in a CPU list means CPU pinning is off
81
CPU_PINNING_OFF = [CPU_PINNING_ALL_VAL]
82

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

    
92
# A KVM-specific implementation detail - the following value is used
93
# to set CPU affinity to all processors (#0 through #31), per taskset
94
# man page.
95
# FIXME: This only works for machines with up to 32 CPU cores
96
CPU_PINNING_ALL_KVM = 0xFFFFFFFF
97

    
98
# Wipe
99
DD_CMD = _constants.DD_CMD
100
MAX_WIPE_CHUNK = _constants.MAX_WIPE_CHUNK
101
MIN_WIPE_CHUNK_PERCENT = _constants.MIN_WIPE_CHUNK_PERCENT
102

    
103
RUN_DIRS_MODE = _constants.RUN_DIRS_MODE
104
SECURE_DIR_MODE = _constants.SECURE_DIR_MODE
105
SECURE_FILE_MODE = _constants.SECURE_FILE_MODE
106
ADOPTABLE_BLOCKDEV_ROOT = _constants.ADOPTABLE_BLOCKDEV_ROOT
107
ENABLE_CONFD = _constants.ENABLE_CONFD
108
ENABLE_MOND = _constants.ENABLE_MOND
109
ENABLE_SPLIT_QUERY = _constants.ENABLE_SPLIT_QUERY
110
ENABLE_RESTRICTED_COMMANDS = _constants.ENABLE_RESTRICTED_COMMANDS
111

    
112
# SSH constants
113
SSH = _constants.SSH
114
SCP = _constants.SCP
115

    
116
NODED = _constants.NODED
117
CONFD = _constants.CONFD
118
LUXID = _constants.LUXID
119
RAPI = _constants.RAPI
120
MASTERD = _constants.MASTERD
121
MOND = _constants.MOND
122

    
123
DAEMONS = _constants.DAEMONS
124

    
125
DAEMONS_PORTS = _constants.DAEMONS_PORTS
126

    
127
DEFAULT_NODED_PORT = _constants.DEFAULT_NODED_PORT
128
DEFAULT_CONFD_PORT = _constants.DEFAULT_CONFD_PORT
129
DEFAULT_MOND_PORT = _constants.DEFAULT_MOND_PORT
130
DEFAULT_RAPI_PORT = _constants.DEFAULT_RAPI_PORT
131

    
132
FIRST_DRBD_PORT = _constants.FIRST_DRBD_PORT
133
LAST_DRBD_PORT = _constants.LAST_DRBD_PORT
134

    
135
DAEMONS_LOGBASE = _constants.DAEMONS_LOGBASE
136

    
137
DAEMONS_LOGFILES = \
138
    dict((daemon, pathutils.GetLogFilename(DAEMONS_LOGBASE[daemon]))
139
         for daemon in DAEMONS_LOGBASE)
140

    
141
# Some daemons might require more than one logfile.
142
# Specifically, right now only the Haskell http library "snap", used by the
143
# monitoring daemon, requires multiple log files.
144

    
145
# These are the only valid reasons for having an extra logfile
146
EXTRA_LOGREASON_ACCESS = "access"
147
EXTRA_LOGREASON_ERROR = "error"
148

    
149
VALID_EXTRA_LOGREASONS = compat.UniqueFrozenset([
150
  EXTRA_LOGREASON_ACCESS,
151
  EXTRA_LOGREASON_ERROR,
152
  ])
153

    
154
# These are the extra logfiles, grouped by daemon
155
DAEMONS_EXTRA_LOGBASE = {
156
  MOND: {
157
    EXTRA_LOGREASON_ACCESS: _constants.EXTRA_LOGREASON_ACCESS,
158
    EXTRA_LOGREASON_ERROR: _constants.EXTRA_LOGREASON_ERROR,
159
    }
160
  }
161

    
162
DAEMONS_EXTRA_LOGFILES = \
163
  dict((daemon, dict((extra,
164
       pathutils.GetLogFilename(DAEMONS_EXTRA_LOGBASE[daemon][extra]))
165
       for extra in DAEMONS_EXTRA_LOGBASE[daemon]))
166
         for daemon in DAEMONS_EXTRA_LOGBASE)
167

    
168
DEV_CONSOLE = _constants.DEV_CONSOLE
169

    
170
PROC_MOUNTS = "/proc/mounts"
171

    
172
# Local UniX Interface related constants
173
LUXI_EOM = chr(3)
174
LUXI_VERSION = CONFIG_VERSION
175
#: Environment variable for the luxi override socket
176
LUXI_OVERRIDE = "FORCE_LUXI_SOCKET"
177
LUXI_OVERRIDE_MASTER = "master"
178
LUXI_OVERRIDE_QUERY = "query"
179

    
180
# one of "no", "yes", "only"
181
SYSLOG_USAGE = _constants.SYSLOG_USAGE
182
SYSLOG_NO = _constants.SYSLOG_NO
183
SYSLOG_YES = _constants.SYSLOG_YES
184
SYSLOG_ONLY = _constants.SYSLOG_ONLY
185
SYSLOG_SOCKET = _constants.SYSLOG_SOCKET
186

    
187
EXPORT_CONF_FILE = "config.ini"
188

    
189
XEN_BOOTLOADER = _constants.XEN_BOOTLOADER
190
XEN_KERNEL = _constants.XEN_KERNEL
191
XEN_INITRD = _constants.XEN_INITRD
192
XEN_CMD_XM = _constants.XEN_CMD_XM
193
XEN_CMD_XL = _constants.XEN_CMD_XL
194
KNOWN_XEN_COMMANDS = _constants.KNOWN_XEN_COMMANDS
195

    
196
# When the Xen toolstack used is "xl", live migration requires the source host
197
# to connect to the target host via ssh (xl runs this command). We need to pass
198
# the command xl runs some extra info so that it can use Ganeti's key
199
# verification and not fail. Note that this string is incomplete: it must be
200
# filled with the cluster name before being used.
201
XL_SSH_CMD = ("ssh -l %s -oGlobalKnownHostsFile=%s"
202
              " -oUserKnownHostsFile=/dev/null"
203
              " -oCheckHostIp=no -oStrictHostKeyChecking=yes"
204
              " -oHostKeyAlias=%%s") % (SSH_LOGIN_USER,
205
                                        pathutils.SSH_KNOWN_HOSTS_FILE)
206

    
207
KVM_PATH = _constants.KVM_PATH
208
KVM_KERNEL = _constants.KVM_KERNEL
209
SOCAT_PATH = _constants.SOCAT_PATH
210
SOCAT_USE_ESCAPE = _constants.SOCAT_USE_ESCAPE
211
SOCAT_USE_COMPRESS = _constants.SOCAT_USE_COMPRESS
212
SOCAT_ESCAPE_CODE = "0x1d"
213

    
214
#: Console as SSH command
215
CONS_SSH = "ssh"
216

    
217
#: Console as VNC server
218
CONS_VNC = "vnc"
219

    
220
#: Console as SPICE server
221
CONS_SPICE = "spice"
222

    
223
#: Display a message for console access
224
CONS_MESSAGE = "msg"
225

    
226
#: All console types
227
CONS_ALL = compat.UniqueFrozenset([
228
  CONS_SSH,
229
  CONS_VNC,
230
  CONS_SPICE,
231
  CONS_MESSAGE,
232
  ])
233

    
234
# For RSA keys more bits are better, but they also make operations more
235
# expensive. NIST SP 800-131 recommends a minimum of 2048 bits from the year
236
# 2010 on.
237
RSA_KEY_BITS = 2048
238

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

    
247
# Digest used to sign certificates ("openssl x509" uses SHA1 by default)
248
X509_CERT_SIGN_DIGEST = "SHA1"
249

    
250
# Default validity of certificates in days
251
X509_CERT_DEFAULT_VALIDITY = 365 * 5
252

    
253
# commonName (CN) used in certificates
254
X509_CERT_CN = "ganeti.example.com"
255

    
256
X509_CERT_SIGNATURE_HEADER = "X-Ganeti-Signature"
257

    
258
# Import/export daemon mode
259
IEM_IMPORT = "import"
260
IEM_EXPORT = "export"
261

    
262
# Import/export transport compression
263
IEC_NONE = "none"
264
IEC_GZIP = "gzip"
265
IEC_ALL = compat.UniqueFrozenset([
266
  IEC_NONE,
267
  IEC_GZIP,
268
  ])
269

    
270
IE_CUSTOM_SIZE = "fd"
271

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

    
274
# Import/export I/O
275
# Direct file I/O, equivalent to a shell's I/O redirection using '<' or '>'
276
IEIO_FILE = "file"
277
# Raw block device I/O using "dd"
278
IEIO_RAW_DISK = "raw"
279
# OS definition import/export script
280
IEIO_SCRIPT = "script"
281

    
282
VALUE_DEFAULT = "default"
283
VALUE_AUTO = "auto"
284
VALUE_GENERATE = "generate"
285
VALUE_NONE = "none"
286
VALUE_TRUE = "true"
287
VALUE_FALSE = "false"
288
VALUE_HS_NOTHING = {"Nothing": None}
289

    
290

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

    
294
# hooks-related constants
295
HOOKS_PHASE_PRE = "pre"
296
HOOKS_PHASE_POST = "post"
297
HOOKS_NAME_CFGUPDATE = "config-update"
298
HOOKS_NAME_WATCHER = "watcher"
299
HOOKS_VERSION = 2
300
HOOKS_PATH = "/sbin:/bin:/usr/sbin:/usr/bin"
301

    
302
# hooks subject type (what object type does the LU deal with)
303
HTYPE_CLUSTER = "CLUSTER"
304
HTYPE_NODE = "NODE"
305
HTYPE_GROUP = "GROUP"
306
HTYPE_INSTANCE = "INSTANCE"
307
HTYPE_NETWORK = "NETWORK"
308

    
309
HKR_SKIP = 0
310
HKR_FAIL = 1
311
HKR_SUCCESS = 2
312

    
313
# Storage types
314
ST_BLOCK = _constants.ST_BLOCK
315
ST_DISKLESS = _constants.ST_DISKLESS
316
ST_EXT = _constants.ST_EXT
317
ST_FILE = _constants.ST_FILE
318
ST_LVM_PV = _constants.ST_LVM_PV
319
ST_LVM_VG = _constants.ST_LVM_VG
320
ST_RADOS = _constants.ST_RADOS
321
STORAGE_TYPES = _constants.STORAGE_TYPES
322

    
323
# the set of storage types for which storage reporting is available
324
# FIXME: Remove this, once storage reporting is available for all types.
325
STS_REPORT = compat.UniqueFrozenset([ST_FILE, ST_LVM_PV, ST_LVM_VG])
326

    
327
# Storage fields
328
# first two are valid in LU context only, not passed to backend
329
SF_NODE = _constants.SF_NODE
330
SF_TYPE = _constants.SF_TYPE
331
# and the rest are valid in backend
332
SF_NAME = _constants.SF_NAME
333
SF_SIZE = _constants.SF_SIZE
334
SF_FREE = _constants.SF_FREE
335
SF_USED = _constants.SF_USED
336
SF_ALLOCATABLE = _constants.SF_ALLOCATABLE
337

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

    
341
# Available fields per storage type
342
VALID_STORAGE_FIELDS = compat.UniqueFrozenset([
343
  SF_NODE,
344
  SF_NAME,
345
  SF_TYPE,
346
  SF_SIZE,
347
  SF_USED,
348
  SF_FREE,
349
  SF_ALLOCATABLE,
350
  ])
351

    
352
MODIFIABLE_STORAGE_FIELDS = {
353
  ST_LVM_PV: frozenset([SF_ALLOCATABLE]),
354
  }
355

    
356
LDS_OKAY = _constants.LDS_OKAY
357
LDS_UNKNOWN = _constants.LDS_UNKNOWN
358
LDS_FAULTY = _constants.LDS_FAULTY
359
LDS_NAMES = _constants.LDS_NAMES
360
VALID_STORAGE_OPERATIONS = {
361
  ST_LVM_VG: frozenset([SO_FIX_CONSISTENCY]),
362
  }
363

    
364
# Volume fields
365
VF_DEV = "dev"
366
VF_INSTANCE = "instance"
367
VF_NAME = "name"
368
VF_NODE = "node"
369
VF_PHYS = "phys"
370
VF_SIZE = "size"
371
VF_VG = "vg"
372

    
373
# disk template types
374
DT_BLOCK = _constants.DT_BLOCK
375
DT_DISKLESS = _constants.DT_DISKLESS
376
DT_DRBD8 = _constants.DT_DRBD8
377
DT_EXT = _constants.DT_EXT
378
DT_FILE = _constants.DT_FILE
379
DT_PLAIN = _constants.DT_PLAIN
380
DT_RBD = _constants.DT_RBD
381
DT_SHARED_FILE = _constants.DT_SHARED_FILE
382
DISK_TEMPLATE_PREFERENCE = _constants.DISK_TEMPLATE_PREFERENCE
383
DISK_TEMPLATES = _constants.DISK_TEMPLATES
384
DEFAULT_ENABLED_DISK_TEMPLATES = _constants.DEFAULT_ENABLED_DISK_TEMPLATES
385

    
386
# mapping of disk templates to storage types
387
MAP_DISK_TEMPLATE_STORAGE_TYPE = {
388
  DT_BLOCK: ST_BLOCK,
389
  DT_DISKLESS: ST_DISKLESS,
390
  DT_DRBD8: ST_LVM_VG,
391
  DT_EXT: ST_EXT,
392
  DT_FILE: ST_FILE,
393
  DT_PLAIN: ST_LVM_VG,
394
  DT_RBD: ST_RADOS,
395
  DT_SHARED_FILE: ST_FILE,
396
  }
397

    
398
# the set of network-mirrored disk templates
399
DTS_INT_MIRROR = compat.UniqueFrozenset([DT_DRBD8])
400

    
401
# the set of externally-mirrored disk templates (e.g. SAN, NAS)
402
DTS_EXT_MIRROR = compat.UniqueFrozenset([
403
  DT_DISKLESS, # 'trivially' externally mirrored
404
  DT_SHARED_FILE,
405
  DT_BLOCK,
406
  DT_RBD,
407
  DT_EXT,
408
  ])
409

    
410
# the set of non-lvm-based disk templates
411
DTS_NOT_LVM = compat.UniqueFrozenset([
412
  DT_DISKLESS,
413
  DT_FILE,
414
  DT_SHARED_FILE,
415
  DT_BLOCK,
416
  DT_RBD,
417
  DT_EXT,
418
  ])
419

    
420
# the set of disk templates which can be grown
421
DTS_GROWABLE = compat.UniqueFrozenset([
422
  DT_PLAIN,
423
  DT_DRBD8,
424
  DT_FILE,
425
  DT_SHARED_FILE,
426
  DT_RBD,
427
  DT_EXT,
428
  ])
429

    
430
# the set of disk templates that allow adoption
431
DTS_MAY_ADOPT = compat.UniqueFrozenset([
432
  DT_PLAIN,
433
  DT_BLOCK,
434
  ])
435

    
436
# the set of disk templates that *must* use adoption
437
DTS_MUST_ADOPT = compat.UniqueFrozenset([DT_BLOCK])
438

    
439
# the set of disk templates that allow migrations
440
DTS_MIRRORED = frozenset.union(DTS_INT_MIRROR, DTS_EXT_MIRROR)
441

    
442
# the set of file based disk templates
443
DTS_FILEBASED = compat.UniqueFrozenset([
444
  DT_FILE,
445
  DT_SHARED_FILE,
446
  ])
447

    
448
# the set of disk templates that can be moved by copying
449
# Note: a requirement is that they're not accessed externally or shared between
450
# nodes; in particular, sharedfile is not suitable.
451
DTS_COPYABLE = compat.UniqueFrozenset([
452
  DT_FILE,
453
  DT_PLAIN,
454
  ])
455

    
456
# the set of disk templates that are supported by exclusive_storage
457
DTS_EXCL_STORAGE = compat.UniqueFrozenset([DT_PLAIN])
458

    
459
# templates for which we don't perform checks on free space
460
DTS_NO_FREE_SPACE_CHECK = compat.UniqueFrozenset([
461
  DT_FILE,
462
  DT_SHARED_FILE,
463
  DT_RBD,
464
  DT_EXT,
465
  ])
466

    
467
DTS_BLOCK = compat.UniqueFrozenset([
468
  DT_PLAIN,
469
  DT_DRBD8,
470
  DT_BLOCK,
471
  DT_RBD,
472
  DT_EXT,
473
  ])
474

    
475
# drbd constants
476
DRBD_HMAC_ALG = "md5"
477
DRBD_DEFAULT_NET_PROTOCOL = "C"
478
DRBD_MIGRATION_NET_PROTOCOL = "C"
479
DRBD_STATUS_FILE = "/proc/drbd"
480

    
481
#: Size of DRBD meta block device
482
DRBD_META_SIZE = 128
483

    
484
# drbd barrier types
485
DRBD_B_NONE = "n"
486
DRBD_B_DISK_BARRIERS = "b"
487
DRBD_B_DISK_DRAIN = "d"
488
DRBD_B_DISK_FLUSH = "f"
489

    
490
# Valid barrier combinations: "n" or any non-null subset of "bfd"
491
DRBD_VALID_BARRIER_OPT = compat.UniqueFrozenset([
492
  frozenset([DRBD_B_NONE]),
493
  frozenset([DRBD_B_DISK_BARRIERS]),
494
  frozenset([DRBD_B_DISK_DRAIN]),
495
  frozenset([DRBD_B_DISK_FLUSH]),
496
  frozenset([DRBD_B_DISK_DRAIN, DRBD_B_DISK_FLUSH]),
497
  frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_DRAIN]),
498
  frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_FLUSH]),
499
  frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_FLUSH, DRBD_B_DISK_DRAIN]),
500
  ])
501

    
502
# rbd tool command
503
RBD_CMD = "rbd"
504

    
505
# file backend driver
506
FD_BLKTAP = _constants.FD_BLKTAP
507
FD_LOOP = _constants.FD_LOOP
508

    
509
LDS_DRBD = _constants.LDS_DRBD
510

    
511
# disk access mode
512
DISK_RDONLY = _constants.DISK_RDONLY
513
DISK_RDWR = _constants.DISK_RDWR
514
DISK_ACCESS_SET = _constants.DISK_ACCESS_SET
515
DISK_USERSPACE = _constants.DISK_USERSPACE
516
DISK_KERNELSPACE = _constants.DISK_KERNELSPACE
517
DISK_VALID_ACCESS_MODES = _constants.DISK_VALID_ACCESS_MODES
518

    
519
REPLACE_DISK_PRI = _constants.REPLACE_DISK_PRI
520
REPLACE_DISK_SEC = _constants.REPLACE_DISK_SEC
521
REPLACE_DISK_CHG = _constants.REPLACE_DISK_CHG
522
REPLACE_DISK_AUTO = _constants.REPLACE_DISK_AUTO
523
REPLACE_MODES = _constants.REPLACE_MODES
524

    
525
# Instance export mode
526
EXPORT_MODE_LOCAL = _constants.EXPORT_MODE_LOCAL
527
EXPORT_MODE_REMOTE = _constants.EXPORT_MODE_REMOTE
528
EXPORT_MODES = _constants.EXPORT_MODES
529

    
530
# instance creation modes
531
INSTANCE_CREATE = _constants.INSTANCE_CREATE
532
INSTANCE_IMPORT = _constants.INSTANCE_IMPORT
533
INSTANCE_REMOTE_IMPORT = _constants.INSTANCE_REMOTE_IMPORT
534
INSTANCE_CREATE_MODES = _constants.INSTANCE_CREATE_MODES
535

    
536
# Remote import/export handshake message and version
537
RIE_VERSION = 0
538
RIE_HANDSHAKE = "Hi, I'm Ganeti"
539

    
540
# Remote import/export certificate validity in seconds
541
RIE_CERT_VALIDITY = 24 * 60 * 60
542

    
543
# Overall timeout for establishing connection
544
RIE_CONNECT_TIMEOUT = 180
545

    
546
# Export only: how long to wait per connection attempt (seconds)
547
RIE_CONNECT_ATTEMPT_TIMEOUT = 20
548

    
549
# Export only: number of attempts to connect
550
RIE_CONNECT_RETRIES = 10
551

    
552
#: Give child process up to 5 seconds to exit after sending a signal
553
CHILD_LINGER_TIMEOUT = 5.0
554

    
555
FILE_DRIVER = compat.UniqueFrozenset([FD_LOOP, FD_BLKTAP])
556

    
557
# import/export config options
558
INISECT_EXP = "export"
559
INISECT_INS = "instance"
560
INISECT_HYP = "hypervisor"
561
INISECT_BEP = "backend"
562
INISECT_OSP = "os"
563

    
564
# dynamic device modification
565
DDM_ADD = _constants.DDM_ADD
566
DDM_MODIFY = _constants.DDM_MODIFY
567
DDM_REMOVE = _constants.DDM_REMOVE
568
DDMS_VALUES = _constants.DDMS_VALUES
569
DDMS_VALUES_WITH_MODIFY = _constants.DDMS_VALUES_WITH_MODIFY
570
# TODO: DDM_SWAP, DDM_MOVE?
571

    
572
# common exit codes
573
EXIT_SUCCESS = _constants.EXIT_SUCCESS
574
EXIT_FAILURE = _constants.EXIT_FAILURE
575
EXIT_NOTCLUSTER = _constants.EXIT_NOTCLUSTER
576
EXIT_NOTMASTER = _constants.EXIT_NOTMASTER
577
EXIT_NODESETUP_ERROR = _constants.EXIT_NODESETUP_ERROR
578
EXIT_CONFIRMATION = _constants.EXIT_CONFIRMATION # need user confirmation
579

    
580
#: Exit code for query operations with unknown fields
581
EXIT_UNKNOWN_FIELD = _constants.EXIT_UNKNOWN_FIELD
582

    
583
# tags
584
TAG_CLUSTER = _constants.TAG_CLUSTER
585
TAG_NODEGROUP = _constants.TAG_NODEGROUP
586
TAG_NODE = _constants.TAG_NODE
587
TAG_INSTANCE = _constants.TAG_INSTANCE
588
TAG_NETWORK = _constants.TAG_NETWORK
589
VALID_TAG_TYPES = _constants.VALID_TAG_TYPES
590

    
591
MAX_TAG_LEN = _constants.MAX_TAG_LEN
592
MAX_TAGS_PER_OBJ = _constants.MAX_TAGS_PER_OBJ
593

    
594
# others
595
DEFAULT_BRIDGE = "xen-br0"
596
DEFAULT_OVS = "switch1"
597
CLASSIC_DRBD_SYNC_SPEED = 60 * 1024  # 60 MiB, expressed in KiB
598
IP4_ADDRESS_LOCALHOST = "127.0.0.1"
599
IP4_ADDRESS_ANY = "0.0.0.0"
600
IP6_ADDRESS_LOCALHOST = "::1"
601
IP6_ADDRESS_ANY = "::"
602
IP4_VERSION = 4
603
IP6_VERSION = 6
604
VALID_IP_VERSIONS = compat.UniqueFrozenset([IP4_VERSION, IP6_VERSION])
605
# for export to htools
606
IP4_FAMILY = socket.AF_INET
607
IP6_FAMILY = socket.AF_INET6
608

    
609
TCP_PING_TIMEOUT = 10
610
DEFAULT_VG = "xenvg"
611
DEFAULT_DRBD_HELPER = "/bin/true"
612
MIN_VG_SIZE = 20480
613
DEFAULT_MAC_PREFIX = "aa:00:00"
614
# default maximum instance wait time, in seconds.
615
DEFAULT_SHUTDOWN_TIMEOUT = 120
616
NODE_MAX_CLOCK_SKEW = _constants.NODE_MAX_CLOCK_SKEW
617
# Time for an intra-cluster disk transfer to wait for a connection
618
DISK_TRANSFER_CONNECT_TIMEOUT = 60
619
# Disk index separator
620
DISK_SEPARATOR = _constants.DISK_SEPARATOR
621
IP_COMMAND_PATH = _constants.IP_COMMAND_PATH
622

    
623
RPC_TMO_URGENT = _constants.RPC_TMO_URGENT
624
RPC_TMO_FAST = _constants.RPC_TMO_FAST
625
RPC_TMO_NORMAL = _constants.RPC_TMO_NORMAL
626
RPC_TMO_SLOW = _constants.RPC_TMO_SLOW
627
RPC_TMO_4HRS = _constants.RPC_TMO_4HRS
628
RPC_TMO_1DAY = _constants.RPC_TMO_1DAY
629
RPC_CONNECT_TIMEOUT = _constants.RPC_CONNECT_TIMEOUT
630

    
631
#: Key for job IDs in opcode result
632
JOB_IDS_KEY = "jobs"
633

    
634
# runparts results
635
(RUNPARTS_SKIP,
636
 RUNPARTS_RUN,
637
 RUNPARTS_ERR) = range(3)
638

    
639
RUNPARTS_STATUS = compat.UniqueFrozenset([
640
  RUNPARTS_SKIP,
641
  RUNPARTS_RUN,
642
  RUNPARTS_ERR,
643
  ])
644

    
645
# RPC constants
646
(RPC_ENCODING_NONE,
647
 RPC_ENCODING_ZLIB_BASE64) = range(2)
648

    
649
# os related constants
650
OS_SCRIPT_CREATE = "create"
651
OS_SCRIPT_IMPORT = "import"
652
OS_SCRIPT_EXPORT = "export"
653
OS_SCRIPT_RENAME = "rename"
654
OS_SCRIPT_VERIFY = "verify"
655
OS_SCRIPTS = compat.UniqueFrozenset([
656
  OS_SCRIPT_CREATE,
657
  OS_SCRIPT_IMPORT,
658
  OS_SCRIPT_EXPORT,
659
  OS_SCRIPT_RENAME,
660
  OS_SCRIPT_VERIFY,
661
  ])
662

    
663
OS_API_FILE = "ganeti_api_version"
664
OS_VARIANTS_FILE = "variants.list"
665
OS_PARAMETERS_FILE = "parameters.list"
666

    
667
OS_VALIDATE_PARAMETERS = "parameters"
668
OS_VALIDATE_CALLS = compat.UniqueFrozenset([OS_VALIDATE_PARAMETERS])
669

    
670
# External Storage (ES) related constants
671
ES_ACTION_CREATE = "create"
672
ES_ACTION_REMOVE = "remove"
673
ES_ACTION_GROW = "grow"
674
ES_ACTION_ATTACH = "attach"
675
ES_ACTION_DETACH = "detach"
676
ES_ACTION_SETINFO = "setinfo"
677
ES_ACTION_VERIFY = "verify"
678

    
679
ES_SCRIPT_CREATE = ES_ACTION_CREATE
680
ES_SCRIPT_REMOVE = ES_ACTION_REMOVE
681
ES_SCRIPT_GROW = ES_ACTION_GROW
682
ES_SCRIPT_ATTACH = ES_ACTION_ATTACH
683
ES_SCRIPT_DETACH = ES_ACTION_DETACH
684
ES_SCRIPT_SETINFO = ES_ACTION_SETINFO
685
ES_SCRIPT_VERIFY = ES_ACTION_VERIFY
686
ES_SCRIPTS = frozenset([
687
  ES_SCRIPT_CREATE,
688
  ES_SCRIPT_REMOVE,
689
  ES_SCRIPT_GROW,
690
  ES_SCRIPT_ATTACH,
691
  ES_SCRIPT_DETACH,
692
  ES_SCRIPT_SETINFO,
693
  ES_SCRIPT_VERIFY
694
  ])
695

    
696
ES_PARAMETERS_FILE = "parameters.list"
697

    
698
# reboot types
699
INSTANCE_REBOOT_SOFT = _constants.INSTANCE_REBOOT_SOFT
700
INSTANCE_REBOOT_HARD = _constants.INSTANCE_REBOOT_HARD
701
INSTANCE_REBOOT_FULL = _constants.INSTANCE_REBOOT_FULL
702
REBOOT_TYPES = _constants.REBOOT_TYPES
703

    
704
# instance reboot behaviors
705
INSTANCE_REBOOT_ALLOWED = "reboot"
706
INSTANCE_REBOOT_EXIT = "exit"
707

    
708
REBOOT_BEHAVIORS = compat.UniqueFrozenset([
709
  INSTANCE_REBOOT_ALLOWED,
710
  INSTANCE_REBOOT_EXIT,
711
  ])
712

    
713
VTYPE_STRING = _constants.VTYPE_STRING
714
VTYPE_MAYBE_STRING = _constants.VTYPE_MAYBE_STRING
715
VTYPE_BOOL = _constants.VTYPE_BOOL
716
VTYPE_SIZE = _constants.VTYPE_SIZE
717
VTYPE_INT = _constants.VTYPE_INT
718
ENFORCEABLE_TYPES = _constants.ENFORCEABLE_TYPES
719

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

    
723
VALID_SERIAL_SPEEDS = compat.UniqueFrozenset([
724
  75,
725
  110,
726
  300,
727
  600,
728
  1200,
729
  1800,
730
  2400,
731
  4800,
732
  9600,
733
  14400,
734
  19200,
735
  28800,
736
  38400,
737
  57600,
738
  115200,
739
  230400,
740
  345600,
741
  460800,
742
  ])
743

    
744
# HV parameter names (global namespace)
745
HV_BOOT_ORDER = "boot_order"
746
HV_CDROM_IMAGE_PATH = "cdrom_image_path"
747
HV_KVM_CDROM2_IMAGE_PATH = "cdrom2_image_path"
748
HV_KVM_FLOPPY_IMAGE_PATH = "floppy_image_path"
749
HV_NIC_TYPE = "nic_type"
750
HV_DISK_TYPE = "disk_type"
751
HV_KVM_CDROM_DISK_TYPE = "cdrom_disk_type"
752
HV_VNC_BIND_ADDRESS = "vnc_bind_address"
753
HV_VNC_PASSWORD_FILE = "vnc_password_file"
754
HV_VNC_TLS = "vnc_tls"
755
HV_VNC_X509 = "vnc_x509_path"
756
HV_VNC_X509_VERIFY = "vnc_x509_verify"
757
HV_KVM_SPICE_BIND = "spice_bind"
758
HV_KVM_SPICE_IP_VERSION = "spice_ip_version"
759
HV_KVM_SPICE_PASSWORD_FILE = "spice_password_file"
760
HV_KVM_SPICE_LOSSLESS_IMG_COMPR = "spice_image_compression"
761
HV_KVM_SPICE_JPEG_IMG_COMPR = "spice_jpeg_wan_compression"
762
HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR = "spice_zlib_glz_wan_compression"
763
HV_KVM_SPICE_STREAMING_VIDEO_DETECTION = "spice_streaming_video"
764
HV_KVM_SPICE_AUDIO_COMPR = "spice_playback_compression"
765
HV_KVM_SPICE_USE_TLS = "spice_use_tls"
766
HV_KVM_SPICE_TLS_CIPHERS = "spice_tls_ciphers"
767
HV_KVM_SPICE_USE_VDAGENT = "spice_use_vdagent"
768
HV_ACPI = "acpi"
769
HV_PAE = "pae"
770
HV_USE_BOOTLOADER = "use_bootloader"
771
HV_BOOTLOADER_ARGS = "bootloader_args"
772
HV_BOOTLOADER_PATH = "bootloader_path"
773
HV_KERNEL_ARGS = "kernel_args"
774
HV_KERNEL_PATH = "kernel_path"
775
HV_INITRD_PATH = "initrd_path"
776
HV_ROOT_PATH = "root_path"
777
HV_SERIAL_CONSOLE = "serial_console"
778
HV_SERIAL_SPEED = "serial_speed"
779
HV_USB_MOUSE = "usb_mouse"
780
HV_KEYMAP = "keymap"
781
HV_DEVICE_MODEL = "device_model"
782
HV_INIT_SCRIPT = "init_script"
783
HV_MIGRATION_PORT = "migration_port"
784
HV_MIGRATION_BANDWIDTH = "migration_bandwidth"
785
HV_MIGRATION_DOWNTIME = "migration_downtime"
786
HV_MIGRATION_MODE = "migration_mode"
787
HV_USE_LOCALTIME = "use_localtime"
788
HV_DISK_CACHE = "disk_cache"
789
HV_SECURITY_MODEL = "security_model"
790
HV_SECURITY_DOMAIN = "security_domain"
791
HV_KVM_FLAG = "kvm_flag"
792
HV_VHOST_NET = "vhost_net"
793
HV_KVM_USE_CHROOT = "use_chroot"
794
HV_CPU_MASK = "cpu_mask"
795
HV_MEM_PATH = "mem_path"
796
HV_PASSTHROUGH = "pci_pass"
797
HV_BLOCKDEV_PREFIX = "blockdev_prefix"
798
HV_REBOOT_BEHAVIOR = "reboot_behavior"
799
HV_CPU_TYPE = "cpu_type"
800
HV_CPU_CAP = "cpu_cap"
801
HV_CPU_WEIGHT = "cpu_weight"
802
HV_CPU_CORES = "cpu_cores"
803
HV_CPU_THREADS = "cpu_threads"
804
HV_CPU_SOCKETS = "cpu_sockets"
805
HV_SOUNDHW = "soundhw"
806
HV_USB_DEVICES = "usb_devices"
807
HV_VGA = "vga"
808
HV_KVM_EXTRA = "kvm_extra"
809
HV_KVM_MACHINE_VERSION = "machine_version"
810
HV_KVM_PATH = "kvm_path"
811
HV_VIF_TYPE = "vif_type"
812
HV_VIF_SCRIPT = "vif_script"
813
HV_XEN_CMD = "xen_cmd"
814
HV_XEN_CPUID = "cpuid"
815
HV_VNET_HDR = "vnet_hdr"
816
HV_VIRIDIAN = "viridian"
817

    
818

    
819
HVS_PARAMETER_TYPES = {
820
  HV_KVM_PATH: VTYPE_STRING,
821
  HV_BOOT_ORDER: VTYPE_STRING,
822
  HV_KVM_FLOPPY_IMAGE_PATH: VTYPE_STRING,
823
  HV_CDROM_IMAGE_PATH: VTYPE_STRING,
824
  HV_KVM_CDROM2_IMAGE_PATH: VTYPE_STRING,
825
  HV_NIC_TYPE: VTYPE_STRING,
826
  HV_DISK_TYPE: VTYPE_STRING,
827
  HV_KVM_CDROM_DISK_TYPE: VTYPE_STRING,
828
  HV_VNC_PASSWORD_FILE: VTYPE_STRING,
829
  HV_VNC_BIND_ADDRESS: VTYPE_STRING,
830
  HV_VNC_TLS: VTYPE_BOOL,
831
  HV_VNC_X509: VTYPE_STRING,
832
  HV_VNC_X509_VERIFY: VTYPE_BOOL,
833
  HV_KVM_SPICE_BIND: VTYPE_STRING,
834
  HV_KVM_SPICE_IP_VERSION: VTYPE_INT,
835
  HV_KVM_SPICE_PASSWORD_FILE: VTYPE_STRING,
836
  HV_KVM_SPICE_LOSSLESS_IMG_COMPR: VTYPE_STRING,
837
  HV_KVM_SPICE_JPEG_IMG_COMPR: VTYPE_STRING,
838
  HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR: VTYPE_STRING,
839
  HV_KVM_SPICE_STREAMING_VIDEO_DETECTION: VTYPE_STRING,
840
  HV_KVM_SPICE_AUDIO_COMPR: VTYPE_BOOL,
841
  HV_KVM_SPICE_USE_TLS: VTYPE_BOOL,
842
  HV_KVM_SPICE_TLS_CIPHERS: VTYPE_STRING,
843
  HV_KVM_SPICE_USE_VDAGENT: VTYPE_BOOL,
844
  HV_ACPI: VTYPE_BOOL,
845
  HV_PAE: VTYPE_BOOL,
846
  HV_USE_BOOTLOADER: VTYPE_BOOL,
847
  HV_BOOTLOADER_PATH: VTYPE_STRING,
848
  HV_BOOTLOADER_ARGS: VTYPE_STRING,
849
  HV_KERNEL_PATH: VTYPE_STRING,
850
  HV_KERNEL_ARGS: VTYPE_STRING,
851
  HV_INITRD_PATH: VTYPE_STRING,
852
  HV_ROOT_PATH: VTYPE_MAYBE_STRING,
853
  HV_SERIAL_CONSOLE: VTYPE_BOOL,
854
  HV_SERIAL_SPEED: VTYPE_INT,
855
  HV_USB_MOUSE: VTYPE_STRING,
856
  HV_KEYMAP: VTYPE_STRING,
857
  HV_DEVICE_MODEL: VTYPE_STRING,
858
  HV_INIT_SCRIPT: VTYPE_STRING,
859
  HV_MIGRATION_PORT: VTYPE_INT,
860
  HV_MIGRATION_BANDWIDTH: VTYPE_INT,
861
  HV_MIGRATION_DOWNTIME: VTYPE_INT,
862
  HV_MIGRATION_MODE: VTYPE_STRING,
863
  HV_USE_LOCALTIME: VTYPE_BOOL,
864
  HV_DISK_CACHE: VTYPE_STRING,
865
  HV_SECURITY_MODEL: VTYPE_STRING,
866
  HV_SECURITY_DOMAIN: VTYPE_STRING,
867
  HV_KVM_FLAG: VTYPE_STRING,
868
  HV_VHOST_NET: VTYPE_BOOL,
869
  HV_KVM_USE_CHROOT: VTYPE_BOOL,
870
  HV_CPU_MASK: VTYPE_STRING,
871
  HV_MEM_PATH: VTYPE_STRING,
872
  HV_PASSTHROUGH: VTYPE_STRING,
873
  HV_BLOCKDEV_PREFIX: VTYPE_STRING,
874
  HV_REBOOT_BEHAVIOR: VTYPE_STRING,
875
  HV_CPU_TYPE: VTYPE_STRING,
876
  HV_CPU_CAP: VTYPE_INT,
877
  HV_CPU_WEIGHT: VTYPE_INT,
878
  HV_CPU_CORES: VTYPE_INT,
879
  HV_CPU_THREADS: VTYPE_INT,
880
  HV_CPU_SOCKETS: VTYPE_INT,
881
  HV_SOUNDHW: VTYPE_STRING,
882
  HV_USB_DEVICES: VTYPE_STRING,
883
  HV_VGA: VTYPE_STRING,
884
  HV_KVM_EXTRA: VTYPE_STRING,
885
  HV_KVM_MACHINE_VERSION: VTYPE_STRING,
886
  HV_VIF_TYPE: VTYPE_STRING,
887
  HV_VIF_SCRIPT: VTYPE_STRING,
888
  HV_XEN_CMD: VTYPE_STRING,
889
  HV_XEN_CPUID: VTYPE_STRING,
890
  HV_VNET_HDR: VTYPE_BOOL,
891
  HV_VIRIDIAN: VTYPE_BOOL,
892
  }
893

    
894
HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
895

    
896
HVS_PARAMETER_TITLES = {
897
  HV_ACPI: "ACPI",
898
  HV_BOOT_ORDER: "Boot_order",
899
  HV_CDROM_IMAGE_PATH: "CDROM_image_path",
900
  HV_DISK_TYPE: "Disk_type",
901
  HV_INITRD_PATH: "Initrd_path",
902
  HV_KERNEL_PATH: "Kernel_path",
903
  HV_NIC_TYPE: "NIC_type",
904
  HV_PAE: "PAE",
905
  HV_VNC_BIND_ADDRESS: "VNC_bind_address",
906
  HV_PASSTHROUGH: "pci_pass",
907
  HV_CPU_TYPE: "cpu_type",
908
  }
909

    
910
# Migration statuses
911
HV_MIGRATION_COMPLETED = "completed"
912
HV_MIGRATION_ACTIVE = "active"
913
HV_MIGRATION_FAILED = "failed"
914
HV_MIGRATION_CANCELLED = "cancelled"
915

    
916
HV_MIGRATION_VALID_STATUSES = compat.UniqueFrozenset([
917
  HV_MIGRATION_COMPLETED,
918
  HV_MIGRATION_ACTIVE,
919
  HV_MIGRATION_FAILED,
920
  HV_MIGRATION_CANCELLED,
921
  ])
922

    
923
HV_MIGRATION_FAILED_STATUSES = compat.UniqueFrozenset([
924
  HV_MIGRATION_FAILED,
925
  HV_MIGRATION_CANCELLED,
926
  ])
927

    
928
# KVM-specific statuses
929
HV_KVM_MIGRATION_VALID_STATUSES = HV_MIGRATION_VALID_STATUSES
930

    
931
# Node info keys
932
HV_NODEINFO_KEY_VERSION = "hv_version"
933

    
934
# Hypervisor state
935
HVST_MEMORY_TOTAL = "mem_total"
936
HVST_MEMORY_NODE = "mem_node"
937
HVST_MEMORY_HV = "mem_hv"
938
HVST_CPU_TOTAL = "cpu_total"
939
HVST_CPU_NODE = "cpu_node"
940

    
941
HVST_DEFAULTS = {
942
  HVST_MEMORY_TOTAL: 0,
943
  HVST_MEMORY_NODE: 0,
944
  HVST_MEMORY_HV: 0,
945
  HVST_CPU_TOTAL: 1,
946
  HVST_CPU_NODE: 1,
947
  }
948

    
949
HVSTS_PARAMETER_TYPES = {
950
  HVST_MEMORY_TOTAL: VTYPE_INT,
951
  HVST_MEMORY_NODE: VTYPE_INT,
952
  HVST_MEMORY_HV: VTYPE_INT,
953
  HVST_CPU_TOTAL: VTYPE_INT,
954
  HVST_CPU_NODE: VTYPE_INT,
955
  }
956

    
957
HVSTS_PARAMETERS = frozenset(HVSTS_PARAMETER_TYPES.keys())
958

    
959
# Disk state
960
DS_DISK_TOTAL = "disk_total"
961
DS_DISK_RESERVED = "disk_reserved"
962
DS_DISK_OVERHEAD = "disk_overhead"
963

    
964
DS_DEFAULTS = {
965
  DS_DISK_TOTAL: 0,
966
  DS_DISK_RESERVED: 0,
967
  DS_DISK_OVERHEAD: 0,
968
  }
969

    
970
ISPEC_MEM_SIZE = _constants.ISPEC_MEM_SIZE
971
ISPEC_CPU_COUNT = _constants.ISPEC_CPU_COUNT
972
ISPEC_DISK_COUNT = _constants.ISPEC_DISK_COUNT
973
ISPEC_DISK_SIZE = _constants.ISPEC_DISK_SIZE
974
ISPEC_NIC_COUNT = _constants.ISPEC_NIC_COUNT
975
ISPEC_SPINDLE_USE = _constants.ISPEC_SPINDLE_USE
976
ISPECS_PARAMETER_TYPES = _constants.ISPECS_PARAMETER_TYPES
977
ISPECS_PARAMETERS = _constants.ISPECS_PARAMETERS
978

    
979
ISPECS_MINMAX = _constants.ISPECS_MINMAX
980
ISPECS_MIN = _constants.ISPECS_MIN
981
ISPECS_MAX = _constants.ISPECS_MAX
982
ISPECS_STD = _constants.ISPECS_STD
983
IPOLICY_DTS = _constants.IPOLICY_DTS
984
IPOLICY_VCPU_RATIO = _constants.IPOLICY_VCPU_RATIO
985
IPOLICY_SPINDLE_RATIO = _constants.IPOLICY_SPINDLE_RATIO
986
ISPECS_MINMAX_KEYS = _constants.ISPECS_MINMAX_KEYS
987
IPOLICY_PARAMETERS = _constants.IPOLICY_PARAMETERS
988
IPOLICY_ALL_KEYS = _constants.IPOLICY_ALL_KEYS
989

    
990
ND_OOB_PROGRAM = _constants.ND_OOB_PROGRAM
991
ND_SPINDLE_COUNT = _constants.ND_SPINDLE_COUNT
992
ND_EXCLUSIVE_STORAGE = _constants.ND_EXCLUSIVE_STORAGE
993
ND_OVS = _constants.ND_OVS
994
ND_OVS_NAME = _constants.ND_OVS_NAME
995
ND_OVS_LINK = _constants.ND_OVS_LINK
996

    
997
NDS_PARAMETER_TYPES = _constants.NDS_PARAMETER_TYPES
998
NDS_PARAMETERS = _constants.NDS_PARAMETERS
999
NDS_PARAMETER_TITLES = _constants.NDS_PARAMETER_TITLES
1000
DSS_PARAMETER_TYPES = {
1001
  DS_DISK_TOTAL: VTYPE_INT,
1002
  DS_DISK_RESERVED: VTYPE_INT,
1003
  DS_DISK_OVERHEAD: VTYPE_INT,
1004
  }
1005

    
1006
DSS_PARAMETERS = frozenset(DSS_PARAMETER_TYPES.keys())
1007
DS_VALID_TYPES = compat.UniqueFrozenset([DT_PLAIN])
1008

    
1009
# Backend parameter names
1010
BE_MEMORY = "memory" # deprecated and replaced by max and min mem
1011
BE_MAXMEM = "maxmem"
1012
BE_MINMEM = "minmem"
1013
BE_VCPUS = "vcpus"
1014
BE_AUTO_BALANCE = "auto_balance"
1015
BE_ALWAYS_FAILOVER = "always_failover"
1016
BE_SPINDLE_USE = "spindle_use"
1017

    
1018
BES_PARAMETER_TYPES = {
1019
  BE_MAXMEM: VTYPE_SIZE,
1020
  BE_MINMEM: VTYPE_SIZE,
1021
  BE_VCPUS: VTYPE_INT,
1022
  BE_AUTO_BALANCE: VTYPE_BOOL,
1023
  BE_ALWAYS_FAILOVER: VTYPE_BOOL,
1024
  BE_SPINDLE_USE: VTYPE_INT,
1025
  }
1026

    
1027
BES_PARAMETER_TITLES = {
1028
  BE_AUTO_BALANCE: "Auto_balance",
1029
  BE_MAXMEM: "ConfigMaxMem",
1030
  BE_MINMEM: "ConfigMinMem",
1031
  BE_VCPUS: "ConfigVCPUs",
1032
  }
1033

    
1034
BES_PARAMETER_COMPAT = {
1035
  BE_MEMORY: VTYPE_SIZE,
1036
  }
1037
BES_PARAMETER_COMPAT.update(BES_PARAMETER_TYPES)
1038

    
1039
BES_PARAMETERS = frozenset(BES_PARAMETER_TYPES.keys())
1040

    
1041
# Logical Disks parameters
1042
LDP_RESYNC_RATE = "resync-rate"
1043
LDP_STRIPES = "stripes"
1044
LDP_BARRIERS = "disabled-barriers"
1045
LDP_NO_META_FLUSH = "disable-meta-flush"
1046
LDP_DEFAULT_METAVG = "default-metavg"
1047
LDP_DISK_CUSTOM = "disk-custom"
1048
LDP_NET_CUSTOM = "net-custom"
1049
LDP_PROTOCOL = "protocol"
1050
LDP_DYNAMIC_RESYNC = "dynamic-resync"
1051
LDP_PLAN_AHEAD = "c-plan-ahead"
1052
LDP_FILL_TARGET = "c-fill-target"
1053
LDP_DELAY_TARGET = "c-delay-target"
1054
LDP_MAX_RATE = "c-max-rate"
1055
LDP_MIN_RATE = "c-min-rate"
1056
LDP_POOL = "pool"
1057
LDP_ACCESS = "access"
1058
DISK_LD_TYPES = {
1059
  LDP_RESYNC_RATE: VTYPE_INT,
1060
  LDP_STRIPES: VTYPE_INT,
1061
  LDP_BARRIERS: VTYPE_STRING,
1062
  LDP_NO_META_FLUSH: VTYPE_BOOL,
1063
  LDP_DEFAULT_METAVG: VTYPE_STRING,
1064
  LDP_DISK_CUSTOM: VTYPE_STRING,
1065
  LDP_NET_CUSTOM: VTYPE_STRING,
1066
  LDP_PROTOCOL: VTYPE_STRING,
1067
  LDP_DYNAMIC_RESYNC: VTYPE_BOOL,
1068
  LDP_PLAN_AHEAD: VTYPE_INT,
1069
  LDP_FILL_TARGET: VTYPE_INT,
1070
  LDP_DELAY_TARGET: VTYPE_INT,
1071
  LDP_MAX_RATE: VTYPE_INT,
1072
  LDP_MIN_RATE: VTYPE_INT,
1073
  LDP_POOL: VTYPE_STRING,
1074
  LDP_ACCESS: VTYPE_STRING,
1075
  }
1076
DISK_LD_PARAMETERS = frozenset(DISK_LD_TYPES.keys())
1077

    
1078
# Disk template parameters (can be set/changed by the user via gnt-cluster and
1079
# gnt-group)
1080
DRBD_RESYNC_RATE = "resync-rate"
1081
DRBD_DATA_STRIPES = "data-stripes"
1082
DRBD_META_STRIPES = "meta-stripes"
1083
DRBD_DISK_BARRIERS = "disk-barriers"
1084
DRBD_META_BARRIERS = "meta-barriers"
1085
DRBD_DEFAULT_METAVG = "metavg"
1086
DRBD_DISK_CUSTOM = "disk-custom"
1087
DRBD_NET_CUSTOM = "net-custom"
1088
DRBD_PROTOCOL = "protocol"
1089
DRBD_DYNAMIC_RESYNC = "dynamic-resync"
1090
DRBD_PLAN_AHEAD = "c-plan-ahead"
1091
DRBD_FILL_TARGET = "c-fill-target"
1092
DRBD_DELAY_TARGET = "c-delay-target"
1093
DRBD_MAX_RATE = "c-max-rate"
1094
DRBD_MIN_RATE = "c-min-rate"
1095
LV_STRIPES = "stripes"
1096
RBD_POOL = "pool"
1097
RBD_ACCESS = "access"
1098
DISK_DT_TYPES = {
1099
  DRBD_RESYNC_RATE: VTYPE_INT,
1100
  DRBD_DATA_STRIPES: VTYPE_INT,
1101
  DRBD_META_STRIPES: VTYPE_INT,
1102
  DRBD_DISK_BARRIERS: VTYPE_STRING,
1103
  DRBD_META_BARRIERS: VTYPE_BOOL,
1104
  DRBD_DEFAULT_METAVG: VTYPE_STRING,
1105
  DRBD_DISK_CUSTOM: VTYPE_STRING,
1106
  DRBD_NET_CUSTOM: VTYPE_STRING,
1107
  DRBD_PROTOCOL: VTYPE_STRING,
1108
  DRBD_DYNAMIC_RESYNC: VTYPE_BOOL,
1109
  DRBD_PLAN_AHEAD: VTYPE_INT,
1110
  DRBD_FILL_TARGET: VTYPE_INT,
1111
  DRBD_DELAY_TARGET: VTYPE_INT,
1112
  DRBD_MAX_RATE: VTYPE_INT,
1113
  DRBD_MIN_RATE: VTYPE_INT,
1114
  LV_STRIPES: VTYPE_INT,
1115
  RBD_POOL: VTYPE_STRING,
1116
  RBD_ACCESS: VTYPE_STRING,
1117
  }
1118

    
1119
DISK_DT_PARAMETERS = frozenset(DISK_DT_TYPES.keys())
1120

    
1121
# dynamic disk parameters
1122
DDP_LOCAL_IP = "local-ip"
1123
DDP_REMOTE_IP = "remote-ip"
1124
DDP_PORT = "port"
1125
DDP_LOCAL_MINOR = "local-minor"
1126
DDP_REMOTE_MINOR = "remote-minor"
1127

    
1128
# OOB supported commands
1129
OOB_POWER_ON = _constants.OOB_POWER_ON
1130
OOB_POWER_OFF = _constants.OOB_POWER_OFF
1131
OOB_POWER_CYCLE = _constants.OOB_POWER_CYCLE
1132
OOB_POWER_STATUS = _constants.OOB_POWER_STATUS
1133
OOB_HEALTH = _constants.OOB_HEALTH
1134
OOB_COMMANDS = _constants.OOB_COMMANDS
1135

    
1136
OOB_POWER_STATUS_POWERED = _constants.OOB_POWER_STATUS_POWERED
1137

    
1138
OOB_TIMEOUT = _constants.OOB_TIMEOUT
1139
OOB_POWER_DELAY = _constants.OOB_POWER_DELAY
1140

    
1141
OOB_STATUS_OK = _constants.OOB_STATUS_OK
1142
OOB_STATUS_WARNING = _constants.OOB_STATUS_WARNING
1143
OOB_STATUS_CRITICAL = _constants.OOB_STATUS_CRITICAL
1144
OOB_STATUS_UNKNOWN = _constants.OOB_STATUS_UNKNOWN
1145
OOB_STATUSES = _constants.OOB_STATUSES
1146

    
1147
# Instance Parameters Profile
1148
PP_DEFAULT = "default"
1149

    
1150
# NIC_* constants are used inside the ganeti config
1151
NIC_MODE = _constants.NIC_MODE
1152
NIC_LINK = _constants.NIC_LINK
1153
NIC_VLAN = _constants.NIC_VLAN
1154

    
1155
NIC_MODE_BRIDGED = _constants.NIC_MODE_BRIDGED
1156
NIC_MODE_ROUTED = _constants.NIC_MODE_ROUTED
1157
NIC_MODE_OVS = _constants.NIC_MODE_OVS
1158
NIC_IP_POOL = _constants.NIC_IP_POOL
1159
NIC_VALID_MODES = _constants.NIC_VALID_MODES
1160

    
1161
RESERVE_ACTION = "reserve"
1162
RELEASE_ACTION = "release"
1163

    
1164
NICS_PARAMETER_TYPES = {
1165
  NIC_MODE: VTYPE_STRING,
1166
  NIC_LINK: VTYPE_STRING,
1167
  NIC_VLAN: VTYPE_MAYBE_STRING,
1168
  }
1169

    
1170
NICS_PARAMETERS = frozenset(NICS_PARAMETER_TYPES.keys())
1171

    
1172
# IDISK_* constants are used in opcodes, to create/change disks
1173
IDISK_SIZE = "size"
1174
IDISK_SPINDLES = "spindles"
1175
IDISK_MODE = "mode"
1176
IDISK_ADOPT = "adopt"
1177
IDISK_VG = "vg"
1178
IDISK_METAVG = "metavg"
1179
IDISK_PROVIDER = "provider"
1180
IDISK_NAME = "name"
1181
IDISK_PARAMS_TYPES = {
1182
  IDISK_SIZE: VTYPE_SIZE,
1183
  IDISK_SPINDLES: VTYPE_INT,
1184
  IDISK_MODE: VTYPE_STRING,
1185
  IDISK_ADOPT: VTYPE_STRING,
1186
  IDISK_VG: VTYPE_STRING,
1187
  IDISK_METAVG: VTYPE_STRING,
1188
  IDISK_PROVIDER: VTYPE_STRING,
1189
  IDISK_NAME: VTYPE_MAYBE_STRING,
1190
  }
1191
IDISK_PARAMS = frozenset(IDISK_PARAMS_TYPES.keys())
1192

    
1193
# INIC_* constants are used in opcodes, to create/change nics
1194
INIC_MAC = "mac"
1195
INIC_IP = "ip"
1196
INIC_MODE = "mode"
1197
INIC_LINK = "link"
1198
INIC_NETWORK = "network"
1199
INIC_NAME = "name"
1200
INIC_VLAN = "vlan"
1201
INIC_BRIDGE = "bridge"
1202
INIC_PARAMS_TYPES = {
1203
  INIC_IP: VTYPE_MAYBE_STRING,
1204
  INIC_LINK: VTYPE_STRING,
1205
  INIC_MAC: VTYPE_STRING,
1206
  INIC_MODE: VTYPE_STRING,
1207
  INIC_NETWORK: VTYPE_MAYBE_STRING,
1208
  INIC_NAME: VTYPE_MAYBE_STRING,
1209
  INIC_VLAN: VTYPE_MAYBE_STRING,
1210
  INIC_BRIDGE: VTYPE_MAYBE_STRING
1211
  }
1212
INIC_PARAMS = frozenset(INIC_PARAMS_TYPES.keys())
1213

    
1214
# Hypervisor constants
1215
HT_XEN_PVM = _constants.HT_XEN_PVM
1216
HT_FAKE = _constants.HT_FAKE
1217
HT_XEN_HVM = _constants.HT_XEN_HVM
1218
HT_KVM = _constants.HT_KVM
1219
HT_CHROOT = _constants.HT_CHROOT
1220
HT_LXC = _constants.HT_LXC
1221
HYPER_TYPES = _constants.HYPER_TYPES
1222
HTS_REQ_PORT = _constants.HTS_REQ_PORT
1223

    
1224
VNC_BASE_PORT = 5900
1225
VNC_DEFAULT_BIND_ADDRESS = IP4_ADDRESS_ANY
1226

    
1227
# NIC types
1228
HT_NIC_RTL8139 = "rtl8139"
1229
HT_NIC_NE2K_PCI = "ne2k_pci"
1230
HT_NIC_NE2K_ISA = "ne2k_isa"
1231
HT_NIC_I82551 = "i82551"
1232
HT_NIC_I85557B = "i82557b"
1233
HT_NIC_I8259ER = "i82559er"
1234
HT_NIC_PCNET = "pcnet"
1235
HT_NIC_E1000 = "e1000"
1236
HT_NIC_PARAVIRTUAL = HT_DISK_PARAVIRTUAL = "paravirtual"
1237

    
1238
HT_HVM_VALID_NIC_TYPES = compat.UniqueFrozenset([
1239
  HT_NIC_RTL8139,
1240
  HT_NIC_NE2K_PCI,
1241
  HT_NIC_E1000,
1242
  HT_NIC_NE2K_ISA,
1243
  HT_NIC_PARAVIRTUAL,
1244
  ])
1245
HT_KVM_VALID_NIC_TYPES = compat.UniqueFrozenset([
1246
  HT_NIC_RTL8139,
1247
  HT_NIC_NE2K_PCI,
1248
  HT_NIC_NE2K_ISA,
1249
  HT_NIC_I82551,
1250
  HT_NIC_I85557B,
1251
  HT_NIC_I8259ER,
1252
  HT_NIC_PCNET,
1253
  HT_NIC_E1000,
1254
  HT_NIC_PARAVIRTUAL,
1255
  ])
1256

    
1257
# Vif types
1258
# default vif type in xen-hvm
1259
HT_HVM_VIF_IOEMU = "ioemu"
1260
HT_HVM_VIF_VIF = "vif"
1261
HT_HVM_VALID_VIF_TYPES = compat.UniqueFrozenset([
1262
  HT_HVM_VIF_IOEMU,
1263
  HT_HVM_VIF_VIF,
1264
  ])
1265

    
1266
# Disk types
1267
HT_DISK_IOEMU = "ioemu"
1268
HT_DISK_IDE = "ide"
1269
HT_DISK_SCSI = "scsi"
1270
HT_DISK_SD = "sd"
1271
HT_DISK_MTD = "mtd"
1272
HT_DISK_PFLASH = "pflash"
1273

    
1274
HT_CACHE_DEFAULT = "default"
1275
HT_CACHE_NONE = "none"
1276
HT_CACHE_WTHROUGH = "writethrough"
1277
HT_CACHE_WBACK = "writeback"
1278
HT_VALID_CACHE_TYPES = compat.UniqueFrozenset([
1279
  HT_CACHE_DEFAULT,
1280
  HT_CACHE_NONE,
1281
  HT_CACHE_WTHROUGH,
1282
  HT_CACHE_WBACK,
1283
  ])
1284

    
1285
HT_HVM_VALID_DISK_TYPES = compat.UniqueFrozenset([
1286
  HT_DISK_PARAVIRTUAL,
1287
  HT_DISK_IOEMU,
1288
  ])
1289
HT_KVM_VALID_DISK_TYPES = compat.UniqueFrozenset([
1290
  HT_DISK_PARAVIRTUAL,
1291
  HT_DISK_IDE,
1292
  HT_DISK_SCSI,
1293
  HT_DISK_SD,
1294
  HT_DISK_MTD,
1295
  HT_DISK_PFLASH,
1296
  ])
1297

    
1298
# Mouse types:
1299
HT_MOUSE_MOUSE = "mouse"
1300
HT_MOUSE_TABLET = "tablet"
1301

    
1302
HT_KVM_VALID_MOUSE_TYPES = compat.UniqueFrozenset([
1303
  HT_MOUSE_MOUSE,
1304
  HT_MOUSE_TABLET,
1305
  ])
1306

    
1307
# Boot order
1308
HT_BO_FLOPPY = "floppy"
1309
HT_BO_CDROM = "cdrom"
1310
HT_BO_DISK = "disk"
1311
HT_BO_NETWORK = "network"
1312

    
1313
HT_KVM_VALID_BO_TYPES = compat.UniqueFrozenset([
1314
  HT_BO_FLOPPY,
1315
  HT_BO_CDROM,
1316
  HT_BO_DISK,
1317
  HT_BO_NETWORK,
1318
  ])
1319

    
1320
# SPICE lossless image compression options
1321
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ = "auto_glz"
1322
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ = "auto_lz"
1323
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC = "quic"
1324
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ = "glz"
1325
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ = "lz"
1326
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF = "off"
1327

    
1328
HT_KVM_SPICE_VALID_LOSSLESS_IMG_COMPR_OPTIONS = compat.UniqueFrozenset([
1329
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ,
1330
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ,
1331
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC,
1332
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ,
1333
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ,
1334
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF,
1335
  ])
1336

    
1337
# SPICE lossy image compression options (valid for both jpeg and zlib-glz)
1338
HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO = "auto"
1339
HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER = "never"
1340
HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS = "always"
1341

    
1342
HT_KVM_SPICE_VALID_LOSSY_IMG_COMPR_OPTIONS = compat.UniqueFrozenset([
1343
  HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO,
1344
  HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER,
1345
  HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS,
1346
  ])
1347

    
1348
# SPICE video stream detection
1349
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF = "off"
1350
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL = "all"
1351
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER = "filter"
1352

    
1353
HT_KVM_SPICE_VALID_VIDEO_STREAM_DETECTION_OPTIONS = compat.UniqueFrozenset([
1354
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF,
1355
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL,
1356
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER,
1357
  ])
1358

    
1359
# Security models
1360
HT_SM_NONE = "none"
1361
HT_SM_USER = "user"
1362
HT_SM_POOL = "pool"
1363

    
1364
HT_KVM_VALID_SM_TYPES = compat.UniqueFrozenset([
1365
  HT_SM_NONE,
1366
  HT_SM_USER,
1367
  HT_SM_POOL,
1368
  ])
1369

    
1370
# Kvm flag values
1371
HT_KVM_ENABLED = "enabled"
1372
HT_KVM_DISABLED = "disabled"
1373

    
1374
HT_KVM_FLAG_VALUES = compat.UniqueFrozenset([HT_KVM_ENABLED, HT_KVM_DISABLED])
1375

    
1376
# Migration type
1377
HT_MIGRATION_LIVE = _constants.HT_MIGRATION_LIVE
1378
HT_MIGRATION_NONLIVE = _constants.HT_MIGRATION_NONLIVE
1379
HT_MIGRATION_MODES = _constants.HT_MIGRATION_MODES
1380

    
1381
# Cluster Verify steps
1382
VERIFY_NPLUSONE_MEM = _constants.VERIFY_NPLUSONE_MEM
1383
VERIFY_OPTIONAL_CHECKS = _constants.VERIFY_OPTIONAL_CHECKS
1384

    
1385
# Cluster Verify error classes
1386
CV_TCLUSTER = _constants.CV_TCLUSTER
1387
CV_TGROUP = _constants.CV_TGROUP
1388
CV_TNODE = _constants.CV_TNODE
1389
CV_TINSTANCE = _constants.CV_TINSTANCE
1390

    
1391
# Cluster Verify error codes and documentation
1392
CV_ECLUSTERCFG = _constants.CV_ECLUSTERCFG
1393
CV_ECLUSTERCERT = _constants.CV_ECLUSTERCERT
1394
CV_ECLUSTERFILECHECK = _constants.CV_ECLUSTERFILECHECK
1395
CV_ECLUSTERDANGLINGNODES = _constants.CV_ECLUSTERDANGLINGNODES
1396
CV_ECLUSTERDANGLINGINST = _constants.CV_ECLUSTERDANGLINGINST
1397
CV_EGROUPDIFFERENTPVSIZE = _constants.CV_EGROUPDIFFERENTPVSIZE
1398
CV_EINSTANCEBADNODE = _constants.CV_EINSTANCEBADNODE
1399
CV_EINSTANCEDOWN = _constants.CV_EINSTANCEDOWN
1400
CV_EINSTANCELAYOUT = _constants.CV_EINSTANCELAYOUT
1401
CV_EINSTANCEMISSINGDISK = _constants.CV_EINSTANCEMISSINGDISK
1402
CV_EINSTANCEFAULTYDISK = _constants.CV_EINSTANCEFAULTYDISK
1403
CV_EINSTANCEWRONGNODE = _constants.CV_EINSTANCEWRONGNODE
1404
CV_EINSTANCESPLITGROUPS = _constants.CV_EINSTANCESPLITGROUPS
1405
CV_EINSTANCEPOLICY = _constants.CV_EINSTANCEPOLICY
1406
CV_EINSTANCEUNSUITABLENODE = _constants.CV_EINSTANCEUNSUITABLENODE
1407
CV_EINSTANCEMISSINGCFGPARAMETER = _constants.CV_EINSTANCEMISSINGCFGPARAMETER
1408
CV_ENODEDRBD = _constants.CV_ENODEDRBD
1409
CV_ENODEDRBDVERSION = _constants.CV_ENODEDRBDVERSION
1410
CV_ENODEDRBDHELPER = _constants.CV_ENODEDRBDHELPER
1411
CV_ENODEFILECHECK = _constants.CV_ENODEFILECHECK
1412
CV_ENODEHOOKS = _constants.CV_ENODEHOOKS
1413
CV_ENODEHV = _constants.CV_ENODEHV
1414
CV_ENODELVM = _constants.CV_ENODELVM
1415
CV_ENODEN1 = _constants.CV_ENODEN1
1416
CV_ENODENET = _constants.CV_ENODENET
1417
CV_ENODEOS = _constants.CV_ENODEOS
1418
CV_ENODEORPHANINSTANCE = _constants.CV_ENODEORPHANINSTANCE
1419
CV_ENODEORPHANLV = _constants.CV_ENODEORPHANLV
1420
CV_ENODERPC = _constants.CV_ENODERPC
1421
CV_ENODESSH = _constants.CV_ENODESSH
1422
CV_ENODEVERSION = _constants.CV_ENODEVERSION
1423
CV_ENODESETUP = _constants.CV_ENODESETUP
1424
CV_ENODETIME = _constants.CV_ENODETIME
1425
CV_ENODEOOBPATH = _constants.CV_ENODEOOBPATH
1426
CV_ENODEUSERSCRIPTS = _constants.CV_ENODEUSERSCRIPTS
1427
CV_ENODEFILESTORAGEPATHS = _constants.CV_ENODEFILESTORAGEPATHS
1428
CV_ENODEFILESTORAGEPATHUNUSABLE = _constants.CV_ENODEFILESTORAGEPATHUNUSABLE
1429
CV_ENODESHAREDFILESTORAGEPATHUNUSABLE = \
1430
  _constants.CV_ENODESHAREDFILESTORAGEPATHUNUSABLE
1431

    
1432
CV_ALL_ECODES = _constants.CV_ALL_ECODES
1433
CV_ALL_ECODES_STRINGS = _constants.CV_ALL_ECODES_STRINGS
1434

    
1435
# Node verify constants
1436
NV_BRIDGES = "bridges"
1437
NV_DRBDHELPER = "drbd-helper"
1438
NV_DRBDVERSION = "drbd-version"
1439
NV_DRBDLIST = "drbd-list"
1440
NV_EXCLUSIVEPVS = "exclusive-pvs"
1441
NV_FILELIST = "filelist"
1442
NV_ACCEPTED_STORAGE_PATHS = "allowed-file-storage-paths"
1443
NV_FILE_STORAGE_PATH = "file-storage-path"
1444
NV_SHARED_FILE_STORAGE_PATH = "shared-file-storage-path"
1445
NV_HVINFO = "hvinfo"
1446
NV_HVPARAMS = "hvparms"
1447
NV_HYPERVISOR = "hypervisor"
1448
NV_INSTANCELIST = "instancelist"
1449
NV_LVLIST = "lvlist"
1450
NV_MASTERIP = "master-ip"
1451
NV_NODELIST = "nodelist"
1452
NV_NODENETTEST = "node-net-test"
1453
NV_NODESETUP = "nodesetup"
1454
NV_OOB_PATHS = "oob-paths"
1455
NV_OSLIST = "oslist"
1456
NV_PVLIST = "pvlist"
1457
NV_TIME = "time"
1458
NV_USERSCRIPTS = "user-scripts"
1459
NV_VERSION = "version"
1460
NV_VGLIST = "vglist"
1461
NV_VMNODES = "vmnodes"
1462

    
1463
# Instance status
1464
INSTST_RUNNING = _constants.INSTST_RUNNING
1465
INSTST_ADMINDOWN = _constants.INSTST_ADMINDOWN
1466
INSTST_ADMINOFFLINE = _constants.INSTST_ADMINOFFLINE
1467
INSTST_NODEOFFLINE = _constants.INSTST_NODEOFFLINE
1468
INSTST_NODEDOWN = _constants.INSTST_NODEDOWN
1469
INSTST_WRONGNODE = _constants.INSTST_WRONGNODE
1470
INSTST_ERRORUP = _constants.INSTST_ERRORUP
1471
INSTST_ERRORDOWN = _constants.INSTST_ERRORDOWN
1472
INSTST_ALL = _constants.INSTST_ALL
1473

    
1474
# Admin states
1475
ADMINST_UP = _constants.ADMINST_UP
1476
ADMINST_DOWN = _constants.ADMINST_DOWN
1477
ADMINST_OFFLINE = _constants.ADMINST_OFFLINE
1478
ADMINST_ALL = _constants.ADMINST_ALL
1479

    
1480
# Node roles
1481
NR_REGULAR = _constants.NR_REGULAR
1482
NR_MASTER = _constants.NR_MASTER
1483
NR_MCANDIDATE = _constants.NR_MCANDIDATE
1484
NR_DRAINED = _constants.NR_DRAINED
1485
NR_OFFLINE = _constants.NR_OFFLINE
1486
NR_ALL = _constants.NR_ALL
1487

    
1488
# SSL certificate check constants (in days)
1489
SSL_CERT_EXPIRATION_WARN = 30
1490
SSL_CERT_EXPIRATION_ERROR = 7
1491

    
1492
# Allocator framework constants
1493
IALLOCATOR_VERSION = _constants.IALLOCATOR_VERSION
1494
IALLOCATOR_DIR_IN = _constants.IALLOCATOR_DIR_IN
1495
IALLOCATOR_DIR_OUT = _constants.IALLOCATOR_DIR_OUT
1496
VALID_IALLOCATOR_DIRECTIONS = _constants.VALID_IALLOCATOR_DIRECTIONS
1497

    
1498
IALLOCATOR_MODE_ALLOC = _constants.IALLOCATOR_MODE_ALLOC
1499
IALLOCATOR_MODE_RELOC = _constants.IALLOCATOR_MODE_RELOC
1500
IALLOCATOR_MODE_CHG_GROUP = _constants.IALLOCATOR_MODE_CHG_GROUP
1501
IALLOCATOR_MODE_NODE_EVAC = _constants.IALLOCATOR_MODE_NODE_EVAC
1502
IALLOCATOR_MODE_MULTI_ALLOC = _constants.IALLOCATOR_MODE_MULTI_ALLOC
1503
VALID_IALLOCATOR_MODES = _constants.VALID_IALLOCATOR_MODES
1504

    
1505
IALLOCATOR_SEARCH_PATH = _constants.IALLOCATOR_SEARCH_PATH
1506
DEFAULT_IALLOCATOR_SHORTCUT = _constants.DEFAULT_IALLOCATOR_SHORTCUT
1507

    
1508
# Node evacuation
1509
NODE_EVAC_PRI = _constants.NODE_EVAC_PRI
1510
NODE_EVAC_SEC = _constants.NODE_EVAC_SEC
1511
NODE_EVAC_ALL = _constants.NODE_EVAC_ALL
1512
NODE_EVAC_MODES = _constants.NODE_EVAC_MODES
1513

    
1514
# Job queue
1515
JOB_QUEUE_VERSION = 1
1516
JOB_QUEUE_SIZE_HARD_LIMIT = 5000
1517
JOB_QUEUE_FILES_PERMS = 0640
1518

    
1519
JOB_ID_TEMPLATE = r"\d+"
1520
JOB_FILE_RE = re.compile(r"^job-(%s)$" % JOB_ID_TEMPLATE)
1521

    
1522
# unchanged job return
1523
JOB_NOTCHANGED = "nochange"
1524

    
1525
# Job status
1526
JOB_STATUS_QUEUED = _constants.JOB_STATUS_QUEUED
1527
JOB_STATUS_WAITING = _constants.JOB_STATUS_WAITING
1528
JOB_STATUS_CANCELING = _constants.JOB_STATUS_CANCELING
1529
JOB_STATUS_RUNNING = _constants.JOB_STATUS_RUNNING
1530
JOB_STATUS_CANCELED = _constants.JOB_STATUS_CANCELED
1531
JOB_STATUS_SUCCESS = _constants.JOB_STATUS_SUCCESS
1532
JOB_STATUS_ERROR = _constants.JOB_STATUS_ERROR
1533
JOBS_PENDING = _constants.JOBS_PENDING
1534
JOBS_FINALIZED = _constants.JOBS_FINALIZED
1535
JOB_STATUS_ALL = _constants.JOB_STATUS_ALL
1536

    
1537
# OpCode status
1538
# not yet finalized
1539
OP_STATUS_QUEUED = _constants.OP_STATUS_QUEUED
1540
OP_STATUS_WAITING = _constants.OP_STATUS_WAITING
1541
OP_STATUS_CANCELING = _constants.OP_STATUS_CANCELING
1542
OP_STATUS_RUNNING = _constants.OP_STATUS_RUNNING
1543
# finalized
1544
OP_STATUS_CANCELED = _constants.OP_STATUS_CANCELED
1545
OP_STATUS_SUCCESS = _constants.OP_STATUS_SUCCESS
1546
OP_STATUS_ERROR = _constants.OP_STATUS_ERROR
1547
OPS_FINALIZED = _constants.OPS_FINALIZED
1548

    
1549
# OpCode priority
1550
OP_PRIO_LOWEST = _constants.OP_PRIO_LOWEST
1551
OP_PRIO_HIGHEST = _constants.OP_PRIO_HIGHEST
1552
OP_PRIO_LOW = _constants.OP_PRIO_LOW
1553
OP_PRIO_NORMAL = _constants.OP_PRIO_NORMAL
1554
OP_PRIO_HIGH = _constants.OP_PRIO_HIGH
1555
OP_PRIO_SUBMIT_VALID = _constants.OP_PRIO_SUBMIT_VALID
1556
OP_PRIO_DEFAULT = _constants.OP_PRIO_DEFAULT
1557

    
1558
# Lock recalculate mode
1559
LOCKS_REPLACE = "replace"
1560
LOCKS_APPEND = "append"
1561

    
1562
# Lock timeout (sum) before we should go into blocking acquire (still
1563
# can be reset by priority change); computed as max time (10 hours)
1564
# before we should actually go into blocking acquire given that we
1565
# start from default priority level; in seconds
1566
# TODO
1567
LOCK_ATTEMPTS_TIMEOUT = 10 * 3600 / (OP_PRIO_DEFAULT - OP_PRIO_HIGHEST)
1568
LOCK_ATTEMPTS_MAXWAIT = 15.0
1569
LOCK_ATTEMPTS_MINWAIT = 1.0
1570

    
1571
# Execution log types
1572
ELOG_MESSAGE = _constants.ELOG_MESSAGE
1573
ELOG_REMOTE_IMPORT = _constants.ELOG_REMOTE_IMPORT
1574
ELOG_JQUEUE_TEST = _constants.ELOG_JQUEUE_TEST
1575

    
1576
# /etc/hosts modification
1577
ETC_HOSTS_ADD = "add"
1578
ETC_HOSTS_REMOVE = "remove"
1579

    
1580
# Job queue test
1581
JQT_MSGPREFIX = "TESTMSG="
1582
JQT_EXPANDNAMES = "expandnames"
1583
JQT_EXEC = "exec"
1584
JQT_LOGMSG = "logmsg"
1585
JQT_STARTMSG = "startmsg"
1586
JQT_ALL = compat.UniqueFrozenset([
1587
  JQT_EXPANDNAMES,
1588
  JQT_EXEC,
1589
  JQT_LOGMSG,
1590
  JQT_STARTMSG,
1591
  ])
1592

    
1593
# Query resources
1594
QR_CLUSTER = "cluster"
1595
QR_INSTANCE = "instance"
1596
QR_NODE = "node"
1597
QR_LOCK = "lock"
1598
QR_GROUP = "group"
1599
QR_OS = "os"
1600
QR_JOB = "job"
1601
QR_EXPORT = "export"
1602
QR_NETWORK = "network"
1603
QR_EXTSTORAGE = "extstorage"
1604

    
1605
#: List of resources which can be queried using L{opcodes.OpQuery}
1606
QR_VIA_OP = compat.UniqueFrozenset([
1607
  QR_CLUSTER,
1608
  QR_INSTANCE,
1609
  QR_NODE,
1610
  QR_GROUP,
1611
  QR_OS,
1612
  QR_EXPORT,
1613
  QR_NETWORK,
1614
  QR_EXTSTORAGE,
1615
  ])
1616

    
1617
#: List of resources which can be queried using Local UniX Interface
1618
QR_VIA_LUXI = QR_VIA_OP.union([
1619
  QR_LOCK,
1620
  QR_JOB,
1621
  ])
1622

    
1623
#: List of resources which can be queried using RAPI
1624
QR_VIA_RAPI = QR_VIA_LUXI
1625

    
1626
# Query field types
1627
QFT_UNKNOWN = "unknown"
1628
QFT_TEXT = "text"
1629
QFT_BOOL = "bool"
1630
QFT_NUMBER = "number"
1631
QFT_UNIT = "unit"
1632
QFT_TIMESTAMP = "timestamp"
1633
QFT_OTHER = "other"
1634

    
1635
#: All query field types
1636
QFT_ALL = compat.UniqueFrozenset([
1637
  QFT_UNKNOWN,
1638
  QFT_TEXT,
1639
  QFT_BOOL,
1640
  QFT_NUMBER,
1641
  QFT_UNIT,
1642
  QFT_TIMESTAMP,
1643
  QFT_OTHER,
1644
  ])
1645

    
1646
# Query result field status (don't change or reuse values as they're used by
1647
# clients)
1648
#: Normal field status
1649
RS_NORMAL = 0
1650
#: Unknown field
1651
RS_UNKNOWN = 1
1652
#: No data (e.g. RPC error), can be used instead of L{RS_OFFLINE}
1653
RS_NODATA = 2
1654
#: Value unavailable/unsupported for item; if this field is supported
1655
#: but we cannot get the data for the moment, RS_NODATA or
1656
#: RS_OFFLINE should be used
1657
RS_UNAVAIL = 3
1658
#: Resource marked offline
1659
RS_OFFLINE = 4
1660

    
1661
RS_ALL = compat.UniqueFrozenset([
1662
  RS_NORMAL,
1663
  RS_UNKNOWN,
1664
  RS_NODATA,
1665
  RS_UNAVAIL,
1666
  RS_OFFLINE,
1667
  ])
1668

    
1669
#: Dictionary with special field cases and their verbose/terse formatting
1670
RSS_DESCRIPTION = {
1671
  RS_UNKNOWN: ("(unknown)", "??"),
1672
  RS_NODATA: ("(nodata)", "?"),
1673
  RS_OFFLINE: ("(offline)", "*"),
1674
  RS_UNAVAIL: ("(unavail)", "-"),
1675
  }
1676

    
1677
# max dynamic devices
1678
MAX_NICS = 8
1679
MAX_DISKS = 16
1680

    
1681
# SSCONF file prefix
1682
SSCONF_FILEPREFIX = "ssconf_"
1683
# SSCONF keys
1684
SS_CLUSTER_NAME = "cluster_name"
1685
SS_CLUSTER_TAGS = "cluster_tags"
1686
SS_FILE_STORAGE_DIR = "file_storage_dir"
1687
SS_SHARED_FILE_STORAGE_DIR = "shared_file_storage_dir"
1688
SS_MASTER_CANDIDATES = "master_candidates"
1689
SS_MASTER_CANDIDATES_IPS = "master_candidates_ips"
1690
SS_MASTER_IP = "master_ip"
1691
SS_MASTER_NETDEV = "master_netdev"
1692
SS_MASTER_NETMASK = "master_netmask"
1693
SS_MASTER_NODE = "master_node"
1694
SS_NODE_LIST = "node_list"
1695
SS_NODE_PRIMARY_IPS = "node_primary_ips"
1696
SS_NODE_SECONDARY_IPS = "node_secondary_ips"
1697
SS_OFFLINE_NODES = "offline_nodes"
1698
SS_ONLINE_NODES = "online_nodes"
1699
SS_PRIMARY_IP_FAMILY = "primary_ip_family"
1700
SS_INSTANCE_LIST = "instance_list"
1701
SS_RELEASE_VERSION = "release_version"
1702
SS_HYPERVISOR_LIST = "hypervisor_list"
1703
SS_MAINTAIN_NODE_HEALTH = "maintain_node_health"
1704
SS_UID_POOL = "uid_pool"
1705
SS_NODEGROUPS = "nodegroups"
1706
SS_NETWORKS = "networks"
1707

    
1708
# This is not a complete SSCONF key, but the prefix for the hypervisor keys
1709
SS_HVPARAMS_PREF = "hvparams_"
1710

    
1711
# Hvparams keys:
1712
SS_HVPARAMS_XEN_PVM = SS_HVPARAMS_PREF + HT_XEN_PVM
1713
SS_HVPARAMS_XEN_FAKE = SS_HVPARAMS_PREF + HT_FAKE
1714
SS_HVPARAMS_XEN_HVM = SS_HVPARAMS_PREF + HT_XEN_HVM
1715
SS_HVPARAMS_XEN_KVM = SS_HVPARAMS_PREF + HT_KVM
1716
SS_HVPARAMS_XEN_CHROOT = SS_HVPARAMS_PREF + HT_CHROOT
1717
SS_HVPARAMS_XEN_LXC = SS_HVPARAMS_PREF + HT_LXC
1718

    
1719
VALID_SS_HVPARAMS_KEYS = compat.UniqueFrozenset([
1720
  SS_HVPARAMS_XEN_PVM,
1721
  SS_HVPARAMS_XEN_FAKE,
1722
  SS_HVPARAMS_XEN_HVM,
1723
  SS_HVPARAMS_XEN_KVM,
1724
  SS_HVPARAMS_XEN_CHROOT,
1725
  SS_HVPARAMS_XEN_LXC,
1726
  ])
1727

    
1728
SS_FILE_PERMS = 0444
1729

    
1730
# cluster wide default parameters
1731
DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM
1732

    
1733
HVC_DEFAULTS = {
1734
  HT_XEN_PVM: {
1735
    HV_USE_BOOTLOADER: False,
1736
    HV_BOOTLOADER_PATH: XEN_BOOTLOADER,
1737
    HV_BOOTLOADER_ARGS: "",
1738
    HV_KERNEL_PATH: XEN_KERNEL,
1739
    HV_INITRD_PATH: "",
1740
    HV_ROOT_PATH: "/dev/xvda1",
1741
    HV_KERNEL_ARGS: "ro",
1742
    HV_MIGRATION_PORT: 8002,
1743
    HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1744
    HV_BLOCKDEV_PREFIX: "sd",
1745
    HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1746
    HV_CPU_MASK: CPU_PINNING_ALL,
1747
    HV_CPU_CAP: 0,
1748
    HV_CPU_WEIGHT: 256,
1749
    HV_VIF_SCRIPT: "",
1750
    HV_XEN_CMD: XEN_CMD_XM,
1751
    HV_XEN_CPUID: "",
1752
    HV_SOUNDHW: "",
1753
    },
1754
  HT_XEN_HVM: {
1755
    HV_BOOT_ORDER: "cd",
1756
    HV_CDROM_IMAGE_PATH: "",
1757
    HV_NIC_TYPE: HT_NIC_RTL8139,
1758
    HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
1759
    HV_VNC_BIND_ADDRESS: IP4_ADDRESS_ANY,
1760
    HV_VNC_PASSWORD_FILE: pathutils.VNC_PASSWORD_FILE,
1761
    HV_ACPI: True,
1762
    HV_PAE: True,
1763
    HV_KERNEL_PATH: "/usr/lib/xen/boot/hvmloader",
1764
    HV_DEVICE_MODEL: "/usr/lib/xen/bin/qemu-dm",
1765
    HV_MIGRATION_PORT: 8002,
1766
    HV_MIGRATION_MODE: HT_MIGRATION_NONLIVE,
1767
    HV_USE_LOCALTIME: False,
1768
    HV_BLOCKDEV_PREFIX: "hd",
1769
    HV_PASSTHROUGH: "",
1770
    HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1771
    HV_CPU_MASK: CPU_PINNING_ALL,
1772
    HV_CPU_CAP: 0,
1773
    HV_CPU_WEIGHT: 256,
1774
    HV_VIF_TYPE: HT_HVM_VIF_IOEMU,
1775
    HV_VIF_SCRIPT: "",
1776
    HV_VIRIDIAN: False,
1777
    HV_XEN_CMD: XEN_CMD_XM,
1778
    HV_XEN_CPUID: "",
1779
    HV_SOUNDHW: "",
1780
    },
1781
  HT_KVM: {
1782
    HV_KVM_PATH: KVM_PATH,
1783
    HV_KERNEL_PATH: KVM_KERNEL,
1784
    HV_INITRD_PATH: "",
1785
    HV_KERNEL_ARGS: "ro",
1786
    HV_ROOT_PATH: "/dev/vda1",
1787
    HV_ACPI: True,
1788
    HV_SERIAL_CONSOLE: True,
1789
    HV_SERIAL_SPEED: 38400,
1790
    HV_VNC_BIND_ADDRESS: "",
1791
    HV_VNC_TLS: False,
1792
    HV_VNC_X509: "",
1793
    HV_VNC_X509_VERIFY: False,
1794
    HV_VNC_PASSWORD_FILE: "",
1795
    HV_KVM_SPICE_BIND: "",
1796
    HV_KVM_SPICE_IP_VERSION: IFACE_NO_IP_VERSION_SPECIFIED,
1797
    HV_KVM_SPICE_PASSWORD_FILE: "",
1798
    HV_KVM_SPICE_LOSSLESS_IMG_COMPR: "",
1799
    HV_KVM_SPICE_JPEG_IMG_COMPR: "",
1800
    HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR: "",
1801
    HV_KVM_SPICE_STREAMING_VIDEO_DETECTION: "",
1802
    HV_KVM_SPICE_AUDIO_COMPR: True,
1803
    HV_KVM_SPICE_USE_TLS: False,
1804
    HV_KVM_SPICE_TLS_CIPHERS: OPENSSL_CIPHERS,
1805
    HV_KVM_SPICE_USE_VDAGENT: True,
1806
    HV_KVM_FLOPPY_IMAGE_PATH: "",
1807
    HV_CDROM_IMAGE_PATH: "",
1808
    HV_KVM_CDROM2_IMAGE_PATH: "",
1809
    HV_BOOT_ORDER: HT_BO_DISK,
1810
    HV_NIC_TYPE: HT_NIC_PARAVIRTUAL,
1811
    HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
1812
    HV_KVM_CDROM_DISK_TYPE: "",
1813
    HV_USB_MOUSE: "",
1814
    HV_KEYMAP: "",
1815
    HV_MIGRATION_PORT: 8102,
1816
    HV_MIGRATION_BANDWIDTH: 32, # MiB/s
1817
    HV_MIGRATION_DOWNTIME: 30,  # ms
1818
    HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1819
    HV_USE_LOCALTIME: False,
1820
    HV_DISK_CACHE: HT_CACHE_DEFAULT,
1821
    HV_SECURITY_MODEL: HT_SM_NONE,
1822
    HV_SECURITY_DOMAIN: "",
1823
    HV_KVM_FLAG: "",
1824
    HV_VHOST_NET: False,
1825
    HV_KVM_USE_CHROOT: False,
1826
    HV_MEM_PATH: "",
1827
    HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1828
    HV_CPU_MASK: CPU_PINNING_ALL,
1829
    HV_CPU_TYPE: "",
1830
    HV_CPU_CORES: 0,
1831
    HV_CPU_THREADS: 0,
1832
    HV_CPU_SOCKETS: 0,
1833
    HV_SOUNDHW: "",
1834
    HV_USB_DEVICES: "",
1835
    HV_VGA: "",
1836
    HV_KVM_EXTRA: "",
1837
    HV_KVM_MACHINE_VERSION: "",
1838
    HV_VNET_HDR: True,
1839
    },
1840
  HT_FAKE: {
1841
    HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1842
  },
1843
  HT_CHROOT: {
1844
    HV_INIT_SCRIPT: "/ganeti-chroot",
1845
    },
1846
  HT_LXC: {
1847
    HV_CPU_MASK: "",
1848
    },
1849
  }
1850

    
1851
HVC_GLOBALS = compat.UniqueFrozenset([
1852
  HV_MIGRATION_PORT,
1853
  HV_MIGRATION_BANDWIDTH,
1854
  HV_MIGRATION_MODE,
1855
  HV_XEN_CMD,
1856
  ])
1857

    
1858
BEC_DEFAULTS = {
1859
  BE_MINMEM: 128,
1860
  BE_MAXMEM: 128,
1861
  BE_VCPUS: 1,
1862
  BE_AUTO_BALANCE: True,
1863
  BE_ALWAYS_FAILOVER: False,
1864
  BE_SPINDLE_USE: 1,
1865
  }
1866

    
1867
NDC_DEFAULTS = {
1868
  ND_OOB_PROGRAM: "",
1869
  ND_SPINDLE_COUNT: 1,
1870
  ND_EXCLUSIVE_STORAGE: False,
1871
  ND_OVS: False,
1872
  ND_OVS_NAME: DEFAULT_OVS,
1873
  ND_OVS_LINK: ""
1874
  }
1875

    
1876
NDC_GLOBALS = compat.UniqueFrozenset([
1877
  ND_EXCLUSIVE_STORAGE,
1878
  ])
1879

    
1880
DISK_LD_DEFAULTS = {
1881
  DT_DRBD8: {
1882
    LDP_RESYNC_RATE: CLASSIC_DRBD_SYNC_SPEED,
1883
    LDP_BARRIERS: _constants.DRBD_BARRIERS,
1884
    LDP_NO_META_FLUSH: _constants.DRBD_NO_META_FLUSH,
1885
    LDP_DEFAULT_METAVG: DEFAULT_VG,
1886
    LDP_DISK_CUSTOM: "",
1887
    LDP_NET_CUSTOM: "",
1888
    LDP_PROTOCOL: DRBD_DEFAULT_NET_PROTOCOL,
1889
    LDP_DYNAMIC_RESYNC: False,
1890

    
1891
    # The default values for the DRBD dynamic resync speed algorithm
1892
    # are taken from the drbsetup 8.3.11 man page, except for
1893
    # c-plan-ahead (that we don't need to set to 0, because we have a
1894
    # separate option to enable it) and for c-max-rate, that we cap to
1895
    # the default value for the static resync rate.
1896
    LDP_PLAN_AHEAD: 20, # ds
1897
    LDP_FILL_TARGET: 0, # sectors
1898
    LDP_DELAY_TARGET: 1, # ds
1899
    LDP_MAX_RATE: CLASSIC_DRBD_SYNC_SPEED, # KiB/s
1900
    LDP_MIN_RATE: 4 * 1024, # KiB/s
1901
    },
1902
  DT_PLAIN: {
1903
    LDP_STRIPES: _constants.LVM_STRIPECOUNT
1904
    },
1905
  DT_FILE: {},
1906
  DT_SHARED_FILE: {},
1907
  DT_BLOCK: {},
1908
  DT_RBD: {
1909
    LDP_POOL: "rbd",
1910
    LDP_ACCESS: DISK_KERNELSPACE,
1911
    },
1912
  DT_EXT: {},
1913
  }
1914

    
1915
# readability shortcuts
1916
_LV_DEFAULTS = DISK_LD_DEFAULTS[DT_PLAIN]
1917
_DRBD_DEFAULTS = DISK_LD_DEFAULTS[DT_DRBD8]
1918

    
1919
DISK_DT_DEFAULTS = {
1920
  DT_PLAIN: {
1921
    LV_STRIPES: DISK_LD_DEFAULTS[DT_PLAIN][LDP_STRIPES],
1922
    },
1923
  DT_DRBD8: {
1924
    DRBD_RESYNC_RATE: _DRBD_DEFAULTS[LDP_RESYNC_RATE],
1925
    DRBD_DATA_STRIPES: _LV_DEFAULTS[LDP_STRIPES],
1926
    DRBD_META_STRIPES: _LV_DEFAULTS[LDP_STRIPES],
1927
    DRBD_DISK_BARRIERS: _DRBD_DEFAULTS[LDP_BARRIERS],
1928
    DRBD_META_BARRIERS: _DRBD_DEFAULTS[LDP_NO_META_FLUSH],
1929
    DRBD_DEFAULT_METAVG: _DRBD_DEFAULTS[LDP_DEFAULT_METAVG],
1930
    DRBD_DISK_CUSTOM: _DRBD_DEFAULTS[LDP_DISK_CUSTOM],
1931
    DRBD_NET_CUSTOM: _DRBD_DEFAULTS[LDP_NET_CUSTOM],
1932
    DRBD_PROTOCOL: _DRBD_DEFAULTS[LDP_PROTOCOL],
1933
    DRBD_DYNAMIC_RESYNC: _DRBD_DEFAULTS[LDP_DYNAMIC_RESYNC],
1934
    DRBD_PLAN_AHEAD: _DRBD_DEFAULTS[LDP_PLAN_AHEAD],
1935
    DRBD_FILL_TARGET: _DRBD_DEFAULTS[LDP_FILL_TARGET],
1936
    DRBD_DELAY_TARGET: _DRBD_DEFAULTS[LDP_DELAY_TARGET],
1937
    DRBD_MAX_RATE: _DRBD_DEFAULTS[LDP_MAX_RATE],
1938
    DRBD_MIN_RATE: _DRBD_DEFAULTS[LDP_MIN_RATE],
1939
    },
1940
  DT_DISKLESS: {},
1941
  DT_FILE: {},
1942
  DT_SHARED_FILE: {},
1943
  DT_BLOCK: {},
1944
  DT_RBD: {
1945
    RBD_POOL: DISK_LD_DEFAULTS[DT_RBD][LDP_POOL],
1946
    RBD_ACCESS: DISK_LD_DEFAULTS[DT_RBD][LDP_ACCESS],
1947
    },
1948
  DT_EXT: {},
1949
  }
1950

    
1951
# we don't want to export the shortcuts
1952
del _LV_DEFAULTS, _DRBD_DEFAULTS
1953

    
1954
NICC_DEFAULTS = {
1955
  NIC_MODE: NIC_MODE_BRIDGED,
1956
  NIC_LINK: DEFAULT_BRIDGE,
1957
  NIC_VLAN: VALUE_HS_NOTHING,
1958
  }
1959

    
1960
# All of the following values are quite arbitrarily - there are no
1961
# "good" defaults, these must be customised per-site
1962
ISPECS_MINMAX_DEFAULTS = {
1963
  ISPECS_MIN: {
1964
    ISPEC_MEM_SIZE: 128,
1965
    ISPEC_CPU_COUNT: 1,
1966
    ISPEC_DISK_COUNT: 1,
1967
    ISPEC_DISK_SIZE: 1024,
1968
    ISPEC_NIC_COUNT: 1,
1969
    ISPEC_SPINDLE_USE: 1,
1970
    },
1971
  ISPECS_MAX: {
1972
    ISPEC_MEM_SIZE: 32768,
1973
    ISPEC_CPU_COUNT: 8,
1974
    ISPEC_DISK_COUNT: MAX_DISKS,
1975
    ISPEC_DISK_SIZE: 1024 * 1024,
1976
    ISPEC_NIC_COUNT: MAX_NICS,
1977
    ISPEC_SPINDLE_USE: 12,
1978
    },
1979
  }
1980
IPOLICY_DEFAULTS = {
1981
  ISPECS_MINMAX: [ISPECS_MINMAX_DEFAULTS],
1982
  ISPECS_STD: {
1983
    ISPEC_MEM_SIZE: 128,
1984
    ISPEC_CPU_COUNT: 1,
1985
    ISPEC_DISK_COUNT: 1,
1986
    ISPEC_DISK_SIZE: 1024,
1987
    ISPEC_NIC_COUNT: 1,
1988
    ISPEC_SPINDLE_USE: 1,
1989
    },
1990
  IPOLICY_DTS: list(DISK_TEMPLATES),
1991
  IPOLICY_VCPU_RATIO: 4.0,
1992
  IPOLICY_SPINDLE_RATIO: 32.0,
1993
  }
1994

    
1995
MASTER_POOL_SIZE_DEFAULT = 10
1996

    
1997
# Exclusive storage:
1998
# Error margin used to compare physical disks
1999
PART_MARGIN = .01
2000
# Space reserved when creating instance disks
2001
PART_RESERVED = .02
2002

    
2003
CONFD_PROTOCOL_VERSION = _constants.CONFD_PROTOCOL_VERSION
2004

    
2005
CONFD_REQ_PING = _constants.CONFD_REQ_PING
2006
CONFD_REQ_NODE_ROLE_BYNAME = _constants.CONFD_REQ_NODE_ROLE_BYNAME
2007
CONFD_REQ_NODE_PIP_BY_INSTANCE_IP = _constants.CONFD_REQ_NODE_PIP_BY_INSTANCE_IP
2008
CONFD_REQ_CLUSTER_MASTER = _constants.CONFD_REQ_CLUSTER_MASTER
2009
CONFD_REQ_NODE_PIP_LIST = _constants.CONFD_REQ_NODE_PIP_LIST
2010
CONFD_REQ_MC_PIP_LIST = _constants.CONFD_REQ_MC_PIP_LIST
2011
CONFD_REQ_INSTANCES_IPS_LIST = _constants.CONFD_REQ_INSTANCES_IPS_LIST
2012
CONFD_REQ_NODE_DRBD = _constants.CONFD_REQ_NODE_DRBD
2013
CONFD_REQ_NODE_INSTANCES = _constants.CONFD_REQ_NODE_INSTANCES
2014
CONFD_REQS = _constants.CONFD_REQS
2015

    
2016
# Confd request query fields. These are used to narrow down queries.
2017
# These must be strings rather than integers, because json-encoding
2018
# converts them to strings anyway, as they're used as dict-keys.
2019
CONFD_REQQ_LINK = _constants.CONFD_REQQ_LINK
2020
CONFD_REQQ_IP = _constants.CONFD_REQQ_IP
2021
CONFD_REQQ_IPLIST = _constants.CONFD_REQQ_IPLIST
2022
CONFD_REQQ_FIELDS = _constants.CONFD_REQQ_FIELDS
2023

    
2024
# FIXME: perhaps update code that uses these constants to deal with
2025
# integers instead of strings
2026
CONFD_REQFIELD_NAME = str(_constants.CONFD_REQFIELD_NAME)
2027
CONFD_REQFIELD_IP = str(_constants.CONFD_REQFIELD_IP)
2028
CONFD_REQFIELD_MNODE_PIP = str(_constants.CONFD_REQFIELD_MNODE_PIP)
2029

    
2030
CONFD_REPL_STATUS_OK = _constants.CONFD_REPL_STATUS_OK
2031
CONFD_REPL_STATUS_ERROR = _constants.CONFD_REPL_STATUS_ERROR
2032
CONFD_REPL_STATUS_NOTIMPLEMENTED = _constants.CONFD_REPL_STATUS_NOTIMPLEMENTED
2033
CONFD_REPL_STATUSES = _constants.CONFD_REPL_STATUSES
2034

    
2035
CONFD_NODE_ROLE_MASTER = _constants.CONFD_NODE_ROLE_MASTER
2036
CONFD_NODE_ROLE_CANDIDATE = _constants.CONFD_NODE_ROLE_CANDIDATE
2037
CONFD_NODE_ROLE_OFFLINE = _constants.CONFD_NODE_ROLE_OFFLINE
2038
CONFD_NODE_ROLE_DRAINED = _constants.CONFD_NODE_ROLE_DRAINED
2039
CONFD_NODE_ROLE_REGULAR = _constants.CONFD_NODE_ROLE_REGULAR
2040

    
2041
CONFD_ERROR_UNKNOWN_ENTRY = _constants.CONFD_ERROR_UNKNOWN_ENTRY
2042
CONFD_ERROR_INTERNAL = _constants.CONFD_ERROR_INTERNAL
2043
CONFD_ERROR_ARGUMENT = _constants.CONFD_ERROR_ARGUMENT
2044

    
2045
# Each request is "salted" by the current timestamp.
2046
# This constants decides how many seconds of skew to accept.
2047
# TODO: make this a default and allow the value to be more configurable
2048
CONFD_MAX_CLOCK_SKEW = _constants.CONFD_MAX_CLOCK_SKEW
2049

    
2050
# When we haven't reloaded the config for more than this amount of
2051
# seconds, we force a test to see if inotify is betraying us. Using a
2052
# prime number to ensure we get less chance of 'same wakeup' with
2053
# other processes.
2054
CONFD_CONFIG_RELOAD_TIMEOUT = _constants.CONFD_CONFIG_RELOAD_TIMEOUT
2055

    
2056
# If we receive more than one update in this amount of microseconds,
2057
# we move to polling every RATELIMIT seconds, rather than relying on
2058
# inotify, to be able to serve more requests.
2059
CONFD_CONFIG_RELOAD_RATELIMIT = _constants.CONFD_CONFIG_RELOAD_RATELIMIT
2060

    
2061
# Magic number prepended to all confd queries.
2062
# This allows us to distinguish different types of confd protocols and handle
2063
# them. For example by changing this we can move the whole payload to be
2064
# compressed, or move away from json.
2065
CONFD_MAGIC_FOURCC = _constants.CONFD_MAGIC_FOURCC
2066

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

    
2072
# Timeout in seconds to expire pending query request in the confd client
2073
# library. We don't actually expect any answer more than 10 seconds after we
2074
# sent a request.
2075
CONFD_CLIENT_EXPIRE_TIMEOUT = _constants.CONFD_CLIENT_EXPIRE_TIMEOUT
2076

    
2077
# Maximum UDP datagram size.
2078
# On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
2079
# On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
2080
#   (assuming we can't use jumbo frames)
2081
# We just set this to 60K, which should be enough
2082
MAX_UDP_DATA_SIZE = 61440
2083

    
2084
# User-id pool minimum/maximum acceptable user-ids.
2085
UIDPOOL_UID_MIN = 0
2086
UIDPOOL_UID_MAX = 2 ** 32 - 1 # Assuming 32 bit user-ids
2087

    
2088
# Name or path of the pgrep command
2089
PGREP = "pgrep"
2090

    
2091
# Name of the node group that gets created at cluster init or upgrade
2092
INITIAL_NODE_GROUP_NAME = "default"
2093

    
2094
# Possible values for NodeGroup.alloc_policy
2095
ALLOC_POLICY_PREFERRED = _constants.ALLOC_POLICY_PREFERRED
2096
ALLOC_POLICY_LAST_RESORT = _constants.ALLOC_POLICY_LAST_RESORT
2097
ALLOC_POLICY_UNALLOCABLE = _constants.ALLOC_POLICY_UNALLOCABLE
2098
VALID_ALLOC_POLICIES = _constants.VALID_ALLOC_POLICIES
2099

    
2100
# Temporary external/shared storage parameters
2101
BLOCKDEV_DRIVER_MANUAL = _constants.BLOCKDEV_DRIVER_MANUAL
2102

    
2103
# qemu-img path, required for ovfconverter
2104
QEMUIMG_PATH = _constants.QEMUIMG_PATH
2105

    
2106
# Whether htools was enabled at compilation time
2107
HTOOLS = _constants.HTOOLS
2108
# The hail iallocator
2109
IALLOC_HAIL = "hail"
2110

    
2111
# Fake opcodes for functions that have hooks attached to them via
2112
# backend.RunLocalHooks
2113
FAKE_OP_MASTER_TURNUP = "OP_CLUSTER_IP_TURNUP"
2114
FAKE_OP_MASTER_TURNDOWN = "OP_CLUSTER_IP_TURNDOWN"
2115

    
2116
# SSH key types
2117
SSHK_RSA = "rsa"
2118
SSHK_DSA = "dsa"
2119
SSHK_ALL = compat.UniqueFrozenset([SSHK_RSA, SSHK_DSA])
2120

    
2121
# SSH authorized key types
2122
SSHAK_RSA = "ssh-rsa"
2123
SSHAK_DSS = "ssh-dss"
2124
SSHAK_ALL = compat.UniqueFrozenset([SSHAK_RSA, SSHAK_DSS])
2125

    
2126
# SSH setup
2127
SSHS_CLUSTER_NAME = "cluster_name"
2128
SSHS_SSH_HOST_KEY = "ssh_host_key"
2129
SSHS_SSH_ROOT_KEY = "ssh_root_key"
2130
SSHS_NODE_DAEMON_CERTIFICATE = "node_daemon_certificate"
2131

    
2132
#: Key files for SSH daemon
2133
SSH_DAEMON_KEYFILES = {
2134
  SSHK_RSA: (pathutils.SSH_HOST_RSA_PRIV, pathutils.SSH_HOST_RSA_PUB),
2135
  SSHK_DSA: (pathutils.SSH_HOST_DSA_PRIV, pathutils.SSH_HOST_DSA_PUB),
2136
  }
2137

    
2138
# Node daemon setup
2139
NDS_CLUSTER_NAME = "cluster_name"
2140
NDS_NODE_DAEMON_CERTIFICATE = "node_daemon_certificate"
2141
NDS_SSCONF = "ssconf"
2142
NDS_START_NODE_DAEMON = "start_node_daemon"
2143

    
2144
# Path generating random UUID
2145
RANDOM_UUID_FILE = _constants.RANDOM_UUID_FILE
2146

    
2147
# Regex string for verifying a UUID
2148
UUID_REGEX = "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
2149

    
2150
# Auto-repair tag prefixes
2151
AUTO_REPAIR_TAG_PREFIX = _constants.AUTO_REPAIR_TAG_PREFIX
2152
AUTO_REPAIR_TAG_ENABLED = _constants.AUTO_REPAIR_TAG_ENABLED
2153
AUTO_REPAIR_TAG_SUSPENDED = _constants.AUTO_REPAIR_TAG_SUSPENDED
2154
AUTO_REPAIR_TAG_PENDING = _constants.AUTO_REPAIR_TAG_PENDING
2155
AUTO_REPAIR_TAG_RESULT = _constants.AUTO_REPAIR_TAG_RESULT
2156

    
2157
# Auto-repair levels
2158
AUTO_REPAIR_FIX_STORAGE = _constants.AUTO_REPAIR_FIX_STORAGE
2159
AUTO_REPAIR_MIGRATE = _constants.AUTO_REPAIR_MIGRATE
2160
AUTO_REPAIR_FAILOVER = _constants.AUTO_REPAIR_FAILOVER
2161
AUTO_REPAIR_REINSTALL = _constants.AUTO_REPAIR_REINSTALL
2162
AUTO_REPAIR_ALL_TYPES = _constants.AUTO_REPAIR_ALL_TYPES
2163

    
2164
# Auto-repair results
2165
AUTO_REPAIR_SUCCESS = _constants.AUTO_REPAIR_SUCCESS
2166
AUTO_REPAIR_FAILURE = _constants.AUTO_REPAIR_FAILURE
2167
AUTO_REPAIR_ENOPERM = _constants.AUTO_REPAIR_ENOPERM
2168
AUTO_REPAIR_ALL_RESULTS = _constants.AUTO_REPAIR_ALL_RESULTS
2169

    
2170
# The version identifier for builtin data collectors
2171
BUILTIN_DATA_COLLECTOR_VERSION = _constants.BUILTIN_DATA_COLLECTOR_VERSION
2172

    
2173
# The reason trail opcode parameter name
2174
OPCODE_REASON = _constants.OPCODE_REASON
2175

    
2176
# The source reasons for the execution of an OpCode
2177
OPCODE_REASON_SRC_CLIENT = "gnt:client"
2178
OPCODE_REASON_SRC_NODED = "gnt:daemon:noded"
2179
OPCODE_REASON_SRC_OPCODE = "gnt:opcode"
2180
OPCODE_REASON_SRC_RLIB2 = "gnt:library:rlib2"
2181
OPCODE_REASON_SRC_USER = "gnt:user"
2182

    
2183
OPCODE_REASON_SOURCES = compat.UniqueFrozenset([
2184
  OPCODE_REASON_SRC_CLIENT,
2185
  OPCODE_REASON_SRC_NODED,
2186
  OPCODE_REASON_SRC_OPCODE,
2187
  OPCODE_REASON_SRC_RLIB2,
2188
  OPCODE_REASON_SRC_USER,
2189
  ])
2190

    
2191
DISKSTATS_FILE = _constants.DISKSTATS_FILE
2192

    
2193
# CPU load collector variables
2194
STAT_FILE = _constants.STAT_FILE
2195
CPUAVGLOAD_BUFFER_SIZE = _constants.CPUAVGLOAD_BUFFER_SIZE
2196
CPUAVGLOAD_WINDOW_SIZE = _constants.CPUAVGLOAD_WINDOW_SIZE
2197

    
2198
# Mond's variable for periodical data collection
2199
MOND_TIME_INTERVAL = _constants.MOND_TIME_INTERVAL
2200

    
2201
# MonD's latest API version
2202
MOND_LATEST_API_VERSION = 1
2203

    
2204
# Timeouts for upgrades
2205

    
2206
UPGRADE_QUEUE_DRAIN_TIMEOUT = _constants.UPGRADE_QUEUE_DRAIN_TIMEOUT
2207
UPGRADE_QUEUE_POLL_INTERVAL = _constants.UPGRADE_QUEUE_POLL_INTERVAL
2208

    
2209
# Do not re-export imported modules
2210
del re, _vcsversion, _constants, socket, pathutils, compat
2211

    
2212

    
2213
ALLOCATABLE_KEY = "allocatable"
2214
FAILED_KEY = "failed"