| Total Complexity | 3 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | # Licensed to the StackStorm, Inc ('StackStorm') under one or more |
||
| 18 | class NcmExecuteScript(OrionBaseAction): |
||
| 19 | def run(self, platform, node, script): |
||
| 20 | """ |
||
| 21 | Excute an Orion NCM script on a node. |
||
| 22 | |||
| 23 | Args: |
||
| 24 | platform |
||
| 25 | node |
||
| 26 | script |
||
| 27 | |||
| 28 | Returns: |
||
| 29 | Output |
||
| 30 | |||
| 31 | Raises: |
||
| 32 | ValueError: If Node is not in NCM. |
||
| 33 | """ |
||
| 34 | results = {} |
||
| 35 | |||
| 36 | self.connect(platform) |
||
| 37 | |||
| 38 | orion_node = self.get_node(node) |
||
| 39 | |||
| 40 | if not orion_node.npm: |
||
| 41 | raise ValueError("Node not found in NPM {}".format( |
||
| 42 | orion_node.caption)) |
||
| 43 | |||
| 44 | if not orion_node.ncm: |
||
| 45 | raise ValueError("Node not found in NCM {}".format( |
||
| 46 | orion_node.caption)) |
||
| 47 | |||
| 48 | orion_data = self.invoke( |
||
| 49 | "Cirrus.ConfigArchive", |
||
| 50 | "ExecuteScript", |
||
| 51 | [orion_node.ncm_id], |
||
| 52 | "show failover") |
||
| 53 | results['job_id'] = orion_data[0] |
||
| 54 | |||
| 55 | results['transfer'] = self.get_ncm_transfer_results( |
||
| 56 | results['job_id']) |
||
| 57 | |||
| 58 | return results |
||
| 59 |