Statistics
| Branch: | Tag: | Revision:

root / lib / constants.py @ b7b8ff87

History | View | Annotate | Download (61.1 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 = _constants.EXPORT_VERSION
41
RAPI_VERSION = _constants.RAPI_VERSION
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_SEP = _constants.CPU_PINNING_SEP
76
CPU_PINNING_ALL = _constants.CPU_PINNING_ALL
77
CPU_PINNING_ALL_VAL = _constants.CPU_PINNING_ALL_VAL
78
CPU_PINNING_OFF = _constants.CPU_PINNING_OFF
79

    
80
CPU_PINNING_ALL_XEN = _constants.CPU_PINNING_ALL_XEN
81

    
82
CPU_PINNING_ALL_KVM = _constants.CPU_PINNING_ALL_KVM
83

    
84
DD_CMD = _constants.DD_CMD
85
MAX_WIPE_CHUNK = _constants.MAX_WIPE_CHUNK
86
MIN_WIPE_CHUNK_PERCENT = _constants.MIN_WIPE_CHUNK_PERCENT
87

    
88
RUN_DIRS_MODE = _constants.RUN_DIRS_MODE
89
SECURE_DIR_MODE = _constants.SECURE_DIR_MODE
90
SECURE_FILE_MODE = _constants.SECURE_FILE_MODE
91
ADOPTABLE_BLOCKDEV_ROOT = _constants.ADOPTABLE_BLOCKDEV_ROOT
92
ENABLE_CONFD = _constants.ENABLE_CONFD
93
ENABLE_MOND = _constants.ENABLE_MOND
94
ENABLE_SPLIT_QUERY = _constants.ENABLE_SPLIT_QUERY
95
ENABLE_RESTRICTED_COMMANDS = _constants.ENABLE_RESTRICTED_COMMANDS
96

    
97
# SSH constants
98
SSH = _constants.SSH
99
SCP = _constants.SCP
100

    
101
NODED = _constants.NODED
102
CONFD = _constants.CONFD
103
LUXID = _constants.LUXID
104
RAPI = _constants.RAPI
105
MASTERD = _constants.MASTERD
106
MOND = _constants.MOND
107

    
108
DAEMONS = _constants.DAEMONS
109

    
110
DAEMONS_PORTS = _constants.DAEMONS_PORTS
111

    
112
DEFAULT_NODED_PORT = _constants.DEFAULT_NODED_PORT
113
DEFAULT_CONFD_PORT = _constants.DEFAULT_CONFD_PORT
114
DEFAULT_MOND_PORT = _constants.DEFAULT_MOND_PORT
115
DEFAULT_RAPI_PORT = _constants.DEFAULT_RAPI_PORT
116

    
117
FIRST_DRBD_PORT = _constants.FIRST_DRBD_PORT
118
LAST_DRBD_PORT = _constants.LAST_DRBD_PORT
119

    
120
DAEMONS_LOGBASE = _constants.DAEMONS_LOGBASE
121

    
122
DAEMONS_LOGFILES = \
123
    dict((daemon, pathutils.GetLogFilename(DAEMONS_LOGBASE[daemon]))
124
         for daemon in DAEMONS_LOGBASE)
125

    
126
# Some daemons might require more than one logfile.
127
# Specifically, right now only the Haskell http library "snap", used by the
128
# monitoring daemon, requires multiple log files.
129

    
130
# These are the only valid reasons for having an extra logfile
131
EXTRA_LOGREASON_ACCESS = "access"
132
EXTRA_LOGREASON_ERROR = "error"
133

    
134
VALID_EXTRA_LOGREASONS = compat.UniqueFrozenset([
135
  EXTRA_LOGREASON_ACCESS,
136
  EXTRA_LOGREASON_ERROR,
137
  ])
138

    
139
# These are the extra logfiles, grouped by daemon
140
DAEMONS_EXTRA_LOGBASE = {
141
  MOND: {
142
    EXTRA_LOGREASON_ACCESS: _constants.EXTRA_LOGREASON_ACCESS,
143
    EXTRA_LOGREASON_ERROR: _constants.EXTRA_LOGREASON_ERROR,
144
    }
145
  }
146

    
147
DAEMONS_EXTRA_LOGFILES = \
148
  dict((daemon, dict((extra,
149
       pathutils.GetLogFilename(DAEMONS_EXTRA_LOGBASE[daemon][extra]))
150
       for extra in DAEMONS_EXTRA_LOGBASE[daemon]))
151
         for daemon in DAEMONS_EXTRA_LOGBASE)
152

    
153
DEV_CONSOLE = _constants.DEV_CONSOLE
154

    
155
PROC_MOUNTS = _constants.PROC_MOUNTS
156

    
157
LUXI_EOM = _constants.LUXI_EOM
158
LUXI_VERSION = _constants.LUXI_VERSION
159
LUXI_OVERRIDE = _constants.LUXI_OVERRIDE
160
LUXI_OVERRIDE_MASTER = _constants.LUXI_OVERRIDE_MASTER
161
LUXI_OVERRIDE_QUERY = _constants.LUXI_OVERRIDE_QUERY
162
# one of "no", "yes", "only"
163
SYSLOG_USAGE = _constants.SYSLOG_USAGE
164
SYSLOG_NO = _constants.SYSLOG_NO
165
SYSLOG_YES = _constants.SYSLOG_YES
166
SYSLOG_ONLY = _constants.SYSLOG_ONLY
167
SYSLOG_SOCKET = _constants.SYSLOG_SOCKET
168

    
169
EXPORT_CONF_FILE = _constants.EXPORT_CONF_FILE
170

    
171
XEN_BOOTLOADER = _constants.XEN_BOOTLOADER
172
XEN_KERNEL = _constants.XEN_KERNEL
173
XEN_INITRD = _constants.XEN_INITRD
174
XEN_CMD_XM = _constants.XEN_CMD_XM
175
XEN_CMD_XL = _constants.XEN_CMD_XL
176
KNOWN_XEN_COMMANDS = _constants.KNOWN_XEN_COMMANDS
177

    
178
# When the Xen toolstack used is "xl", live migration requires the source host
179
# to connect to the target host via ssh (xl runs this command). We need to pass
180
# the command xl runs some extra info so that it can use Ganeti's key
181
# verification and not fail. Note that this string is incomplete: it must be
182
# filled with the cluster name before being used.
183
XL_SSH_CMD = ("ssh -l %s -oGlobalKnownHostsFile=%s"
184
              " -oUserKnownHostsFile=/dev/null"
185
              " -oCheckHostIp=no -oStrictHostKeyChecking=yes"
186
              " -oHostKeyAlias=%%s") % (SSH_LOGIN_USER,
187
                                        pathutils.SSH_KNOWN_HOSTS_FILE)
188

    
189
KVM_PATH = _constants.KVM_PATH
190
KVM_KERNEL = _constants.KVM_KERNEL
191
SOCAT_PATH = _constants.SOCAT_PATH
192
SOCAT_USE_ESCAPE = _constants.SOCAT_USE_ESCAPE
193
SOCAT_USE_COMPRESS = _constants.SOCAT_USE_COMPRESS
194
SOCAT_ESCAPE_CODE = _constants.SOCAT_ESCAPE_CODE
195

    
196

    
197
CONS_SSH = _constants.CONS_SSH
198
CONS_VNC = _constants.CONS_VNC
199
CONS_SPICE = _constants.CONS_SPICE
200
CONS_MESSAGE = _constants.CONS_MESSAGE
201
CONS_ALL = _constants.CONS_ALL
202

    
203
RSA_KEY_BITS = _constants.RSA_KEY_BITS
204
OPENSSL_CIPHERS = _constants.OPENSSL_CIPHERS
205

    
206
X509_CERT_SIGN_DIGEST = _constants.X509_CERT_SIGN_DIGEST
207
X509_CERT_DEFAULT_VALIDITY = _constants.X509_CERT_DEFAULT_VALIDITY
208
X509_CERT_CN = _constants.X509_CERT_CN
209
X509_CERT_SIGNATURE_HEADER = _constants.X509_CERT_SIGNATURE_HEADER
210

    
211
# Import/export daemon mode
212
IEM_IMPORT = _constants.IEM_IMPORT
213
IEM_EXPORT = _constants.IEM_EXPORT
214

    
215
# Import/export transport compression
216
IEC_NONE = _constants.IEC_NONE
217
IEC_GZIP = _constants.IEC_GZIP
218
IEC_ALL = _constants.IEC_ALL
219

    
220
IE_CUSTOM_SIZE = _constants.IE_CUSTOM_SIZE
221

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

    
224
IEIO_FILE = _constants.IEIO_FILE
225
IEIO_RAW_DISK = _constants.IEIO_RAW_DISK
226
IEIO_SCRIPT = _constants.IEIO_SCRIPT
227

    
228
VALUE_DEFAULT = "default"
229
VALUE_AUTO = "auto"
230
VALUE_GENERATE = "generate"
231
VALUE_NONE = "none"
232
VALUE_TRUE = "true"
233
VALUE_FALSE = "false"
234
VALUE_HS_NOTHING = {"Nothing": None}
235

    
236

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

    
240
HOOKS_PHASE_PRE = _constants.HOOKS_PHASE_PRE
241
HOOKS_PHASE_POST = _constants.HOOKS_PHASE_POST
242
HOOKS_NAME_CFGUPDATE = _constants.HOOKS_NAME_CFGUPDATE
243
HOOKS_NAME_WATCHER = _constants.HOOKS_NAME_WATCHER
244
HOOKS_VERSION = _constants.HOOKS_VERSION
245
HOOKS_PATH = _constants.HOOKS_PATH
246

    
247
HTYPE_CLUSTER = _constants.HTYPE_CLUSTER
248
HTYPE_NODE = _constants.HTYPE_NODE
249
HTYPE_GROUP = _constants.HTYPE_GROUP
250
HTYPE_INSTANCE = _constants.HTYPE_INSTANCE
251
HTYPE_NETWORK = _constants.HTYPE_NETWORK
252

    
253
HKR_SKIP = _constants.HKR_SKIP
254
HKR_FAIL = _constants.HKR_FAIL
255
HKR_SUCCESS = _constants.HKR_SUCCESS
256

    
257
# Storage types
258
ST_BLOCK = _constants.ST_BLOCK
259
ST_DISKLESS = _constants.ST_DISKLESS
260
ST_EXT = _constants.ST_EXT
261
ST_FILE = _constants.ST_FILE
262
ST_LVM_PV = _constants.ST_LVM_PV
263
ST_LVM_VG = _constants.ST_LVM_VG
264
ST_RADOS = _constants.ST_RADOS
265
STORAGE_TYPES = _constants.STORAGE_TYPES
266
STS_REPORT = _constants.STS_REPORT
267

    
268
# Storage fields
269
# first two are valid in LU context only, not passed to backend
270
SF_NODE = _constants.SF_NODE
271
SF_TYPE = _constants.SF_TYPE
272
# and the rest are valid in backend
273
SF_NAME = _constants.SF_NAME
274
SF_SIZE = _constants.SF_SIZE
275
SF_FREE = _constants.SF_FREE
276
SF_USED = _constants.SF_USED
277
SF_ALLOCATABLE = _constants.SF_ALLOCATABLE
278
VALID_STORAGE_FIELDS = _constants.VALID_STORAGE_FIELDS
279
MODIFIABLE_STORAGE_FIELDS = _constants.MODIFIABLE_STORAGE_FIELDS
280

    
281
SO_FIX_CONSISTENCY = _constants.SO_FIX_CONSISTENCY
282
VALID_STORAGE_OPERATIONS = _constants.VALID_STORAGE_OPERATIONS
283

    
284
VF_DEV = _constants.VF_DEV
285
VF_INSTANCE = _constants.VF_INSTANCE
286
VF_NAME = _constants.VF_NAME
287
VF_NODE = _constants.VF_NODE
288
VF_PHYS = _constants.VF_PHYS
289
VF_SIZE = _constants.VF_SIZE
290
VF_VG = _constants.VF_VG
291

    
292
LDS_OKAY = _constants.LDS_OKAY
293
LDS_UNKNOWN = _constants.LDS_UNKNOWN
294
LDS_FAULTY = _constants.LDS_FAULTY
295
LDS_NAMES = _constants.LDS_NAMES
296

    
297
# disk template types
298
DT_BLOCK = _constants.DT_BLOCK
299
DT_DISKLESS = _constants.DT_DISKLESS
300
DT_DRBD8 = _constants.DT_DRBD8
301
DT_EXT = _constants.DT_EXT
302
DT_FILE = _constants.DT_FILE
303
DT_PLAIN = _constants.DT_PLAIN
304
DT_RBD = _constants.DT_RBD
305
DT_SHARED_FILE = _constants.DT_SHARED_FILE
306
DISK_TEMPLATE_PREFERENCE = _constants.DISK_TEMPLATE_PREFERENCE
307
DISK_TEMPLATES = _constants.DISK_TEMPLATES
308
DEFAULT_ENABLED_DISK_TEMPLATES = _constants.DEFAULT_ENABLED_DISK_TEMPLATES
309

    
310
MAP_DISK_TEMPLATE_STORAGE_TYPE = _constants.MAP_DISK_TEMPLATE_STORAGE_TYPE
311

    
312
DTS_INT_MIRROR = _constants.DTS_INT_MIRROR
313
DTS_EXT_MIRROR = _constants.DTS_EXT_MIRROR
314
DTS_NOT_LVM = _constants.DTS_NOT_LVM
315
DTS_GROWABLE = _constants.DTS_GROWABLE
316
DTS_MAY_ADOPT = _constants.DTS_MAY_ADOPT
317
DTS_MUST_ADOPT = _constants.DTS_MUST_ADOPT
318
DTS_MIRRORED = _constants.DTS_MIRRORED
319
DTS_FILEBASED = _constants.DTS_FILEBASED
320
DTS_COPYABLE = _constants.DTS_COPYABLE
321
DTS_EXCL_STORAGE = _constants.DTS_EXCL_STORAGE
322
DTS_NO_FREE_SPACE_CHECK = _constants.DTS_NO_FREE_SPACE_CHECK
323
DTS_BLOCK = _constants.DTS_BLOCK
324

    
325
DRBD_HMAC_ALG = _constants.DRBD_HMAC_ALG
326
DRBD_DEFAULT_NET_PROTOCOL = _constants.DRBD_DEFAULT_NET_PROTOCOL
327
DRBD_MIGRATION_NET_PROTOCOL = _constants.DRBD_MIGRATION_NET_PROTOCOL
328
DRBD_STATUS_FILE = _constants.DRBD_STATUS_FILE
329
DRBD_META_SIZE = _constants.DRBD_META_SIZE
330

    
331
DRBD_B_NONE = _constants.DRBD_B_NONE
332
DRBD_B_DISK_BARRIERS = _constants.DRBD_B_DISK_BARRIERS
333
DRBD_B_DISK_DRAIN = _constants.DRBD_B_DISK_DRAIN
334
DRBD_B_DISK_FLUSH = _constants.DRBD_B_DISK_FLUSH
335

    
336
# Valid barrier combinations: "n" or any non-null subset of "bfd"
337
DRBD_VALID_BARRIER_OPT = compat.UniqueFrozenset([
338
  frozenset([DRBD_B_NONE]),
339
  frozenset([DRBD_B_DISK_BARRIERS]),
340
  frozenset([DRBD_B_DISK_DRAIN]),
341
  frozenset([DRBD_B_DISK_FLUSH]),
342
  frozenset([DRBD_B_DISK_DRAIN, DRBD_B_DISK_FLUSH]),
343
  frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_DRAIN]),
344
  frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_FLUSH]),
