| Total Complexity | 3 |
| Total Lines | 19 |
| Duplicated Lines | 0 % |
| 1 | from pyVmomi import vim |
||
| 8 | class VMCPUMemFlex(BaseAction): |
||
| 9 | |||
| 10 | def run(self, vm_id, vm_name, cpu_flex, mem_flex): |
||
| 11 | # check a means of finding the VM has been provided |
||
| 12 | checkinputs.vm_identifier(vm_id, vm_name) |
||
| 13 | |||
| 14 | vm = inventory.get_virtualmachine(self.si_content, |
||
| 15 | moid=vm_id, |
||
| 16 | name=vm_name) |
||
| 17 | spec = vim.vm.ConfigSpec() |
||
| 18 | if cpu_flex: |
||
| 19 | spec.numCPUs = cpu_flex |
||
| 20 | if mem_flex: |
||
| 21 | spec.memoryMB = mem_flex * 1024 |
||
| 22 | |||
| 23 | task = vm.ReconfigVM_Task(spec) |
||
| 24 | self._wait_for_task(task) |
||
| 25 | |||
| 26 | return {'state': str(task.info.state)} |
||
| 27 |