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

Module cmdlib

source code

Module implementing the master-side code.

Classes [hide private]
  ResultWithJobs
Data container for LU results with jobs.
  LogicalUnit
Logical Unit base class.
  NoHooksLU
Simple LU which runs no hooks.
  Tasklet
Tasklet base class.
  _QueryBase
Base for query utility classes.
  LUClusterPostInit
Logical unit for running hooks after cluster initialization.
  LUClusterDestroy
Logical unit for destroying the cluster.
  _VerifyErrors
Mix-in for cluster/group verify LUs.
  LUClusterVerify
Submits all jobs necessary to verify the cluster.
  LUClusterVerifyConfig
Verifies the cluster config.
  LUClusterVerifyGroup
Verifies the status of a node group.
  LUClusterVerifyDisks
Verifies the cluster disks status.
  LUGroupVerifyDisks
Verifies the status of all disks in a node group.
  LUClusterRepairDiskSizes
Verifies the cluster disks sizes.
  LUClusterRename
Rename the cluster.
  LUClusterSetParams
Change the parameters of the cluster.
  LUClusterRedistConf
Force the redistribution of cluster configuration.
  LUOobCommand
Logical unit for OOB handling.
  _OsQuery
  LUOsDiagnose
Logical unit for OS diagnose/query.
  LUNodeRemove
Logical unit for removing a node.
  _NodeQuery
  LUNodeQuery
Logical unit for querying nodes.
  LUNodeQueryvols
Logical unit for getting volumes on node(s).
  LUNodeQueryStorage
Logical unit for getting information on storage units on node(s).
  _InstanceQuery
  LUQuery
Query for resources/items of a certain kind.
  LUQueryFields
Query for resources/items of a certain kind.
  LUNodeModifyStorage
Logical unit for modifying a storage volume on a node.
  LUNodeAdd
Logical unit for adding node to the cluster.
  LUNodeSetParams
Modifies the parameters of a node.
  LUNodePowercycle
Powercycles a node.
  LUClusterQuery
Query cluster configuration.
  LUClusterConfigQuery
Return configuration values.
  LUInstanceActivateDisks
Bring up an instance's disks.
  LUInstanceDeactivateDisks
Shutdown an instance's disks.
  LUInstanceStartup
Starts an instance.
  LUInstanceReboot
Reboot an instance.
  LUInstanceShutdown
Shutdown an instance.
  LUInstanceReinstall
Reinstall an instance.
  LUInstanceRecreateDisks
Recreate an instance's missing disks.
  LUInstanceRename
Rename an instance.
  LUInstanceRemove
Remove an instance.
  LUInstanceQuery
Logical unit for querying instances.
  LUInstanceFailover
Failover an instance.
  LUInstanceMigrate
Migrate an instance.
  LUInstanceMove
Move an instance by data-copying.
  LUNodeMigrate
Migrate all instances from a node.
  TLMigrateInstance
Tasklet class for instance migration.
  LUInstanceCreate
Create an instance.
  LUInstanceConsole
Connect to an instance's console.
  LUInstanceReplaceDisks
Replace the disks of an instance.
  TLReplaceDisks
Replaces disks for an instance.
  LURepairNodeStorage
Repairs the volume group on a node.
  LUNodeEvacuate
Evacuates instances off a list of nodes.
  LUInstanceGrowDisk
Grow a disk of an instance.
  LUInstanceQueryData
Query runtime instance data.
  LUInstanceSetParams
Modifies an instances's parameters.
  LUInstanceChangeGroup
  LUBackupQuery
Query the exports list
  LUBackupPrepare
Prepares an instance for an export and returns useful information.
  LUBackupExport
Export an instance to an image in the cluster.
  LUBackupRemove
Remove exports related to the named instance.
  LUGroupAdd
Logical unit for creating node groups.
  LUGroupAssignNodes
Logical unit for assigning nodes to groups.
  _GroupQuery
  LUGroupQuery
Logical unit for querying node groups.
  LUGroupSetParams
Modifies the parameters of a node group.
  LUGroupRemove
  LUGroupRename
  LUGroupEvacuate
  TagsLU
Generic tags LU.
  LUTagsGet
Returns the tags of a given object.
  LUTagsSearch
Searches the tags for a given pattern.
  LUTagsSet
Sets a tag on a given object.
  LUTagsDel
