Completed
Pull Request — master (#460)
by Manas
02:10
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 pyVmomi import vim
2
3
from vmwarelib import inventory
4
from vmwarelib.actions import BaseAction
5
6
7
class StopVM(BaseAction):
8
9
    def run(self, vm, kill=False):
10
        # convert ids to stubs
11
        vm_obj = inventory.get_virtualmachine(self.si_content, moid=vm_id)
12
        if kill:
13
            vm_obj.TerminateVM()
14
            success = true
15
        else:
16
            task = vm_obj.PowerOffVM_Task()
17
            success = self._wait_for_task(task)
18
        return {'success': success}
19