class documentation

class IAllocator(object):

View In Hierarchy

IAllocator framework.

An IAllocator instance has three sets of attributes:

  • cfg that is needed to query the cluster
  • input data (all members of the _KEYS class attribute are required)
  • four buffer attributes (in|out_data|text), that represent the input (to the external script) in text and data structure format, and the output from it, again in two formats
  • the result variables from the script (success, info, nodes) for easy usage
Method __init__ Undocumented
Method Run Run an instance allocator and return the results.
Instance Variable cfg Undocumented
Instance Variable in_data Undocumented
Instance Variable in_text Undocumented
Instance Variable info Undocumented
Instance Variable out_data Undocumented
Instance Variable out_text Undocumented
Instance Variable req Undocumented
Instance Variable result Undocumented
Instance Variable rpc Undocumented
Instance Variable success Undocumented
Static Method _ComputeBasicNodeData Compute global node data.
Static Method _ComputeInstanceData Compute global instance data.
Static Method _ComputeInstanceMemory Compute memory used by primary instances.
Static Method _ComputeNodeGroupData Compute node groups data.
Static Method _ComputeStorageDataFromSpaceInfo Extract storage data from node info.
Static Method _ComputeStorageDataFromSpaceInfoByTemplate Extract storage data from node info.
Static Method _GetAttributeFromHypervisorNodeData Extract an attribute from the hypervisor's node information.
Method _BuildInputData Build input data structures.
Method _ComputeClusterData Compute the generic allocator input data.
Method _ComputeClusterDataNodeInfo Prepare and execute node info call.
Method _ComputeDynamicNodeData Compute global node data.
Method _ValidateResult Process the allocator results.
def __init__(self, cfg, rpc_runner, req):

Undocumented

def Run(self, name, validate=True, call_fn=None):

Run an instance allocator and return the results.

cfg =

Undocumented

in_data =

Undocumented

in_text =

Undocumented

info =

Undocumented

out_data =

Undocumented

out_text =

Undocumented

req =

Undocumented

result =

Undocumented

rpc =

Undocumented

success =

Undocumented

@staticmethod
def _ComputeBasicNodeData(cfg, node_cfg):

Compute global node data.

Returns
dicta dict of name: (node dict, node config)
@staticmethod
def _ComputeInstanceData(cfg, cluster_info, i_list):

Compute global instance data.

@staticmethod
def _ComputeInstanceMemory(instance_list, node_instances_info, node_uuid, input_mem_free):

Compute memory used by primary instances.

Returns
tuple (int, int, int)A tuple of three integers: 1. the sum of memory used by primary instances on the node (including the ones that are currently down), 2. the sum of memory used by primary instances of the node that are up, 3. the amount of memory that is free on the node considering the current usage of the instances.
@staticmethod
def _ComputeNodeGroupData(cluster, ginfo):

Compute node groups data.

@staticmethod
def _ComputeStorageDataFromSpaceInfo(space_info, node_name, has_lvm):

Extract storage data from node info.

Parameters
space_info:see result of the RPC call node infothe storage reporting part of the result of the RPC call node info
node_name:stringthe node's name
has_lvm:booleanwhether or not LVM storage information is requested
Returns
4-tuple of integerstuple of storage info (total_disk, free_disk, total_spindles, free_spindles)
@staticmethod
def _ComputeStorageDataFromSpaceInfoByTemplate(space_info, node_name, disk_template):

Extract storage data from node info.

Parameters
space_info:see result of the RPC call node infothe storage reporting part of the result of the RPC call node info
node_name:stringthe node's name
disk_template:stringthe disk template to report space for
Returns
4-tuple of integerstuple of storage info (total_disk, free_disk, total_spindles, free_spindles)
@staticmethod
def _GetAttributeFromHypervisorNodeData(hv_info, node_name, attr):

Extract an attribute from the hypervisor's node information.

This is a helper function to extract data from the hypervisor's information about the node, as part of the result of a node_info query.

Parameters
hv_info:dict of stringsdictionary of node information from the hypervisor
node_name:stringname of the node
attr:stringkey of the attribute in the hv_info dictionary
Returns
integerthe value of the attribute
Raises
errors.OpExecErrorif key not in dictionary or value not integer
def _BuildInputData(self, req):

Build input data structures.

def _ComputeClusterData(self, disk_template=None):

Compute the generic allocator input data.

Parameters
disk_template:list of stringthe disk templates of the instances to be allocated
def _ComputeClusterDataNodeInfo(self, disk_templates, node_list, cluster_info, hypervisor_name):

Prepare and execute node info call.

Parameters
disk_templates:list of stringthe disk templates of the instances to be allocated
node_list:list of stringslist of nodes' UUIDs
cluster_info:objects.Clusterthe cluster's information from the config
hypervisor_name:stringthe hypervisor name
Returns
same as the result of the node info RPC callthe result of the node info RPC call
def _ComputeDynamicNodeData(self, node_cfg, node_data, node_iinfo, i_list, node_results, disk_template):

Compute global node data.

Parameters
node_cfgUndocumented
node_dataUndocumented
node_iinfoUndocumented
i_listUndocumented
node_resultsthe basic node structures as filled from the config
disk_templateUndocumented
def _ValidateResult(self):

Process the allocator results.

This will process and if successful save the result in self.out_data and the other parameters.