root / lib / constants.py @ a3758ab2
History | View | Annotate | Download (18.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 |
ETC_HOSTS = "/etc/hosts"
|
108 |
DEFAULT_FILE_STORAGE_DIR = _autoconf.FILE_STORAGE_DIR |
109 |
SYSCONFDIR = _autoconf.SYSCONFDIR |
110 |
TOOLSDIR = _autoconf.TOOLSDIR |
111 |
CONF_DIR = SYSCONFDIR + "/ganeti"
|
112 |
|
113 |
MASTER_SOCKET = SOCKET_DIR + "/ganeti-master"
|
114 |
|
115 |
NODE_INITD_SCRIPT = SYSCONFDIR + "/init.d/ganeti"
|
116 |
|
117 |
NODED = "ganeti-noded"
|
118 |
CONFD = "ganeti-confd"
|
119 |
RAPI = "ganeti-rapi"
|
120 |
MASTERD = "ganeti-masterd"
|
121 |
|
122 |
MULTITHREADED_DAEMONS = frozenset([MASTERD])
|
123 |
|
124 |
DAEMONS_SSL = { |
125 |
# daemon-name: (default-cert-path, default-key-path)
|
126 |
NODED: (SSL_CERT_FILE, SSL_CERT_FILE), |
127 |
RAPI: (RAPI_CERT_FILE, RAPI_CERT_FILE), |
128 |
} |
129 |
|
130 |
DAEMONS_PORTS = { |
131 |
# daemon-name: ("proto", "default-port")
|
132 |
NODED: ("tcp", 1811), |
133 |
CONFD: ("udp", 1814), |
134 |
RAPI: ("tcp", 5080), |
135 |
} |
136 |
DEFAULT_NODED_PORT = DAEMONS_PORTS[NODED][1]
|
137 |
DEFAULT_CONFD_PORT = DAEMONS_PORTS[CONFD][1]
|
138 |
DEFAULT_RAPI_PORT = DAEMONS_PORTS[RAPI][1]
|
139 |
|
140 |
FIRST_DRBD_PORT = 11000
|
141 |
LAST_DRBD_PORT = 14999
|
142 |
MASTER_SCRIPT = "ganeti-master"
|
143 |
|
144 |
LOG_DIR = _autoconf.LOCALSTATEDIR + "/log/ganeti/"
|
145 |
DAEMONS_LOGFILES = { |
146 |
# "daemon-name": "logfile"
|
147 |
NODED: LOG_DIR + "node-daemon.log",
|
148 |
CONFD: LOG_DIR + "conf-daemon.log",
|
149 |
RAPI: LOG_DIR + "rapi-daemon.log",
|
150 |
MASTERD: LOG_DIR + "master-daemon.log",
|
151 |
} |
152 |
LOG_OS_DIR = LOG_DIR + "os"
|
153 |
LOG_WATCHER = LOG_DIR + "watcher.log"
|
154 |
LOG_COMMANDS = LOG_DIR + "commands.log"
|
155 |
LOG_BURNIN = LOG_DIR + "burnin.log"
|
156 |
|
157 |
OS_SEARCH_PATH = _autoconf.OS_SEARCH_PATH |
158 |
EXPORT_DIR = _autoconf.EXPORT_DIR |
159 |
|
160 |
EXPORT_CONF_FILE = "config.ini"
|
161 |
|
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 |
KVM_MIGRATION_PORT = _autoconf.KVM_MIGRATION_PORT |
168 |
|
169 |
VALUE_DEFAULT = "default"
|
170 |
VALUE_AUTO = "auto"
|
171 |
VALUE_GENERATE = "generate"
|
172 |
VALUE_NONE = "none"
|
173 |
VALUE_TRUE = "true"
|
174 |
VALUE_FALSE = "false"
|
175 |
|
176 |
# hooks-related constants
|
177 |
HOOKS_BASE_DIR = CONF_DIR + "/hooks"
|
178 |
HOOKS_PHASE_PRE = "pre"
|
179 |
HOOKS_PHASE_POST = "post"
|
180 |
HOOKS_NAME_CFGUPDATE = "config-update"
|
181 |
HOOKS_VERSION = 2
|
182 |
|
183 |
# hooks subject type (what object type does the LU deal with)
|
184 |
HTYPE_CLUSTER = "CLUSTER"
|
185 |
HTYPE_NODE = "NODE"
|
186 |
HTYPE_INSTANCE = "INSTANCE"
|
187 |
|
188 |
HKR_SKIP = 0
|
189 |
HKR_FAIL = 1
|
190 |
HKR_SUCCESS = 2
|
191 |
|
192 |
# Storage types
|
193 |
ST_FILE = "file"
|
194 |
ST_LVM_PV = "lvm-pv"
|
195 |
ST_LVM_VG = "lvm-vg"
|
196 |
|
197 |
# Storage fields
|
198 |
SF_NAME = "name"
|
199 |
SF_SIZE = "size"
|
200 |
SF_FREE = "free"
|
201 |
SF_USED = "used"
|
202 |
SF_ALLOCATABLE = "allocatable"
|
203 |
|
204 |
# Storage operations
|
205 |
SO_FIX_CONSISTENCY = "fix-consistency"
|
206 |
|
207 |
# Available fields per storage type
|
208 |
VALID_STORAGE_FIELDS = { |
209 |
ST_FILE: frozenset([SF_NAME, SF_USED, SF_FREE]),
|
210 |
ST_LVM_PV: frozenset([SF_NAME, SF_SIZE, SF_USED, SF_FREE, SF_ALLOCATABLE]),
|
211 |
ST_LVM_VG: frozenset([SF_NAME, SF_SIZE]),
|
212 |
} |
213 |
|
214 |
MODIFIABLE_STORAGE_FIELDS = { |
215 |
ST_LVM_PV: frozenset([SF_ALLOCATABLE]),
|
216 |
} |
217 |
|
218 |
VALID_STORAGE_OPERATIONS = { |
219 |
ST_LVM_VG: frozenset([SO_FIX_CONSISTENCY]),
|
220 |
} |
221 |
|
222 |
# Local disk status
|
223 |
# Note: Code depends on LDS_OKAY < LDS_UNKNOWN < LDS_FAULTY
|
224 |
(LDS_OKAY, |
225 |
LDS_UNKNOWN, |
226 |
LDS_FAULTY) = range(1, 4) |
227 |
|
228 |
# disk template types
|
229 |
DT_DISKLESS = "diskless"
|
230 |
DT_PLAIN = "plain"
|
231 |
DT_DRBD8 = "drbd"
|
232 |
DT_FILE = "file"
|
233 |
|
234 |
# the set of network-mirrored disk templates
|
235 |
DTS_NET_MIRROR = frozenset([DT_DRBD8])
|
236 |
|
237 |
# the set of non-lvm-based disk templates
|
238 |
DTS_NOT_LVM = frozenset([DT_DISKLESS, DT_FILE])
|
239 |
|
240 |
# logical disk types
|
241 |
LD_LV = "lvm"
|
242 |
LD_DRBD8 = "drbd8"
|
243 |
LD_FILE = "file"
|
244 |
LDS_BLOCK = frozenset([LD_LV, LD_DRBD8])
|
245 |
|
246 |
# drbd constants
|
247 |
DRBD_HMAC_ALG = "md5"
|
248 |
DRBD_NET_PROTOCOL = "C"
|
249 |
|
250 |
# file backend driver
|
251 |
FD_LOOP = "loop"
|
252 |
FD_BLKTAP = "blktap"
|
253 |
|
254 |
# the set of drbd-like disk types
|
255 |
LDS_DRBD = frozenset([LD_DRBD8])
|
256 |
|
257 |
# disk access mode
|
258 |
DISK_RDONLY = "ro"
|
259 |
DISK_RDWR = "rw"
|
260 |
DISK_ACCESS_SET = frozenset([DISK_RDONLY, DISK_RDWR])
|
261 |
|
262 |
# disk replacement mode
|
263 |
REPLACE_DISK_PRI = "replace_on_primary" # replace disks on primary |
264 |
REPLACE_DISK_SEC = "replace_on_secondary" # replace disks on secondary |
265 |
REPLACE_DISK_CHG = "replace_new_secondary" # change secondary node |
266 |
REPLACE_DISK_AUTO = "replace_auto"
|
267 |
|
268 |
# lock recalculate mode
|
269 |
LOCKS_REPLACE = 'replace'
|
270 |
LOCKS_APPEND = 'append'
|
271 |
|
272 |
# instance creation modes
|
273 |
INSTANCE_CREATE = "create"
|
274 |
INSTANCE_IMPORT = "import"
|
275 |
|
276 |
DISK_TEMPLATES = frozenset([DT_DISKLESS, DT_PLAIN,
|
277 |
DT_DRBD8, DT_FILE]) |
278 |
|
279 |
FILE_DRIVER = frozenset([FD_LOOP, FD_BLKTAP])
|
280 |
|
281 |
# import/export config options
|
282 |
INISECT_EXP = "export"
|
283 |
INISECT_INS = "instance"
|
284 |
|
285 |
# dynamic device modification
|
286 |
|
287 |
DDM_ADD = 'add'
|
288 |
DDM_REMOVE = 'remove'
|
289 |
|
290 |
# common exit codes
|
291 |
EXIT_SUCCESS = 0
|
292 |
EXIT_FAILURE = 1
|
293 |
EXIT_NOTCLUSTER = 5
|
294 |
EXIT_NOTMASTER = 11
|
295 |
EXIT_NODESETUP_ERROR = 12
|
296 |
EXIT_CONFIRMATION = 13 # need user confirmation |
297 |
EXIT_NOTCANDIDATE = 14
|
298 |
|
299 |
# tags
|
300 |
TAG_CLUSTER = "cluster"
|
301 |
TAG_NODE = "node"
|
302 |
TAG_INSTANCE = "instance"
|
303 |
MAX_TAG_LEN = 128
|
304 |
MAX_TAGS_PER_OBJ = 4096
|
305 |
|
306 |
# others
|
307 |
DEFAULT_BRIDGE = "xen-br0"
|
308 |
SYNC_SPEED = 60 * 1024 |
309 |
LOCALHOST_IP_ADDRESS = "127.0.0.1"
|
310 |
TCP_PING_TIMEOUT = 10
|
311 |
GANETI_RUNAS = "root"
|
312 |
DEFAULT_VG = "xenvg"
|
313 |
BIND_ADDRESS_GLOBAL = "0.0.0.0"
|
314 |
MIN_VG_SIZE = 20480
|
315 |
DEFAULT_MAC_PREFIX = "aa:00:00"
|
316 |
LVM_STRIPECOUNT = _autoconf.LVM_STRIPECOUNT |
317 |
|
318 |
# RPC constants
|
319 |
(RPC_ENCODING_NONE, |
320 |
RPC_ENCODING_ZLIB_BASE64) = range(2) |
321 |
|
322 |
# os related constants
|
323 |
OS_SCRIPT_CREATE = 'create'
|
324 |
OS_SCRIPT_IMPORT = 'import'
|
325 |
OS_SCRIPT_EXPORT = 'export'
|
326 |
OS_SCRIPT_RENAME = 'rename'
|
327 |
OS_SCRIPTS = frozenset([OS_SCRIPT_CREATE, OS_SCRIPT_IMPORT,
|
328 |
OS_SCRIPT_EXPORT, OS_SCRIPT_RENAME]) |
329 |
|
330 |
# ssh constants
|
331 |
SSH_INITD_SCRIPT = _autoconf.SSH_INITD_SCRIPT |
332 |
SSH_CONFIG_DIR = "/etc/ssh/"
|
333 |
SSH_HOST_DSA_PRIV = SSH_CONFIG_DIR + "ssh_host_dsa_key"
|
334 |
SSH_HOST_DSA_PUB = SSH_HOST_DSA_PRIV + ".pub"
|
335 |
SSH_HOST_RSA_PRIV = SSH_CONFIG_DIR + "ssh_host_rsa_key"
|
336 |
SSH_HOST_RSA_PUB = SSH_HOST_RSA_PRIV + ".pub"
|
337 |
SSH = "ssh"
|
338 |
SCP = "scp"
|
339 |
|
340 |
# reboot types
|
341 |
INSTANCE_REBOOT_SOFT = "soft"
|
342 |
INSTANCE_REBOOT_HARD = "hard"
|
343 |
INSTANCE_REBOOT_FULL = "full"
|
344 |
|
345 |
REBOOT_TYPES = frozenset([INSTANCE_REBOOT_SOFT,
|
346 |
INSTANCE_REBOOT_HARD, |
347 |
INSTANCE_REBOOT_FULL]) |
348 |
|
349 |
VTYPE_STRING = 'string'
|
350 |
VTYPE_BOOL = 'bool'
|
351 |
VTYPE_SIZE = 'size' # size, in MiBs |
352 |
VTYPE_INT = 'int'
|
353 |
ENFORCEABLE_TYPES = frozenset([
|
354 |
VTYPE_STRING, |
355 |
VTYPE_BOOL, |
356 |
VTYPE_SIZE, |
357 |
VTYPE_INT, |
358 |
]) |
359 |
|
360 |
# HV parameter names (global namespace)
|
361 |
HV_BOOT_ORDER = "boot_order"
|
362 |
HV_CDROM_IMAGE_PATH = "cdrom_image_path"
|
363 |
HV_NIC_TYPE = "nic_type"
|
364 |
HV_DISK_TYPE = "disk_type"
|
365 |
HV_VNC_BIND_ADDRESS = "vnc_bind_address"
|
366 |
HV_VNC_TLS = "vnc_tls"
|
367 |
HV_VNC_X509 = "vnc_x509_path"
|
368 |
HV_VNC_X509_VERIFY = "vnc_x509_verify"
|
369 |
HV_ACPI = "acpi"
|
370 |
HV_PAE = "pae"
|
371 |
HV_KERNEL_ARGS = "kernel_args"
|
372 |
HV_KERNEL_PATH = "kernel_path"
|
373 |
HV_INITRD_PATH = "initrd_path"
|
374 |
HV_ROOT_PATH = "root_path"
|
375 |
HV_SERIAL_CONSOLE = "serial_console"
|
376 |
HV_USB_MOUSE = "usb_mouse"
|
377 |
HV_DEVICE_MODEL = "device_model"
|
378 |
HV_INIT_SCRIPT = "init_script"
|
379 |
|
380 |
HVS_PARAMETER_TYPES = { |
381 |
HV_BOOT_ORDER: VTYPE_STRING, |
382 |
HV_CDROM_IMAGE_PATH: VTYPE_STRING, |
383 |
HV_NIC_TYPE: VTYPE_STRING, |
384 |
HV_DISK_TYPE: VTYPE_STRING, |
385 |
HV_VNC_BIND_ADDRESS: VTYPE_STRING, |
386 |
HV_VNC_TLS: VTYPE_BOOL, |
387 |
HV_VNC_X509: VTYPE_STRING, |
388 |
HV_VNC_X509_VERIFY: VTYPE_BOOL, |
389 |
HV_ACPI: VTYPE_BOOL, |
390 |
HV_PAE: VTYPE_BOOL, |
391 |
HV_KERNEL_PATH: VTYPE_STRING, |
392 |
HV_KERNEL_ARGS: VTYPE_STRING, |
393 |
HV_INITRD_PATH: VTYPE_STRING, |
394 |
HV_ROOT_PATH: VTYPE_STRING, |
395 |
HV_SERIAL_CONSOLE: VTYPE_BOOL, |
396 |
HV_USB_MOUSE: VTYPE_STRING, |
397 |
HV_DEVICE_MODEL: VTYPE_STRING, |
398 |
HV_INIT_SCRIPT: VTYPE_STRING, |
399 |
} |
400 |
|
401 |
HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
|
402 |
|
403 |
# BE parameter names
|
404 |
BE_MEMORY = "memory"
|
405 |
BE_VCPUS = "vcpus"
|
406 |
BE_AUTO_BALANCE = "auto_balance"
|
407 |
|
408 |
BES_PARAMETER_TYPES = { |
409 |
BE_MEMORY: VTYPE_SIZE, |
410 |
BE_VCPUS: VTYPE_INT, |
411 |
BE_AUTO_BALANCE: VTYPE_BOOL, |
412 |
} |
413 |
|
414 |
BES_PARAMETERS = frozenset(BES_PARAMETER_TYPES.keys())
|
415 |
|
416 |
# Instance Parameters Profile
|
417 |
PP_DEFAULT = "default"
|
418 |
|
419 |
NIC_MODE = "mode"
|
420 |
NIC_LINK = "link"
|
421 |
|
422 |
NIC_MODE_BRIDGED = "bridged"
|
423 |
NIC_MODE_ROUTED = "routed"
|
424 |
|
425 |
NIC_VALID_MODES = frozenset([NIC_MODE_BRIDGED, NIC_MODE_ROUTED])
|
426 |
|
427 |
NICS_PARAMETER_TYPES = { |
428 |
NIC_MODE: VTYPE_STRING, |
429 |
NIC_LINK: VTYPE_STRING, |
430 |
} |
431 |
|
432 |
NICS_PARAMETERS = frozenset(NICS_PARAMETER_TYPES.keys())
|
433 |
|
434 |
# Hypervisor constants
|
435 |
HT_XEN_PVM = "xen-pvm"
|
436 |
HT_FAKE = "fake"
|
437 |
HT_XEN_HVM = "xen-hvm"
|
438 |
HT_KVM = "kvm"
|
439 |
HT_CHROOT = "chroot"
|
440 |
HYPER_TYPES = frozenset([HT_XEN_PVM, HT_FAKE, HT_XEN_HVM, HT_KVM, HT_CHROOT])
|
441 |
HTS_REQ_PORT = frozenset([HT_XEN_HVM, HT_KVM])
|
442 |
|
443 |
VNC_BASE_PORT = 5900
|
444 |
VNC_PASSWORD_FILE = CONF_DIR + "/vnc-cluster-password"
|
445 |
VNC_DEFAULT_BIND_ADDRESS = '0.0.0.0'
|
446 |
|
447 |
# NIC types
|
448 |
HT_NIC_RTL8139 = "rtl8139"
|
449 |
HT_NIC_NE2K_PCI = "ne2k_pci"
|
450 |
HT_NIC_NE2K_ISA = "ne2k_isa"
|
451 |
HT_NIC_I82551 = "i82551"
|
452 |
HT_NIC_I85557B = "i82557b"
|
453 |
HT_NIC_I8259ER = "i82559er"
|
454 |
HT_NIC_PCNET = "pcnet"
|
455 |
HT_NIC_E1000 = "e1000"
|
456 |
HT_NIC_PARAVIRTUAL = HT_DISK_PARAVIRTUAL = "paravirtual"
|
457 |
|
458 |
HT_HVM_VALID_NIC_TYPES = frozenset([HT_NIC_RTL8139, HT_NIC_NE2K_PCI,
|
459 |
HT_NIC_NE2K_ISA, HT_NIC_PARAVIRTUAL]) |
460 |
HT_KVM_VALID_NIC_TYPES = frozenset([HT_NIC_RTL8139, HT_NIC_NE2K_PCI,
|
461 |
HT_NIC_NE2K_ISA, HT_NIC_I82551, |
462 |
HT_NIC_I85557B, HT_NIC_I8259ER, |
463 |
HT_NIC_PCNET, HT_NIC_E1000, |
464 |
HT_NIC_PARAVIRTUAL]) |
465 |
# Disk types
|
466 |
HT_DISK_IOEMU = "ioemu"
|
467 |
HT_DISK_IDE = "ide"
|
468 |
HT_DISK_SCSI = "scsi"
|
469 |
HT_DISK_SD = "sd"
|
470 |
HT_DISK_MTD = "mtd"
|
471 |
HT_DISK_PFLASH = "pflash"
|
472 |
|
473 |
HT_HVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IOEMU])
|
474 |
HT_KVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IDE,
|
475 |
HT_DISK_SCSI, HT_DISK_SD, HT_DISK_MTD, |
476 |
HT_DISK_PFLASH]) |
477 |
|
478 |
# Mouse types:
|
479 |
HT_MOUSE_MOUSE = "mouse"
|
480 |
HT_MOUSE_TABLET = "tablet"
|
481 |
|
482 |
HT_KVM_VALID_MOUSE_TYPES = frozenset([HT_MOUSE_MOUSE, HT_MOUSE_TABLET])
|
483 |
|
484 |
# Boot order
|
485 |
HT_BO_CDROM = "cdrom"
|
486 |
HT_BO_DISK = "disk"
|
487 |
HT_BO_NETWORK = "network"
|
488 |
|
489 |
HT_KVM_VALID_BO_TYPES = frozenset([HT_BO_CDROM, HT_BO_DISK, HT_BO_NETWORK])
|
490 |
|
491 |
# Cluster Verify steps
|
492 |
VERIFY_NPLUSONE_MEM = 'nplusone_mem'
|
493 |
VERIFY_OPTIONAL_CHECKS = frozenset([VERIFY_NPLUSONE_MEM])
|
494 |
|
495 |
# Node verify constants
|
496 |
NV_FILELIST = "filelist"
|
497 |
NV_HVINFO = "hvinfo"
|
498 |
NV_HYPERVISOR = "hypervisor"
|
499 |
NV_INSTANCELIST = "instancelist"
|
500 |
NV_LVLIST = "lvlist"
|
501 |
NV_NODELIST = "nodelist"
|
502 |
NV_NODENETTEST = "node-net-test"
|
503 |
NV_VERSION = "version"
|
504 |
NV_VGLIST = "vglist"
|
505 |
NV_DRBDLIST = "drbd-list"
|
506 |
|
507 |
# Allocator framework constants
|
508 |
IALLOCATOR_VERSION = 2
|
509 |
IALLOCATOR_DIR_IN = "in"
|
510 |
IALLOCATOR_DIR_OUT = "out"
|
511 |
IALLOCATOR_MODE_ALLOC = "allocate"
|
512 |
IALLOCATOR_MODE_RELOC = "relocate"
|
513 |
IALLOCATOR_SEARCH_PATH = _autoconf.IALLOCATOR_SEARCH_PATH |
514 |
|
515 |
# Job queue
|
516 |
JOB_QUEUE_VERSION = 1
|
517 |
JOB_QUEUE_LOCK_FILE = QUEUE_DIR + "/lock"
|
518 |
JOB_QUEUE_VERSION_FILE = QUEUE_DIR + "/version"
|
519 |
JOB_QUEUE_SERIAL_FILE = QUEUE_DIR + "/serial"
|
520 |
JOB_QUEUE_ARCHIVE_DIR = QUEUE_DIR + "/archive"
|
521 |
JOB_QUEUE_DRAIN_FILE = QUEUE_DIR + "/drain"
|
522 |
JOB_QUEUE_SIZE_HARD_LIMIT = 5000
|
523 |
JOB_QUEUE_SIZE_SOFT_LIMIT = JOB_QUEUE_SIZE_HARD_LIMIT * 0.8
|
524 |
|
525 |
JOB_ID_TEMPLATE = r"\d+"
|
526 |
|
527 |
# unchanged job return
|
528 |
JOB_NOTCHANGED = "nochange"
|
529 |
|
530 |
# Job status
|
531 |
JOB_STATUS_QUEUED = "queued"
|
532 |
JOB_STATUS_WAITLOCK = "waiting"
|
533 |
JOB_STATUS_CANCELING = "canceling"
|
534 |
JOB_STATUS_RUNNING = "running"
|
535 |
JOB_STATUS_CANCELED = "canceled"
|
536 |
JOB_STATUS_SUCCESS = "success"
|
537 |
JOB_STATUS_ERROR = "error"
|
538 |
|
539 |
# OpCode status
|
540 |
# not yet finalized
|
541 |
OP_STATUS_QUEUED = "queued"
|
542 |
OP_STATUS_WAITLOCK = "waiting"
|
543 |
OP_STATUS_CANCELING = "canceling"
|
544 |
OP_STATUS_RUNNING = "running"
|
545 |
# finalized
|
546 |
OP_STATUS_CANCELED = "canceled"
|
547 |
OP_STATUS_SUCCESS = "success"
|
548 |
OP_STATUS_ERROR = "error"
|
549 |
OPS_FINALIZED = frozenset([OP_STATUS_CANCELED,
|
550 |
OP_STATUS_SUCCESS, |
551 |
OP_STATUS_ERROR]) |
552 |
|
553 |
# Execution log types
|
554 |
ELOG_MESSAGE = "message"
|
555 |
ELOG_PROGRESS = "progress"
|
556 |
|
557 |
# max dynamic devices
|
558 |
MAX_NICS = 8
|
559 |
MAX_DISKS = 16
|
560 |
|
561 |
# SSCONF keys
|
562 |
SS_CLUSTER_NAME = "cluster_name"
|
563 |
SS_CLUSTER_TAGS = "cluster_tags"
|
564 |
SS_FILE_STORAGE_DIR = "file_storage_dir"
|
565 |
SS_MASTER_CANDIDATES = "master_candidates"
|
566 |
SS_MASTER_CANDIDATES_IPS = "master_candidates_ips"
|
567 |
SS_MASTER_IP = "master_ip"
|
568 |
SS_MASTER_NETDEV = "master_netdev"
|
569 |
SS_MASTER_NODE = "master_node"
|
570 |
SS_NODE_LIST = "node_list"
|
571 |
SS_NODE_PRIMARY_IPS = "node_primary_ips"
|
572 |
SS_NODE_SECONDARY_IPS = "node_secondary_ips"
|
573 |
SS_OFFLINE_NODES = "offline_nodes"
|
574 |
SS_ONLINE_NODES = "online_nodes"
|
575 |
SS_INSTANCE_LIST = "instance_list"
|
576 |
SS_RELEASE_VERSION = "release_version"
|
577 |
|
578 |
# cluster wide default parameters
|
579 |
DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM |
580 |
|
581 |
HVC_DEFAULTS = { |
582 |
HT_XEN_PVM: { |
583 |
HV_KERNEL_PATH: "/boot/vmlinuz-2.6-xenU",
|
584 |
HV_INITRD_PATH: '',
|
585 |
HV_ROOT_PATH: '/dev/sda1',
|
586 |
HV_KERNEL_ARGS: 'ro',
|
587 |
}, |
588 |
HT_XEN_HVM: { |
589 |
HV_BOOT_ORDER: "cd",
|
590 |
HV_CDROM_IMAGE_PATH: '',
|
591 |
HV_NIC_TYPE: HT_NIC_RTL8139, |
592 |
HV_DISK_TYPE: HT_DISK_PARAVIRTUAL, |
593 |
HV_VNC_BIND_ADDRESS: '0.0.0.0',
|
594 |
HV_ACPI: True,
|
595 |
HV_PAE: True,
|
596 |
HV_KERNEL_PATH: "/usr/lib/xen/boot/hvmloader",
|
597 |
HV_DEVICE_MODEL: "/usr/lib/xen/bin/qemu-dm",
|
598 |
}, |
599 |
HT_KVM: { |
600 |
HV_KERNEL_PATH: "/boot/vmlinuz-2.6-kvmU",
|
601 |
HV_INITRD_PATH: '',
|
602 |
HV_KERNEL_ARGS: 'ro',
|
603 |
HV_ROOT_PATH: '/dev/vda1',
|
604 |
HV_ACPI: True,
|
605 |
HV_SERIAL_CONSOLE: True,
|
606 |
HV_VNC_BIND_ADDRESS: '',
|
607 |
HV_VNC_TLS: False,
|
608 |
HV_VNC_X509: '',
|
609 |
HV_VNC_X509_VERIFY: False,
|
610 |
HV_CDROM_IMAGE_PATH: '',
|
611 |
HV_BOOT_ORDER: HT_BO_DISK, |
612 |
HV_NIC_TYPE: HT_NIC_PARAVIRTUAL, |
613 |
HV_DISK_TYPE: HT_DISK_PARAVIRTUAL, |
614 |
HV_USB_MOUSE: '',
|
615 |
}, |
616 |
HT_FAKE: { |
617 |
}, |
618 |
HT_CHROOT: { |
619 |
HV_INIT_SCRIPT: "/ganeti-chroot",
|
620 |
}, |
621 |
} |
622 |
|
623 |
BEC_DEFAULTS = { |
624 |
BE_MEMORY: 128,
|
625 |
BE_VCPUS: 1,
|
626 |
BE_AUTO_BALANCE: True,
|
627 |
} |
628 |
|
629 |
NICC_DEFAULTS = { |
630 |
NIC_MODE: NIC_MODE_BRIDGED, |
631 |
NIC_LINK: DEFAULT_BRIDGE, |
632 |
} |
633 |
|
634 |
MASTER_POOL_SIZE_DEFAULT = 10
|
635 |
|
636 |
CONFD_PROTOCOL_VERSION = 1
|
637 |
|
638 |
CONFD_REQ_PING = 0
|
639 |
CONFD_REQ_NODE_ROLE_BYNAME = 1
|
640 |
CONFD_REQ_NODE_PIP_BY_INSTANCE_IP = 2
|
641 |
CONFD_REQ_CLUSTER_MASTER = 3
|
642 |
|
643 |
CONFD_REQS = frozenset([
|
644 |
CONFD_REQ_PING, |
645 |
CONFD_REQ_NODE_ROLE_BYNAME, |
646 |
CONFD_REQ_NODE_PIP_BY_INSTANCE_IP, |
647 |
CONFD_REQ_CLUSTER_MASTER, |
648 |
]) |
649 |
|
650 |
CONFD_REPL_STATUS_OK = 0
|
651 |
CONFD_REPL_STATUS_ERROR = 1
|
652 |
CONFD_REPL_STATUS_NOTIMPLEMENTED = 2
|
653 |
|
654 |
CONFD_REPL_STATUSES = frozenset([
|
655 |
CONFD_REPL_STATUS_OK, |
656 |
CONFD_REPL_STATUS_ERROR, |
657 |
CONFD_REPL_STATUS_NOTIMPLEMENTED, |
658 |
]) |
659 |
|
660 |
(CONFD_NODE_ROLE_MASTER, |
661 |
CONFD_NODE_ROLE_CANDIDATE, |
662 |
CONFD_NODE_ROLE_OFFLINE, |
663 |
CONFD_NODE_ROLE_DRAINED, |
664 |
CONFD_NODE_ROLE_REGULAR, |
665 |
) = range(5) |
666 |
|
667 |
# A few common errors for confd
|
668 |
CONFD_ERROR_UNKNOWN_ENTRY = 1
|
669 |
CONFD_ERROR_INTERNAL = 2
|
670 |
|
671 |
# Each request is "salted" by the current timestamp.
|
672 |
# This constants decides how many seconds of skew to accept.
|
673 |
# TODO: make this a default and allow the value to be more configurable
|
674 |
CONFD_MAX_CLOCK_SKEW = 300
|
675 |
|
676 |
# When we haven't reloaded the config for more than this amount of seconds, we
|
677 |
# force a test to see if inotify is betraying us.
|
678 |
CONFD_CONFIG_RELOAD_TIMEOUT = 60
|
679 |
|
680 |
# If we receive more than one update in this amount of seconds, we move to
|
681 |
# polling every RATELIMIT seconds, rather than relying on inotify, to be able
|
682 |
# to serve more requests.
|
683 |
CONFD_CONFIG_RELOAD_RATELIMIT = 2
|
684 |
|
685 |
# Magic number prepended to all confd queries.
|
686 |
# This allows us to distinguish different types of confd protocols and handle
|
687 |
# them. For example by changing this we can move the whole payload to be
|
688 |
# compressed, or move away from json.
|
689 |
CONFD_MAGIC_FOURCC = 'plj0'
|
690 |
|
691 |
# Maximum UDP datagram size.
|
692 |
# On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
|
693 |
# On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
|
694 |
# (assuming we can't use jumbo frames)
|
695 |
# We just set this to 60K, which should be enough
|
696 |
MAX_UDP_DATA_SIZE = 61440
|