module documentation

Module containing utilities for virtual clusters.

Most functions manipulate file system paths and are no-ops when the environment variables GANETI_ROOTDIR and GANETI_HOSTNAME are not set. See the functions' docstrings for details.

Function AddNodePrefix Adds a node-specific prefix to a path in a virtual cluster.
Function EnvironmentForHost Returns the environment variables for a host.
Function ExchangeNodeRoot Replaces the node-specific root directory in a path.
Function GetVirtualHostname Returns the virtual hostname.
Function LocalizeVirtualPath Localizes a virtual path.
Function MakeNodeRoot Appends a node name to the base directory.
Function MakeVirtualPath Virtualizes a path.
Function _CheckHostname Very basic check for hostnames.
Function _GetHostname Retrieves virtual hostname from an environment variable.
Function _GetRootDirectory Retrieves root directory from an environment variable.
Function _PreparePaths Checks if the root directory and hostname are acceptable.
Function _RemoveNodePrefix Removes the node-specific prefix from a path.
Constant _VIRT_BASEDIR Undocumented
Constant _VIRT_HOSTNAME Undocumented
Constant _VIRT_NODEROOT Undocumented
def AddNodePrefix(path, _noderoot=_VIRT_NODEROOT):

Adds a node-specific prefix to a path in a virtual cluster.

Returned path includes user-specified root directory if specified in environment. As an example, the path /var/lib/ganeti becomes /tmp/vcluster/node1/var/lib/ganeti if /tmp/vcluster/node1 is the root directory specified in the environment.

def EnvironmentForHost(hostname, _basedir=_VIRT_BASEDIR):

Returns the environment variables for a host.

def ExchangeNodeRoot(node_name, filename, _basedir=_VIRT_BASEDIR, _noderoot=_VIRT_NODEROOT):

Replaces the node-specific root directory in a path.

Replaces it with the root directory for another node. Assuming /tmp/vcluster/node1 is the root directory for node1, the result will be /tmp/vcluster/node3 for node3 (as long as a root directory is specified in the environment).

def GetVirtualHostname():

Returns the virtual hostname.

Returns
string or NoneUndocumented
def LocalizeVirtualPath(path, _noderoot=_VIRT_NODEROOT):

Localizes a virtual path.

A "virtualized" path consists of a prefix (LocalizeVirtualPath) and a local path. This function adds the node-specific directory to the local path. Virtual paths are meant to be transported via RPC.

def MakeNodeRoot(base, node_name):

Appends a node name to the base directory.

def MakeVirtualPath(path, _noderoot=_VIRT_NODEROOT):

Virtualizes a path.

A path is "virtualized" by stripping it of its node-specific directory and prepending a prefix (_VIRT_PATH_PREFIX). Use LocalizeVirtualPath to undo the process. Virtual paths are meant to be transported via RPC.

def _CheckHostname(hostname):

Very basic check for hostnames.

Parameters
hostname:stringHostname
def _GetHostname(envname):

Retrieves virtual hostname from an environment variable.

Parameters
envname:stringEnvironment variable name
Returns
stringHost name (can be empty)
def _GetRootDirectory(envname):

Retrieves root directory from an environment variable.

Parameters
envname:stringEnvironment variable name
Returns
stringRoot directory (can be empty)
def _PreparePaths(rootdir, hostname):

Checks if the root directory and hostname are acceptable.

The (node-specific) root directory must have the hostname as its last component. The parent directory then becomes the cluster-wide root directory. This is necessary as some components must be able to predict the root path on a remote node (e.g. copying files via scp).

Parameters
rootdir:stringRoot directory (from environment)
hostname:stringHostname (from environment)
Returns
tuple; (string, string, string or None)Tuple containing cluster-global root directory, node root directory and virtual hostname
def _RemoveNodePrefix(path, _noderoot=_VIRT_NODEROOT):

Removes the node-specific prefix from a path.

This is the opposite of AddNodePrefix and removes a node-local prefix path.

_VIRT_BASEDIR =

Undocumented

_VIRT_HOSTNAME =

Undocumented

_VIRT_NODEROOT =

Undocumented