345
  frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_FLUSH, DRBD_B_DISK_DRAIN]),
346
  ])
347

    
348
RBD_CMD = _constants.RBD_CMD
349

    
350
FD_BLKTAP = _constants.FD_BLKTAP
351
FD_LOOP = _constants.FD_LOOP
352
FILE_DRIVER = _constants.FILE_DRIVER
353

    
354
LDS_DRBD = _constants.LDS_DRBD
355

    
356
# disk access mode
357
DISK_RDONLY = _constants.DISK_RDONLY
358
DISK_RDWR = _constants.DISK_RDWR
359
DISK_ACCESS_SET = _constants.DISK_ACCESS_SET
360
DISK_USERSPACE = _constants.DISK_USERSPACE
361
DISK_KERNELSPACE = _constants.DISK_KERNELSPACE
362
DISK_VALID_ACCESS_MODES = _constants.DISK_VALID_ACCESS_MODES
363

    
364
REPLACE_DISK_PRI = _constants.REPLACE_DISK_PRI
365
REPLACE_DISK_SEC = _constants.REPLACE_DISK_SEC
366
REPLACE_DISK_CHG = _constants.REPLACE_DISK_CHG
367
REPLACE_DISK_AUTO = _constants.REPLACE_DISK_AUTO
368
REPLACE_MODES = _constants.REPLACE_MODES
369

    
370
# Instance export mode
371
EXPORT_MODE_LOCAL = _constants.EXPORT_MODE_LOCAL
372
EXPORT_MODE_REMOTE = _constants.EXPORT_MODE_REMOTE
373
EXPORT_MODES = _constants.EXPORT_MODES
374

    
375
# instance creation modes
376
INSTANCE_CREATE = _constants.INSTANCE_CREATE
377
INSTANCE_IMPORT = _constants.INSTANCE_IMPORT
378
INSTANCE_REMOTE_IMPORT = _constants.INSTANCE_REMOTE_IMPORT
379
INSTANCE_CREATE_MODES = _constants.INSTANCE_CREATE_MODES
380

    
381
RIE_VERSION = _constants.RIE_VERSION
382
RIE_HANDSHAKE = _constants.RIE_HANDSHAKE
383
RIE_CERT_VALIDITY = _constants.RIE_CERT_VALIDITY
384
RIE_CONNECT_TIMEOUT = _constants.RIE_CONNECT_TIMEOUT
385
RIE_CONNECT_ATTEMPT_TIMEOUT = _constants.RIE_CONNECT_ATTEMPT_TIMEOUT
386
RIE_CONNECT_RETRIES = _constants.RIE_CONNECT_RETRIES
387
CHILD_LINGER_TIMEOUT = _constants.CHILD_LINGER_TIMEOUT
388

    
389
INISECT_EXP = _constants.INISECT_EXP
390
INISECT_INS = _constants.INISECT_INS
391
INISECT_HYP = _constants.INISECT_HYP
392
INISECT_BEP = _constants.INISECT_BEP
393
INISECT_OSP = _constants.INISECT_OSP
394

    
395
# dynamic device modification
396
DDM_ADD = _constants.DDM_ADD
397
DDM_MODIFY = _constants.DDM_MODIFY
398
DDM_REMOVE = _constants.DDM_REMOVE
399
DDMS_VALUES = _constants.DDMS_VALUES
400
DDMS_VALUES_WITH_MODIFY = _constants.DDMS_VALUES_WITH_MODIFY
401
# TODO: DDM_SWAP, DDM_MOVE?
402

    
403
# common exit codes
404
EXIT_SUCCESS = _constants.EXIT_SUCCESS
405
EXIT_FAILURE = _constants.EXIT_FAILURE
406
EXIT_NOTCLUSTER = _constants.EXIT_NOTCLUSTER
407
EXIT_NOTMASTER = _constants.EXIT_NOTMASTER
408
EXIT_NODESETUP_ERROR = _constants.EXIT_NODESETUP_ERROR
409
EXIT_CONFIRMATION = _constants.EXIT_CONFIRMATION # need user confirmation
410

    
411
#: Exit code for query operations with unknown fields
412
EXIT_UNKNOWN_FIELD = _constants.EXIT_UNKNOWN_FIELD
413

    
414
# tags
415
TAG_CLUSTER = _constants.TAG_CLUSTER
416
TAG_NODEGROUP = _constants.TAG_NODEGROUP
417
TAG_NODE = _constants.TAG_NODE
418
TAG_INSTANCE = _constants.TAG_INSTANCE
419
TAG_NETWORK = _constants.TAG_NETWORK
420
VALID_TAG_TYPES = _constants.VALID_TAG_TYPES
421

    
422
MAX_TAG_LEN = _constants.MAX_TAG_LEN
423
MAX_TAGS_PER_OBJ = _constants.MAX_TAGS_PER_OBJ
424

    
425
# others
426
DEFAULT_BRIDGE = _constants.DEFAULT_BRIDGE
427
DEFAULT_OVS = _constants.DEFAULT_OVS
428
CLASSIC_DRBD_SYNC_SPEED = _constants.CLASSIC_DRBD_SYNC_SPEED
429
IP4_ADDRESS_LOCALHOST = _constants.IP4_ADDRESS_LOCALHOST
430
IP4_ADDRESS_ANY = _constants.IP4_ADDRESS_ANY
431
IP6_ADDRESS_LOCALHOST = _constants.IP6_ADDRESS_LOCALHOST
432
IP6_ADDRESS_ANY = _constants.IP6_ADDRESS_ANY
433
IP4_VERSION = _constants.IP4_VERSION
434
IP6_VERSION = _constants.IP6_VERSION
435
VALID_IP_VERSIONS = _constants.VALID_IP_VERSIONS
436
# for export to htools
437
IP4_FAMILY = socket.AF_INET
438
IP6_FAMILY = socket.AF_INET6
439

    
440
TCP_PING_TIMEOUT = _constants.TCP_PING_TIMEOUT
441
DEFAULT_VG = _constants.DEFAULT_VG
442
DEFAULT_DRBD_HELPER = _constants.DEFAULT_DRBD_HELPER
443
MIN_VG_SIZE = _constants.MIN_VG_SIZE
444
DEFAULT_MAC_PREFIX = _constants.DEFAULT_MAC_PREFIX
445
DEFAULT_SHUTDOWN_TIMEOUT = _constants.DEFAULT_SHUTDOWN_TIMEOUT
446
NODE_MAX_CLOCK_SKEW = _constants.NODE_MAX_CLOCK_SKEW
447
# Time for an intra-cluster disk transfer to wait for a connection
448
DISK_TRANSFER_CONNECT_TIMEOUT = 60
449
# Disk index separator
450
DISK_SEPARATOR = _constants.DISK_SEPARATOR
451
IP_COMMAND_PATH = _constants.IP_COMMAND_PATH
452

    
453
RPC_TMO_URGENT = _constants.RPC_TMO_URGENT
454
RPC_TMO_FAST = _constants.RPC_TMO_FAST
455
RPC_TMO_NORMAL = _constants.RPC_TMO_NORMAL
456
RPC_TMO_SLOW = _constants.RPC_TMO_SLOW
457
RPC_TMO_4HRS = _constants.RPC_TMO_4HRS
458
RPC_TMO_1DAY = _constants.RPC_TMO_1DAY
459
RPC_CONNECT_TIMEOUT = _constants.RPC_CONNECT_TIMEOUT
460

    
461
#: Key for job IDs in opcode result
462
JOB_IDS_KEY = "jobs"
463

    
464
# runparts results
465
(RUNPARTS_SKIP,
466
 RUNPARTS_RUN,
467
 RUNPARTS_ERR) = range(3)
468

    
469
RUNPARTS_STATUS = compat.UniqueFrozenset([
470
  RUNPARTS_SKIP,
471
  RUNPARTS_RUN,
472
  RUNPARTS_ERR,
473
  ])
474

    
475
# RPC constants
476
(RPC_ENCODING_NONE,
477
 RPC_ENCODING_ZLIB_BASE64) = range(2)
478

    
479
# os related constants
480
OS_SCRIPT_CREATE = "create"
481
OS_SCRIPT_IMPORT = "import"
482
OS_SCRIPT_EXPORT = "export"
483
OS_SCRIPT_RENAME = "rename"
484
OS_SCRIPT_VERIFY = "verify"
485
OS_SCRIPTS = compat.UniqueFrozenset([
486
  OS_SCRIPT_CREATE,
487
  OS_SCRIPT_IMPORT,
488
  OS_SCRIPT_EXPORT,
489
  OS_SCRIPT_RENAME,
490
  OS_SCRIPT_VERIFY,
491
  ])
492

    
493
OS_API_FILE = "ganeti_api_version"
494
OS_VARIANTS_FILE = "variants.list"
495
OS_PARAMETERS_FILE = "parameters.list"
496

    
497
OS_VALIDATE_PARAMETERS = "parameters"
498
OS_VALIDATE_CALLS = compat.UniqueFrozenset([OS_VALIDATE_PARAMETERS])
499

    
500
# External Storage (ES) related constants
501
ES_ACTION_CREATE = "create"
502
ES_ACTION_REMOVE = "remove"
503
ES_ACTION_GROW = "grow"
504
ES_ACTION_ATTACH = "attach"
505
ES_ACTION_DETACH = "detach"
506
ES_ACTION_SETINFO = "setinfo"
507
ES_ACTION_VERIFY = "verify"
508

    
509
ES_SCRIPT_CREATE = ES_ACTION_CREATE
510
ES_SCRIPT_REMOVE = ES_ACTION_REMOVE
511
ES_SCRIPT_GROW = ES_ACTION_GROW
512
ES_SCRIPT_ATTACH = ES_ACTION_ATTACH
513
ES_SCRIPT_DETACH = ES_ACTION_DETACH
514
ES_SCRIPT_SETINFO = ES_ACTION_SETINFO
515
ES_SCRIPT_VERIFY = ES_ACTION_VERIFY
516
ES_SCRIPTS = frozenset([
517
  ES_SCRIPT_CREATE,
518
  ES_SCRIPT_REMOVE,
519
  ES_SCRIPT_GROW,
520
  ES_SCRIPT_ATTACH,
521
  ES_SCRIPT_DETACH,
522
  ES_SCRIPT_SETINFO,
523
  ES_SCRIPT_VERIFY
524
  ])
525

    
526
ES_PARAMETERS_FILE = "parameters.list"
527

    
528
# reboot types
529
INSTANCE_REBOOT_SOFT = _constants.INSTANCE_REBOOT_SOFT
530
INSTANCE_REBOOT_HARD = _constants.INSTANCE_REBOOT_HARD
531
INSTANCE_REBOOT_FULL = _constants.INSTANCE_REBOOT_FULL
532
REBOOT_TYPES = _constants.REBOOT_TYPES
533

    
534
# instance reboot behaviors
535
INSTANCE_REBOOT_ALLOWED = "reboot"
536
INSTANCE_REBOOT_EXIT = "exit"
537

    
538
REBOOT_BEHAVIORS = compat.UniqueFrozenset([
539
  INSTANCE_REBOOT_ALLOWED,
540
  INSTANCE_REBOOT_EXIT,
541
  ])
542

    
543
VTYPE_STRING = _constants.VTYPE_STRING
544
VTYPE_MAYBE_STRING = _constants.VTYPE_MAYBE_STRING
545
VTYPE_BOOL = _constants.VTYPE_BOOL
546
VTYPE_SIZE = _constants.VTYPE_SIZE
547
VTYPE_INT = _constants.VTYPE_INT
548
ENFORCEABLE_TYPES = _constants.ENFORCEABLE_TYPES
549

    
550
# Constant representing that the user does not specify any IP version
551
IFACE_NO_IP_VERSION_SPECIFIED = 0
552

    
553
VALID_SERIAL_SPEEDS = compat.UniqueFrozenset([
554
  75,
555
  110,
556
  300,
557
  600,
558
  1200,
559
  1800,
560
  2400,
561
  4800,
562
  9600,
563
  14400,
564
  19200,
565
  28800,
566
  38400,
567
  57600,
568
  115200,
569
  230400,
570
  345600,
571
  460800,
572
  ])
