orchestrator

Generic API client module.

exception spicerack.orchestrator.OrchestratorError[source]

Bases: SpicerackError

General errors raised by this module.

class spicerack.orchestrator.Orchestrator(base_url: str, http_session: requests.sessions.Session, *, dry_run: bool = True) None[source]

Bases: APIClient

Orchestrator API class.

Initialize the instance.

Parameters:
  • base_url (str) -- the full base URL for the API. It must include the scheme and the domain and can include the API path prefix if there is one.

  • http_session (requests.sessions.Session) -- the requests's session to use to make the API calls.

  • dry_run (bool, default: True) -- whether this is a DRY-RUN.

clusters() dict[str, dict][source]

Get the current clusters and their metadata.

Return type:

dict[str, dict]

Returns:

a dictionary of clusters with cluster names as keys and cluster metadata as values.

Raises:

spicerack.apiclient.APIClient -- if the request fails for any reason.

instance(instance: str) dict[source]

Get the metadata of an instance. It will automatically splits the port if present or use the default if not.

Parameters:

instance (str) -- the instance name as reported in orchestrator (FQDN:PORT). If the port is not present it will automatically use the spicerack.orchestrator.DEFAULT_PORT.

Return type:

dict

Returns:

a dictionary with the instance metadata.

Raises:

spicerack.apiclient.APIClient -- if the request fails for any reason or the instance does not exists.

request(*args: Any, **kwargs: Any) requests.models.Response[source]

Perform an API request to Orchestrator based on the given parameters.

See spicerack.apiclient.APIClient.request() for all the arguments and return values.

Raises:
Return type:

requests.models.Response