Statistics
| Branch: | Tag: | Revision:

root / lib / constants.py @ 3c075436

History | View | Annotate | Download (20.3 kB)

1
#
2
#
3

    
4
# Copyright (C) 2006, 2007 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
from ganeti import _autoconf
25

    
26
# various versions
27
PROTOCOL_VERSION = 20
28
RELEASE_VERSION = _autoconf.PACKAGE_VERSION
29
OS_API_V10 = 10
30
OS_API_V15 = 15
31
OS_API_VERSIONS = frozenset([OS_API_V10, OS_API_V15])
32
EXPORT_VERSION = 0
33
RAPI_VERSION = 2
34

    
35

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

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

    
50
def BuildVersion(major, minor, revision):
51
  """Calculates int version number from major, minor and revision numbers.
52

53
  Returns: int representing version number
54

55
  """
56
  assert isinstance(major, int)
57
  assert isinstance(minor, int)
58
  assert isinstance(revision, int)
59
  return (1000000 * major +
60
            10000 * minor +
61
                1 * revision)
62

    
63

    
64
def SplitVersion(version):
65
  """Splits version number stored in an int.
66

67
  Returns: tuple; (major, minor, revision)
68

69
  """
70
  assert isinstance(version, int)
71

    
72
  (major, remainder) = divmod(version, 1000000)
73
  (minor, revision) = divmod(remainder, 10000)
74

    
75
  return (major, minor, revision)
76

    
77

    
78
CONFIG_MAJOR = int(_autoconf.VERSION_MAJOR)
79
CONFIG_MINOR = int(_autoconf.VERSION_MINOR)
80
CONFIG_REVISION = 0
81
CONFIG_VERSION = BuildVersion(CONFIG_MAJOR, CONFIG_MINOR, CONFIG_REVISION)
82

    
83
# file paths
84
DATA_DIR = _autoconf.LOCALSTATEDIR + "/lib/ganeti"
85
RUN_DIR = _autoconf.LOCALSTATEDIR + "/run"
86
RUN_GANETI_DIR = RUN_DIR + "/ganeti"
87
BDEV_CACHE_DIR = RUN_GANETI_DIR + "/bdev-cache"
88
DISK_LINKS_DIR = RUN_GANETI_DIR + "/instance-disks"
89
RUN_DIRS_MODE = 0755
90
SOCKET_DIR = RUN_GANETI_DIR + "/socket"
91
SOCKET_DIR_MODE = 0700
92
# keep RUN_GANETI_DIR first here, to make sure all get created when the node
93
# daemon is started (this takes care of RUN_DIR being tmpfs)
94
SUB_RUN_DIRS = [ RUN_GANETI_DIR, BDEV_CACHE_DIR, DISK_LINKS_DIR ]
95
LOCK_DIR = _autoconf.LOCALSTATEDIR + "/lock"
96
SSCONF_LOCK_FILE = LOCK_DIR + "/ganeti-ssconf.lock"
97
CLUSTER_CONF_FILE = DATA_DIR + "/config.data"
98
SSL_CERT_FILE = DATA_DIR + "/server.pem"
99
RAPI_CERT_FILE = DATA_DIR + "/rapi.pem"
100
HMAC_CLUSTER_KEY = DATA_DIR + "/hmac.key"
101
WATCHER_STATEFILE = DATA_DIR + "/watcher.data"
102
WATCHER_PAUSEFILE = DATA_DIR + "/watcher.pause"
103
INSTANCE_UPFILE = RUN_GANETI_DIR + "/instance-status"
104
SSH_KNOWN_HOSTS_FILE = DATA_DIR + "/known_hosts"
105
RAPI_USERS_FILE = DATA_DIR + "/rapi_users"
106
QUEUE_DIR = DATA_DIR + "/queue"
107
DAEMON_UTIL = _autoconf.PKGLIBDIR + "/daemon-util"
108
ETC_HOSTS = "/etc/hosts"
109
DEFAULT_FILE_STORAGE_DIR = _autoconf.FILE_STORAGE_DIR
110
SYSCONFDIR = _autoconf.SYSCONFDIR
111
TOOLSDIR = _autoconf.TOOLSDIR
112
CONF_DIR = SYSCONFDIR + "/ganeti"
113

    
114
MASTER_SOCKET = SOCKET_DIR + "/ganeti-master"
115

    
116
NODED = "ganeti-noded"
117
CONFD = "ganeti-confd"
118
RAPI = "ganeti-rapi"
119
MASTERD = "ganeti-masterd"
120

    
121
MULTITHREADED_DAEMONS = frozenset([MASTERD])
122

    
123
DAEMONS_SSL = {
124
  # daemon-name: (default-cert-path, default-key-path)
125
  NODED: (SSL_CERT_FILE, SSL_CERT_FILE),
126
  RAPI: (RAPI_CERT_FILE, RAPI_CERT_FILE),
127
}
128

    
129
DAEMONS_PORTS = {
130
  # daemon-name: ("proto", "default-port")
131
  NODED: ("tcp", 1811),
132
  CONFD: ("udp", 1814),
133
  RAPI: ("tcp", 5080),
134
}
135
DEFAULT_NODED_PORT = DAEMONS_PORTS[NODED][1]
136
DEFAULT_CONFD_PORT = DAEMONS_PORTS[CONFD][1]
137
DEFAULT_RAPI_PORT = DAEMONS_PORTS[RAPI][1]
138

    
139
FIRST_DRBD_PORT = 11000
140
LAST_DRBD_PORT = 14999
141
MASTER_SCRIPT = "ganeti-master"
142

    
143
LOG_DIR = _autoconf.LOCALSTATEDIR + "/log/ganeti/"
144
DAEMONS_LOGFILES = {
145
  # "daemon-name": "logfile"
146
  NODED: LOG_DIR + "node-daemon.log",
147
  CONFD: LOG_DIR + "conf-daemon.log",
148
  RAPI: LOG_DIR + "rapi-daemon.log",
149
  MASTERD: LOG_DIR + "master-daemon.log",
150
  }
