|
|
@ -1186,8 +1186,9 @@ class VmsModule(BaseModule):
|
|
|
|
def post_present(self, entity_id):
|
|
|
|
def post_present(self, entity_id):
|
|
|
|
# After creation of the VM, attach disks and NICs:
|
|
|
|
# After creation of the VM, attach disks and NICs:
|
|
|
|
entity = self._service.service(entity_id).get()
|
|
|
|
entity = self._service.service(entity_id).get()
|
|
|
|
self.changed = self.__attach_disks(entity)
|
|
|
|
self.__attach_disks(entity)
|
|
|
|
self.changed = self.__attach_nics(entity)
|
|
|
|
self.__attach_nics(entity)
|
|
|
|
|
|
|
|
self._attach_cd(entity)
|
|
|
|
self.changed = self.__attach_numa_nodes(entity)
|
|
|
|
self.changed = self.__attach_numa_nodes(entity)
|
|
|
|
self.changed = self.__attach_watchdog(entity)
|
|
|
|
self.changed = self.__attach_watchdog(entity)
|
|
|
|
self.changed = self.__attach_graphical_console(entity)
|
|
|
|
self.changed = self.__attach_graphical_console(entity)
|
|
|
@ -1239,7 +1240,7 @@ class VmsModule(BaseModule):
|
|
|
|
cd_iso = self.param('cd_iso')
|
|
|
|
cd_iso = self.param('cd_iso')
|
|
|
|
if cd_iso is not None:
|
|
|
|
if cd_iso is not None:
|
|
|
|
vm_service = self._service.service(entity.id)
|
|
|
|
vm_service = self._service.service(entity.id)
|
|
|
|
current = vm_service.get().status == otypes.VmStatus.UP
|
|
|
|
current = vm_service.get().status == otypes.VmStatus.UP and self.param('state') == 'running'
|
|
|
|
cdroms_service = vm_service.cdroms_service()
|
|
|
|
cdroms_service = vm_service.cdroms_service()
|
|
|
|
cdrom_device = cdroms_service.list()[0]
|
|
|
|
cdrom_device = cdroms_service.list()[0]
|
|
|
|
cdrom_service = cdroms_service.cdrom_service(cdrom_device.id)
|
|
|
|
cdrom_service = cdroms_service.cdrom_service(cdrom_device.id)
|
|
|
@ -1339,7 +1340,7 @@ class VmsModule(BaseModule):
|
|
|
|
def __attach_graphical_console(self, entity):
|
|
|
|
def __attach_graphical_console(self, entity):
|
|
|
|
graphical_console = self.param('graphical_console')
|
|
|
|
graphical_console = self.param('graphical_console')
|
|
|
|
if not graphical_console:
|
|
|
|
if not graphical_console:
|
|
|
|
return
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
vm_service = self._service.service(entity.id)
|
|
|
|
vm_service = self._service.service(entity.id)
|
|
|
|
gcs_service = vm_service.graphics_consoles_service()
|
|
|
|
gcs_service = vm_service.graphics_consoles_service()
|
|
|
@ -1450,6 +1451,7 @@ class VmsModule(BaseModule):
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def __attach_numa_nodes(self, entity):
|
|
|
|
def __attach_numa_nodes(self, entity):
|
|
|
|
|
|
|
|
updated = False
|
|
|
|
numa_nodes_service = self._service.service(entity.id).numa_nodes_service()
|
|
|
|
numa_nodes_service = self._service.service(entity.id).numa_nodes_service()
|
|
|
|
|
|
|
|
|
|
|
|
if len(self.param('numa_nodes')) > 0:
|
|
|
|
if len(self.param('numa_nodes')) > 0:
|
|
|
@ -1458,10 +1460,11 @@ class VmsModule(BaseModule):
|
|
|
|
existed_numa_nodes.sort(reverse=len(existed_numa_nodes) > 1 and existed_numa_nodes[1].index > existed_numa_nodes[0].index)
|
|
|
|
existed_numa_nodes.sort(reverse=len(existed_numa_nodes) > 1 and existed_numa_nodes[1].index > existed_numa_nodes[0].index)
|
|
|
|
for current_numa_node in existed_numa_nodes:
|
|
|
|
for current_numa_node in existed_numa_nodes:
|
|
|
|
numa_nodes_service.node_service(current_numa_node.id).remove()
|
|
|
|
numa_nodes_service.node_service(current_numa_node.id).remove()
|
|
|
|
|
|
|
|
updated = True
|
|
|
|
|
|
|
|
|
|
|
|
for numa_node in self.param('numa_nodes'):
|
|
|
|
for numa_node in self.param('numa_nodes'):
|
|
|
|
if numa_node is None or numa_node.get('index') is None or numa_node.get('cores') is None or numa_node.get('memory') is None:
|
|
|
|
if numa_node is None or numa_node.get('index') is None or numa_node.get('cores') is None or numa_node.get('memory') is None:
|
|
|
|
return False
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
numa_nodes_service.add(
|
|
|
|
numa_nodes_service.add(
|
|
|
|
otypes.VirtualNumaNode(
|
|
|
|
otypes.VirtualNumaNode(
|
|
|
@ -1481,8 +1484,9 @@ class VmsModule(BaseModule):
|
|
|
|
] if numa_node.get('numa_node_pins') is not None else None,
|
|
|
|
] if numa_node.get('numa_node_pins') is not None else None,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
updated = True
|
|
|
|
|
|
|
|
|
|
|
|
return True
|
|
|
|
return updated
|
|
|
|
|
|
|
|
|
|
|
|
def __attach_watchdog(self, entity):
|
|
|
|
def __attach_watchdog(self, entity):
|
|
|
|
watchdogs_service = self._service.service(entity.id).watchdogs_service()
|
|
|
|
watchdogs_service = self._service.service(entity.id).watchdogs_service()
|
|
|
@ -2002,11 +2006,9 @@ def main():
|
|
|
|
clone=module.params['clone'],
|
|
|
|
clone=module.params['clone'],
|
|
|
|
clone_permissions=module.params['clone_permissions'],
|
|
|
|
clone_permissions=module.params['clone_permissions'],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
vms_module.post_present(ret['id'])
|
|
|
|
|
|
|
|
if module.params['force']:
|
|
|
|
if module.params['force']:
|
|
|
|
ret = vms_module.action(
|
|
|
|
ret = vms_module.action(
|
|
|
|
action='stop',
|
|
|
|
action='stop',
|
|
|
|
post_action=vms_module._attach_cd,
|
|
|
|
|
|
|
|
action_condition=lambda vm: vm.status != otypes.VmStatus.DOWN,
|
|
|
|
action_condition=lambda vm: vm.status != otypes.VmStatus.DOWN,
|
|
|
|
wait_condition=vms_module.wait_for_down,
|
|
|
|
wait_condition=vms_module.wait_for_down,
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -2014,10 +2016,10 @@ def main():
|
|
|
|
ret = vms_module.action(
|
|
|
|
ret = vms_module.action(
|
|
|
|
action='shutdown',
|
|
|
|
action='shutdown',
|
|
|
|
pre_action=vms_module._pre_shutdown_action,
|
|
|
|
pre_action=vms_module._pre_shutdown_action,
|
|
|
|
post_action=vms_module._attach_cd,
|
|
|
|
|
|
|
|
action_condition=lambda vm: vm.status != otypes.VmStatus.DOWN,
|
|
|
|
action_condition=lambda vm: vm.status != otypes.VmStatus.DOWN,
|
|
|
|
wait_condition=vms_module.wait_for_down,
|
|
|
|
wait_condition=vms_module.wait_for_down,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
vms_module.post_present(ret['id'])
|
|
|
|
elif state == 'suspended':
|
|
|
|
elif state == 'suspended':
|
|
|
|
vms_module.create(
|
|
|
|
vms_module.create(
|
|
|
|
entity=vm,
|
|
|
|
entity=vm,
|
|
|
|