Skip to content

Commit 60f329e

Browse files
committed
Do not deprecate vm_nic records return value
The module does work with list of NICs (the items input parameter). It is natural to also return a list of NICs. Reverts db9dff7 Signed-off-by: Justin Cinkelj <justin.cinkelj@xlab.si>
1 parent 4316a22 commit 60f329e

File tree

5 files changed

+13
-96
lines changed

5 files changed

+13
-96
lines changed

changelogs/fragments/return_documentation_update_vm_nic.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

docs/rst/extra/deprecation.rst

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,8 @@ return value ``results`` is deprecated.
2525
A new return value ``record`` is added as replacement.
2626
The old ``results`` return value will remain available until release 3.0.0.
2727

28-
Module `scale_computing.hypercore.vm_nic <../collections/scale_computing/hypercore/vm_nic_module.html>`_
29-
return value ``records`` is deprecated.
30-
A new return value ``record`` is added as replacement.
31-
The old ``records`` return value will remain available until release 3.0.0.
32-
3328
Only playbooks that store output from ``scale_computing.hypercore.iso``
34-
(or ``scale_computing.hypercore.vm_nic``) module using ``register:`` keyword are affected.
29+
module using ``register:`` keyword are affected.
3530

3631
Added deprecation note for modules
3732
`scale_computing.hypercore.vm <../collections/scale_computing/hypercore/vm_module.html>`_ and
@@ -62,31 +57,6 @@ For ``scale_computing.hypercore.iso`` module:
6257
ansible.builtin.debug:
6358
msg: The uploaded_iso size={{ uploaded_iso.record.size }}
6459
65-
66-
For ``scale_computing.hypercore.vm_nic`` module:
67-
68-
.. code-block:: yaml
69-
70-
# Store vm_nic module output
71-
- name: Set VLAN for VM {{ vm_name }} 1st NIC
72-
scale_computing.hypercore.vm_nic:
73-
vm_name: "{{ vm_name }}"
74-
items:
75-
- vlan: "{{ vlan }}"
76-
state: present
77-
register: vm_nic_result
78-
79-
# Use vm_nic module output, old syntax, valid until release < 3.0.0
80-
- name: Show VM {{ vm_name }} 1st NIC VLAN - deprecated syntax
81-
ansible.builtin.debug:
82-
msg: The configured VLAN is {{ vm_nic_result.records.vlan }} - deprecated syntax
83-
84-
# Use vm_nic module output, new syntax, valid after release >= 1.2.0
85-
- name: Show VM {{ vm_name }} 1st NIC VLAN
86-
ansible.builtin.debug:
87-
msg: The configured VLAN is {{ vm_nic_result.record.vlan }}
88-
89-
9060
Release 3.0.0 (not yet released)
9161
================================
9262

examples/vm_nic.yml

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,27 @@
11
---
2-
- name: Change VLAN for 1st NIC of a specific VM
2+
- name: Configure VM with a two NICs with specific VLANs
33
hosts: localhost
44
connection: local
55
gather_facts: false
66
vars:
77
vm_name: demo-vm
8-
vlan: 10
8+
vlan_a: 10
9+
vlan_b: 11
910

1011
tasks:
11-
- name: Set VLAN for VM {{ vm_name }} 1st NIC
12+
- name: Configure VM {{ vm_name }} with 2 NICs, VLANs {{ vlan_a }} and {{ vlan_b }}
1213
scale_computing.hypercore.vm_nic:
1314
vm_name: "{{ vm_name }}"
1415
items:
15-
- vlan: "{{ vlan }}"
16-
state: present
16+
- vlan: "{{ vlan_a }}"
17+
- vlan: "{{ vlan_b }}"
18+
state: set
1719
register: vm_nic_result
1820

1921
- name: Show the VM {{ vm_name }} new NIC state
2022
ansible.builtin.debug:
21-
var: vm_nic_result.record
23+
var: vm_nic_result
2224

23-
# Use vm_nic module output, old syntax, valid until release < 3.0.0
24-
- name: Show VM {{ vm_name }} 1st NIC VLAN - deprecated syntax
25+
- name: Show VM {{ vm_name }} new NIC VLANs
2526
ansible.builtin.debug:
26-
msg: The configured VLAN is {{ vm_nic_result.records.vlan }} - deprecated syntax
27-
28-
# Use vm_nic module output, new syntax, valid after release >= 1.2.0
29-
- name: Show VM {{ vm_name }} 1st NIC VLAN
30-
ansible.builtin.debug:
31-
msg: The configured VLAN is {{ vm_nic_result.record.vlan }}
27+
msg: The configured VLANs are {{ vm_nic_result.records | map(attribute="vlan") }}

plugins/modules/vm_nic.py

Lines changed: 2 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@
6969
- Is network interface connected or not.
7070
notes:
7171
- C(check_mode) is not supported.
72-
- Return value C(record) is added in version 1.2.0, and deprecates return value C(records).
73-
Return value C(records) will be removed in future release.
74-
R(List of deprecation changes, scale_computing.hypercore.deprecation)
75-
includes examples to help with transition.
7672
"""
7773

7874
EXAMPLES = r"""
@@ -140,41 +136,9 @@
140136
"""
141137

142138
RETURN = r"""
143-
record:
144-
description:
145-
- The created or changed record for nic on a specified virtual machine.
146-
returned: success
147-
type: dict
148-
contains:
149-
uuid:
150-
description: Unique identifier
151-
type: str
152-
sample: 07a2a68a-0afa-4718-9c6f-00a39d08b67e
153-
vlan:
154-
description: VLAN tag of the interface
155-
type: int
156-
sample: 15
157-
type:
158-
description: Virtualized network device types
159-
type: str
160-
sample: virtio
161-
mac:
162-
description: MAC address of the virtual network device
163-
type: str
164-
sample: 12-34-56-78-AB
165-
connected:
166-
description: Enabled and can make connections
167-
type: bool
168-
sample: true
169-
ipv4_addresses:
170-
description: IPv4 addresses registered with this device
171-
type: list
172-
elements: str
173-
sample: 192.0.2.1
174139
records:
175140
description:
176141
- The created or changed record for nic on a specified virtual machine.
177-
- This value is deprecated and will be removed in a future release. Please use record instead.
178142
returned: success
179143
type: dict
180144
contains:
@@ -339,22 +303,13 @@ def main():
339303
),
340304
)
341305

342-
module.deprecate(
343-
"The 'records' return value is being renamed to 'record'. "
344-
"Please use 'record' since 'records' will be removed in future release. "
345-
"But for now both values are being returned to allow users to migrate their automation.",
346-
version="3.0.0",
347-
collection_name="scale_computing.hypercore",
348-
)
349-
350306
try:
351307
client = Client.get_client(module.params["cluster_instance"])
352308
rest_client = RestClient(client=client)
353-
changed, record, diff, reboot = run(module, rest_client)
309+
changed, records, diff, reboot = run(module, rest_client)
354310
module.exit_json(
355311
changed=changed,
356-
records=record,
357-
record=record,
312+
records=records,
358313
diff=diff,
359314
vm_rebooted=reboot,
360315
)

tests/unit/plugins/modules/test_vm_nic.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ def test_minimal_set_of_params(self, run_main_with_reboot, mocker):
200200
assert results == {
201201
"changed": False,
202202
"records": {},
203-
"record": {},
204203
"diff": {"before": {}, "after": {}},
205204
"vm_rebooted": False,
206205
}

0 commit comments

Comments
 (0)