151
LOG_OS_DIR = LOG_DIR + "os"
152
LOG_WATCHER = LOG_DIR + "watcher.log"
153
LOG_COMMANDS = LOG_DIR + "commands.log"
154
LOG_BURNIN = LOG_DIR + "burnin.log"
155

    
156
OS_SEARCH_PATH = _autoconf.OS_SEARCH_PATH
157
EXPORT_DIR = _autoconf.EXPORT_DIR
158

    
159
EXPORT_CONF_FILE = "config.ini"
160

    
161
XEN_BOOTLOADER = _autoconf.XEN_BOOTLOADER
162
XEN_KERNEL = _autoconf.XEN_KERNEL
163
XEN_INITRD = _autoconf.XEN_INITRD
164

    
165
KVM_PATH = _autoconf.KVM_PATH
166
SOCAT_PATH = _autoconf.SOCAT_PATH
167
SOCAT_ESCAPE = _autoconf.SOCAT_ESCAPE
168
SOCAT_ESCAPE_CODE = "0x1d"
169

    
170
VALUE_DEFAULT = "default"
171
VALUE_AUTO = "auto"
172
VALUE_GENERATE = "generate"
173
VALUE_NONE = "none"
174
VALUE_TRUE = "true"
175
VALUE_FALSE = "false"
176

    
177
# hooks-related constants
178
HOOKS_BASE_DIR = CONF_DIR + "/hooks"
179
HOOKS_PHASE_PRE = "pre"
180
HOOKS_PHASE_POST = "post"
181
HOOKS_NAME_CFGUPDATE = "config-update"
182
HOOKS_VERSION = 2
183

    
184
# hooks subject type (what object type does the LU deal with)
185
HTYPE_CLUSTER = "CLUSTER"
186
HTYPE_NODE = "NODE"
187
HTYPE_INSTANCE = "INSTANCE"
188

    
189
HKR_SKIP = 0
190
HKR_FAIL = 1
191
HKR_SUCCESS = 2
192

    
193
# Storage types
194
ST_FILE = "file"
195
ST_LVM_PV = "lvm-pv"
196
ST_LVM_VG = "lvm-vg"
197

    
198
# Storage fields
199
# first two are valid in LU context only, not passed to backend
200
SF_NODE = "node"
201
SF_TYPE = "type"
202
# and the rest are valid in backend
203
SF_NAME = "name"
204
SF_SIZE = "size"
205
SF_FREE = "free"
206
SF_USED = "used"
207
SF_ALLOCATABLE = "allocatable"
208

    
209
# Storage operations
210
SO_FIX_CONSISTENCY = "fix-consistency"
211

    
212
# Available fields per storage type
213
VALID_STORAGE_FIELDS = frozenset([SF_NAME, SF_TYPE, SF_SIZE,
214
                                  SF_USED, SF_FREE, SF_ALLOCATABLE])
