Statistics
| Branch: | Tag: | Revision:

root / lib / constants.py @ 173dbf05

History | View | Annotate | Download (36.8 kB)

1
#
2
#
3

    
4
# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Google Inc.
5
#
6
# This program is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 2 of the License, or
9
# (at your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful, but
12
# WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
# General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
# 02110-1301, USA.
20

    
21

    
22
"""Module holding different constants."""
23

    
24
import re
25

    
26
from ganeti import _autoconf
27
from ganeti import _vcsversion
28

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

    
39

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

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

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

57
  Returns: int representing version number
58

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

    
67

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

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

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

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

    
79
  return (major, minor, revision)
80

    
81

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

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

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

    
102

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

    
109

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

    
157
#: Lock file for watcher, locked in shared mode by watcher; lock in exclusive
158
# mode to block watcher (see L{cli._RunWhileClusterStoppedHelper.Call}
159
WATCHER_LOCK_FILE = LOCK_DIR + "/ganeti-watcher.lock"
160

    
161
#: Status file for per-group watcher, locked in exclusive mode by watcher
162
WATCHER_GROUP_STATE_FILE = DATA_DIR + "/watcher.%s.data"
163

    
164
#: File containing Unix timestamp until which watcher should be paused
165
WATCHER_PAUSEFILE = DATA_DIR + "/watcher.pause"
166

    
167
ALL_CERT_FILES = frozenset([NODED_CERT_FILE, RAPI_CERT_FILE])
168

    
169
MASTER_SOCKET = SOCKET_DIR + "/ganeti-master"
170

    
171
NODED = "ganeti-noded"
172
CONFD = "ganeti-confd"
173
RAPI = "ganeti-rapi"
174
MASTERD = "ganeti-masterd"
175
# used in the ganeti-nbma project
176
NLD = "ganeti-nld"
177

    
178
DAEMONS_PORTS = {
179
  # daemon-name: ("proto", "default-port")
180
  NODED: ("tcp", 1811),
181
  CONFD: ("udp", 1814),
182
  RAPI: ("tcp", 5080),
183
  "ssh": ("tcp", 22),
184
  # used in the ganeti-nbma project
185
  NLD: ("udp", 1816),
186
}
187
DEFAULT_NODED_PORT = DAEMONS_PORTS[NODED][1]
188
DEFAULT_CONFD_PORT = DAEMONS_PORTS[CONFD][1]
189
DEFAULT_RAPI_PORT = DAEMONS_PORTS[RAPI][1]
190
# used in the ganeti-nbma project
191
DEFAULT_NLD_PORT = DAEMONS_PORTS[NLD][1]
192

    
193
FIRST_DRBD_PORT = 11000
194
LAST_DRBD_PORT = 14999
195
MASTER_SCRIPT = "ganeti-master"
196

    
197
LOG_DIR = _autoconf.LOCALSTATEDIR + "/log/ganeti/"
198
DAEMONS_LOGFILES = {
199
  # "daemon-name": "logfile"
200
  NODED: LOG_DIR + "node-daemon.log",
201
  CONFD: LOG_DIR + "conf-daemon.log",
202
  RAPI: LOG_DIR + "rapi-daemon.log",
203
  MASTERD: LOG_DIR + "master-daemon.log",
204
  # used in the ganeti-nbma project
205
  NLD: LOG_DIR + "nl-daemon.log",
206
  }
207

    
208
LOG_OS_DIR = LOG_DIR + "os"
209
LOG_WATCHER = LOG_DIR + "watcher.log"
210
LOG_COMMANDS = LOG_DIR + "commands.log"
211
LOG_BURNIN = LOG_DIR + "burnin.log"
212
LOG_SETUP_SSH = LOG_DIR + "setup-ssh.log"
213

    
214
DEV_CONSOLE = "/dev/console"
215

    
216
PROC_MOUNTS = "/proc/mounts"
217

    
218
# Local UniX Interface related constants
219
LUXI_EOM = "\3"
220
LUXI_VERSION = CONFIG_VERSION
221

    
222
# one of "no", "yes", "only"
223
SYSLOG_USAGE = _autoconf.SYSLOG_USAGE
224
SYSLOG_NO = "no"
225
SYSLOG_YES = "yes"
226
SYSLOG_ONLY = "only"
227
SYSLOG_SOCKET = "/dev/log"
228

    
229
OS_SEARCH_PATH = _autoconf.OS_SEARCH_PATH
230
EXPORT_DIR = _autoconf.EXPORT_DIR
231

    
232
EXPORT_CONF_FILE = "config.ini"
233

    
234
XEN_BOOTLOADER = _autoconf.XEN_BOOTLOADER
235
XEN_KERNEL = _autoconf.XEN_KERNEL
236
XEN_INITRD = _autoconf.XEN_INITRD
237

    
238
KVM_PATH = _autoconf.KVM_PATH
239
SOCAT_PATH = _autoconf.SOCAT_PATH
240
SOCAT_USE_ESCAPE = _autoconf.SOCAT_USE_ESCAPE
241
SOCAT_USE_COMPRESS = _autoconf.SOCAT_USE_COMPRESS
242
SOCAT_ESCAPE_CODE = "0x1d"
243

    
244
#: Console as SSH command
245
CONS_SSH = "ssh"
246

    
247
#: Console as VNC server
248
CONS_VNC = "vnc"
249

    
250
#: Display a message for console access
251
CONS_MESSAGE = "msg"
252

    
253
#: All console types
254
CONS_ALL = frozenset([CONS_SSH, CONS_VNC, CONS_MESSAGE])
255

    
256
# For RSA keys more bits are better, but they also make operations more
257
# expensive. NIST SP 800-131 recommends a minimum of 2048 bits from the year
258
# 2010 on.
259
RSA_KEY_BITS = 2048
260

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

    
269
# Digest used to sign certificates ("openssl x509" uses SHA1 by default)
270
X509_CERT_SIGN_DIGEST = "SHA1"
271

    
272
# Default validity of certificates in days
273
X509_CERT_DEFAULT_VALIDITY = 365 * 5
274

    
275
# commonName (CN) used in certificates
276
X509_CERT_CN = "ganeti.example.com"
277

    
278
X509_CERT_SIGNATURE_HEADER = "X-Ganeti-Signature"
279

    
280
IMPORT_EXPORT_DAEMON = _autoconf.PKGLIBDIR + "/import-export"
281

    
282
# Import/export daemon mode
283
IEM_IMPORT = "import"
284
IEM_EXPORT = "export"
285

    
286
# Import/export transport compression
287
IEC_NONE = "none"
288
IEC_GZIP = "gzip"
289
IEC_ALL = frozenset([
290
  IEC_NONE,
291
  IEC_GZIP,
292
  ])
