raise ValueError("Invalid data to LoadOpcode, missing OP_ID")
op_id = data["OP_ID"]
op_class = None
- for item in globals().values():
- if (isinstance(item, type) and
- issubclass(item, cls) and
- hasattr(item, "OP_ID") and
- getattr(item, "OP_ID") == op_id):
- op_class = item
- break
- if op_class is None:
+ if op_id in OP_MAPPING:
+ op_class = OP_MAPPING[op_id]
+ else:
raise ValueError("Invalid data to LoadOpCode: OP_ID %s unsupported" %
op_id)
op = op_class()
__slots__ = []
+class OpRepairDiskSizes(OpCode):
+ """Verify the disk sizes of the instances and fixes configuration
+ mimatches.
+
+ Parameters: optional instances list, in case we want to restrict the
+ checks to only a subset of the instances.
+
+ Result: a list of tuples, (instance, disk, new-size) for changed
+ configurations.
+
+ In normal operation, the list should be empty.
+
+ @type instances: list
+ @ivar instances: the list of instances to check, or empty for all instances
+
+ """
+ OP_ID = "OP_CLUSTER_REPAIR_DISK_SIZES"
+ __slots__ = ["instances"]
+
+
class OpQueryConfigValues(OpCode):
"""Query cluster configuration values."""
OP_ID = "OP_CLUSTER_CONFIG_QUERY"
class OpQueryNodes(OpCode):
"""Compute the list of nodes."""
OP_ID = "OP_NODE_QUERY"
- __slots__ = ["output_fields", "names"]
+ __slots__ = ["output_fields", "names", "use_locking"]
class OpQueryNodeVolumes(OpCode):
"force",
"master_candidate",
"offline",
+ "drained",
]
# instance opcodes
"""Startup an instance."""
OP_ID = "OP_INSTANCE_STARTUP"
OP_DSC_FIELD = "instance_name"
- __slots__ = ["instance_name", "force", "extra_args"]
+ __slots__ = ["instance_name", "force", "hvparams", "beparams"]
class OpShutdownInstance(OpCode):
"""Reboot an instance."""
OP_ID = "OP_INSTANCE_REBOOT"
OP_DSC_FIELD = "instance_name"
- __slots__ = ["instance_name", "reboot_type", "extra_args",
- "ignore_secondaries" ]
+ __slots__ = ["instance_name", "reboot_type", "ignore_secondaries" ]
class OpReplaceDisks(OpCode):
__slots__ = ["instance_name", "ignore_consistency"]
+class OpMigrateInstance(OpCode):
+ """Migrate an instance.
+
+ This migrates (without shutting down an instance) to its secondary
+ node.
+
+ @ivar instance_name: the name of the instance
+
+ """
+ OP_ID = "OP_INSTANCE_MIGRATE"
+ OP_DSC_FIELD = "instance_name"
+ __slots__ = ["instance_name", "live", "cleanup"]
+
+
class OpConnectConsole(OpCode):
"""Connect to an instance's console."""
OP_ID = "OP_INSTANCE_CONSOLE"
"""Activate an instance's disks."""
OP_ID = "OP_INSTANCE_ACTIVATE_DISKS"
OP_DSC_FIELD = "instance_name"
- __slots__ = ["instance_name"]
+ __slots__ = ["instance_name", "ignore_size"]
class OpDeactivateInstanceDisks(OpCode):
class OpQueryInstances(OpCode):
"""Compute the list of instances."""
OP_ID = "OP_INSTANCE_QUERY"
- __slots__ = ["output_fields", "names"]
+ __slots__ = ["output_fields", "names", "use_locking"]
class OpQueryInstanceData(OpCode):
class OpQueryExports(OpCode):
"""Compute the list of exported images."""
OP_ID = "OP_BACKUP_QUERY"
- __slots__ = ["nodes"]
+ __slots__ = ["nodes", "use_locking"]
class OpExportInstance(OpCode):
"mem_size", "disks", "disk_template",
"os", "tags", "nics", "vcpus", "hypervisor",
]
+
+OP_MAPPING = dict([(v.OP_ID, v) for v in globals().values()
+ if (isinstance(v, type) and issubclass(v, OpCode) and
+ hasattr(v, "OP_ID"))])