| Total Complexity | 3 |
| Total Lines | 16 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | # Licensed to the StackStorm, Inc ('StackStorm') under one or more |
||
| 21 | class VMRemove(BaseAction): |
||
| 22 | |||
| 23 | def run(self, vm, delete_permanently): |
||
| 24 | si = self.si |
||
| 25 | |||
| 26 | vm = vim.VirtualMachine(vm, stub=si._stub) |
||
| 27 | if vm.runtime.powerState == vim.VirtualMachine.PowerState.poweredOn: |
||
| 28 | raise Exception("VM Currently Powered On") |
||
| 29 | if delete_permanently: |
||
| 30 | task = vm.Destroy_Task() |
||
| 31 | success = self._wait_for_task(task) |
||
| 32 | else: |
||
| 33 | vm.UnregisterVM() |
||
| 34 | success = True |
||
| 35 | |||
| 36 | return {"success": success} |
||
| 37 |