1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Ovirt add kernel persist (#45555)

* ovirt add kernel persist

* Add description to kernel_params_persist

* update kernel_params_persist control logic

* correct pep8 syntax

* add condition for kernel_params

* put kernel persist check to function

* kernel persist check update tabs
This commit is contained in:
Martin Nečas 2018-10-05 09:09:45 +02:00 committed by ansibot
parent d79be6a00c
commit 4c7bb32c1f

View file

@ -363,6 +363,12 @@ options:
type: bool type: bool
version_added: "2.5" version_added: "2.5"
aliases: [ 'sysprep_persist' ] aliases: [ 'sysprep_persist' ]
kernel_params_persist:
description:
- "If I(true) C(kernel_params), C(initrd_path) and C(kernel_path) will persist in virtual machine configuration,
if I(False) it will be used for run once."
type: bool
version_added: "2.8"
kernel_path: kernel_path:
description: description:
- Path to a kernel image used to boot the virtual machine. - Path to a kernel image used to boot the virtual machine.
@ -1081,8 +1087,11 @@ class VmsModule(BaseModule):
otypes.BootDevice(dev) for dev in self.param('boot_devices') otypes.BootDevice(dev) for dev in self.param('boot_devices')
], ],
) if self.param('boot_devices') else None, ) if self.param('boot_devices') else None,
cmdline=self.param('kernel_params') if self.param('kernel_params_persist') else None,
initrd=self.param('initrd_path') if self.param('kernel_params_persist') else None,
kernel=self.param('kernel_path') if self.param('kernel_params_persist') else None,
) if ( ) if (
self.param('operating_system') or self.param('boot_devices') self.param('operating_system') or self.param('boot_devices') or self.param('kernel_params_persist')
) else None, ) else None,
type=otypes.VmType( type=otypes.VmType(
self.param('type') self.param('type')
@ -1181,6 +1190,7 @@ class VmsModule(BaseModule):
check_custom_properties() and check_custom_properties() and
check_host() and check_host() and
not self.param('cloud_init_persist') and not self.param('cloud_init_persist') and
not self.param('kernel_params_persist') and
equal(self.param('cluster'), get_link_name(self._connection, entity.cluster)) and equal(convert_to_bytes(self.param('memory')), entity.memory) and equal(self.param('cluster'), get_link_name(self._connection, entity.cluster)) and equal(convert_to_bytes(self.param('memory')), entity.memory) and
equal(convert_to_bytes(self.param('memory_guaranteed')), entity.memory_policy.guaranteed) and equal(convert_to_bytes(self.param('memory_guaranteed')), entity.memory_policy.guaranteed) and
equal(convert_to_bytes(self.param('memory_max')), entity.memory_policy.max) and equal(convert_to_bytes(self.param('memory_max')), entity.memory_policy.max) and
@ -1947,6 +1957,7 @@ def main():
cloud_init=dict(type='dict'), cloud_init=dict(type='dict'),
cloud_init_nics=dict(type='list', default=[]), cloud_init_nics=dict(type='list', default=[]),
cloud_init_persist=dict(type='bool', default=False, aliases=['sysprep_persist']), cloud_init_persist=dict(type='bool', default=False, aliases=['sysprep_persist']),
kernel_params_persist=dict(type='bool', default=False),
sysprep=dict(type='dict'), sysprep=dict(type='dict'),
host=dict(type='str'), host=dict(type='str'),
clone=dict(type='bool', default=False), clone=dict(type='bool', default=False),
@ -2021,6 +2032,11 @@ def main():
vms_module.post_present(ret['id']) vms_module.post_present(ret['id'])
# Run the VM if it was just created, else don't run it: # Run the VM if it was just created, else don't run it:
if state == 'running': if state == 'running':
def kernel_persist_check():
return (module.params.get('kernel_params') or
module.params.get('initrd_path') or
module.params.get('kernel_path')
and not module.params.get('cloud_init_persist'))
initialization = vms_module.get_initialization() initialization = vms_module.get_initialization()
ret = vms_module.action( ret = vms_module.action(
action='start', action='start',
@ -2048,17 +2064,12 @@ def main():
cmdline=module.params.get('kernel_params'), cmdline=module.params.get('kernel_params'),
initrd=module.params.get('initrd_path'), initrd=module.params.get('initrd_path'),
kernel=module.params.get('kernel_path'), kernel=module.params.get('kernel_path'),
) if (kernel_persist_check()) else None,
) if ( ) if (
module.params.get('kernel_params') or kernel_persist_check() or
module.params.get('initrd_path') or
module.params.get('kernel_path')
) else None,
) if (
module.params.get('kernel_params') or
module.params.get('initrd_path') or
module.params.get('kernel_path') or
module.params.get('host') or module.params.get('host') or
initialization is not None and not module.params.get('cloud_init_persist') initialization is not None
and not module.params.get('cloud_init_persist')
) else None, ) else None,
) )