Delete a list of tags from a given object.
  LUTestDelay
Sleep for a specified amount of time.
  LUTestJqueue
Utility LU to test some aspects of the job queue.
  IAllocator
IAllocator framework.
  LUTestAllocator
Run allocator tests.
Functions [hide private]
 
_ShareAll()
Returns a dict declaring all lock levels shared.
source code
 
_CheckInstanceNodeGroups(cfg, instance_name, owned_groups)
Checks if the owned node groups are still correct for an instance.
source code
 
_CheckNodeGroupInstances(cfg, group_uuid, owned_instances)
Checks if the instances in a node group are still correct.
source code
 
_SupportsOob(cfg, node)
Tells if node supports OOB.
source code
list
_GetWantedNodes(lu, nodes)
Returns list of checked and expanded node names.
source code
list
_GetWantedInstances(lu, instances)
Returns list of checked and expanded instance names.
source code
dict
_GetUpdatedParams(old_params, update_dict, use_default=True, use_none=False)
Return the new version of a parameter dictionary.
source code
 
_ReleaseLocks(lu, level, names=None, keep=None)
Releases locks owned by an LU.
source code
dict; tuple of (node name, volume name) as key, instance name as value
_MapInstanceDisksToNodes(instances)
Creates a map from (node, volume) to instance name.
source code
 
_RunPostHook(lu, node_name)
Runs the post-hook for an opcode on a single node.
source code
 
_CheckOutputFields(static, dynamic, selected)
Checks whether all selected fields are valid.
source code
 
_CheckGlobalHvParams(params)
Validates that given hypervisor params are not global ones.
source code
 
_CheckNodeOnline(lu, node, msg=None)
Ensure that a given node is online.
source code
 
_CheckNodeNotDrained(lu, node)
Ensure that a given node is not drained.
source code
 
_CheckNodeVmCapable(lu, node)
Ensure that a given node is vm capable.
source code
 
_CheckNodeHasOS(lu, node, os_name, force_variant)
Ensure that a node supports a given OS.
source code
 
_CheckNodeHasSecondaryIP(lu, node, secondary_ip, prereq)
Ensure that a node has the given secondary ip.
source code
 
_GetClusterDomainSecret()
Reads the cluster domain secret.
source code
 
_CheckInstanceDown(lu, instance, reason)
Ensure that an instance is not running.
source code
 
_ExpandItemName(fn, name, kind)
Expand an item name.
source code
 
_ExpandNodeName(cfg, name)
Wrapper over _ExpandItemName for nodes.
source code
 
_ExpandInstanceName(cfg, name)
Wrapper over _ExpandItemName for instance.
source code
dict
_BuildInstanceHookEnv(name, primary_node, secondary_nodes, os_type, status, memory, vcpus, nics, disk_template, disks, bep, hvp, hypervisor_name, tags)
Builds instance related env variables for hooks
source code
 
_NICListToTuple(lu, nics)
Build a list of nic information tuples.
source code
dict
_BuildInstanceHookEnvByObject(lu, instance, override=None)
Builds instance related env variables for hooks from an object.
source code
 
_AdjustCandidatePool(lu, exceptions)
Adjust the candidate pool after node operations.
source code
 
_DecideSelfPromotion(lu, exceptions=None)
Decide whether I should promote myself as a master candidate.
source code
 
_CheckNicsBridgesExist(lu, target_nics, target_node)
Check that the brigdes needed by a list of nics exist.
source code
 
_CheckInstanceBridgesExist(lu, instance, node=None)
Check that the brigdes needed by an instance exist.
source code
 
_CheckOSVariant(os_obj, name)
Check whether an OS name conforms to the os variants specification.
source code
 
_GetNodeInstancesInner(cfg, fn) source code
 
_GetNodeInstances(cfg, node_name)
Returns a list of all primary and secondary instances on a node.
source code
 
_GetNodePrimaryInstances(cfg, node_name)
Returns primary instances on a node.
source code
 
_GetNodeSecondaryInstances(cfg, node_name)
Returns secondary instances on a node.
source code
 
_GetStorageTypeArgs(cfg, storage_type)
Returns the arguments for a storage type.
source code
 
_FindFaultyInstanceDisks(cfg, rpc, instance, node_name, prereq) source code
 
