Replace frozenset with compat.UniqueFrozenset
authorMichael Hanselmann <hansmi@google.com>
Mon, 10 Dec 2012 17:45:26 +0000 (18:45 +0100)
committerMichael Hanselmann <hansmi@google.com>
Wed, 19 Dec 2012 16:29:53 +0000 (17:29 +0100)
This is not a trivial s/frozenset/compat.UniqueFrozenset/, but rather
only replaces “frozenset” where appropriate. Most of the places are
“static” information that doesn't change after the module has been
loaded.

Some docstrings and code formatting (e.g. empty lines) issues are
addressed as well. Some lines got too long and were wrapped.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

31 files changed:
lib/backend.py
lib/bdev.py
lib/cli.py
lib/client/gnt_debug.py
lib/client/gnt_group.py
lib/client/gnt_instance.py
lib/client/gnt_node.py
lib/cmdlib.py
lib/confd/client.py
lib/constants.py
lib/errors.py
lib/impexpd/__init__.py
lib/locking.py
lib/luxi.py
lib/mcpu.py
lib/pathutils.py
lib/query.py
lib/rapi/__init__.py
lib/rapi/baserlib.py
lib/rapi/rlib2.py
lib/ssconf.py
lib/tools/ensure_dirs.py
lib/vcluster.py
lib/watcher/__init__.py
qa/qa_rapi.py
test/docs_unittest.py
test/ganeti.mcpu_unittest.py
test/ganeti.opcodes_unittest.py
test/ganeti.rapi.testutils_unittest.py
tools/cluster-merge
tools/lvmstrap

index ccb6a17..c3279a7 100644 (file)
@@ -68,7 +68,7 @@ from ganeti import ht
 
 
 _BOOT_ID_PATH = "/proc/sys/kernel/random/boot_id"
