4 # Copyright (C) 2006, 2007 Google Inc.
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.
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.
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
22 """Module holding different constants."""
24 from ganeti import _autoconf
28 RELEASE_VERSION = _autoconf.PACKAGE_VERSION
31 OS_API_VERSIONS = frozenset([OS_API_V10, OS_API_V15])
36 # Format for CONFIG_VERSION:
37 # 01 03 0123 = 01030123
39 # | | + Configuration version/revision
43 # It stored as an integer. Make sure not to write an octal number.
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
50 def BuildVersion(major, minor, revision):
51 """Calculates int version number from major, minor and revision numbers.
53 Returns: int representing version number
56 assert isinstance(major, int)
57 assert isinstance(minor, int)
58 assert isinstance(revision, int)
59 return (1000000 * major +
64 def SplitVersion(version):
65 """Splits version number stored in an int.
67 Returns: tuple; (major, minor, revision)
70 assert isinstance(version, int)
72 (major, remainder) = divmod(version, 1000000)
73 (minor, revision) = divmod(remainder, 10000)
75 return (major, minor, revision)
78 CONFIG_MAJOR = int(_autoconf.VERSION_MAJOR)
79 CONFIG_MINOR = int(_autoconf.VERSION_MINOR)
81 CONFIG_VERSION = BuildVersion(CONFIG_MAJOR, CONFIG_MINOR, CONFIG_REVISION)
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"
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"
113 MASTER_SOCKET = SOCKET_DIR + "/ganeti-master"
115 NODE_INITD_SCRIPT = SYSCONFDIR + "/init.d/ganeti"
117 NODED = "ganeti-noded"
118 CONFD = "ganeti-confd"
120 MASTERD = "ganeti-masterd"
122 MULTITHREADED_DAEMONS = frozenset([MASTERD])
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),
131 # daemon-name: ("proto", "default-port")
132 NODED: ("tcp", 1811),
133 CONFD: ("udp", 1814),
136 DEFAULT_NODED_PORT = DAEMONS_PORTS[NODED][1]
137 DEFAULT_CONFD_PORT = DAEMONS_PORTS[CONFD][1]
138 DEFAULT_RAPI_PORT = DAEMONS_PORTS[RAPI][1]
140 FIRST_DRBD_PORT = 11000
141 LAST_DRBD_PORT = 14999
142 MASTER_SCRIPT = "ganeti-master"
144 LOG_DIR = _autoconf.LOCALSTATEDIR + "/log/ganeti/"
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",
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"
157 OS_SEARCH_PATH = _autoconf.OS_SEARCH_PATH
158 EXPORT_DIR = _autoconf.EXPORT_DIR
160 EXPORT_CONF_FILE = "config.ini"
162 XEN_BOOTLOADER = _autoconf.XEN_BOOTLOADER
163 XEN_KERNEL = _autoconf.XEN_KERNEL
164 XEN_INITRD = _autoconf.XEN_INITRD
166 KVM_PATH = _autoconf.KVM_PATH
167 SOCAT_PATH = _autoconf.SOCAT_PATH
168 KVM_MIGRATION_PORT = _autoconf.KVM_MIGRATION_PORT
170 VALUE_DEFAULT = "default"
172 VALUE_GENERATE = "generate"
175 VALUE_FALSE = "false"
177 # hooks-related constants
178 HOOKS_BASE_DIR = CONF_DIR + "/hooks"
179 HOOKS_PHASE_PRE = "pre"
180 HOOKS_PHASE_POST = "post"
181 HOOKS_NAME_CFGUPDATE = "config-update"
184 # hooks subject type (what object type does the LU deal with)
185 HTYPE_CLUSTER = "CLUSTER"
187 HTYPE_INSTANCE = "INSTANCE"
203 SF_ALLOCATABLE = "allocatable"
206 SO_FIX_CONSISTENCY = "fix-consistency"
208 # Available fields per storage type
209 VALID_STORAGE_FIELDS = {
210 ST_FILE: frozenset([SF_NAME, SF_USED, SF_FREE]),
211 ST_LVM_PV: frozenset([SF_NAME, SF_SIZE, SF_USED, SF_FREE, SF_ALLOCATABLE]),
212 ST_LVM_VG: frozenset([SF_NAME, SF_SIZE]),
215 MODIFIABLE_STORAGE_FIELDS = {
216 ST_LVM_PV: frozenset([SF_ALLOCATABLE]),
219 VALID_STORAGE_OPERATIONS = {
220 ST_LVM_VG: frozenset([SO_FIX_CONSISTENCY]),
224 # Note: Code depends on LDS_OKAY < LDS_UNKNOWN < LDS_FAULTY
227 LDS_FAULTY) = range(1, 4)
229 # disk template types
230 DT_DISKLESS = "diskless"
235 # the set of network-mirrored disk templates
236 DTS_NET_MIRROR = frozenset([DT_DRBD8])
238 # the set of non-lvm-based disk templates
239 DTS_NOT_LVM = frozenset([DT_DISKLESS, DT_FILE])
245 LDS_BLOCK = frozenset([LD_LV, LD_DRBD8])
248 DRBD_HMAC_ALG = "md5"
249 DRBD_NET_PROTOCOL = "C"
251 # file backend driver
255 # the set of drbd-like disk types
256 LDS_DRBD = frozenset([LD_DRBD8])
261 DISK_ACCESS_SET = frozenset([DISK_RDONLY, DISK_RDWR])
263 # disk replacement mode
264 REPLACE_DISK_PRI = "replace_on_primary" # replace disks on primary
265 REPLACE_DISK_SEC = "replace_on_secondary" # replace disks on secondary
266 REPLACE_DISK_CHG = "replace_new_secondary" # change secondary node
267 REPLACE_DISK_AUTO = "replace_auto"
269 # lock recalculate mode
270 LOCKS_REPLACE = 'replace'
271 LOCKS_APPEND = 'append'
273 # instance creation modes
274 INSTANCE_CREATE = "create"
275 INSTANCE_IMPORT = "import"
277 DISK_TEMPLATES = frozenset([DT_DISKLESS, DT_PLAIN,
280 FILE_DRIVER = frozenset([FD_LOOP, FD_BLKTAP])
282 # import/export config options
283 INISECT_EXP = "export"
284 INISECT_INS = "instance"
286 # dynamic device modification
289 DDM_REMOVE = 'remove'
296 EXIT_NODESETUP_ERROR = 12
297 EXIT_CONFIRMATION = 13 # need user confirmation
298 EXIT_NOTCANDIDATE = 14
301 TAG_CLUSTER = "cluster"
303 TAG_INSTANCE = "instance"
305 MAX_TAGS_PER_OBJ = 4096
308 DEFAULT_BRIDGE = "xen-br0"
309 SYNC_SPEED = 60 * 1024
310 LOCALHOST_IP_ADDRESS = "127.0.0.1"
311 TCP_PING_TIMEOUT = 10
312 GANETI_RUNAS = "root"
314 BIND_ADDRESS_GLOBAL = "0.0.0.0"
316 DEFAULT_MAC_PREFIX = "aa:00:00"
317 LVM_STRIPECOUNT = _autoconf.LVM_STRIPECOUNT
321 RPC_ENCODING_ZLIB_BASE64) = range(2)
323 # os related constants
324 OS_SCRIPT_CREATE = 'create'
325 OS_SCRIPT_IMPORT = 'import'
326 OS_SCRIPT_EXPORT = 'export'
327 OS_SCRIPT_RENAME = 'rename'
328 OS_SCRIPTS = frozenset([OS_SCRIPT_CREATE, OS_SCRIPT_IMPORT,
329 OS_SCRIPT_EXPORT, OS_SCRIPT_RENAME])
331 OS_API_FILE = 'ganeti_api_version'
334 SSH_INITD_SCRIPT = _autoconf.SSH_INITD_SCRIPT
335 SSH_CONFIG_DIR = "/etc/ssh/"
336 SSH_HOST_DSA_PRIV = SSH_CONFIG_DIR + "ssh_host_dsa_key"
337 SSH_HOST_DSA_PUB = SSH_HOST_DSA_PRIV + ".pub"
338 SSH_HOST_RSA_PRIV = SSH_CONFIG_DIR + "ssh_host_rsa_key"
339 SSH_HOST_RSA_PUB = SSH_HOST_RSA_PRIV + ".pub"
344 INSTANCE_REBOOT_SOFT = "soft"
345 INSTANCE_REBOOT_HARD = "hard"
346 INSTANCE_REBOOT_FULL = "full"
348 REBOOT_TYPES = frozenset([INSTANCE_REBOOT_SOFT,
349 INSTANCE_REBOOT_HARD,
350 INSTANCE_REBOOT_FULL])
352 VTYPE_STRING = 'string'
354 VTYPE_SIZE = 'size' # size, in MiBs
356 ENFORCEABLE_TYPES = frozenset([
363 # HV parameter names (global namespace)
364 HV_BOOT_ORDER = "boot_order"
365 HV_CDROM_IMAGE_PATH = "cdrom_image_path"
366 HV_NIC_TYPE = "nic_type"
367 HV_DISK_TYPE = "disk_type"
368 HV_VNC_BIND_ADDRESS = "vnc_bind_address"
369 HV_VNC_TLS = "vnc_tls"
370 HV_VNC_X509 = "vnc_x509_path"
371 HV_VNC_X509_VERIFY = "vnc_x509_verify"
374 HV_USE_BOOTLOADER = "use_bootloader"
375 HV_BOOTLOADER_ARGS = "bootloader_args"
376 HV_BOOTLOADER_PATH = "bootloader_path"
377 HV_KERNEL_ARGS = "kernel_args"
378 HV_KERNEL_PATH = "kernel_path"
379 HV_INITRD_PATH = "initrd_path"
380 HV_ROOT_PATH = "root_path"
381 HV_SERIAL_CONSOLE = "serial_console"
382 HV_USB_MOUSE = "usb_mouse"
383 HV_DEVICE_MODEL = "device_model"
384 HV_INIT_SCRIPT = "init_script"
386 HVS_PARAMETER_TYPES = {
387 HV_BOOT_ORDER: VTYPE_STRING,
388 HV_CDROM_IMAGE_PATH: VTYPE_STRING,
389 HV_NIC_TYPE: VTYPE_STRING,
390 HV_DISK_TYPE: VTYPE_STRING,
391 HV_VNC_BIND_ADDRESS: VTYPE_STRING,
392 HV_VNC_TLS: VTYPE_BOOL,
393 HV_VNC_X509: VTYPE_STRING,
394 HV_VNC_X509_VERIFY: VTYPE_BOOL,
397 HV_USE_BOOTLOADER: VTYPE_BOOL,
398 HV_BOOTLOADER_PATH: VTYPE_STRING,
399 HV_BOOTLOADER_ARGS: VTYPE_STRING,
400 HV_KERNEL_PATH: VTYPE_STRING,
401 HV_KERNEL_ARGS: VTYPE_STRING,
402 HV_INITRD_PATH: VTYPE_STRING,
403 HV_ROOT_PATH: VTYPE_STRING,
404 HV_SERIAL_CONSOLE: VTYPE_BOOL,
405 HV_USB_MOUSE: VTYPE_STRING,
406 HV_DEVICE_MODEL: VTYPE_STRING,
407 HV_INIT_SCRIPT: VTYPE_STRING,
410 HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
415 BE_AUTO_BALANCE = "auto_balance"
417 BES_PARAMETER_TYPES = {
418 BE_MEMORY: VTYPE_SIZE,
420 BE_AUTO_BALANCE: VTYPE_BOOL,
423 BES_PARAMETERS = frozenset(BES_PARAMETER_TYPES.keys())
425 # Instance Parameters Profile
426 PP_DEFAULT = "default"
431 NIC_MODE_BRIDGED = "bridged"
432 NIC_MODE_ROUTED = "routed"
434 NIC_VALID_MODES = frozenset([NIC_MODE_BRIDGED, NIC_MODE_ROUTED])
436 NICS_PARAMETER_TYPES = {
437 NIC_MODE: VTYPE_STRING,
438 NIC_LINK: VTYPE_STRING,
441 NICS_PARAMETERS = frozenset(NICS_PARAMETER_TYPES.keys())
443 # Hypervisor constants
444 HT_XEN_PVM = "xen-pvm"
446 HT_XEN_HVM = "xen-hvm"
449 HYPER_TYPES = frozenset([HT_XEN_PVM, HT_FAKE, HT_XEN_HVM, HT_KVM, HT_CHROOT])
450 HTS_REQ_PORT = frozenset([HT_XEN_HVM, HT_KVM])
453 VNC_PASSWORD_FILE = CONF_DIR + "/vnc-cluster-password"
454 VNC_DEFAULT_BIND_ADDRESS = '0.0.0.0'
457 HT_NIC_RTL8139 = "rtl8139"
458 HT_NIC_NE2K_PCI = "ne2k_pci"
459 HT_NIC_NE2K_ISA = "ne2k_isa"
460 HT_NIC_I82551 = "i82551"
461 HT_NIC_I85557B = "i82557b"
462 HT_NIC_I8259ER = "i82559er"
463 HT_NIC_PCNET = "pcnet"
464 HT_NIC_E1000 = "e1000"
465 HT_NIC_PARAVIRTUAL = HT_DISK_PARAVIRTUAL = "paravirtual"
467 HT_HVM_VALID_NIC_TYPES = frozenset([HT_NIC_RTL8139, HT_NIC_NE2K_PCI,
468 HT_NIC_NE2K_ISA, HT_NIC_PARAVIRTUAL])
469 HT_KVM_VALID_NIC_TYPES = frozenset([HT_NIC_RTL8139, HT_NIC_NE2K_PCI,
470 HT_NIC_NE2K_ISA, HT_NIC_I82551,
471 HT_NIC_I85557B, HT_NIC_I8259ER,
472 HT_NIC_PCNET, HT_NIC_E1000,
475 HT_DISK_IOEMU = "ioemu"
477 HT_DISK_SCSI = "scsi"
480 HT_DISK_PFLASH = "pflash"
482 HT_HVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IOEMU])
483 HT_KVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IDE,
484 HT_DISK_SCSI, HT_DISK_SD, HT_DISK_MTD,
488 HT_MOUSE_MOUSE = "mouse"
489 HT_MOUSE_TABLET = "tablet"
491 HT_KVM_VALID_MOUSE_TYPES = frozenset([HT_MOUSE_MOUSE, HT_MOUSE_TABLET])
494 HT_BO_CDROM = "cdrom"
496 HT_BO_NETWORK = "network"
498 HT_KVM_VALID_BO_TYPES = frozenset([HT_BO_CDROM, HT_BO_DISK, HT_BO_NETWORK])
500 # Cluster Verify steps
501 VERIFY_NPLUSONE_MEM = 'nplusone_mem'
502 VERIFY_OPTIONAL_CHECKS = frozenset([VERIFY_NPLUSONE_MEM])
504 # Node verify constants
505 NV_FILELIST = "filelist"
507 NV_HYPERVISOR = "hypervisor"
508 NV_INSTANCELIST = "instancelist"
510 NV_NODELIST = "nodelist"
511 NV_NODENETTEST = "node-net-test"
512 NV_VERSION = "version"
514 NV_DRBDLIST = "drbd-list"
516 # Allocator framework constants
517 IALLOCATOR_VERSION = 2
518 IALLOCATOR_DIR_IN = "in"
519 IALLOCATOR_DIR_OUT = "out"
520 IALLOCATOR_MODE_ALLOC = "allocate"
521 IALLOCATOR_MODE_RELOC = "relocate"
522 IALLOCATOR_SEARCH_PATH = _autoconf.IALLOCATOR_SEARCH_PATH
525 JOB_QUEUE_VERSION = 1
526 JOB_QUEUE_LOCK_FILE = QUEUE_DIR + "/lock"
527 JOB_QUEUE_VERSION_FILE = QUEUE_DIR + "/version"
528 JOB_QUEUE_SERIAL_FILE = QUEUE_DIR + "/serial"
529 JOB_QUEUE_ARCHIVE_DIR = QUEUE_DIR + "/archive"
530 JOB_QUEUE_DRAIN_FILE = QUEUE_DIR + "/drain"
531 JOB_QUEUE_SIZE_HARD_LIMIT = 5000
532 JOB_QUEUE_SIZE_SOFT_LIMIT = JOB_QUEUE_SIZE_HARD_LIMIT * 0.8
534 JOB_ID_TEMPLATE = r"\d+"
536 # unchanged job return
537 JOB_NOTCHANGED = "nochange"
540 JOB_STATUS_QUEUED = "queued"
541 JOB_STATUS_WAITLOCK = "waiting"
542 JOB_STATUS_CANCELING = "canceling"
543 JOB_STATUS_RUNNING = "running"
544 JOB_STATUS_CANCELED = "canceled"
545 JOB_STATUS_SUCCESS = "success"
546 JOB_STATUS_ERROR = "error"
550 OP_STATUS_QUEUED = "queued"
551 OP_STATUS_WAITLOCK = "waiting"
552 OP_STATUS_CANCELING = "canceling"
553 OP_STATUS_RUNNING = "running"
555 OP_STATUS_CANCELED = "canceled"
556 OP_STATUS_SUCCESS = "success"
557 OP_STATUS_ERROR = "error"
558 OPS_FINALIZED = frozenset([OP_STATUS_CANCELED,
562 # Execution log types
563 ELOG_MESSAGE = "message"
564 ELOG_PROGRESS = "progress"
566 # max dynamic devices
571 SS_CLUSTER_NAME = "cluster_name"
572 SS_CLUSTER_TAGS = "cluster_tags"
573 SS_FILE_STORAGE_DIR = "file_storage_dir"
574 SS_MASTER_CANDIDATES = "master_candidates"
575 SS_MASTER_CANDIDATES_IPS = "master_candidates_ips"
576 SS_MASTER_IP = "master_ip"
577 SS_MASTER_NETDEV = "master_netdev"
578 SS_MASTER_NODE = "master_node"
579 SS_NODE_LIST = "node_list"
580 SS_NODE_PRIMARY_IPS = "node_primary_ips"
581 SS_NODE_SECONDARY_IPS = "node_secondary_ips"
582 SS_OFFLINE_NODES = "offline_nodes"
583 SS_ONLINE_NODES = "online_nodes"
584 SS_INSTANCE_LIST = "instance_list"
585 SS_RELEASE_VERSION = "release_version"
587 # cluster wide default parameters
588 DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM
592 HV_USE_BOOTLOADER: False,
593 HV_BOOTLOADER_PATH: XEN_BOOTLOADER,
594 HV_BOOTLOADER_ARGS: '',
595 HV_KERNEL_PATH: "/boot/vmlinuz-2.6-xenU",
597 HV_ROOT_PATH: '/dev/sda1',
598 HV_KERNEL_ARGS: 'ro',
602 HV_CDROM_IMAGE_PATH: '',
603 HV_NIC_TYPE: HT_NIC_RTL8139,
604 HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
605 HV_VNC_BIND_ADDRESS: '0.0.0.0',
608 HV_KERNEL_PATH: "/usr/lib/xen/boot/hvmloader",
609 HV_DEVICE_MODEL: "/usr/lib/xen/bin/qemu-dm",
612 HV_KERNEL_PATH: "/boot/vmlinuz-2.6-kvmU",
614 HV_KERNEL_ARGS: 'ro',
615 HV_ROOT_PATH: '/dev/vda1',
617 HV_SERIAL_CONSOLE: True,
618 HV_VNC_BIND_ADDRESS: '',
621 HV_VNC_X509_VERIFY: False,
622 HV_CDROM_IMAGE_PATH: '',
623 HV_BOOT_ORDER: HT_BO_DISK,
624 HV_NIC_TYPE: HT_NIC_PARAVIRTUAL,
625 HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
631 HV_INIT_SCRIPT: "/ganeti-chroot",
638 BE_AUTO_BALANCE: True,
642 NIC_MODE: NIC_MODE_BRIDGED,
643 NIC_LINK: DEFAULT_BRIDGE,
646 MASTER_POOL_SIZE_DEFAULT = 10
648 CONFD_PROTOCOL_VERSION = 1
651 CONFD_REQ_NODE_ROLE_BYNAME = 1
652 CONFD_REQ_NODE_PIP_BY_INSTANCE_IP = 2
653 CONFD_REQ_CLUSTER_MASTER = 3
654 CONFD_REQ_NODE_PIP_LIST = 4
655 CONFD_REQ_MC_PIP_LIST = 5
656 CONFD_REQ_INSTANCES_IPS_LIST = 6
658 CONFD_REQS = frozenset([
660 CONFD_REQ_NODE_ROLE_BYNAME,
661 CONFD_REQ_NODE_PIP_BY_INSTANCE_IP,
662 CONFD_REQ_CLUSTER_MASTER,
663 CONFD_REQ_NODE_PIP_LIST,
664 CONFD_REQ_MC_PIP_LIST,
665 CONFD_REQ_INSTANCES_IPS_LIST,
668 CONFD_REPL_STATUS_OK = 0
669 CONFD_REPL_STATUS_ERROR = 1
670 CONFD_REPL_STATUS_NOTIMPLEMENTED = 2
672 CONFD_REPL_STATUSES = frozenset([
673 CONFD_REPL_STATUS_OK,
674 CONFD_REPL_STATUS_ERROR,
675 CONFD_REPL_STATUS_NOTIMPLEMENTED,
678 (CONFD_NODE_ROLE_MASTER,
679 CONFD_NODE_ROLE_CANDIDATE,
680 CONFD_NODE_ROLE_OFFLINE,
681 CONFD_NODE_ROLE_DRAINED,
682 CONFD_NODE_ROLE_REGULAR,
685 # A few common errors for confd
686 CONFD_ERROR_UNKNOWN_ENTRY = 1
687 CONFD_ERROR_INTERNAL = 2
689 # Each request is "salted" by the current timestamp.
690 # This constants decides how many seconds of skew to accept.
691 # TODO: make this a default and allow the value to be more configurable
692 CONFD_MAX_CLOCK_SKEW = 300
694 # When we haven't reloaded the config for more than this amount of seconds, we
695 # force a test to see if inotify is betraying us.
696 CONFD_CONFIG_RELOAD_TIMEOUT = 60
698 # If we receive more than one update in this amount of seconds, we move to
699 # polling every RATELIMIT seconds, rather than relying on inotify, to be able
700 # to serve more requests.
701 CONFD_CONFIG_RELOAD_RATELIMIT = 2
703 # Magic number prepended to all confd queries.
704 # This allows us to distinguish different types of confd protocols and handle
705 # them. For example by changing this we can move the whole payload to be
706 # compressed, or move away from json.
707 CONFD_MAGIC_FOURCC = 'plj0'
709 # By default a confd request is sent to the minimum between this number and all
710 # MCs. 6 was chosen because even in the case of a disastrous 50% response rate,
711 # we should have enough answers to be able to compare more than one.
712 CONFD_DEFAULT_REQ_COVERAGE = 6
714 # Timeout in seconds to expire pending query request in the confd client
715 # library. We don't actually expect any answer more than 10 seconds after we
717 CONFD_CLIENT_EXPIRE_TIMEOUT = 10
719 # Maximum UDP datagram size.
720 # On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
721 # On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
722 # (assuming we can't use jumbo frames)
723 # We just set this to 60K, which should be enough
724 MAX_UDP_DATA_SIZE = 61440