293

    
294
IE_CUSTOM_SIZE = "fd"
295

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

    
298
# Import/export I/O
299
# Direct file I/O, equivalent to a shell's I/O redirection using '<' or '>'
300
IEIO_FILE = "file"
301
# Raw block device I/O using "dd"
302
IEIO_RAW_DISK = "raw"
303
# OS definition import/export script
304
IEIO_SCRIPT = "script"
305

    
306
VALUE_DEFAULT = "default"
307
VALUE_AUTO = "auto"
308
VALUE_GENERATE = "generate"
309
VALUE_NONE = "none"
310
VALUE_TRUE = "true"
311
VALUE_FALSE = "false"
312

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

    
316
# hooks-related constants
317
HOOKS_BASE_DIR = CONF_DIR + "/hooks"
318
HOOKS_PHASE_PRE = "pre"
319
HOOKS_PHASE_POST = "post"
320
HOOKS_NAME_CFGUPDATE = "config-update"
321
HOOKS_NAME_WATCHER = "watcher"
322
HOOKS_VERSION = 2
323

    
324
# hooks subject type (what object type does the LU deal with)
325
HTYPE_CLUSTER = "CLUSTER"
326
HTYPE_NODE = "NODE"
327
HTYPE_GROUP = "GROUP"
328
HTYPE_INSTANCE = "INSTANCE"
329

    
330
HKR_SKIP = 0
331
HKR_FAIL = 1
332
HKR_SUCCESS = 2
333

    
334
# Storage types
335
ST_FILE = "file"
336
ST_LVM_PV = "lvm-pv"
337
ST_LVM_VG = "lvm-vg"
338

    
339
# Storage fields
340
# first two are valid in LU context only, not passed to backend
341
SF_NODE = "node"
342
SF_TYPE = "type"
343
# and the rest are valid in backend
344
SF_NAME = "name"
345
SF_SIZE = "size"
346
SF_FREE = "free"
347
SF_USED = "used"
348
SF_ALLOCATABLE = "allocatable"
349

    
350
# Storage operations
351
SO_FIX_CONSISTENCY = "fix-consistency"
352

    
353
# Available fields per storage type
354
VALID_STORAGE_FIELDS = frozenset([
355
  SF_NAME,
356
  SF_TYPE,
357
  SF_SIZE,
358
  SF_USED,
359
  SF_FREE,
360
  SF_ALLOCATABLE
361
  ])
362

    
363
VALID_STORAGE_TYPES = frozenset([ST_FILE, ST_LVM_PV, ST_LVM_VG])
364

    
365
MODIFIABLE_STORAGE_FIELDS = {
366
  ST_LVM_PV: frozenset([SF_ALLOCATABLE]),
367
  }
368

    
369
VALID_STORAGE_OPERATIONS = {
370
  ST_LVM_VG: frozenset([SO_FIX_CONSISTENCY]),
371
  }
372

    
373
# Local disk status
374
# Note: Code depends on LDS_OKAY < LDS_UNKNOWN < LDS_FAULTY
375
(LDS_OKAY,
376
 LDS_UNKNOWN,
377
 LDS_FAULTY) = range(1, 4)
378

    
379
# disk template types
380
DT_DISKLESS = "diskless"
381
DT_PLAIN = "plain"
382
DT_DRBD8 = "drbd"
383
DT_FILE = "file"
384
DT_SHARED_FILE = "sharedfile"
385
DT_BLOCK = "blockdev"
386

    
387
# the set of network-mirrored disk templates
388
DTS_INT_MIRROR = frozenset([DT_DRBD8])
389

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

    
393
# the set of non-lvm-based disk templates
394
DTS_NOT_LVM = frozenset([DT_DISKLESS, DT_FILE, DT_SHARED_FILE, DT_BLOCK])
395

    
396
# the set of disk templates which can be grown
397
DTS_GROWABLE = frozenset([DT_PLAIN, DT_DRBD8, DT_FILE, DT_SHARED_FILE])
398

    
399
# the set of disk templates that allow adoption
400
DTS_MAY_ADOPT = frozenset([DT_PLAIN, DT_BLOCK])
401

    
402
# the set of disk templates that *must* use adoption
403
DTS_MUST_ADOPT = frozenset([DT_BLOCK])
404

    
405
# the set of disk templates that allow migrations
406
DTS_MIRRORED = frozenset.union(DTS_INT_MIRROR, DTS_EXT_MIRROR)
407

    
408
# the set of file based disk templates
409
DTS_FILEBASED = frozenset([DT_FILE, DT_SHARED_FILE])
410

    
411
# logical disk types
412
LD_LV = "lvm"
413
LD_DRBD8 = "drbd8"
414
LD_FILE = "file"
415
LD_BLOCKDEV = "blockdev"
416
LDS_BLOCK = frozenset([LD_LV, LD_DRBD8, LD_BLOCKDEV])
417

    
418
# drbd constants
419
DRBD_HMAC_ALG = "md5"
420
DRBD_NET_PROTOCOL = "C"
421
DRBD_BARRIERS = _autoconf.DRBD_BARRIERS
422

    
423
# file backend driver
424
FD_LOOP = "loop"
425
FD_BLKTAP = "blktap"
426

    
427
# the set of drbd-like disk types
428
LDS_DRBD = frozenset([LD_DRBD8])
429

    
430
# disk access mode
431
DISK_RDONLY = "ro"
432
DISK_RDWR = "rw"
433
DISK_ACCESS_SET = frozenset([DISK_RDONLY, DISK_RDWR])
434

    
435
# disk replacement mode
436
REPLACE_DISK_PRI = "replace_on_primary"    # replace disks on primary
437
REPLACE_DISK_SEC = "replace_on_secondary"  # replace disks on secondary
438
REPLACE_DISK_CHG = "replace_new_secondary" # change secondary node
439
REPLACE_DISK_AUTO = "replace_auto"
440
REPLACE_MODES = frozenset([
441
  REPLACE_DISK_PRI,
442
  REPLACE_DISK_SEC,
443
  REPLACE_DISK_CHG,
444
  REPLACE_DISK_AUTO,
445
  ])
446

    
447
# Instance export mode
448
EXPORT_MODE_LOCAL = "local"
449
EXPORT_MODE_REMOTE = "remote"
450
EXPORT_MODES = frozenset([
451
  EXPORT_MODE_LOCAL,
452
  EXPORT_MODE_REMOTE,
453
  ])
454

    
455
# Lock recalculate mode
456
LOCKS_REPLACE = "replace"
457
LOCKS_APPEND = "append"
458

    
459
# Lock timeout (sum) before we should go into blocking acquire (still
460
# can be reset by priority change); computed as max time (10 hours)
461
# before we should actually go into blocking acquire given that we
462
# start from default priority level; in seconds
463
LOCK_ATTEMPTS_TIMEOUT = 10 * 3600 / 20.0
464
LOCK_ATTEMPTS_MAXWAIT = 15.0
465
LOCK_ATTEMPTS_MINWAIT = 1.0
466

    
467
# instance creation modes
468
INSTANCE_CREATE = "create"
469
INSTANCE_IMPORT = "import"
470
INSTANCE_REMOTE_IMPORT = "remote-import"
471
INSTANCE_CREATE_MODES = frozenset([
472
  INSTANCE_CREATE,
473
  INSTANCE_IMPORT,
474
  INSTANCE_REMOTE_IMPORT,
475
  ])
476

    
477
# Remote import/export handshake message and version
478
RIE_VERSION = 0
479
RIE_HANDSHAKE = "Hi, I'm Ganeti"
480

    
481
# Remote import/export certificate validity in seconds
482
RIE_CERT_VALIDITY = 24 * 60 * 60
483

    
484
# Overall timeout for establishing connection
485
RIE_CONNECT_TIMEOUT = 180
486

    
487
# Export only: how long to wait per connection attempt (seconds)
488
RIE_CONNECT_ATTEMPT_TIMEOUT = 20
489

    
490
# Export only: number of attempts to connect
491
RIE_CONNECT_RETRIES = 10
492

    
493
#: Give child process up to 5 seconds to exit after sending a signal
494
CHILD_LINGER_TIMEOUT = 5.0
495

    
496
DISK_TEMPLATES = frozenset([
497
  DT_DISKLESS,
498
  DT_PLAIN,
499
  DT_DRBD8,
500
  DT_FILE,
501
  DT_SHARED_FILE,
502
  DT_BLOCK
503
  ])
