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 | |
Adds a node-specific prefix to a path in a virtual cluster. |
| Function | |
Returns the environment variables for a host. |
| Function | |
Replaces the node-specific root directory in a path. |
| Function | |
Returns the virtual hostname. |
| Function | |
Localizes a virtual path. |
| Function | |
Appends a node name to the base directory. |
| Function | |
Virtualizes a path. |
| Function | _ |
Very basic check for hostnames. |
| Function | _ |
Retrieves virtual hostname from an environment variable. |
| Function | _ |
Retrieves root directory from an environment variable. |
| Function | _ |
Checks if the root directory and hostname are acceptable. |
| Function | _ |
Removes the node-specific prefix from a path. |
| Constant | _VIRT |
Undocumented |
| Constant | _VIRT |
Undocumented |
| Constant | _VIRT |
Undocumented |
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.
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).
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.
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.
Retrieves virtual hostname from an environment variable.
| Parameters | |
| envname:string | Environment variable name |
| Returns | |
| string | Host name (can be empty) |
Retrieves root directory from an environment variable.
| Parameters | |
| envname:string | Environment variable name |
| Returns | |
| string | Root directory (can be empty) |
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:string | Root directory (from environment) |
| hostname:string | Hostname (from environment) |
| Returns | |
| tuple; (string, string, string or None) | Tuple containing cluster-global root directory, node root directory and virtual hostname |
Removes the node-specific prefix from a path.
This is the opposite of AddNodePrefix and removes a node-local prefix path.