Common functions used by multiple logical units.
Function |
|
Create an OpCode that adds the instance communication network. |
Function |
|
Undocumented |
Function |
|
Add the node's client SSL certificate digest to the candidate certs. |
Function |
|
Adjust the candidate pool after node operations. |
Function |
|
Little helper wrapper to the rpc annotation method. |
Function |
|
Checks if the access param is consistent with the cluster configuration. |
Function |
|
Checks if the access parameter is legal. |
Function |
|
Helper function to check if a disk template is enabled. |
Function |
|
Hypervisor parameter validation. |
Function |
|
Check the sanity of iallocator and node arguments and use the cluster-wide iallocator if appropriate. |
Function |
|
Checks if a given image description is either a valid file path or a URL. |
Function |
|
Checks if the owned node groups are still correct for an instance. |
Function |
|
Checks if node groups for locked instances are still correct. |
Function |
|
Ensure that an instance is in one of the required states. |
Function |
|
Checks ipolicy disk templates against enabled disk tempaltes. |
Function |
|
Checks if the instances in a node group are still correct. |
Function |
|
Ensure that a given node is online. |
Function |
|
Check node PVs. |
Function |
|
Checks if the OS image in the OS parameters of an opcode is valid. |
Function |
|
OS parameters validation. |
Function |
|
Make sure that none of the given paramters is global. |
Function |
|
Helper function to check if a storage type is enabled. |
Function |
|
Compute files external to Ganeti which need to be consistent. |
Function |
|
Verifies ipolicy against provided disk sizes. |
Function |
|
Compute if instance meets the specs of ipolicy. |
Function |
|
Verifies ipolicy against provided specs. |
Function |
|
Computes a set of any instances that would violate the new ipolicy. |
Function |
|
Create an OpCode that connects a group to the instance communication network. |
Function |
|
Determines the size of the specified image. |
Function |
|
Ensure KVM daemon is running on nodes with KVM instances. |
Function |
|
Wrapper over _ExpandItemName for instance. |
Function |
|
Expand a short node name into the node UUID and full name. |
Function |
|
Undocumented |
Function |
|
Get the client SSL certificate digest for the node. |
Function |
|
Decides on which iallocator to use. |
Function |
|
Return the new version of an instance policy. |
Function |
|
Return the new version of a parameter dictionary. |
Function |
|
Returns list of checked and expanded instance names. |
Function |
|
Returns list of checked and expanded node names. |
Function |
|
Whether exclusive_storage is in effect for the given node. |
Function |
|
Given an instance object, checks if the instance is running. |
Function |
|
Checks if an hypervisor can read a disk template with given mode. |
Function |
|
Unpacks the result of change-group and node-evacuate iallocator requests. |
Function |
|
Creates a map from (node, volume) to instance name. |
Function |
|
Combines the disk state from an opcode with the one of the object |
Function |
|
Combines the hv state from an opcode with the one of the object |
Function |
|
Distribute additional files which are part of the cluster configuration. |
Function |
|
Removes the node's certificate from the candidate certificates list. |
Function |
|
Runs the post-hook for an opcode on a single node. |
Function |
|
Returns a dict declaring all lock levels shared. |
Function |
|
Tells if node supports OOB. |
Function |
|
Helper for uploading a file and showing warnings. |
Function |
|
Undocumented |
Constant | INSTANCE |
Undocumented |
Constant | INSTANCE |
Undocumented |
Constant | INSTANCE |
Undocumented |
Function | _ |
Computes if value is in the desired range. |
Function | _ |
Computes a set of instances who violates given ipolicy. |
Function | _ |
Expand an item name. |
Function | _ |
Filters out non-vm_capable nodes from a list. |
Function | _ |
Returns group or nodes depending on caller's choice. |
Function | _ |
Sets early_release flag on opcodes if available. |
Function | _ |
Updates and verifies a dict with sub dicts of the same type. |
Create an OpCode that adds the instance communication network.
This OpCode contains the configuration necessary for the instance communication network.
Parameters | |
network:string | name or UUID of the instance communication network |
Returns | |
ganeti.opcodes.OpCode | OpCode that creates the instance communication network |
Add the node's client SSL certificate digest to the candidate certs.
Parameters | |
lu:LogicalUnit | the logical unit |
cfg:ConfigWriter | the configuration client to use |
node | the node's UUID |
Adjust the candidate pool after node operations.
Parameters | |
lu | Undocumented |
exceptions | Undocumented |
master | name of the master node |
potential | list of node names of potential master candidates |
feedback | function emitting user-visible output |
modify | whether or not the ssh setup can be modified. |
Little helper wrapper to the rpc annotation method.
Parameters | |
instance | The instance object |
devs:List of objects.Disk | The root devices (not any of its children!) |
cfg | The config object @returns The annotated disk copies @see ganeti.rpc.node.AnnotateDiskParams |
Checks if the access param is consistent with the cluster configuration.
Parameters | |
parameters | the parameters to validate |
cfg | the cfg object of the cluster |
group | if set, only check for consistency within this group. |
Raises | |
errors.OpPrereqError | if the LU attempts to change the access parameter to an invalid value, such as "pink bunny". |
errors.OpPrereqError | if the LU attempts to change the access parameter to an inconsistent value, such as asking for RBD userspace access to the chroot hypervisor. |
Note | |
requires a configuration lock to run. |
Checks if the access parameter is legal.
Raises | |
errors.OpPrereqError | if the check fails. |
See Also | |
CheckDiskAccessModeConsistency for cluster consistency checks. |
Helper function to check if a disk template is enabled.
Parameters | |
cluster:objects.Cluster | the cluster's configuration |
disk | the disk template to be checked |
Hypervisor parameter validation.
This function abstracts the hypervisor parameter validation to be used in both instance create and instance modify.
Parameters | |
lu:LogicalUnit | the logical unit for which we check |
node | 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 | |
errors.OpPrereqError | if the parameters are not valid |
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, or the iallocator is constants.DEFAULT_IALLOCATOR_SHORTCUT
, then the LU's opcode's iallocator slot is filled with the cluster-wide default iallocator.
Parameters | |
lu | Undocumented |
iallocator | the name of the opcode iallocator slot |
node | the name of the opcode target node slot |
Checks if a given image description is either a valid file path or a URL.
Parameters | |
image:string | An absolute path or URL, the assumed location of a disk image. |
error | The error message to show if the image is not valid. |
Raises | |
errors.OpPrereqError | If the validation fails. |
Checks if the owned node groups are still correct for an instance.
Parameters | |
cfg:config.ConfigWriter | The cluster configuration |
inst | Instance UUID |
owned | List of currently owned node groups |
primary | Whether to check node groups for only the primary node |
Checks if node groups for locked instances are still correct.
Parameters | |
cfg:config.ConfigWriter | Cluster configuration |
instances:dict; string as key, objects.Instance as value | Dictionary, instance UUID as key, instance object as value |
owned | List of owned groups |
owned | List of owned nodes |
cur | Optional group UUID to check against instance's groups |
Ensure that an instance is in one of the required states.
Parameters | |
lu | the LU on behalf of which we make the check |
instance | the instance to check |
req | Undocumented |
msg | if passed, should be a message to replace the default one |
Raises | |
errors.OpPrereqError | if the instance is not in the required state |
Checks ipolicy disk templates against enabled disk tempaltes.
Parameters | |
ipolicy:dict | the new ipolicy |
enabled | list of enabled disk templates on the cluster |
Raises | |
errors.OpPrereqError | if there is at least one allowed disk template that is not also enabled. |
Checks if the instances in a node group are still correct.
Parameters | |
cfg:config.ConfigWriter | The cluster configuration |
group | Node group UUID |
owned | List of currently owned instances |
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 | |
errors.OpPrereqError | if the node is offline |
Checks if the OS image in the OS parameters of an opcode is valid.
This function can also be used in LUs as they carry an opcode.
Parameters | |
op:opcodes.OpCode | opcode containing the OS params |
Returns | |
string or NoneType | None if the OS parameters in the opcode do not contain the OS image, otherwise the OS image value contained in the OS parameters |
Raises | |
errors.OpPrereqError | if OS image is not a URL or an absolute path |
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 |
node | the list of nodes on which we should check |
osname:string | the name of the OS we should use |
osparams:dict | the parameters which we need to check |
force | Undocumented |
Raises | |
errors.OpPrereqError | if the parameters are not valid |
Make sure that none of the given paramters is global.
If a global parameter is found, an errors.OpPrereqError
exception is raised. This is used to avoid setting global parameters for individual nodes.
Parameters | |
params:dictionary | Parameters to check |
glob | Forbidden parameters |
kind:string | Kind of parameters (e.g. "node") |
bad | Level(s) at which the parameters are forbidden (e.g. "instance") |
good | Level(s) at which the parameters are allowed (e.g. "cluster or group") |
Helper function to check if a storage type is enabled.
Parameters | |
cluster:objects.Cluster | the cluster's configuration |
storage | the storage type to be checked |
Compute files external to Ganeti which need to be consistent.
Parameters | |
cluster | Undocumented |
redist:boolean | Whether to include files which need to be redistributed |
Verifies ipolicy against provided disk sizes.
No other specs except the disk sizes, the number of disks and the disk template are checked.
Parameters | |
ipolicy:dict | The ipolicy |
disk | Disk sizes of used disk (len must match disk_count) |
disks:list of Disk | The Disk objects of the instance |
_compute | The compute function (unittest only) |
Returns | |
A list of violations, or an empty list of no violations are found |
Compute if instance meets the specs of ipolicy.
Parameters | |
ipolicy:dict | The ipolicy to verify against |
instance:objects.Instance | The instance to verify |
cfg:config.ConfigWriter | Cluster configuration |
_compute | The function to verify ipolicy (unittest only) |
See Also | |
ComputeIPolicySpecViolation |
Verifies ipolicy against provided specs.
Parameters | |
ipolicy:dict | The ipolicy |
mem | The memory size |
cpu | Used cpu cores |
disk | Number of disks used |
nic | Number of nics used |
disk | Disk sizes of used disk (len must match disk_count) |
spindle | The number of spindles this instance uses |
disk | The disk template of the instance |
_compute | The compute function (unittest only) |
Returns | |
A list of violations, or an empty list of no violations are found |
Computes a set of any instances that would violate the new ipolicy.
Parameters | |
old | The current (still in-place) ipolicy |
new | The new (to become) ipolicy |
instances | List of instances to verify |
cfg:config.ConfigWriter | Cluster configuration |
Returns | |
A list of instances which violates the new ipolicy but did not before |
Create an OpCode that connects a group to the instance communication network.
This OpCode contains the configuration necessary for the instance communication network.
Parameters | |
group | UUID of the group to connect |
network:string | name or UUID of the network to connect to, i.e., the instance communication network |
Returns | |
ganeti.opcodes.OpCode | OpCode that connects the group to the instance communication network |
Determines the size of the specified image.
Parameters | |
lu | Undocumented |
image:string | absolute filepath or URL of the image |
node | if image is a filepath, this is the UUID of the node where the image is located |
Returns | |
int | size of the image in MB, rounded up |
Raises | |
OpExecError | if the image does not exist |
Ensure KVM daemon is running on nodes with KVM instances.
If user shutdown is enabled in the cluster:
- The KVM daemon will be started on VM capable nodes containing KVM instances.
- The KVM daemon will be stopped on non VM capable nodes.
If user shutdown is disabled in the cluster:
- The KVM daemon will be stopped on all nodes
Issues a warning for each failed RPC call.
Parameters | |
lu:LogicalUnit | logical unit on whose behalf we execute |
feedback | feedback function |
nodes:list of string | if supplied, it overrides the node uuids to start/stop; this is used mainly for optimization |
silent | if we should suppress warnings in case KVM daemon is already stopped |
Expand a short node name into the node UUID and full name.
Parameters | |
cfg:config.ConfigWriter | The cluster configuration |
expected | expected UUID for the node (or None if there is no expectation). If it does not match, a errors.OpPrereqError is raised. |
name:string | the short node name |
Get the client SSL certificate digest for the node.
Parameters | |
lu | Undocumented |
node | the node's UUID |
filename:string | the certificate's filename |
Returns | |
string | the digest of the newly created certificate |
Decides on which iallocator to use.
Parameters | |
cfg:config.ConfigWriter | Cluster configuration object |
ialloc:string or None | Iallocator specified in opcode |
Returns | |
string | Iallocator name |
Return the new version of an instance policy.
Parameters | |
old | Undocumented |
new | Undocumented |
group | whether this policy applies to a group and thus we should support removal of policy entries |
Return the new version of a parameter dictionary.
Parameters | |
old | old parameters |
update | dict containing new parameter values, or constants.VALUE_DEFAULT to reset the parameter to its default value |
useconstants.VALUE_DEFAULT values as 'to be deleted' values | boolean |
use | boolean |
Returns | |
dict | the new parameter dictionary |
Returns list of checked and expanded instance names.
Parameters | |
lu:LogicalUnit | the logical unit on whose behalf we execute |
short | list of instance names or None for all instances |
Returns | |
tuple of lists | tuple of (instance UUIDs, instance names) |
Raises | |
errors.OpPrereqError | if the instances parameter is wrong type |
errors.OpPrereqError | if any of the passed instances is not found |
Returns list of checked and expanded node names.
Parameters | |
lu:LogicalUnit | the logical unit on whose behalf we execute |
short | list of node names or None for all nodes |
Returns | |
tuple of lists | tupe with (list of node UUIDs, list of node names) |
Raises | |
errors.ProgrammerError | if the nodes parameter is wrong type |
Whether exclusive_storage is in effect for the given node.
Parameters | |
cfg:config.ConfigWriter | The cluster configuration |
node:objects.Node | The node |
Returns | |
bool | The effective value of exclusive_storage |
Given an instance object, checks if the instance is running.
This function asks the backend whether the instance is running and user shutdown instances are considered not to be running.
Parameters | |
lu:LogicalUnit | LU on behalf of which we make the check |
instance:objects.Instance | instance to check whether it is running |
prereq | Undocumented |
Returns | |
bool | 'True' if the instance is running, 'False' otherwise |
Checks if an hypervisor can read a disk template with given mode.
Parameters | |
hv | the hypervisor that will access the data |
disk | the disk template the data is stored as |
mode | how the hypervisor should access the data |
Returns | |
True if the hypervisor can read a given read disk_template in the specified mode. |
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 from iallocator |
early | Whether to release locks early if possible |
use | Whether to display node names instead of groups |
Creates a map from (node, volume) to instance name.
Parameters | |
cfg:config.ConfigWriter | The cluster configuration |
instances:list of objects.Instance | Undocumented |
Returns | |
dict; tuple of (node uuid, volume name) as key, objects.Instance object as value | Undocumented |
Combines the disk state from an opcode with the one of the object
Parameters | |
op | The input dict from the opcode |
obj | The input dict from the objects |
Returns | |
The verified and updated dict |
Combines the hv state from an opcode with the one of the object
Parameters | |
op | The input dict from the opcode |
obj | The input dict from the objects |
Returns | |
The verified and updated dict |
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.
Removes the node's certificate from the candidate certificates list.
Parameters | |
cfg:config.ConfigWriter | the cluster's configuration |
node | the node's UUID |
Tells if node supports OOB.
Parameters | |
cfg:config.ConfigWriter | The cluster configuration |
node:objects.Node | The node |
Returns | |
The OOB script if supported or an empty string otherwise |
Computes if value is in the desired range.
Parameters | |
name | name of the parameter for which we perform the check |
qualifier | a qualifier used in the error message (e.g. 'disk/1', not just 'disk') |
ispecs | dictionary containing min and max values |
value | actual value that we want to use |
Returns | |
None or an error string |
Computes a set of instances who violates given ipolicy.
Parameters | |
ipolicy | The ipolicy to verify |
instances:objects.Instance | List of instances to verify |
cfg:config.ConfigWriter | Cluster configuration |
Returns | |
A frozenset of instance names violating the ipolicy |
Expand an item name.
Parameters | |
expand | the function to use for expansion |
name | requested item name |
kind | text description ('Node' or 'Instance') |
Returns | |
the result of the expand_fn, if successful | |
Raises | |
errors.OpPrereqError | if the item is not found |
Filters out non-vm_capable nodes from a list.
Parameters | |
lu:LogicalUnit | the logical unit for which we check |
node | the list of nodes on which we should check |
Returns | |
list | the list of vm-capable nodes |