573

    
574
# HV parameter names (global namespace)
575
HV_BOOT_ORDER = "boot_order"
576
HV_CDROM_IMAGE_PATH = "cdrom_image_path"
577
HV_KVM_CDROM2_IMAGE_PATH = "cdrom2_image_path"
578
HV_KVM_FLOPPY_IMAGE_PATH = "floppy_image_path"
579
HV_NIC_TYPE = "nic_type"
580
HV_DISK_TYPE = "disk_type"
581
HV_KVM_CDROM_DISK_TYPE = "cdrom_disk_type"
582
HV_VNC_BIND_ADDRESS = "vnc_bind_address"
583
HV_VNC_PASSWORD_FILE = "vnc_password_file"
584
HV_VNC_TLS = "vnc_tls"
585
HV_VNC_X509 = "vnc_x509_path"
586
HV_VNC_X509_VERIFY = "vnc_x509_verify"
587
HV_KVM_SPICE_BIND = "spice_bind"
588
HV_KVM_SPICE_IP_VERSION = "spice_ip_version"
589
HV_KVM_SPICE_PASSWORD_FILE = "spice_password_file"
590
HV_KVM_SPICE_LOSSLESS_IMG_COMPR = "spice_image_compression"
591
HV_KVM_SPICE_JPEG_IMG_COMPR = "spice_jpeg_wan_compression"
592
HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR = "spice_zlib_glz_wan_compression"
593
HV_KVM_SPICE_STREAMING_VIDEO_DETECTION = "spice_streaming_video"
594
HV_KVM_SPICE_AUDIO_COMPR = "spice_playback_compression"
595
HV_KVM_SPICE_USE_TLS = "spice_use_tls"
596
HV_KVM_SPICE_TLS_CIPHERS = "spice_tls_ciphers"
597
HV_KVM_SPICE_USE_VDAGENT = "spice_use_vdagent"
598
HV_ACPI = "acpi"
599
HV_PAE = "pae"
600
HV_USE_BOOTLOADER = "use_bootloader"
601
HV_BOOTLOADER_ARGS = "bootloader_args"
602
HV_BOOTLOADER_PATH = "bootloader_path"
603
HV_KERNEL_ARGS = "kernel_args"
604
HV_KERNEL_PATH = "kernel_path"
605
HV_INITRD_PATH = "initrd_path"
606
HV_ROOT_PATH = "root_path"
607
HV_SERIAL_CONSOLE = "serial_console"
608
HV_SERIAL_SPEED = "serial_speed"
609
HV_USB_MOUSE = "usb_mouse"
610
HV_KEYMAP = "keymap"
611
HV_DEVICE_MODEL = "device_model"
612
HV_INIT_SCRIPT = "init_script"
613
HV_MIGRATION_PORT = "migration_port"
614
HV_MIGRATION_BANDWIDTH = "migration_bandwidth"
615
HV_MIGRATION_DOWNTIME = "migration_downtime"
616
HV_MIGRATION_MODE = "migration_mode"
617
HV_USE_LOCALTIME = "use_localtime"
618
HV_DISK_CACHE = "disk_cache"
619
HV_SECURITY_MODEL = "security_model"
620
HV_SECURITY_DOMAIN = "security_domain"
621
HV_KVM_FLAG = "kvm_flag"
622
HV_VHOST_NET = "vhost_net"
623
HV_KVM_USE_CHROOT = "use_chroot"
624
HV_CPU_MASK = "cpu_mask"
625
HV_MEM_PATH = "mem_path"
626
HV_PASSTHROUGH = "pci_pass"
627
HV_BLOCKDEV_PREFIX = "blockdev_prefix"
628
HV_REBOOT_BEHAVIOR = "reboot_behavior"
629
HV_CPU_TYPE = "cpu_type"
630
HV_CPU_CAP = "cpu_cap"
631
HV_CPU_WEIGHT = "cpu_weight"
632
HV_CPU_CORES = "cpu_cores"
633
HV_CPU_THREADS = "cpu_threads"
634
HV_CPU_SOCKETS = "cpu_sockets"
635
HV_SOUNDHW = "soundhw"
636
HV_USB_DEVICES = "usb_devices"
637
HV_VGA = "vga"
638
HV_KVM_EXTRA = "kvm_extra"
639
HV_KVM_MACHINE_VERSION = "machine_version"
640
HV_KVM_PATH = "kvm_path"
641
HV_VIF_TYPE = "vif_type"
642
HV_VIF_SCRIPT = "vif_script"
643
HV_XEN_CMD = "xen_cmd"
644
HV_XEN_CPUID = "cpuid"
645
HV_VNET_HDR = "vnet_hdr"
646
HV_VIRIDIAN = "viridian"
647

    
648

    
649
HVS_PARAMETER_TYPES = {
650
  HV_KVM_PATH: VTYPE_STRING,
651
  HV_BOOT_ORDER: VTYPE_STRING,
652
  HV_KVM_FLOPPY_IMAGE_PATH: VTYPE_STRING,
653
  HV_CDROM_IMAGE_PATH: VTYPE_STRING,
654
  HV_KVM_CDROM2_IMAGE_PATH: VTYPE_STRING,
655
  HV_NIC_TYPE: VTYPE_STRING,
656
  HV_DISK_TYPE: VTYPE_STRING,
657
  HV_KVM_CDROM_DISK_TYPE: VTYPE_STRING,
658
  HV_VNC_PASSWORD_FILE: VTYPE_STRING,
659
  HV_VNC_BIND_ADDRESS: VTYPE_STRING,
660
  HV_VNC_TLS: VTYPE_BOOL,
661
  HV_VNC_X509: VTYPE_STRING,
662
  HV_VNC_X509_VERIFY: VTYPE_BOOL,
663
  HV_KVM_SPICE_BIND: VTYPE_STRING,
664
  HV_KVM_SPICE_IP_VERSION: VTYPE_INT,
665
  HV_KVM_SPICE_PASSWORD_FILE: VTYPE_STRING,
666
  HV_KVM_SPICE_LOSSLESS_IMG_COMPR: VTYPE_STRING,
667
  HV_KVM_SPICE_JPEG_IMG_COMPR: VTYPE_STRING,
668
  HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR: VTYPE_STRING,
669
  HV_KVM_SPICE_STREAMING_VIDEO_DETECTION: VTYPE_STRING,
670
  HV_KVM_SPICE_AUDIO_COMPR: VTYPE_BOOL,
671
  HV_KVM_SPICE_USE_TLS: VTYPE_BOOL,
672
  HV_KVM_SPICE_TLS_CIPHERS: VTYPE_STRING,
673
  HV_KVM_SPICE_USE_VDAGENT: VTYPE_BOOL,
674
  HV_ACPI: VTYPE_BOOL,
675
  HV_PAE: VTYPE_BOOL,
676
  HV_USE_BOOTLOADER: VTYPE_BOOL,
677
  HV_BOOTLOADER_PATH: VTYPE_STRING,
678
  HV_BOOTLOADER_ARGS: VTYPE_STRING,
679
  HV_KERNEL_PATH: VTYPE_STRING,
680
  HV_KERNEL_ARGS: VTYPE_STRING,
681
  HV_INITRD_PATH: VTYPE_STRING,
682
  HV_ROOT_PATH: VTYPE_MAYBE_STRING,
683
  HV_SERIAL_CONSOLE: VTYPE_BOOL,
684
  HV_SERIAL_SPEED: VTYPE_INT,
685
  HV_USB_MOUSE: VTYPE_STRING,
686
  HV_KEYMAP: VTYPE_STRING,
687
  HV_DEVICE_MODEL: VTYPE_STRING,
688
  HV_INIT_SCRIPT: VTYPE_STRING,
689
  HV_MIGRATION_PORT: VTYPE_INT,
690
  HV_MIGRATION_BANDWIDTH: VTYPE_INT,
691
  HV_MIGRATION_DOWNTIME: VTYPE_INT,
692
  HV_MIGRATION_MODE: VTYPE_STRING,
693
  HV_USE_LOCALTIME: VTYPE_BOOL,
694
  HV_DISK_CACHE: VTYPE_STRING,
695
  HV_SECURITY_MODEL: VTYPE_STRING,
696
  HV_SECURITY_DOMAIN: VTYPE_STRING,
697
  HV_KVM_FLAG: VTYPE_STRING,
698
  HV_VHOST_NET: VTYPE_BOOL,
699
  HV_KVM_USE_CHROOT: VTYPE_BOOL,
700
  HV_CPU_MASK: VTYPE_STRING,
701
  HV_MEM_PATH: VTYPE_STRING,
702
  HV_PASSTHROUGH: VTYPE_STRING,
703
  HV_BLOCKDEV_PREFIX: VTYPE_STRING,
704
  HV_REBOOT_BEHAVIOR: VTYPE_STRING,
705
  HV_CPU_TYPE: VTYPE_STRING,
706
  HV_CPU_CAP: VTYPE_INT,
707
  HV_CPU_WEIGHT: VTYPE_INT,
708
  HV_CPU_CORES: VTYPE_INT,
709
  HV_CPU_THREADS: VTYPE_INT,
710
  HV_CPU_SOCKETS: VTYPE_INT,
711
  HV_SOUNDHW: VTYPE_STRING,
712
  HV_USB_DEVICES: VTYPE_STRING,
713
  HV_VGA: VTYPE_STRING,
714
  HV_KVM_EXTRA: VTYPE_STRING,
715
  HV_KVM_MACHINE_VERSION: VTYPE_STRING,
716
  HV_VIF_TYPE: VTYPE_STRING,
717
  HV_VIF_SCRIPT: VTYPE_STRING,
718
  HV_XEN_CMD: VTYPE_STRING,
719
  HV_XEN_CPUID: VTYPE_STRING,
720
  HV_VNET_HDR: VTYPE_BOOL,
721
  HV_VIRIDIAN: VTYPE_BOOL,
722
  }
723

    
724
HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
725

    
726
HVS_PARAMETER_TITLES = {
727
  HV_ACPI: "ACPI",
728
  HV_BOOT_ORDER: "Boot_order",
729
  HV_CDROM_IMAGE_PATH: "CDROM_image_path",
730
  HV_DISK_TYPE: "Disk_type",
731
  HV_INITRD_PATH: "Initrd_path",
732
  HV_KERNEL_PATH: "Kernel_path",
733
  HV_NIC_TYPE: "NIC_type",
734
  HV_PAE: "PAE",
735
  HV_VNC_BIND_ADDRESS: "VNC_bind_address",
736
  HV_PASSTHROUGH: "pci_pass",
737
  HV_CPU_TYPE: "cpu_type",
738
  }
739

    
740
# Migration statuses
741
HV_MIGRATION_COMPLETED = "completed"
742
HV_MIGRATION_ACTIVE = "active"
743
HV_MIGRATION_FAILED = "failed"
744
HV_MIGRATION_CANCELLED = "cancelled"
745

    
746
HV_MIGRATION_VALID_STATUSES = compat.UniqueFrozenset([
747
  HV_MIGRATION_COMPLETED,
748
  HV_MIGRATION_ACTIVE,
749
  HV_MIGRATION_FAILED,
750
  HV_MIGRATION_CANCELLED,
751
  ])
752

    
753
HV_MIGRATION_FAILED_STATUSES = compat.UniqueFrozenset([
754
  HV_MIGRATION_FAILED,
755
  HV_MIGRATION_CANCELLED,
756
  ])
757

    
758
# KVM-specific statuses
759
HV_KVM_MIGRATION_VALID_STATUSES = HV_MIGRATION_VALID_STATUSES
760

    
761
# Node info keys
762
HV_NODEINFO_KEY_VERSION = "hv_version"
763

    
764
# Hypervisor state
765
HVST_MEMORY_TOTAL = "mem_total"
766
HVST_MEMORY_NODE = "mem_node"
767
HVST_MEMORY_HV = "mem_hv"
768
HVST_CPU_TOTAL = "cpu_total"
769
HVST_CPU_NODE = "cpu_node"
770

    
771
HVST_DEFAULTS = {
772
  HVST_MEMORY_TOTAL: 0,
773
  HVST_MEMORY_NODE: 0,
774
  HVST_MEMORY_HV: 0,
775
  HVST_CPU_TOTAL: 1,
776
  HVST_CPU_NODE: 1,
777
  }
778

    
779
HVSTS_PARAMETER_TYPES = {
780
  HVST_MEMORY_TOTAL: VTYPE_INT,
781
  HVST_MEMORY_NODE: VTYPE_INT,
782
  HVST_MEMORY_HV: VTYPE_INT,
783
  HVST_CPU_TOTAL: VTYPE_INT,
784
  HVST_CPU_NODE: VTYPE_INT,
785
  }
786

    
787
HVSTS_PARAMETERS = frozenset(HVSTS_PARAMETER_TYPES.keys())
788

    
789
# Disk state
790
DS_DISK_TOTAL = "disk_total"
791
DS_DISK_RESERVED = "disk_reserved"
792
DS_DISK_OVERHEAD = "disk_overhead"
793

    
794
DS_DEFAULTS = {
795
  DS_DISK_TOTAL: 0,
796
  DS_DISK_RESERVED: 0,
797
  DS_DISK_OVERHEAD: 0,
798
  }
