Completed
Pull Request — master (#429)
by Tomaz
03:32
created

SetNodeConfAction   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %
Metric Value
dl 0
loc 14
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 12 3
1
import requests
2
import yaml
3
4
from lib.base import OpscenterAction
5
6
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