Completed
Push — master ( 10442d...b7796a )
by Edward
09:39 queued 06:47
created

RestartClusterAction   A

Complexity

Total Complexity 3

Size/Duplication

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 17 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