799

    
800
ISPEC_MEM_SIZE = _constants.ISPEC_MEM_SIZE
801
ISPEC_CPU_COUNT = _constants.ISPEC_CPU_COUNT
802
ISPEC_DISK_COUNT = _constants.ISPEC_DISK_COUNT
803
ISPEC_DISK_SIZE = _constants.ISPEC_DISK_SIZE
804
ISPEC_NIC_COUNT = _constants.ISPEC_NIC_COUNT
805
ISPEC_SPINDLE_USE = _constants.ISPEC_SPINDLE_USE
806
ISPECS_PARAMETER_TYPES = _constants.ISPECS_PARAMETER_TYPES
807
ISPECS_PARAMETERS = _constants.ISPECS_PARAMETERS
808

    
809
ISPECS_MINMAX = _constants.ISPECS_MINMAX
810
ISPECS_MIN = _constants.ISPECS_MIN
811
ISPECS_MAX = _constants.ISPECS_MAX
812
ISPECS_STD = _constants.ISPECS_STD
813
IPOLICY_DTS = _constants.IPOLICY_DTS
814
IPOLICY_VCPU_RATIO = _constants.IPOLICY_VCPU_RATIO
815
IPOLICY_SPINDLE_RATIO = _constants.IPOLICY_SPINDLE_RATIO
816
ISPECS_MINMAX_KEYS = _constants.ISPECS_MINMAX_KEYS
817
IPOLICY_PARAMETERS = _constants.IPOLICY_PARAMETERS
818
IPOLICY_ALL_KEYS = _constants.IPOLICY_ALL_KEYS
819

    
820
ND_OOB_PROGRAM = _constants.ND_OOB_PROGRAM
821
ND_SPINDLE_COUNT = _constants.ND_SPINDLE_COUNT
822
ND_EXCLUSIVE_STORAGE = _constants.ND_EXCLUSIVE_STORAGE
823
ND_OVS = _constants.ND_OVS
824
ND_OVS_NAME = _constants.ND_OVS_NAME
825
ND_OVS_LINK = _constants.ND_OVS_LINK
826

    
827
NDS_PARAMETER_TYPES = _constants.NDS_PARAMETER_TYPES
828
NDS_PARAMETERS = _constants.NDS_PARAMETERS
829
NDS_PARAMETER_TITLES = _constants.NDS_PARAMETER_TITLES
830
DSS_PARAMETER_TYPES = {
831
  DS_DISK_TOTAL: VTYPE_INT,
832
  DS_DISK_RESERVED: VTYPE_INT,
833
  DS_DISK_OVERHEAD: VTYPE_INT,
834
  }
835

    
836
DSS_PARAMETERS = frozenset(DSS_PARAMETER_TYPES.keys())
837
DS_VALID_TYPES = compat.UniqueFrozenset([DT_PLAIN])
838

    
839
# Backend parameter names
840
BE_MEMORY = "memory" # deprecated and replaced by max and min mem
841
BE_MAXMEM = "maxmem"
842
BE_MINMEM = "minmem"
843
BE_VCPUS = "vcpus"
844
BE_AUTO_BALANCE = "auto_balance"
845
BE_ALWAYS_FAILOVER = "always_failover"
846
BE_SPINDLE_USE = "spindle_use"
847

    
848
BES_PARAMETER_TYPES = {
849
  BE_MAXMEM: VTYPE_SIZE,
850
  BE_MINMEM: VTYPE_SIZE,
851
  BE_VCPUS: VTYPE_INT,
852
  BE_AUTO_BALANCE: VTYPE_BOOL,
853
  BE_ALWAYS_FAILOVER: VTYPE_BOOL,
854
  BE_SPINDLE_USE: VTYPE_INT,
855
  }
856

    
857
BES_PARAMETER_TITLES = {
858
  BE_AUTO_BALANCE: "Auto_balance",
859
  BE_MAXMEM: "ConfigMaxMem",
860
  BE_MINMEM: "ConfigMinMem",
861
  BE_VCPUS: "ConfigVCPUs",
862
  }
863

    
864
BES_PARAMETER_COMPAT = {
865
  BE_MEMORY: VTYPE_SIZE,
866
  }
867
BES_PARAMETER_COMPAT.update(BES_PARAMETER_TYPES)
868

    
869
BES_PARAMETERS = frozenset(BES_PARAMETER_TYPES.keys())
870

    
871
# Logical Disks parameters
872
LDP_RESYNC_RATE = "resync-rate"
873
LDP_STRIPES = "stripes"
874
LDP_BARRIERS = "disabled-barriers"
875
LDP_NO_META_FLUSH = "disable-meta-flush"
876
LDP_DEFAULT_METAVG = "default-metavg"
877
LDP_DISK_CUSTOM = "disk-custom"
878
LDP_NET_CUSTOM = "net-custom"
879
LDP_PROTOCOL = "protocol"
880
LDP_DYNAMIC_RESYNC = "dynamic-resync"
881
LDP_PLAN_AHEAD = "c-plan-ahead"
882
LDP_FILL_TARGET = "c-fill-target"
883
LDP_DELAY_TARGET = "c-delay-target"
884
LDP_MAX_RATE = "c-max-rate"
885
LDP_MIN_RATE = "c-min-rate"
886
LDP_POOL = "pool"
887
LDP_ACCESS = "access"
888
DISK_LD_TYPES = {
889
  LDP_RESYNC_RATE: VTYPE_INT,
890
  LDP_STRIPES: VTYPE_INT,
891
  LDP_BARRIERS: VTYPE_STRING,
892
  LDP_NO_META_FLUSH: VTYPE_BOOL,
893
  LDP_DEFAULT_METAVG: VTYPE_STRING,
894
  LDP_DISK_CUSTOM: VTYPE_STRING,
895
  LDP_NET_CUSTOM: VTYPE_STRING,
896
  LDP_PROTOCOL: VTYPE_STRING,
897
  LDP_DYNAMIC_RESYNC: VTYPE_BOOL,
898
  LDP_PLAN_AHEAD: VTYPE_INT,
899
  LDP_FILL_TARGET: VTYPE_INT,
900
  LDP_DELAY_TARGET: VTYPE_INT,
901
  LDP_MAX_RATE: VTYPE_INT,
902
  LDP_MIN_RATE: VTYPE_INT,
903
  LDP_POOL: VTYPE_STRING,
904
  LDP_ACCESS: VTYPE_STRING,
905
  }
906
DISK_LD_PARAMETERS = frozenset(DISK_LD_TYPES.keys())
907

    
908
# Disk template parameters (can be set/changed by the user via gnt-cluster and
909
# gnt-group)
910
DRBD_RESYNC_RATE = "resync-rate"
911
DRBD_DATA_STRIPES = "data-stripes"
912
DRBD_META_STRIPES = "meta-stripes"
913
DRBD_DISK_BARRIERS = "disk-barriers"
914
DRBD_META_BARRIERS = "meta-barriers"
915
DRBD_DEFAULT_METAVG = "metavg"
916
DRBD_DISK_CUSTOM = "disk-custom"
917
DRBD_NET_CUSTOM = "net-custom"
918
DRBD_PROTOCOL = "protocol"
919
DRBD_DYNAMIC_RESYNC = "dynamic-resync"
920
DRBD_PLAN_AHEAD = "c-plan-ahead"
921
DRBD_FILL_TARGET = "c-fill-target"
922
DRBD_DELAY_TARGET = "c-delay-target"
923
DRBD_MAX_RATE = "c-max-rate"
924
DRBD_MIN_RATE = "c-min-rate"
925
LV_STRIPES = "stripes"
926
RBD_POOL = "pool"
927
RBD_ACCESS = "access"
928
DISK_DT_TYPES = {
929
  DRBD_RESYNC_RATE: VTYPE_INT,
930
  DRBD_DATA_STRIPES: VTYPE_INT,
931
  DRBD_META_STRIPES: VTYPE_INT,
932
  DRBD_DISK_BARRIERS: VTYPE_STRING,
933
  DRBD_META_BARRIERS: VTYPE_BOOL,
934
  DRBD_DEFAULT_METAVG: VTYPE_STRING,
935
  DRBD_DISK_CUSTOM: VTYPE_STRING,
936
  DRBD_NET_CUSTOM: VTYPE_STRING,
937
  DRBD_PROTOCOL: VTYPE_STRING,
938
  DRBD_DYNAMIC_RESYNC: VTYPE_BOOL,
939
  DRBD_PLAN_AHEAD: VTYPE_INT,
940
  DRBD_FILL_TARGET: VTYPE_INT,
941
  DRBD_DELAY_TARGET: VTYPE_INT,
942
  DRBD_MAX_RATE: VTYPE_INT,
943
  DRBD_MIN_RATE: VTYPE_INT,
944
  LV_STRIPES: VTYPE_INT,
945
  RBD_POOL: VTYPE_STRING,
946
  RBD_ACCESS: VTYPE_STRING,
947
  }
948

    
949
DISK_DT_PARAMETERS = frozenset(DISK_DT_TYPES.keys())
950

    
951
# dynamic disk parameters
952
DDP_LOCAL_IP = "local-ip"
953
DDP_REMOTE_IP = "remote-ip"
954
DDP_PORT = "port"
955
DDP_LOCAL_MINOR = "local-minor"
956
DDP_REMOTE_MINOR = "remote-minor"
957

    
958
# OOB supported commands
959
OOB_POWER_ON = _constants.OOB_POWER_ON
960
OOB_POWER_OFF = _constants.OOB_POWER_OFF
961
OOB_POWER_CYCLE = _constants.OOB_POWER_CYCLE
962
OOB_POWER_STATUS = _constants.OOB_POWER_STATUS
963
OOB_HEALTH = _constants.OOB_HEALTH
964
OOB_COMMANDS = _constants.OOB_COMMANDS
965

    
966
OOB_POWER_STATUS_POWERED = _constants.OOB_POWER_STATUS_POWERED
967

    
968
OOB_TIMEOUT = _constants.OOB_TIMEOUT
969
OOB_POWER_DELAY = _constants.OOB_POWER_DELAY
970

    
971
OOB_STATUS_OK = _constants.OOB_STATUS_OK
972
OOB_STATUS_WARNING = _constants.OOB_STATUS_WARNING
973
OOB_STATUS_CRITICAL = _constants.OOB_STATUS_CRITICAL
974
OOB_STATUS_UNKNOWN = _constants.OOB_STATUS_UNKNOWN
975
OOB_STATUSES = _constants.OOB_STATUSES
976

    
977
# Instance Parameters Profile
978
PP_DEFAULT = "default"
979

    
980
# NIC_* constants are used inside the ganeti config
981
NIC_MODE = _constants.NIC_MODE
982
NIC_LINK = _constants.NIC_LINK
983
NIC_VLAN = _constants.NIC_VLAN
984

    
985
NIC_MODE_BRIDGED = _constants.NIC_MODE_BRIDGED
986
NIC_MODE_ROUTED = _constants.NIC_MODE_ROUTED
987
NIC_MODE_OVS = _constants.NIC_MODE_OVS
988
NIC_IP_POOL = _constants.NIC_IP_POOL
989
NIC_VALID_MODES = _constants.NIC_VALID_MODES
990

    
991
RESERVE_ACTION = "reserve"
992
RELEASE_ACTION = "release"
993

    
994
NICS_PARAMETER_TYPES = {
995
  NIC_MODE: VTYPE_STRING,
996
  NIC_LINK: VTYPE_STRING,
997
  NIC_VLAN: VTYPE_MAYBE_STRING,
998
  }
999

    
1000
NICS_PARAMETERS = frozenset(NICS_PARAMETER_TYPES.keys())
1001

    
1002
# IDISK_* constants are used in opcodes, to create/change disks
1003
IDISK_SIZE = "size"
1004
IDISK_SPINDLES = "spindles"
1005
IDISK_MODE = "mode"
1006
IDISK_ADOPT = "adopt"
1007
IDISK_VG = "vg"
1008
IDISK_METAVG = "metavg"
1009
IDISK_PROVIDER = "provider"
1010
IDISK_NAME = "name"
1011
IDISK_PARAMS_TYPES = {
1012
  IDISK_SIZE: VTYPE_SIZE,
1013
  IDISK_SPINDLES: VTYPE_INT,
1014
  IDISK_MODE: VTYPE_STRING,
1015
  IDISK_ADOPT: VTYPE_STRING,
1016
  IDISK_VG: VTYPE_STRING,
1017
  IDISK_METAVG: VTYPE_STRING,
1018
  IDISK_PROVIDER: VTYPE_STRING,
1019
  IDISK_NAME: VTYPE_MAYBE_STRING,
1020
  }
1021
IDISK_PARAMS = frozenset(IDISK_PARAMS_TYPES.keys())
1022

    
1023
# INIC_* constants are used in opcodes, to create/change nics
1024
INIC_MAC = "mac"
1025
INIC_IP = "ip"
1026
INIC_MODE = "mode"
1027
INIC_LINK = "link"
1028
INIC_NETWORK = "network"
1029
INIC_NAME = "name"
1030
INIC_VLAN = "vlan"
1031
INIC_BRIDGE = "bridge"
1032
INIC_PARAMS_TYPES = {
1033
  INIC_IP: VTYPE_MAYBE_STRING,
1034
  INIC_LINK: VTYPE_STRING,
1035
  INIC_MAC: VTYPE_STRING,
1036
  INIC_MODE: VTYPE_STRING,
1037
  INIC_NETWORK: VTYPE_MAYBE_STRING,
1038
  INIC_NAME: VTYPE_MAYBE_STRING,
1039
  INIC_VLAN: VTYPE_MAYBE_STRING,
1040
  INIC_BRIDGE: VTYPE_MAYBE_STRING
1041
  }
