Commit 4f05fd3b authored by Iustin Pop's avatar Iustin Pop
Browse files

Introduce __slots__ deriving in opcodes.py



This simple patch adds to all opcodes extension of the base opcode
__slots__. This way we can add slots across all opcodes, for example
'dry-run'.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent f2fd87d7
...@@ -107,7 +107,7 @@ class OpCode(BaseOpCode): ...@@ -107,7 +107,7 @@ class OpCode(BaseOpCode):
""" """
OP_ID = "OP_ABSTRACT" OP_ID = "OP_ABSTRACT"
__slots__ = [] __slots__ = BaseOpCode.__slots__ + []
def __getstate__(self): def __getstate__(self):
"""Specialized getstate for opcodes. """Specialized getstate for opcodes.
...@@ -181,13 +181,13 @@ class OpDestroyCluster(OpCode): ...@@ -181,13 +181,13 @@ class OpDestroyCluster(OpCode):
""" """
OP_ID = "OP_CLUSTER_DESTROY" OP_ID = "OP_CLUSTER_DESTROY"
__slots__ = [] __slots__ = OpCode.__slots__ + []
class OpQueryClusterInfo(OpCode): class OpQueryClusterInfo(OpCode):
"""Query cluster information.""" """Query cluster information."""
OP_ID = "OP_CLUSTER_QUERY" OP_ID = "OP_CLUSTER_QUERY"
__slots__ = [] __slots__ = OpCode.__slots__ + []
class OpVerifyCluster(OpCode): class OpVerifyCluster(OpCode):
...@@ -201,7 +201,7 @@ class OpVerifyCluster(OpCode): ...@@ -201,7 +201,7 @@ class OpVerifyCluster(OpCode):
""" """
OP_ID = "OP_CLUSTER_VERIFY" OP_ID = "OP_CLUSTER_VERIFY"
__slots__ = ["skip_checks"] __slots__ = OpCode.__slots__ + ["skip_checks"]
class OpVerifyDisks(OpCode): class OpVerifyDisks(OpCode):
...@@ -226,13 +226,13 @@ class OpVerifyDisks(OpCode): ...@@ -226,13 +226,13 @@ class OpVerifyDisks(OpCode):
""" """
OP_ID = "OP_CLUSTER_VERIFY_DISKS" OP_ID = "OP_CLUSTER_VERIFY_DISKS"
__slots__ = [] __slots__ = OpCode.__slots__ + []
class OpQueryConfigValues(OpCode): class OpQueryConfigValues(OpCode):
"""Query cluster configuration values.""" """Query cluster configuration values."""
OP_ID = "OP_CLUSTER_CONFIG_QUERY" OP_ID = "OP_CLUSTER_CONFIG_QUERY"
__slots__ = ["output_fields"] __slots__ = OpCode.__slots__ + ["output_fields"]
class OpRenameCluster(OpCode): class OpRenameCluster(OpCode):
...@@ -246,7 +246,7 @@ class OpRenameCluster(OpCode): ...@@ -246,7 +246,7 @@ class OpRenameCluster(OpCode):
""" """
OP_ID = "OP_CLUSTER_RENAME" OP_ID = "OP_CLUSTER_RENAME"
OP_DSC_FIELD = "name" OP_DSC_FIELD = "name"
__slots__ = ["name"] __slots__ = OpCode.__slots__ + ["name"]
class OpSetClusterParams(OpCode): class OpSetClusterParams(OpCode):
...@@ -257,7 +257,7 @@ class OpSetClusterParams(OpCode): ...@@ -257,7 +257,7 @@ class OpSetClusterParams(OpCode):
""" """
OP_ID = "OP_CLUSTER_SET_PARAMS" OP_ID = "OP_CLUSTER_SET_PARAMS"
__slots__ = [ __slots__ = OpCode.__slots__ + [
"vg_name", "vg_name",
"enabled_hypervisors", "enabled_hypervisors",
"hvparams", "hvparams",
...@@ -272,7 +272,7 @@ class OpRedistributeConfig(OpCode): ...@@ -272,7 +272,7 @@ class OpRedistributeConfig(OpCode):
""" """
OP_ID = "OP_CLUSTER_REDIST_CONF" OP_ID = "OP_CLUSTER_REDIST_CONF"
__slots__ = [ __slots__ = OpCode.__slots__ + [
] ]
# node opcodes # node opcodes
...@@ -287,7 +287,7 @@ class OpRemoveNode(OpCode): ...@@ -287,7 +287,7 @@ class OpRemoveNode(OpCode):
""" """
OP_ID = "OP_NODE_REMOVE" OP_ID = "OP_NODE_REMOVE"
OP_DSC_FIELD = "node_name" OP_DSC_FIELD = "node_name"
__slots__ = ["node_name"] __slots__ = OpCode.__slots__ + ["node_name"]
class OpAddNode(OpCode): class OpAddNode(OpCode):
...@@ -314,26 +314,28 @@ class OpAddNode(OpCode): ...@@ -314,26 +314,28 @@ class OpAddNode(OpCode):
""" """
OP_ID = "OP_NODE_ADD" OP_ID = "OP_NODE_ADD"
OP_DSC_FIELD = "node_name" OP_DSC_FIELD = "node_name"
__slots__ = ["node_name", "primary_ip", "secondary_ip", "readd"] __slots__ = OpCode.__slots__ + [
"node_name", "primary_ip", "secondary_ip", "readd",
]
class OpQueryNodes(OpCode): class OpQueryNodes(OpCode):
"""Compute the list of nodes.""" """Compute the list of nodes."""
OP_ID = "OP_NODE_QUERY" OP_ID = "OP_NODE_QUERY"
__slots__ = ["output_fields", "names", "use_locking"] __slots__ = OpCode.__slots__ + ["output_fields", "names", "use_locking"]
class OpQueryNodeVolumes(OpCode): class OpQueryNodeVolumes(OpCode):
"""Get list of volumes on node.""" """Get list of volumes on node."""
OP_ID = "OP_NODE_QUERYVOLS" OP_ID = "OP_NODE_QUERYVOLS"
__slots__ = ["nodes", "output_fields"] __slots__ = OpCode.__slots__ + ["nodes", "output_fields"]
class OpSetNodeParams(OpCode): class OpSetNodeParams(OpCode):
"""Change the parameters of a node.""" """Change the parameters of a node."""
OP_ID = "OP_NODE_SET_PARAMS" OP_ID = "OP_NODE_SET_PARAMS"
OP_DSC_FIELD = "node_name" OP_DSC_FIELD = "node_name"
__slots__ = [ __slots__ = OpCode.__slots__ + [
"node_name", "node_name",
"force", "force",
"master_candidate", "master_candidate",
...@@ -346,7 +348,7 @@ class OpPowercycleNode(OpCode): ...@@ -346,7 +348,7 @@ class OpPowercycleNode(OpCode):
"""Tries to powercycle a node.""" """Tries to powercycle a node."""
OP_ID = "OP_NODE_POWERCYCLE" OP_ID = "OP_NODE_POWERCYCLE"
OP_DSC_FIELD = "node_name" OP_DSC_FIELD = "node_name"
__slots__ = [ __slots__ = OpCode.__slots__ + [
"node_name", "node_name",
"force", "force",
] ]
...@@ -357,7 +359,7 @@ class OpCreateInstance(OpCode): ...@@ -357,7 +359,7 @@ class OpCreateInstance(OpCode):
"""Create an instance.""" """Create an instance."""
OP_ID = "OP_INSTANCE_CREATE" OP_ID = "OP_INSTANCE_CREATE"
OP_DSC_FIELD = "instance_name" OP_DSC_FIELD = "instance_name"
__slots__ = [ __slots__ = OpCode.__slots__ + [
"instance_name", "os_type", "pnode", "instance_name", "os_type", "pnode",
"disk_template", "snode", "mode", "disk_template", "snode", "mode",
"disks", "nics", "disks", "nics",
...@@ -366,6 +368,7 @@ class OpCreateInstance(OpCode): ...@@ -366,6 +368,7 @@ class OpCreateInstance(OpCode):
"file_storage_dir", "file_driver", "file_storage_dir", "file_driver",
"iallocator", "iallocator",
"hypervisor", "hvparams", "beparams", "hypervisor", "hvparams", "beparams",
"dry_run",
] ]
...@@ -373,55 +376,63 @@ class OpReinstallInstance(OpCode): ...@@ -373,55 +376,63 @@ class OpReinstallInstance(OpCode):
"""Reinstall an instance's OS.""" """Reinstall an instance's OS."""
OP_ID = "OP_INSTANCE_REINSTALL" OP_ID = "OP_INSTANCE_REINSTALL"
OP_DSC_FIELD = "instance_name" OP_DSC_FIELD = "instance_name"
__slots__ = ["instance_name", "os_type"] __slots__ = OpCode.__slots__ + ["instance_name", "os_type"]
class OpRemoveInstance(OpCode): class OpRemoveInstance(OpCode):
"""Remove an instance.""" """Remove an instance."""
OP_ID = "OP_INSTANCE_REMOVE" OP_ID = "OP_INSTANCE_REMOVE"
OP_DSC_FIELD = "instance_name" OP_DSC_FIELD = "instance_name"
__slots__ = ["instance_name", "ignore_failures"] __slots__ = OpCode.__slots__ + ["instance_name", "ignore_failures"]
class OpRenameInstance(OpCode): class OpRenameInstance(OpCode):
"""Rename an instance.""" """Rename an instance."""
OP_ID = "OP_INSTANCE_RENAME" OP_ID = "OP_INSTANCE_RENAME"
__slots__ = ["instance_name", "ignore_ip", "new_name"] __slots__ = OpCode.__slots__ + [
"instance_name", "ignore_ip", "new_name",
]
class OpStartupInstance(OpCode): class OpStartupInstance(OpCode):
"""Startup an instance.""" """Startup an instance."""
OP_ID = "OP_INSTANCE_STARTUP" OP_ID = "OP_INSTANCE_STARTUP"
OP_DSC_FIELD = "instance_name" OP_DSC_FIELD = "instance_name"
__slots__ = ["instance_name", "force", "hvparams", "beparams"] __slots__ = OpCode.__slots__ + [
"instance_name", "force", "hvparams", "beparams",
]
class OpShutdownInstance(OpCode): class OpShutdownInstance(OpCode):
"""Shutdown an instance.""" """Shutdown an instance."""
OP_ID = "OP_INSTANCE_SHUTDOWN" OP_ID = "OP_INSTANCE_SHUTDOWN"
OP_DSC_FIELD = "instance_name" OP_DSC_FIELD = "instance_name"
__slots__ = ["instance_name"] __slots__ = OpCode.__slots__ + ["instance_name"]
class OpRebootInstance(OpCode): class OpRebootInstance(OpCode):
"""Reboot an instance.""" """Reboot an instance."""
OP_ID = "OP_INSTANCE_REBOOT" OP_ID = "OP_INSTANCE_REBOOT"
OP_DSC_FIELD = "instance_name" OP_DSC_FIELD = "instance_name"
__slots__ = ["instance_name", "reboot_type", "ignore_secondaries" ] __slots__ = OpCode.__slots__ + [
"instance_name", "reboot_type", "ignore_secondaries",
]
class OpReplaceDisks(OpCode): class OpReplaceDisks(OpCode):
"""Replace the disks of an instance.""" """Replace the disks of an instance."""
OP_ID = "OP_INSTANCE_REPLACE_DISKS" OP_ID = "OP_INSTANCE_REPLACE_DISKS"
OP_DSC_FIELD = "instance_name" OP_DSC_FIELD = "instance_name"
__slots__ = ["instance_name", "remote_node", "mode", "disks", "iallocator"] __slots__ = OpCode.__slots__ + [
"instance_name", "remote_node", "mode", "disks", "iallocator",
]
class OpFailoverInstance(OpCode): class OpFailoverInstance(OpCode):
"""Failover an instance.""" """Failover an instance."""
OP_ID = "OP_INSTANCE_FAILOVER" OP_ID = "OP_INSTANCE_FAILOVER"
OP_DSC_FIELD = "instance_name" OP_DSC_FIELD = "instance_name"
__slots__ = ["instance_name", "ignore_consistency"] __slots__ = OpCode.__slots__ + ["instance_name", "ignore_consistency"]
class OpMigrateInstance(OpCode): class OpMigrateInstance(OpCode):
...@@ -435,47 +446,47 @@ class OpMigrateInstance(OpCode): ...@@ -435,47 +446,47 @@ class OpMigrateInstance(OpCode):
""" """
OP_ID = "OP_INSTANCE_MIGRATE" OP_ID = "OP_INSTANCE_MIGRATE"
OP_DSC_FIELD = "instance_name" OP_DSC_FIELD = "instance_name"
__slots__ = ["instance_name", "live", "cleanup"] __slots__ = OpCode.__slots__ + ["instance_name", "live", "cleanup"]
class OpConnectConsole(OpCode): class OpConnectConsole(OpCode):
"""Connect to an instance's console.""" """Connect to an instance's console."""
OP_ID = "OP_INSTANCE_CONSOLE" OP_ID = "OP_INSTANCE_CONSOLE"
OP_DSC_FIELD = "instance_name" OP_DSC_FIELD = "instance_name"
__slots__ = ["instance_name"] __slots__ = OpCode.__slots__ + ["instance_name"]
class OpActivateInstanceDisks(OpCode): class OpActivateInstanceDisks(OpCode):
"""Activate an instance's disks.""" """Activate an instance's disks."""
OP_ID = "OP_INSTANCE_ACTIVATE_DISKS" OP_ID = "OP_INSTANCE_ACTIVATE_DISKS"
OP_DSC_FIELD = "instance_name" OP_DSC_FIELD = "instance_name"
__slots__ = ["instance_name"] __slots__ = OpCode.__slots__ + ["instance_name"]
class OpDeactivateInstanceDisks(OpCode): class OpDeactivateInstanceDisks(OpCode):
"""Deactivate an instance's disks.""" """Deactivate an instance's disks."""
OP_ID = "OP_INSTANCE_DEACTIVATE_DISKS" OP_ID = "OP_INSTANCE_DEACTIVATE_DISKS"
OP_DSC_FIELD = "instance_name" OP_DSC_FIELD = "instance_name"
__slots__ = ["instance_name"] __slots__ = OpCode.__slots__ + ["instance_name"]
class OpQueryInstances(OpCode): class OpQueryInstances(OpCode):
"""Compute the list of instances.""" """Compute the list of instances."""
OP_ID = "OP_INSTANCE_QUERY" OP_ID = "OP_INSTANCE_QUERY"
__slots__ = ["output_fields", "names", "use_locking"] __slots__ = OpCode.__slots__ + ["output_fields", "names", "use_locking"]
class OpQueryInstanceData(OpCode): class OpQueryInstanceData(OpCode):
"""Compute the run-time status of instances.""" """Compute the run-time status of instances."""
OP_ID = "OP_INSTANCE_QUERY_DATA" OP_ID = "OP_INSTANCE_QUERY_DATA"
__slots__ = ["instances", "static"] __slots__ = OpCode.__slots__ + ["instances", "static"]
class OpSetInstanceParams(OpCode): class OpSetInstanceParams(OpCode):
"""Change the parameters of an instance.""" """Change the parameters of an instance."""
OP_ID = "OP_INSTANCE_SET_PARAMS" OP_ID = "OP_INSTANCE_SET_PARAMS"
OP_DSC_FIELD = "instance_name" OP_DSC_FIELD = "instance_name"
__slots__ = [ __slots__ = OpCode.__slots__ + [
"instance_name", "instance_name",
"hvparams", "beparams", "force", "hvparams", "beparams", "force",
"nics", "disks", "nics", "disks",
...@@ -486,35 +497,37 @@ class OpGrowDisk(OpCode): ...@@ -486,35 +497,37 @@ class OpGrowDisk(OpCode):
"""Grow a disk of an instance.""" """Grow a disk of an instance."""
OP_ID = "OP_INSTANCE_GROW_DISK" OP_ID = "OP_INSTANCE_GROW_DISK"
OP_DSC_FIELD = "instance_name" OP_DSC_FIELD = "instance_name"
__slots__ = ["instance_name", "disk", "amount", "wait_for_sync"] __slots__ = OpCode.__slots__ + [
"instance_name", "disk", "amount", "wait_for_sync",
]
# OS opcodes # OS opcodes
class OpDiagnoseOS(OpCode): class OpDiagnoseOS(OpCode):
"""Compute the list of guest operating systems.""" """Compute the list of guest operating systems."""
OP_ID = "OP_OS_DIAGNOSE" OP_ID = "OP_OS_DIAGNOSE"
__slots__ = ["output_fields", "names"] __slots__ = OpCode.__slots__ + ["output_fields", "names"]
# Exports opcodes # Exports opcodes
class OpQueryExports(OpCode): class OpQueryExports(OpCode):
"""Compute the list of exported images.""" """Compute the list of exported images."""
OP_ID = "OP_BACKUP_QUERY" OP_ID = "OP_BACKUP_QUERY"
__slots__ = ["nodes", "use_locking"] __slots__ = OpCode.__slots__ + ["nodes", "use_locking"]
class OpExportInstance(OpCode): class OpExportInstance(OpCode):
"""Export an instance.""" """Export an instance."""
OP_ID = "OP_BACKUP_EXPORT" OP_ID = "OP_BACKUP_EXPORT"
OP_DSC_FIELD = "instance_name" OP_DSC_FIELD = "instance_name"
__slots__ = ["instance_name", "target_node", "shutdown"] __slots__ = OpCode.__slots__ + ["instance_name", "target_node", "shutdown"]
class OpRemoveExport(OpCode): class OpRemoveExport(OpCode):
"""Remove an instance's export.""" """Remove an instance's export."""
OP_ID = "OP_BACKUP_REMOVE" OP_ID = "OP_BACKUP_REMOVE"
OP_DSC_FIELD = "instance_name" OP_DSC_FIELD = "instance_name"
__slots__ = ["instance_name"] __slots__ = OpCode.__slots__ + ["instance_name"]
# Tags opcodes # Tags opcodes
...@@ -522,26 +535,26 @@ class OpGetTags(OpCode): ...@@ -522,26 +535,26 @@ class OpGetTags(OpCode):
"""Returns the tags of the given object.""" """Returns the tags of the given object."""
OP_ID = "OP_TAGS_GET" OP_ID = "OP_TAGS_GET"
OP_DSC_FIELD = "name" OP_DSC_FIELD = "name"
__slots__ = ["kind", "name"] __slots__ = OpCode.__slots__ + ["kind", "name"]
class OpSearchTags(OpCode): class OpSearchTags(OpCode):
"""Searches the tags in the cluster for a given pattern.""" """Searches the tags in the cluster for a given pattern."""
OP_ID = "OP_TAGS_SEARCH" OP_ID = "OP_TAGS_SEARCH"
OP_DSC_FIELD = "pattern" OP_DSC_FIELD = "pattern"
__slots__ = ["pattern"] __slots__ = OpCode.__slots__ + ["pattern"]
class OpAddTags(OpCode): class OpAddTags(OpCode):
"""Add a list of tags on a given object.""" """Add a list of tags on a given object."""
OP_ID = "OP_TAGS_SET" OP_ID = "OP_TAGS_SET"
__slots__ = ["kind", "name", "tags"] __slots__ = OpCode.__slots__ + ["kind", "name", "tags"]
class OpDelTags(OpCode): class OpDelTags(OpCode):
"""Remove a list of tags from a given object.""" """Remove a list of tags from a given object."""
OP_ID = "OP_TAGS_DEL" OP_ID = "OP_TAGS_DEL"
__slots__ = ["kind", "name", "tags"] __slots__ = OpCode.__slots__ + ["kind", "name", "tags"]
# Test opcodes # Test opcodes
...@@ -568,7 +581,7 @@ class OpTestDelay(OpCode): ...@@ -568,7 +581,7 @@ class OpTestDelay(OpCode):
""" """
OP_ID = "OP_TEST_DELAY" OP_ID = "OP_TEST_DELAY"
OP_DSC_FIELD = "duration" OP_DSC_FIELD = "duration"
__slots__ = ["duration", "on_master", "on_nodes"] __slots__ = OpCode.__slots__ + ["duration", "on_master", "on_nodes"]
class OpTestAllocator(OpCode): class OpTestAllocator(OpCode):
...@@ -584,7 +597,7 @@ class OpTestAllocator(OpCode): ...@@ -584,7 +597,7 @@ class OpTestAllocator(OpCode):
""" """
OP_ID = "OP_TEST_ALLOCATOR" OP_ID = "OP_TEST_ALLOCATOR"
OP_DSC_FIELD = "allocator" OP_DSC_FIELD = "allocator"
__slots__ = [ __slots__ = OpCode.__slots__ + [
"direction", "mode", "allocator", "name", "direction", "mode", "allocator", "name",
"mem_size", "disks", "disk_template", "mem_size", "disks", "disk_template",
"os", "tags", "nics", "vcpus", "hypervisor", "os", "tags", "nics", "vcpus", "hypervisor",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment