Merge branch 'devel-2.7'
[ganeti-local] / lib / constants.py
index 0ce3927..5f96c47 100644 (file)
@@ -1,7 +1,7 @@
 #
 #
 
-# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Google Inc.
+# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Google Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -197,6 +197,12 @@ XEN_CMD_XM = "xm"
 XEN_CMD_XL = "xl"
 # FIXME: This will be made configurable using hvparams in Ganeti 2.7
 XEN_CMD = _autoconf.XEN_CMD
+
+KNOWN_XEN_COMMANDS = compat.UniqueFrozenset([
+  XEN_CMD_XM,
+  XEN_CMD_XL,
+  ])
+
 # When the Xen toolstack used is "xl", live migration requires the source host
 # to connect to the target host via ssh (xl runs this command). We need to pass
 # the command xl runs some extra info so that it can use Ganeti's key
@@ -421,7 +427,7 @@ DTS_FILEBASED = compat.UniqueFrozenset([
   ])
 
 # the set of disk templates that are supported by exclusive_storage
-DTS_EXCL_STORAGE = frozenset([DT_PLAIN])
+DTS_EXCL_STORAGE = compat.UniqueFrozenset([DT_PLAIN])
 
 # templates for which we don't perform checks on free space
 DTS_NO_FREE_SPACE_CHECK = compat.UniqueFrozenset([
@@ -748,6 +754,27 @@ ENFORCEABLE_TYPES = compat.UniqueFrozenset([
 # Constant representing that the user does not specify any IP version
 IFACE_NO_IP_VERSION_SPECIFIED = 0
 
+VALID_SERIAL_SPEEDS = compat.UniqueFrozenset([
+  75,
+  110,
+  300,
+  600,
+  1200,
+  1800,
+  2400,
+  4800,
+  9600,
+  14400,
+  19200,
+  28800,
+  38400,
+  57600,
+  115200,
+  230400,
+  345600,
+  460800,
+  ])
+
 # HV parameter names (global namespace)
 HV_BOOT_ORDER = "boot_order"
 HV_CDROM_IMAGE_PATH = "cdrom_image_path"
@@ -782,6 +809,7 @@ HV_KERNEL_PATH = "kernel_path"
 HV_INITRD_PATH = "initrd_path"
 HV_ROOT_PATH = "root_path"
 HV_SERIAL_CONSOLE = "serial_console"
+HV_SERIAL_SPEED = "serial_speed"
 HV_USB_MOUSE = "usb_mouse"
 HV_KEYMAP = "keymap"
 HV_DEVICE_MODEL = "device_model"
@@ -805,9 +833,19 @@ HV_REBOOT_BEHAVIOR = "reboot_behavior"
 HV_CPU_TYPE = "cpu_type"
 HV_CPU_CAP = "cpu_cap"
 HV_CPU_WEIGHT = "cpu_weight"
+HV_CPU_CORES = "cpu_cores"
+HV_CPU_THREADS = "cpu_threads"
+HV_CPU_SOCKETS = "cpu_sockets"
+HV_SOUNDHW = "soundhw"
+HV_USB_DEVICES = "usb_devices"
+HV_VGA = "vga"
+HV_KVM_EXTRA = "kvm_extra"
+HV_KVM_MACHINE_VERSION = "machine_version"
+HV_KVM_PATH = "kvm_path"
 
 
 HVS_PARAMETER_TYPES = {
+  HV_KVM_PATH: VTYPE_STRING,
   HV_BOOT_ORDER: VTYPE_STRING,
   HV_KVM_FLOPPY_IMAGE_PATH: VTYPE_STRING,
   HV_CDROM_IMAGE_PATH: VTYPE_STRING,
@@ -841,6 +879,7 @@ HVS_PARAMETER_TYPES = {
   HV_INITRD_PATH: VTYPE_STRING,
   HV_ROOT_PATH: VTYPE_MAYBE_STRING,
   HV_SERIAL_CONSOLE: VTYPE_BOOL,
+  HV_SERIAL_SPEED: VTYPE_INT,
   HV_USB_MOUSE: VTYPE_STRING,
   HV_KEYMAP: VTYPE_STRING,
   HV_DEVICE_MODEL: VTYPE_STRING,
@@ -864,6 +903,14 @@ HVS_PARAMETER_TYPES = {
   HV_CPU_TYPE: VTYPE_STRING,
   HV_CPU_CAP: VTYPE_INT,
   HV_CPU_WEIGHT: VTYPE_INT,
+  HV_CPU_CORES: VTYPE_INT,
+  HV_CPU_THREADS: VTYPE_INT,
+  HV_CPU_SOCKETS: VTYPE_INT,
+  HV_SOUNDHW: VTYPE_STRING,
+  HV_USB_DEVICES: VTYPE_STRING,
+  HV_VGA: VTYPE_STRING,
+  HV_KVM_EXTRA: VTYPE_STRING,
+  HV_KVM_MACHINE_VERSION: VTYPE_STRING,
   }
 
 HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
@@ -1391,6 +1438,7 @@ VERIFY_OPTIONAL_CHECKS = compat.UniqueFrozenset([VERIFY_NPLUSONE_MEM])
 
 # Cluster Verify error classes
 CV_TCLUSTER = "cluster"
+CV_TGROUP = "group"
 CV_TNODE = "node"
 CV_TINSTANCE = "instance"
 
@@ -1409,6 +1457,11 @@ CV_ECLUSTERDANGLINGNODES = \
 CV_ECLUSTERDANGLINGINST = \
   (CV_TNODE, "ECLUSTERDANGLINGINST",
    "Some instances have a non-existing primary node")
+CV_EGROUPMIXEDESFLAG = \
+  (CV_TGROUP, "EGROUPMIXEDESFLAG",
+   "exclusive_storage flag is not uniform within the group")
+CV_EGROUPDIFFERENTPVSIZE = \
+  (CV_TGROUP, "EGROUPDIFFERENTPVSIZE", "PVs in the group have different sizes")
 CV_EINSTANCEBADNODE = \
   (CV_TINSTANCE, "EINSTANCEBADNODE",
    "Instance marked as running lives on an offline node")
@@ -1429,6 +1482,9 @@ CV_EINSTANCESPLITGROUPS = \
 CV_EINSTANCEPOLICY = \
   (CV_TINSTANCE, "EINSTANCEPOLICY",
    "Instance does not meet policy")
+CV_EINSTANCEUNSUITABLENODE = \
+  (CV_TINSTANCE, "EINSTANCEUNSUITABLENODE",
+   "Instance running on nodes that are not suitable for it")
 CV_ENODEDRBD = \
   (CV_TNODE, "ENODEDRBD", "Error parsing the DRBD status file")
 CV_ENODEDRBDHELPER = \
@@ -1510,28 +1566,29 @@ CV_ALL_ECODES_STRINGS = \
   compat.UniqueFrozenset(estr for (_, estr, _) in CV_ALL_ECODES)
 
 # Node verify constants
+NV_BRIDGES = "bridges"
 NV_DRBDHELPER = "drbd-helper"
 NV_DRBDLIST = "drbd-list"
+NV_EXCLUSIVEPVS = "exclusive-pvs"
 NV_FILELIST = "filelist"
+NV_FILE_STORAGE_PATHS = "file-storage-paths"
 NV_HVINFO = "hvinfo"
-NV_HYPERVISOR = "hypervisor"
 NV_HVPARAMS = "hvparms"
+NV_HYPERVISOR = "hypervisor"
 NV_INSTANCELIST = "instancelist"
 NV_LVLIST = "lvlist"
 NV_MASTERIP = "master-ip"
 NV_NODELIST = "nodelist"
 NV_NODENETTEST = "node-net-test"
 NV_NODESETUP = "nodesetup"
+NV_OOB_PATHS = "oob-paths"
 NV_OSLIST = "oslist"
 NV_PVLIST = "pvlist"
 NV_TIME = "time"
+NV_USERSCRIPTS = "user-scripts"
 NV_VERSION = "version"
 NV_VGLIST = "vglist"
 NV_VMNODES = "vmnodes"
-NV_OOB_PATHS = "oob-paths"
-NV_BRIDGES = "bridges"
-NV_USERSCRIPTS = "user-scripts"
-NV_FILE_STORAGE_PATHS = "file-storage-paths"
 
 # Instance status
 INSTST_RUNNING = "running"
@@ -1881,12 +1938,14 @@ HVC_DEFAULTS = {
     HV_CPU_WEIGHT: 256,
     },
   HT_KVM: {
+    HV_KVM_PATH: KVM_PATH,
     HV_KERNEL_PATH: KVM_KERNEL,
     HV_INITRD_PATH: "",
     HV_KERNEL_ARGS: "ro",
     HV_ROOT_PATH: "/dev/vda1",
     HV_ACPI: True,
     HV_SERIAL_CONSOLE: True,
+    HV_SERIAL_SPEED: 38400,
     HV_VNC_BIND_ADDRESS: "",
     HV_VNC_TLS: False,
     HV_VNC_X509: "",
@@ -1927,6 +1986,14 @@ HVC_DEFAULTS = {
     HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
     HV_CPU_MASK: CPU_PINNING_ALL,
     HV_CPU_TYPE: "",
+    HV_CPU_CORES: 0,
+    HV_CPU_THREADS: 0,
+    HV_CPU_SOCKETS: 0,
+    HV_SOUNDHW: "",
+    HV_USB_DEVICES: "",
+    HV_VGA: "",
+    HV_KVM_EXTRA: "",
+    HV_KVM_MACHINE_VERSION: "",
     },
   HT_FAKE: {},
   HT_CHROOT: {
@@ -2133,14 +2200,16 @@ CONFD_ERROR_ARGUMENT = 3
 # TODO: make this a default and allow the value to be more configurable
 CONFD_MAX_CLOCK_SKEW = 2 * NODE_MAX_CLOCK_SKEW
 
-# When we haven't reloaded the config for more than this amount of seconds, we
-# force a test to see if inotify is betraying us.
-CONFD_CONFIG_RELOAD_TIMEOUT = 60
+# When we haven't reloaded the config for more than this amount of
+# seconds, we force a test to see if inotify is betraying us. Using a
+# prime number to ensure we get less chance of 'same wakeup' with
+# other processes.
+CONFD_CONFIG_RELOAD_TIMEOUT = 17
 
-# If we receive more than one update in this amount of seconds, we move to
-# polling every RATELIMIT seconds, rather than relying on inotify, to be able
-# to serve more requests.
-CONFD_CONFIG_RELOAD_RATELIMIT = 2
+# If we receive more than one update in this amount of microseconds,
+# we move to polling every RATELIMIT seconds, rather than relying on
+# inotify, to be able to serve more requests.
+CONFD_CONFIG_RELOAD_RATELIMIT = 250000
 
 # Magic number prepended to all confd queries.
 # This allows us to distinguish different types of confd protocols and handle
@@ -2235,5 +2304,37 @@ RANDOM_UUID_FILE = "/proc/sys/kernel/random/uuid"
 # Regex string for verifying a UUID
 UUID_REGEX = "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
 
+# Auto-repair tag prefixes
+AUTO_REPAIR_TAG_PREFIX = "ganeti:watcher:autorepair:"
+AUTO_REPAIR_TAG_ENABLED = AUTO_REPAIR_TAG_PREFIX
+AUTO_REPAIR_TAG_SUSPENDED = AUTO_REPAIR_TAG_ENABLED + "suspend:"
+AUTO_REPAIR_TAG_PENDING = AUTO_REPAIR_TAG_PREFIX + "pending:"
+AUTO_REPAIR_TAG_RESULT = AUTO_REPAIR_TAG_PREFIX + "result:"
+
+# Auto-repair levels
+AUTO_REPAIR_FIX_STORAGE = "fix-storage"
+AUTO_REPAIR_MIGRATE = "migrate"
+AUTO_REPAIR_FAILOVER = "failover"
+AUTO_REPAIR_REINSTALL = "reinstall"
+AUTO_REPAIR_ALL_TYPES = [
+  AUTO_REPAIR_FIX_STORAGE,
+  AUTO_REPAIR_MIGRATE,
+  AUTO_REPAIR_FAILOVER,
+  AUTO_REPAIR_REINSTALL,
+]
+
+# Auto-repair results
+AUTO_REPAIR_SUCCESS = "success"
+AUTO_REPAIR_FAILURE = "failure"
+AUTO_REPAIR_ENOPERM = "enoperm"
+AUTO_REPAIR_ALL_RESULTS = frozenset([
+    AUTO_REPAIR_SUCCESS,
+    AUTO_REPAIR_FAILURE,
+    AUTO_REPAIR_ENOPERM,
+])
+
+# The version identifier for builtin data collectors
+BUILTIN_DATA_COLLECTOR_VERSION = "B"
+
 # Do not re-export imported modules
 del re, _vcsversion, _autoconf, socket, pathutils, compat