1042
INIC_PARAMS = frozenset(INIC_PARAMS_TYPES.keys())
1043

    
1044
# Hypervisor constants
1045
HT_XEN_PVM = _constants.HT_XEN_PVM
1046
HT_FAKE = _constants.HT_FAKE
1047
HT_XEN_HVM = _constants.HT_XEN_HVM
1048
HT_KVM = _constants.HT_KVM
1049
HT_CHROOT = _constants.HT_CHROOT
1050
HT_LXC = _constants.HT_LXC
1051
HYPER_TYPES = _constants.HYPER_TYPES
1052
HTS_REQ_PORT = _constants.HTS_REQ_PORT
1053

    
1054
VNC_BASE_PORT = 5900
1055
VNC_DEFAULT_BIND_ADDRESS = IP4_ADDRESS_ANY
1056

    
1057
# NIC types
1058
HT_NIC_RTL8139 = "rtl8139"
1059
HT_NIC_NE2K_PCI = "ne2k_pci"
1060
HT_NIC_NE2K_ISA = "ne2k_isa"
1061
HT_NIC_I82551 = "i82551"
1062
HT_NIC_I85557B = "i82557b"
1063
HT_NIC_I8259ER = "i82559er"
1064
HT_NIC_PCNET = "pcnet"
1065
HT_NIC_E1000 = "e1000"
1066
HT_NIC_PARAVIRTUAL = HT_DISK_PARAVIRTUAL = "paravirtual"
1067

    
1068
HT_HVM_VALID_NIC_TYPES = compat.UniqueFrozenset([
1069
  HT_NIC_RTL8139,
1070
  HT_NIC_NE2K_PCI,
1071
  HT_NIC_E1000,
1072
  HT_NIC_NE2K_ISA,
1073
  HT_NIC_PARAVIRTUAL,
1074
  ])
1075
HT_KVM_VALID_NIC_TYPES = compat.UniqueFrozenset([
1076
  HT_NIC_RTL8139,
1077
  HT_NIC_NE2K_PCI,
1078
  HT_NIC_NE2K_ISA,
1079
  HT_NIC_I82551,
1080
  HT_NIC_I85557B,
1081
  HT_NIC_I8259ER,
1082
  HT_NIC_PCNET,
1083
  HT_NIC_E1000,
1084
  HT_NIC_PARAVIRTUAL,
1085
  ])
1086

    
1087
# Vif types
1088
# default vif type in xen-hvm
1089
HT_HVM_VIF_IOEMU = "ioemu"
1090
HT_HVM_VIF_VIF = "vif"
1091
HT_HVM_VALID_VIF_TYPES = compat.UniqueFrozenset([
1092
  HT_HVM_VIF_IOEMU,
1093
  HT_HVM_VIF_VIF,
1094
  ])
1095

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

    
1104
HT_CACHE_DEFAULT = "default"
1105
HT_CACHE_NONE = "none"
1106
HT_CACHE_WTHROUGH = "writethrough"
1107
HT_CACHE_WBACK = "writeback"
1108
HT_VALID_CACHE_TYPES = compat.UniqueFrozenset([
1109
  HT_CACHE_DEFAULT,
1110
  HT_CACHE_NONE,
1111
  HT_CACHE_WTHROUGH,
1112
  HT_CACHE_WBACK,
1113
  ])
1114

    
1115
HT_HVM_VALID_DISK_TYPES = compat.UniqueFrozenset([
1116
  HT_DISK_PARAVIRTUAL,
1117
  HT_DISK_IOEMU,
1118
  ])
1119
HT_KVM_VALID_DISK_TYPES = compat.UniqueFrozenset([
1120
  HT_DISK_PARAVIRTUAL,
1121
  HT_DISK_IDE,
1122
  HT_DISK_SCSI,
1123
  HT_DISK_SD,
1124
  HT_DISK_MTD,
1125
  HT_DISK_PFLASH,
1126
  ])
1127

    
1128
# Mouse types:
1129
HT_MOUSE_MOUSE = "mouse"
1130
HT_MOUSE_TABLET = "tablet"
1131

    
1132
HT_KVM_VALID_MOUSE_TYPES = compat.UniqueFrozenset([
1133
  HT_MOUSE_MOUSE,
1134
  HT_MOUSE_TABLET,
1135
  ])
1136

    
1137
# Boot order
1138
HT_BO_FLOPPY = "floppy"
1139
HT_BO_CDROM = "cdrom"
1140
HT_BO_DISK = "disk"
1141
HT_BO_NETWORK = "network"
1142

    
1143
HT_KVM_VALID_BO_TYPES = compat.UniqueFrozenset([
1144
  HT_BO_FLOPPY,
1145
  HT_BO_CDROM,
1146
  HT_BO_DISK,
1147
  HT_BO_NETWORK,
1148
  ])
1149

    
1150
# SPICE lossless image compression options
1151
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ = "auto_glz"
1152
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ = "auto_lz"
1153
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC = "quic"
1154
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ = "glz"
1155
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ = "lz"
1156
HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF = "off"
1157

    
1158
HT_KVM_SPICE_VALID_LOSSLESS_IMG_COMPR_OPTIONS = compat.UniqueFrozenset([
1159
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ,
1160
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ,
1161
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC,
1162
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ,
1163
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ,
1164
  HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF,
1165
  ])
1166

    
1167
# SPICE lossy image compression options (valid for both jpeg and zlib-glz)
1168
HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO = "auto"
1169
HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER = "never"
1170
HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS = "always"
1171

    
1172
HT_KVM_SPICE_VALID_LOSSY_IMG_COMPR_OPTIONS = compat.UniqueFrozenset([
1173
  HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO,
1174
  HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER,
1175
  HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS,
1176
  ])
1177

    
1178
# SPICE video stream detection
1179
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF = "off"
1180
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL = "all"
1181
HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER = "filter"
1182

    
1183
HT_KVM_SPICE_VALID_VIDEO_STREAM_DETECTION_OPTIONS = compat.UniqueFrozenset([
1184
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF,
1185
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL,
1186
  HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER,
1187
  ])
1188

    
1189
# Security models
1190
HT_SM_NONE = "none"
1191
HT_SM_USER = "user"
1192
HT_SM_POOL = "pool"
1193

    
1194
HT_KVM_VALID_SM_TYPES = compat.UniqueFrozenset([
1195
  HT_SM_NONE,
1196
  HT_SM_USER,
1197
  HT_SM_POOL,
1198
  ])
1199

    
1200
# Kvm flag values
1201
HT_KVM_ENABLED = "enabled"
1202
HT_KVM_DISABLED = "disabled"
1203

    
1204
HT_KVM_FLAG_VALUES = compat.UniqueFrozenset([HT_KVM_ENABLED, HT_KVM_DISABLED])
1205

    
1206
# Migration type
1207
HT_MIGRATION_LIVE = _constants.HT_MIGRATION_LIVE
1208
HT_MIGRATION_NONLIVE = _constants.HT_MIGRATION_NONLIVE
1209
HT_MIGRATION_MODES = _constants.HT_MIGRATION_MODES
1210

    
1211
# Cluster Verify steps
1212
VERIFY_NPLUSONE_MEM = _constants.VERIFY_NPLUSONE_MEM
1213
VERIFY_OPTIONAL_CHECKS = _constants.VERIFY_OPTIONAL_CHECKS
1214

    
1215
# Cluster Verify error classes
1216
CV_TCLUSTER = _constants.CV_TCLUSTER
1217
CV_TGROUP = _constants.CV_TGROUP
1218
CV_TNODE = _constants.CV_TNODE
1219
CV_TINSTANCE = _constants.CV_TINSTANCE
1220

    
1221
# Cluster Verify error codes and documentation
1222
CV_ECLUSTERCFG = _constants.CV_ECLUSTERCFG
1223
CV_ECLUSTERCERT = _constants.CV_ECLUSTERCERT
1224
CV_ECLUSTERFILECHECK = _constants.CV_ECLUSTERFILECHECK
1225
CV_ECLUSTERDANGLINGNODES = _constants.CV_ECLUSTERDANGLINGNODES
1226
CV_ECLUSTERDANGLINGINST = _constants.CV_ECLUSTERDANGLINGINST
1227
CV_EGROUPDIFFERENTPVSIZE = _constants.CV_EGROUPDIFFERENTPVSIZE
1228
CV_EINSTANCEBADNODE = _constants.CV_EINSTANCEBADNODE
1229
CV_EINSTANCEDOWN = _constants.CV_EINSTANCEDOWN
1230
CV_EINSTANCELAYOUT = _constants.CV_EINSTANCELAYOUT
1231
CV_EINSTANCEMISSINGDISK = _constants.CV_EINSTANCEMISSINGDISK
1232
CV_EINSTANCEFAULTYDISK = _constants.CV_EINSTANCEFAULTYDISK
1233
CV_EINSTANCEWRONGNODE = _constants.CV_EINSTANCEWRONGNODE
1234
CV_EINSTANCESPLITGROUPS = _constants.CV_EINSTANCESPLITGROUPS
1235
CV_EINSTANCEPOLICY = _constants.CV_EINSTANCEPOLICY
1236
CV_EINSTANCEUNSUITABLENODE = _constants.CV_EINSTANCEUNSUITABLENODE
1237
CV_EINSTANCEMISSINGCFGPARAMETER = _constants.CV_EINSTANCEMISSINGCFGPARAMETER
1238
CV_ENODEDRBD = _constants.CV_ENODEDRBD
1239
CV_ENODEDRBDVERSION = _constants.CV_ENODEDRBDVERSION
1240
CV_ENODEDRBDHELPER = _constants.CV_ENODEDRBDHELPER
1241
CV_ENODEFILECHECK = _constants.CV_ENODEFILECHECK
1242
CV_ENODEHOOKS = _constants.CV_ENODEHOOKS
1243
CV_ENODEHV = _constants.CV_ENODEHV
1244
CV_ENODELVM = _constants.CV_ENODELVM
1245
CV_ENODEN1 = _constants.CV_ENODEN1
1246
CV_ENODENET = _constants.CV_ENODENET
1247
CV_ENODEOS = _constants.CV_ENODEOS
1248
CV_ENODEORPHANINSTANCE = _constants.CV_ENODEORPHANINSTANCE
1249
CV_ENODEORPHANLV = _constants.CV_ENODEORPHANLV
1250
CV_ENODERPC = _constants.CV_ENODERPC
1251
CV_ENODESSH = _constants.CV_ENODESSH
1252
CV_ENODEVERSION = _constants.CV_ENODEVERSION
1253
CV_ENODESETUP = _constants.CV_ENODESETUP
1254
CV_ENODETIME = _constants.CV_ENODETIME
1255
CV_ENODEOOBPATH = _constants.CV_ENODEOOBPATH
1256
CV_ENODEUSERSCRIPTS = _constants.CV_ENODEUSERSCRIPTS
1257
CV_ENODEFILESTORAGEPATHS = _constants.CV_ENODEFILESTORAGEPATHS
1258
CV_ENODEFILESTORAGEPATHUNUSABLE = _constants.CV_ENODEFILESTORAGEPATHUNUSABLE
1259
CV_ENODESHAREDFILESTORAGEPATHUNUSABLE = \
1260
  _constants.CV_ENODESHAREDFILESTORAGEPATHUNUSABLE
