Skip to content

Commit db9dff7

Browse files
PolonaMjustinc1
authored andcommitted
Update return documentation, deprecate records value - vm_nic module
records will be replaced by record.
1 parent c2d7931 commit db9dff7

File tree

3 files changed

+79
-10
lines changed

3 files changed

+79
-10
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
major_changes:
3+
- Deprecate records value and add record value in vm_nic module return values. (https://github.com/ScaleComputing/HyperCoreAnsibleCollection/pull/183)

plugins/modules/vm_nic.py

Lines changed: 75 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
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.
7274
"""
7375

7476
EXAMPLES = r"""
@@ -136,18 +138,69 @@
136138
"""
137139

138140
RETURN = r"""
141+
record:
142+
description:
143+
- The created or changed record for nic on a specified virtual machine.
144+
returned: success
145+
type: dict
146+
contains:
147+
uuid:
148+
description: Unique identifier
149+
type: str
150+
sample: 07a2a68a-0afa-4718-9c6f-00a39d08b67e
151+
vlan:
152+
description: VLAN tag of the interface
153+
type: int
154+
sample: 15
155+
type:
156+
description: Virtualized network device types
157+
type: str
158+
sample: virtio
159+
mac:
160+
description: MAC address of the virtual network device
161+
type: str
162+
sample: 12-34-56-78-AB
163+
connected:
164+
description: Enabled and can make connections
165+
type: bool
166+
sample: true
167+
ipv4_addresses:
168+
description: IPv4 addresses registered with this device
169+
type: list
170+
elements: str
171+
sample: 192.0.2.1
139172
records:
140173
description:
141174
- The created or changed record for nic on a specified virtual machine.
175+
- This value is deprecated and will be removed in a future release. Please use record instead.
142176
returned: success
143-
type: list
144-
sample:
145-
- uuid: 07a2a68a-0afa-4718-9c6f-00a39d08b67e
146-
vlan: 15
147-
type: virtio
148-
mac: 12-34-56-78-AB
149-
connected: true
150-
ipv4_addresses: []
177+
type: dict
178+
contains:
179+
uuid:
180+
description: Unique identifier
181+
type: str
182+
sample: 07a2a68a-0afa-4718-9c6f-00a39d08b67e
183+
vlan:
184+
description: VLAN tag of the interface
185+
type: int
186+
sample: 15
187+
type:
188+
description: Virtualized network device types
189+
type: str
190+
sample: virtio
191+
mac:
192+
description: MAC address of the virtual network device
193+
type: str
194+
sample: 12-34-56-78-AB
195+
connected:
196+
description: Enabled and can make connections
197+
type: bool
198+
sample: true
199+
ipv4_addresses:
200+
description: IPv4 addresses registered with this device
201+
type: list
202+
elements: str
203+
sample: 192.0.2.1
151204
"""
152205

153206
from ansible.module_utils.basic import AnsibleModule
@@ -278,12 +331,24 @@ def main():
278331
),
279332
)
280333

334+
module.deprecate(
335+
"The 'records' return value is being renamed to 'record'."
336+
"Please use 'record' since 'records' will be removed in future release."
337+
"But for now both values are being returned to allow users to migrate their automation.",
338+
version="3.0.0",
339+
collection_name="scale_computing.hypercore",
340+
)
341+
281342
try:
282343
client = Client.get_client(module.params["cluster_instance"])
283344
rest_client = RestClient(client=client)
284-
changed, records, diff, reboot = run(module, rest_client)
345+
changed, record, diff, reboot = run(module, rest_client)
285346
module.exit_json(
286-
changed=changed, records=records, diff=diff, vm_rebooted=reboot
347+
changed=changed,
348+
records=record,
349+
record=record,
350+
diff=diff,
351+
vm_rebooted=reboot,
287352
)
288353
except errors.ScaleComputingError as e:
289354
module.fail_json(msg=str(e))

tests/unit/plugins/modules/test_vm_nic.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ def test_minimal_set_of_params(self, run_main_with_reboot, mocker):
197197
assert results == {
198198
"changed": False,
199199
"records": {},
200+
"record": {},
200201
"diff": {"before": {}, "after": {}},
201202
"vm_rebooted": False,
202203
}

0 commit comments

Comments
 (0)