Completed
Pull Request — master (#460)
by Manas
02:32
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 import inventory
4
from vmwarelib.actions import BaseAction
5
6
7
class RemoveVM(BaseAction):
8
9
    def run(self, vm, delete_permanently):
10
        si = self.si
11
12
        vm_obj = vim.VirtualMachine(vm, stub=si._stub)
13
        if delete_permanently:
14
            task = vm_obj.Destroy_Task()
15
            success = self._wait_for_task(task)
16
        else:
17
            vm_obj.UnregisterVM()
18
            success = True
19
20
        return {"success": success}
21