504

    
505
FILE_DRIVER = frozenset([FD_LOOP, FD_BLKTAP])
506

    
507
# import/export config options
508
INISECT_EXP = "export"
509
INISECT_INS = "instance"
510
INISECT_HYP = "hypervisor"
511
INISECT_BEP = "backend"
512
INISECT_OSP = "os"
513

    
514
# dynamic device modification
515
DDM_ADD = "add"
516
DDM_REMOVE = "remove"
517
DDMS_VALUES = frozenset([DDM_ADD, DDM_REMOVE])
518

    
519
# common exit codes
520
EXIT_SUCCESS = 0
521
EXIT_FAILURE = 1
522
EXIT_NOTCLUSTER = 5
523
EXIT_NOTMASTER = 11
524
EXIT_NODESETUP_ERROR = 12
525
EXIT_CONFIRMATION = 13 # need user confirmation
526

    
527
#: Exit code for query operations with unknown fields
528
EXIT_UNKNOWN_FIELD = 14
529

    
530
# tags
531
TAG_CLUSTER = "cluster"
532
TAG_NODEGROUP = "nodegroup"
533
TAG_NODE = "node"
534
TAG_INSTANCE = "instance"
535
VALID_TAG_TYPES = frozenset([
536
  TAG_CLUSTER,
537
  TAG_NODEGROUP,
538
  TAG_NODE,
539
  TAG_INSTANCE,
540
  ])
541
MAX_TAG_LEN = 128
542
MAX_TAGS_PER_OBJ = 4096
543

    
544
# others
545
DEFAULT_BRIDGE = "xen-br0"
546
SYNC_SPEED = 60 * 1024
547
IP4_ADDRESS_LOCALHOST = "127.0.0.1"
548
IP4_ADDRESS_ANY = "0.0.0.0"
549
IP6_ADDRESS_LOCALHOST = "::1"
550
IP6_ADDRESS_ANY = "::"
551
IP4_VERSION = 4
552
IP6_VERSION = 6
553
TCP_PING_TIMEOUT = 10
554
GANETI_RUNAS = "root"
555
DEFAULT_VG = "xenvg"
556
DEFAULT_DRBD_HELPER = "/bin/true"
557
MIN_VG_SIZE = 20480
558
DEFAULT_MAC_PREFIX = "aa:00:00"
559
LVM_STRIPECOUNT = _autoconf.LVM_STRIPECOUNT
560
# default maximum instance wait time, in seconds.
561
DEFAULT_SHUTDOWN_TIMEOUT = 120
562
NODE_MAX_CLOCK_SKEW = 150
563
# Time for an intra-cluster disk transfer to wait for a connection
564
DISK_TRANSFER_CONNECT_TIMEOUT = 60
565
# Disk index separator
566
DISK_SEPARATOR = _autoconf.DISK_SEPARATOR
567

    
568
#: Key for job IDs in opcode result
569
JOB_IDS_KEY = "jobs"
570

    
571
# runparts results
572
(RUNPARTS_SKIP,
573
 RUNPARTS_RUN,
574
 RUNPARTS_ERR) = range(3)
575

    
576
RUNPARTS_STATUS = frozenset([RUNPARTS_SKIP, RUNPARTS_RUN, RUNPARTS_ERR])
577

    
578
# RPC constants
579
(RPC_ENCODING_NONE,
580
 RPC_ENCODING_ZLIB_BASE64) = range(2)
581

    
582
# os related constants
583
OS_SCRIPT_CREATE = "create"
584
OS_SCRIPT_IMPORT = "import"
585
OS_SCRIPT_EXPORT = "export"
586
OS_SCRIPT_RENAME = "rename"
587
OS_SCRIPT_VERIFY = "verify"
588
OS_SCRIPTS = frozenset([
589
  OS_SCRIPT_CREATE,
590
  OS_SCRIPT_IMPORT,
591
  OS_SCRIPT_EXPORT,
592
  OS_SCRIPT_RENAME,
593
  OS_SCRIPT_VERIFY
594
  ])
595

    
596
OS_API_FILE = "ganeti_api_version"
597
OS_VARIANTS_FILE = "variants.list"
598
OS_PARAMETERS_FILE = "parameters.list"
599

    
600
OS_VALIDATE_PARAMETERS = "parameters"
601
OS_VALIDATE_CALLS = frozenset([OS_VALIDATE_PARAMETERS])
602

    
603
# ssh constants
604
SSH_CONFIG_DIR = _autoconf.SSH_CONFIG_DIR
605
SSH_HOST_DSA_PRIV = SSH_CONFIG_DIR + "/ssh_host_dsa_key"
606
SSH_HOST_DSA_PUB = SSH_HOST_DSA_PRIV + ".pub"
607
SSH_HOST_RSA_PRIV = SSH_CONFIG_DIR + "/ssh_host_rsa_key"
608
SSH_HOST_RSA_PUB = SSH_HOST_RSA_PRIV + ".pub"
609
SSH = "ssh"
610
SCP = "scp"
611

    
612
# reboot types
613
INSTANCE_REBOOT_SOFT = "soft"
614
INSTANCE_REBOOT_HARD = "hard"
615
INSTANCE_REBOOT_FULL = "full"
616

    
617
REBOOT_TYPES = frozenset([
618
  INSTANCE_REBOOT_SOFT,
619
  INSTANCE_REBOOT_HARD,
620
  INSTANCE_REBOOT_FULL
621
  ])
622

    
623
# instance reboot behaviors
624
INSTANCE_REBOOT_ALLOWED = "reboot"
625
INSTANCE_REBOOT_EXIT = "exit"
626

    
627
REBOOT_BEHAVIORS = frozenset([
628
  INSTANCE_REBOOT_ALLOWED,
629
  INSTANCE_REBOOT_EXIT
630
  ])
631

    
632
VTYPE_STRING = "string"
633
VTYPE_MAYBE_STRING = "maybe-string"
634
VTYPE_BOOL = "bool"
635
VTYPE_SIZE = "size" # size, in MiBs
636
VTYPE_INT = "int"
637
ENFORCEABLE_TYPES = frozenset([
638
  VTYPE_STRING,
639
  VTYPE_MAYBE_STRING,
640
  VTYPE_BOOL,
641
  VTYPE_SIZE,
642
  VTYPE_INT,
643
  ])