215

    
216
VALID_STORAGE_TYPES = frozenset([ST_FILE, ST_LVM_PV, ST_LVM_VG])
217

    
218
MODIFIABLE_STORAGE_FIELDS = {
219
  ST_LVM_PV: frozenset([SF_ALLOCATABLE]),
220
  }
221

    
222
VALID_STORAGE_OPERATIONS = {
223
  ST_LVM_VG: frozenset([SO_FIX_CONSISTENCY]),
224
  }
225

    
226
# Local disk status
227
# Note: Code depends on LDS_OKAY < LDS_UNKNOWN < LDS_FAULTY
228
(LDS_OKAY,
229
 LDS_UNKNOWN,
230
 LDS_FAULTY) = range(1, 4)
231

    
232
# disk template types
233
DT_DISKLESS = "diskless"
234
DT_PLAIN = "plain"
235
DT_DRBD8 = "drbd"
236
DT_FILE = "file"
237

    
238
# the set of network-mirrored disk templates
239
DTS_NET_MIRROR = frozenset([DT_DRBD8])
240

    
241
# the set of non-lvm-based disk templates
242
DTS_NOT_LVM = frozenset([DT_DISKLESS, DT_FILE])
243

    
244
# logical disk types
245
LD_LV = "lvm"
246
LD_DRBD8 = "drbd8"
247
LD_FILE = "file"
248
LDS_BLOCK = frozenset([LD_LV, LD_DRBD8])
249

    
250
# drbd constants
251
DRBD_HMAC_ALG = "md5"
252
DRBD_NET_PROTOCOL = "C"
253

    
254
# file backend driver
255
FD_LOOP = "loop"
256
FD_BLKTAP = "blktap"
257

    
258
# the set of drbd-like disk types
259
LDS_DRBD = frozenset([LD_DRBD8])
260

    
261
# disk access mode
262
DISK_RDONLY = "ro"
263
DISK_RDWR = "rw"
264
DISK_ACCESS_SET = frozenset([DISK_RDONLY, DISK_RDWR])
265

    
266
# disk replacement mode
267
REPLACE_DISK_PRI = "replace_on_primary"    # replace disks on primary
268
REPLACE_DISK_SEC = "replace_on_secondary"  # replace disks on secondary
269
REPLACE_DISK_CHG = "replace_new_secondary" # change secondary node
270
REPLACE_DISK_AUTO = "replace_auto"
271

    
272
# lock recalculate mode
273
LOCKS_REPLACE = 'replace'
274
LOCKS_APPEND = 'append'
275

    
276
# instance creation modes
277
INSTANCE_CREATE = "create"
278
INSTANCE_IMPORT = "import"
279

    
280
DISK_TEMPLATES = frozenset([DT_DISKLESS, DT_PLAIN,
281
                            DT_DRBD8, DT_FILE])
282

    
283
FILE_DRIVER = frozenset([FD_LOOP, FD_BLKTAP])
284

    
285
# import/export config options
286
INISECT_EXP = "export"
287
INISECT_INS = "instance"
288

    
289
# dynamic device modification
290

    
291
DDM_ADD = 'add'
292
DDM_REMOVE = 'remove'
293

    
294
# common exit codes
295
EXIT_SUCCESS = 0
296
EXIT_FAILURE = 1
297
EXIT_NOTCLUSTER = 5
298
EXIT_NOTMASTER = 11
299
EXIT_NODESETUP_ERROR = 12
300
EXIT_CONFIRMATION = 13 # need user confirmation
301
EXIT_NOTCANDIDATE = 14
302

    
303
# tags
304
TAG_CLUSTER = "cluster"
305
TAG_NODE = "node"
306
TAG_INSTANCE = "instance"
307
MAX_TAG_LEN = 128
308
MAX_TAGS_PER_OBJ = 4096
309

    
310
# others
311
DEFAULT_BRIDGE = "xen-br0"
312
SYNC_SPEED = 60 * 1024
313
LOCALHOST_IP_ADDRESS = "127.0.0.1"
314
TCP_PING_TIMEOUT = 10
315
GANETI_RUNAS = "root"
316
DEFAULT_VG = "xenvg"
317
BIND_ADDRESS_GLOBAL = "0.0.0.0"
318
MIN_VG_SIZE = 20480
319
DEFAULT_MAC_PREFIX = "aa:00:00"
320
LVM_STRIPECOUNT = _autoconf.LVM_STRIPECOUNT
321
# default maximum instance wait time, in seconds.
322
DEFAULT_SHUTDOWN_TIMEOUT = 120
323

    
324

    
325
# RPC constants
326
(RPC_ENCODING_NONE,
327
 RPC_ENCODING_ZLIB_BASE64) = range(2)
