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

StopVM.run()   A

Complexity

Conditions 2

Size

Total Lines 10

Duplication

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