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

Module instance

source code

Logical units dealing with instances.

Classes [hide private]
  LUInstanceCreate
Create an instance.
  LUInstanceRename
Rename an instance.
  LUInstanceRemove
Remove an instance.
  LUInstanceMove
Move an instance by data-copying.
  LUInstanceMultiAlloc
Allocates multiple instances at the same time.
  _InstNicModPrivate
Data structure for network interface modifications.
  LUInstanceSetParams
Modifies an instances's parameters.
  LUInstanceChangeGroup
Functions [hide private]
 
_CheckHostnameSane(lu, name)
Ensures that a given hostname resolves to a 'sane' name.
source code
 
_CheckOpportunisticLocking(op)
Generate error if opportunistic locking is not possible.
source code
 
_CreateInstanceAllocRequest(op, disks, nics, beparams, node_name_whitelist)
Wrapper around IAReqInstanceAlloc.
source code
 
_ComputeFullBeParams(op, cluster)
Computes the full beparams.
source code
 
_ComputeNics(op, cluster, default_ip, cfg, ec_id)
Computes the nics.
source code
 
_CheckForConflictingIp(lu, ip, node_uuid)
In case of conflicting IP address raise error.
source code
 
_ComputeIPolicyInstanceSpecViolation(ipolicy, instance_spec, disk_template, _compute_fn=ComputeIPolicySpecViolation)
Compute if instance specs meets the specs of ipolicy.
source code
 
_CheckOSVariant(os_obj, name)
Check whether an OS name conforms to the os variants specification.
source code
list
_PrepareContainerMods(mods, private_fn)
Prepares a list of container modifications by adding a private data field.
source code
 
_CheckNodesPhysicalCPUs(lu, node_uuids, requested, hypervisor_specs)
Checks if nodes have enough physical CPUs
source code
 
GetItemFromContainer(identifier, kind, container)
Return the item refered by the identifier.
source code
 
_ApplyContainerMods(kind, container, chgdesc, mods, create_fn, modify_fn, remove_fn)
Applies descriptions in mods to container.
source code
 
