Statistics
| Branch: | Tag: | Revision:

root / lib / constants.py @ 4d32feba

History | View | Annotate | Download (21.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
import re
25

    
26
from ganeti import _autoconf
27

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

    
37

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

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

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

55
  Returns: int representing version number
56

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

    
65

    
66
def SplitVersion(version):
67
  """Splits version number stored in an int.
68

69
  Returns: tuple; (major, minor, revision)
70

71
  """
72
  assert isinstance(version, int)
73

    
74
  (major, remainder) = divmod(version, 1000000)
75
  (minor, revision) = divmod(remainder, 10000)
76

    
77
  return (major, minor, revision)
78

    
79

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

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

    
116
MASTER_SOCKET = SOCKET_DIR + "/ganeti-master"
117

    
118
NODED = "ganeti-noded"
119
CONFD = "ganeti-confd"
120
RAPI = "ganeti-rapi"
121
MASTERD = "ganeti-masterd"
122
# used in the ganeti-nbma project
123
NLD = "ganeti-nld"
124

    
125
MULTITHREADED_DAEMONS = frozenset([MASTERD])
126

    
127
DAEMONS_SSL = {
128
  # daemon-name: (default-cert-path, default-key-path)
129
  NODED: (SSL_CERT_FILE, SSL_CERT_FILE),
130
  RAPI: (RAPI_CERT_FILE, RAPI_CERT_FILE),
131
}
132

    
133
DAEMONS_PORTS = {
134
  # daemon-name: ("proto", "default-port")
135
  NODED: ("tcp", 1811),
136
  CONFD: ("udp", 1814),
137
  RAPI: ("tcp", 5080),
138
  # used in the ganeti-nbma project
139
  NLD: ("udp", 1816),
140
}
141
DEFAULT_NODED_PORT = DAEMONS_PORTS[NODED][1]
142
DEFAULT_CONFD_PORT = DAEMONS_PORTS[CONFD][1]
143
DEFAULT_RAPI_PORT = DAEMONS_PORTS[RAPI][1]
144
# used in the ganeti-nbma project
145
DEFAULT_NLD_PORT = DAEMONS_PORTS[NLD][1]
146

    
147
FIRST_DRBD_PORT = 11000
148
LAST_DRBD_PORT = 14999
149
MASTER_SCRIPT = "ganeti-master"
150

    
151
LOG_DIR = _autoconf.LOCALSTATEDIR + "/log/ganeti/"
152
DAEMONS_LOGFILES = {
153
  # "daemon-name": "logfile"
154
  NODED: LOG_DIR + "node-daemon.log",
155
  CONFD: LOG_DIR + "conf-daemon.log",
156
  RAPI: LOG_DIR + "rapi-daemon.log",
157
  MASTERD: LOG_DIR + "master-daemon.log",
158
  # used in the ganeti-nbma project
159
  NLD: LOG_DIR + "nl-daemon.log",
160
  }
161
LOG_OS_DIR = LOG_DIR + "os"
162
LOG_WATCHER = LOG_DIR + "watcher.log"
163
LOG_COMMANDS = LOG_DIR + "commands.log"
164
LOG_BURNIN = LOG_DIR + "burnin.log"
165

    
166
OS_SEARCH_PATH = _autoconf.OS_SEARCH_PATH
167
EXPORT_DIR = _autoconf.EXPORT_DIR
168

    
169
EXPORT_CONF_FILE = "config.ini"
170

    
171
XEN_BOOTLOADER = _autoconf.XEN_BOOTLOADER
172
XEN_KERNEL = _autoconf.XEN_KERNEL
173
XEN_INITRD = _autoconf.XEN_INITRD
174

    
175
KVM_PATH = _autoconf.KVM_PATH
176
SOCAT_PATH = _autoconf.SOCAT_PATH
177
SOCAT_USE_ESCAPE = _autoconf.SOCAT_USE_ESCAPE
178
SOCAT_ESCAPE_CODE = "0x1d"
179

    
180
VALUE_DEFAULT = "default"
181
VALUE_AUTO = "auto"
182
VALUE_GENERATE = "generate"
183
VALUE_NONE = "none"
184
VALUE_TRUE = "true"
185
VALUE_FALSE = "false"
186

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

    
190
# hooks-related constants
191
HOOKS_BASE_DIR = CONF_DIR + "/hooks"
192
HOOKS_PHASE_PRE = "pre"
193
HOOKS_PHASE_POST = "post"
194
HOOKS_NAME_CFGUPDATE = "config-update"
195
HOOKS_VERSION = 2
196

    
197
# hooks subject type (what object type does the LU deal with)
198
HTYPE_CLUSTER = "CLUSTER"
199
HTYPE_NODE = "NODE"
200
HTYPE_INSTANCE = "INSTANCE"
201

    
202
HKR_SKIP = 0
203
HKR_FAIL = 1
204
HKR_SUCCESS = 2
205

    
206
# Storage types
207
ST_FILE = "file"
208
ST_LVM_PV = "lvm-pv"
209
ST_LVM_VG = "lvm-vg"
210

    
211
# Storage fields
212
# first two are valid in LU context only, not passed to backend
213
SF_NODE = "node"
214
SF_TYPE = "type"
215
# and the rest are valid in backend
216
SF_NAME = "name"
217
SF_SIZE = "size"
218
SF_FREE = "free"
219
SF_USED = "used"
220
SF_ALLOCATABLE = "allocatable"
221

    
222
# Storage operations
223
SO_FIX_CONSISTENCY = "fix-consistency"
224

    
225
# Available fields per storage type
226
VALID_STORAGE_FIELDS = frozenset([SF_NAME, SF_TYPE, SF_SIZE,
227
                                  SF_USED, SF_FREE, SF_ALLOCATABLE])
228

    
229
VALID_STORAGE_TYPES = frozenset([ST_FILE, ST_LVM_PV, ST_LVM_VG])
230

    
231
MODIFIABLE_STORAGE_FIELDS = {
232
  ST_LVM_PV: frozenset([SF_ALLOCATABLE]),
233
  }
234

    
235
VALID_STORAGE_OPERATIONS = {
236
  ST_LVM_VG: frozenset([SO_FIX_CONSISTENCY]),
237
  }
238

    
239
# Local disk status
240
# Note: Code depends on LDS_OKAY < LDS_UNKNOWN < LDS_FAULTY
241
(LDS_OKAY,
242
 LDS_UNKNOWN,
243
 LDS_FAULTY) = range(1, 4)
244

    
245
# disk template types
246
DT_DISKLESS = "diskless"
247
DT_PLAIN = "plain"
248
DT_DRBD8 = "drbd"
249
DT_FILE = "file"
250

    
251
# the set of network-mirrored disk templates
252
DTS_NET_MIRROR = frozenset([DT_DRBD8])
253

    
254
# the set of non-lvm-based disk templates
255
DTS_NOT_LVM = frozenset([DT_DISKLESS, DT_FILE])
256

    
257
# logical disk types
258
LD_LV = "lvm"
259
LD_DRBD8 = "drbd8"
260
LD_FILE = "file"
261
LDS_BLOCK = frozenset([LD_LV, LD_DRBD8])
262

    
263
# drbd constants
264
DRBD_HMAC_ALG = "md5"
265
DRBD_NET_PROTOCOL = "C"
266

    
267
# file backend driver
268
FD_LOOP = "loop"
269
FD_BLKTAP = "blktap"
270

    
271
# the set of drbd-like disk types
272
LDS_DRBD = frozenset([LD_DRBD8])
273

    
274
# disk access mode
275
DISK_RDONLY = "ro"
276
DISK_RDWR = "rw"
277
DISK_ACCESS_SET = frozenset([DISK_RDONLY, DISK_RDWR])
278

    
279
# disk replacement mode
280
REPLACE_DISK_PRI = "replace_on_primary"    # replace disks on primary
281
REPLACE_DISK_SEC = "replace_on_secondary"  # replace disks on secondary
282
REPLACE_DISK_CHG = "replace_new_secondary" # change secondary node
283
REPLACE_DISK_AUTO = "replace_auto"
284

    
285
# lock recalculate mode
286
LOCKS_REPLACE = 'replace'
287
LOCKS_APPEND = 'append'
288

    
289
# instance creation modes
290
INSTANCE_CREATE = "create"
291
INSTANCE_IMPORT = "import"
292

    
293
DISK_TEMPLATES = frozenset([DT_DISKLESS, DT_PLAIN,
294
                            DT_DRBD8, DT_FILE])
295

    
296
FILE_DRIVER = frozenset([FD_LOOP, FD_BLKTAP])
297

    
298
# import/export config options
299
INISECT_EXP = "export"
300
INISECT_INS = "instance"
301

    
302
# dynamic device modification
303

    
304
DDM_ADD = 'add'
305
DDM_REMOVE = 'remove'
306

    
307
# common exit codes
308
EXIT_SUCCESS = 0
309
EXIT_FAILURE = 1
310
EXIT_NOTCLUSTER = 5
311
EXIT_NOTMASTER = 11
312
EXIT_NODESETUP_ERROR = 12
313
EXIT_CONFIRMATION = 13 # need user confirmation
314
EXIT_NOTCANDIDATE = 14
315

    
316
# tags
317
TAG_CLUSTER = "cluster"
318
TAG_NODE = "node"
319
TAG_INSTANCE = "instance"
320
MAX_TAG_LEN = 128
321
MAX_TAGS_PER_OBJ = 4096
322

    
323
# others
324
DEFAULT_BRIDGE = "xen-br0"
325
SYNC_SPEED = 60 * 1024
326
LOCALHOST_IP_ADDRESS = "127.0.0.1"
327
TCP_PING_TIMEOUT = 10
328
GANETI_RUNAS = "root"
329
DEFAULT_VG = "xenvg"
330
BIND_ADDRESS_GLOBAL = "0.0.0.0"
331
MIN_VG_SIZE = 20480
332
DEFAULT_MAC_PREFIX = "aa:00:00"
333
LVM_STRIPECOUNT = _autoconf.LVM_STRIPECOUNT
334
# default maximum instance wait time, in seconds.
335
DEFAULT_SHUTDOWN_TIMEOUT = 120
336
NODE_MAX_CLOCK_SKEW = 150
337

    
338
# RPC constants
339
(RPC_ENCODING_NONE,
340
 RPC_ENCODING_ZLIB_BASE64) = range(2)
341

    
342
# os related constants
343
OS_SCRIPT_CREATE = 'create'
344
OS_SCRIPT_IMPORT = 'import'
345
OS_SCRIPT_EXPORT = 'export'
346
OS_SCRIPT_RENAME = 'rename'
347
OS_SCRIPTS = frozenset([OS_SCRIPT_CREATE, OS_SCRIPT_IMPORT,
348
                        OS_SCRIPT_EXPORT, OS_SCRIPT_RENAME])
349

    
350
OS_API_FILE = 'ganeti_api_version'
351
OS_VARIANTS_FILE = 'variants.list'
352

    
353
# ssh constants
354
SSH_CONFIG_DIR = "/etc/ssh/"
355
SSH_HOST_DSA_PRIV = SSH_CONFIG_DIR + "ssh_host_dsa_key"
356
SSH_HOST_DSA_PUB = SSH_HOST_DSA_PRIV + ".pub"
357
SSH_HOST_RSA_PRIV = SSH_CONFIG_DIR + "ssh_host_rsa_key"
358
SSH_HOST_RSA_PUB = SSH_HOST_RSA_PRIV + ".pub"
359
SSH = "ssh"
360
SCP = "scp"
361

    
362
# reboot types
363
INSTANCE_REBOOT_SOFT = "soft"
364
INSTANCE_REBOOT_HARD = "hard"
365
INSTANCE_REBOOT_FULL = "full"
366

    
367
REBOOT_TYPES = frozenset([INSTANCE_REBOOT_SOFT,
368
                          INSTANCE_REBOOT_HARD,
369
                          INSTANCE_REBOOT_FULL])
370

    
371
VTYPE_STRING = 'string'
372
VTYPE_BOOL = 'bool'
373
VTYPE_SIZE = 'size' # size, in MiBs
374
VTYPE_INT = 'int'
375
ENFORCEABLE_TYPES = frozenset([
376
                      VTYPE_STRING,
377
                      VTYPE_BOOL,
378
                      VTYPE_SIZE,
379
                      VTYPE_INT,
380
                      ])
381

    
382
# HV parameter names (global namespace)
383
HV_BOOT_ORDER = "boot_order"
384
HV_CDROM_IMAGE_PATH = "cdrom_image_path"
385
HV_NIC_TYPE = "nic_type"
386
HV_DISK_TYPE = "disk_type"
387
HV_VNC_BIND_ADDRESS = "vnc_bind_address"
388
HV_VNC_PASSWORD_FILE = "vnc_password_file"
389
HV_VNC_TLS = "vnc_tls"
390
HV_VNC_X509 = "vnc_x509_path"
391
HV_VNC_X509_VERIFY = "vnc_x509_verify"
392
HV_ACPI = "acpi"
393
HV_PAE = "pae"
394
HV_USE_BOOTLOADER = "use_bootloader"
395
HV_BOOTLOADER_ARGS = "bootloader_args"
396
HV_BOOTLOADER_PATH = "bootloader_path"
397
HV_KERNEL_ARGS = "kernel_args"
398
HV_KERNEL_PATH = "kernel_path"
399
HV_INITRD_PATH = "initrd_path"
400
HV_ROOT_PATH = "root_path"
401
HV_SERIAL_CONSOLE = "serial_console"
402
HV_USB_MOUSE = "usb_mouse"
403
HV_DEVICE_MODEL = "device_model"
404
HV_INIT_SCRIPT = "init_script"
405
HV_MIGRATION_PORT = "migration_port"
406
HV_USE_LOCALTIME = "use_localtime"
407
HV_DISK_CACHE = "disk_cache"
408

    
409
HVS_PARAMETER_TYPES = {
410
  HV_BOOT_ORDER: VTYPE_STRING,
411
  HV_CDROM_IMAGE_PATH: VTYPE_STRING,
412
  HV_NIC_TYPE: VTYPE_STRING,
413
  HV_DISK_TYPE: VTYPE_STRING,
414
  HV_VNC_PASSWORD_FILE: VTYPE_STRING,
415
  HV_VNC_BIND_ADDRESS: VTYPE_STRING,
416
  HV_VNC_TLS: VTYPE_BOOL,
417
  HV_VNC_X509: VTYPE_STRING,
418
  HV_VNC_X509_VERIFY: VTYPE_BOOL,
419
  HV_ACPI: VTYPE_BOOL,
420
  HV_PAE: VTYPE_BOOL,
421
  HV_USE_BOOTLOADER: VTYPE_BOOL,
422
  HV_BOOTLOADER_PATH: VTYPE_STRING,
423
  HV_BOOTLOADER_ARGS: VTYPE_STRING,
424
  HV_KERNEL_PATH: VTYPE_STRING,
425
  HV_KERNEL_ARGS: VTYPE_STRING,
426
  HV_INITRD_PATH: VTYPE_STRING,
427
  HV_ROOT_PATH: VTYPE_STRING,
428
  HV_SERIAL_CONSOLE: VTYPE_BOOL,
429
  HV_USB_MOUSE: VTYPE_STRING,
430
  HV_DEVICE_MODEL: VTYPE_STRING,
431
  HV_INIT_SCRIPT: VTYPE_STRING,
432
  HV_MIGRATION_PORT: VTYPE_INT,
433
  HV_USE_LOCALTIME: VTYPE_BOOL,
434
  HV_DISK_CACHE: VTYPE_STRING,
435
  }
436

    
437
HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
438

    
439
# BE parameter names
440
BE_MEMORY = "memory"
441
BE_VCPUS = "vcpus"
442
BE_AUTO_BALANCE = "auto_balance"
443

    
444
BES_PARAMETER_TYPES = {
445
    BE_MEMORY: VTYPE_SIZE,
446
    BE_VCPUS: VTYPE_INT,
447
    BE_AUTO_BALANCE: VTYPE_BOOL,
448
    }
449

    
450
BES_PARAMETERS = frozenset(BES_PARAMETER_TYPES.keys())
451

    
452
# Instance Parameters Profile
453
PP_DEFAULT = "default"
454

    
455
NIC_MODE = "mode"
456
NIC_LINK = "link"
457

    
458
NIC_MODE_BRIDGED = "bridged"
459
NIC_MODE_ROUTED = "routed"
460

    
461
NIC_VALID_MODES = frozenset([NIC_MODE_BRIDGED, NIC_MODE_ROUTED])
462

    
463
NICS_PARAMETER_TYPES = {
464
    NIC_MODE: VTYPE_STRING,
465
    NIC_LINK: VTYPE_STRING,
466
    }
467

    
468
NICS_PARAMETERS = frozenset(NICS_PARAMETER_TYPES.keys())
469

    
470
# Hypervisor constants
471
HT_XEN_PVM = "xen-pvm"
472
HT_FAKE = "fake"
473
HT_XEN_HVM = "xen-hvm"
474
HT_KVM = "kvm"
475
HT_CHROOT = "chroot"
476
HYPER_TYPES = frozenset([HT_XEN_PVM, HT_FAKE, HT_XEN_HVM, HT_KVM, HT_CHROOT])
477
HTS_REQ_PORT = frozenset([HT_XEN_HVM, HT_KVM])
478

    
479
VNC_BASE_PORT = 5900
480
VNC_PASSWORD_FILE = CONF_DIR + "/vnc-cluster-password"
481
VNC_DEFAULT_BIND_ADDRESS = '0.0.0.0'
482

    
483
# NIC types
484
HT_NIC_RTL8139 = "rtl8139"
485
HT_NIC_NE2K_PCI = "ne2k_pci"
486
HT_NIC_NE2K_ISA = "ne2k_isa"
487
HT_NIC_I82551 = "i82551"
488
HT_NIC_I85557B = "i82557b"
489
HT_NIC_I8259ER = "i82559er"
490
HT_NIC_PCNET = "pcnet"
491
HT_NIC_E1000 = "e1000"
492
HT_NIC_PARAVIRTUAL = HT_DISK_PARAVIRTUAL = "paravirtual"
493

    
494
HT_HVM_VALID_NIC_TYPES = frozenset([HT_NIC_RTL8139, HT_NIC_NE2K_PCI,
495
                                    HT_NIC_NE2K_ISA, HT_NIC_PARAVIRTUAL])
496
HT_KVM_VALID_NIC_TYPES = frozenset([HT_NIC_RTL8139, HT_NIC_NE2K_PCI,
497
                                    HT_NIC_NE2K_ISA, HT_NIC_I82551,
498
                                    HT_NIC_I85557B, HT_NIC_I8259ER,
499
                                    HT_NIC_PCNET, HT_NIC_E1000,
500
                                    HT_NIC_PARAVIRTUAL])
501
# Disk types
502
HT_DISK_IOEMU = "ioemu"
503
HT_DISK_IDE = "ide"
504
HT_DISK_SCSI = "scsi"
505
HT_DISK_SD = "sd"
506
HT_DISK_MTD = "mtd"
507
HT_DISK_PFLASH = "pflash"
508

    
509
HT_CACHE_DEFAULT = "default"
510
HT_CACHE_NONE = "none"
511
HT_CACHE_WTHROUGH = "writethrough"
512
HT_CACHE_WBACK = "writeback"
513
HT_VALID_CACHE_TYPES = frozenset([HT_CACHE_DEFAULT,
514
                                  HT_CACHE_NONE,
515
                                  HT_CACHE_WTHROUGH,
516
                                  HT_CACHE_WBACK])
517

    
518
HT_HVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IOEMU])
519
HT_KVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IDE,
520
                                     HT_DISK_SCSI, HT_DISK_SD, HT_DISK_MTD,
