Package ganeti :: Module opcodes
[hide private]
[frames] | no frames]

Module opcodes

source code

OpCodes module

This module implements the data structures which define the cluster operations - the so-called opcodes.

Every operation which modifies the cluster state is expressed via opcodes.

Classes [hide private]
  _AutoOpParamSlots
Meta class for opcode definitions.
  BaseOpCode
A simple serializable object.
  OpCode
Abstract OpCode.
  OpClusterPostInit
Post cluster initialization.
  OpClusterDestroy
Destroy the cluster.
  OpClusterQuery
Query cluster information.
  OpClusterVerify
Submits all jobs necessary to verify the cluster.
  OpClusterVerifyConfig
Verify the cluster config.
  OpClusterVerifyGroup
Run verify on a node group from the cluster.
  OpClusterVerifyDisks
Verify the cluster disks.
  OpGroupVerifyDisks
Verifies the status of all disks in a node group.
  OpClusterRepairDiskSizes
Verify the disk sizes of the instances and fixes configuration mimatches.
  OpClusterConfigQuery
Query cluster configuration values.
  OpClusterRename
Rename the cluster.
  OpClusterSetParams
Change the parameters of the cluster.
  OpClusterRedistConf
Force a full push of the cluster configuration.
  OpQuery
Query for resources/items.
  OpQueryFields
Query for available resource/item fields.
  OpOobCommand
Interact with OOB.
  OpNodeRemove
Remove a node.
  OpNodeAdd
Add a node to the cluster.
  OpNodeQuery
Compute the list of nodes.
  OpNodeQueryvols
Get list of volumes on node.
  OpNodeQueryStorage
Get information on storage for node(s).
  OpNodeModifyStorage
Modifies the properies of a storage unit
  OpRepairNodeStorage
Repairs the volume group on a node.
  OpNodeSetParams
Change the parameters of a node.
  OpNodePowercycle
Tries to powercycle a node.
  OpNodeMigrate
Migrate all instances from a node.
  OpNodeEvacuate
Evacuate instances off a number of nodes.
  OpInstanceCreate
Create an instance.
  OpInstanceReinstall
Reinstall an instance's OS.
  OpInstanceRemove
Remove an instance.
  OpInstanceRename
Rename an instance.
  OpInstanceStartup
Startup an instance.
  OpInstanceShutdown
Shutdown an instance.
  OpInstanceReboot
Reboot an instance.
  OpInstanceReplaceDisks
Replace the disks of an instance.
  OpInstanceFailover
Failover an instance.
  OpInstanceMigrate
Migrate an instance.
  OpInstanceMove
Move an instance.
  OpInstanceConsole
Connect to an instance's console.
  OpInstanceActivateDisks
Activate an instance's disks.
  OpInstanceDeactivateDisks
Deactivate an instance's disks.
  OpInstanceRecreateDisks
Deactivate an instance's disks.
  OpInstanceQuery
Compute the list of instances.
  OpInstanceQueryData
Compute the run-time status of instances.
  OpInstanceSetParams
Change the parameters of an instance.
  OpInstanceGrowDisk
Grow a disk of an instance.
  OpInstanceChangeGroup
Moves an instance to another node group.
  OpGroupAdd
Add a node group to the cluster.
  OpGroupAssignNodes
Assign nodes to a node group.
  OpGroupQuery
Compute the list of node groups.
  OpGroupSetParams
Change the parameters of a node group.
  OpGroupRemove
Remove a node group from the cluster.
  OpGroupRename
Rename a node group in the cluster.
  OpGroupEvacuate
Evacuate a node group in the cluster.
  OpOsDiagnose
Compute the list of guest operating systems.
  OpBackupQuery
Compute the list of exported images.
  OpBackupPrepare
Prepares an instance export.
  OpBackupExport
Export an instance.
  OpBackupRemove
Remove an instance's export.
  OpTagsGet
Returns the tags of the given object.
  OpTagsSearch
Searches the tags in the cluster for a given pattern.
  OpTagsSet
Add a list of tags on a given object.
  OpTagsDel
Remove a list of tags from a given object.
  OpTestDelay
