Utility function mainly, but not only used by instance LU's.
Function |
|
Applies descriptions in mods to container. |
Function |
|
Helper method to create disk's hooks env |
Function |
|
Helper method to create hooks env related to disk's logical_id |
Function |
|
Builds instance related env variables for hooks |
Function |
|
Builds instance related env variables for hooks from an object. |
Function |
|
Checks if the provided compression tool is allowed to be used. |
Function |
|
In case of conflicting IP address raise error. |
Function |
|
Ensures that a given hostname resolves to a 'sane' name. |
Function |
|
Check that the brigdes needed by an instance exist. |
Function |
|
Raises an error if an instance with the given name exists already. |
Function |
|
Check that the brigdes needed by a list of nics exist. |
Function |
|
Checks if a node has enough free memory. |
Function |
|
Ensure that a given node is not drained. |
Function |
|
Checks if nodes have enough physical CPUs |
Function |
|
Ensure that a given node is vm capable. |
Function |
|
Generate error if opportunistic locking is not possible. |
Function |
|
Checks that the target node is correct in terms of instance policy. |
Function |
|
Computes the full beparams. |
Function |
|
Compute the name of the instance NIC used by instance communication. |
Function |
|
Compute if instance specs meets the specs of ipolicy. |
Function |
|
Computes the nics. |
Function |
|
Makes a copy of a list of lock names. |
Function |
|
Wrapper around IAReqInstanceAlloc. |
Function |
|
Reads the cluster domain secret. |
Function |
|
Check if the identifier represents a valid container index and return it. |
Function |
|
Compute that text that should be added to the disk's metadata. |
Function |
|
Return the item refered by the identifier. |
Function |
|
Insert an item to the provided index of a container. |
Function |
|
Build a list of nic information tuples. |
Function |
|
Build a tupple of nic information. |
Function |
|
Prepares a list of container modifications by adding a private data field. |
Function |
|
Releases locks owned by an LU. |
Function |
|
Remove all or a subset of disks for an instance. |
Function |
|
Utility function to remove an instance. |
Function |
|
Updates instance metadata on the metadata daemon on the instance's primary node. |
Function | _ |
Compute if instance meets the specs of the new target group. |
Function | _ |
Returns an iterable of all storage paths to be removed. |
Variable | _ |
Undocumented |
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 | 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 |
attach | Callback for attaching an existing item to a container (constants.DDM_ATTACH ); receives absolute item index and item UUID or name, returns tuple containing new item and changes as list |
modify | 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 | Callback on removing item; receives absolute item index, item and private data object as added by PrepareContainerMods |
detach | Callback on detaching item; receives absolute item index, item and private data object as added by PrepareContainerMods |
post | Callable for post-processing a newly created item after it has been put into the container. It receives the index of the new item and the new item as parameters. |
Helper method to create disk's hooks env
Parameters | |
idx:integer | The index of the disk |
disk:objects.Disk or dict | The disk object or a simple dict in case of LUInstanceCreate |
Helper method to create hooks env related to disk's logical_id
Parameters | |
idx:integer | The index of the disk |
disk:objects.Disk | The disk object |
Builds instance related env variables for hooks
This builds the hook environment from individual variables.
Parameters | |
name:string | the name of the instance |
primary | the name of the instance's primary node |
secondary | list of secondary nodes as strings |
os | the name of the instance's OS |
status:string | the desired status of the instance |
minmem:string | the minimum memory size of the instance |
maxmem:string | the maximum memory size of the instance |
vcpus:string | the count of VCPUs the instance has |
nics:list | list of tuples (name, uuid, ip, mac, mode, link, vlan, net, netinfo) representing the NICs the instance has |
disk | the disk template of the instance |
disks:list | list of disks (either objects.Disk or dict) |
bep:dict | the backend parameters for the instance |
hvp:dict | the hypervisor parameters for the instance |
hypervisor | the hypervisor for the instance |
tags:list | list of instance tags as strings |
Returns | |
dict | the hook environment for this instance |
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 |
secondary | Undocumented |
disks | Undocumented |
override:dict | dictionary with key/values that will override our values |
Returns | |
dict | the hook environment dictionary |
Checks if the provided compression tool is allowed to be used.
Parameters | |
lu | Undocumented |
compression | Compression tool to use for importing or exporting the instance |
Returns | |
NoneType | None |
Raises | |
errors.OpPrereqError | If the tool is not enabled by Ganeti or whitelisted |
In case of conflicting IP address raise error.
Parameters | |
lu | Undocumented |
ip:string | IP address |
node | node UUID |
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 |
Raises an error if an instance with the given name exists already.
Parameters | |
lu | Undocumented |
instance | The name of the instance. To be used in the locking phase. |
Checks if a node has enough free memory.
This function checks 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 raises an OpPrereqError exception.
Parameters | |
lu:LogicalUnit | a logical unit from which we get configuration data |
node | the node to check |
reason:str | string to use in the error message |
requested:int | the amount of memory in MiB to check for |
hvname:string | the hypervisor's name |
hvparams:dict of strings | the hypervisor's parameters |
Returns | |
integer | node current free memory |
Raises | |
errors.OpPrereqError | if the node doesn't have enough memory, or we cannot check the node |
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 | |
errors.OpPrereqError | if the node is drained |
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 | the list of node UUIDs to check |
requested:int | the minimum acceptable number of physical CPUs |
hypervisor | list of hypervisor specifications in pairs (hypervisor_name, hvparams) |
Raises | |
errors.OpPrereqError | if the node doesn't have enough CPUs, or we cannot check the node |
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 | |
errors.OpPrereqError | if the node is not vm capable |
Checks that the target node is correct in terms of instance policy.
Parameters | |
lu | Undocumented |
ipolicy | The ipolicy to verify |
instance | The instance object to verify |
node | The new node to relocate |
cfg:config.ConfigWriter | Cluster configuration |
ignore | Ignore violations of the ipolicy |
_compute | The function to verify ipolicy (unittest only) |
See Also | |
ganeti.cmdlib.common.ComputeIPolicySpecViolation |
Computes the full beparams.
Parameters | |
op | The instance opcode |
cluster | The cluster config object |
Returns | |
The fully filled beparams |
Compute the name of the instance NIC used by instance communication.
With instance communication, a new NIC is added to the instance. This NIC has a special name that identities it as being part of instance communication, and not just a normal NIC. This function generates the name of the NIC based on a prefix and the instance name
Parameters | |
instance | name of the instance the NIC belongs to |
Returns | |
string | name of the NIC |
Compute if instance specs meets the specs of ipolicy.
Parameters | |
ipolicy:dict | The ipolicy to verify against |
instance | The instance spec to verify |
disk | the disk templates of the instance |
_compute | The function to verify ipolicy (unittest only) |
See Also | |
ComputeIPolicySpecViolation |
Computes the nics.
Parameters | |
op | The instance opcode |
cluster | Cluster configuration object |
default | The default ip to assign |
cfg | An instance of the configuration object |
ec | Execution context ID |
Returns | |
The build up nics |
Wrapper around IAReqInstanceAlloc.
Parameters | |
op | The instance opcode |
disks | The computed disks |
nics | The computed nics |
beparams | The full filled beparams |
node | List of nodes which should appear as online to the allocator (unless the node is already marked offline) |
Returns | |
A filled iallocator.IAReqInstanceAlloc |
Check if the identifier represents a valid container index and return it.
Used in "add" and "attach" actions.
Parameters | |
identifier:string | Item index or name or UUID |
kind:string | Type of item, e.g. "disk", "nic" |
container:list | Container to calculate the index from |
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 |
Insert an item to the provided index of a container.
Used in "add" and "attach" actions.
Parameters | |
identifier:string | Item index |
item:object | The item to be inserted |
container:list | Container to insert the item to |
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 |
Build a tupple of nic information.
Parameters | |
lu:LogicalUnit | the logical unit on whose behalf we execute |
nic:objects.NIC | nic to convert to hooks tuple |
Prepares a list of container modifications by adding a private data field.
Parameters | |
mods:list of tuples; (operation, index, parameters) | List of modifications |
private | Callable for constructing a private data field for a modification |
Returns | |
list | Undocumented |
Releases locks owned by an LU.
Parameters | |
lu:LogicalUnit | Undocumented |
level | Lock level |
names:list or None | Names of locks to release |
keep:list or None | Names of locks to retain |
Remove all or a subset of 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.
This function is also used by the disk template conversion mechanism to remove the old block devices of the instance. Since the instance has changed its template at the time we remove the original disks, we must specify the template of the disks we are about to remove as an argument.
Parameters | |
lu:LogicalUnit | the logical unit on whose behalf we execute |
instance:objects.Instance | the instance whose disks we should remove |
disks:list of objects.Disk | the disks to remove; if not specified, all the disks of the instance are removed |
target | used to override the node on which to remove the disks |
ignore | Undocumented |
Returns | |
boolean | the success of the removal |
Updates instance metadata on the metadata daemon on the instance's primary node.
If the daemon isn't available (not compiled), do nothing.
In case the RPC fails, this function simply issues a warning and proceeds normally.
Parameters | |
feedback | function used send feedback back to the caller |
rpc:rpc.node.RpcRunner | RPC runner |
instance:objects.Instance | instance for which the metadata should be updated |
osparams | public OS parameters used to override those defined in instance |
osparams | private OS parameters used to override those defined in instance |
osparams | secret OS parameters used to override those defined in instance |
Returns | |
NoneType | None |
Compute if instance meets the specs of the new target group.
Parameters | |
ipolicy | The ipolicy to verify |
instance | The instance object to verify |
current | The current group of the instance |
target | The new group of the instance |
cfg:config.ConfigWriter | Cluster configuration |
_compute | The function to verify ipolicy (unittest only) |
See Also | |
ganeti.cmdlib.common.ComputeIPolicySpecViolation |
Returns an iterable of all storage paths to be removed.
A storage path is removed if no disks are contained in it anymore.
Parameters | |
removed:list of objects.Disk | The disks that are being removed |
disks:list of objects.Disk | All disks attached to the instance |
Returns | |
list of file paths | the storage directories that need to be removed |