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

RestartContainerAction.run()   A

Complexity

Conditions 2

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 2
dl 0
loc 13
rs 9.4285
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
        self._get_driver_for_credentials(credentials=credentials)
13
        container = self.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('Successfully restarted container "%s"' % (container))
20
        else:
21
            self.logger.error('Failed to restarted container "%s"' % (container))
22
23
        return status
24