Completed
Pull Request — master (#460)
by Manas
02:06
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 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