libcloud.container package

Subpackages

Submodules

libcloud.container.base module

class libcloud.container.base.ClusterLocation(id, name, country, driver)[source]

Bases: object

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.

class libcloud.container.base.Container(id, name, image, state, ip_addresses, driver, extra=None, created_at=None)[source]

Bases: object

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. running

  • ip_addresses (list of str) – A list of IP addresses for this container

  • driver (ContainerDriver) – ContainerDriver instance.

  • extra (dict) – (optional) Extra attributes (driver specific).

destroy() bool[source]
restart() Container[source]
start() Container[source]
stop() Container[source]
class libcloud.container.base.ContainerCluster(id, name, driver, extra=None)[source]

Bases: object

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).

destroy() bool[source]
list_containers() List[Container][source]
class libcloud.container.base.ContainerDriver(key, secret=None, secure=True, host=None, port=None, **kwargs)[source]

Bases: BaseDriver

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: Optional[ClusterLocation] = None) ContainerCluster[source]

Create a container cluster

Parameters:
  • name (str) – The name of the cluster

  • location (ClusterLocation) – The location to create the cluster in

Return type:

ContainerCluster

deploy_container(name: str, image: ContainerImage, cluster: Optional[ContainerCluster] = None, parameters: Optional[str] = None, start: bool = True) Container[source]

Deploy an installed container image

Parameters:
  • name (str) – The name of the new container

  • image (ContainerImage) – The container image to deploy

  • cluster (ContainerCluster) – The cluster to deploy to, None is default

  • parameters (str) – Container Image parameters

  • start (bool) – Start the container on deployment

Return type:

Container

destroy_cluster(cluster: ContainerCluster) bool[source]

Delete a cluster

Returns:

True if the destroy was successful, otherwise False.

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:

ContainerCluster

get_container(id: str) Container[source]

Get a container by ID

Parameters:

id (str) – The ID of the container to get

Return type:

Container

install_image(path: str) ContainerImage[source]

Install a container image from a remote path.

Parameters:

path (str) – Path to the container image

Return type:

ContainerImage

list_clusters(location: Optional[ClusterLocation] = None) List[ContainerCluster][source]

Get a list of potential locations to deploy clusters into

Parameters:

location (ClusterLocation) – The location to search in

Return type:

list of ContainerCluster

list_containers(image: Optional[ContainerImage] = None, cluster: Optional[ContainerCluster] = None) List[Container][source]

List the deployed container images

Parameters:
Return type:

list of Container

list_images() List[ContainerImage][source]

List the installed container images

Return type:

list of ContainerImage

list_locations() List[ClusterLocation][source]

Get a list of potential locations to deploy clusters into

Return type:

list of ClusterLocation

name = None
restart_container(container: Container) Container[source]

Restart a deployed container

Parameters:

container (Container) – The container to restart

Return type:

Container

start_container(container: Container) Container[source]

Start a deployed container

Parameters:

container (Container) – The container to start

Return type:

Container

stop_container(container: Container) Container[source]

Stop a deployed container

Parameters:

container (Container) – The container to stop

Return type:

Container

supports_clusters = False

Whether the driver supports containers being deployed into clusters

website = None
class libcloud.container.base.ContainerImage(id, name, path, version, driver, extra=None)[source]

Bases: object

Container Image.

Parameters:
  • id (str) – Container Image id.

  • name (str) – The name of the image.

  • path (str) – The path to the image

  • version (str) – The version of the image

  • driver (ContainerDriver) – ContainerDriver instance.

  • extra (dict) – (optional) Extra attributes (driver specific).

deploy(name: str, parameters: str, cluster: Optional[ContainerCluster] = None, start: bool = True) Container[source]

libcloud.container.providers module

libcloud.container.providers.get_driver(provider: Union[Provider, str]) Type[ContainerDriver][source]
libcloud.container.providers.set_driver(provider: Union[Provider, str], module: ModuleType, klass: type) Type[ContainerDriver][source]

libcloud.container.types module

class libcloud.container.types.ContainerState[source]

Bases: Type

Standard states for a container

Variables:
  • RUNNING – Container is running.

  • REBOOTING – Container is rebooting.

  • TERMINATED – Container is terminated. This container can’t be started later on.

  • STOPPED – Container is stopped. This container can be started later on.

  • PENDING – Container is pending.

  • SUSPENDED – Container is suspended.

  • ERROR – Container is an error state. Usually no operations can be performed on the container once it ends up in the error state.

  • PAUSED – Container is paused.

  • UNKNOWN – Container state is unknown.

ERROR = 'error'
PAUSED = 'paused'
PENDING = 'pending'
REBOOTING = 'rebooting'
RUNNING = 'running'
STOPPED = 'stopped'
SUSPENDED = 'suspended'
TERMINATED = 'terminated'
UNKNOWN = 'unknown'
class libcloud.container.types.Provider[source]

Bases: object

Defines for each of the supported providers

Non-Dummy drivers are sorted in alphabetical order. Please preserve this ordering when adding new drivers.

DOCKER = 'docker'
DUMMY = 'dummy'
ECS = 'ecs'
GKE = 'GKE'
JOYENT = 'joyent'
KUBERNETES = 'kubernetes'
LXD = 'lxd'
RANCHER = 'rancher'

Module contents