From 0b41750f9dbc87eece8cfabd43b1c8cfc3009185 Mon Sep 17 00:00:00 2001 From: mnecas Date: Wed, 19 Jun 2019 12:07:14 +0200 Subject: [PATCH 1/3] ovirt add nic linked --- lib/ansible/modules/cloud/ovirt/ovirt_nic.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_nic.py b/lib/ansible/modules/cloud/ovirt/ovirt_nic.py index 61e0b6d9cbe470..91f5691f31110a 100644 --- a/lib/ansible/modules/cloud/ovirt/ovirt_nic.py +++ b/lib/ansible/modules/cloud/ovirt/ovirt_nic.py @@ -54,6 +54,10 @@ mac_address: description: - Custom MAC address of the network interface, by default it's obtained from MAC pool. + linked: + description: + - Defines if the NIC is linked to the virtual machine. + type: bool extends_documentation_fragment: ovirt ''' @@ -80,6 +84,7 @@ - name: Unplug NIC from VM ovirt_nic: state: unplugged + linked: false vm: myvm name: mynic @@ -165,12 +170,14 @@ def build_entity(self): mac=otypes.Mac( address=self._module.params.get('mac_address') ) if self._module.params.get('mac_address') else None, + linked=self.param('linked') if self.param('linked') is not None else None, ) def update_check(self, entity): if self._module.params.get('vm'): return ( equal(self._module.params.get('interface'), str(entity.interface)) and + equal(self._module.params.get('linked'), str(entity.linked)) and equal(self._module.params.get('name'), str(entity.name)) and equal(self._module.params.get('profile'), get_link_name(self._connection, entity.vnic_profile)) and equal(self._module.params.get('mac_address'), entity.mac.address) @@ -178,6 +185,7 @@ def update_check(self, entity): elif self._module.params.get('template'): return ( equal(self._module.params.get('interface'), str(entity.interface)) and + equal(self._module.params.get('linked'), str(entity.linked)) and equal(self._module.params.get('name'), str(entity.name)) and equal(self._module.params.get('profile'), get_link_name(self._connection, entity.vnic_profile)) ) @@ -194,6 +202,7 @@ def main(): profile=dict(type='str'), network=dict(type='str'), mac_address=dict(type='str'), + linked=dict(type='bool'), ) module = AnsibleModule( argument_spec=argument_spec, From ea1dee7aee3631d43581c67877c160a6afcaad96 Mon Sep 17 00:00:00 2001 From: mnecas Date: Wed, 19 Jun 2019 12:08:06 +0200 Subject: [PATCH 2/3] add version added --- lib/ansible/modules/cloud/ovirt/ovirt_nic.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_nic.py b/lib/ansible/modules/cloud/ovirt/ovirt_nic.py index 91f5691f31110a..35167b837ae6b7 100644 --- a/lib/ansible/modules/cloud/ovirt/ovirt_nic.py +++ b/lib/ansible/modules/cloud/ovirt/ovirt_nic.py @@ -58,6 +58,7 @@ description: - Defines if the NIC is linked to the virtual machine. type: bool + version_added: "2.9" extends_documentation_fragment: ovirt ''' From 1177f6c312bc279bce265d7bf761336401e7a678 Mon Sep 17 00:00:00 2001 From: mnecas Date: Wed, 19 Jun 2019 13:07:23 +0200 Subject: [PATCH 3/3] update check method --- lib/ansible/modules/cloud/ovirt/ovirt_nic.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_nic.py b/lib/ansible/modules/cloud/ovirt/ovirt_nic.py index 35167b837ae6b7..c411f6b95d0082 100644 --- a/lib/ansible/modules/cloud/ovirt/ovirt_nic.py +++ b/lib/ansible/modules/cloud/ovirt/ovirt_nic.py @@ -178,7 +178,7 @@ def update_check(self, entity): if self._module.params.get('vm'): return ( equal(self._module.params.get('interface'), str(entity.interface)) and - equal(self._module.params.get('linked'), str(entity.linked)) and + equal(self._module.params.get('linked'), entity.linked) and equal(self._module.params.get('name'), str(entity.name)) and equal(self._module.params.get('profile'), get_link_name(self._connection, entity.vnic_profile)) and equal(self._module.params.get('mac_address'), entity.mac.address) @@ -186,7 +186,7 @@ def update_check(self, entity): elif self._module.params.get('template'): return ( equal(self._module.params.get('interface'), str(entity.interface)) and - equal(self._module.params.get('linked'), str(entity.linked)) and + equal(self._module.params.get('linked'), entity.linked) and equal(self._module.params.get('name'), str(entity.name)) and equal(self._module.params.get('profile'), get_link_name(self._connection, entity.vnic_profile)) )