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.
  OpClusterActivateMasterIp
Activate the master IP on the master node.
  OpClusterDeactivateMasterIp
Deactivate the master IP on the master node.
  OpQuery
Query for resources/items.
  OpQueryFields
Query for available resource/item fields.
  OpOobCommand
Interact with OOB.
  OpRestrictedCommand
Runs a restricted command on node(s).
  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.
  OpInstanceMultiAlloc
Allocates multiple instances.
  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
Recreate 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.
  OpExtStorageDiagnose
Compute the list of external storage providers.
  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.
  OpNetworkAdd
Add an IP network to the cluster.
  OpNetworkRemove
Remove an existing network from the cluster.
  OpNetworkSetParams
Modify Network's parameters except for IPv4 subnet
  OpNetworkConnect
Connect a Network to a specific Nodegroup with the defined netparams (mode, link).
  OpNetworkDisconnect
Disconnect a Network from a Nodegroup.
  OpNetworkQuery
Compute the list of networks.
Functions [hide private]
array of strings
_NameComponents(name)
Split an opcode class name into its components
source code
string
_NameToId(name)
Convert an opcode class name to an OP_ID.
source code
string
NameToReasonSrc(name)
Convert an opcode class name to a source string for the reason trail
source code
 
_GenerateObjectTypeCheck(obj, fields_types)
Helper to generate type checks for objects.
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
callable
_BuildDiskTemplateCheck(accept_none)
Builds check for disk template.
source code
 
_CheckStorageType(storage_type)
Ensure a given storage type is valid.
source code
 
_CheckCIDRNetNotation(value)
Ensure a given CIDR notation type is valid.
source code
 
_CheckCIDRAddrNotation(value)
Ensure a given CIDR notation type is valid.
source code
 
_CheckCIDR6AddrNotation(value)
Ensure a given CIDR notation type is valid.
source code
 
_CheckCIDR6NetNotation(value)
Ensure a given CIDR notation type is valid.
source code
callable
_BuildJobDepCheck(relative)
Builds check for job dependencies (DEPEND_ATTR).
source code
 
