Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cable_length attribute to QoS interfaces module #468

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/468-cable-length.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- sonic_qos_interfaces - Add 'cable_length' attribute (https://github.com/ansible-collections/dellemc.enterprise_sonic/pull/468).
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ def __init__(self, **kwargs):
},
'type': 'list'
},
'scheduler_policy': {'type': 'str'}
'scheduler_policy': {'type': 'str'},
'cable_length': {'choices': ['5m', '40m', '300m'], 'default': '40m', 'type': 'str'}
},
'type': 'list'
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ def get_modify_qos_interfaces_requests(self, commands):
intf_dict = {}
name = intf.get('name')
scheduler_policy = intf.get('scheduler_policy')
cable_length = intf.get('cable_length')
qos_maps = intf.get('qos_maps')
pfc = intf.get('pfc')
queues = intf.get('queues')
Expand All @@ -257,6 +258,8 @@ def get_modify_qos_interfaces_requests(self, commands):
intf_dict.update({'interface-id': name, 'config': {'interface-id': name}})
if scheduler_policy:
intf_dict['output'] = {'scheduler-policy': {'config': {'name': scheduler_policy}}}
if cable_length:
intf_dict['openconfig-qos-buffer:cable-length'] = {'config': {'length': cable_length}}
if qos_maps:
map_dict = {}
dscp_fwd_group = qos_maps.get('dscp_fwd_group')
Expand Down Expand Up @@ -364,6 +367,7 @@ def get_delete_qos_interfaces_requests(self, commands, have, is_delete_all):
for intf in commands:
name = intf.get('name')
scheduler_policy = intf.get('scheduler_policy')
cable_length = intf.get('cable_length')
qos_maps = intf.get('qos_maps')
pfc = intf.get('pfc')
queues = intf.get('queues')
Expand All @@ -373,6 +377,7 @@ def get_delete_qos_interfaces_requests(self, commands, have, is_delete_all):
continue
config_dict = {}
cfg_scheduler_policy = cfg_intf.get('scheduler_policy')
cfg_cable_length = cfg_intf.get('cable_length')
cfg_qos_maps = cfg_intf.get('qos_maps')
cfg_pfc = cfg_intf.get('pfc')
cfg_queues = cfg_intf.get('queues')
Expand All @@ -381,6 +386,12 @@ def get_delete_qos_interfaces_requests(self, commands, have, is_delete_all):
url = '%s/interface=%s/output/scheduler-policy' % (QOS_INTF_PATH, name)
requests.append({'path': url, 'method': DELETE})
config_dict.update({'name': name, 'scheduler_policy': scheduler_policy})

if cable_length and cable_length == cfg_cable_length:
url = '%s/interface=%s/openconfig-qos-buffer:cable-length' % (QOS_INTF_PATH, name)
requests.append({'path': url, 'method': DELETE})
config_dict.update({'name': name, 'cable_length': cable_length})

if qos_maps and cfg_qos_maps:
maps_dict = {}
dscp_fwd_group = qos_maps.get('dscp_fwd_group')
Expand Down Expand Up @@ -508,7 +519,7 @@ def get_delete_qos_interfaces_requests(self, commands, have, is_delete_all):
config_dict.update({'name': name, 'queues': queues_list})
if config_dict:
config_list.append(config_dict)
if not scheduler_policy and not qos_maps and not pfc and not queues:
if not scheduler_policy and not qos_maps and not pfc and not queues and not cable_length:
self._module.fail_json(msg='Deletion of a QoS interface not supported')
commands = config_list

Expand Down Expand Up @@ -556,6 +567,11 @@ def remove_default_entries(self, data):
pfc.pop('priorities')
if not pfc:
intf.pop('pfc')

cable_length = intf.get('cable_length')
if cable_length == '40m':
intf.pop('cable_length')