328

    
329
# os related constants
330
OS_SCRIPT_CREATE = 'create'
331
OS_SCRIPT_IMPORT = 'import'
332
OS_SCRIPT_EXPORT = 'export'
333
OS_SCRIPT_RENAME = 'rename'
334
OS_SCRIPTS = frozenset([OS_SCRIPT_CREATE, OS_SCRIPT_IMPORT,
335
                        OS_SCRIPT_EXPORT, OS_SCRIPT_RENAME])
336

    
337
OS_API_FILE = 'ganeti_api_version'
338
OS_VARIANTS_FILE = 'variants.list'
339

    
340
# ssh constants
341
SSH_INITD_SCRIPT = _autoconf.SSH_INITD_SCRIPT
342
SSH_CONFIG_DIR = "/etc/ssh/"
343
SSH_HOST_DSA_PRIV = SSH_CONFIG_DIR + "ssh_host_dsa_key"
344
SSH_HOST_DSA_PUB = SSH_HOST_DSA_PRIV + ".pub"
345
SSH_HOST_RSA_PRIV = SSH_CONFIG_DIR + "ssh_host_rsa_key"
346
SSH_HOST_RSA_PUB = SSH_HOST_RSA_PRIV + ".pub"
347
SSH = "ssh"
348
SCP = "scp"
349

    
350
# reboot types
351
INSTANCE_REBOOT_SOFT = "soft"
352
INSTANCE_REBOOT_HARD = "hard"
353
INSTANCE_REBOOT_FULL = "full"
354

    
355
REBOOT_TYPES = frozenset([INSTANCE_REBOOT_SOFT,
356
                          INSTANCE_REBOOT_HARD,
357
                          INSTANCE_REBOOT_FULL])
358

    
359
VTYPE_STRING = 'string'
360
VTYPE_BOOL = 'bool'
361
VTYPE_SIZE = 'size' # size, in MiBs
362
VTYPE_INT = 'int'
363
ENFORCEABLE_TYPES = frozenset([
364
                      VTYPE_STRING,
365
                      VTYPE_BOOL,
366
                      VTYPE_SIZE,
367
                      VTYPE_INT,
368
                      ])
369

    
370
# HV parameter names (global namespace)
371
HV_BOOT_ORDER = "boot_order"
372
HV_CDROM_IMAGE_PATH = "cdrom_image_path"
373
HV_NIC_TYPE = "nic_type"
374
HV_DISK_TYPE = "disk_type"
375
HV_VNC_BIND_ADDRESS = "vnc_bind_address"
376
HV_VNC_PASSWORD_FILE = "vnc_password_file"
377
HV_VNC_TLS = "vnc_tls"
378
HV_VNC_X509 = "vnc_x509_path"
379
HV_VNC_X509_VERIFY = "vnc_x509_verify"
380
HV_ACPI = "acpi"
381
HV_PAE = "pae"
382
HV_USE_BOOTLOADER = "use_bootloader"
383
HV_BOOTLOADER_ARGS = "bootloader_args"
384
HV_BOOTLOADER_PATH = "bootloader_path"
385
HV_KERNEL_ARGS = "kernel_args"
386
HV_KERNEL_PATH = "kernel_path"
387
HV_INITRD_PATH = "initrd_path"
388
HV_ROOT_PATH = "root_path"
389
HV_SERIAL_CONSOLE = "serial_console"
390
HV_USB_MOUSE = "usb_mouse"
391
HV_DEVICE_MODEL = "device_model"
392
HV_INIT_SCRIPT = "init_script"
393
HV_MIGRATION_PORT = "migration_port"
394

    
395
HVS_PARAMETER_TYPES = {
396
  HV_BOOT_ORDER: VTYPE_STRING,
397
  HV_CDROM_IMAGE_PATH: VTYPE_STRING,
398
  HV_NIC_TYPE: VTYPE_STRING,
399
  HV_DISK_TYPE: VTYPE_STRING,
400
  HV_VNC_PASSWORD_FILE: VTYPE_STRING,
401
  HV_VNC_BIND_ADDRESS: VTYPE_STRING,
402
  HV_VNC_TLS: VTYPE_BOOL,
403
  HV_VNC_X509: VTYPE_STRING,
404
  HV_VNC_X509_VERIFY: VTYPE_BOOL,
405
  HV_ACPI: VTYPE_BOOL,
406
  HV_PAE: VTYPE_BOOL,
407
  HV_USE_BOOTLOADER: VTYPE_BOOL,
408
  HV_BOOTLOADER_PATH: VTYPE_STRING,
409
  HV_BOOTLOADER_ARGS: VTYPE_STRING,
410
  HV_KERNEL_PATH: VTYPE_STRING,
411
  HV_KERNEL_ARGS: VTYPE_STRING,
412
  HV_INITRD_PATH: VTYPE_STRING,
413
  HV_ROOT_PATH: VTYPE_STRING,
414
  HV_SERIAL_CONSOLE: VTYPE_BOOL,
415
  HV_USB_MOUSE: VTYPE_STRING,
416
  HV_DEVICE_MODEL: VTYPE_STRING,
417
  HV_INIT_SCRIPT: VTYPE_STRING,
418
  HV_MIGRATION_PORT: VTYPE_INT,
419
  }
