ganeti¶
Ganeti module.
-
class
spicerack.ganeti.
Ganeti
(username: str, password: str, timeout: int, remote: spicerack.remote.Remote)[source]¶ Bases:
object
Class which wraps all Ganeti clusters.
Initialize the instance.
- Parameters
username (str) -- The RAPI username to use.
password (str) -- The RAPI password to use.
timeout (int) -- The timeout in seconds for each request to the API.
remote (spicerack.remote.Remote) -- the remote instance to connect to Ganeti hosts.
-
fetch_cluster_for_instance
(fqdn: str) → str[source]¶ Return the cluster name for a given FQDN if possible.
- Parameters
fqdn (str) -- The FQDN for the host to locate.
- Returns
The cluster name if found.
- Return type
- Raises
spicerack.ganeti.GanetiError -- if the host was not found in any configured cluster.
-
instance
(instance: str, *, cluster: str = '') → spicerack.ganeti.GntInstance[source]¶ Return an instance of GntInstance to perform RW operation on the given Ganeti VM instance.
- Parameters
- Returns
ready to perform RW actions.
- Return type
-
rapi
(cluster: str) → spicerack.ganeti.GanetiRAPI[source]¶ Return a RAPI object for a particular cluster.
- Parameters
cluster (str) -- the name of the cluster to get a RAPI for.
- Returns
the RAPI interface object
- Return type
- Raises
spicerack.ganeti.GanetiError -- on an invalid cluster name
-
exception
spicerack.ganeti.
GanetiError
[source]¶ Bases:
spicerack.exceptions.SpicerackError
Raised on errors from Ganeti operations.
-
class
spicerack.ganeti.
GanetiRAPI
(cluster_url: str, username: str, password: str, timeout: int, ca_path: str)[source]¶ Bases:
object
Class which wraps the read-only Ganeti RAPI.
Initialize the instance.
- Parameters
-
fetch_instance
(fqdn: str) → Dict[source]¶ Return full information about an instance.
- Parameters
fqdn -- the FQDN of the instance in question
- Returns
host information
- Return type
- Raises
spicerack.ganeti.GanetiError -- API errors
-
fetch_instance_mac
(fqdn: str) → str[source]¶ Convenience method to return the 0th adapter's MAC address for an instance.
Note that we don't allow the creation of instances with more than one MAC address at this time.
- Parameters
fqdn -- the FQDN of the instance in question
- Returns
MAC address
- Return type
- Raises
GanetiError -- API errors
-
property
info
¶ Return complete cluster information.
- Returns
Cluster information dictionary
- Return type
- Raises
spicerack.ganeti.GanetiError -- API errors
-
property
master
¶ Return the internal name for the current ganeti master node.
- Returns
The hostname of the master node (or None if the data is missing).
- Return type
- Raises
spicerack.ganeti.GanetiError -- API errors
-
class
spicerack.ganeti.
GntInstance
(master: spicerack.remote.RemoteHosts, cluster: str, instance: str)[source]¶ Bases:
object
Class that wraps gnt-instance command execution on a Ganeti cluster master host.
Initialize the instance.
- Parameters
master (spicerack.remote.RemoteHosts) -- the Ganeti cluster master remote instance.
cluster (str) -- the Ganeti cluster name.
instance (str) -- the FQDN of the Ganeti VM instance to act upon.
-
property
cluster
¶ Getter for the Ganeti cluster property.
- Returns
the Ganeti cluster name the instance belongs to.
- Return type
-
remove
(*, shutdown_timeout: int = 2) → None[source]¶ Shutdown and remove the VM instance from the Ganeti cluster, including its disks.
- Parameters
shutdown_timeout (int) -- time in minutes to wait for a clean shutdown before pulling the plug.
Note
This action requires few minutes, inform the user about the waiting time when using this method.