644

    
645
# HV parameter names (global namespace)
646
HV_BOOT_ORDER = "boot_order"
647
HV_CDROM_IMAGE_PATH = "cdrom_image_path"
648
HV_KVM_CDROM2_IMAGE_PATH = "cdrom2_image_path"
649
HV_KVM_FLOPPY_IMAGE_PATH = "floppy_image_path"
650
HV_NIC_TYPE = "nic_type"
651
HV_DISK_TYPE = "disk_type"
652
HV_KVM_CDROM_DISK_TYPE = "cdrom_disk_type"
653
HV_VNC_BIND_ADDRESS = "vnc_bind_address"
654
HV_VNC_PASSWORD_FILE = "vnc_password_file"
655
HV_VNC_TLS = "vnc_tls"
656
HV_VNC_X509 = "vnc_x509_path"
657
HV_VNC_X509_VERIFY = "vnc_x509_verify"
658
HV_ACPI = "acpi"
659
HV_PAE = "pae"
660
HV_USE_BOOTLOADER = "use_bootloader"
661
HV_BOOTLOADER_ARGS = "bootloader_args"
662
HV_BOOTLOADER_PATH = "bootloader_path"
663
HV_KERNEL_ARGS = "kernel_args"
664
HV_KERNEL_PATH = "kernel_path"
665
HV_INITRD_PATH = "initrd_path"
666
HV_ROOT_PATH = "root_path"
667
HV_SERIAL_CONSOLE = "serial_console"
668
HV_USB_MOUSE = "usb_mouse"
669
HV_KEYMAP = "keymap"
670
HV_DEVICE_MODEL = "device_model"
671
HV_INIT_SCRIPT = "init_script"
672
HV_MIGRATION_PORT = "migration_port"
673
HV_MIGRATION_BANDWIDTH = "migration_bandwidth"
674
HV_MIGRATION_DOWNTIME = "migration_downtime"
675
HV_MIGRATION_MODE = "migration_mode"
676
HV_USE_LOCALTIME = "use_localtime"
677
HV_DISK_CACHE = "disk_cache"
678
HV_SECURITY_MODEL = "security_model"
679
HV_SECURITY_DOMAIN = "security_domain"
680
HV_KVM_FLAG = "kvm_flag"
681
HV_VHOST_NET = "vhost_net"
682
HV_KVM_USE_CHROOT = "use_chroot"
683
HV_CPU_MASK = "cpu_mask"
684
HV_MEM_PATH = "mem_path"
685
HV_BLOCKDEV_PREFIX = "blockdev_prefix"
686
HV_REBOOT_BEHAVIOR = "reboot_behavior"
687

    
688
HVS_PARAMETER_TYPES = {
689
  HV_BOOT_ORDER: VTYPE_STRING,
690
  HV_KVM_FLOPPY_IMAGE_PATH: VTYPE_STRING,
691
  HV_CDROM_IMAGE_PATH: VTYPE_STRING,
692
  HV_KVM_CDROM2_IMAGE_PATH: VTYPE_STRING,
693
  HV_NIC_TYPE: VTYPE_STRING,
694
  HV_DISK_TYPE: VTYPE_STRING,
695
  HV_KVM_CDROM_DISK_TYPE: VTYPE_STRING,
696
  HV_VNC_PASSWORD_FILE: VTYPE_STRING,
697
  HV_VNC_BIND_ADDRESS: VTYPE_STRING,
698
  HV_VNC_TLS: VTYPE_BOOL,
699
  HV_VNC_X509: VTYPE_STRING,
700
  HV_VNC_X509_VERIFY: VTYPE_BOOL,
701
  HV_ACPI: VTYPE_BOOL,
702
  HV_PAE: VTYPE_BOOL,
703
  HV_USE_BOOTLOADER: VTYPE_BOOL,
704
  HV_BOOTLOADER_PATH: VTYPE_STRING,
705
  HV_BOOTLOADER_ARGS: VTYPE_STRING,
706
  HV_KERNEL_PATH: VTYPE_STRING,
707
  HV_KERNEL_ARGS: VTYPE_STRING,
708
  HV_INITRD_PATH: VTYPE_STRING,
709
  HV_ROOT_PATH: VTYPE_MAYBE_STRING,
710
  HV_SERIAL_CONSOLE: VTYPE_BOOL,
711
  HV_USB_MOUSE: VTYPE_STRING,
712
  HV_KEYMAP: VTYPE_STRING,
713
  HV_DEVICE_MODEL: VTYPE_STRING,
714
  HV_INIT_SCRIPT: VTYPE_STRING,
715
  HV_MIGRATION_PORT: VTYPE_INT,
716
  HV_MIGRATION_BANDWIDTH: VTYPE_INT,
717
  HV_MIGRATION_DOWNTIME: VTYPE_INT,
718
  HV_MIGRATION_MODE: VTYPE_STRING,
719
  HV_USE_LOCALTIME: VTYPE_BOOL,
720
  HV_DISK_CACHE: VTYPE_STRING,
721
  HV_SECURITY_MODEL: VTYPE_STRING,
722
  HV_SECURITY_DOMAIN: VTYPE_STRING,
723
  HV_KVM_FLAG: VTYPE_STRING,
724
  HV_VHOST_NET: VTYPE_BOOL,
725
  HV_KVM_USE_CHROOT: VTYPE_BOOL,
726
  HV_CPU_MASK: VTYPE_STRING,
727
  HV_MEM_PATH: VTYPE_STRING,
728
  HV_BLOCKDEV_PREFIX: VTYPE_STRING,
729
  HV_REBOOT_BEHAVIOR: VTYPE_STRING,
730
  }
731

    
732
HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
733

    
734
# Backend parameter names
735
BE_MEMORY = "memory"
736
BE_VCPUS = "vcpus"
737
BE_AUTO_BALANCE = "auto_balance"
738

    
739
BES_PARAMETER_TYPES = {
740
    BE_MEMORY: VTYPE_SIZE,
741
    BE_VCPUS: VTYPE_INT,
742
    BE_AUTO_BALANCE: VTYPE_BOOL,
743
    }
744

    
745
BES_PARAMETERS = frozenset(BES_PARAMETER_TYPES.keys())
746

    
747
# Node parameter names
748
ND_OOB_PROGRAM = "oob_program"
749

    
750
NDS_PARAMETER_TYPES = {
751
    ND_OOB_PROGRAM: VTYPE_MAYBE_STRING,
752
    }
753

    
754
NDS_PARAMETERS = frozenset(NDS_PARAMETER_TYPES.keys())
755

    
756
# OOB supported commands
757
OOB_POWER_ON = "power-on"
758
OOB_POWER_OFF = "power-off"
759
OOB_POWER_CYCLE = "power-cycle"
760
OOB_POWER_STATUS = "power-status"
761
OOB_HEALTH = "health"
762

    
763
OOB_COMMANDS = frozenset([
764
  OOB_POWER_ON,
765
  OOB_POWER_OFF,
766
  OOB_POWER_CYCLE,
767
  OOB_POWER_STATUS,
768
  OOB_HEALTH
769
  ])
770

    
771
OOB_POWER_STATUS_POWERED = "powered"
772

    
773
OOB_TIMEOUT = 60 # 60 seconds
774
OOB_POWER_DELAY = 2.0 # 2 seconds
775

    
776
OOB_STATUS_OK = "OK"
777
OOB_STATUS_WARNING = "WARNING"
778
OOB_STATUS_CRITICAL = "CRITICAL"
779
OOB_STATUS_UNKNOWN = "UNKNOWN"
780

    
781
OOB_STATUSES = frozenset([
782
  OOB_STATUS_OK,
783
  OOB_STATUS_WARNING,
784
  OOB_STATUS_CRITICAL,
785
  OOB_STATUS_UNKNOWN,
786
  ])
787

    
788
# Instance Parameters Profile
789
PP_DEFAULT = "default"
790

    
791
# NIC_* constants are used inside the ganeti config
792
NIC_MODE = "mode"
793
NIC_LINK = "link"
794

    
795
NIC_MODE_BRIDGED = "bridged"
796
NIC_MODE_ROUTED = "routed"
797

    
798
NIC_VALID_MODES = frozenset([NIC_MODE_BRIDGED, NIC_MODE_ROUTED])
799

    
800
NICS_PARAMETER_TYPES = {
801
    NIC_MODE: VTYPE_STRING,
802
    NIC_LINK: VTYPE_STRING,
803
    }