521
                                     HT_DISK_PFLASH])
522

    
523
# Mouse types:
524
HT_MOUSE_MOUSE = "mouse"
525
HT_MOUSE_TABLET = "tablet"
526

    
527
HT_KVM_VALID_MOUSE_TYPES = frozenset([HT_MOUSE_MOUSE, HT_MOUSE_TABLET])
528

    
529
# Boot order
530
HT_BO_CDROM = "cdrom"
531
HT_BO_DISK = "disk"
532
HT_BO_NETWORK = "network"
533

    
534
HT_KVM_VALID_BO_TYPES = frozenset([HT_BO_CDROM, HT_BO_DISK, HT_BO_NETWORK])
535

    
536
# Cluster Verify steps
537
VERIFY_NPLUSONE_MEM = 'nplusone_mem'
538
VERIFY_OPTIONAL_CHECKS = frozenset([VERIFY_NPLUSONE_MEM])
539

    
540
# Node verify constants
541
NV_FILELIST = "filelist"
542
NV_HVINFO = "hvinfo"
543
NV_HYPERVISOR = "hypervisor"
544
NV_INSTANCELIST = "instancelist"
545
NV_NODELIST = "nodelist"
546
NV_NODENETTEST = "node-net-test"
547
NV_VERSION = "version"
548
NV_VGLIST = "vglist"
549
NV_LVLIST = "lvlist"
550
NV_PVLIST = "pvlist"
551
NV_DRBDLIST = "drbd-list"
552
NV_NODESETUP = "nodesetup"
553
NV_TIME = "time"
554

    
555
# Allocator framework constants
556
IALLOCATOR_VERSION = 2
557
IALLOCATOR_DIR_IN = "in"
558
IALLOCATOR_DIR_OUT = "out"
559
IALLOCATOR_MODE_ALLOC = "allocate"
560
IALLOCATOR_MODE_RELOC = "relocate"
561
IALLOCATOR_SEARCH_PATH = _autoconf.IALLOCATOR_SEARCH_PATH
562

    
563
# Job queue
564
JOB_QUEUE_VERSION = 1
565
JOB_QUEUE_LOCK_FILE = QUEUE_DIR + "/lock"
566
JOB_QUEUE_VERSION_FILE = QUEUE_DIR + "/version"
567
JOB_QUEUE_SERIAL_FILE = QUEUE_DIR + "/serial"
568
JOB_QUEUE_ARCHIVE_DIR = QUEUE_DIR + "/archive"
569
JOB_QUEUE_DRAIN_FILE = QUEUE_DIR + "/drain"
570
JOB_QUEUE_SIZE_HARD_LIMIT = 5000
571
JOB_QUEUE_SIZE_SOFT_LIMIT = JOB_QUEUE_SIZE_HARD_LIMIT * 0.8
572

    
573
JOB_ID_TEMPLATE = r"\d+"
574

    
575
# unchanged job return
576
JOB_NOTCHANGED = "nochange"
577

    
578
# Job status
579
JOB_STATUS_QUEUED = "queued"
580
JOB_STATUS_WAITLOCK = "waiting"
581
JOB_STATUS_CANCELING = "canceling"
582
JOB_STATUS_RUNNING = "running"
583
JOB_STATUS_CANCELED = "canceled"
584
JOB_STATUS_SUCCESS = "success"
585
JOB_STATUS_ERROR = "error"
586

    
587
# OpCode status
588
# not yet finalized
589
OP_STATUS_QUEUED = "queued"
590
OP_STATUS_WAITLOCK = "waiting"
591
OP_STATUS_CANCELING = "canceling"
592
OP_STATUS_RUNNING = "running"
593
# finalized
594
OP_STATUS_CANCELED = "canceled"
595
OP_STATUS_SUCCESS = "success"
596
OP_STATUS_ERROR = "error"
597
OPS_FINALIZED = frozenset([OP_STATUS_CANCELED,
598
                           OP_STATUS_SUCCESS,
599
                           OP_STATUS_ERROR])
