ganeti

Ganeti module.

class spicerack.ganeti.Ganeti(username: str, password: str, timeout: int)[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.

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

str

Raises

spicerack.ganeti.GanetiError -- if the host was not found in any configured cluster.

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

spicerack.ganeti.GanetiRAPI

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
  • cluster (str) -- the short name of the cluster to access.

  • username (str) -- the RAPI user name

  • password (str) -- the RAPI user's password

  • timeout (int) -- the timeout in seconds for each request

  • ca_path (str) -- the path to the signing certificate authority

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

dict

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

str

Raises

GanetiError -- API errors

property info

Return complete cluster information.

Returns

Cluster information dictionary

Return type

dict

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

str

Raises

spicerack.ganeti.GanetiError -- API errors