Sleeps for a configured amount of time.
  OpTestAllocator
Allocator framework testing.
  OpTestJqueue
Utility opcode to test some aspects of the job queue.
  OpTestDummy
Utility opcode used by unittests.
Functions [hide private]
string
_NameToId(name)
Convert an opcode class name to an OP_ID.
source code
 
RequireFileStorage()
Checks that file storage is enabled.
source code
 
RequireSharedFileStorage()
Checks that shared file storage is enabled.
source code
 
_CheckFileStorage(value)
Ensures file storage is enabled if used.
source code
 
_CheckStorageType(storage_type)
Ensure a given storage type is valid.
source code
callable
_BuildJobDepCheck(relative)
Builds check for job dependencies (DEPEND_ATTR).
source code
 
_GetOpList()
Returns list of all defined opcodes.
source code
Variables [hide private]
  _POutputFields = "output_fields", ht.NoDefault, ht.TListOf(ht....
output fields for a query operation
  _PShutdownTimeout = "shutdown_timeout", constants.DEFAULT_SHUT...
the shutdown timeout
  _PForce = "force", False, ht.TBool, "Whether to force the oper...
the force parameter
  _PInstanceName = "instance_name", ht.NoDefault, ht.TNonEmptySt...
a required instance name (for single-instance LUs)
  _PIgnoreOfflineNodes = "ignore_offline_nodes", False, ht.TBool...
Whether to ignore offline nodes
  _PNodeName = "node_name", ht.NoDefault, ht.TNonEmptyString, "N...
a required node name (for single-node LUs)
  _PGroupName = "group_name", ht.NoDefault, ht.TNonEmptyString, ...
a required node group name (for single-group LUs)
  _PMigrationMode = "mode", None, ht.TOr(ht.TNone, ht.TElemOf(co...
Migration type (live/non-live)
  _PMigrationLive = "live", None, ht.TMaybeBool, "Legacy setting...
Obsolete 'live' migration mode (boolean)
  _PTagKind = "kind", ht.NoDefault, ht.TElemOf(constants.VALID_T...
Tag type
  _PTags = "tags", ht.NoDefault, ht.TListOf(ht.TNonEmptyString),...
List of tag strings
  _PForceVariant = "force_variant", False, ht.TBool, "Whether to...
  _PWaitForSync = "wait_for_sync", True, ht.TBool, "Whether to w...
  _PIgnoreConsistency = "ignore_consistency", False, ht.TBool, "...
  _PStorageName = "name", ht.NoDefault, ht.TMaybeString, "Storag...
  _PUseLocking = "use_locking", False, ht.TBool, "Whether to use...
  _PNameCheck = "name_check", True, ht.TBool, "Whether to check ...
  _PNodeGroupAllocPolicy = "alloc_policy", None, ht.TOr(ht.TNone...
  _PGroupNodeParams = "ndparams", None, ht.TMaybeDict, "Default ...
  _PQueryWhat = "what", ht.NoDefault, ht.TElemOf(constants.QR_VI...
  _PEarlyRelease = "early_release", False, ht.TBool, "Whether to...
  _PIpCheckDoc = "Whether to ensure instance's IP address is ina...
  _PNoRemember = "no_remember", False, ht.TBool, "Do not remembe...
Do not remember instance state changes
  _PMigrationTargetNode = "target_node", None, ht.TMaybeString, ...
Target node for instance migration/failover
  _PStartupPaused = "startup_paused", False, ht.TBool, "Pause in...
  _PVerbose = "verbose", False, ht.TBool, "Verbose mode"
  _PDebugSimulateErrors = "debug_simulate_errors", False, ht.TBo...
  _PErrorCodes = "error_codes", False, ht.TBool, "Error codes"
  _PSkipChecks = "skip_checks", ht.EmptyList, ht.TListOf(ht.TEle...
  _OPID_RE = re.compile("([a-z])([A-Z])")
OP_ID conversion regular expression
  _TestClusterOsList = ht.TOr(ht.TNone, ht.TListOf(ht.TAnd(ht.TL...
Utility function for OpClusterSetParams
  _TestNicDef = ht.TDictOf(ht.TElemOf(constants.INIC_PARAMS), ht...
Utility function for testing NIC definitions
  _TSetParamsResultItemItems = [ht.Comment("name of changed para...
  _TSetParamsResult = ht.TListOf(ht.TAnd(ht.TIsLength(len(_TSetP...
  _SUMMARY_PREFIX = {"CLUSTER_": "C_", "GROUP_": "G_", "NODE_": ...
  DEPEND_ATTR = "depends"
Attribute name for dependencies
  COMMENT_ATTR = "comment"
Attribute name for comment
  _CheckDiskTemplate = ht.TAnd(ht.TElemOf(constants.DISK_TEMPLAT...
  _PStorageType = "storage_type", ht.NoDefault, _CheckStorageTyp...
Storage type parameter
  TNoRelativeJobDependencies = _BuildJobDepCheck(False)
  _TJobIdListItem = ht.TAnd(ht.TIsLength(2), ht.TItems([ht.Comme...
List of submission status and job ID as returned by SubmitManyJobs
  TJobIdList = ht.TListOf(_TJobIdListItem)
  TJobIdListOnly = ht.TStrictDict(True, True, {constants.JOB_IDS...
Result containing only list of submitted jobs
  OP_MAPPING = dict((v.OP_ID, v) for v in _GetOpList())

Imports: logging, re, compat, constants, errors, ht


Function Details [hide private]

_NameToId(name)

source code 

Convert an opcode class name to an OP_ID.

Parameters:
  • name (string) - the class name, as OpXxxYyy
Returns: string
the name in the OP_XXXX_YYYY format

RequireFileStorage()

source code 

Checks that file storage is enabled.

While it doesn't really fit into this module, utils was deemed too large of a dependency to be imported for just one or two functions.

Raises:

RequireSharedFileStorage()

source code 

Checks that shared file storage is enabled.

While it doesn't really fit into this module, utils was deemed too large of a dependency to be imported for just one or two functions.

Raises:

_CheckFileStorage(value)

source code 

Ensures file storage is enabled if used.

Decorators:
  • @ht.WithDesc("CheckFileStorage")

_BuildJobDepCheck(relative)

source code 

Builds check for job dependencies (DEPEND_ATTR).

Parameters:
  • relative (bool) - Whether to accept relative job IDs (negative)
Returns: callable

_GetOpList()

source code 

Returns list of all defined opcodes.

Does not eliminate duplicates by OP_ID.


Variables Details [hide private]

_POutputFields

output fields for a query operation

Value:
"output_fields", ht.NoDefault, ht.TListOf(ht.TNonEmptyString), "Select\
ed output fields"

_PShutdownTimeout

the shutdown timeout

Value:
"shutdown_timeout", constants.DEFAULT_SHUTDOWN_TIMEOUT, ht.TPositiveIn\
t, "How long to wait for instance to shut down"

_PForce

the force parameter

Value:
"force", False, ht.TBool, "Whether to force the operation"

_PInstanceName

a required instance name (for single-instance LUs)

Value:
"instance_name", ht.NoDefault, ht.TNonEmptyString, "Instance name"

_PIgnoreOfflineNodes

Whether to ignore offline nodes

Value:
"ignore_offline_nodes", False, ht.TBool, "Whether to ignore offline no\
des"

_PNodeName

a required node name (for single-node LUs)

Value:
"node_name", ht.NoDefault, ht.TNonEmptyString, "Node name"

_PGroupName

a required node group name (for single-group LUs)

Value:
"group_name", ht.NoDefault, ht.TNonEmptyString, "Group name"

_PMigrationMode

Migration type (live/non-live)

Value:
"mode", None, ht.TOr(ht.TNone, ht.TElemOf(constants.HT_MIGRATION_MODES\
)), "Migration mode"

_PMigrationLive

Obsolete 'live' migration mode (boolean)

Value:
"live", None, ht.TMaybeBool, "Legacy setting for live migration, do no\
t use"

_PTagKind

Tag type

Value:
"kind", ht.NoDefault, ht.TElemOf(constants.VALID_TAG_TYPES), None

_PTags

List of tag strings

Value:
"tags", ht.NoDefault, ht.TListOf(ht.TNonEmptyString), None

_PForceVariant

Value:
"force_variant", False, ht.TBool, "Whether to force an unknown OS vari\
ant"

_PWaitForSync

Value:
"wait_for_sync", True, ht.TBool, "Whether to wait for the disk to sync\
hronize"

_PIgnoreConsistency

Value:
"ignore_consistency", False, ht.TBool, "Whether to ignore disk consist\
ency"

_PStorageName

Value:
"name", ht.NoDefault, ht.TMaybeString, "Storage name"

_PUseLocking

Value:
"use_locking", False, ht.TBool, "Whether to use synchronization"

_PNameCheck

Value:
"name_check", True, ht.TBool, "Whether to check name"

_PNodeGroupAllocPolicy

Value:
"alloc_policy", None, ht.TOr(ht.TNone, ht.TElemOf(constants.VALID_ALLO\
C_POLICIES)), "Instance allocation policy"

_PGroupNodeParams

Value:
"ndparams", None, ht.TMaybeDict, "Default node parameters for group"

_PQueryWhat

Value:
"what", ht.NoDefault, ht.TElemOf(constants.QR_VIA_OP), "Resource(s) to\
 query for"

_PEarlyRelease

Value:
"early_release", False, ht.TBool, "Whether to release locks as soon as\
 possible"

_PIpCheckDoc

Value:
"Whether to ensure instance's IP address is inactive"

_PNoRemember

Do not remember instance state changes

Value:
"no_remember", False, ht.TBool, "Do not remember the state change"

_PMigrationTargetNode

Target node for instance migration/failover

Value:
"target_node", None, ht.TMaybeString, "Target node for shared-storage \
instances"

_PStartupPaused

Value:
"startup_paused", False, ht.TBool, "Pause instance at startup"

_PDebugSimulateErrors

Value:
"debug_simulate_errors", False, ht.TBool, "Whether to simulate errors \
(useful for debugging)"

_PSkipChecks

Value:
"skip_checks", ht.EmptyList, ht.TListOf(ht.TElemOf(constants.VERIFY_OP\
TIONAL_CHECKS)), "Which checks to skip"

_TestClusterOsList

Utility function for OpClusterSetParams

Value:
ht.TOr(ht.TNone, ht.TListOf(ht.TAnd(ht.TList, ht.TIsLength(2), ht.TMap\
(ht.WithDesc("GetFirstItem")(compat.fst), ht.TElemOf(constants.DDMS_VA\
LUES)))))

_TestNicDef

Utility function for testing NIC definitions

Value:
ht.TDictOf(ht.TElemOf(constants.INIC_PARAMS), ht.TOr(ht.TNone, ht.TNon\
EmptyString))

_TSetParamsResultItemItems

Value:
[ht.Comment("name of changed parameter")(ht.TNonEmptyString), ht.TAny,\
]

_TSetParamsResult

Value:
ht.TListOf(ht.TAnd(ht.TIsLength(len(_TSetParamsResultItemItems)), ht.T\
Items(_TSetParamsResultItemItems)))

_SUMMARY_PREFIX

Value:
{"CLUSTER_": "C_", "GROUP_": "G_", "NODE_": "N_", "INSTANCE_": "I_",}

_CheckDiskTemplate

Value:
ht.TAnd(ht.TElemOf(constants.DISK_TEMPLATES), _CheckFileStorage)

_PStorageType

Storage type parameter

Value:
"storage_type", ht.NoDefault, _CheckStorageType, "Storage type"

_TJobIdListItem

List of submission status and job ID as returned by SubmitManyJobs

Value:
ht.TAnd(ht.TIsLength(2), ht.TItems([ht.Comment("success")(ht.TBool), h\
t.Comment("Job ID if successful, error message" " otherwise")(ht.TOr(h\
t.TString, ht.TJobId))]))

TJobIdListOnly

Result containing only list of submitted jobs

Value:
ht.TStrictDict(True, True, {constants.JOB_IDS_KEY: ht.Comment("List of\
 submitted jobs")(TJobIdList),})