_TestInstSetParamsModList(fn)
Generates a check for modification lists.
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.TMaybe(ht.TElemOf(constants...
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...
  _PWaitForSyncFalse = "wait_for_sync", False, ht.TBool, "Whethe...
  _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.TMaybe(ht.TE...
  _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...
  _PIgnoreErrors = "ignore_errors", ht.EmptyList, ht.TListOf(ht....
  _PDiskParams = "diskparams", None, ht.TMaybe(ht.TDictOf(ht.TEl...
  _PHvState = "hv_state", None, ht.TMaybeDict, "Set hypervisor s...
  _PDiskState = "disk_state", None, ht.TMaybeDict, "Set disk sta...
  _POpportunisticLocking = "opportunistic_locking", False, ht.TB...
Opportunistic locking
  _PIgnoreIpolicy = "ignore_ipolicy", False, ht.TBool, "Whether ...
  _PAllowRuntimeChgs = "allow_runtime_changes", True, ht.TBool, ...
  _PIAllocFromDesc = lambda desc:
IAllocator field builder
  _PNetworkName = "network_name", ht.NoDefault, ht.TNonEmptyStri...
a required network name
  _PTargetGroups = "target_groups", None, ht.TMaybeListOf(ht.TNo...
  _OPID_RE = re.compile("([a-z])([A-Z])")
OP_ID conversion regular expression
  _TestClusterOsListItem = ht.TAnd(ht.TIsLength(2), ht.TItems([h...
Utility function for OpClusterSetParams
  _TestClusterOsList = ht.TMaybeListOf(_TestClusterOsListItem)
  _TestNicDef = ht.Comment("NIC parameters")(ht.TDictOf(ht.TElem...
Utility function for testing NIC definitions
  _TSetParamsResultItemItems = [ht.Comment("name of changed para...
  _TSetParamsResult = ht.TListOf(ht.TAnd(ht.TIsLength(len(_TSetP...
  _TDiskParams = ht.Comment("Disk parameters")(ht.TDictOf(ht.TNo...
  _TQueryRow = ht.TListOf(ht.TAnd(ht.TIsLength(2), ht.TItems([ht...
  _TQueryResult = ht.TListOf(_TQueryRow)
  _TOldQueryRow = ht.TListOf(ht.TAny)
  _TOldQueryResult = ht.TListOf(_TOldQueryRow)
  _SUMMARY_PREFIX = {"CLUSTER_": "C_", "GROUP_": "G_", "NODE_": ...
  DEPEND_ATTR = "depends"
Attribute name for dependencies
  COMMENT_ATTR = "comment"
Attribute name for comment
  _TQueryFieldDef = _GenerateObjectTypeCheck(objects.QueryFieldD...
  _PStorageType = "storage_type", ht.NoDefault, _CheckStorageTyp...
Storage type parameter
  _TIpAddress4 = ht.TAnd(ht.TString, _CheckCIDRAddrNotation)
  _TIpAddress6 = ht.TAnd(ht.TString, _CheckCIDR6AddrNotation)
  _TIpNetwork4 = ht.TAnd(ht.TString, _CheckCIDRNetNotation)
  _TIpNetwork6 = ht.TAnd(ht.TString, _CheckCIDR6NetNotation)
  _TMaybeAddr4List = ht.TMaybe(ht.TListOf(_TIpAddress4))
  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, ipaddr, constants, errors, ht, objects, outils


Function Details [hide private]

_NameComponents(name)

source code 

Split an opcode class name into its components

Parameters:
  • name (string) - the class name, as OpXxxYyy
Returns: array of strings
the components of the name

_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

NameToReasonSrc(name)

source code 

Convert an opcode class name to a source string for the reason trail

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

_GenerateObjectTypeCheck(obj, fields_types)

source code 

Helper to generate type checks for objects.

Parameters:
  • obj - The object to generate type checks
  • fields_types - The fields and their types as a dict
Returns:
A ht type check function

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")

_BuildDiskTemplateCheck(accept_none)

source code 

Builds check for disk template.

Parameters:
  • accept_none (bool) - whether to accept None as a correct value
Returns: callable

_CheckCIDRNetNotation(value)

source code 

Ensure a given CIDR notation type is valid.

Decorators:
  • @ht.WithDesc("IPv4 network")

_CheckCIDRAddrNotation(value)

source code 

Ensure a given CIDR notation type is valid.

Decorators:
  • @ht.WithDesc("IPv4 address")

_CheckCIDR6AddrNotation(value)

source code 

Ensure a given CIDR notation type is valid.

Decorators:
  • @ht.WithDesc("IPv6 address")

_CheckCIDR6NetNotation(value)

source code 

Ensure a given CIDR notation type is valid.

Decorators:
  • @ht.WithDesc("IPv6 network")

_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.TNonNegativ\
eInt, "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.TMaybe(ht.TElemOf(constants.HT_MIGRATION_MODES)), "Mi\
gration 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), "Tag kind\
"

_PTags

List of tag strings

Value:
"tags", ht.NoDefault, ht.TListOf(ht.TNonEmptyString), "List of tag nam\
es"

_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"

_PWaitForSyncFalse

Value:
"wait_for_sync", False, ht.TBool, "Whether to wait for the disk to syn\
chronize" " (defaults to false)"

_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.TMaybe(ht.TElemOf(constants.VALID_ALLOC_POLIC\
IES)), "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"

_PIgnoreErrors

Value:
"ignore_errors", ht.EmptyList, ht.TListOf(ht.TElemOf(constants.CV_ALL_\
ECODES_STRINGS)), "List of error codes that should be treated as warni\
ngs"

_PDiskParams

Value:
"diskparams", None, ht.TMaybe(ht.TDictOf(ht.TElemOf(constants.DISK_TEM\
PLATES), ht.TDict)), "Disk templates' parameter defaults"

_PHvState

Value:
"hv_state", None, ht.TMaybeDict, "Set hypervisor states"

_PDiskState

Value:
"disk_state", None, ht.TMaybeDict, "Set disk states"

_POpportunisticLocking

Opportunistic locking

Value:
"opportunistic_locking", False, ht.TBool, ("Whether to employ opportun\
istic locking for nodes, meaning nodes" " already locked by another op\
code won't be considered for instance" " allocation (only when an iall\
ocator is used)")

_PIgnoreIpolicy

Value:
"ignore_ipolicy", False, ht.TBool, "Whether to ignore ipolicy violatio\
ns"

_PAllowRuntimeChgs

Value:
"allow_runtime_changes", True, ht.TBool, "Allow runtime changes (eg. m\
emory ballooning)"

_PNetworkName

a required network name

Value:
"network_name", ht.NoDefault, ht.TNonEmptyString, "Set network name"

_PTargetGroups

Value:
"target_groups", None, ht.TMaybeListOf(ht.TNonEmptyString), "Destinati\
on group names or UUIDs (defaults to \"all but current group\")"

_TestClusterOsListItem

Utility function for OpClusterSetParams

Value:
ht.TAnd(ht.TIsLength(2), ht.TItems([ht.TElemOf(constants.DDMS_VALUES),\
 ht.TNonEmptyString,]))

_TestNicDef

Utility function for testing NIC definitions

Value:
ht.Comment("NIC parameters")(ht.TDictOf(ht.TElemOf(constants.INIC_PARA\
MS), ht.TMaybeString))

_TSetParamsResultItemItems

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

_TSetParamsResult

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

_TDiskParams

Value:
ht.Comment("Disk parameters")(ht.TDictOf(ht.TNonEmptyString, ht.TOr(ht\
.TNonEmptyString, ht.TInt)))

_TQueryRow

Value:
ht.TListOf(ht.TAnd(ht.TIsLength(2), ht.TItems([ht.TElemOf(constants.RS\
_ALL), ht.TAny])))

_SUMMARY_PREFIX

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

_TQueryFieldDef

Value:
_GenerateObjectTypeCheck(objects.QueryFieldDefinition, {"name": ht.TNo\
nEmptyString, "title": ht.TNonEmptyString, "kind": ht.TElemOf(constant\
s.QFT_ALL), "doc": ht.TNonEmptyString,})

_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),})