_UpdateIvNames(base_index, disks)
Updates the iv_name attribute of disks.
source code
Variables [hide private]
  _TApplyContModsCbChanges = ht.TMaybeListOf(ht.TAnd(ht.TIsLengt...
Type description for changes as returned by _ApplyContainerMods's callbacks

Imports: OpenSSL, copy, logging, os, compat, constants, errors, ht, hypervisor, locking, iallocator, masterd, netutils, objects, opcodes, pathutils, rpc, utils, NoHooksLU, LogicalUnit, ResultWithJobs, INSTANCE_DOWN, INSTANCE_NOT_RUNNING, CAN_CHANGE_INSTANCE_OFFLINE, CheckNodeOnline, ShareAll, GetDefaultIAllocator, CheckInstanceNodeGroups, LoadNodeEvacResult, CheckIAllocatorOrNode, CheckParamsNotGlobal, IsExclusiveStorageEnabledNode, CheckHVParams, CheckOSParams, AnnotateDiskParams, GetUpdatedParams, ExpandInstanceUuidAndName, ComputeIPolicySpecViolation, CheckInstanceState, ExpandNodeUuidAndName, CheckDiskTemplateEnabled, CreateDisks, CheckNodesFreeDiskPerVG, WipeDisks, WipeOrCleanupDisks, WaitForSync, IsExclusiveStorageEnabledNodeUuid, CreateSingleBlockDev, ComputeDisks, CheckRADOSFreeSpace, ComputeDiskSizePerVG, GenerateDiskTemplate, StartInstanceDisks, ShutdownInstanceDisks, AssembleInstanceDisks, CheckSpindlesExclusiveStorage, BuildInstanceHookEnvByObject, GetClusterDomainSecret, BuildInstanceHookEnv, NICListToTuple, NICToTuple, CheckNodeNotDrained, RemoveInstance, CopyLockList, ReleaseLocks, CheckNodeVmCapable, CheckTargetNodeIPolicy, GetInstanceInfoText, RemoveDisks, CheckNodeFreeMemory, CheckInstanceBridgesExist, CheckNicsBridgesExist, CheckNodeHasOS, ganeti


Function Details [hide private]

_CheckHostnameSane(lu, name)

source code 

Ensures that a given hostname resolves to a 'sane' name.

The given name is required to be a prefix of the resolved hostname, to prevent accidental mismatches.

Parameters:
  • lu - the logical unit on behalf of which we're checking
  • name - the name we should resolve and check
Returns:
the resolved hostname object

_CreateInstanceAllocRequest(op, disks, nics, beparams, node_name_whitelist)

source code 

Wrapper around IAReqInstanceAlloc.

Parameters:
  • op - The instance opcode
  • disks - The computed disks
  • nics - The computed nics
  • beparams - The full filled beparams
  • node_name_whitelist - List of nodes which should appear as online to the allocator (unless the node is already marked offline)
Returns:
A filled iallocator.IAReqInstanceAlloc

_ComputeFullBeParams(op, cluster)

source code 

Computes the full beparams.

Parameters:
  • op - The instance opcode
  • cluster - The cluster config object
Returns:
The fully filled beparams

_ComputeNics(op, cluster, default_ip, cfg, ec_id)

source code 

Computes the nics.

Parameters:
  • op - The instance opcode
  • cluster - Cluster configuration object
  • default_ip - The default ip to assign
  • cfg - An instance of the configuration object
  • ec_id - Execution context ID
Returns:
The build up nics

_CheckForConflictingIp(lu, ip, node_uuid)

source code 

In case of conflicting IP address raise error.

Parameters:
  • ip (string) - IP address
  • node_uuid (string) - node UUID

_ComputeIPolicyInstanceSpecViolation(ipolicy, instance_spec, disk_template, _compute_fn=ComputeIPolicySpecViolation)

source code 

Compute if instance specs meets the specs of ipolicy.

Parameters:
  • ipolicy (dict) - The ipolicy to verify against
  • instance_spec - dict
  • instance_spec - The instance spec to verify
  • disk_template (string) - the disk template of the instance
  • _compute_fn - The function to verify ipolicy (unittest only)

_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

_PrepareContainerMods(mods, private_fn)

source code 

Prepares a list of container modifications by adding a private data field.

Parameters:
  • mods (list of tuples; (operation, index, parameters)) - List of modifications
  • private_fn (callable or None) - Callable for constructing a private data field for a modification
Returns: list

_CheckNodesPhysicalCPUs(lu, node_uuids, requested, hypervisor_specs)

source code 

Checks if nodes have enough physical CPUs

This function checks if all given nodes have the needed number of physical CPUs. In case any node has less CPUs or we cannot get the information from the node, this function raises an OpPrereqError exception.

Parameters:
  • lu (LogicalUnit) - a logical unit from which we get configuration data
  • node_uuids (list) - the list of node UUIDs to check
  • requested (int) - the minimum acceptable number of physical CPUs
  • hypervisor_specs (list of pairs (string, dict of strings)) - list of hypervisor specifications in pairs (hypervisor_name, hvparams)
Raises:

GetItemFromContainer(identifier, kind, container)

source code 

Return the item refered by the identifier.

Parameters:
  • identifier (string) - Item index or name or UUID
  • kind (string) - One-word item description
  • container (list) - Container to get the item from

_ApplyContainerMods(kind, container, chgdesc, mods, create_fn, modify_fn, remove_fn)

source code 

Applies descriptions in mods to container.

Parameters:
  • kind (string) - One-word item description
  • container (list) - Container to modify
  • chgdesc (None or list) - List of applied changes
  • mods (list) - Modifications as returned by _PrepareContainerMods
  • create_fn (callable) - Callback for creating a new item (constants.DDM_ADD); receives absolute item index, parameters and private data object as added by _PrepareContainerMods, returns tuple containing new item and changes as list
  • modify_fn (callable) - Callback for modifying an existing item (constants.DDM_MODIFY); receives absolute item index, item, parameters and private data object as added by _PrepareContainerMods, returns changes as list
  • remove_fn (callable) - Callback on removing item; receives absolute item index, item and private data object as added by _PrepareContainerMods

_UpdateIvNames(base_index, disks)

source code 

Updates the iv_name attribute of disks.

Parameters:

Variables Details [hide private]

_TApplyContModsCbChanges

Type description for changes as returned by _ApplyContainerMods's callbacks

Value:
ht.TMaybeListOf(ht.TAnd(ht.TIsLength(2), ht.TItems([ht.TNonEmptyString\
, ht.TAny,])))