| Total Complexity | 3 |
| Total Lines | 14 |
| Duplicated Lines | 0 % |
| 1 | import requests |
||
| 7 | class SetNodeConfAction(OpscenterAction): |
||
| 8 | |||
| 9 | def run(self, node_ip, node_conf, cluster_id=None): |
||
| 10 | if not cluster_id: |
||
| 11 | cluster_id = self.cluster_id |
||
| 12 | |||
| 13 | try: |
||
| 14 | yaml.safe_load(node_conf) # If this throws, fail the action. |
||
| 15 | except: |
||
| 16 | self.logger.error('Configuration is not valid YAML.') |
||
| 17 | raise |
||
| 18 | url = self._get_full_url([cluster_id, 'nodeconf', node_ip]) |
||
| 19 | |||
| 20 | return requests.post(url, data=node_conf).json() |
||
| 21 |