Completed
Push — master ( 32acac...19ae40 )
by Lakshmi
11:34
created

RestartContainerAction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 15 2
1
from lib.actions import BaseAction
2
3
__all__ = [
4
    'RestartContainerAction'
5
]
6
7
8
class RestartContainerAction(BaseAction):
9
    api_type = 'container'
10
11
    def run(self, credentials, container_id):
12
        driver = self._get_driver_for_credentials(credentials=credentials)
13
        container = driver.get_container(container_id)
14
15
        self.logger.info('Restarting container: %s' % (container))
16
        status = container.restart()
17
18
        if status is True:
19
            self.logger.info(
20
                'Successfully restarted container "%s"' % (container))
21
        else:
22
            self.logger.error(
23
                'Failed to restarted container "%s"' % (container))
24
25
        return status
26