600

    
601
# Execution log types
602
ELOG_MESSAGE = "message"
603
ELOG_PROGRESS = "progress"
604

    
605
# max dynamic devices
606
MAX_NICS = 8
607
MAX_DISKS = 16
608

    
609
# SSCONF keys
610
SS_CLUSTER_NAME = "cluster_name"
611
SS_CLUSTER_TAGS = "cluster_tags"
612
SS_FILE_STORAGE_DIR = "file_storage_dir"
613
SS_MASTER_CANDIDATES = "master_candidates"
614
SS_MASTER_CANDIDATES_IPS = "master_candidates_ips"
615
SS_MASTER_IP = "master_ip"
616
SS_MASTER_NETDEV = "master_netdev"
617
SS_MASTER_NODE = "master_node"
618
SS_NODE_LIST = "node_list"
619
SS_NODE_PRIMARY_IPS = "node_primary_ips"
620
SS_NODE_SECONDARY_IPS = "node_secondary_ips"
621
SS_OFFLINE_NODES = "offline_nodes"
622
SS_ONLINE_NODES = "online_nodes"
623
SS_INSTANCE_LIST = "instance_list"
624
SS_RELEASE_VERSION = "release_version"
625

    
626
# cluster wide default parameters
627
DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM
628

    
629
HVC_DEFAULTS = {
630
  HT_XEN_PVM: {
631
    HV_USE_BOOTLOADER: False,
632
    HV_BOOTLOADER_PATH: XEN_BOOTLOADER,
633
    HV_BOOTLOADER_ARGS: '',
634
    HV_KERNEL_PATH: "/boot/vmlinuz-2.6-xenU",
635
    HV_INITRD_PATH: '',
636
    HV_ROOT_PATH: '/dev/sda1',
637
    HV_KERNEL_ARGS: 'ro',
638
    HV_MIGRATION_PORT: 8002,
639
    },
640
  HT_XEN_HVM: {
641
    HV_BOOT_ORDER: "cd",
642
    HV_CDROM_IMAGE_PATH: '',
643
    HV_NIC_TYPE: HT_NIC_RTL8139,
644
    HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
645
    HV_VNC_BIND_ADDRESS: '0.0.0.0',
646
    HV_VNC_PASSWORD_FILE: VNC_PASSWORD_FILE,
647
    HV_ACPI: True,
648
    HV_PAE: True,
649
    HV_KERNEL_PATH: "/usr/lib/xen/boot/hvmloader",
650
    HV_DEVICE_MODEL: "/usr/lib/xen/bin/qemu-dm",
651
    HV_MIGRATION_PORT: 8002,
652
    HV_USE_LOCALTIME: False,
653
    },
654
  HT_KVM: {
655
    HV_KERNEL_PATH: "/boot/vmlinuz-2.6-kvmU",
656
    HV_INITRD_PATH: '',
657
    HV_KERNEL_ARGS: 'ro',
658
    HV_ROOT_PATH: '/dev/vda1',
659
    HV_ACPI: True,
660
    HV_SERIAL_CONSOLE: True,
661
    HV_VNC_BIND_ADDRESS: '',
662
    HV_VNC_TLS: False,
663
    HV_VNC_X509: '',
664
    HV_VNC_X509_VERIFY: False,
665
    HV_VNC_PASSWORD_FILE: '',
666
    HV_CDROM_IMAGE_PATH: '',
667
    HV_BOOT_ORDER: HT_BO_DISK,
668
    HV_NIC_TYPE: HT_NIC_PARAVIRTUAL,
669
    HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
670
    HV_USB_MOUSE: '',
671
    HV_MIGRATION_PORT: 8102,
672
    HV_USE_LOCALTIME: False,
673
    HV_DISK_CACHE: HT_CACHE_DEFAULT,
674
    },
675
  HT_FAKE: {
676
    },
677
  HT_CHROOT: {
678
    HV_INIT_SCRIPT: "/ganeti-chroot",
679
    },
680
  }