420

    
421
HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
422

    
423
# BE parameter names
424
BE_MEMORY = "memory"
425
BE_VCPUS = "vcpus"
426
BE_AUTO_BALANCE = "auto_balance"
427

    
428
BES_PARAMETER_TYPES = {
429
    BE_MEMORY: VTYPE_SIZE,
430
    BE_VCPUS: VTYPE_INT,
431
    BE_AUTO_BALANCE: VTYPE_BOOL,
432
    }
433

    
434
BES_PARAMETERS = frozenset(BES_PARAMETER_TYPES.keys())
435

    
436
# Instance Parameters Profile
437
PP_DEFAULT = "default"
438

    
439
NIC_MODE = "mode"
440
NIC_LINK = "link"
441

    
442
NIC_MODE_BRIDGED = "bridged"
443
NIC_MODE_ROUTED = "routed"
444

    
445
NIC_VALID_MODES = frozenset([NIC_MODE_BRIDGED, NIC_MODE_ROUTED])
446

    
447
NICS_PARAMETER_TYPES = {
448
    NIC_MODE: VTYPE_STRING,
449
    NIC_LINK: VTYPE_STRING,
450
    }
451

    
452
NICS_PARAMETERS = frozenset(NICS_PARAMETER_TYPES.keys())
453

    
454
# Hypervisor constants
455
HT_XEN_PVM = "xen-pvm"
456
HT_FAKE = "fake"
457
HT_XEN_HVM = "xen-hvm"
458
HT_KVM = "kvm"
459
HT_CHROOT = "chroot"
460
HYPER_TYPES = frozenset([HT_XEN_PVM, HT_FAKE, HT_XEN_HVM, HT_KVM, HT_CHROOT])
461
HTS_REQ_PORT = frozenset([HT_XEN_HVM, HT_KVM])
462

    
463
VNC_BASE_PORT = 5900
464
VNC_PASSWORD_FILE = CONF_DIR + "/vnc-cluster-password"
465
VNC_DEFAULT_BIND_ADDRESS = '0.0.0.0'
466

    
467
# NIC types
468
HT_NIC_RTL8139 = "rtl8139"
469
HT_NIC_NE2K_PCI = "ne2k_pci"
470
HT_NIC_NE2K_ISA = "ne2k_isa"
471
HT_NIC_I82551 = "i82551"
472
HT_NIC_I85557B = "i82557b"
473
HT_NIC_I8259ER = "i82559er"
474
HT_NIC_PCNET = "pcnet"
475
HT_NIC_E1000 = "e1000"
476
HT_NIC_PARAVIRTUAL = HT_DISK_PARAVIRTUAL = "paravirtual"
477

    
478
HT_HVM_VALID_NIC_TYPES = frozenset([HT_NIC_RTL8139, HT_NIC_NE2K_PCI,
479
                                    HT_NIC_NE2K_ISA, HT_NIC_PARAVIRTUAL])
