ganeti¶
Ganeti module.
- exception spicerack.ganeti.GanetiError[source]¶
Bases:
spicerack.exceptions.SpicerackError
Raised on errors from Ganeti operations.
- 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 Ganeti cluster to get a RAPI for.
- Returns
the RAPI interface object
- Return type
- Raises
spicerack.ganeti.GanetiError -- on an invalid cluster name
- 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: Dict¶
Return complete cluster information.
- Returns
Cluster information dictionary
- Return type
- Raises
spicerack.ganeti.GanetiError -- API errors
- property master: Optional[str]¶
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.
- add(*, row: str, vcpus: int, memory: int, disk: int, link: str) None [source]¶
Create the VM for the instance in the Ganeti cluster with the specified characteristic.
- Parameters
row (str) -- the Datacenter physical row where to allocate the instance, one of
spicerack.ganeti.CLUSTERS_AND_ROWS
based on the current cluster.vcpus (int) -- the number of virtual CPUs to assign to the instance.
memory (int) -- the amount of RAM to assign to the instance in gigabytes.
disk (int) -- the amount of disk to assign to the instance in gigabytes.
link (str) -- the type of network link to use, one of
spicerack.ganeti.INSTANCE_LINKS
.
- Raises
spicerack.ganeti.GanetiError -- on parameter validation error.
Note
This action requires few minutes, inform the user about the waiting time when using this method.
- 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.
- spicerack.ganeti.CLUSTERS_AND_ROWS: Dict[str, Tuple[str, ...]] = {'ganeti-test01.svc.codfw.wmnet': ('A',), 'ganeti01.svc.codfw.wmnet': ('A', 'B', 'C', 'D'), 'ganeti01.svc.drmrs.wmnet': ('B12',), 'ganeti01.svc.eqiad.wmnet': ('A', 'B', 'C', 'D'), 'ganeti01.svc.eqsin.wmnet': ('1',), 'ganeti01.svc.esams.wmnet': ('OE',), 'ganeti01.svc.ulsfo.wmnet': ('1',), 'ganeti02.svc.drmrs.wmnet': ('B13',)}¶
the available Ganeti clusters with the set of available rows in each of them.
- Type