Statistics
| Branch: | Tag: | Revision:

root / lib / constants.py @ d19d94db

History | View | Annotate | Download (22.1 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
ENABLE_FILE_STORAGE = _autoconf.ENABLE_FILE_STORAGE
113
SYSCONFDIR = _autoconf.SYSCONFDIR
114
TOOLSDIR = _autoconf.TOOLSDIR
115
CONF_DIR = SYSCONFDIR + "/ganeti"
116

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

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

    
126
MULTITHREADED_DAEMONS = frozenset([MASTERD])
127

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

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

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

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

    
167
# one of 'no', 'yes', 'only'
168
SYSLOG_USAGE = _autoconf.SYSLOG_USAGE
169
SYSLOG_NO = "no"
170
SYSLOG_YES = "yes"
171
SYSLOG_ONLY = "only"
172
SYSLOG_SOCKET = "/dev/log"
173

    
174
OS_SEARCH_PATH = _autoconf.OS_SEARCH_PATH
175
EXPORT_DIR = _autoconf.EXPORT_DIR
176

    
177
EXPORT_CONF_FILE = "config.ini"
178

    
179
XEN_BOOTLOADER = _autoconf.XEN_BOOTLOADER
180
XEN_KERNEL = _autoconf.XEN_KERNEL
181
XEN_INITRD = _autoconf.XEN_INITRD
182

    
183
KVM_PATH = _autoconf.KVM_PATH
184
SOCAT_PATH = _autoconf.SOCAT_PATH
185
SOCAT_USE_ESCAPE = _autoconf.SOCAT_USE_ESCAPE
186
SOCAT_ESCAPE_CODE = "0x1d"
187

    
188
VALUE_DEFAULT = "default"
189
VALUE_AUTO = "auto"
190
VALUE_GENERATE = "generate"
191
VALUE_NONE = "none"
192
VALUE_TRUE = "true"
193
VALUE_FALSE = "false"
194

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

    
198
# hooks-related constants
199
HOOKS_BASE_DIR = CONF_DIR + "/hooks"
200
HOOKS_PHASE_PRE = "pre"
201
HOOKS_PHASE_POST = "post"
202
HOOKS_NAME_CFGUPDATE = "config-update"
203
HOOKS_NAME_WATCHER = "watcher"
204
HOOKS_VERSION = 2
205

    
206
# hooks subject type (what object type does the LU deal with)
207
HTYPE_CLUSTER = "CLUSTER"
208
HTYPE_NODE = "NODE"
209
HTYPE_INSTANCE = "INSTANCE"
210

    
211
HKR_SKIP = 0
212
HKR_FAIL = 1
213
HKR_SUCCESS = 2
214

    
215
# Storage types
216
ST_FILE = "file"
217
ST_LVM_PV = "lvm-pv"
218
ST_LVM_VG = "lvm-vg"
219

    
220
# Storage fields
221
# first two are valid in LU context only, not passed to backend
222
SF_NODE = "node"
223
SF_TYPE = "type"
224
# and the rest are valid in backend
225
SF_NAME = "name"
226
SF_SIZE = "size"
227
SF_FREE = "free"
228
SF_USED = "used"
229
SF_ALLOCATABLE = "allocatable"
230

    
231
# Storage operations
232
SO_FIX_CONSISTENCY = "fix-consistency"
233

    
234
# Available fields per storage type
235
VALID_STORAGE_FIELDS = frozenset([SF_NAME, SF_TYPE, SF_SIZE,
236
                                  SF_USED, SF_FREE, SF_ALLOCATABLE])
237

    
238
VALID_STORAGE_TYPES = frozenset([ST_FILE, ST_LVM_PV, ST_LVM_VG])
239

    
240
MODIFIABLE_STORAGE_FIELDS = {
241
  ST_LVM_PV: frozenset([SF_ALLOCATABLE]),
242
  }
243

    
244
VALID_STORAGE_OPERATIONS = {
245
  ST_LVM_VG: frozenset([SO_FIX_CONSISTENCY]),
246
  }
247

    
248
# Local disk status
249
# Note: Code depends on LDS_OKAY < LDS_UNKNOWN < LDS_FAULTY
250
(LDS_OKAY,
251
 LDS_UNKNOWN,
252
 LDS_FAULTY) = range(1, 4)
253

    
254
# disk template types
255
DT_DISKLESS = "diskless"
256
DT_PLAIN = "plain"
257
DT_DRBD8 = "drbd"
258
DT_FILE = "file"
259

    
260
# the set of network-mirrored disk templates
261
DTS_NET_MIRROR = frozenset([DT_DRBD8])
262

    
263
# the set of non-lvm-based disk templates
264
DTS_NOT_LVM = frozenset([DT_DISKLESS, DT_FILE])
265

    
266
# logical disk types
267
LD_LV = "lvm"
268
LD_DRBD8 = "drbd8"
269
LD_FILE = "file"
270
LDS_BLOCK = frozenset([LD_LV, LD_DRBD8])
271

    
272
# drbd constants
273
DRBD_HMAC_ALG = "md5"
274
DRBD_NET_PROTOCOL = "C"
275
DRBD_BARRIERS = _autoconf.DRBD_BARRIERS
276

    
277
# file backend driver
278
FD_LOOP = "loop"
279
FD_BLKTAP = "blktap"
280

    
281
# the set of drbd-like disk types
282
LDS_DRBD = frozenset([LD_DRBD8])
283

    
284
# disk access mode
285
DISK_RDONLY = "ro"
286
DISK_RDWR = "rw"
287
DISK_ACCESS_SET = frozenset([DISK_RDONLY, DISK_RDWR])
288

    
289
# disk replacement mode
290
REPLACE_DISK_PRI = "replace_on_primary"    # replace disks on primary
291
REPLACE_DISK_SEC = "replace_on_secondary"  # replace disks on secondary
292
REPLACE_DISK_CHG = "replace_new_secondary" # change secondary node
293
REPLACE_DISK_AUTO = "replace_auto"
294

    
295
# lock recalculate mode
296
LOCKS_REPLACE = 'replace'
297
LOCKS_APPEND = 'append'
298

    
299
# instance creation modes
300
INSTANCE_CREATE = "create"
301
INSTANCE_IMPORT = "import"
302

    
303
DISK_TEMPLATES = frozenset([DT_DISKLESS, DT_PLAIN,
304
                            DT_DRBD8, DT_FILE])
305

    
306
FILE_DRIVER = frozenset([FD_LOOP, FD_BLKTAP])
307

    
308
# import/export config options
309
INISECT_EXP = "export"
310
INISECT_INS = "instance"
311

    
312
# dynamic device modification
313

    
314
DDM_ADD = 'add'
315
DDM_REMOVE = 'remove'
316

    
317
# common exit codes
318
EXIT_SUCCESS = 0
319
EXIT_FAILURE = 1
320
EXIT_NOTCLUSTER = 5
321
EXIT_NOTMASTER = 11
322
EXIT_NODESETUP_ERROR = 12
323
EXIT_CONFIRMATION = 13 # need user confirmation
324
EXIT_NOTCANDIDATE = 14
325

    
326
# tags
327
TAG_CLUSTER = "cluster"
328
TAG_NODE = "node"
329
TAG_INSTANCE = "instance"
330
MAX_TAG_LEN = 128
331
MAX_TAGS_PER_OBJ = 4096
332

    
333
# others
334
DEFAULT_BRIDGE = "xen-br0"
335
SYNC_SPEED = 60 * 1024
336
LOCALHOST_IP_ADDRESS = "127.0.0.1"
337
TCP_PING_TIMEOUT = 10
338
GANETI_RUNAS = "root"
339
DEFAULT_VG = "xenvg"
340
BIND_ADDRESS_GLOBAL = "0.0.0.0"
341
MIN_VG_SIZE = 20480
342
DEFAULT_MAC_PREFIX = "aa:00:00"
343
LVM_STRIPECOUNT = _autoconf.LVM_STRIPECOUNT
344
# default maximum instance wait time, in seconds.
345
DEFAULT_SHUTDOWN_TIMEOUT = 120
346
NODE_MAX_CLOCK_SKEW = 150
347

    
348
# runparts results
349
(RUNPARTS_SKIP,
350
 RUNPARTS_RUN,
351
 RUNPARTS_ERR) = range(3)
352

    
353
RUNPARTS_STATUS = frozenset([RUNPARTS_SKIP, RUNPARTS_RUN, RUNPARTS_ERR])
354

    
355
# RPC constants
356
(RPC_ENCODING_NONE,
357
 RPC_ENCODING_ZLIB_BASE64) = range(2)
358

    
359
# os related constants
360
OS_SCRIPT_CREATE = 'create'
361
OS_SCRIPT_IMPORT = 'import'
362
OS_SCRIPT_EXPORT = 'export'
363
OS_SCRIPT_RENAME = 'rename'
364
OS_SCRIPTS = frozenset([OS_SCRIPT_CREATE, OS_SCRIPT_IMPORT,
365
                        OS_SCRIPT_EXPORT, OS_SCRIPT_RENAME])
366

    
367
OS_API_FILE = 'ganeti_api_version'
368
OS_VARIANTS_FILE = 'variants.list'
369

    
370
# ssh constants
371
SSH_CONFIG_DIR = _autoconf.SSH_CONFIG_DIR
372
SSH_HOST_DSA_PRIV = SSH_CONFIG_DIR + "/ssh_host_dsa_key"
373
SSH_HOST_DSA_PUB = SSH_HOST_DSA_PRIV + ".pub"
374
SSH_HOST_RSA_PRIV = SSH_CONFIG_DIR + "/ssh_host_rsa_key"
375
SSH_HOST_RSA_PUB = SSH_HOST_RSA_PRIV + ".pub"
376
SSH = "ssh"
377
SCP = "scp"
378

    
379
# reboot types
380
INSTANCE_REBOOT_SOFT = "soft"
381
INSTANCE_REBOOT_HARD = "hard"
382
INSTANCE_REBOOT_FULL = "full"
383

    
384
REBOOT_TYPES = frozenset([INSTANCE_REBOOT_SOFT,
385
                          INSTANCE_REBOOT_HARD,
386
                          INSTANCE_REBOOT_FULL])
387

    
388
VTYPE_STRING = 'string'
389
VTYPE_BOOL = 'bool'
390
VTYPE_SIZE = 'size' # size, in MiBs
391
VTYPE_INT = 'int'
392
ENFORCEABLE_TYPES = frozenset([
393
                      VTYPE_STRING,
394
                      VTYPE_BOOL,
395
                      VTYPE_SIZE,
396
                      VTYPE_INT,
397
                      ])
398

    
399
# HV parameter names (global namespace)
400
HV_BOOT_ORDER = "boot_order"
401
HV_CDROM_IMAGE_PATH = "cdrom_image_path"
402
HV_NIC_TYPE = "nic_type"
403
HV_DISK_TYPE = "disk_type"
404
HV_VNC_BIND_ADDRESS = "vnc_bind_address"
405
HV_VNC_PASSWORD_FILE = "vnc_password_file"
406
HV_VNC_TLS = "vnc_tls"
407
HV_VNC_X509 = "vnc_x509_path"
408
HV_VNC_X509_VERIFY = "vnc_x509_verify"
409
HV_ACPI = "acpi"
410
HV_PAE = "pae"
411
HV_USE_BOOTLOADER = "use_bootloader"
412
HV_BOOTLOADER_ARGS = "bootloader_args"
413
HV_BOOTLOADER_PATH = "bootloader_path"
414
HV_KERNEL_ARGS = "kernel_args"
415
HV_KERNEL_PATH = "kernel_path"
416
HV_INITRD_PATH = "initrd_path"
417
HV_ROOT_PATH = "root_path"
418
HV_SERIAL_CONSOLE = "serial_console"
419
HV_USB_MOUSE = "usb_mouse"
420
HV_DEVICE_MODEL = "device_model"
421
HV_INIT_SCRIPT = "init_script"
422
HV_MIGRATION_PORT = "migration_port"
423
HV_USE_LOCALTIME = "use_localtime"
424
HV_DISK_CACHE = "disk_cache"
425
HV_SECURITY_MODEL = "security_model"
426
HV_SECURITY_DOMAIN = "security_domain"
427

    
428
HVS_PARAMETER_TYPES = {
429
  HV_BOOT_ORDER: VTYPE_STRING,
430
  HV_CDROM_IMAGE_PATH: VTYPE_STRING,
431
  HV_NIC_TYPE: VTYPE_STRING,
432
  HV_DISK_TYPE: VTYPE_STRING,
433
  HV_VNC_PASSWORD_FILE: VTYPE_STRING,
434
  HV_VNC_BIND_ADDRESS: VTYPE_STRING,
435
  HV_VNC_TLS: VTYPE_BOOL,
436
  HV_VNC_X509: VTYPE_STRING,
437
  HV_VNC_X509_VERIFY: VTYPE_BOOL,
438
  HV_ACPI: VTYPE_BOOL,
439
  HV_PAE: VTYPE_BOOL,
440
  HV_USE_BOOTLOADER: VTYPE_BOOL,
441
  HV_BOOTLOADER_PATH: VTYPE_STRING,
442
  HV_BOOTLOADER_ARGS: VTYPE_STRING,
443
  HV_KERNEL_PATH: VTYPE_STRING,
444
  HV_KERNEL_ARGS: VTYPE_STRING,
445
  HV_INITRD_PATH: VTYPE_STRING,
446
  HV_ROOT_PATH: VTYPE_STRING,
447
  HV_SERIAL_CONSOLE: VTYPE_BOOL,
448
  HV_USB_MOUSE: VTYPE_STRING,
449
  HV_DEVICE_MODEL: VTYPE_STRING,
450
  HV_INIT_SCRIPT: VTYPE_STRING,
451
  HV_MIGRATION_PORT: VTYPE_INT,
452
  HV_USE_LOCALTIME: VTYPE_BOOL,
453
  HV_DISK_CACHE: VTYPE_STRING,
454
  HV_SECURITY_MODEL: VTYPE_STRING,
455
  HV_SECURITY_DOMAIN: VTYPE_STRING,
456
  }
457

    
458
HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
459

    
460
# BE parameter names
461
BE_MEMORY = "memory"
462
BE_VCPUS = "vcpus"
463
BE_AUTO_BALANCE = "auto_balance"
464

    
465
BES_PARAMETER_TYPES = {
466
    BE_MEMORY: VTYPE_SIZE,
467
    BE_VCPUS: VTYPE_INT,
468
    BE_AUTO_BALANCE: VTYPE_BOOL,
469
    }
470

    
471
BES_PARAMETERS = frozenset(BES_PARAMETER_TYPES.keys())
472

    
473
# Instance Parameters Profile
474
PP_DEFAULT = "default"
475

    
476
NIC_MODE = "mode"
477
NIC_LINK = "link"
478

    
479
NIC_MODE_BRIDGED = "bridged"
480
NIC_MODE_ROUTED = "routed"
481

    
482
NIC_VALID_MODES = frozenset([NIC_MODE_BRIDGED, NIC_MODE_ROUTED])
483

    
484
NICS_PARAMETER_TYPES = {
485
    NIC_MODE: VTYPE_STRING,
486
    NIC_LINK: VTYPE_STRING,
487
    }
488

    
489
NICS_PARAMETERS = frozenset(NICS_PARAMETER_TYPES.keys())
490

    
491
# Hypervisor constants
492
HT_XEN_PVM = "xen-pvm"
493
HT_FAKE = "fake"
494
HT_XEN_HVM = "xen-hvm"
495
HT_KVM = "kvm"
496
HT_CHROOT = "chroot"
497
HYPER_TYPES = frozenset([HT_XEN_PVM, HT_FAKE, HT_XEN_HVM, HT_KVM, HT_CHROOT])
498
HTS_REQ_PORT = frozenset([HT_XEN_HVM, HT_KVM])
499

    
500
VNC_BASE_PORT = 5900
501
VNC_PASSWORD_FILE = CONF_DIR + "/vnc-cluster-password"
502
VNC_DEFAULT_BIND_ADDRESS = '0.0.0.0'
503

    
504
# NIC types
505
HT_NIC_RTL8139 = "rtl8139"
506
HT_NIC_NE2K_PCI = "ne2k_pci"
507
HT_NIC_NE2K_ISA = "ne2k_isa"
508
HT_NIC_I82551 = "i82551"
509
HT_NIC_I85557B = "i82557b"
510
HT_NIC_I8259ER = "i82559er"
511
HT_NIC_PCNET = "pcnet"
512
HT_NIC_E1000 = "e1000"
513
HT_NIC_PARAVIRTUAL = HT_DISK_PARAVIRTUAL = "paravirtual"
514

    
515
HT_HVM_VALID_NIC_TYPES = frozenset([HT_NIC_RTL8139, HT_NIC_NE2K_PCI,
516
                                    HT_NIC_NE2K_ISA, HT_NIC_PARAVIRTUAL])
517
HT_KVM_VALID_NIC_TYPES = frozenset([HT_NIC_RTL8139, HT_NIC_NE2K_PCI,
518
                                    HT_NIC_NE2K_ISA, HT_NIC_I82551,
519
                                    HT_NIC_I85557B, HT_NIC_I8259ER,
520
                                    HT_NIC_PCNET, HT_NIC_E1000,
521
                                    HT_NIC_PARAVIRTUAL])
522
# Disk types
523
HT_DISK_IOEMU = "ioemu"
524
HT_DISK_IDE = "ide"
525
HT_DISK_SCSI = "scsi"
526
HT_DISK_SD = "sd"
527
HT_DISK_MTD = "mtd"
528
HT_DISK_PFLASH = "pflash"
529

    
530
HT_CACHE_DEFAULT = "default"
531
HT_CACHE_NONE = "none"
532
HT_CACHE_WTHROUGH = "writethrough"
533
HT_CACHE_WBACK = "writeback"
534
HT_VALID_CACHE_TYPES = frozenset([HT_CACHE_DEFAULT,
535
                                  HT_CACHE_NONE,
536
                                  HT_CACHE_WTHROUGH,
537
                                  HT_CACHE_WBACK])
538

    
539
HT_HVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IOEMU])
540
HT_KVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IDE,
541
                                     HT_DISK_SCSI, HT_DISK_SD, HT_DISK_MTD,
