Skip to content

Commit

Permalink
[ignore] Add the possibility to use CoS values or their respective tr…
Browse files Browse the repository at this point in the history
…affic types for attributes in ndo_tenant_custom_qos_policy.
  • Loading branch information
gmicol committed Dec 17, 2024
1 parent 4e57b14 commit 8d9596e
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 15 deletions.
6 changes: 3 additions & 3 deletions plugins/module_utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def append_update_ops_data(ops, existing_data, update_path, replace_data=None, r
replace_data = {
("name"): "new_name",
"description": "new_description",
("ospfIntfPol"): dict(ifControl=dict(adminState="disbaled"), cost=0)),
("ospfIntfPol"): dict(ifControl=dict(adminState="disabled"), cost=0)),
}
remove_data = [("bfdMultiHopPol", "ifControl", "adminState"), "bfdPol"]
Expand Down Expand Up @@ -149,7 +149,7 @@ def recursive_delete(data, path, keys):

def format_list_dict(list_dict, keys_map):
"""
Convert an Python list of dictionaries into its equivalent NDO API format.
Convert a Python list of dictionaries into its equivalent NDO API format.
All keys must be defined in the keys map even if no conversion is needed for some keys.
:param list_dict: The Python list of dictionaries to format. Can be an empty List or None -> List
Expand Down Expand Up @@ -210,7 +210,7 @@ def format_dict(d): # format individual dictionary to its equivalent NDO API fo
for key, value in keys_map.items():
# keys_map can have values of type list including the API key string and the map conversion for values
if isinstance(value, list):
formatted_dict[value[0]] = value[1].get(d.get(key))
formatted_dict[value[0]] = d[key] if d.get(key) in value[1].values() else value[1].get(d.get(key))
else:
formatted_dict[value] = d.get(key)
else:
Expand Down
105 changes: 93 additions & 12 deletions plugins/modules/ndo_tenant_custom_qos_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,30 @@
aliases: [ target ]
target_cos:
description:
- The target CoS traffic type for the egressing traffic.
- The target CoS value/traffic type for the egressing traffic.
- Defaults to C(unspecified) when unset during creation.
- Both CoS value and traffic type are allowed.
For example, O(dscp_mappings.target_cos=cos0) or O(dscp_mappings.target_cos=background) are the same valid inputs.
type: str
choices: [ background, best_effort, excellent_effort, critical_applications, video, voice, internetwork_control, network_control, unspecified ]
choices:
- background
- cos0
- best_effort
- cos1
- excellent_effort
- cos2
- critical_applications
- cos3
- video
- cos4
- voice
- cos5
- internetwork_control
- cos6
- network_control
- cos7
- unspecified
- cos8
qos_priority:
description:
- The QoS priority level to which the DSCP values will be mapped.
Expand All @@ -166,17 +186,57 @@
suboptions:
dot1p_from:
description:
- The starting traffic type of the CoS range.
- The starting value/traffic type of the CoS range.
- Defaults to C(unspecified) when unset during creation.
- Both CoS values and their respective traffic types are allowed.
For example, O(cos_mappings.dot1p_from=cos0) or O(cos_mappings.dot1p_from=background) are the same valid inputs.
type: str
choices: [ background, best_effort, excellent_effort, critical_applications, video, voice, internetwork_control, network_control, unspecified ]
choices:
- background
- cos0
- best_effort
- cos1
- excellent_effort
- cos2
- critical_applications
- cos3
- video
- cos4
- voice
- cos5
- internetwork_control
- cos6
- network_control
- cos7
- unspecified
- cos8
aliases: [ from ]
dot1p_to:
description:
- The encoding traffic type of the CoS range.
- The ending value/traffic type of the CoS range.
- Defaults to C(unspecified) when unset during creation.
- Both CoS value and traffic type are allowed.
For example, O(cos_mappings.dot1p_to=cos0) or O(cos_mappings.dot1p_to=background) are the same valid inputs.
type: str
choices: [ background, best_effort, excellent_effort, critical_applications, video, voice, internetwork_control, network_control, unspecified ]
choices:
- background
- cos0
- best_effort
- cos1
- excellent_effort
- cos2
- critical_applications
- cos3
- video
- cos4
- voice
- cos5
- internetwork_control
- cos6
- network_control
- cos7
- unspecified
- cos8
aliases: [ to ]
dscp_target:
description:
Expand Down Expand Up @@ -210,10 +270,30 @@
aliases: [ target ]
target_cos:
description:
- The target CoS traffic type for the egressing traffic.
- The target CoS value/traffic type for the egressing traffic.
- Defaults to C(unspecified) when unset during creation.
- Both CoS values and their respective traffic types are allowed.
For example, O(cos_mappings.target_cos=cos0) or O(cos_mappings.target_cos=background) are the same valid inputs.
type: str
choices: [ background, best_effort, excellent_effort, critical_applications, video, voice, internetwork_control, network_control, unspecified ]
choices:
- background
- cos0
- best_effort
- cos1
- excellent_effort
- cos2
- critical_applications
- cos3
- video
- cos4
- voice
- cos5
- internetwork_control
- cos6
- network_control
- cos7
- unspecified
- cos8
qos_priority:
description:
- The QoS priority level to which the DSCP values will be mapped.
Expand Down Expand Up @@ -335,6 +415,7 @@


def main():
COS_MAP_CHOICES = list(TARGET_COS_MAP) + list(TARGET_COS_MAP.values())
argument_spec = mso_argument_spec()
argument_spec.update(
template=dict(type="str", required=True, aliases=["tenant_template"]),
Expand All @@ -348,7 +429,7 @@ def main():
dscp_from=dict(type="str", choices=list(TARGET_DSCP_MAP), aliases=["from"]),
dscp_to=dict(type="str", choices=list(TARGET_DSCP_MAP), aliases=["to"]),
dscp_target=dict(type="str", choices=list(TARGET_DSCP_MAP), aliases=["target"]),
target_cos=dict(type="str", choices=list(TARGET_COS_MAP)),
target_cos=dict(type="str", choices=COS_MAP_CHOICES),
qos_priority=dict(
type="str",
choices=["level1", "level2", "level3", "level4", "level5", "level6", "unspecified"],
Expand All @@ -360,10 +441,10 @@ def main():
type="list",
elements="dict",
options=dict(
dot1p_from=dict(type="str", choices=list(TARGET_COS_MAP), aliases=["from"]),
dot1p_to=dict(type="str", choices=list(TARGET_COS_MAP), aliases=["to"]),
dot1p_from=dict(type="str", choices=COS_MAP_CHOICES, aliases=["from"]),
dot1p_to=dict(type="str", choices=COS_MAP_CHOICES, aliases=["to"]),
dscp_target=dict(type="str", choices=list(TARGET_DSCP_MAP), aliases=["target"]),
target_cos=dict(type="str", choices=list(TARGET_COS_MAP)),
target_cos=dict(type="str", choices=COS_MAP_CHOICES),
qos_priority=dict(
type="str",
choices=["level1", "level2", "level3", "level4", "level5", "level6", "unspecified"],
Expand Down

0 comments on commit 8d9596e

Please sign in to comment.