| Total Complexity | 4 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | """ |
||
| 15 | class NodeActionCommand(Command): |
||
| 16 | """ |
||
| 17 | Requests the controller for a node action |
||
| 18 | |||
| 19 | node_action |
||
| 20 | {uri : The URI of the node} |
||
| 21 | {action : The action: trigger, restart, or restart_failed} |
||
| 22 | """ |
||
| 23 | |||
| 24 | # ------------------------------------------------------------------------------------------------------------------ |
||
| 25 | def handle(self): |
||
| 26 | """ |
||
| 27 | Executes the request node action command. |
||
| 28 | """ |
||
| 29 | self.output = EnarkshStyle(self.input, self.output) |
||
| 30 | |||
| 31 | action = self.input.get_argument('action') |
||
| 32 | if action == 'trigger': |
||
| 33 | act_id = enarksh.ENK_ACT_ID_TRIGGER |
||
| 34 | elif action == 'restart': |
||
| 35 | act_id = enarksh.ENK_ACT_ID_RESTART |
||
| 36 | elif action == 'restart_failed': |
||
| 37 | act_id = enarksh.ENK_ACT_ID_RESTART_FAILED |
||
| 38 | else: |
||
| 39 | raise RuntimeError("Unknown action '{}'".format(action)) |
||
| 40 | |||
| 41 | uri = self.input.get_argument('uri') |
||
| 42 | |||
| 43 | client = NodeActionClient() |
||
| 44 | ret = client.main(uri, act_id) |
||
| 45 | |||
| 46 | return ret |
||
| 47 | |||
| 49 |