Completed
Pull Request — master (#460)
by Manas
02:06
created

StopVM   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %
Metric Value
wmc 2
dl 0
loc 12
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 10 2
1
from vmwarelib import inventory
2
from vmwarelib.actions import BaseAction
3
4
5
class StopVM(BaseAction):
6
7
    def run(self, vm, kill=False):
8
        # convert ids to stubs
9
        vm_obj = inventory.get_virtualmachine(self.si_content, moid=vm)
10
        if kill:
11
            vm_obj.TerminateVM()
12
            success = True
13
        else:
14
            task = vm_obj.PowerOffVM_Task()
15
            success = self._wait_for_task(task)
16
        return {'success': success}
17