libcloud.container.drivers package¶
Submodules¶
libcloud.container.drivers.docker module¶
-
class
libcloud.container.drivers.docker.
DockerConnection
(user_id, key, secure=True, host=None, port=None, url=None, timeout=None, proxy_url=None, backoff=None, retry_delay=None)[source]¶ Bases:
libcloud.common.base.ConnectionUserAndKey
-
add_default_headers
(headers)[source]¶ Add parameters that are necessary for every request If user and password are specified, include a base http auth header
-
responseCls
¶ alias of
DockerResponse
-
timeout
= 60¶
-
-
class
libcloud.container.drivers.docker.
DockerContainerDriver
(key='', secret='', secure=False, host='localhost', port=4243, key_file=None, cert_file=None)[source]¶ Bases:
libcloud.container.base.ContainerDriver
Docker container driver class.
>>> from libcloud.container.providers import get_driver >>> driver = get_driver('docker') >>> conn = driver(host='198.61.239.128', port=4243) >>> conn.list_containers() or connecting to http basic auth protected https host: >>> conn = driver('user', 'pass', host='https://198.61.239.128', port=443)
connect with tls authentication, by providing a hostname, port, a private key file (.pem) and certificate (.pem) file >>> conn = driver(host=’https://198.61.239.128’, >>> port=4243, key_file=’key.pem’, cert_file=’cert.pem’)
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. - key_file (
str
) – Path to private key for TLS connection (optional) - cert_file (
str
) – Path to public key for TLS connection (optional)
Returns: None
-
connectionCls
¶ alias of
DockerConnection
-
deploy_container
(name, image, parameters=None, start=True, command=None, hostname=None, user='', stdin_open=True, tty=True, mem_limit=0, ports=None, environment=None, dns=None, volumes=None, volumes_from=None, network_disabled=False, entrypoint=None, cpu_shares=None, working_dir='', domainname=None, memswap_limit=0, port_bindings=None, network_mode='bridge', labels=None)[source]¶ Deploy an installed container image
For details on the additional parameters see : http://bit.ly/1PjMVKV
Parameters: - name (
str
) – The name of the new container - image (
libcloud.container.base.ContainerImage
) – The container image to deploy - parameters (
str
) – Container Image parameters - start (
bool
) – Start the container on deployment
Return type: Container
- name (
-
destroy_container
(container)[source]¶ Remove a container
Parameters: container ( libcloud.container.base.Container
) – The container to be destroyedReturns: True if the destroy was successful, False otherwise. Return type: bool
-
ex_delete_image
(image)[source]¶ Remove image from the filesystem
Parameters: image ( libcloud.container.base.ContainerImage
) – The image to removeReturn type: bool
-
ex_get_logs
(container, stream=False)[source]¶ Get container logs
If stream == True, logs will be yielded as a stream From Api Version 1.11 and above we need a GET request to get the logs Logs are in different format of those of Version 1.10 and below
Parameters: - container (
libcloud.container.base.Container
) – The container to list logs for - stream (
bool
) – Stream the output
Return type: bool
- container (
-
ex_list_processes
(container)[source]¶ List processes running inside a container
Parameters: container ( libcloud.container.base.Container
) – The container to list processes for.Return type: str
-
ex_rename_container
(container, name)[source]¶ Rename a container
Parameters: - container (
libcloud.container.base.Container
) – The container to be renamed - name (
str
) – The new name
Return type: - container (
-
ex_search_images
(term)[source]¶ Search for an image on Docker.io. Returns a list of ContainerImage objects
>>> images = conn.ex_search_images(term='mistio') >>> images [<ContainerImage: id=rolikeusch/docker-mistio...>, <ContainerImage: id=mist/mistio, name=mist/mistio, driver=Docker ...>]
param term: The search term type term: str
rtype: list
oflibcloud.container.base.ContainerImage
-
get_container
(id)[source]¶ Get a container by ID
Parameters: id ( str
) – The ID of the container to getReturn type: libcloud.container.base.Container
-
install_image
(path)[source]¶ Install a container image from a remote path.
Parameters: path ( str
) – Path to the container imageReturn type: libcloud.container.base.ContainerImage
-
list_containers
(image=None, all=True)[source]¶ List the deployed container images
Parameters: - image (
libcloud.container.base.ContainerImage
) – Filter to containers with a certain image - all (
bool
) – Show all container (including stopped ones)
Return type: - image (
-
list_images
()[source]¶ List the installed container images
Return type: list
oflibcloud.container.base.ContainerImage
-
name
= 'Docker'¶
-
restart_container
(container)[source]¶ Restart a container
Parameters: container ( libcloud.container.base.Container
) – The container to be stoppedReturns: The container refreshed with current data Return type: libcloud.container.base.Container
-
start_container
(container)[source]¶ Start a container
Parameters: container ( libcloud.container.base.Container
) – The container to be startedReturns: The container refreshed with current data Return type: libcloud.container.base.Container
-
stop_container
(container)[source]¶ Stop a container
Parameters: container ( libcloud.container.base.Container
) – The container to be stoppedReturns: The container refreshed with current data Return type: libcloud.container.base.Container
-
supports_clusters
= False¶
-
type
= 'docker'¶
-
version
= '1.24'¶
-
website
= 'http://docker.io'¶
- key (
-
exception
libcloud.container.drivers.docker.
DockerException
(code, message)[source]¶ Bases:
exceptions.Exception
-
class
libcloud.container.drivers.docker.
DockerResponse
(response, connection)[source]¶ Bases:
libcloud.common.base.JsonResponse
Parameters: - response (
httplib.HTTPResponse
) – HTTP response object. (optional) - connection (
Connection
) – Parent connection object.
-
parse_body
()[source]¶ Parse response body.
Override in a provider’s subclass.
Returns: Parsed body. Return type: str
-
parse_error
()[source]¶ Parse the error messages.
Override in a provider’s subclass.
Returns: Parsed error. Return type: str
-
success
()[source]¶ Determine if our request was successful.
The meaning of this can be arbitrary; did we receive OK status? Did the node get created? Were we authenticated?
Return type: bool
Returns: True
orFalse
-
valid_response_codes
= [200, 202, 201, 204]¶
- response (
-
class
libcloud.container.drivers.docker.
DockertlsConnection
(key, secret, secure=True, host='localhost', port=4243, key_file='', cert_file='', **kwargs)[source]¶ Bases:
libcloud.common.base.KeyCertificateConnection
-
add_default_headers
(headers)[source]¶ Adds default headers (such as Authorization, X-Foo-Bar) to the passed headers
Should return a dictionary.
-
responseCls
¶ alias of
DockerResponse
-
libcloud.container.drivers.dummy module¶
-
class
libcloud.container.drivers.dummy.
DummyContainerDriver
(api_key, api_secret)[source]¶ Bases:
libcloud.container.base.ContainerDriver
Dummy Container driver.
>>> from libcloud.container.drivers.dummy import DummyContainerDriver >>> driver = DummyContainerDriver('key', 'secret') >>> driver.name 'Dummy Container Provider'
Parameters: - api_key (
str
) – API key or username to used (required) - api_secret (
str
) – Secret password to be used (required)
Return type: None
-
name
= 'Dummy Container Provider'¶
-
supports_clusters
= False¶
-
website
= 'http://example.com'¶
- api_key (
libcloud.container.drivers.ecs module¶
-
class
libcloud.container.drivers.ecs.
ElasticContainerDriver
(access_id, secret, region)[source]¶ Bases:
libcloud.container.base.ContainerDriver
-
connectionCls
¶ alias of
ECSJsonConnection
-
create_cluster
(name, location=None)[source]¶ Create a container cluster
Parameters: - name (
str
) – The name of the cluster - location (
libcloud.container.base.ClusterLocation
) – The location to create the cluster in
Return type: - name (
-
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 container - image (
libcloud.container.base.ContainerImage
) – The container image to deploy - cluster (
libcloud.container.base.ContainerCluster
) – The cluster to deploy to, None is default - parameters (
str
) – Container Image parameters - start (
bool
) – Start the container on deployment
Return type: - name (
-
destroy_cluster
(cluster)[source]¶ Delete a cluster
Returns: True
if 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 destroyReturn type: libcloud.container.base.Container
-
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 service - cluster (
libcloud.container.base.ContainerCluster
) – The cluster to run the service on - task_definition (
str
) – The task definition name or ARN for the service - desired_count (
int
) – The desired number of tasks to be running at any one time
Return type: object
The service object- name (
-
ex_describe_service
(service_arn)[source]¶ Get the details of a service
Parameters: - cluster (
libcloud.container.base.ContainerCluster
) – The hosting cluster - service_arn (
str
) – The service ARN to describe
Returns: The service object
Return type: object
- cluster (
-
ex_destroy_service
(service_arn)[source]¶ Deletes a service
Parameters: - cluster (
libcloud.container.base.ContainerCluster
) – The target cluster - service_arn (
str
) – The service ARN to destroy
- cluster (
-
ex_get_registry_client
(repository_name)[source]¶ Get a client for an ECR repository
Parameters: repository_name ( str
) – The unique name of the repositoryReturns: a docker registry API client Return type: libcloud.container.utils.docker.RegistryClient
-
ex_get_repository_id
(repository_name)[source]¶ Get the ID of a repository
Parameters: repository_name ( str
) – The unique name of the repositoryReturns: 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 repositoryReturns: 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 ( list
ofstr
) – The list of ARNsReturn type: list
oflibcloud.container.base.Container
-
ex_list_service_arns
(cluster=None)[source]¶ List the services
Parameters: cluster ( libcloud.container.base.ContainerCluster
) – The cluster hosting the servicesReturn type: list
ofstr
-
ex_start_task
(task_arn, count=1)[source]¶ Run a task definition and get the containers
Parameters: - task_arn (
str
) – The task ARN to Run - count (
int
) – The number of containers to start
Return type: - task_arn (
-
get_container
(id)[source]¶ Get a container by ID
Parameters: id ( str
) – The ID of the container to getReturn type: libcloud.container.base.Container
-
list_clusters
()[source]¶ Get a list of potential locations to deploy clusters into
Parameters: location ( libcloud.container.base.ClusterLocation
) – The location to search inReturn type: list
oflibcloud.container.base.ContainerCluster
-
list_containers
(image=None, cluster=None)[source]¶ List the deployed container images
Parameters: - image (
libcloud.container.base.ContainerImage
) – Filter to containers with a certain image - cluster (
libcloud.container.base.ContainerCluster
) – Filter to containers in a cluster
Return type: - image (
-
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: list
oflibcloud.container.base.ContainerImage
-
name
= 'Amazon Elastic Container Service'¶
-
restart_container
(container)[source]¶ Restart a deployed container
Parameters: container ( libcloud.container.base.Container
) – The container to restartReturn type: libcloud.container.base.Container
-
start_container
(container, count=1)[source]¶ Start a deployed task
Parameters: - container (
libcloud.container.base.Container
) – The container to start - count (
int
) – Number of containers to start
Return type: - container (
-
status_map
= {'RUNNING': 'running'}¶
-
stop_container
(container)[source]¶ Stop a deployed container
Parameters: container ( libcloud.container.base.Container
) – The container to stopReturn type: libcloud.container.base.Container
-
supports_clusters
= False¶
-
website
= 'https://aws.amazon.com/ecs/details/'¶
-
libcloud.container.drivers.gke module¶
-
class
libcloud.container.drivers.gke.
GKEConnection
(user_id, key, secure, auth_type=None, credential_file=None, project=None, **kwargs)[source]¶ Bases:
libcloud.common.google.GoogleBaseConnection
Connection class for the GKE driver.
- GKEConnection extends
google.GoogleBaseConnection
for 3 reasons: - modify request_path for GKE URI.
- Implement gce_params functionality described below.
- Add request_aggregated_items method for making aggregated API calls.
-
host
= 'container.googleapis.com'¶
-
pre_connect_hook
(params, headers)[source]¶ Update URL parameters with values from self.gke_params.
@inherits:
GoogleBaseConnection.pre_connect_hook
-
request
(*args, **kwargs)[source]¶ Perform request then do GKE-specific processing of URL params.
@inherits:
GoogleBaseConnection.request
-
responseCls
¶ alias of
GKEResponse
- GKEConnection extends
-
class
libcloud.container.drivers.gke.
GKEContainerDriver
(user_id, key=None, datacenter=None, project=None, auth_type=None, scopes=None, credential_file=None, host=None, port=443, **kwargs)[source]¶ Bases:
libcloud.container.drivers.kubernetes.KubernetesContainerDriver
GKE Container Driver class.
This is the primary driver for interacting with Google Container Engine. It contains all of the standard libcloud methods, plus additional ex_* methods for more features.
Note that many methods allow either objects or strings (or lists of objects/strings). In most cases, passing strings instead of objects will result in additional GKE API calls.
Parameters: - user_id (
str
) – The email address (for service accounts) or Client ID (for installed apps) to be used for authentication. - key (
str
) – The RSA Key (for service accounts) or file path containing key or Client Secret (for installed apps) to be used for authentication. - datacenter (
str
) – The name of the datacenter (zone) used for operations. - project (
str
) – Your GKE project name. (required) - auth_type (
str
) – Accepted values are “SA” or “IA” or “GKE” (“Service Account” or “Installed Application” or “GKE” if libcloud is being used on a GKE instance with service account enabled). If not supplied, auth_type will be guessed based on value of user_id or if the code is being executed in a GKE instance. - scopes (
list
) – List of authorization URLs. Default is empty and grants read/write to Compute, Storage, DNS. - credential_file (
str
) – Path to file for caching authentication information used by GKEConnection.
-
AUTH_URL
= 'https://container.googleapis.com/auth/'¶
-
api_name
= 'google'¶
-
connectionCls
¶ alias of
GKEConnection
-
get_server_config
(ex_zone=None)[source]¶ Return configuration info about the Container Engine service.
Parameters: ex_zone ( str
orGCEZone
orNodeLocation
orNone
) – Optional zone name or None
-
list_clusters
(ex_zone=None)[source]¶ Return a list of cluster information in the current zone or all zones.
Parameters: ex_zone ( str
orGCEZone
orNodeLocation
orNone
) – Optional zone name or None
-
name
= 'Google Container Engine'¶
-
supports_clusters
= True¶
-
type
= 'GKE'¶
-
website
= 'https://container.googleapis.com'¶
- user_id (
-
class
libcloud.container.drivers.gke.
GKEResponse
(response, connection)[source]¶ Bases:
libcloud.common.google.GoogleResponse
Parameters: - response (
httplib.HTTPResponse
) – HTTP response object. (optional) - connection (
Connection
) – Parent connection object.
- response (
libcloud.container.drivers.joyent module¶
-
class
libcloud.container.drivers.joyent.
JoyentContainerDriver
(key=None, secret=None, secure=False, host='localhost', port=2376, key_file=None, cert_file=None)[source]¶ Bases:
libcloud.container.drivers.docker.DockerContainerDriver
Joyent Triton container driver class.
>>> from libcloud.container.providers import get_driver >>> driver = get_driver('joyent') >>> conn = driver(host='https://us-east-1.docker.joyent.com', port=2376, key_file='key.pem', cert_file='cert.pem')
-
connectionCls
¶
-
name
= 'Joyent Triton'¶
-
supports_clusters
= False¶
-
type
= 'joyent'¶
-
website
= 'http://joyent.com'¶
-
libcloud.container.drivers.kubernetes module¶
-
class
libcloud.container.drivers.kubernetes.
KubernetesConnection
(user_id, key, secure=True, host=None, port=None, url=None, timeout=None, proxy_url=None, backoff=None, retry_delay=None)[source]¶ Bases:
libcloud.common.base.ConnectionUserAndKey
-
add_default_headers
(headers)[source]¶ Add parameters that are necessary for every request If user and password are specified, include a base http auth header
-
responseCls
¶ alias of
KubernetesResponse
-
timeout
= 60¶
-
-
class
libcloud.container.drivers.kubernetes.
KubernetesContainerDriver
(key=None, secret=None, secure=False, host='localhost', port=4243)[source]¶ Bases:
libcloud.container.base.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
KubernetesConnection
-
create_cluster
(name, location=None)[source]¶ Create a container cluster (a namespace)
Parameters: - name (
str
) – The name of the cluster - location (
ClusterLocation
) – The location to create the cluster in
Return type: ContainerCluster
- name (
-
deploy_container
(name, image, cluster=None, parameters=None, start=True)[source]¶ Deploy an installed container image. In kubernetes this deploys a single container Pod. https://cloud.google.com/container-engine/docs/pods/single-container
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
- name (
-
destroy_cluster
(cluster)[source]¶ Delete a cluster (namespace)
Returns: True
if the destroy was successful, otherwiseFalse
.Return type: bool
-
destroy_container
(container)[source]¶ Destroy a deployed container. Because the containers are single container pods, this will delete the pod.
Parameters: container ( Container
) – The container to destroyReturn type: bool
-
ex_list_pods
()[source]¶ List available Pods
Return type: list
ofKubernetesPod
-
get_cluster
(id)[source]¶ Get a cluster by ID
Parameters: id ( str
) – The ID of the cluster to getReturn type: libcloud.container.base.ContainerCluster
-
get_container
(id)[source]¶ Get a container by ID
Parameters: id ( str
) – The ID of the container to getReturn type: libcloud.container.base.Container
-
list_clusters
()[source]¶ Get a list of namespaces that pods can be deployed into
Parameters: location ( libcloud.container.base.ClusterLocation
) – The location to search inReturn type: list
oflibcloud.container.base.ContainerCluster
-
list_containers
(image=None, all=True)[source]¶ List the deployed container images
Parameters: - image (
libcloud.container.base.ContainerImage
) – Filter to containers with a certain image - all (
bool
) – Show all container (including stopped ones)
Return type: - image (
-
name
= 'Kubernetes'¶
-
supports_clusters
= True¶
-
type
= 'kubernetes'¶
-
website
= 'http://kubernetes.io'¶
- key (
-
exception
libcloud.container.drivers.kubernetes.
KubernetesException
(code, message)[source]¶ Bases:
exceptions.Exception
-
class
libcloud.container.drivers.kubernetes.
KubernetesPod
(name, containers, namespace)[source]¶ Bases:
object
A Kubernetes pod
-
class
libcloud.container.drivers.kubernetes.
KubernetesResponse
(response, connection)[source]¶ Bases:
libcloud.common.base.JsonResponse
Parameters: - response (
httplib.HTTPResponse
) – HTTP response object. (optional) - connection (
Connection
) – Parent connection object.
-
parse_error
()[source]¶ Parse the error messages.
Override in a provider’s subclass.
Returns: Parsed error. Return type: str
-
success
()[source]¶ Determine if our request was successful.
The meaning of this can be arbitrary; did we receive OK status? Did the node get created? Were we authenticated?
Return type: bool
Returns: True
orFalse
-
valid_response_codes
= [200, 202, 201, 204]¶
- response (
libcloud.container.drivers.rancher module¶
-
class
libcloud.container.drivers.rancher.
RancherConnection
(user_id, key, secure=True, host=None, port=None, url=None, timeout=None, proxy_url=None, backoff=None, retry_delay=None)[source]¶ Bases:
libcloud.common.base.ConnectionUserAndKey
-
add_default_headers
(headers)[source]¶ Add parameters that are necessary for every request If user and password are specified, include a base http auth header
-
responseCls
¶ alias of
RancherResponse
-
timeout
= 30¶
-
-
class
libcloud.container.drivers.rancher.
RancherContainerDriver
(key, secret, secure=True, host='localhost', port=443)[source]¶ Bases:
libcloud.container.base.ContainerDriver
Driver for Rancher by Rancher Labs.
This driver is capable of interacting with the Version 1 API of Rancher. It currently does NOT support the Version 2 API.
Example:
>>> from libcloud.container.providers import get_driver >>> from libcloud.container.types import Provider
>>> driver = get_driver(Provider.RANCHER) >>> connection = driver(key="ACCESS_KEY_HERE", secret="SECRET_KEY_HERE", host="172.30.0.100", port=8080)
>>> image = ContainerImage("hastebin", "hastebin", "rlister/hastebin", "latest", driver=None) >>> newcontainer = connection.deploy_container("myawesomepastebin", image, environment={"STORAGE_TYPE": "file"})
Variables: baseuri – The URL base path to the API. Creates a new Rancher Container 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. - host (
str
) – Override hostname used for connections. This can also be a full URL string, including scheme, port, and base path. - port (
int
) – Override port used for connections.
Returns: A newly initialized driver instance.
-
connectionCls
¶ alias of
RancherConnection
-
deploy_container
(name, image, parameters=None, start=True, **config)[source]¶ Deploy a new container.
http://docs.rancher.com/rancher/v1.2/en/api/api-resources/container/#create
The following is the Image format used for ``ContainerImage``
For a ``imageuuid``:
docker:<hostname>:<port>/<namespace>/<imagename>:<version>
The following applies:
id
=<imagename>
name
=<imagename>
path
=<hostname>:<port>/<namespace>/<imagename>
version
=<version>
Any extra configuration can also be passed i.e. “environment”
Parameters: - name (
str
) – The desired name of the container. (required) - image (
libcloud.container.base.ContainerImage
) – The Image object to deploy. (required) - parameters (
str
) – Container Image parameters (unused) - start (
bool
) – Whether to start the container on creation(startOnCreate)
Return type: Container
-
destroy_container
(container)[source]¶ Remove a container
Parameters: container ( libcloud.container.base.Container
) – The container to be destroyedReturns: True if the destroy was successful, False otherwise. Return type: bool
-
ex_activate_service
(service_id)[source]¶ Activate a service.
http://docs.rancher.com/rancher/v1.2/en/api/api-resources/service/#activate
Parameters: service_id ( str
) – The service to activate services for.Returns: True if activate was successful, False otherwise. Return type: bool
-
ex_activate_stack
(env_id)[source]¶ Activate Services for a stack.
http://docs.rancher.com/rancher/v1.2/en/api/api-resources/environment/#activateservices
Parameters: env_id ( str
) – The stack to activate services for.Returns: True if activate was successful, False otherwise. Return type: bool
-
ex_deactivate_service
(service_id)[source]¶ Deactivate a service.
http://docs.rancher.com/rancher/v1.2/en/api/api-resources/service/#deactivate
Parameters: service_id ( str
) – The service to deactivate services for.Returns: True if deactivate was successful, False otherwise. Return type: bool
-
ex_deactivate_stack
(env_id)[source]¶ Deactivate Services for a stack.
http://docs.rancher.com/rancher/v1.2/en/api/api-resources/environment/#deactivateservices
Parameters: env_id ( str
) – The stack to deactivate services for.Returns: True if deactivate was successful, False otherwise. Return type: bool
-
ex_deploy_service
(name, image, environment_id, start=True, assign_service_ip_address=None, service_description=None, external_id=None, metadata=None, retain_ip=None, scale=None, scale_policy=None, secondary_launch_configs=None, selector_container=None, selector_link=None, vip=None, **launch_conf)[source]¶ Deploy a Rancher Service under a stack.
http://docs.rancher.com/rancher/v1.2/en/api/api-resources/service/#create
Any further configuration passed applies to the ``launchConfig``
Parameters: - name (
str
) – The desired name of the service. (required) - image (
libcloud.container.base.ContainerImage
) – The Image object to deploy. (required) - environment_id (
str
) – The stack ID this service is tied to. (required) - start (
bool
) – Whether to start the service on creation. - assign_service_ip_address (
bool
) – The IP address to assign the service. - service_description (
str
) – The service description. - external_id (
str
) – The externalId for this service. - metadata (
dict
) – K/V Metadata for this service. - retain_ip (
bool
) – Whether this service should retain its IP. - scale (
int
) – The scale of containers in this service. - scale_policy (
dict
) – The scaling policy for this service. - secondary_launch_configs (
list
) – Secondary container launch configs. - selector_container (
str
) – The selectorContainer for this service. - selector_link (
type
) – The selectorLink for this service. - vip (
str
) – The VIP to assign to this service.
Returns: The newly created service.
Return type: dict
- name (
-
ex_deploy_stack
(name, description=None, docker_compose=None, environment=None, external_id=None, rancher_compose=None, start=True)[source]¶ Deploy a new stack.
http://docs.rancher.com/rancher/v1.2/en/api/api-resources/environment/#create
Parameters: - name (
str
) – The desired name of the stack. (required) - description (
str
) – A desired description for the stack. - docker_compose (
str
) – The Docker Compose configuration to use. - environment (
dict
) – Environment K/V specific to this stack. - external_id (
str
) – The externalId of the stack. - rancher_compose (
str
) – The Rancher Compose configuration for this env. - start (
bool
) – Whether to start this stack on creation.
Returns: The newly created stack.
Return type: dict
- name (
-
ex_destroy_service
(service_id)[source]¶ Destroy a service by ID
http://docs.rancher.com/rancher/v1.2/en/api/api-resources/service/#delete
Parameters: service_id ( str
) – The service to be destroyed.Returns: True if destroy was successful, False otherwise. Return type: bool
-
ex_destroy_stack
(env_id)[source]¶ Destroy a stack by ID
http://docs.rancher.com/rancher/v1.2/en/api/api-resources/environment/#delete
Parameters: env_id ( str
) – The stack to be destroyed.Returns: True if destroy was successful, False otherwise. Return type: bool
-
ex_get_service
(service_id)[source]¶ Get a service by ID
Parameters: service_id ( str
) – The service_id to be obtained.Return type: dict
-
ex_get_stack
(env_id)[source]¶ Get a stack by ID
Parameters: env_id ( str
) – The stack to be obtained.Return type: dict
-
ex_list_services
()[source]¶ List all Rancher Services
http://docs.rancher.com/rancher/v1.2/en/api/api-resources/service/
Return type: list
ofdict
-
ex_list_stacks
()[source]¶ List all Rancher Stacks
http://docs.rancher.com/rancher/v1.2/en/api/api-resources/environment/
Return type: list
ofdict
-
ex_search_containers
(search_params)[source]¶ Search for containers matching certain filters
i.e.
{ "imageUuid": "docker:mysql", "state": "running"}
Parameters: search_params ( dict
) – A collection of search parameters to use.Return type: list
-
ex_search_services
(search_params)[source]¶ Search for services matching certain filters
i.e.
{ "name": "awesomesause", "environmentId": "1e2"}
Parameters: search_params ( dict
) – A collection of search parameters to use.Return type: list
-
ex_search_stacks
(search_params)[source]¶ Search for stacks matching certain filters
i.e.
{ "name": "awesomestack"}
Parameters: search_params ( dict
) – A collection of search parameters to use.Return type: list
-
get_container
(con_id)[source]¶ Get a container by ID
Parameters: con_id ( str
) – The ID of the container to getReturn type: libcloud.container.base.Container
-
list_containers
()[source]¶ List the deployed containers.
http://docs.rancher.com/rancher/v1.2/en/api/api-resources/container/
Return type: list
oflibcloud.container.base.Container
-
name
= 'Rancher'¶
-
start_container
(container)[source]¶ Start a container
Parameters: container ( libcloud.container.base.Container
) – The container to be startedReturns: The container refreshed with current data Return type: libcloud.container.base.Container
-
stop_container
(container)[source]¶ Stop a container
Parameters: container ( libcloud.container.base.Container
) – The container to be stoppedReturns: The container refreshed with current data Return type: libcloud.container.base.Container
-
supports_clusters
= False¶
-
type
= 'rancher'¶
-
version
= '1'¶
-
website
= 'http://rancher.com'¶
- key (
-
exception
libcloud.container.drivers.rancher.
RancherException
(code, message)[source]¶ Bases:
exceptions.Exception
-
class
libcloud.container.drivers.rancher.
RancherResponse
(response, connection)[source]¶ Bases:
libcloud.common.base.JsonResponse
Parameters: - response (
httplib.HTTPResponse
) – HTTP response object. (optional) - connection (
Connection
) – Parent connection object.
- response (