libcloud.container.drivers.ecs module
- class libcloud.container.drivers.ecs.ElasticContainerDriver(access_id, secret, region)[source]
Bases:
ContainerDriver- 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
ECSJsonConnection
- create_cluster(name, location=None)[source]
Create a container cluster
- Parameters:
name (
str) – The name of the clusterlocation (
libcloud.container.base.ClusterLocation) – The location to create the cluster in
- Return type:
- deploy_container(name, image, cluster=None, parameters=None, start=True, ex_cpu=10, ex_memory=500, ex_container_port=None, ex_host_port=None)[source]
Creates a task definition from a container image that can be run in a cluster.
- Parameters:
name (
str) – The name of the new containerimage (
libcloud.container.base.ContainerImage) – The container image to deploycluster (
libcloud.container.base.ContainerCluster) – The cluster to deploy to, None is defaultparameters (
str) – Container Image parametersstart (
bool) – Start the container on deployment
- Return type:
- destroy_cluster(cluster)[source]
Delete a cluster
- Returns:
Trueif the destroy was successful, otherwiseFalse.- Return type:
bool
- destroy_container(container)[source]
Destroy a deployed container
- Parameters:
container (
libcloud.container.base.Container) – The container to destroy- Return type:
- ecrConnectionClass
alias of
ECRJsonConnection
- ecr_repository_host = '%s.dkr.ecr.%s.amazonaws.com'
- ex_create_service(name, cluster, task_definition, desired_count=1)[source]
Runs and maintains a desired number of tasks from a specified task definition. If the number of tasks running in a service drops below desired_count, Amazon ECS spawns another instantiation of the task in the specified cluster.
- Parameters:
name (
str) – the name of the servicecluster (
libcloud.container.base.ContainerCluster) – The cluster to run the service ontask_definition (
str) – The task definition name or ARN for the servicedesired_count (
int) – The desired number of tasks to be running at any one time
- Return type:
objectThe service object
- ex_describe_service(service_arn)[source]
Get the details of a service
- Parameters:
cluster (
libcloud.container.base.ContainerCluster) – The hosting clusterservice_arn (
str) – The service ARN to describe
- Returns:
The service object
- Return type:
object
- ex_destroy_service(service_arn)[source]
Deletes a service
- Parameters:
cluster (
libcloud.container.base.ContainerCluster) – The target clusterservice_arn (
str) – The service ARN to destroy
- ex_get_registry_client(repository_name)[source]
Get a client for an ECR repository
- Parameters:
repository_name (
str) – The unique name of the repository- Returns:
a docker registry API client
- Return type:
- ex_get_repository_id(repository_name)[source]
Get the ID of a repository
- Parameters:
repository_name (
str) – The unique name of the repository- Returns:
The repository ID
- Return type:
str
- ex_get_repository_token(repository_id)[source]
Get the authorization token (12 hour expiry) for a repository
- Parameters:
repository_id (
str) – The ID of the repository- Returns:
A token for login
- Return type:
str
- ex_list_containers_for_task(task_arns)[source]
Get a list of containers by ID collection (ARN)
- Parameters:
task_arns (
listofstr) – The list of ARNs- Return type:
- ex_list_service_arns(cluster=None)[source]
List the services
- Parameters:
cluster (
libcloud.container.base.ContainerCluster) – The cluster hosting the services- Return type:
listofstr
- ex_start_task(task_arn, count=1)[source]
Run a task definition and get the containers
- Parameters:
task_arn (
str) – The task ARN to Runcount (
int) – The number of containers to start
- Return type:
- get_container(id)[source]
Get a container by ID
- Parameters:
id (
str) – The ID of the container to get- Return type:
- list_clusters()[source]
Get a list of potential locations to deploy clusters into
- Parameters:
location (
libcloud.container.base.ClusterLocation) – The location to search in- Return type:
- list_containers(image=None, cluster=None)[source]
List the deployed container images
- Parameters:
image (
libcloud.container.base.ContainerImage) – Filter to containers with a certain imagecluster (
libcloud.container.base.ContainerCluster) – Filter to containers in a cluster
- Return type:
- list_images(ex_repository_name)[source]
List the images in an ECR repository
- Parameters:
ex_repository_name (
str) – The name of the repository to check defaults to the default repository.- Returns:
a list of images
- Return type:
- name = 'Amazon Elastic Container Service'
- restart_container(container)[source]
Restart a deployed container
- Parameters:
container (
libcloud.container.base.Container) – The container to restart- Return type:
- start_container(container, count=1)[source]
Start a deployed task
- Parameters:
container (
libcloud.container.base.Container) – The container to startcount (
int) – Number of containers to start
- Return type:
- status_map = {'RUNNING': 'running'}
- stop_container(container)[source]
Stop a deployed container
- Parameters:
container (
libcloud.container.base.Container) – The container to stop- Return type:
- supports_clusters = False
Whether the driver supports containers being deployed into clusters
- website = 'https://aws.amazon.com/ecs/details/'