681

    
682
HVC_GLOBALS = frozenset([
683
  HV_MIGRATION_PORT,
684
  ])
685

    
686
BEC_DEFAULTS = {
687
  BE_MEMORY: 128,
688
  BE_VCPUS: 1,
689
  BE_AUTO_BALANCE: True,
690
  }
691

    
692
NICC_DEFAULTS = {
693
  NIC_MODE: NIC_MODE_BRIDGED,
694
  NIC_LINK: DEFAULT_BRIDGE,
695
  }
696

    
697
MASTER_POOL_SIZE_DEFAULT = 10
698

    
699
CONFD_PROTOCOL_VERSION = 1
700

    
701
CONFD_REQ_PING = 0
702
CONFD_REQ_NODE_ROLE_BYNAME = 1
703
CONFD_REQ_NODE_PIP_BY_INSTANCE_IP = 2
704
CONFD_REQ_CLUSTER_MASTER = 3
705
CONFD_REQ_NODE_PIP_LIST = 4
706
CONFD_REQ_MC_PIP_LIST = 5
707
CONFD_REQ_INSTANCES_IPS_LIST = 6
708

    
709
# Confd request query fields. These are used to narrow down queries.
710
# These must be strings rather than integers, because json-encoding
711
# converts them to strings anyway, as they're used as dict-keys.
712
CONFD_REQQ_LINK = "0"
713
CONFD_REQQ_IP = "1"
714
CONFD_REQQ_IPLIST = "2"
715
CONFD_REQQ_FIELDS = "3"
716

    
717
CONFD_REQFIELD_NAME = "0"
718
CONFD_REQFIELD_IP = "1"
719
CONFD_REQFIELD_MNODE_PIP = "2"
720

    
721
CONFD_REQS = frozenset([
722
  CONFD_REQ_PING,
723
  CONFD_REQ_NODE_ROLE_BYNAME,
724
  CONFD_REQ_NODE_PIP_BY_INSTANCE_IP,
725
  CONFD_REQ_CLUSTER_MASTER,
726
  CONFD_REQ_NODE_PIP_LIST,
727
  CONFD_REQ_MC_PIP_LIST,
728
  CONFD_REQ_INSTANCES_IPS_LIST,
729
  ])
