Completed
Pull Request — master (#415)
by Anthony
02:06
created

WaitForCAASServerOperationAction.run()   A

Complexity

Conditions 3

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 3
dl 0
loc 8
rs 9.4285
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