Skip to content

Commit 93dfc56

Browse files
Merge pull request #129 from meraki/develop
v2.21.7
2 parents bdd74de + ed96c09 commit 93dfc56

File tree

6 files changed

+50
-29
lines changed

6 files changed

+50
-29
lines changed

CHANGELOG.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ Cisco.Meraki Release Notes
44

55
.. contents:: Topics
66

7+
v2.21.7
8+
=======
9+
10+
Bugfixes
11+
--------
12+
13+
- "Enhanced networks_switch_qos_rules_order object lookup logic to properly match QoS rules by vlan, protocol, srcPort, and dstPort parameters"
14+
- "Fixed parameter handling in networks_switch_switch_qos_rules_order to use qosRuleId instead of id for object identification"
15+
- "Improved meraki_compare_equality2 function to handle None value comparisons more accurately"
16+
- "Updated networks_switch_qos_rules_order playbook with corrected parameter values and VLAN configuration"
17+
718
v2.21.6
819
=======
920

changelogs/changelog.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,3 +1292,11 @@ releases:
12921292
- "Enhanced networks_switch_qos_rules_order with improved VLAN handling and debugging capabilities"
12931293

12941294
release_date: "2025-01-11"
1295+
2.21.7:
1296+
changes:
1297+
bugfixes:
1298+
- "Enhanced networks_switch_qos_rules_order object lookup logic to properly match QoS rules by vlan, protocol, srcPort, and dstPort parameters"
1299+
- "Fixed parameter handling in networks_switch_qos_rules_order to use qosRuleId instead of id for object identification"
1300+
- "Improved meraki_compare_equality2 function to handle None value comparisons more accurately"
1301+
- "Updated networks_switch_qos_rules_order playbook with corrected parameter values and VLAN configuration"
1302+
release_date: "2025-01-11"

galaxy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
namespace: cisco
33
name: meraki
4-
version: 2.21.6
4+
version: 2.21.7
55
readme: README.md
66
authors:
77
- Francisco Muñoz <[email protected]>

playbooks/networks_switch_qos_rules_order.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
cisco.meraki.networks_switch_qos_rules_order:
77
meraki_suppress_logging: false
88
state: present
9-
dscp: 1
10-
dstPort: 3000
9+
dscp: -1
10+
# dstPort: 3000
11+
dstPortRange: ANY
1112
networkId: L_828099381482771185
1213
protocol: UDP
13-
srcPort: 2000
14-
vlan: null
14+
srcPort: 2001
15+
vlan: 10

plugins/action/networks_switch_qos_rules_order.py

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@
2323
meraki_compare_equality2,
2424
get_dict_result,
2525
)
26-
from ansible_collections.cisco.meraki.plugins.plugin_utils.exceptions import (
27-
InconsistentParameters,
28-
)
26+
2927

3028
# Get common arguments specification
3129
argument_spec = meraki_argument_spec()
@@ -165,9 +163,13 @@ def get_object_by_name(self, name):
165163
if isinstance(items, dict):
166164
if 'response' in items:
167165
items = items.get('response')
168-
result = get_dict_result(items, 'vlan', name)
169-
if result is None:
170-
result = items
166+
for item in items:
167+
if (item.get("vlan") == self.new_object.get("vlan") and
168+
item.get("protocol") == self.new_object.get("protocol") and
169+
item.get("srcPort") == self.new_object.get("srcPort") and
170+
item.get("dstPort") == self.new_object.get("dstPort")):
171+
result = item
172+
break
171173
except Exception as e:
172174
print("Error: ", e)
173175
result = None
@@ -184,7 +186,12 @@ def get_object_by_id(self, id):
184186
if isinstance(items, dict):
185187
if 'response' in items:
186188
items = items.get('response')
187-
result = get_dict_result(items, 'qosRuleId', id)
189+
if id is not None:
190+
print("Is NOT NONE")
191+
result = get_dict_result(items, 'qosRuleId', id)
192+
else:
193+
# Validate if this
194+
print("Is NONE")
188195
except Exception as e:
189196
print("Error: ", e)
190197
result = None
@@ -194,33 +201,21 @@ def exists(self):
194201
id_exists = False
195202
name_exists = False
196203
prev_obj = None
197-
o_id = self.new_object.get("id")
204+
o_id = self.new_object.get("qosRuleId") or self.new_object.get("id")
198205
o_id = o_id or self.new_object.get(
199206
"qos_rule_id") or self.new_object.get("qosRuleId")
200-
name = self.new_object.get("vlan")
207+
name = self.new_object.get("name") or self.new_object.get("id")
201208
if o_id:
202209
prev_obj = self.get_object_by_id(o_id)
203-
id_exists = prev_obj is not None and isinstance(prev_obj, dict)
204-
if not id_exists and name or name is None:
210+
else:
211+
print("Is NONE")
205212
prev_obj = self.get_object_by_name(name)
206-
name_exists = prev_obj is not None and isinstance(prev_obj, dict)
207-
if name_exists:
208-
_id = prev_obj.get("id")
209-
_id = _id or prev_obj.get("qosRuleId")
210-
if id_exists and name_exists and o_id != _id:
211-
raise InconsistentParameters(
212-
"The 'id' and 'name' params don't refer to the same object")
213-
if _id:
214-
self.new_object.update(dict(id=_id))
215-
self.new_object.update(dict(qosRuleId=_id))
216-
if _id:
217-
prev_obj = self.get_object_by_id(_id)
218213
it_exists = prev_obj is not None and isinstance(prev_obj, dict)
219214
return (it_exists, prev_obj)
220215

221216
def requires_update(self, current_obj):
222217
requested_obj = self.new_object
223-
218+
current_obj["networkId"] = requested_obj.get("networkId") or None
224219
obj_params = [
225220
("dscp", "dscp"),
226221
("dstPort", "dstPort"),

plugins/plugin_utils/meraki.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,14 @@ def meraki_compare_equality(current_value, requested_value):
152152

153153
def meraki_compare_equality2(current_value, requested_value):
154154
# print("meraki_compare_equality", current_value, requested_value)
155+
if requested_value is not None and current_value is None:
156+
# print("requested_value is not None and current_value is None", False)
157+
return False
155158
if requested_value is None:
159+
# print("requested_value is None", True)
156160
return True
157161
if current_value is None:
162+
# print("current_value", True)
158163
return True
159164
if isinstance(current_value, dict) and isinstance(requested_value, dict):
160165
all_dict_params = list(current_value.keys()) + \
@@ -163,6 +168,7 @@ def meraki_compare_equality2(current_value, requested_value):
163168
elif isinstance(current_value, list) and isinstance(requested_value, list):
164169
return compare_list(current_value, requested_value)
165170
else:
171+
# print("current_value == requested_value", current_value == requested_value)
166172
return current_value == requested_value
167173

168174

0 commit comments

Comments
 (0)