542
                                     HT_DISK_PFLASH])
543

    
544
# Mouse types:
545
HT_MOUSE_MOUSE = "mouse"
546
HT_MOUSE_TABLET = "tablet"
547

    
548
HT_KVM_VALID_MOUSE_TYPES = frozenset([HT_MOUSE_MOUSE, HT_MOUSE_TABLET])
549

    
550
# Boot order
551
HT_BO_CDROM = "cdrom"
552
HT_BO_DISK = "disk"
553
HT_BO_NETWORK = "network"
554

    
555
HT_KVM_VALID_BO_TYPES = frozenset([HT_BO_CDROM, HT_BO_DISK, HT_BO_NETWORK])
556

    
557
# Security models
558
HT_SM_NONE = "none"
559
HT_SM_USER = "user"
560
HT_SM_POOL = "pool"
561

    
562
HT_KVM_VALID_SM_TYPES = frozenset([HT_SM_NONE, HT_SM_USER, HT_SM_POOL])
563

    
564
# Cluster Verify steps
565
VERIFY_NPLUSONE_MEM = 'nplusone_mem'
566
VERIFY_OPTIONAL_CHECKS = frozenset([VERIFY_NPLUSONE_MEM])
567

    
568
# Node verify constants
569
NV_FILELIST = "filelist"
570
NV_HVINFO = "hvinfo"
571
NV_HYPERVISOR = "hypervisor"
572
NV_INSTANCELIST = "instancelist"
573
NV_NODELIST = "nodelist"
574
NV_NODENETTEST = "node-net-test"
575
NV_VERSION = "version"
576
NV_VGLIST = "vglist"
577
NV_LVLIST = "lvlist"
578
NV_PVLIST = "pvlist"
579
NV_DRBDLIST = "drbd-list"
580
NV_NODESETUP = "nodesetup"
581
NV_TIME = "time"
582

    
583
# Allocator framework constants
584
IALLOCATOR_VERSION = 2
585
IALLOCATOR_DIR_IN = "in"
586
IALLOCATOR_DIR_OUT = "out"
587
IALLOCATOR_MODE_ALLOC = "allocate"
588
IALLOCATOR_MODE_RELOC = "relocate"
589
IALLOCATOR_MODE_MEVAC = "multi-evacuate"
590
IALLOCATOR_SEARCH_PATH = _autoconf.IALLOCATOR_SEARCH_PATH
591

    
592
# Job queue
593
JOB_QUEUE_VERSION = 1
594
JOB_QUEUE_LOCK_FILE = QUEUE_DIR + "/lock"
595
JOB_QUEUE_VERSION_FILE = QUEUE_DIR + "/version"
596
JOB_QUEUE_SERIAL_FILE = QUEUE_DIR + "/serial"
597
JOB_QUEUE_ARCHIVE_DIR = QUEUE_DIR + "/archive"
598
JOB_QUEUE_DRAIN_FILE = QUEUE_DIR + "/drain"
599
JOB_QUEUE_SIZE_HARD_LIMIT = 5000
600
JOB_QUEUE_SIZE_SOFT_LIMIT = JOB_QUEUE_SIZE_HARD_LIMIT * 0.8
601

    
602
JOB_ID_TEMPLATE = r"\d+"
603

    
604
# unchanged job return
605
JOB_NOTCHANGED = "nochange"
606

    
607
# Job status
608
JOB_STATUS_QUEUED = "queued"
609
JOB_STATUS_WAITLOCK = "waiting"
610
JOB_STATUS_CANCELING = "canceling"
611
JOB_STATUS_RUNNING = "running"
612
JOB_STATUS_CANCELED = "canceled"
613
JOB_STATUS_SUCCESS = "success"
614
JOB_STATUS_ERROR = "error"
615

    
616
# OpCode status
617
# not yet finalized
618
OP_STATUS_QUEUED = "queued"
619
OP_STATUS_WAITLOCK = "waiting"
620
OP_STATUS_CANCELING = "canceling"
621
OP_STATUS_RUNNING = "running"
622
# finalized
623
OP_STATUS_CANCELED = "canceled"
624
OP_STATUS_SUCCESS = "success"
625
OP_STATUS_ERROR = "error"
626
OPS_FINALIZED = frozenset([OP_STATUS_CANCELED,
627
                           OP_STATUS_SUCCESS,
628
                           OP_STATUS_ERROR])