if 'name' in intf and (len(intf) == 1 or intf['name'] == 'CPU'):
intf_idx = data.index(intf)
intf_pop_list.insert(0, intf_idx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ def update_qos_interfaces(self, module):
scheduler_policy = intf['output']['scheduler-policy']['config']['name']
config_dict['scheduler_policy'] = scheduler_policy

if ('openconfig-qos-buffer:cable-length' in intf and 'config' in intf['openconfig-qos-buffer:cable-length']):
cable_length = intf['openconfig-qos-buffer:cable-length']['config']['length']
config_dict['cable_length'] = cable_length

if 'openconfig-qos-maps-ext:interface-maps' in intf and 'config' in intf['openconfig-qos-maps-ext:interface-maps']:
maps_dict = {}
maps = intf['openconfig-qos-maps-ext:interface-maps']['config']
Expand Down
14 changes: 14 additions & 0 deletions plugins/modules/sonic_qos_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@
description:
- Name of scheduler policy to be applied to traffic on the interface
type: str
cable_length:
version_added: 3.1.0
description:
ohu1 marked this conversation as resolved.
Show resolved Hide resolved
- Cable length of the interface
type: str
ohu1 marked this conversation as resolved.
Show resolved Hide resolved
choices: ['5m', '40m', '300m']
default: '40m'
qos_maps:
description:
- QoS maps interface configuration
Expand Down Expand Up @@ -182,6 +189,7 @@
- id: 0
wred_profile: profile1
scheduler_policy: policy1
cable_length: 40m
qos_maps:
dscp_fwd_group: dscp_map1
dot1p_fwd_group: dot1p_map1
Expand Down Expand Up @@ -211,6 +219,7 @@
# interface Eth1/5
# queue 0 wred-policy profile1
# scheduler-policy policy1
# cable-length 40m
# qos-map dscp-tc dscp_map1
# qos-map dot1p-tc dot1p_map1
# qos-map tc-queue fwd_queue_map1
Expand Down Expand Up @@ -238,6 +247,7 @@
# queue 0 wred-policy profile2
# queue 1 wred-policy profile1
# scheduler-policy policy2
# cable-length 5m
# qos-map dscp-tc dscp_map2
# qos-map dot1p-tc dot1p_map2
# qos-map tc-queue fwd_queue_map2
Expand All @@ -255,6 +265,7 @@
# interface Eth1/6
# queue 0 wred-policy profile1
# scheduler-policy policy1
# cable-length 40m
# qos-map dscp-tc dscp_map1
# qos-map dot1p-tc dot1p_map1
# qos-map tc-queue fwd_queue_map1
Expand All @@ -277,6 +288,7 @@
wred_profile: profile2
- id: 1
scheduler_policy: policy2
cable_length: 5m
qos_maps:
dscp_fwd_group: dscp_map2
dot1p_fwd_group: dot1p_map2
Expand All @@ -303,6 +315,7 @@
# sonic# show running-configuration interface Eth 1/5
# !
# interface Eth1/5
# cable-length 40m
stalabi1 marked this conversation as resolved.
Show resolved Hide resolved
# qos-map pfc-priority-queue pfc_queue_map1
# qos-map pfc-priority-pg pfc_pg_map1
# priority-flow-control priority 1
Expand All @@ -314,6 +327,7 @@
# interface Eth1/6
# queue 0 wred-policy profile1
# scheduler-policy policy1
# cable-length 40m
# qos-map dscp-tc dscp_map1
# qos-map dot1p-tc dot1p_map1
# qos-map tc-queue fwd_queue_map1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ tests:
- id: 0
wred_profile: profile1
scheduler_policy: policy1
cable_length: 40m
qos_maps:
dscp_fwd_group: dscp_map1
dot1p_fwd_group: dot1p_map1
Expand Down Expand Up @@ -43,6 +44,7 @@ tests:
- id: 1
wred_profile: profile1
scheduler_policy: policy2
cable_length: 5m
qos_maps:
dscp_fwd_group: dscp_map2
dot1p_fwd_group: dot1p_map2
Expand All @@ -60,6 +62,7 @@ tests:
- id: 0
wred_profile: profile1
scheduler_policy: policy1
cable_length: 40m
qos_maps:
dscp_fwd_group: dscp_map1
dot1p_fwd_group: dot1p_map1
Expand Down Expand Up @@ -105,6 +108,7 @@ tests:
wred_profile: profile2
- id: 1
scheduler_policy: policy2
cable_length: 5m
qos_maps:
dscp_fwd_group: dscp_map2
dot1p_fwd_group: dot1p_map2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@
config: []
state: deleted
ignore_errors: yes

- name: No Buffer Init
sonic_qos_buffer:
config:
buffer_init: false
ignore_errors: yes
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
- name: Buffer Init
sonic_qos_buffer:
config:
buffer_init: true

- name: Delete QoS interfaces configuration
sonic_qos_interfaces:
config: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ merged_01:
- id: 1
wred_profile: profile2
scheduler_policy: policy1
cable_length: 5m
qos_maps:
dscp_fwd_group: dscp_map1
dot1p_fwd_group: dot1p_map1
Expand Down Expand Up @@ -45,6 +46,9 @@ merged_01:
scheduler-policy:
config:
name: policy1
openconfig-qos-buffer:cable-length:
config:
length: 5m
pfc:
config:
asymmetric: true
Expand Down Expand Up @@ -96,6 +100,7 @@ deleted_01:
wred_profile: profile1
- id: 1
scheduler_policy: policy1
cable_length: 5m
qos_maps:
dscp_fwd_group: dscp_map1
dot1p_fwd_group: dot1p_map1
Expand Down Expand Up @@ -151,6 +156,9 @@ deleted_01:
pfc-priority-to-queue: pfc_queue_map1
forwarding-group-to-priority-group: fwd_pg_map1
pfc-priority-to-priority-group: pfc_pg_map1
openconfig-qos-buffer:cable-length:
config:
length: 5m
- path: '/data/openconfig-qos:qos/queues/queue'
response:
code: 200
Expand Down Expand Up @@ -217,3 +225,6 @@ deleted_01:
- path: '/data/openconfig-qos:qos/interfaces/interface=Eth1%2f5/pfc/pfc-priorities/pfc-priority=0/config/enable'
method: 'delete'
data:
- path: '/data/openconfig-qos:qos/interfaces/interface=Eth1%2f5/openconfig-qos-buffer:cable-length'
method: 'delete'
data:
Loading