diff --git a/config/plugins/barefoot.py b/config/plugins/barefoot.py deleted file mode 100644 index 088ee8e928..0000000000 --- a/config/plugins/barefoot.py +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env python - -import click -import json -import subprocess -from sonic_py_common import device_info -from swsscommon.swsscommon import ConfigDBConnector - -def abort_if_false(ctx, param, value): - if not value: - ctx.abort() - -@click.group() -def barefoot(): - pass - -@barefoot.command() -@click.option('-y', '--yes', is_flag=True, callback=abort_if_false, - expose_value=False, prompt='Swss service will be restarted, continue?') -@click.argument('profile') -def profile(profile): - # Check if profile can be changed - completed_process = subprocess.run(['docker', 'exec', '-it', 'syncd', - 'test', '-h', '/opt/bfn/install']) - if completed_process.returncode != 0: - click.echo('Cannot change profile: default one is in use') - raise click.Abort() - - # Get chip family - hwsku_dir = device_info.get_path_to_hwsku_dir() - with open(hwsku_dir + '/switch-tna-sai.conf') as file: - chip_family = json.load(file)['chip_list'][0]['chip_family'].lower() - - # Check if profile is supported - if chip_family == 'tofino' and profile[0] == 'y' or \ - chip_family == 'tofino2' and profile[0] == 'x': - click.echo('Specified profile is unsupported on the system') - raise click.Abort() - - # Check if profile exists - completed_process = subprocess.run(['docker', 'exec', '-it', 'syncd', - 'test', '-d', '/opt/bfn/install_' + profile + '_profile']) - if completed_process.returncode != 0: - click.echo('No profile with the provided name found') - raise click.Abort() - - # Update configuration - config_db = ConfigDBConnector() - config_db.connect() - config_db.mod_entry('DEVICE_METADATA', 'localhost', - {'p4_profile': profile + '_profile'}) - subprocess.run(['systemctl', 'restart', 'swss'], check=True) - -def register(cli): - version_info = device_info.get_sonic_version_info() - if version_info and version_info.get('asic_type') == 'barefoot': - cli.commands['platform'].add_command(barefoot) diff --git a/doc/Command-Reference.md b/doc/Command-Reference.md index 294695a72d..8970098452 100644 --- a/doc/Command-Reference.md +++ b/doc/Command-Reference.md @@ -119,8 +119,6 @@ * [Platform Component Firmware config commands](#platform-component-firmware-config-commands) * [Platform Component Firmware vendor specific behaviour](#platform-component-firmware-vendor-specific-behaviour) * [Platform Specific Commands](#platform-specific-commands) - * [Mellanox Platform Specific Commands](#mellanox-platform-specific-commands) - * [Barefoot Platform Specific Commands](#barefoot-platform-specific-commands) * [PortChannels](#portchannels) * [PortChannel Show commands](#portchannel-show-commands) * [PortChannel Config commands](#portchannel-config-commands) @@ -6585,8 +6583,6 @@ Go Back To [Beginning of the document](#) or [Beginning of this section](#platfo ## Platform Specific Commands -### Mellanox Platform Specific Commands - There are few commands that are platform specific. Mellanox has used this feature and implemented Mellanox specific commands as follows. **show platform mlnx sniffer** @@ -6656,41 +6652,6 @@ In order to avoid that confirmation the -y / --yes option should be used. NOTE: In order to avoid that confirmation the -y / --yes option should be used. ``` -### Barefoot Platform Specific Commands - -**show platform barefoot profile** - -This command displays active P4 profile and lists available ones. - -- Usage: - ``` - show platform barefoot profile - ``` - -- Example: - ``` - admin@sonic:~$ show platform barefoot profile - Current profile: x1 - Available profile(s): - x1 - x2 - ``` - -**config platform barefoot profile** - -This command sets P4 profile. - -- Usage: - ``` - config platform barefoot profile [-y|--yes] - ``` - -- Example: - ``` - admin@sonic:~$ sudo config platform barefoot profile x1 - Swss service will be restarted, continue? [y/N]: y - ``` - Go Back To [Beginning of the document](#) or [Beginning of this section](#platform-specific-commands) diff --git a/generic_config_updater/gu_common.py b/generic_config_updater/gu_common.py index c824407564..6ed9699f26 100644 --- a/generic_config_updater/gu_common.py +++ b/generic_config_updater/gu_common.py @@ -423,6 +423,7 @@ def _find_leafref_paths(self, path, config): ref_paths.append(ref_path) ref_paths_set.add(ref_path) + ref_paths.sort() return ref_paths def _get_inner_leaf_xpaths(self, xpath, sy): diff --git a/show/plugins/barefoot.py b/show/plugins/barefoot.py deleted file mode 100644 index bc80c47ba3..0000000000 --- a/show/plugins/barefoot.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env python - -import click -import json -import subprocess -from sonic_py_common import device_info - -@click.group() -def barefoot(): - pass - -@barefoot.command() -def profile(): - # Check if profile can be changed - completed_process = subprocess.run(['docker', 'exec', '-it', 'syncd', - 'test', '-h', '/opt/bfn/install']) - if completed_process.returncode != 0: - click.echo('Current profile: default') - return - - # Get chip family - hwsku_dir = device_info.get_path_to_hwsku_dir() - with open(hwsku_dir + '/switch-tna-sai.conf') as file: - chip_family = json.load(file)['chip_list'][0]['chip_family'].lower() - - # Print current profile - click.echo('Current profile: ', nl=False) - subprocess.run('docker exec -it syncd readlink /opt/bfn/install | sed ' - r's/install_\\\(.\*\\\)_profile/\\1/', check=True, shell=True) - - # Exclude current and unsupported profiles - opts = '' - if chip_family == 'tofino': - opts = r'\! -name install_y\*_profile ' - elif chip_family == 'tofino2': - opts = r'\! -name install_x\*_profile ' - - # Print profile list - click.echo('Available profile(s):') - subprocess.run('docker exec -it syncd find /opt/bfn -mindepth 1 ' - r'-maxdepth 1 -type d -name install_\*_profile ' + opts + '| sed ' - r's%/opt/bfn/install_\\\(.\*\\\)_profile%\\1%', shell=True) - -def register(cli): - version_info = device_info.get_sonic_version_info() - if version_info and version_info.get('asic_type') == 'barefoot': - cli.commands['platform'].add_command(barefoot) diff --git a/tests/generic_config_updater/gu_common_test.py b/tests/generic_config_updater/gu_common_test.py index dbc93fcf07..ff3b504dfb 100644 --- a/tests/generic_config_updater/gu_common_test.py +++ b/tests/generic_config_updater/gu_common_test.py @@ -639,13 +639,13 @@ def test_find_ref_paths__path_is_table__returns_ref_paths(self): # Arrange path = "/PORT" expected = [ - "/ACL_TABLE/NO-NSW-PACL-V4/ports/0", - "/VLAN_MEMBER/Vlan1000|Ethernet0", "/ACL_TABLE/DATAACL/ports/0", - "/ACL_TABLE/EVERFLOWV6/ports/0", - "/VLAN_MEMBER/Vlan1000|Ethernet4", "/ACL_TABLE/EVERFLOW/ports/0", + "/ACL_TABLE/EVERFLOWV6/ports/0", "/ACL_TABLE/EVERFLOWV6/ports/1", + "/ACL_TABLE/NO-NSW-PACL-V4/ports/0", + "/VLAN_MEMBER/Vlan1000|Ethernet0", + "/VLAN_MEMBER/Vlan1000|Ethernet4", "/VLAN_MEMBER/Vlan1000|Ethernet8" ] @@ -659,14 +659,14 @@ def test_find_ref_paths__whole_config_path__returns_all_refs(self): # Arrange path = "" expected = [ - "/VLAN_MEMBER/Vlan1000|Ethernet0", - "/VLAN_MEMBER/Vlan1000|Ethernet4", - "/VLAN_MEMBER/Vlan1000|Ethernet8", - "/ACL_TABLE/NO-NSW-PACL-V4/ports/0", "/ACL_TABLE/DATAACL/ports/0", - "/ACL_TABLE/EVERFLOWV6/ports/0", "/ACL_TABLE/EVERFLOW/ports/0", + "/ACL_TABLE/EVERFLOWV6/ports/0", "/ACL_TABLE/EVERFLOWV6/ports/1", + "/ACL_TABLE/NO-NSW-PACL-V4/ports/0", + "/VLAN_MEMBER/Vlan1000|Ethernet0", + "/VLAN_MEMBER/Vlan1000|Ethernet4", + "/VLAN_MEMBER/Vlan1000|Ethernet8", ] # Act