Completed
Pull Request — master (#364)
by Anthony
02:17
created

DeployContainerAction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %
Metric Value
dl 0
loc 16
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 13 2
1
from libcloud.container.utils.docker import HubClient
2
3
from lib.actions import BaseAction
4
5
__all__ = [
6
    'DeployContainerAction'
7
]
8
9
10
class DeployContainerAction(BaseAction):
11
    api_type = 'container'
12
13
    def run(self, credentials, name, repository_name, tag,
14
            start, cluster_id=None, parameters=None):
15
        driver = self._get_driver_for_credentials(credentials=credentials)
16
        hub_client = HubClient()
17
        image = hub_client.get_image(repository_name, tag)
18
        if cluster_id is not None:
19
            cluster = driver.get_cluster(cluster_id)
20
        else:
21
            cluster = None
22
        record = driver.deploy_container(name=name, image=image,
23
                                         start=start, cluster=cluster,
24
                                         parameters=parameters)
25
        return self.resultsets.formatter(record)
26