629

    
630
# Execution log types
631
ELOG_MESSAGE = "message"
632
ELOG_PROGRESS = "progress"
633

    
634
# max dynamic devices
635
MAX_NICS = 8
636
MAX_DISKS = 16
637

    
638
# SSCONF keys
639
SS_CLUSTER_NAME = "cluster_name"
640
SS_CLUSTER_TAGS = "cluster_tags"
641
SS_FILE_STORAGE_DIR = "file_storage_dir"
642
SS_MASTER_CANDIDATES = "master_candidates"
643
SS_MASTER_CANDIDATES_IPS = "master_candidates_ips"
644
SS_MASTER_IP = "master_ip"
645
SS_MASTER_NETDEV = "master_netdev"
646
SS_MASTER_NODE = "master_node"
647
SS_NODE_LIST = "node_list"
648
SS_NODE_PRIMARY_IPS = "node_primary_ips"
649
SS_NODE_SECONDARY_IPS = "node_secondary_ips"
650
SS_OFFLINE_NODES = "offline_nodes"
651
SS_ONLINE_NODES = "online_nodes"
652
SS_INSTANCE_LIST = "instance_list"
653
SS_RELEASE_VERSION = "release_version"
654

    
655
# cluster wide default parameters
656
DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM
657

    
658
HVC_DEFAULTS = {
659
  HT_XEN_PVM: {
660
    HV_USE_BOOTLOADER: False,
661
    HV_BOOTLOADER_PATH: XEN_BOOTLOADER,
662
    HV_BOOTLOADER_ARGS: '',
663
    HV_KERNEL_PATH: "/boot/vmlinuz-2.6-xenU",
664
    HV_INITRD_PATH: '',
665
    HV_ROOT_PATH: '/dev/sda1',
666
    HV_KERNEL_ARGS: 'ro',
667
    HV_MIGRATION_PORT: 8002,
668
    },
669
  HT_XEN_HVM: {
670
    HV_BOOT_ORDER: "cd",
671
    HV_CDROM_IMAGE_PATH: '',
672
    HV_NIC_TYPE: HT_NIC_RTL8139,
673
    HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
674
    HV_VNC_BIND_ADDRESS: '0.0.0.0',
675
    HV_VNC_PASSWORD_FILE: VNC_PASSWORD_FILE,
676
    HV_ACPI: True,
677
    HV_PAE: True,
678
    HV_KERNEL_PATH: "/usr/lib/xen/boot/hvmloader",
679
    HV_DEVICE_MODEL: "/usr/lib/xen/bin/qemu-dm",
680
    HV_MIGRATION_PORT: 8002,
681
    HV_USE_LOCALTIME: False,
682
    },
683
  HT_KVM: {
684
    HV_KERNEL_PATH: "/boot/vmlinuz-2.6-kvmU",
685
    HV_INITRD_PATH: '',
686
    HV_KERNEL_ARGS: 'ro',
687
    HV_ROOT_PATH: '/dev/vda1',
688
    HV_ACPI: True,
689
    HV_SERIAL_CONSOLE: True,
690
    HV_VNC_BIND_ADDRESS: '',
691
    HV_VNC_TLS: False,
692
    HV_VNC_X509: '',
693
    HV_VNC_X509_VERIFY: False,
694
    HV_VNC_PASSWORD_FILE: '',
695
    HV_CDROM_IMAGE_PATH: '',
696
    HV_BOOT_ORDER: HT_BO_DISK,
697
    HV_NIC_TYPE: HT_NIC_PARAVIRTUAL,
698
    HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
699
    HV_USB_MOUSE: '',
700
    HV_MIGRATION_PORT: 8102,
701
    HV_USE_LOCALTIME: False,
702
    HV_DISK_CACHE: HT_CACHE_DEFAULT,
703
    HV_SECURITY_MODEL: HT_SM_NONE,
704
    HV_SECURITY_DOMAIN: '',
705
    },
706
  HT_FAKE: {
707
    },
708
  HT_CHROOT: {
709
    HV_INIT_SCRIPT: "/ganeti-chroot",
710
    },
711
  }
