Completed
Pull Request — master (#415)
by Anthony
13:50
created

WaitForCAASServerOperationAction   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 15
Duplicated Lines 0 %
Metric Value
dl 0
loc 15
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 8 3
A getNode() 0 4 1
1
from lib import actions
2
from time import sleep
3
4
__all__ = [
5
    'WaitForCAASServerOperationAction',
6
]
7
8
9
class WaitForCAASServerOperationAction(actions.BaseAction):
10
11
    def run(self, region, id):
0 ignored issues
show
Bug Best Practice introduced by
This seems to re-define the built-in id.

It is generally discouraged to redefine built-ins as this makes code very hard to read.

Loading history...
12
        node = self.getNode(region, id)
13
        if node is not None:
14
            while(node.extra['status'].action == 'None'):
0 ignored issues
show
Unused Code Coding Style introduced by
There is an unnecessary parenthesis after while.
Loading history...
15
                sleep(5)
16
                node = self.getNode(region, id)
17
        else:
18
            raise "VM with the name doesn't exist"
19
20
    def getNode(self, region, id):
0 ignored issues
show
Bug Best Practice introduced by
This seems to re-define the built-in id.

It is generally discouraged to redefine built-ins as this makes code very hard to read.

Loading history...
21
        driver = self._get_compute_driver(region)
22
        node = driver.ex_get_node_by_id(id)
23
        return node
24