From 4bc12481f4461df4ff518dd19b9dc4b9746ddc7b Mon Sep 17 00:00:00 2001 From: ohu1 Date: Thu, 22 Aug 2024 15:52:04 -0500 Subject: [PATCH 01/20] cable length support --- .../sonic/argspec/qos_interfaces/qos_interfaces.py | 3 ++- .../sonic/config/qos_interfaces/qos_interfaces.py | 11 ++++++++++- .../sonic/facts/qos_interfaces/qos_interfaces.py | 4 ++++ plugins/modules/sonic_qos_interfaces.py | 10 ++++++++++ .../roles/sonic_qos_interfaces/defaults/main.yml | 4 ++++ 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/plugins/module_utils/network/sonic/argspec/qos_interfaces/qos_interfaces.py b/plugins/module_utils/network/sonic/argspec/qos_interfaces/qos_interfaces.py index 7dbb043bb..0a53b78d1 100644 --- a/plugins/module_utils/network/sonic/argspec/qos_interfaces/qos_interfaces.py +++ b/plugins/module_utils/network/sonic/argspec/qos_interfaces/qos_interfaces.py @@ -79,7 +79,8 @@ def __init__(self, **kwargs): }, 'type': 'list' }, - 'scheduler_policy': {'type': 'str'} + 'scheduler_policy': {'type': 'str'}, + 'cable_length': {'type': 'str'} }, 'type': 'list' }, diff --git a/plugins/module_utils/network/sonic/config/qos_interfaces/qos_interfaces.py b/plugins/module_utils/network/sonic/config/qos_interfaces/qos_interfaces.py index 1d60b22e0..c542da280 100644 --- a/plugins/module_utils/network/sonic/config/qos_interfaces/qos_interfaces.py +++ b/plugins/module_utils/network/sonic/config/qos_interfaces/qos_interfaces.py @@ -248,6 +248,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') @@ -256,6 +257,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['cable-length'] = {'config': {'length': cable_length}} if qos_maps: map_dict = {} dscp_fwd_group = qos_maps.get('dscp_fwd_group') @@ -363,6 +366,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') @@ -372,6 +376,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') @@ -380,6 +385,10 @@ 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}) + if cable_length and cable_length == cfg_cable_length: + url = '%s/interface=%s/cable-length' % (QOS_INTF_PATH, name) + requests.append({'path': url, 'method': DELETE}) + if qos_maps and cfg_qos_maps: maps_dict = {} dscp_fwd_group = qos_maps.get('dscp_fwd_group') @@ -507,7 +516,7 @@ def get_delete_qos_interfaces_requests(self, commands, have, is_delete_all): config_dict['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 diff --git a/plugins/module_utils/network/sonic/facts/qos_interfaces/qos_interfaces.py b/plugins/module_utils/network/sonic/facts/qos_interfaces/qos_interfaces.py index b1645c19d..6cbbffd47 100644 --- a/plugins/module_utils/network/sonic/facts/qos_interfaces/qos_interfaces.py +++ b/plugins/module_utils/network/sonic/facts/qos_interfaces/qos_interfaces.py @@ -84,6 +84,10 @@ def update_qos_interfaces(self, module): scheduler_policy = intf['output']['scheduler-policy']['config']['name'] config_dict['scheduler_policy'] = scheduler_policy + if ('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'] diff --git a/plugins/modules/sonic_qos_interfaces.py b/plugins/modules/sonic_qos_interfaces.py index 33329ac5a..bcde3517a 100644 --- a/plugins/modules/sonic_qos_interfaces.py +++ b/plugins/modules/sonic_qos_interfaces.py @@ -72,6 +72,10 @@ description: - Name of scheduler policy to be applied to traffic on the interface type: str + cable_length: + description: + - Cable Length of the interface + type: str qos_maps: description: - QoS maps interface configuration @@ -182,6 +186,7 @@ - id: 0 wred_profile: profile1 scheduler_policy: policy1 + cable_length: 40m qos_maps: dscp_fwd_group: dscp_map1 dot1p_fwd_group: dot1p_map1 @@ -211,6 +216,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 @@ -238,6 +244,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 @@ -255,6 +262,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 @@ -277,6 +285,7 @@ wred_profile: profile2 - id: 1 scheduler_policy: policy2 + cable_length: 5m qos_maps: dscp_fwd_group: dscp_map2 dot1p_fwd_group: dot1p_map2 @@ -314,6 +323,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 diff --git a/tests/regression/roles/sonic_qos_interfaces/defaults/main.yml b/tests/regression/roles/sonic_qos_interfaces/defaults/main.yml index 5271784ae..66a6fbd92 100644 --- a/tests/regression/roles/sonic_qos_interfaces/defaults/main.yml +++ b/tests/regression/roles/sonic_qos_interfaces/defaults/main.yml @@ -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 @@ -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 @@ -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 @@ -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 From a6cb1c37f48607fa320482e06bef2fe8d82a8f77 Mon Sep 17 00:00:00 2001 From: ohu1 Date: Fri, 11 Oct 2024 16:10:13 -0500 Subject: [PATCH 02/20] more for cable length change --- changelogs/fragments/468-cable-length.yaml | 2 ++ .../roles/sonic_qos_interfaces/tasks/cleanup_tests.yaml | 7 +++++++ .../sonic_qos_interfaces/tasks/preparation_tests.yaml | 5 +++++ 3 files changed, 14 insertions(+) create mode 100644 changelogs/fragments/468-cable-length.yaml diff --git a/changelogs/fragments/468-cable-length.yaml b/changelogs/fragments/468-cable-length.yaml new file mode 100644 index 000000000..9e92fbd54 --- /dev/null +++ b/changelogs/fragments/468-cable-length.yaml @@ -0,0 +1,2 @@ +minor_changes: + - sonic_qos_interfaces - add Cable Length feature Ansible test (https://github.com/ansible-collections/dellemc.enterprise_sonic/pull/468). diff --git a/tests/regression/roles/sonic_qos_interfaces/tasks/cleanup_tests.yaml b/tests/regression/roles/sonic_qos_interfaces/tasks/cleanup_tests.yaml index 9ffcb333b..0e95b1618 100644 --- a/tests/regression/roles/sonic_qos_interfaces/tasks/cleanup_tests.yaml +++ b/tests/regression/roles/sonic_qos_interfaces/tasks/cleanup_tests.yaml @@ -15,3 +15,10 @@ config: [] state: deleted ignore_errors: yes + +- name: No Buffer Init + sonic_qos_buffer: + config: + buffer_init: false + ignore_errors: yes + diff --git a/tests/regression/roles/sonic_qos_interfaces/tasks/preparation_tests.yaml b/tests/regression/roles/sonic_qos_interfaces/tasks/preparation_tests.yaml index 6cb82e73f..ca4fd6ba6 100644 --- a/tests/regression/roles/sonic_qos_interfaces/tasks/preparation_tests.yaml +++ b/tests/regression/roles/sonic_qos_interfaces/tasks/preparation_tests.yaml @@ -1,3 +1,8 @@ +- name: Buffer Init + sonic_qos_buffer: + config: + buffer_init: true + - name: Delete QoS interfaces configuration sonic_qos_interfaces: config: [] From 1ea63da5f5ed67ac3fb8bdd6a32885dac82a593e Mon Sep 17 00:00:00 2001 From: ohu1 Date: Mon, 14 Oct 2024 14:40:41 -0500 Subject: [PATCH 03/20] fix sanity failure --- plugins/modules/sonic_qos_interfaces.py | 8 ++++---- .../roles/sonic_qos_interfaces/tasks/cleanup_tests.yaml | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/plugins/modules/sonic_qos_interfaces.py b/plugins/modules/sonic_qos_interfaces.py index bcde3517a..65e37c9d0 100644 --- a/plugins/modules/sonic_qos_interfaces.py +++ b/plugins/modules/sonic_qos_interfaces.py @@ -186,7 +186,7 @@ - id: 0 wred_profile: profile1 scheduler_policy: policy1 - cable_length: 40m + cable_length: 40m qos_maps: dscp_fwd_group: dscp_map1 dot1p_fwd_group: dot1p_map1 @@ -244,7 +244,7 @@ # queue 0 wred-policy profile2 # queue 1 wred-policy profile1 # scheduler-policy policy2 -# cable-length 5m +# cable-length 5m # qos-map dscp-tc dscp_map2 # qos-map dot1p-tc dot1p_map2 # qos-map tc-queue fwd_queue_map2 @@ -285,7 +285,7 @@ wred_profile: profile2 - id: 1 scheduler_policy: policy2 - cable_length: 5m + cable_length: 5m qos_maps: dscp_fwd_group: dscp_map2 dot1p_fwd_group: dot1p_map2 @@ -323,7 +323,7 @@ # interface Eth1/6 # queue 0 wred-policy profile1 # scheduler-policy policy1 -# cable-length 40m +# cable-length 40m # qos-map dscp-tc dscp_map1 # qos-map dot1p-tc dot1p_map1 # qos-map tc-queue fwd_queue_map1 diff --git a/tests/regression/roles/sonic_qos_interfaces/tasks/cleanup_tests.yaml b/tests/regression/roles/sonic_qos_interfaces/tasks/cleanup_tests.yaml index 0e95b1618..4e723dac6 100644 --- a/tests/regression/roles/sonic_qos_interfaces/tasks/cleanup_tests.yaml +++ b/tests/regression/roles/sonic_qos_interfaces/tasks/cleanup_tests.yaml @@ -21,4 +21,3 @@ config: buffer_init: false ignore_errors: yes - From 2e1c185294d797648c0fc5bb42b4b2c763663332 Mon Sep 17 00:00:00 2001 From: ohu1 Date: Fri, 18 Oct 2024 11:48:43 -0500 Subject: [PATCH 04/20] unit test --- .../sonic/fixtures/sonic_qos_interfaces.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/unit/modules/network/sonic/fixtures/sonic_qos_interfaces.yaml b/tests/unit/modules/network/sonic/fixtures/sonic_qos_interfaces.yaml index 93ec86d54..1d116c4f5 100644 --- a/tests/unit/modules/network/sonic/fixtures/sonic_qos_interfaces.yaml +++ b/tests/unit/modules/network/sonic/fixtures/sonic_qos_interfaces.yaml @@ -25,6 +25,8 @@ merged_01: priorities: - dot1p: 0 enable: True + cable_length: + length: 5m existing_qos_interfaces_config: - path: '/data/openconfig-qos:qos/interfaces/interface' response: @@ -69,6 +71,9 @@ merged_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' method: 'patch' data: @@ -113,6 +118,8 @@ deleted_01: priorities: - dot1p: 0 enable: True + cable_length: + length: 40m state: deleted existing_qos_interfaces_config: - path: '/data/openconfig-qos:qos/interfaces/interface' @@ -151,6 +158,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 @@ -217,3 +227,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/config/length' + method: 'delete' + data: From f20a480020afdbcfb2e148404ae2340cde41a47f Mon Sep 17 00:00:00 2001 From: ohu1 Date: Fri, 18 Oct 2024 12:03:05 -0500 Subject: [PATCH 05/20] fix typo --- .../modules/network/sonic/fixtures/sonic_qos_interfaces.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/modules/network/sonic/fixtures/sonic_qos_interfaces.yaml b/tests/unit/modules/network/sonic/fixtures/sonic_qos_interfaces.yaml index 1d116c4f5..91631f4f5 100644 --- a/tests/unit/modules/network/sonic/fixtures/sonic_qos_interfaces.yaml +++ b/tests/unit/modules/network/sonic/fixtures/sonic_qos_interfaces.yaml @@ -158,7 +158,7 @@ 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: + openconfig-qos-buffer:cable-length: config: length: 5m - path: '/data/openconfig-qos:qos/queues/queue' From 45f5a19d8c5658032ebf4f0b664ab0b777245570 Mon Sep 17 00:00:00 2001 From: ohu1 Date: Fri, 18 Oct 2024 12:26:06 -0500 Subject: [PATCH 06/20] fix typo --- .../network/sonic/fixtures/sonic_qos_interfaces.yaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/unit/modules/network/sonic/fixtures/sonic_qos_interfaces.yaml b/tests/unit/modules/network/sonic/fixtures/sonic_qos_interfaces.yaml index 91631f4f5..a91d373d2 100644 --- a/tests/unit/modules/network/sonic/fixtures/sonic_qos_interfaces.yaml +++ b/tests/unit/modules/network/sonic/fixtures/sonic_qos_interfaces.yaml @@ -25,8 +25,7 @@ merged_01: priorities: - dot1p: 0 enable: True - cable_length: - length: 5m + cable_length: 5m existing_qos_interfaces_config: - path: '/data/openconfig-qos:qos/interfaces/interface' response: @@ -118,8 +117,7 @@ deleted_01: priorities: - dot1p: 0 enable: True - cable_length: - length: 40m + cable_length: 40m state: deleted existing_qos_interfaces_config: - path: '/data/openconfig-qos:qos/interfaces/interface' From 63337e04f3b353897e173bff19458b0a9b2512df Mon Sep 17 00:00:00 2001 From: ohu1 Date: Fri, 18 Oct 2024 12:51:54 -0500 Subject: [PATCH 07/20] fix deletion output --- plugins/modules/sonic_qos_interfaces.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/modules/sonic_qos_interfaces.py b/plugins/modules/sonic_qos_interfaces.py index 65e37c9d0..f44ca4d18 100644 --- a/plugins/modules/sonic_qos_interfaces.py +++ b/plugins/modules/sonic_qos_interfaces.py @@ -312,6 +312,7 @@ # sonic# show running-configuration interface Eth 1/5 # ! # interface Eth1/5 +# cable-length 40m # qos-map pfc-priority-queue pfc_queue_map1 # qos-map pfc-priority-pg pfc_pg_map1 # priority-flow-control priority 1 From ca875739ad39145aeaa46bb77502b5c230979539 Mon Sep 17 00:00:00 2001 From: ohu1 Date: Fri, 18 Oct 2024 12:58:05 -0500 Subject: [PATCH 08/20] fix unit test deletion --- .../network/sonic/fixtures/sonic_qos_interfaces.yaml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/unit/modules/network/sonic/fixtures/sonic_qos_interfaces.yaml b/tests/unit/modules/network/sonic/fixtures/sonic_qos_interfaces.yaml index a91d373d2..49d6d52a8 100644 --- a/tests/unit/modules/network/sonic/fixtures/sonic_qos_interfaces.yaml +++ b/tests/unit/modules/network/sonic/fixtures/sonic_qos_interfaces.yaml @@ -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 @@ -25,7 +26,6 @@ merged_01: priorities: - dot1p: 0 enable: True - cable_length: 5m existing_qos_interfaces_config: - path: '/data/openconfig-qos:qos/interfaces/interface' response: @@ -46,6 +46,9 @@ merged_01: scheduler-policy: config: name: policy1 + openconfig-qos-buffer:cable-length: + config: + length: 5m pfc: config: asymmetric: true @@ -70,9 +73,6 @@ merged_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' method: 'patch' data: @@ -117,7 +117,6 @@ deleted_01: priorities: - dot1p: 0 enable: True - cable_length: 40m state: deleted existing_qos_interfaces_config: - path: '/data/openconfig-qos:qos/interfaces/interface' From 9533ba96761117039ab7fb8f9c5db8bbeb9cdced Mon Sep 17 00:00:00 2001 From: ohu1 Date: Fri, 18 Oct 2024 15:09:38 -0500 Subject: [PATCH 09/20] add cable length in deletion --- .../modules/network/sonic/fixtures/sonic_qos_interfaces.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit/modules/network/sonic/fixtures/sonic_qos_interfaces.yaml b/tests/unit/modules/network/sonic/fixtures/sonic_qos_interfaces.yaml index 49d6d52a8..6a12aca06 100644 --- a/tests/unit/modules/network/sonic/fixtures/sonic_qos_interfaces.yaml +++ b/tests/unit/modules/network/sonic/fixtures/sonic_qos_interfaces.yaml @@ -100,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 From 4aa93fbbbac736f034588155d53e6ac6d1970d94 Mon Sep 17 00:00:00 2001 From: ohu1 Date: Fri, 18 Oct 2024 15:38:31 -0500 Subject: [PATCH 10/20] revise the deletion path --- .../network/sonic/config/qos_interfaces/qos_interfaces.py | 2 +- .../modules/network/sonic/fixtures/sonic_qos_interfaces.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/module_utils/network/sonic/config/qos_interfaces/qos_interfaces.py b/plugins/module_utils/network/sonic/config/qos_interfaces/qos_interfaces.py index 0d169cb12..97755f67b 100644 --- a/plugins/module_utils/network/sonic/config/qos_interfaces/qos_interfaces.py +++ b/plugins/module_utils/network/sonic/config/qos_interfaces/qos_interfaces.py @@ -387,7 +387,7 @@ def get_delete_qos_interfaces_requests(self, commands, have, is_delete_all): requests.append({'path': url, 'method': DELETE}) if cable_length and cable_length == cfg_cable_length: - url = '%s/interface=%s/cable-length' % (QOS_INTF_PATH, name) + url = '%s/interface=%s/openconfig-qos-buffer:cable-length' % (QOS_INTF_PATH, name) requests.append({'path': url, 'method': DELETE}) if qos_maps and cfg_qos_maps: diff --git a/tests/unit/modules/network/sonic/fixtures/sonic_qos_interfaces.yaml b/tests/unit/modules/network/sonic/fixtures/sonic_qos_interfaces.yaml index 6a12aca06..628820d87 100644 --- a/tests/unit/modules/network/sonic/fixtures/sonic_qos_interfaces.yaml +++ b/tests/unit/modules/network/sonic/fixtures/sonic_qos_interfaces.yaml @@ -225,6 +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/config/length' + - path: '/data/openconfig-qos:qos/interfaces/interface=Eth1%2f5/openconfig-qos-buffer:cable-length' method: 'delete' data: From 31d7c4612037d5e4d60044e62489bb778f5dd545 Mon Sep 17 00:00:00 2001 From: ohu1 Date: Fri, 18 Oct 2024 16:38:41 -0500 Subject: [PATCH 11/20] correct the path prefix --- .../network/sonic/config/qos_interfaces/qos_interfaces.py | 2 +- .../network/sonic/facts/qos_interfaces/qos_interfaces.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/module_utils/network/sonic/config/qos_interfaces/qos_interfaces.py b/plugins/module_utils/network/sonic/config/qos_interfaces/qos_interfaces.py index 97755f67b..b3b421fd6 100644 --- a/plugins/module_utils/network/sonic/config/qos_interfaces/qos_interfaces.py +++ b/plugins/module_utils/network/sonic/config/qos_interfaces/qos_interfaces.py @@ -259,7 +259,7 @@ def get_modify_qos_interfaces_requests(self, commands): if scheduler_policy: intf_dict['output'] = {'scheduler-policy': {'config': {'name': scheduler_policy}}} if cable_length: - intf_dict['cable-length'] = {'config': {'length': 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') diff --git a/plugins/module_utils/network/sonic/facts/qos_interfaces/qos_interfaces.py b/plugins/module_utils/network/sonic/facts/qos_interfaces/qos_interfaces.py index 0235bd752..f377e24c3 100644 --- a/plugins/module_utils/network/sonic/facts/qos_interfaces/qos_interfaces.py +++ b/plugins/module_utils/network/sonic/facts/qos_interfaces/qos_interfaces.py @@ -85,7 +85,7 @@ def update_qos_interfaces(self, module): scheduler_policy = intf['output']['scheduler-policy']['config']['name'] config_dict['scheduler_policy'] = scheduler_policy - if ('cable-length' in intf and 'config' in intf['openconfig-qos-buffer:cable-length']): + 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 From fe33d2e1c0574b89c4669b7610a811fa11cb769a Mon Sep 17 00:00:00 2001 From: ohu1 <55407253+ohu1@users.noreply.github.com> Date: Wed, 23 Oct 2024 16:35:27 -0700 Subject: [PATCH 12/20] Update changelogs/fragments/468-cable-length.yaml Co-authored-by: stalabi1 <54641848+stalabi1@users.noreply.github.com> --- changelogs/fragments/468-cable-length.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/468-cable-length.yaml b/changelogs/fragments/468-cable-length.yaml index 9e92fbd54..f92002552 100644 --- a/changelogs/fragments/468-cable-length.yaml +++ b/changelogs/fragments/468-cable-length.yaml @@ -1,2 +1,2 @@ minor_changes: - - sonic_qos_interfaces - add Cable Length feature Ansible test (https://github.com/ansible-collections/dellemc.enterprise_sonic/pull/468). + - sonic_qos_interfaces - Add 'cable_length' attribute (https://github.com/ansible-collections/dellemc.enterprise_sonic/pull/468). From cdc5dcb48d3ca2dbfea28b996630aa49f3db6441 Mon Sep 17 00:00:00 2001 From: ohu1 <55407253+ohu1@users.noreply.github.com> Date: Wed, 23 Oct 2024 16:35:44 -0700 Subject: [PATCH 13/20] Update plugins/modules/sonic_qos_interfaces.py Co-authored-by: stalabi1 <54641848+stalabi1@users.noreply.github.com> --- plugins/modules/sonic_qos_interfaces.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/sonic_qos_interfaces.py b/plugins/modules/sonic_qos_interfaces.py index f44ca4d18..44542f874 100644 --- a/plugins/modules/sonic_qos_interfaces.py +++ b/plugins/modules/sonic_qos_interfaces.py @@ -74,7 +74,7 @@ type: str cable_length: description: - - Cable Length of the interface + - Cable length of the interface type: str qos_maps: description: From 5a8896a408cf9318d941b4eeab6d6dd1d1c4e018 Mon Sep 17 00:00:00 2001 From: ohu1 <55407253+ohu1@users.noreply.github.com> Date: Wed, 23 Oct 2024 16:36:07 -0700 Subject: [PATCH 14/20] Update plugins/module_utils/network/sonic/argspec/qos_interfaces/qos_interfaces.py Co-authored-by: stalabi1 <54641848+stalabi1@users.noreply.github.com> --- .../network/sonic/argspec/qos_interfaces/qos_interfaces.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/module_utils/network/sonic/argspec/qos_interfaces/qos_interfaces.py b/plugins/module_utils/network/sonic/argspec/qos_interfaces/qos_interfaces.py index 0a53b78d1..bfd22b239 100644 --- a/plugins/module_utils/network/sonic/argspec/qos_interfaces/qos_interfaces.py +++ b/plugins/module_utils/network/sonic/argspec/qos_interfaces/qos_interfaces.py @@ -80,7 +80,7 @@ def __init__(self, **kwargs): 'type': 'list' }, 'scheduler_policy': {'type': 'str'}, - 'cable_length': {'type': 'str'} + 'cable_length': {'choices': ['5m', '40m', '300m'], 'type': 'str'} }, 'type': 'list' }, From a0c8c48456bbba5dbe4dd338c080cf80db9baa8c Mon Sep 17 00:00:00 2001 From: ohu1 <55407253+ohu1@users.noreply.github.com> Date: Wed, 23 Oct 2024 16:36:23 -0700 Subject: [PATCH 15/20] Update plugins/modules/sonic_qos_interfaces.py Co-authored-by: stalabi1 <54641848+stalabi1@users.noreply.github.com> --- plugins/modules/sonic_qos_interfaces.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/modules/sonic_qos_interfaces.py b/plugins/modules/sonic_qos_interfaces.py index 44542f874..7c543eed5 100644 --- a/plugins/modules/sonic_qos_interfaces.py +++ b/plugins/modules/sonic_qos_interfaces.py @@ -76,6 +76,7 @@ description: - Cable length of the interface type: str + choices: ['5m', '40m', '300m'] qos_maps: description: - QoS maps interface configuration From a2f685c3f06342050c2b6a617c3da05fef78b0f3 Mon Sep 17 00:00:00 2001 From: ohu1 <55407253+ohu1@users.noreply.github.com> Date: Wed, 23 Oct 2024 16:38:21 -0700 Subject: [PATCH 16/20] Update plugins/modules/sonic_qos_interfaces.py Co-authored-by: stalabi1 <54641848+stalabi1@users.noreply.github.com> --- plugins/modules/sonic_qos_interfaces.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/modules/sonic_qos_interfaces.py b/plugins/modules/sonic_qos_interfaces.py index 7c543eed5..87f1ffe61 100644 --- a/plugins/modules/sonic_qos_interfaces.py +++ b/plugins/modules/sonic_qos_interfaces.py @@ -73,6 +73,7 @@ - Name of scheduler policy to be applied to traffic on the interface type: str cable_length: + version_added: 3.1.0 description: - Cable length of the interface type: str From 6e613e77925ceb3238dd4bcf816eefa5395d1372 Mon Sep 17 00:00:00 2001 From: ohu1 Date: Fri, 8 Nov 2024 13:01:25 -0600 Subject: [PATCH 17/20] add default value --- .../network/sonic/argspec/qos_interfaces/qos_interfaces.py | 2 +- .../network/sonic/config/qos_interfaces/qos_interfaces.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/module_utils/network/sonic/argspec/qos_interfaces/qos_interfaces.py b/plugins/module_utils/network/sonic/argspec/qos_interfaces/qos_interfaces.py index bfd22b239..36f8aad56 100644 --- a/plugins/module_utils/network/sonic/argspec/qos_interfaces/qos_interfaces.py +++ b/plugins/module_utils/network/sonic/argspec/qos_interfaces/qos_interfaces.py @@ -80,7 +80,7 @@ def __init__(self, **kwargs): 'type': 'list' }, 'scheduler_policy': {'type': 'str'}, - 'cable_length': {'choices': ['5m', '40m', '300m'], 'type': 'str'} + 'cable_length': {'choices': ['5m', '40m', '300m'], 'default': '40m', 'type': 'str'} }, 'type': 'list' }, diff --git a/plugins/module_utils/network/sonic/config/qos_interfaces/qos_interfaces.py b/plugins/module_utils/network/sonic/config/qos_interfaces/qos_interfaces.py index b3b421fd6..16f9a0a6c 100644 --- a/plugins/module_utils/network/sonic/config/qos_interfaces/qos_interfaces.py +++ b/plugins/module_utils/network/sonic/config/qos_interfaces/qos_interfaces.py @@ -565,6 +565,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) From d3a1a13bd8e3fceb06c3773abbed70f70e3c9840 Mon Sep 17 00:00:00 2001 From: ohu1 Date: Fri, 8 Nov 2024 14:24:44 -0600 Subject: [PATCH 18/20] add default 40m --- plugins/modules/sonic_qos_interfaces.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/modules/sonic_qos_interfaces.py b/plugins/modules/sonic_qos_interfaces.py index 87f1ffe61..c66c28995 100644 --- a/plugins/modules/sonic_qos_interfaces.py +++ b/plugins/modules/sonic_qos_interfaces.py @@ -78,6 +78,7 @@ - Cable length of the interface type: str choices: ['5m', '40m', '300m'] + default: '40m' qos_maps: description: - QoS maps interface configuration From eb8e29f389c175f85a7cb5755ce01b30f196b5d5 Mon Sep 17 00:00:00 2001 From: ohu1 Date: Fri, 8 Nov 2024 14:35:20 -0600 Subject: [PATCH 19/20] fix whitespace --- .../network/sonic/config/qos_interfaces/qos_interfaces.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/module_utils/network/sonic/config/qos_interfaces/qos_interfaces.py b/plugins/module_utils/network/sonic/config/qos_interfaces/qos_interfaces.py index b914978e8..1b6d9e9a9 100644 --- a/plugins/module_utils/network/sonic/config/qos_interfaces/qos_interfaces.py +++ b/plugins/module_utils/network/sonic/config/qos_interfaces/qos_interfaces.py @@ -570,7 +570,7 @@ def remove_default_entries(self, data): 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) From 2c993de3c18aebe4680914af00ef1d7f5966208c Mon Sep 17 00:00:00 2001 From: ohu1 Date: Fri, 8 Nov 2024 16:26:00 -0600 Subject: [PATCH 20/20] fix the deletion op for cable length --- .../network/sonic/config/qos_interfaces/qos_interfaces.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/module_utils/network/sonic/config/qos_interfaces/qos_interfaces.py b/plugins/module_utils/network/sonic/config/qos_interfaces/qos_interfaces.py index 1b6d9e9a9..a56a965c6 100644 --- a/plugins/module_utils/network/sonic/config/qos_interfaces/qos_interfaces.py +++ b/plugins/module_utils/network/sonic/config/qos_interfaces/qos_interfaces.py @@ -390,6 +390,7 @@ def get_delete_qos_interfaces_requests(self, commands, have, is_delete_all): 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 = {}