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:
- 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 thespicerack.orchestrator.DEFAULT_PORT
.- Return type:
- 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:
spicerack.apiclient.APIClientError -- if the given uri does not start with a slash (/) or if the request couldn't be performed.
spicerack.orchestrator.OrchestratorError -- if the response status code is not ok, between 400 and 600. It will parse the JSON response and use it in the exception message if present.
- Return type: