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

RemoveVM   A

Complexity

Total Complexity 2

Size/Duplication

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 12 2
1
from pyVmomi import vim
2
3
from vmwarelib.actions import BaseAction
4
5
6
class RemoveVM(BaseAction):
7
8
    def run(self, vm, delete_permanently):
9
        si = self.si
10
11
        vm_obj = vim.VirtualMachine(vm, stub=si._stub)
12
        if delete_permanently:
13
            task = vm_obj.Destroy_Task()
14
            success = self._wait_for_task(task)
15
        else:
16
            vm_obj.UnregisterVM()
17
            success = True
18
19
        return {"success": success}
20