712

    
713
HVC_GLOBALS = frozenset([
714
  HV_MIGRATION_PORT,
715
  ])
716

    
717
BEC_DEFAULTS = {
718
  BE_MEMORY: 128,
719
  BE_VCPUS: 1,
720
  BE_AUTO_BALANCE: True,
721
  }
722

    
723
NICC_DEFAULTS = {
724
  NIC_MODE: NIC_MODE_BRIDGED,
725
  NIC_LINK: DEFAULT_BRIDGE,
726
  }
727

    
728
MASTER_POOL_SIZE_DEFAULT = 10
729

    
730
CONFD_PROTOCOL_VERSION = 1
731

    
732
CONFD_REQ_PING = 0
733
CONFD_REQ_NODE_ROLE_BYNAME = 1
734
CONFD_REQ_NODE_PIP_BY_INSTANCE_IP = 2
735
CONFD_REQ_CLUSTER_MASTER = 3
736
CONFD_REQ_NODE_PIP_LIST = 4
737
CONFD_REQ_MC_PIP_LIST = 5
738
CONFD_REQ_INSTANCES_IPS_LIST = 6
739

    
740
# Confd request query fields. These are used to narrow down queries.
741
# These must be strings rather than integers, because json-encoding
742
# converts them to strings anyway, as they're used as dict-keys.
743
CONFD_REQQ_LINK = "0"
744
CONFD_REQQ_IP = "1"
745
CONFD_REQQ_IPLIST = "2"
746
CONFD_REQQ_FIELDS = "3"
747

    
748
CONFD_REQFIELD_NAME = "0"
749
CONFD_REQFIELD_IP = "1"
750
CONFD_REQFIELD_MNODE_PIP = "2"
751

    
752
CONFD_REQS = frozenset([
753
  CONFD_REQ_PING,
754
  CONFD_REQ_NODE_ROLE_BYNAME,
755
  CONFD_REQ_NODE_PIP_BY_INSTANCE_IP,
756
  CONFD_REQ_CLUSTER_MASTER,
757
  CONFD_REQ_NODE_PIP_LIST,
758
  CONFD_REQ_MC_PIP_LIST,
759
  CONFD_REQ_INSTANCES_IPS_LIST,
760
  ])