730

    
731
CONFD_REPL_STATUS_OK = 0
732
CONFD_REPL_STATUS_ERROR = 1
733
CONFD_REPL_STATUS_NOTIMPLEMENTED = 2
734

    
735
CONFD_REPL_STATUSES = frozenset([
736
  CONFD_REPL_STATUS_OK,
737
  CONFD_REPL_STATUS_ERROR,
738
  CONFD_REPL_STATUS_NOTIMPLEMENTED,
739
  ])
740

    
741
(CONFD_NODE_ROLE_MASTER,
742
 CONFD_NODE_ROLE_CANDIDATE,
743
 CONFD_NODE_ROLE_OFFLINE,
744
 CONFD_NODE_ROLE_DRAINED,
745
 CONFD_NODE_ROLE_REGULAR,
746
 ) = range(5)
747

    
748
# A few common errors for confd
749
CONFD_ERROR_UNKNOWN_ENTRY = 1
750
CONFD_ERROR_INTERNAL = 2
751
CONFD_ERROR_ARGUMENT = 3
752

    
753
# Each request is "salted" by the current timestamp.
754
# This constants decides how many seconds of skew to accept.
755
# TODO: make this a default and allow the value to be more configurable
756
CONFD_MAX_CLOCK_SKEW = 2 * NODE_MAX_CLOCK_SKEW
757

    
758
# When we haven't reloaded the config for more than this amount of seconds, we
759
# force a test to see if inotify is betraying us.
760
CONFD_CONFIG_RELOAD_TIMEOUT = 60
761

    
762
# If we receive more than one update in this amount of seconds, we move to
763
# polling every RATELIMIT seconds, rather than relying on inotify, to be able
764
# to serve more requests.
765
CONFD_CONFIG_RELOAD_RATELIMIT = 2
766

    
767
# Magic number prepended to all confd queries.
768
# This allows us to distinguish different types of confd protocols and handle
769
# them. For example by changing this we can move the whole payload to be
770
# compressed, or move away from json.
771
CONFD_MAGIC_FOURCC = 'plj0'
772

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

    
778
# Timeout in seconds to expire pending query request in the confd client
779
# library. We don't actually expect any answer more than 10 seconds after we
780
# sent a request.
781
CONFD_CLIENT_EXPIRE_TIMEOUT = 10
782

    
783
# Maximum UDP datagram size.
784
# On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
785
# On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
786
#   (assuming we can't use jumbo frames)
787
# We just set this to 60K, which should be enough
788
MAX_UDP_DATA_SIZE = 61440