1261

    
1262
CV_ALL_ECODES = _constants.CV_ALL_ECODES
1263
CV_ALL_ECODES_STRINGS = _constants.CV_ALL_ECODES_STRINGS
1264

    
1265
# Node verify constants
1266
NV_BRIDGES = "bridges"
1267
NV_DRBDHELPER = "drbd-helper"
1268
NV_DRBDVERSION = "drbd-version"
1269
NV_DRBDLIST = "drbd-list"
1270
NV_EXCLUSIVEPVS = "exclusive-pvs"
1271
NV_FILELIST = "filelist"
1272
NV_ACCEPTED_STORAGE_PATHS = "allowed-file-storage-paths"
1273
NV_FILE_STORAGE_PATH = "file-storage-path"
1274
NV_SHARED_FILE_STORAGE_PATH = "shared-file-storage-path"
1275
NV_HVINFO = "hvinfo"
1276
NV_HVPARAMS = "hvparms"
1277
NV_HYPERVISOR = "hypervisor"
1278
NV_INSTANCELIST = "instancelist"
1279
NV_LVLIST = "lvlist"
1280
NV_MASTERIP = "master-ip"
1281
NV_NODELIST = "nodelist"
1282
NV_NODENETTEST = "node-net-test"
1283
NV_NODESETUP = "nodesetup"
1284
NV_OOB_PATHS = "oob-paths"
1285
NV_OSLIST = "oslist"
1286
NV_PVLIST = "pvlist"
1287
NV_TIME = "time"
1288
NV_USERSCRIPTS = "user-scripts"
1289
NV_VERSION = "version"
1290
NV_VGLIST = "vglist"
1291
NV_VMNODES = "vmnodes"
1292

    
1293
# Instance status
1294
INSTST_RUNNING = _constants.INSTST_RUNNING
1295
INSTST_ADMINDOWN = _constants.INSTST_ADMINDOWN
1296
INSTST_ADMINOFFLINE = _constants.INSTST_ADMINOFFLINE
1297
INSTST_NODEOFFLINE = _constants.INSTST_NODEOFFLINE
1298
INSTST_NODEDOWN = _constants.INSTST_NODEDOWN
1299
INSTST_WRONGNODE = _constants.INSTST_WRONGNODE
1300
INSTST_ERRORUP = _constants.INSTST_ERRORUP
1301
INSTST_ERRORDOWN = _constants.INSTST_ERRORDOWN
1302
INSTST_ALL = _constants.INSTST_ALL
1303

    
1304
# Admin states
1305
ADMINST_UP = _constants.ADMINST_UP
1306
ADMINST_DOWN = _constants.ADMINST_DOWN
1307
ADMINST_OFFLINE = _constants.ADMINST_OFFLINE
1308
ADMINST_ALL = _constants.ADMINST_ALL
1309

    
1310
# Node roles
1311
NR_REGULAR = _constants.NR_REGULAR
1312
NR_MASTER = _constants.NR_MASTER
1313
NR_MCANDIDATE = _constants.NR_MCANDIDATE
1314
NR_DRAINED = _constants.NR_DRAINED
1315
NR_OFFLINE = _constants.NR_OFFLINE
1316
NR_ALL = _constants.NR_ALL
1317

    
1318
# SSL certificate check constants (in days)
1319
SSL_CERT_EXPIRATION_WARN = 30
1320
SSL_CERT_EXPIRATION_ERROR = 7
1321

    
1322
# Allocator framework constants
1323
IALLOCATOR_VERSION = _constants.IALLOCATOR_VERSION
1324
IALLOCATOR_DIR_IN = _constants.IALLOCATOR_DIR_IN
1325
IALLOCATOR_DIR_OUT = _constants.IALLOCATOR_DIR_OUT
1326
VALID_IALLOCATOR_DIRECTIONS = _constants.VALID_IALLOCATOR_DIRECTIONS
1327

    
1328
IALLOCATOR_MODE_ALLOC = _constants.IALLOCATOR_MODE_ALLOC
1329
IALLOCATOR_MODE_RELOC = _constants.IALLOCATOR_MODE_RELOC
1330
IALLOCATOR_MODE_CHG_GROUP = _constants.IALLOCATOR_MODE_CHG_GROUP
1331
IALLOCATOR_MODE_NODE_EVAC = _constants.IALLOCATOR_MODE_NODE_EVAC
1332
IALLOCATOR_MODE_MULTI_ALLOC = _constants.IALLOCATOR_MODE_MULTI_ALLOC
1333
VALID_IALLOCATOR_MODES = _constants.VALID_IALLOCATOR_MODES
1334

    
1335
IALLOCATOR_SEARCH_PATH = _constants.IALLOCATOR_SEARCH_PATH
1336
DEFAULT_IALLOCATOR_SHORTCUT = _constants.DEFAULT_IALLOCATOR_SHORTCUT
1337

    
1338
# Node evacuation
1339
NODE_EVAC_PRI = _constants.NODE_EVAC_PRI
1340
NODE_EVAC_SEC = _constants.NODE_EVAC_SEC
1341
NODE_EVAC_ALL = _constants.NODE_EVAC_ALL
1342
NODE_EVAC_MODES = _constants.NODE_EVAC_MODES
1343

    
1344
# Job queue
1345
JOB_QUEUE_VERSION = 1
1346
JOB_QUEUE_SIZE_HARD_LIMIT = 5000
1347
JOB_QUEUE_FILES_PERMS = 0640
1348

    
1349
JOB_ID_TEMPLATE = r"\d+"
1350
JOB_FILE_RE = re.compile(r"^job-(%s)$" % JOB_ID_TEMPLATE)
1351

    
1352
# unchanged job return
1353
JOB_NOTCHANGED = "nochange"
1354

    
1355
# Job status
1356
JOB_STATUS_QUEUED = _constants.JOB_STATUS_QUEUED
1357
JOB_STATUS_WAITING = _constants.JOB_STATUS_WAITING
1358
JOB_STATUS_CANCELING = _constants.JOB_STATUS_CANCELING
1359
JOB_STATUS_RUNNING = _constants.JOB_STATUS_RUNNING
1360
JOB_STATUS_CANCELED = _constants.JOB_STATUS_CANCELED
1361
JOB_STATUS_SUCCESS = _constants.JOB_STATUS_SUCCESS
1362
JOB_STATUS_ERROR = _constants.JOB_STATUS_ERROR
1363
JOBS_PENDING = _constants.JOBS_PENDING
1364
JOBS_FINALIZED = _constants.JOBS_FINALIZED
1365
JOB_STATUS_ALL = _constants.JOB_STATUS_ALL
1366

    
1367
# OpCode status
1368
# not yet finalized
1369
OP_STATUS_QUEUED = _constants.OP_STATUS_QUEUED
1370
OP_STATUS_WAITING = _constants.OP_STATUS_WAITING
1371
OP_STATUS_CANCELING = _constants.OP_STATUS_CANCELING
1372
OP_STATUS_RUNNING = _constants.OP_STATUS_RUNNING
1373
# finalized
1374
OP_STATUS_CANCELED = _constants.OP_STATUS_CANCELED
1375
OP_STATUS_SUCCESS = _constants.OP_STATUS_SUCCESS
1376
OP_STATUS_ERROR = _constants.OP_STATUS_ERROR
1377
OPS_FINALIZED = _constants.OPS_FINALIZED
1378

    
1379
# OpCode priority
1380
OP_PRIO_LOWEST = _constants.OP_PRIO_LOWEST
1381
OP_PRIO_HIGHEST = _constants.OP_PRIO_HIGHEST
1382
OP_PRIO_LOW = _constants.OP_PRIO_LOW
1383
OP_PRIO_NORMAL = _constants.OP_PRIO_NORMAL
1384
OP_PRIO_HIGH = _constants.OP_PRIO_HIGH
1385
OP_PRIO_SUBMIT_VALID = _constants.OP_PRIO_SUBMIT_VALID
1386
OP_PRIO_DEFAULT = _constants.OP_PRIO_DEFAULT
1387

    
1388
# Lock recalculate mode
1389
LOCKS_REPLACE = "replace"
1390
LOCKS_APPEND = "append"
1391

    
1392
# Lock timeout (sum) before we should go into blocking acquire (still
1393
# can be reset by priority change); computed as max time (10 hours)
1394
# before we should actually go into blocking acquire given that we
1395
# start from default priority level; in seconds
1396
# TODO
1397
LOCK_ATTEMPTS_TIMEOUT = 10 * 3600 / (OP_PRIO_DEFAULT - OP_PRIO_HIGHEST)
1398
LOCK_ATTEMPTS_MAXWAIT = 15.0
1399
LOCK_ATTEMPTS_MINWAIT = 1.0
1400

    
1401
# Execution log types
1402
ELOG_MESSAGE = _constants.ELOG_MESSAGE
1403
ELOG_REMOTE_IMPORT = _constants.ELOG_REMOTE_IMPORT
1404
ELOG_JQUEUE_TEST = _constants.ELOG_JQUEUE_TEST
1405

    
1406
# /etc/hosts modification
1407
ETC_HOSTS_ADD = "add"
1408
ETC_HOSTS_REMOVE = "remove"
1409

    
1410
# Job queue test
1411
JQT_MSGPREFIX = "TESTMSG="
1412
JQT_EXPANDNAMES = "expandnames"
1413
JQT_EXEC = "exec"
1414
JQT_LOGMSG = "logmsg"
1415
JQT_STARTMSG = "startmsg"
1416
JQT_ALL = compat.UniqueFrozenset([
1417
  JQT_EXPANDNAMES,
1418
  JQT_EXEC,
1419
  JQT_LOGMSG,
1420
  JQT_STARTMSG,
1421
  ])
1422

    
1423
# Query resources
1424
QR_CLUSTER = "cluster"
1425
QR_INSTANCE = "instance"
1426
QR_NODE = "node"
1427
QR_LOCK = "lock"
1428
QR_GROUP = "group"
1429
QR_OS = "os"
1430
QR_JOB = "job"
1431
QR_EXPORT = "export"
1432
QR_NETWORK = "network"
1433
QR_EXTSTORAGE = "extstorage"
1434

    
1435
#: List of resources which can be queried using L{opcodes.OpQuery}
1436
QR_VIA_OP = compat.UniqueFrozenset([
1437
  QR_CLUSTER,
1438
  QR_INSTANCE,
1439
  QR_NODE,
1440
  QR_GROUP,
1441
  QR_OS,
1442
  QR_EXPORT,
1443
  QR_NETWORK,
1444
  QR_EXTSTORAGE,
1445
  ])
1446

    
1447
#: List of resources which can be queried using Local UniX Interface
1448
QR_VIA_LUXI = QR_VIA_OP.union([
1449
  QR_LOCK,
1450
  QR_JOB,
1451
  ])
1452

    
1453
#: List of resources which can be queried using RAPI
1454
QR_VIA_RAPI = QR_VIA_LUXI
1455

    
1456
# Query field types
1457
QFT_UNKNOWN = "unknown"
1458
QFT_TEXT = "text"
1459
QFT_BOOL = "bool"
1460
QFT_NUMBER = "number"
1461
QFT_UNIT = "unit"
1462
QFT_TIMESTAMP = "timestamp"
1463
QFT_OTHER = "other"
1464

    
1465
#: All query field types
1466
QFT_ALL = compat.UniqueFrozenset([
1467
  QFT_UNKNOWN,
1468
  QFT_TEXT,
1469
  QFT_BOOL,
1470
  QFT_NUMBER,
1471
  QFT_UNIT,
1472
  QFT_TIMESTAMP,
1473
  QFT_OTHER,
1474
  ])
1475

    
1476
# Query result field status (don't change or reuse values as they're used by
1477
# clients)
1478
#: Normal field status
1479
RS_NORMAL = 0
1480
#: Unknown field
1481
RS_UNKNOWN = 1
1482
#: No data (e.g. RPC error), can be used instead of L{RS_OFFLINE}
1483
RS_NODATA = 2
1484
#: Value unavailable/unsupported for item; if this field is supported
1485
#: but we cannot get the data for the moment, RS_NODATA or
1486
#: RS_OFFLINE should be used
1487
RS_UNAVAIL = 3
1488
#: Resource marked offline
1489
RS_OFFLINE = 4
1490

    
1491
RS_ALL = compat.UniqueFrozenset([
1492
  RS_NORMAL,
1493
  RS_UNKNOWN,
1494
  RS_NODATA,
1495
  RS_UNAVAIL,
1496
  RS_OFFLINE,
1497
  ])
1498

    
1499
#: Dictionary with special field cases and their verbose/terse formatting
1500
RSS_DESCRIPTION = {
1501
  RS_UNKNOWN: ("(unknown)", "??"),
1502
  RS_NODATA: ("(nodata)", "?"),
1503
  RS_OFFLINE: ("(offline)", "*"),
1504
  RS_UNAVAIL: ("(unavail)", "-"),
1505
  }
1506

    
1507
# max dynamic devices
1508
MAX_NICS = 8
1509
MAX_DISKS = 16
1510

    
1511
# SSCONF file prefix
1512
SSCONF_FILEPREFIX = "ssconf_"
1513
# SSCONF keys
1514
SS_CLUSTER_NAME = "cluster_name"
1515
SS_CLUSTER_TAGS = "cluster_tags"
1516
SS_FILE_STORAGE_DIR = "file_storage_dir"
1517
SS_SHARED_FILE_STORAGE_DIR = "shared_file_storage_dir"
1518
SS_MASTER_CANDIDATES = "master_candidates"
1519
SS_MASTER_CANDIDATES_IPS = "master_candidates_ips"
1520
SS_MASTER_IP = "master_ip"
1521
SS_MASTER_NETDEV = "master_netdev"
1522
SS_MASTER_NETMASK = "master_netmask"
1523
SS_MASTER_NODE = "master_node"
1524
SS_NODE_LIST = "node_list"
1525
SS_NODE_PRIMARY_IPS = "node_primary_ips"
1526
SS_NODE_SECONDARY_IPS = "node_secondary_ips"
1527
SS_OFFLINE_NODES = "offline_nodes"
1528
SS_ONLINE_NODES = "online_nodes"
1529
SS_PRIMARY_IP_FAMILY = "primary_ip_family"
1530
SS_INSTANCE_LIST = "instance_list"
1531
SS_RELEASE_VERSION = "release_version"
1532
SS_HYPERVISOR_LIST = "hypervisor_list"
1533
SS_MAINTAIN_NODE_HEALTH = "maintain_node_health"
1534
SS_UID_POOL = "uid_pool"
1535
SS_NODEGROUPS = "nodegroups"
1536
SS_NETWORKS = "networks"
1537

    
1538
# This is not a complete SSCONF key, but the prefix for the hypervisor keys
1539
SS_HVPARAMS_PREF = "hvparams_"
1540

    
1541
# Hvparams keys:
1542
SS_HVPARAMS_XEN_PVM = SS_HVPARAMS_PREF + HT_XEN_PVM
1543
SS_HVPARAMS_XEN_FAKE = SS_HVPARAMS_PREF + HT_FAKE
1544
SS_HVPARAMS_XEN_HVM = SS_HVPARAMS_PREF + HT_XEN_HVM
1545
SS_HVPARAMS_XEN_KVM = SS_HVPARAMS_PREF + HT_KVM
1546
SS_HVPARAMS_XEN_CHROOT = SS_HVPARAMS_PREF + HT_CHROOT
1547
SS_HVPARAMS_XEN_LXC = SS_HVPARAMS_PREF + HT_LXC
1548

    
1549
VALID_SS_HVPARAMS_KEYS = compat.UniqueFrozenset([
1550
  SS_HVPARAMS_XEN_PVM,
1551
  SS_HVPARAMS_XEN_FAKE,
1552
  SS_HVPARAMS_XEN_HVM,
1553
  SS_HVPARAMS_XEN_KVM,
1554
  SS_HVPARAMS_XEN_CHROOT,
1555
  SS_HVPARAMS_XEN_LXC,
1556
  ])
1557

    
1558
SS_FILE_PERMS = 0444
1559

    
1560
# cluster wide default parameters
1561
DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM
1562

    
1563
HVC_DEFAULTS = {
1564
  HT_XEN_PVM: {
1565
    HV_USE_BOOTLOADER: False,
1566
    HV_BOOTLOADER_PATH: XEN_BOOTLOADER,
1567
    HV_BOOTLOADER_ARGS: "",
1568
    HV_KERNEL_PATH: XEN_KERNEL,
1569
    HV_INITRD_PATH: "",
1570
    HV_ROOT_PATH: "/dev/xvda1",
1571
    HV_KERNEL_ARGS: "ro",
1572
    HV_MIGRATION_PORT: 8002,
1573
    HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1574
    HV_BLOCKDEV_PREFIX: "sd",
1575
    HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1576
    HV_CPU_MASK: CPU_PINNING_ALL,
1577
    HV_CPU_CAP: 0,
1578
    HV_CPU_WEIGHT: 256,
1579
    HV_VIF_SCRIPT: "",
1580
    HV_XEN_CMD: XEN_CMD_XM,
1581
    HV_XEN_CPUID: "",
1582
    HV_SOUNDHW: "",
1583
    },
1584
  HT_XEN_HVM: {
1585
    HV_BOOT_ORDER: "cd",
1586
    HV_CDROM_IMAGE_PATH: "",
1587
    HV_NIC_TYPE: HT_NIC_RTL8139,
1588
    HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
1589
    HV_VNC_BIND_ADDRESS: IP4_ADDRESS_ANY,
1590
    HV_VNC_PASSWORD_FILE: pathutils.VNC_PASSWORD_FILE,
1591
    HV_ACPI: True,
1592
    HV_PAE: True,
1593
    HV_KERNEL_PATH: "/usr/lib/xen/boot/hvmloader",
1594
    HV_DEVICE_MODEL: "/usr/lib/xen/bin/qemu-dm",
1595
    HV_MIGRATION_PORT: 8002,
1596
    HV_MIGRATION_MODE: HT_MIGRATION_NONLIVE,
1597
    HV_USE_LOCALTIME: False,
1598
    HV_BLOCKDEV_PREFIX: "hd",
1599
    HV_PASSTHROUGH: "",
1600
    HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1601
    HV_CPU_MASK: CPU_PINNING_ALL,
1602
    HV_CPU_CAP: 0,
1603
    HV_CPU_WEIGHT: 256,
1604
    HV_VIF_TYPE: HT_HVM_VIF_IOEMU,
1605
    HV_VIF_SCRIPT: "",
1606
    HV_VIRIDIAN: False,
1607
    HV_XEN_CMD: XEN_CMD_XM,
1608
    HV_XEN_CPUID: "",
1609
    HV_SOUNDHW: "",
1610
    },
1611
  HT_KVM: {
1612
    HV_KVM_PATH: KVM_PATH,
1613
    HV_KERNEL_PATH: KVM_KERNEL,
1614
    HV_INITRD_PATH: "",
1615
    HV_KERNEL_ARGS: "ro",
1616
    HV_ROOT_PATH: "/dev/vda1",
1617
    HV_ACPI: True,
1618
    HV_SERIAL_CONSOLE: True,
1619
    HV_SERIAL_SPEED: 38400,
1620
    HV_VNC_BIND_ADDRESS: "",
1621
    HV_VNC_TLS: False,
1622
    HV_VNC_X509: "",
1623
    HV_VNC_X509_VERIFY: False,
1624
    HV_VNC_PASSWORD_FILE: "",
1625
    HV_KVM_SPICE_BIND: "",
1626
    HV_KVM_SPICE_IP_VERSION: IFACE_NO_IP_VERSION_SPECIFIED,
1627
    HV_KVM_SPICE_PASSWORD_FILE: "",
1628
    HV_KVM_SPICE_LOSSLESS_IMG_COMPR: "",
1629
    HV_KVM_SPICE_JPEG_IMG_COMPR: "",
1630
    HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR: "",
1631
    HV_KVM_SPICE_STREAMING_VIDEO_DETECTION: "",
1632
    HV_KVM_SPICE_AUDIO_COMPR: True,
1633
    HV_KVM_SPICE_USE_TLS: False,
1634
    HV_KVM_SPICE_TLS_CIPHERS: OPENSSL_CIPHERS,
1635
    HV_KVM_SPICE_USE_VDAGENT: True,
1636
    HV_KVM_FLOPPY_IMAGE_PATH: "",
1637
    HV_CDROM_IMAGE_PATH: "",
1638
    HV_KVM_CDROM2_IMAGE_PATH: "",
1639
    HV_BOOT_ORDER: HT_BO_DISK,
1640
    HV_NIC_TYPE: HT_NIC_PARAVIRTUAL,
1641
    HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
1642
    HV_KVM_CDROM_DISK_TYPE: "",
1643
    HV_USB_MOUSE: "",
1644
    HV_KEYMAP: "",
1645
    HV_MIGRATION_PORT: 8102,
1646
    HV_MIGRATION_BANDWIDTH: 32, # MiB/s
1647
    HV_MIGRATION_DOWNTIME: 30,  # ms
1648
    HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1649
    HV_USE_LOCALTIME: False,
1650
    HV_DISK_CACHE: HT_CACHE_DEFAULT,
1651
    HV_SECURITY_MODEL: HT_SM_NONE,
1652
    HV_SECURITY_DOMAIN: "",
1653
    HV_KVM_FLAG: "",
1654
    HV_VHOST_NET: False,
1655
    HV_KVM_USE_CHROOT: False,
1656
    HV_MEM_PATH: "",
1657
    HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1658
    HV_CPU_MASK: CPU_PINNING_ALL,
1659
    HV_CPU_TYPE: "",
1660
    HV_CPU_CORES: 0,
1661
    HV_CPU_THREADS: 0,
1662
    HV_CPU_SOCKETS: 0,
1663
    HV_SOUNDHW: "",
1664
    HV_USB_DEVICES: "",
1665
    HV_VGA: "",
1666
    HV_KVM_EXTRA: "",
1667
    HV_KVM_MACHINE_VERSION: "",
1668
    HV_VNET_HDR: True,
1669
    },
1670
  HT_FAKE: {
1671
    HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1672
  },
1673
  HT_CHROOT: {
1674
    HV_INIT_SCRIPT: "/ganeti-chroot",
1675
    },
1676
  HT_LXC: {
1677
    HV_CPU_MASK: "",
1678
    },
1679
  }
1680

    
1681
HVC_GLOBALS = compat.UniqueFrozenset([
1682
  HV_MIGRATION_PORT,
1683
  HV_MIGRATION_BANDWIDTH,
1684
  HV_MIGRATION_MODE,
1685
  HV_XEN_CMD,
1686
  ])
1687

    
1688
BEC_DEFAULTS = {
1689
  BE_MINMEM: 128,
1690
  BE_MAXMEM: 128,
1691
  BE_VCPUS: 1,
1692
  BE_AUTO_BALANCE: True,
1693
  BE_ALWAYS_FAILOVER: False,
1694
  BE_SPINDLE_USE: 1,
1695
  }
1696

    
1697
NDC_DEFAULTS = {
1698
  ND_OOB_PROGRAM: "",
1699
  ND_SPINDLE_COUNT: 1,
1700
  ND_EXCLUSIVE_STORAGE: False,
1701
  ND_OVS: False,
1702
  ND_OVS_NAME: DEFAULT_OVS,
1703
  ND_OVS_LINK: ""
1704
  }
1705

    
1706
NDC_GLOBALS = compat.UniqueFrozenset([
1707
  ND_EXCLUSIVE_STORAGE,
1708
  ])
1709

    
1710
DISK_LD_DEFAULTS = {
1711
  DT_DRBD8: {
1712
    LDP_RESYNC_RATE: CLASSIC_DRBD_SYNC_SPEED,
1713
    LDP_BARRIERS: _constants.DRBD_BARRIERS,
1714
    LDP_NO_META_FLUSH: _constants.DRBD_NO_META_FLUSH,
1715
    LDP_DEFAULT_METAVG: DEFAULT_VG,
1716
    LDP_DISK_CUSTOM: "",
1717
    LDP_NET_CUSTOM: "",
1718
    LDP_PROTOCOL: DRBD_DEFAULT_NET_PROTOCOL,
1719
    LDP_DYNAMIC_RESYNC: False,
1720

    
1721
    # The default values for the DRBD dynamic resync speed algorithm
1722
    # are taken from the drbsetup 8.3.11 man page, except for
1723
    # c-plan-ahead (that we don't need to set to 0, because we have a
1724
    # separate option to enable it) and for c-max-rate, that we cap to
1725
    # the default value for the static resync rate.
1726
    LDP_PLAN_AHEAD: 20, # ds
1727
    LDP_FILL_TARGET: 0, # sectors
1728
    LDP_DELAY_TARGET: 1, # ds
1729
    LDP_MAX_RATE: CLASSIC_DRBD_SYNC_SPEED, # KiB/s
1730
    LDP_MIN_RATE: 4 * 1024, # KiB/s
1731
    },
1732
  DT_PLAIN: {
1733
    LDP_STRIPES: _constants.LVM_STRIPECOUNT
1734
    },
1735
  DT_FILE: {},
1736
  DT_SHARED_FILE: {},
1737
  DT_BLOCK: {},
1738
  DT_RBD: {
1739
    LDP_POOL: "rbd",
1740
    LDP_ACCESS: DISK_KERNELSPACE,
1741
    },
1742
  DT_EXT: {},
1743
  }
1744

    
1745
# readability shortcuts
1746
_LV_DEFAULTS = DISK_LD_DEFAULTS[DT_PLAIN]
1747
_DRBD_DEFAULTS = DISK_LD_DEFAULTS[DT_DRBD8]
1748

    
1749
DISK_DT_DEFAULTS = {
1750
  DT_PLAIN: {
1751
    LV_STRIPES: DISK_LD_DEFAULTS[DT_PLAIN][LDP_STRIPES],
1752
    },
1753
  DT_DRBD8: {
1754
    DRBD_RESYNC_RATE: _DRBD_DEFAULTS[LDP_RESYNC_RATE],
1755
    DRBD_DATA_STRIPES: _LV_DEFAULTS[LDP_STRIPES],
1756
    DRBD_META_STRIPES: _LV_DEFAULTS[LDP_STRIPES],
1757
    DRBD_DISK_BARRIERS: _DRBD_DEFAULTS[LDP_BARRIERS],
1758
    DRBD_META_BARRIERS: _DRBD_DEFAULTS[LDP_NO_META_FLUSH],
1759
    DRBD_DEFAULT_METAVG: _DRBD_DEFAULTS[LDP_DEFAULT_METAVG],
1760
    DRBD_DISK_CUSTOM: _DRBD_DEFAULTS[LDP_DISK_CUSTOM],
1761
    DRBD_NET_CUSTOM: _DRBD_DEFAULTS[LDP_NET_CUSTOM],
1762
    DRBD_PROTOCOL: _DRBD_DEFAULTS[LDP_PROTOCOL],
1763
    DRBD_DYNAMIC_RESYNC: _DRBD_DEFAULTS[LDP_DYNAMIC_RESYNC],
1764
    DRBD_PLAN_AHEAD: _DRBD_DEFAULTS[LDP_PLAN_AHEAD],
1765
    DRBD_FILL_TARGET: _DRBD_DEFAULTS[LDP_FILL_TARGET],
1766
    DRBD_DELAY_TARGET: _DRBD_DEFAULTS[LDP_DELAY_TARGET],
1767
    DRBD_MAX_RATE: _DRBD_DEFAULTS[LDP_MAX_RATE],
1768
    DRBD_MIN_RATE: _DRBD_DEFAULTS[LDP_MIN_RATE],
1769
    },
1770
  DT_DISKLESS: {},
1771
  DT_FILE: {},
1772
  DT_SHARED_FILE: {},
1773
  DT_BLOCK: {},
1774
  DT_RBD: {
1775
    RBD_POOL: DISK_LD_DEFAULTS[DT_RBD][LDP_POOL],
1776
    RBD_ACCESS: DISK_LD_DEFAULTS[DT_RBD][LDP_ACCESS],
1777
    },
1778
  DT_EXT: {},
1779
  }
1780

    
1781
# we don't want to export the shortcuts
1782
del _LV_DEFAULTS, _DRBD_DEFAULTS
1783

    
1784
NICC_DEFAULTS = {
1785
  NIC_MODE: NIC_MODE_BRIDGED,
1786
  NIC_LINK: DEFAULT_BRIDGE,
1787
  NIC_VLAN: VALUE_HS_NOTHING,
1788
  }
1789

    
1790
# All of the following values are quite arbitrarily - there are no
1791
# "good" defaults, these must be customised per-site
1792
ISPECS_MINMAX_DEFAULTS = {
1793
  ISPECS_MIN: {
1794
    ISPEC_MEM_SIZE: 128,
1795
    ISPEC_CPU_COUNT: 1,
1796
    ISPEC_DISK_COUNT: 1,
1797
    ISPEC_DISK_SIZE: 1024,
1798
    ISPEC_NIC_COUNT: 1,
1799
    ISPEC_SPINDLE_USE: 1,
1800
    },
1801
  ISPECS_MAX: {
1802
    ISPEC_MEM_SIZE: 32768,
1803
    ISPEC_CPU_COUNT: 8,
1804
    ISPEC_DISK_COUNT: MAX_DISKS,
1805
    ISPEC_DISK_SIZE: 1024 * 1024,
1806
    ISPEC_NIC_COUNT: MAX_NICS,
1807
    ISPEC_SPINDLE_USE: 12,
1808
    },
1809
  }
1810
IPOLICY_DEFAULTS = {
1811
  ISPECS_MINMAX: [ISPECS_MINMAX_DEFAULTS],
1812
  ISPECS_STD: {
1813
    ISPEC_MEM_SIZE: 128,
1814
    ISPEC_CPU_COUNT: 1,
1815
    ISPEC_DISK_COUNT: 1,
1816
    ISPEC_DISK_SIZE: 1024,
1817
    ISPEC_NIC_COUNT: 1,
1818
    ISPEC_SPINDLE_USE: 1,
1819
    },
1820
  IPOLICY_DTS: list(DISK_TEMPLATES),
1821
  IPOLICY_VCPU_RATIO: 4.0,
1822
  IPOLICY_SPINDLE_RATIO: 32.0,
1823
  }
