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

RestartNodeAction.run()   A

Complexity

Conditions 2

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 2
dl 0
loc 13
rs 9.4285
1
import json
2
3
import requests
4
5
from lib.base import OpscenterAction
6
7
8
class RestartNodeAction(OpscenterAction):
9
    def run(self, node_ip, cluster_id=None, drain_first=True,
10
            wait_for_thrift=True):
11
        if not cluster_id:
12
            cluster_id = self.cluster_id
13
14
        url = self._get_full_url([cluster_id, 'ops', 'restart', node_ip])
15
16
        payload = {
17
            'wait_for_thrift': wait_for_thrift,
18
            'drain_first': drain_first
19
        }
20
21
        return requests.post(url, data=json.dumps(payload)).json()
22