-_ALLOWED_CLEAN_DIRS = frozenset([
+_ALLOWED_CLEAN_DIRS = compat.UniqueFrozenset([
   pathutils.DATA_DIR,
   pathutils.JOB_QUEUE_ARCHIVE_DIR,
   pathutils.QUEUE_DIR,
index 9221d0c..915112b 100644 (file)
@@ -120,7 +120,7 @@ def _GetForbiddenFileStoragePaths():
     paths.update(map(lambda s: "%s/%s" % (prefix, s),
                      ["bin", "lib", "lib32", "lib64", "sbin"]))
 
-  return frozenset(map(os.path.normpath, paths))
+  return compat.UniqueFrozenset(map(os.path.normpath, paths))
 
 
 def _ComputeWrongFileStoragePaths(paths,
@@ -503,8 +503,8 @@ class LogicalVolume(BlockDev):
 
   """
   _VALID_NAME_RE = re.compile("^[a-zA-Z0-9+_.-]*$")
-  _INVALID_NAMES = frozenset([".", "..", "snapshot", "pvmove"])
-  _INVALID_SUBSTRINGS = frozenset(["_mlog", "_mimage"])
+  _INVALID_NAMES = compat.UniqueFrozenset([".", "..", "snapshot", "pvmove"])
+  _INVALID_SUBSTRINGS = compat.UniqueFrozenset(["_mlog", "_mimage"])
 
   def __init__(self, unique_id, children, size, params):
     """Attaches to a LV device.
@@ -958,7 +958,7 @@ class DRBD8Status(object):
   CS_SYNCTARGET = "SyncTarget"
   CS_PAUSEDSYNCS = "PausedSyncS"
   CS_PAUSEDSYNCT = "PausedSyncT"
-  CSET_SYNC = frozenset([
+  CSET_SYNC = compat.UniqueFrozenset([
     CS_WFREPORTPARAMS,
     CS_STARTINGSYNCS,
     CS_STARTINGSYNCT,
index 603cdc4..0162bdd 100644 (file)
@@ -666,7 +666,7 @@ def check_maybefloat(option, opt, value): # pylint: disable=W0613
  OPT_COMPL_INST_ADD_NODES,
  OPT_COMPL_ONE_NODEGROUP) = range(100, 108)
 
-OPT_COMPL_ALL = frozenset([
+OPT_COMPL_ALL = compat.UniqueFrozenset([
   OPT_COMPL_MANY_NODES,
   OPT_COMPL_ONE_NODE,
   OPT_COMPL_ONE_INSTANCE,
index ffbd569..829ed05 100644 (file)
@@ -432,7 +432,12 @@ def TestJobqueue(opts, _):
    TM_MULTISUCCESS,
    TM_FAIL,
    TM_PARTFAIL) = range(4)
-  TM_ALL = frozenset([TM_SUCCESS, TM_MULTISUCCESS, TM_FAIL, TM_PARTFAIL])
+  TM_ALL = compat.UniqueFrozenset([
+    TM_SUCCESS,
+    TM_MULTISUCCESS,
+    TM_FAIL,
+    TM_PARTFAIL,
+    ])
 
   for mode in TM_ALL:
     test_messages = [
index 8e73da9..e05f982 100644 (file)
@@ -28,14 +28,14 @@ from ganeti.cli import *
 from ganeti import constants
 from ganeti import opcodes
 from ganeti import utils
+from ganeti import compat
 from cStringIO import StringIO
 
 
 #: default list of fields for L{ListGroups}
 _LIST_DEF_FIELDS = ["name", "node_cnt", "pinst_cnt", "alloc_policy", "ndparams"]
 
-
-_ENV_OVERRIDE = frozenset(["list"])
+_ENV_OVERRIDE = compat.UniqueFrozenset(["list"])
 
 
 def AddGroup(opts, args):
index c488395..ee9bf44 100644 (file)
@@ -53,21 +53,19 @@ _EXPAND_NODES_SEC_BY_TAGS = "nodes-sec-by-tags"
 _EXPAND_INSTANCES = "instances"
 _EXPAND_INSTANCES_BY_TAGS = "instances-by-tags"
 
-_EXPAND_NODES_TAGS_MODES = frozenset([
+_EXPAND_NODES_TAGS_MODES = compat.UniqueFrozenset([
   _EXPAND_NODES_BOTH_BY_TAGS,
   _EXPAND_NODES_PRI_BY_TAGS,
   _EXPAND_NODES_SEC_BY_TAGS,
   ])
 
-
 #: default list of options for L{ListInstances}
 _LIST_DEF_FIELDS = [
   "name", "hypervisor", "os", "pnode", "status", "oper_ram",
   ]
 
-
 _MISSING = object()
-_ENV_OVERRIDE = frozenset(["list"])
+_ENV_OVERRIDE = compat.UniqueFrozenset(["list"])
 
 _INST_DATA_VAL = ht.TListOf(ht.TDict)
 
index 6bf6bf6..e893b5e 100644 (file)
@@ -39,6 +39,7 @@ from ganeti import errors
 from ganeti import netutils
 from ganeti import pathutils
 from ganeti import ssh
+from ganeti import compat
 from cStringIO import StringIO
 
 from ganeti import confd
@@ -106,13 +107,12 @@ _REPAIRABLE_STORAGE_TYPES = \
 
 _MODIFIABLE_STORAGE_TYPES = constants.MODIFIABLE_STORAGE_FIELDS.keys()
 
+_OOB_COMMAND_ASK = compat.UniqueFrozenset([
+  constants.OOB_POWER_OFF,
+  constants.OOB_POWER_CYCLE,
+  ])
 
-_OOB_COMMAND_ASK = frozenset([constants.OOB_POWER_OFF,
-                              constants.OOB_POWER_CYCLE])
-
-
-_ENV_OVERRIDE = frozenset(["list"])
-
+_ENV_OVERRIDE = compat.UniqueFrozenset(["list"])
 
 NONODE_SETUP_OPT = cli_option("--no-node-setup", default=True,
                               action="store_false", dest="node_setup",
index c09e1d8..0b1d5ce 100644 (file)
@@ -7288,7 +7288,7 @@ class LUInstanceRecreateDisks(LogicalUnit):
   HTYPE = constants.HTYPE_INSTANCE
   REQ_BGL = False
 
-  _MODIFYABLE = frozenset([
+  _MODIFYABLE = compat.UniqueFrozenset([
     constants.IDISK_SIZE,
     constants.IDISK_MODE,
     ])
index 9b3f160..e37a3cd 100644 (file)
@@ -406,7 +406,7 @@ UPCALL_REPLY = 1
 # UPCALL_EXPIRE: internal library request expire
 # has only salt, type, orig_request and extra_args
 UPCALL_EXPIRE = 2
-CONFD_UPCALL_TYPES = frozenset([
+CONFD_UPCALL_TYPES = compat.UniqueFrozenset([
   UPCALL_REPLY,
   UPCALL_EXPIRE,
   ])
index e96bcba..6f277dc 100644 (file)
@@ -26,6 +26,7 @@ import socket
 
 from ganeti import _autoconf
 from ganeti import _vcsversion
+from ganeti import compat
 from ganeti import pathutils
 
 
@@ -34,7 +35,11 @@ RELEASE_VERSION = _autoconf.PACKAGE_VERSION
 OS_API_V10 = 10
 OS_API_V15 = 15
 OS_API_V20 = 20
-OS_API_VERSIONS = frozenset([OS_API_V10, OS_API_V15, OS_API_V20])
+OS_API_VERSIONS = compat.UniqueFrozenset([
+  OS_API_V10,
+  OS_API_V15,
+  OS_API_V20,
+  ])
 VCS_VERSION = _vcsversion.VCS_VERSION
 EXPORT_VERSION = 0
 RAPI_VERSION = 2
@@ -223,7 +228,12 @@ CONS_SPICE = "spice"
 CONS_MESSAGE = "msg"
 
 #: All console types
-CONS_ALL = frozenset([CONS_SSH, CONS_VNC, CONS_SPICE, CONS_MESSAGE])
+CONS_ALL = compat.UniqueFrozenset([
+  CONS_SSH,
+  CONS_VNC,
+  CONS_SPICE,
+  CONS_MESSAGE,
+  ])
 
 # For RSA keys more bits are better, but they also make operations more
 # expensive. NIST SP 800-131 recommends a minimum of 2048 bits from the year
@@ -256,7 +266,7 @@ IEM_EXPORT = "export"
 # Import/export transport compression
 IEC_NONE = "none"
 IEC_GZIP = "gzip"
-IEC_ALL = frozenset([
+IEC_ALL = compat.UniqueFrozenset([
   IEC_NONE,
   IEC_GZIP,
   ])
@@ -322,7 +332,7 @@ SF_ALLOCATABLE = "allocatable"
 SO_FIX_CONSISTENCY = "fix-consistency"
 
 # Available fields per storage type
-VALID_STORAGE_FIELDS = frozenset([
+VALID_STORAGE_FIELDS = compat.UniqueFrozenset([
   SF_NAME,
   SF_TYPE,
   SF_SIZE,
@@ -331,7 +341,11 @@ VALID_STORAGE_FIELDS = frozenset([
   SF_ALLOCATABLE,
   ])
 
-VALID_STORAGE_TYPES = frozenset([ST_FILE, ST_LVM_PV, ST_LVM_VG])
+VALID_STORAGE_TYPES = compat.UniqueFrozenset([
+  ST_FILE,
+  ST_LVM_PV,
+  ST_LVM_VG,
+  ])
 
 MODIFIABLE_STORAGE_FIELDS = {
   ST_LVM_PV: frozenset([SF_ALLOCATABLE]),
@@ -357,29 +371,50 @@ DT_BLOCK = "blockdev"
 DT_RBD = "rbd"
 
 # the set of network-mirrored disk templates
-DTS_INT_MIRROR = frozenset([DT_DRBD8])
+DTS_INT_MIRROR = compat.UniqueFrozenset([DT_DRBD8])
 
 # the set of externally-mirrored disk templates (e.g. SAN, NAS)
-DTS_EXT_MIRROR = frozenset([DT_SHARED_FILE, DT_BLOCK, DT_RBD])
+DTS_EXT_MIRROR = compat.UniqueFrozenset([
+  DT_SHARED_FILE,
+  DT_BLOCK,
+  DT_RBD,
+  ])
 
 # the set of non-lvm-based disk templates
-DTS_NOT_LVM = frozenset([DT_DISKLESS, DT_FILE, DT_SHARED_FILE,
-                         DT_BLOCK, DT_RBD])
+DTS_NOT_LVM = compat.UniqueFrozenset([
+  DT_DISKLESS,
+  DT_FILE,
+  DT_SHARED_FILE,
+  DT_BLOCK,
+  DT_RBD,
+  ])
 
 # the set of disk templates which can be grown
-DTS_GROWABLE = frozenset([DT_PLAIN, DT_DRBD8, DT_FILE, DT_SHARED_FILE, DT_RBD])
+DTS_GROWABLE = compat.UniqueFrozenset([
+  DT_PLAIN,
+  DT_DRBD8,
+  DT_FILE,
+  DT_SHARED_FILE,
+  DT_RBD,
+  ])
 
 # the set of disk templates that allow adoption
-DTS_MAY_ADOPT = frozenset([DT_PLAIN, DT_BLOCK])
+DTS_MAY_ADOPT = compat.UniqueFrozenset([
+  DT_PLAIN,
+  DT_BLOCK,
+  ])
 
 # the set of disk templates that *must* use adoption
-DTS_MUST_ADOPT = frozenset([DT_BLOCK])
+DTS_MUST_ADOPT = compat.UniqueFrozenset([DT_BLOCK])
 
 # the set of disk templates that allow migrations
 DTS_MIRRORED = frozenset.union(DTS_INT_MIRROR, DTS_EXT_MIRROR)
 
 # the set of file based disk templates
-DTS_FILEBASED = frozenset([DT_FILE, DT_SHARED_FILE])
+DTS_FILEBASED = compat.UniqueFrozenset([
+  DT_FILE,
+  DT_SHARED_FILE,
+  ])
 
 # logical disk types
 LD_LV = "lvm"
@@ -387,7 +422,7 @@ LD_DRBD8 = "drbd8"
 LD_FILE = "file"
 LD_BLOCKDEV = "blockdev"
 LD_RBD = "rbd"
-LOGICAL_DISK_TYPES = frozenset([
+LOGICAL_DISK_TYPES = compat.UniqueFrozenset([
   LD_LV,
   LD_DRBD8,
   LD_FILE,
@@ -395,7 +430,12 @@ LOGICAL_DISK_TYPES = frozenset([
   LD_RBD,
   ])
 
-LDS_BLOCK = frozenset([LD_LV, LD_DRBD8, LD_BLOCKDEV, LD_RBD])
+LDS_BLOCK = compat.UniqueFrozenset([
+  LD_LV,
+  LD_DRBD8,
+  LD_BLOCKDEV,
+  LD_RBD,
+  ])
 
 # drbd constants
 DRBD_HMAC_ALG = "md5"
@@ -412,7 +452,7 @@ DRBD_B_DISK_DRAIN = "d"
 DRBD_B_DISK_FLUSH = "f"
 
 # Valid barrier combinations: "n" or any non-null subset of "bfd"
-DRBD_VALID_BARRIER_OPT = frozenset([
+DRBD_VALID_BARRIER_OPT = compat.UniqueFrozenset([
   frozenset([DRBD_B_NONE]),
   frozenset([DRBD_B_DISK_BARRIERS]),
   frozenset([DRBD_B_DISK_DRAIN]),
@@ -431,19 +471,19 @@ FD_LOOP = "loop"
 FD_BLKTAP = "blktap"
 
 # the set of drbd-like disk types
-LDS_DRBD = frozenset([LD_DRBD8])
+LDS_DRBD = compat.UniqueFrozenset([LD_DRBD8])
 
 # disk access mode
 DISK_RDONLY = "ro"
 DISK_RDWR = "rw"
-DISK_ACCESS_SET = frozenset([DISK_RDONLY, DISK_RDWR])
+DISK_ACCESS_SET = compat.UniqueFrozenset([DISK_RDONLY, DISK_RDWR])
 
 # disk replacement mode
 REPLACE_DISK_PRI = "replace_on_primary"    # replace disks on primary
 REPLACE_DISK_SEC = "replace_on_secondary"  # replace disks on secondary
 REPLACE_DISK_CHG = "replace_new_secondary" # change secondary node
 REPLACE_DISK_AUTO = "replace_auto"
-REPLACE_MODES = frozenset([
+REPLACE_MODES = compat.UniqueFrozenset([
   REPLACE_DISK_PRI,
   REPLACE_DISK_SEC,
   REPLACE_DISK_CHG,
@@ -453,7 +493,7 @@ REPLACE_MODES = frozenset([
 # Instance export mode
 EXPORT_MODE_LOCAL = "local"
 EXPORT_MODE_REMOTE = "remote"
-EXPORT_MODES = frozenset([
+EXPORT_MODES = compat.UniqueFrozenset([
   EXPORT_MODE_LOCAL,
   EXPORT_MODE_REMOTE,
   ])
@@ -462,7 +502,7 @@ EXPORT_MODES = frozenset([
 INSTANCE_CREATE = "create"
 INSTANCE_IMPORT = "import"
 INSTANCE_REMOTE_IMPORT = "remote-import"
-INSTANCE_CREATE_MODES = frozenset([
+INSTANCE_CREATE_MODES = compat.UniqueFrozenset([
   INSTANCE_CREATE,
   INSTANCE_IMPORT,
   INSTANCE_REMOTE_IMPORT,
@@ -487,7 +527,7 @@ RIE_CONNECT_RETRIES = 10
 #: Give child process up to 5 seconds to exit after sending a signal
 CHILD_LINGER_TIMEOUT = 5.0
 
-DISK_TEMPLATES = frozenset([
+DISK_TEMPLATES = compat.UniqueFrozenset([
   DT_DISKLESS,
   DT_PLAIN,
   DT_DRBD8,
@@ -497,7 +537,7 @@ DISK_TEMPLATES = frozenset([
   DT_RBD,
   ])
 
-FILE_DRIVER = frozenset([FD_LOOP, FD_BLKTAP])
+FILE_DRIVER = compat.UniqueFrozenset([FD_LOOP, FD_BLKTAP])
 
 # import/export config options
 INISECT_EXP = "export"
@@ -510,7 +550,7 @@ INISECT_OSP = "os"
 DDM_ADD = "add"
 DDM_MODIFY = "modify"
 DDM_REMOVE = "remove"
-DDMS_VALUES = frozenset([DDM_ADD, DDM_REMOVE])
+DDMS_VALUES = compat.UniqueFrozenset([DDM_ADD, DDM_REMOVE])
 DDMS_VALUES_WITH_MODIFY = (DDMS_VALUES | frozenset([
   DDM_MODIFY,
   ]))
@@ -533,7 +573,7 @@ TAG_NODEGROUP = "nodegroup"
 TAG_NODE = "node"
 TAG_INSTANCE = "instance"
 TAG_NETWORK = "network"
-VALID_TAG_TYPES = frozenset([
+VALID_TAG_TYPES = compat.UniqueFrozenset([
   TAG_CLUSTER,
   TAG_NODEGROUP,
   TAG_NODE,
@@ -552,7 +592,7 @@ IP6_ADDRESS_LOCALHOST = "::1"
 IP6_ADDRESS_ANY = "::"
 IP4_VERSION = 4
 IP6_VERSION = 6
-VALID_IP_VERSIONS = frozenset([IP4_VERSION, IP6_VERSION])
+VALID_IP_VERSIONS = compat.UniqueFrozenset([IP4_VERSION, IP6_VERSION])
 # for export to htools
 IP4_FAMILY = socket.AF_INET
 IP6_FAMILY = socket.AF_INET6
@@ -579,7 +619,11 @@ JOB_IDS_KEY = "jobs"
  RUNPARTS_RUN,
  RUNPARTS_ERR) = range(3)
 
-RUNPARTS_STATUS = frozenset([RUNPARTS_SKIP, RUNPARTS_RUN, RUNPARTS_ERR])
+RUNPARTS_STATUS = compat.UniqueFrozenset([
+  RUNPARTS_SKIP,
+  RUNPARTS_RUN,
+  RUNPARTS_ERR,
+  ])
 
 # RPC constants
 (RPC_ENCODING_NONE,
@@ -602,7 +646,7 @@ OS_SCRIPT_IMPORT = "import"
 OS_SCRIPT_EXPORT = "export"
 OS_SCRIPT_RENAME = "rename"
 OS_SCRIPT_VERIFY = "verify"
-OS_SCRIPTS = frozenset([
+OS_SCRIPTS = compat.UniqueFrozenset([
   OS_SCRIPT_CREATE,
   OS_SCRIPT_IMPORT,
   OS_SCRIPT_EXPORT,
@@ -615,7 +659,7 @@ OS_VARIANTS_FILE = "variants.list"
 OS_PARAMETERS_FILE = "parameters.list"
 
 OS_VALIDATE_PARAMETERS = "parameters"
-OS_VALIDATE_CALLS = frozenset([OS_VALIDATE_PARAMETERS])
+OS_VALIDATE_CALLS = compat.UniqueFrozenset([OS_VALIDATE_PARAMETERS])
 
 # ssh constants
 SSH = "ssh"
@@ -626,7 +670,7 @@ INSTANCE_REBOOT_SOFT = "soft"
 INSTANCE_REBOOT_HARD = "hard"
 INSTANCE_REBOOT_FULL = "full"
 
-REBOOT_TYPES = frozenset([
+REBOOT_TYPES = compat.UniqueFrozenset([
   INSTANCE_REBOOT_SOFT,
   INSTANCE_REBOOT_HARD,
   INSTANCE_REBOOT_FULL,
@@ -636,7 +680,7 @@ REBOOT_TYPES = frozenset([
 INSTANCE_REBOOT_ALLOWED = "reboot"
 INSTANCE_REBOOT_EXIT = "exit"
 
-REBOOT_BEHAVIORS = frozenset([
+REBOOT_BEHAVIORS = compat.UniqueFrozenset([
   INSTANCE_REBOOT_ALLOWED,
   INSTANCE_REBOOT_EXIT,
   ])
@@ -646,7 +690,7 @@ VTYPE_MAYBE_STRING = "maybe-string"
 VTYPE_BOOL = "bool"
 VTYPE_SIZE = "size" # size, in MiBs
 VTYPE_INT = "int"
-ENFORCEABLE_TYPES = frozenset([
+ENFORCEABLE_TYPES = compat.UniqueFrozenset([
   VTYPE_STRING,
   VTYPE_MAYBE_STRING,
   VTYPE_BOOL,
@@ -797,14 +841,14 @@ HV_MIGRATION_ACTIVE = "active"
 HV_MIGRATION_FAILED = "failed"
 HV_MIGRATION_CANCELLED = "cancelled"
 
-HV_MIGRATION_VALID_STATUSES = frozenset([
+HV_MIGRATION_VALID_STATUSES = compat.UniqueFrozenset([
   HV_MIGRATION_COMPLETED,
   HV_MIGRATION_ACTIVE,
   HV_MIGRATION_FAILED,
   HV_MIGRATION_CANCELLED,
   ])
 
-HV_MIGRATION_FAILED_STATUSES = frozenset([
+HV_MIGRATION_FAILED_STATUSES = compat.UniqueFrozenset([
   HV_MIGRATION_FAILED,
   HV_MIGRATION_CANCELLED,
   ])
@@ -858,7 +902,7 @@ DSS_PARAMETER_TYPES = {
   }
 
 DSS_PARAMETERS = frozenset(DSS_PARAMETER_TYPES.keys())
-DS_VALID_TYPES = frozenset([LD_LV])
+DS_VALID_TYPES = compat.UniqueFrozenset([LD_LV])
 
 # Backend parameter names
 BE_MEMORY = "memory" # deprecated and replaced by max and min mem
@@ -918,13 +962,13 @@ IPOLICY_DTS = "disk-templates"
 IPOLICY_VCPU_RATIO = "vcpu-ratio"
 IPOLICY_SPINDLE_RATIO = "spindle-ratio"
 
-IPOLICY_ISPECS = frozenset([
+IPOLICY_ISPECS = compat.UniqueFrozenset([
   ISPECS_MIN,
   ISPECS_MAX,
   ISPECS_STD,
   ])
 
-IPOLICY_PARAMETERS = frozenset([
+IPOLICY_PARAMETERS = compat.UniqueFrozenset([
   IPOLICY_VCPU_RATIO,
   IPOLICY_SPINDLE_RATIO,
   ])
@@ -1031,7 +1075,7 @@ OOB_POWER_CYCLE = "power-cycle"
 OOB_POWER_STATUS = "power-status"
 OOB_HEALTH = "health"
 
-OOB_COMMANDS = frozenset([
+OOB_COMMANDS = compat.UniqueFrozenset([
   OOB_POWER_ON,
   OOB_POWER_OFF,
   OOB_POWER_CYCLE,
@@ -1049,7 +1093,7 @@ OOB_STATUS_WARNING = "WARNING"
 OOB_STATUS_CRITICAL = "CRITICAL"
 OOB_STATUS_UNKNOWN = "UNKNOWN"
 
-OOB_STATUSES = frozenset([
+OOB_STATUSES = compat.UniqueFrozenset([
   OOB_STATUS_OK,
   OOB_STATUS_WARNING,
   OOB_STATUS_CRITICAL,
@@ -1068,7 +1112,11 @@ NIC_MODE_ROUTED = "routed"
 NIC_MODE_OVS = "openvswitch"
 NIC_IP_POOL = "pool"
 
-NIC_VALID_MODES = frozenset([NIC_MODE_BRIDGED, NIC_MODE_ROUTED, NIC_MODE_OVS])
+NIC_VALID_MODES = compat.UniqueFrozenset([
+  NIC_MODE_BRIDGED,
+  NIC_MODE_ROUTED,
+  NIC_MODE_OVS,
+  ])
 
 RESERVE_ACTION = "reserve"
 RELEASE_ACTION = "release"
@@ -1078,7 +1126,10 @@ RELEASE_ACTION = "release"
 NETWORK_TYPE_PRIVATE = "private"
 NETWORK_TYPE_PUBLIC = "public"
 
-NETWORK_VALID_TYPES = frozenset([NETWORK_TYPE_PRIVATE, NETWORK_TYPE_PUBLIC])
+NETWORK_VALID_TYPES = compat.UniqueFrozenset([
+  NETWORK_TYPE_PRIVATE,
+  NETWORK_TYPE_PUBLIC,
+  ])
 
 NICS_PARAMETER_TYPES = {
   NIC_MODE: VTYPE_STRING,
@@ -1124,7 +1175,7 @@ HT_XEN_HVM = "xen-hvm"
 HT_KVM = "kvm"
 HT_CHROOT = "chroot"
 HT_LXC = "lxc"
-HYPER_TYPES = frozenset([
+HYPER_TYPES = compat.UniqueFrozenset([
   HT_XEN_PVM,
   HT_FAKE,
   HT_XEN_HVM,
@@ -1132,7 +1183,7 @@ HYPER_TYPES = frozenset([
   HT_CHROOT,
   HT_LXC,
   ])
-HTS_REQ_PORT = frozenset([HT_XEN_HVM, HT_KVM])
+HTS_REQ_PORT = compat.UniqueFrozenset([HT_XEN_HVM, HT_KVM])
 
 VNC_BASE_PORT = 5900
 VNC_DEFAULT_BIND_ADDRESS = IP4_ADDRESS_ANY
@@ -1148,14 +1199,14 @@ HT_NIC_PCNET = "pcnet"
 HT_NIC_E1000 = "e1000"
 HT_NIC_PARAVIRTUAL = HT_DISK_PARAVIRTUAL = "paravirtual"
 
-HT_HVM_VALID_NIC_TYPES = frozenset([
+HT_HVM_VALID_NIC_TYPES = compat.UniqueFrozenset([
   HT_NIC_RTL8139,
   HT_NIC_NE2K_PCI,
   HT_NIC_E1000,
   HT_NIC_NE2K_ISA,
   HT_NIC_PARAVIRTUAL,
   ])
-HT_KVM_VALID_NIC_TYPES = frozenset([
+HT_KVM_VALID_NIC_TYPES = compat.UniqueFrozenset([
   HT_NIC_RTL8139,
   HT_NIC_NE2K_PCI,
   HT_NIC_NE2K_ISA,
@@ -1179,15 +1230,18 @@ HT_CACHE_DEFAULT = "default"
 HT_CACHE_NONE = "none"
 HT_CACHE_WTHROUGH = "writethrough"
 HT_CACHE_WBACK = "writeback"
-HT_VALID_CACHE_TYPES = frozenset([
+HT_VALID_CACHE_TYPES = compat.UniqueFrozenset([
   HT_CACHE_DEFAULT,
   HT_CACHE_NONE,
   HT_CACHE_WTHROUGH,
   HT_CACHE_WBACK,
   ])
 
-HT_HVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IOEMU])
-HT_KVM_VALID_DISK_TYPES = frozenset([
+HT_HVM_VALID_DISK_TYPES = compat.UniqueFrozenset([
+  HT_DISK_PARAVIRTUAL,
+  HT_DISK_IOEMU,
+  ])
+HT_KVM_VALID_DISK_TYPES = compat.UniqueFrozenset([
   HT_DISK_PARAVIRTUAL,
   HT_DISK_IDE,
   HT_DISK_SCSI,
@@ -1200,7 +1254,10 @@ HT_KVM_VALID_DISK_TYPES = frozenset([
 HT_MOUSE_MOUSE = "mouse"
 HT_MOUSE_TABLET = "tablet"
 
-HT_KVM_VALID_MOUSE_TYPES = frozenset([HT_MOUSE_MOUSE, HT_MOUSE_TABLET])
+HT_KVM_VALID_MOUSE_TYPES = compat.UniqueFrozenset([
+  HT_MOUSE_MOUSE,
+  HT_MOUSE_TABLET,
+  ])
 
 # Boot order
 HT_BO_FLOPPY = "floppy"
@@ -1208,7 +1265,7 @@ HT_BO_CDROM = "cdrom"
 HT_BO_DISK = "disk"
 HT_BO_NETWORK = "network"
 
-HT_KVM_VALID_BO_TYPES = frozenset([
+HT_KVM_VALID_BO_TYPES = compat.UniqueFrozenset([
   HT_BO_FLOPPY,
   HT_BO_CDROM,
   HT_BO_DISK,
@@ -1223,7 +1280,7 @@ HT_KVM_SPICE_LOSSLESS_IMG_COMPR_GLZ = "glz"
 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_LZ = "lz"
 HT_KVM_SPICE_LOSSLESS_IMG_COMPR_OFF = "off"
 
-HT_KVM_SPICE_VALID_LOSSLESS_IMG_COMPR_OPTIONS = frozenset([
+HT_KVM_SPICE_VALID_LOSSLESS_IMG_COMPR_OPTIONS = compat.UniqueFrozenset([
   HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_GLZ,
   HT_KVM_SPICE_LOSSLESS_IMG_COMPR_AUTO_LZ,
   HT_KVM_SPICE_LOSSLESS_IMG_COMPR_QUIC,
@@ -1237,7 +1294,7 @@ HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO = "auto"
 HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER = "never"
 HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS = "always"
 
-HT_KVM_SPICE_VALID_LOSSY_IMG_COMPR_OPTIONS = frozenset([
+HT_KVM_SPICE_VALID_LOSSY_IMG_COMPR_OPTIONS = compat.UniqueFrozenset([
   HT_KVM_SPICE_LOSSY_IMG_COMPR_AUTO,
   HT_KVM_SPICE_LOSSY_IMG_COMPR_NEVER,
   HT_KVM_SPICE_LOSSY_IMG_COMPR_ALWAYS,
@@ -1248,7 +1305,7 @@ HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF = "off"
 HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL = "all"
 HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER = "filter"
 
-HT_KVM_SPICE_VALID_VIDEO_STREAM_DETECTION_OPTIONS = frozenset([
+HT_KVM_SPICE_VALID_VIDEO_STREAM_DETECTION_OPTIONS = compat.UniqueFrozenset([
   HT_KVM_SPICE_VIDEO_STREAM_DETECTION_OFF,
   HT_KVM_SPICE_VIDEO_STREAM_DETECTION_ALL,
   HT_KVM_SPICE_VIDEO_STREAM_DETECTION_FILTER,
@@ -1259,22 +1316,29 @@ HT_SM_NONE = "none"
 HT_SM_USER = "user"
 HT_SM_POOL = "pool"
 
-HT_KVM_VALID_SM_TYPES = frozenset([HT_SM_NONE, HT_SM_USER, HT_SM_POOL])
+HT_KVM_VALID_SM_TYPES = compat.UniqueFrozenset([
+  HT_SM_NONE,
+  HT_SM_USER,
+  HT_SM_POOL,
+  ])
 
 # Kvm flag values
 HT_KVM_ENABLED = "enabled"
 HT_KVM_DISABLED = "disabled"
 
-HT_KVM_FLAG_VALUES = frozenset([HT_KVM_ENABLED, HT_KVM_DISABLED])
+HT_KVM_FLAG_VALUES = compat.UniqueFrozenset([HT_KVM_ENABLED, HT_KVM_DISABLED])
 
 # Migration type
 HT_MIGRATION_LIVE = "live"
 HT_MIGRATION_NONLIVE = "non-live"
-HT_MIGRATION_MODES = frozenset([HT_MIGRATION_LIVE, HT_MIGRATION_NONLIVE])
+HT_MIGRATION_MODES = compat.UniqueFrozenset([
+  HT_MIGRATION_LIVE,
+  HT_MIGRATION_NONLIVE,
+  ])
 
 # Cluster Verify steps
 VERIFY_NPLUSONE_MEM = "nplusone_mem"
-VERIFY_OPTIONAL_CHECKS = frozenset([VERIFY_NPLUSONE_MEM])
+VERIFY_OPTIONAL_CHECKS = compat.UniqueFrozenset([VERIFY_NPLUSONE_MEM])
 
 # Cluster Verify error classes
 CV_TCLUSTER = "cluster"
@@ -1358,7 +1422,7 @@ CV_ENODEUSERSCRIPTS = \
 CV_ENODEFILESTORAGEPATHS = \
   (CV_TNODE, "ENODEFILESTORAGEPATHS", "Detected bad file storage paths")
 
-CV_ALL_ECODES = frozenset([
+CV_ALL_ECODES = compat.UniqueFrozenset([
   CV_ECLUSTERCFG,
   CV_ECLUSTERCERT,
   CV_ECLUSTERFILECHECK,
@@ -1393,7 +1457,8 @@ CV_ALL_ECODES = frozenset([
   CV_ENODEFILESTORAGEPATHS,
   ])
 
-CV_ALL_ECODES_STRINGS = frozenset(estr for (_, estr, _) in CV_ALL_ECODES)
+CV_ALL_ECODES_STRINGS = \
+  compat.UniqueFrozenset(estr for (_, estr, _) in CV_ALL_ECODES)
 
 # Node verify constants
 NV_DRBDHELPER = "drbd-helper"
@@ -1428,7 +1493,7 @@ INSTST_NODEDOWN = "ERROR_nodedown"
 INSTST_WRONGNODE = "ERROR_wrongnode"
 INSTST_ERRORUP = "ERROR_up"
 INSTST_ERRORDOWN = "ERROR_down"
-INSTST_ALL = frozenset([
+INSTST_ALL = compat.UniqueFrozenset([
   INSTST_RUNNING,
   INSTST_ADMINDOWN,
   INSTST_ADMINOFFLINE,
@@ -1443,7 +1508,7 @@ INSTST_ALL = frozenset([
 ADMINST_UP = "up"
 ADMINST_DOWN = "down"
 ADMINST_OFFLINE = "offline"
-ADMINST_ALL = frozenset([
+ADMINST_ALL = compat.UniqueFrozenset([
   ADMINST_UP,
   ADMINST_DOWN,
   ADMINST_OFFLINE,
@@ -1455,7 +1520,7 @@ NR_MASTER = "M"
 NR_MCANDIDATE = "C"
 NR_DRAINED = "D"
 NR_OFFLINE = "O"
-NR_ALL = frozenset([
+NR_ALL = compat.UniqueFrozenset([
   NR_REGULAR,
   NR_MASTER,
   NR_MCANDIDATE,
@@ -1471,7 +1536,7 @@ SSL_CERT_EXPIRATION_ERROR = 7
 IALLOCATOR_VERSION = 2
 IALLOCATOR_DIR_IN = "in"
 IALLOCATOR_DIR_OUT = "out"
-VALID_IALLOCATOR_DIRECTIONS = frozenset([
+VALID_IALLOCATOR_DIRECTIONS = compat.UniqueFrozenset([
   IALLOCATOR_DIR_IN,
   IALLOCATOR_DIR_OUT,
   ])
@@ -1480,7 +1545,7 @@ IALLOCATOR_MODE_RELOC = "relocate"
 IALLOCATOR_MODE_CHG_GROUP = "change-group"
 IALLOCATOR_MODE_NODE_EVAC = "node-evacuate"
 IALLOCATOR_MODE_MULTI_ALLOC = "multi-allocate"
-VALID_IALLOCATOR_MODES = frozenset([
+VALID_IALLOCATOR_MODES = compat.UniqueFrozenset([
   IALLOCATOR_MODE_ALLOC,
   IALLOCATOR_MODE_RELOC,
   IALLOCATOR_MODE_CHG_GROUP,
@@ -1493,7 +1558,7 @@ DEFAULT_IALLOCATOR_SHORTCUT = "."
 IALLOCATOR_NEVAC_PRI = "primary-only"
 IALLOCATOR_NEVAC_SEC = "secondary-only"
 IALLOCATOR_NEVAC_ALL = "all"
-IALLOCATOR_NEVAC_MODES = frozenset([
+IALLOCATOR_NEVAC_MODES = compat.UniqueFrozenset([
   IALLOCATOR_NEVAC_PRI,
   IALLOCATOR_NEVAC_SEC,
   IALLOCATOR_NEVAC_ALL,
@@ -1503,7 +1568,7 @@ IALLOCATOR_NEVAC_MODES = frozenset([
 NODE_EVAC_PRI = "primary-only"
 NODE_EVAC_SEC = "secondary-only"
 NODE_EVAC_ALL = "all"
-NODE_EVAC_MODES = frozenset([
+NODE_EVAC_MODES = compat.UniqueFrozenset([
   NODE_EVAC_PRI,
   NODE_EVAC_SEC,
   NODE_EVAC_ALL,
@@ -1527,17 +1592,17 @@ JOB_STATUS_RUNNING = "running"
 JOB_STATUS_CANCELED = "canceled"
 JOB_STATUS_SUCCESS = "success"
 JOB_STATUS_ERROR = "error"
-JOBS_PENDING = frozenset([
+JOBS_PENDING = compat.UniqueFrozenset([
   JOB_STATUS_QUEUED,
   JOB_STATUS_WAITING,
   JOB_STATUS_CANCELING,
   ])
-JOBS_FINALIZED = frozenset([
+JOBS_FINALIZED = compat.UniqueFrozenset([
   JOB_STATUS_CANCELED,
   JOB_STATUS_SUCCESS,
   JOB_STATUS_ERROR,
   ])
-JOB_STATUS_ALL = frozenset([
+JOB_STATUS_ALL = compat.UniqueFrozenset([
   JOB_STATUS_RUNNING,
   ]) | JOBS_PENDING | JOBS_FINALIZED
 
@@ -1551,7 +1616,7 @@ OP_STATUS_RUNNING = "running"
 OP_STATUS_CANCELED = "canceled"
 OP_STATUS_SUCCESS = "success"
 OP_STATUS_ERROR = "error"
-OPS_FINALIZED = frozenset([
+OPS_FINALIZED = compat.UniqueFrozenset([
   OP_STATUS_CANCELED,
   OP_STATUS_SUCCESS,
   OP_STATUS_ERROR,
@@ -1565,7 +1630,7 @@ OP_PRIO_LOW = +10
 OP_PRIO_NORMAL = 0
 OP_PRIO_HIGH = -10
 
-OP_PRIO_SUBMIT_VALID = frozenset([
+OP_PRIO_SUBMIT_VALID = compat.UniqueFrozenset([
   OP_PRIO_LOW,
   OP_PRIO_NORMAL,
   OP_PRIO_HIGH,
@@ -1601,7 +1666,7 @@ JQT_EXPANDNAMES = "expandnames"
 JQT_EXEC = "exec"
 JQT_LOGMSG = "logmsg"
 JQT_STARTMSG = "startmsg"
-JQT_ALL = frozenset([
+JQT_ALL = compat.UniqueFrozenset([
   JQT_EXPANDNAMES,
   JQT_EXEC,
   JQT_LOGMSG,
@@ -1620,7 +1685,7 @@ QR_EXPORT = "export"
 QR_NETWORK = "network"
 
 #: List of resources which can be queried using L{opcodes.OpQuery}
-QR_VIA_OP = frozenset([
+QR_VIA_OP = compat.UniqueFrozenset([
   QR_CLUSTER,
   QR_INSTANCE,
   QR_NODE,
@@ -1649,7 +1714,7 @@ QFT_TIMESTAMP = "timestamp"
 QFT_OTHER = "other"
 
 #: All query field types
-QFT_ALL = frozenset([
+QFT_ALL = compat.UniqueFrozenset([
   QFT_UNKNOWN,
   QFT_TEXT,
   QFT_BOOL,
@@ -1674,7 +1739,7 @@ RS_UNAVAIL = 3
 #: Resource marked offline
 RS_OFFLINE = 4
 
-RS_ALL = frozenset([
+RS_ALL = compat.UniqueFrozenset([
   RS_NORMAL,
   RS_UNKNOWN,
   RS_NODATA,
@@ -1821,7 +1886,7 @@ HVC_DEFAULTS = {
     },
   }
 
-HVC_GLOBALS = frozenset([
+HVC_GLOBALS = compat.UniqueFrozenset([
   HV_MIGRATION_PORT,
   HV_MIGRATION_BANDWIDTH,
   HV_MIGRATION_MODE,
@@ -1971,7 +2036,7 @@ CONFD_REQFIELD_NAME = "0"
 CONFD_REQFIELD_IP = "1"
 CONFD_REQFIELD_MNODE_PIP = "2"
 
-CONFD_REQS = frozenset([
+CONFD_REQS = compat.UniqueFrozenset([
   CONFD_REQ_PING,
   CONFD_REQ_NODE_ROLE_BYNAME,
   CONFD_REQ_NODE_PIP_BY_INSTANCE_IP,
@@ -1986,7 +2051,7 @@ CONFD_REPL_STATUS_OK = 0
 CONFD_REPL_STATUS_ERROR = 1
 CONFD_REPL_STATUS_NOTIMPLEMENTED = 2
 
-CONFD_REPL_STATUSES = frozenset([
+CONFD_REPL_STATUSES = compat.UniqueFrozenset([
   CONFD_REPL_STATUS_OK,
   CONFD_REPL_STATUS_ERROR,
   CONFD_REPL_STATUS_NOTIMPLEMENTED,
@@ -2080,12 +2145,12 @@ FAKE_OP_MASTER_TURNDOWN = "OP_CLUSTER_IP_TURNDOWN"
 # SSH key types
 SSHK_RSA = "rsa"
 SSHK_DSA = "dsa"
-SSHK_ALL = frozenset([SSHK_RSA, SSHK_DSA])
+SSHK_ALL = compat.UniqueFrozenset([SSHK_RSA, SSHK_DSA])
 
 # SSH authorized key types
 SSHAK_RSA = "ssh-rsa"
 SSHAK_DSS = "ssh-dss"
-SSHAK_ALL = frozenset([SSHAK_RSA, SSHAK_DSS])
+SSHAK_ALL = compat.UniqueFrozenset([SSHAK_RSA, SSHAK_DSS])
 
 # SSH setup
 SSHS_CLUSTER_NAME = "cluster_name"
@@ -2106,4 +2171,4 @@ NDS_SSCONF = "ssconf"
 NDS_START_NODE_DAEMON = "start_node_daemon"
 
 # Do not re-export imported modules
-del re, _vcsversion, _autoconf, socket, pathutils
+del re, _vcsversion, _autoconf, socket, pathutils, compat
index 486c638..3a264c3 100644 (file)
 # 02110-1301, USA.
 
 
-"""Ganeti exception handling"""
+"""Ganeti exception handling.
+
+"""
+
+from ganeti import compat
 
 
 # OpPrereqError failure types
@@ -55,7 +59,7 @@ ECODE_FAULT = "internal_error"
 ECODE_ENVIRON = "environment_error"
 
 #: List of all failure types
-ECODE_ALL = frozenset([
+ECODE_ALL = compat.UniqueFrozenset([
   ECODE_RESOLVER,
   ECODE_NORES,
   ECODE_TEMP_NORES,
index 0131cb0..dd6e981 100644 (file)
@@ -36,6 +36,7 @@ from ganeti import constants
 from ganeti import errors
 from ganeti import utils
 from ganeti import netutils
+from ganeti import compat
 
 
 #: Used to recognize point at which socat(1) starts to listen on its socket.
@@ -56,7 +57,7 @@ SOCAT_LOG_WARNING = "W"
 SOCAT_LOG_ERROR = "E"
 SOCAT_LOG_FATAL = "F"
 
-SOCAT_LOG_IGNORE = frozenset([
+SOCAT_LOG_IGNORE = compat.UniqueFrozenset([
   SOCAT_LOG_DEBUG,
   SOCAT_LOG_INFO,
   SOCAT_LOG_NOTICE,
@@ -93,7 +94,8 @@ SOCAT_OPTION_MAXLEN = 400
  PROG_DD,
  PROG_DD_PID,
  PROG_EXP_SIZE) = range(1, 6)
-PROG_ALL = frozenset([
+
+PROG_ALL = compat.UniqueFrozenset([
   PROG_OTHER,
   PROG_SOCAT,
   PROG_DD,
index eb96a70..abcf22b 100644 (file)
@@ -56,7 +56,7 @@ _LOCK_ACQUIRE_MIN_TIMEOUT = (1.0 / 1000)
  _LS_ACQUIRE_ALL,
  _LS_ACQUIRE_OPPORTUNISTIC) = range(1, 4)
 
-_LS_ACQUIRE_MODES = frozenset([
+_LS_ACQUIRE_MODES = compat.UniqueFrozenset([
   _LS_ACQUIRE_EXACT,
   _LS_ACQUIRE_ALL,
   _LS_ACQUIRE_OPPORTUNISTIC,
@@ -1599,7 +1599,7 @@ LEVELS = [
   ]
 
 # Lock levels which are modifiable
-LEVELS_MOD = frozenset([
+LEVELS_MOD = compat.UniqueFrozenset([
   LEVEL_NODE_RES,
   LEVEL_NODE,
   LEVEL_NODEGROUP,
index 2009749..a84085d 100644 (file)
@@ -35,6 +35,7 @@ import time
 import errno
 import logging
 
+from ganeti import compat
 from ganeti import serializer
 from ganeti import constants
 from ganeti import errors
@@ -71,7 +72,7 @@ REQ_SET_DRAIN_FLAG = "SetDrainFlag"
 REQ_SET_WATCHER_PAUSE = "SetWatcherPause"
 
 #: List of all LUXI requests
-REQ_ALL = frozenset([
+REQ_ALL = compat.UniqueFrozenset([
   REQ_ARCHIVE_JOB,
   REQ_AUTO_ARCHIVE_JOBS,
   REQ_CANCEL_JOB,
index 2851f29..a7e705a 100644 (file)
@@ -50,12 +50,12 @@ _LU_PREFIX = "LU"
 
 #: LU classes which don't need to acquire the node allocation lock
 #: (L{locking.NAL}) when they acquire all node or node resource locks
-_NODE_ALLOC_WHITELIST = frozenset()
+_NODE_ALLOC_WHITELIST = frozenset([])
 
 #: LU classes which don't need to acquire the node allocation lock
 #: (L{locking.NAL}) in the same mode (shared/exclusive) as the node
 #: or node resource locks
-_NODE_ALLOC_MODE_WHITELIST = frozenset([
+_NODE_ALLOC_MODE_WHITELIST = compat.UniqueFrozenset([
   cmdlib.LUBackupExport,
   cmdlib.LUBackupRemove,
   cmdlib.LUOobCommand,
index 8bea0a6..0334c3d 100644 (file)
@@ -24,6 +24,7 @@
 """
 
 from ganeti import _autoconf
+from ganeti import compat
 from ganeti import vcluster
 
 
@@ -130,7 +131,7 @@ JOB_QUEUE_SERIAL_FILE = QUEUE_DIR + "/serial"
 JOB_QUEUE_ARCHIVE_DIR = QUEUE_DIR + "/archive"
 JOB_QUEUE_DRAIN_FILE = QUEUE_DIR + "/drain"
 
-ALL_CERT_FILES = frozenset([
+ALL_CERT_FILES = compat.UniqueFrozenset([
   NODED_CERT_FILE,
   RAPI_CERT_FILE,
   SPICE_CERT_FILE,
index 7efdaa4..3ccc6c2 100644 (file)
@@ -137,7 +137,12 @@ _FS_UNAVAIL = object()
 _FS_OFFLINE = object()
 
 #: List of all special status
-_FS_ALL = frozenset([_FS_UNKNOWN, _FS_NODATA, _FS_UNAVAIL, _FS_OFFLINE])
+_FS_ALL = compat.UniqueFrozenset([
+  _FS_UNKNOWN,
+  _FS_NODATA,
+  _FS_UNAVAIL,
+  _FS_OFFLINE,
+  ])
 
 #: VType to QFT mapping
 _VTToQFT = {
index be08b2a..18c933c 100644 (file)
@@ -1,7 +1,7 @@
 #
 #
 
-# Copyright (C) 2007, 2008 Google Inc.
+# Copyright (C) 2007, 2008, 2012 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
 
 """Ganeti RAPI module"""
 
+from ganeti import compat
+
+
 RAPI_ACCESS_WRITE = "write"
 RAPI_ACCESS_READ = "read"
 
-RAPI_ACCESS_ALL = frozenset([
+RAPI_ACCESS_ALL = compat.UniqueFrozenset([
   RAPI_ACCESS_WRITE,
   RAPI_ACCESS_READ,
   ])
index 99a71a0..15d1e32 100644 (file)
@@ -42,7 +42,7 @@ from ganeti import pathutils
 _DEFAULT = object()
 
 #: Supported HTTP methods
-_SUPPORTED_METHODS = frozenset([
+_SUPPORTED_METHODS = compat.UniqueFrozenset([
   http.HTTP_DELETE,
   http.HTTP_GET,
   http.HTTP_POST,
index c7596c9..bfd5415 100644 (file)
@@ -155,7 +155,7 @@ _NODE_MIGRATE_REQV1 = "node-migrate-reqv1"
 # Feature string for node evacuation with LU-generated jobs
 _NODE_EVAC_RES1 = "node-evac-res1"
 
-ALL_FEATURES = frozenset([
+ALL_FEATURES = compat.UniqueFrozenset([
   _INST_CREATE_REQV1,
   _INST_REINSTALL_REQV1,
   _NODE_MIGRATE_REQV1,
index c1f5ce1..fc79422 100644 (file)
@@ -30,6 +30,7 @@ import sys
 import errno
 import logging
 
+from ganeti import compat
 from ganeti import errors
 from ganeti import constants
 from ganeti import utils
@@ -40,7 +41,7 @@ from ganeti import pathutils
 SSCONF_LOCK_TIMEOUT = 10
 
 #: Valid ssconf keys
-_VALID_KEYS = frozenset([
+_VALID_KEYS = compat.UniqueFrozenset([
   constants.SS_CLUSTER_NAME,
   constants.SS_CLUSTER_TAGS,
   constants.SS_FILE_STORAGE_DIR,
index 11dece3..95d2fce 100644 (file)
@@ -35,13 +35,14 @@ from ganeti import ssconf
 from ganeti import utils
 from ganeti import cli
 from ganeti import pathutils
+from ganeti import compat
 
 
 (DIR,
  FILE,
  QUEUE_DIR) = range(1, 4)
 
-ALL_TYPES = frozenset([
+ALL_TYPES = compat.UniqueFrozenset([
   DIR,
   FILE,
   QUEUE_DIR,
index 0443d11..ed28cab 100644 (file)
@@ -39,7 +39,7 @@ _ROOTDIR_ENVNAME = "GANETI_ROOTDIR"
 _HOSTNAME_ENVNAME = "GANETI_HOSTNAME"
 
 #: List of paths which shouldn't be virtualized
-_VPATH_WHITELIST = frozenset([
+_VPATH_WHITELIST = compat.UniqueFrozenset([
   ETC_HOSTS,
   ])
 
index c60f4a1..a4fb16e 100644 (file)
@@ -59,10 +59,10 @@ from ganeti.watcher import state
 
 
 MAXTRIES = 5
-BAD_STATES = frozenset([
+BAD_STATES = compat.UniqueFrozenset([
   constants.INSTST_ERRORDOWN,
   ])
-HELPLESS_STATES = frozenset([
+HELPLESS_STATES = compat.UniqueFrozenset([
   constants.INSTST_NODEDOWN,
   constants.INSTST_NODEOFFLINE,
   ])
index dfea6cb..0401107 100644 (file)
@@ -104,13 +104,13 @@ NODE_FIELDS = ("name", "dtotal", "dfree",
                "mtotal", "mnode", "mfree",
                "pinst_cnt", "sinst_cnt", "tags")
 
-GROUP_FIELDS = frozenset([
+GROUP_FIELDS = compat.UniqueFrozenset([
   "name", "uuid",
   "alloc_policy",
   "node_cnt", "node_list",
   ])
 
-JOB_FIELDS = frozenset([
+JOB_FIELDS = compat.UniqueFrozenset([
   "id", "ops", "status", "summary",
   "opstatus", "opresult", "oplog",
   "received_ts", "start_ts", "end_ts",
index 1fa24f5..f66b66b 100755 (executable)
@@ -43,7 +43,7 @@ import testutils
 
 VALID_URI_RE = re.compile(r"^[-/a-z0-9]*$")
 
-RAPI_OPCODE_EXCLUDE = frozenset([
+RAPI_OPCODE_EXCLUDE = compat.UniqueFrozenset([
   # Not yet implemented
   opcodes.OpBackupQuery,
   opcodes.OpBackupRemove,
@@ -89,7 +89,7 @@ def _ReadDocFile(filename):
 
 
 class TestHooksDocs(unittest.TestCase):
-  HOOK_PATH_OK = frozenset([
+  HOOK_PATH_OK = compat.UniqueFrozenset([
     "master-ip-turnup",
     "master-ip-turndown",
     ])
@@ -223,7 +223,7 @@ class TestRapiDocs(unittest.TestCase):
 
       prevline = line
 
-    prefix_exception = frozenset(["/", "/version", "/2"])
+    prefix_exception = compat.UniqueFrozenset(["/", "/version", "/2"])
 
     undocumented = []
     used_uris = []
index 33d2d67..8a997a0 100755 (executable)
@@ -25,6 +25,7 @@
 import unittest
 import itertools
 
+from ganeti import compat
 from ganeti import mcpu
 from ganeti import opcodes
 from ganeti import cmdlib
@@ -38,7 +39,7 @@ from ganeti.constants import \
 import testutils
 
 
-REQ_BGL_WHITELIST = frozenset([
+REQ_BGL_WHITELIST = compat.UniqueFrozenset([
   opcodes.OpClusterActivateMasterIp,
   opcodes.OpClusterDeactivateMasterIp,
   opcodes.OpClusterDestroy,
index 9cc80ff..98ec769 100755 (executable)
@@ -37,7 +37,7 @@ import testutils
 
 #: Unless an opcode is included in the following list it must have a result
 #: check of some sort
-MISSING_RESULT_CHECK = frozenset([
+MISSING_RESULT_CHECK = compat.UniqueFrozenset([
   opcodes.OpTestAllocator,
   opcodes.OpTestDelay,
   opcodes.OpTestDummy,
index 91ba27d..a2f3fca 100755 (executable)
@@ -37,7 +37,7 @@ import ganeti.rapi.client
 import testutils
 
 
-KNOWN_UNUSED_LUXI = frozenset([
+KNOWN_UNUSED_LUXI = compat.UniqueFrozenset([
   luxi.REQ_SUBMIT_MANY_JOBS,
   luxi.REQ_ARCHIVE_JOB,
   luxi.REQ_AUTO_ARCHIVE_JOBS,
index a066335..a4787d4 100755 (executable)
@@ -41,6 +41,7 @@ from ganeti import errors
 from ganeti import ssh
 from ganeti import utils
 from ganeti import pathutils
+from ganeti import compat
 
 
 _GROUPS_MERGE = "merge"
@@ -134,7 +135,7 @@ class Merger(object):
   """Handling the merge.
 
   """
-  RUNNING_STATUSES = frozenset([
+  RUNNING_STATUSES = compat.UniqueFrozenset([
     constants.INSTST_RUNNING,
     constants.INSTST_ERRORUP,
     ])
index 2049bcf..b79dc11 100755 (executable)
@@ -68,7 +68,7 @@ SUPPORTED_TYPES = [
   ]
 
 #: Excluded filesystem types
-EXCLUDED_FS = frozenset([
+EXCLUDED_FS = compat.UniqueFrozenset([
   "nfs",
   "nfs4",
   "autofs",