Skip to content

Commit 2609955

Browse files
committed
[ignore] Fixed logical issues in the ndo_tenant_netflow_monitor module
1 parent 2eae7c9 commit 2609955

5 files changed

Lines changed: 19 additions & 9 deletions

File tree

plugins/module_utils/mso.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2120,7 +2120,7 @@ def epg_object_reference_spec(aliases=None):
21202120
return epg_reference_spec
21212121

21222122

2123-
def ndo_template_object_spec_with_uuid(aliases=None, required_uuid_and_reference=True):
2123+
def ndo_template_object_spec_with_uuid(aliases=None, required_uuid_or_reference=True):
21242124
ndo_template_object_spec_with_uuid = dict(
21252125
options=dict(
21262126
uuid=dict(type="str"),
@@ -2148,7 +2148,7 @@ def ndo_template_object_spec_with_uuid(aliases=None, required_uuid_and_reference
21482148
],
21492149
)
21502150

2151-
if not required_uuid_and_reference:
2151+
if not required_uuid_or_reference:
21522152
ndo_template_object_spec_with_uuid.pop("required_one_of")
21532153

21542154
if aliases:

plugins/modules/ndo_tenant_netflow_exporter.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ def main():
200200
ops.append(dict(op="remove", path=path))
201201

202202
if mso.proposed:
203-
mso.proposed = copy.deepcopy(mso.proposed)
204203
mso_template.update_config_with_template_and_references(mso.proposed)
205204

206205
if not module.check_mode and ops:

plugins/modules/ndo_tenant_netflow_monitor.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def main():
239239
name=dict(type="str"),
240240
uuid=dict(type="str"),
241241
description=dict(type="str"),
242-
netflow_record=dict(type="dict", **ndo_template_object_spec_with_uuid(required_uuid_and_reference=False)),
242+
netflow_record=dict(type="dict", **ndo_template_object_spec_with_uuid(required_uuid_or_reference=False)),
243243
netflow_exporters=dict(type="list", elements="dict", **ndo_template_object_spec_with_uuid()),
244244
state=dict(type="str", default="query", choices=["absent", "query", "present"]),
245245
)
@@ -298,8 +298,7 @@ def main():
298298
netflow_monitor_object = copy.deepcopy(match.details)
299299
netflow_monitor_object["exporterRefs"] = netflow_exporters_list_to_dict(netflow_monitor_object.get("exporterRefs"))
300300
updated_netflow_monitor_object = mso_template.update_config_with_template_and_references(netflow_monitor_object, reference_details, False)
301-
mso.previous = copy.deepcopy(updated_netflow_monitor_object)
302-
mso.existing = copy.deepcopy(updated_netflow_monitor_object)
301+
mso.previous = mso.existing = copy.deepcopy(updated_netflow_monitor_object)
303302
elif match: # Query all objects
304303
for obj in match:
305304
obj["exporterRefs"] = netflow_exporters_list_to_dict(obj.get("exporterRefs"))
@@ -347,6 +346,9 @@ def main():
347346
if not netflow_exporter_uuids:
348347
mso_values.pop("exporterRefs", None)
349348

349+
if netflow_record is None and netflow_record_uuid is None:
350+
mso_values.pop("recordRef", None)
351+
350352
append_update_ops_data(ops, match.details, path, mso_values)
351353
mso.sanitize(mso_values, collate=True)
352354
else:
@@ -357,8 +359,6 @@ def main():
357359
ops.append(dict(op="remove", path=path))
358360

359361
if mso.proposed:
360-
mso.proposed = copy.deepcopy(mso.proposed)
361-
362362
if (
363363
mso.proposed.get("exporterRefs")
364364
and isinstance(mso.proposed.get("exporterRefs"), list)

plugins/modules/ndo_tenant_netflow_record.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@ def main():
234234
ops.append(dict(op="remove", path=path))
235235

236236
if mso.proposed:
237-
mso.proposed = copy.deepcopy(mso.proposed)
238237
mso_template.update_config_with_template_and_references(mso.proposed)
239238

240239
if not module.check_mode and ops:

tests/integration/targets/ndo_tenant_netflow_monitor/tasks/main.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,15 @@
227227
state: present
228228
register: update_netflow_monitor_2_without_changing_exporter
229229

230+
- name: Update NetFlow Monitor without specifying description, NetFlow Record and NetFlow Exporter
231+
cisco.mso.ndo_tenant_netflow_monitor:
232+
<<: *mso_info
233+
template: ansible_tenant_template
234+
uuid: "{{ nm_add_netflow_monitor.current.uuid }}"
235+
name: netflow_monitor_1_updated
236+
state: present
237+
register: update_netflow_monitor_without_description_record_exporter
238+
230239
- name: Assertion check for update NetFlow Monitor
231240
ansible.builtin.assert:
232241
that:
@@ -324,6 +333,9 @@
324333
- update_netflow_monitor_2_without_changing_exporter.current.name == "netflow_monitor_2"
325334
- update_netflow_monitor_2_without_changing_exporter.current.recordRef == ""
326335
- update_netflow_monitor_2_without_changing_exporter.previous.description == ""
336+
- update_netflow_monitor_without_description_record_exporter is not changed
337+
- update_netflow_monitor_without_description_record_exporter.current == nm_update_netflow_monitor_again.current
338+
- update_netflow_monitor_without_description_record_exporter.previous == nm_update_netflow_monitor_again.previous
327339

328340
# QUERY
329341
- name: Query NetFlow Monitor using UUID

0 commit comments

Comments
 (0)