From 96dda702f761e43db1db4993e33ec247be6bd311 Mon Sep 17 00:00:00 2001 From: pmargara <34438580+pmargara@users.noreply.github.com> Date: Sat, 27 Jan 2018 21:18:09 +0100 Subject: [PATCH] cloud:ovirt:ovirt_vms.py: Added 'quota_id','sso', 'boot_menu', 'usb_support', 'serial_console' fields to ovirt_vms module (#34048) * Added 'quota_id','sso', 'boot_menu', 'usb_support', 'serial_console' fields to ovirt_vms module * always run ansible-test first * always run ansible-test first 2 * suggested changes applied --- lib/ansible/modules/cloud/ovirt/ovirt_vms.py | 58 ++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_vms.py b/lib/ansible/modules/cloud/ovirt/ovirt_vms.py index 49786bfa6cc..bbd2ab8ad6c 100644 --- a/lib/ansible/modules/cloud/ovirt/ovirt_vms.py +++ b/lib/ansible/modules/cloud/ovirt/ovirt_vms.py @@ -171,6 +171,10 @@ options: - Type of the Virtual Machine. - Default value is set by oVirt/RHV engine. choices: [ desktop, server ] + quota_id: + description: + - "Virtual Machine quota ID to be used for disk. By default quota is chosen by oVirt/RHV engine." + version_added: "2.5" operating_system: description: - Operating system of the Virtual Machine. @@ -221,6 +225,22 @@ options: - List of boot devices which should be used to boot. For example C([ cdrom, hd ]). - Default value is set by oVirt/RHV engine. choices: [ cdrom, hd, network ] + boot_menu: + description: + - "I(True) enable menu to select boot device, I(False) to disable it. By default is chosen by oVirt/RHV engine." + version_added: "2.5" + usb_support: + description: + - "I(True) enable USB support, I(False) to disable it. By default is chosen by oVirt/RHV engine." + version_added: "2.5" + serial_console: + description: + - "I(True) enable VirtIO serial console, I(False) to disable it. By default is chosen by oVirt/RHV engine." + version_added: "2.5" + sso: + description: + - "I(True) enable Single Sign On by Guest Agent, I(False) to disable it. By default is chosen by oVirt/RHV engine." + version_added: "2.5" host: description: - Specify host where Virtual Machine should be running. By default the host is chosen by engine scheduler. @@ -686,6 +706,19 @@ EXAMPLES = ''' ovirt_vms: state: absent name: myvm + +# Defining a specific quota for a VM: +# Since Ansible 2.5 +- ovirt_quotas_facts: + data_center: Default + name: myquota +- ovirt_vms: + name: myvm + sso: False + boot_menu: True + usb_support: True + serial_console: True + quota_id: "{{ ovirt_quotas[0]['id'] }}" ''' @@ -802,6 +835,21 @@ class VmsModule(BaseModule): use_latest_template_version=self.param('use_latest_template_version'), stateless=self.param('stateless') or self.param('use_latest_template_version'), delete_protected=self.param('delete_protected'), + bios=( + otypes.Bios(boot_menu=otypes.BootMenu(enabled=self.param('boot_menu'))) + ) if self.param('boot_menu') is not None else None, + console=( + otypes.Console(enabled=self.param('serial_console')) + ) if self.param('serial_console') is not None else None, + usb=( + otypes.Usb(enabled=self.param('usb_support')) + ) if self.param('usb_support') is not None else None, + sso=( + otypes.Sso( + methods=[otypes.Method(id=otypes.SsoMethod.GUEST_AGENT)] if self.param('sso') else [] + ) + ), + quota=otypes.Quota(id=self._module.params.get('quota_id')) if self.param('quota_id') is not None else None, high_availability=otypes.HighAvailability( enabled=self.param('high_availability') ) if self.param('high_availability') is not None else None, @@ -871,6 +919,11 @@ class VmsModule(BaseModule): equal(self.param('cpu_threads'), entity.cpu.topology.threads) and equal(self.param('type'), str(entity.type)) and equal(self.param('operating_system'), str(entity.os.type)) and + equal(self.param('boot_menu'), entity.boot.boot_menu.enabled) and + equal(self.param('serial_console'), entity.console.enabled) and + equal(self.param('usb_support'), entity.usb.enabled) and + equal(self.param('sso'), True if entity.sso.methods else False) and + equal(self.param('quota_id'), getattr(entity.quota, 'id')) and equal(self.param('high_availability'), entity.high_availability.enabled) and equal(self.param('lease'), get_link_name(self._connection, getattr(entity.lease, 'storage_domain', None))) and equal(self.param('stateless'), entity.stateless) and @@ -1457,6 +1510,11 @@ def main(): lun_mappings=dict(default=[], type='list'), domain_mappings=dict(default=[], type='list'), reassign_bad_macs=dict(default=None, type='bool'), + boot_menu=dict(type='bool'), + serial_console=dict(type='bool'), + usb_support=dict(type='bool'), + sso=dict(type='bool'), + quota_id=dict(type='str'), high_availability=dict(type='bool'), lease=dict(type='str'), stateless=dict(type='bool'),