_CheckIAllocatorOrNode(lu, iallocator_slot, node_slot)
Check the sanity of iallocator and node arguments and use the cluster-wide iallocator if appropriate.
source code
string
_GetDefaultIAllocator(cfg, iallocator)
Decides on which iallocator to use.
source code
 
_VerifyCertificate(filename)
Verifies a certificate for LUClusterVerifyConfig.
source code
list of (origin, hypervisor, parameters)
_GetAllHypervisorParameters(cluster, instances)
Compute the set of all hypervisor parameters.
source code
 
_UploadHelper(lu, nodes, fname)
Helper for uploading a file and showing warnings.
source code
 
_ComputeAncillaryFiles(cluster, redist)
Compute files external to Ganeti which need to be consistent.
source code
 
_RedistributeAncillaryFiles(lu, additional_nodes=None, additional_vm=True)
Distribute additional files which are part of the cluster configuration.
source code
 
_WaitForSync(lu, instance, disks=None, oneshot=False)
Sleep and poll for an instance's disk to sync.
source code
 
_CheckDiskConsistency(lu, dev, node, on_primary, ldisk=False)
Check that mirrors are not degraded.
source code
 
_AssembleInstanceDisks(lu, instance, disks=None, ignore_secondaries=False, ignore_size=False)
Prepare the block devices for an instance.
source code
 
_StartInstanceDisks(lu, instance, force)
Start the disks of an instance.
source code
 
_SafeShutdownInstanceDisks(lu, instance, disks=None)
Shutdown block devices of an instance.
source code
list of objects.Disk
_ExpandCheckDisks(instance, disks)
Return the instance disks selected by the disks list
source code
 
_ShutdownInstanceDisks(lu, instance, disks=None, ignore_primary=False)
Shutdown block devices of an instance.
source code
 
_CheckNodeFreeMemory(lu, node, reason, requested, hypervisor_name)
Checks if a node has enough free memory.
source code
 
_CheckNodesFreeDiskPerVG(lu, nodenames, req_sizes)
Checks if nodes have enough free disk space in the all VGs.
source code
 
_CheckNodesFreeDiskOnVG(lu, nodenames, vg, requested)
Checks if nodes have enough free disk space in the specified VG.
source code
 
_RemoveInstance(lu, feedback_fn, instance, ignore_failures)
Utility function to remove an instance.
source code
 
_CreateBlockDev(lu, node, instance, device, force_create, info, force_open)
Create a tree of block devices on a given node.
source code
 
_CreateSingleBlockDev(lu, node, instance, device, info, force_open)
Create a single block device on a given node.
source code
 
_GenerateUniqueNames(lu, exts)
Generate a suitable LV name.
source code
 
_GenerateDRBD8Branch(lu, primary, secondary, size, vgnames, names, iv_name, p_minor, s_minor)
Generate a drbd8 device complete with its children.
source code
 
_GenerateDiskTemplate(lu, template_name, instance_name, primary_node, secondary_nodes, disk_info, file_storage_dir, file_driver, base_index, feedback_fn)
Generate the entire disk layout for a given template type.
source code
 
_GetInstanceInfoText(instance)
Compute that text that should be added to the disk's metadata.
source code
 
_CalcEta(time_taken, written, total_size)
Calculates the ETA based on size written and total size.
source code
 
_WipeDisks(lu, instance)
Wipes instance disks.
source code
boolean
_CreateDisks(lu, instance, to_skip=None, target_node=None)
Create all disks for an instance.
source code
boolean
_RemoveDisks(lu, instance, target_node=None, ignore_failures=False)
Remove all disks for an instance.
source code
 
_ComputeDiskSizePerVG(disk_template, disks)
Compute disk size requirements in the volume group
source code
 
_ComputeDiskSize(disk_template, disks)
Compute disk size requirements in the volume group
source code
list
_FilterVmNodes(lu, nodenames)
Filters out non-vm_capable nodes from a list.
source code
 
_CheckHVParams(lu, nodenames, hvname, hvparams)
Hypervisor parameter validation.
source code
 
_CheckOSParams(lu, required, nodenames, osname, osparams)
OS parameters validation.
source code
dict
_GetInstanceConsole(cluster, instance)
Returns console information for an instance.
source code
 
_SetOpEarlyRelease(early_release, op)
Sets early_release flag on opcodes if available.
source code
 
_NodeEvacDest(use_nodes, group, nodes)
Returns group or nodes depending on caller's choice.
source code
 
