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