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

Module rpc

source code

Inter-node RPC library.

Classes [hide private]
  RpcResult
RPC Result class.
  _StaticResolver
  _RpcProcessor
  _RpcClientBase
  RpcRunner
RPC runner class.
  JobQueueRunner
RPC wrappers for job queue.
  BootstrapRunner
RPC wrappers for bootstrapping.
  DnsOnlyRunner
RPC wrappers for calls using only DNS.
  ConfigRunner
RPC wrappers for config.
Functions [hide private]
 
Init()
Initializes the module-global HTTP client manager.
source code
 
Shutdown()
Stops the module-global HTTP client manager.
source code
 
_ConfigRpcCurl(curl) source code
 
RunWithRPC(fn)
RPC-wrapper decorator.
source code
tuple
_Compress(_, data)
Compresses a string for transport over RPC.
source code
list of tuple; (string, string)
_SsconfResolver(ssconf_ips, node_list, _, ssc=ssconf.SimpleStore, nslookup_fn=netutils.Hostname.GetIP)
Return addresses for given node names.
source code
 
_CheckConfigNode(node_uuid_or_name, node, accept_offline_node)
Checks if a node is online.
source code
 
_NodeConfigResolver(single_node_fn, all_nodes_fn, node_uuids, opts)
Calculate node addresses using configuration.
source code
 
_ObjectToDict(_, value)
Converts an object to a dictionary.
source code
 
_ObjectListToDict(node, value)
Converts a list of objects to dictionaries.
source code
 
_PrepareFileUpload(getents_fn, node, filename)
Loads a file and prepares it for an upload to nodes.
source code
 
_PrepareFinalizeExportDisks(_, snap_disks)
Encodes disks for finalizing export.
source code
 
_EncodeBlockdevRename(_, value)
Encodes information for renaming block devices.
source code
None
_AddSpindlesToLegacyNodeInfo(result, space_info)
Extracts the spindle information from the space info and adds it to the result dictionary.
source code
 
_AddStorageInfoToLegacyNodeInfoByTemplate(result, space_info, disk_template)
Extracts the storage space information of the disk template from the space info and adds it to the result dictionary.
source code
 
MakeLegacyNodeInfo(data, disk_template)
Formats the data returned by rpc.RpcRunner.call_node_info.
source code
 
_AnnotateDParamsDRBD(disk, (drbd_params, data_params, meta_params))
Annotates just DRBD disks layouts.
source code
 
_AnnotateDParamsGeneric(disk, (params,))
Generic disk parameter annotation routine.
source code
 
AnnotateDiskParams(disks, disk_params)
Annotates the disk objects with the disk parameters.
source code
 
