__slots__ attribute for this class.
"""
+ slots = self._all_slots()
for key in kwargs:
- if key not in self.__slots__:
+ if key not in slots:
raise TypeError("Object %s doesn't support the parameter '%s'" %
(self.__class__.__name__, key))
setattr(self, key, kwargs[key])
"""
state = {}
- for name in self.__slots__:
+ for name in self._all_slots():
if hasattr(self, name):
state[name] = getattr(self, name)
return state
raise ValueError("Invalid data to __setstate__: expected dict, got %s" %
type(state))
- for name in self.__slots__:
+ for name in self._all_slots():
if name not in state:
delattr(self, name)
for name in state:
setattr(self, name, state[name])
+ @classmethod
+ def _all_slots(cls):
+ """Compute the list of all declared slots for a class.
+
+ """
+ slots = []
+ for parent in cls.__mro__:
+ slots.extend(getattr(parent, "__slots__", []))
+ return slots
+
class OpCode(BaseOpCode):
"""Abstract OpCode.
"""
OP_ID = "OP_ABSTRACT"
- __slots__ = BaseOpCode.__slots__ + ["dry_run"]
+ __slots__ = ["dry_run", "debug_level"]
def __getstate__(self):
"""Specialized getstate for opcodes.
"""
OP_ID = "OP_CLUSTER_POST_INIT"
- __slots__ = OpCode.__slots__ + []
+ __slots__ = []
class OpDestroyCluster(OpCode):
"""
OP_ID = "OP_CLUSTER_DESTROY"
- __slots__ = OpCode.__slots__ + []
+ __slots__ = []
class OpQueryClusterInfo(OpCode):
"""Query cluster information."""
OP_ID = "OP_CLUSTER_QUERY"
- __slots__ = OpCode.__slots__ + []
+ __slots__ = []
class OpVerifyCluster(OpCode):
"""
OP_ID = "OP_CLUSTER_VERIFY"
- __slots__ = OpCode.__slots__ + ["skip_checks"]
+ __slots__ = ["skip_checks", "verbose", "error_codes",
+ "debug_simulate_errors"]
class OpVerifyDisks(OpCode):
"""
OP_ID = "OP_CLUSTER_VERIFY_DISKS"
- __slots__ = OpCode.__slots__ + []
+ __slots__ = []
class OpRepairDiskSizes(OpCode):
class OpQueryConfigValues(OpCode):
"""Query cluster configuration values."""
OP_ID = "OP_CLUSTER_CONFIG_QUERY"
- __slots__ = OpCode.__slots__ + ["output_fields"]
+ __slots__ = ["output_fields"]
class OpRenameCluster(OpCode):
"""
OP_ID = "OP_CLUSTER_RENAME"
OP_DSC_FIELD = "name"
- __slots__ = OpCode.__slots__ + ["name"]
+ __slots__ = ["name"]
class OpSetClusterParams(OpCode):
"""
OP_ID = "OP_CLUSTER_SET_PARAMS"
- __slots__ = OpCode.__slots__ + [
+ __slots__ = [
"vg_name",
"enabled_hypervisors",
"hvparams",
"""
OP_ID = "OP_CLUSTER_REDIST_CONF"
- __slots__ = OpCode.__slots__ + [
- ]
+ __slots__ = []
# node opcodes
"""
OP_ID = "OP_NODE_REMOVE"
OP_DSC_FIELD = "node_name"
- __slots__ = OpCode.__slots__ + ["node_name"]
+ __slots__ = ["node_name"]
class OpAddNode(OpCode):
"""
OP_ID = "OP_NODE_ADD"
OP_DSC_FIELD = "node_name"
- __slots__ = OpCode.__slots__ + [
- "node_name", "primary_ip", "secondary_ip", "readd",
- ]
+ __slots__ = ["node_name", "primary_ip", "secondary_ip", "readd"]
class OpQueryNodes(OpCode):
"""Compute the list of nodes."""
OP_ID = "OP_NODE_QUERY"
- __slots__ = OpCode.__slots__ + ["output_fields", "names", "use_locking"]
+ __slots__ = ["output_fields", "names", "use_locking"]
class OpQueryNodeVolumes(OpCode):
"""Get list of volumes on node."""
OP_ID = "OP_NODE_QUERYVOLS"
- __slots__ = OpCode.__slots__ + ["nodes", "output_fields"]
+ __slots__ = ["nodes", "output_fields"]
class OpQueryNodeStorage(OpCode):
"""Get information on storage for node(s)."""
OP_ID = "OP_NODE_QUERY_STORAGE"
- __slots__ = OpCode.__slots__ + [
+ __slots__ = [
"nodes",
"storage_type",
"name",
class OpModifyNodeStorage(OpCode):
- """"""
+ """Modifies the properies of a storage unit"""
OP_ID = "OP_NODE_MODIFY_STORAGE"
- __slots__ = OpCode.__slots__ + [
+ __slots__ = [
"node_name",
"storage_type",
"name",
"""Repairs the volume group on a node."""
OP_ID = "OP_REPAIR_NODE_STORAGE"
OP_DSC_FIELD = "node_name"
- __slots__ = OpCode.__slots__ + [
+ __slots__ = [
"node_name",
"storage_type",
"name",
+ "ignore_consistency",
]
"""Change the parameters of a node."""
OP_ID = "OP_NODE_SET_PARAMS"
OP_DSC_FIELD = "node_name"
- __slots__ = OpCode.__slots__ + [
+ __slots__ = [
"node_name",
"force",
"master_candidate",
"""Tries to powercycle a node."""
OP_ID = "OP_NODE_POWERCYCLE"
OP_DSC_FIELD = "node_name"
- __slots__ = OpCode.__slots__ + [
+ __slots__ = [
"node_name",
"force",
]
"""Relocate secondary instances from a node."""
OP_ID = "OP_NODE_EVACUATE"
OP_DSC_FIELD = "node_name"
- __slots__ = OpCode.__slots__ + [
- "node_name", "remote_node", "iallocator",
+ __slots__ = [
+ "node_name", "remote_node", "iallocator", "early_release",
]
"""Migrate all instances from a node."""
OP_ID = "OP_NODE_MIGRATE"
OP_DSC_FIELD = "node_name"
- __slots__ = OpCode.__slots__ + [
+ __slots__ = [
"node_name",
"live",
]
"""Create an instance."""
OP_ID = "OP_INSTANCE_CREATE"
OP_DSC_FIELD = "instance_name"
- __slots__ = OpCode.__slots__ + [
- "instance_name", "os_type", "pnode",
- "disk_template", "snode", "mode",
+ __slots__ = [
+ "instance_name", "os_type", "force_variant",
+ "pnode", "disk_template", "snode", "mode",
"disks", "nics",
"src_node", "src_path", "start",
- "wait_for_sync", "ip_check",
+ "wait_for_sync", "ip_check", "name_check",
"file_storage_dir", "file_driver",
"iallocator",
"hypervisor", "hvparams", "beparams",
"""Reinstall an instance's OS."""
OP_ID = "OP_INSTANCE_REINSTALL"
OP_DSC_FIELD = "instance_name"
- __slots__ = OpCode.__slots__ + ["instance_name", "os_type"]
+ __slots__ = ["instance_name", "os_type", "force_variant"]
class OpRemoveInstance(OpCode):
"""Remove an instance."""
OP_ID = "OP_INSTANCE_REMOVE"
OP_DSC_FIELD = "instance_name"
- __slots__ = OpCode.__slots__ + ["instance_name", "ignore_failures"]
+ __slots__ = [
+ "instance_name",
+ "ignore_failures",
+ "shutdown_timeout",
+ ]
class OpRenameInstance(OpCode):
"""Rename an instance."""
OP_ID = "OP_INSTANCE_RENAME"
- __slots__ = OpCode.__slots__ + [
+ __slots__ = [
"instance_name", "ignore_ip", "new_name",
]
"""Startup an instance."""
OP_ID = "OP_INSTANCE_STARTUP"
OP_DSC_FIELD = "instance_name"
- __slots__ = OpCode.__slots__ + [
+ __slots__ = [
"instance_name", "force", "hvparams", "beparams",
]
"""Shutdown an instance."""
OP_ID = "OP_INSTANCE_SHUTDOWN"
OP_DSC_FIELD = "instance_name"
- __slots__ = OpCode.__slots__ + ["instance_name"]
+ __slots__ = ["instance_name", "timeout"]
class OpRebootInstance(OpCode):
"""Reboot an instance."""
OP_ID = "OP_INSTANCE_REBOOT"
OP_DSC_FIELD = "instance_name"
- __slots__ = OpCode.__slots__ + [
- "instance_name", "reboot_type", "ignore_secondaries",
+ __slots__ = [
+ "instance_name", "reboot_type", "ignore_secondaries", "shutdown_timeout",
]
"""Replace the disks of an instance."""
OP_ID = "OP_INSTANCE_REPLACE_DISKS"
OP_DSC_FIELD = "instance_name"
- __slots__ = OpCode.__slots__ + [
+ __slots__ = [
"instance_name", "remote_node", "mode", "disks", "iallocator",
+ "early_release",
]
"""Failover an instance."""
OP_ID = "OP_INSTANCE_FAILOVER"
OP_DSC_FIELD = "instance_name"
- __slots__ = OpCode.__slots__ + ["instance_name", "ignore_consistency"]
+ __slots__ = [
+ "instance_name", "ignore_consistency", "shutdown_timeout",
+ ]
class OpMigrateInstance(OpCode):
"""
OP_ID = "OP_INSTANCE_MIGRATE"
OP_DSC_FIELD = "instance_name"
- __slots__ = OpCode.__slots__ + ["instance_name", "live", "cleanup"]
+ __slots__ = ["instance_name", "live", "cleanup"]
class OpMoveInstance(OpCode):
"""
OP_ID = "OP_INSTANCE_MOVE"
OP_DSC_FIELD = "instance_name"
- __slots__ = OpCode.__slots__ + ["instance_name", "target_node"]
+ __slots__ = [
+ "instance_name", "target_node", "shutdown_timeout",
+ ]
class OpConnectConsole(OpCode):
"""Connect to an instance's console."""
OP_ID = "OP_INSTANCE_CONSOLE"
OP_DSC_FIELD = "instance_name"
- __slots__ = OpCode.__slots__ + ["instance_name"]
+ __slots__ = ["instance_name"]
class OpActivateInstanceDisks(OpCode):
"""Activate an instance's disks."""
OP_ID = "OP_INSTANCE_ACTIVATE_DISKS"
OP_DSC_FIELD = "instance_name"
- __slots__ = OpCode.__slots__ + ["instance_name", "ignore_size"]
+ __slots__ = ["instance_name", "ignore_size"]
class OpDeactivateInstanceDisks(OpCode):
"""Deactivate an instance's disks."""
OP_ID = "OP_INSTANCE_DEACTIVATE_DISKS"
OP_DSC_FIELD = "instance_name"
- __slots__ = OpCode.__slots__ + ["instance_name"]
+ __slots__ = ["instance_name"]
class OpRecreateInstanceDisks(OpCode):
"""Deactivate an instance's disks."""
OP_ID = "OP_INSTANCE_RECREATE_DISKS"
OP_DSC_FIELD = "instance_name"
- __slots__ = OpCode.__slots__ + ["instance_name", "disks"]
+ __slots__ = ["instance_name", "disks"]
class OpQueryInstances(OpCode):
"""Compute the list of instances."""
OP_ID = "OP_INSTANCE_QUERY"
- __slots__ = OpCode.__slots__ + ["output_fields", "names", "use_locking"]
+ __slots__ = ["output_fields", "names", "use_locking"]
class OpQueryInstanceData(OpCode):
"""Compute the run-time status of instances."""
OP_ID = "OP_INSTANCE_QUERY_DATA"
- __slots__ = OpCode.__slots__ + ["instances", "static"]
+ __slots__ = ["instances", "static"]
class OpSetInstanceParams(OpCode):
"""Change the parameters of an instance."""
OP_ID = "OP_INSTANCE_SET_PARAMS"
OP_DSC_FIELD = "instance_name"
- __slots__ = OpCode.__slots__ + [
+ __slots__ = [
"instance_name",
"hvparams", "beparams", "force",
"nics", "disks",
"""Grow a disk of an instance."""
OP_ID = "OP_INSTANCE_GROW_DISK"
OP_DSC_FIELD = "instance_name"
- __slots__ = OpCode.__slots__ + [
+ __slots__ = [
"instance_name", "disk", "amount", "wait_for_sync",
]
class OpDiagnoseOS(OpCode):
"""Compute the list of guest operating systems."""
OP_ID = "OP_OS_DIAGNOSE"
- __slots__ = OpCode.__slots__ + ["output_fields", "names"]
+ __slots__ = ["output_fields", "names"]
# Exports opcodes
class OpQueryExports(OpCode):
"""Compute the list of exported images."""
OP_ID = "OP_BACKUP_QUERY"
- __slots__ = OpCode.__slots__ + ["nodes", "use_locking"]
+ __slots__ = ["nodes", "use_locking"]
class OpExportInstance(OpCode):
"""Export an instance."""
OP_ID = "OP_BACKUP_EXPORT"
OP_DSC_FIELD = "instance_name"
- __slots__ = OpCode.__slots__ + ["instance_name", "target_node", "shutdown"]
+ __slots__ = [
+ "instance_name", "target_node", "shutdown", "shutdown_timeout",
+ ]
class OpRemoveExport(OpCode):
"""Remove an instance's export."""
OP_ID = "OP_BACKUP_REMOVE"
OP_DSC_FIELD = "instance_name"
- __slots__ = OpCode.__slots__ + ["instance_name"]
+ __slots__ = ["instance_name"]
# Tags opcodes
"""Returns the tags of the given object."""
OP_ID = "OP_TAGS_GET"
OP_DSC_FIELD = "name"
- __slots__ = OpCode.__slots__ + ["kind", "name"]
+ __slots__ = ["kind", "name"]
class OpSearchTags(OpCode):
"""Searches the tags in the cluster for a given pattern."""
OP_ID = "OP_TAGS_SEARCH"
OP_DSC_FIELD = "pattern"
- __slots__ = OpCode.__slots__ + ["pattern"]
+ __slots__ = ["pattern"]
class OpAddTags(OpCode):
"""Add a list of tags on a given object."""
OP_ID = "OP_TAGS_SET"
- __slots__ = OpCode.__slots__ + ["kind", "name", "tags"]
+ __slots__ = ["kind", "name", "tags"]
class OpDelTags(OpCode):
"""Remove a list of tags from a given object."""
OP_ID = "OP_TAGS_DEL"
- __slots__ = OpCode.__slots__ + ["kind", "name", "tags"]
+ __slots__ = ["kind", "name", "tags"]
# Test opcodes
"""
OP_ID = "OP_TEST_DELAY"
OP_DSC_FIELD = "duration"
- __slots__ = OpCode.__slots__ + ["duration", "on_master", "on_nodes"]
+ __slots__ = ["duration", "on_master", "on_nodes"]
class OpTestAllocator(OpCode):
"""
OP_ID = "OP_TEST_ALLOCATOR"
OP_DSC_FIELD = "allocator"
- __slots__ = OpCode.__slots__ + [
+ __slots__ = [
"direction", "mode", "allocator", "name",
"mem_size", "disks", "disk_template",
"os", "tags", "nics", "vcpus", "hypervisor",