804

    
805
NICS_PARAMETERS = frozenset(NICS_PARAMETER_TYPES.keys())
806

    
807
# IDISK_* constants are used in opcodes, to create/change disks
808
IDISK_SIZE = "size"
809
IDISK_MODE = "mode"
810
IDISK_ADOPT = "adopt"
811
IDISK_VG = "vg"
812
IDISK_METAVG = "metavg"
813
IDISK_PARAMS_TYPES = {
814
  IDISK_SIZE: VTYPE_SIZE,
815
  IDISK_MODE: VTYPE_STRING,
816
  IDISK_ADOPT: VTYPE_STRING,
817
  IDISK_VG: VTYPE_STRING,
818
  IDISK_METAVG: VTYPE_STRING,
819
  }
820
IDISK_PARAMS = frozenset(IDISK_PARAMS_TYPES.keys())
821

    
822
# INIC_* constants are used in opcodes, to create/change nics
823
INIC_MAC = "mac"
824
INIC_IP = "ip"
825
INIC_MODE = "mode"
826
INIC_LINK = "link"
827
INIC_PARAMS_TYPES = {
828
  INIC_IP: VTYPE_MAYBE_STRING,
829
  INIC_LINK: VTYPE_STRING,
830
  INIC_MAC: VTYPE_STRING,
831
  INIC_MODE: VTYPE_STRING,
832
  }
833
INIC_PARAMS = frozenset(INIC_PARAMS_TYPES.keys())
834

    
835
# Hypervisor constants
836
HT_XEN_PVM = "xen-pvm"
837
HT_FAKE = "fake"
838
HT_XEN_HVM = "xen-hvm"
839
HT_KVM = "kvm"
840
HT_CHROOT = "chroot"
841
HT_LXC = "lxc"
842
HYPER_TYPES = frozenset([
843
  HT_XEN_PVM,
844
  HT_FAKE,
845
  HT_XEN_HVM,
846
  HT_KVM,
847
  HT_CHROOT,
848
  HT_LXC,
849
  ])
850
HTS_REQ_PORT = frozenset([HT_XEN_HVM, HT_KVM])
851

    
852
VNC_BASE_PORT = 5900
853
VNC_PASSWORD_FILE = CONF_DIR + "/vnc-cluster-password"
854
VNC_DEFAULT_BIND_ADDRESS = IP4_ADDRESS_ANY
855

    
856
# NIC types
857
HT_NIC_RTL8139 = "rtl8139"
858
HT_NIC_NE2K_PCI = "ne2k_pci"
859
HT_NIC_NE2K_ISA = "ne2k_isa"
860
HT_NIC_I82551 = "i82551"
861
HT_NIC_I85557B = "i82557b"
862
HT_NIC_I8259ER = "i82559er"
863
HT_NIC_PCNET = "pcnet"
864
HT_NIC_E1000 = "e1000"
865
HT_NIC_PARAVIRTUAL = HT_DISK_PARAVIRTUAL = "paravirtual"
866

    
867
HT_HVM_VALID_NIC_TYPES = frozenset([
868
  HT_NIC_RTL8139,
869
  HT_NIC_NE2K_PCI,
870
  HT_NIC_E1000,
871
  HT_NIC_NE2K_ISA,
872
  HT_NIC_PARAVIRTUAL
873
  ])
874
HT_KVM_VALID_NIC_TYPES = frozenset([
875
  HT_NIC_RTL8139,
876
  HT_NIC_NE2K_PCI,
877
  HT_NIC_NE2K_ISA,
878
  HT_NIC_I82551,
879
  HT_NIC_I85557B,
880
  HT_NIC_I8259ER,
881
  HT_NIC_PCNET,
882
  HT_NIC_E1000,
883
  HT_NIC_PARAVIRTUAL
884
  ])
885

    
886
# Disk types
887
HT_DISK_IOEMU = "ioemu"
888
HT_DISK_IDE = "ide"
889
HT_DISK_SCSI = "scsi"
890
HT_DISK_SD = "sd"
891
HT_DISK_MTD = "mtd"
892
HT_DISK_PFLASH = "pflash"
893

    
894
HT_CACHE_DEFAULT = "default"
895
HT_CACHE_NONE = "none"
896
HT_CACHE_WTHROUGH = "writethrough"
897
HT_CACHE_WBACK = "writeback"
898
HT_VALID_CACHE_TYPES = frozenset([
899
  HT_CACHE_DEFAULT,
900
  HT_CACHE_NONE,
901
  HT_CACHE_WTHROUGH,
902
  HT_CACHE_WBACK
903
  ])
904

    
905
HT_HVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IOEMU])
906
HT_KVM_VALID_DISK_TYPES = frozenset([
907
  HT_DISK_PARAVIRTUAL,
908
  HT_DISK_IDE,
909
  HT_DISK_SCSI,
910
  HT_DISK_SD,
911
  HT_DISK_MTD,
912
  HT_DISK_PFLASH
913
  ])
914

    
915
# Mouse types:
916
HT_MOUSE_MOUSE = "mouse"
917
HT_MOUSE_TABLET = "tablet"
918

    
919
HT_KVM_VALID_MOUSE_TYPES = frozenset([HT_MOUSE_MOUSE, HT_MOUSE_TABLET])
920

    
921
# Boot order
922
HT_BO_FLOPPY = "floppy"
923
HT_BO_CDROM = "cdrom"
924
HT_BO_DISK = "disk"
925
HT_BO_NETWORK = "network"
926

    
927
HT_KVM_VALID_BO_TYPES = frozenset([
928
  HT_BO_FLOPPY,
929
  HT_BO_CDROM,
930
  HT_BO_DISK,
931
  HT_BO_NETWORK
932
  ])
933

    
934
# Security models
935
HT_SM_NONE = "none"
936
HT_SM_USER = "user"
937
HT_SM_POOL = "pool"
938

    
939
HT_KVM_VALID_SM_TYPES = frozenset([HT_SM_NONE, HT_SM_USER, HT_SM_POOL])
940

    
941
# Kvm flag values
942
HT_KVM_ENABLED = "enabled"
943
HT_KVM_DISABLED = "disabled"
944

    
945
HT_KVM_FLAG_VALUES = frozenset([HT_KVM_ENABLED, HT_KVM_DISABLED])
946

    
947
# Migration type
948
HT_MIGRATION_LIVE = "live"
949
HT_MIGRATION_NONLIVE = "non-live"
950
HT_MIGRATION_MODES = frozenset([HT_MIGRATION_LIVE, HT_MIGRATION_NONLIVE])
951

    
952
# Cluster Verify steps
953
VERIFY_NPLUSONE_MEM = "nplusone_mem"
954
VERIFY_OPTIONAL_CHECKS = frozenset([VERIFY_NPLUSONE_MEM])
955

    
956
# Node verify constants
957
NV_DRBDHELPER = "drbd-helper"
958
NV_DRBDLIST = "drbd-list"
959
NV_FILELIST = "filelist"
960
NV_HVINFO = "hvinfo"
961
NV_HYPERVISOR = "hypervisor"
962
NV_HVPARAMS = "hvparms"
963
NV_INSTANCELIST = "instancelist"
964
NV_LVLIST = "lvlist"
965
NV_MASTERIP = "master-ip"
966
NV_NODELIST = "nodelist"
967
NV_NODENETTEST = "node-net-test"
968
NV_NODESETUP = "nodesetup"
969
NV_OSLIST = "oslist"
970
NV_PVLIST = "pvlist"
971
NV_TIME = "time"
972
NV_VERSION = "version"
973
NV_VGLIST = "vglist"
974
NV_VMNODES = "vmnodes"
975
NV_OOB_PATHS = "oob-paths"
976
NV_BRIDGES = "bridges"
977

    
978
# Instance status
979
INSTST_RUNNING = "running"
980
INSTST_ADMINDOWN = "ADMIN_down"
981
INSTST_NODEOFFLINE = "ERROR_nodeoffline"
982
INSTST_NODEDOWN = "ERROR_nodedown"
983
INSTST_WRONGNODE = "ERROR_wrongnode"
984
INSTST_ERRORUP = "ERROR_up"
985
INSTST_ERRORDOWN = "ERROR_down"
986
INSTST_ALL = frozenset([
987
  INSTST_RUNNING,
988
  INSTST_ADMINDOWN,
989
  INSTST_NODEOFFLINE,
990
  INSTST_NODEDOWN,
991
  INSTST_WRONGNODE,
992
  INSTST_ERRORUP,
993
  INSTST_ERRORDOWN,
994
  ])
