Total Complexity | 2 |
Total Lines | 18 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | from lib.actions import BaseAction |
||
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 |