761

    
762
CONFD_REPL_STATUS_OK = 0
763
CONFD_REPL_STATUS_ERROR = 1
764
CONFD_REPL_STATUS_NOTIMPLEMENTED = 2
765

    
766
CONFD_REPL_STATUSES = frozenset([
767
  CONFD_REPL_STATUS_OK,
768
  CONFD_REPL_STATUS_ERROR,
769
  CONFD_REPL_STATUS_NOTIMPLEMENTED,
770
  ])
771

    
772
(CONFD_NODE_ROLE_MASTER,
773
 CONFD_NODE_ROLE_CANDIDATE,
774
 CONFD_NODE_ROLE_OFFLINE,
775
 CONFD_NODE_ROLE_DRAINED,
776
 CONFD_NODE_ROLE_REGULAR,
777
 ) = range(5)
778

    
779
# A few common errors for confd
780
CONFD_ERROR_UNKNOWN_ENTRY = 1
781
CONFD_ERROR_INTERNAL = 2
782
CONFD_ERROR_ARGUMENT = 3
783

    
784
# Each request is "salted" by the current timestamp.
785
# This constants decides how many seconds of skew to accept.
786
# TODO: make this a default and allow the value to be more configurable
787
CONFD_MAX_CLOCK_SKEW = 2 * NODE_MAX_CLOCK_SKEW
788

    
789
# When we haven't reloaded the config for more than this amount of seconds, we
790
# force a test to see if inotify is betraying us.
791
CONFD_CONFIG_RELOAD_TIMEOUT = 60
792

    
793
# If we receive more than one update in this amount of seconds, we move to
794
# polling every RATELIMIT seconds, rather than relying on inotify, to be able
795
# to serve more requests.
796
CONFD_CONFIG_RELOAD_RATELIMIT = 2
797

    
798
# Magic number prepended to all confd queries.
799
# This allows us to distinguish different types of confd protocols and handle
800
# them. For example by changing this we can move the whole payload to be
801
# compressed, or move away from json.
802
CONFD_MAGIC_FOURCC = 'plj0'
803

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

    
809
# Timeout in seconds to expire pending query request in the confd client
810
# library. We don't actually expect any answer more than 10 seconds after we
811
# sent a request.
812
CONFD_CLIENT_EXPIRE_TIMEOUT = 10
813

    
814
# Maximum UDP datagram size.
815
# On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
816
# On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
817
#   (assuming we can't use jumbo frames)
818
# We just set this to 60K, which should be enough
819
MAX_UDP_DATA_SIZE = 61440