_GetExclusiveStorageFlag(cfg, node_uuid) source code
list of tuples (string, string, list)
_AddExclusiveStorageFlagToLvmStorageUnits(storage_units, es_flag)
Adds the exclusive storage flag to lvm units.
source code
dict
GetExclusiveStorageForNodes(cfg, node_uuids)
Return the exclusive storage flag for all the given nodes.
source code
dict
PrepareStorageUnitsForNodes(cfg, storage_units, node_uuids)
Return the lvm storage unit for all the given nodes.
source code
Variables [hide private]
  _RPC_CLIENT_HEADERS = ["Content-type: %s" % http.HTTP_APP_JSON...
  _OFFLINE = object()
Special value to describe an offline host
  _ENCODERS = {rpc_defs.ED_OBJECT_DICT: _ObjectToDict, rpc_defs....
Generic encoders

Imports: logging, zlib, base64, pycurl, threading, copy, utils, objects, http, serializer, constants, errors, netutils, ssconf, runtime, compat, rpc_defs, pathutils, vcluster, _generated_rpc, ganeti


Function Details [hide private]

Init()

source code 

Initializes the module-global HTTP client manager.

Must be called before using any RPC function and while exactly one thread is running.

Shutdown()

source code 

Stops the module-global HTTP client manager.

Must be called before quitting the program and while exactly one thread is running.

RunWithRPC(fn)

source code 

RPC-wrapper decorator.

When applied to a function, it runs it with the RPC system initialized, and it shutsdown the system afterwards. This means the function must be called without RPC being initialized.

_Compress(_, data)

source code 

Compresses a string for transport over RPC.

Small amounts of data are not compressed.

Parameters:
  • data (str) - Data
Returns: tuple
Encoded data to send

_SsconfResolver(ssconf_ips, node_list, _, ssc=ssconf.SimpleStore, nslookup_fn=netutils.Hostname.GetIP)

source code 

Return addresses for given node names.

Parameters:
  • ssconf_ips (bool) - Use the ssconf IPs
  • node_list (list) - List of node names
  • ssc (class) - SimpleStore class that is used to obtain node->ip mappings
  • nslookup_fn (callable) - function use to do NS lookup
Returns: list of tuple; (string, string)
List of tuples containing node name and IP address

_CheckConfigNode(node_uuid_or_name, node, accept_offline_node)

source code 

Checks if a node is online.

Parameters:
  • node_uuid_or_name (string) - Node UUID
  • node (objects.Node or None) - Node object

_NodeConfigResolver(single_node_fn, all_nodes_fn, node_uuids, opts)

source code 

Calculate node addresses using configuration.

Note that strings in node_uuids are treated as node names if the UUID is not found in the configuration.

_ObjectToDict(_, value)

source code 

Converts an object to a dictionary.

Note: See objects.

_AddSpindlesToLegacyNodeInfo(result, space_info)

source code 

Extracts the spindle information from the space info and adds it to the result dictionary.

Parameters:
  • result (dict of strings) - dictionary holding the result of the legacy node info
  • space_info (list of dicts of strings) - list, each row holding space information of one storage unit
Returns: None
does not return anything, manipulates the result variable

_AddStorageInfoToLegacyNodeInfoByTemplate(result, space_info, disk_template)

source code 

Extracts the storage space information of the disk template from the space info and adds it to the result dictionary.

See Also: _AddSpindlesToLegacyNodeInfo for parameter information.

MakeLegacyNodeInfo(data, disk_template)

source code 

Formats the data returned by rpc.RpcRunner.call_node_info.

Converts the data into a single dictionary. This is fine for most use cases, but some require information from more than one volume group or hypervisor.

AnnotateDiskParams(disks, disk_params)

source code 

Annotates the disk objects with the disk parameters.

Parameters:
  • disks - The list of disks objects to annotate
  • disk_params - The disk parameters for annotation
Returns:
A list of disk objects annotated

_AddExclusiveStorageFlagToLvmStorageUnits(storage_units, es_flag)

source code 

Adds the exclusive storage flag to lvm units.

This function creates a copy of the storage_units lists, with the es_flag being added to all lvm storage units.

Parameters:
  • storage_units (list of pairs (string, string)) - list of 'raw' storage units, consisting only of (storage_type, storage_key)
  • es_flag (boolean) - exclusive storage flag
Returns: list of tuples (string, string, list)
list of storage units (storage_type, storage_key, params) with the params containing the es_flag for lvm-vg storage units

GetExclusiveStorageForNodes(cfg, node_uuids)

source code 

Return the exclusive storage flag for all the given nodes.

Parameters:
  • cfg (config.ConfigWriter) - cluster configuration
  • node_uuids (list or tuple) - node UUIDs for which to read the flag
Returns: dict
mapping from node uuids to exclusive storage flags
Raises:

PrepareStorageUnitsForNodes(cfg, storage_units, node_uuids)

source code 

Return the lvm storage unit for all the given nodes.

Main purpose of this function is to map the exclusive storage flag, which can be different for each node, to the default LVM storage unit.

Parameters:
  • cfg (config.ConfigWriter) - cluster configuration
  • storage_units (list of pairs (string, string)) - list of 'raw' storage units, e.g. pairs of (storage_type, storage_key)
  • node_uuids (list or tuple) - node UUIDs for which to read the flag
Returns: dict
mapping from node uuids to a list of storage units which include the exclusive storage flag for lvm storage
Raises:

Variables Details [hide private]

_RPC_CLIENT_HEADERS

Value:
["Content-type: %s" % http.HTTP_APP_JSON, "Expect:",]

_ENCODERS

Generic encoders

Value:
{rpc_defs.ED_OBJECT_DICT: _ObjectToDict, rpc_defs.ED_OBJECT_DICT_LIST:\
 _ObjectListToDict, rpc_defs.ED_COMPRESS: _Compress, rpc_defs.ED_FINAL\
IZE_EXPORT_DISKS: _PrepareFinalizeExportDisks, rpc_defs.ED_BLOCKDEV_RE\
NAME: _EncodeBlockdevRename,}