Newer
Older
OP_PARAMS = [
_PGroupName,
("ndparams", None, ht.TOr(ht.TDict, ht.TNone)),
("alloc_policy", None, ht.TOr(ht.TNone,
ht.TElemOf(constants.VALID_ALLOC_POLICIES))),
class OpRemoveGroup(OpCode):
"""Remove a node group from the cluster."""
OP_ID = "OP_GROUP_REMOVE"
OP_DSC_FIELD = "group_name"
OP_PARAMS = [
_PGroupName,
]
class OpRenameGroup(OpCode):
"""Rename a node group in the cluster."""
OP_ID = "OP_GROUP_RENAME"
OP_DSC_FIELD = "old_name"
OP_PARAMS = [
("old_name", ht.NoDefault, ht.TNonEmptyString),
("new_name", ht.NoDefault, ht.TNonEmptyString),
]
# OS opcodes
class OpDiagnoseOS(OpCode):
"""Compute the list of guest operating systems."""
OP_ID = "OP_OS_DIAGNOSE"
OP_PARAMS = [
_POutputFields,
("names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)),
]
# Exports opcodes
class OpQueryExports(OpCode):
"""Compute the list of exported images."""
OP_ID = "OP_BACKUP_QUERY"
OP_PARAMS = [
("nodes", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)),
("use_locking", False, ht.TBool),
]
class OpPrepareExport(OpCode):
"""Prepares an instance export.
@ivar instance_name: Instance name
@ivar mode: Export mode (one of L{constants.EXPORT_MODES})
"""
OP_ID = "OP_BACKUP_PREPARE"
OP_DSC_FIELD = "instance_name"
OP_PARAMS = [
_PInstanceName,
("mode", ht.NoDefault, ht.TElemOf(constants.EXPORT_MODES)),
"""Export an instance.
For local exports, the export destination is the node name. For remote
exports, the export destination is a list of tuples, each consisting of
hostname/IP address, port, HMAC and HMAC salt. The HMAC is calculated using
the cluster domain secret over the value "${index}:${hostname}:${port}". The
destination X509 CA must be a signed certificate.
@ivar mode: Export mode (one of L{constants.EXPORT_MODES})
@ivar target_node: Export destination
@ivar x509_key_name: X509 key to use (remote export only)
@ivar destination_x509_ca: Destination X509 CA in PEM format (remote export
only)
"""
OP_PARAMS = [
_PInstanceName,
_PShutdownTimeout,
# TODO: Rename target_node as it changes meaning for different export modes
# (e.g. "destination")
("target_node", ht.NoDefault, ht.TOr(ht.TNonEmptyString, ht.TList)),
("shutdown", True, ht.TBool),
("remove_instance", False, ht.TBool),
("ignore_remove_failures", False, ht.TBool),
("mode", constants.EXPORT_MODE_LOCAL, ht.TElemOf(constants.EXPORT_MODES)),
("x509_key_name", None, ht.TOr(ht.TList, ht.TNone)),
("destination_x509_ca", None, ht.TMaybeString),
class OpRemoveExport(OpCode):
"""Remove an instance's export."""
OP_ID = "OP_BACKUP_REMOVE"
OP_PARAMS = [
_PInstanceName,
]
# Tags opcodes
class OpGetTags(OpCode):
"""Returns the tags of the given object."""
OP_ID = "OP_TAGS_GET"
OP_PARAMS = [
_PTagKind,
# Name is only meaningful for nodes and instances
("name", ht.NoDefault, ht.TMaybeString),
]
class OpSearchTags(OpCode):
"""Searches the tags in the cluster for a given pattern."""
OP_ID = "OP_TAGS_SEARCH"
OP_PARAMS = [
("pattern", ht.NoDefault, ht.TNonEmptyString),
]
class OpAddTags(OpCode):
"""Add a list of tags on a given object."""
OP_ID = "OP_TAGS_SET"
OP_PARAMS = [
_PTagKind,
_PTags,
# Name is only meaningful for nodes and instances
("name", ht.NoDefault, ht.TMaybeString),
]
class OpDelTags(OpCode):
"""Remove a list of tags from a given object."""
OP_ID = "OP_TAGS_DEL"
OP_PARAMS = [
_PTagKind,
_PTags,
# Name is only meaningful for nodes and instances
("name", ht.NoDefault, ht.TMaybeString),
]
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
# 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_PARAMS = [
("duration", ht.NoDefault, ht.TFloat),
("on_master", True, ht.TBool),
("on_nodes", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)),
("repeat", 0, ht.TPositiveInt)
]
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_PARAMS = [
("direction", ht.NoDefault,
ht.TElemOf(constants.VALID_IALLOCATOR_DIRECTIONS)),
("mode", ht.NoDefault, ht.TElemOf(constants.VALID_IALLOCATOR_MODES)),
("name", ht.NoDefault, ht.TNonEmptyString),
("nics", ht.NoDefault, ht.TOr(ht.TNone, ht.TListOf(
ht.TDictOf(ht.TElemOf(["mac", "ip", "bridge"]),
ht.TOr(ht.TNone, ht.TNonEmptyString))))),
("disks", ht.NoDefault, ht.TOr(ht.TNone, ht.TList)),
("hypervisor", None, ht.TMaybeString),
("allocator", None, ht.TMaybeString),
("tags", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)),
("mem_size", None, ht.TOr(ht.TNone, ht.TPositiveInt)),
("vcpus", None, ht.TOr(ht.TNone, ht.TPositiveInt)),
("os", None, ht.TMaybeString),
("disk_template", None, ht.TMaybeString),
("evac_nodes", None, ht.TOr(ht.TNone, ht.TListOf(ht.TNonEmptyString))),
class OpTestJobqueue(OpCode):
"""Utility opcode to test some aspects of the job queue.
"""
OP_ID = "OP_TEST_JQUEUE"
OP_PARAMS = [
("notify_waitlock", False, ht.TBool),
("notify_exec", False, ht.TBool),
("log_messages", ht.EmptyList, ht.TListOf(ht.TString)),
("fail", False, ht.TBool),
class OpTestDummy(OpCode):
"""Utility opcode used by unittests.
"""
OP_ID = "OP_TEST_DUMMY"
OP_PARAMS = [
("result", ht.NoDefault, ht.NoType),
("messages", ht.NoDefault, ht.NoType),
("fail", ht.NoDefault, ht.NoType),
]
def _GetOpList():
"""Returns list of all defined opcodes.
Does not eliminate duplicates by C{OP_ID}.
"""
return [v for v in globals().values()
if (isinstance(v, type) and issubclass(v, OpCode) and
hasattr(v, "OP_ID"))]
OP_MAPPING = dict((v.OP_ID, v) for v in _GetOpList())