Container Base API
- class libcloud.container.base.ContainerDriver(key, secret=None, secure=True, host=None, port=None, **kwargs)[source]
A base ContainerDriver class to derive from
This class is always subclassed by a specific driver.
- Parameters:
key (
str) – API key or username to used (required)secret (
str) – Secret password to be used (required)secure (
bool) – Whether to use HTTPS or HTTP. Note: Some providers only support HTTPS, and it is on by default.host (
str) – Override hostname used for connections.port (
int) – Override port used for connections.
- Returns:
None
- connectionCls
alias of
ConnectionUserAndKey
- create_cluster(name: str, location: ClusterLocation | None = None) ContainerCluster[source]
Create a container cluster
- Parameters:
name (
str) – The name of the clusterlocation (
ClusterLocation) – The location to create the cluster in
- Return type:
- deploy_container(name: str, image: ContainerImage, cluster: ContainerCluster | None = None, parameters: str | None = None, start: bool = True) Container[source]
Deploy an installed container image
- Parameters:
name (
str) – The name of the new containerimage (
ContainerImage) – The container image to deploycluster (
ContainerCluster) – The cluster to deploy to, None is defaultparameters (
str) – Container Image parametersstart (
bool) – Start the container on deployment
- Return type:
- destroy_cluster(cluster: ContainerCluster) bool[source]
Delete a cluster
- Returns:
Trueif the destroy was successful, otherwiseFalse.- Return type:
bool
- destroy_container(container: Container) bool[source]
Destroy a deployed container
- Parameters:
container (
Container) – The container to destroy- Return type:
bool
- get_cluster(id: str) ContainerCluster[source]
Get a cluster by ID
- Parameters:
id (
str) – The ID of the cluster to get- Return type:
- get_container(id: str) Container[source]
Get a container by ID
- Parameters:
id (
str) – The ID of the container to get- Return type:
- install_image(path: str) ContainerImage[source]
Install a container image from a remote path.
- Parameters:
path (
str) – Path to the container image- Return type:
- list_clusters(location: ClusterLocation | None = None) List[ContainerCluster][source]
Get a list of potential locations to deploy clusters into
- Parameters:
location (
ClusterLocation) – The location to search in- Return type:
listofContainerCluster
- list_containers(image: ContainerImage | None = None, cluster: ContainerCluster | None = None) List[Container][source]
List the deployed container images
- Parameters:
image (
ContainerImage) – Filter to containers with a certain imagecluster (
ContainerCluster) – Filter to containers in a cluster
- Return type:
listofContainer
- list_images() List[ContainerImage][source]
List the installed container images
- Return type:
listofContainerImage
- list_locations() List[ClusterLocation][source]
Get a list of potential locations to deploy clusters into
- Return type:
listofClusterLocation
- supports_clusters = False
Whether the driver supports containers being deployed into clusters
- class libcloud.container.base.Container(id, name, image, state, ip_addresses, driver, extra=None, created_at=None)[source]
Container.
- Parameters:
id (
str) – Container id.name (
str) – The name of the container.image (
ContainerImage) – The image this container was deployed using.state (
libcloud.container.types.ContainerState) – The state of the container, e.g. runningip_addresses (
listofstr) – A list of IP addresses for this containerdriver (
ContainerDriver) – ContainerDriver instance.extra (
dict) – (optional) Extra attributes (driver specific).
- class libcloud.container.base.ContainerImage(id, name, path, version, driver, extra=None)[source]
Container Image.
- Parameters:
id (
str) – Container Image id.name (
str) – The name of the image.path (
str) – The path to the imageversion (
str) – The version of the imagedriver (
ContainerDriver) – ContainerDriver instance.extra (
dict) – (optional) Extra attributes (driver specific).
- class libcloud.container.base.ContainerCluster(id, name, driver, extra=None)[source]
A cluster group for containers
- Parameters:
id (
str) – Container Image id.name (
str) – The name of the image.driver (
ContainerDriver) – ContainerDriver instance.extra (
dict) – (optional) Extra attributes (driver specific).
- class libcloud.container.base.ClusterLocation(id, name, country, driver)[source]
A physical location where clusters can be.
>>> from libcloud.container.drivers.dummy import DummyContainerDriver >>> driver = DummyContainerDriver(0) >>> location = driver.list_locations()[0] >>> location.country 'US'
- Parameters:
id (
str) – Location ID.name (
str) – Location name.country (
str) – Location country.driver (
ContainerDriver) – Driver this location belongs to.