1824

    
1825
MASTER_POOL_SIZE_DEFAULT = 10
1826

    
1827
# Exclusive storage:
1828
# Error margin used to compare physical disks
1829
PART_MARGIN = .01
1830
# Space reserved when creating instance disks
1831
PART_RESERVED = .02
1832

    
1833
CONFD_PROTOCOL_VERSION = _constants.CONFD_PROTOCOL_VERSION
1834

    
1835
CONFD_REQ_PING = _constants.CONFD_REQ_PING
1836
CONFD_REQ_NODE_ROLE_BYNAME = _constants.CONFD_REQ_NODE_ROLE_BYNAME
1837
CONFD_REQ_NODE_PIP_BY_INSTANCE_IP = _constants.CONFD_REQ_NODE_PIP_BY_INSTANCE_IP
1838
CONFD_REQ_CLUSTER_MASTER = _constants.CONFD_REQ_CLUSTER_MASTER
1839
CONFD_REQ_NODE_PIP_LIST = _constants.CONFD_REQ_NODE_PIP_LIST
1840
CONFD_REQ_MC_PIP_LIST = _constants.CONFD_REQ_MC_PIP_LIST
1841
CONFD_REQ_INSTANCES_IPS_LIST = _constants.CONFD_REQ_INSTANCES_IPS_LIST
1842
CONFD_REQ_NODE_DRBD = _constants.CONFD_REQ_NODE_DRBD
1843
CONFD_REQ_NODE_INSTANCES = _constants.CONFD_REQ_NODE_INSTANCES
1844
CONFD_REQS = _constants.CONFD_REQS
1845

    
1846
# Confd request query fields. These are used to narrow down queries.
1847
# These must be strings rather than integers, because json-encoding
1848
# converts them to strings anyway, as they're used as dict-keys.
1849
CONFD_REQQ_LINK = _constants.CONFD_REQQ_LINK
1850
CONFD_REQQ_IP = _constants.CONFD_REQQ_IP
1851
CONFD_REQQ_IPLIST = _constants.CONFD_REQQ_IPLIST
1852
CONFD_REQQ_FIELDS = _constants.CONFD_REQQ_FIELDS
1853

    
1854
# FIXME: perhaps update code that uses these constants to deal with
1855
# integers instead of strings
1856
CONFD_REQFIELD_NAME = str(_constants.CONFD_REQFIELD_NAME)
1857
CONFD_REQFIELD_IP = str(_constants.CONFD_REQFIELD_IP)
1858
CONFD_REQFIELD_MNODE_PIP = str(_constants.CONFD_REQFIELD_MNODE_PIP)
1859

    
1860
CONFD_REPL_STATUS_OK = _constants.CONFD_REPL_STATUS_OK
1861
CONFD_REPL_STATUS_ERROR = _constants.CONFD_REPL_STATUS_ERROR
1862
CONFD_REPL_STATUS_NOTIMPLEMENTED = _constants.CONFD_REPL_STATUS_NOTIMPLEMENTED
1863
CONFD_REPL_STATUSES = _constants.CONFD_REPL_STATUSES
1864

    
1865
CONFD_NODE_ROLE_MASTER = _constants.CONFD_NODE_ROLE_MASTER
1866
CONFD_NODE_ROLE_CANDIDATE = _constants.CONFD_NODE_ROLE_CANDIDATE
1867
CONFD_NODE_ROLE_OFFLINE = _constants.CONFD_NODE_ROLE_OFFLINE
1868
CONFD_NODE_ROLE_DRAINED = _constants.CONFD_NODE_ROLE_DRAINED
1869
CONFD_NODE_ROLE_REGULAR = _constants.CONFD_NODE_ROLE_REGULAR
1870

    
1871
CONFD_ERROR_UNKNOWN_ENTRY = _constants.CONFD_ERROR_UNKNOWN_ENTRY
1872
CONFD_ERROR_INTERNAL = _constants.CONFD_ERROR_INTERNAL
1873
CONFD_ERROR_ARGUMENT = _constants.CONFD_ERROR_ARGUMENT
1874

    
1875
# Each request is "salted" by the current timestamp.
1876
# This constants decides how many seconds of skew to accept.
1877
# TODO: make this a default and allow the value to be more configurable
1878
CONFD_MAX_CLOCK_SKEW = _constants.CONFD_MAX_CLOCK_SKEW
1879

    
1880
# When we haven't reloaded the config for more than this amount of
1881
# seconds, we force a test to see if inotify is betraying us. Using a
1882
# prime number to ensure we get less chance of 'same wakeup' with
1883
# other processes.
1884
CONFD_CONFIG_RELOAD_TIMEOUT = _constants.CONFD_CONFIG_RELOAD_TIMEOUT
1885

    
1886
# If we receive more than one update in this amount of microseconds,
1887
# we move to polling every RATELIMIT seconds, rather than relying on
1888
# inotify, to be able to serve more requests.
1889
CONFD_CONFIG_RELOAD_RATELIMIT = _constants.CONFD_CONFIG_RELOAD_RATELIMIT
1890

    
1891
# Magic number prepended to all confd queries.
1892
# This allows us to distinguish different types of confd protocols and handle
1893
# them. For example by changing this we can move the whole payload to be
1894
# compressed, or move away from json.
1895
CONFD_MAGIC_FOURCC = _constants.CONFD_MAGIC_FOURCC
1896

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

    
1902
# Timeout in seconds to expire pending query request in the confd client
1903
# library. We don't actually expect any answer more than 10 seconds after we
1904
# sent a request.
1905
CONFD_CLIENT_EXPIRE_TIMEOUT = _constants.CONFD_CLIENT_EXPIRE_TIMEOUT
1906

    
1907
# Maximum UDP datagram size.
1908
# On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
1909
# On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
1910
#   (assuming we can't use jumbo frames)
1911
# We just set this to 60K, which should be enough
1912
MAX_UDP_DATA_SIZE = 61440
1913

    
1914
# User-id pool minimum/maximum acceptable user-ids.
1915
UIDPOOL_UID_MIN = 0
1916
UIDPOOL_UID_MAX = 2 ** 32 - 1 # Assuming 32 bit user-ids
1917

    
1918
# Name or path of the pgrep command
1919
PGREP = "pgrep"
1920

    
1921
# Name of the node group that gets created at cluster init or upgrade
1922
INITIAL_NODE_GROUP_NAME = "default"
1923

    
1924
# Possible values for NodeGroup.alloc_policy
1925
ALLOC_POLICY_PREFERRED = _constants.ALLOC_POLICY_PREFERRED
1926
ALLOC_POLICY_LAST_RESORT = _constants.ALLOC_POLICY_LAST_RESORT
1927
ALLOC_POLICY_UNALLOCABLE = _constants.ALLOC_POLICY_UNALLOCABLE
1928
VALID_ALLOC_POLICIES = _constants.VALID_ALLOC_POLICIES
1929

    
1930
# Temporary external/shared storage parameters
1931
BLOCKDEV_DRIVER_MANUAL = _constants.BLOCKDEV_DRIVER_MANUAL
1932

    
1933
# qemu-img path, required for ovfconverter
1934
QEMUIMG_PATH = _constants.QEMUIMG_PATH
1935

    
1936
# Whether htools was enabled at compilation time
1937
HTOOLS = _constants.HTOOLS
1938
# The hail iallocator
1939
IALLOC_HAIL = "hail"
1940

    
1941
# Fake opcodes for functions that have hooks attached to them via
1942
# backend.RunLocalHooks
1943
FAKE_OP_MASTER_TURNUP = "OP_CLUSTER_IP_TURNUP"
1944
FAKE_OP_MASTER_TURNDOWN = "OP_CLUSTER_IP_TURNDOWN"
1945

    
1946
# SSH key types
1947
SSHK_RSA = "rsa"
1948
SSHK_DSA = "dsa"
1949
SSHK_ALL = compat.UniqueFrozenset([SSHK_RSA, SSHK_DSA])
1950

    
1951
# SSH authorized key types
1952
SSHAK_RSA = "ssh-rsa"
1953
SSHAK_DSS = "ssh-dss"
1954
SSHAK_ALL = compat.UniqueFrozenset([SSHAK_RSA, SSHAK_DSS])
1955

    
1956
# SSH setup
1957
SSHS_CLUSTER_NAME = "cluster_name"
1958
SSHS_SSH_HOST_KEY = "ssh_host_key"
1959
SSHS_SSH_ROOT_KEY = "ssh_root_key"
1960
SSHS_NODE_DAEMON_CERTIFICATE = "node_daemon_certificate"
1961

    
1962
#: Key files for SSH daemon
1963
SSH_DAEMON_KEYFILES = {
1964
  SSHK_RSA: (pathutils.SSH_HOST_RSA_PRIV, pathutils.SSH_HOST_RSA_PUB),
1965
  SSHK_DSA: (pathutils.SSH_HOST_DSA_PRIV, pathutils.SSH_HOST_DSA_PUB),
1966
  }
1967

    
1968
# Node daemon setup
1969
NDS_CLUSTER_NAME = "cluster_name"
1970
NDS_NODE_DAEMON_CERTIFICATE = "node_daemon_certificate"
1971
NDS_SSCONF = "ssconf"
1972
NDS_START_NODE_DAEMON = "start_node_daemon"
1973

    
1974
# Path generating random UUID
1975
RANDOM_UUID_FILE = _constants.RANDOM_UUID_FILE
1976

    
1977
# Regex string for verifying a UUID
1978
UUID_REGEX = "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
1979

    
1980
# Auto-repair tag prefixes
1981
AUTO_REPAIR_TAG_PREFIX = _constants.AUTO_REPAIR_TAG_PREFIX
1982
AUTO_REPAIR_TAG_ENABLED = _constants.AUTO_REPAIR_TAG_ENABLED
1983
AUTO_REPAIR_TAG_SUSPENDED = _constants.AUTO_REPAIR_TAG_SUSPENDED
1984
AUTO_REPAIR_TAG_PENDING = _constants.AUTO_REPAIR_TAG_PENDING
1985
AUTO_REPAIR_TAG_RESULT = _constants.AUTO_REPAIR_TAG_RESULT
1986

    
1987
# Auto-repair levels
1988
AUTO_REPAIR_FIX_STORAGE = _constants.AUTO_REPAIR_FIX_STORAGE
1989
AUTO_REPAIR_MIGRATE = _constants.AUTO_REPAIR_MIGRATE
1990
AUTO_REPAIR_FAILOVER = _constants.AUTO_REPAIR_FAILOVER
1991
AUTO_REPAIR_REINSTALL = _constants.AUTO_REPAIR_REINSTALL
1992
AUTO_REPAIR_ALL_TYPES = _constants.AUTO_REPAIR_ALL_TYPES
1993

    
1994
# Auto-repair results
1995
AUTO_REPAIR_SUCCESS = _constants.AUTO_REPAIR_SUCCESS
1996
AUTO_REPAIR_FAILURE = _constants.AUTO_REPAIR_FAILURE
1997
AUTO_REPAIR_ENOPERM = _constants.AUTO_REPAIR_ENOPERM
1998
AUTO_REPAIR_ALL_RESULTS = _constants.AUTO_REPAIR_ALL_RESULTS
1999

    
2000
# The version identifier for builtin data collectors
2001
BUILTIN_DATA_COLLECTOR_VERSION = _constants.BUILTIN_DATA_COLLECTOR_VERSION
2002

    
2003
# The reason trail opcode parameter name
2004
OPCODE_REASON = _constants.OPCODE_REASON
2005

    
2006
# The source reasons for the execution of an OpCode
2007
OPCODE_REASON_SRC_CLIENT = "gnt:client"
2008
OPCODE_REASON_SRC_NODED = "gnt:daemon:noded"
2009
OPCODE_REASON_SRC_OPCODE = "gnt:opcode"
2010
OPCODE_REASON_SRC_RLIB2 = "gnt:library:rlib2"
2011
OPCODE_REASON_SRC_USER = "gnt:user"
2012

    
2013
OPCODE_REASON_SOURCES = compat.UniqueFrozenset([
2014
  OPCODE_REASON_SRC_CLIENT,
2015
  OPCODE_REASON_SRC_NODED,
2016
  OPCODE_REASON_SRC_OPCODE,
2017
  OPCODE_REASON_SRC_RLIB2,
2018
  OPCODE_REASON_SRC_USER,
2019
  ])
2020

    
2021
DISKSTATS_FILE = _constants.DISKSTATS_FILE
2022

    
2023
# CPU load collector variables
2024
STAT_FILE = _constants.STAT_FILE
2025
CPUAVGLOAD_BUFFER_SIZE = _constants.CPUAVGLOAD_BUFFER_SIZE
2026
CPUAVGLOAD_WINDOW_SIZE = _constants.CPUAVGLOAD_WINDOW_SIZE
2027

    
2028
# Mond's variable for periodical data collection
2029
MOND_TIME_INTERVAL = _constants.MOND_TIME_INTERVAL
2030

    
2031
# MonD's latest API version
2032
MOND_LATEST_API_VERSION = 1
2033

    
2034
# Timeouts for upgrades
2035

    
2036
UPGRADE_QUEUE_DRAIN_TIMEOUT = _constants.UPGRADE_QUEUE_DRAIN_TIMEOUT
2037
UPGRADE_QUEUE_POLL_INTERVAL = _constants.UPGRADE_QUEUE_POLL_INTERVAL
2038

    
2039
# Do not re-export imported modules
2040
del re, _vcsversion, _constants, socket, pathutils, compat
2041

    
2042

    
2043
ALLOCATABLE_KEY = "allocatable"
2044
FAILED_KEY = "failed"