480
HT_KVM_VALID_NIC_TYPES = frozenset([HT_NIC_RTL8139, HT_NIC_NE2K_PCI,
481
                                    HT_NIC_NE2K_ISA, HT_NIC_I82551,
482
                                    HT_NIC_I85557B, HT_NIC_I8259ER,
483
                                    HT_NIC_PCNET, HT_NIC_E1000,
484
                                    HT_NIC_PARAVIRTUAL])
485
# Disk types
486
HT_DISK_IOEMU = "ioemu"
487
HT_DISK_IDE = "ide"
488
HT_DISK_SCSI = "scsi"
489
HT_DISK_SD = "sd"
490
HT_DISK_MTD = "mtd"
491
HT_DISK_PFLASH = "pflash"
492

    
493
HT_HVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IOEMU])
494
HT_KVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IDE,
495
                                     HT_DISK_SCSI, HT_DISK_SD, HT_DISK_MTD,
496
                                     HT_DISK_PFLASH])
497

    
498
# Mouse types:
499
HT_MOUSE_MOUSE = "mouse"
500
HT_MOUSE_TABLET = "tablet"
501

    
502
HT_KVM_VALID_MOUSE_TYPES = frozenset([HT_MOUSE_MOUSE, HT_MOUSE_TABLET])
503

    
504
# Boot order
505
HT_BO_CDROM = "cdrom"
506
HT_BO_DISK = "disk"
507
HT_BO_NETWORK = "network"
508

    
509
HT_KVM_VALID_BO_TYPES = frozenset([HT_BO_CDROM, HT_BO_DISK, HT_BO_NETWORK])
510

    
511
# Cluster Verify steps
512
VERIFY_NPLUSONE_MEM = 'nplusone_mem'
513
VERIFY_OPTIONAL_CHECKS = frozenset([VERIFY_NPLUSONE_MEM])
514

    
515
# Node verify constants
516
NV_FILELIST = "filelist"
517
NV_HVINFO = "hvinfo"
518
NV_HYPERVISOR = "hypervisor"
519
NV_INSTANCELIST = "instancelist"
520
NV_NODELIST = "nodelist"
521
NV_NODENETTEST = "node-net-test"
522
NV_VERSION = "version"
523
NV_VGLIST = "vglist"
524
NV_LVLIST = "lvlist"
525
NV_PVLIST = "pvlist"
526
NV_DRBDLIST = "drbd-list"
527
NV_NODESETUP = "nodesetup"
528

    
529
# Allocator framework constants
530
IALLOCATOR_VERSION = 2
531
IALLOCATOR_DIR_IN = "in"
532
IALLOCATOR_DIR_OUT = "out"
533
IALLOCATOR_MODE_ALLOC = "allocate"
534
IALLOCATOR_MODE_RELOC = "relocate"
535
IALLOCATOR_SEARCH_PATH = _autoconf.IALLOCATOR_SEARCH_PATH
536

    
537
# Job queue
538
JOB_QUEUE_VERSION = 1
539
JOB_QUEUE_LOCK_FILE = QUEUE_DIR + "/lock"
540
JOB_QUEUE_VERSION_FILE = QUEUE_DIR + "/version"
541
JOB_QUEUE_SERIAL_FILE = QUEUE_DIR + "/serial"
542
JOB_QUEUE_ARCHIVE_DIR = QUEUE_DIR + "/archive"
543
JOB_QUEUE_DRAIN_FILE = QUEUE_DIR + "/drain"
544
JOB_QUEUE_SIZE_HARD_LIMIT = 5000
545
JOB_QUEUE_SIZE_SOFT_LIMIT = JOB_QUEUE_SIZE_HARD_LIMIT * 0.8
546

    
547
JOB_ID_TEMPLATE = r"\d+"
548

    
549
# unchanged job return
550
JOB_NOTCHANGED = "nochange"
551

    
552
# Job status
553
JOB_STATUS_QUEUED = "queued"
554
JOB_STATUS_WAITLOCK = "waiting"
555
JOB_STATUS_CANCELING = "canceling"
556
JOB_STATUS_RUNNING = "running"
557
JOB_STATUS_CANCELED = "canceled"
558
JOB_STATUS_SUCCESS = "success"
559
JOB_STATUS_ERROR = "error"
560

    
561
# OpCode status
562
# not yet finalized
563
OP_STATUS_QUEUED = "queued"
564
OP_STATUS_WAITLOCK = "waiting"
565
OP_STATUS_CANCELING = "canceling"
566
OP_STATUS_RUNNING = "running"
567
# finalized
568
OP_STATUS_CANCELED = "canceled"
569
OP_STATUS_SUCCESS = "success"
570
OP_STATUS_ERROR = "error"
571
OPS_FINALIZED = frozenset([OP_STATUS_CANCELED,
572
                           OP_STATUS_SUCCESS,
573
                           OP_STATUS_ERROR])
