+ OP_DSC_FIELD = "instance_name"
+ __slots__ = OpCode.__slots__ + ["instance_name", "target_node", "shutdown"]
+
+
+class OpRemoveExport(OpCode):
+ """Remove an instance's export."""
+ OP_ID = "OP_BACKUP_REMOVE"
+ OP_DSC_FIELD = "instance_name"
+ __slots__ = OpCode.__slots__ + ["instance_name"]
+
+
+# Tags opcodes
+class OpGetTags(OpCode):
+ """Returns the tags of the given object."""
+ OP_ID = "OP_TAGS_GET"
+ OP_DSC_FIELD = "name"
+ __slots__ = OpCode.__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"]
+
+
+class OpAddTags(OpCode):
+ """Add a list of tags on a given object."""
+ OP_ID = "OP_TAGS_SET"
+ __slots__ = OpCode.__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"]
+
+
+# Test opcodes
+class OpTestDelay(OpCode):
+ """Sleeps for a configured amount of time.
+
+ This is used just for debugging and testing.
+
+ Parameters:
+ - duration: the time to sleep
+ - on_master: if true, sleep on the master
+ - on_nodes: list of nodes in which to sleep
+
+ If the on_master parameter is true, it will execute a sleep on the
+ master (before any node sleep).
+
+ If the on_nodes list is not empty, it will sleep on those nodes
+ (after the sleep on the master, if that is enabled).
+
+ As an additional feature, the case of duration < 0 will be reported
+ as an execution error, so this opcode can be used as a failure
+ generator. The case of duration == 0 will not be treated specially.
+
+ """
+ OP_ID = "OP_TEST_DELAY"
+ OP_DSC_FIELD = "duration"
+ __slots__ = OpCode.__slots__ + ["duration", "on_master", "on_nodes"]
+
+
+class OpTestAllocator(OpCode):
+ """Allocator framework testing.
+
+ This opcode has two modes:
+ - gather and return allocator input for a given mode (allocate new
+ or replace secondary) and a given instance definition (direction
+ 'in')
+ - run a selected allocator for a given operation (as above) and
+ return the allocator output (direction 'out')
+
+ """
+ OP_ID = "OP_TEST_ALLOCATOR"
+ OP_DSC_FIELD = "allocator"
+ __slots__ = OpCode.__slots__ + [
+ "direction", "mode", "allocator", "name",
+ "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"))])