995

    
996
# Node roles
997
NR_REGULAR = "R"
998
NR_MASTER = "M"
999
NR_MCANDIDATE = "C"
1000
NR_DRAINED = "D"
1001
NR_OFFLINE = "O"
1002
NR_ALL = frozenset([
1003
  NR_REGULAR,
1004
  NR_MASTER,
1005
  NR_MCANDIDATE,
1006
  NR_DRAINED,
1007
  NR_OFFLINE,
1008
  ])
1009

    
1010
# SSL certificate check constants (in days)
1011
SSL_CERT_EXPIRATION_WARN = 30
1012
SSL_CERT_EXPIRATION_ERROR = 7
1013

    
1014
# Allocator framework constants
1015
IALLOCATOR_VERSION = 2
1016
IALLOCATOR_DIR_IN = "in"
1017
IALLOCATOR_DIR_OUT = "out"
1018
VALID_IALLOCATOR_DIRECTIONS = frozenset([
1019
  IALLOCATOR_DIR_IN,
1020
  IALLOCATOR_DIR_OUT,
1021
  ])
1022
IALLOCATOR_MODE_ALLOC = "allocate"
1023
IALLOCATOR_MODE_RELOC = "relocate"
1024
IALLOCATOR_MODE_MEVAC = "multi-evacuate"
1025
IALLOCATOR_MODE_CHG_GROUP = "change-group"
1026
IALLOCATOR_MODE_NODE_EVAC = "node-evacuate"
1027
VALID_IALLOCATOR_MODES = frozenset([
1028
  IALLOCATOR_MODE_ALLOC,
1029
  IALLOCATOR_MODE_RELOC,
1030
  IALLOCATOR_MODE_MEVAC,
1031
  IALLOCATOR_MODE_CHG_GROUP,
1032
  IALLOCATOR_MODE_NODE_EVAC,
1033
  ])
1034
IALLOCATOR_SEARCH_PATH = _autoconf.IALLOCATOR_SEARCH_PATH
1035

    
1036
IALLOCATOR_NEVAC_PRI = "primary-only"
1037
IALLOCATOR_NEVAC_SEC = "secondary-only"
1038
IALLOCATOR_NEVAC_ALL = "all"
1039
IALLOCATOR_NEVAC_MODES = frozenset([
1040
  IALLOCATOR_NEVAC_PRI,
1041
  IALLOCATOR_NEVAC_SEC,
1042
  IALLOCATOR_NEVAC_ALL,
1043
  ])
1044

    
1045
# Job queue
1046
JOB_QUEUE_VERSION = 1
1047
JOB_QUEUE_LOCK_FILE = QUEUE_DIR + "/lock"
1048
JOB_QUEUE_VERSION_FILE = QUEUE_DIR + "/version"
1049
JOB_QUEUE_SERIAL_FILE = QUEUE_DIR + "/serial"
1050
JOB_QUEUE_ARCHIVE_DIR = QUEUE_DIR + "/archive"
1051
JOB_QUEUE_DRAIN_FILE = QUEUE_DIR + "/drain"
1052
JOB_QUEUE_SIZE_HARD_LIMIT = 5000
1053
JOB_QUEUE_DIRS = [QUEUE_DIR, JOB_QUEUE_ARCHIVE_DIR]
1054
JOB_QUEUE_DIRS_MODE = SECURE_DIR_MODE
1055

    
1056
JOB_ID_TEMPLATE = r"\d+"
1057

    
1058
# unchanged job return
1059
JOB_NOTCHANGED = "nochange"
1060

    
1061
# Job status
1062
JOB_STATUS_QUEUED = "queued"
1063
JOB_STATUS_WAITING = "waiting"
1064
JOB_STATUS_CANCELING = "canceling"
1065
JOB_STATUS_RUNNING = "running"
1066
JOB_STATUS_CANCELED = "canceled"
1067
JOB_STATUS_SUCCESS = "success"
1068
JOB_STATUS_ERROR = "error"
1069
JOBS_FINALIZED = frozenset([
1070
  JOB_STATUS_CANCELED,
1071
  JOB_STATUS_SUCCESS,
1072
  JOB_STATUS_ERROR,
1073
  ])
1074
JOB_STATUS_ALL = frozenset([
1075
  JOB_STATUS_QUEUED,
1076
  JOB_STATUS_WAITING,
1077
  JOB_STATUS_CANCELING,
1078
  JOB_STATUS_RUNNING,
1079
  ]) | JOBS_FINALIZED
1080

    
1081
# OpCode status
1082
# not yet finalized
1083
OP_STATUS_QUEUED = "queued"
1084
OP_STATUS_WAITING = "waiting"
1085
OP_STATUS_CANCELING = "canceling"
1086
OP_STATUS_RUNNING = "running"
1087
# finalized
1088
OP_STATUS_CANCELED = "canceled"
1089
OP_STATUS_SUCCESS = "success"
1090
OP_STATUS_ERROR = "error"
1091
OPS_FINALIZED = frozenset([
1092
  OP_STATUS_CANCELED,
1093
  OP_STATUS_SUCCESS,
1094
  OP_STATUS_ERROR
1095
  ])
1096

    
1097
# OpCode priority
1098
OP_PRIO_LOWEST = +19
1099
OP_PRIO_HIGHEST = -20
1100

    
1101
OP_PRIO_LOW = +10
1102
OP_PRIO_NORMAL = 0
1103
OP_PRIO_HIGH = -10
1104

    
1105
OP_PRIO_SUBMIT_VALID = frozenset([
1106
  OP_PRIO_LOW,
1107
  OP_PRIO_NORMAL,
1108
  OP_PRIO_HIGH,
1109
  ])
1110

    
1111
OP_PRIO_DEFAULT = OP_PRIO_NORMAL
1112

    
1113
# Execution log types
1114
ELOG_MESSAGE = "message"
1115
ELOG_PROGRESS = "progress"
1116
ELOG_REMOTE_IMPORT = "remote-import"
1117
ELOG_JQUEUE_TEST = "jqueue-test"
1118

    
1119
# /etc/hosts modification
1120
ETC_HOSTS_ADD = "add"
1121
ETC_HOSTS_REMOVE = "remove"
1122

    
1123
# Job queue test
1124
JQT_MSGPREFIX = "TESTMSG="
1125
JQT_EXPANDNAMES = "expandnames"
1126
JQT_EXEC = "exec"
1127
JQT_LOGMSG = "logmsg"
1128
JQT_STARTMSG = "startmsg"
1129
JQT_ALL = frozenset([
1130
  JQT_EXPANDNAMES,
1131
  JQT_EXEC,
1132
  JQT_LOGMSG,
1133
  JQT_STARTMSG,
1134
  ])
