Completed
Pull Request — master (#543)
by
unknown
02:30
created

RestartClusterAction   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 3
1
import json
2
3
import requests
4
5
from lib.base import OpscenterAction
6
7
8
class RestartClusterAction(OpscenterAction):
9
    def run(self, cluster_id=None, drain_first=True, sleep_interval=60,
10
            ips=None):
11
12
        if not cluster_id:
13
            cluster_id = self.cluster_id
14
15
        url = self._get_full_url([cluster_id, 'ops', 'restart'])
16
17
        payload = {
18
            'drain_first': drain_first,
19
            'sleep': sleep_interval,
20
        }
21
22
        if ips:
23
            payload['ips'] = ips
24
25
        return requests.post(url, data=json.dumps(payload)).json()
26