574

    
575
# Execution log types
576
ELOG_MESSAGE = "message"
577
ELOG_PROGRESS = "progress"
578

    
579
# max dynamic devices
580
MAX_NICS = 8
581
MAX_DISKS = 16
582

    
583
# SSCONF keys
584
SS_CLUSTER_NAME = "cluster_name"
585
SS_CLUSTER_TAGS = "cluster_tags"
586
SS_FILE_STORAGE_DIR = "file_storage_dir"
587
SS_MASTER_CANDIDATES = "master_candidates"
588
SS_MASTER_CANDIDATES_IPS = "master_candidates_ips"
589
SS_MASTER_IP = "master_ip"
590
SS_MASTER_NETDEV = "master_netdev"
591
SS_MASTER_NODE = "master_node"
592
SS_NODE_LIST = "node_list"
593
SS_NODE_PRIMARY_IPS = "node_primary_ips"
594
SS_NODE_SECONDARY_IPS = "node_secondary_ips"
595
SS_OFFLINE_NODES = "offline_nodes"
596
SS_ONLINE_NODES = "online_nodes"
597
SS_INSTANCE_LIST = "instance_list"
598
SS_RELEASE_VERSION = "release_version"
599

    
600
# cluster wide default parameters
601
DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM
602

    
603
HVC_DEFAULTS = {
604
  HT_XEN_PVM: {
605
    HV_USE_BOOTLOADER: False,
606
    HV_BOOTLOADER_PATH: XEN_BOOTLOADER,
607
    HV_BOOTLOADER_ARGS: '',
608
    HV_KERNEL_PATH: "/boot/vmlinuz-2.6-xenU",
609
    HV_INITRD_PATH: '',
610
    HV_ROOT_PATH: '/dev/sda1',
611
    HV_KERNEL_ARGS: 'ro',
612
    HV_MIGRATION_PORT: 8002,
613
    },
614
  HT_XEN_HVM: {
615
    HV_BOOT_ORDER: "cd",
616
    HV_CDROM_IMAGE_PATH: '',
617
    HV_NIC_TYPE: HT_NIC_RTL8139,
618
    HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
619
    HV_VNC_BIND_ADDRESS: '0.0.0.0',
620
    HV_VNC_PASSWORD_FILE: VNC_PASSWORD_FILE,
621
    HV_ACPI: True,
622
    HV_PAE: True,
623
    HV_KERNEL_PATH: "/usr/lib/xen/boot/hvmloader",
624
    HV_DEVICE_MODEL: "/usr/lib/xen/bin/qemu-dm",
625
    HV_MIGRATION_PORT: 8002,
626
    },
627
  HT_KVM: {
628
    HV_KERNEL_PATH: "/boot/vmlinuz-2.6-kvmU",
629
    HV_INITRD_PATH: '',
630
    HV_KERNEL_ARGS: 'ro',
631
    HV_ROOT_PATH: '/dev/vda1',
632
    HV_ACPI: True,
633
    HV_SERIAL_CONSOLE: True,
634
    HV_VNC_BIND_ADDRESS: '',
635
    HV_VNC_TLS: False,
636
    HV_VNC_X509: '',
637
    HV_VNC_X509_VERIFY: False,
638
    HV_VNC_PASSWORD_FILE: '',
639
    HV_CDROM_IMAGE_PATH: '',
640
    HV_BOOT_ORDER: HT_BO_DISK,
641
    HV_NIC_TYPE: HT_NIC_PARAVIRTUAL,
642
    HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
643
    HV_USB_MOUSE: '',
644
    HV_MIGRATION_PORT: 8102,
645
    },
646
  HT_FAKE: {
647
    },
648
  HT_CHROOT: {
649
    HV_INIT_SCRIPT: "/ganeti-chroot",
650
    },
651
  }
652

    
653
HVC_GLOBALS = frozenset([
654
  HV_MIGRATION_PORT,
655
  ])
