Package ganeti :: Module constants
[hide private]
[frames] | no frames]

Source Code for Module ganeti.constants

   1  # 
   2  # 
   3   
   4  # Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 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  RELEASE_VERSION = _autoconf.PACKAGE_VERSION 
  30  OS_API_V10 = 10 
  31  OS_API_V15 = 15 
  32  OS_API_V20 = 20 
  33  OS_API_VERSIONS = frozenset([OS_API_V10, OS_API_V15, OS_API_V20]) 
  34  VCS_VERSION = _autoconf.VCS_VERSION 
  35  EXPORT_VERSION = 0 
  36  RAPI_VERSION = 2 
  37   
  38   
  39  # Format for CONFIG_VERSION: 
  40  #   01 03 0123 = 01030123 
  41  #   ^^ ^^ ^^^^ 
  42  #   |  |  + Configuration version/revision 
  43  #   |  + Minor version 
  44  #   + Major version 
  45  # 
  46  # It stored as an integer. Make sure not to write an octal number. 
  47   
  48  # BuildVersion and SplitVersion must be in here because we can't import other 
  49  # modules. The cfgupgrade tool must be able to read and write version numbers 
  50  # and thus requires these functions. To avoid code duplication, they're kept in 
  51  # here. 
  52   
53 -def BuildVersion(major, minor, revision):
54 """Calculates int version number from major, minor and revision numbers. 55 56 Returns: int representing version number 57 58 """ 59 assert isinstance(major, int) 60 assert isinstance(minor, int) 61 assert isinstance(revision, int) 62 return (1000000 * major + 63 10000 * minor + 64 1 * revision)
65 66
67 -def SplitVersion(version):
68 """Splits version number stored in an int. 69 70 Returns: tuple; (major, minor, revision) 71 72 """ 73 assert isinstance(version, int) 74 75 (major, remainder) = divmod(version, 1000000) 76 (minor, revision) = divmod(remainder, 10000) 77 78 return (major, minor, revision)
79 80 81 CONFIG_MAJOR = int(_autoconf.VERSION_MAJOR) 82 CONFIG_MINOR = int(_autoconf.VERSION_MINOR) 83 CONFIG_REVISION = 0 84 CONFIG_VERSION = BuildVersion(CONFIG_MAJOR, CONFIG_MINOR, CONFIG_REVISION) 85 86 #: RPC protocol version 87 PROTOCOL_VERSION = BuildVersion(CONFIG_MAJOR, CONFIG_MINOR, 0) 88 89 # user separation 90 DAEMONS_GROUP = _autoconf.DAEMONS_GROUP 91 ADMIN_GROUP = _autoconf.ADMIN_GROUP 92 MASTERD_USER = _autoconf.MASTERD_USER 93 MASTERD_GROUP = _autoconf.MASTERD_GROUP 94 RAPI_USER = _autoconf.RAPI_USER 95 RAPI_GROUP = _autoconf.RAPI_GROUP 96 CONFD_USER = _autoconf.CONFD_USER 97 CONFD_GROUP = _autoconf.CONFD_GROUP 98 NODED_USER = _autoconf.NODED_USER 99 NODED_GROUP = _autoconf.NODED_GROUP 100 101 102 # Wipe 103 DD_CMD = "dd" 104 WIPE_BLOCK_SIZE = 1024**2 105 MAX_WIPE_CHUNK = 1024 # 1GB 106 MIN_WIPE_CHUNK_PERCENT = 10 107 108 109 # file paths 110 DATA_DIR = _autoconf.LOCALSTATEDIR + "/lib/ganeti" 111 RUN_DIR = _autoconf.LOCALSTATEDIR + "/run" 112 RUN_GANETI_DIR = RUN_DIR + "/ganeti" 113 BDEV_CACHE_DIR = RUN_GANETI_DIR + "/bdev-cache" 114 DISK_LINKS_DIR = RUN_GANETI_DIR + "/instance-disks" 115 RUN_DIRS_MODE = 0775 116 SOCKET_DIR = RUN_GANETI_DIR + "/socket" 117 SECURE_DIR_MODE = 0700 118 SECURE_FILE_MODE = 0600 119 SOCKET_DIR_MODE = 0750 120 CRYPTO_KEYS_DIR = RUN_GANETI_DIR + "/crypto" 121 CRYPTO_KEYS_DIR_MODE = SECURE_DIR_MODE 122 IMPORT_EXPORT_DIR = RUN_GANETI_DIR + "/import-export" 123 IMPORT_EXPORT_DIR_MODE = 0755 124 # keep RUN_GANETI_DIR first here, to make sure all get created when the node 125 # daemon is started (this takes care of RUN_DIR being tmpfs) 126 SUB_RUN_DIRS = [ RUN_GANETI_DIR, BDEV_CACHE_DIR, DISK_LINKS_DIR ] 127 LOCK_DIR = _autoconf.LOCALSTATEDIR + "/lock" 128 SSCONF_LOCK_FILE = LOCK_DIR + "/ganeti-ssconf.lock" 129 # User-id pool lock directory 130 # The user-ids that are in use have a corresponding lock file in this directory 131 UIDPOOL_LOCKDIR = RUN_GANETI_DIR + "/uid-pool" 132 CLUSTER_CONF_FILE = DATA_DIR + "/config.data" 133 NODED_CERT_FILE = DATA_DIR + "/server.pem" 134 RAPI_CERT_FILE = DATA_DIR + "/rapi.pem" 135 CONFD_HMAC_KEY = DATA_DIR + "/hmac.key" 136 CLUSTER_DOMAIN_SECRET_FILE = DATA_DIR + "/cluster-domain-secret" 137 WATCHER_STATEFILE = DATA_DIR + "/watcher.data" 138 WATCHER_PAUSEFILE = DATA_DIR + "/watcher.pause" 139 INSTANCE_UPFILE = RUN_GANETI_DIR + "/instance-status" 140 SSH_KNOWN_HOSTS_FILE = DATA_DIR + "/known_hosts" 141 RAPI_USERS_FILE = DATA_DIR + "/rapi/users" 142 QUEUE_DIR = DATA_DIR + "/queue" 143 DAEMON_UTIL = _autoconf.PKGLIBDIR + "/daemon-util" 144 SETUP_SSH = _autoconf.TOOLSDIR + "/setup-ssh" 145 KVM_IFUP = _autoconf.PKGLIBDIR + "/kvm-ifup" 146 ETC_HOSTS = "/etc/hosts" 147 DEFAULT_FILE_STORAGE_DIR = _autoconf.FILE_STORAGE_DIR 148 ENABLE_FILE_STORAGE = _autoconf.ENABLE_FILE_STORAGE 149 SYSCONFDIR = _autoconf.SYSCONFDIR 150 TOOLSDIR = _autoconf.TOOLSDIR 151 CONF_DIR = SYSCONFDIR + "/ganeti" 152 153 ALL_CERT_FILES = frozenset([NODED_CERT_FILE, RAPI_CERT_FILE]) 154 155 MASTER_SOCKET = SOCKET_DIR + "/ganeti-master" 156 157 NODED = "ganeti-noded" 158 CONFD = "ganeti-confd" 159 RAPI = "ganeti-rapi" 160 MASTERD = "ganeti-masterd" 161 # used in the ganeti-nbma project 162 NLD = "ganeti-nld" 163 164 DAEMONS_PORTS = { 165 # daemon-name: ("proto", "default-port") 166 NODED: ("tcp", 1811), 167 CONFD: ("udp", 1814), 168 RAPI: ("tcp", 5080), 169 "ssh": ("tcp", 22), 170 # used in the ganeti-nbma project 171 NLD: ("udp", 1816), 172 } 173 DEFAULT_NODED_PORT = DAEMONS_PORTS[NODED][1] 174 DEFAULT_CONFD_PORT = DAEMONS_PORTS[CONFD][1] 175 DEFAULT_RAPI_PORT = DAEMONS_PORTS[RAPI][1] 176 # used in the ganeti-nbma project 177 DEFAULT_NLD_PORT = DAEMONS_PORTS[NLD][1] 178 179 FIRST_DRBD_PORT = 11000 180 LAST_DRBD_PORT = 14999 181 MASTER_SCRIPT = "ganeti-master" 182 183 LOG_DIR = _autoconf.LOCALSTATEDIR + "/log/ganeti/" 184 DAEMONS_LOGFILES = { 185 # "daemon-name": "logfile" 186 NODED: LOG_DIR + "node-daemon.log", 187 CONFD: LOG_DIR + "conf-daemon.log", 188 RAPI: LOG_DIR + "rapi-daemon.log", 189 MASTERD: LOG_DIR + "master-daemon.log", 190 # used in the ganeti-nbma project 191 NLD: LOG_DIR + "nl-daemon.log", 192 } 193 194 LOG_OS_DIR = LOG_DIR + "os" 195 LOG_WATCHER = LOG_DIR + "watcher.log" 196 LOG_COMMANDS = LOG_DIR + "commands.log" 197 LOG_BURNIN = LOG_DIR + "burnin.log" 198 LOG_SETUP_SSH = LOG_DIR + "setup-ssh.log" 199 200 DEV_CONSOLE = "/dev/console" 201 202 PROC_MOUNTS = "/proc/mounts" 203 204 # Local UniX Interface related constants 205 LUXI_EOM = "\3" 206 LUXI_VERSION = CONFIG_VERSION 207 208 # one of 'no', 'yes', 'only' 209 SYSLOG_USAGE = _autoconf.SYSLOG_USAGE 210 SYSLOG_NO = "no" 211 SYSLOG_YES = "yes" 212 SYSLOG_ONLY = "only" 213 SYSLOG_SOCKET = "/dev/log" 214 215 OS_SEARCH_PATH = _autoconf.OS_SEARCH_PATH 216 EXPORT_DIR = _autoconf.EXPORT_DIR 217 218 EXPORT_CONF_FILE = "config.ini" 219 220 XEN_BOOTLOADER = _autoconf.XEN_BOOTLOADER 221 XEN_KERNEL = _autoconf.XEN_KERNEL 222 XEN_INITRD = _autoconf.XEN_INITRD 223 224 KVM_PATH = _autoconf.KVM_PATH 225 SOCAT_PATH = _autoconf.SOCAT_PATH 226 SOCAT_USE_ESCAPE = _autoconf.SOCAT_USE_ESCAPE 227 SOCAT_USE_COMPRESS = _autoconf.SOCAT_USE_COMPRESS 228 SOCAT_ESCAPE_CODE = "0x1d" 229 230 #: Console as SSH command 231 CONS_SSH = "ssh" 232 233 #: Console as VNC server 234 CONS_VNC = "vnc" 235 236 #: Display a message for console access 237 CONS_MESSAGE = "msg" 238 239 #: All console types 240 CONS_ALL = frozenset([CONS_SSH, CONS_VNC, CONS_MESSAGE]) 241 242 # For RSA keys more bits are better, but they also make operations more 243 # expensive. NIST SP 800-131 recommends a minimum of 2048 bits from the year 244 # 2010 on. 245 RSA_KEY_BITS = 2048 246 247 # Ciphers allowed for SSL connections. For the format, see ciphers(1). A better 248 # way to disable ciphers would be to use the exclamation mark (!), but socat 249 # versions below 1.5 can't parse exclamation marks in options properly. When 250 # modifying the ciphers, ensure not to accidentially add something after it's 251 # been removed. Use the "openssl" utility to check the allowed ciphers, e.g. 252 # "openssl ciphers -v HIGH:-DES". 253 OPENSSL_CIPHERS = "HIGH:-DES:-3DES:-EXPORT:-ADH" 254 255 # Digest used to sign certificates ("openssl x509" uses SHA1 by default) 256 X509_CERT_SIGN_DIGEST = "SHA1" 257 258 # Default validity of certificates in days 259 X509_CERT_DEFAULT_VALIDITY = 365 * 5 260 261 # commonName (CN) used in certificates 262 X509_CERT_CN = "ganeti.example.com" 263 264 X509_CERT_SIGNATURE_HEADER = "X-Ganeti-Signature" 265 266 IMPORT_EXPORT_DAEMON = _autoconf.PKGLIBDIR + "/import-export" 267 268 # Import/export daemon mode 269 IEM_IMPORT = "import" 270 IEM_EXPORT = "export" 271 272 # Import/export transport compression 273 IEC_NONE = "none" 274 IEC_GZIP = "gzip" 275 IEC_ALL = frozenset([ 276 IEC_NONE, 277 IEC_GZIP, 278 ]) 279 280 IE_CUSTOM_SIZE = "fd" 281 282 IE_MAGIC_RE = re.compile(r"^[-_.a-zA-Z0-9]{5,100}$") 283 284 # Import/export I/O 285 # Direct file I/O, equivalent to a shell's I/O redirection using '<' or '>' 286 IEIO_FILE = "file" 287 # Raw block device I/O using "dd" 288 IEIO_RAW_DISK = "raw" 289 # OS definition import/export script 290 IEIO_SCRIPT = "script" 291 292 VALUE_DEFAULT = "default" 293 VALUE_AUTO = "auto" 294 VALUE_GENERATE = "generate" 295 VALUE_NONE = "none" 296 VALUE_TRUE = "true" 297 VALUE_FALSE = "false" 298 299 # External script validation mask 300 EXT_PLUGIN_MASK = re.compile("^[a-zA-Z0-9_-]+$") 301 302 # hooks-related constants 303 HOOKS_BASE_DIR = CONF_DIR + "/hooks" 304 HOOKS_PHASE_PRE = "pre" 305 HOOKS_PHASE_POST = "post" 306 HOOKS_NAME_CFGUPDATE = "config-update" 307 HOOKS_NAME_WATCHER = "watcher" 308 HOOKS_VERSION = 2 309 310 # hooks subject type (what object type does the LU deal with) 311 HTYPE_CLUSTER = "CLUSTER" 312 HTYPE_NODE = "NODE" 313 HTYPE_GROUP = "GROUP" 314 HTYPE_INSTANCE = "INSTANCE" 315 316 HKR_SKIP = 0 317 HKR_FAIL = 1 318 HKR_SUCCESS = 2 319 320 # Storage types 321 ST_FILE = "file" 322 ST_LVM_PV = "lvm-pv" 323 ST_LVM_VG = "lvm-vg" 324 325 # Storage fields 326 # first two are valid in LU context only, not passed to backend 327 SF_NODE = "node" 328 SF_TYPE = "type" 329 # and the rest are valid in backend 330 SF_NAME = "name" 331 SF_SIZE = "size" 332 SF_FREE = "free" 333 SF_USED = "used" 334 SF_ALLOCATABLE = "allocatable" 335 336 # Storage operations 337 SO_FIX_CONSISTENCY = "fix-consistency" 338 339 # Available fields per storage type 340 VALID_STORAGE_FIELDS = frozenset([SF_NAME, SF_TYPE, SF_SIZE, 341 SF_USED, SF_FREE, SF_ALLOCATABLE]) 342 343 VALID_STORAGE_TYPES = frozenset([ST_FILE, ST_LVM_PV, ST_LVM_VG]) 344 345 MODIFIABLE_STORAGE_FIELDS = { 346 ST_LVM_PV: frozenset([SF_ALLOCATABLE]), 347 } 348 349 VALID_STORAGE_OPERATIONS = { 350 ST_LVM_VG: frozenset([SO_FIX_CONSISTENCY]), 351 } 352 353 # Local disk status 354 # Note: Code depends on LDS_OKAY < LDS_UNKNOWN < LDS_FAULTY 355 (LDS_OKAY, 356 LDS_UNKNOWN, 357 LDS_FAULTY) = range(1, 4) 358 359 # disk template types 360 DT_DISKLESS = "diskless" 361 DT_PLAIN = "plain" 362 DT_DRBD8 = "drbd" 363 DT_FILE = "file" 364 365 # the set of network-mirrored disk templates 366 DTS_NET_MIRROR = frozenset([DT_DRBD8]) 367 368 # the set of non-lvm-based disk templates 369 DTS_NOT_LVM = frozenset([DT_DISKLESS, DT_FILE]) 370 371 # the set of disk templates which can be grown 372 DTS_GROWABLE = frozenset([DT_PLAIN, DT_DRBD8, DT_FILE]) 373 374 # the set of disk templates that allow adoption 375 DTS_MAY_ADOPT = frozenset([DT_PLAIN]) 376 377 # logical disk types 378 LD_LV = "lvm" 379 LD_DRBD8 = "drbd8" 380 LD_FILE = "file" 381 LDS_BLOCK = frozenset([LD_LV, LD_DRBD8]) 382 383 # drbd constants 384 DRBD_HMAC_ALG = "md5" 385 DRBD_NET_PROTOCOL = "C" 386 DRBD_BARRIERS = _autoconf.DRBD_BARRIERS 387 388 # file backend driver 389 FD_LOOP = "loop" 390 FD_BLKTAP = "blktap" 391 392 # the set of drbd-like disk types 393 LDS_DRBD = frozenset([LD_DRBD8]) 394 395 # disk access mode 396 DISK_RDONLY = "ro" 397 DISK_RDWR = "rw" 398 DISK_ACCESS_SET = frozenset([DISK_RDONLY, DISK_RDWR]) 399 400 # disk replacement mode 401 REPLACE_DISK_PRI = "replace_on_primary" # replace disks on primary 402 REPLACE_DISK_SEC = "replace_on_secondary" # replace disks on secondary 403 REPLACE_DISK_CHG = "replace_new_secondary" # change secondary node 404 REPLACE_DISK_AUTO = "replace_auto" 405 REPLACE_MODES = frozenset([ 406 REPLACE_DISK_PRI, 407 REPLACE_DISK_SEC, 408 REPLACE_DISK_CHG, 409 REPLACE_DISK_AUTO, 410 ]) 411 412 # Instance export mode 413 EXPORT_MODE_LOCAL = "local" 414 EXPORT_MODE_REMOTE = "remote" 415 EXPORT_MODES = frozenset([ 416 EXPORT_MODE_LOCAL, 417 EXPORT_MODE_REMOTE, 418 ]) 419 420 # Lock recalculate mode 421 LOCKS_REPLACE = 'replace' 422 LOCKS_APPEND = 'append' 423 424 # Lock timeout (sum) before we should go into blocking acquire (still 425 # can be reset by priority change); computed as max time (10 hours) 426 # before we should actually go into blocking acquire given that we 427 # start from default priority level; in seconds 428 LOCK_ATTEMPTS_TIMEOUT = 10 * 3600 / 20.0 429 LOCK_ATTEMPTS_MAXWAIT = 15.0 430 LOCK_ATTEMPTS_MINWAIT = 1.0 431 432 # instance creation modes 433 INSTANCE_CREATE = "create" 434 INSTANCE_IMPORT = "import" 435 INSTANCE_REMOTE_IMPORT = "remote-import" 436 INSTANCE_CREATE_MODES = frozenset([ 437 INSTANCE_CREATE, 438 INSTANCE_IMPORT, 439 INSTANCE_REMOTE_IMPORT, 440 ]) 441 442 # Remote import/export handshake message and version 443 RIE_VERSION = 0 444 RIE_HANDSHAKE = "Hi, I'm Ganeti" 445 446 # Remote import/export certificate validity in seconds 447 RIE_CERT_VALIDITY = 24 * 60 * 60 448 449 # Overall timeout for establishing connection 450 RIE_CONNECT_TIMEOUT = 180 451 452 # Export only: how long to wait per connection attempt (seconds) 453 RIE_CONNECT_ATTEMPT_TIMEOUT = 20 454 455 # Export only: number of attempts to connect 456 RIE_CONNECT_RETRIES = 10 457 458 #: Give child process up to 5 seconds to exit after sending a signal 459 CHILD_LINGER_TIMEOUT = 5.0 460 461 DISK_TEMPLATES = frozenset([DT_DISKLESS, DT_PLAIN, 462 DT_DRBD8, DT_FILE]) 463 464 FILE_DRIVER = frozenset([FD_LOOP, FD_BLKTAP]) 465 466 # import/export config options 467 INISECT_EXP = "export" 468 INISECT_INS = "instance" 469 INISECT_HYP = "hypervisor" 470 INISECT_BEP = "backend" 471 INISECT_OSP = "os" 472 473 # dynamic device modification 474 DDM_ADD = "add" 475 DDM_REMOVE = "remove" 476 DDMS_VALUES = frozenset([DDM_ADD, DDM_REMOVE]) 477 478 # common exit codes 479 EXIT_SUCCESS = 0 480 EXIT_FAILURE = 1 481 EXIT_NOTCLUSTER = 5 482 EXIT_NOTMASTER = 11 483 EXIT_NODESETUP_ERROR = 12 484 EXIT_CONFIRMATION = 13 # need user confirmation 485 486 #: Exit code for query operations with unknown fields 487 EXIT_UNKNOWN_FIELD = 14 488 489 # tags 490 TAG_CLUSTER = "cluster" 491 TAG_NODE = "node" 492 TAG_INSTANCE = "instance" 493 VALID_TAG_TYPES = frozenset([ 494 TAG_CLUSTER, 495 TAG_NODE, 496 TAG_INSTANCE, 497 ]) 498 MAX_TAG_LEN = 128 499 MAX_TAGS_PER_OBJ = 4096 500 501 # others 502 DEFAULT_BRIDGE = "xen-br0" 503 SYNC_SPEED = 60 * 1024 504 IP4_ADDRESS_LOCALHOST = "127.0.0.1" 505 IP4_ADDRESS_ANY = "0.0.0.0" 506 IP6_ADDRESS_LOCALHOST = "::1" 507 IP6_ADDRESS_ANY = "::" 508 IP4_VERSION = 4 509 IP6_VERSION = 6 510 TCP_PING_TIMEOUT = 10 511 GANETI_RUNAS = "root" 512 DEFAULT_VG = "xenvg" 513 DEFAULT_DRBD_HELPER = "/bin/true" 514 MIN_VG_SIZE = 20480 515 DEFAULT_MAC_PREFIX = "aa:00:00" 516 LVM_STRIPECOUNT = _autoconf.LVM_STRIPECOUNT 517 # default maximum instance wait time, in seconds. 518 DEFAULT_SHUTDOWN_TIMEOUT = 120 519 NODE_MAX_CLOCK_SKEW = 150 520 # Time for an intra-cluster disk transfer to wait for a connection 521 DISK_TRANSFER_CONNECT_TIMEOUT = 60 522 # Disk index separator 523 DISK_SEPARATOR = _autoconf.DISK_SEPARATOR 524 525 # runparts results 526 (RUNPARTS_SKIP, 527 RUNPARTS_RUN, 528 RUNPARTS_ERR) = range(3) 529 530 RUNPARTS_STATUS = frozenset([RUNPARTS_SKIP, RUNPARTS_RUN, RUNPARTS_ERR]) 531 532 # RPC constants 533 (RPC_ENCODING_NONE, 534 RPC_ENCODING_ZLIB_BASE64) = range(2) 535 536 # os related constants 537 OS_SCRIPT_CREATE = 'create' 538 OS_SCRIPT_IMPORT = 'import' 539 OS_SCRIPT_EXPORT = 'export' 540 OS_SCRIPT_RENAME = 'rename' 541 OS_SCRIPT_VERIFY = 'verify' 542 OS_SCRIPTS = frozenset([OS_SCRIPT_CREATE, OS_SCRIPT_IMPORT, 543 OS_SCRIPT_EXPORT, OS_SCRIPT_RENAME, 544 OS_SCRIPT_VERIFY]) 545 546 OS_API_FILE = 'ganeti_api_version' 547 OS_VARIANTS_FILE = 'variants.list' 548 OS_PARAMETERS_FILE = 'parameters.list' 549 550 OS_VALIDATE_PARAMETERS = 'parameters' 551 OS_VALIDATE_CALLS = frozenset([OS_VALIDATE_PARAMETERS]) 552 553 # ssh constants 554 SSH_CONFIG_DIR = _autoconf.SSH_CONFIG_DIR 555 SSH_HOST_DSA_PRIV = SSH_CONFIG_DIR + "/ssh_host_dsa_key" 556 SSH_HOST_DSA_PUB = SSH_HOST_DSA_PRIV + ".pub" 557 SSH_HOST_RSA_PRIV = SSH_CONFIG_DIR + "/ssh_host_rsa_key" 558 SSH_HOST_RSA_PUB = SSH_HOST_RSA_PRIV + ".pub" 559 SSH = "ssh" 560 SCP = "scp" 561 562 # reboot types 563 INSTANCE_REBOOT_SOFT = "soft" 564 INSTANCE_REBOOT_HARD = "hard" 565 INSTANCE_REBOOT_FULL = "full" 566 567 REBOOT_TYPES = frozenset([INSTANCE_REBOOT_SOFT, 568 INSTANCE_REBOOT_HARD, 569 INSTANCE_REBOOT_FULL]) 570 571 VTYPE_STRING = 'string' 572 VTYPE_MAYBE_STRING = "maybe-string" 573 VTYPE_BOOL = 'bool' 574 VTYPE_SIZE = 'size' # size, in MiBs 575 VTYPE_INT = 'int' 576 ENFORCEABLE_TYPES = frozenset([ 577 VTYPE_STRING, 578 VTYPE_MAYBE_STRING, 579 VTYPE_BOOL, 580 VTYPE_SIZE, 581 VTYPE_INT, 582 ]) 583 584 # HV parameter names (global namespace) 585 HV_BOOT_ORDER = "boot_order" 586 HV_CDROM_IMAGE_PATH = "cdrom_image_path" 587 HV_KVM_CDROM2_IMAGE_PATH = "cdrom2_image_path" 588 HV_KVM_FLOPPY_IMAGE_PATH = "floppy_image_path" 589 HV_NIC_TYPE = "nic_type" 590 HV_DISK_TYPE = "disk_type" 591 HV_KVM_CDROM_DISK_TYPE = "cdrom_disk_type" 592 HV_VNC_BIND_ADDRESS = "vnc_bind_address" 593 HV_VNC_PASSWORD_FILE = "vnc_password_file" 594 HV_VNC_TLS = "vnc_tls" 595 HV_VNC_X509 = "vnc_x509_path" 596 HV_VNC_X509_VERIFY = "vnc_x509_verify" 597 HV_ACPI = "acpi" 598 HV_PAE = "pae" 599 HV_USE_BOOTLOADER = "use_bootloader" 600 HV_BOOTLOADER_ARGS = "bootloader_args" 601 HV_BOOTLOADER_PATH = "bootloader_path" 602 HV_KERNEL_ARGS = "kernel_args" 603 HV_KERNEL_PATH = "kernel_path" 604 HV_INITRD_PATH = "initrd_path" 605 HV_ROOT_PATH = "root_path" 606 HV_SERIAL_CONSOLE = "serial_console" 607 HV_USB_MOUSE = "usb_mouse" 608 HV_DEVICE_MODEL = "device_model" 609 HV_INIT_SCRIPT = "init_script" 610 HV_MIGRATION_PORT = "migration_port" 611 HV_MIGRATION_BANDWIDTH = "migration_bandwidth" 612 HV_MIGRATION_DOWNTIME = "migration_downtime" 613 HV_MIGRATION_MODE = "migration_mode" 614 HV_USE_LOCALTIME = "use_localtime" 615 HV_DISK_CACHE = "disk_cache" 616 HV_SECURITY_MODEL = "security_model" 617 HV_SECURITY_DOMAIN = "security_domain" 618 HV_KVM_FLAG = "kvm_flag" 619 HV_VHOST_NET = "vhost_net" 620 HV_KVM_USE_CHROOT = "use_chroot" 621 HV_CPU_MASK = "cpu_mask" 622 HV_MEM_PATH = "mem_path" 623 HV_BLOCKDEV_PREFIX = "blockdev_prefix" 624 625 HVS_PARAMETER_TYPES = { 626 HV_BOOT_ORDER: VTYPE_STRING, 627 HV_KVM_FLOPPY_IMAGE_PATH: VTYPE_STRING, 628 HV_CDROM_IMAGE_PATH: VTYPE_STRING, 629 HV_KVM_CDROM2_IMAGE_PATH: VTYPE_STRING, 630 HV_NIC_TYPE: VTYPE_STRING, 631 HV_DISK_TYPE: VTYPE_STRING, 632 HV_KVM_CDROM_DISK_TYPE: VTYPE_STRING, 633 HV_VNC_PASSWORD_FILE: VTYPE_STRING, 634 HV_VNC_BIND_ADDRESS: VTYPE_STRING, 635 HV_VNC_TLS: VTYPE_BOOL, 636 HV_VNC_X509: VTYPE_STRING, 637 HV_VNC_X509_VERIFY: VTYPE_BOOL, 638 HV_ACPI: VTYPE_BOOL, 639 HV_PAE: VTYPE_BOOL, 640 HV_USE_BOOTLOADER: VTYPE_BOOL, 641 HV_BOOTLOADER_PATH: VTYPE_STRING, 642 HV_BOOTLOADER_ARGS: VTYPE_STRING, 643 HV_KERNEL_PATH: VTYPE_STRING, 644 HV_KERNEL_ARGS: VTYPE_STRING, 645 HV_INITRD_PATH: VTYPE_STRING, 646 HV_ROOT_PATH: VTYPE_MAYBE_STRING, 647 HV_SERIAL_CONSOLE: VTYPE_BOOL, 648 HV_USB_MOUSE: VTYPE_STRING, 649 HV_DEVICE_MODEL: VTYPE_STRING, 650 HV_INIT_SCRIPT: VTYPE_STRING, 651 HV_MIGRATION_PORT: VTYPE_INT, 652 HV_MIGRATION_BANDWIDTH: VTYPE_INT, 653 HV_MIGRATION_DOWNTIME: VTYPE_INT, 654 HV_MIGRATION_MODE: VTYPE_STRING, 655 HV_USE_LOCALTIME: VTYPE_BOOL, 656 HV_DISK_CACHE: VTYPE_STRING, 657 HV_SECURITY_MODEL: VTYPE_STRING, 658 HV_SECURITY_DOMAIN: VTYPE_STRING, 659 HV_KVM_FLAG: VTYPE_STRING, 660 HV_VHOST_NET: VTYPE_BOOL, 661 HV_KVM_USE_CHROOT: VTYPE_BOOL, 662 HV_CPU_MASK: VTYPE_STRING, 663 HV_MEM_PATH: VTYPE_STRING, 664 HV_BLOCKDEV_PREFIX: VTYPE_STRING, 665 } 666 667 HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys()) 668 669 # Backend parameter names 670 BE_MEMORY = "memory" 671 BE_VCPUS = "vcpus" 672 BE_AUTO_BALANCE = "auto_balance" 673 674 BES_PARAMETER_TYPES = { 675 BE_MEMORY: VTYPE_SIZE, 676 BE_VCPUS: VTYPE_INT, 677 BE_AUTO_BALANCE: VTYPE_BOOL, 678 } 679 680 BES_PARAMETERS = frozenset(BES_PARAMETER_TYPES.keys()) 681 682 # Node parameter names 683 ND_OOB_PROGRAM = "oob_program" 684 685 NDS_PARAMETER_TYPES = { 686 ND_OOB_PROGRAM: VTYPE_MAYBE_STRING, 687 } 688 689 NDS_PARAMETERS = frozenset(NDS_PARAMETER_TYPES.keys()) 690 691 # OOB supported commands 692 OOB_POWER_ON = "power-on" 693 OOB_POWER_OFF = "power-off" 694 OOB_POWER_CYCLE = "power-cycle" 695 OOB_POWER_STATUS = "power-status" 696 OOB_HEALTH = "health" 697 698 OOB_COMMANDS = frozenset([OOB_POWER_ON, OOB_POWER_OFF, OOB_POWER_CYCLE, 699 OOB_POWER_STATUS, OOB_HEALTH]) 700 701 OOB_POWER_STATUS_POWERED = "powered" 702 703 OOB_TIMEOUT = 60 # 60 seconds 704 705 OOB_STATUS_OK = "OK" 706 OOB_STATUS_WARNING = "WARNING" 707 OOB_STATUS_CRITICAL = "CRITICAL" 708 OOB_STATUS_UNKNOWN = "UNKNOWN" 709 710 OOB_STATUSES = frozenset([ 711 OOB_STATUS_OK, 712 OOB_STATUS_WARNING, 713 OOB_STATUS_CRITICAL, 714 OOB_STATUS_UNKNOWN, 715 ]) 716 717 # Instance Parameters Profile 718 PP_DEFAULT = "default" 719 720 NIC_MODE = "mode" 721 NIC_LINK = "link" 722 723 NIC_MODE_BRIDGED = "bridged" 724 NIC_MODE_ROUTED = "routed" 725 726 NIC_VALID_MODES = frozenset([NIC_MODE_BRIDGED, NIC_MODE_ROUTED]) 727 728 NICS_PARAMETER_TYPES = { 729 NIC_MODE: VTYPE_STRING, 730 NIC_LINK: VTYPE_STRING, 731 } 732 733 NICS_PARAMETERS = frozenset(NICS_PARAMETER_TYPES.keys()) 734 735 IDISK_SIZE = "size" 736 IDISK_MODE = "mode" 737 IDISK_ADOPT = "adopt" 738 IDISK_VG = "vg" 739 IDISK_METAVG = "metavg" 740 IDISK_PARAMS_TYPES = { 741 IDISK_SIZE: VTYPE_SIZE, 742 IDISK_MODE: VTYPE_STRING, 743 IDISK_ADOPT: VTYPE_STRING, 744 IDISK_VG: VTYPE_STRING, 745 IDISK_METAVG: VTYPE_STRING, 746 } 747 IDISK_PARAMS = frozenset(IDISK_PARAMS_TYPES.keys()) 748 749 INIC_MAC = "mac" 750 INIC_IP = "ip" 751 INIC_MODE = "mode" 752 INIC_LINK = "link" 753 INIC_BRIDGE = "bridge" 754 INIC_PARAMS_TYPES = { 755 INIC_BRIDGE: VTYPE_STRING, 756 INIC_IP: VTYPE_MAYBE_STRING, 757 INIC_LINK: VTYPE_STRING, 758 INIC_MAC: VTYPE_STRING, 759 INIC_MODE: VTYPE_STRING, 760 } 761 INIC_PARAMS = frozenset(INIC_PARAMS_TYPES.keys()) 762 763 # Hypervisor constants 764 HT_XEN_PVM = "xen-pvm" 765 HT_FAKE = "fake" 766 HT_XEN_HVM = "xen-hvm" 767 HT_KVM = "kvm" 768 HT_CHROOT = "chroot" 769 HT_LXC = "lxc" 770 HYPER_TYPES = frozenset([ 771 HT_XEN_PVM, 772 HT_FAKE, 773 HT_XEN_HVM, 774 HT_KVM, 775 HT_CHROOT, 776 HT_LXC, 777 ]) 778 HTS_REQ_PORT = frozenset([HT_XEN_HVM, HT_KVM]) 779 780 VNC_BASE_PORT = 5900 781 VNC_PASSWORD_FILE = CONF_DIR + "/vnc-cluster-password" 782 VNC_DEFAULT_BIND_ADDRESS = IP4_ADDRESS_ANY 783 784 # NIC types 785 HT_NIC_RTL8139 = "rtl8139" 786 HT_NIC_NE2K_PCI = "ne2k_pci" 787 HT_NIC_NE2K_ISA = "ne2k_isa" 788 HT_NIC_I82551 = "i82551" 789 HT_NIC_I85557B = "i82557b" 790 HT_NIC_I8259ER = "i82559er" 791 HT_NIC_PCNET = "pcnet" 792 HT_NIC_E1000 = "e1000" 793 HT_NIC_PARAVIRTUAL = HT_DISK_PARAVIRTUAL = "paravirtual" 794 795 HT_HVM_VALID_NIC_TYPES = frozenset([HT_NIC_RTL8139, HT_NIC_NE2K_PCI, 796 HT_NIC_E1000, HT_NIC_NE2K_ISA, 797 HT_NIC_PARAVIRTUAL]) 798 HT_KVM_VALID_NIC_TYPES = frozenset([HT_NIC_RTL8139, HT_NIC_NE2K_PCI, 799 HT_NIC_NE2K_ISA, HT_NIC_I82551, 800 HT_NIC_I85557B, HT_NIC_I8259ER, 801 HT_NIC_PCNET, HT_NIC_E1000, 802 HT_NIC_PARAVIRTUAL]) 803 # Disk types 804 HT_DISK_IOEMU = "ioemu" 805 HT_DISK_IDE = "ide" 806 HT_DISK_SCSI = "scsi" 807 HT_DISK_SD = "sd" 808 HT_DISK_MTD = "mtd" 809 HT_DISK_PFLASH = "pflash" 810 811 HT_CACHE_DEFAULT = "default" 812 HT_CACHE_NONE = "none" 813 HT_CACHE_WTHROUGH = "writethrough" 814 HT_CACHE_WBACK = "writeback" 815 HT_VALID_CACHE_TYPES = frozenset([HT_CACHE_DEFAULT, 816 HT_CACHE_NONE, 817 HT_CACHE_WTHROUGH, 818 HT_CACHE_WBACK]) 819 820 HT_HVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IOEMU]) 821 HT_KVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IDE, 822 HT_DISK_SCSI, HT_DISK_SD, HT_DISK_MTD, 823 HT_DISK_PFLASH]) 824 825 # Mouse types: 826 HT_MOUSE_MOUSE = "mouse" 827 HT_MOUSE_TABLET = "tablet" 828 829 HT_KVM_VALID_MOUSE_TYPES = frozenset([HT_MOUSE_MOUSE, HT_MOUSE_TABLET]) 830 831 # Boot order 832 HT_BO_FLOPPY = "floppy" 833 HT_BO_CDROM = "cdrom" 834 HT_BO_DISK = "disk" 835 HT_BO_NETWORK = "network" 836 837 HT_KVM_VALID_BO_TYPES = frozenset([HT_BO_FLOPPY, HT_BO_CDROM, 838 HT_BO_DISK, HT_BO_NETWORK]) 839 840 # Security models 841 HT_SM_NONE = "none" 842 HT_SM_USER = "user" 843 HT_SM_POOL = "pool" 844 845 HT_KVM_VALID_SM_TYPES = frozenset([HT_SM_NONE, HT_SM_USER, HT_SM_POOL]) 846 847 # Kvm flag values 848 HT_KVM_ENABLED = "enabled" 849 HT_KVM_DISABLED = "disabled" 850 851 HT_KVM_FLAG_VALUES = frozenset([HT_KVM_ENABLED, HT_KVM_DISABLED]) 852 853 # Migration type 854 HT_MIGRATION_LIVE = "live" 855 HT_MIGRATION_NONLIVE = "non-live" 856 HT_MIGRATION_MODES = frozenset([HT_MIGRATION_LIVE, HT_MIGRATION_NONLIVE]) 857 858 # Cluster Verify steps 859 VERIFY_NPLUSONE_MEM = 'nplusone_mem' 860 VERIFY_OPTIONAL_CHECKS = frozenset([VERIFY_NPLUSONE_MEM]) 861 862 # Node verify constants 863 NV_DRBDHELPER = "drbd-helper" 864 NV_DRBDLIST = "drbd-list" 865 NV_FILELIST = "filelist" 866 NV_HVINFO = "hvinfo" 867 NV_HYPERVISOR = "hypervisor" 868 NV_HVPARAMS = "hvparms" 869 NV_INSTANCELIST = "instancelist" 870 NV_LVLIST = "lvlist" 871 NV_MASTERIP = "master-ip" 872 NV_NODELIST = "nodelist" 873 NV_NODENETTEST = "node-net-test" 874 NV_NODESETUP = "nodesetup" 875 NV_OSLIST = "oslist" 876 NV_PVLIST = "pvlist" 877 NV_TIME = "time" 878 NV_VERSION = "version" 879 NV_VGLIST = "vglist" 880 NV_VMNODES = "vmnodes" 881 NV_OOB_PATHS = "oob-paths" 882 NV_BRIDGES = "bridges" 883 884 # SSL certificate check constants (in days) 885 SSL_CERT_EXPIRATION_WARN = 30 886 SSL_CERT_EXPIRATION_ERROR = 7 887 888 # Allocator framework constants 889 IALLOCATOR_VERSION = 2 890 IALLOCATOR_DIR_IN = "in" 891 IALLOCATOR_DIR_OUT = "out" 892 VALID_IALLOCATOR_DIRECTIONS = frozenset([ 893 IALLOCATOR_DIR_IN, 894 IALLOCATOR_DIR_OUT, 895 ]) 896 IALLOCATOR_MODE_ALLOC = "allocate" 897 IALLOCATOR_MODE_RELOC = "relocate" 898 IALLOCATOR_MODE_MEVAC = "multi-evacuate" 899 VALID_IALLOCATOR_MODES = frozenset([ 900 IALLOCATOR_MODE_ALLOC, 901 IALLOCATOR_MODE_RELOC, 902 IALLOCATOR_MODE_MEVAC, 903 ]) 904 IALLOCATOR_SEARCH_PATH = _autoconf.IALLOCATOR_SEARCH_PATH 905 906 # Job queue 907 JOB_QUEUE_VERSION = 1 908 JOB_QUEUE_LOCK_FILE = QUEUE_DIR + "/lock" 909 JOB_QUEUE_VERSION_FILE = QUEUE_DIR + "/version" 910 JOB_QUEUE_SERIAL_FILE = QUEUE_DIR + "/serial" 911 JOB_QUEUE_ARCHIVE_DIR = QUEUE_DIR + "/archive" 912 JOB_QUEUE_DRAIN_FILE = QUEUE_DIR + "/drain" 913 JOB_QUEUE_SIZE_HARD_LIMIT = 5000 914 JOB_QUEUE_DIRS = [QUEUE_DIR, JOB_QUEUE_ARCHIVE_DIR] 915 JOB_QUEUE_DIRS_MODE = SECURE_DIR_MODE 916 917 JOB_ID_TEMPLATE = r"\d+" 918 919 # unchanged job return 920 JOB_NOTCHANGED = "nochange" 921 922 # Job status 923 JOB_STATUS_QUEUED = "queued" 924 JOB_STATUS_WAITLOCK = "waiting" 925 JOB_STATUS_CANCELING = "canceling" 926 JOB_STATUS_RUNNING = "running" 927 JOB_STATUS_CANCELED = "canceled" 928 JOB_STATUS_SUCCESS = "success" 929 JOB_STATUS_ERROR = "error" 930 JOBS_FINALIZED = frozenset([ 931 JOB_STATUS_CANCELED, 932 JOB_STATUS_SUCCESS, 933 JOB_STATUS_ERROR, 934 ]) 935 JOB_STATUS_ALL = frozenset([ 936 JOB_STATUS_QUEUED, 937 JOB_STATUS_WAITLOCK, 938 JOB_STATUS_CANCELING, 939 JOB_STATUS_RUNNING, 940 ]) | JOBS_FINALIZED 941 942 # OpCode status 943 # not yet finalized 944 OP_STATUS_QUEUED = "queued" 945 OP_STATUS_WAITLOCK = "waiting" 946 OP_STATUS_CANCELING = "canceling" 947 OP_STATUS_RUNNING = "running" 948 # finalized 949 OP_STATUS_CANCELED = "canceled" 950 OP_STATUS_SUCCESS = "success" 951 OP_STATUS_ERROR = "error" 952 OPS_FINALIZED = frozenset([OP_STATUS_CANCELED, 953 OP_STATUS_SUCCESS, 954 OP_STATUS_ERROR]) 955 956 # OpCode priority 957 OP_PRIO_LOWEST = +19 958 OP_PRIO_HIGHEST = -20 959 960 OP_PRIO_LOW = +10 961 OP_PRIO_NORMAL = 0 962 OP_PRIO_HIGH = -10 963 964 OP_PRIO_SUBMIT_VALID = frozenset([ 965 OP_PRIO_LOW, 966 OP_PRIO_NORMAL, 967 OP_PRIO_HIGH, 968 ]) 969 970 OP_PRIO_DEFAULT = OP_PRIO_NORMAL 971 972 # Execution log types 973 ELOG_MESSAGE = "message" 974 ELOG_PROGRESS = "progress" 975 ELOG_REMOTE_IMPORT = "remote-import" 976 ELOG_JQUEUE_TEST = "jqueue-test" 977 978 # /etc/hosts modification 979 ETC_HOSTS_ADD = "add" 980 ETC_HOSTS_REMOVE = "remove" 981 982 # Job queue test 983 JQT_MSGPREFIX = "TESTMSG=" 984 JQT_EXPANDNAMES = "expandnames" 985 JQT_EXEC = "exec" 986 JQT_LOGMSG = "logmsg" 987 JQT_STARTMSG = "startmsg" 988 JQT_ALL = frozenset([ 989 JQT_EXPANDNAMES, 990 JQT_EXEC, 991 JQT_LOGMSG, 992 JQT_STARTMSG, 993 ]) 994 995 # Query resources 996 QR_INSTANCE = "instance" 997 QR_NODE = "node" 998 QR_LOCK = "lock" 999 QR_GROUP = "group" 1000 1001 #: List of resources which can be queried using L{opcodes.OpQuery} 1002 QR_OP_QUERY = frozenset([QR_INSTANCE, QR_NODE, QR_GROUP]) 1003 1004 #: List of resources which can be queried using Local UniX Interface 1005 QR_OP_LUXI = QR_OP_QUERY.union([ 1006 QR_LOCK, 1007 ]) 1008 1009 # Query field types 1010 QFT_UNKNOWN = "unknown" 1011 QFT_TEXT = "text" 1012 QFT_BOOL = "bool" 1013 QFT_NUMBER = "number" 1014 QFT_UNIT = "unit" 1015 QFT_TIMESTAMP = "timestamp" 1016 QFT_OTHER = "other" 1017 1018 #: All query field types 1019 QFT_ALL = frozenset([ 1020 QFT_UNKNOWN, 1021 QFT_TEXT, 1022 QFT_BOOL, 1023 QFT_NUMBER, 1024 QFT_UNIT, 1025 QFT_TIMESTAMP, 1026 QFT_OTHER, 1027 ]) 1028 1029 # Query result field status (don't change or reuse values as they're used by 1030 # clients) 1031 #: Normal field status 1032 RS_NORMAL = 0 1033 #: Unknown field 1034 RS_UNKNOWN = 1 1035 #: No data (e.g. RPC error), can be used instead of L{RS_OFFLINE} 1036 RS_NODATA = 2 1037 #: Value unavailable/unsupported for item; if this field is supported 1038 #: but we cannot get the data for the moment, RS_NODATA or 1039 #: RS_OFFLINE should be used 1040 RS_UNAVAIL = 3 1041 #: Resource marked offline 1042 RS_OFFLINE = 4 1043 1044 RS_ALL = frozenset([ 1045 RS_NORMAL, 1046 RS_UNKNOWN, 1047 RS_NODATA, 1048 RS_UNAVAIL, 1049 RS_OFFLINE, 1050 ]) 1051 1052 #: Dictionary with special field cases and their verbose/terse formatting 1053 RSS_DESCRIPTION = { 1054 RS_UNKNOWN: ("(unknown)", "??"), 1055 RS_NODATA: ("(nodata)", "?"), 1056 RS_OFFLINE: ("(offline)", "*"), 1057 RS_UNAVAIL: ("(unavail)", "-"), 1058 } 1059 1060 # max dynamic devices 1061 MAX_NICS = 8 1062 MAX_DISKS = 16 1063 1064 # SSCONF keys 1065 SS_CLUSTER_NAME = "cluster_name" 1066 SS_CLUSTER_TAGS = "cluster_tags" 1067 SS_FILE_STORAGE_DIR = "file_storage_dir" 1068 SS_MASTER_CANDIDATES = "master_candidates" 1069 SS_MASTER_CANDIDATES_IPS = "master_candidates_ips" 1070 SS_MASTER_IP = "master_ip" 1071 SS_MASTER_NETDEV = "master_netdev" 1072 SS_MASTER_NODE = "master_node" 1073 SS_NODE_LIST = "node_list" 1074 SS_NODE_PRIMARY_IPS = "node_primary_ips" 1075 SS_NODE_SECONDARY_IPS = "node_secondary_ips" 1076 SS_OFFLINE_NODES = "offline_nodes" 1077 SS_ONLINE_NODES = "online_nodes" 1078 SS_PRIMARY_IP_FAMILY = "primary_ip_family" 1079 SS_INSTANCE_LIST = "instance_list" 1080 SS_RELEASE_VERSION = "release_version" 1081 SS_HYPERVISOR_LIST = "hypervisor_list" 1082 SS_MAINTAIN_NODE_HEALTH = "maintain_node_health" 1083 SS_UID_POOL = "uid_pool" 1084 SS_NODEGROUPS = "nodegroups" 1085 1086 # cluster wide default parameters 1087 DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM 1088 1089 HVC_DEFAULTS = { 1090 HT_XEN_PVM: { 1091 HV_USE_BOOTLOADER: False, 1092 HV_BOOTLOADER_PATH: XEN_BOOTLOADER, 1093 HV_BOOTLOADER_ARGS: '', 1094 HV_KERNEL_PATH: "/boot/vmlinuz-2.6-xenU", 1095 HV_INITRD_PATH: '', 1096 HV_ROOT_PATH: '/dev/sda1', 1097 HV_KERNEL_ARGS: 'ro', 1098 HV_MIGRATION_PORT: 8002, 1099 HV_MIGRATION_MODE: HT_MIGRATION_LIVE, 1100 HV_BLOCKDEV_PREFIX: "sd", 1101 }, 1102 HT_XEN_HVM: { 1103 HV_BOOT_ORDER: "cd", 1104 HV_CDROM_IMAGE_PATH: '', 1105 HV_NIC_TYPE: HT_NIC_RTL8139, 1106 HV_DISK_TYPE: HT_DISK_PARAVIRTUAL, 1107 HV_VNC_BIND_ADDRESS: IP4_ADDRESS_ANY, 1108 HV_VNC_PASSWORD_FILE: VNC_PASSWORD_FILE, 1109 HV_ACPI: True, 1110 HV_PAE: True, 1111 HV_KERNEL_PATH: "/usr/lib/xen/boot/hvmloader", 1112 HV_DEVICE_MODEL: "/usr/lib/xen/bin/qemu-dm", 1113 HV_MIGRATION_PORT: 8002, 1114 HV_MIGRATION_MODE: HT_MIGRATION_NONLIVE, 1115 HV_USE_LOCALTIME: False, 1116 HV_BLOCKDEV_PREFIX: "hd", 1117 }, 1118 HT_KVM: { 1119 HV_KERNEL_PATH: "/boot/vmlinuz-2.6-kvmU", 1120 HV_INITRD_PATH: '', 1121 HV_KERNEL_ARGS: 'ro', 1122 HV_ROOT_PATH: '/dev/vda1', 1123 HV_ACPI: True, 1124 HV_SERIAL_CONSOLE: True, 1125 HV_VNC_BIND_ADDRESS: '', 1126 HV_VNC_TLS: False, 1127 HV_VNC_X509: '', 1128 HV_VNC_X509_VERIFY: False, 1129 HV_VNC_PASSWORD_FILE: '', 1130 HV_KVM_FLOPPY_IMAGE_PATH: '', 1131 HV_CDROM_IMAGE_PATH: '', 1132 HV_KVM_CDROM2_IMAGE_PATH: '', 1133 HV_BOOT_ORDER: HT_BO_DISK, 1134 HV_NIC_TYPE: HT_NIC_PARAVIRTUAL, 1135 HV_DISK_TYPE: HT_DISK_PARAVIRTUAL, 1136 HV_KVM_CDROM_DISK_TYPE: '', 1137 HV_USB_MOUSE: '', 1138 HV_MIGRATION_PORT: 8102, 1139 HV_MIGRATION_BANDWIDTH: 32, # MiB/s 1140 HV_MIGRATION_DOWNTIME: 30, # ms 1141 HV_MIGRATION_MODE: HT_MIGRATION_LIVE, 1142 HV_USE_LOCALTIME: False, 1143 HV_DISK_CACHE: HT_CACHE_DEFAULT, 1144 HV_SECURITY_MODEL: HT_SM_NONE, 1145 HV_SECURITY_DOMAIN: '', 1146 HV_KVM_FLAG: "", 1147 HV_VHOST_NET: False, 1148 HV_KVM_USE_CHROOT: False, 1149 HV_MEM_PATH: "", 1150 }, 1151 HT_FAKE: { 1152 }, 1153 HT_CHROOT: { 1154 HV_INIT_SCRIPT: "/ganeti-chroot", 1155 }, 1156 HT_LXC: { 1157 HV_CPU_MASK: "", 1158 }, 1159 } 1160 1161 HVC_GLOBALS = frozenset([ 1162 HV_MIGRATION_PORT, 1163 HV_MIGRATION_BANDWIDTH, 1164 HV_MIGRATION_MODE, 1165 ]) 1166 1167 BEC_DEFAULTS = { 1168 BE_MEMORY: 128, 1169 BE_VCPUS: 1, 1170 BE_AUTO_BALANCE: True, 1171 } 1172 1173 NDC_DEFAULTS = { 1174 ND_OOB_PROGRAM: None, 1175 } 1176 1177 NICC_DEFAULTS = { 1178 NIC_MODE: NIC_MODE_BRIDGED, 1179 NIC_LINK: DEFAULT_BRIDGE, 1180 } 1181 1182 MASTER_POOL_SIZE_DEFAULT = 10 1183 1184 CONFD_PROTOCOL_VERSION = 1 1185 1186 CONFD_REQ_PING = 0 1187 CONFD_REQ_NODE_ROLE_BYNAME = 1 1188 CONFD_REQ_NODE_PIP_BY_INSTANCE_IP = 2 1189 CONFD_REQ_CLUSTER_MASTER = 3 1190 CONFD_REQ_NODE_PIP_LIST = 4 1191 CONFD_REQ_MC_PIP_LIST = 5 1192 CONFD_REQ_INSTANCES_IPS_LIST = 6 1193 1194 # Confd request query fields. These are used to narrow down queries. 1195 # These must be strings rather than integers, because json-encoding 1196 # converts them to strings anyway, as they're used as dict-keys. 1197 CONFD_REQQ_LINK = "0" 1198 CONFD_REQQ_IP = "1" 1199 CONFD_REQQ_IPLIST = "2" 1200 CONFD_REQQ_FIELDS = "3" 1201 1202 CONFD_REQFIELD_NAME = "0" 1203 CONFD_REQFIELD_IP = "1" 1204 CONFD_REQFIELD_MNODE_PIP = "2" 1205 1206 CONFD_REQS = frozenset([ 1207 CONFD_REQ_PING, 1208 CONFD_REQ_NODE_ROLE_BYNAME, 1209 CONFD_REQ_NODE_PIP_BY_INSTANCE_IP, 1210 CONFD_REQ_CLUSTER_MASTER, 1211 CONFD_REQ_NODE_PIP_LIST, 1212 CONFD_REQ_MC_PIP_LIST, 1213 CONFD_REQ_INSTANCES_IPS_LIST, 1214 ]) 1215 1216 CONFD_REPL_STATUS_OK = 0 1217 CONFD_REPL_STATUS_ERROR = 1 1218 CONFD_REPL_STATUS_NOTIMPLEMENTED = 2 1219 1220 CONFD_REPL_STATUSES = frozenset([ 1221 CONFD_REPL_STATUS_OK, 1222 CONFD_REPL_STATUS_ERROR, 1223 CONFD_REPL_STATUS_NOTIMPLEMENTED, 1224 ]) 1225 1226 (CONFD_NODE_ROLE_MASTER, 1227 CONFD_NODE_ROLE_CANDIDATE, 1228 CONFD_NODE_ROLE_OFFLINE, 1229 CONFD_NODE_ROLE_DRAINED, 1230 CONFD_NODE_ROLE_REGULAR, 1231 ) = range(5) 1232 1233 # A few common errors for confd 1234 CONFD_ERROR_UNKNOWN_ENTRY = 1 1235 CONFD_ERROR_INTERNAL = 2 1236 CONFD_ERROR_ARGUMENT = 3 1237 1238 # Each request is "salted" by the current timestamp. 1239 # This constants decides how many seconds of skew to accept. 1240 # TODO: make this a default and allow the value to be more configurable 1241 CONFD_MAX_CLOCK_SKEW = 2 * NODE_MAX_CLOCK_SKEW 1242 1243 # When we haven't reloaded the config for more than this amount of seconds, we 1244 # force a test to see if inotify is betraying us. 1245 CONFD_CONFIG_RELOAD_TIMEOUT = 60 1246 1247 # If we receive more than one update in this amount of seconds, we move to 1248 # polling every RATELIMIT seconds, rather than relying on inotify, to be able 1249 # to serve more requests. 1250 CONFD_CONFIG_RELOAD_RATELIMIT = 2 1251 1252 # Magic number prepended to all confd queries. 1253 # This allows us to distinguish different types of confd protocols and handle 1254 # them. For example by changing this we can move the whole payload to be 1255 # compressed, or move away from json. 1256 CONFD_MAGIC_FOURCC = 'plj0' 1257 1258 # By default a confd request is sent to the minimum between this number and all 1259 # MCs. 6 was chosen because even in the case of a disastrous 50% response rate, 1260 # we should have enough answers to be able to compare more than one. 1261 CONFD_DEFAULT_REQ_COVERAGE = 6 1262 1263 # Timeout in seconds to expire pending query request in the confd client 1264 # library. We don't actually expect any answer more than 10 seconds after we 1265 # sent a request. 1266 CONFD_CLIENT_EXPIRE_TIMEOUT = 10 1267 1268 # Maximum UDP datagram size. 1269 # On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507 1270 # On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487 1271 # (assuming we can't use jumbo frames) 1272 # We just set this to 60K, which should be enough 1273 MAX_UDP_DATA_SIZE = 61440 1274 1275 # User-id pool minimum/maximum acceptable user-ids. 1276 UIDPOOL_UID_MIN = 0 1277 UIDPOOL_UID_MAX = 2**32-1 # Assuming 32 bit user-ids 1278 1279 # Name or path of the pgrep command 1280 PGREP = "pgrep" 1281 1282 # Name of the node group that gets created at cluster init or upgrade 1283 INITIAL_NODE_GROUP_NAME = "default" 1284 1285 # Possible values for NodeGroup.alloc_policy 1286 ALLOC_POLICY_PREFERRED = "preferred" 1287 ALLOC_POLICY_LAST_RESORT = "last_resort" 1288 ALLOC_POLICY_UNALLOCABLE = "unallocable" 1289 VALID_ALLOC_POLICIES = [ 1290 ALLOC_POLICY_PREFERRED, 1291 ALLOC_POLICY_LAST_RESORT, 1292 ALLOC_POLICY_UNALLOCABLE, 1293 ] 1294