_LoadNodeEvacResult(lu, alloc_result, early_release, use_nodes)
Unpacks the result of change-group and node-evacuate iallocator requests.
source code
 
_GetQueryImplementation(name)
Returns the implemtnation for a query type.
source code
Variables [hide private]
  _QUERY_IMPL = {constants.QR_INSTANCE: _InstanceQuery, constant...
Query type implementations

Imports: os, time, re, platform, logging, copy, OpenSSL, socket, tempfile, shutil, itertools, operator, ssh, utils, errors, hypervisor, locking, constants, objects, serializer, ssconf, uidpool, compat, masterd, netutils, query, qlang, opcodes, ht, ganeti


Function Details [hide private]

_CheckInstanceNodeGroups(cfg, instance_name, owned_groups)

source code 

Checks if the owned node groups are still correct for an instance.

Parameters:
  • cfg (config.ConfigWriter) - The cluster configuration
  • instance_name (string) - Instance name
  • owned_groups (set or frozenset) - List of currently owned node groups

_CheckNodeGroupInstances(cfg, group_uuid, owned_instances)

source code 

Checks if the instances in a node group are still correct.

Parameters:
  • cfg (config.ConfigWriter) - The cluster configuration
  • group_uuid (string) - Node group UUID
  • owned_instances (set or frozenset) - List of currently owned instances

_SupportsOob(cfg, node)

source code 

Tells if node supports OOB.

Parameters:
Returns:
The OOB script if supported or an empty string otherwise

_GetWantedNodes(lu, nodes)

source code 

Returns list of checked and expanded node names.

Parameters:
  • lu (LogicalUnit) - the logical unit on whose behalf we execute
  • nodes (list) - list of node names or None for all nodes
Returns: list
the list of nodes, sorted
Raises:

_GetWantedInstances(lu, instances)

source code 

Returns list of checked and expanded instance names.

Parameters:
  • lu (LogicalUnit) - the logical unit on whose behalf we execute
  • instances (list) - list of instance names or None for all instances
Returns: list
the list of instances, sorted
Raises:

_GetUpdatedParams(old_params, update_dict, use_default=True, use_none=False)

source code 

Return the new version of a parameter dictionary.

Parameters:
  • old_params (dict) - old parameters
  • update_dict (dict) - dict containing new parameter values, or constants.VALUE_DEFAULT to reset the parameter to its default value
  • use_default (whether to recognise constants.VALUE_DEFAULT values as 'to be deleted' values) - boolean
  • use_none (whether to recognise None values as 'to be deleted' values) - boolean
Returns: dict
the new parameter dictionary

_ReleaseLocks(lu, level, names=None, keep=None)

source code 

Releases locks owned by an LU.

Parameters:
  • level - Lock level
  • names (list or None) - Names of locks to release
  • keep (list or None) - Names of locks to retain
  • lu (LogicalUnit)

_MapInstanceDisksToNodes(instances)

source code 

Creates a map from (node, volume) to instance name.

Parameters:
Returns: dict; tuple of (node name, volume name) as key, instance name as value

_CheckOutputFields(static, dynamic, selected)

source code 

Checks whether all selected fields are valid.

Parameters:

_CheckGlobalHvParams(params)

source code 

Validates that given hypervisor params are not global ones.

This will ensure that instances don't get customised versions of global params.

_CheckNodeOnline(lu, node, msg=None)

source code 

Ensure that a given node is online.

Parameters:
  • lu - the LU on behalf of which we make the check
  • node - the node to check
  • msg - if passed, should be a message to replace the default one
Raises:

_CheckNodeNotDrained(lu, node)

source code 

Ensure that a given node is not drained.

Parameters:
  • lu - the LU on behalf of which we make the check
  • node - the node to check
Raises:

_CheckNodeVmCapable(lu, node)

source code 

Ensure that a given node is vm capable.

Parameters:
  • lu - the LU on behalf of which we make the check
  • node - the node to check
Raises:

_CheckNodeHasOS(lu, node, os_name, force_variant)

source code 

Ensure that a node supports a given OS.

Parameters:
  • lu - the LU on behalf of which we make the check
  • node - the node to check
  • os_name - the OS to query about
  • force_variant - whether to ignore variant errors
Raises:

_CheckNodeHasSecondaryIP(lu, node, secondary_ip, prereq)

source code 

Ensure that a node has the given secondary ip.

Parameters:
  • lu (LogicalUnit) - the LU on behalf of which we make the check
  • node (string) - the node to check
  • secondary_ip (string) - the ip to check
  • prereq (boolean) - whether to throw a prerequisite or an execute error
Raises:

_ExpandItemName(fn, name, kind)

source code 

Expand an item name.

Parameters:
  • fn - the function to use for expansion
  • name - requested item name
  • kind - text description ('Node' or 'Instance')
Returns:
the resolved (full) name
Raises:

_BuildInstanceHookEnv(name, primary_node, secondary_nodes, os_type, status, memory, vcpus, nics, disk_template, disks, bep, hvp, hypervisor_name, tags)

source code 

Builds instance related env variables for hooks

This builds the hook environment from individual variables.

Parameters:
  • name (string) - the name of the instance
  • primary_node (string) - the name of the instance's primary node
  • secondary_nodes (list) - list of secondary nodes as strings
  • os_type (string) - the name of the instance's OS
  • status (boolean) - the should_run status of the instance
  • memory (string) - the memory size of the instance
  • vcpus (string) - the count of VCPUs the instance has
  • nics (list) - list of tuples (ip, mac, mode, link) representing the NICs the instance has
  • disk_template (string) - the disk template of the instance
  • disks (list) - the list of (size, mode) pairs
  • bep (dict) - the backend parameters for the instance
  • hvp (dict) - the hypervisor parameters for the instance
  • hypervisor_name (string) - the hypervisor for the instance
  • tags (list) - list of instance tags as strings
Returns: dict
the hook environment for this instance

_NICListToTuple(lu, nics)

source code 

Build a list of nic information tuples.

This list is suitable to be passed to _BuildInstanceHookEnv or as a return value in LUInstanceQueryData.

Parameters:
  • lu (LogicalUnit) - the logical unit on whose behalf we execute
  • nics (list of objects.NIC) - list of nics to convert to hooks tuples

_BuildInstanceHookEnvByObject(lu, instance, override=None)

source code 

Builds instance related env variables for hooks from an object.

Parameters:
  • lu (LogicalUnit) - the logical unit on whose behalf we execute
  • instance (objects.Instance) - the instance for which we should build the environment
  • override (dict) - dictionary with key/values that will override our values
Returns: dict
the hook environment dictionary

_CheckOSVariant(os_obj, name)

source code 

Check whether an OS name conforms to the os variants specification.

Parameters:
  • os_obj (objects.OS) - OS object to check
  • name (string) - OS name passed by the user, to check for validity

_CheckIAllocatorOrNode(lu, iallocator_slot, node_slot)

source code 

Check the sanity of iallocator and node arguments and use the cluster-wide iallocator if appropriate.

Check that at most one of (iallocator, node) is specified. If none is specified, then the LU's opcode's iallocator slot is filled with the cluster-wide default iallocator.

Parameters:
  • iallocator_slot (string) - the name of the opcode iallocator slot
  • node_slot (string) - the name of the opcode target node slot

_GetDefaultIAllocator(cfg, iallocator)

source code 

Decides on which iallocator to use.

Parameters:
  • cfg (config.ConfigWriter) - Cluster configuration object
  • iallocator (string or None) - Iallocator specified in opcode
Returns: string
Iallocator name

_VerifyCertificate(filename)

source code 

Verifies a certificate for LUClusterVerifyConfig.

Parameters:
  • filename (string) - Path to PEM file

_GetAllHypervisorParameters(cluster, instances)

source code 

Compute the set of all hypervisor parameters.

Parameters:
Returns: list of (origin, hypervisor, parameters)
a list with all parameters found, indicating the hypervisor they apply to, and the origin (can be "cluster", "os X", or "instance Y")

_ComputeAncillaryFiles(cluster, redist)

source code 

Compute files external to Ganeti which need to be consistent.

Parameters:
  • redist (boolean) - Whether to include files which need to be redistributed

_RedistributeAncillaryFiles(lu, additional_nodes=None, additional_vm=True)

source code 

Distribute additional files which are part of the cluster configuration.

ConfigWriter takes care of distributing the config and ssconf files, but there are more files which should be distributed to all nodes. This function makes sure those are copied.

Parameters:
  • lu - calling logical unit
  • additional_nodes - list of nodes not in the config to distribute to
  • additional_vm (boolean) - whether the additional nodes are vm-capable or not

_CheckDiskConsistency(lu, dev, node, on_primary, ldisk=False)

source code 

Check that mirrors are not degraded.

The ldisk parameter, if True, will change the test from the is_degraded attribute (which represents overall non-ok status for the device(s)) to the ldisk (representing the local storage status).

_AssembleInstanceDisks(lu, instance, disks=None, ignore_secondaries=False, ignore_size=False)

source code 

Prepare the block devices for an instance.

This sets up the block devices on all nodes.

Parameters:
  • lu (LogicalUnit) - the logical unit on whose behalf we execute
  • instance (objects.Instance) - the instance for whose disks we assemble
  • disks (list of objects.Disk or None) - which disks to assemble (or all, if None)
  • ignore_secondaries (boolean) - if true, errors on secondary nodes won't result in an error return from the function
  • ignore_size (boolean) - if true, the current known size of the disk will not be used during the disk activation, useful for cases when the size is wrong
Returns:
False if the operation failed, otherwise a list of (host, instance_visible_name, node_visible_name) with the mapping from node devices to instance devices

_SafeShutdownInstanceDisks(lu, instance, disks=None)

source code 

Shutdown block devices of an instance.

This function checks if an instance is running, before calling _ShutdownInstanceDisks.

_ExpandCheckDisks(instance, disks)

source code 

Return the instance disks selected by the disks list

Parameters:
Returns: list of objects.Disk
selected instance disks to act on

_ShutdownInstanceDisks(lu, instance, disks=None, ignore_primary=False)

source code 

Shutdown block devices of an instance.

This does the shutdown on all nodes of the instance.

If the ignore_primary is false, errors on the primary node are ignored.

_CheckNodeFreeMemory(lu, node, reason, requested, hypervisor_name)

source code 

Checks if a node has enough free memory.

This function check if a given node has the needed amount of free memory. In case the node has less memory or we cannot get the information from the node, this function raise an OpPrereqError exception.

Parameters:
  • lu (LogicalUnit) - a logical unit from which we get configuration data
  • node (str) - the node to check
  • reason (str) - string to use in the error message
  • requested (int) - the amount of memory in MiB to check for
  • hypervisor_name (str) - the hypervisor to ask for memory stats
Raises:

_CheckNodesFreeDiskPerVG(lu, nodenames, req_sizes)

source code 

Checks if nodes have enough free disk space in the all VGs.

This function check if all given nodes have the needed amount of free disk. In case any node has less disk or we cannot get the information from the node, this function raise an OpPrereqError exception.

Parameters:
  • lu (LogicalUnit) - a logical unit from which we get configuration data
  • nodenames (list) - the list of node names to check
  • req_sizes (dict) - the hash of vg and corresponding amount of disk in MiB to check for
Raises:

_CheckNodesFreeDiskOnVG(lu, nodenames, vg, requested)

source code 

Checks if nodes have enough free disk space in the specified VG.

This function check if all given nodes have the needed amount of free disk. In case any node has less disk or we cannot get the information from the node, this function raise an OpPrereqError exception.

Parameters:
  • lu (LogicalUnit) - a logical unit from which we get configuration data
  • nodenames (list) - the list of node names to check
  • vg (str) - the volume group to check
  • requested (int) - the amount of disk in MiB to check for
Raises:

_CreateBlockDev(lu, node, instance, device, force_create, info, force_open)

source code 

Create a tree of block devices on a given node.

If this device type has to be created on secondaries, create it and all its children.

If not, just recurse to children keeping the same 'force' value.

Parameters:
  • lu - the lu on whose behalf we execute
  • node - the node on which to create the device
  • instance (objects.Instance) - the instance which owns the device
  • device (objects.Disk) - the device to create
  • force_create (boolean) - whether to force creation of this device; this will be change to True whenever we find a device which has CreateOnSecondary() attribute
  • info - the extra 'metadata' we should attach to the device (this will be represented as a LVM tag)
  • force_open (boolean) - this parameter will be passes to the backend.BlockdevCreate function where it specifies whether we run on primary or not, and it affects both the child assembly and the device own Open() execution

_CreateSingleBlockDev(lu, node, instance, device, info, force_open)

source code 

Create a single block device on a given node.

This will not recurse over children of the device, so they must be created in advance.

Parameters:
  • lu - the lu on whose behalf we execute
  • node - the node on which to create the device
  • instance (objects.Instance) - the instance which owns the device
  • device (objects.Disk) - the device to create
  • info - the extra 'metadata' we should attach to the device (this will be represented as a LVM tag)
  • force_open (boolean) - this parameter will be passes to the backend.BlockdevCreate function where it specifies whether we run on primary or not, and it affects both the child assembly and the device own Open() execution

_GenerateUniqueNames(lu, exts)

source code 

Generate a suitable LV name.

This will generate a logical volume name for the given instance.

_CalcEta(time_taken, written, total_size)

source code 

Calculates the ETA based on size written and total size.

Parameters:
  • time_taken - The time taken so far
  • written - amount written so far
  • total_size - The total size of data to be written
Returns:
The remaining time in seconds

_WipeDisks(lu, instance)

source code 

Wipes instance disks.

Parameters:
  • lu (LogicalUnit) - the logical unit on whose behalf we execute
  • instance (objects.Instance) - the instance whose disks we should create
Returns:
the success of the wipe

_CreateDisks(lu, instance, to_skip=None, target_node=None)

source code 

Create all disks for an instance.

This abstracts away some work from AddInstance.

Parameters:
  • lu (LogicalUnit) - the logical unit on whose behalf we execute
  • instance (objects.Instance) - the instance whose disks we should create
  • to_skip (list) - list of indices to skip
  • target_node (string) - if passed, overrides the target node for creation
Returns: boolean
the success of the creation

_RemoveDisks(lu, instance, target_node=None, ignore_failures=False)

source code 

Remove all disks for an instance.

This abstracts away some work from `AddInstance()` and `RemoveInstance()`. Note that in case some of the devices couldn't be removed, the removal will continue with the other ones (compare with `_CreateDisks()`).

Parameters:
  • lu (LogicalUnit) - the logical unit on whose behalf we execute
  • instance (objects.Instance) - the instance whose disks we should remove
  • target_node (string) - used to override the node on which to remove the disks
Returns: boolean
the success of the removal

_FilterVmNodes(lu, nodenames)

source code 

Filters out non-vm_capable nodes from a list.

Parameters:
  • lu (LogicalUnit) - the logical unit for which we check
  • nodenames (list) - the list of nodes on which we should check
Returns: list
the list of vm-capable nodes

_CheckHVParams(lu, nodenames, hvname, hvparams)

source code 

Hypervisor parameter validation.

This function abstract the hypervisor parameter validation to be used in both instance create and instance modify.

Parameters:
  • lu (LogicalUnit) - the logical unit for which we check
  • nodenames (list) - the list of nodes on which we should check
  • hvname (string) - the name of the hypervisor we should use
  • hvparams (dict) - the parameters which we need to check
Raises:

_CheckOSParams(lu, required, nodenames, osname, osparams)

source code 

OS parameters validation.

Parameters:
  • lu (LogicalUnit) - the logical unit for which we check
  • required (boolean) - whether the validation should fail if the OS is not found
  • nodenames (list) - the list of nodes on which we should check
  • osname (string) - the name of the hypervisor we should use
  • osparams (dict) - the parameters which we need to check
Raises:

_GetInstanceConsole(cluster, instance)

source code 

Returns console information for an instance.

Parameters:
Returns: dict

_LoadNodeEvacResult(lu, alloc_result, early_release, use_nodes)

source code 

Unpacks the result of change-group and node-evacuate iallocator requests.

Iallocator modes constants.IALLOCATOR_MODE_NODE_EVAC and constants.IALLOCATOR_MODE_CHG_GROUP.

Parameters:
  • lu (LogicalUnit) - Logical unit instance
  • alloc_result (tuple/list) - Result from iallocator
  • early_release (bool) - Whether to release locks early if possible
  • use_nodes (bool) - Whether to display node names instead of groups

_GetQueryImplementation(name)

source code 

Returns the implemtnation for a query type.

Parameters:

Variables Details [hide private]

_QUERY_IMPL

Query type implementations

Value:
{constants.QR_INSTANCE: _InstanceQuery, constants.QR_NODE: _NodeQuery,\
 constants.QR_GROUP: _GroupQuery, constants.QR_OS: _OsQuery,}