656

    
657
BEC_DEFAULTS = {
658
  BE_MEMORY: 128,
659
  BE_VCPUS: 1,
660
  BE_AUTO_BALANCE: True,
661
  }
662

    
663
NICC_DEFAULTS = {
664
  NIC_MODE: NIC_MODE_BRIDGED,
665
  NIC_LINK: DEFAULT_BRIDGE,
666
  }
667

    
668
MASTER_POOL_SIZE_DEFAULT = 10
669

    
670
CONFD_PROTOCOL_VERSION = 1
671

    
672
CONFD_REQ_PING = 0
673
CONFD_REQ_NODE_ROLE_BYNAME = 1
674
CONFD_REQ_NODE_PIP_BY_INSTANCE_IP = 2
675
CONFD_REQ_CLUSTER_MASTER = 3
676
CONFD_REQ_NODE_PIP_LIST = 4
677
CONFD_REQ_MC_PIP_LIST = 5
678
CONFD_REQ_INSTANCES_IPS_LIST = 6
679

    
680
# Confd request query fields. These are used to narrow down queries.
681
# These must be strings rather than integers, because json-encoding
682
# converts them to strings anyway, as they're used as dict-keys.
683
CONFD_REQQ_LINK = "0"
684
CONFD_REQQ_IP = "1"
685
CONFD_REQQ_IPLIST = "2"
686

    
687
CONFD_REQS = frozenset([
688
  CONFD_REQ_PING,
689
  CONFD_REQ_NODE_ROLE_BYNAME,
690
  CONFD_REQ_NODE_PIP_BY_INSTANCE_IP,
691
  CONFD_REQ_CLUSTER_MASTER,
692
  CONFD_REQ_NODE_PIP_LIST,
693
  CONFD_REQ_MC_PIP_LIST,
694
  CONFD_REQ_INSTANCES_IPS_LIST,
695
  ])
696

    
697
CONFD_REPL_STATUS_OK = 0
698
CONFD_REPL_STATUS_ERROR = 1
699
CONFD_REPL_STATUS_NOTIMPLEMENTED = 2
700

    
701
CONFD_REPL_STATUSES = frozenset([
702
  CONFD_REPL_STATUS_OK,
703
  CONFD_REPL_STATUS_ERROR,
704
  CONFD_REPL_STATUS_NOTIMPLEMENTED,
705
  ])
706

    
707
(CONFD_NODE_ROLE_MASTER,
708
 CONFD_NODE_ROLE_CANDIDATE,
709
 CONFD_NODE_ROLE_OFFLINE,
710
 CONFD_NODE_ROLE_DRAINED,
711
 CONFD_NODE_ROLE_REGULAR,
712
 ) = range(5)
713

    
714
# A few common errors for confd
715
CONFD_ERROR_UNKNOWN_ENTRY = 1
716
CONFD_ERROR_INTERNAL = 2
717
CONFD_ERROR_ARGUMENT = 3
718

    
719
# Each request is "salted" by the current timestamp.
720
# This constants decides how many seconds of skew to accept.
721
# TODO: make this a default and allow the value to be more configurable
722
CONFD_MAX_CLOCK_SKEW = 300
723

    
724
# When we haven't reloaded the config for more than this amount of seconds, we
725
# force a test to see if inotify is betraying us.
726
CONFD_CONFIG_RELOAD_TIMEOUT = 60
727

    
728
# If we receive more than one update in this amount of seconds, we move to
729
# polling every RATELIMIT seconds, rather than relying on inotify, to be able
730
# to serve more requests.
731
CONFD_CONFIG_RELOAD_RATELIMIT = 2
732

    
733
# Magic number prepended to all confd queries.
734
# This allows us to distinguish different types of confd protocols and handle
735
# them. For example by changing this we can move the whole payload to be
736
# compressed, or move away from json.
737
CONFD_MAGIC_FOURCC = 'plj0'
738

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

    
744
# Timeout in seconds to expire pending query request in the confd client
745
# library. We don't actually expect any answer more than 10 seconds after we
746
# sent a request.
747
CONFD_CLIENT_EXPIRE_TIMEOUT = 10
748

    
749
# Maximum UDP datagram size.
750
# On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
751
# On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
752
#   (assuming we can't use jumbo frames)
753
# We just set this to 60K, which should be enough
754
MAX_UDP_DATA_SIZE = 61440