1135

    
1136
# Query resources
1137
QR_INSTANCE = "instance"
1138
QR_NODE = "node"
1139
QR_LOCK = "lock"
1140
QR_GROUP = "group"
1141
QR_OS = "os"
1142

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

    
1146
#: List of resources which can be queried using Local UniX Interface
1147
QR_VIA_LUXI = QR_VIA_OP.union([
1148
  QR_LOCK,
1149
  ])
1150

    
1151
#: List of resources which can be queried using RAPI
1152
QR_VIA_RAPI = QR_VIA_LUXI
1153

    
1154
# Query field types
1155
QFT_UNKNOWN = "unknown"
1156
QFT_TEXT = "text"
1157
QFT_BOOL = "bool"
1158
QFT_NUMBER = "number"
1159
QFT_UNIT = "unit"
1160
QFT_TIMESTAMP = "timestamp"
1161
QFT_OTHER = "other"
1162

    
1163
#: All query field types
1164
QFT_ALL = frozenset([
1165
  QFT_UNKNOWN,
1166
  QFT_TEXT,
1167
  QFT_BOOL,
1168
  QFT_NUMBER,
1169
  QFT_UNIT,
1170
  QFT_TIMESTAMP,
1171
  QFT_OTHER,
1172
  ])
1173

    
1174
# Query result field status (don't change or reuse values as they're used by
1175
# clients)
1176
#: Normal field status
1177
RS_NORMAL = 0
1178
#: Unknown field
1179
RS_UNKNOWN = 1
1180
#: No data (e.g. RPC error), can be used instead of L{RS_OFFLINE}
1181
RS_NODATA = 2
1182
#: Value unavailable/unsupported for item; if this field is supported
1183
#: but we cannot get the data for the moment, RS_NODATA or
1184
#: RS_OFFLINE should be used
1185
RS_UNAVAIL = 3
1186
#: Resource marked offline
1187
RS_OFFLINE = 4
1188

    
1189
RS_ALL = frozenset([
1190
  RS_NORMAL,
1191
  RS_UNKNOWN,
1192
  RS_NODATA,
1193
  RS_UNAVAIL,
1194
  RS_OFFLINE,
1195
  ])
1196

    
1197
#: Dictionary with special field cases and their verbose/terse formatting
1198
RSS_DESCRIPTION = {
1199
  RS_UNKNOWN: ("(unknown)", "??"),
1200
  RS_NODATA:  ("(nodata)",  "?"),
1201
  RS_OFFLINE: ("(offline)", "*"),
1202
  RS_UNAVAIL: ("(unavail)", "-"),
1203
  }
1204

    
1205
# max dynamic devices
1206
MAX_NICS = 8
1207
MAX_DISKS = 16
1208

    
1209
# SSCONF keys
1210
SS_CLUSTER_NAME = "cluster_name"
1211
SS_CLUSTER_TAGS = "cluster_tags"
1212
SS_FILE_STORAGE_DIR = "file_storage_dir"
1213
SS_SHARED_FILE_STORAGE_DIR = "shared_file_storage_dir"
1214
SS_MASTER_CANDIDATES = "master_candidates"
1215
SS_MASTER_CANDIDATES_IPS = "master_candidates_ips"
1216
SS_MASTER_IP = "master_ip"
1217
SS_MASTER_NETDEV = "master_netdev"
1218
SS_MASTER_NODE = "master_node"
1219
SS_NODE_LIST = "node_list"
1220
SS_NODE_PRIMARY_IPS = "node_primary_ips"
1221
SS_NODE_SECONDARY_IPS = "node_secondary_ips"
1222
SS_OFFLINE_NODES = "offline_nodes"
1223
SS_ONLINE_NODES = "online_nodes"
1224
SS_PRIMARY_IP_FAMILY = "primary_ip_family"
1225
SS_INSTANCE_LIST = "instance_list"
1226
SS_RELEASE_VERSION = "release_version"
1227
SS_HYPERVISOR_LIST = "hypervisor_list"
1228
SS_MAINTAIN_NODE_HEALTH = "maintain_node_health"
1229
SS_UID_POOL = "uid_pool"
1230
SS_NODEGROUPS = "nodegroups"
1231

    
1232
# cluster wide default parameters
1233
DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM
1234

    
1235
HVC_DEFAULTS = {
1236
  HT_XEN_PVM: {
1237
    HV_USE_BOOTLOADER: False,
1238
    HV_BOOTLOADER_PATH: XEN_BOOTLOADER,
1239
    HV_BOOTLOADER_ARGS: "",
1240
    HV_KERNEL_PATH: "/boot/vmlinuz-2.6-xenU",
1241
    HV_INITRD_PATH: "",
1242
    HV_ROOT_PATH: "/dev/sda1",
1243
    HV_KERNEL_ARGS: "ro",
1244
    HV_MIGRATION_PORT: 8002,
1245
    HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1246
    HV_BLOCKDEV_PREFIX: "sd",
1247
    HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1248
    },
1249
  HT_XEN_HVM: {
1250
    HV_BOOT_ORDER: "cd",
1251
    HV_CDROM_IMAGE_PATH: "",
1252
    HV_NIC_TYPE: HT_NIC_RTL8139,
1253
    HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
1254
    HV_VNC_BIND_ADDRESS: IP4_ADDRESS_ANY,
1255
    HV_VNC_PASSWORD_FILE: VNC_PASSWORD_FILE,
1256
    HV_ACPI: True,
1257
    HV_PAE: True,
1258
    HV_KERNEL_PATH: "/usr/lib/xen/boot/hvmloader",
1259
    HV_DEVICE_MODEL: "/usr/lib/xen/bin/qemu-dm",
1260
    HV_MIGRATION_PORT: 8002,
1261
    HV_MIGRATION_MODE: HT_MIGRATION_NONLIVE,
1262
    HV_USE_LOCALTIME: False,
1263
    HV_BLOCKDEV_PREFIX: "hd",
1264
    HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1265
    },
1266
  HT_KVM: {
1267
    HV_KERNEL_PATH: "/boot/vmlinuz-2.6-kvmU",
1268
    HV_INITRD_PATH: "",
1269
    HV_KERNEL_ARGS: "ro",
1270
    HV_ROOT_PATH: "/dev/vda1",
1271
    HV_ACPI: True,
1272
    HV_SERIAL_CONSOLE: True,
1273
    HV_VNC_BIND_ADDRESS: "",
1274
    HV_VNC_TLS: False,
1275
    HV_VNC_X509: "",
1276
    HV_VNC_X509_VERIFY: False,
1277
    HV_VNC_PASSWORD_FILE: "",
1278
    HV_KVM_FLOPPY_IMAGE_PATH: "",
1279
    HV_CDROM_IMAGE_PATH: "",
1280
    HV_KVM_CDROM2_IMAGE_PATH: "",
1281
    HV_BOOT_ORDER: HT_BO_DISK,
1282
    HV_NIC_TYPE: HT_NIC_PARAVIRTUAL,
1283
    HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
1284
    HV_KVM_CDROM_DISK_TYPE: "",
1285
    HV_USB_MOUSE: "",
1286
    HV_KEYMAP: "",
1287
    HV_MIGRATION_PORT: 8102,
1288
    HV_MIGRATION_BANDWIDTH: 32, # MiB/s
1289
    HV_MIGRATION_DOWNTIME: 30,  # ms
1290
    HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1291
    HV_USE_LOCALTIME: False,
1292
    HV_DISK_CACHE: HT_CACHE_DEFAULT,
1293
    HV_SECURITY_MODEL: HT_SM_NONE,
1294
    HV_SECURITY_DOMAIN: "",
1295
    HV_KVM_FLAG: "",
1296
    HV_VHOST_NET: False,
1297
    HV_KVM_USE_CHROOT: False,
1298
    HV_MEM_PATH: "",
1299
    HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1300
    },
1301
  HT_FAKE: {
1302
    },
1303
  HT_CHROOT: {
1304
    HV_INIT_SCRIPT: "/ganeti-chroot",
1305
    },
1306
  HT_LXC: {
1307
    HV_CPU_MASK: "",
1308
    },
1309
  }
