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(name, node, accept_offline_node)
Checks if a node is online.
source code
 
_NodeConfigResolver(single_node_fn, all_nodes_fn, hosts, opts)
Calculate node addresses using configuration.
source code
 
_ObjectToDict(value)
Converts an object to a dictionary.
source code
 
_ObjectListToDict(value)
Converts a list of objects to dictionaries.
source code
 
_EncodeNodeToDiskDict(value)
Encodes a dictionary with node name as key and disk objects as values.
source code
 
_PrepareFileUpload(getents_fn, filename)
Loads a file and prepares it for an upload to nodes.
source code
 
_PrepareFinalizeExportDisks(snap_disks)
Encodes disks for finalizing export.
source code
 
_EncodeImportExportIO((ieio, ieioargs))
Encodes import/export I/O information.
source code
 
_EncodeBlockdevRename(value)
Encodes information for renaming block devices.
source code
 
MakeLegacyNodeInfo(data, require_vg_info=True)
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(template, disks, disk_params)
Annotates the disk objects with the disk parameters.
source code
 
_GetESFlag(cfg, nodename) source code
dict
GetExclusiveStorageForNodeNames(cfg, nodelist)
Return the exclusive storage flag 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(name, node, accept_offline_node)

source code 

Checks if a node is online.

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

_ObjectToDict(value)

source code 

Converts an object to a dictionary.

Note: See objects.

MakeLegacyNodeInfo(data, require_vg_info=True)

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.

Parameters:
  • require_vg_info - raise an error if the returnd vg_info doesn't have any values

AnnotateDiskParams(template, disks, disk_params)

source code 

Annotates the disk objects with the disk parameters.

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

GetExclusiveStorageForNodeNames(cfg, nodelist)

source code 

Return the exclusive storage flag for all the given nodes.

Parameters:
  • cfg (config.ConfigWriter) - cluster configuration
  • nodelist (list or tuple) - node names for which to read the flag
Returns: dict
mapping from node names to exclusive storage flags
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_NODE_TO_DISK_DICT: _EncodeNodeToDiskDi\
ct, rpc_defs.ED_COMPRESS: _Compress, rpc_defs.ED_FINALIZE_EXPORT_DISKS\
: _PrepareFinalizeExportDisks, rpc_defs.ED_IMPEXP_IO: _EncodeImportExp\
ortIO, rpc_defs.ED_BLOCKDEV_RENAME: _EncodeBlockdevRename,}