Statistics
| Branch: | Tag: | Revision:

root / lib / constants.py @ fe5b0c42

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_USE_ESCAPE = _autoconf.SOCAT_USE_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_CONFIG_DIR = "/etc/ssh/"
342
SSH_HOST_DSA_PRIV = SSH_CONFIG_DIR + "ssh_host_dsa_key"
343
SSH_HOST_DSA_PUB = SSH_HOST_DSA_PRIV + ".pub"
344
SSH_HOST_RSA_PRIV = SSH_CONFIG_DIR + "ssh_host_rsa_key"
345
SSH_HOST_RSA_PUB = SSH_HOST_RSA_PRIV + ".pub"
346
SSH = "ssh"
347
SCP = "scp"
348

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
548
JOB_ID_TEMPLATE = r"\d+"
549

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

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

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

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

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

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

    
601
# cluster wide default parameters
602
DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM
603

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

    
656
HVC_GLOBALS = frozenset([
657
  HV_MIGRATION_PORT,
658
  ])
659

    
660
BEC_DEFAULTS = {
661
  BE_MEMORY: 128,
662
  BE_VCPUS: 1,
663
  BE_AUTO_BALANCE: True,
664
  }
665

    
666
NICC_DEFAULTS = {
667
  NIC_MODE: NIC_MODE_BRIDGED,
668
  NIC_LINK: DEFAULT_BRIDGE,
669
  }
670

    
671
MASTER_POOL_SIZE_DEFAULT = 10
672

    
673
CONFD_PROTOCOL_VERSION = 1
674

    
675
CONFD_REQ_PING = 0
676
CONFD_REQ_NODE_ROLE_BYNAME = 1
677
CONFD_REQ_NODE_PIP_BY_INSTANCE_IP = 2
678
CONFD_REQ_CLUSTER_MASTER = 3
679
CONFD_REQ_NODE_PIP_LIST = 4
680
CONFD_REQ_MC_PIP_LIST = 5
681
CONFD_REQ_INSTANCES_IPS_LIST = 6
682

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

    
690
CONFD_REQS = frozenset([
691
  CONFD_REQ_PING,
692
  CONFD_REQ_NODE_ROLE_BYNAME,
693
  CONFD_REQ_NODE_PIP_BY_INSTANCE_IP,
694
  CONFD_REQ_CLUSTER_MASTER,
695
  CONFD_REQ_NODE_PIP_LIST,
696
  CONFD_REQ_MC_PIP_LIST,
697
  CONFD_REQ_INSTANCES_IPS_LIST,
698
  ])
699

    
700
CONFD_REPL_STATUS_OK = 0
701
CONFD_REPL_STATUS_ERROR = 1
702
CONFD_REPL_STATUS_NOTIMPLEMENTED = 2
703

    
704
CONFD_REPL_STATUSES = frozenset([
705
  CONFD_REPL_STATUS_OK,
706
  CONFD_REPL_STATUS_ERROR,
707
  CONFD_REPL_STATUS_NOTIMPLEMENTED,
708
  ])
709

    
710
(CONFD_NODE_ROLE_MASTER,
711
 CONFD_NODE_ROLE_CANDIDATE,
712
 CONFD_NODE_ROLE_OFFLINE,
713
 CONFD_NODE_ROLE_DRAINED,
714
 CONFD_NODE_ROLE_REGULAR,
715
 ) = range(5)
716

    
717
# A few common errors for confd
718
CONFD_ERROR_UNKNOWN_ENTRY = 1
719
CONFD_ERROR_INTERNAL = 2
720
CONFD_ERROR_ARGUMENT = 3
721

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

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

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

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

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

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

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