1310

    
1311
HVC_GLOBALS = frozenset([
1312
  HV_MIGRATION_PORT,
1313
  HV_MIGRATION_BANDWIDTH,
1314
  HV_MIGRATION_MODE,
1315
  ])
1316

    
1317
BEC_DEFAULTS = {
1318
  BE_MEMORY: 128,
1319
  BE_VCPUS: 1,
1320
  BE_AUTO_BALANCE: True,
1321
  }
1322

    
1323
NDC_DEFAULTS = {
1324
  ND_OOB_PROGRAM: None,
1325
  }
1326

    
1327
NICC_DEFAULTS = {
1328
  NIC_MODE: NIC_MODE_BRIDGED,
1329
  NIC_LINK: DEFAULT_BRIDGE,
1330
  }
1331

    
1332
MASTER_POOL_SIZE_DEFAULT = 10
1333

    
1334
CONFD_PROTOCOL_VERSION = 1
1335

    
1336
CONFD_REQ_PING = 0
1337
CONFD_REQ_NODE_ROLE_BYNAME = 1
1338
CONFD_REQ_NODE_PIP_BY_INSTANCE_IP = 2
1339
CONFD_REQ_CLUSTER_MASTER = 3
1340
CONFD_REQ_NODE_PIP_LIST = 4
1341
CONFD_REQ_MC_PIP_LIST = 5
1342
CONFD_REQ_INSTANCES_IPS_LIST = 6
1343

    
1344
# Confd request query fields. These are used to narrow down queries.
1345
# These must be strings rather than integers, because json-encoding
1346
# converts them to strings anyway, as they're used as dict-keys.
1347
CONFD_REQQ_LINK = "0"
1348
CONFD_REQQ_IP = "1"
1349
CONFD_REQQ_IPLIST = "2"
1350
CONFD_REQQ_FIELDS = "3"
1351

    
1352
CONFD_REQFIELD_NAME = "0"
1353
CONFD_REQFIELD_IP = "1"
1354
CONFD_REQFIELD_MNODE_PIP = "2"
1355

    
1356
CONFD_REQS = frozenset([
1357
  CONFD_REQ_PING,
1358
  CONFD_REQ_NODE_ROLE_BYNAME,
1359
  CONFD_REQ_NODE_PIP_BY_INSTANCE_IP,
1360
  CONFD_REQ_CLUSTER_MASTER,
1361
  CONFD_REQ_NODE_PIP_LIST,
1362
  CONFD_REQ_MC_PIP_LIST,
1363
  CONFD_REQ_INSTANCES_IPS_LIST,
1364
  ])
1365

    
1366
CONFD_REPL_STATUS_OK = 0
1367
CONFD_REPL_STATUS_ERROR = 1
1368
CONFD_REPL_STATUS_NOTIMPLEMENTED = 2
1369

    
1370
CONFD_REPL_STATUSES = frozenset([
1371
  CONFD_REPL_STATUS_OK,
1372
  CONFD_REPL_STATUS_ERROR,
1373
  CONFD_REPL_STATUS_NOTIMPLEMENTED,
1374
  ])
1375

    
1376
(CONFD_NODE_ROLE_MASTER,
1377
 CONFD_NODE_ROLE_CANDIDATE,
1378
 CONFD_NODE_ROLE_OFFLINE,
1379
 CONFD_NODE_ROLE_DRAINED,
1380
 CONFD_NODE_ROLE_REGULAR,
1381
 ) = range(5)
1382

    
1383
# A few common errors for confd
1384
CONFD_ERROR_UNKNOWN_ENTRY = 1
1385
CONFD_ERROR_INTERNAL = 2
1386
CONFD_ERROR_ARGUMENT = 3
1387

    
1388
# Each request is "salted" by the current timestamp.
1389
# This constants decides how many seconds of skew to accept.
1390
# TODO: make this a default and allow the value to be more configurable
1391
CONFD_MAX_CLOCK_SKEW = 2 * NODE_MAX_CLOCK_SKEW
1392

    
1393
# When we haven't reloaded the config for more than this amount of seconds, we
1394
# force a test to see if inotify is betraying us.
1395
CONFD_CONFIG_RELOAD_TIMEOUT = 60
1396

    
1397
# If we receive more than one update in this amount of seconds, we move to
1398
# polling every RATELIMIT seconds, rather than relying on inotify, to be able
1399
# to serve more requests.
1400
CONFD_CONFIG_RELOAD_RATELIMIT = 2
1401

    
1402
# Magic number prepended to all confd queries.
1403
# This allows us to distinguish different types of confd protocols and handle
1404
# them. For example by changing this we can move the whole payload to be
1405
# compressed, or move away from json.
1406
CONFD_MAGIC_FOURCC = "plj0"
1407

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

    
1413
# Timeout in seconds to expire pending query request in the confd client
1414
# library. We don't actually expect any answer more than 10 seconds after we
1415
# sent a request.
1416
CONFD_CLIENT_EXPIRE_TIMEOUT = 10
1417

    
1418
# Maximum UDP datagram size.
1419
# On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
1420
# On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
1421
#   (assuming we can't use jumbo frames)
1422
# We just set this to 60K, which should be enough
1423
MAX_UDP_DATA_SIZE = 61440
1424

    
1425
# User-id pool minimum/maximum acceptable user-ids.
1426
UIDPOOL_UID_MIN = 0
1427
UIDPOOL_UID_MAX = 2**32-1 # Assuming 32 bit user-ids
1428

    
1429
# Name or path of the pgrep command
1430
PGREP = "pgrep"
1431

    
1432
# Name of the node group that gets created at cluster init or upgrade
1433
INITIAL_NODE_GROUP_NAME = "default"
1434

    
1435
# Possible values for NodeGroup.alloc_policy
1436
ALLOC_POLICY_PREFERRED = "preferred"
1437
ALLOC_POLICY_LAST_RESORT = "last_resort"
1438
ALLOC_POLICY_UNALLOCABLE = "unallocable"
1439
VALID_ALLOC_POLICIES = [
1440
  ALLOC_POLICY_PREFERRED,
1441
  ALLOC_POLICY_LAST_RESORT,
1442
  ALLOC_POLICY_UNALLOCABLE,
1443
  ]
1444

    
1445
# Temporary external/shared storage parameters
1446
BLOCKDEV_DRIVER_MANUAL = "manual"
1447

    
1448
# Whether htools was enabled at compilation time
1449
HTOOLS = _autoconf.HTOOLS
1450
# The hail iallocator
1451
IALLOC_HAIL = "hail"