diff --git a/.github/codeql/codeql-config.yml b/.github/codeql/codeql-config.yml new file mode 100644 index 0000000000..2c8b0498f3 --- /dev/null +++ b/.github/codeql/codeql-config.yml @@ -0,0 +1,4 @@ +name: "CodeQL config" +queries: + - uses: security-and-quality + - uses: security-extended diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000000..6478fb99f7 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,43 @@ +# For more infomation, please visit: https://github.com/github/codeql-action + +name: "CodeQL" + +on: + push: + branches: + - 'master' + - '202[0-9][0-9][0-9]' + pull_request_target: + branches: + - 'master' + - '202[0-9][0-9][0-9]' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'python' ] + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + config-file: ./.github/codeql/codeql-config.yml + languages: ${{ matrix.language }} + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}" diff --git a/.github/workflows/semgrep.yml b/.github/workflows/semgrep.yml new file mode 100644 index 0000000000..8ebe082f50 --- /dev/null +++ b/.github/workflows/semgrep.yml @@ -0,0 +1,21 @@ +name: Semgrep + +on: + pull_request: {} + push: + branches: + - master + - '201[7-9][0-1][0-9]' + - '202[0-9][0-1][0-9]' + +jobs: + semgrep: + name: Semgrep + runs-on: ubuntu-latest + container: + image: returntocorp/semgrep + steps: + - uses: actions/checkout@v3 + - run: semgrep ci + env: + SEMGREP_RULES: p/default diff --git a/acl_loader/main.py b/acl_loader/main.py index ada7162154..dedaf0eb3e 100644 --- a/acl_loader/main.py +++ b/acl_loader/main.py @@ -4,6 +4,7 @@ import ipaddress import json import syslog +import operator import openconfig_acl import tabulate @@ -758,7 +759,7 @@ def incremental_update(self): namespace_configdb.mod_entry(self.ACL_RULE, key, None) for key in existing_controlplane_rules: - if cmp(self.rules_info[key], self.rules_db_info[key]) != 0: + if not operator.eq(self.rules_info[key], self.rules_db_info[key]): self.configdb.set_entry(self.ACL_RULE, key, self.rules_info[key]) # Program for per-asic namespace corresponding to front asic also if present. # For control plane ACL it's not needed but to keep all db in sync program everywhere diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 202bba1d5b..8fc73203d1 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -10,8 +10,8 @@ resources: repositories: - repository: sonic-swss type: github - name: Azure/sonic-swss - endpoint: build + name: sonic-net/sonic-swss + endpoint: sonic-net stages: - stage: Build @@ -26,7 +26,7 @@ stages: vmImage: ubuntu-20.04 container: - image: sonicdev-microsoft.azurecr.io:443/sonic-slave-buster:latest + image: sonicdev-microsoft.azurecr.io:443/sonic-slave-bullseye:latest steps: - script: | @@ -58,7 +58,7 @@ stages: sudo dpkg -i libyang_1.0.73_amd64.deb sudo dpkg -i libyang-cpp_1.0.73_amd64.deb sudo dpkg -i python3-yang_1.0.73_amd64.deb - workingDirectory: $(Pipeline.Workspace)/target/debs/buster/ + workingDirectory: $(Pipeline.Workspace)/target/debs/bullseye/ displayName: 'Install Debian dependencies' - task: DownloadPipelineArtifact@2 @@ -66,7 +66,7 @@ stages: source: specific project: build pipeline: 9 - artifact: sonic-swss-common + artifact: sonic-swss-common.bullseye.amd64 runVersion: 'latestFromBranch' runBranch: 'refs/heads/master' displayName: "Download sonic swss common deb packages" @@ -86,14 +86,14 @@ stages: sudo pip3 install sonic_yang_models-1.0-py3-none-any.whl sudo pip3 install sonic_config_engine-1.0-py3-none-any.whl sudo pip3 install sonic_platform_common-1.0-py3-none-any.whl - workingDirectory: $(Pipeline.Workspace)/target/python-wheels/buster/ + workingDirectory: $(Pipeline.Workspace)/target/python-wheels/bullseye/ displayName: 'Install Python dependencies' - script: | set -ex # Install .NET CORE curl -sSL https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - - sudo apt-add-repository https://packages.microsoft.com/debian/10/prod + sudo apt-add-repository https://packages.microsoft.com/debian/11/prod sudo apt-get update sudo apt-get install -y dotnet-sdk-5.0 displayName: "Install .NET CORE" diff --git a/config/kube.py b/config/kube.py index a2dbeeffb6..706a5ab260 100644 --- a/config/kube.py +++ b/config/kube.py @@ -25,7 +25,7 @@ def _update_kube_server(db, field, val): def_data = { KUBE_SERVER_IP: "", KUBE_SERVER_PORT: "6443", - KUBE_SERVER_INSECURE: "False", + KUBE_SERVER_INSECURE: "True", KUBE_SERVER_DISABLE: "False" } for f in def_data: diff --git a/config/main.py b/config/main.py index f6ad1aa041..1f22b8f216 100644 --- a/config/main.py +++ b/config/main.py @@ -12,6 +12,7 @@ import sys import time import itertools +import copy from collections import OrderedDict from generic_config_updater.generic_updater import GenericUpdater, ConfigFormat @@ -43,7 +44,7 @@ from . import vlan from . import vxlan from . import plugins -from .config_mgmt import ConfigMgmtDPB +from .config_mgmt import ConfigMgmtDPB, ConfigMgmt from . import mclag # mock masic APIs for unit test @@ -365,6 +366,19 @@ def get_interface_ipaddresses(config_db, interface_name): return ipaddresses +def is_vrf_exists(config_db, vrf_name): + """Check if VRF exists + """ + keys = config_db.get_keys("VRF") + if vrf_name in keys: + return True + elif vrf_name == "mgmt": + entry = config_db.get_entry("MGMT_VRF_CONFIG", "vrf_global") + if entry and entry.get("mgmtVrfEnabled") == "true": + return True + + return False + def is_interface_bind_to_vrf(config_db, interface_name): """Get interface if bind to vrf or not """ @@ -638,7 +652,24 @@ def _clear_cbf(): config_db.delete_table(cbf_table) -def _clear_qos(): +def _wait_until_clear(table, interval=0.5, timeout=30): + start = time.time() + empty = False + app_db = SonicV2Connector(host='127.0.0.1') + app_db.connect(app_db.APPL_DB) + + while not empty and time.time() - start < timeout: + current_profiles = app_db.keys(app_db.APPL_DB, table) + if not current_profiles: + empty = True + else: + time.sleep(interval) + if not empty: + click.echo("Operation not completed successfully, please save and reload configuration.") + return empty + + +def _clear_qos(delay = False): QOS_TABLE_NAMES = [ 'PORT_QOS_MAP', 'QUEUE', @@ -674,6 +705,8 @@ def _clear_qos(): config_db.connect() for qos_table in QOS_TABLE_NAMES: config_db.delete_table(qos_table) + if delay: + _wait_until_clear("BUFFER_POOL_TABLE:*",interval=0.5, timeout=30) def _get_sonic_generated_services(num_asic): if not os.path.isfile(SONIC_GENERATED_SERVICE_PATH): @@ -734,24 +767,27 @@ def _stop_services(): def _get_sonic_services(): - out = clicommon.run_command("systemctl list-dependencies --plain sonic.target | sed '1d'", return_cmd=True) + out, _ = clicommon.run_command("systemctl list-dependencies --plain sonic.target | sed '1d'", return_cmd=True) return (unit.strip() for unit in out.splitlines()) -def _get_delayed_sonic_services(): - rc1 = clicommon.run_command("systemctl list-dependencies --plain sonic-delayed.target | sed '1d'", return_cmd=True) - rc2 = clicommon.run_command("systemctl is-enabled {}".format(rc1.replace("\n", " ")), return_cmd=True) +def _get_delayed_sonic_units(get_timers=False): + rc1, _ = clicommon.run_command("systemctl list-dependencies --plain sonic-delayed.target | sed '1d'", return_cmd=True) + rc2, _ = clicommon.run_command("systemctl is-enabled {}".format(rc1.replace("\n", " ")), return_cmd=True) timer = [line.strip() for line in rc1.splitlines()] state = [line.strip() for line in rc2.splitlines()] services = [] for unit in timer: if state[timer.index(unit)] == "enabled": - services.append(unit.rstrip(".timer")) + if not get_timers: + services.append(re.sub('\.timer$', '', unit, 1)) + else: + services.append(unit) return services def _reset_failed_services(): - for service in itertools.chain(_get_sonic_services(), _get_delayed_sonic_services()): + for service in itertools.chain(_get_sonic_services(), _get_delayed_sonic_units()): clicommon.run_command("systemctl reset-failed {}".format(service)) @@ -770,22 +806,18 @@ def _restart_services(): click.echo("Reloading Monit configuration ...") clicommon.run_command("sudo monit reload") -def _get_delay_timers(): - out = clicommon.run_command("systemctl list-dependencies sonic-delayed.target --plain |sed '1d'", return_cmd=True) - return [timer.strip() for timer in out.splitlines()] - def _delay_timers_elapsed(): - for timer in _get_delay_timers(): - out = clicommon.run_command("systemctl show {} --property=LastTriggerUSecMonotonic --value".format(timer), return_cmd=True) + for timer in _get_delayed_sonic_units(get_timers=True): + out, _ = clicommon.run_command("systemctl show {} --property=LastTriggerUSecMonotonic --value".format(timer), return_cmd=True) if out.strip() == "0": return False return True def _per_namespace_swss_ready(service_name): - out = clicommon.run_command("systemctl show {} --property ActiveState --value".format(service_name), return_cmd=True) + out, _ = clicommon.run_command("systemctl show {} --property ActiveState --value".format(service_name), return_cmd=True) if out.strip() != "active": return False - out = clicommon.run_command("systemctl show {} --property ActiveEnterTimestampMonotonic --value".format(service_name), return_cmd=True) + out, _ = clicommon.run_command("systemctl show {} --property ActiveEnterTimestampMonotonic --value".format(service_name), return_cmd=True) swss_up_time = float(out.strip())/1000000 now = time.monotonic() if (now - swss_up_time > 120): @@ -810,7 +842,7 @@ def _swss_ready(): return True def _is_system_starting(): - out = clicommon.run_command("sudo systemctl is-system-running", return_cmd=True) + out, _ = clicommon.run_command("sudo systemctl is-system-running", return_cmd=True) return out.strip() == "starting" def interface_is_in_vlan(vlan_member_table, interface_name): @@ -911,6 +943,7 @@ def cli_sroute_to_config(ctx, command_str, strict_nh = True): nexthop_str = None config_entry = {} vrf_name = "" + config_db = ctx.obj['config_db'] if "nexthop" in command_str: idx = command_str.index("nexthop") @@ -923,10 +956,13 @@ def cli_sroute_to_config(ctx, command_str, strict_nh = True): if 'prefix' in prefix_str and 'vrf' in prefix_str: # prefix_str: ['prefix', 'vrf', Vrf-name, ip] vrf_name = prefix_str[2] + if not is_vrf_exists(config_db, vrf_name): + ctx.fail("VRF %s does not exist!"%(vrf_name)) ip_prefix = prefix_str[3] elif 'prefix' in prefix_str: # prefix_str: ['prefix', ip] ip_prefix = prefix_str[1] + vrf_name = "default" else: ctx.fail("prefix is not in pattern!") @@ -934,6 +970,8 @@ def cli_sroute_to_config(ctx, command_str, strict_nh = True): if 'nexthop' in nexthop_str and 'vrf' in nexthop_str: # nexthop_str: ['nexthop', 'vrf', Vrf-name, ip] config_entry["nexthop"] = nexthop_str[3] + if not is_vrf_exists(config_db, nexthop_str[2]): + ctx.fail("VRF %s does not exist!"%(nexthop_str[2])) config_entry["nexthop-vrf"] = nexthop_str[2] elif 'nexthop' in nexthop_str and 'dev' in nexthop_str: # nexthop_str: ['nexthop', 'dev', ifname] @@ -984,38 +1022,6 @@ def update_sonic_environment(): display_cmd=True ) -def cache_arp_entries(): - success = True - cache_dir = '/host/config-reload' - click.echo('Caching ARP table to {}'.format(cache_dir)) - - if not os.path.exists(cache_dir): - os.mkdir(cache_dir) - - arp_cache_cmd = '/usr/local/bin/fast-reboot-dump.py -t {}'.format(cache_dir) - cache_proc = subprocess.Popen(arp_cache_cmd, shell=True, text=True, stdout=subprocess.PIPE) - _, cache_err = cache_proc.communicate() - if cache_err: - click.echo("Could not cache ARP and FDB info prior to reloading") - success = False - - if not cache_err: - fdb_cache_file = os.path.join(cache_dir, 'fdb.json') - arp_cache_file = os.path.join(cache_dir, 'arp.json') - fdb_filter_cmd = '/usr/local/bin/filter_fdb_entries -f {} -a {} -c /etc/sonic/configdb.json'.format(fdb_cache_file, arp_cache_file) - filter_proc = subprocess.Popen(fdb_filter_cmd, shell=True, text=True, stdout=subprocess.PIPE) - _, filter_err = filter_proc.communicate() - if filter_err: - click.echo("Could not filter FDB entries prior to reloading") - success = False - - # If we are able to successfully cache ARP table info, signal SWSS to restore from our cache - # by creating /host/config-reload/needs-restore - if success: - restore_flag_file = os.path.join(cache_dir, 'needs-restore') - open(restore_flag_file, 'w').close() - return success - def remove_router_interface_ip_address(config_db, interface_name, ipaddress_to_remove): table_name = get_interface_table_name(interface_name) keys = config_db.get_keys(table_name) @@ -1045,6 +1051,8 @@ def validate_ipv4_address(ctx, param, ip_addr): def validate_gre_type(ctx, _, value): """A validator for validating input gre_type """ + if value is None: + return None try: base = 10 if value.lower().startswith('0x'): @@ -1056,6 +1064,41 @@ def validate_gre_type(ctx, _, value): except ValueError: raise click.UsageError("{} is not a valid GRE type".format(value)) +def _is_storage_device(cfg_db): + """ + Check if the device is a storage device or not + """ + device_metadata = cfg_db.get_entry("DEVICE_METADATA", "localhost") + return device_metadata.get("storage_device", "Unknown") == "true" + +def _is_acl_table_present(cfg_db, acl_table_name): + """ + Check if acl table exists + """ + return acl_table_name in cfg_db.get_keys("ACL_TABLE") + +def load_backend_acl(cfg_db, device_type): + """ + Load acl on backend storage device + """ + + BACKEND_ACL_TEMPLATE_FILE = os.path.join('/', "usr", "share", "sonic", "templates", "backend_acl.j2") + BACKEND_ACL_FILE = os.path.join('/', "etc", "sonic", "backend_acl.json") + + if device_type and device_type == "BackEndToRRouter" and _is_storage_device(cfg_db) and _is_acl_table_present(cfg_db, "DATAACL"): + if os.path.isfile(BACKEND_ACL_TEMPLATE_FILE): + clicommon.run_command( + "{} -d -t {},{}".format( + SONIC_CFGGEN_PATH, + BACKEND_ACL_TEMPLATE_FILE, + BACKEND_ACL_FILE + ), + display_cmd=True + ) + if os.path.isfile(BACKEND_ACL_FILE): + clicommon.run_command("acl-loader update incremental {}".format(BACKEND_ACL_FILE), display_cmd=True) + + # This is our main entrypoint - the main 'config' command @click.group(cls=clicommon.AbbreviationGroup, context_settings=CONTEXT_SETTINGS) @click.pass_context @@ -1076,6 +1119,10 @@ def config(ctx): print("Caught an exception: " + str(e)) raise click.Abort() + if asic_type == 'cisco-8000': + from sonic_platform.cli.cisco import cisco + platform.add_command(cisco) + # Load database config files load_db_config() @@ -1249,6 +1296,20 @@ def apply_patch(ctx, patch_file_path, format, dry_run, ignore_non_yang_tables, i patch_as_json = json.loads(text) patch = jsonpatch.JsonPatch(patch_as_json) + # convert IPv6 addresses to lowercase + for patch_line in patch: + if 'remove' == patch_line['op']: + match = re.search(r"(?P/INTERFACE/\w+\|)(?P([a-fA-F0-9]{0,4}[:~]|::){1,7}[a-fA-F0-9]{0,4})" + "(?P.*)", str.format(patch_line['path'])) + if match: + prefix = match.group('prefix') + ipv6_address_str = match.group('ipv6_address') + suffix = match.group('suffix') + ipv6_address_str = ipv6_address_str.lower() + click.secho("converted ipv6 address to lowercase {} with prefix {} in value: {}" + .format(ipv6_address_str, prefix, patch_line['path'])) + patch_line['path'] = prefix + ipv6_address_str + suffix + config_format = ConfigFormat[format.upper()] GenericUpdater().apply_patch(patch, config_format, verbose, dry_run, ignore_non_yang_tables, ignore_path) @@ -1364,27 +1425,27 @@ def list_checkpoints(ctx, verbose): @click.option('-y', '--yes', is_flag=True) @click.option('-l', '--load-sysinfo', is_flag=True, help='load system default information (mac, portmap etc) first.') @click.option('-n', '--no_service_restart', default=False, is_flag=True, help='Do not restart docker services') -@click.option('-d', '--disable_arp_cache', default=False, is_flag=True, help='Do not cache ARP table before reloading (applies to dual ToR systems only)') @click.option('-f', '--force', default=False, is_flag=True, help='Force config reload without system checks') @click.option('-t', '--file_format', default='config_db',type=click.Choice(['config_yang', 'config_db']),show_default=True,help='specify the file format') @click.argument('filename', required=False) @clicommon.pass_db -def reload(db, filename, yes, load_sysinfo, no_service_restart, disable_arp_cache, force, file_format): +def reload(db, filename, yes, load_sysinfo, no_service_restart, force, file_format): """Clear current configuration and import a previous saved config DB dump file. : Names of configuration file(s) to load, separated by comma with no spaces in between """ + CONFIG_RELOAD_NOT_READY = 1 if not force and not no_service_restart: if _is_system_starting(): click.echo("System is not up. Retry later or use -f to avoid system checks") - return + sys.exit(CONFIG_RELOAD_NOT_READY) if not _delay_timers_elapsed(): click.echo("Relevant services are not up. Retry later or use -f to avoid system checks") - return + sys.exit(CONFIG_RELOAD_NOT_READY) if not _swss_ready(): click.echo("SwSS container is not ready. Retry later or use -f to avoid system checks") - return + sys.exit(CONFIG_RELOAD_NOT_READY) if filename is None: message = 'Clear current config and reload config in {} format from the default config file(s) ?'.format(file_format) @@ -1404,11 +1465,6 @@ def reload(db, filename, yes, load_sysinfo, no_service_restart, disable_arp_cach if multi_asic.is_multi_asic() and file_format == 'config_db': num_cfg_file += num_asic - # Remove cached PG drop counters data - dropstat_dir_prefix = '/tmp/dropstat' - command = "rm -rf {}-*".format(dropstat_dir_prefix) - clicommon.run_command(command, display_cmd=True) - # If the user give the filename[s], extract the file names. if filename is not None: cfg_files = filename.split(',') @@ -1417,13 +1473,6 @@ def reload(db, filename, yes, load_sysinfo, no_service_restart, disable_arp_cach click.echo("Input {} config file(s) separated by comma for multiple files ".format(num_cfg_file)) return - # For dual ToR devices, cache ARP and FDB info - localhost_metadata = db.cfgdb.get_table('DEVICE_METADATA')['localhost'] - cache_arp_table = not disable_arp_cache and 'subtype' in localhost_metadata and localhost_metadata['subtype'].lower() == 'dualtor' - - if cache_arp_table: - cache_arp_entries() - #Stop services before config push if not no_service_restart: log.log_info("'reload' stopping services...") @@ -1551,24 +1600,36 @@ def load_mgmt_config(filename): config_data = parse_device_desc_xml(filename) hostname = config_data['DEVICE_METADATA']['localhost']['hostname'] _change_hostname(hostname) - mgmt_conf = netaddr.IPNetwork(list(config_data['MGMT_INTERFACE'].keys())[0][1]) - gw_addr = list(config_data['MGMT_INTERFACE'].values())[0]['gwaddr'] - command = "ifconfig eth0 {} netmask {}".format(str(mgmt_conf.ip), str(mgmt_conf.netmask)) - clicommon.run_command(command, display_cmd=True) - command = "ip route add default via {} dev eth0 table default".format(gw_addr) - clicommon.run_command(command, display_cmd=True, ignore_error=True) - command = "ip rule add from {} table default".format(str(mgmt_conf.ip)) - clicommon.run_command(command, display_cmd=True, ignore_error=True) - command = "[ -f /var/run/dhclient.eth0.pid ] && kill `cat /var/run/dhclient.eth0.pid` && rm -f /var/run/dhclient.eth0.pid" - clicommon.run_command(command, display_cmd=True, ignore_error=True) + for key in list(config_data['MGMT_INTERFACE'].keys()): + # key: (eth0, ipprefix) + # value: { gwaddr: ip } + mgmt_conf = netaddr.IPNetwork(key[1]) + gw_addr = config_data['MGMT_INTERFACE'][key]['gwaddr'] + if mgmt_conf.version == 4: + command = "ifconfig eth0 {} netmask {}".format(str(mgmt_conf.ip), str(mgmt_conf.netmask)) + clicommon.run_command(command, display_cmd=True) + else: + command = "ifconfig eth0 add {}".format(str(mgmt_conf)) + # Ignore error for IPv6 configuration command due to it not allows config the same IP twice + clicommon.run_command(command, display_cmd=True, ignore_error=True) + command = "ip{} route add default via {} dev eth0 table default".format(" -6" if mgmt_conf.version == 6 else "", gw_addr) + clicommon.run_command(command, display_cmd=True, ignore_error=True) + command = "ip{} rule add from {} table default".format(" -6" if mgmt_conf.version == 6 else "", str(mgmt_conf.ip)) + clicommon.run_command(command, display_cmd=True, ignore_error=True) + if len(config_data['MGMT_INTERFACE'].keys()) > 0: + command = "[ -f /var/run/dhclient.eth0.pid ] && kill `cat /var/run/dhclient.eth0.pid` && rm -f /var/run/dhclient.eth0.pid" + clicommon.run_command(command, display_cmd=True, ignore_error=True) click.echo("Please note loaded setting will be lost after system reboot. To preserve setting, run `config save`.") @config.command("load_minigraph") @click.option('-y', '--yes', is_flag=True, callback=_abort_if_false, expose_value=False, prompt='Reload config from minigraph?') @click.option('-n', '--no_service_restart', default=False, is_flag=True, help='Do not restart docker services') +@click.option('-t', '--traffic_shift_away', default=False, is_flag=True, help='Keep device in maintenance with TSA') +@click.option('-o', '--override_config', default=False, is_flag=True, help='Enable config override. Proceed with default path.') +@click.option('-p', '--golden_config_path', help='Provide golden config path to override. Use with --override_config') @clicommon.pass_db -def load_minigraph(db, no_service_restart): +def load_minigraph(db, no_service_restart, traffic_shift_away, override_config, golden_config_path): """Reconfigure based on minigraph.""" log.log_info("'load_minigraph' executing...") @@ -1610,6 +1671,12 @@ def load_minigraph(db, no_service_restart): if os.path.isfile('/etc/sonic/acl.json'): clicommon.run_command("acl-loader update full /etc/sonic/acl.json", display_cmd=True) + # get the device type + device_type = _get_device_type() + + # Load backend acl + load_backend_acl(db.cfgdb, device_type) + # Load port_config.json try: load_port_config(db.cfgdb, '/etc/sonic/port_config.json') @@ -1617,10 +1684,8 @@ def load_minigraph(db, no_service_restart): click.secho("Failed to load port_config.json, Error: {}".format(str(e)), fg='magenta') # generate QoS and Buffer configs - clicommon.run_command("config qos reload --no-dynamic-buffer", display_cmd=True) + clicommon.run_command("config qos reload --no-dynamic-buffer --no-delay", display_cmd=True) - # get the device type - device_type = _get_device_type() if device_type != 'MgmtToRRouter' and device_type != 'MgmtTsToR' and device_type != 'BmcMgmtToRRouter' and device_type != 'EPMS': clicommon.run_command("pfcwd start_default", display_cmd=True) @@ -1634,9 +1699,22 @@ def load_minigraph(db, no_service_restart): cfggen_namespace_option = " -n {}".format(namespace) clicommon.run_command(db_migrator + ' -o set_version' + cfggen_namespace_option) + # Keep device isolated with TSA + if traffic_shift_away: + clicommon.run_command("TSA", display_cmd=True) + if override_config: + log.log_warning("Golden configuration may override System Maintenance state. Please execute TSC to check the current System mode") + click.secho("[WARNING] Golden configuration may override Traffic-shift-away state. Please execute TSC to check the current System mode") + # Load golden_config_db.json - if os.path.isfile(DEFAULT_GOLDEN_CONFIG_DB_FILE): - override_config_by(DEFAULT_GOLDEN_CONFIG_DB_FILE) + if override_config: + if golden_config_path is None: + golden_config_path = DEFAULT_GOLDEN_CONFIG_DB_FILE + if not os.path.isfile(golden_config_path): + click.secho("Cannot find '{}'!".format(golden_config_path), + fg='magenta') + raise click.Abort() + override_config_by(golden_config_path) # We first run "systemctl reset-failed" to remove the "failed" # status from all services before we attempt to restart them @@ -1723,27 +1801,66 @@ def override_config_table(db, input_config_db, dry_run): config_db = db.cfgdb + # Read config from configDB + current_config = config_db.get_config() + # Serialize to the same format as json input + sonic_cfggen.FormatConverter.to_serialized(current_config) + + updated_config = update_config(current_config, config_input) + + yang_enabled = device_info.is_yang_config_validation_enabled(config_db) + if yang_enabled: + # The ConfigMgmt will load YANG and running + # config during initialization. + try: + cm = ConfigMgmt() + cm.validateConfigData() + except Exception as ex: + click.secho("Failed to validate running config. Error: {}".format(ex), fg="magenta") + sys.exit(1) + + # Validate input config + validate_config_by_cm(cm, config_input, "config_input") + # Validate updated whole config + validate_config_by_cm(cm, updated_config, "updated_config") + if dry_run: - # Read config from configDB - current_config = config_db.get_config() - # Serialize to the same format as json input - sonic_cfggen.FormatConverter.to_serialized(current_config) - # Override current config with golden config - for table in config_input: - current_config[table] = config_input[table] - print(json.dumps(current_config, sort_keys=True, + print(json.dumps(updated_config, sort_keys=True, indent=4, cls=minigraph_encoder)) else: - # Deserialized golden config to DB recognized format - sonic_cfggen.FormatConverter.to_deserialized(config_input) - # Delete table from DB then mod_config to apply golden config - click.echo("Removing configDB overriden table first ...") - for table in config_input: - config_db.delete_table(table) - click.echo("Overriding input config to configDB ...") - data = sonic_cfggen.FormatConverter.output_to_db(config_input) - config_db.mod_config(data) - click.echo("Overriding completed. No service is restarted.") + override_config_db(config_db, config_input) + + +def validate_config_by_cm(cm, config_json, jname): + tmp_config_json = copy.deepcopy(config_json) + try: + cm.loadData(tmp_config_json) + cm.validateConfigData() + except Exception as ex: + click.secho("Failed to validate {}. Error: {}".format(jname, ex), fg="magenta") + sys.exit(1) + + +def update_config(current_config, config_input): + updated_config = copy.deepcopy(current_config) + # Override current config with golden config + for table in config_input: + updated_config[table] = config_input[table] + return updated_config + + +def override_config_db(config_db, config_input): + # Deserialized golden config to DB recognized format + sonic_cfggen.FormatConverter.to_deserialized(config_input) + # Delete table from DB then mod_config to apply golden config + click.echo("Removing configDB overriden table first ...") + for table in config_input: + config_db.delete_table(table) + click.echo("Overriding input config to configDB ...") + data = sonic_cfggen.FormatConverter.output_to_db(config_input) + config_db.mod_config(data) + click.echo("Overriding completed. No service is restarted.") + # # 'hostname' command @@ -1851,6 +1968,11 @@ def remove_portchannel(ctx, portchannel_name): if is_portchannel_present_in_db(db, portchannel_name) is False: ctx.fail("{} is not present.".format(portchannel_name)) + # Dont let to remove port channel if vlan membership exists + for k,v in db.get_table('VLAN_MEMBER'): + if v == portchannel_name: + ctx.fail("{} has vlan {} configured, remove vlan membership to proceed".format(portchannel_name, str(k))) + if len([(k, v) for k, v in db.get_table('PORTCHANNEL_MEMBER') if k == portchannel_name]) != 0: click.echo("Error: Portchannel {} contains members. Remove members before deleting Portchannel!".format(portchannel_name)) else: @@ -1892,6 +2014,14 @@ def add_portchannel_member(ctx, portchannel_name, port_name): ctx.fail(" {} has ip address configured".format(port_name)) return + for key in db.get_keys('VLAN_SUB_INTERFACE'): + if type(key) == tuple: + continue + intf = key.split(VLAN_SUB_INTERFACE_SEPARATOR)[0] + parent_intf = get_intf_longname(intf) + if parent_intf == port_name: + ctx.fail(" {} has subinterfaces configured".format(port_name)) + # Dont allow a port to be member of port channel if it is configured as a VLAN member for k,v in db.get_table('VLAN_MEMBER'): if v == port_name: @@ -2025,7 +2155,7 @@ def gather_session_info(session_info, policer, queue, src_port, direction): if policer: session_info['policer'] = policer - if queue: + if queue is not None: session_info['queue'] = queue if src_port: @@ -2051,7 +2181,7 @@ def add_erspan(session_name, src_ip, dst_ip, dscp, ttl, gre_type, queue, policer "ttl": ttl } - if gre_type: + if gre_type is not None: session_info['gre_type'] = gre_type session_info = gather_session_info(session_info, policer, queue, src_port, direction) @@ -2338,6 +2468,7 @@ def _update_buffer_calculation_model(config_db, model): @click.pass_context @click.option('--ports', is_flag=False, required=False, help="List of ports that needs to be updated") @click.option('--no-dynamic-buffer', is_flag=True, help="Disable dynamic buffer calculation") +@click.option('--no-delay', is_flag=True, hidden=True) @click.option( '--json-data', type=click.STRING, help="json string with additional data, valid with --dry-run option" @@ -2346,7 +2477,7 @@ def _update_buffer_calculation_model(config_db, model): '--dry_run', type=click.STRING, help="Dry run, writes config to the given file" ) -def reload(ctx, no_dynamic_buffer, dry_run, json_data, ports): +def reload(ctx, no_dynamic_buffer, no_delay, dry_run, json_data, ports): """Reload QoS configuration""" if ports: log.log_info("'qos reload --ports {}' executing...".format(ports)) @@ -2354,7 +2485,8 @@ def reload(ctx, no_dynamic_buffer, dry_run, json_data, ports): return log.log_info("'qos reload' executing...") - _clear_qos() + if not dry_run: + _clear_qos(delay = not no_delay) _, hwsku_path = device_info.get_paths_to_platform_and_hwsku_dirs() sonic_version_file = device_info.get_sonic_version_file() @@ -2499,7 +2631,7 @@ def _qos_update_ports(ctx, ports, dry_run, json_data): command = "{} {} {} -t {},config-db -t {},config-db -y {} --print-data".format( SONIC_CFGGEN_PATH, cmd_ns, from_db, buffer_template_file, qos_template_file, sonic_version_file ) - jsonstr = clicommon.run_command(command, display_cmd=False, return_cmd=True) + jsonstr, _ = clicommon.run_command(command, display_cmd=False, return_cmd=True) jsondict = json.loads(jsonstr) port_table = jsondict.get('PORT') @@ -3674,6 +3806,36 @@ def speed(ctx, interface_name, interface_speed, verbose): command += " -vv" clicommon.run_command(command, display_cmd=verbose) +# +# 'link-training' subcommand +# + +@interface.command() +@click.pass_context +@click.argument('interface_name', metavar='', required=True) +@click.argument('mode', metavar='', required=True, type=click.Choice(["on", "off"])) +@click.option('-v', '--verbose', is_flag=True, help="Enable verbose output") +def link_training(ctx, interface_name, mode, verbose): + """Set interface link training mode""" + # Get the config_db connector + config_db = ctx.obj['config_db'] + + if clicommon.get_interface_naming_mode() == "alias": + interface_name = interface_alias_to_name(config_db, interface_name) + if interface_name is None: + ctx.fail("'interface_name' is None!") + + log.log_info("'interface link-training {} {}' executing...".format(interface_name, mode)) + + if ctx.obj['namespace'] is DEFAULT_NAMESPACE: + command = "portconfig -p {} -lt {}".format(interface_name, mode) + else: + command = "portconfig -p {} -lt {} -n {}".format(interface_name, mode, ctx.obj['namespace']) + + if verbose: + command += " -vv" + clicommon.run_command(command, display_cmd=verbose) + # # 'autoneg' subcommand # @@ -4011,8 +4173,6 @@ def fec(ctx, interface_name, interface_fec, verbose): # Get the config_db connector config_db = ctx.obj['config_db'] - if interface_fec not in ["rs", "fc", "none"]: - ctx.fail("'fec not in ['rs', 'fc', 'none']!") if clicommon.get_interface_naming_mode() == "alias": interface_name = interface_alias_to_name(config_db, interface_name) if interface_name is None: @@ -4034,7 +4194,7 @@ def fec(ctx, interface_name, interface_fec, verbose): @interface.group(cls=clicommon.AbbreviationGroup) @click.pass_context def ip(ctx): - """Add or remove IP address""" + """Set IP interface attributes""" pass # @@ -4063,6 +4223,12 @@ def add(ctx, interface_name, ip_addr, gw): click.echo("Interface {} is a member of vlan\nAborting!".format(interface_name)) return + portchannel_member_table = config_db.get_table('PORTCHANNEL_MEMBER') + + if interface_is_in_portchannel(portchannel_member_table, interface_name): + ctx.fail("{} is configured as a member of portchannel." + .format(interface_name)) + try: ip_address = ipaddress.ip_interface(ip_addr) except ValueError as err: @@ -4156,7 +4322,8 @@ def remove(ctx, interface_name, ip_addr): remove_router_interface_ip_address(config_db, interface_name, ip_address) interface_addresses = get_interface_ipaddresses(config_db, interface_name) if len(interface_addresses) == 0 and is_interface_bind_to_vrf(config_db, interface_name) is False and get_intf_ipv6_link_local_mode(ctx, interface_name, table_name) != "enable": - config_db.set_entry(table_name, interface_name, None) + if table_name != "VLAN_SUB_INTERFACE": + config_db.set_entry(table_name, interface_name, None) if multi_asic.is_multi_asic(): command = "sudo ip netns exec {} ip neigh flush dev {} {}".format(ctx.obj['namespace'], interface_name, str(ip_address)) @@ -4164,6 +4331,32 @@ def remove(ctx, interface_name, ip_addr): command = "ip neigh flush dev {} {}".format(interface_name, str(ip_address)) clicommon.run_command(command) +# +# 'loopback-action' subcommand +# + +@ip.command() +@click.argument('interface_name', metavar='', required=True) +@click.argument('action', metavar='', required=True) +@click.pass_context +def loopback_action(ctx, interface_name, action): + """Set IP interface loopback action""" + config_db = ctx.obj['config_db'] + + if clicommon.get_interface_naming_mode() == "alias": + interface_name = interface_alias_to_name(config_db, interface_name) + if interface_name is None: + ctx.fail('Interface {} is invalid'.format(interface_name)) + + if not clicommon.is_interface_in_config_db(config_db, interface_name): + ctx.fail('Interface {} is not an IP interface'.format(interface_name)) + + allowed_actions = ['drop', 'forward'] + if action not in allowed_actions: + ctx.fail('Invalid action') + + table_name = get_interface_table_name(interface_name) + config_db.mod_entry(table_name, interface_name, {"loopback_action": action}) # # buffer commands and utilities @@ -4506,6 +4699,67 @@ def transceiver(ctx): """SFP transceiver configuration""" pass +# +# 'frequency' subcommand ('config interface transceiver frequency ...') +# +@transceiver.command() +@click.pass_context +@click.argument('interface_name', metavar='', required=True) +@click.argument('frequency', metavar='', required=True, type=int) +def frequency(ctx, interface_name, frequency): + """Set transciever (only for 400G-ZR) frequency""" + # Get the config_db connector + config_db = ctx.obj['config_db'] + + if clicommon.get_interface_naming_mode() == "alias": + interface_name = interface_alias_to_name(config_db, interface_name) + if interface_name is None: + ctx.fail("'interface_name' is None!") + + if interface_name_is_valid(config_db, interface_name) is False: + ctx.fail("Interface name is invalid. Please enter a valid interface name!!") + + log.log_info("{} Setting transceiver frequency {} GHz".format(interface_name, frequency)) + + if ctx.obj['namespace'] is DEFAULT_NAMESPACE: + command = "portconfig -p {} -F {}".format(interface_name, frequency) + else: + command = "portconfig -p {} -F {} -n {}".format(interface_name, frequency, ctx.obj['namespace']) + + clicommon.run_command(command) + + +# +# 'tx_power' subcommand ('config interface transceiver tx_power ...') +# For negative float use:- +# config interface transceiver tx_power Ethernet0 -- -27.4" +# +@transceiver.command('tx_power') +@click.pass_context +@click.argument('interface_name', metavar='', required=True) +@click.argument('tx-power', metavar='', required=True, type=float) +def tx_power(ctx, interface_name, tx_power): + """Set transciever (only for 400G-ZR) Tx laser power""" + # Get the config_db connector + config_db = ctx.obj['config_db'] + + if clicommon.get_interface_naming_mode() == "alias": + interface_name = interface_alias_to_name(config_db, interface_name) + if interface_name is None: + ctx.fail("'interface_name' is None!") + + if interface_name_is_valid(config_db, interface_name) is False: + ctx.fail("Interface name is invalid. Please enter a valid interface name!!") + + log.log_info("{} Setting transceiver power {} dBm".format(interface_name, tx_power)) + + if ctx.obj['namespace'] is DEFAULT_NAMESPACE: + command = "portconfig -p {} -P {}".format(interface_name, tx_power) + else: + command = "portconfig -p {} -P {} -n {}".format(interface_name, tx_power, ctx.obj['namespace']) + + clicommon.run_command(command) + # # 'lpmode' subcommand ('config interface transceiver lpmode ...') # @@ -4635,6 +4889,9 @@ def bind(ctx, interface_name, vrf_name): if interface_name is None: ctx.fail("'interface_name' is None!") + if not is_vrf_exists(config_db, vrf_name): + ctx.fail("VRF %s does not exist!"%(vrf_name)) + table_name = get_interface_table_name(interface_name) if table_name == "": ctx.fail("'interface_name' is not valid. Valid names [Ethernet/PortChannel/Vlan/Loopback]") @@ -4645,6 +4902,11 @@ def bind(ctx, interface_name, vrf_name): interface_addresses = get_interface_ipaddresses(config_db, interface_name) for ipaddress in interface_addresses: remove_router_interface_ip_address(config_db, interface_name, ipaddress) + if table_name == "VLAN_SUB_INTERFACE": + subintf_entry = config_db.get_entry(table_name, interface_name) + if 'vrf_name' in subintf_entry: + subintf_entry.pop('vrf_name') + config_db.set_entry(table_name, interface_name, None) # When config_db del entry and then add entry with same key, the DEL will lost. if ctx.obj['namespace'] is DEFAULT_NAMESPACE: @@ -4656,7 +4918,11 @@ def bind(ctx, interface_name, vrf_name): while state_db.exists(state_db.STATE_DB, _hash): time.sleep(0.01) state_db.close(state_db.STATE_DB) - config_db.set_entry(table_name, interface_name, {"vrf_name": vrf_name}) + if table_name == "VLAN_SUB_INTERFACE": + subintf_entry['vrf_name'] = vrf_name + config_db.set_entry(table_name, interface_name, subintf_entry) + else: + config_db.set_entry(table_name, interface_name, {"vrf_name": vrf_name}) # # 'unbind' subcommand @@ -4678,13 +4944,37 @@ def unbind(ctx, interface_name): table_name = get_interface_table_name(interface_name) if table_name == "": ctx.fail("'interface_name' is not valid. Valid names [Ethernet/PortChannel/Vlan/Loopback]") + if is_interface_bind_to_vrf(config_db, interface_name) is False: return + if table_name == "VLAN_SUB_INTERFACE": + subintf_entry = config_db.get_entry(table_name, interface_name) + if 'vrf_name' in subintf_entry: + subintf_entry.pop('vrf_name') + interface_ipaddresses = get_interface_ipaddresses(config_db, interface_name) for ipaddress in interface_ipaddresses: remove_router_interface_ip_address(config_db, interface_name, ipaddress) - config_db.set_entry(table_name, interface_name, None) + if table_name == "VLAN_SUB_INTERFACE": + # First delete subinterface, once subinterface deletion successful, + # recreate same with same config on default vrf + if 'state_db' not in ctx.obj: + if ctx.obj['namespace'] is DEFAULT_NAMESPACE: + state_db = SonicV2Connector(use_unix_socket_path=True) + else: + state_db = SonicV2Connector(use_unix_socket_path=True, namespace=ctx.obj['namespace']) + state_db.connect(state_db.STATE_DB, False) + else: + state_db = ctx.obj['state_db'] + config_db.set_entry(table_name, interface_name, None) + _hash = '{}{}'.format('INTERFACE_TABLE|', interface_name) + while state_db.exists(state_db.STATE_DB, _hash): + time.sleep(0.01) + state_db.close(state_db.STATE_DB) + config_db.set_entry(table_name, interface_name, subintf_entry) + else: + config_db.set_entry(table_name, interface_name, None) # # 'ipv6' subgroup ('config interface ipv6 ...') @@ -4931,6 +5221,7 @@ def add_route(ctx, command_str): if (not route['ifname'] in config_db.get_keys('VLAN_INTERFACE') and not route['ifname'] in config_db.get_keys('INTERFACE') and not route['ifname'] in config_db.get_keys('PORTCHANNEL_INTERFACE') and + not route['ifname'] in config_db.get_keys('VLAN_SUB_INTERFACE') and not route['ifname'] == 'null'): ctx.fail('interface {} doesn`t exist'.format(route['ifname'])) @@ -4973,7 +5264,7 @@ def add_route(ctx, command_str): # Check if exist entry with key keys = config_db.get_keys('STATIC_ROUTE') - if key in keys: + if tuple(key.split("|")) in keys: # If exist update current entry current_entry = config_db.get_entry('STATIC_ROUTE', key) @@ -4998,7 +5289,7 @@ def del_route(ctx, command_str): key, route = cli_sroute_to_config(ctx, command_str, strict_nh=False) keys = config_db.get_keys('STATIC_ROUTE') prefix_tuple = tuple(key.split('|')) - if not key in keys and not prefix_tuple in keys: + if not tuple(key.split("|")) in keys and not prefix_tuple in keys: ctx.fail('Route {} doesnt exist'.format(key)) else: # If not defined nexthop or intf name remove entire route @@ -6415,6 +6706,13 @@ def subintf_vlan_check(config_db, parent_intf, vlan): return True return False +def is_subintf_shortname(intf): + if VLAN_SUB_INTERFACE_SEPARATOR in intf: + if intf.startswith("Ethernet") or intf.startswith("PortChannel"): + return False + return True + return False + @subinterface.command('add') @click.argument('subinterface_name', metavar='', required=True) @click.argument('vid', metavar='', required=False, type=click.IntRange(1,4094)) @@ -6435,23 +6733,24 @@ def add_subinterface(ctx, subinterface_name, vid): config_db = ctx.obj['db'] port_dict = config_db.get_table(intf_table_name) + parent_intf = get_intf_longname(interface_alias) if interface_alias is not None: if not port_dict: ctx.fail("{} parent interface not found. {} table none".format(interface_alias, intf_table_name)) - if get_intf_longname(interface_alias) not in port_dict.keys(): + if parent_intf not in port_dict.keys(): ctx.fail("{} parent interface not found".format(subinterface_name)) # Validate if parent is portchannel member portchannel_member_table = config_db.get_table('PORTCHANNEL_MEMBER') - if interface_is_in_portchannel(portchannel_member_table, interface_alias): + if interface_is_in_portchannel(portchannel_member_table, parent_intf): ctx.fail("{} is configured as a member of portchannel. Cannot configure subinterface" - .format(interface_alias)) + .format(parent_intf)) # Validate if parent is vlan member vlan_member_table = config_db.get_table('VLAN_MEMBER') - if interface_is_in_vlan(vlan_member_table, interface_alias): + if interface_is_in_vlan(vlan_member_table, parent_intf): ctx.fail("{} is configured as a member of vlan. Cannot configure subinterface" - .format(interface_alias)) + .format(parent_intf)) sub_intfs = [k for k,v in config_db.get_table('VLAN_SUB_INTERFACE').items() if type(k) != tuple] if subinterface_name in sub_intfs: @@ -6460,6 +6759,8 @@ def add_subinterface(ctx, subinterface_name, vid): subintf_dict = {} if vid is not None: subintf_dict.update({"vlan" : vid}) + elif is_subintf_shortname(subinterface_name): + ctx.fail("{} Encap vlan is mandatory for short name subinterfaces".format(subinterface_name)) if subintf_vlan_check(config_db, get_intf_longname(interface_alias), vid) is True: ctx.fail("Vlan {} encap already configured on other subinterface on {}".format(vid, interface_alias)) diff --git a/config/muxcable.py b/config/muxcable.py index f6b5a6a39d..f53eae22e3 100644 --- a/config/muxcable.py +++ b/config/muxcable.py @@ -11,6 +11,7 @@ from swsscommon import swsscommon from tabulate import tabulate from utilities_common import platform_sfputil_helper +from utilities_common.general import get_optional_value_for_key_in_config_tbl platform_sfputil = None @@ -203,7 +204,6 @@ def update_and_get_response_for_xcvr_cmd(cmd_name, rsp_name, exp_rsp, cmd_table_ return res_dict - def get_value_for_key_in_config_tbl(config_db, port, key, table): info_dict = {} info_dict = config_db.get_entry(table, port) @@ -244,6 +244,8 @@ def lookup_statedb_and_update_configdb(db, per_npu_statedb, config_db, port, sta configdb_state = get_value_for_key_in_config_tbl(config_db, port, "state", "MUX_CABLE") ipv4_value = get_value_for_key_in_config_tbl(config_db, port, "server_ipv4", "MUX_CABLE") ipv6_value = get_value_for_key_in_config_tbl(config_db, port, "server_ipv6", "MUX_CABLE") + soc_ipv4_value = get_optional_value_for_key_in_config_tbl(config_db, port, "soc_ipv4", "MUX_CABLE") + cable_type = get_optional_value_for_key_in_config_tbl(config_db, port, "cable_type", "MUX_CABLE") state = get_value_for_key_in_dict(muxcable_statedb_dict, port, "state", "MUX_CABLE_TABLE") @@ -252,8 +254,16 @@ def lookup_statedb_and_update_configdb(db, per_npu_statedb, config_db, port, sta if str(state_cfg_val) == str(configdb_state): port_status_dict[port_name] = 'OK' else: - config_db.set_entry("MUX_CABLE", port, {"state": state_cfg_val, - "server_ipv4": ipv4_value, "server_ipv6": ipv6_value}) + if cable_type is not None or soc_ipv4_value is not None: + config_db.set_entry("MUX_CABLE", port, {"state": state_cfg_val, + "server_ipv4": ipv4_value, + "server_ipv6": ipv6_value, + "soc_ipv4":soc_ipv4_value, + "cable_type": cable_type}) + else: + config_db.set_entry("MUX_CABLE", port, {"state": state_cfg_val, + "server_ipv4": ipv4_value, + "server_ipv6": ipv6_value}) if (str(state_cfg_val) == 'active' and str(state) != 'active') or (str(state_cfg_val) == 'standby' and str(state) != 'standby'): port_status_dict[port_name] = 'INPROGRESS' else: @@ -270,7 +280,7 @@ def update_configdb_pck_loss_data(config_db, port, val): # 'muxcable' command ("config muxcable mode active|auto") @muxcable.command() -@click.argument('state', metavar='', required=True, type=click.Choice(["active", "auto", "manual", "standby"])) +@click.argument('state', metavar='', required=True, type=click.Choice(["active", "auto", "manual", "standby", "detach"])) @click.argument('port', metavar='', required=True, default=None) @click.option('--json', 'json_output', required=False, is_flag=True, type=click.BOOL) @clicommon.pass_db @@ -360,6 +370,22 @@ def mode(db, state, port, json_output): sys.exit(CONFIG_SUCCESSFUL) +# 'muxcable' command ("config muxcable kill-radv ") +@muxcable.command(short_help="Kill radv service when it is meant to be stopped, so no good-bye packet is sent for ceasing To Be an Advertising Interface") +@click.argument('knob', metavar='', required=True, type=click.Choice(["enable", "disable"])) +@clicommon.pass_db +def kill_radv(db, knob): + """config muxcable kill radv""" + + namespaces = multi_asic.get_front_end_namespaces() + for namespace in namespaces: + config_db = ConfigDBConnector(use_unix_socket_path=True, namespace=namespace) + config_db.connect() + + mux_lmgrd_cfg_tbl = config_db.get_table("MUX_LINKMGR") + config_db.mod_entry("MUX_LINKMGR", "SERVICE_MGMT", {"kill_radv": "True" if knob == "enable" else "False"}) + + #'muxcable' command ("config muxcable packetloss reset ") @muxcable.command() @click.argument('action', metavar='', required=True, type=click.Choice(["reset"])) @@ -1190,3 +1216,46 @@ def set_fec(db, port, target, mode): else: click.echo("ERR: Unable to set fec enable/disable port {} to {}".format(port, mode)) sys.exit(CONFIG_FAIL) + +def update_configdb_ycable_telemetry_data(config_db, key, val): + log_verbosity = get_value_for_key_in_config_tbl(config_db, key, "log_verbosity", "XCVRD_LOG") + + config_db.set_entry("XCVRD_LOG", key, {"log_verbosity": log_verbosity, + "disable_telemetry": val}) + return 0 + +@muxcable.command() +@click.argument('state', metavar='', required=True, type=click.Choice(["enable", "disable"])) +@clicommon.pass_db +def telemetry(db, state): + """Enable/Disable Telemetry for ycabled """ + + per_npu_configdb = {} + xcvrd_log_cfg_db_tbl = {} + + if state == 'enable': + val = 'False' + elif state == 'disable': + val = 'True' + + + # Getting all front asic namespace and correspding config and state DB connector + + namespaces = multi_asic.get_front_end_namespaces() + for namespace in namespaces: + asic_id = multi_asic.get_asic_index_from_namespace(namespace) + # replace these with correct macros + per_npu_configdb[asic_id] = ConfigDBConnector(use_unix_socket_path=True, namespace=namespace) + per_npu_configdb[asic_id].connect() + + xcvrd_log_cfg_db_tbl[asic_id] = per_npu_configdb[asic_id].get_table("XCVRD_LOG") + + asic_index = multi_asic.get_asic_index_from_namespace(EMPTY_NAMESPACE) + rc = update_configdb_ycable_telemetry_data(per_npu_configdb[asic_index], "Y_CABLE", val) + + + if rc == 0: + click.echo("Success in ycabled telemetry state to {}".format(state)) + else: + click.echo("ERR: Unable to set ycabled telemetry state to {}".format(state)) + sys.exit(CONFIG_FAIL) diff --git a/config/plugins/auto_techsupport.py b/config/plugins/auto_techsupport.py index c2960646d4..10bebbaaff 100644 --- a/config/plugins/auto_techsupport.py +++ b/config/plugins/auto_techsupport.py @@ -228,6 +228,50 @@ def AUTO_TECHSUPPORT_GLOBAL_max_core_limit(db, max_core_limit): exit_with_error(f"Error: {err}", fg="red") +@AUTO_TECHSUPPORT_GLOBAL.command(name="available-mem-threshold") +@click.argument( + "available-mem-threshold", + nargs=1, + required=True, +) +@clicommon.pass_db +def AUTO_TECHSUPPORT_GLOBAL_available_mem_threshold(db, available_mem_threshold): + """ Memory threshold; 0 to disable techsupport invocation on memory usage threshold crossing. + """ + + table = "AUTO_TECHSUPPORT" + key = "GLOBAL" + data = { + "available_mem_threshold": available_mem_threshold, + } + try: + update_entry_validated(db.cfgdb, table, key, data, create_if_not_exists=True) + except Exception as err: + exit_with_error(f"Error: {err}", fg="red") + + +@AUTO_TECHSUPPORT_GLOBAL.command(name="min-available-mem") +@click.argument( + "min-available-mem", + nargs=1, + required=True, +) +@clicommon.pass_db +def AUTO_TECHSUPPORT_GLOBAL_min_available_mem(db, min_available_mem): + """ Minimum free memory amount in Kb when techsupport will be executed. + """ + + table = "AUTO_TECHSUPPORT" + key = "GLOBAL" + data = { + "min_available_mem": min_available_mem, + } + try: + update_entry_validated(db.cfgdb, table, key, data, create_if_not_exists=True) + except Exception as err: + exit_with_error(f"Error: {err}", fg="red") + + @AUTO_TECHSUPPORT_GLOBAL.command(name="since") @click.argument( "since", @@ -271,8 +315,12 @@ def AUTO_TECHSUPPORT_FEATURE(): "--rate-limit-interval", help="Rate limit interval for the corresponding feature. Configure 0 to explicitly disable", ) +@click.option( + "--available-mem-threshold", + help="Memory threshold; 0 to disable techsupport invocation on memory usage threshold crossing.", +) @clicommon.pass_db -def AUTO_TECHSUPPORT_FEATURE_add(db, feature_name, state, rate_limit_interval): +def AUTO_TECHSUPPORT_FEATURE_add(db, feature_name, state, rate_limit_interval, available_mem_threshold): """ Add object in AUTO_TECHSUPPORT_FEATURE. """ table = "AUTO_TECHSUPPORT_FEATURE" @@ -282,6 +330,8 @@ def AUTO_TECHSUPPORT_FEATURE_add(db, feature_name, state, rate_limit_interval): data["state"] = state if rate_limit_interval is not None: data["rate_limit_interval"] = rate_limit_interval + if available_mem_threshold is not None: + data["available_mem_threshold"] = available_mem_threshold try: add_entry_validated(db.cfgdb, table, key, data) @@ -303,8 +353,12 @@ def AUTO_TECHSUPPORT_FEATURE_add(db, feature_name, state, rate_limit_interval): "--rate-limit-interval", help="Rate limit interval for the corresponding feature. Configure 0 to explicitly disable", ) +@click.option( + "--available-mem-threshold", + help="Memory threshold; 0 to disable techsupport invocation on memory usage threshold crossing.", +) @clicommon.pass_db -def AUTO_TECHSUPPORT_FEATURE_update(db, feature_name, state, rate_limit_interval): +def AUTO_TECHSUPPORT_FEATURE_update(db, feature_name, state, rate_limit_interval, available_mem_threshold): """ Add object in AUTO_TECHSUPPORT_FEATURE. """ table = "AUTO_TECHSUPPORT_FEATURE" @@ -314,6 +368,8 @@ def AUTO_TECHSUPPORT_FEATURE_update(db, feature_name, state, rate_limit_interval data["state"] = state if rate_limit_interval is not None: data["rate_limit_interval"] = rate_limit_interval + if available_mem_threshold is not None: + data["available_mem_threshold"] = available_mem_threshold try: update_entry_validated(db.cfgdb, table, key, data) diff --git a/config/plugins/pbh.py b/config/plugins/pbh.py index b6726aa154..ce9187a36d 100644 --- a/config/plugins/pbh.py +++ b/config/plugins/pbh.py @@ -6,13 +6,14 @@ CLI Auto-generation tool HLD - https://github.com/Azure/SONiC/pull/78 """ +import os import click import json import ipaddress import re import utilities_common.cli as clicommon -from show.plugins.pbh import deserialize_pbh_counters +from show.plugins.pbh import deserialize_pbh_counters, PBH_COUNTERS_CACHE_FILENAME GRE_KEY_RE = r"^(0x){1}[a-fA-F0-9]{1,8}/(0x){1}[a-fA-F0-9]{1,8}$" @@ -79,8 +80,6 @@ PBH_UPDATE = "UPDATE" PBH_REMOVE = "REMOVE" -PBH_COUNTERS_LOCATION = "/tmp/.pbh_counters.txt" - # # DB interface -------------------------------------------------------------------------------------------------------- # @@ -467,11 +466,14 @@ def serialize_pbh_counters(obj): obj: counters dict. """ + cache = clicommon.UserCache('pbh') + counters_cache_file = os.path.join(cache.get_directory(), PBH_COUNTERS_CACHE_FILENAME) + def remap_keys(obj): return [{'key': k, 'value': v} for k, v in obj.items()] try: - with open(PBH_COUNTERS_LOCATION, 'w') as f: + with open(counters_cache_file, 'w') as f: json.dump(remap_keys(obj), f) except IOError as err: pass diff --git a/config/plugins/sonic-passwh_yang.py b/config/plugins/sonic-passwh_yang.py new file mode 100644 index 0000000000..6cfe2acafe --- /dev/null +++ b/config/plugins/sonic-passwh_yang.py @@ -0,0 +1,380 @@ +import copy +import click +import utilities_common.cli as clicommon +import utilities_common.general as general +from config import config_mgmt + + +# Load sonic-cfggen from source since /usr/local/bin/sonic-cfggen does not have .py extension. +sonic_cfggen = general.load_module_from_source('sonic_cfggen', '/usr/local/bin/sonic-cfggen') + + +def exit_with_error(*args, **kwargs): + """ Print a message with click.secho and abort CLI. + + Args: + args: Positional arguments to pass to click.secho + kwargs: Keyword arguments to pass to click.secho + """ + + click.secho(*args, **kwargs) + raise click.Abort() + + +def validate_config_or_raise(cfg): + """ Validate config db data using ConfigMgmt. + + Args: + cfg (Dict): Config DB data to validate. + Raises: + Exception: when cfg does not satisfy YANG schema. + """ + + try: + cfg = sonic_cfggen.FormatConverter.to_serialized(copy.deepcopy(cfg)) + config_mgmt.ConfigMgmt().loadData(cfg) + except Exception as err: + raise Exception('Failed to validate configuration: {}'.format(err)) + + +def update_entry_validated(db, table, key, data, create_if_not_exists=False): + """ Update entry in table and validate configuration. + If attribute value in data is None, the attribute is deleted. + + Args: + db (swsscommon.ConfigDBConnector): Config DB connector obect. + table (str): Table name to add new entry to. + key (Union[str, Tuple]): Key name in the table. + data (Dict): Entry data. + create_if_not_exists (bool): + In case entry does not exists already a new entry + is not created if this flag is set to False and + creates a new entry if flag is set to True. + Raises: + Exception: when cfg does not satisfy YANG schema. + """ + + cfg = db.get_config() + cfg.setdefault(table, {}) + + if not data: + raise Exception(f"No field/values to update {key}") + + if create_if_not_exists: + cfg[table].setdefault(key, {}) + + if key not in cfg[table]: + raise Exception(f"{key} does not exist") + + entry_changed = False + for attr, value in data.items(): + if value == cfg[table][key].get(attr): + continue + entry_changed = True + if value is None: + cfg[table][key].pop(attr, None) + else: + cfg[table][key][attr] = value + + if not entry_changed: + return + + validate_config_or_raise(cfg) + db.set_entry(table, key, cfg[table][key]) + + +@click.group(name="passw-hardening", + cls=clicommon.AliasedGroup) +def PASSW_HARDENING(): + """ PASSWORD HARDENING part of config_db.json """ + + pass + + + + +@PASSW_HARDENING.group(name="policies", + cls=clicommon.AliasedGroup) +@clicommon.pass_db +def PASSW_HARDENING_POLICIES(db): + """ """ + + pass + + + + +@PASSW_HARDENING_POLICIES.command(name="state") + +@click.argument( + "state", + nargs=1, + required=True, +) +@clicommon.pass_db +def PASSW_HARDENING_POLICIES_state(db, state): + """ state of the feature """ + + table = "PASSW_HARDENING" + key = "POLICIES" + data = { + "state": state, + } + try: + update_entry_validated(db.cfgdb, table, key, data, create_if_not_exists=True) + except Exception as err: + exit_with_error(f"Error: {err}", fg="red") + + + +@PASSW_HARDENING_POLICIES.command(name="expiration") + +@click.argument( + "expiration", + nargs=1, + required=True, +) +@clicommon.pass_db +def PASSW_HARDENING_POLICIES_expiration(db, expiration): + """ expiration time (days unit) """ + + table = "PASSW_HARDENING" + key = "POLICIES" + data = { + "expiration": expiration, + } + try: + update_entry_validated(db.cfgdb, table, key, data, create_if_not_exists=True) + except Exception as err: + exit_with_error(f"Error: {err}", fg="red") + + + +@PASSW_HARDENING_POLICIES.command(name="expiration-warning") + +@click.argument( + "expiration-warning", + nargs=1, + required=True, +) +@clicommon.pass_db +def PASSW_HARDENING_POLICIES_expiration_warning(db, expiration_warning): + """ expiration warning time (days unit) """ + + table = "PASSW_HARDENING" + key = "POLICIES" + data = { + "expiration_warning": expiration_warning, + } + try: + update_entry_validated(db.cfgdb, table, key, data, create_if_not_exists=True) + except Exception as err: + exit_with_error(f"Error: {err}", fg="red") + + + +@PASSW_HARDENING_POLICIES.command(name="history-cnt") + +@click.argument( + "history-cnt", + nargs=1, + required=True, +) +@clicommon.pass_db +def PASSW_HARDENING_POLICIES_history_cnt(db, history_cnt): + """ num of old password that the system will recorded """ + + table = "PASSW_HARDENING" + key = "POLICIES" + data = { + "history_cnt": history_cnt, + } + try: + update_entry_validated(db.cfgdb, table, key, data, create_if_not_exists=True) + except Exception as err: + exit_with_error(f"Error: {err}", fg="red") + + + +@PASSW_HARDENING_POLICIES.command(name="len-min") + +@click.argument( + "len-min", + nargs=1, + required=True, +) +@clicommon.pass_db +def PASSW_HARDENING_POLICIES_len_min(db, len_min): + """ password min length """ + + table = "PASSW_HARDENING" + key = "POLICIES" + data = { + "len_min": len_min, + } + try: + update_entry_validated(db.cfgdb, table, key, data, create_if_not_exists=True) + except Exception as err: + exit_with_error(f"Error: {err}", fg="red") + + + +@PASSW_HARDENING_POLICIES.command(name="reject-user-passw-match") + +@click.argument( + "reject-user-passw-match", + nargs=1, + required=True, +) +@clicommon.pass_db +def PASSW_HARDENING_POLICIES_reject_user_passw_match(db, reject_user_passw_match): + """ username password match """ + + table = "PASSW_HARDENING" + key = "POLICIES" + data = { + "reject_user_passw_match": reject_user_passw_match, + } + try: + update_entry_validated(db.cfgdb, table, key, data, create_if_not_exists=True) + except Exception as err: + exit_with_error(f"Error: {err}", fg="red") + + + +@PASSW_HARDENING_POLICIES.command(name="lower-class") + +@click.argument( + "lower-class", + nargs=1, + required=True, +) +@clicommon.pass_db +def PASSW_HARDENING_POLICIES_lower_class(db, lower_class): + """ password lower chars policy """ + + table = "PASSW_HARDENING" + key = "POLICIES" + data = { + "lower_class": lower_class, + } + try: + update_entry_validated(db.cfgdb, table, key, data, create_if_not_exists=True) + except Exception as err: + exit_with_error(f"Error: {err}", fg="red") + + + +@PASSW_HARDENING_POLICIES.command(name="upper-class") + +@click.argument( + "upper-class", + nargs=1, + required=True, +) +@clicommon.pass_db +def PASSW_HARDENING_POLICIES_upper_class(db, upper_class): + """ password upper chars policy """ + + table = "PASSW_HARDENING" + key = "POLICIES" + data = { + "upper_class": upper_class, + } + try: + update_entry_validated(db.cfgdb, table, key, data, create_if_not_exists=True) + except Exception as err: + exit_with_error(f"Error: {err}", fg="red") + + + +@PASSW_HARDENING_POLICIES.command(name="digits-class") + +@click.argument( + "digits-class", + nargs=1, + required=True, +) +@clicommon.pass_db +def PASSW_HARDENING_POLICIES_digits_class(db, digits_class): + """ password digits chars policy """ + + table = "PASSW_HARDENING" + key = "POLICIES" + data = { + "digits_class": digits_class, + } + try: + update_entry_validated(db.cfgdb, table, key, data, create_if_not_exists=True) + except Exception as err: + exit_with_error(f"Error: {err}", fg="red") + + + +@PASSW_HARDENING_POLICIES.command(name="special-class") + +@click.argument( + "special-class", + nargs=1, + required=True, +) +@clicommon.pass_db +def PASSW_HARDENING_POLICIES_special_class(db, special_class): + """ password special chars policy """ + + table = "PASSW_HARDENING" + key = "POLICIES" + data = { + "special_class": special_class, + } + try: + update_entry_validated(db.cfgdb, table, key, data, create_if_not_exists=True) + except Exception as err: + exit_with_error(f"Error: {err}", fg="red") + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +def register(cli): + """ Register new CLI nodes in root CLI. + + Args: + cli: Root CLI node. + Raises: + Exception: when root CLI already has a command + we are trying to register. + """ + cli_node = PASSW_HARDENING + if cli_node.name in cli.commands: + raise Exception(f"{cli_node.name} already exists in CLI") + cli.add_command(PASSW_HARDENING) diff --git a/config/vlan.py b/config/vlan.py index 80b4ff4984..6ea6ee7d65 100644 --- a/config/vlan.py +++ b/config/vlan.py @@ -60,6 +60,10 @@ def del_vlan(db, vid): if keys: ctx.fail("VLAN ID {} can not be removed. First remove all members assigned to this VLAN.".format(vid)) + vxlan_table = db.cfgdb.get_table('VXLAN_TUNNEL_MAP') + for vxmap_key, vxmap_data in vxlan_table.items(): + if vxmap_data['vlan'] == 'Vlan{}'.format(vid): + ctx.fail("vlan: {} can not be removed. First remove vxlan mapping '{}' assigned to VLAN".format(vid, '|'.join(vxmap_key)) ) db.cfgdb.set_entry('VLAN', 'Vlan{}'.format(vid), None) @@ -69,7 +73,7 @@ def restart_ndppd(): ndppd_config_gen_cmd = "sonic-cfggen -d -t /usr/share/sonic/templates/ndppd.conf.j2,/etc/ndppd.conf" ndppd_restart_cmd = "supervisorctl restart ndppd" - output = clicommon.run_command(verify_swss_running_cmd, return_cmd=True) + output, _ = clicommon.run_command(verify_swss_running_cmd, return_cmd=True) if output and output.strip() != "running": click.echo(click.style('SWSS container is not running, changes will take effect the next time the SWSS container starts', fg='red'),) diff --git a/config/vxlan.py b/config/vxlan.py index bfda1f4eff..be0a961001 100644 --- a/config/vxlan.py +++ b/config/vxlan.py @@ -38,6 +38,10 @@ def del_vxlan(db, vxlan_name): """Del VXLAN""" ctx = click.get_current_context() + vxlan_keys = db.cfgdb.get_keys('VXLAN_TUNNEL') + if vxlan_name not in vxlan_keys: + ctx.fail("Vxlan tunnel {} does not exist".format(vxlan_name)) + vxlan_keys = db.cfgdb.get_keys('VXLAN_EVPN_NVO') if not vxlan_keys: vxlan_count = 0 @@ -56,6 +60,12 @@ def del_vxlan(db, vxlan_name): if(vxlan_count > 0): ctx.fail("Please delete all VLAN VNI mappings.") + vnet_table = db.cfgdb.get_table('VNET') + vnet_keys = vnet_table.keys() + for vnet_key in vnet_keys: + if ('vxlan_tunnel' in vnet_table[vnet_key] and vnet_table[vnet_key]['vxlan_tunnel'] == vxlan_name): + ctx.fail("Please delete all VNET configuration referencing the tunnel " + vxlan_name) + db.cfgdb.set_entry('VXLAN_TUNNEL', vxlan_name, None) @vxlan.group('evpn_nvo') diff --git a/counterpoll/main.py b/counterpoll/main.py index f3befe1311..ad15c8c248 100644 --- a/counterpoll/main.py +++ b/counterpoll/main.py @@ -419,9 +419,9 @@ def show(): if buffer_pool_wm_info: data.append(["BUFFER_POOL_WATERMARK_STAT", buffer_pool_wm_info.get("POLL_INTERVAL", DEFLT_60_SEC), buffer_pool_wm_info.get("FLEX_COUNTER_STATUS", DISABLE)]) if acl_info: - data.append([ACL, pg_drop_info.get("POLL_INTERVAL", DEFLT_10_SEC), acl_info.get("FLEX_COUNTER_STATUS", DISABLE)]) + data.append([ACL, acl_info.get("POLL_INTERVAL", DEFLT_10_SEC), acl_info.get("FLEX_COUNTER_STATUS", DISABLE)]) if tunnel_info: - data.append(["TUNNEL_STAT", rif_info.get("POLL_INTERVAL", DEFLT_10_SEC), rif_info.get("FLEX_COUNTER_STATUS", DISABLE)]) + data.append(["TUNNEL_STAT", tunnel_info.get("POLL_INTERVAL", DEFLT_10_SEC), tunnel_info.get("FLEX_COUNTER_STATUS", DISABLE)]) if trap_info: data.append(["FLOW_CNT_TRAP_STAT", trap_info.get("POLL_INTERVAL", DEFLT_10_SEC), trap_info.get("FLEX_COUNTER_STATUS", DISABLE)]) if route_info: diff --git a/crm/main.py b/crm/main.py index f728f87dd9..9b0d06e89a 100644 --- a/crm/main.py +++ b/crm/main.py @@ -237,9 +237,9 @@ def polling(ctx): @polling.command() @click.pass_context -@click.argument('interval', type=click.INT) +@click.argument('interval', type=click.IntRange(1, 9999)) def interval(ctx, interval): - """CRM polling interval configuration""" + """CRM polling interval configuration in seconds (range: 1-9999)""" ctx.obj["crm"].config('polling_interval', interval) @config.group() diff --git a/doc/Command-Reference.md b/doc/Command-Reference.md old mode 100644 new mode 100755 index 4beef0cafa..d28aaa6bb4 --- a/doc/Command-Reference.md +++ b/doc/Command-Reference.md @@ -1,10876 +1,33553 @@ -# SONiC Command Line Interface Guide - -## Table of Contents - -* [Document History](#document-history) -* [Introduction](#introduction) -* [Basic Tasks](#basic-tasks) - * [SSH Login](#ssh-login) - * [Show Management Interface](#show-management-interface) - * [Configuring Management Interface](#configuring-management-interface) -* [Getting Help](#getting-help) - * [Help for Config Commands](#help-for-config-commands) - * [Help for Show Commands](#help-for-show-commands) -* [Basic Show Commands](#basic-show-commands) - * [Show Versions](#show-versions) - * [Show System Status](#show-system-status) - * [Show Hardware Platform](#show-hardware-platform) - * [Transceivers](#transceivers) -* [AAA & TACACS+](#aaa--tacacs) - * [AAA](#aaa) - * [AAA show commands](#aaa-show-commands) - * [AAA config commands](#aaa-config-commands) - * [TACACS+](#tacacs) - * [TACACS+ show commands](#tacacs-show-commands) - * [TACACS+ config commands](#tacacs-config-commands) -* [ACL](#acl) - * [ACL show commands](#acl-show-commands) - * [ACL config commands](#acl-config-commands) -* [ARP & NDP](#arp--ndp) - * [ARP show commands](#arp-show-commands) - * [NDP show commands](#ndp-show-commands) -* [BFD](#bfd) - * [BFD show commands](#bfd-show-commands) -* [BGP](#bgp) - * [BGP show commands](#bgp-show-commands) - * [BGP config commands](#bgp-config-commands) -* [Console](#console) - * [Console show commands](#console-show-commands) - * [Console config commands](#console-config-commands) - * [Console connect commands](#console-connect-commands) - * [Console clear commands](#console-clear-commands) -* [DHCP Relay](#dhcp-relay) - * [DHCP Relay config commands](#dhcp-relay-config-commands) -* [Drop Counters](#drop-counters) - * [Drop Counter show commands](#drop-counters-show-commands) - * [Drop Counter config commands](#drop-counters-config-commands) - * [Drop Counter clear commands](#drop-counters-clear-commands) -* [Dynamic Buffer Management](#dynamic-buffer-management) - * [Configuration commands](#configuration-commands) - * [Show commands](#show-commands) -* [ECN](#ecn) - * [ECN show commands](#ecn-show-commands) - * [ECN config commands](#ecn-config-commands) -* [Feature](#feature) - * [Feature show commands](#feature-show-commands) - * [Feature config commands](#feature-config-commands) -* [Flow Counters](#flow-counters) - * [Flow Counters show commands](#flow-counters-show-commands) - * [Flow Counters clear commands](#flow-counters-clear-commands) - * [Flow Counters config commands](#flow-counters-config-commands) -* [Gearbox](#gearbox) - * [Gearbox show commands](#gearbox-show-commands) -* [Interfaces](#interfaces) - * [Interface Show Commands](#interface-show-commands) - * [Interface Config Commands](#interface-config-commands) -* [Interface Naming Mode](#interface-naming-mode) - * [Interface naming mode show commands](#interface-naming-mode-show-commands) - * [Interface naming mode config commands](#interface-naming-mode-config-commands) - * [Interface Vrf binding](#interface-vrf-binding) - * [Interface vrf bind & unbind config commands](#interface-vrf-bind-&-unbind-config-commands) - * [Interface vrf binding show commands](#interface-vrf-binding-show-commands) -* [IP / IPv6](#ip--ipv6) - * [IP show commands](#ip-show-commands) - * [IPv6 show commands](#ipv6-show-commands) -* [IPv6 Link Local](#ipv6-link-local) - * [IPv6 Link Local config commands](#ipv6-link-local-config-commands) - * [IPv6 Link Local show commands](#ipv6-link-local-show-commands) -* [Kubernetes](#Kubernetes) - * [Kubernetes show commands](#Kubernetes-show-commands) - * [Kubernetes config commands](#Kubernetes-config-commands) -* [Linux Kernel Dump](#kdump) - * [Linux Kernel Dump show commands](#kdump-show-commands) - * [Linux Kernel Dump config commands](#kdump-config-commands) -* [LLDP](#lldp) - * [LLDP show commands](#lldp-show-commands) -* [Loading, Reloading And Saving Configuration](#loading-reloading-and-saving-configuration) - * [Loading configuration from JSON file](#loading-configuration-from-json-file) - * [Loading configuration from minigraph (XML) file](#loading-configuration-from-minigraph-xml-file) - * [Reloading Configuration](#reloading-configuration) - * [Loading Management Configuration](#loading-management-configuration) - * [Saving Configuration to a File for Persistence](saving-configuration-to-a-file-for-persistence) - * [Loopback Interfaces](#loopback-interfaces) - * [Loopback show commands](#loopback-show-commands) - * [Loopback config commands](#loopback-config-commands) -* [VRF Configuration](#vrf-configuration) - * [VRF show commands](#vrf-show-commands) - * [VRF config commands](#vrf-config-commands) -* [Management VRF](#Management-VRF) - * [Management VRF Show commands](#management-vrf-show-commands) - * [Management VRF Config commands](#management-vrf-config-commands) -* [Mirroring](#mirroring) - * [Mirroring Show commands](#mirroring-show-commands) - * [Mirroring Config commands](#mirroring-config-commands) -* [Muxcable](#muxcable) - * [Muxcable Show commands](#muxcable-show-commands) - * [Muxcable Config commands](#muxcable-config-commands) -* [NAT](#nat) - * [NAT Show commands](#nat-show-commands) - * [NAT Config commands](#nat-config-commands) - * [NAT Clear commands](#nat-clear-commands) -* [NTP](#ntp) - * [NTP show commands](#ntp-show-commands) - * [NTP config commands](#ntp-config-commands) -* [NVGRE](#nvgre) - * [NVGRE show commands](#nvgre-show-commands) - * [NVGRE config commands](#nvgre-config-commands) -* [PBH](#pbh) - * [PBH show commands](#pbh-show-commands) - * [PBH config commands](#pbh-config-commands) -* [PFC Watchdog Commands](#pfc-watchdog-commands) -* [Platform Component Firmware](#platform-component-firmware) - * [Platform Component Firmware show commands](#platform-component-firmware-show-commands) - * [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) -* [QoS](#qos) - * [QoS Show commands](#qos-show-commands) - * [PFC](#pfc) - * [Queue And Priority-Group](#queue-and-priority-group) - * [Buffer Pool](#buffer-pool) - * [QoS config commands](#qos-config-commands) -* [sFlow](#sflow) - * [sFlow Show commands](#sflow-show-commands) - * [sFlow Config commands](#sflow-config-commands) -* [SNMP](#snmp) - * [SNMP Show commands](#snmp-show-commands) - * [SNMP Config commands](#snmp-config-commands) -* [Startup & Running Configuration](#startup--running-configuration) - * [Startup Configuration](#startup-configuration) - * [Running Configuration](#running-configuration) -* [Static routing](#static-routing) -* [Subinterfaces](#subinterfaces) - * [Subinterfaces Show Commands](#subinterfaces-show-commands) - * [Subinterfaces Config Commands](#subinterfaces-config-commands) -* [Syslog](#syslog) - * [Syslog config commands](#syslog-config-commands) -* [System State](#system-state) - * [Processes](#processes) - * [Services & Memory](#services--memory) -* [System-Health](#System-Health) -* [VLAN & FDB](#vlan--fdb) - * [VLAN](#vlan) - * [VLAN show commands](#vlan-show-commands) - * [VLAN Config commands](#vlan-config-commands) - * [FDB](#fdb) - * [FDB show commands](#fdb-show-commands) -* [VxLAN & Vnet](#vxlan--vnet) - * [VxLAN](#vxlan) - * [VxLAN show commands](#vxlan-show-commands) - * [Vnet](#vnet) - * [Vnet show commands](#vnet-show-commands) -* [Warm Reboot](#warm-reboot) -* [Warm Restart](#warm-restart) - * [Warm Restart show commands](#warm-restart-show-commands) - * [Warm Restart Config commands](#warm-restart-config-commands) -* [Watermark](#watermark) - * [Watermark Show commands](#watermark-show-commands) - * [Watermark Config commands](#watermark-config-commands) -* [Software Installation and Management](#software-installation-and-management) - * [SONiC Package Manager](#sonic-package-manager) - * [SONiC Installer](#sonic-installer) -* [Troubleshooting Commands](#troubleshooting-commands) - * [Debug Dumps](#debug-dumps) - * [Event Driven Techsupport Invocation](#event-driven-techsupport-invocation) -* [Routing Stack](#routing-stack) -* [Quagga BGP Show Commands](#Quagga-BGP-Show-Commands) -* [ZTP Configuration And Show Commands](#ztp-configuration-and-show-commands) - * [ ZTP show commands](#ztp-show-commands) - * [ZTP configuration commands](#ztp-configuration-commands) - -## Document History - -| Version | Modification Date | Details | -| --- | --- | --- | -| v6 | May-06-2021 | Add SNMP show and config commands | -| v5 | Nov-05-2020 | Add document for console commands | -| v4 | Oct-17-2019 | Unify usage statements and other formatting; Replace tabs with spaces; Modify heading sizes; Fix spelling, grammar and other errors; Fix organization of new commands | -| v3 | Jun-26-2019 | Update based on 201904 (build#19) release, "config interface" command changes related to interfacename order, FRR/Quagga show command changes, platform specific changes, ACL show changes and few formatting changes | -| v2 | Apr-22-2019 | CLI Guide for SONiC 201811 version (build#32) with complete "config" command set | -| v1 | Mar-23-2019 | Initial version of CLI Guide with minimal command set | - -## Introduction -SONiC is an open source network operating system based on Linux that runs on switches from multiple vendors and ASICs. SONiC offers a full-suite of network functionality, like BGP and RDMA, that has been production-hardened in the data centers of some of the largest cloud-service providers. It offers teams the flexibility to create the network solutions they need while leveraging the collective strength of a large ecosystem and community. - -SONiC software shall be loaded in these [supported devices](https://github.com/Azure/SONiC/wiki/Supported-Devices-and-Platforms) and this CLI guide shall be used to configure the devices as well as to display the configuration, state and status. - -Follow the [Quick Start Guide](https://github.com/Azure/SONiC/wiki/Quick-Start) to boot the device in ONIE mode, install the SONiC software using the steps specified in the document and login to the device using the default username and password. - -After logging into the device, SONiC software can be configured in following three methods. - 1. Command Line Interface (CLI) - 2. [config_db.json](https://github.com/Azure/SONiC/wiki/Configuration) - 3. [minigraph.xml](https://github.com/Azure/SONiC/wiki/Configuration-with-Minigraph-(~Sep-2017)) - -This document explains the first method and gives the complete list of commands that are supported in SONiC 201904 version (build#19). -All the configuration commands need root privileges to execute them. Note that show commands can be executed by all users without the root privileges. -Root privileges can be obtained either by using "sudo" keyword in front of all config commands, or by going to root prompt using "sudo -i". -Note that all commands are case sensitive. - -- Example: - ``` - admin@sonic:~$ sudo config aaa authentication login tacacs+ - - OR - - admin@sonic:~$ sudo -i - root@sonic:~# config aaa authentication login tacacs+ - ``` - -Note that the command list given in this document is just a subset of all possible configurations in SONiC. -Please follow config_db.json based configuration for the complete list of configuration options. - -**Scope of this Document** - -It is assumed that all configuration commands start with the keyword “config” as prefix. -Any other scripts/utilities/commands that need user configuration control are wrapped as sub-commands under the “config” command. -The direct scripts/utilities/commands (examples given below) that are not wrapped under the "config" command are not in the scope of this document. - 1. acl_loader – This script is already wrapped inside “config acl” command; i.e. any ACL configuration that user is allowed to do is already part of “config acl” command; users are not expected to use the acl_loader script directly and hence this document need not explain the “acl_loader” script. - 2. crm – this command is not explained in this document. - 3. sonic-clear, sfputil, etc., This document does not explain these scripts also. - -## Basic Tasks - -This section covers the basic configurations related to the following: - 1. [SSH login](#SSH-Login) - 2. [Configuring the Management Interface](#Configuring-Management-Interface) - -### SSH Login - -All SONiC devices support both the serial console based login and the SSH based login by default. -The default credential (if not modified at image build time) for login is `admin/YourPaSsWoRd`. -In case of SSH login, users can login to the management interface (eth0) IP address after configuring the same using serial console. -Refer the following section for configuring the IP address for management interface. - -- Example: - ``` - At Console: - Debian GNU/Linux 9 sonic ttyS1 - - sonic login: admin - Password: YourPaSsWoRd - - SSH from any remote server to sonic can be done by connecting to SONiC IP - user@debug:~$ ssh admin@sonic_ip_address(or SONIC DNS Name) - admin@sonic's password: - ``` - -By default, login takes the user to the default prompt from which all the show commands can be executed. - -Go Back To [Beginning of the document](#) or [Beginning of this section](#basic-tasks) - -### Show Management Interface - -Please check [show ip interfaces](#show-ip-interfaces) - -### Configuring Management Interface - -The management interface (eth0) in SONiC is configured (by default) to use DHCP client to get the IP address from the DHCP server. Connect the management interface to the same network in which your DHCP server is connected and get the IP address from DHCP server. -The IP address received from DHCP server can be verified using the `/sbin/ifconfig eth0` Linux command. - -SONiC provides a CLI to configure the static IP for the management interface. There are few ways by which a static IP address can be configured for the management interface. - 1. Use the `config interface ip add eth0` command. - - Example: - ``` - admin@sonic:~$ sudo config interface ip add eth0 20.11.12.13/24 20.11.12.254 - ``` - 2. Use config_db.json and configure the MGMT_INTERFACE key with the appropriate values. Refer [here](https://github.com/Azure/SONiC/wiki/Configuration#Management-Interface) - 3. Use minigraph.xml and configure "ManagementIPInterfaces" tag inside "DpgDesc" tag as given at the [page](https://github.com/Azure/SONiC/wiki/Configuration-with-Minigraph-(~Sep-2017)) - -Once the IP address is configured, the same can be verified using either `show management_interface address` command or the `/sbin/ifconfig eth0` linux command. -Users can SSH login to this management interface IP address from their management network. - -- Example: - ``` - admin@sonic:~$ /sbin/ifconfig eth0 - eth0: flags=4163 mtu 1500 - inet 10.11.11.13 netmask 255.255.255.0 broadcast 10.11.12.255 - ``` -Go Back To [Beginning of the document](#) or [Beginning of this section](#basic-tasks) - -## Getting Help - -Subsections: - 1. [Help for Config Commands](#Config-Help) - 2. [Help for Show Commands](#Show-Help) - 3. [Show Versions](#Show-Versions) - 4. [Show System Status](#Show-System-Status) - 5. [Show Hardware Platform](#Show-Hardware-Platform) - -### Help for Config Commands - -All commands have in-built help that aids the user in understanding the command as well as the possible sub-commands and options. -"--help" can be used at any level of the command; i.e. it can be used at the command level, or sub-command level or at argument level. The in-built help will display the available possibilities corresponding to that particular command/sub-command. - -**config --help** - -This command lists all the possible configuration commands at the top level. - -- Usage: - ``` - config --help - ``` - -- Example: - ``` - admin@sonic:~$ config --help - Usage: config [OPTIONS] COMMAND [ARGS] - SONiC command line - 'config' command - - Options: - --help Show this message and exit. - - Commands: - aaa AAA command line - acl ACL-related configuration tasks - bgp BGP-related configuration tasks - ecn ECN-related configuration tasks - feature Modify configuration of features - hostname Change device hostname without impacting traffic - interface Interface-related configuration tasks - interface_naming_mode Modify interface naming mode for interacting... - kubernetes Kubernetes server related configuration - load Import a previous saved config DB dump file. - load_mgmt_config Reconfigure hostname and mgmt interface based... - load_minigraph Reconfigure based on minigraph. - loopback Loopback-related configuration tasks. - mirror_session - nat NAT-related configuration tasks - platform Platform-related configuration tasks - portchannel - qos - reload Clear current configuration and import a... - route route-related configuration tasks - save Export current config DB to a file on disk. - tacacs TACACS+ server configuration - vlan VLAN-related configuration tasks - vrf VRF-related configuration tasks - warm_restart warm_restart-related configuration tasks - watermark Configure watermark - ``` -Go Back To [Beginning of the document](#) or [Beginning of this section](#getting-help) - -### Help For Show Commands - -**show help** - -This command displays the full list of show commands available in the software; the output of each of those show commands can be used to analyze, debug or troubleshoot the network node. - -- Usage: - ``` - show (-?|-h|--help) - ``` - -- Example: - ``` - admin@sonic:~$ show -? - Usage: show [OPTIONS] COMMAND [ARGS]... - SONiC command line - 'show' command - - Options: - -?, -h, --help Show this message and exit. - - Commands: - aaa Show AAA configuration - acl Show ACL related information - arp Show IP ARP table - buffer_pool Show details of the Buffer-pools - clock Show date and time - ecn Show ECN configuration - environment Show environmentals (voltages, fans, temps) - feature Show feature status - interfaces Show details of the network interfaces - ip Show IP (IPv4) commands - ipv6 Show IPv6 commands - kubernetes Show kubernetes commands - line Show all /dev/ttyUSB lines and their info - lldp Show LLDP information - logging Show system log - mac Show MAC (FDB) entries - mirror_session Show existing everflow sessions - mmu Show mmu configuration - muxcable Show muxcable information - nat Show details of the nat - ndp Show IPv6 Neighbour table - ntp Show NTP information - pfc Show details of the priority-flow-control... - platform Show platform-specific hardware info - priority-group Show details of the PGs - processes Show process information - queue Show details of the queues - reboot-cause Show cause of most recent reboot - route-map Show route-map - runningconfiguration Show current running configuration... - services Show all daemon services - startupconfiguration Show startup configuration information - subinterfaces Show details of the sub port interfaces - system-memory Show memory information - tacacs Show TACACS+ configuration - techsupport Gather information for troubleshooting - uptime Show system uptime - users Show users - version Show version information - vlan Show VLAN information - vrf Show vrf config - warm_restart Show warm restart configuration and state - watermark Show details of watermark - ``` - -The same syntax applies to all subgroups of `show` which themselves contain subcommands, and subcommands which accept options/arguments. - -- Example: - ``` - admin@sonic:~$ show interfaces -? - - Show details of the network interfaces - - Options: - -?, -h, --help Show this message and exit. - - Commands: - counters Show interface counters - description Show interface status, protocol and... - naming_mode Show interface naming_mode status - neighbor Show neighbor related information - portchannel Show PortChannel information - status Show Interface status information - tpid Show Interface tpid information - transceiver Show SFP Transceiver information - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#getting-help) - -## Basic Show Commands - -Subsections: - 1. [Show Versions](#Show-Versions) - 2. [Show System Status](#Show-System-Status) - 3. [Show Hardware Platform](#Show-Hardware-Platform) - -### Show Versions - -**show version** - -This command displays software component versions of the currently running SONiC image. This includes the SONiC image version as well as Docker image versions. -This command displays relevant information as the SONiC and Linux kernel version being utilized, as well as the ID of the commit used to build the SONiC image. The second section of the output displays the various docker images and their associated IDs. - -- Usage: - ``` - show version - ``` - -- Example: - ``` - admin@sonic:~$ show version - SONiC Software Version: SONiC.HEAD.32-21ea29a - Distribution: Debian 9.8 - Kernel: 4.9.0-8-amd64 - Build commit: 21ea29a - Build date: Fri Mar 22 01:55:48 UTC 2019 - Built by: johnar@jenkins-worker-4 - - Platform: x86_64-mlnx_msn2700-r0 - HwSKU: Mellanox-SN2700 - ASIC: mellanox - ASIC Count: 1 - Serial Number: MT1822K07815 - Model Number: MSN2700-CS2FO - Hardware Rev: A1 - Uptime: 14:40:15 up 3 min, 1 user, load average: 1.26, 1.45, 0.66 - Date: Fri 22 Mar 2019 14:40:15 - - Docker images: - REPOSITORY TAG IMAGE ID SIZE - docker-syncd-brcm HEAD.32-21ea29a 434240daff6e 362MB - docker-syncd-brcm latest 434240daff6e 362MB - docker-orchagent-brcm HEAD.32-21ea29a e4f9c4631025 287MB - docker-orchagent-brcm latest e4f9c4631025 287MB - docker-nat HEAD.32-21ea29a 46075edc1c69 305MB - docker-nat latest 46075edc1c69 305MB - docker-lldp-sv2 HEAD.32-21ea29a 9681bbfea3ac 275MB - docker-lldp-sv2 latest 9681bbfea3ac 275MB - docker-dhcp-relay HEAD.32-21ea29a 2db34c7bc6f4 257MB - docker-dhcp-relay latest 2db34c7bc6f4 257MB - docker-database HEAD.32-21ea29a badc6fc84cdb 256MB - docker-database latest badc6fc84cdb 256MB - docker-snmp-sv2 HEAD.32-21ea29a e2776e2a30b7 295MB - docker-snmp-sv2 latest e2776e2a30b7 295MB - docker-teamd HEAD.32-21ea29a caf957cd2ad1 275MB - docker-teamd latest caf957cd2ad1 275MB - docker-router-advertiser HEAD.32-21ea29a b1a62023958c 255MB - docker-router-advertiser latest b1a62023958c 255MB - docker-platform-monitor HEAD.32-21ea29a 40b40a4b2164 287MB - docker-platform-monitor latest 40b40a4b2164 287MB - docker-fpm-quagga HEAD.32-21ea29a 546036fe6838 282MB - docker-fpm-quagga latest 546036fe6838 282MB - ``` -Go Back To [Beginning of the document](#) or [Beginning of this section](#basic-show-commands) - - -### Show System Status -This sub-section explains some set of sub-commands that are used to display the status of various parameters pertaining to the physical state of the network node. - -**show clock** - -This command displays the current date and time configured on the system - -- Usage: - ``` - show clock - ``` - -- Example: - ``` - admin@sonic:~$ show clock - Mon Mar 25 20:25:16 UTC 2019 - ``` - -**show boot** - -This command displays the current OS image, the image to be loaded on next reboot, and lists all the available images installed on the device - -- Usage: - ``` - show boot - ``` - -- Example: - ``` - admin@sonic:~$ show boot - Current: SONiC-OS-20181130.31 - Next: SONiC-OS-20181130.31 - Available: - SONiC-OS-20181130.31 - ``` - -**show environment** - -This command displays the platform environmentals, such as voltages, temperatures and fan speeds - -- Usage: - ``` - show environment - ``` - -- Example: - ``` - admin@sonic:~$ show environment - coretemp-isa-0000 - Adapter: ISA adapter - Core 0: +28.0 C (high = +98.0 C, crit = +98.0 C) - Core 1: +28.0 C (high = +98.0 C, crit = +98.0 C) - Core 2: +28.0 C (high = +98.0 C, crit = +98.0 C) - Core 3: +28.0 C (high = +98.0 C, crit = +98.0 C) - SMF_Z9100_ON-isa-0000 - Adapter: ISA adapter - CPU XP3R3V_EARLY: +3.22 V - <... few more things ...> - - Onboard Temperature Sensors: - CPU: 30 C - BCM56960 (PSU side): 35 C - <... few more things ...> - - Onboard Voltage Sensors: - CPU XP3R3V_EARLY 3.22 V - <... few more things ...> - - Fan Trays: - Fan Tray 1: - Fan1 Speed: 6192 RPM - Fan2 Speed: 6362 RPM - Fan1 State: Normal - Fan2 State: Normal - Air Flow: F2B - <... few more things ...> - - PSUs: - PSU 1: - Input: AC - <... few more things ...> - ``` -NOTE: The show output has got lot of information; only the sample output is given in the above example. -Though the displayed output slightly differs from one platform to another platform, the overall content will be similar to the example mentioned above. - -**show reboot-cause** - -This command displays the cause of the previous reboot - -- Usage: - ``` - show reboot-cause - ``` - -- Example: - ``` - admin@sonic:~$ show reboot-cause - User issued reboot command [User: admin, Time: Mon Mar 25 01:02:03 UTC 2019] - ``` - -**show reboot-cause history** - -This command displays the history of the previous reboots up to 10 entry - -- Usage: - ``` - show reboot-cause history - ``` - -- Example: - ``` - admin@sonic:~$ show reboot-cause history - Name Cause Time User Comment - ------------------- ----------- ---------------------------- ------ --------- - 2020_10_09_02_33_06 reboot Fri Oct 9 02:29:44 UTC 2020 admin - 2020_10_09_01_56_59 reboot Fri Oct 9 01:53:49 UTC 2020 admin - 2020_10_09_02_00_53 fast-reboot Fri Oct 9 01:58:04 UTC 2020 admin - 2020_10_09_04_53_58 warm-reboot Fri Oct 9 04:51:47 UTC 2020 admin - ``` - -**show uptime** - -This command displays the current system uptime - -- Usage: - ``` - show uptime - ``` - -- Example: - ``` - admin@sonic:~$ show uptime - up 2 days, 21 hours, 30 minutes - ``` - -**show logging** - -This command displays all the currently stored log messages. -All the latest processes and corresponding transactions are stored in the "syslog" file. -This file is saved in the path `/var/log` and can be viewed by giving the command ` sudo cat syslog` as this requires root login. - -- Usage: - ``` - show logging [( [-l|--lines ]) | (-f|--follow)] - ``` - -- Example: - ``` - admin@sonic:~$ show logging - ``` - -It can be useful to pipe the output from `show logging` to the command `more` in order to examine one screenful of log messages at a time - -- Example: - ``` - admin@sonic:~$ show logging | more - ``` - -Optionally, you can specify a process name in order to display only log messages mentioning that process - -- Example: - ``` - admin@sonic:~$ show logging sensord - ``` - -Optionally, you can specify a number of lines to display using the `-l` or `--lines` option. Only the most recent N lines will be displayed. Also note that this option can be combined with a process name. - -- Examples: - ``` - admin@sonic:~$ show logging --lines 50 - ``` - ``` - admin@sonic:~$ show logging sensord --lines 50 - ``` - -Optionally, you can follow the log live as entries are written to it by specifying the `-f` or `--follow` flag - -- Example: - ``` - admin@sonic:~$ show logging --follow - ``` - -**show users** - -This command displays a list of users currently logged in to the device - -- Usage: - ``` - show users - ``` - -- Examples: - ``` - admin@sonic:~$ show users - admin pts/9 Mar 25 20:31 (100.127.20.23) - - admin@sonic:~$ show users - admin ttyS1 2019-03-25 20:31 - ``` -Go Back To [Beginning of the document](#) or [Beginning of this section](#basic-show-commands) - -### Show Hardware Platform - -The information displayed in this set of commands partially overlaps with the one generated by “show envinronment” instruction. In this case though, the information is presented in a more succinct fashion. In the future these two CLI stanzas may end up getting combined. - -**show platform summary** - -This command displays a summary of the device's hardware platform - -- Usage: - ``` - show platform summary - ``` - -- Example: - ``` - admin@sonic:~$ show platform summary - Platform: x86_64-mlnx_msn2700-r0 - HwSKU: Mellanox-SN2700 - ASIC: mellanox - ASIC Count: 1 - Serial Number: MT1822K07815 - Model Number: MSN2700-CS2FO - Hardware Rev: A1 - ``` - -**show platform syseeprom** - -This command displays information stored on the system EEPROM. -Note that the output of this command is not the same for all vendor's platforms. -Couple of example outputs are given below. - -- Usage: - ``` - show platform syseeprom - ``` - -- Example: - ``` - admin@sonic:~$ show platform syseeprom - lsTLV Name Len Value - -------------------- --- ----- - PPID 20 XX-XXXXXX-00000-000-0000 - DPN Rev 3 XXX - Service Tag 7 XXXXXXX - Part Number 10 XXXXXX - Part Number Rev 3 XXX - Mfg Test Results 2 FF - Card ID 2 0x0000 - Module ID 2 0 - Base MAC Address 12 FE:EC:BA:AB:CD:EF - (checksum valid) - ``` - - ``` - admin@sonic:~$ show platform syseeprom - TlvInfo Header: - Id String: TlvInfo - Version: 1 - Total Length: 527 - TLV Name Code Len Value - ---- --- ----- - Product Name 0x21 64 MSN2700 - Part Number 0x22 20 MSN2700-CS2FO - Serial Number 0x23 24 MT1822K07815 - Base MAC Address 0x24 6 50:6B:4B:8F:CE:40 - Manufacture Date 0x25 19 05/28/2018 23:56:02 - Device Version 0x26 1 16 - MAC Addresses 0x2A 2 128 - Manufacturer 0x2B 8 Mellanox - Vendor Extension 0xFD 36 - Vendor Extension 0xFD 164 - Vendor Extension 0xFD 36 - Vendor Extension 0xFD 36 - Vendor Extension 0xFD 36 - Platform Name 0x28 18 x86_64-mlnx_x86-r0 - ONIE Version 0x29 21 2018.08-5.2.0006-9600 - CRC-32 0xFE 4 0x11C017E1 - - (checksum valid) - ``` - -**show platform ssdhealth** - -This command displays health parameters of the device's SSD - -- Usage: - ``` - show platform ssdhealth [--vendor] - ``` - -- Example: - ``` - admin@sonic:~$ show platform ssdhealth - Device Model : M.2 (S42) 3IE3 - Health : 99.665% - Temperature : 30C - ``` - -**show platform psustatus** - -This command displays the status of the device's power supply units - -- Usage: - ``` - show platform psustatus - ``` - -- Example: - ``` - admin@sonic:~$ show platform psustatus - PSU Model Serial HW Rev Voltage (V) Current (A) Power (W) Status LED - ----- ------------- ------------ -------- ------------- ------------- ----------- -------- ----- - PSU 1 MTEF-PSF-AC-A MT1621X15246 A3 11.97 4.56 54.56 OK green - ``` - -**show platform fan** - -This command displays the status of the device's fans - -- Usage: - ``` - show platform fan - ``` - -- Example: - ``` - admin@sonic:~$ show platform fan - FAN Speed Direction Presence Status Timestamp - ----------- -------- ----------- ---------- -------- ----------------- - fan1 34% intake Present OK 20200302 06:58:56 - fan2 43% intake Present OK 20200302 06:58:56 - fan3 38% intake Present OK 20200302 06:58:56 - fan4 49% intake Present OK 20200302 06:58:57 - fan5 38% exhaust Present OK 20200302 06:58:57 - fan6 48% exhaust Present OK 20200302 06:58:57 - fan7 39% exhaust Present OK 20200302 06:58:57 - fan8 48% exhaust Present OK 20200302 06:58:57 - ``` - -**show platform temperature** - -This command displays the status of the device's thermal sensors - -- Usage: - ``` - show platform temperature - ``` - -- Example: - ``` - admin@sonic:~$ show platform temperature - NAME Temperature High Th Low Th Crit High Th Crit Low Th Warning Timestamp - ---------------------- ------------- --------- -------- -------------- ------------- --------- ----------------- - Ambient ASIC Temp 37.0 100.0 N/A 120.0 N/A False 20200302 06:58:57 - Ambient Fan Side Temp 28.5 100.0 N/A 120.0 N/A False 20200302 06:58:57 - Ambient Port Side Temp 31.0 100.0 N/A 120.0 N/A False 20200302 06:58:57 - CPU Core 0 Temp 36.0 87.0 N/A 105.0 N/A False 20200302 06:59:57 - CPU Core 1 Temp 38.0 87.0 N/A 105.0 N/A False 20200302 06:59:57 - CPU Pack Temp 38.0 87.0 N/A 105.0 N/A False 20200302 06:59:57 - PSU-1 Temp 28.0 100.0 N/A 120.0 N/A False 20200302 06:59:58 - PSU-2 Temp 28.0 100.0 N/A 120.0 N/A False 20200302 06:59:58 - xSFP module 1 Temp 31.5 70.0 N/A 90.0 N/A False 20200302 06:59:57 - xSFP module 2 Temp 35.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 - xSFP module 3 Temp 32.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 - xSFP module 4 Temp 33.5 70.0 N/A 90.0 N/A False 20200302 06:59:57 - xSFP module 5 Temp 34.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 - xSFP module 6 Temp 36.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 - xSFP module 7 Temp 33.5 70.0 N/A 90.0 N/A False 20200302 06:59:57 - xSFP module 8 Temp 33.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 - xSFP module 9 Temp 32.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 - xSFP module 10 Temp 38.5 70.0 N/A 90.0 N/A False 20200302 06:59:57 - xSFP module 11 Temp 38.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 - xSFP module 12 Temp 39.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 - xSFP module 13 Temp 35.5 70.0 N/A 90.0 N/A False 20200302 06:59:57 - xSFP module 14 Temp 37.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 - xSFP module 15 Temp 36.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 - xSFP module 16 Temp 36.5 70.0 N/A 90.0 N/A False 20200302 06:59:57 - xSFP module 17 Temp 32.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 - xSFP module 18 Temp 34.5 70.0 N/A 90.0 N/A False 20200302 06:59:57 - xSFP module 19 Temp 30.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 - xSFP module 20 Temp 31.5 70.0 N/A 90.0 N/A False 20200302 06:59:57 - xSFP module 21 Temp 34.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 - xSFP module 22 Temp 34.4 70.0 N/A 90.0 N/A False 20200302 06:59:57 - xSFP module 23 Temp 34.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 - xSFP module 24 Temp 35.6 70.0 N/A 90.0 N/A False 20200302 06:59:57 - xSFP module 25 Temp 38.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 - xSFP module 26 Temp 32.2 70.0 N/A 90.0 N/A False 20200302 06:59:58 - xSFP module 27 Temp 39.0 70.0 N/A 90.0 N/A False 20200302 06:59:58 - xSFP module 28 Temp 30.1 70.0 N/A 90.0 N/A False 20200302 06:59:58 - xSFP module 29 Temp 32.0 70.0 N/A 90.0 N/A False 20200302 06:59:58 - xSFP module 30 Temp 35.3 70.0 N/A 90.0 N/A False 20200302 06:59:58 - xSFP module 31 Temp 31.0 70.0 N/A 90.0 N/A False 20200302 06:59:58 - xSFP module 32 Temp 39.5 70.0 N/A 90.0 N/A False 20200302 06:59:58 - ``` - -#### Transceivers -Displays diagnostic monitoring information of the transceivers - -**show interfaces transceiver** - -This command displays information for all the interfaces for the transceiver requested or a specific interface if the optional "interface_name" is specified. - -- Usage: - ``` - show interfaces transceiver (eeprom [-d|--dom] | lpmode | presence | error-status [-hw|--fetch-from-hardware]) [] - ``` - -- Example (Decode and display information stored on the EEPROM of SFP transceiver connected to Ethernet0): - ``` - admin@sonic:~$ show interfaces transceiver eeprom --dom Ethernet0 - Ethernet0: SFP detected - Connector : No separable connector - Encoding : Unspecified - Extended Identifier : Unknown - Extended RateSelect Compliance : QSFP+ Rate Select Version 1 - Identifier : QSFP+ - Length Cable Assembly(m) : 1 - Specification compliance : - 10/40G Ethernet Compliance Code : 40GBASE-CR4 - Fibre Channel Speed : 1200 Mbytes/Sec - Fibre Channel link length/Transmitter Technology : Electrical inter-enclosure (EL) - Fibre Channel transmission media : Twin Axial Pair (TW) - Vendor Date Code(YYYY-MM-DD Lot) : 2015-10-31 - Vendor Name : XXXXX - Vendor OUI : XX-XX-XX - Vendor PN : 1111111111 - Vendor Rev : - Vendor SN : 111111111 - ChannelMonitorValues: - RX1Power: -1.1936dBm - RX2Power: -1.1793dBm - RX3Power: -0.9388dBm - RX4Power: -1.0729dBm - TX1Bias: 4.0140mA - TX2Bias: 4.0140mA - TX3Bias: 4.0140mA - TX4Bias: 4.0140mA - ModuleMonitorValues : - Temperature : 1.1111C - Vcc : 0.0000Volts - ``` - -- Example (Display status of low-power mode of SFP transceiver connected to Ethernet100): - ``` - admin@sonic:~$ show interfaces transceiver lpmode Ethernet100 - Port Low-power Mode - ----------- ---------------- - Ethernet100 On - ``` - - -- Example (Display presence of SFP transceiver connected to Ethernet100): - ``` - admin@sonic:~$ show interfaces transceiver presence Ethernet100 - Port Presence - ----------- ---------- - Ethernet100 Present - ``` - -- Example (Display error status of SFP transceiver connected to Ethernet100): - ``` - admin@sonic:~$ show interfaces transceiver error-status Ethernet100 - Port Error Status - ----------- -------------- - Ethernet100 OK - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#basic-show-commands) - -## AAA & TACACS+ -This section captures the various show commands & configuration commands that are applicable for the AAA (Authentication, Authorization, and Accounting) module. -Admins can configure the type of authentication (local or remote tacacs based) required for the users and also the authentication failthrough and fallback options. -Following show command displays the current running configuration related to the AAA. - -### AAA - -#### AAA show commands - -This command is used to view the Authentication, Authorization & Accounting settings that are configured in the network node. - -**show aaa** - -This command displays the AAA settings currently present in the network node - -- Usage: - ``` - show aaa - ``` - -- Example: - ``` - admin@sonic:~$ show aaa - AAA authentication login local (default) - AAA authentication failthrough True (default) - AAA authentication fallback True (default) - ``` - -#### AAA config commands - -This sub-section explains all the possible CLI based configuration options for the AAA module. The list of commands/sub-commands possible for aaa is given below. - - Command: aaa authentication - sub-commands: - - aaa authentication failthrough - - aaa authentication fallback - - aaa authentication login - -**aaa authentication failthrough** - -This command is used to either enable or disable the failthrough option. -This command is useful when user has configured more than one tacacs+ server and when user has enabled tacacs+ authentication. -When authentication request to the first server fails, this configuration allows to continue the request to the next server. -When this configuration is enabled, authentication process continues through all servers configured. -When this is disabled and if the authentication request fails on first server, authentication process will stop and the login will be disallowed. - - -- Usage: - ``` - config aaa authentication failthrough (enable | disable | default) - ``` - - - Parameters: - - enable: This allows the AAA module to process with local authentication if remote authentication fails. - - disable: This disallows the AAA module to proceed further if remote authentication fails. - - default: This re-configures the default value, which is "enable". - - -- Example: - ``` - admin@sonic:~$ sudo config aaa authentication failthrough enable - ``` -**aaa authentication fallback** - -The command is not used at the moment. -When the tacacs+ authentication fails, it falls back to local authentication by default. - -- Usage: - ``` - config aaa authentication fallback (enable | disable | default) - ``` - -- Example: - ``` - admin@sonic:~$ sudo config aaa authentication fallback enable - ``` - -**aaa authentication login** - -This command is used to either configure whether AAA should use local database or remote tacacs+ database for user authentication. -By default, AAA uses local database for authentication. New users can be added/deleted using the linux commands (Note that the configuration done using linux commands are not preserved during reboot). -Admin can enable remote tacacs+ server based authentication by selecting the AUTH_PROTOCOL as tacacs+ in this command. -Admins need to configure the tacacs+ server accordingly and ensure that the connectivity to tacacas+ server is available via the management interface. -Once if the admins choose the remote authentication based on tacacs+ server, all user logins will be authenticated by the tacacs+ server. -If the authentication fails, AAA will check the "failthrough" configuration and authenticates the user based on local database if failthrough is enabled. - -- Usage: - ``` - config aaa authentication (tacacs+ | local | default) - ``` - - - Parameters: - - tacacs+: Enables remote authentication based on tacacs+ - - local: Disables remote authentication and uses local authentication - - default: Reset back to default value, which is only "local" authentication - - -- Example: - ``` - admin@sonic:~$ sudo config aaa authentication login tacacs+ - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#aaa--tacacs) - -### TACACS+ - -#### TACACS+ show commands - -**show tacacs** - -This command displays the global configuration fields and the list of all tacacs servers and their correponding configurations. - -- Usage: - ``` - show tacacs - ``` - -- Example: - ``` - admin@sonic:~$ show tacacs - TACPLUS global auth_type pap (default) - TACPLUS global timeout 99 - TACPLUS global passkey (default) - - TACPLUS_SERVER address 10.11.12.14 - priority 9 - tcp_port 50 - auth_type mschap - timeout 10 - passkey testing789 - - TACPLUS_SERVER address 10.0.0.9 - priority 1 - tcp_port 49 - ``` - -#### TACACS+ config commands - -This sub-section explains the command "config tacacs" and its sub-commands that are used to configure the following tacacs+ parameters. -Some of the parameters like authtype, passkey and timeout can be either configured at per server level or at global level (global value will be applied if there no server level configuration) - -1) Add/Delete the tacacs+ server details. -2) authtype - global configuration that is applied to all servers if there is no server specific configuration. -3) default - reset the authtype or passkey or timeout to the default values. -4) passkey - global configuration that is applied to all servers if there is no server specific configuration. -5) timeout - global configuration that is applied to all servers if there is no server specific configuration. - -**config tacacs add** - -This command is used to add a TACACS+ server to the tacacs server list. -Note that more than one tacacs+ (maximum of seven) can be added in the device. -When user tries to login, tacacs client shall contact the servers one by one. -When any server times out, device will try the next server one by one based on the priority value configured for that server. -When this command is executed, the configured tacacs+ server addresses are updated in /etc/pam.d/common-auth-sonic configuration file which is being used by tacacs service. - -- Usage: - ``` - config tacacs add [-t|--timeout ] [-k|--key ] [-a|--type ] [-o|--port ] [-p|--pri ] [-m|--use-mgmt-vrf] - ``` - - - Parameters: - - ip_address: TACACS+ server IP address. - - timeout: Transmission timeout interval in seconds, range 1 to 60, default 5 - - key: Shared secret - - type: Authentication type, "chap" or "pap" or "mschap" or "login", default is "pap". - - port: TCP port range is 1 to 65535, default 49 - - pri: Priority, priority range 1 to 64, default 1. - - use-mgmt-vrf: This means that the server is part of Management vrf, default is "no vrf" - - -- Example: - ``` - admin@sonic:~$ sudo config tacacs add 10.11.12.13 -t 10 -k testing789 -a mschap -o 50 -p 9 - ``` - - - Example Server Configuration in /etc/pam.d/common-auth-sonic configuration file: - ``` - auth [success=done new_authtok_reqd=done default=ignore] pam_tacplus.so server=10.11.12.14:50 secret=testing789 login=mschap timeout=10 try_first_pass - auth [success=done new_authtok_reqd=done default=ignore] pam_tacplus.so server=10.11.12.24:50 secret=testing789 login=mschap timeout=987654321098765433211 - 0987 try_first_pass - auth [success=done new_authtok_reqd=done default=ignore] pam_tacplus.so server=10.0.0.9:49 secret= login=mschap timeout=5 try_first_pass - auth [success=done new_authtok_reqd=done default=ignore] pam_tacplus.so server=10.0.0.8:49 secret= login=mschap timeout=5 try_first_pass - auth [success=done new_authtok_reqd=done default=ignore] pam_tacplus.so server=10.11.12.13:50 secret=testing789 login=mschap timeout=10 try_first_pass - auth [success=1 default=ignore] pam_unix.so nullok try_first_pass - ``` - - *NOTE: In the above example, the servers are stored (sorted) based on the priority value configured for the server.* - -**config tacacs delete** - -This command is used to delete the tacacs+ servers configured. - -- Usage: - ``` - config tacacs delete - ``` - -- Example: - ``` - admin@sonic:~$ sudo config tacacs delete 10.11.12.13 - ``` - -**config tacacs authtype** - -This command is used to modify the global value for the TACACS+ authtype. -When user has not configured server specific authtype, this global value shall be used for that server. - -- Usage: - ``` - config tacacs authtype (chap | pap | mschap | login) - ``` - -- Example: - ``` - admin@sonic:~$ sudo config tacacs authtype mschap - ``` - -**config tacacs default** - -This command is used to reset the global value for authtype or passkey or timeout to default value. -Default for authtype is "pap", default for passkey is EMPTY_STRING and default for timeout is 5 seconds. - -- Usage: - ``` - config tacacs default (authtype | passkey | timeout) - ``` - -- Example (This will reset the global authtype back to the default value "pap"): - ``` - admin@sonic:~$ sudo config tacacs default authtype - ``` - -**config tacacs passkey** - -This command is used to modify the global value for the TACACS+ passkey. -When user has not configured server specific passkey, this global value shall be used for that server. - -- Usage: - ``` - config tacacs passkey - ``` - -- Example: - ``` - admin@sonic:~$ sudo config tacacs passkey testing123 - ``` - -**config tacacs timeout** - -This command is used to modify the global value for the TACACS+ timeout. -When user has not configured server specific timeout, this global value shall be used for that server. - - -- Usage: - ``` - config tacacs [default] timeout [] - ``` - - - Options: - - Valid values for timeout is 1 to 60 seconds. - - When the optional keyword "default" is specified, timeout_value_in_seconds parameter wont be used; default value of 5 is used. - - Configuration using the keyword "default" is introduced in 201904 release. - -- Example: To configure non-default timeout value - ``` - admin@sonic:~$ sudo config tacacs timeout 60 - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#aaa--tacacs) - - - -## ACL - -This section explains the various show commands and configuration commands available for users. - -### ACL show commands - -**show acl table** - -This command displays either all the ACL tables that are configured or only the specified "TABLE_NAME". -Output from the command displays the table name, type of the table, the list of interface(s) to which the table is bound and the description about the table. - -- Usage: - ``` - show acl table [] - ``` - -- Example: - ``` - admin@sonic:~$ show acl table - Name Type Binding Description Stage - -------- --------- --------------- ---------------- ------- - EVERFLOW MIRROR Ethernet16 EVERFLOW ingress - Ethernet96 - Ethernet108 - Ethernet112 - PortChannel0001 - PortChannel0002 - SNMP_ACL CTRLPLANE SNMP SNMP_ACL ingress - DT_ACL_T1 L3 Ethernet0 DATA_ACL_TABLE_1 egress - Ethernet4 - Ethernet112 - Ethernet116 - SSH_ONLY CTRLPLANE SSH SSH_ONLY ingress - ``` - -**show acl rule** - -This command displays all the ACL rules present in all the ACL tables or only the rules present in specified table "TABLE_NAME" or only the rule matching the RULE_ID option. -Output from the command gives the following information about the rules -1) Table name - ACL table name to which the rule belongs to. -2) Rule name - ACL rule name -3) Priority - Priority for this rule. -4) Action - Action to be performed if the packet matches with this ACL rule. - -It can be: -- "DROP"/"FORWARD"("ACCEPT" for control plane ACL) -- "REDIRECT: redirect-object" for redirect rule, where "redirect-object" is either: - - physical interface name, e.g. "Ethernet10" - - port channel name, e.g. "PortChannel0002" - - next-hop IP address, e.g. "10.0.0.1" - - next-hop group set of IP addresses with comma seperator, e.g. "10.0.0.1,10.0.0.3" -- "MIRROR INGRESS|EGRESS: session-name" for mirror rules, where "session-name" refers to mirror session - -Users can choose to have a default permit rule or default deny rule. In case of default "deny all" rule, add the permitted rules on top of the deny rule. In case of the default "permit all" rule, users can add the deny rules on top of it. If users have not confgured any rule, SONiC allows all traffic (which is "permit all"). - -5) Match - The fields from the packet header that need to be matched against the same present in the incoming traffic. - -- Usage: - ``` - show acl rule [] [] - ``` - -- Example: - ``` - admin@sonic:~$ show acl rule - Table Rule Priority Action Match - -------- ------------ ---------- ------------------------- ---------------------------- - SNMP_ACL RULE_1 9999 ACCEPT IP_PROTOCOL: 17 - SRC_IP: 1.1.1.1/32 - SSH_ONLY RULE_2 9998 ACCEPT IP_PROTOCOL: 6 - SRC_IP: 1.1.1.1/32 - EVERFLOW RULE_3 9997 MIRROR INGRESS: everflow0 SRC_IP: 20.0.0.2/32 - EVERFLOW RULE_4 9996 MIRROR EGRESS : everflow1 L4_SRC_PORT: 4621 - DATAACL RULE_5 9995 REDIRECT: Ethernet8 IP_PROTOCOL: 126 - DATAACL RULE_6 9994 FORWARD L4_SRC_PORT: 179 - DATAACL RULE_7 9993 FORWARD L4_DST_PORT: 179 - SNMP_ACL DEFAULT_RULE 1 DROP ETHER_TYPE: 2048 - SSH_ONLY DEFAULT_RULE 1 DROP ETHER_TYPE: 2048 - ``` - - -### ACL config commands -This sub-section explains the list of configuration options available for ACL module. -Note that there is no direct command to add or delete or modify the ACL table and ACL rule. -Existing ACL tables and ACL rules can be updated by specifying the ACL rules in json file formats and configure those files using this CLI command. - -**config acl update full** - -This command is to update the rules in all the tables or in one specific table in full. If a table_name is provided, the operation will be restricted in the specified table. All existing rules in the specified table or all tables will be removed. New rules loaded from file will be installed. If the table_name is specified, only rules within that table will be removed and new rules in that table will be installed. If the table_name is not specified, all rules from all tables will be removed and only the rules present in the input file will be added. - -The command does not modify anything in the list of acl tables. It modifies only the rules present in those pre-existing tables. - -In order to create acl tables, either follow the config_db.json method or minigraph method to populate the list of ACL tables. - -After creating tables, either the config_db.json method or the minigraph method or the CLI method (explained here) can be used to populate the rules in those ACL tables. - -This command updates only the ACL rules and it does not disturb the ACL tables; i.e. the output of "show acl table" is not alterted by using this command; only the output of "show acl rule" will be changed after this command. - -When "--session_name" optional argument is specified, command sets the session_name for the ACL table with this mirror session name. It fails if the specified mirror session name does not exist. - -When "--mirror_stage" optional argument is specified, command sets the mirror action to ingress/egress based on this parameter. By default command sets ingress mirror action in case argument is not specified. - -When the optional argument "max_priority" is specified, each rule’s priority is calculated by subtracting its “sequence_id” value from the “max_priority”. If this value is not passed, the default “max_priority” 10000 is used. - -- Usage: - ``` - config acl update full [--table_name ] [--session_name ] [--mirror_stage (ingress | egress)] [--max_priority ] - ``` - - - Parameters: - - table_name: Specifiy the name of the ACL table to load. Example: config acl update full "--table_name DT_ACL_T1 /etc/sonic/acl_table_1.json" - - session_name: Specifiy the name of the ACL session to load. Example: config acl update full "--session_name mirror_ses1 /etc/sonic/acl_table_1.json" - - priority_value: Specify the maximum priority to use when loading ACL rules. Example: config acl update full "--max-priority 100 /etc/sonic/acl_table_1.json" - - *NOTE 1: All these optional parameters should be inside double quotes. If none of the options are provided, double quotes are not required for specifying filename alone.* - *NOTE 2: Any number of optional parameters can be configured in the same command.* - -- Examples: - ``` - admin@sonic:~$ sudo config acl update full /etc/sonic/acl_full_snmp_1_2_ssh_4.json - admin@sonic:~$ sudo config acl update full "--table_name SNMP-ACL /etc/sonic/acl_full_snmp_1_2_ssh_4.json" - admin@sonic:~$ sudo config acl update full "--session_name everflow0 /etc/sonic/acl_full_snmp_1_2_ssh_4.json" - ``` - - This command will remove all rules from all the ACL tables and insert all the rules present in this input file. - Refer the example file [acl_full_snmp_1_2_ssh_4.json](#) that adds two rules for SNMP (Rule1 and Rule2) and one rule for SSH (Rule4) - Refer an example for input file format [here](https://github.com/Azure/sonic-mgmt/blob/master/ansible/roles/test/files/helpers/config_service_acls.sh) - Refer another example [here](https://github.com/Azure/sonic-mgmt/blob/master/ansible/roles/test/tasks/acl/acltb_test_rules_part_1.json) - -**config acl update incremental** - -This command is used to perform incremental update of ACL rule table. This command gets existing rules from Config DB and compares with rules specified in input file and performs corresponding modifications. - -With respect to DATA ACLs, the command does not assume that new dataplane ACLs can be inserted in betweeen by shifting existing ACLs in all ASICs. Therefore, this command performs a full update on dataplane ACLs. -With respect to control plane ACLs, this command performs an incremental update. -If we assume that "file1.json" is the already loaded ACL rules file and if "file2.json" is the input file that is passed as parameter for this command, the following requirements are valid for the input file. -1) First copy the file1.json to file2.json. -2) Remove the unwanted ACL rules from file2.json -3) Add the newly required ACL rules into file2.json. -4) Modify the existing ACL rules (that require changes) in file2.json. - -NOTE: If any ACL rule that is already available in file1.json is required even after this command execution, such rules should remain unalterted in file2.json. Don't remove them. -Note that "incremental" is working like "full". - -When "--session_name" optional argument is specified, command sets the session_name for the ACL table with this mirror session name. It fails if the specified mirror session name does not exist. - -When "--mirror_stage" optional argument is specified, command sets the mirror action to ingress/egress based on this parameter. By default command sets ingress mirror action in case argument is not specified. - -When the optional argument "max_priority" is specified, each rule’s priority is calculated by subtracting its “sequence_id” value from the “max_priority”. If this value is not passed, the default “max_priority” 10000 is used. - -- Usage: - ``` - config acl update incremental [--session_name ] [--mirror_stage (ingress | egress)] [--max_priority ] - ``` - - - Parameters: - - table_name: Specifiy the name of the ACL table to load. Example: config acl update full "--table_name DT_ACL_T1 /etc/sonic/acl_table_1.json" - - session_name: Specifiy the name of the ACL session to load. Example: config acl update full "--session_name mirror_ses1 /etc/sonic/acl_table_1.json" - - priority_value: Specify the maximum priority to use when loading ACL rules. Example: config acl update full "--max-priority 100 /etc/sonic/acl_table_1.json" - - *NOTE 1: All these optional parameters should be inside double quotes. If none of the options are provided, double quotes are not required for specifying filename alone.* - *NOTE 2: Any number of optional parameters can be configured in the same command.* - -- Examples: - ``` - admin@sonic:~$ sudo config acl update incremental /etc/sonic/acl_incremental_snmp_1_3_ssh_4.json - ``` - ``` - admin@sonic:~$ sudo config acl update incremental "--session_name everflow0 /etc/sonic/acl_incremental_snmp_1_3_ssh_4.json" - ``` - - Refer the example file [acl_incremental_snmp_1_3_ssh_4.json](#) that adds two rules for SNMP (Rule1 and Rule3) and one rule for SSH (Rule4) - When this "incremental" command is executed after "full" command, it has removed SNMP Rule2 and added SNMP Rule3 in the example. - File "acl_full_snmp_1_2_ssh_4.json" has got SNMP Rule1, SNMP Rule2 and SSH Rule4. - File "acl_incremental_snmp_1_3_ssh_4.json" has got SNMP Rule1, SNMP Rule3 and SSH Rule4. - This file is created by copying the file "acl_full_snmp_1_2_ssh_4.json" to "acl_incremental_snmp_1_3_ssh_4.json" and then removing SNMP Rule2 and adding SNMP Rule3. - -Go Back To [Beginning of the document](#) or [Beginning of this section](#acl) - -**config acl add table** - -This command is used to create new ACL tables. - -- Usage: - ``` - config acl add table [OPTIONS] [-d ] [-p ] [-s (ingress | egress)] - ``` - -- Parameters: - - table_name: The name of the ACL table to create. - - table_type: The type of ACL table to create (e.g. "L3", "L3V6", "MIRROR") - - description: A description of the table for the user. (default is the table_name) - - ports: A comma-separated list of ports/interfaces to add to the table. The behavior is as follows: - - Physical ports will be bound as physical ports - - Portchannels will be bound as portchannels - passing a portchannel member is invalid - - VLANs will be expanded into their members (e.g. "Vlan1000" will become "Ethernet0,Ethernet2,Ethernet4...") - - stage: The stage this ACL table will be applied to, either ingress or egress. (default is ingress) - -- Examples: - ``` - admin@sonic:~$ sudo config acl add table EXAMPLE L3 -p Ethernet0,Ethernet4 -s ingress - ``` - ``` - admin@sonic:~$ sudo config acl add table EXAMPLE_2 L3V6 -p Vlan1000,PortChannel0001,Ethernet128 -s egress - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#acl) - - -## ARP & NDP - -### ARP show commands - -**show arp** - -This command displays the ARP entries in the device with following options. -1) Display the entire table. -2) Display the ARP entries learnt on a specific interface. -3) Display the ARP of a specific ip-address. - -- Usage: - ``` - show arp [-if ] [] - ``` - -- Details: - - show arp: Displays all entries - - show arp -if : Displays the ARP specific to the specified interface. - - show arp : Displays the ARP specific to the specicied ip-address. - - -- Example: - ``` - admin@sonic:~$ show arp - Address MacAddress Iface Vlan - ------------- ----------------- ------- ------ - 192.168.1.183 88:5a:92:fb:bf:41 Ethernet44 - - 192.168.1.175 88:5a:92:fc:95:81 Ethernet28 - - 192.168.1.181 e4:c7:22:c1:07:7c Ethernet40 - - 192.168.1.179 88:5a:92:de:a8:bc Ethernet36 - - 192.168.1.118 00:1c:73:3c:de:43 Ethernet64 - - 192.168.1.11 00:1c:73:3c:e1:38 Ethernet88 - - 192.168.1.161 24:e9:b3:71:3a:01 Ethernet0 - - 192.168.1.189 24:e9:b3:9d:57:41 Ethernet56 - - 192.168.1.187 74:26:ac:8b:8f:c1 Ethernet52 - - 192.168.1.165 88:5a:92:de:a0:7c Ethernet8 - - - Total number of entries 10 - ``` - -Optionally, you can specify the interface in order to display the ARPs learnt on that particular interface - -- Example: - ``` - admin@sonic:~$ show arp -if Ethernet40 - Address MacAddress Iface Vlan - ------------- ----------------- ---------- ------ - 192.168.1.181 e4:c7:22:c1:07:7c Ethernet40 - - Total number of entries 1 - ``` - -Optionally, you can specify an IP address in order to display only that particular entry - -- Example: - ``` - admin@sonic:~$ show arp 192.168.1.181 - Address MacAddress Iface Vlan - ------------- ----------------- ---------- ------ - 192.168.1.181 e4:c7:22:c1:07:7c Ethernet40 - - Total number of entries 1 - ``` - -### NDP show commands - -**show ndp** - -This command displays either all the IPv6 neighbor mac addresses, or for a particular IPv6 neighbor, or for all IPv6 neighbors reachable via a specific interface. - -- Usage: - ``` - show ndp [-if|--iface ] - ``` - -- Example (show all IPv6 neighbors): - ``` - admin@sonic:~$ show ndp - Address MacAddress Iface Vlan Status - ------------------------ ----------------- ------- ------ --------- - fe80::20c:29ff:feb8:b11e 00:0c:29:b8:b1:1e eth0 - REACHABLE - fe80::20c:29ff:feb8:cff0 00:0c:29:b8:cf:f0 eth0 - REACHABLE - fe80::20c:29ff:fef9:324 00:0c:29:f9:03:24 eth0 - REACHABLE - Total number of entries 3 - ``` - -- Example (show specific IPv6 neighbor): - ``` - admin@sonic:~$ show ndp fe80::20c:29ff:feb8:b11e - Address MacAddress Iface Vlan Status - ------------------------ ----------------- ------- ------ --------- - fe80::20c:29ff:feb8:b11e 00:0c:29:b8:b1:1e eth0 - REACHABLE - Total number of entries 1 - ``` - -- Example (show IPv6 neighbors learned on a specific interface): - ``` - admin@sonic:~$ show ndp -if eth0 - Address MacAddress Iface Vlan Status - ------------------------ ----------------- ------- ------ --------- - fe80::20c:29ff:feb8:b11e 00:0c:29:b8:b1:1e eth0 - REACHABLE - fe80::20c:29ff:feb8:cff0 00:0c:29:b8:cf:f0 eth0 - REACHABLE - fe80::20c:29ff:fef9:324 00:0c:29:f9:03:24 eth0 - REACHABLE - Total number of entries 3 - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#arp--ndp) - -## BFD - -### BFD show commands - -**show bfd summary** - -This command displays the state and key parameters of all BFD sessions. - -- Usage: - ``` - show bgp summary - ``` -- Example: - ``` - >> show bfd summary - Total number of BFD sessions: 3 - Peer Addr Interface Vrf State Type Local Addr TX Interval RX Interval Multiplier Multihop - ----------- ----------- ------- ------- ------------ ------------ ------------- ------------- ------------ ---------- - 10.0.1.1 default default DOWN async_active 10.0.0.1 300 500 3 true - 10.0.2.1 Ethernet12 default UP async_active 10.0.0.1 200 600 3 false - 2000::10:1 default default UP async_active 2000::1 100 700 3 false - ``` - -**show bfd peer** - -This command displays the state and key parameters of all BFD sessions that match an IP address. - -- Usage: - ``` - show bgp peer - ``` -- Example: - ``` - >> show bfd peer 10.0.1.1 - Total number of BFD sessions for peer IP 10.0.1.1: 1 - Peer Addr Interface Vrf State Type Local Addr TX Interval RX Interval Multiplier Multihop - ----------- ----------- ------- ------- ------------ ------------ ------------- ------------- ------------ ---------- - 10.0.1.1 default default DOWN async_active 10.0.0.1 300 500 3 true - ``` - -## BGP - -This section explains all the BGP show commands and BGP configuation commands in both "Quagga" and "FRR" routing software that are supported in SONiC. -In 201811 and older verisons "Quagga" was enabled by default. In current version "FRR" is enabled by default. -Most of the FRR show commands start with "show bgp". Similar commands in Quagga starts with "show ip bgp". All sub-options supported in all these show commands are common for FRR and Quagga. -Detailed show commands examples for Quagga are provided at the end of this document.This section captures only the commands supported by FRR. - -### BGP show commands - - -**show bgp summary (Versions >= 201904 using default FRR routing stack)** - -**show ip bgp summary (Versions <= 201811 using Quagga routing stack)** - -This command displays the summary of all IPv4 & IPv6 bgp neighbors that are configured and the corresponding states. - -- Usage: - - *Versions >= 201904 using default FRR routing stack* - ``` - show bgp summary - ``` - *Versions <= 201811 using Quagga routing stack* - ``` - show ip bgp summary - ``` - -- Example: - ``` - admin@sonic:~$ show ip bgp summary - - IPv4 Unicast Summary: - BGP router identifier 10.1.0.32, local AS number 65100 vrf-id 0 - BGP table version 6465 - RIB entries 12807, using 2001 KiB of memory - Peers 4, using 83 KiB of memory - Peer groups 2, using 128 bytes of memory - - Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd NeighborName - 10.0.0.57 4 64600 3995 4001 0 0 0 00:39:32 6400 Lab-T1-01 - 10.0.0.59 4 64600 3995 3998 0 0 0 00:39:32 6400 Lab-T1-02 - 10.0.0.61 4 64600 3995 4001 0 0 0 00:39:32 6400 Lab-T1-03 - 10.0.0.63 4 64600 3995 3998 0 0 0 00:39:32 6400 NotAvailable - - Total number of neighbors 4 - ``` - -- Example: - ``` - admin@sonic:~$ show bgp summary - - IPv4 Unicast Summary: - BGP router identifier 10.1.0.32, local AS number 65100 vrf-id 0 - BGP table version 6465 - RIB entries 12807, using 2001 KiB of memory - Peers 4, using 83 KiB of memory - Peer groups 2, using 128 bytes of memory - - Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd - 10.0.0.57 4 64600 3995 4001 0 0 0 00:39:32 6400 - 10.0.0.59 4 64600 3995 3998 0 0 0 00:39:32 6400 - 10.0.0.61 4 64600 3995 4001 0 0 0 00:39:32 6400 - 10.0.0.63 4 64600 3995 3998 0 0 0 00:39:32 6400 - - Total number of neighbors 4 - - IPv6 Unicast Summary: - BGP router identifier 10.1.0.32, local AS number 65100 vrf-id 0 - BGP table version 12803 - RIB entries 12805, using 2001 KiB of memory - Peers 4, using 83 KiB of memory - Peer groups 2, using 128 bytes of memory - - Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd - fc00::72 4 64600 3995 5208 0 0 0 00:39:30 6400 - fc00::76 4 64600 3994 5208 0 0 0 00:39:30 6400 - fc00::7a 4 64600 3993 5208 0 0 0 00:39:30 6400 - fc00::7e 4 64600 3993 5208 0 0 0 00:39:30 6400 - - Total number of neighbors 4 - ``` - Click [here](#Quagga-BGP-Show-Commands) to see the example for "show ip bgp summary" for Quagga. - - - -**show bgp neighbors (Versions >= 201904 using default FRR routing stack)** - -**show ip bgp neighbors (Versions <= 201811 using Quagga routing stack)** - -This command displays all the details of IPv4 & IPv6 BGP neighbors when no optional argument is specified. - -When the optional argument IPv4_address is specified, it displays the detailed neighbor information about that specific IPv4 neighbor. - -Command has got additional optional arguments to display only the advertised routes, or the received routes, or all routes. - -In order to get details for an IPv6 neigbor, use "show bgp ipv6 neighbor " command. - - -- Usage: - - *Versions >= 201904 using default FRR routing stack* - ``` - show bgp neighbors [ [advertised-routes | received-routes | routes]] - ``` - *Versions <= 201811 using Quagga routing stack* - ``` - show ip bgp neighbors [ [advertised-routes | received-routes | routes]] - ``` - -- Example: - ``` - admin@sonic:~$ show bgp neighbors - BGP neighbor is 10.0.0.57, remote AS 64600, local AS 65100, external link - Description: ARISTA01T1 - BGP version 4, remote router ID 100.1.0.29, local router ID 10.1.0.32 - BGP state = Established, up for 00:42:15 - Last read 00:00:00, Last write 00:00:03 - Hold time is 10, keepalive interval is 3 seconds - Configured hold time is 10, keepalive interval is 3 seconds - Neighbor capabilities: - 4 Byte AS: advertised and received - AddPath: - IPv4 Unicast: RX advertised IPv4 Unicast and received - Route refresh: advertised and received(new) - Address Family IPv4 Unicast: advertised and received - Hostname Capability: advertised (name: sonic-z9264f-9251,domain name: n/a) not received - Graceful Restart Capabilty: advertised and received - Remote Restart timer is 300 seconds - Address families by peer: - none - Graceful restart information: - End-of-RIB send: IPv4 Unicast - End-of-RIB received: IPv4 Unicast - Message statistics: - Inq depth is 0 - Outq depth is 0 - Sent Rcvd - Opens: 2 1 - Notifications: 2 0 - Updates: 3206 3202 - Keepalives: 845 847 - Route Refresh: 0 0 - Capability: 0 0 - Total: 4055 4050 - Minimum time between advertisement runs is 0 seconds - - For address family: IPv4 Unicast - Update group 1, subgroup 1 - Packet Queue length 0 - Inbound soft reconfiguration allowed - Community attribute sent to this neighbor(all) - 6400 accepted prefixes - - Connections established 1; dropped 0 - Last reset 00:42:37, due to NOTIFICATION sent (Cease/Connection collision resolution) - Local host: 10.0.0.56, Local port: 179 - Foreign host: 10.0.0.57, Foreign port: 46419 - Nexthop: 10.0.0.56 - Nexthop global: fc00::71 - Nexthop local: fe80::2204:fff:fe36:9449 - BGP connection: shared network - BGP Connect Retry Timer in Seconds: 120 - Read thread: on Write thread: on - ``` - -Optionally, you can specify an IP address in order to display only that particular neighbor. In this mode, you can optionally specify whether you want to display all routes advertised to the specified neighbor, all routes received from the specified neighbor or all routes (received and accepted) from the specified neighbor. - -- Example: - ``` - admin@sonic:~$ show bgp neighbors 10.0.0.57 - - admin@sonic:~$ show bgp neighbors 10.0.0.57 advertised-routes - - admin@sonic:~$ show bgp neighbors 10.0.0.57 received-routes - - admin@sonic:~$ show bgp neighbors 10.0.0.57 routes - ``` - - Click [here](#Quagga-BGP-Show-Commands) to see the example for "show ip bgp neighbors" for Quagga. - - -**show ip bgp network [[|] [(bestpath | multipath | longer-prefixes | json)]] - -This command displays all the details of IPv4 Border Gateway Protocol (BGP) prefixes. - -- Usage: - - - ``` - show ip bgp network [[|] [(bestpath | multipath | longer-prefixes | json)]] - ``` - -- Example: - - NOTE: The "longer-prefixes" option is only available when a network prefix with a "/" notation is used. - - ``` - admin@sonic:~$ show ip bgp network - - admin@sonic:~$ show ip bgp network 10.1.0.32 bestpath - - admin@sonic:~$ show ip bgp network 10.1.0.32 multipath - - admin@sonic:~$ show ip bgp network 10.1.0.32 json - - admin@sonic:~$ show ip bgp network 10.1.0.32/32 bestpath - - admin@sonic:~$ show ip bgp network 10.1.0.32/32 multipath - - admin@sonic:~$ show ip bgp network 10.1.0.32/32 json - - admin@sonic:~$ show ip bgp network 10.1.0.32/32 longer-prefixes - ``` - -**show bgp ipv6 summary (Versions >= 201904 using default FRR routing stack)** - -**show ipv6 bgp summary (Versions <= 201811 using Quagga routing stack)** - -This command displays the summary of all IPv6 bgp neighbors that are configured and the corresponding states. - -- Usage: - - *Versions >= 201904 using default FRR routing stack* - ``` - show bgp ipv6 summary - ``` - *Versions <= 201811 using Quagga routing stack* - ``` - show ipv6 bgp summary - ``` - -- Example: - ``` - admin@sonic:~$ show bgp ipv6 summary - BGP router identifier 10.1.0.32, local AS number 65100 vrf-id 0 - BGP table version 12803 - RIB entries 12805, using 2001 KiB of memory - Peers 4, using 83 KiB of memory - Peer groups 2, using 128 bytes of memory - - Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd NeighborName - fc00::72 4 64600 3995 5208 0 0 0 00:39:30 6400 Lab-T1-01 - fc00::76 4 64600 3994 5208 0 0 0 00:39:30 6400 Lab-T1-02 - fc00::7a 4 64600 3993 5208 0 0 0 00:39:30 6400 Lab-T1-03 - fc00::7e 4 64600 3993 5208 0 0 0 00:39:30 6400 Lab-T1-04 - - Total number of neighbors 4 - ``` - Click [here](#Quagga-BGP-Show-Commands) to see the example for "show ipv6 bgp summary" for Quagga. - - - -**show bgp ipv6 neighbors (Versions >= 201904 using default FRR routing stack)** - -**show ipv6 bgp neighbors (Versions <= 201811 using Quagga routing stack)** - -This command displays all the details of one particular IPv6 Border Gateway Protocol (BGP) neighbor. Option is also available to display only the advertised routes, or the received routes, or all routes. - - -- Usage: - - *Versions >= 201904 using default FRR routing stack* - ``` - show bgp ipv6 neighbors [ [(advertised-routes | received-routes | routes)]] - ``` - *Versions <= 201811 using Quagga routing stack* - ``` - show ipv6 bgp neighbors [ [(advertised-routes | received-routes | routes)]] - ``` - -- Example: - ``` - admin@sonic:~$ show bgp ipv6 neighbors fc00::72 advertised-routes - - admin@sonic:~$ show bgp ipv6 neighbors fc00::72 received-routes - - admin@sonic:~$ show bgp ipv6 neighbors fc00::72 routes - ``` - Click [here](#Quagga-BGP-Show-Commands) to see the example for "show ip bgp summary" for Quagga. - - -**show ipv6 bgp network [[|] [(bestpath | multipath | longer-prefixes | json)]] - -This command displays all the details of IPv6 Border Gateway Protocol (BGP) prefixes. - -- Usage: - - - ``` - show ipv6 bgp network [[|] [(bestpath | multipath | longer-prefixes | json)]] - ``` - -- Example: - - NOTE: The "longer-prefixes" option is only available when a network prefix with a "/" notation is used. - - ``` - admin@sonic:~$ show ipv6 bgp network - - admin@sonic:~$ show ipv6 bgp network fc00::72 bestpath - - admin@sonic:~$ show ipv6 bgp network fc00::72 multipath - - admin@sonic:~$ show ipv6 bgp network fc00::72 json - - admin@sonic:~$ show ipv6 bgp network fc00::72/64 bestpath - - admin@sonic:~$ show ipv6 bgp network fc00::72/64 multipath - - admin@sonic:~$ show ipv6 bgp network fc00::72/64 json - - admin@sonic:~$ show ipv6 bgp network fc00::72/64 longer-prefixes - ``` - - - - -**show route-map** - -This command displays the routing policy that takes precedence over the other route processes that are configured. - -- Usage: - ``` - show route-map - ``` - -- Example: - ``` - admin@sonic:~$ show route-map - ZEBRA: - route-map RM_SET_SRC, permit, sequence 10 - Match clauses: - Set clauses: - src 10.12.0.102 - Call clause: - Action: - Exit routemap - ZEBRA: - route-map RM_SET_SRC6, permit, sequence 10 - Match clauses: - Set clauses: - src fc00:1::102 - Call clause: - Action: - Exit routemap - BGP: - route-map FROM_BGP_SPEAKER_V4, permit, sequence 10 - Match clauses: - Set clauses: - Call clause: - Action: - Exit routemap - BGP: - route-map TO_BGP_SPEAKER_V4, deny, sequence 10 - Match clauses: - Set clauses: - Call clause: - Action: - Exit routemap - BGP: - route-map ISOLATE, permit, sequence 10 - Match clauses: - Set clauses: - as-path prepend 65000 - Call clause: - Action: - Exit routemap - ``` - - -### BGP config commands - -This sub-section explains the list of configuration options available for BGP module for both IPv4 and IPv6 BGP neighbors. - -**config bgp shutdown all** - -This command is used to shutdown all the BGP IPv4 & IPv6 sessions. -When the session is shutdown using this command, BGP state in "show ip bgp summary" is displayed as "Idle (Admin)" - -- Usage: - ``` - config bgp shutdown all - ``` - -- Example: - ``` - admin@sonic:~$ sudo config bgp shutdown all - ``` - -**config bgp shutdown neighbor** - -This command is to shut down a BGP session with a neighbor by that neighbor's IP address or hostname - -- Usage: - ``` - sudo config bgp shutdown neighbor ( | ) - ``` - -- Examples: - ``` - admin@sonic:~$ sudo config bgp shutdown neighbor 192.168.1.124 - ``` - ``` - admin@sonic:~$ sudo config bgp shutdown neighbor SONIC02SPINE - ``` - - -**config bgp startup all** - -This command is used to start up all the IPv4 & IPv6 BGP neighbors - -- Usage: - ``` - config bgp startup all - ``` - -- Example: - ``` - admin@sonic:~$ sudo config bgp startup all - ``` - - -**config bgp startup neighbor** - -This command is used to start up the particular IPv4 or IPv6 BGP neighbor using either the IP address or hostname. - -- Usage: - ``` - config bgp startup neighbor ( | ) - ``` - -- Examples: - ``` - admin@sonic:~$ sudo config bgp startup neighbor 192.168.1.124 - ``` - ``` - admin@sonic:~$ sudo config bgp startup neighbor SONIC02SPINE - ``` - - -**config bgp remove neighbor** - -This command is used to remove particular IPv4 or IPv6 BGP neighbor configuration using either the IP address or hostname. - -- Usage: - ``` - config bgp remove neighbor - ``` - -- Examples: - ``` - admin@sonic:~$ sudo config bgp remove neighbor 192.168.1.124 - ``` - ``` - admin@sonic:~$ sudo config bgp remove neighbor 2603:10b0:b0f:346::4a - ``` - ``` - admin@sonic:~$ sudo config bgp remove neighbor SONIC02SPINE - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#bgp) - -## Console - -This section explains all Console show commands and configuration options that are supported in SONiC. - -All commands are used only when SONiC is used as console switch. - -All commands under this section are not applicable when SONiC used as regular switch. - -### Console show commands - -**show line** - -This command displays serial port or a virtual network connection status. - -- Usage: - ``` - show line (-b|--breif) - ``` - -- Example: - ``` - admin@sonic:~$ show line - Line Baud Flow Control PID Start Time Device - ------ ------ -------------- ----- ------------ -------- - 1 9600 Enabled - - switch1 - 2 - Disabled - - - 3 - Disabled - - - 4 - Disabled - - - 5 - Disabled - - - ``` - -Optionally, you can display configured console ports only by specifying the `-b` or `--breif` flag. - -- Example: - ``` - admin@sonic:~$ show line -b - Line Baud Flow Control PID Start Time Device - ------ ------ -------------- ----- ------------ -------- - 1 9600 Enabled - - switch1 - ``` - -## Console config commands - -This sub-section explains the list of configuration options available for console management module. - -**config console enable** - -This command is used to enable SONiC console switch feature. - -- Usage: - ``` - config console enable - ``` - -- Example: - ``` - admin@sonic:~$ sudo config console enable - ``` - -**config console disable** - -This command is used to disable SONiC console switch feature. - -- Usage: - ``` - config console disable - ``` - -- Example: - ``` - admin@sonic:~$ sudo config console disable - ``` - -**config console add** - -This command is used to add a console port setting. - -- Usage: - ``` - config console add [--baud|-b ] [--flowcontrol|-f] [--devicename|-d ] - ``` - -- Example: - ``` - admin@sonic:~$ config console add 1 --baud 9600 --devicename switch1 - ``` - -**config console del** - -This command is used to remove a console port setting. - -- Usage: - ``` - config console del - ``` - -- Example: - ``` - admin@sonic:~$ sudo config console del 1 - ``` - -**config console remote_device** - -This command is used to update the remote device name for a console port. - -- Usage: - ``` - config console remote_device - ``` - -- Example: - ``` - admin@sonic:~$ sudo config console remote_device 1 switch1 - ``` - -**config console baud** - -This command is used to update the baud rate for a console port. - -- Usage: - ``` - config console baud - ``` - -- Example: - ``` - admin@sonic:~$ sudo config console baud 1 9600 - ``` - -**config console flow_control** - -This command is used to enable or disable flow control feature for a console port. - -- Usage: - ``` - config console flow_control {enable|disable} - ``` - -- Example: - ``` - admin@sonic:~$ sudo config console flow_control enable 1 - ``` - -### Console connect commands - -**connect line** - -This command allows user to connect to a remote device via console line with an interactive cli. - -- Usage: - ``` - connect line (-d|--devicename) - ``` - -By default, the target is `port_name`. - -- Example: - ``` - admin@sonic:~$ connect line 1 - Successful connection to line 1 - Press ^A ^X to disconnect - ``` - -Optionally, you can connect with a remote device name by specifying the `-d` or `--devicename` flag. - -- Example: - ``` - admin@sonic:~$ connect line --devicename switch1 - Successful connection to line 1 - Press ^A ^X to disconnect - ``` - -**connect device** - -This command allows user to connect to a remote device via console line with an interactive cli. - -- Usage: - ``` - connect device - ``` - -The command is same with `connect line --devicename ` - -- Example: - ``` - admin@sonic:~$ connect line 1 - Successful connection to line 1 - Press ^A ^X to disconnect - ``` - -### Console clear commands - -**sonic-clear line** - -This command allows user to connect to a remote device via console line with an interactive cli. - -- Usage: - ``` - sonc-clear line (-d|--devicename) - ``` - -By default, the target is `port_name`. - -- Example: - ``` - admin@sonic:~$ sonic-clear line 1 - ``` - -Optionally, you can clear with a remote device name by specifying the `-d` or `--devicename` flag. - -- Example: - ``` - admin@sonic:~$ sonic-clear --devicename switch1 - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#console) - - -## DHCP Relay - -### DHCP Relay config commands - -This sub-section of commands is used to add or remove the DHCP Relay Destination IP address(es) for a VLAN interface. - -**config vlan dhcp_relay add** - -This command is used to add a DHCP Relay Destination IP address or multiple IP addresses to a VLAN. Note that more than one DHCP Relay Destination IP address can be added on a VLAN interface. - -- Usage: - ``` - config vlan dhcp_relay add - ``` - -- Example: - ``` - admin@sonic:~$ sudo config vlan dhcp_relay add 1000 7.7.7.7 - Added DHCP relay destination address ['7.7.7.7'] to Vlan1000 - Restarting DHCP relay service... - ``` - ``` - admin@sonic:~$ sudo config vlan dhcp_relay add 1000 7.7.7.7 1.1.1.1 - Added DHCP relay destination address ['7.7.7.7', '1.1.1.1'] to Vlan1000 - Restarting DHCP relay service... - ``` - -**config vlan dhcp_relay delete** - -This command is used to delete a configured DHCP Relay Destination IP address or multiple IP addresses from a VLAN interface. - -- Usage: - ``` - config vlan dhcp_relay del - ``` - -- Example: - ``` - admin@sonic:~$ sudo config vlan dhcp_relay del 1000 7.7.7.7 - Removed DHCP relay destination address 7.7.7.7 from Vlan1000 - Restarting DHCP relay service... - ``` - ``` - admin@sonic:~$ sudo config vlan dhcp_relay del 1000 7.7.7.7 1.1.1.1 - Removed DHCP relay destination address ('7.7.7.7', '1.1.1.1') from Vlan1000 - Restarting DHCP relay service... - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#dhcp-relay) - - -## Drop Counters - -This section explains all the Configurable Drop Counters show commands and configuration options that are supported in SONiC. - -### Drop Counters show commands - -**show dropcounters capabilities** - -This command is used to show the drop counter capabilities that are available on this device. It displays the total number of drop counters that can be configured on this device as well as the drop reasons that can be configured for the counters. - -- Usage: - ``` - show dropcounters capabilities - ``` - -- Examples: - ``` - admin@sonic:~$ show dropcounters capabilities - Counter Type Total - -------------------- ------- - PORT_INGRESS_DROPS 3 - SWITCH_EGRESS_DROPS 2 - - PORT_INGRESS_DROPS: - L2_ANY - SMAC_MULTICAST - SMAC_EQUALS_DMAC - INGRESS_VLAN_FILTER - EXCEEDS_L2_MTU - SIP_CLASS_E - SIP_LINK_LOCAL - DIP_LINK_LOCAL - UNRESOLVED_NEXT_HOP - DECAP_ERROR - - SWITCH_EGRESS_DROPS: - L2_ANY - L3_ANY - A_CUSTOM_REASON - ``` - -**show dropcounters configuration** - -This command is used to show the current running configuration of the drop counters on this device. - -- Usage: - ``` - show dropcounters configuration [-g ] - ``` - -- Examples: - ``` - admin@sonic:~$ show dropcounters configuration - Counter Alias Group Type Reasons Description - -------- -------- ----- ------------------ ------------------- -------------- - DEBUG_0 RX_LEGIT LEGIT PORT_INGRESS_DROPS SMAC_EQUALS_DMAC Legitimate port-level RX pipeline drops - INGRESS_VLAN_FILTER - DEBUG_1 TX_LEGIT None SWITCH_EGRESS_DROPS EGRESS_VLAN_FILTER Legitimate switch-level TX pipeline drops - - admin@sonic:~$ show dropcounters configuration -g LEGIT - Counter Alias Group Type Reasons Description - -------- -------- ----- ------------------ ------------------- -------------- - DEBUG_0 RX_LEGIT LEGIT PORT_INGRESS_DROPS SMAC_EQUALS_DMAC Legitimate port-level RX pipeline drops - INGRESS_VLAN_FILTER - ``` - -**show dropcounters counts** - -This command is used to show the current statistics for the configured drop counters. Standard drop counters are displayed as well for convenience. - -Because clear (see below) is handled on a per-user basis different users may see different drop counts. - -- Usage: - ``` - show dropcounters counts [-g ] [-t ] - ``` - -- Example: - ``` - admin@sonic:~$ show dropcounters counts - IFACE STATE RX_ERR RX_DROPS TX_ERR TX_DROPS RX_LEGIT - --------- ------- -------- ---------- -------- ---------- --------- - Ethernet0 U 10 100 0 0 20 - Ethernet4 U 0 1000 0 0 100 - Ethernet8 U 100 10 0 0 0 - - DEVICE TX_LEGIT - ------ -------- - sonic 1000 - - admin@sonic:~$ show dropcounters counts -g LEGIT - IFACE STATE RX_ERR RX_DROPS TX_ERR TX_DROPS RX_LEGIT - --------- ------- -------- ---------- -------- ---------- --------- - Ethernet0 U 10 100 0 0 20 - Ethernet4 U 0 1000 0 0 100 - Ethernet8 U 100 10 0 0 0 - - admin@sonic:~$ show dropcounters counts -t SWITCH_EGRESS_DROPS - DEVICE TX_LEGIT - ------ -------- - sonic 1000 - ``` - -### Drop Counters config commands - -**config dropcounters install** - -This command is used to initialize a new drop counter. The user must specify a name, type, and initial list of drop reasons. - -This command will fail if the given name is already in use, if the type of counter is not supported, or if any of the specified drop reasons are not supported. It will also fail if all avaialble counters are already in use on the device. - -- Usage: - ``` - config dropcounters install [-d ] [-g ] [-a ] - ``` - -- Example: - ``` - admin@sonic:~$ sudo config dropcounters install DEBUG_2 PORT_INGRESS_DROPS [EXCEEDS_L2_MTU,DECAP_ERROR] -d "More port ingress drops" -g BAD -a BAD_DROPS - ``` - -**config dropcounters add_reasons** - -This command is used to add drop reasons to an already initialized counter. - -This command will fail if any of the specified drop reasons are not supported. - -- Usage: - ``` - config dropcounters add_reasons - ``` - -- Example: - ``` - admin@sonic:~$ sudo config dropcounters add_reasons DEBUG_2 [SIP_CLASS_E] - ``` - -**config dropcounters remove_reasons** - -This command is used to remove drop reasons from an already initialized counter. - -- Usage: - ``` - config dropcounters remove_reasons - ``` - -- Example: - ``` - admin@sonic:~$ sudo config dropcounters remove_reasons DEBUG_2 [SIP_CLASS_E] - ``` - -**config dropcounters delete** - -This command is used to delete a drop counter. - -- Usage: - ``` - config dropcounters delete - ``` - -- Example: - ``` - admin@sonic:~$ sudo config dropcounters delete DEBUG_2 - ``` - -### Drop Counters clear commands - -**sonic-clear dropcounters** - -This comnmand is used to clear drop counters. This is done on a per-user basis. - -- Usage: - ``` - sonic-clear dropcounters - ``` - -- Example: - ``` - admin@sonic:~$ sonic-clear dropcounters - Cleared drop counters - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](##drop-counters) - -## Dynamic Buffer Management - -This section explains all the show and configuration commands regarding the dynamic buffer management. - -Dynamic buffer management is responsible for calculating buffer size according to the ports' configured speed and administrative state. In order to enable dynamic buffer management feature, the ports' speed must be configured. For this please refer [Interface naming mode config commands](#interface-naming-mode-config-commands) - -### Configuration commands - -**configure shared headroom pool** - -This command is used to configure the shared headroom pool. The shared headroom pool can be enabled in the following ways: - -- Configure the over subscribe ratio. In this case, the size of shared headroom pool is calculated as the accumulative xoff of all of the lossless PG divided by the over subscribe ratio. -- Configure the size. - -In case both of the above parameters have been configured, the `size` will take effect. To disable shared headroom pool, configure both parameters to zero. - -- Usage: - - ``` - config buffer shared-headroom-pool over-subscribe-ratio - config buffer shared-headroom-pool size - ``` - - The range of over-subscribe-ratio is from 1 to number of ports inclusive. - -- Example: - - ``` - admin@sonic:~$ sudo config shared-headroom-pool over-subscribe-ratio 2 - admin@sonic:~$ sudo config shared-headroom-pool size 1024000 - ``` - -**configure a lossless buffer profile** - -This command is used to configure a lossless buffer profile. - -- Usage: - - ``` - config buffer profile add --xon --xoff [-size ] [-dynamic_th ] [-pool ] - config buffer profile set --xon --xoff [-size ] [-dynamic_th ] [-pool ] - config buffer profile remove - ``` - - All the parameters are devided to two groups, one for headroom and one for dynamic_th. For any command at lease one group of parameters should be provided. - For headroom parameters: - - - `xon` is madantory. - - If shared headroom pool is disabled: - - At lease one of `xoff` and `size` should be provided and the other will be optional and conducted via the formula `xon + xoff = size`. - - `xon` + `xoff` <= `size`; For Mellanox platform xon + xoff == size - - If shared headroom pool is enabled: - - `xoff` should be provided. - - `size` = `xoff` if it is not provided. - - If only headroom parameters are provided, the `dynamic_th` will be taken from `CONFIG_DB.DEFAULT_LOSSLESS_BUFFER_PARAMETER.default_dynamic_th`. - - If only dynamic_th parameter is provided, the `headroom_type` will be set as `dynamic` and `xon`, `xoff` and `size` won't be set. This is only used for non default dynamic_th. In this case, the profile won't be deployed to ASIC directly. It can be configured to a lossless PG and then a dynamic profile will be generated based on the port's speed, cable length, and MTU and deployed to the ASIC. - - The subcommand `add` is designed for adding a new buffer profile to the system. - - The subcommand `set` is designed for modifying an existing buffer profile in the system. - For a profile with dynamically calculated headroom information, only `dynamic_th` can be modified. - - The subcommand `remove` is designed for removing an existing buffer profile from the system. When removing a profile, it shouldn't be referenced by any entry in `CONFIG_DB.BUFFER_PG`. - -- Example: - - ``` - admin@sonic:~$ sudo config buffer profile add profile1 --xon 18432 --xoff 18432 - admin@sonic:~$ sudo config buffer profile remove profile1 - ``` - -**config interface cable_length** - -This command is used to configure the length of the cable connected to a port. The cable_length is in unit of meters and must be suffixed with "m". - -- Usage: - - ``` - config interface cable_length - ``` - -- Example: - - ``` - admin@sonic:~$ sudo config interface cable_length Ethernet0 40m - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#dynamic-buffer-management) - -**config interface buffer priority-group lossless** - -This command is used to configure the priority groups on which lossless traffic runs. - -- Usage: - - ``` - config interface buffer priority-group lossless add [profile] - config interface buffer priority-group lossless set [profile] - config interface buffer priority-group lossless remove [] - ``` - - The can be in one of the following two forms: - - - For a range of priorities, the lower bound and upper bound connected by a dash, like `3-4` - - For a single priority, the number, like `6` - - The `pg-map` represents the map of priorities for lossless traffic. It should be a string and in form of a bit map like `3-4`. The `-` connects the lower bound and upper bound of a range of priorities. - - The subcommand `add` is designed for adding a new lossless PG on top of current PGs. The new PG range must be disjoint with all existing PGs. - - For example, currently the PG range 3-4 exist on port Ethernet4, to add PG range 4-5 will fail because it isn't disjoint with 3-4. To add PG range 5-6 will succeed. After that both range 3-4 and 5-6 will work as lossless PG. - - The `override-profile` parameter is optional. When provided, it represents the predefined buffer profile for headroom override. - - The subcommand `set` is designed for modifying an existing PG from dynamic calculation to headroom override or vice versa. The `pg-map` must be an existing PG. - - The subcommand `remove` is designed for removing an existing PG. The option `pg-map` must be an existing PG. All lossless PGs will be removed in case no `pg-map` provided. - -- Example: - - To configure lossless_pg on a port: - - ``` - admin@sonic:~$ sudo config interface buffer priority-group lossless add Ethernet0 3-4 - ``` - - To change the profile used for lossless_pg on a port: - - ``` - admin@sonic:~$ sudo config interface buffer priority-group lossless set Ethernet0 3-4 new-profile - ``` - - To remove one lossless priority from a port: - - ``` - admin@sonic:~$ sudo config interface buffer priority-group lossless remove Ethernet0 6 - ``` - - To remove all lossless priorities from a port: - - ``` - admin@sonic:~$ sudo config interface buffer priority-group lossless remove Ethernet0 - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#dynamic-buffer-management) - -**config interface buffer queue** - -This command is used to configure the buffer profiles for queues. - -- Usage: - - ``` - config interface buffer queue add - config interface buffer queue set - config interface buffer queue remove - ``` - - The represents the map of queues. It can be in one of the following two forms: - - - For a range of priorities, the lower bound and upper bound connected by a dash, like `3-4` - - For a single priority, the number, like `6` - - The subcommand `add` is designed for adding a buffer profile for a group of queues. The new queue range must be disjoint with all queues with buffer profile configured. - - For example, currently the buffer profile configured on queue 3-4 on port Ethernet4, to configure buffer profile on queue 4-5 will fail because it isn't disjoint with 3-4. To configure it on range 5-6 will succeed. - - The `profile` parameter represents a predefined egress buffer profile to be configured on the queues. - - The subcommand `set` is designed for modifying an existing group of queues. - - The subcommand `remove` is designed for removing buffer profile on an existing group of queues. - -- Example: - - To configure buffer profiles for queues on a port: - - ``` - admin@sonic:~$ sudo config interface buffer queue add Ethernet0 3-4 egress_lossless_profile - ``` - - To change the profile used for queues on a port: - - ``` - admin@sonic:~$ sudo config interface buffer queue set Ethernet0 3-4 new-profile - ``` - - To remove a group of queues from a port: - - ``` - admin@sonic:~$ sudo config interface buffer queue remove Ethernet0 3-4 - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#dynamic-buffer-management) - -### Show commands - -**show buffer information** - -This command is used to display the status of buffer pools and profiles currently deployed to the ASIC. - -- Usage: - - ``` - show buffer information - ``` - -- Example: - - ``` - admin@sonic:~$ show buffer information - Pool: ingress_lossless_pool - ---- -------- - type ingress - mode dynamic - size 17170432 - ---- -------- - - Pool: egress_lossless_pool - ---- -------- - type egress - mode dynamic - size 34340822 - ---- -------- - - Pool: ingress_lossy_pool - ---- -------- - type ingress - mode dynamic - size 17170432 - ---- -------- - - Pool: egress_lossy_pool - ---- -------- - type egress - mode dynamic - size 17170432 - ---- -------- - - Profile: pg_lossless_100000_5m_profile - ---------- ----------------------------------- - xon 18432 - dynamic_th 0 - xoff 18432 - pool [BUFFER_POOL:ingress_lossless_pool] - size 36864 - ---------- ----------------------------------- - - Profile: q_lossy_profile - ---------- ------------------------------- - dynamic_th 3 - pool [BUFFER_POOL:egress_lossy_pool] - size 0 - ---------- ------------------------------- - - Profile: egress_lossy_profile - ---------- ------------------------------- - dynamic_th 3 - pool [BUFFER_POOL:egress_lossy_pool] - size 4096 - ---------- ------------------------------- - - Profile: egress_lossless_profile - ---------- ---------------------------------- - dynamic_th 7 - pool [BUFFER_POOL:egress_lossless_pool] - size 0 - ---------- ---------------------------------- - - Profile: ingress_lossless_profile - ---------- ----------------------------------- - dynamic_th 0 - pool [BUFFER_POOL:ingress_lossless_pool] - size 0 - ---------- ----------------------------------- - - Profile: pg_lossless_100000_79m_profile - ---------- ----------------------------------- - xon 18432 - dynamic_th 0 - xoff 60416 - pool [BUFFER_POOL:ingress_lossless_pool] - size 78848 - ---------- ----------------------------------- - - Profile: pg_lossless_100000_40m_profile - ---------- ----------------------------------- - xon 18432 - dynamic_th 0 - xoff 38912 - pool [BUFFER_POOL:ingress_lossless_pool] - size 57344 - ---------- ----------------------------------- - - Profile: ingress_lossy_profile - ---------- -------------------------------- - dynamic_th 3 - pool [BUFFER_POOL:ingress_lossy_pool] - size 0 - ---------- -------------------------------- - ``` - -**show buffer configuration** - -This command is used to display the status of buffer pools and profiles currently configured. - -- Usage: - - ``` - show buffer configuration - ``` - -- Example: - - ``` - admin@sonic:~$ show buffer configuration - Lossless traffic pattern: - -------------------- - - default_dynamic_th 0 - over_subscribe_ratio 0 - -------------------- - - - Pool: ingress_lossless_pool - ---- -------- - type ingress - mode dynamic - ---- -------- - - Pool: egress_lossless_pool - ---- -------- - type egress - mode dynamic - size 34340822 - ---- -------- - - Pool: ingress_lossy_pool - ---- -------- - type ingress - mode dynamic - ---- -------- - - Pool: egress_lossy_pool - ---- -------- - type egress - mode dynamic - ---- -------- - - Profile: q_lossy_profile - ---------- ------------------------------- - dynamic_th 3 - pool [BUFFER_POOL:egress_lossy_pool] - size 0 - ---------- ------------------------------- - - Profile: egress_lossy_profile - ---------- ------------------------------- - dynamic_th 3 - pool [BUFFER_POOL:egress_lossy_pool] - size 4096 - ---------- ------------------------------- - - Profile: egress_lossless_profile - ---------- ---------------------------------- - dynamic_th 7 - pool [BUFFER_POOL:egress_lossless_pool] - size 0 - ---------- ---------------------------------- - - Profile: ingress_lossless_profile - ---------- ----------------------------------- - dynamic_th 0 - pool [BUFFER_POOL:ingress_lossless_pool] - size 0 - ---------- ----------------------------------- - - Profile: ingress_lossy_profile - ---------- -------------------------------- - dynamic_th 3 - pool [BUFFER_POOL:ingress_lossy_pool] - size 0 - ---------- -------------------------------- - ``` - -## ECN - -This section explains all the Explicit Congestion Notification (ECN) show commands and ECN configuation options that are supported in SONiC. - -### ECN show commands -This sub-section contains the show commands that are supported in ECN. - -**show ecn** - -This command displays all the WRED profiles that are configured in the device. - -- Usage: - ``` - show ecn - ``` - -- Example: - ``` - admin@sonic:~$ show ecn - Profile: **AZURE_LOSSLESS** - ----------------------- ------- - red_max_threshold 2097152 - red_drop_probability 5 - yellow_max_threshold 2097152 - ecn ecn_all - green_min_threshold 1048576 - red_min_threshold 1048576 - wred_yellow_enable true - yellow_min_threshold 1048576 - green_max_threshold 2097152 - green_drop_probability 5 - wred_green_enable true - yellow_drop_probability 5 - wred_red_enable true - ----------------------- ------- - - Profile: **wredprofileabcd** - ----------------- --- - red_max_threshold 100 - ----------------- --- - ``` - -### ECN config commands - -This sub-section contains the configuration commands that can configure the WRED profiles. - -**config ecn** - -This command configures the possible fields in a particular WRED profile that is specified using "-profile " argument. -The list of the WRED profile fields that are configurable is listed in the below "Usage". - -- Usage: - ``` - config ecn -profile [-rmax ] [-rmin ] [-ymax ] [-ymin ] [-gmax ] [-gmin ] [-v|--verbose] - ``` - - - Parameters: - - profile_name Profile name - - red_threshold_max Set red max threshold - - red_threshold_min Set red min threshold - - yellow_threshold_max Set yellow max threshold - - yellow_threshold_min Set yellow min threshold - - green_threshold_max Set green max threshold - - green_threshold_min Set green min threshold - -- Example (Configures the "red max threshold" for the WRED profile name "wredprofileabcd". It will create the WRED profile if it does not exist.): - ``` - admin@sonic:~$ sudo config ecn -profile wredprofileabcd -rmax 100 - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#ecn) - -## Feature - -SONiC includes a capability in which Feature state can be enabled/disabled -which will make corresponding feature docker container to start/stop. - -Also SONiC provide capability in which Feature docker container can be automatically shut -down and restarted if one of critical processes running in the container exits -unexpectedly. Restarting the entire feature container ensures that configuration is -reloaded and all processes in the feature container get restarted, thus increasing the -likelihood of entering a healthy state. - -### Feature show commands - -**show feature config** - -Shows the config of given feature or all if no feature is given. The "fallback" is shown only if configured. The fallback defaults to "true" when not configured. - -- Usage: - ``` - show feature config [] - ``` - -- Example: - ``` - admin@sonic:~$ show feature config - Feature State AutoRestart Owner fallback - -------------- -------- ------------- ------- ---------- - bgp enabled enabled local - database enabled disabled local - dhcp_relay enabled enabled kube - lldp enabled enabled kube true - mgmt-framework enabled enabled local - nat disabled enabled local - pmon enabled enabled kube - radv enabled enabled kube - sflow disabled enabled local - snmp enabled enabled kube - swss enabled enabled local - syncd enabled enabled local - teamd enabled enabled local - telemetry enabled enabled kube - ``` - -**show feature status** - -Shows the status of given feature or all if no feature is given. The "fallback" defaults to "true" when not configured. -The subset of features are configurable for remote management and only those report additional data. - -- Usage: - ``` - show feature status [] - ``` - -- Example: - ``` - admin@sonic:~$ show feature status - Feature State AutoRestart SystemState UpdateTime ContainerId ContainerVersion SetOwner CurrentOwner RemoteState - -------------- -------- ------------- ------------- ------------------- ------------- ------------------ ---------- -------------- ------------- - bgp enabled enabled up local local none - database enabled disabled local - dhcp_relay enabled enabled up 2020-11-15 18:21:09 249e70102f55 20201230.100 kube local - lldp enabled enabled up 2020-11-15 18:21:09 779c2d55ee12 20201230.100 kube local - mgmt-framework enabled enabled up local local none - nat disabled enabled local - pmon enabled enabled up 2020-11-15 18:20:27 a2b9ffa8aba3 20201230.100 kube local - radv enabled enabled up 2020-11-15 18:21:05 d8ff27dcfe46 20201230.100 kube local - sflow disabled enabled local - snmp enabled enabled up 2020-11-15 18:25:51 8b7d5529e306 20201230.111 kube kube running - swss enabled enabled up local local none - syncd enabled enabled up local local none - teamd enabled enabled up local local none - telemetry enabled enabled down 2020-11-15 18:24:59 20201230.100 kube none - ``` - -**config feature owner** - -Configures the owner for a feature as "local" or "kube". The "local" implies starting the feature container from local image. The "kube" implies that kubernetes server is made eligible to deploy the feature. The deployment of a feature by kubernetes is conditional based on many factors like, whether the kube server is configured or not, connected-to-kube-server or not and if that master has manifest for this feature for this switch or not and more. At some point in future, the deployment *could* happen and till that point the feature can run from local image, called "fallback". The fallback is allowed by default and it could be toggled to "not allowed". When fallback is not allowed, the feature would run only upon deployment by kubernetes master. - -- Usage: - ``` - config feature owner [] [local/kube] - ``` - -- Example: - ``` - admin@sonic:~$ sudo config feature owner snmp kube - ``` - -**config feature fallback** - -Features configured for "kube" deployment could be allowed to fallback to using local image, until the point of successful kube deployment. The fallback is allowed by default. - -- Usage: - ``` - config feature fallback [] [on/off] - ``` - -- Example: - ``` - admin@sonic:~$ sudo config feature fallback snmp on - ``` - -**show feature autorestart** - -This command will display the status of auto-restart for feature container. - -- Usage: - ``` - show feature autorestart [] - admin@sonic:~$ show feature autorestart - Feature AutoRestart - ---------- -------------- - bgp enabled - database always_enabled - dhcp_relay enabled - lldp enabled - pmon enabled - radv enabled - snmp enabled - swss enabled - syncd enabled - teamd enabled - telemetry enabled - ``` - -Optionally, you can specify a feature name in order to display -status for that feature - -### Feature config commands - -**config feature state ** - -This command will configure the state for a specific feature. - -- Usage: - ``` - config feature state (enabled | disabled) - admin@sonic:~$ sudo config feature state bgp disabled - ``` - -**config feature autorestart ** - -This command will configure the status of auto-restart for a specific feature container. - -- Usage: - ``` - config feature autorestart (enabled | disabled) - admin@sonic:~$ sudo config feature autorestart bgp disabled - ``` -NOTE: If the existing state or auto-restart value for a feature is "always_enabled" then config -commands are don't care and will not update state/auto-restart value. - -Go Back To [Beginning of the document](#) or [Beginning of this section](#feature) - -## Flow Counters - -This section explains all the Flow Counters show commands, clear commands and config commands that are supported in SONiC. Flow counters are usually used for debugging, troubleshooting and performance enhancement processes. Flow counters supports case like: - - - Host interface traps (number of received traps per Trap ID) - - Routes matching the configured prefix pattern (number of hits and number of bytes) - -### Flow Counters show commands - -**show flowcnt-trap stats** - -This command is used to show the current statistics for the registered host interface traps. - -Because clear (see below) is handled on a per-user basis different users may see different counts. - -- Usage: - ``` - show flowcnt-trap stats - ``` - -- Example: - ``` - admin@sonic:~$ show flowcnt-trap stats - Trap Name Packets Bytes PPS - --------- --------- ------- ------- - dhcp 100 2,000 50.25/s - - For multi-ASIC: - admin@sonic:~$ show flowcnt-trap stats - ASIC ID Trap Name Packets Bytes PPS - ------- ----------- --------- ------- ------- - asic0 dhcp 100 2,000 50.25/s - asic1 dhcp 200 3,000 45.25/s - ``` - -**show flowcnt-route stats** - -This command is used to show the current statistics for route flow patterns. - -Because clear (see below) is handled on a per-user basis different users may see different counts. - -- Usage: - ``` - show flowcnt-route stats - show flowcnt-route stats pattern [--vrf ] - show flowcnt-route stats route [--vrf ] - ``` - -- Example: - ``` - admin@sonic:~$ show flowcnt-route stats - Route pattern VRF Matched routes Packets Bytes - -------------------------------------------------------------------------------------- - 3.3.0.0/16 default 3.3.1.0/24 100 4543 - 3.3.2.3/32 3443 929229 - 3.3.0.0/16 0 0 - 2000::/64 default 2000::1/128 100 4543 - ``` - -The "pattern" subcommand is used to display the route flow counter statistics by route pattern. - -- Example: - ``` - admin@sonic:~$ show flowcnt-route stats pattern 3.3.0.0/16 - Route pattern VRF Matched routes Packets Bytes - -------------------------------------------------------------------------------------- - 3.3.0.0/16 default 3.3.1.0/24 100 4543 - 3.3.2.3/32 3443 929229 - 3.3.0.0/16 0 0 - ``` - -The "route" subcommand is used to display the route flow counter statistics by route prefix. - ``` - admin@sonic:~$ show flowcnt-route stats route 3.3.3.2/32 --vrf Vrf_1 - Route VRF Route Pattern Packets Bytes - ----------------------------------------------------------------------------------------- - 3.3.3.2/32 Vrf_1 3.3.0.0/16 100 4543 - ``` - -### Flow Counters clear commands - -**sonic-clear flowcnt-trap** - -This command is used to clear the current statistics for the registered host interface traps. This is done on a per-user basis. - -- Usage: - ``` - sonic-clear flowcnt-trap - ``` - -- Example: - ``` - admin@sonic:~$ sonic-clear flowcnt-trap - Trap Flow Counters were successfully cleared - ``` - -**sonic-clear flowcnt-route** - -This command is used to clear the current statistics for the route flow counter. This is done on a per-user basis. - -- Usage: - ``` - sonic-clear flowcnt-route - sonic-clear flowcnt-route pattern [--vrf ] - sonic-clear flowcnt-route route [--vrf ] - ``` - -- Example: - ``` - admin@sonic:~$ sonic-clear flowcnt-route - Route Flow Counters were successfully cleared - ``` - -The "pattern" subcommand is used to clear the route flow counter statistics by route pattern. - -- Example: - ``` - admin@sonic:~$ sonic-clear flowcnt-route pattern 3.3.0.0/16 --vrf Vrf_1 - Flow Counters of all routes matching the configured route pattern were successfully cleared - ``` - -The "route" subcommand is used to clear the route flow counter statistics by route prefix. - -- Example: - ``` - admin@sonic:~$ sonic-clear flowcnt-route route 3.3.3.2/32 --vrf Vrf_1 - Flow Counters of the specified route were successfully cleared - ``` - -### Flow Counters config commands - -**config flowcnt-route pattern add** - -This command is used to add or update the route pattern which is used by route flow counter to match route entries. - -- Usage: - ``` - config flowcnt-route pattern add [--vrf ] [--max ] - ``` - -- Example: - ``` - admin@sonic:~$ config flowcnt-route pattern add 2.2.0.0/16 --vrf Vrf_1 --max 50 - ``` - -**config flowcnt-route pattern remove** - -This command is used to remove the route pattern which is used by route flow counter to match route entries. - -- Usage: - ``` - config flowcnt-route pattern remove [--vrf ] - ``` - -- Example: - ``` - admin@sonic:~$ config flowcnt-route pattern remove 2.2.0.0/16 --vrf Vrf_1 - ``` - - -Go Back To [Beginning of the document](#) or [Beginning of this section](#flow-counters) -## Gearbox - -This section explains all the Gearbox PHY show commands that are supported in SONiC. - -### Gearbox show commands -This sub-section contains the show commands that are supported for gearbox phy. - -**show gearbox interfaces status** - -This command displays information about the gearbox phy interface lanes, speeds and status. Data is displayed for both MAC side and line side of the gearbox phy - -- Usage: - ``` - show gearbox interfaces status - ``` - -- Example: - -``` -home/admin# show gearbox interfaces status - PHY Id Interface MAC Lanes MAC Lane Speed PHY Lanes PHY Lane Speed Line Lanes Line Lane Speed Oper Admin --------- ----------- ----------- ---------------- ----------- ---------------- ------------ ----------------- ------ ------- - 1 Ethernet0 25,26,27,28 10G 200,201 20G 206 40G up up - 1 Ethernet4 29,30,31,32 10G 202,203 20G 207 40G up up - 1 Ethernet8 33,34,35,36 10G 204,205 20G 208 40G up up - - ``` - -**show gearbox phys status** - -This command displays basic information about the gearbox phys configured on the switch. - -- Usage: - ``` - show gearbox phys status - ``` - -- Example: - -``` -/home/admin# show gearbox phys status - PHY Id Name Firmware --------- ------- ---------- - 1 sesto-1 v0.1 - - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#gearbox) - - -## Update Device Hostname Configuration Commands - -This sub-section of commands is used to change device hostname without traffic being impacted. - -**config hostname** - -This command is used to change device hostname without traffic being impacted. - -- Usage: - ``` - config hostname - ``` - -- Example: - ``` - admin@sonic:~$ sudo config hostname CSW06 - Please note loaded setting will be lost after system reboot. To preserve setting, run `config save`. - ``` - -## Interfaces - -### Interface Show Commands - -This sub-section lists all the possible show commands for the interfaces available in the device. Following example gives the list of possible shows on interfaces. -Subsequent pages explain each of these commands in detail. - -- Example: - ``` - admin@sonic:~$ show interfaces -? - - Show details of the network interfaces - - Options: - -?, -h, --help Show this message and exit. - - Commands: - autoneg Show interface autoneg information - breakout Show Breakout Mode information by interfaces - counters Show interface counters - description Show interface status, protocol and... - mpls Show Interface MPLS status - naming_mode Show interface naming_mode status - neighbor Show neighbor related information - portchannel Show PortChannel information - status Show Interface status information - tpid Show Interface tpid information - transceiver Show SFP Transceiver information - ``` - -**show interfaces autoneg** - -This show command displays the port auto negotiation status for all interfaces i.e. interface name, auto negotiation mode, speed, advertised speeds, interface type, advertised interface types, operational status, admin status. For a single interface, provide the interface name with the sub-command. - -- Usage: - ``` - show interfaces autoneg status - show interfaces autoneg status - ``` - -- Example: - ``` - admin@sonic:~$ show interfaces autoneg status - Interface Auto-Neg Mode Speed Adv Speeds Type Adv Types Oper Admin - ----------- --------------- ------- ------------ ------ ----------- ------ ------- - Ethernet0 enabled 25G 10G,25G CR CR,CR4 up up - Ethernet4 disabled 100G all CR4 all up up - - admin@sonic:~$ show interfaces autoneg status Ethernet8 - Interface Auto-Neg Mode Speed Adv Speeds Type Adv Types Oper Admin - ----------- --------------- ------- ------------ ------ ----------- ------ ------- - Ethernet8 disabled 100G N/A CR4 N/A up up - ``` - -**show interfaces breakout (Versions >= 202006)** - -This show command displays the port capability for all interfaces i.e. index, lanes, default_brkout_mode, breakout_modes(i.e. available breakout modes) and brkout_mode (i.e. current breakout mode). To display current breakout mode, "current-mode" subcommand can be used.For a single interface, provide the interface name with the sub-command. - -- Usage: - ``` - show interfaces breakout - show interfaces breakout current-mode - show interfaces breakout current-mode - ``` - -- Example: - ``` - admin@lnos-x1-a-fab01:~$ show interfaces breakout - { - "Ethernet0": { - "index": "1,1,1,1", - "default_brkout_mode": "1x100G[40G]", - "child ports": "Ethernet0", - "child port speed": "100G", - "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]", - "Current Breakout Mode": "1x100G[40G]", - "lanes": "65,66,67,68", - "alias_at_lanes": "Eth1/1, Eth1/2, Eth1/3, Eth1/4" - },... continue - } - ``` -The "current-mode" subcommand is used to display current breakout mode for all interfaces. - ``` - admin@lnos-x1-a-fab01:~$ show interfaces breakout current-mode - +-------------+-------------------------+ - | Interface | Current Breakout Mode | - +=============+=========================+ - | Ethernet0 | 4x25G[10G] | - +-------------+-------------------------+ - | Ethernet4 | 4x25G[10G] | - +-------------+-------------------------+ - | Ethernet8 | 4x25G[10G] | - +-------------+-------------------------+ - | Ethernet12 | 4x25G[10G] | - +-------------+-------------------------+ - - admin@lnos-x1-a-fab01:~$ show interfaces breakout current-mode Ethernet0 - +-------------+-------------------------+ - | Interface | Current Breakout Mode | - +=============+=========================+ - | Ethernet0 | 4x25G[10G] | - +-------------+-------------------------+ - ``` - -**show interfaces counters** - -This show command displays packet counters for all interfaces since the last time the counters were cleared. To display l3 counters "rif" subcommand can be used. There is no facility to display counters for one specific l2 interface. For l3 interfaces a single interface output mode is present. Optional argument "-a" provides two additional columns - RX-PPS and TX_PPS. -Optional argument "-p" specify a period (in seconds) with which to gather counters over. - -- Usage: - ``` - show interfaces counters [-a|--printall] [-p|--period ] - show interfaces counters errors - show interfaces counters rates - show interfaces counters rif [-p|--period ] [-i ] - ``` - -- Example: - ``` - admin@sonic:~$ show interfaces counters - IFACE STATE RX_OK RX_BPS RX_UTIL RX_ERR RX_DRP RX_OVR TX_OK TX_BPS TX_UTIL TX_ERR TX_DRP TX_OVR - ----------- ------- --------------- ----------- --------- -------- -------- -------- --------------- ----------- --------- -------- -------- -------- - Ethernet0 U 471,729,839,997 653.87 MB/s 12.77% 0 18,682 0 409,682,385,925 556.84 MB/s 10.88% 0 0 0 - Ethernet4 U 453,838,006,636 632.97 MB/s 12.36% 0 1,636 0 388,299,875,056 529.34 MB/s 10.34% 0 0 0 - Ethernet8 U 549,034,764,539 761.15 MB/s 14.87% 0 18,274 0 457,603,227,659 615.20 MB/s 12.02% 0 0 0 - Ethernet12 U 458,052,204,029 636.84 MB/s 12.44% 0 17,614 0 388,341,776,615 527.37 MB/s 10.30% 0 0 0 - Ethernet16 U 16,679,692,972 13.83 MB/s 0.27% 0 17,605 0 18,206,586,265 17.51 MB/s 0.34% 0 0 0 - Ethernet20 U 47,983,339,172 35.89 MB/s 0.70% 0 2,174 0 58,986,354,359 51.83 MB/s 1.01% 0 0 0 - Ethernet24 U 33,543,533,441 36.59 MB/s 0.71% 0 1,613 0 43,066,076,370 49.92 MB/s 0.97% 0 0 0 - - admin@sonic:~$ show interfaces counters -i Ethernet4,Ethernet12-16 - IFACE STATE RX_OK RX_BPS RX_UTIL RX_ERR RX_DRP RX_OVR TX_OK TX_BPS TX_UTIL TX_ERR TX_DRP TX_OVR - ----------- ------- --------------- ----------- --------- -------- -------- -------- --------------- ----------- --------- -------- -------- -------- - Ethernet4 U 453,838,006,636 632.97 MB/s 12.36% 0 1,636 0 388,299,875,056 529.34 MB/s 10.34% 0 0 0 - Ethernet12 U 458,052,204,029 636.84 MB/s 12.44% 0 17,614 0 388,341,776,615 527.37 MB/s 10.30% 0 0 0 - Ethernet16 U 16,679,692,972 13.83 MB/s 0.27% 0 17,605 0 18,206,586,265 17.51 MB/s 0.34% 0 0 0 - ``` - -The "errors" subcommand is used to display the interface errors. - -- Example: - ``` - admin@str-s6000-acs-11:~$ show interface counters errors - IFACE STATE RX_ERR RX_DRP RX_OVR TX_ERR TX_DRP TX_OVR - ----------- ------- -------- -------- -------- -------- -------- -------- - Ethernet0 U 0 4 0 0 0 0 - Ethernet4 U 0 0 0 0 0 0 - Ethernet8 U 0 1 0 0 0 0 - Ethernet12 U 0 0 0 0 0 0 - ``` - -The "rates" subcommand is used to disply only the interface rates. - -- Example: - ``` - admin@str-s6000-acs-11:/usr/bin$ show int counters rates - IFACE STATE RX_OK RX_BPS RX_PPS RX_UTIL TX_OK TX_BPS TX_PPS TX_UTIL - ----------- ------- ------- -------- -------- --------- ------- -------- -------- --------- - Ethernet0 U 467510 N/A N/A N/A 466488 N/A N/A N/A - Ethernet4 U 469679 N/A N/A N/A 469245 N/A N/A N/A - Ethernet8 U 466660 N/A N/A N/A 465982 N/A N/A N/A - Ethernet12 U 466579 N/A N/A N/A 466318 N/A N/A N/A - ``` - - -The "rif" subcommand is used to display l3 interface counters. Layer 3 interfaces include router interfaces, portchannels and vlan interfaces. - -- Example: - -``` - admin@sonic:~$ show interfaces counters rif - IFACE RX_OK RX_BPS RX_PPS RX_ERR TX_OK TX_BPS TX_PPS TX_ERR ---------------- ------- ---------- -------- -------- ------- -------- -------- -------- -PortChannel0001 62,668 107.81 B/s 1.34/s 3 6 0.02 B/s 0.00/s 0 -PortChannel0002 62,645 107.77 B/s 1.34/s 3 2 0.01 B/s 0.00/s 0 -PortChannel0003 62,481 107.56 B/s 1.34/s 3 3 0.01 B/s 0.00/s 0 -PortChannel0004 62,732 107.88 B/s 1.34/s 2 3 0.01 B/s 0.00/s 0 - Vlan1000 0 0.00 B/s 0.00/s 0 0 0.00 B/s 0.00/s 0 -``` - - -Optionally, you can specify a layer 3 interface name to display the counters in single interface mode. - -- Example: - -``` - admin@sonic:~$ show interfaces counters rif PortChannel0001 - PortChannel0001 - --------------- - - RX: - 3269 packets - 778494 bytesq - 3 error packets - 292 error bytes - TX: - 0 packets - 0 bytes - 0 error packets - 0 error bytes -``` - - -Optionally, you can specify a period (in seconds) with which to gather counters over. Note that this function will take `` seconds to execute. - -- Example: - -``` - admin@sonic:~$ show interfaces counters -p 5 - IFACE STATE RX_OK RX_BPS RX_UTIL RX_ERR RX_DRP RX_OVR TX_OK TX_BPS TX_UTIL TX_ERR TX_DRP TX_OVR - ----------- ------- ------- ----------- --------- -------- -------- -------- ------- ----------- --------- -------- -------- -------- - Ethernet0 U 515 59.14 KB/s 0.00% 0 0 0 1,305 127.60 KB/s 0.00% 0 0 0 - Ethernet4 U 305 26.54 KB/s 0.00% 0 0 0 279 39.12 KB/s 0.00% 0 0 0 - Ethernet8 U 437 42.96 KB/s 0.00% 0 0 0 182 18.37 KB/s 0.00% 0 0 0 - Ethernet12 U 284 40.79 KB/s 0.00% 0 0 0 160 13.03 KB/s 0.00% 0 0 0 - Ethernet16 U 377 32.64 KB/s 0.00% 0 0 0 214 18.01 KB/s 0.00% 0 0 0 - Ethernet20 U 284 36.81 KB/s 0.00% 0 0 0 138 8758.25 B/s 0.00% 0 0 0 - Ethernet24 U 173 16.09 KB/s 0.00% 0 0 0 169 11.39 KB/s 0.00% 0 0 0 -``` - -- NOTE: Interface counters can be cleared by the user with the following command: - - ``` - admin@sonic:~$ sonic-clear counters - ``` - -- NOTE: Layer 3 interface counters can be cleared by the user with the following command: - - ``` - admin@sonic:~$ sonic-clear rifcounters - ``` - -**show interfaces description** - -This command displays the key fields of the interfaces such as Operational Status, Administrative Status, Alias and Description. - -- Usage: - ``` - show interfaces description [] - ``` - -- Example: - ``` - admin@sonic:~$ show interfaces description - Interface Oper Admin Alias Description - ----------- ------ ------- --------------- -------------------- - Ethernet0 down up hundredGigE1/1 T0-1:hundredGigE1/30 - Ethernet4 down up hundredGigE1/2 T0-2:hundredGigE1/30 - Ethernet8 down down hundredGigE1/3 hundredGigE1/3 - Ethernet12 down down hundredGigE1/4 hundredGigE1/4 - ``` - -- Example (to only display the description for interface Ethernet4): - - ``` - admin@sonic:~$ show interfaces description Ethernet4 - Interface Oper Admin Alias Description - ----------- ------ ------- -------------- -------------------- - Ethernet4 down up hundredGigE1/2 T0-2:hundredGigE1/30 - ``` - -**show interfaces mpls** - -This command is used to display the configured MPLS state for the list of configured interfaces. - -- Usage: - ``` - show interfaces mpls [] - ``` - -- Example: - ``` - admin@sonic:~$ show interfaces mpls - Interface MPLS State - ----------- ------------ - Ethernet0 disable - Ethernet4 enable - Ethernet8 enable - Ethernet12 disable - Ethernet16 disable - Ethernet20 disable - ``` - -- Example (to only display the MPLS state for interface Ethernet4): - ``` - admin@sonic:~$ show interfaces mpls Ethernet4 - Interface MPLS State - ----------- ------------ - Ethernet4 enable - ``` - -**show interfaces tpid** - -This command displays the key fields of the interfaces such as Operational Status, Administrative Status, Alias and TPID. - -- Usage: - ``` - show interfaces tpid [] - ``` - -- Example: - ``` - admin@sonic:~$ show interfaces tpid - Interface Alias Oper Admin TPID - --------------- --------------- ------ ------- ------ - Ethernet0 fortyGigE1/1/1 up up 0x8100 - Ethernet1 fortyGigE1/1/2 up up 0x8100 - Ethernet2 fortyGigE1/1/3 down down 0x8100 - Ethernet3 fortyGigE1/1/4 down down 0x8100 - Ethernet4 fortyGigE1/1/5 up up 0x8100 - Ethernet5 fortyGigE1/1/6 up up 0x8100 - Ethernet6 fortyGigE1/1/7 up up 0x9200 - Ethernet7 fortyGigE1/1/8 up up 0x88A8 - Ethernet8 fortyGigE1/1/9 up up 0x8100 - ... - Ethernet63 fortyGigE1/4/16 down down 0x8100 - PortChannel0001 N/A up up 0x8100 - PortChannel0002 N/A up up 0x8100 - PortChannel0003 N/A up up 0x8100 - PortChannel0004 N/A up up 0x8100 - admin@sonic:~$ - ``` - -- Example (to only display the TPID for interface Ethernet6): - - ``` - admin@sonic:~$ show interfaces tpid Ethernet6 - Interface Alias Oper Admin TPID - ----------- -------------- ------ ------- ------ - Ethernet6 fortyGigE1/1/7 up up 0x9200 - admin@sonic:~$ - ``` - -**show interfaces naming_mode** - -Refer sub-section [Interface-Naming-Mode](#Interface-Naming-Mode) - - -**show interfaces neighbor** - -This command is used to display the list of expected neighbors for all interfaces (or for a particular interface) that is configured. - -- Usage: - ``` - show interfaces neighbor expected [] - ``` - -- Example: - ``` - admin@sonic:~$ show interfaces neighbor expected - LocalPort Neighbor NeighborPort NeighborLoopback NeighborMgmt NeighborType - ----------- ---------- -------------- ------------------ -------------- -------------- - Ethernet112 ARISTA01T1 Ethernet1 None 10.16.205.100 ToRRouter - Ethernet116 ARISTA02T1 Ethernet1 None 10.16.205.101 SpineRouter - Ethernet120 ARISTA03T1 Ethernet1 None 10.16.205.102 LeafRouter - Ethernet124 ARISTA04T1 Ethernet1 None 10.16.205.103 LeafRouter - ``` - -**show interfaces portchannel** - -This command displays information regarding port-channel interfaces - -- Usage: - ``` - show interfaces portchannel - ``` - -- Example: - ``` - admin@sonic:~$ show interfaces portchannel - Flags: A - active, I - inactive, Up - up, Dw - Down, N/A - not available, S - selected, D - deselected - No. Team Dev Protocol Ports - ----- ------------- ----------- --------------------------- - 24 PortChannel24 LACP(A)(Up) Ethernet28(S) Ethernet24(S) - 48 PortChannel48 LACP(A)(Up) Ethernet52(S) Ethernet48(S) - 40 PortChannel40 LACP(A)(Up) Ethernet44(S) Ethernet40(S) - 0 PortChannel0 LACP(A)(Up) Ethernet0(S) Ethernet4(S) - 8 PortChannel8 LACP(A)(Up) Ethernet8(S) Ethernet12(S) - ``` - -**show interface status** - -This command displays some more fields such as Lanes, Speed, MTU, Type, Asymmetric PFC status and also the operational and administrative status of the interfaces - -- Usage: - ``` - show interfaces status [] - ``` - -- Example (show interface status of all interfaces): - ``` - admin@sonic:~$ show interfaces status - Interface Lanes Speed MTU Alias Oper Admin Type Asym PFC - ----------- --------------- ------- ----- --------------- ------ ------- ------ ---------- - Ethernet0 49,50,51,52 100G 9100 hundredGigE1/1 down up N/A off - Ethernet4 53,54,55,56 100G 9100 hundredGigE1/2 down up N/A off - Ethernet8 57,58,59,60 100G 9100 hundredGigE1/3 down down N/A off - - ``` - -- Example (to only display the status for interface Ethernet0): - ``` - admin@sonic:~$ show interface status Ethernet0 - Interface Lanes Speed MTU Alias Oper Admin - ----------- -------- ------- ----- -------------- ------ ------- - Ethernet0 101,102 40G 9100 fortyGigE1/1/1 up up - ``` - -- Example (to only display the status for range of interfaces): - ``` - admin@sonic:~$ show interfaces status Ethernet8,Ethernet168-180 - Interface Lanes Speed MTU Alias Oper Admin Type Asym PFC - ----------- ----------------- ------- ----- --------------- ------ ------- ------ ---------- - Ethernet8 49,50,51,52 100G 9100 hundredGigE3 down down N/A N/A - Ethernet168 9,10,11,12 100G 9100 hundredGigE43 down down N/A N/A - Ethernet172 13,14,15,16 100G 9100 hundredGigE44 down down N/A N/A - Ethernet176 109,110,111,112 100G 9100 hundredGigE45 down down N/A N/A - Ethernet180 105,106,107,108 100G 9100 hundredGigE46 down down N/A N/A - ``` - -**show interfaces transceiver** - -This command is already explained [here](#Transceivers) - -### Interface Config Commands -This sub-section explains the following list of configuration on the interfaces. -1) ip - To add or remove IP address for the interface -2) pfc - to set the PFC configuration for the interface -3) shutdown - to administratively shut down the interface -4) speed - to set the interface speed -5) startup - to bring up the administratively shutdown interface -6) breakout - to set interface breakout mode -7) autoneg - to set interface auto negotiation mode -8) advertised-speeds - to set interface advertised speeds -9) advertised-types - to set interface advertised types -10) type - to set interface type -11) mpls - To add or remove MPLS operation for the interface - -From 201904 release onwards, the “config interface” command syntax is changed and the format is as follows: - -- config interface interface_subcommand -i.e Interface name comes after the subcommand -- Ex: config interface startup Ethernet63 - -The syntax for all such interface_subcommands are given below under each command - -NOTE: In older versions of SONiC until 201811 release, the command syntax was `config interface interface_subcommand` - - -**config interface ip add [default_gw] (Versions >= 201904)** - -**config interface ip add (Versions <= 201811)** - -This command is used for adding the IP address for an interface. -IP address for either physical interface or for portchannel or for VLAN interface or for Loopback interface can be configured using this command. -While configuring the IP address for the management interface "eth0", users can provide the default gateway IP address as an optional parameter from release 201911. - - -- Usage: - - *Versions >= 201904* - ``` - config interface ip add - ``` - *Versions <= 201811* - ``` - config interface ip add - ``` - -- Example: - - *Versions >= 201904* - ``` - admin@sonic:~$ sudo config interface ip add Ethernet63 10.11.12.13/24 - admin@sonic:~$ sudo config interface ip add eth0 20.11.12.13/24 20.11.12.254 - ``` - *Versions <= 201811* - ``` - admin@sonic:~$ sudo config interface Ethernet63 ip add 10.11.12.13/24 - ``` - -VLAN interface names take the form of `vlan`. E.g., VLAN 100 will be named `vlan100` - -- Example: - - *Versions >= 201904* - ``` - admin@sonic:~$ sudo config interface ip add Vlan100 10.11.12.13/24 - ``` - *Versions <= 201811* - ``` - admin@sonic:~$ sudo config interface vlan100 ip add 10.11.12.13/24 - ``` - - -**config interface ip remove (Versions >= 201904)** - -**config interface ip remove (Versions <= 201811)** - -- Usage: - - *Versions >= 201904* - ``` - config interface ip remove - ``` - *Versions <= 201811* - ``` - config interface ip remove - ``` - -- Example: - - *Versions >= 201904* - ``` - admin@sonic:~$ sudo config interface ip remove Ethernet63 10.11.12.13/24 - admin@sonic:~$ sudo config interface ip remove eth0 20.11.12.13/24 - ``` - *Versions <= 201811* - ``` - admin@sonic:~$ sudo config interface Ethernet63 ip remove 10.11.12.13/24 - ``` - -VLAN interface names take the form of `vlan`. E.g., VLAN 100 will be named `vlan100` - -- Example: - - *Versions >= 201904* - ``` - admin@sonic:~$ sudo config interface ip remove vlan100 10.11.12.13/24 - ``` - *Versions <= 201811* - ``` - admin@sonic:~$ sudo config interface vlan100 ip remove 10.11.12.13/24 - ``` - -**config interface pfc priority (on | off)** - -This command is used to set PFC on a given priority of a given interface to either "on" or "off". Once it is successfully configured, it will show current losses priorities on the given interface. Otherwise, it will show error information - -- Example: - *Versions >= 201904* - ``` - admin@sonic:~$ sudo config interface pfc priority Ethernet0 3 off - - Interface Lossless priorities - ----------- --------------------- - Ethernet0 4 - - admin@sonic:~$ sudo config interface pfc priority Ethernet0 8 off - Usage: pfc config priority [OPTIONS] STATUS INTERFACE PRIORITY - - Error: Invalid value for "priority": invalid choice: 8. (choose from 0, 1, 2, 3, 4, 5, 6, 7) - - admin@sonic:~$ sudo config interface pfc priority Ethernet101 3 off - Cannot find interface Ethernet101 - - admin@sonic:~$ sudo config interface pfc priority Ethernet0 3 on - - Interface Lossless priorities - ----------- --------------------- - Ethernet0 3,4 - ``` - -**config interface pfc asymmetric (Versions >= 201904)** - -**config interface pfc asymmetric (Versions <= 201811)** - -This command is used for setting the asymmetric PFC for an interface to either "on" or "off". Once if it is configured, use "show interfaces status" to check the same. - -- Usage: - - *Versions >= 201904* - ``` - config interface pfc asymmetric on/off (for 201904+ version) - ``` - *Versions <= 201811* - ``` - config interface pfc asymmetric on/off (for 201811- version) - ``` - -- Example: - - *Versions >= 201904* - ``` - admin@sonic:~$ sudo config interface pfc asymmetric Ethernet60 on - ``` - *Versions <= 201811* - ``` - admin@sonic:~$ sudo config interface Ethernet60 pfc asymmetric on - ``` - -**config interface shutdown (Versions >= 201904)** - -**config interface shutdown (Versions <= 201811)** - -This command is used to administratively shut down either the Physical interface or port channel interface. Once if it is configured, use "show interfaces status" to check the same. - -- Usage: - - *Versions >= 201904* - ``` - config interface shutdown (for 201904+ version) - ``` - *Versions <= 201811* - ``` - config interface shutdown (for 201811- version) - ``` - -- Example: - - *Versions >= 201904* - ``` - admin@sonic:~$ sudo config interface shutdown Ethernet63 - ``` - *Versions <= 201811* - ``` - admin@sonic:~$ sudo config interface Ethernet63 shutdown - ``` - - shutdown multiple interfaces - ``` - admin@sonic:~$ sudo config interface shutdown Ethernet8,Ethernet16-20,Ethernet32 - ``` - -**config interface startup (Versions >= 201904)** - -**config interface startup (Versions <= 201811)** - -This command is used for administratively bringing up the Physical interface or port channel interface.Once if it is configured, use "show interfaces status" to check the same. - -- Usage: - - *Versions >= 201904* - ``` - config interface startup (for 201904+ version) - ``` - *Versions <= 201811* - ``` - config interface startup (for 201811- version) - ``` - -- Example: - - *Versions >= 201904* - ``` - admin@sonic:~$ sudo config interface startup Ethernet63 - ``` - *Versions <= 201811* - ``` - admin@sonic:~$ sudo config interface Ethernet63 startup - ``` - - startup multiple interfaces - ``` - admin@sonic:~$ sudo config interface startup Ethernet8,Ethernet16-20,Ethernet32 - ``` - -**config interface speed (Versions >= 202006)** - -Dynamic breakout feature is supported in SONiC from 202006 version. -User can configure any speed specified under "breakout_modes" keys for the parent interface in the platform-specific port configuration file (i.e. platform.json). - -For example for a breakout mode of 2x50G[25G,10G] the default speed is 50G but the interface also supports 25G and 10G. - -Refer [DPB HLD DOC](https://github.com/Azure/SONiC/blob/master/doc/dynamic-port-breakout/sonic-dynamic-port-breakout-HLD.md#cli-design) to know more about this command. - -**config interface speed (Versions >= 201904)** - -**config interface speed (Versions <= 201811)** - -This command is used to configure the speed for the Physical interface. Use the value 40000 for setting it to 40G and 100000 for 100G. Users need to know the device to configure it properly. - -- Usage: - - *Versions >= 201904* - ``` - config interface speed - ``` - *Versions <= 201811* - ``` - config interface speed - ``` - -- Example (Versions >= 201904): - ``` - admin@sonic:~$ sudo config interface speed Ethernet63 40000 - ``` - -- Example (Versions <= 201811): - ``` - admin@sonic:~$ sudo config interface Ethernet63 speed 40000 - - ``` - -**config interface transceiver lpmode** - -This command is used to enable or disable low-power mode for an SFP transceiver - -- Usage: - - ``` - config interface transceiver lpmode (enable | disable) - ``` - -- Examples: - - ``` - user@sonic~$ sudo config interface transceiver lpmode Ethernet0 enable - Enabling low-power mode for port Ethernet0... OK - - user@sonic~$ sudo config interface transceiver lpmode Ethernet0 disable - Disabling low-power mode for port Ethernet0... OK - ``` - -**config interface transceiver reset** - -This command is used to reset an SFP transceiver - -- Usage: - - ``` - config interface transceiver reset - ``` - -- Examples: - - ``` - user@sonic~$ sudo config interface transceiver reset Ethernet0 - Resetting port Ethernet0... OK - ``` - -**config interface mtu (Versions >= 201904)** - -This command is used to configure the mtu for the Physical interface. Use the value 1500 for setting max transfer unit size to 1500 bytes. - -- Usage: - - *Versions >= 201904* - ``` - config interface mtu - ``` - -- Example (Versions >= 201904): - ``` - admin@sonic:~$ sudo config interface mtu Ethernet64 1500 - ``` - -**config interface tpid (Versions >= 202106)** - -This command is used to configure the TPID for the Physical/PortChannel interface. default is 0x8100. Other allowed values if supported by HW SKU (0x9100, 0x9200, 0x88A8). - -- Usage: - - *Versions >= 202106* - ``` - config interface tpid - ``` - -- Example (Versions >= 202106): - ``` - admin@sonic:~$ sudo config interface tpid Ethernet64 0x9200 - ``` - -**config interface breakout (Versions >= 202006)** - -This command is used to set active breakout mode available for user-specified interface based on the platform-specific port configuration file(i.e. platform.json) -and the current mode set for the interface. - -Based on the platform.json and the current mode set in interface, this command acts on setting breakout mode for the interface. - -Double tab i.e. to see the available breakout option customized for each interface provided by the user. - -- Usage: - ``` - sudo config interface breakout --help - Usage: config interface breakout [OPTIONS] MODE - - Set interface breakout mode - - Options: - -f, --force-remove-dependencies - Clear all depenedecies internally first. - -l, --load-predefined-config load predefied user configuration (alias, - lanes, speed etc) first. - -y, --yes - -v, --verbose Enable verbose output - -?, -h, --help Show this message and exit. - ``` -- Example : - ``` - admin@sonic:~$ sudo config interface breakout Ethernet0 - - 1x100G[40G] 2x50G 4x25G[10G] - ``` - - This command also provides "--force-remove-dependencies/-f" option to CLI, which will automatically determine and remove the configuration dependencies using Yang models. - - ``` - admin@sonic:~$ sudo config interface breakout Ethernet0 4x25G[10G] -f -l -v -y - ``` - -For details please refer [DPB HLD DOC](https://github.com/Azure/SONiC/blob/master/doc/dynamic-port-breakout/sonic-dynamic-port-breakout-HLD.md#cli-design) to know more about this command. - -Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces) - -**config interface autoneg (Versions >= 202106)** - -This command is used to set port auto negotiation mode. - -- Usage: - ``` - sudo config interface autoneg --help - Usage: config interface autoneg [OPTIONS] - - Set interface auto negotiation mode - - Options: - -v, --verbose Enable verbose output - -h, -?, --help Show this message and exit. - ``` - -- Example: - ``` - admin@sonic:~$ sudo config interface autoneg Ethernet0 enabled - - admin@sonic:~$ sudo config interface autoneg Ethernet0 disabled - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces) - -**config interface advertised-speeds (Versions >= 202106)** - -This command is used to set port advertised speed. - -- Usage: - ``` - sudo config interface advertised-speeds --help - Usage: config interface advertised-speeds [OPTIONS] - - Set interface advertised speeds - - Options: - -v, --verbose Enable verbose output - -h, -?, --help Show this message and exit. - ``` - -- Example: - ``` - admin@sonic:~$ sudo config interface advertised-speeds Ethernet0 all - - admin@sonic:~$ sudo config interface advertised-speeds Ethernet0 50000,100000 - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces) - -**config interface advertised-types (Versions >= 202106)** - -This command is used to set port advertised interface types. - -- Usage: - ``` - sudo config interface advertised-types --help - Usage: config interface advertised-types [OPTIONS] - - Set interface advertised types - - Options: - -v, --verbose Enable verbose output - -h, -?, --help Show this message and exit. - ``` - -- Example: - ``` - admin@sonic:~$ sudo config interface advertised-types Ethernet0 all - - admin@sonic:~$ sudo config interface advertised-types Ethernet0 CR,CR4 - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces) - -**config interface type (Versions >= 202106)** - -This command is used to set port interface type. - -- Usage: - ``` - sudo config interface type --help - Usage: config interface type [OPTIONS] - - Set interface type - - Options: - -v, --verbose Enable verbose output - -h, -?, --help Show this message and exit. - ``` - -- Example: - ``` - admin@sonic:~$ sudo config interface type Ethernet0 CR4 - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces) - -**config interface cable_length (Versions >= 202006)** - -This command is used to configure the length of the cable connected to a port. The cable_length is in unit of meters and must be suffixed with "m". - -For details please refer [dynamic buffer management](#dynamic-buffer-management) - -Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces) - -**config interface lossless_pg (Versions >= 202006)** - -This command is used to configure the priority groups on which lossless traffic runs. - -For details please refer [dynamic buffer management](#dynamic-buffer-management) - -Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces) - -**config interface headroom_override (Versions >= 202006)** - -This command is used to configure a static buffer profile on a port's lossless priorities. There shouldn't be any `lossless_pg` configured on the port when configuring `headroom_override`. The port's headroom won't be updated after `headroom_override` has been configured on the port. - -For details please refer [dynamic buffer management](#dynamic-buffer-management) - -Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces) - -**config interface mpls add (Versions >= 202106)** - -This command is used for adding MPLS operation on the interface. -MPLS operation for either physical, portchannel, or VLAN interface can be configured using this command. - - -- Usage: - ``` - sudo config interface mpls add --help - Usage: config interface mpls add [OPTIONS] - - Add MPLS operation on the interface - - Options: - -?, -h, --help Show this message and exit. - ``` - -- Example: - ``` - admin@sonic:~$ sudo config interface mpls add Ethernet4 - ``` - -**config interface mpls remove (Versions >= 202106)** - -This command is used for removing MPLS operation on the interface. -MPLS operation for either physical, portchannel, or VLAN interface can be configured using this command. - -- Usage: - ``` - sudo config interface mpls remove --help - Usage: config interface mpls remove [OPTIONS] - - Remove MPLS operation from the interface - - Options: - -?, -h, --help Show this message and exit. - ``` - -- Example: - ``` - admin@sonic:~$ sudo config interface mpls remove Ethernet4 - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces) - -## Interface Naming Mode - -### Interface naming mode show commands -This command displays the current interface naming mode. Interface naming mode originally set to 'default'. Interfaces are referenced by default SONiC interface names. -Users can change the naming_mode using "config interface_naming_mode" command. - -**show interfaces naming_mode** - -This command displays the current interface naming mode - -- Usage: - ``` - show interfaces naming_mode - ``` - -- Examples: - ``` - admin@sonic:~$ show interfaces naming_mode - default - ``` - - - "default" naming mode will display all SONiC interface names in 'show' commands and accept SONiC interface names as parameters in 'config commands - - ``` - admin@sonic:~$ show interfaces naming_mode - alias - ``` - - - "alias" naming mode will display all hardware vendor interface aliases in 'show' commands and accept hardware vendor interface aliases as parameters in 'config commands - - -### Interface naming mode config commands - -**config interface_naming_ mode** - -This command is used to change the interface naming mode. -Users can select between default mode (SONiC interface names) or alias mode (Hardware vendor names). -The user must log out and log back in for changes to take effect. Note that the newly-applied interface mode will affect all interface-related show/config commands. - - -*NOTE: Some platforms do not support alias mapping. In such cases, this command is not applicable. Such platforms always use the same SONiC interface names.* - -- Usage: - ``` - config interface_naming_mode (default | alias) - ``` - - - Interface naming mode is originally set to 'default'. Interfaces are referenced by default SONiC interface names: - -- Example: - ``` - admin@sonic:~$ show interfaces naming_mode - default - - admin@sonic:~$ show interface status Ethernet0 - Interface Lanes Speed MTU Alias Oper Admin - ----------- -------- ------- ----- -------------- ------ ------- - Ethernet0 101,102 40G 9100 fortyGigE1/1/1 up up - - admin@sonic:~$ sudo config interface_naming_mode alias - Please logout and log back in for changes take effect. - ``` - - - After user logs out and logs back in again, interfaces will then referenced by hardware vendor aliases: - - ``` - admin@sonic:~$ show interfaces naming_mode - alias - - admin@sonic:~$ sudo config interface fortyGigE1/1/1 shutdown - admin@sonic:~$ show interface status fortyGigE1/1/1 - Interface Lanes Speed MTU Alias Oper Admin - ----------- -------- ------- ----- -------------- ------ ------- - Ethernet0 101,102 40G 9100 fortyGigE1/1/1 down down - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#interface-naming-mode) - -## Interface Vrf binding - -### Interface vrf bind & unbind config commands - -**config interface vrf bind** - -This command is used to bind a interface to a vrf. -By default, all L3 interfaces will be in default vrf. Above vrf bind command will let users bind interface to a vrf. - -- Usage: - ``` - config interface vrf bind - ``` - -**config interface vrf unbind** - -This command is used to ubind a interface from a vrf. -This will move the interface to default vrf. - -- Usage: - ``` - config interface vrf unbind - ``` - - ### Interface vrf binding show commands - - To display interface vrf binding information, user can use show vrf command. Please refer sub-section [Vrf-show-command](#vrf-show-commands). - -Go Back To [Beginning of the document](#) or [Beginning of this section](#interface-vrf-binding) - -## IP / IPv6 - -### IP show commands - -This sub-section explains the various IP protocol specific show commands that are used to display the following. -1) routes -2) bgp details - Explained in the [bgp section](#show-bgp) -3) IP interfaces -4) prefix-list -5) protocol - -#### show ip route - -This command displays either all the route entries from the routing table or a specific route. - -- Usage: - ``` - show ip route [] [] - ``` - -- Example: - ``` - admin@sonic:~$ show ip route - Codes: K - kernel route, C - connected, S - static, R - RIP, - O - OSPF, I - IS-IS, B - BGP, P - PIM, A - Babel, - > - selected route, * - FIB route - S>* 0.0.0.0/0 [200/0] via 10.11.162.254, eth0 - C>* 1.1.0.0/16 is directly connected, Vlan100 - C>* 10.1.1.0/31 is directly connected, Ethernet112 - C>* 10.1.1.2/31 is directly connected, Ethernet116 - C>* 10.11.162.0/24 is directly connected, eth0 - C>* 127.0.0.0/8 is directly connected, lo - C>* 240.127.1.0/24 is directly connected, docker0 - ``` - - - Optionally, you can specify an IP address in order to display only routes to that particular IP address - -- Example: - ``` - admin@sonic:~$ show ip route 10.1.1.0 - Routing entry for 10.1.1.0/31 - Known via "connected", distance 0, metric 0, best - * directly connected, Ethernet112 - ``` - - - Vrf-name can also be specified to get IPv4 routes programmed in the vrf. - - - Example: - ``` - admin@sonic:~$ show ip route vrf Vrf-red - Codes: K - kernel route, C - connected, S - static, R - RIP, - O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, - T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, - F - PBR, f - OpenFabric, - > - selected route, * - FIB route - VRF Vrf-red: - C>* 11.1.1.1/32 is directly connected, Loopback11, 21:50:47 - C>* 100.1.1.0/24 is directly connected, Vlan100, 03w1d06h - - admin@sonic:~$ show ip route vrf Vrf-red 11.1.1.1/32 - Routing entry for 11.1.1.1/32 - Known via "connected", distance 0, metric 0, vrf Vrf-red, best - Last update 21:57:53 ago - * directly connected, Loopback11 - ``` - -#### show ip interfaces - -This command displays the details about all the Layer3 IP interfaces in the device for which IP address has been assigned. -The type of interfaces include the following. -1) Front panel physical ports. -2) PortChannel. -3) VLAN interface. -4) Loopback interfaces -5) docker interface and -6) management interface - -- Usage: - ``` - show ip interfaces - ``` - -- Example: - ``` - admin@sonic:~$ show ip interfaces - Interface Master IPv4 address/mask Admin/Oper BGP Neighbor Neighbor IP Flags - ------------- ------------ ------------------ -------------- ------------- ------------- ------- - Loopback0 1.0.0.1/32 up/up N/A N/A - Loopback11 Vrf-red 11.1.1.1/32 up/up N/A N/A - Loopback100 Vrf-blue 100.0.0.1/32 up/up N/A N/A - PortChannel01 10.0.0.56/31 up/down DEVICE1 10.0.0.57 - PortChannel02 10.0.0.58/31 up/down DEVICE2 10.0.0.59 - PortChannel03 10.0.0.60/31 up/down DEVICE3 10.0.0.61 - PortChannel04 10.0.0.62/31 up/down DEVICE4 10.0.0.63 - Vlan100 Vrf-red 1001.1.1/24 up/up N/A N/A - Vlan1000 192.168.0.1/27 up/up N/A N/A - docker0 240.127.1.1/24 up/down N/A N/A - eth0 10.3.147.252/23 up/up N/A N/A - lo 127.0.0.1/8 up/up N/A N/A - ``` - -#### show ip protocol - -This command displays the route-map that is configured for the routing protocol. -Refer the routing stack [Quagga Command Reference](https://www.quagga.net/docs/quagga.pdf) or [FRR Command Reference](https://buildmedia.readthedocs.org/media/pdf/frrouting/latest/frrouting.pdf) to know more about this command. - -- Usage: - ``` - show ip protocol - ``` - -- Example: - ``` - admin@sonic:~$ show ip protocol - Protocol : route-map - ------------------------ - system : none - kernel : none - connected : none - static : none - rip : none - ripng : none - ospf : none - ospf6 : none - isis : none - bgp : RM_SET_SRC - pim : none - hsls : none - olsr : none - babel : none - any : none - ``` - -### IPv6 show commands - -This sub-section explains the various IPv6 protocol specific show commands that are used to display the following. -1) routes -2) IPv6 bgp details - Explained in the [bgp section](#show-bgp) -3) IP interfaces -4) protocol - -**show ipv6 route** - -This command displays either all the IPv6 route entries from the routing table or a specific IPv6 route. - -- Usage: - ``` - show ipv6 route [] [] - ``` - -- Example: - ``` - admin@sonic:~$ show ipv6 route - Codes: K - kernel route, C - connected, S - static, R - RIPng, - O - OSPFv6, I - IS-IS, B - BGP, A - Babel, - > - selected route, * - FIB route - - C>* ::1/128 is directly connected, lo - C>* 2018:2001::/126 is directly connected, Ethernet112 - C>* 2018:2002::/126 is directly connected, Ethernet116 - C>* fc00:1::32/128 is directly connected, lo - C>* fc00:1::102/128 is directly connected, lo - C>* fc00:2::102/128 is directly connected, eth0 - C * fe80::/64 is directly connected, Vlan100 - C * fe80::/64 is directly connected, Ethernet112 - C * fe80::/64 is directly connected, Ethernet116 - C * fe80::/64 is directly connected, Bridge - C * fe80::/64 is directly connected, PortChannel0011 - C>* fe80::/64 is directly connected, eth0 - ``` - - Optionally, you can specify an IPv6 address in order to display only routes to that particular IPv6 address - - -- Example: - ``` - admin@sonic:~$ show ipv6 route fc00:1::32 - Routing entry for fc00:1::32/128 - Known via "connected", distance 0, metric 0, best - * directly connected, lo - ``` - - Vrf-name can also be specified to get IPv6 routes programmed in the vrf. - - - Example: - ``` - admin@sonic:~$ show ipv6 route vrf Vrf-red - Codes: K - kernel route, C - connected, S - static, R - RIP, - O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, - T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, - F - PBR, f - OpenFabric, - > - selected route, * - FIB route - VRF Vrf-red: - C>* 1100::1/128 is directly connected, Loopback11, 21:50:47 - C>* 100::/112 is directly connected, Vlan100, 03w1d06h - C>* fe80::/64 is directly connected, Loopback11, 21:50:47 - C>* fe80::/64 is directly connected, Vlan100, 03w1d06h - - admin@sonic:~$ show ipv6 route vrf Vrf-red 1100::1/128 - Routing entry for 1100::1/128 - Known via "connected", distance 0, metric 0, vrf Vrf-red, best - Last update 21:57:53 ago - * directly connected, Loopback11 - ``` - -**show ipv6 interfaces** - -This command displays the details about all the Layer3 IPv6 interfaces in the device for which IPv6 address has been assigned. -The type of interfaces include the following. -1) Front panel physical ports. -2) PortChannel. -3) VLAN interface. -4) Loopback interfaces -5) management interface - -- Usage: - ``` - show ipv6 interfaces - ``` - -- Example: - ``` - admin@sonic:~$ show ipv6 interfaces - Interface Master IPv6 address/mask Admin/Oper BGP Neighbor Neighbor IP - ----------- -------- ---------------------------------------- ------------ -------------- ------------- - Bridge fe80::7c45:1dff:fe08:cdd%Bridge/64 up/up N/A N/A - Loopback11 Vrf-red 1100::1/128 up/up - PortChannel01 fc00::71/126 up/down DEVICE1 fc00::72 - PortChannel02 fc00::75/126 up/down DEVICE2 fc00::76 - PortChannel03 fc00::79/126 up/down DEVICE3 fc00::7a - PortChannel04 fc00::7d/126 up/down DEVICE4 fc00::7e - Vlan100 Vrf-red 100::1/112 up/up N/A N/A - fe80::eef4:bbff:fefe:880a%Vlan100/64 - eth0 fe80::eef4:bbff:fefe:880a%eth0/64 up/up N/A N/A - lo fc00:1::32/128 up/up N/A N/A - ``` - -**show ipv6 protocol** - -This command displays the route-map that is configured for the IPv6 routing protocol. -Refer the routing stack [Quagga Command Reference](https://www.quagga.net/docs/quagga.pdf) or [FRR Command Reference](https://buildmedia.readthedocs.org/media/pdf/frrouting/latest/frrouting.pdf) to know more about this command. - - -- Usage: - ``` - show ipv6 protocol - ``` - -- Example: - ``` - admin@sonic:~$ show ipv6 protocol - Protocol : route-map - ------------------------ - system : none - kernel : none - connected : none - static : none - rip : none - ripng : none - ospf : none - ospf6 : none - isis : none - bgp : RM_SET_SRC6 - pim : none - hsls : none - olsr : none - babel : none - any : none - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#ip--ipv6) - -## IPv6 Link Local - -### IPv6 Link Local config commands - -This section explains all the commands that are supported in SONiC to configure IPv6 Link-local. - -**config interface ipv6 enable use-link-local-only ** - -This command enables user to enable an interface to forward L3 traffic with out configuring an address. This command creates the routing interface based on the auto generated IPv6 link-local address. This command can be used even if an address is configured on the interface. - -- Usage: - ``` - config interface ipv6 enable use-link-local-only - ``` - -- Example: - ``` - admin@sonic:~$ sudo config interface ipv6 enable use-link-local-only Vlan206 - admin@sonic:~$ sudo config interface ipv6 enable use-link-local-only PortChannel007 - admin@sonic:~$ sudo config interface ipv6 enable use-link-local-only Ethernet52 - ``` - -**config interface ipv6 disable use-link-local-only ** - -This command enables user to disable use-link-local-only configuration on an interface. - -- Usage: - ``` - config interface ipv6 disable use-link-local-only - ``` - -- Example: - ``` - admin@sonic:~$ sudo config interface ipv6 disable use-link-local-only Vlan206 - admin@sonic:~$ sudo config interface ipv6 disable use-link-local-only PortChannel007 - admin@sonic:~$ sudo config interface ipv6 disable use-link-local-only Ethernet52 - ``` - -**config ipv6 enable link-local** - -This command enables user to enable use-link-local-only command on all the interfaces globally. - -- Usage: - ``` - sudo config ipv6 enable link-local - ``` - -- Example: - ``` - admin@sonic:~$ sudo config ipv6 enable link-local - ``` - -**config ipv6 disable link-local** - -This command enables user to disable use-link-local-only command on all the interfaces globally. - -- Usage: - ``` - sudo config ipv6 disable link-local - ``` - -- Example: - ``` - admin@sonic:~$ sudo config ipv6 disable link-local - ``` - -### IPv6 Link Local show commands - -**show ipv6 link-local-mode** - -This command displays the link local mode of all the interfaces. - -- Usage: - ``` - show ipv6 link-local-mode - ``` - -- Example: - ``` - root@sonic:/home/admin# show ipv6 link-local-mode - +------------------+----------+ - | Interface Name | Mode | - +==================+==========+ - | Ethernet16 | Disabled | - +------------------+----------+ - | Ethernet18 | Enabled | - +------------------+----------+ - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#ipv6-link-local) - -## Kubernetes - -### Kubernetes show commands - -**show kubernetes server config** - -This command displays the kubernetes server configuration, if any, else would report as not configured. - -- Usage: - ``` - show kubernetes server config - ``` - -- Example: - ``` - admin@sonic:~$ show kubernetes server config - ip port insecure disable - ----------- ------ ---------- --------- - 10.3.157.24 6443 True False - ``` - -**show kubernetes server status** - -This command displays the kubernetes server status. - -- Usage: - ``` - show kubernetes server status - ``` - -- Example: - ``` - admin@sonic:~$ show kubernetes server status - ip port connected update-time - ----------- ------ ----------- ------------------- - 10.3.157.24 6443 true 2020-11-15 18:25:05 - ``` -Go Back To [Beginning of the document](#) or [Beginning of this section](#Kubernetes) - -## Linux Kernel Dump - -This section demonstrates the show commands and configuration commands of Linux kernel dump mechanism in SONiC. - -### Linux Kernel Dump show commands - -**show kdump config** - -This command shows the configuration of Linux kernel dump. - -- Usage: - ``` - show kdump config - ``` - -- Example: - ``` - admin@sonic:$ show kdump config - Kdump administrative mode: Disabled - Kdump operational mode: Unready - Kdump memory researvation: 0M-2G:256M,2G-4G:320M,4G-8G:384M,8G-:448M - Maximum number of Kdump files: 3 - ``` - -**show kdump files** - -This command shows the Linux kernel core dump files and dmesg files which are -generated by kernel dump tool. - -- Usage: - ``` - show kdump files - ``` - -- Example: - ``` - admin@sonic:~$ show kdump files - Kernel core dump files Kernel dmesg files - ------------------------------------------ ------------------------------------------ - /var/crash/202106242344/kdump.202106242344 /var/crash/202106242344/dmesg.202106242344 - /var/crash/202106242337/kdump.202106242337 /var/crash/202106242337/dmesg.202106242337 - ``` - -**show kdump logging ** - -By default, this command will show the last 10 lines of latest dmesg file. -This command can also accept a specific file name and number of lines as arguments. - -- Usage: - ``` - show kdump logging - ``` - -- Example: - ``` - admin@sonic:~$ show kdump logging - [ 157.642053] RSP: 002b:00007fff1beee708 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 - [ 157.732635] RAX: ffffffffffffffda RBX: 0000000000000002 RCX: 00007fc3887d4504 - [ 157.818015] RDX: 0000000000000002 RSI: 000055d388eceb40 RDI: 0000000000000001 - [ 157.903401] RBP: 000055d388eceb40 R08: 000000000000000a R09: 00007fc3888255f0 - [ 157.988784] R10: 000000000000000a R11: 0000000000000246 R12: 00007fc3888a6760 - [ 158.074166] R13: 0000000000000002 R14: 00007fc3888a1760 R15: 0000000000000002 - [ 158.159553] Modules linked in: nft_chain_route_ipv6(E) nft_chain_route_ipv4(E) xt_TCPMSS(E) dummy(E) team_mode_loadbalance(E) team(E) sx_bfd(OE) sx_netdev(OE) psample(E) sx_core(OE) 8021q(E) garp(E) mrp(E) mst_pciconf(OE) mst_pci(OE) xt_hl(E) xt_tcpudp(E) ip6_tables(E) nft_compat(E) nft_chain_nat_ipv4(E) nf_nat_ipv4(E) nft_counter(E) xt_conntrack(E) nf_nat(E) jc42(E) nf_conntrack_netlink(E) nf_conntrack(E) nf_defrag_ipv6(E) nf_defrag_ipv4(E) libcrc32c(E) xfrm_user(E) xfrm_algo(E) mlxsw_minimal(E) mlxsw_i2c(E) i2c_mux_reg(E) i2c_mux(E) i2c_mlxcpld(E) leds_mlxreg(E) mlxreg_io(E) mlxreg_hotplug(E) mei_wdt(E) evdev(E) intel_rapl(E) x86_pkg_temp_thermal(E) intel_powerclamp(E) kvm_intel(E) mlx_platform(E) kvm(E) irqbypass(E) crct10dif_pclmul(E) crc32_pclmul(E) ghash_clmulni_intel(E) intel_cstate(E) intel_uncore(E) - [ 159.016731] intel_rapl_perf(E) pcspkr(E) sg(E) iTCO_wdt(E) iTCO_vendor_support(E) mei_me(E) mei(E) bonding(E) pcc_cpufreq(E) video(E) button(E) ebt_vlan(E) ebtable_broute(E) bridge(E) stp(E) llc(E) ebtable_nat(E) ebtable_filter(E) ebtables(E) nf_tables(E) nfnetlink(E) xdpe12284(E) at24(E) ledtrig_timer(E) tmp102(E) lm75(E) drm(E) coretemp(E) max1363(E) industrialio_triggered_buffer(E) kfifo_buf(E) industrialio(E) tps53679(E) fuse(E) pmbus(E) pmbus_core(E) i2c_dev(E) configfs(E) ip_tables(E) x_tables(E) autofs4(E) loop(E) ext4(E) crc16(E) mbcache(E) jbd2(E) crc32c_generic(E) fscrypto(E) ecb(E) crypto_simd(E) cryptd(E) glue_helper(E) aes_x86_64(E) nvme(E) nvme_core(E) nls_utf8(E) nls_cp437(E) nls_ascii(E) vfat(E) fat(E) overlay(E) squashfs(E) zstd_decompress(E) xxhash(E) sd_mod(E) gpio_ich(E) ahci(E) - [ 159.864532] libahci(E) mlxsw_core(E) devlink(E) ehci_pci(E) ehci_hcd(E) crc32c_intel(E) libata(E) i2c_i801(E) scsi_mod(E) usbcore(E) usb_common(E) lpc_ich(E) mfd_core(E) e1000e(E) fan(E) thermal(E) - [ 160.075846] CR2: 0000000000000000 - ``` -You can specify a file name in order to show its -last 10 lines. - -- Example: - ``` - admin@sonic:~$ show kdump logging dmesg.202106242337 - [ 654.120195] RSP: 002b:00007ffe697690f8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 - [ 654.210778] RAX: ffffffffffffffda RBX: 0000000000000002 RCX: 00007fcfca27b504 - [ 654.296157] RDX: 0000000000000002 RSI: 000055a6e4d1b3f0 RDI: 0000000000000001 - [ 654.381543] RBP: 000055a6e4d1b3f0 R08: 000000000000000a R09: 00007fcfca2cc5f0 - [ 654.466925] R10: 000000000000000a R11: 0000000000000246 R12: 00007fcfca34d760 - [ 654.552310] R13: 0000000000000002 R14: 00007fcfca348760 R15: 0000000000000002 - [ 654.637694] Modules linked in: binfmt_misc(E) nft_chain_route_ipv6(E) nft_chain_route_ipv4(E) xt_TCPMSS(E) dummy(E) team_mode_loadbalance(E) team(E) sx_bfd(OE) sx_netdev(OE) psample(E) sx_core(OE) 8021q(E) garp(E) mrp(E) mst_pciconf(OE) mst_pci(OE) xt_hl(E) xt_tcpudp(E) ip6_tables(E) nft_chain_nat_ipv4(E) nf_nat_ipv4(E) nft_compat(E) nft_counter(E) xt_conntrack(E) nf_nat(E) jc42(E) nf_conntrack_netlink(E) nf_conntrack(E) nf_defrag_ipv6(E) nf_defrag_ipv4(E) libcrc32c(E) xfrm_user(E) xfrm_algo(E) mlxsw_minimal(E) mlxsw_i2c(E) i2c_mux_reg(E) i2c_mux(E) mlxreg_hotplug(E) mlxreg_io(E) i2c_mlxcpld(E) leds_mlxreg(E) mei_wdt(E) evdev(E) intel_rapl(E) x86_pkg_temp_thermal(E) intel_powerclamp(E) kvm_intel(E) kvm(E) mlx_platform(E) irqbypass(E) crct10dif_pclmul(E) crc32_pclmul(E) ghash_clmulni_intel(E) intel_cstate(E) - [ 655.493833] intel_uncore(E) intel_rapl_perf(E) pcspkr(E) sg(E) iTCO_wdt(E) iTCO_vendor_support(E) mei_me(E) mei(E) bonding(E) video(E) button(E) pcc_cpufreq(E) ebt_vlan(E) ebtable_broute(E) bridge(E) stp(E) llc(E) ebtable_nat(E) ebtable_filter(E) ebtables(E) nf_tables(E) nfnetlink(E) xdpe12284(E) at24(E) ledtrig_timer(E) tmp102(E) drm(E) lm75(E) coretemp(E) max1363(E) industrialio_triggered_buffer(E) kfifo_buf(E) industrialio(E) fuse(E) tps53679(E) pmbus(E) pmbus_core(E) i2c_dev(E) configfs(E) ip_tables(E) x_tables(E) autofs4(E) loop(E) ext4(E) crc16(E) mbcache(E) jbd2(E) crc32c_generic(E) fscrypto(E) ecb(E) crypto_simd(E) cryptd(E) glue_helper(E) aes_x86_64(E) nvme(E) nvme_core(E) nls_utf8(E) nls_cp437(E) nls_ascii(E) vfat(E) fat(E) overlay(E) squashfs(E) zstd_decompress(E) xxhash(E) sd_mod(E) - [ 656.337476] gpio_ich(E) ahci(E) mlxsw_core(E) libahci(E) devlink(E) crc32c_intel(E) libata(E) i2c_i801(E) scsi_mod(E) lpc_ich(E) mfd_core(E) ehci_pci(E) ehci_hcd(E) usbcore(E) e1000e(E) usb_common(E) fan(E) thermal(E) - [ 656.569590] CR2: 0000000000000000 - ``` -You can also specify a file name and number of lines in order to show the -last number of lines. - -- Example: - ``` - admin@sonic:~$ show kdump logging dmesg.202106242337 -l 20 - [ 653.525427] __handle_sysrq.cold.9+0x45/0xf2 - [ 653.576487] write_sysrq_trigger+0x2b/0x30 - [ 653.625472] proc_reg_write+0x39/0x60 - [ 653.669252] vfs_write+0xa5/0x1a0 - [ 653.708881] ksys_write+0x57/0xd0 - [ 653.748501] do_syscall_64+0x53/0x110 - [ 653.792287] entry_SYSCALL_64_after_hwframe+0x44/0xa9 - [ 653.852707] RIP: 0033:0x7fcfca27b504 - [ 653.895452] Code: 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b3 0f 1f 80 00 00 00 00 48 8d 05 f9 61 0d 00 8b 00 85 c0 75 13 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 54 c3 0f 1f 00 41 54 49 89 d4 55 48 89 f5 53 - [ 654.120195] RSP: 002b:00007ffe697690f8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 - [ 654.210778] RAX: ffffffffffffffda RBX: 0000000000000002 RCX: 00007fcfca27b504 - [ 654.296157] RDX: 0000000000000002 RSI: 000055a6e4d1b3f0 RDI: 0000000000000001 - [ 654.381543] RBP: 000055a6e4d1b3f0 R08: 000000000000000a R09: 00007fcfca2cc5f0 - [ 654.466925] R10: 000000000000000a R11: 0000000000000246 R12: 00007fcfca34d760 - [ 654.552310] R13: 0000000000000002 R14: 00007fcfca348760 R15: 0000000000000002 - [ 654.637694] Modules linked in: binfmt_misc(E) nft_chain_route_ipv6(E) nft_chain_route_ipv4(E) xt_TCPMSS(E) dummy(E) team_mode_loadbalance(E) team(E) sx_bfd(OE) sx_netdev(OE) psample(E) sx_core(OE) 8021q(E) garp(E) mrp(E) mst_pciconf(OE) mst_pci(OE) xt_hl(E) xt_tcpudp(E) ip6_tables(E) nft_chain_nat_ipv4(E) nf_nat_ipv4(E) nft_compat(E) nft_counter(E) xt_conntrack(E) nf_nat(E) jc42(E) nf_conntrack_netlink(E) nf_conntrack(E) nf_defrag_ipv6(E) nf_defrag_ipv4(E) libcrc32c(E) xfrm_user(E) xfrm_algo(E) mlxsw_minimal(E) mlxsw_i2c(E) i2c_mux_reg(E) i2c_mux(E) mlxreg_hotplug(E) mlxreg_io(E) i2c_mlxcpld(E) leds_mlxreg(E) mei_wdt(E) evdev(E) intel_rapl(E) x86_pkg_temp_thermal(E) intel_powerclamp(E) kvm_intel(E) kvm(E) mlx_platform(E) irqbypass(E) crct10dif_pclmul(E) crc32_pclmul(E) ghash_clmulni_intel(E) intel_cstate(E) - [ 655.493833] intel_uncore(E) intel_rapl_perf(E) pcspkr(E) sg(E) iTCO_wdt(E) iTCO_vendor_support(E) mei_me(E) mei(E) bonding(E) video(E) button(E) pcc_cpufreq(E) ebt_vlan(E) ebtable_broute(E) bridge(E) stp(E) llc(E) ebtable_nat(E) ebtable_filter(E) ebtables(E) nf_tables(E) nfnetlink(E) xdpe12284(E) at24(E) ledtrig_timer(E) tmp102(E) drm(E) lm75(E) coretemp(E) max1363(E) industrialio_triggered_buffer(E) kfifo_buf(E) industrialio(E) fuse(E) tps53679(E) pmbus(E) pmbus_core(E) i2c_dev(E) configfs(E) ip_tables(E) x_tables(E) autofs4(E) loop(E) ext4(E) crc16(E) mbcache(E) jbd2(E) crc32c_generic(E) fscrypto(E) ecb(E) crypto_simd(E) cryptd(E) glue_helper(E) aes_x86_64(E) nvme(E) nvme_core(E) nls_utf8(E) nls_cp437(E) nls_ascii(E) vfat(E) fat(E) overlay(E) squashfs(E) zstd_decompress(E) xxhash(E) sd_mod(E) - [ 656.337476] gpio_ich(E) ahci(E) mlxsw_core(E) libahci(E) devlink(E) crc32c_intel(E) libata(E) i2c_i801(E) scsi_mod(E) lpc_ich(E) mfd_core(E) ehci_pci(E) ehci_hcd(E) usbcore(E) e1000e(E) usb_common(E) fan(E) thermal(E) - [ 656.569590] CR2: 0000000000000000 - ``` -Go Back To [Beginning of the document](#) or [Beginning of this section](#kdump) - -## LLDP - -### LLDP show commands - -**show lldp table** - -This command displays the brief summary of all LLDP neighbors. - -- Usage: - ``` - show lldp table - ``` - -- Example: - ``` - admin@sonic:~$ show lldp table - Capability codes: (R) Router, (B) Bridge, (O) Other - LocalPort RemoteDevice RemotePortID Capability RemotePortDescr - ----------- ----------------- ------------------- ------------ -------------------- - Ethernet112 T1-1 hundredGigE1/2 BR T0-2:hundredGigE1/29 - Ethernet116 T1-2 hundredGigE1/2 BR T0-2:hundredGigE1/30 - eth0 swtor-b2lab2-1610 GigabitEthernet 0/2 OBR - -------------------------------------------------- - Total entries displayed: 3 - ``` - -**show lldp neighbors** - -This command displays more details about all LLDP neighbors or only the neighbors connected to a specific interface. - -- Usage: - ``` - show lldp neighbors - ``` - -- Example1: To display all neighbors in all interfaces - ``` - admin@sonic:~$ show lldp neighbors - ------------------------------------------------------------------------------- - LLDP neighbors: - ------------------------------------------------------------------------------- - Interface: eth0, via: LLDP, RID: 1, Time: 0 day, 12:21:21 - Chassis: - ChassisID: mac 00:01:e8:81:e3:45 - SysName: swtor-b2lab2-1610 - SysDescr: Dell Force10 Networks Real Time Operating System Software. Dell Force10 Operating System Version: 1.0. Dell Force10 Application Software Version: 8.3.3.10d. Copyright (c) 1999-2012 by Dell Inc. All Rights Reserved.Build Time: Tue Sep 22 11:21:54 PDT 2015 - TTL: 20 - Capability: Repeater, on - Capability: Bridge, on - Capability: Router, on - Port: - PortID: ifname GigabitEthernet 0/2 - VLAN: 162, pvid: yes - ------------------------------------------------------------------------------- - Interface: Ethernet116, via: LLDP, RID: 3, Time: 0 day, 12:20:49 - Chassis: - ChassisID: mac 4c:76:25:e7:f0:c0 - SysName: T1-2 - SysDescr: Debian GNU/Linux 8 (jessie) Linux 4.9.0-8-amd64 #1 SMP Debian 4.9.110-3+deb9u6 (2015-12-19) x86_64 - TTL: 120 - MgmtIP: 10.11.162.40 - Capability: Bridge, on - Capability: Router, on - Capability: Wlan, off - Capability: Station, off - Port: - PortID: local hundredGigE1/2 - PortDescr: T0-2:hundredGigE1/30 - ------------------------------------------------------------------------------- - ``` - -Optionally, you can specify an interface name in order to display only that particular interface - -- Example2: - ``` - admin@sonic:~$ show lldp neighbors Ethernet112 - show lldp neighbors Ethernet112 - ------------------------------------------------------------------------------- - LLDP neighbors: - ------------------------------------------------------------------------------- - Interface: Ethernet112, via: LLDP, RID: 2, Time: 0 day, 19:24:17 - Chassis: - ChassisID: mac 4c:76:25:e5:e6:c0 - SysName: T1-1 - SysDescr: Debian GNU/Linux 8 (jessie) Linux 4.9.0-8-amd64 #1 SMP Debian 4.9.110-3+deb9u6 (2015-12-19) x86_64 - TTL: 120 - MgmtIP: 10.11.162.41 - Capability: Bridge, on - Capability: Router, on - Capability: Wlan, off - Capability: Station, off - Port: - PortID: local hundredGigE1/2 - PortDescr: T0-2:hundredGigE1/29 - ------------------------------------------------------------------------------- - ``` -Go Back To [Beginning of the document](#) or [Beginning of this section](#lldp) - - -## Loading, Reloading And Saving Configuration - -This section explains the commands that are used to load the configuration from either the ConfigDB or from the minigraph. - -### Loading configuration from JSON file - -**config load** - -This command is used to load the configuration from a JSON file like the file which SONiC saves its configuration to, `/etc/sonic/config_db.json` -This command loads the configuration from the input file (if user specifies this optional filename, it will use that input file. Otherwise, it will use the default `/etc/sonic/config_db.json` file as the input file) into CONFIG_DB. -The configuration present in the input file is applied on top of the already running configuration. -This command does not flush the config DB before loading the new configuration (i.e., If the configuration present in the input file is same as the current running configuration, nothing happens) -If the config present in the input file is not present in running configuration, it will be added. -If the config present in the input file differs (when key matches) from that of the running configuration, it will be modified as per the new values for those keys. - -When user specifies the optional argument "-y" or "--yes", this command forces the loading without prompting the user for confirmation. -If the argument is not specified, it prompts the user to confirm whether user really wants to load this configuration file. - -- Usage: - ``` - config load [-y|--yes] [] - ``` - -- Example: - ``` - admin@sonic:~$ sudo config load - Load config from the file /etc/sonic/config_db.json? [y/N]: y - Running command: /usr/local/bin/sonic-cfggen -j /etc/sonic/config_db.json --write-to-db - ``` - -### Loading configuration from minigraph (XML) file - -**config load_minigraph** - -This command is used to load the configuration from /etc/sonic/minigraph.xml. -When users do not want to use configuration from config_db.json, they can copy the minigraph.xml configuration file to the device and load it using this command. -This command restarts various services running in the device and it takes some time to complete the command. - -NOTE: If the user had logged in using SSH, users might get disconnected and some configuration failures might happen which might be hard to recover. Users need to reconnect their SSH sessions after configuring the management IP address. It is recommended to execute this command from console port -NOTE: Management interface IP address and default route (or specific route) may require reconfiguration in case if those parameters are not part of the minigraph.xml. - -When user specifies the optional argument "-y" or "--yes", this command forces the loading without prompting the user for confirmation. -If the argument is not specified, it prompts the user to confirm whether user really wants to load this configuration file. - -When user specifies the optional argument "-n" or "--no-service-restart", this command loads the configuration without restarting dependent services -running on the device. One use case for this option is during boot time when config-setup service loads minigraph configuration and there is no services -running on the device. - -- Usage: - ``` - config load_minigraph [-y|--yes] [-n|--no-service-restart] - ``` - -- Example: - ``` - admin@sonic:~$ sudo config load_minigraph - Reload config from minigraph? [y/N]: y - Running command: /usr/local/bin/sonic-cfggen -j /etc/sonic/config_db.json --write-to-db - ``` - -### Reloading Configuration - -**config reload** - -This command is used to clear current configuration and import new configurationn from the input file or from /etc/sonic/config_db.json. -This command shall stop all services before clearing the configuration and it then restarts those services. - -This command restarts various services running in the device and it takes some time to complete the command. -NOTE: If the user had logged in using SSH, users **might get disconnected** depending upon the new management IP address. Users need to reconnect their SSH sessions. -In general, it is recommended to execute this command from console port after disconnecting all SSH sessions to the device. -When users to do “config reload” the newly loaded config may have management IP address, or it may not have management IP address. -If mgmtIP is there in the newly loaded config file, that mgmtIP might be same as previously configured value or it might be different. -This difference in mgmtIP address values results in following possible behaviours. - -Case1: Previously configured mgmtIP is same as newly loaded mgmtIP. The SSH session may not be affected at all, but it’s possible that there will be a brief interruption in the SSH session. But, assuming the client’s timeout value isn’t on the order of a couple of seconds, the session would most likely just resume again as soon as the interface is reconfigured and up with the same IP. -Case2: Previously configured mgmtIP is different from newly loaded mgmtIP. Users will lose their SSH connections. -Case3: Newly loaded config does not have any mgmtIP. Users will lose their SSH connections. - -NOTE: Management interface IP address and default route (or specific route) may require reconfiguration in case if those parameters are not part of the minigraph.xml. - -When user specifies the optional argument "-y" or "--yes", this command forces the loading without prompting the user for confirmation. -If the argument is not specified, it prompts the user to confirm whether user really wants to load this configuration file. - -When user specifies the optional argument "-n" or "--no-service-restart", this command clear and loads the configuration without restarting dependent services -running on the device. One use case for this option is during boot time when config-setup service loads existing old configuration and there is no services -running on the device. - -When user specifies the optional argument "-f" or "--force", this command ignores the system sanity checks. By default a list of sanity checks are performed and if one of the checks fail, the command will not execute. The sanity checks include ensuring the system status is not starting, all the essential services are up and swss is in ready state. - -- Usage: - ``` - config reload [-y|--yes] [-l|--load-sysinfo] [] [-n|--no-service-restart] [-f|--force] - ``` - -- Example: - ``` - admin@sonic:~$ sudo config reload - Clear current config and reload config from the file /etc/sonic/config_db.json? [y/N]: y - Running command: systemctl stop dhcp_relay - Running command: systemctl stop swss - Running command: systemctl stop snmp - Warning: Stopping snmp.service, but it can still be activated by: - snmp.timer - Running command: systemctl stop lldp - Running command: systemctl stop pmon - Running command: systemctl stop bgp - Running command: systemctl stop teamd - Running command: /usr/local/bin/sonic-cfggen -H -k Force10-Z9100-C32 --write-to-db - Running command: /usr/local/bin/sonic-cfggen -j /etc/sonic/config_db.json --write-to-db - Running command: systemctl restart hostname-config - Running command: systemctl restart interfaces-config - Timeout, server 10.11.162.42 not responding. - ``` - When some sanity checks fail below error messages can be seen - ``` - admin@sonic:~$ sudo config reload -y - System is not up. Retry later or use -f to avoid system checks - ``` - ``` - admin@sonic:~$ sudo config reload -y - Relevant services are not up. Retry later or use -f to avoid system checks - ``` - ``` - admin@sonic:~$ sudo config reload -y - SwSS container is not ready. Retry later or use -f to avoid system checks - ``` - - -### Loading Management Configuration - -**config load_mgmt_config** - -This command is used to reconfigure hostname and mgmt interface based on device description file. -This command either uses the optional file specified as arguement or looks for the file "/etc/sonic/device_desc.xml". -If the file does not exist or if the file does not have valid fields for "hostname" and "ManagementAddress", it fails. - -When user specifies the optional argument "-y" or "--yes", this command forces the loading without prompting the user for confirmation. -If the argument is not specified, it prompts the user to confirm whether user really wants to load this configuration file. - -- Usage: - ``` - config load_mgmt_config [-y|--yes] [] - ``` - -- Example: - ``` - admin@sonic:~$ sudo config load_mgmt_config - Reload config from minigraph? [y/N]: y - Running command: /usr/local/bin/sonic-cfggen -M /etc/sonic/device_desc.xml --write-to-db - ``` - - -### Saving Configuration to a File for Persistence - -**config save** - -This command is to save the config DB configuration into the user-specified filename or into the default /etc/sonic/config_db.json. This saves the configuration into the disk which is available even after reboots. -Saved file can be transferred to remote machines for debugging. If users wants to load the configuration from this new file at any point of time, they can use "config load" command and provide this newly generated file as input. If users wants this newly generated file to be used during reboot, they need to copy this file to /etc/sonic/config_db.json. - -- Usage: - ``` - config save [-y|--yes] [] - ``` - -- Example (Save configuration to /etc/sonic/config_db.json): - ``` - admin@sonic:~$ sudo config save -y - ``` - -- Example (Save configuration to a specified file): - ``` - admin@sonic:~$ sudo config save -y /etc/sonic/config2.json - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#loading-reloading-and-saving-configuration) - -## Loopback Interfaces - -### Loopback show commands - -Please check [show ip interfaces](#show-ip-interfaces) - -### Loopback config commands - -This sub-section explains how to create and delete loopback interfaces. - -**config interface loopback** - -This command is used to add or delete loopback interfaces. -It is recommended to use loopback names in the format "Loopbackxxx", where "xxx" is number of 1 to 3 digits. Ex: "Loopback11". - -- Usage: - ``` - config loopback (add | del) - ``` - -- Example (Create the loopback with name "Loopback11"): - ``` - admin@sonic:~$ sudo config loopback add Loopback11 - ``` - -## VRF Configuration - -### VRF show commands - -**show vrf** - -This command displays all vrfs configured on the system along with interface binding to the vrf. -If vrf-name is also provided as part of the command, if the vrf is created it will display all interfaces binding to the vrf, if vrf is not created nothing will be displayed. - -- Usage: - ``` - show vrf [] - ``` - -- Example: - ```` - admin@sonic:~$ show vrf - VRF Interfaces - ------- ------------ - default Vlan20 - Vrf-red Vlan100 - Loopback11 - Eth0.100 - Vrf-blue Loopback100 - Loopback102 - Ethernet0.10 - PortChannel101 - ```` - -### VRF config commands - -**config vrf add ** - -This command creates vrf in SONiC system with provided vrf-name. - -- Usage: - ``` -config vrf add -``` -Note: vrf-name should always start with keyword "Vrf" - -**config vrf del ** - -This command deletes vrf with name vrf-name. - -- Usage: - ``` -config vrf del -``` - -## Management VRF - -### Management VRF Show commands - -**show mgmt-vrf** - -This command displays whether the management VRF is enabled or disabled. It also displays the details about the the links (eth0, mgmt, lo-m) that are related to management VRF. - -- Usage: - ``` - show mgmt-vrf - ``` - -- Example: - ``` - admin@sonic:~$ show mgmt-vrf - - ManagementVRF : Enabled - - Management VRF interfaces in Linux: - 348: mgmt: mtu 65536 qdisc noqueue state UP mode DEFAULT group default qlen 1000 - link/ether f2:2a:d9:bc:e8:f0 brd ff:ff:ff:ff:ff:ff - 2: eth0: mtu 1500 qdisc mq master mgmt state UP mode DEFAULT group default qlen 1000 - link/ether 4c:76:25:f4:f9:f3 brd ff:ff:ff:ff:ff:ff - 350: lo-m: mtu 1500 qdisc noqueue master mgmt state UNKNOWN mode DEFAULT group default qlen 1000 - link/ether b2:4c:c6:f3:e9:92 brd ff:ff:ff:ff:ff:ff - - NOTE: The management interface "eth0" shows the "master" as "mgmt" since it is part of management VRF. - ``` - -**show mgmt-vrf routes** - -This command displays the routes that are present in the routing table 5000 that is meant for management VRF. - -- Usage: - ``` - show mgmt-vrf routes - ``` - -- Example: - ``` - admin@sonic:~$ show mgmt-vrf routes - - Routes in Management VRF Routing Table: - default via 10.16.210.254 dev eth0 metric 201 - broadcast 10.16.210.0 dev eth0 proto kernel scope link src 10.16.210.75 - 10.16.210.0/24 dev eth0 proto kernel scope link src 10.16.210.75 - local 10.16.210.75 dev eth0 proto kernel scope host src 10.16.210.75 - broadcast 10.16.210.255 dev eth0 proto kernel scope link src 10.16.210.75 - broadcast 127.0.0.0 dev lo-m proto kernel scope link src 127.0.0.1 - 127.0.0.0/8 dev lo-m proto kernel scope link src 127.0.0.1 - local 127.0.0.1 dev lo-m proto kernel scope host src 127.0.0.1 - broadcast 127.255.255.255 dev lo-m proto kernel scope link src 127.0.0.1 - ``` - -**show management_interface address** - -This command displays the IP address(es) configured for the management interface "eth0" and the management network default gateway. - -- Usage: - ``` - show management_interface address - ``` - -- Example: - ``` - admin@sonic:~$ show management_interface address - Management IP address = 10.16.210.75/24 - Management NetWork Default Gateway = 10.16.210.254 - Management IP address = FC00:2::32/64 - Management Network Default Gateway = fc00:2::1 - ``` - -**show snmpagentaddress** - -This command displays the configured SNMP agent IP addresses. - -- Usage: - ``` - show snmpagentaddress - ``` - -- Example: - ``` - admin@sonic:~$ show snmpagentaddress - ListenIP ListenPort ListenVrf - ---------- ------------ ----------- - 1.2.3.4 787 mgmt - ``` - -**show snmptrap** - -This command displays the configured SNMP Trap server IP addresses. - -- Usage: - ``` - show snmptrap - ``` - -- Example: - ``` - admin@sonic:~$ show snmptrap - Version TrapReceiverIP Port VRF Community - --------- ---------------- ------ ----- ----------- - 2 31.31.31.31 456 mgmt public - ``` - -### Management VRF Config commands - -**config vrf add mgmt** - -This command enables the management VRF in the system. This command restarts the "interfaces-config" service which in turn regenerates the /etc/network/interfaces file and restarts the "networking" service. This creates a new interface and l3mdev CGROUP with the name as "mgmt" and enslaves the management interface "eth0" into this master interface "mgmt". Note that the VRFName "mgmt" (or "management") is reserved for management VRF. i.e. Data VRFs should not use these reserved VRF names. - -- Usage: - ``` - config vrf add mgmt - ``` - -- Example: - ``` - admin@sonic:~$ sudo config vrf add mgmt - ``` - -**config vrf del mgmt** - -This command disables the management VRF in the system. This command restarts the "interfaces-config" service which in turn regenerates the /etc/network/interfaces file and restarts the "networking" service. This deletes the interface "mgmt" and deletes the l3mdev CGROUP named "mgmt" and puts back the management interface "eth0" into the default VRF. Note that the VRFName "mgmt" (or "management") is reserved for management VRF. i.e. Data VRFs should not use these reserved VRF names. - -- Usage: - ``` - config vrf del mgmt - ``` - -- Example: - ``` - admin@sonic:~$ sudo config vrf del mgmt - ``` - -**config snmpagentaddress add** - -This command adds the SNMP agent IP address on which the SNMP agent is expected to listen. When SNMP agent is expected to work as part of management VRF, users should specify the optional vrf_name parameter as "mgmt". This configuration goes into snmpd.conf that is used by SNMP agent. SNMP service is restarted to make this configuration effective in SNMP agent. - -- Usage: - ``` - config snmpagentaddress add [-p ] [-v ] agentip - ``` - -- Example: - ``` - admin@sonic:~$ sudo config snmpagentaddress add -v mgmt -p 123 21.22.13.14 - - Note: For this example, configuration goes into /etc/snmp/snmpd.conf inside snmp docker as follows. When "-v" parameter is not used, the additional "%" in the following line will not be present. - - agentAddress 21.22.13.14:123%mgmt - ``` - -**config snmpagentaddress del** - -This command deletes the SNMP agent IP address on which the SNMP agent is expected to listen. When users had added the agent IP as part of "mgmt" VRF, users should specify the optional vrf_name parameter as "mgmt" while deleting as well. This configuration is removed from snmpd.conf that is used by SNMP agent. SNMP service is restarted to make this configuration effective in SNMP agent. - -- Usage: - ``` - config snmpagentaddress del [-p ] [-v ] agentip - ``` - -- Example: - ``` - admin@sonic:~$ sudo config snmpagentaddress del -v mgmt -p 123 21.22.13.14 - - ``` - -**config snmptrap modify** - -This command modifies the SNMP trap server IP address to which the SNMP agent is expected to send the traps. Users can configure one server IP addrss for each SNMP version to send the traps. When SNMP agent is expected to send traps as part of management VRF, users should specify the optional vrf_name parameter as "mgmt". This configuration goes into snmpd.conf that is used by SNMP agent. SNMP service is restarted to make this configuration effective in SNMP agent. - -- Usage: - ``` - config snmptrap modify [-p ] [-v ] [-c ] trapserverip - ``` - -- Example: - ``` - admin@sonic:~$ sudo config snmptrap modify 2 -p 456 -v mgmt 21.21.21.21 - - For this example, configuration goes into /etc/snmp/snmpd.conf inside snmp docker as follows. When "-v" parameter is not used, the additional "%" in the following line will not be present. In case of SNMPv1, "trapsink" will be updated, in case of v2, "trap2sink" will be updated and in case of v3, "informsink" will be updated. - - trap2sink 31.31.31.31:456%mgmt public - - ``` - -**config snmptrap del** - -This command deletes the SNMP Trap server IP address to which SNMP agent is expected to send TRAPs. When users had added the trap server IP as part of "mgmt" VRF, users should specify the optional vrf_name parameter as "mgmt" while deleting as well. This configuration is removed from snmpd.conf that is used by SNMP agent. SNMP service is restarted to make this configuration effective in SNMP agent. - -- Usage: - ``` - config snmptrap del [-p ] [-v ] [-c ] trapserverip - ``` - -- Example: - ``` - admin@sonic:~$ sudo config snmptrap del -v mgmt -p 123 21.22.13.14 - - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#management-vrf) - -## Muxcable - -### Muxcable Show commands - -**show muxcable status** - -This command displays all the status of either all the ports which are connected to muxcable or any individual port selected by the user. The resultant table or json output will show the current status of muxcable on the port (auto/active) and also the health of the muxcable. - -- Usage: - ``` - show muxcable status [OPTIONS] [PORT] - ``` - -While displaying the muxcable status, users can configure the following fields - -- PORT optional - Port name should be a valid port -- --json optional - -- option to display the result in json format. By default output will be in tabular format. - -With no optional argument, all the ports muxcable status will be displayed in tabular form, or user can pass --json option to display in json format - -- Example: - ``` - admin@sonic:~$ show muxcable status - PORT STATUS HEALTH - ---------- -------- -------- - Ethernet32 active HEALTHY - Ethernet0 auto HEALTHY - ``` - ``` - admin@sonic:~$ show muxcable status --json - ``` - ```json - { - "MUX_CABLE": { - "Ethernet32": { - "STATUS": "active", - "HEALTH": "HEALTHY" - }, - "Ethernet0": { - "STATUS": "auto", - "HEALTH": "HEALTHY" - } - } - } - - ``` - ``` - admin@sonic:~$ show muxcable status Ethernet0 - PORT STATUS HEALTH - --------- -------- -------- - Ethernet0 auto HEALTHY - ``` - ``` - admin@sonic:~$ show muxcable status Ethernet0 --json - ``` - ```json - { - "MUX_CABLE": { - "Ethernet0": { - "STATUS": "auto", - "HEALTH": "HEALTHY" - } - } - } - ``` - -**show muxcable config** - -This command displays all the configurations of either all the ports which are connected to muxcable or any individual port selected by the user. The resultant table or json output will show the current configurations of muxcable on the port(active/standby) and also the ipv4 and ipv6 address of the port as well as peer TOR ip address with the hostname. - -- Usage: - ``` - show muxcable config [OPTIONS] [PORT] - ``` - -With no optional argument, all the ports muxcable configuration will be displayed in tabular form -While displaying the muxcable configuration, users can configure the following fields - -- PORT optional - Port name should be a valid port -- --json optional - option to display the result in json format. By default output will be in tabular format. - -- Example: - ``` - admin@sonic:~$ show muxcable config - SWITCH_NAME PEER_TOR - ------------- ---------- - sonic 10.1.1.1 - port state ipv4 ipv6 - --------- ------- -------- -------- - Ethernet0 active 10.1.1.1 fc00::75 - ``` - ``` - admin@sonic:~$ show muxcable config --json - ``` - ```json - { - "MUX_CABLE": { - "PEER_TOR": "10.1.1.1", - "PORTS": { - "Ethernet0": { - "STATE": "active", - "SERVER": { - "IPv4": "10.1.1.1", - "IPv6": "fc00::75" - } - } - } - } - } - ``` - ``` - admin@sonic:~$ show muxcable config Ethernet0 - SWITCH_NAME PEER_TOR - ------------- ---------- - sonic 10.1.1.1 - port state ipv4 ipv6 - --------- ------- -------- -------- - Ethernet0 active 10.1.1.1 fc00::75 - ``` - ``` - admin@sonic:~$ show muxcable config Ethernet0 --json - ``` - ```json - { - "MUX_CABLE": { - "PORTS": { - "Ethernet0": { - "STATE": "active", - "SERVER": { - "IPv4": "10.1.1.1", - "IPv6": "fc00::75" - } - } - } - } - } - ``` - -**show muxcable ber-info** - -This command displays the ber(Bit error rate) of the port user provides on the target user provides. The target provided as an integer corresponds to actual target as. -0 -> local -1 -> tor 1 -2 -> tor 2 -3 -> nic - -- Usage: - ``` - Usage: show muxcable ber-info [OPTIONS] PORT TARGET - ``` - - -- PORT required - Port number should be a valid port -- TARGET required - the actual target to get the ber info of. - -- Example: - ``` - admin@sonic:~$ show muxcable ber-info 1 1 - Lane1 Lane2 - ------- ------- - 0 0 - ``` - -**show muxcable ber-info** - -This command displays the eye info in mv(milli volts) of the port user provides on the target user provides. The target provided as an integer corresponds to actual target as. -0 -> local -1 -> tor 1 -2 -> tor 2 -3 -> nic - -- Usage: - ``` - Usage: show muxcable eye-info [OPTIONS] PORT TARGET - ``` - -- PORT required - Port number should be a valid port -- TARGET required - the actual target to get the eye info of. - -- Example: - ``` - admin@sonic:~$ show muxcable ber-info 1 1 - Lane1 Lane2 - ------- ------- - 632 622 - ``` - -### Muxcable Config commands - - -**config muxcable mode** - -This command is used for setting the configuration of a muxcable Port/all ports to be active or auto. The user has to enter a port number or else all to make the muxcable config operation on all the ports. Depending on the status of the muxcable port state the resultant output could be OK or INPROGRESS . OK would imply no change on the state, INPROGRESS would mean the toggle is happening in the background. - -- Usage: - ``` - config muxcable mode [OPTIONS] - ``` - -While configuring the muxcable, users needs to configure the following fields for the operation - -- operation_state, permitted operation to be configured which can only be auto or active -- PORT optional - Port name should be a valid port -- --json optional - option to display the result in json format. By default output will be in tabular format. - - -- Example: - ``` - admin@sonic:~$ sudo config muxcable mode active Ethernet0 - port state - --------- ------- - Ethernet0 OK - ``` - ``` - admin@sonic:~$ sudo config muxcable mode --json active Ethernet0 - ``` - ```json - { - "Ethernet0": "OK" - } - ``` - ``` - admin@sonic:~$ sudo config muxcable mode active all - port state - ---------- ---------- - Ethernet0 OK - Ethernet32 INPROGRESS - ``` - ``` - admin@sonic:~$ sudo config muxcable mode active all --json - ``` - ```json - { - "Ethernet32": "INPROGRESS", - "Ethernet0": "OK" - } - ``` -**config muxcable prbs enable/disable** - -This command is used for setting the configuration and enable/diable of prbs on a port user provides. While enabling in addition to port the user also needs to provides the target, prbs mode and lane map on which the user intends to run prbs on. The target reflects where the enable/dsiable will happen. - -- Usage: - ``` - config muxcable prbs enable [OPTIONS] PORT TARGET MODE_VALUE LANE_MAP - config muxcable prbs disable [OPTIONS] PORT TARGET - ``` - -While configuring the muxcable, users needs to configure the following fields for the operation - -- PORT required - Port number should be a valid port -- TARGET required - the actual target to run the prbs on - 0 -> local side, - 1 -> TOR 1 - 2 -> TOR 2 - 3 -> NIC -- MODE_VALUE required - the mode/type for configuring the PRBS mode. - 0x00 = PRBS 9, 0x01 = PRBS 15, 0x02 = PRBS 23, 0x03 = PRBS 31 -- LANE_MAP required - an integer representing the lane_map to be run PRBS on - 0bit for lane 0, 1bit for lane1 and so on. - for example 3 -> 0b'0011 , means running on lane0 and lane1 -- Example: - ``` - admin@sonic:~$ sudo config muxcable prbs enable 1 1 3 3 - PRBS config sucessful - admin@sonic:~$ sudo config muxcable prbs disable 1 0 - PRBS disable sucessful - ``` - -**config muxcable loopback enable/disable** - -This command is used for setting the configuration and enable/disable of loopback on a port user provides. While enabling in addition to port the user also needs to provides the target and lane map on which the user intends to run loopback on. The target reflects where the enable/dsiable will happen. - -- Usage: - ``` - config muxcable loopback enable [OPTIONS] PORT TARGET LANE_MAP - config muxcable loopback disable [OPTIONS] PORT TARGET - ``` - -While configuring the muxcable, users needs to configure the following fields for the operation - -- PORT required - Port number should be a valid port -- TARGET required - the actual target to run the loopback on - 0 -> local side, - 1 -> TOR 1 - 2 -> TOR 2 - 3 -> NIC -- LANE_MAP required - an integer representing the lane_map to be run loopback on - 0bit for lane 0, 1bit for lane1 and so on. - for example 3 -> 0b'0011 , means running on lane0 and lane1 - -- Example: - ``` - admin@sonic:~$ sudo config muxcable loopback enable 1 1 3 - loopback config sucessful - admin@sonic:~$ sudo config muxcable loopback disable 1 0 - loopback disable sucessfull - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#muxcable) - -## Mirroring - -### Mirroring Show commands - -**show mirror_session** - -This command displays all the mirror sessions that are configured. - -- Usage: - ``` - show mirror_session - ``` - -- Example: - ``` - admin@sonic:~$ show mirror_session - ERSPAN Sessions - Name Status SRC IP DST IP GRE DSCP TTL Queue Policer Monitor Port SRC Port Direction - ------ -------- -------- -------- ----- ------ ----- ------- --------- -------------- ---------- ----------- - everflow0 active 10.1.0.32 10.0.0.7 - - SPAN Sessions - Name Status DST Port SRC Port Direction - ------ -------- ---------- ------------- ----------- - port0 active Ethernet0 PortChannel10 rx - ``` - -### Mirroring Config commands - -**config mirror_session** - -This command is used to add or remove mirroring sessions. Mirror session is identified by "session_name". -This command supports configuring both SPAN/ERSPAN sessions. -In SPAN user can configure mirroring of list of source ports/LAG to destination port in ingress/egress/both directions. -In ERSPAN user can configure mirroring of list of source ports/LAG to a destination IP. -Both SPAN/ERSPAN support ACL based mirroring and can be used in ACL configurations. - -While adding a new ERSPAN session, users need to configure the following fields that are used while forwarding the mirrored packets. - -1) source IP address, -2) destination IP address, -3) DSCP (QoS) value with which mirrored packets are forwarded -4) TTL value -5) optional - GRE Type in case if user wants to send the packet via GRE tunnel. GRE type could be anything; it could also be left as empty; by default, it is 0x8949 for Mellanox; and 0x88be for the rest of the chips. -6) optional - Queue in which packets shall be sent out of the device. Valid values 0 to 7 for most of the devices. Users need to know their device and the number of queues supported in that device. -7) optional - Policer which will be used to control the rate at which frames are mirrored. -8) optional - List of source ports which can have both Ethernet and LAG ports. -9) optional - Direction - Mirror session direction when configured along with Source port. (Supported rx/tx/both. default direction is both) - -- Usage: - ``` - config mirror_session erspan add [gre_type] [queue] [policer ] [source-port-list] [direction] - ``` - - The following command is also supported to be backward compatible. - This command will be deprecated in future releases. - ``` - config mirror_session add [gre_type] [queue] - ``` - -- Example: - ``` - root@T1-2:~# config mirror_session add mrr_legacy 1.2.3.4 20.21.22.23 8 100 0x6558 0 - root@T1-2:~# show mirror_session - Name Status SRC IP DST IP GRE DSCP TTL Queue Policer Monitor Port SRC Port Direction - --------- -------- -------- ----------- ------ ------ ----- ------- --------- -------------- ---------- ----------- - mrr_legacy inactive 1.2.3.4 20.21.22.23 0x6558 8 100 0 - - - root@T1-2:~# config mirror_session erspan add mrr_abcd 1.2.3.4 20.21.22.23 8 100 0x6558 0 - root@T1-2:~# show mirror_session - Name Status SRC IP DST IP GRE DSCP TTL Queue Policer Monitor Port SRC Port Direction - --------- -------- -------- ----------- ------ ------ ----- ------- --------- -------------- ---------- ----------- - mrr_abcd inactive 1.2.3.4 20.21.22.23 0x6558 8 100 0 - root@T1-2:~# - - root@T1-2:~# config mirror_session erspan add mrr_port 1.2.3.4 20.21.22.23 8 100 0x6558 0 Ethernet0 - root@T1-2:~# show mirror_session - Name Status SRC IP DST IP GRE DSCP TTL Queue Policer Monitor Port SRC Port Direction - --------- -------- -------- ----------- ------ ------ ----- ------- --------- -------------- ---------- ----------- - mrr_port inactive 1.2.3.4 20.21.22.23 0x6558 8 100 0 Ethernet0 both - root@T1-2:~# - ``` - -While adding a new SPAN session, users need to configure the following fields that are used while forwarding the mirrored packets. -1) destination port, -2) optional - List of source ports- List of source ports which can have both Ethernet and LAG ports. -3) optional - Direction - Mirror session direction when configured along with Source port. (Supported rx/tx/both. default direction is both) -4) optional - Queue in which packets shall be sent out of the device. Valid values 0 to 7 for most of the devices. Users need to know their device and the number of queues supported in that device. -5) optional - Policer which will be used to control the rate at which frames are mirrored. - -- Usage: - ``` - config mirror_session span add [source-port-list] [direction] [queue] [policer ] - ``` - -- Example: - ``` - root@T1-2:~# config mirror_session span add port0 Ethernet0 Ethernet4,PortChannel001,Ethernet8 - root@T1-2:~# show mirror_session - Name Status DST Port SRC Port Direction - ------ -------- ---------- --------------------------------- ----------- - port0 active Ethernet0 Ethernet4,PortChannel10,Ethernet8 both - root@T1-2:~# - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#mirroring) - -## NAT - -### NAT Show commands - -**show nat config** - -This command displays the NAT configuration. - -- Usage: - ``` - show nat config [static | pool | bindings | globalvalues | zones] - ``` - -With no optional arguments, the whole NAT configuration is displayed. - -- Example: - ``` - admin@sonic:~$ show nat config static - - Nat Type IP Protocol Global IP Global L4 Port Local IP Local L4 Port Twice-Nat Id - -------- ----------- ------------ -------------- ------------- ------------- ------------ - dnat all 65.55.45.5 --- 10.0.0.1 --- --- - dnat all 65.55.45.6 --- 10.0.0.2 --- --- - dnat tcp 65.55.45.7 2000 20.0.0.1 4500 1 - snat tcp 20.0.0.2 4000 65.55.45.8 1030 1 - - admin@sonic:~$ show nat config pool - - Pool Name Global IP Range Global L4 Port Range - ------------ ------------------------- -------------------- - Pool1 65.55.45.5 1024-65535 - Pool2 65.55.45.6-65.55.45.8 --- - Pool3 65.55.45.10-65.55.45.15 500-1000 - - admin@sonic:~$ show nat config bindings - - Binding Name Pool Name Access-List Nat Type Twice-Nat Id - ------------ ------------ ------------ -------- ------------ - Bind1 Pool1 --- snat --- - Bind2 Pool2 1 snat 1 - Bind3 Pool3 2 snat -- - - admin@sonic:~$ show nat config globalvalues - - Admin Mode : enabled - Global Timeout : 600 secs - TCP Timeout : 86400 secs - UDP Timeout : 300 secs - - admin@sonic:~$ show nat config zones - - Port Zone - ---- ---- - Ethernet2 0 - Vlan100 1 - ``` - -**show nat statistics** - -This command displays the NAT translation statistics for each entry. - -- Usage: - ``` - show nat statistics - ``` - -- Example: - ``` - admin@sonic:~$ show nat statistics - - Protocol Source Destination Packets Bytes - -------- --------- -------------- ------------- ------------- - all 10.0.0.1 --- 802 1009280 - all 10.0.0.2 --- 23 5590 - tcp 20.0.0.1:4500 --- 110 12460 - udp 20.0.0.1:4000 --- 1156 789028 - tcp 20.0.0.1:6000 --- 30 34800 - tcp 20.0.0.1:5000 65.55.42.1:2000 128 110204 - tcp 20.0.0.1:5500 65.55.42.1:2000 8 3806 - ``` - -**show nat translations** - -This command displays the NAT translation entries. - -- Usage: - ``` - show nat translations [count] - ``` -Giving the optional count argument displays only the details about the number of translation entries. -- Example: - ``` - admin@sonic:~$ show nat translations - - Static NAT Entries ................. 4 - Static NAPT Entries ................. 2 - Dynamic NAT Entries ................. 0 - Dynamic NAPT Entries ................. 4 - Static Twice NAT Entries ................. 0 - Static Twice NAPT Entries ................. 4 - Dynamic Twice NAT Entries ................ 0 - Dynamic Twice NAPT Entries ................ 0 - Total SNAT/SNAPT Entries ................ 9 - Total DNAT/DNAPT Entries ................ 9 - Total Entries ................ 14 - - Protocol Source Destination Translated Source Translated Destination - -------- --------- -------------- ----------------- ---------------------- - all 10.0.0.1 --- 65.55.42.2 --- - all --- 65.55.42.2 --- 10.0.0.1 - all 10.0.0.2 --- 65.55.42.3 --- - all --- 65.55.42.3 --- 10.0.0.2 - tcp 20.0.0.1:4500 --- 65.55.42.1:2000 --- - tcp --- 65.55.42.1:2000 --- 20.0.0.1:4500 - udp 20.0.0.1:4000 --- 65.55.42.1:1030 --- - udp --- 65.55.42.1:1030 --- 20.0.0.1:4000 - tcp 20.0.0.1:6000 --- 65.55.42.1:1024 --- - tcp --- 65.55.42.1:1024 --- 20.0.0.1:6000 - tcp 20.0.0.1:5000 65.55.42.1:2000 65.55.42.1:1025 20.0.0.1:4500 - tcp 20.0.0.1:4500 65.55.42.1:1025 65.55.42.1:2000 20.0.0.1:5000 - tcp 20.0.0.1:5500 65.55.42.1:2000 65.55.42.1:1026 20.0.0.1:4500 - tcp 20.0.0.1:4500 65.55.42.1:1026 65.55.42.1:2000 20.0.0.1:5500 - - admin@sonic:~$ show nat translations count - - Static NAT Entries ................. 4 - Static NAPT Entries ................. 2 - Dynamic NAT Entries ................. 0 - Dynamic NAPT Entries ................. 4 - Static Twice NAT Entries ................. 0 - Static Twice NAPT Entries ................. 4 - Dynamic Twice NAT Entries ................ 0 - Dynamic Twice NAPT Entries ................ 0 - Total SNAT/SNAPT Entries ................ 9 - Total DNAT/DNAPT Entries ................ 9 - Total Entries ................ 14 - ``` - -### NAT Config commands - -**config nat add static** - -This command is used to add a static NAT or NAPT entry. -When configuring the Static NAT entry, user has to specify the following fields with 'basic' keyword. - -1. Global IP address, -2. Local IP address, -3. NAT type (snat / dnat) to be applied on the Global IP address. Default value is dnat. This is optinoal argument. -4. Twice NAT Id. This is optional argument used in case of twice nat configuration. - -When configuring the Static NAPT entry, user has to specify the following fields. - -1. IP protocol type (tcp / udp) -2. Global IP address + Port -3. Local IP address + Port -4. NAT type (snat / dnat) to be applied on the Global IP address + Port. Default value is dnat. This is optional argument. -5. Twicw NAT Id. This is optional argument used in case of twice nat configuration. - -- Usage: - ``` - config nat add static {{basic (global-ip) (local-ip)} | {{tcp | udp} (global-ip) (global-port) (local-ip) (local-port)}} [-nat_type {snat | dnat}] [-twice_nat_id (value)] - ``` - -To delete a static NAT or NAPT entry, use the command below. Giving the all argument deletes all the configured static NAT and NAPT entries. -``` -config nat remove static {{basic (global-ip) (local-ip)} | {{tcp | udp} (global-ip) (global-port) (local-ip) (local-port)} | all} -``` -- Example: - ``` - admin@sonic:~$ sudo config nat add static basic 65.55.45.1 12.12.12.14 -nat_type dnat - admin@sonic:~$ sudo config nat add static tcp 65.55.45.2 100 12.12.12.15 200 -nat_type dnat - - admin@sonic:~$ show nat translations - - Static NAT Entries ................. 2 - Static NAPT Entries ................. 2 - Dynamic NAT Entries ................. 0 - Dynamic NAPT Entries ................. 0 - Static Twice NAT Entries ................. 0 - Static Twice NAPT Entries ................. 0 - Dynamic Twice NAT Entries ................ 0 - Dynamic Twice NAPT Entries ................ 0 - Total SNAT/SNAPT Entries ................ 2 - Total DNAT/DNAPT Entries ................ 2 - Total Entries ................ 4 - - Protocol Source Destination Translated Source Translated Destination - -------- --------- -------------- ----------------- ---------------------- - all 12.12.12.14 --- 65.55.42.1 --- - all --- 65.55.42.1 --- 12.12.12.14 - tcp 12.12.12.15:200 --- 65.55.42.2:100 --- - tcp --- 65.55.42.2:100 --- 12.12.12.15:200 - ``` - -**config nat add pool** - -This command is used to create a NAT pool used for dynamic Source NAT or NAPT translations. -Pool can be configured in one of the following combinations. - -1. Global IP address range (or) -2. Global IP address + L4 port range (or) -3. Global IP address range + L4 port range. - -- Usage: - ``` - config nat add pool (pool-name) (global-ip-range) (global-port-range) - ``` -To delete a NAT pool, use the command. Pool cannot be removed if it is referenced by a NAT binding. Giving the pools argument removes all the configured pools. -``` -config nat remove {pool (pool-name) | pools} -``` -- Example: - ``` - admin@sonic:~$ sudo config nat add pool pool1 65.55.45.2-65.55.45.10 - admin@sonic:~$ sudo config nat add pool pool2 65.55.45.3 100-1024 - - admin@sonic:~$ show nat config pool - - Pool Name Global IP Range Global Port Range - ----------- ---------------------- ------------------- - pool1 65.55.45.2-65.55.45.10 --- - pool2 65.55.45.3 100-1024 - ``` - -**config nat add binding** - -This command is used to create a NAT binding between a pool and an ACL. The following fields are needed for configuring the binding. - - 1. ACL is an optional argument. If ACL argument is not given, the NAT binding is applicable to match all traffic. - 2. NAT type is an optional argument. Only DNAT type is supoprted for binding. - 3. Twice NAT Id is an optional argument. This Id is used to form a twice nat grouping with the static NAT/NAPT entry configured with the same Id. - -- Usage: - ``` - config nat add binding (binding-name) [(pool-name)] [(acl-name)] [-nat_type {snat | dnat}] [-twice_nat_id (value)] - ``` -To delete a NAT binding, use the command below. Giving the bindings argument removes all the configured bindings. -``` -config nat remove {binding (binding-name) | bindings} -``` -- Example: - ``` - admin@sonic:~$ sudo config nat add binding bind1 pool1 acl1 - admin@sonic:~$ sudo config nat add binding bind2 pool2 - - admin@sonic:~$ show nat config bindings - - Binding Name Pool Name Access-List Nat Type Twice-NAT Id - -------------- ----------- ------------- ---------- -------------- - bind1 pool1 acl1 snat --- - bind2 pool2 snat --- - ``` - -**config nat add interface** - -This command is used to configure NAT zone on an L3 interface. Default value of NAT zone on an L3 interface is 0. Valid range of zone values is 0-3. - -- Usage: - ``` - config nat add interface (interface-name) -nat_zone (value) - ``` -To reset the NAT zone on an interface, use the command below. Giving the interfaces argument resets the NAT zone on all the L3 interfaces to 0. -``` -config nat remove {interface (interface-name) | interfaces} -``` -- Example: - ``` - admin@sonic:~$ sudo config nat add interface Ethernet28 -nat_zone 1 - - admin@sonic:~$ show nat config zones - - Port Zone - ---------- ------ - Ethernet0 0 - Ethernet28 1 - Ethernet22 0 - Vlan2091 0 - ``` - -**config nat set** - -This command is used to set the NAT timeout values. Different timeout values can be configured for the NAT entry timeout, NAPT TCP entry timeout, NAPT UDP entry timeout. -Range for Global NAT entry timeout is 300 sec to 432000 sec, default value is 600 sec. -Range for TCP NAT/NAPT entry timeout is 300 sec to 432000 sec, default value is 86400 sec. -Range for UDP NAT/NAPT entry timeout is 120 sec to 600 sec, default value is 300 sec. - -- Usage: - ``` - config nat set {tcp-timeout (value) | timeout (value) | udp-timeout (value)} - ``` -To reset the timeout values to the default values, use the command -``` -config nat reset {tcp-timeout | timeout | udp-timeout} -``` -- Example: - ``` - admin@sonic:~$ sudo config nat add set tcp-timeout 3600 - - admin@sonic:~$ show nat config globalvalues - - Admin Mode : enabled - Global Timeout : 600 secs - TCP Timeout : 600 secs - UDP Timeout : 300 secs - ``` - -**config nat feature** - -This command is used to enable or disable the NAT feature. - -- Usage: - ``` - config nat feature {enable | disable} - ``` - -- Example: - ``` - admin@sonic:~$ sudo config nat feature enable - admin@sonic:~$ sudo config nat feature disable - ``` - -### NAT Clear commands - -**sonic-clear nat translations** - -This command is used to clear the dynamic NAT and NAPT translation entries. - -- Usage: - ``` - sonic-clear nat translations - ``` - -**sonic-clear nat statistics** - -This command is used to clear the statistics of all the NAT and NAPT entries. - -- Usage: - ``` - sonic-clear nat statistics - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#nat) - - -## NTP - -### NTP show commands - -**show ntp** - -This command displays a list of NTP peers known to the server as well as a summary of their state. - -- Usage: - ``` - show ntp - ``` - -- Example: - ``` - admin@sonic:~$ show ntp - synchronised to NTP server (204.2.134.164) at stratum 3 - time correct to within 326797 ms - polling server every 1024 s - - remote refid st t when poll reach delay offset jitter - ============================================================================== - 23.92.29.245 .XFAC. 16 u - 1024 0 0.000 0.000 0.000 - *204.2.134.164 46.233.231.73 2 u 916 1024 377 3.079 0.394 0.128 - ``` - - -### NTP Config Commands - -This sub-section of commands is used to add or remove the configured NTP servers. - -**config ntp add** - -This command is used to add a NTP server IP address to the NTP server list. Note that more that one NTP server IP address can be added in the device. - -- Usage: - ``` - config ntp add - ``` - -- Example: - ``` - admin@sonic:~$ sudo config ntp add 9.9.9.9 - NTP server 9.9.9.9 added to configuration - Restarting ntp-config service... - ``` - -**config ntp delete** - -This command is used to delete a configured NTP server IP address. - -- Usage: - ``` - config ntp del - ``` - -- Example: - ``` - admin@sonic:~$ sudo config ntp del 9.9.9.9 - NTP server 9.9.9.9 removed from configuration - Restarting ntp-config service... - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#NTP) - -# PFC Watchdog Commands -Detailed description of the PFC Watchdog could be fount on the [this wiki page](https://github.com/Azure/SONiC/wiki/PFC-Watchdog) - -**config pfcwd start \** - -This command starts PFC Watchdog - -- Usage: - ``` - config pfcwd start --action drop all 400 --restoration-time 400 - config pfcwd start --action forward Ethernet0 Ethernet8 400 - ``` - -**config pfcwd stop** - -This command stops PFC Watchdog - -- Usage: - ``` - config pfcwd stop - ``` - -**config pfcwd interval \** - -This command sets PFC Watchdog counter polling interval (in ms) - -- Usage: - ``` - config pfcwd interval 200 - ``` - -**config pfcwd counter_poll \** - -This command enables or disables PFCWD related counters polling - -- Usage: - ``` - config pfcwd counter_poll disable - ``` - -**config pfcwd big_red_switch \** - -This command enables or disables PFCWD's "BIG RED SWITCH"(BRS). After enabling BRS PFC Watchdog will be activated on all ports/queues it is configured for no matter whether the storm was detected or not - -- Usage: - ``` - config pfcwd big_red_switch enable - ``` - -**config pfcwd start_default** - -This command starts PFC Watchdog with the default settings. - -- Usage: - ``` - config pfcwd start_default - ``` - -Default values are the following: - - - detection time - 200ms - - restoration time - 200ms - - polling interval - 200ms - - action - 'drop' - -Additionally if number of ports in the system exceeds 32, all times will be multiplied by roughly /32. - - -**show pfcwd config** - -This command shows current PFC Watchdog configuration - -- Usage: - ``` - show pfcwd config - ``` - -**show pfcwd stats** - -This command shows current PFC Watchdog statistics (storms detected, packets dropped, etc) - -- Usage: - ``` - show pfcwd stats - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#pfc-watchdog-commands) - -## Platform Component Firmware - -### Platform Component Firmware show commands - -**show platform firmware status** - -This command displays platform components firmware status information. - -- Usage: -```bash -show platform firmware status -``` - -- Example: -```bash -admin@sonic:~$ sudo show platform firmware status -Chassis Module Component Version Description ---------- -------- ----------- ----------------------- ---------------------------------------- -MSN3800 N/A ONIE 2020.11-5.2.0022-9600 ONIE - Open Network Install Environment - SSD 0202-000 SSD - Solid-State Drive - BIOS 0ACLH004_02.02.008_9600 BIOS - Basic Input/Output System - CPLD1 CPLD000120_REV0900 CPLD - Complex Programmable Logic Device - CPLD2 CPLD000165_REV0500 CPLD - Complex Programmable Logic Device - CPLD3 CPLD000166_REV0300 CPLD - Complex Programmable Logic Device - CPLD4 CPLD000167_REV0100 CPLD - Complex Programmable Logic Device -``` - -**show platform firmware updates** - -This command displays platform components firmware updates information. - -- Usage: -```bash -show platform firmware updates [-i|--image] -``` - -- Options: - - _-i|--image_: show updates using current/next SONiC image - - Valid values: - - current - - next - - Default: - - current - -- Example: -```bash -admin@sonic:~$ sudo show platform firmware updates -Chassis Module Component Firmware Version (Current/Available) Status ---------- -------- ----------- ------------------------------------------ ------------------------------------------------- ------------------ -MSN3800 N/A ONIE /usr/local/lib/firmware/mellanox/onie.bin 2020.11-5.2.0022-9600 / 2020.11-5.2.0024-9600 update is required - SSD /usr/local/lib/firmware/mellanox/ssd.bin 0202-000 / 0204-000 update is required - BIOS /usr/local/lib/firmware/mellanox/bios.bin 0ACLH004_02.02.008_9600 / 0ACLH004_02.02.010_9600 update is required - CPLD1 /usr/local/lib/firmware/mellanox/cpld.mpfa CPLD000120_REV0900 / CPLD000120_REV0900 up-to-date - CPLD2 /usr/local/lib/firmware/mellanox/cpld.mpfa CPLD000165_REV0500 / CPLD000165_REV0500 up-to-date - CPLD3 /usr/local/lib/firmware/mellanox/cpld.mpfa CPLD000166_REV0300 / CPLD000166_REV0300 up-to-date - CPLD4 /usr/local/lib/firmware/mellanox/cpld.mpfa CPLD000167_REV0100 / CPLD000167_REV0100 up-to-date -``` - -- Note: - - current/next values for _-i|--image_ are taken from `sonic-installer list` - ```bash - admin@sonic:~$ sudo sonic-installer list - Current: SONiC-OS-202012.0-fb89c28c9 - Next: SONiC-OS-201911.0-2bec3004e - Available: - SONiC-OS-202012.0-fb89c28c9 - SONiC-OS-201911.0-2bec3004e - ``` - -**show platform firmware version** - -This command displays platform components firmware utility version. - -- Usage: -```bash -show platform firmware version -``` - -- Example: -```bash -admin@sonic:~$ show platform firmware version -fwutil version 2.0.0.0 -``` - -### Platform Component Firmware config commands - -**config platform firmware install** - -This command is used to install a platform component firmware. -Both modular and non modular chassis platforms are supported. - -- Usage: -```bash -config platform firmware install chassis component fw [-y|--yes] -config platform firmware install module component fw [-y|--yes] -``` - -- Options: - - _-y|--yes_: automatic yes to prompts. Assume "yes" as answer to all prompts and run non-interactively - -- Example: -```bash -admin@sonic:~$ sudo config platform firmware install chassis component BIOS fw /usr/local/lib/firmware/mellanox/sn3800/chassis1/bios.bin -Warning: Immediate cold reboot is required to complete BIOS firmware update. -New firmware will be installed, continue? [y/N]: y -Installing firmware: - /usr/local/lib/firmware/mellanox/sn3800/chassis1/bios.bin - -admin@sonic:~$ sudo config platform firmware install module Module1 component BIOS fw https://www.mellanox.com/fw/sn3800/module1/bios.bin -Warning: Immediate cold reboot is required to complete BIOS firmware update. -New firmware will be installed, continue? [y/N]: y -Downloading firmware: - [##################################################] 100% -Installing firmware: - /tmp/bios.bin -``` - -- Note: - - can be absolute path or URL - -**config platform firmware update** - -This command is used to update a platform component firmware from current/next SONiC image. -Both modular and non modular chassis platforms are supported. - -FW update requires `platform_components.json` to be created and placed at: -sonic-buildimage/device///platform_components.json - -Example: -1. Non modular chassis platform -```json -{ - "chassis": { - "Chassis1": { - "component": { - "BIOS": { - "firmware": "/usr/local/lib/firmware///chassis1/bios.bin", - "version": "" - }, - "CPLD": { - "firmware": "/usr/local/lib/firmware///chassis1/cpld.bin", - "version": "" - }, - "FPGA": { - "firmware": "/usr/local/lib/firmware///chassis1/fpga.bin", - "version": "" - } - } - } - } -} -``` - -2. Modular chassis platform -```json -{ - "chassis": { - "Chassis1": { - "component": { - "BIOS": { - "firmware": "/usr/local/lib/firmware///chassis1/bios.bin", - "version": "" - }, - "CPLD": { - "firmware": "/usr/local/lib/firmware///chassis1/cpld.bin", - "version": "" - }, - "FPGA": { - "firmware": "/usr/local/lib/firmware///chassis1/fpga.bin", - "version": "" - } - } - } - }, - "module": { - "Module1": { - "component": { - "CPLD": { - "firmware": "/usr/local/lib/firmware///module1/cpld.bin", - "version": "" - }, - "FPGA": { - "firmware": "/usr/local/lib/firmware///module1/fpga.bin", - "version": "" - } - } - } - } -} -``` - -- Usage: -```bash -config platform firmware update chassis component fw [-y|--yes] [-f|--force] [-i|--image] -config platform firmware update module component fw [-y|--yes] [-f|--force] [-i|--image] -``` - -- Options: - - _-y|--yes_: automatic yes to prompts. Assume "yes" as answer to all prompts and run non-interactively - - _-f|--force_: update FW regardless the current version - - _-i|--image_: update FW using current/next SONiC image - - Valid values: - - current - - next - - Default: - - current - -- Example: -```bash -admin@sonic:~$ sudo config platform firmware update chassis component BIOS fw -Warning: Immediate cold reboot is required to complete BIOS firmware update. -New firmware will be installed, continue? [y/N]: y -Updating firmware: - /usr/local/lib/firmware/mellanox/x86_64-mlnx_msn3800-r0/chassis1/bios.bin - -admin@sonic:~$ sudo config platform firmware update module Module1 component BIOS fw -Warning: Immediate cold reboot is required to complete BIOS firmware update. -New firmware will be installed, continue? [y/N]: y -Updating firmware: - /usr/local/lib/firmware/mellanox/x86_64-mlnx_msn3800-r0/module1/bios.bin -``` - -- Note: - - FW update will be disabled if component definition is not provided (e.g., 'BIOS': { }) - - FW version will be read from image if `version` field is not provided - - current/next values for _-i|--image_ are taken from `sonic-installer list` - ```bash - admin@sonic:~$ sudo sonic-installer list - Current: SONiC-OS-202012.0-fb89c28c9 - Next: SONiC-OS-201911.0-2bec3004e - Available: - SONiC-OS-202012.0-fb89c28c9 - SONiC-OS-201911.0-2bec3004e - ``` - -### Platform Component Firmware vendor specific behaviour - -#### Mellanox - -**CPLD update** - -On Mellanox platforms CPLD update can be done either for single or for all components at once. -The second approach is preferred. In this case an aggregated `vme` binary is used and -CPLD component can be specified arbitrary. - -- Example: -```bash -root@sonic:/home/admin# show platform firmware -Chassis Module Component Version Description ----------------------- -------- ----------- ----------------------- ---------------------------------------- -x86_64-mlnx_msn3800-r0 N/A BIOS 0ACLH004_02.02.007_9600 BIOS - Basic Input/Output System - CPLD1 CPLD000000_REV0400 CPLD - Complex Programmable Logic Device - CPLD2 CPLD000000_REV0300 CPLD - Complex Programmable Logic Device - CPLD3 CPLD000000_REV0300 CPLD - Complex Programmable Logic Device - CPLD4 CPLD000000_REV0100 CPLD - Complex Programmable Logic Device - -root@sonic:/home/admin# BURN_VME="$(pwd)/FUI000091_Burn_SN3800_CPLD000120_REV0600_CPLD000165_REV0400_CPLD000166_REV0300_CPLD000167_REV0100.vme" -root@sonic:/home/admin# REFRESH_VME="$(pwd)/FUI000091_Refresh_SN3800_CPLD000120_REV0600_CPLD000165_REV0400_CPLD000166_REV0300_CPLD000167_REV0100.vme" - -root@sonic:/home/admin# config platform firmware install chassis component CPLD1 fw -y ${BURN_VME} -root@sonic:/home/admin# config platform firmware install chassis component CPLD1 fw -y ${REFRESH_VME} - -root@sonic:/home/admin# show platform firmware -Chassis Module Component Version Description ----------------------- -------- ----------- ----------------------- ---------------------------------------- -x86_64-mlnx_msn3800-r0 N/A BIOS 0ACLH004_02.02.007_9600 BIOS - Basic Input/Output System - CPLD1 CPLD000000_REV0600 CPLD - Complex Programmable Logic Device - CPLD2 CPLD000000_REV0400 CPLD - Complex Programmable Logic Device - CPLD3 CPLD000000_REV0300 CPLD - Complex Programmable Logic Device - CPLD4 CPLD000000_REV0100 CPLD - Complex Programmable Logic Device -``` - -Note: the update will have the same effect if any of CPLD1/CPLD2/CPLD3/CPLD4 will be used - -Go Back To [Beginning of the document](#) or [Beginning of this section](#platform-component-firmware) - - -## 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** - -This command shows the SDK sniffer status - -- Usage: - ``` - show platform mlnx sniffer - ``` - -- Example: - ``` - admin@sonic:~$ show platform mlnx sniffer - sdk sniffer is disabled - ``` - -**show platform mlnx sniffer** - -Another show command available on ‘show platform mlnx’ which is the issu status. -This means if ISSU is enabled on this SKU or not. A warm boot command can be executed only when ISSU is enabled on the SKU. - -- Usage: - ``` - show platform mlnx issu - ``` - -- Example: - ``` - admin@sonic:~$ show platform mlnx issu - ISSU is enabled - ``` - -In the case ISSU is disabled and warm-boot is called, the user will get a notification message explaining that the command cannot be invoked. - -- Example: - ``` - admin@sonic:~$ sudo warm-reboot - ISSU is not enabled on this HWSKU - Warm reboot is not supported - ``` - -**config platform mlnx** - -This command is valid only on mellanox devices. The sub-commands for "config platform" gets populated only on mellanox platforms. -There are no other subcommands on non-Mellanox devices and hence this command appears empty and useless in other platforms. -The platform mellanox command currently includes a single sub command which is the SDK sniffer. -The SDK sniffer is a troubleshooting tool which records the RPC calls from the Mellanox SDK user API library to the sx_sdk task into a .pcap file. -This .pcap file can be replayed afterward to get the exact same configuration state on SDK and FW to reproduce and investigate issues. - -A new folder will be created to store the sniffer files: "/var/log/mellanox/sniffer/". The result file will be stored in a .pcap file, which includes a time stamp of the starting time in the file name, for example, "sx_sdk_sniffer_20180224081306.pcap" -In order to have a complete .pcap file with all the RPC calls, the user should disable the SDK sniffer. Swss service will be restarted and no capturing is taken place from that moment. -It is recommended to review the .pcap file while sniffing is disabled. -Once SDK sniffer is enabled/disabled, the user is requested to approve that swss service will be restarted. -For example: To change SDK sniffer status, swss service will be restarted, continue? [y/N]: -In order to avoid that confirmation the -y / --yes option should be used. - -- Usage: - ``` - config platform mlnx sniffer sdk [-y|--yes] - ``` - -- Example: - ``` - admin@sonic:~$ config platform mlnx sniffer sdk - To change SDK sniffer status, swss service will be restarted, continue? [y/N]: y - 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) - - -## PortChannels - -### PortChannel Show commands - -**show interfaces portchannel** - -This command displays all the port channels that are configured in the device and its current status. - -- Usage: - ``` - show interfaces portchannel - ``` - -- Example: - ``` - admin@sonic:~$ show interfaces portchannel - Flags: A - active, I - inactive, Up - up, Dw - Down, N/A - not available, S - selected, D - deselected - No. Team Dev Protocol Ports - ----- ------------- ----------- --------------------------- - 24 PortChannel24 LACP(A)(Up) Ethernet28(S) Ethernet24(S) - 48 PortChannel48 LACP(A)(Up) Ethernet52(S) Ethernet48(S) - 40 PortChannel40 LACP(A)(Up) Ethernet44(S) Ethernet40(S) - 0 PortChannel0 LACP(A)(Up) Ethernet0(S) Ethernet4(S) - 8 PortChannel8 LACP(A)(Up) Ethernet8(S) Ethernet12(S) - ``` - - -### PortChannel Config commands - -This sub-section explains how to configure the portchannel and its member ports. - -**config portchannel** - -This command is used to add or delete the portchannel. -It is recommended to use portchannel names in the format "PortChannelxxxx", where "xxxx" is number of 1 to 4 digits. Ex: "PortChannel0002". - -NOTE: If users specify any other name like "pc99", command will succeed, but such names are not supported. Such names are not printed properly in the "show interface portchannel" command. It is recommended not to use such names. - -When any port is already member of any other portchannel and if user tries to add the same port in some other portchannel (without deleting it from the current portchannel), the command fails internally. But, it does not print any error message. In such cases, remove the member from current portchannel and then add it to new portchannel. - -Command takes two optional arguements given below. -1) min-links - minimum number of links required to bring up the portchannel -2) fallback - true/false. LACP fallback feature can be enabled / disabled. When it is set to true, only one member port will be selected as active per portchannel during fallback mode. Refer https://github.com/Azure/SONiC/blob/master/doc/lag/LACP%20Fallback%20Feature%20for%20SONiC_v0.5.md for more details about fallback feature. - -A port channel can be deleted only if it does not have any members or the members are already deleted. When a user tries to delete a port channel and the port channel still has one or more members that exist, the deletion of port channel is blocked. - -- Usage: - ``` - config portchannel (add | del) [--min-links ] [--fallback (true | false)] - ``` - -- Example (Create the portchannel with name "PortChannel0011"): - ``` - admin@sonic:~$ sudo config portchannel add PortChannel0011 - ``` - -**config portchannel member** - -This command adds or deletes a member port to/from the already created portchannel. - -- Usage: - ``` - config portchannel member (add | del) - ``` - -- Example (Add interface Ethernet4 as member of the portchannel "PortChannel0011"): - ``` - admin@sonic:~$ sudo config portchannel member add PortChannel0011 Ethernet4 - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#portchannels) - -## NVGRE - -This section explains the various show commands and configuration commands available for users. - -### NVGRE show commands - -This subsection explains how to display the NVGRE configuration. - -**show nvgre-tunnel** - -This command displays the NVGRE tunnel configuration. - -- Usage: -```bash -show nvgre-tunnel -``` - -- Example: -```bash -admin@sonic:~$ show nvgre-tunnel -TUNNEL NAME SRC IP -------------- -------- -tunnel_1 10.0.0.1 -``` - -**show nvgre-tunnel-map** - -This command displays the NVGRE tunnel map configuration. - -- Usage: -```bash -show nvgre-tunnel-map -``` - -- Example: -```bash -admin@sonic:~$ show nvgre-tunnel-map -TUNNEL NAME TUNNEL MAP NAME VLAN ID VSID -------------- ----------------- --------- ------ -tunnel_1 Vlan1000 1000 5000 -tunnel_1 Vlan2000 2000 6000 -``` - -### NVGRE config commands - -This subsection explains how to configure the NVGRE. - -**config nvgre-tunnel** - -This command is used to manage the NVGRE tunnel objects. -It supports add/delete operations. - -- Usage: -```bash -config nvgre-tunnel add --src-ip -config nvgre-tunnel delete -``` - -- Parameters: - - _tunnel-name_: the name of the NVGRE tunnel - - _src-ip_: source ip address - -- Examples: -```bash -config nvgre-tunnel add 'tunnel_1' --src-ip '10.0.0.1' -config nvgre-tunnel delete 'tunnel_1' -``` - -**config nvgre-tunnel-map** - -This command is used to manage the NVGRE tunnel map objects. -It supports add/delete operations. - -- Usage: -```bash -config nvgre-tunnel-map add --vlan-id --vsid -config nvgre-tunnel-map delete -``` - -- Parameters: - - _tunnel-name_: the name of the NVGRE tunnel - - _tunnel-map-name_: the name of the NVGRE tunnel map - - _vlan-id_: VLAN identifier - - _vsid_: Virtual Subnet Identifier - -- Examples: -```bash -config nvgre-tunnel-map add 'tunnel_1' 'Vlan2000' --vlan-id '2000' --vsid '6000' -config nvgre-tunnel-map delete 'tunnel_1' 'Vlan2000' -``` - -## PBH - -This section explains the various show commands and configuration commands available for users. - -### PBH show commands - -This subsection explains how to display PBH configuration and statistics. - -**show pbh table** - -This command displays PBH table configuration. - -- Usage: -```bash -show pbh table -``` - -- Example: -```bash -admin@sonic:~$ show pbh table -NAME INTERFACE DESCRIPTION ---------- --------------- --------------- -pbh_table Ethernet0 NVGRE and VxLAN - Ethernet4 - PortChannel0001 - PortChannel0002 -``` - -**show pbh rule** - -This command displays PBH rule configuration. - -- Usage: -```bash -show pbh rule -``` - -- Example: -```bash -admin@sonic:~$ show pbh rule -TABLE RULE PRIORITY MATCH HASH ACTION COUNTER ---------- ------ ---------- ------------------------------------ ------------- ------------- --------- -pbh_table nvgre 2 ether_type: 0x0800 inner_v6_hash SET_ECMP_HASH DISABLED - ip_protocol: 0x2f - gre_key: 0x2500/0xffffff00 - inner_ether_type: 0x86dd -pbh_table vxlan 1 ether_type: 0x0800 inner_v4_hash SET_LAG_HASH ENABLED - ip_protocol: 0x11 - l4_dst_port: 0x12b5 - inner_ether_type: 0x0800 -``` - -**show pbh hash** - -This command displays PBH hash configuration. - -- Usage: -```bash -show pbh hash -``` - -- Example: -```bash -admin@sonic:~$ show pbh hash -NAME HASH FIELD -------------- ----------------- -inner_v4_hash inner_ip_proto - inner_l4_dst_port - inner_l4_src_port - inner_dst_ipv4 - inner_src_ipv4 -inner_v6_hash inner_ip_proto - inner_l4_dst_port - inner_l4_src_port - inner_dst_ipv6 - inner_src_ipv6 -``` - -**show pbh hash-field** - -This command displays PBH hash field configuration. - -- Usage: -```bash -show pbh hash-field -``` - -- Example: -```bash -admin@sonic:~$ show pbh hash-field -NAME FIELD MASK SEQUENCE SYMMETRIC ------------------ ----------------- --------- ---------- ----------- -inner_ip_proto INNER_IP_PROTOCOL N/A 1 No -inner_l4_dst_port INNER_L4_DST_PORT N/A 2 Yes -inner_l4_src_port INNER_L4_SRC_PORT N/A 2 Yes -inner_dst_ipv4 INNER_DST_IPV4 255.0.0.0 3 Yes -inner_src_ipv4 INNER_SRC_IPV4 0.0.0.255 3 Yes -inner_dst_ipv6 INNER_DST_IPV6 ffff:: 4 Yes -inner_src_ipv6 INNER_SRC_IPV6 ::ffff 4 Yes -``` - -- Note: - - _SYMMETRIC_ is an artificial column and is only used to indicate fields symmetry - -**show pbh statistics** - -This command displays PBH statistics. - -- Usage: -```bash -show pbh statistics -``` - -- Example: -```bash -admin@sonic:~$ show pbh statistics -TABLE RULE RX PACKETS COUNT RX BYTES COUNT ---------- ------ ------------------ ---------------- -pbh_table nvgre 0 0 -pbh_table vxlan 0 0 -``` - -- Note: - - _RX PACKETS COUNT_ and _RX BYTES COUNT_ can be cleared by user: - ```bash - admin@sonic:~$ sonic-clear pbh statistics - ``` - -### PBH config commands - -This subsection explains how to configure PBH. - -**config pbh table** - -This command is used to manage PBH table objects. -It supports add/update/remove operations. - -- Usage: -```bash -config pbh table add --interface-list --description -config pbh table update [ --interface-list ] [ --description ] -config pbh table delete -``` - -- Parameters: - - _table_name_: the name of the PBH table - - _interface_list_: interfaces to which PBH table is applied - - _description_: the description of the PBH table - -- Examples: -```bash -config pbh table add 'pbh_table' \ ---interface-list 'Ethernet0,Ethernet4,PortChannel0001,PortChannel0002' \ ---description 'NVGRE and VxLAN' -config pbh table update 'pbh_table' \ ---interface-list 'Ethernet0' -config pbh table delete 'pbh_table' -``` - -**config pbh rule** - -This command is used to manage PBH rule objects. -It supports add/update/remove operations. - -- Usage: -```bash -config pbh rule add --priority \ -[ --gre-key ] [ --ether-type ] [ --ip-protocol ] \ -[ --ipv6-next-header ] [ --l4-dst-port ] [ --inner-ether-type ] \ ---hash [ --packet-action ] [ --flow-counter ] -config pbh rule update [ --priority ] \ -[ --gre-key ] [ --ether-type ] [ --ip-protocol ] \ -[ --ipv6-next-header ] [ --l4-dst-port ] [ --inner-ether-type ] \ -[ --hash ] [ --packet-action ] [ --flow-counter ] -config pbh rule delete -``` - -- Parameters: - - _table_name_: the name of the PBH table - - _rule_name_: the name of the PBH rule - - _priority_: the priority of the PBH rule - - _gre_key_: packet match for the PBH rule: GRE key (value/mask) - - _ether_type_: packet match for the PBH rule: EtherType (IANA Ethertypes) - - _ip_protocol_: packet match for the PBH rule: IP protocol (IANA Protocol Numbers) - - _ipv6_next_header_: packet match for the PBH rule: IPv6 Next header (IANA Protocol Numbers) - - _l4_dst_port_: packet match for the PBH rule: L4 destination port - - _inner_ether_type_: packet match for the PBH rule: inner EtherType (IANA Ethertypes) - - _hash_: _hash_ object to apply with the PBH rule - - _packet_action_: packet action for the PBH rule - - Valid values: - - SET_ECMP_HASH - - SET_LAG_HASH - - Default: - - SET_ECMP_HASH - - - _flow_counter_: packet/byte counter for the PBH rule - - Valid values: - - DISABLED - - ENABLED - - Default: - - DISABLED - -- Examples: -```bash -config pbh rule add 'pbh_table' 'nvgre' \ ---priority '2' \ ---ether-type '0x0800' \ ---ip-protocol '0x2f' \ ---gre-key '0x2500/0xffffff00' \ ---inner-ether-type '0x86dd' \ ---hash 'inner_v6_hash' \ ---packet-action 'SET_ECMP_HASH' \ ---flow-counter 'DISABLED' -config pbh rule update 'pbh_table' 'nvgre' \ ---flow-counter 'ENABLED' -config pbh rule delete 'pbh_table' 'nvgre' -``` - -**config pbh hash** - -This command is used to manage PBH hash objects. -It supports add/update/remove operations. - -- Usage: -```bash -config pbh hash add --hash-field-list -config pbh hash update [ --hash-field-list ] -config pbh hash delete -``` - -- Parameters: - - _hash_name_: the name of the PBH hash - - _hash_field_list_: list of _hash-field_ objects to apply with the PBH hash - -- Examples: -```bash -config pbh hash add 'inner_v6_hash' \ ---hash-field-list 'inner_ip_proto,inner_l4_dst_port,inner_l4_src_port,inner_dst_ipv6,inner_src_ipv6' -config pbh hash update 'inner_v6_hash' \ ---hash-field-list 'inner_ip_proto' -config pbh hash delete 'inner_v6_hash' -``` - -**config pbh hash-field** - -This command is used to manage PBH hash field objects. -It supports add/update/remove operations. - -- Usage: -```bash -config pbh hash-field add \ ---hash-field [ --ip-mask ] --sequence-id -config pbh hash-field update \ -[ --hash-field ] [ --ip-mask ] [ --sequence-id ] -config pbh hash-field delete -``` - -- Parameters: - - _hash_field_name_: the name of the PBH hash field - - _hash_field_: native hash field for the PBH hash field - - Valid values: - - INNER_IP_PROTOCOL - - INNER_L4_DST_PORT - - INNER_L4_SRC_PORT - - INNER_DST_IPV4 - - INNER_SRC_IPV4 - - INNER_DST_IPV6 - - INNER_SRC_IPV6 - - - _ip_mask_: IPv4/IPv6 address mask for the PBH hash field - - Valid only: _hash_field_ is: - - INNER_DST_IPV4 - - INNER_SRC_IPV4 - - INNER_DST_IPV6 - - INNER_SRC_IPV6 - - - _sequence_id_: the order in which fields are hashed - -- Examples: -```bash -config pbh hash-field add 'inner_dst_ipv6' \ ---hash-field 'INNER_DST_IPV6' \ ---ip-mask 'ffff::' \ ---sequence-id '4' -config pbh hash-field update 'inner_dst_ipv6' \ ---ip-mask 'ffff:ffff::' -config pbh hash-field delete 'inner_dst_ipv6' -``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#pbh) - -## QoS - -### QoS Show commands - -#### PFC - -**show pfc counters** - -This command displays the details of Rx & Tx priority-flow-control (pfc) for all ports. This command can be used to clear the counters using -c option. - -- Usage: - ``` - show pfc counters - ``` - -- Example: - ``` - admin@sonic:~$ show pfc counters - Port Rx PFC0 PFC1 PFC2 PFC3 PFC4 PFC5 PFC6 PFC7 - ----------- ------ ------ ------ ------ ------ ------ ------ ------ - Ethernet0 0 0 0 0 0 0 0 0 - Ethernet4 0 0 0 0 0 0 0 0 - Ethernet8 0 0 0 0 0 0 0 0 - Ethernet12 0 0 0 0 0 0 0 0 - - Port Tx PFC0 PFC1 PFC2 PFC3 PFC4 PFC5 PFC6 PFC7 - ----------- ------ ------ ------ ------ ------ ------ ------ ------ - Ethernet0 0 0 0 0 0 0 0 0 - Ethernet4 0 0 0 0 0 0 0 0 - Ethernet8 0 0 0 0 0 0 0 0 - Ethernet12 0 0 0 0 0 0 0 0 - - ... - ``` - - -- NOTE: PFC counters can be cleared by the user with the following command: - ``` - admin@sonic:~$ sonic-clear pfccounters - ``` - -**show pfc asymmetric** - -This command displays the status of asymmetric PFC for all interfaces or a given interface. - -- Usage: - ``` - show pfc asymmetric [] - ``` - -- Example: - ``` - admin@sonic:~$ show pfc asymmetric - - Interface Asymmetric - ----------- ------------ - Ethernet0 off - Ethernet2 off - Ethernet4 off - Ethernet6 off - Ethernet8 off - Ethernet10 off - Ethernet12 off - Ethernet14 off - - admin@sonic:~$ show pfc asymmetric Ethernet0 - - Interface Asymmetric - ----------- ------------ - Ethernet0 off - ``` - -**show pfc priority** - -This command displays the lossless priorities for all interfaces or a given interface. - -- Usage: - ``` - show pfc priority [] - ``` - -- Example: - ``` - admin@sonic:~$ show pfc priority - - Interface Lossless priorities - ----------- --------------------- - Ethernet0 3,4 - Ethernet2 3,4 - Ethernet8 3,4 - Ethernet10 3,4 - Ethernet16 3,4 - - admin@sonic:~$ show pfc priority Ethernet0 - - Interface Lossless priorities - ----------- --------------------- - Ethernet0 3,4 - ``` - -#### Queue And Priority-Group - -This sub-section explains the following queue parameters that can be displayed using "show queue" command. -1) queue counters -2) queue watermark -3) priority-group watermark -4) queue persistent-watermark - - -**show queue counters** - -This command displays packet and byte counters for all queues of all ports or one specific-port given as arguement. -This command can be used to clear the counters for all queues of all ports. Note that port specific clear is not supported. - -- Usage: - ``` - show queue counters [] - ``` - -- Example: - ``` - admin@sonic:~$ show queue counters - Port TxQ Counter/pkts Counter/bytes Drop/pkts Drop/bytes - --------- ----- -------------- --------------- ----------- ------------ - Ethernet0 UC0 0 0 0 0 - Ethernet0 UC1 0 0 0 0 - Ethernet0 UC2 0 0 0 0 - Ethernet0 UC3 0 0 0 0 - Ethernet0 UC4 0 0 0 0 - Ethernet0 UC5 0 0 0 0 - Ethernet0 UC6 0 0 0 0 - Ethernet0 UC7 0 0 0 0 - Ethernet0 UC8 0 0 0 0 - Ethernet0 UC9 0 0 0 0 - Ethernet0 MC0 0 0 0 0 - Ethernet0 MC1 0 0 0 0 - Ethernet0 MC2 0 0 0 0 - Ethernet0 MC3 0 0 0 0 - Ethernet0 MC4 0 0 0 0 - Ethernet0 MC5 0 0 0 0 - Ethernet0 MC6 0 0 0 0 - Ethernet0 MC7 0 0 0 0 - Ethernet0 MC8 0 0 0 0 - Ethernet0 MC9 0 0 0 0 - - Port TxQ Counter/pkts Counter/bytes Drop/pkts Drop/bytes - --------- ----- -------------- --------------- ----------- ------------ - Ethernet4 UC0 0 0 0 0 - Ethernet4 UC1 0 0 0 0 - Ethernet4 UC2 0 0 0 0 - Ethernet4 UC3 0 0 0 0 - Ethernet4 UC4 0 0 0 0 - Ethernet4 UC5 0 0 0 0 - Ethernet4 UC6 0 0 0 0 - Ethernet4 UC7 0 0 0 0 - Ethernet4 UC8 0 0 0 0 - Ethernet4 UC9 0 0 0 0 - Ethernet4 MC0 0 0 0 0 - Ethernet4 MC1 0 0 0 0 - Ethernet4 MC2 0 0 0 0 - Ethernet4 MC3 0 0 0 0 - Ethernet4 MC4 0 0 0 0 - Ethernet4 MC5 0 0 0 0 - Ethernet4 MC6 0 0 0 0 - Ethernet4 MC7 0 0 0 0 - Ethernet4 MC8 0 0 0 0 - Ethernet4 MC9 0 0 0 0 - - ... - ``` - -Optionally, you can specify an interface name in order to display only that particular interface - -- Example: - ``` - admin@sonic:~$ show queue counters Ethernet72 - ``` - -- NOTE: Queue counters can be cleared by the user with the following command: - ``` - admin@sonic:~$ sonic-clear queuecounters - ``` - -**show queue watermark** - -This command displays the user watermark for the queues (Egress shared pool occupancy per queue) for either the unicast queues or multicast queues for all ports - -- Usage: - ``` - show queue watermark (multicast | unicast) - ``` - -- Example: - ``` - admin@sonic:~$ show queue watermark unicast - Egress shared pool occupancy per unicast queue: - Port UC0 UC1 UC2 UC3 UC4 UC5 UC6 UC7 - ----------- ----- ----- ----- ----- ----- ----- ----- ----- - Ethernet0 0 0 0 0 0 0 0 0 - Ethernet4 0 0 0 0 0 0 0 0 - Ethernet8 0 0 0 0 0 0 0 0 - Ethernet12 0 0 0 0 0 0 0 0 - - admin@sonic:~$ show queue watermark multicast (Egress shared pool occupancy per multicast queue) - ``` - -**show priority-group** - -This command displays: -1) The user watermark or persistent-watermark for the Ingress "headroom" or "shared pool occupancy" per priority-group for all ports. -2) Dropped packets per priority-group for all ports - -- Usage: - ``` - show priority-group (watermark | persistent-watermark) (headroom | shared) - show priority-group drop counters - ``` - -- Example: - ``` - admin@sonic:~$ show priority-group watermark shared - Ingress shared pool occupancy per PG: - Port PG0 PG1 PG2 PG3 PG4 PG5 PG6 PG7 - ----------- ----- ----- ----- ----- ----- ----- ----- ----- - Ethernet0 0 0 0 0 0 0 0 0 - Ethernet4 0 0 0 0 0 0 0 0 - Ethernet8 0 0 0 0 0 0 0 0 - Ethernet12 0 0 0 0 0 0 0 0 - ``` - -- Example (Ingress headroom per PG): - ``` - admin@sonic:~$ show priority-group watermark headroom - ``` - -- Example (Ingress shared pool occupancy per PG): - ``` - admin@sonic:~$ show priority-group persistent-watermark shared - ``` - -- Example (Ingress headroom per PG): - ``` - admin@sonic:~$ show priority-group persistent-watermark headroom - ``` - -- Example (Ingress dropped packets per PG): - ``` - admin@sonic:~$ show priority-group drop counters - Ingress PG dropped packets: - Port PG0 PG1 PG2 PG3 PG4 PG5 PG6 PG7 - ----------- ----- ----- ----- ----- ----- ----- ----- ----- - Ethernet0 0 0 0 0 0 0 0 0 - Ethernet4 0 0 0 0 0 0 0 0 - Ethernet8 0 0 0 0 0 0 0 0 - Ethernet12 0 0 0 0 0 0 0 0 - ``` - -In addition to user watermark("show queue|priority-group watermark ..."), a persistent watermark is available. -It hold values independently of user watermark. This way user can use "user watermark" for debugging, clear it, etc, but the "persistent watermark" will not be affected. - -**show queue persistent-watermark** - -This command displays the user persistet-watermark for the queues (Egress shared pool occupancy per queue) for either the unicast queues or multicast queues for all ports - -- Usage: - ``` - show queue persistent-watermark (unicast | multicast) - ``` - -- Example: - ``` - admin@sonic:~$ show queue persistent-watermark unicast - Egress shared pool occupancy per unicast queue: - Port UC0 UC1 UC2 UC3 UC4 UC5 UC6 UC7 - ----------- ----- ----- ----- ----- ----- ----- ----- ----- - Ethernet0 N/A N/A N/A N/A N/A N/A N/A N/A - Ethernet4 N/A N/A N/A N/A N/A N/A N/A N/A - Ethernet8 N/A N/A N/A N/A N/A N/A N/A N/A - Ethernet12 N/A N/A N/A N/A N/A N/A N/A N/A - ``` - -- Example (Egress shared pool occupancy per multicast queue): - ``` - admin@sonic:~$ show queue persistent-watermark multicast - ``` - -- NOTE: "user watermark", "persistent watermark" and "ingress dropped packets" can be cleared by user: - - ``` - admin@sonic:~$ sonic-clear queue persistent-watermark unicast - - admin@sonic:~$ sonic-clear queue persistent-watermark multicast - - admin@sonic:~$ sonic-clear priority-group persistent-watermark shared - - admin@sonic:~$ sonic-clear priority-group persistent-watermark headroom - - admin@sonic:~$ sonic-clear priority-group drop counters - ``` - -#### Buffer Pool - -This sub-section explains the following buffer pool parameters that can be displayed using "show buffer_pool" command. -1) buffer pool watermark -2) buffer pool persistent-watermark - -**show buffer_pool watermark** - -This command displays the user watermark for all the buffer pools - -- Usage: - ``` - show buffer_pool watermark - ``` - -- Example: - ``` - admin@sonic:~$ show buffer_pool watermark - Shared pool maximum occupancy: - Pool Bytes - --------------------- ------- - ingress_lossless_pool 0 - lossy_pool 2464 - ``` - - -**show buffer_pool persistent-watermark** - -This command displays the user persistent-watermark for all the buffer pools - -- Usage: - ``` - show buffer_pool persistent-watermark - ``` - -- Example: - ``` - admin@sonic:~$ show buffer_pool persistent-watermark - Shared pool maximum occupancy: - Pool Bytes - --------------------- ------- - ingress_lossless_pool 0 - lossy_pool 2464 - ``` - - - -### QoS config commands - -**config qos clear** - -This command is used to clear all the QoS configuration from all the following QOS Tables in ConfigDB. - -1) TC_TO_PRIORITY_GROUP_MAP, -2) MAP_PFC_PRIORITY_TO_QUEUE, -3) TC_TO_QUEUE_MAP, -4) DSCP_TO_TC_MAP, -5) MPLS_TC_TO_TC_MAP, -6) SCHEDULER, -7) PFC_PRIORITY_TO_PRIORITY_GROUP_MAP, -8) PORT_QOS_MAP, -9) WRED_PROFILE, -10) QUEUE, -11) CABLE_LENGTH, -12) BUFFER_POOL, -13) BUFFER_PROFILE, -14) BUFFER_PG, -15) BUFFER_QUEUE - -- Usage: - ``` - config qos clear - ``` - -- Example: - ``` - admin@sonic:~$ sudo config qos clear - ``` - -**config qos reload** - -This command is used to reload the QoS configuration. -QoS configuration has got two sets of configurations. -1) Generic QOS Configuration - This gives complete list of all possible QOS configuration. Its given in the file /usr/share/sonic/templates/qos_config.j2 in the device. - Reference: https://github.com/Azure/sonic-buildimage/blob/master/files/build_templates/qos_config.j2 - Users have flexibility to have platform specific qos configuration by placing the qos_config.j2 file at /usr/share/sonic/device///. - If users want to modify any of this loaded QOS configuration, they can modify this file in the device and then issue the "config qos reload" command. - -2) Platform specific buffer configuration. Every platform has got platform specific and topology specific (T0 or T1 or T2) buffer configuration at /usr/share/sonic/device///buffers_defaults_tx.j2 - In addition to platform specific configuration file, a generic configuration file is also present at /usr/share/sonic/templates/buffers_config.j2. - Reference: https://github.com/Azure/sonic-buildimage/blob/master/files/build_templates/buffers_config.j2 - Users can either modify the platform specific configuration file, or the generic configuration file and then issue this "config qos reload" command. - -These configuration files are already loaded in the device as part of the reboot process. In case if users wants to modify any of these configurations, they need to modify the appropriate QOS tables and fields in these files and then use this reload command. -This command uses those modified buffers.json.j2 file & qos.json.j2 file and reloads the new QOS configuration. -If users have not made any changes in these configuration files, this command need not be executed. - -Some of the example QOS configurations that users can modify are given below. -1) TC_TO_PRIORITY_GROUP_MAP -2) MAP_PFC_PRIORITY_TO_QUEUE -3) TC_TO_QUEUE_MAP -4) DSCP_TO_TC_MAP -5) MPLS_TC_TO_TC_MAP -6) SCHEDULER -7) PFC_PRIORITY_TO_PRIORITY_GROUP_MAP -8) PORT_QOS_MAP -9) WRED_PROFILE -10) CABLE_LENGTH -11) BUFFER_QUEUE - -- Usage: - ``` - config qos reload - ``` - -- Example: - ``` - admin@sonic:~$ sudo config qos reload - Running command: /usr/local/bin/sonic-cfggen -d -t /usr/share/sonic/device/x86_64-dell_z9100_c2538-r0/Force10-Z9100-C32/buffers.json.j2 >/tmp/buffers.json - Running command: /usr/local/bin/sonic-cfggen -d -t /usr/share/sonic/device/x86_64-dell_z9100_c2538-r0/Force10-Z9100-C32/qos.json.j2 -y /etc/sonic/sonic_version.yml >/tmp/qos.json - Running command: /usr/local/bin/sonic-cfggen -j /tmp/buffers.json --write-to-db - Running command: /usr/local/bin/sonic-cfggen -j /tmp/qos.json --write-to-db - - In this example, it uses the buffers.json.j2 file and qos.json.j2 file from platform specific folders. - When there are no changes in the platform specific configutation files, they internally use the file "/usr/share/sonic/templates/buffers_config.j2" and "/usr/share/sonic/templates/qos_config.j2" to generate the configuration. - ``` - -**config qos reload --ports port_list** - -This command is used to reload the default QoS configuration on a group of ports. -Typically, the default QoS configuration is in the following tables. -1) PORT_QOS_MAP -2) QUEUE -3) BUFFER_PG -4) BUFFER_QUEUE -5) BUFFER_PORT_INGRESS_PROFILE_LIST -6) BUFFER_PORT_EGRESS_PROFILE_LIST -7) CABLE_LENGTH - -If there was QoS configuration in the above tables for the ports: - - - if `--force` option is provied, the existing QoS configuration will be replaced by the default QoS configuration, - - otherwise, the command will exit with nothing updated. - -- Usage: - ``` - config qos reload --ports [,port] - ``` - -- Example: - ``` - admin@sonic:~$ sudo config qos reload --ports Ethernet0,Ethernet4 - - In this example, it updates the QoS configuration on port Ethernet0 and Ethernet4 to default. - If there was QoS configuration on the ports, the command will clear the existing QoS configuration on the port and reload to default. - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#qos) - -## sFlow - -### sFlow Show commands - -**show sflow** - -This command displays the global sFlow configuration that includes the admin state, collectors, the Agent ID and counter polling interval. - -- Usage: - ``` - show sflow - ``` - -- Example: - ``` - admin@sonic:~# show sflow - sFlow Global Information: - sFlow Admin State: up - sFlow Polling Interval: default - sFlow AgentID: lo - - 2 Collectors configured: - Name: collector_A IP addr: 10.11.46.2 UDP port: 6343 - Name: collector_lo IP addr: 127.0.0.1 UDP port: 6343 - ``` - - -**show sflow interface** - -This command displays the per-interface sflow admin status and the sampling rate. - -- Usage: - ``` - show sflow interface - ``` - -- Example: - ``` - admin@sonic:~# show sflow interface - - sFlow interface configurations - +-------------+---------------+-----------------+ - | Interface | Admin State | Sampling Rate | - +=============+===============+=================+ - | Ethernet0 | up | 4000 | - +-------------+---------------+-----------------+ - | Ethernet1 | up | 4000 | - +-------------+---------------+-----------------+ - ... - +-------------+---------------+-----------------+ - | Ethernet61 | up | 4000 | - +-------------+---------------+-----------------+ - | Ethernet62 | up | 4000 | - +-------------+---------------+-----------------+ - | Ethernet63 | up | 4000 | - +-------------+---------------+-----------------+ - - ``` - -### sFlow Config commands - -**config sflow collector add** - -This command is used to add a sFlow collector. Note that a maximum of 2 collectors is allowed. - -- Usage: - ``` - config sflow collector add [port ] - ``` - - - Parameters: - - collector-name: unique name of the sFlow collector - - ipv4-address : IP address of the collector in dotted decimal format for IPv4 - - ipv6-address : x: x: x: x::x format for IPv6 address of the collector (where :: notation specifies successive hexadecimal fields of zeros) - - port (OPTIONAL): specifies the UDP port of the collector (the range is from 0 to 65535. The default is 6343.) - -- Example: - ``` - admin@sonic:~# sudo config sflow collector add collector_A 10.11.46.2 - ``` - -**config sflow collector del** - -This command is used to delete a sFlow collector with the given name. - -- Usage: - ``` - config sflow collector del - ``` - - - Parameters: - - collector-name: unique name of the sFlow collector - -- Example: - ``` - admin@sonic:~# sudo config sflow collector del collector_A - ``` - -**config sflow agent-id** - -This command is used to add/delete the sFlow agent-id. This setting is global (applicable to both collectors) and optional. Only a single agent-id is allowed. If agent-id is not specified (with this CLI), an appropriate IP that belongs to the switch is used as the agent-id based on some simple heuristics. - -- Usage: - ``` - config sflow agent-id - ``` - - - Parameters: - - interface-name: specify the interface name whose ipv4 or ipv6 address will be used as the agent-id in sFlow datagrams. - -- Example: - ``` - admin@sonic:~# sudo config sflow agent-id add lo - ``` - -**config sflow** - -Globally, sFlow is disabled by default. When sFlow is enabled globally, the sflow deamon is started and sampling will start on all interfaces which have sFlow enabled at the interface level (see “config sflow interface…”). When sflow is disabled globally, sampling is stopped on all relevant interfaces and sflow daemon is stopped. - -- Usage: - ``` - config sflow - ``` -- Example: - ``` - admin@sonic:~# sudo config sflow enable - ``` -**config sflow interface** - -Enable/disable sflow at an interface level. By default, sflow is enabled on all interfaces at the interface level. Use this command to explicitly disable sFlow for a specific interface. An interface is sampled if sflow is enabled globally as well as at the interface level. Note that this configuration deals only with sFlow flow samples and not counter samples. - -- Usage: - ``` - config sflow interface - ``` - - - Parameters: - - interface-name: specify the interface for which sFlow flow samples have to be enabled/disabled. The “all” keyword is used as a convenience to enable/disable sflow at the interface level for all the interfaces. - -- Example: - ``` - admin@sonic:~# sudo config sflow interface disable Ethernet40 - ``` - -**config sflow interface sample-rate** - -Configure the sample-rate for a specific interface. - -The default sample rate for any interface is (ifSpeed / 1e6) where ifSpeed is in bits/sec. So, the default sample rate based on interface speed is: - - 1-in-1000 for a 1G link - 1-in-10,000 for a 10G link - 1-in-40,000 for a 40G link - 1-in-50,000 for a 50G link - 1-in-100,000 for a 100G link - -It is recommended not to change the defaults. This CLI is to be used only in case of exceptions (e.g., to set the sample-rate to the nearest power-of-2 if there are hardware restrictions in using the defaults) - -- Usage: - ``` - config sflow interface sample-rate - ``` - - - Parameters: - - interface-name: specify the interface for which the sampling rate value is to be set - - value: value is the average number of packets skipped before the sample is taken. "The sampling rate specifies random sampling probability as the ratio of packets observed to samples generated. For example a sampling rate of 256 specifies that, on average, 1 sample will be generated for every 256 packets observed." Valid range 256:8388608. - -- Example: - ``` - admin@sonic:~# sudo config sflow interface sample-rate Ethernet32 1000 - ``` -**config sflow polling-interval** - -This command is used to set the counter polling interval. Default is 20 seconds. - -- Usage: - ``` - config sflow polling-interval - ``` - - - Parameters: - - value: 0-300 seconds. Set polling-interval to 0 to disable counter polling - -- Example: - ``` - admin@sonic:~# sudo config sflow polling-interval 30 - ``` - - -Go Back To [Beginning of the document](#) or [Beginning of this section](#sflow) - -## SNMP - -### SNMP Show commands - -**show runningconfiguration snmp** - -This command displays the global SNMP configuration that includes the location, contact, community, and user settings. - -- Usage: - ``` - show runningconfiguration snmp - ``` - -- Example: - ``` - admin@sonic:~$ show runningconfiguration snmp - Location - ------------ - Emerald City - - - SNMP_CONTACT SNMP_CONTACT_EMAIL - -------------- -------------------- - joe joe@contoso.com - - - Community String Community Type - ------------------ ---------------- - Jack RW - - - User Permission Type Type Auth Type Auth Password Encryption Type Encryption Password - ------ ----------------- ------ ----------- --------------- ----------------- --------------------- - Travis RO Priv SHA TravisAuthPass AES TravisEncryptPass - ``` - -**show runningconfiguration snmp location** - -This command displays the SNMP location setting. - -- Usage: - ``` - show runningconfiguration snmp location - ``` - -- Example: - ``` - admin@sonic:~$ show runningconfiguration snmp location - Location - ------------ - Emerald City - ``` - -- Usage: - ``` - show runningconfiguration snmp location --json - ``` - -- Example: - ``` - admin@sonic:~$ show runningconfiguration snmp location --json - {'Location': 'Emerald City'} - ``` - -**show runningconfiguration snmp contact** - -This command displays the SNMP contact setting. - -- Usage: - ``` - show runningconfiguration snmp contact - ``` - -- Example: - ``` - admin@sonic:~$ show runningconfiguration snmp contact - Contact Contact Email - --------- --------------- - joe joe@contoso.com - ``` - -- Usage: - ``` - show runningconfiguration snmp contact --json - ``` - -- Example: - ``` - admin@sonic:~$ show runningconfiguration snmp contact --json - {'joe': 'joe@contoso.com'} - ``` - -**show runningconfiguration snmp community** - -This command display the SNMP community settings. - -- Usage: - ``` - show runningconfiguration snmp community - ``` - -- Example: - ``` - admin@sonic:~$ show runningconfiguration snmp community - Community String Community Type - ------------------ ---------------- - Jack RW - ``` - -- Usage: - ``` - show runningconfiguration snmp community --json - ``` - -- Example: - ``` - admin@sonic:~$ show runningconfiguration snmp community --json - {'Jack': {'TYPE': 'RW'}} - ``` - -**show runningconfiguration snmp user** - -This command display the SNMP user settings. - -- Usage: - ``` - show runningconfiguration snmp user - ``` - -- Example: - ``` - admin@sonic:~$ show runningconfiguration snmp user - User Permission Type Type Auth Type Auth Password Encryption Type Encryption Password - ------ ----------------- ------ ----------- --------------- ----------------- --------------------- - Travis RO Priv SHA TravisAuthPass AES TravisEncryptPass - ``` - -- Usage: - ``` - show runningconfiguration snmp user --json - ``` - -- Example: - ``` - admin@sonic:~$ show runningconfiguration snmp user --json - {'Travis': {'SNMP_USER_TYPE': 'Priv', 'SNMP_USER_PERMISSION': 'RO', 'SNMP_USER_AUTH_TYPE': 'SHA', 'SNMP_USER_AUTH_PASSWORD': 'TravisAuthPass', 'SNMP_USER_ENCRYPTION_TYPE': 'AES', 'SNMP_USER_ENCRYPTION_PASSWORD': 'TravisEncryptPass'}} - ``` - - -### SNMP Config commands - -This sub-section explains how to configure SNMP. - -**config snmp location add/del/modify** - -This command is used to add, delete, or modify the SNMP location. - -- Usage: - ``` - config snmp location (add | del | modify) - ``` - -- Example (Add new SNMP location "Emerald City" if it does not already exist): - ``` - admin@sonic:~$ sudo config snmp location add Emerald City - SNMP Location Emerald City has been added to configuration - Restarting SNMP service... - ``` - -- Example (Delete SNMP location "Emerald City" if it already exists): - ``` - admin@sonic:~$ sudo config snmp location del Emerald City - SNMP Location Emerald City removed from configuration - Restarting SNMP service... - ``` - -- Example (Modify SNMP location "Emerald City" to "Redmond"): - ``` - admin@sonic:~$ sudo config snmp location modify Redmond - SNMP location Redmond modified in configuration - Restarting SNMP service... - ``` - -**config snmp contact add/del/modify** - -This command is used to add, delete, or modify the SNMP contact. - -- Usage: - ``` - config snmp contact add - ``` - -- Example: - ``` - admin@sonic:~$ sudo config snmp contact add joe joe@contoso.com - Contact name joe and contact email joe@contoso.com have been added to configuration - Restarting SNMP service... - ``` - -- Usage: - ``` - config snmp contact del - ``` - -- Example: - ``` - admin@sonic:~$ sudo config snmp contact del joe - SNMP contact joe removed from configuration - Restarting SNMP service... - ``` - -- Usage: - ``` - config snmp contact modify - ``` - -- Example: - ``` - admin@sonic:~$ sudo config snmp contact modify test test@contoso.com - SNMP contact test and contact email test@contoso.com updated - Restarting SNMP service... - ``` - -**config snmp community add/del/replace** - -This command is used to add, delete, or replace the SNMP community. - -- Usage: - ``` - config snmp community add (RO | RW) - ``` - -- Example: - ``` - admin@sonic:~$ sudo config snmp community add testcomm ro - SNMP community testcomm added to configuration - Restarting SNMP service... - ``` - -- Usage: - ``` - config snmp community del - ``` - -- Example: - ``` - admin@sonic:~$ sudo config snmp community del testcomm - SNMP community testcomm removed from configuration - Restarting SNMP service... - ``` - -- Usage: - ``` - config snmp community replace - ``` - -- Example: - ``` - admin@sonic:~$ sudo config snmp community replace testcomm newtestcomm - SNMP community newtestcomm added to configuration - SNMP community newtestcomm replace community testcomm - Restarting SNMP service... - ``` - -**config snmp user add/del** - -This command is used to add or delete the SNMP user for SNMPv3. - -- Usage: - ``` - config snmp user add (noAuthNoPriv | AuthNoPriv | Priv) (RO | RW) [[(MD5 | SHA | MMAC-SHA-2) ] [(DES |AES) ]] - ``` - -- Example: - ``` - admin@sonic:~$ sudo config snmp user add testuser1 noauthnopriv ro - SNMP user testuser1 added to configuration - Restarting SNMP service... - ``` - -- Example: - ``` - admin@sonic:~$ sudo config snmp user add testuser2 authnopriv ro sha testuser2_auth_pass - SNMP user testuser2 added to configuration - Restarting SNMP service... - ``` - -- Example: - ``` - admin@sonic:~$ sudo config snmp user add testuser3 priv rw md5 testuser3_auth_pass aes testuser3_encrypt_pass - SNMP user testuser3 added to configuration - Restarting SNMP service... - ``` - -- Usage: - ``` - config snmp user del - ``` - -- Example: - ``` - admin@sonic:~$ sudo config snmp user del testuser1 - SNMP user testuser1 removed from configuration - Restarting SNMP service... - ``` - -## Startup & Running Configuration - -### Startup Configuration - -**show startupconfiguration bgp** - -This command is used to display the startup configuration for the BGP module. - -- Usage: - ``` - show startupconfiguration bgp - ``` - -- Example: - ``` - admin@sonic:~$ show startupconfiguration bgp - Routing-Stack is: quagga - ! - ! =========== Managed by sonic-cfggen DO NOT edit manually! ==================== - ! generated by templates/quagga/bgpd.conf.j2 with config DB data - ! file: bgpd.conf - ! - ! - hostname T1-2 - password zebra - log syslog informational - log facility local4 - ! enable password ! - ! - ! bgp multiple-instance - ! - route-map FROM_BGP_SPEAKER_V4 permit 10 - ! - route-map TO_BGP_SPEAKER_V4 deny 10 - ! - router bgp 65000 - bgp log-neighbor-changes - bgp bestpath as-path multipath-relax - no bgp default ipv4-unicast - bgp graceful-restart restart-time 180 - - - ``` - -### Running Configuration -This sub-section explains the show commands for displaying the running configuration for the following modules. -1) bgp -2) interfaces -3) ntp -4) snmp -5) all -6) acl -7) ports -8) syslog - -**show runningconfiguration all** - -This command displays the entire running configuration. - -- Usage: - ``` - show runningconfiguration all - ``` - -- Example: - ``` - admin@sonic:~$ show runningconfiguration all - ``` - -**show runningconfiguration bgp** - -This command displays the running configuration of the BGP module. - -- Usage: - ``` - show runningconfiguration bgp - ``` - -- Example: - ``` - admin@sonic:~$ show runningconfiguration bgp - ``` - -**show runningconfiguration interfaces** - -This command displays the running configuration for the "interfaces". - -- Usage: - ``` - show runningconfiguration interfaces - ``` - -- Example: - ``` - admin@sonic:~$ show runningconfiguration interfaces - ``` - -**show runningconfiguration ntp** - -This command displays the running configuration of the ntp module. - -- Usage: - ``` - show runningconfiguration ntp - ``` - -- Example: - ``` - admin@sonic:~$ show runningconfiguration ntp - NTP Servers - ------------- - 1.1.1.1 - 2.2.2.2 - ``` - -**show runningconfiguration syslog** - -This command displays the running configuration of the syslog module. - -- Usage: - ``` - show runningconfiguration syslog - ``` - -- Example: - ``` - admin@sonic:~$ show runningconfiguration syslog - Syslog Servers - ---------------- - 4.4.4.4 - 5.5.5.5 - ``` - - -**show runningconfiguration snmp** - -This command displays the running configuration of the snmp module. - -- Usage: - ``` - show runningconfiguration snmp - ``` - -- Example: - ``` - admin@sonic:~$ show runningconfiguration snmp - ``` - -**show runningconfiguration acl** - - This command displays the running configuration of the acls - -- Usage: - ``` - show runningconfiguration acl - ``` - -- Example: - ``` - admin@sonic:~$ show runningconfiguration acl - ``` - - **show runningconfiguration ports** - - This command displays the running configuration of the ports - -- Usage: - ``` - show runningconfiguration ports [] - ``` - -- Examples: - ``` - admin@sonic:~$ show runningconfiguration ports - ``` - - ``` - admin@sonic:~$ show runningconfiguration ports Ethernet0 - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#Startup--Running-Configuration) - - -## Static routing - -### Static routing Config Commands - -This sub-section explains of commands is used to add or remove the static route. - -**config route add** - -This command is used to add a static route. Note that prefix /nexthop vrf`s and interface name are optional. - -- Usage: - - ``` - config route add prefix [vrf ] nexthop [vrf ] dev - ``` - -- Example: - - ``` - admin@sonic:~$ config route add prefix 2.2.3.4/32 nexthop 30.0.0.9 - ``` - -It also supports ECMP, and adding a new nexthop to the existing prefix will complement it and not overwrite them. - -- Example: - - ``` - admin@sonic:~$ sudo config route add prefix 2.2.3.4/32 nexthop vrf Vrf-RED 30.0.0.9 - admin@sonic:~$ sudo config route add prefix 2.2.3.4/32 nexthop vrf Vrf-BLUE 30.0.0.10 - ``` - -**config route del** - -This command is used to remove a static route. Note that prefix /nexthop vrf`s and interface name are optional. - -- Usage: - - ``` - config route del prefix [vrf ] nexthop [vrf ] dev - ``` - -- Example: - - ``` - admin@sonic:~$ sudo config route del prefix 2.2.3.4/32 nexthop vrf Vrf-RED 30.0.0.9 - admin@sonic:~$ sudo config route del prefix 2.2.3.4/32 nexthop vrf Vrf-BLUE 30.0.0.10 - ``` - -This sub-section explains of command is used to show current routes. - -**show ip route** - -- Usage: - - ``` - show ip route - ``` - -- Example: - - ``` - admin@sonic:~$ show ip route - Codes: K - kernel route, C - connected, S - static, R - RIP, - O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, - T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, - F - PBR, f - OpenFabric, - > - selected route, * - FIB route, q - queued, r - rejected, b - backup - - S>* 0.0.0.0/0 [200/0] via 192.168.111.3, eth0, weight 1, 3d03h58m - S> 1.2.3.4/32 [1/0] via 30.0.0.7, weight 1, 00:00:06 - C>* 10.0.0.18/31 is directly connected, Ethernet36, 3d03h57m - C>* 10.0.0.20/31 is directly connected, Ethernet40, 3d03h57m - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#static-routing) - -## Subinterfaces - -### Subinterfaces Show Commands - -**show subinterfaces status** - -This command displays all the subinterfaces that are configured on the device and its current status. - -- Usage: -``` -show subinterfaces status -``` - -- Example: -``` -admin@sonic:~$ show subinterfaces status -Sub port interface Speed MTU Vlan Admin Type ------------------- ------- ----- ------ ------- ------------------- - Eth64.10 100G 9100 100 up dot1q-encapsulation - Ethernet0.100 100G 9100 100 up dot1q-encapsulation -``` - -### Subinterfaces Config Commands - -This sub-section explains how to configure subinterfaces. - -**config subinterface** - -- Usage: -``` -config subinterface (add | del) [vlan <1-4094>] -``` - -- Example (Create the subinterfces with name "Ethernet0.100"): -``` -admin@sonic:~$ sudo config subinterface add Ethernet0.100 -``` - -- Example (Create the subinterfces with name "Eth64.100"): -``` -admin@sonic:~$ sudo config subinterface add Eth64.100 100 -``` - -- Example (Delete the subinterfces with name "Ethernet0.100"): -``` -admin@sonic:~$ sudo config subinterface del Ethernet0.100 -``` - -- Example (Delete the subinterfces with name "Eth64.100"): -``` -admin@sonic:~$ sudo config subinterface del Eth64.100 100 -``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#static-routing) - -## Syslog - -### Syslog Config Commands - -This sub-section of commands is used to add or remove the configured syslog servers. - -**config syslog add** - -This command is used to add a SYSLOG server to the syslog server list. Note that more that one syslog server can be added in the device. - -- Usage: - ``` - config syslog add - ``` - -- Example: - ``` - admin@sonic:~$ sudo config syslog add 1.1.1.1 - Syslog server 1.1.1.1 added to configuration - Restarting rsyslog-config service... - ``` - -**config syslog delete** - -This command is used to delete the syslog server configured. - -- Usage: - ``` - config syslog del - ``` - -- Example: - ``` - admin@sonic:~$ sudo config syslog del 1.1.1.1 - Syslog server 1.1.1.1 removed from configuration - Restarting rsyslog-config service... - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#syslog) - -## System State - -### Processes - -This command is used to determine the CPU utilization. It also lists the active processes along with their corresponding process ID and other relevant parameters. - -This sub-section explains the various "processes" specific data that includes the following. -1) cpu Show processes CPU info -2) memory Show processes memory info -3) summary Show processes info - -“show processes” commands provide a wrapper over linux’s “top” command. “show process cpu” sorts the processes being displayed by cpu-utilization, whereas “show process memory” does it attending to processes’ memory-utilization. - -**show processes cpu** - -This command displays the current CPU usage by process. This command uses linux's "top -bn 1 -o %CPU" command to display the output. - -- Usage: - ``` - show processes cpu - ``` - -*TIP: Users can pipe the output to "head" to display only the "n" number of lines (e.g., `show processes cpu | head -n 10`)* - -- Example: - ``` - admin@sonic:~$ show processes cpu - top - 23:50:08 up 1:18, 1 user, load average: 0.25, 0.29, 0.25 - Tasks: 161 total, 1 running, 160 sleeping, 0 stopped, 0 zombie - %Cpu(s): 3.8 us, 1.0 sy, 0.0 ni, 95.1 id, 0.1 wa, 0.0 hi, 0.0 si, 0.0 st - KiB Mem: 8181216 total, 1161060 used, 7020156 free, 105656 buffers - KiB Swap: 0 total, 0 used, 0 free. 557560 cached Mem - - PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND - 2047 root 20 0 683772 109288 39652 S 23.8 1.3 7:44.79 syncd - 1351 root 20 0 43360 5616 2844 S 11.9 0.1 1:41.56 redis-server - 10093 root 20 0 21944 2476 2088 R 5.9 0.0 0:00.03 top - 1 root 20 0 28992 5508 3236 S 0.0 0.1 0:06.42 systemd - 2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd - 3 root 20 0 0 0 0 S 0.0 0.0 0:00.56 ksoftirqd/0 - 5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H - ... - ``` - -*TIP: Advanced users can view individual processes using variations of the `ps` command (e.g., `ps -ax | grep `)* - -**show processes memory** - -This command displays the current memory usage by processes. This command uses linux's "top -bn 1 -o %MEM" command to display the output. - -- Usage: - ``` - show processes memory - ``` - -*NOTE that pipe option can be used using " | head -n" to display only the "n" number of lines* - -- Example: - ``` - admin@sonic:~$ show processes memory - top - 23:41:24 up 7 days, 39 min, 2 users, load average: 1.21, 1.19, 1.18 - Tasks: 191 total, 2 running, 189 sleeping, 0 stopped, 0 zombie - %Cpu(s): 2.8 us, 20.7 sy, 0.0 ni, 76.3 id, 0.0 wa, 0.0 hi, 0.2 si, 0.0 st - KiB Mem : 8162264 total, 5720412 free, 945516 used, 1496336 buff/cache - KiB Swap: 0 total, 0 free, 0 used. 6855632 avail Mem - - PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND - 18051 root 20 0 851540 274784 8344 S 0.0 3.4 0:02.77 syncd - 17760 root 20 0 1293428 259212 58732 S 5.9 3.2 96:46.22 syncd - 508 root 20 0 725364 76244 38220 S 0.0 0.9 4:54.49 dockerd - 30853 root 20 0 96348 56824 7880 S 0.0 0.7 0:00.98 show - 17266 root 20 0 509876 49772 30640 S 0.0 0.6 0:06.36 docker - 24891 admin 20 0 515864 49560 30644 S 0.0 0.6 0:05.54 docker - 17643 admin 20 0 575668 49428 30628 S 0.0 0.6 0:06.29 docker - 23885 admin 20 0 369552 49344 30840 S 0.0 0.6 0:05.57 docker - 18055 root 20 0 509076 49260 30296 S 0.0 0.6 0:06.36 docker - 17268 root 20 0 371120 49052 30372 S 0.0 0.6 0:06.45 docker - 1227 root 20 0 443284 48640 30100 S 0.0 0.6 0:41.91 docker - 23785 admin 20 0 443796 48552 30128 S 0.0 0.6 0:05.58 docker - 17820 admin 20 0 435088 48144 29480 S 0.0 0.6 0:06.33 docker - 506 root 20 0 1151040 43140 23964 S 0.0 0.5 8:51.08 containerd - 18437 root 20 0 84852 26388 7380 S 0.0 0.3 65:59.76 python3.6 - ``` - - -**show processes summary** - -This command displays the current summary information about all the processes - -- Usage: - ``` - show processes summary - ``` - -- Example: - ``` - admin@sonic:~$ show processes summary - PID PPID CMD %MEM %CPU - 1 0 /sbin/init 0.0 0.0 - 2 0 [kthreadd] 0.0 0.0 - 3 2 [ksoftirqd/0] 0.0 0.0 - 5 2 [kworker/0:0H] 0.0 0.0 - ... - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#System-State) - -### Services & Memory - -These commands are used to know the services that are running and the memory that is utilized currently. - - -**show services** - -This command displays the state of all the SONiC processes running inside a docker container. This helps to identify the status of SONiC’s critical processes. - -- Usage: - ``` - show services - ``` - -- Example: - ``` - admin@sonic:~$ show services - dhcp_relay docker - --------------------------- - UID PID PPID C STIME TTY TIME CMD - root 1 0 0 05:26 ? 00:00:12 /usr/bin/python /usr/bin/supervi - root 24 1 0 05:26 ? 00:00:00 /usr/sbin/rsyslogd -n - - nat docker - --------------------------- - USER PID PPID C STIME TTY TIME CMD - root 1 0 0 05:26 ? 00:00:12 /usr/bin/python /usr/bin/supervisord - root 18 1 0 05:26 ? 00:00:00 /usr/sbin/rsyslogd -n - root 23 1 0 05:26 ? 00:00:01 /usr/bin/natmgrd - root 34 1 0 05:26 ? 00:00:00 /usr/bin/natsyncd - - snmp docker - --------------------------- - UID PID PPID C STIME TTY TIME CMD - root 1 0 0 05:26 ? 00:00:16 /usr/bin/python /usr/bin/supervi - root 24 1 0 05:26 ? 00:00:02 /usr/sbin/rsyslogd -n - Debian-+ 29 1 0 05:26 ? 00:00:04 /usr/sbin/snmpd -f -LS4d -u Debi - root 31 1 1 05:26 ? 00:15:10 python3.6 -m sonic_ax_impl - - syncd docker - --------------------------- - UID PID PPID C STIME TTY TIME CMD - root 1 0 0 05:26 ? 00:00:13 /usr/bin/python /usr/bin/supervi - root 12 1 0 05:26 ? 00:00:00 /usr/sbin/rsyslogd -n - root 17 1 0 05:26 ? 00:00:00 /usr/bin/dsserve /usr/bin/syncd - root 27 17 22 05:26 ? 04:09:30 /usr/bin/syncd --diag -p /usr/sh - root 51 27 0 05:26 ? 00:00:01 /usr/bin/syncd --diag -p /usr/sh - - swss docker - --------------------------- - UID PID PPID C STIME TTY TIME CMD - root 1 0 0 05:26 ? 00:00:29 /usr/bin/python /usr/bin/supervi - root 25 1 0 05:26 ? 00:00:00 /usr/sbin/rsyslogd -n - root 30 1 0 05:26 ? 00:00:13 /usr/bin/orchagent -d /var/log/s - root 42 1 1 05:26 ? 00:12:40 /usr/bin/portsyncd -p /usr/share - root 45 1 0 05:26 ? 00:00:00 /usr/bin/intfsyncd - root 48 1 0 05:26 ? 00:00:03 /usr/bin/neighsyncd - root 59 1 0 05:26 ? 00:00:01 /usr/bin/vlanmgrd - root 92 1 0 05:26 ? 00:00:01 /usr/bin/intfmgrd - root 3606 1 0 23:36 ? 00:00:00 bash -c /usr/bin/arp_update; sle - root 3621 3606 0 23:36 ? 00:00:00 sleep 300 - - ... - ``` - -**show system-memory** - -This command displays the system-wide memory utilization information – just a wrapper over linux native “free” command - -- Usage: - ``` - show system-memory - ``` - -- Example: - ``` - admin@sonic:~$ show system-memory - Command: free -m -h - total used free shared buffers cached - Mem: 3.9G 2.0G 1.8G 33M 324M 791M - -/+ buffers/cache: 951M 2.9G - Swap: 0B 0B 0B - ``` - -**show mmu** - -This command displays virtual address to the physical address translation status of the Memory Management Unit (MMU). - -- Usage: - ``` - show mmu - ``` - -- Example: - ``` - admin@sonic:~$ show mmu - Pool: ingress_lossless_pool - ---- -------- - xoff 4194112 - type ingress - mode dynamic - size 10875072 - ---- -------- - - Pool: egress_lossless_pool - ---- -------- - type egress - mode static - size 15982720 - ---- -------- - - Pool: egress_lossy_pool - ---- ------- - type egress - mode dynamic - size 9243812 - ---- ------- - - Profile: egress_lossy_profile - ---------- ------------------------------- - dynamic_th 3 - pool [BUFFER_POOL|egress_lossy_pool] - size 1518 - ---------- ------------------------------- - - Profile: pg_lossless_100000_300m_profile - ---------- ----------------------------------- - xon_offset 2288 - dynamic_th -3 - xon 2288 - xoff 268736 - pool [BUFFER_POOL|ingress_lossless_pool] - size 1248 - ---------- ----------------------------------- - - Profile: egress_lossless_profile - --------- ---------------------------------- - static_th 3995680 - pool [BUFFER_POOL|egress_lossless_pool] - size 1518 - --------- ---------------------------------- - - Profile: pg_lossless_100000_40m_profile - ---------- ----------------------------------- - xon_offset 2288 - dynamic_th -3 - xon 2288 - xoff 177632 - pool [BUFFER_POOL|ingress_lossless_pool] - size 1248 - ---------- ----------------------------------- - - Profile: ingress_lossy_profile - ---------- ----------------------------------- - dynamic_th 3 - pool [BUFFER_POOL|ingress_lossless_pool] - size 0 - ---------- ----------------------------------- - - Profile: pg_lossless_40000_40m_profile - ---------- ----------------------------------- - xon_offset 2288 - dynamic_th -3 - xon 2288 - xoff 71552 - pool [BUFFER_POOL|ingress_lossless_pool] - size 1248 - ---------- ----------------------------------- - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#System-State) - -Go Back To [Beginning of the document](#) or [Beginning of this section](#System-Health) - -### System-Health - -These commands are used to monitor the system current running services and hardware state. - -**show system-health summary** - -This command displays the current status of 'Services' and 'Hardware' under monitoring. -If any of the elements under each of these two sections is 'Not OK' a proper message will appear under the relevant section. - -- Usage: - ``` - show system-health summary - ``` - -- Example: - ``` - admin@sonic:~$ show system-health summary - System status summary - - System status LED red - Services: - Status: Not OK - Not Running: 'telemetry', 'sflowmgrd' - Hardware: - Status: OK - ``` - ``` - admin@sonic:~$ show system-health summary - System status summary - - System status LED green - Services: - Status: OK - Hardware: - Status: OK - ``` - -**show system-health monitor-list** - -This command displays a list of all current 'Services' and 'Hardware' being monitored, their status and type. - -- Usage: - ``` - show system-health monitor-list - ``` - -- Example: - ``` - admin@sonic:~$ show system-health monitor-list - System services and devices monitor list - - Name Status Type - -------------- -------- ---------- - telemetry Not OK Process - orchagent Not OK Process - neighsyncd OK Process - vrfmgrd OK Process - dialout_client OK Process - zebra OK Process - rsyslog OK Process - snmpd OK Process - redis_server OK Process - intfmgrd OK Process - vxlanmgrd OK Process - lldpd_monitor OK Process - portsyncd OK Process - var-log OK Filesystem - lldpmgrd OK Process - syncd OK Process - sonic OK System - buffermgrd OK Process - portmgrd OK Process - staticd OK Process - bgpd OK Process - lldp_syncd OK Process - bgpcfgd OK Process - snmp_subagent OK Process - root-overlay OK Filesystem - fpmsyncd OK Process - sflowmgrd OK Process - vlanmgrd OK Process - nbrmgrd OK Process - PSU 2 OK PSU - psu_1_fan_1 OK Fan - psu_2_fan_1 OK Fan - fan11 OK Fan - fan10 OK Fan - fan12 OK Fan - ASIC OK ASIC - fan1 OK Fan - PSU 1 OK PSU - fan3 OK Fan - fan2 OK Fan - fan5 OK Fan - fan4 OK Fan - fan7 OK Fan - fan6 OK Fan - fan9 OK Fan - fan8 OK Fan - ``` - -**show system-health detail** - -This command displays the current status of 'Services' and 'Hardware' under monitoring. -If any of the elements under each of these two sections is 'Not OK' a proper message will appear under the relevant section. -In addition, displays a list of all current 'Services' and 'Hardware' being monitored and a list of ignored elements. - -- Usage: - ``` - show system-health detail - ``` - -- Example: - ``` - admin@sonic:~$ show system-health detail - System status summary - - System status LED red - Services: - Status: Not OK - Not Running: 'telemetry', 'orchagent' - Hardware: - Status: OK - - System services and devices monitor list - - Name Status Type - -------------- -------- ---------- - telemetry Not OK Process - orchagent Not OK Process - neighsyncd OK Process - vrfmgrd OK Process - dialout_client OK Process - zebra OK Process - rsyslog OK Process - snmpd OK Process - redis_server OK Process - intfmgrd OK Process - vxlanmgrd OK Process - lldpd_monitor OK Process - portsyncd OK Process - var-log OK Filesystem - lldpmgrd OK Process - syncd OK Process - sonic OK System - buffermgrd OK Process - portmgrd OK Process - staticd OK Process - bgpd OK Process - lldp_syncd OK Process - bgpcfgd OK Process - snmp_subagent OK Process - root-overlay OK Filesystem - fpmsyncd OK Process - sflowmgrd OK Process - vlanmgrd OK Process - nbrmgrd OK Process - PSU 2 OK PSU - psu_1_fan_1 OK Fan - psu_2_fan_1 OK Fan - fan11 OK Fan - fan10 OK Fan - fan12 OK Fan - ASIC OK ASIC - fan1 OK Fan - PSU 1 OK PSU - fan3 OK Fan - fan2 OK Fan - fan5 OK Fan - fan4 OK Fan - fan7 OK Fan - fan6 OK Fan - fan9 OK Fan - fan8 OK Fan - - System services and devices ignore list - - Name Status Type - ----------- -------- ------ - psu.voltage Ignored Device - ``` -Go Back To [Beginning of the document](#) or [Beginning of this section](#System-Health) - -## VLAN & FDB - -### VLAN - -#### VLAN show commands - -**show vlan brief** - -This command displays brief information about all the vlans configured in the device. It displays the vlan ID, IP address (if configured for the vlan), list of vlan member ports, whether the port is tagged or in untagged mode, the DHCP Helper Address, and the proxy ARP status - -- Usage: - ``` - show vlan brief - ``` - -- Example: - ``` - admin@sonic:~$ show vlan brief - - +-----------+--------------+-----------+----------------+-----------------------+-------------+ - | VLAN ID | IP Address | Ports | Port Tagging | DHCP Helper Address | Proxy ARP | - +===========+==============+===========+================+=======================+=============+ - | 100 | 1.1.2.2/16 | Ethernet0 | tagged | 192.0.0.1 | disabled | - | | | Ethernet4 | tagged | 192.0.0.2 | | - | | | | | 192.0.0.3 | | - +-----------+--------------+-----------+----------------+-----------------------+-------------+ - ``` - -**show vlan config** - -This command displays all the vlan configuration. - -- Usage: - ``` - show vlan config - ``` - -- Example: - ``` - admin@sonic:~$ show vlan config - Name VID Member Mode - ------- ----- --------- ------ - Vlan100 100 Ethernet0 tagged - Vlan100 100 Ethernet4 tagged - ``` - - -#### VLAN Config commands - -This sub-section explains how to configure the vlan and its member ports. - -**config vlan add/del** - -This command is used to add or delete the vlan. - -- Usage: - ``` - config vlan (add | del) - ``` - -- Example (Create the VLAN "Vlan100" if it does not already exist): - ``` - admin@sonic:~$ sudo config vlan add 100 - ``` - -**config vlan member add/del** - -This command is to add or delete a member port into the already created vlan. - -- Usage: - ``` - config vlan member add/del [-u|--untagged] - ``` - -*NOTE: Adding the -u or --untagged flag will set the member in "untagged" mode* - - -- Example: - ``` - admin@sonic:~$ sudo config vlan member add 100 Ethernet0 - This command will add Ethernet0 as member of the vlan 100 - - admin@sonic:~$ sudo config vlan member add 100 Ethernet4 - This command will add Ethernet4 as member of the vlan 100. - ``` - -**config proxy_arp enabled/disabled** - -This command is used to enable or disable proxy ARP for a VLAN interface - -- Usage: - ``` - config vlan proxy_arp enabled/disabled - ``` - -- Example: - ``` - admin@sonic:~$ sudo config vlan proxy_arp 1000 enabled - This command will enable proxy ARP for the interface 'Vlan1000' - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#vlan--FDB) - -### FDB - -#### FDB show commands - -**show mac** - -This command displays the MAC (FDB) entries either in full or partial as given below. -1) show mac - displays the full table -2) show mac -v - displays the MACs learnt on the particular VLAN ID. -3) show mac -p - displays the MACs learnt on the particular port. -4) show mac -a - display the MACs that match a specific mac-address -5) show mac -t - display the MACs that match a specific type (static/dynamic) -6) show mac -c - display the count of MAC addresses - -To show the default MAC address aging time on the switch. - -- Usage: - ``` - show mac [-v ] [-p ] [-a ] [-t ] [-c] - ``` - -- Example: - ``` - admin@sonic:~$ show mac - No. Vlan MacAddress Port Type - ----- ------ ----------------- ----------- ------- - 1 1000 E2:8C:56:85:4A:CD Ethernet192 Dynamic - 2 1000 A0:1B:5E:47:C9:76 Ethernet192 Dynamic - 3 1000 AA:54:EF:2C:EE:30 Ethernet192 Dynamic - 4 1000 A4:3F:F2:17:A3:FC Ethernet192 Dynamic - 5 1000 0C:FC:01:72:29:91 Ethernet192 Dynamic - 6 1000 48:6D:01:7E:C9:FD Ethernet192 Dynamic - 7 1000 1C:6B:7E:34:5F:A6 Ethernet192 Dynamic - 8 1000 EE:81:D9:7B:93:A9 Ethernet192 Dynamic - 9 1000 CC:F8:8D:BB:85:E2 Ethernet192 Dynamic - 10 1000 0A:52:B3:9C:FB:6C Ethernet192 Dynamic - 11 1000 C6:E2:72:02:D1:23 Ethernet192 Dynamic - 12 1000 8A:C9:5C:25:E9:28 Ethernet192 Dynamic - 13 1000 5E:CD:34:E4:94:18 Ethernet192 Dynamic - 14 1000 7E:49:1F:B5:91:B5 Ethernet192 Dynamic - 15 1000 AE:DD:67:F3:09:5A Ethernet192 Dynamic - 16 1000 DC:2F:D1:08:4B:DE Ethernet192 Dynamic - 17 1000 50:96:23:AD:F1:65 Ethernet192 Static - 18 1000 C6:C9:5E:AE:24:42 Ethernet192 Static - Total number of entries 18 - ``` - -Optionally, you can specify a VLAN ID or interface name or type or mac-address in order to display only that particular entries - -- Examples: - ``` - admin@sonic:~$ show mac -v 1000 - No. Vlan MacAddress Port Type - ----- ------ ----------------- ----------- ------- - 1 1000 E2:8C:56:85:4A:CD Ethernet192 Dynamic - 2 1000 A0:1B:5E:47:C9:76 Ethernet192 Dynamic - 3 1000 AA:54:EF:2C:EE:30 Ethernet192 Dynamic - 4 1000 A4:3F:F2:17:A3:FC Ethernet192 Dynamic - 5 1000 0C:FC:01:72:29:91 Ethernet192 Dynamic - 6 1000 48:6D:01:7E:C9:FD Ethernet192 Dynamic - 7 1000 1C:6B:7E:34:5F:A6 Ethernet192 Dynamic - 8 1000 EE:81:D9:7B:93:A9 Ethernet192 Dynamic - 9 1000 CC:F8:8D:BB:85:E2 Ethernet192 Dynamic - 10 1000 0A:52:B3:9C:FB:6C Ethernet192 Dynamic - 11 1000 C6:E2:72:02:D1:23 Ethernet192 Dynamic - 12 1000 8A:C9:5C:25:E9:28 Ethernet192 Dynamic - 13 1000 5E:CD:34:E4:94:18 Ethernet192 Dynamic - 14 1000 7E:49:1F:B5:91:B5 Ethernet192 Dynamic - 15 1000 AE:DD:67:F3:09:5A Ethernet192 Dynamic - 16 1000 DC:2F:D1:08:4B:DE Ethernet192 Dynamic - 17 1000 50:96:23:AD:F1:65 Ethernet192 Static - 18 1000 C6:C9:5E:AE:24:42 Ethernet192 Static - Total number of entries 18 - ``` - ``` - admin@sonic:~$ show mac -p Ethernet192 - No. Vlan MacAddress Port Type - ----- ------ ----------------- ----------- ------- - 1 1000 E2:8C:56:85:4A:CD Ethernet192 Dynamic - 2 1000 A0:1B:5E:47:C9:76 Ethernet192 Dynamic - 3 1000 AA:54:EF:2C:EE:30 Ethernet192 Dynamic - 4 1000 A4:3F:F2:17:A3:FC Ethernet192 Dynamic - 5 1000 0C:FC:01:72:29:91 Ethernet192 Dynamic - 6 1000 48:6D:01:7E:C9:FD Ethernet192 Dynamic - 7 1000 1C:6B:7E:34:5F:A6 Ethernet192 Dynamic - 8 1000 EE:81:D9:7B:93:A9 Ethernet192 Dynamic - 9 1000 CC:F8:8D:BB:85:E2 Ethernet192 Dynamic - 10 1000 0A:52:B3:9C:FB:6C Ethernet192 Dynamic - 11 1000 C6:E2:72:02:D1:23 Ethernet192 Dynamic - 12 1000 8A:C9:5C:25:E9:28 Ethernet192 Dynamic - 13 1000 5E:CD:34:E4:94:18 Ethernet192 Dynamic - 14 1000 7E:49:1F:B5:91:B5 Ethernet192 Dynamic - 15 1000 AE:DD:67:F3:09:5A Ethernet192 Dynamic - 16 1000 DC:2F:D1:08:4B:DE Ethernet192 Dynamic - 17 1000 50:96:23:AD:F1:65 Ethernet192 Static - 18 1000 C6:C9:5E:AE:24:42 Ethernet192 Static - Total number of entries 18 - ``` - ``` - admin@sonic:~$ show mac -a E2:8C:56:85:4A:CD - No. Vlan MacAddress Port Type - ----- ------ ----------------- ----------- ------- - 1 1000 E2:8C:56:85:4A:CD Ethernet192 Dynamic - Total number of entries 1 - ``` - ``` - admin@sonic:~$ show mac -t Static - No. Vlan MacAddress Port Type - ----- ------ ----------------- ----------- ------- - 2 1000 50:96:23:AD:F1:65 Ethernet192 Static - 2 1000 C6:C9:5E:AE:24:42 Ethernet192 Static - Total number of entries 2 - ``` - ``` - admin@sonic:~$ show mac -c - Total number of entries 18 - ``` - -**show mac aging-time** - -This command displays the default mac aging time on the switch - - ``` - admin@sonic:~$ show mac aging-time - Aging time for switch is 600 seconds - ``` - -**sonic-clear fdb all** - -Clear the FDB table - -- Usage: - ``` - sonic-clear fdb all - ``` -- Example: - ``` - admin@sonic:~$ sonic-clear fdb all - FDB entries are cleared. - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#vlan--FDB) - -## VxLAN & Vnet - -### VxLAN - -#### VxLAN show commands - -**show vxlan tunnel** - -This command displays brief information about all the vxlans configured in the device. It displays the vxlan tunnel name, source IP address, destination IP address (if configured), tunnel map name and mapping. - -- Usage: - - ``` - show vxlan tunnel - ``` - -- Example: - - ``` - admin@sonic:~$ show vxlan tunnel - vxlan tunnel name source ip destination ip tunnel map name tunnel map mapping(vni -> vlan) - ------------------- ----------- ---------------- ----------------- --------------------------------- - tunnel1 10.10.10.10 - tunnel2 10.10.10.10 20.10.10.10 tmap1 1234 -> 100 - tunnel3 10.10.10.10 30.10.10.10 tmap2 1235 -> 200 - ``` - -**show vxlan name ** - -This command displays configuration. - -- Usage: - - ``` - show vxlan name - ``` - -- Example: - - ``` - admin@sonic:~$ show vxlan name tunnel3 - vxlan tunnel name source ip destination ip tunnel map name tunnel map mapping(vni -> vlan) - ------------------- ----------- ---------------- ----------------- --------------------------------- - tunnel3 10.10.10.10 30.10.10.10 tmap2 1235 -> 200 - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#vxlan--vnet) - -### Vnet - -#### Vnet show commands - -**show vnet brief** - -This command displays brief information about all the vnets configured in the device. It displays the vnet name, vxlan tunnel name, vni and peer list (if configured). - -- Usage: - - ``` - show vnet brief - ``` - -- Example: - - ``` - admin@sonic:~$ show vnet brief - vnet name vxlan tunnel vni peer list - ----------- -------------- ----- ------------------ - Vnet_2000 tunnel1 2000 - Vnet_3000 tunnel1 3000 Vnet_2000,Vnet4000 - ``` - -**show vnet name ** - -This command displays brief information about configured in the device. - -- Usage: - - ``` - show vnet name - ``` - -- Example: - - ``` - admin@sonic:~$ show vnet name Vnet_3000 - vnet name vxlan tunnel vni peer list - ----------- -------------- ----- ------------------ - Vnet_3000 tunnel1 3000 Vnet_2000,Vnet4000 - ``` - -**show vnet interfaces** - -This command displays vnet interfaces information about all the vnets configured in the device. - -- Usage: - - ``` - show vnet interfaces - ``` - -- Example: - - ``` - admin@sonic:~$ show vnet interfaces - vnet name interfaces - ----------- ------------ - Vnet_2000 Ethernet1 - Vnet_3000 Vlan2000 - ``` - -**show vnet neighbors** - -This command displays vnet neighbor information about all the vnets configured in the device. It displays the vnet name, neighbor IP address, neighbor mac address (if configured) and interface. - -- Usage: - - ``` - show vnet neighbors - ``` - -- Example: - - ``` - admin@sonic:~$ show vnet neighbors - Vnet_2000 neighbor mac_address interfaces - ----------- ----------- ------------- ------------ - 11.11.11.11 Ethernet1 - 11.11.11.12 Ethernet1 - - Vnet_3000 neighbor mac_address interfaces - ----------- ----------- ----------------- ------------ - 20.20.20.20 aa:bb:cc:dd:ee:ff Vlan2000 - ``` - -**show vnet routes all** - -This command displays all routes information about all the vnets configured in the device. - -- Usage: - - ``` - show vnet routes all - ``` - -- Example: - - ``` - admin@sonic:~$ show vnet routes all - vnet name prefix nexthop interface - ----------- -------------- --------- ----------- - Vnet_2000 100.100.3.0/24 Ethernet52 - Vnet_3000 100.100.4.0/24 Vlan2000 - - vnet name prefix endpoint mac address vni - ----------- -------------- ---------- ----------------- ----- - Vnet_2000 100.100.1.1/32 10.10.10.1 - Vnet_3000 100.100.2.1/32 10.10.10.2 00:00:00:00:03:04 - ``` - -**show vnet routes tunnel** - -This command displays tunnel routes information about all the vnets configured in the device. - -- Usage: - - ``` - show vnet routes tunnel - ``` - -- Example: - - ``` - admin@sonic:~$ show vnet routes tunnel - vnet name prefix endpoint mac address vni - ----------- -------------- ---------- ----------------- ----- - Vnet_2000 100.100.1.1/32 10.10.10.1 - Vnet_3000 100.100.2.1/32 10.10.10.2 00:00:00:00:03:04 - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#vxlan--vnet) - -## Warm Reboot - -warm-reboot command initiates a warm reboot of the device. - -warm-reboot command doesn't require setting warm restart configuration. The -command will setup everything needed to perform warm reboot. - -This command requires root privilege. - -- Usage: - ``` - warm-reboot [-h|-?|-v|-f|-r|-k|-x|-c |-s|-D] - ``` - -- Parameters: - ``` - -h,-? : get this help - -v : turn on verbose mode - -f : force execution - -r : reboot with /sbin/reboot - -k : reboot with /sbin/kexec -e [default] - -x : execute script with -x flag - -c : specify control plane assistant IP list - -s : strict mode: do not proceed without: - - control plane assistant IP list. - -D : detached mode - closing terminal will not cause stopping reboot - ``` - -- Example: - ``` - admin@sonic:~$ sudo warm-reboot -v - Tue Oct 22 23:20:53 UTC 2019 Pausing orchagent ... - Tue Oct 22 23:20:53 UTC 2019 Stopping radv ... - Tue Oct 22 23:20:54 UTC 2019 Stopping bgp ... - Tue Oct 22 23:20:54 UTC 2019 Stopped bgp ... - Tue Oct 22 23:20:57 UTC 2019 Initialize pre-shutdown ... - Tue Oct 22 23:20:58 UTC 2019 Requesting pre-shutdown ... - Tue Oct 22 23:20:58 UTC 2019 Waiting for pre-shutdown ... - Tue Oct 22 23:20:59 UTC 2019 Pre-shutdown succeeded ... - Tue Oct 22 23:20:59 UTC 2019 Backing up database ... - Tue Oct 22 23:21:00 UTC 2019 Stopping teamd ... - Tue Oct 22 23:21:00 UTC 2019 Stopped teamd ... - Tue Oct 22 23:21:00 UTC 2019 Stopping syncd ... - Tue Oct 22 23:21:11 UTC 2019 Stopped syncd ... - Tue Oct 22 23:21:11 UTC 2019 Stopping all remaining containers ... - Tue Oct 22 23:21:13 UTC 2019 Stopped all remaining containers ... - Tue Oct 22 23:21:15 UTC 2019 Rebooting with /sbin/kexec -e to SONiC-OS-20191021.01 ... - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#Warm-Reboot) - -## Warm Restart - -Besides device level warm reboot, SONiC also provides docker based warm restart. This feature is currently supported by following dockers: BGP, teamD, and SWSS. A user can manage to restart a particular docker, with no interruption on packet forwarding and no effect on other services. This helps to reduce operational costs as well as development efforts. For example, to fix a bug in BGP routing stack, only the BGP docker image needs to be built, tested and upgraded. - -To achieve uninterrupted packet forwarding during the restarting stage and database reconciliation at the post restarting stage, warm restart enabled dockers with adjacency state machine facilitate standardized protocols. For example, a BGP restarting switch must have BGP "Graceful Restart" enabled, and its BGP neighbors must be "Graceful Restart Helper Capable", as specified in [IETF RFC4724](https://tools.ietf.org/html/rfc4724). - -Before warm restart BGP docker, the following BGP commands should be enabled: - ``` - bgp graceful-restart - bgp graceful-restart preserve-fw-state - ``` -In current SONiC release, the above two commands are enabled by default. - -It should be aware that during a warm restart, certain BGP fast convergence feature and black hole avoidance feature should either be disabled or be set to a lower preference to avoid conflicts with BGP graceful restart. - -For example, BGP BFD could be disabled via: - - ``` - no neighbor bfd - ``` - -otherwise, the fast failure detection would cause packet drop during warm reboot. - -Another commonly deployed blackhole avoidance feature: dynamic route priority adjustment, could be disabled via: - - ``` - no bgp max-med on-peerup - ``` - -to avoid large routes churn during BGP restart. - - -### Warm Restart show commands - -**show warm_restart config** - -This command displays all the configuration related to warm_restart. - -- Usage: - ``` - show warm_restart config - ``` - -- Example: - ``` - admin@sonic:~$ show warm_restart config - name enable timer_name timer_duration - ------ -------- ---------------- ---------------- - bgp true bgp_timer 100 - teamd false teamsyncd_timer 300 - swss false neighsyncd_timer 200 - system true NULL NULL - ``` - -**show warm_restart state** - -This command displays the warm_restart state. - -- Usage: - ``` - show warm_restart state - ``` - -- Example: - ``` - admin@sonic:~$ show warm_restart state - name restore_count state - ---------- --------------- ---------- - orchagent 0 - vlanmgrd 0 - bgp 1 reconciled - portsyncd 0 - teammgrd 1 - neighsyncd 0 - teamsyncd 1 - syncd 0 - natsyncd 0 - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#warm-restart) - -### Warm Restart Config commands - -This sub-section explains the various configuration related to warm restart feature. Following parameters can be configured using this command. -1) bgp_timer -2) disable -3) enable -4) neighsyncd_timer -5) teamsyncd_timer -Each of these sub-commands are explained in the following section. - -Users can use an optional parameter "-s" to use the unix domain socket for communicating with the RedisDB which will be faster when compared to using the default network sockets. -All these commands have the following option. - -Options: - -s, --redis-unix-socket-path TEXT - unix socket path for redis connection - - -**config warm_restart bgp_timer** - -This command is used to set the bgp_timer value for warm_restart of BGP service. -bgp_timer holds the time interval utilized by fpmsyncd during warm-restart episodes. -During this interval fpmsyncd will recover all the routing state previously pushed to AppDB, as well as all the new state coming from zebra/bgpd. -Upon expiration of this timer, fpmsyncd will execute the reconciliation logic to eliminate all the stale entries from AppDB. -This timer should match the BGP-GR restart-timer configured within the elected routing-stack. -Supported range: 1-3600. - -- Usage: - ``` - config warm_restart [-s|--redis-unix-socket-path ] bgp_timer - ``` - - - Parameters: - - seconds: Range from 1 to 3600 - -- Example: - ``` - admin@sonic:~$ sudo config warm_restart bgp_timer 1000 - ``` - -**config warm_restart enable/disable** - -This command is used to enable or disable the warm_restart for a particular service that supports warm reboot. -Following four services support warm reboot. When user restarts the particular service using "systemctl restart ", this configured value will be checked for whether it is enabled or disabled. -If this configuration is enabled for that service, it will perform warm reboot for that service. Otherwise, it will do cold restart of the service. - -- Usage: - ``` - config warm_restart [-s|--redis-unix-socket-path ] enable [] - ``` - - - Parameters: - - module_name: Can be either system or swss or bgp or teamd. If "module_name" argument is not specified, it will enable "system" module. - -- Example (Set warm_restart as "enable" for the "system" service): - ``` - admin@sonic:~$ sudo config warm_restart enable - ``` - -- Example (Set warm_restart as "enable" for the "swss" service. When user does "systemctl restart swss", it will perform warm reboot instead of cold reboot) - ``` - admin@sonic:~$ sudo config warm_restart enable swss - ``` - -- Example (Set warm_restart as "enable" for the "teamd" service. When user does "systemctl restart teamd", it will perform warm reboot instead of cold reboot) - ``` - admin@sonic:~$ sudo config warm_restart enable teamd - ``` - - -**config warm_restart neighsyncd_timer** - -This command is used to set the neighsyncd_timer value for warm_restart of "swss" service. -neighsyncd_timer is the timer used for "swss" (neighsyncd) service during the warm restart. -Timer is started after the neighborTable is restored to internal data structures. -neighborsyncd then starts to read all Linux kernel entries and mark the entries in the data structures accordingly. -Once the timer is expired, reconciliation is done and the delta is pushed to appDB -Valid value is 1-9999. 0 is invalid. - -- Usage: - ``` - config warm_restart [-s|--redis-unix-socket-path ] neighsyncd_timer - ``` - - - Parameters: - - seconds: Range from 1 to 9999 - -- Example: - ``` - admin@sonic:~$ sudo config warm_restart neighsyncd_timer 2000 - ``` - - -**config warm_restart bgp_timer** - -This command is used to set the bgp_timer value for warm_restart of "bgp" service. -bgp_timer is the timer used for "bgp" service during the warm restart. -Timer is started after the BGP table is restored to internal data structures. -BGP services then start to read all Linux kernel entries and mark the entries in the data structures accordingly. -Once the timer is expired, reconciliation is done and the delta is pushed to appDB -Valid value is 1-9999. 0 is invalid. - -- Usage: - ``` - config warm_restart [-s|--redis-unix-socket-path ] bgp_timer - ``` - - - Parameters: - - seconds: Range from 1 to 9999 - -- Example: - ``` - admin@sonic:~$ sudo config warm_restart bgp_timer 2000 - ``` - -**config warm_restart teamsyncd_timer** - -This command is used to set the teamsyncd_timer value for warm_restart of teamd service. -teamsyncd_timer holds the time interval utilized by teamsyncd during warm-restart episodes. -The timer is started when teamsyncd starts. During the timer interval, teamsyncd will preserve all LAG interface changes, but it will not apply them. -The changes will only be applied when the timer expires. -When the changes are applied, the stale LAG entries will be removed, the new LAG entries will be created. -Supported range: 1-9999. 0 is invalid - -- Usage: - ``` - config warm_restart teamsyncd_timer - ``` - - - Parameters: - - seconds: Range from 1 to 9999 - -- Example: - ``` - admin@sonic:~$ sudo config warm_restart teamsyncd_timer 3000 - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#warm-restart) - - -## Watermark - -### Watermark Show commands - -**show watermark telemetry interval** - -This command displays the configured interval for the telemetry. - -- Usage: - ``` - show watermark telemetry interval - ``` - -- Example: - ``` - admin@sonic:~$ show watermark telemetry interval - - Telemetry interval 120 second(s) - ``` - -### Watermark Config commands - -**config watermark telemetry interval** - -This command is used to configure the interval for telemetry. -The default interval is 120 seconds. -There is no regulation on the valid range of values; it leverages linux timer. - -- Usage: - ``` - config watermark telemetry interval - ``` - -- Example: - ``` - admin@sonic:~$ sudo config watermark telemetry interval 999 - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#watermark) - - - -## Software Installation and Management - -SONiC images can be installed in one of two methods: -1. From within a running SONiC image using the `sonic-installer` utility -2. From the vendor's bootloader (E.g., ONIE, Aboot, etc.) - -SONiC packages are available as prebuilt Docker images and meant to be installed with the *sonic-package-manager* utility. - -### SONiC Package Manager - -The *sonic-package-manager* is a command line tool to manage (e.g. install, upgrade or uninstall) SONiC Packages. - -**sonic-package-manager list** - -This command lists all available SONiC packages, their desription, installed version and installation status. -SONiC package status can be *Installed*, *Not installed* or *Built-In*. "Built-In" status means that a feature is built-in to SONiC image and can't be upgraded or uninstalled. - -- Usage: - ``` - sonic-package-manager list - ``` - -- Example: - ``` - admin@sonic:~$ sonic-package-manager list - Name Repository Description Version Status - -------------- --------------------------- ---------------------------- --------- -------------- - cpu-report azure/cpu-report CPU report package N/A Not Installed - database docker-database SONiC database package 1.0.0 Built-In - dhcp-relay azure/docker-dhcp-relay SONiC dhcp-relay package 1.0.0 Installed - fpm-frr docker-fpm-frr SONiC fpm-frr package 1.0.0 Built-In - lldp docker-lldp SONiC lldp package 1.0.0 Built-In - macsec docker-macsec SONiC macsec package 1.0.0 Built-In - mgmt-framework docker-sonic-mgmt-framework SONiC mgmt-framework package 1.0.0 Built-In - nat docker-nat SONiC nat package 1.0.0 Built-In - pmon docker-platform-monitor SONiC pmon package 1.0.0 Built-In - radv docker-router-advertiser SONiC radv package 1.0.0 Built-In - sflow docker-sflow SONiC sflow package 1.0.0 Built-In - snmp docker-snmp SONiC snmp package 1.0.0 Built-In - swss docker-orchagent SONiC swss package 1.0.0 Built-In - syncd docker-syncd-mlnx SONiC syncd package 1.0.0 Built-In - teamd docker-teamd SONiC teamd package 1.0.0 Built-In - telemetry docker-sonic-telemetry SONiC telemetry package 1.0.0 Built-In - ``` - -**sonic-package-manager repository add** - -This command will add a new repository as source for SONiC packages to the database. *NOTE*: requires elevated (root) privileges to run - -- Usage: - ``` - Usage: sonic-package-manager repository add [OPTIONS] NAME REPOSITORY - - Add a new repository to database. - - NOTE: This command requires elevated (root) privileges to run. - - Options: - --default-reference TEXT Default installation reference. Can be a tag or - sha256 digest in repository. - --description TEXT Optional package entry description. - --help Show this message and exit. - ``` -- Example: - ``` - admin@sonic:~$ sudo sonic-package-manager repository add \ - cpu-report azure/sonic-cpu-report --default-reference 1.0.0 - ``` - -**sonic-package-manager repository remove** - -This command will remove a repository as source for SONiC packages from the database . The package has to be *Not Installed* in order to be removed from package database. *NOTE*: requires elevated (root) privileges to run - -- Usage: - ``` - Usage: sonic-package-manager repository remove [OPTIONS] NAME - - Remove repository from database. - - NOTE: This command requires elevated (root) privileges to run. - - Options: - --help Show this message and exit. - ``` -- Example: - ``` - admin@sonic:~$ sudo sonic-package-manager repository remove cpu-report - ``` - -**sonic-package-manager install** - -This command pulls and installs a package on SONiC host. *NOTE*: this command requires elevated (root) privileges to run - -- Usage: - ``` - Usage: sonic-package-manager install [OPTIONS] [PACKAGE_EXPR] - - Install/Upgrade package using [PACKAGE_EXPR] in format - "[=|@]". - - The repository to pull the package from is resolved by lookup in - package database, thus the package has to be added via "sonic- - package-manager repository add" command. - - In case when [PACKAGE_EXPR] is a package name "" this command - will install or upgrade to a version referenced by "default- - reference" in package database. - - NOTE: This command requires elevated (root) privileges to run. - - Options: - --enable Set the default state of the feature to enabled - and enable feature right after installation. NOTE: - user needs to execute "config save -y" to make - this setting persistent. - --set-owner [local|kube] Default owner configuration setting for a feature. - --from-repository TEXT Fetch package directly from image registry - repository. NOTE: This argument is mutually - exclusive with arguments: [package_expr, - from_tarball]. - --from-tarball FILE Fetch package from saved image tarball. NOTE: This - argument is mutually exclusive with arguments: - [package_expr, from_repository]. - -f, --force Force operation by ignoring package dependency - tree and package manifest validation failures. - -y, --yes Automatically answer yes on prompts. - -v, --verbosity LVL Either CRITICAL, ERROR, WARNING, INFO or DEBUG. - Default is INFO. - --skip-host-plugins Do not install host OS plugins provided by the - package (CLI, etc). NOTE: In case when package - host OS plugins are set as mandatory in package - manifest this option will fail the installation. - --allow-downgrade Allow package downgrade. By default an attempt to - downgrade the package will result in a failure - since downgrade might not be supported by the - package, thus requires explicit request from the - user. - --help Show this message and exit.. - ``` -- Example: - ``` - admin@sonic:~$ sudo sonic-package-manager install dhcp-relay=1.0.2 - ``` - ``` - admin@sonic:~$ sudo sonic-package-manager install dhcp-relay@latest - ``` - ``` - admin@sonic:~$ sudo sonic-package-manager install dhcp-relay@sha256:9780f6d83e45878749497a6297ed9906c19ee0cc48cc88dc63827564bb8768fd - ``` - ``` - admin@sonic:~$ sudo sonic-package-manager install --from-repository azure/sonic-cpu-report:latest - ``` - ``` - admin@sonic:~$ sudo sonic-package-manager install --from-tarball sonic-docker-image.gz - ``` - -**sonic-package-manager uninstall** - -This command uninstalls package from SONiC host. User needs to stop the feature prior to uninstalling it. -*NOTE*: this command requires elevated (root) privileges to run. - -- Usage: - ``` - Usage: sonic-package-manager uninstall [OPTIONS] NAME - - Uninstall package. - - NOTE: This command requires elevated (root) privileges to run. - - Options: - -f, --force Force operation by ignoring package dependency tree and - package manifest validation failures. - -y, --yes Automatically answer yes on prompts. - -v, --verbosity LVL Either CRITICAL, ERROR, WARNING, INFO or DEBUG. Default - is INFO. - --help Show this message and exit. - ``` -- Example: - ``` - admin@sonic:~$ sudo sonic-package-manager uninstall dhcp-relay - ``` - -**sonic-package-manager reset** - -This comamnd resets the package by reinstalling it to its default version. *NOTE*: this command requires elevated (root) privileges to run. - -- Usage: - ``` - Usage: sonic-package-manager reset [OPTIONS] NAME - - Reset package to the default version. - - NOTE: This command requires elevated (root) privileges to run. - - Options: - -f, --force Force operation by ignoring package dependency tree and - package manifest validation failures. - -y, --yes Automatically answer yes on prompts. - -v, --verbosity LVL Either CRITICAL, ERROR, WARNING, INFO or DEBUG. Default - is INFO. - --skip-host-plugins Do not install host OS plugins provided by the package - (CLI, etc). NOTE: In case when package host OS plugins - are set as mandatory in package manifest this option - will fail the installation. - --help Show this message and exit. - ``` -- Example: - ``` - admin@sonic:~$ sudo sonic-package-manager reset dhcp-relay - ``` - -**sonic-package-manager show package versions** - -This command will retrieve a list of all available versions for the given package from the configured upstream repository - -- Usage: - ``` - Usage: sonic-package-manager show package versions [OPTIONS] NAME - - Show available versions. - - Options: - --all Show all available tags in repository. - --plain Plain output. - --help Show this message and exit. - ``` -- Example: - ``` - admin@sonic:~$ sonic-package-manager show package versions dhcp-relay - • 1.0.0 - • 1.0.2 - • 2.0.0 - ``` - ``` - admin@sonic:~$ sonic-package-manager show package versions dhcp-relay --plain - 1.0.0 - 1.0.2 - 2.0.0 - ``` - ``` - admin@sonic:~$ sonic-package-manager show package versions dhcp-relay --all - • 1.0.0 - • 1.0.2 - • 2.0.0 - • latest - ``` - -**sonic-package-manager show package changelog** - -This command fetches the changelog from the package manifest and displays it. *NOTE*: package changelog can be retrieved from registry or read from image tarball without installing it. - -- Usage: - ``` - Usage: sonic-package-manager show package changelog [OPTIONS] [PACKAGE_EXPR] - - Show package changelog. - - Options: - --from-repository TEXT Fetch package directly from image registry - repository NOTE: This argument is mutually exclusive - with arguments: [from_tarball, package_expr]. - --from-tarball FILE Fetch package from saved image tarball NOTE: This - argument is mutually exclusive with arguments: - [package_expr, from_repository]. - --help Show this message and exit. - ``` -- Example: - ``` - admin@sonic:~$ sonic-package-manager show package changelog dhcp-relay - 1.0.0: - - • Initial release - - Author (author@email.com) Mon, 25 May 2020 12:25:00 +0300 - ``` - -**sonic-package-manager show package manifest** - -This command fetches the package manifest and displays it. *NOTE*: package manifest can be retrieved from registry or read from image tarball without installing it. - -- Usage: - ``` - Usage: sonic-package-manager show package manifest [OPTIONS] [PACKAGE_EXPR] - - Show package manifest. - - Options: - --from-repository TEXT Fetch package directly from image registry - repository NOTE: This argument is mutually exclusive - with arguments: [package_expr, from_tarball]. - --from-tarball FILE Fetch package from saved image tarball NOTE: This - argument is mutually exclusive with arguments: - [from_repository, package_expr]. - -v, --verbosity LVL Either CRITICAL, ERROR, WARNING, INFO or DEBUG - --help Show this message and exit. - ``` -- Example: - ``` - admin@sonic:~$ sonic-package-manager show package manifest dhcp-relay=2.0.0 - { - "version": "1.0.0", - "package": { - "version": "2.0.0", - "depends": [ - "database>=1.0.0,<2.0.0" - ] - }, - "service": { - "name": "dhcp_relay" - } - } - ``` - -### SONiC Installer -This is a command line tool available as part of the SONiC software; If the device is already running the SONiC software, this tool can be used to install an alternate image in the partition. -This tool has facility to install an alternate image, list the available images and to set the next reboot image. -This command requires elevated (root) privileges to run. - -**sonic-installer list** - -This command displays information about currently installed images. It displays a list of installed images, currently running image and image set to be loaded in next reboot. - -- Usage: - ``` - sonic-installer list - ``` - -- Example: - ``` - admin@sonic:~$ sudo sonic-installer list - Current: SONiC-OS-HEAD.XXXX - Next: SONiC-OS-HEAD.XXXX - Available: - SONiC-OS-HEAD.XXXX - SONiC-OS-HEAD.YYYY - ``` - -TIP: This output can be obtained without evelated privileges by running the `show boot` command. See [here](#show-system-status) for details. - -**sonic-installer install** - -This command is used to install a new image on the alternate image partition. This command takes a path to an installable SONiC image or URL and installs the image. - -- Usage: - ``` - sonic-installer install - ``` - -- Example: - ``` - admin@sonic:~$ sudo sonic-installer install https://sonic-jenkins.westus.cloudapp.azure.com/job/xxxx/job/buildimage-xxxx-all/xxx/artifact/target/sonic-xxxx.bin - New image will be installed, continue? [y/N]: y - Downloading image... - ...100%, 480 MB, 3357 KB/s, 146 seconds passed - Command: /tmp/sonic_image - Verifying image checksum ... OK. - Preparing image archive ... OK. - ONIE Installer: platform: XXXX - onie_platform: - Installing SONiC in SONiC - Installing SONiC to /host/image-xxxx - Directory /host/image-xxxx/ already exists. Cleaning up... - Archive: fs.zip - creating: /host/image-xxxx/boot/ - inflating: /host/image-xxxx/boot/vmlinuz-3.16.0-4-amd64 - inflating: /host/image-xxxx/boot/config-3.16.0-4-amd64 - inflating: /host/image-xxxx/boot/System.map-3.16.0-4-amd64 - inflating: /host/image-xxxx/boot/initrd.img-3.16.0-4-amd64 - creating: /host/image-xxxx/platform/ - extracting: /host/image-xxxx/platform/firsttime - inflating: /host/image-xxxx/fs.squashfs - inflating: /host/image-xxxx/dockerfs.tar.gz - Log file system already exists. Size: 4096MB - Installed SONiC base image SONiC-OS successfully - - Command: cp /etc/sonic/minigraph.xml /host/ - - Command: grub-set-default --boot-directory=/host 0 - - Done - ``` - -Installing a new image using the sonic-installer will keep using the packages installed on the currently running SONiC image and automatically migrate those. In order to perform clean SONiC installation use the *--skip-package-migration* option: - -- Example: - ``` - admin@sonic:~$ sudo sonic-installer install https://sonic-jenkins.westus.cloudapp.azure.com/job/xxxx/job/buildimage-xxxx-all/xxx/artifact/target/sonic-xxxx.bin --skip-package-migration - ``` - -**sonic-installer set_default** - -This command is be used to change the image which can be loaded by default in all the subsequent reboots. - -- Usage: - ``` - sonic-installer set_default - ``` - -- Example: - ``` - admin@sonic:~$ sudo sonic-installer set_default SONiC-OS-HEAD.XXXX - ``` - -**sonic-installer set_next_boot** - -This command is used to change the image that can be loaded in the *next* reboot only. Note that it will fallback to current image in all other subsequent reboots after the next reboot. - -- Usage: - ``` - sonic-installer set_next_boot - ``` - -- Example: - ``` - admin@sonic:~$ sudo sonic-installer set_next_boot SONiC-OS-HEAD.XXXX - ``` - -**sonic-installer remove** - -This command is used to remove the unused SONiC image from the disk. Note that it's *not* allowed to remove currently running image. - -- Usage: - ``` - sonic-installer remove [-y|--yes] - ``` - -- Example: - ``` - admin@sonic:~$ sudo sonic-installer remove SONiC-OS-HEAD.YYYY - Image will be removed, continue? [y/N]: y - Updating GRUB... - Done - Removing image root filesystem... - Done - Command: grub-set-default --boot-directory=/host 0 - - Image removed - ``` - -**sonic-installer cleanup** - -This command removes all unused images from the device, leaving only the currently active image and the image which will be booted into next (if different) installed. If there are no images which can be removed, the command will output `No image(s) to remove` - -- Usage: - ``` - sonic-installer cleanup [-y|--yes] - ``` - -- Example: - ``` - admin@sonic:~$ sudo sonic-installer cleanup - Remove images which are not current and next, continue? [y/N]: y - No image(s) to remove - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#software-installation-and-management) - - - -## Troubleshooting Commands - -For troubleshooting and debugging purposes, this command gathers pertinent information about the state of the device; information is as diverse as syslog entries, database state, routing-stack state, etc., It then compresses it into an archive file. This archive file can be sent to the SONiC development team for examination. -Resulting archive file is saved as `/var/dump/_YYYYMMDD_HHMMSS.tar.gz` - -- Usage: - ``` - show techsupport - ``` - -- Example: - ``` - admin@sonic:~$ show techsupport [--since=] - ``` - -If the SONiC system was running for quite some time `show techsupport` will produce a large dump file. To reduce the amount of syslog and core files gathered during system dump use `--since` option: - -- Examples: - ``` - admin@sonic:~$ show techsupport --since=yesterday # Will collect syslog and core files for the last 24 hours - ``` - ``` - admin@sonic:~$ show techsupport --since='hour ago' # Will collect syslog and core files for the last one hour - ``` - -### Debug Dumps - -In SONiC, there usually exists a set of tables related/relevant to a particular module. All of these might have to be looked at to confirm whether any configuration update is properly applied and propagated. This utility comes in handy because it prints a unified view of the redis-state for a given module - -- Usage: - ``` - Usage: dump state [OPTIONS] MODULE IDENTIFIER - Dump the redis-state of the identifier for the module specified - - Options: - -s, --show Display Modules Available - -d, --db TEXT Only dump from these Databases - -t, --table Print in tabular format [default: False] - -k, --key-map Only fetch the keys matched, don't extract field-value dumps [default: False] - -v, --verbose Prints any intermediate output to stdout useful for dev & troubleshooting [default: False] - -n, --namespace TEXT Dump the redis-state for this namespace. [default: DEFAULT_NAMESPACE] - --help Show this message and exit. - ``` - - -- Examples: - ``` - root@sonic# dump state --show - Module Identifier - -------- ------------ - port port_name - copp trap_id - ``` - - ``` - admin@sonic:~$ dump state copp arp_req --key-map --db ASIC_DB - { - "arp_req": { - "ASIC_DB": { - "keys": [ - "ASIC_STATE:SAI_OBJECT_TYPE_HOSTIF_TRAP:oid:0x22000000000c5b", - "ASIC_STATE:SAI_OBJECT_TYPE_HOSTIF_TRAP_GROUP:oid:0x11000000000c59", - "ASIC_STATE:SAI_OBJECT_TYPE_POLICER:oid:0x12000000000c5a", - "ASIC_STATE:SAI_OBJECT_TYPE_QUEUE:oid:0x15000000000626" - ], - "tables_not_found": [], - "vidtorid": { - "oid:0x22000000000c5b": "oid:0x200000000022", - "oid:0x11000000000c59": "oid:0x300000011", - "oid:0x12000000000c5a": "oid:0x200000012", - "oid:0x15000000000626": "oid:0x12e0000040015" - } - } - } - } - ``` - -### Event Driven Techsupport Invocation - -This feature/capability makes the techsupport invocation event-driven based on core dump generation. This feature is only applicable for the processes running in the containers. More detailed explanation can be found in the HLD https://github.com/Azure/SONiC/blob/master/doc/auto_techsupport_and_coredump_mgmt.md - -#### config auto-techsupport global commands - -**config auto-techsupport global state** - -- Usage: - ``` - config auto-techsupport global state - ``` - -- Example: - ``` - config auto-techsupport global state enabled - ``` - -**config auto-techsupport global rate-limit-interval ** - -- Usage: - ``` - config auto-techsupport global rate-limit-interval - ``` - - Parameters: - - rate-limit-interval: Minimum time in seconds to wait after the last techsupport creation time before invoking a new one. - -- Example: - ``` - config auto-techsupport global rate-limit-interval 200 - ``` - -**config auto-techsupport global max-techsupport-limit ** - -- Usage: - ``` - config auto-techsupport global max-techsupport-limit - ``` - - Parameters: - - max-techsupport-limit: A percentage value should be specified. This signifies maximum size to which /var/dump/ directory can be grown until. - -- Example: - ``` - config auto-techsupport global max-techsupport-limit 10.15 - ``` - -**config auto-techsupport global max-core-limit ** - -- Usage: - ``` - config auto-techsupport global max-core-limit - ``` - - Parameters: - - max-core-limit: A percentage value should be specified. This signifies maximum size to which /var/core/ directory can be grown until. - -- Example: - ``` - config auto-techsupport global max-core-limit 10.15 - ``` - -**config auto-techsupport global since** - -- Usage: - ``` - config auto-techsupport global since - ``` - - Parameters: - - since: This limits the auto-invoked techsupport to only collect the logs & core-dumps generated since the time provided. Any valid date string of the formats specified here can be used. (https://www.gnu.org/software/coreutils/manual/html_node/Date-input-formats.html). If this value is not explicitly configured or a non-valid string is provided, a default value of "2 days ago" is used. - -- Example: - ``` - config auto-techsupport global since - ``` - - -#### config auto-techsupport-feature commands - -**config auto-techsupport-feature add** - -- Usage: - ``` - config auto-techsupport-feature add --state --rate-limit-interval - ``` - - Parameters: - - state: enable/disable the capability for the specific feature/container. - - rate-limit-interval: Rate limit interval for the corresponding feature. Configure 0 to explicitly disable. For the techsupport to be generated by auto-techsupport, both the global and feature specific rate-limit-interval has to be passed - -- Example: - ``` - config auto-techsupport-feature add bgp --state enabled --rate-limit-interval 200 - ``` - - -**config auto-techsupport-feature delete** - -- Usage: - ``` - config auto-techsupport-feature delete - ``` - -- Example: - ``` - config auto-techsupport-feature delete swss - ``` - -**config auto-techsupport-feature update** - -- Usage: - ``` - config auto-techsupport-feature update --state - config auto-techsupport-feature update --rate-limit-interval - ``` - -- Example: - ``` - config auto-techsupport-feature update snmp --state enabled - config auto-techsupport-feature update swss --rate-limit-interval 200 - ``` - -#### Show CLI: - -**show auto-techsupport global** - -- Usage: - ``` - show auto-techsupport global - ``` - -- Example: - ``` - admin@sonic:~$ show auto-techsupport global - STATE RATE LIMIT INTERVAL (sec) MAX TECHSUPPORT LIMIT (%) MAX CORE LIMIT (%) SINCE - ------- --------------------------- -------------------------- ------------------ ---------- - enabled 180 10.0 5.0 2 days ago - ``` - -**show auto-techsupport-feature** - -- Usage: - ``` - show auto-techsupport-feature - ``` - -- Example: - ``` - admin@sonic:~$ show auto-techsupport-feature - FEATURE NAME STATE RATE LIMIT INTERVAL (sec) - -------------- -------- -------------------------- - bgp enabled 600 - database enabled 600 - dhcp_relay enabled 600 - lldp enabled 600 - swss disabled 800 - ``` - -**show auto-techsupport history** - -- Usage: - ``` - show auto-techsupport history - ``` - -- Example: - ``` - admin@sonic:~$ show auto-techsupport history - TECHSUPPORT DUMP TRIGGERED BY CORE DUMP - ---------------------------------------- -------------- ----------------------------- - sonic_dump_r-lionfish-16_20210901_221402 bgp bgpcfgd.1630534439.55.core.gz - sonic_dump_r-lionfish-16_20210901_203725 snmp python3.1630528642.23.core.gz - sonic_dump_r-lionfish-16_20210901_222408 teamd python3.1630535045.34.core.gz - ``` - -Go Back To [Beginning of the document](#) or [Beginning of this section](#troubleshooting-commands) - -## Routing Stack - -SONiC software is agnostic of the routing software that is being used in the device. For example, users can use either Quagga or FRR routing stack as per their requirement. -A separate shell (vtysh) is provided to configure such routing stacks. -Once if users go to "vtysh", they can use the routing stack specific commands as given in the following example. - -- Example (Quagga Routing Stack): - ``` - admin@sonic:~$ vtysh - - Hello, this is Quagga (version 0.99.24.1). - Copyright 1996-2005 Kunihiro Ishiguro, et al. - - sonic# show route-map (This command displays the route-map that is configured for the routing protocol.) - ZEBRA: - route-map RM_SET_SRC, permit, sequence 10 - Match clauses: - Set clauses: - src 10.12.0.102 - Call clause: - Action: - Exit routemap - ``` - -Refer the routing stack [Quagga Command Reference](https://www.quagga.net/docs/quagga.pdf) or [FRR Command Reference](https://buildmedia.readthedocs.org/media/pdf/frrouting/latest/frrouting.pdf) to know more about about the routing stack configuration. - - -Go Back To [Beginning of the document](#) or [Beginning of this section](#routing-stack) - - -## Quagga BGP Show Commands - -**show ip bgp summary** - -This command displays the summary of all IPv4 bgp neighbors that are configured and the corresponding states. - -- Usage: - ``` - show ip bgp summary - ``` - -- Example: - ``` - admin@sonic:~$ show ip bgp summary - BGP router identifier 1.2.3.4, local AS number 65061 - RIB entries 6124, using 670 KiB of memory - Peers 2, using 143 KiB of memory - - Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd - 192.168.1.161 4 65501 88698 102781 0 0 0 08w5d14h 2 - 192.168.1.163 4 65502 88698 102780 0 0 0 08w5d14h 2 - - Total number of neighbors 2 - ``` - -**show ip bgp neighbors** - -This command displays all the details of IPv4 & IPv6 BGP neighbors when no optional argument is specified. - -When the optional argument IPv4_address is specified, it displays the detailed neighbor information about that specific IPv4 neighbor. - -Command has got additional optional arguments to display only the advertised routes, or the received routes, or all routes. - -In order to get details for an IPv6 neigbor, use "show ipv6 bgp neighbor " command. - -- Usage: - ``` - show ip bgp neighbors [ [advertised-routes | received-routes | routes]] - ``` - -- Example: - ``` - admin@sonic:~$ show ip bgp neighbors - BGP neighbor is 192.168.1.161, remote AS 65501, local AS 65061, external link - Description: ARISTA01T0 - BGP version 4, remote router ID 1.2.3.4 - BGP state = Established, up for 08w5d14h - Last read 00:00:46, hold time is 180, keepalive interval is 60 seconds - Neighbor capabilities: - 4 Byte AS: advertised and received - Dynamic: received - Route refresh: advertised and received(old & new) - Address family IPv4 Unicast: advertised and received - Graceful Restart Capabilty: advertised and received - Remote Restart timer is 120 seconds - Address families by peer: - IPv4 Unicast(not preserved) - Graceful restart informations: - End-of-RIB send: IPv4 Unicast - End-of-RIB received: IPv4 Unicast - Message statistics: - Inq depth is 0 - Outq depth is 0 - Sent Rcvd - Opens: 1 1 - Notifications: 0 0 - Updates: 14066 3 - Keepalives: 88718 88698 - Route Refresh: 0 0 - Capability: 0 0 - Total: 102785 88702 - Minimum time between advertisement runs is 30 seconds - - For address family: IPv4 Unicast - Community attribute sent to this neighbor(both) - 2 accepted prefixes - - Connections established 1; dropped 0 - Last reset never - Local host: 192.168.1.160, Local port: 32961 - Foreign host: 192.168.1.161, Foreign port: 179 - Nexthop: 192.168.1.160 - Nexthop global: fe80::f60f:1bff:fe89:bc00 - Nexthop local: :: - BGP connection: non shared network - Read thread: on Write thread: off - ``` - -Optionally, you can specify an IP address in order to display only that particular neighbor. In this mode, you can optionally specify whether you want to display all routes advertised to the specified neighbor, all routes received from the specified neighbor or all routes (received and accepted) from the specified neighbor. - - -- Examples: - ``` - admin@sonic:~$ show ip bgp neighbors 192.168.1.161 - - admin@sonic:~$ show ip bgp neighbors 192.168.1.161 advertised-routes - - admin@sonic:~$ show ip bgp neighbors 192.168.1.161 received-routes - - admin@sonic:~$ show ip bgp neighbors 192.168.1.161 routes - ``` - -**show ipv6 bgp summary** - -This command displays the summary of all IPv4 bgp neighbors that are configured and the corresponding states. - -- Usage: - ``` - show ipv6 bgp summary - ``` - -- Example: - ``` - admin@sonic:~$ show ipv6 bgp summary - BGP router identifier 10.1.0.32, local AS number 65100 - RIB entries 12809, using 1401 KiB of memory - Peers 8, using 36 KiB of memory - - Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd - fc00::72 4 64600 12588 12591 0 0 0 06:51:17 6402 - fc00::76 4 64600 12587 6190 0 0 0 06:51:28 6402 - fc00::7a 4 64600 12587 9391 0 0 0 06:51:23 6402 - fc00::7e 4 64600 12589 12592 0 0 0 06:51:25 6402 - - Total number of neighbors 4 - ``` - -**show ipv6 bgp neighbors** - -This command displays all the details of one particular IPv6 Border Gateway Protocol (BGP) neighbor. Option is also available to display only the advertised routes, or the received routes, or all routes. - -- Usage: - ``` - show ipv6 bgp neighbors (advertised-routes | received-routes | routes) - ``` - -- Examples: - ``` - admin@sonic:~$ show ipv6 bgp neighbors fc00::72 advertised-routes - - admin@sonic:~$ show ipv6 bgp neighbors fc00::72 received-routes - - admin@sonic:~$ show ipv6 bgp neighbors fc00::72 routes - ``` - -**show route-map** - -This command displays the routing policy that takes precedence over the other route processes that are configured. - -- Usage: - ``` - show route-map - ``` - -- Example: - ``` - admin@sonic:~$ show route-map - ZEBRA: - route-map RM_SET_SRC, permit, sequence 10 - Match clauses: - Set clauses: - src 10.12.0.102 - Call clause: - Action: - Exit routemap - ZEBRA: - route-map RM_SET_SRC6, permit, sequence 10 - Match clauses: - Set clauses: - src fc00:1::102 - Call clause: - Action: - Exit routemap - BGP: - route-map FROM_BGP_SPEAKER_V4, permit, sequence 10 - Match clauses: - Set clauses: - Call clause: - Action: - Exit routemap - BGP: - route-map TO_BGP_SPEAKER_V4, deny, sequence 10 - Match clauses: - Set clauses: - Call clause: - Action: - Exit routemap - BGP: - route-map ISOLATE, permit, sequence 10 - Match clauses: - Set clauses: - as-path prepend 65000 - Call clause: - Action: - Exit routemap - ``` -Go Back To [Beginning of the document](#) or [Beginning of this section](#quagga-bgp-show-commands) - -# ZTP Configuration And Show Commands - -This section explains all the Zero Touch Provisioning commands that are supported in SONiC. - -## ZTP show commands - - -This command displays the current ZTP configuration of the switch. It also displays detailed information about current state of a ZTP session. It displays information related to all configuration sections as defined in the switch provisioning information discovered in a particular ZTP session. - -- Usage: - show ztp status - - show ztp status --verbose - -- Example: - -``` -root@B1-SP1-7712:/home/admin# show ztp status -ZTP Admin Mode : True -ZTP Service : Inactive -ZTP Status : SUCCESS -ZTP Source : dhcp-opt67 (eth0) -Runtime : 05m 31s -Timestamp : 2019-09-11 19:12:24 UTC - -ZTP Service is not running - -01-configdb-json: SUCCESS -02-connectivity-check: SUCCESS -``` -Use the verbose option to display more detailed information. - -``` -root@B1-SP1-7712:/home/admin# show ztp status --verbose -Command: ztp status --verbose -======================================== -ZTP -======================================== -ZTP Admin Mode : True -ZTP Service : Inactive -ZTP Status : SUCCESS -ZTP Source : dhcp-opt67 (eth0) -Runtime : 05m 31s -Timestamp : 2019-09-11 19:12:16 UTC -ZTP JSON Version : 1.0 - -ZTP Service is not running - ----------------------------------------- -01-configdb-json ----------------------------------------- -Status : SUCCESS -Runtime : 02m 48s -Timestamp : 2019-09-11 19:11:55 UTC -Exit Code : 0 -Ignore Result : False - ----------------------------------------- -02-connectivity-check ----------------------------------------- -Status : SUCCESS -Runtime : 04s -Timestamp : 2019-09-11 19:12:16 UTC -Exit Code : 0 -Ignore Result : False -``` - -- Description - - - **ZTP Admin Mode** - Displays if the ZTP feature is administratively enabled or disabled. Possible values are True or False. This value is configurable using "config ztp enabled" and "config ztp disable" commands. - - **ZTP Service** - Displays the ZTP service status. The following are possible values this field can display: - - *Active Discovery*: ZTP service is operational and is performing DHCP discovery to learn switch provisioning information - - *Processing*: ZTP service has discovered switch provisioning information and is processing it - - **ZTP Status** - Displays the current state and result of ZTP session. The following are possible values this field can display: - - *IN-PROGRESS*: ZTP session is currently in progress. ZTP service is processing switch provisioning information. - - *SUCCESS*: ZTP service has successfully processed the switch provisioning information. - - *FAILED*: ZTP service has failed to process the switch provisioning information. - - *Not Started*: ZTP service has not started processing the discovered switch provisioning information. - - **ZTP Source** - Displays the DHCP option and then interface name from which switch provisioning information has been discovered. - - **Runtime** - Displays the time taken for ZTP process to complete from start to finish. For individual configuration sections it indicates the time taken to process the associated configuration section. - - **Timestamp** - Displays the date/time stamp when the status field has last changed. - - **ZTP JSON Version** - Version of ZTP JSON file used for describing switch provisioning information. - - **Status** - Displays the current state and result of a configuration section. The following are possible values this field can display: - - *IN-PROGRESS*: Corresponding configuration section is currently being processed. - - *SUCCESS*: Corresponding configuration section was processed successfully. - - *FAILED*: Corresponding configuration section failed to execute successfully. - - *Not Started*: ZTP service has not started processing the corresponding configuration section. - - *DISABLED*: Corresponding configuration section has been marked as disabled and will not be processed. - - **Exit Code** - Displays the program exit code of the configuration section executed. Non-zero exit code indicates that the configuration section has failed to execute successfully. - - **Ignore Result** - If this value is True, the result of the corresponding configuration section is ignored and not used to evaluate the overall ZTP result. - - **Activity String** - In addition to above information an activity string is displayed indicating the current action being performed by the ZTP service and how much time it has been performing the mentioned activity. Below is an example. - - (04m 12s) Discovering provisioning data - -## ZTP configuration commands - -This sub-section explains the list of the configuration options available for ZTP. - - - -**config ztp enable** - -Use this command to enable ZTP administrative mode - -- Example: - -``` -root@sonic:/home/admin# config ztp enable -Running command: ztp enable -``` - - - -**config ztp disable** - -Use this command to disable ZTP administrative mode. This command can also be used to abort a current ZTP session and load the factory default switch configuration. - -- Usage: - config ztp disable - - config ztp disable -y - -- Example: - -``` -root@sonic:/home/admin# config ztp disable -Active ZTP session will be stopped and disabled, continue? [y/N]: y -Running command: ztp disable -y -``` - - -**config ztp run** - -Use this command to manually restart a new ZTP session. This command deletes the existing */etc/sonic/config_db.json* file and stats ZTP service. It also erases the previous ZTP session data. ZTP configuration is loaded on to the switch and ZTP discovery is performed. - -- Usage: - config ztp run - - config ztp run -y - -- Example: - -``` -root@sonic:/home/admin# config ztp run -ZTP will be restarted. You may lose switch data and connectivity, continue? [y/N]: y -Running command: ztp run -y -``` - -Go Back To [Beginning of the document](#SONiC-COMMAND-LINE-INTERFACE-GUIDE) or [Beginning of this section](#ztp-configuration-and-show-commands) +<<<<<<< clidoc_202205_update +<<<<<<< clidoc_202205_update +# SONiC Command Line Interface Guide + +## Table of Contents + +* [Document History](#document-history) +* [Introduction](#introduction) +* [Basic Tasks](#basic-tasks) + * [SSH Login](#ssh-login) + * [Show Management Interface](#show-management-interface) + * [Configuring Management Interface](#configuring-management-interface) +* [Getting Help](#getting-help) + * [Help for Config Commands](#help-for-config-commands) + * [Help for Show Commands](#help-for-show-commands) +* [Basic Show Commands](#basic-show-commands) + * [Show Versions](#show-versions) + * [Show System Status](#show-system-status) + * [Show Hardware Platform](#show-hardware-platform) + * [Transceivers](#transceivers) +* [AAA & TACACS+](#aaa--tacacs) + * [AAA](#aaa) + * [AAA show commands](#aaa-show-commands) + * [AAA config commands](#aaa-config-commands) + * [TACACS+](#tacacs) + * [TACACS+ show commands](#tacacs-show-commands) + * [TACACS+ config commands](#tacacs-config-commands) +* [ACL](#acl) + * [ACL show commands](#acl-show-commands) + * [ACL config commands](#acl-config-commands) +* [ARP & NDP](#arp--ndp) + * [ARP show commands](#arp-show-commands) + * [NDP show commands](#ndp-show-commands) +* [BFD](#bfd) + * [BFD show commands](#bfd-show-commands) +* [BGP](#bgp) + * [BGP show commands](#bgp-show-commands) + * [BGP config commands](#bgp-config-commands) +* [Console](#console) + * [Console show commands](#console-show-commands) + * [Console config commands](#console-config-commands) + * [Console connect commands](#console-connect-commands) + * [Console clear commands](#console-clear-commands) +* [DHCP Relay](#dhcp-relay) + * [DHCP Relay config commands](#dhcp-relay-config-commands) +* [Drop Counters](#drop-counters) + * [Drop Counter show commands](#drop-counters-show-commands) + * [Drop Counter config commands](#drop-counters-config-commands) + * [Drop Counter clear commands](#drop-counters-clear-commands) +* [Dynamic Buffer Management](#dynamic-buffer-management) + * [Configuration commands](#configuration-commands) + * [Show commands](#show-commands) +* [ECN](#ecn) + * [ECN show commands](#ecn-show-commands) + * [ECN config commands](#ecn-config-commands) +* [Feature](#feature) + * [Feature show commands](#feature-show-commands) + * [Feature config commands](#feature-config-commands) +* [Flow Counters](#flow-counters) + * [Flow Counters show commands](#flow-counters-show-commands) + * [Flow Counters clear commands](#flow-counters-clear-commands) + * [Flow Counters config commands](#flow-counters-config-commands) +* [Gearbox](#gearbox) + * [Gearbox show commands](#gearbox-show-commands) +* [Generic Configuration Update and Rollback](#Generic-Configuration-Update-and-Rollback) + * [Apply-patch command](#Apply-patch-command) + * [Replace Command](#Replace-Command) + * [Rollback Command](#Rollback-Command) + * [Checkpoint Command](#Checkpoint-Command) + * [Delete-checkpoint Command](#Delete-checkpoint-Command) + * [List-checkpoints Command](#List-checkpoints-Command) +* [Interfaces](#interfaces) + * [Interface Show Commands](#interface-show-commands) + * [Interface Config Commands](#interface-config-commands) +* [Interface Naming Mode](#interface-naming-mode) + * [Interface naming mode show commands](#interface-naming-mode-show-commands) + * [Interface naming mode config commands](#interface-naming-mode-config-commands) + * [Interface Vrf binding](#interface-vrf-binding) + * [Interface vrf bind & unbind config commands](#interface-vrf-bind-&-unbind-config-commands) + * [Interface vrf binding show commands](#interface-vrf-binding-show-commands) +* [IP / IPv6](#ip--ipv6) + * [IP show commands](#ip-show-commands) + * [IPv6 show commands](#ipv6-show-commands) +* [IPv6 Link Local](#ipv6-link-local) + * [IPv6 Link Local config commands](#ipv6-link-local-config-commands) + * [IPv6 Link Local show commands](#ipv6-link-local-show-commands) +* [Kubernetes](#Kubernetes) + * [Kubernetes show commands](#Kubernetes-show-commands) + * [Kubernetes config commands](#Kubernetes-config-commands) +* [Linux Kernel Dump](#kdump) + * [Linux Kernel Dump show commands](#kdump-show-commands) + * [Linux Kernel Dump config commands](#kdump-config-commands) +* [LLDP](#lldp) + * [LLDP show commands](#lldp-show-commands) +* [Loading, Reloading And Saving Configuration](#loading-reloading-and-saving-configuration) + * [Loading configuration from JSON file](#loading-configuration-from-json-file) + * [Loading configuration from minigraph (XML) file](#loading-configuration-from-minigraph-xml-file) + * [Reloading Configuration](#reloading-configuration) + * [Loading Management Configuration](#loading-management-configuration) + * [Saving Configuration to a File for Persistence](saving-configuration-to-a-file-for-persistence) + * [Loopback Interfaces](#loopback-interfaces) + * [Loopback show commands](#loopback-show-commands) + * [Loopback config commands](#loopback-config-commands) + * [MACsec Commands](#macsec-commands) + * [MACsec config command](#macsec-config-command) + * [MACsec show command](#macsec-show-command) + * [MACsec clear command](#macsec-clear-command) +* [VRF Configuration](#vrf-configuration) + * [VRF show commands](#vrf-show-commands) + * [VRF config commands](#vrf-config-commands) +* [Management VRF](#Management-VRF) + * [Management VRF Show commands](#management-vrf-show-commands) + * [Management VRF Config commands](#management-vrf-config-commands) +* [Mirroring](#mirroring) + * [Mirroring Show commands](#mirroring-show-commands) + * [Mirroring Config commands](#mirroring-config-commands) +* [Muxcable](#muxcable) + * [Muxcable Show commands](#muxcable-show-commands) + * [Muxcable Config commands](#muxcable-config-commands) +* [NAT](#nat) + * [NAT Show commands](#nat-show-commands) + * [NAT Config commands](#nat-config-commands) + * [NAT Clear commands](#nat-clear-commands) +* [NTP](#ntp) + * [NTP show commands](#ntp-show-commands) + * [NTP config commands](#ntp-config-commands) +* [NVGRE](#nvgre) + * [NVGRE show commands](#nvgre-show-commands) + * [NVGRE config commands](#nvgre-config-commands) +* [Password Hardening](#Password-Hardening) + * [PW config commands](#pw-config-commands) + * [PW show commands](#pw-show-commands) +* [PBH](#pbh) + * [PBH show commands](#pbh-show-commands) + * [PBH config commands](#pbh-config-commands) +* [PFC Watchdog Commands](#pfc-watchdog-commands) +* [Platform Component Firmware](#platform-component-firmware) + * [Platform Component Firmware show commands](#platform-component-firmware-show-commands) + * [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) +* [QoS](#qos) + * [QoS Show commands](#qos-show-commands) + * [PFC](#pfc) + * [Queue And Priority-Group](#queue-and-priority-group) + * [Buffer Pool](#buffer-pool) + * [QoS config commands](#qos-config-commands) +* [Radius](#radius) + * [radius show commands](#show-radius-commands) + * [radius config commands](#Radius-config-commands) +* [sFlow](#sflow) + * [sFlow Show commands](#sflow-show-commands) + * [sFlow Config commands](#sflow-config-commands) +* [SNMP](#snmp) + * [SNMP Show commands](#snmp-show-commands) + * [SNMP Config commands](#snmp-config-commands) +* [Startup & Running Configuration](#startup--running-configuration) + * [Startup Configuration](#startup-configuration) + * [Running Configuration](#running-configuration) +* [Static routing](#static-routing) +* [Subinterfaces](#subinterfaces) + * [Subinterfaces Show Commands](#subinterfaces-show-commands) + * [Subinterfaces Config Commands](#subinterfaces-config-commands) +* [Syslog](#syslog) + * [Syslog config commands](#syslog-config-commands) +* [System State](#system-state) + * [Processes](#processes) + * [Services & Memory](#services--memory) +* [System-Health](#System-Health) +* [VLAN & FDB](#vlan--fdb) + * [VLAN](#vlan) + * [VLAN show commands](#vlan-show-commands) + * [VLAN Config commands](#vlan-config-commands) + * [FDB](#fdb) + * [FDB show commands](#fdb-show-commands) +* [VxLAN & Vnet](#vxlan--vnet) + * [VxLAN](#vxlan) + * [VxLAN show commands](#vxlan-show-commands) + * [Vnet](#vnet) + * [Vnet show commands](#vnet-show-commands) +* [Warm Reboot](#warm-reboot) +* [Warm Restart](#warm-restart) + * [Warm Restart show commands](#warm-restart-show-commands) + * [Warm Restart Config commands](#warm-restart-config-commands) +* [Watermark](#watermark) + * [Watermark Show commands](#watermark-show-commands) + * [Watermark Config commands](#watermark-config-commands) +* [Software Installation and Management](#software-installation-and-management) + * [SONiC Package Manager](#sonic-package-manager) + * [SONiC Installer](#sonic-installer) +* [Troubleshooting Commands](#troubleshooting-commands) + * [Debug Dumps](#debug-dumps) + * [Event Driven Techsupport Invocation](#event-driven-techsupport-invocation) +* [Routing Stack](#routing-stack) +* [Quagga BGP Show Commands](#Quagga-BGP-Show-Commands) +* [ZTP Configuration And Show Commands](#ztp-configuration-and-show-commands) + * [ ZTP show commands](#ztp-show-commands) + * [ZTP configuration commands](#ztp-configuration-commands) + +## Document History + +| Version | Modification Date | Details | +| --- | --- | --- | +| v6 | May-06-2021 | Add SNMP show and config commands | +| v5 | Nov-05-2020 | Add document for console commands | +| v4 | Oct-17-2019 | Unify usage statements and other formatting; Replace tabs with spaces; Modify heading sizes; Fix spelling, grammar and other errors; Fix organization of new commands | +| v3 | Jun-26-2019 | Update based on 201904 (build#19) release, "config interface" command changes related to interfacename order, FRR/Quagga show command changes, platform specific changes, ACL show changes and few formatting changes | +| v2 | Apr-22-2019 | CLI Guide for SONiC 201811 version (build#32) with complete "config" command set | +| v1 | Mar-23-2019 | Initial version of CLI Guide with minimal command set | + +## Introduction +SONiC is an open source network operating system based on Linux that runs on switches from multiple vendors and ASICs. SONiC offers a full-suite of network functionality, like BGP and RDMA, that has been production-hardened in the data centers of some of the largest cloud-service providers. It offers teams the flexibility to create the network solutions they need while leveraging the collective strength of a large ecosystem and community. + +SONiC software shall be loaded in these [supported devices](https://github.com/Azure/SONiC/wiki/Supported-Devices-and-Platforms) and this CLI guide shall be used to configure the devices as well as to display the configuration, state and status. + +Follow the [Quick Start Guide](https://github.com/Azure/SONiC/wiki/Quick-Start) to boot the device in ONIE mode, install the SONiC software using the steps specified in the document and login to the device using the default username and password. + +After logging into the device, SONiC software can be configured in following three methods. + 1. Command Line Interface (CLI) + 2. [config_db.json](https://github.com/Azure/SONiC/wiki/Configuration) + 3. [minigraph.xml](https://github.com/Azure/SONiC/wiki/Configuration-with-Minigraph-(~Sep-2017)) + +This document explains the first method and gives the complete list of commands that are supported in SONiC 201904 version (build#19). +All the configuration commands need root privileges to execute them. Note that show commands can be executed by all users without the root privileges. +Root privileges can be obtained either by using "sudo" keyword in front of all config commands, or by going to root prompt using "sudo -i". +Note that all commands are case sensitive. + +- Example: + ``` + admin@sonic:~$ sudo config aaa authentication login tacacs+ + + OR + + admin@sonic:~$ sudo -i + root@sonic:~# config aaa authentication login tacacs+ + ``` + +Note that the command list given in this document is just a subset of all possible configurations in SONiC. +Please follow config_db.json based configuration for the complete list of configuration options. + +**Scope of this Document** + +It is assumed that all configuration commands start with the keyword “config” as prefix. +Any other scripts/utilities/commands that need user configuration control are wrapped as sub-commands under the “config” command. +The direct scripts/utilities/commands (examples given below) that are not wrapped under the "config" command are not in the scope of this document. + 1. acl_loader – This script is already wrapped inside “config acl” command; i.e. any ACL configuration that user is allowed to do is already part of “config acl” command; users are not expected to use the acl_loader script directly and hence this document need not explain the “acl_loader” script. + 2. crm – this command is not explained in this document. + 3. sonic-clear, sfputil, etc., This document does not explain these scripts also. + +## Basic Tasks + +This section covers the basic configurations related to the following: + 1. [SSH login](#SSH-Login) + 2. [Configuring the Management Interface](#Configuring-Management-Interface) + +### SSH Login + +All SONiC devices support both the serial console based login and the SSH based login by default. +The default credential (if not modified at image build time) for login is `admin/YourPaSsWoRd`. +In case of SSH login, users can login to the management interface (eth0) IP address after configuring the same using serial console. +Refer the following section for configuring the IP address for management interface. + +- Example: + ``` + At Console: + Debian GNU/Linux 9 sonic ttyS1 + + sonic login: admin + Password: YourPaSsWoRd + + SSH from any remote server to sonic can be done by connecting to SONiC IP + user@debug:~$ ssh admin@sonic_ip_address(or SONIC DNS Name) + admin@sonic's password: + ``` + +By default, login takes the user to the default prompt from which all the show commands can be executed. + +Go Back To [Beginning of the document](#) or [Beginning of this section](#basic-tasks) + +### Show Management Interface + +Please check [show ip interfaces](#show-ip-interfaces) + +### Configuring Management Interface + +The management interface (eth0) in SONiC is configured (by default) to use DHCP client to get the IP address from the DHCP server. Connect the management interface to the same network in which your DHCP server is connected and get the IP address from DHCP server. +The IP address received from DHCP server can be verified using the `/sbin/ifconfig eth0` Linux command. + +SONiC provides a CLI to configure the static IP for the management interface. There are few ways by which a static IP address can be configured for the management interface. + 1. Use the `config interface ip add eth0` command. + - Example: + ``` + admin@sonic:~$ sudo config interface ip add eth0 20.11.12.13/24 20.11.12.254 + ``` + 2. Use config_db.json and configure the MGMT_INTERFACE key with the appropriate values. Refer [here](https://github.com/Azure/SONiC/wiki/Configuration#Management-Interface) + 3. Use minigraph.xml and configure "ManagementIPInterfaces" tag inside "DpgDesc" tag as given at the [page](https://github.com/Azure/SONiC/wiki/Configuration-with-Minigraph-(~Sep-2017)) + +Once the IP address is configured, the same can be verified using either `show management_interface address` command or the `/sbin/ifconfig eth0` linux command. +Users can SSH login to this management interface IP address from their management network. + +- Example: + ``` + admin@sonic:~$ /sbin/ifconfig eth0 + eth0: flags=4163 mtu 1500 + inet 10.11.11.13 netmask 255.255.255.0 broadcast 10.11.12.255 + ``` +Go Back To [Beginning of the document](#) or [Beginning of this section](#basic-tasks) + +## Getting Help + +Subsections: + 1. [Help for Config Commands](#Config-Help) + 2. [Help for Show Commands](#Show-Help) + 3. [Show Versions](#Show-Versions) + 4. [Show System Status](#Show-System-Status) + 5. [Show Hardware Platform](#Show-Hardware-Platform) + +### Help for Config Commands + +All commands have in-built help that aids the user in understanding the command as well as the possible sub-commands and options. +"--help" can be used at any level of the command; i.e. it can be used at the command level, or sub-command level or at argument level. The in-built help will display the available possibilities corresponding to that particular command/sub-command. + +**config --help** + +This command lists all the possible configuration commands at the top level. + +- Usage: + ``` + config --help + ``` + +- Example: + ``` + admin@sonic:~$ config --help + Usage: config [OPTIONS] COMMAND [ARGS] + SONiC command line - 'config' command + + Options: + --help Show this message and exit. + + Commands: + aaa AAA command line + acl ACL-related configuration tasks + bgp BGP-related configuration tasks + ecn ECN-related configuration tasks + feature Modify configuration of features + hostname Change device hostname without impacting traffic + interface Interface-related configuration tasks + interface_naming_mode Modify interface naming mode for interacting... + kubernetes Kubernetes server related configuration + load Import a previous saved config DB dump file. + load_mgmt_config Reconfigure hostname and mgmt interface based... + load_minigraph Reconfigure based on minigraph. + loopback Loopback-related configuration tasks. + mirror_session + nat NAT-related configuration tasks + platform Platform-related configuration tasks + portchannel + qos + reload Clear current configuration and import a... + route route-related configuration tasks + save Export current config DB to a file on disk. + tacacs TACACS+ server configuration + vlan VLAN-related configuration tasks + vrf VRF-related configuration tasks + warm_restart warm_restart-related configuration tasks + watermark Configure watermark + ``` +Go Back To [Beginning of the document](#) or [Beginning of this section](#getting-help) + +### Help For Show Commands + +**show help** + +This command displays the full list of show commands available in the software; the output of each of those show commands can be used to analyze, debug or troubleshoot the network node. + +- Usage: + ``` + show (-?|-h|--help) + ``` + +- Example: + ``` + admin@sonic:~$ show -? + Usage: show [OPTIONS] COMMAND [ARGS]... + SONiC command line - 'show' command + + Options: + -?, -h, --help Show this message and exit. + + Commands: + aaa Show AAA configuration + acl Show ACL related information + arp Show IP ARP table + buffer_pool Show details of the Buffer-pools + clock Show date and time + ecn Show ECN configuration + environment Show environmentals (voltages, fans, temps) + feature Show feature status + interfaces Show details of the network interfaces + ip Show IP (IPv4) commands + ipv6 Show IPv6 commands + kubernetes Show kubernetes commands + line Show all /dev/ttyUSB lines and their info + lldp Show LLDP information + logging Show system log + mac Show MAC (FDB) entries + mirror_session Show existing everflow sessions + mmu Show mmu configuration + muxcable Show muxcable information + nat Show details of the nat + ndp Show IPv6 Neighbour table + ntp Show NTP information + pfc Show details of the priority-flow-control... + platform Show platform-specific hardware info + priority-group Show details of the PGs + processes Show process information + queue Show details of the queues + reboot-cause Show cause of most recent reboot + route-map Show route-map + runningconfiguration Show current running configuration... + services Show all daemon services + startupconfiguration Show startup configuration information + subinterfaces Show details of the sub port interfaces + system-memory Show memory information + tacacs Show TACACS+ configuration + techsupport Gather information for troubleshooting + uptime Show system uptime + users Show users + version Show version information + vlan Show VLAN information + vrf Show vrf config + warm_restart Show warm restart configuration and state + watermark Show details of watermark + ``` + +The same syntax applies to all subgroups of `show` which themselves contain subcommands, and subcommands which accept options/arguments. + +- Example: + ``` + admin@sonic:~$ show interfaces -? + + Show details of the network interfaces + + Options: + -?, -h, --help Show this message and exit. + + Commands: + counters Show interface counters + description Show interface status, protocol and... + naming_mode Show interface naming_mode status + neighbor Show neighbor related information + portchannel Show PortChannel information + status Show Interface status information + tpid Show Interface tpid information + transceiver Show SFP Transceiver information + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#getting-help) + +## Basic Show Commands + +Subsections: + 1. [Show Versions](#Show-Versions) + 2. [Show System Status](#Show-System-Status) + 3. [Show Hardware Platform](#Show-Hardware-Platform) + +### Show Versions + +**show version** + +This command displays software component versions of the currently running SONiC image. This includes the SONiC image version as well as Docker image versions. +This command displays relevant information as the SONiC and Linux kernel version being utilized, as well as the ID of the commit used to build the SONiC image. The second section of the output displays the various docker images and their associated IDs. + +- Usage: + ``` + show version + ``` + +- Example: + ``` + admin@sonic:~$ show version + SONiC Software Version: SONiC.HEAD.32-21ea29a + Distribution: Debian 9.8 + Kernel: 4.9.0-8-amd64 + Build commit: 21ea29a + Build date: Fri Mar 22 01:55:48 UTC 2019 + Built by: johnar@jenkins-worker-4 + + Platform: x86_64-mlnx_msn2700-r0 + HwSKU: Mellanox-SN2700 + ASIC: mellanox + ASIC Count: 1 + Serial Number: MT1822K07815 + Model Number: MSN2700-CS2FO + Hardware Rev: A1 + Uptime: 14:40:15 up 3 min, 1 user, load average: 1.26, 1.45, 0.66 + Date: Fri 22 Mar 2019 14:40:15 + + Docker images: + REPOSITORY TAG IMAGE ID SIZE + docker-syncd-brcm HEAD.32-21ea29a 434240daff6e 362MB + docker-syncd-brcm latest 434240daff6e 362MB + docker-orchagent-brcm HEAD.32-21ea29a e4f9c4631025 287MB + docker-orchagent-brcm latest e4f9c4631025 287MB + docker-nat HEAD.32-21ea29a 46075edc1c69 305MB + docker-nat latest 46075edc1c69 305MB + docker-lldp-sv2 HEAD.32-21ea29a 9681bbfea3ac 275MB + docker-lldp-sv2 latest 9681bbfea3ac 275MB + docker-dhcp-relay HEAD.32-21ea29a 2db34c7bc6f4 257MB + docker-dhcp-relay latest 2db34c7bc6f4 257MB + docker-database HEAD.32-21ea29a badc6fc84cdb 256MB + docker-database latest badc6fc84cdb 256MB + docker-snmp-sv2 HEAD.32-21ea29a e2776e2a30b7 295MB + docker-snmp-sv2 latest e2776e2a30b7 295MB + docker-teamd HEAD.32-21ea29a caf957cd2ad1 275MB + docker-teamd latest caf957cd2ad1 275MB + docker-router-advertiser HEAD.32-21ea29a b1a62023958c 255MB + docker-router-advertiser latest b1a62023958c 255MB + docker-platform-monitor HEAD.32-21ea29a 40b40a4b2164 287MB + docker-platform-monitor latest 40b40a4b2164 287MB + docker-fpm-quagga HEAD.32-21ea29a 546036fe6838 282MB + docker-fpm-quagga latest 546036fe6838 282MB + ``` +Go Back To [Beginning of the document](#) or [Beginning of this section](#basic-show-commands) + + +### Show System Status +This sub-section explains some set of sub-commands that are used to display the status of various parameters pertaining to the physical state of the network node. + +**show clock** + +This command displays the current date and time configured on the system + +- Usage: + ``` + show clock + ``` + +- Example: + ``` + admin@sonic:~$ show clock + Mon Mar 25 20:25:16 UTC 2019 + ``` + +**show boot** + +This command displays the current OS image, the image to be loaded on next reboot, and lists all the available images installed on the device + +- Usage: + ``` + show boot + ``` + +- Example: + ``` + admin@sonic:~$ show boot + Current: SONiC-OS-20181130.31 + Next: SONiC-OS-20181130.31 + Available: + SONiC-OS-20181130.31 + ``` + +**show environment** + +This command displays the platform environmentals, such as voltages, temperatures and fan speeds + +- Usage: + ``` + show environment + ``` + +- Example: + ``` + admin@sonic:~$ show environment + coretemp-isa-0000 + Adapter: ISA adapter + Core 0: +28.0 C (high = +98.0 C, crit = +98.0 C) + Core 1: +28.0 C (high = +98.0 C, crit = +98.0 C) + Core 2: +28.0 C (high = +98.0 C, crit = +98.0 C) + Core 3: +28.0 C (high = +98.0 C, crit = +98.0 C) + SMF_Z9100_ON-isa-0000 + Adapter: ISA adapter + CPU XP3R3V_EARLY: +3.22 V + <... few more things ...> + + Onboard Temperature Sensors: + CPU: 30 C + BCM56960 (PSU side): 35 C + <... few more things ...> + + Onboard Voltage Sensors: + CPU XP3R3V_EARLY 3.22 V + <... few more things ...> + + Fan Trays: + Fan Tray 1: + Fan1 Speed: 6192 RPM + Fan2 Speed: 6362 RPM + Fan1 State: Normal + Fan2 State: Normal + Air Flow: F2B + <... few more things ...> + + PSUs: + PSU 1: + Input: AC + <... few more things ...> + ``` +NOTE: The show output has got lot of information; only the sample output is given in the above example. +Though the displayed output slightly differs from one platform to another platform, the overall content will be similar to the example mentioned above. + +**show reboot-cause** + +This command displays the cause of the previous reboot + +- Usage: + ``` + show reboot-cause + ``` + +- Example: + ``` + admin@sonic:~$ show reboot-cause + User issued reboot command [User: admin, Time: Mon Mar 25 01:02:03 UTC 2019] + ``` + +**show reboot-cause history** + +This command displays the history of the previous reboots up to 10 entry + +- Usage: + ``` + show reboot-cause history + ``` + +- Example: + ``` + admin@sonic:~$ show reboot-cause history + Name Cause Time User Comment + ------------------- ----------- ---------------------------- ------ --------- + 2020_10_09_02_33_06 reboot Fri Oct 9 02:29:44 UTC 2020 admin + 2020_10_09_01_56_59 reboot Fri Oct 9 01:53:49 UTC 2020 admin + 2020_10_09_02_00_53 fast-reboot Fri Oct 9 01:58:04 UTC 2020 admin + 2020_10_09_04_53_58 warm-reboot Fri Oct 9 04:51:47 UTC 2020 admin + ``` + +**show uptime** + +This command displays the current system uptime + +- Usage: + ``` + show uptime + ``` + +- Example: + ``` + admin@sonic:~$ show uptime + up 2 days, 21 hours, 30 minutes + ``` + +**show logging** + +This command displays all the currently stored log messages. +All the latest processes and corresponding transactions are stored in the "syslog" file. +This file is saved in the path `/var/log` and can be viewed by giving the command ` sudo cat syslog` as this requires root login. + +- Usage: + ``` + show logging [( [-l|--lines ]) | (-f|--follow)] + ``` + +- Example: + ``` + admin@sonic:~$ show logging + ``` + +It can be useful to pipe the output from `show logging` to the command `more` in order to examine one screenful of log messages at a time + +- Example: + ``` + admin@sonic:~$ show logging | more + ``` + +Optionally, you can specify a process name in order to display only log messages mentioning that process + +- Example: + ``` + admin@sonic:~$ show logging sensord + ``` + +Optionally, you can specify a number of lines to display using the `-l` or `--lines` option. Only the most recent N lines will be displayed. Also note that this option can be combined with a process name. + +- Examples: + ``` + admin@sonic:~$ show logging --lines 50 + ``` + ``` + admin@sonic:~$ show logging sensord --lines 50 + ``` + +Optionally, you can follow the log live as entries are written to it by specifying the `-f` or `--follow` flag + +- Example: + ``` + admin@sonic:~$ show logging --follow + ``` + +**show users** + +This command displays a list of users currently logged in to the device + +- Usage: + ``` + show users + ``` + +- Examples: + ``` + admin@sonic:~$ show users + admin pts/9 Mar 25 20:31 (100.127.20.23) + + admin@sonic:~$ show users + admin ttyS1 2019-03-25 20:31 + ``` +Go Back To [Beginning of the document](#) or [Beginning of this section](#basic-show-commands) + +### Show Hardware Platform + +The information displayed in this set of commands partially overlaps with the one generated by “show envinronment” instruction. In this case though, the information is presented in a more succinct fashion. In the future these two CLI stanzas may end up getting combined. + +**show platform summary** + +This command displays a summary of the device's hardware platform + +- Usage: + ``` + show platform summary + ``` + +- Example: + ``` + admin@sonic:~$ show platform summary + Platform: x86_64-mlnx_msn2700-r0 + HwSKU: Mellanox-SN2700 + ASIC: mellanox + ASIC Count: 1 + Serial Number: MT1822K07815 + Model Number: MSN2700-CS2FO + Hardware Rev: A1 + ``` + +**show platform syseeprom** + +This command displays information stored on the system EEPROM. +Note that the output of this command is not the same for all vendor's platforms. +Couple of example outputs are given below. + +- Usage: + ``` + show platform syseeprom + ``` + +- Example: + ``` + admin@sonic:~$ show platform syseeprom + lsTLV Name Len Value + -------------------- --- ----- + PPID 20 XX-XXXXXX-00000-000-0000 + DPN Rev 3 XXX + Service Tag 7 XXXXXXX + Part Number 10 XXXXXX + Part Number Rev 3 XXX + Mfg Test Results 2 FF + Card ID 2 0x0000 + Module ID 2 0 + Base MAC Address 12 FE:EC:BA:AB:CD:EF + (checksum valid) + ``` + + ``` + admin@sonic:~$ show platform syseeprom + TlvInfo Header: + Id String: TlvInfo + Version: 1 + Total Length: 527 + TLV Name Code Len Value + ---- --- ----- + Product Name 0x21 64 MSN2700 + Part Number 0x22 20 MSN2700-CS2FO + Serial Number 0x23 24 MT1822K07815 + Base MAC Address 0x24 6 50:6B:4B:8F:CE:40 + Manufacture Date 0x25 19 05/28/2018 23:56:02 + Device Version 0x26 1 16 + MAC Addresses 0x2A 2 128 + Manufacturer 0x2B 8 Mellanox + Vendor Extension 0xFD 36 + Vendor Extension 0xFD 164 + Vendor Extension 0xFD 36 + Vendor Extension 0xFD 36 + Vendor Extension 0xFD 36 + Platform Name 0x28 18 x86_64-mlnx_x86-r0 + ONIE Version 0x29 21 2018.08-5.2.0006-9600 + CRC-32 0xFE 4 0x11C017E1 + + (checksum valid) + ``` + +**show platform ssdhealth** + +This command displays health parameters of the device's SSD + +- Usage: + ``` + show platform ssdhealth [--vendor] + ``` + +- Example: + ``` + admin@sonic:~$ show platform ssdhealth + Device Model : M.2 (S42) 3IE3 + Health : 99.665% + Temperature : 30C + ``` + +**show platform psustatus** + +This command displays the status of the device's power supply units + +- Usage: + ``` + show platform psustatus + ``` + +- Example: + ``` + admin@sonic:~$ show platform psustatus + PSU Model Serial HW Rev Voltage (V) Current (A) Power (W) Status LED + ----- ------------- ------------ -------- ------------- ------------- ----------- -------- ----- + PSU 1 MTEF-PSF-AC-A MT1621X15246 A3 11.97 4.56 54.56 OK green + ``` + +**show platform fan** + +This command displays the status of the device's fans + +- Usage: + ``` + show platform fan + ``` + +- Example: + ``` + admin@sonic:~$ show platform fan + FAN Speed Direction Presence Status Timestamp + ----------- -------- ----------- ---------- -------- ----------------- + fan1 34% intake Present OK 20200302 06:58:56 + fan2 43% intake Present OK 20200302 06:58:56 + fan3 38% intake Present OK 20200302 06:58:56 + fan4 49% intake Present OK 20200302 06:58:57 + fan5 38% exhaust Present OK 20200302 06:58:57 + fan6 48% exhaust Present OK 20200302 06:58:57 + fan7 39% exhaust Present OK 20200302 06:58:57 + fan8 48% exhaust Present OK 20200302 06:58:57 + ``` + +**show platform temperature** + +This command displays the status of the device's thermal sensors + +- Usage: + ``` + show platform temperature + ``` + +- Example: + ``` + admin@sonic:~$ show platform temperature + NAME Temperature High Th Low Th Crit High Th Crit Low Th Warning Timestamp + ---------------------- ------------- --------- -------- -------------- ------------- --------- ----------------- + Ambient ASIC Temp 37.0 100.0 N/A 120.0 N/A False 20200302 06:58:57 + Ambient Fan Side Temp 28.5 100.0 N/A 120.0 N/A False 20200302 06:58:57 + Ambient Port Side Temp 31.0 100.0 N/A 120.0 N/A False 20200302 06:58:57 + CPU Core 0 Temp 36.0 87.0 N/A 105.0 N/A False 20200302 06:59:57 + CPU Core 1 Temp 38.0 87.0 N/A 105.0 N/A False 20200302 06:59:57 + CPU Pack Temp 38.0 87.0 N/A 105.0 N/A False 20200302 06:59:57 + PSU-1 Temp 28.0 100.0 N/A 120.0 N/A False 20200302 06:59:58 + PSU-2 Temp 28.0 100.0 N/A 120.0 N/A False 20200302 06:59:58 + xSFP module 1 Temp 31.5 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 2 Temp 35.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 3 Temp 32.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 4 Temp 33.5 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 5 Temp 34.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 6 Temp 36.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 7 Temp 33.5 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 8 Temp 33.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 9 Temp 32.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 10 Temp 38.5 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 11 Temp 38.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 12 Temp 39.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 13 Temp 35.5 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 14 Temp 37.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 15 Temp 36.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 16 Temp 36.5 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 17 Temp 32.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 18 Temp 34.5 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 19 Temp 30.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 20 Temp 31.5 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 21 Temp 34.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 22 Temp 34.4 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 23 Temp 34.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 24 Temp 35.6 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 25 Temp 38.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 26 Temp 32.2 70.0 N/A 90.0 N/A False 20200302 06:59:58 + xSFP module 27 Temp 39.0 70.0 N/A 90.0 N/A False 20200302 06:59:58 + xSFP module 28 Temp 30.1 70.0 N/A 90.0 N/A False 20200302 06:59:58 + xSFP module 29 Temp 32.0 70.0 N/A 90.0 N/A False 20200302 06:59:58 + xSFP module 30 Temp 35.3 70.0 N/A 90.0 N/A False 20200302 06:59:58 + xSFP module 31 Temp 31.0 70.0 N/A 90.0 N/A False 20200302 06:59:58 + xSFP module 32 Temp 39.5 70.0 N/A 90.0 N/A False 20200302 06:59:58 + ``` + +#### Transceivers +Displays diagnostic monitoring information of the transceivers + +**show interfaces transceiver** + +This command displays information for all the interfaces for the transceiver requested or a specific interface if the optional "interface_name" is specified. + +- Usage: + ``` + show interfaces transceiver (eeprom [-d|--dom] | lpmode | presence | error-status [-hw|--fetch-from-hardware]) [] + ``` + +- Example (Decode and display information stored on the EEPROM of SFP transceiver connected to Ethernet0): + ``` + admin@sonic:~$ show interfaces transceiver eeprom --dom Ethernet0 + Ethernet0: SFP detected + Connector : No separable connector + Encoding : Unspecified + Extended Identifier : Unknown + Extended RateSelect Compliance : QSFP+ Rate Select Version 1 + Identifier : QSFP+ + Length Cable Assembly(m) : 1 + Specification compliance : + 10/40G Ethernet Compliance Code : 40GBASE-CR4 + Fibre Channel Speed : 1200 Mbytes/Sec + Fibre Channel link length/Transmitter Technology : Electrical inter-enclosure (EL) + Fibre Channel transmission media : Twin Axial Pair (TW) + Vendor Date Code(YYYY-MM-DD Lot) : 2015-10-31 + Vendor Name : XXXXX + Vendor OUI : XX-XX-XX + Vendor PN : 1111111111 + Vendor Rev : + Vendor SN : 111111111 + ChannelMonitorValues: + RX1Power: -1.1936dBm + RX2Power: -1.1793dBm + RX3Power: -0.9388dBm + RX4Power: -1.0729dBm + TX1Bias: 4.0140mA + TX2Bias: 4.0140mA + TX3Bias: 4.0140mA + TX4Bias: 4.0140mA + ModuleMonitorValues : + Temperature : 1.1111C + Vcc : 0.0000Volts + ``` + +- Example (Display status of low-power mode of SFP transceiver connected to Ethernet100): + ``` + admin@sonic:~$ show interfaces transceiver lpmode Ethernet100 + Port Low-power Mode + ----------- ---------------- + Ethernet100 On + ``` + + +- Example (Display presence of SFP transceiver connected to Ethernet100): + ``` + admin@sonic:~$ show interfaces transceiver presence Ethernet100 + Port Presence + ----------- ---------- + Ethernet100 Present + ``` + +- Example (Display error status of SFP transceiver connected to Ethernet100): + ``` + admin@sonic:~$ show interfaces transceiver error-status Ethernet100 + Port Error Status + ----------- -------------- + Ethernet100 OK + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#basic-show-commands) + +## AAA & TACACS+ +This section captures the various show commands & configuration commands that are applicable for the AAA (Authentication, Authorization, and Accounting) module. +Admins can configure the type of authentication (local or remote tacacs based) required for the users and also the authentication failthrough and fallback options. +Following show command displays the current running configuration related to the AAA. + +### AAA + +#### AAA show commands + +This command is used to view the Authentication, Authorization & Accounting settings that are configured in the network node. + +**show aaa** + +This command displays the AAA settings currently present in the network node + +- Usage: + ``` + show aaa + ``` + +- Example: + ``` + admin@sonic:~$ show aaa + AAA authentication login local (default) + AAA authentication failthrough True (default) + AAA authentication fallback True (default) + ``` + +#### AAA config commands + +This sub-section explains all the possible CLI based configuration options for the AAA module. The list of commands/sub-commands possible for aaa is given below. + + Command: aaa authentication + sub-commands: + - aaa authentication failthrough + - aaa authentication fallback + - aaa authentication login + +**aaa authentication failthrough** + +This command is used to either enable or disable the failthrough option. +This command is useful when user has configured more than one tacacs+ server and when user has enabled tacacs+ authentication. +When authentication request to the first server fails, this configuration allows to continue the request to the next server. +When this configuration is enabled, authentication process continues through all servers configured. +When this is disabled and if the authentication request fails on first server, authentication process will stop and the login will be disallowed. + + +- Usage: + ``` + config aaa authentication failthrough (enable | disable | default) + ``` + + - Parameters: + - enable: This allows the AAA module to process with local authentication if remote authentication fails. + - disable: This disallows the AAA module to proceed further if remote authentication fails. + - default: This re-configures the default value, which is "enable". + + +- Example: + ``` + admin@sonic:~$ sudo config aaa authentication failthrough enable + ``` +**aaa authentication fallback** + +The command is not used at the moment. +When the tacacs+ authentication fails, it falls back to local authentication by default. + +- Usage: + ``` + config aaa authentication fallback (enable | disable | default) + ``` + +- Example: + ``` + admin@sonic:~$ sudo config aaa authentication fallback enable + ``` + +**aaa authentication login** + +This command is used to either configure whether AAA should use local database or remote tacacs+ database for user authentication. +By default, AAA uses local database for authentication. New users can be added/deleted using the linux commands (Note that the configuration done using linux commands are not preserved during reboot). +Admin can enable remote tacacs+ server based authentication by selecting the AUTH_PROTOCOL as tacacs+ in this command. +Admins need to configure the tacacs+ server accordingly and ensure that the connectivity to tacacas+ server is available via the management interface. +Once if the admins choose the remote authentication based on tacacs+ server, all user logins will be authenticated by the tacacs+ server. +If the authentication fails, AAA will check the "failthrough" configuration and authenticates the user based on local database if failthrough is enabled. + +- Usage: + ``` + config aaa authentication (tacacs+ | local | default) + ``` + + - Parameters: + - tacacs+: Enables remote authentication based on tacacs+ + - local: Disables remote authentication and uses local authentication + - default: Reset back to default value, which is only "local" authentication + + +- Example: + ``` + admin@sonic:~$ sudo config aaa authentication login tacacs+ + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#aaa--tacacs) + +### TACACS+ + +#### TACACS+ show commands + +**show tacacs** + +This command displays the global configuration fields and the list of all tacacs servers and their correponding configurations. + +- Usage: + ``` + show tacacs + ``` + +- Example: + ``` + admin@sonic:~$ show tacacs + TACPLUS global auth_type pap (default) + TACPLUS global timeout 99 + TACPLUS global passkey (default) + + TACPLUS_SERVER address 10.11.12.14 + priority 9 + tcp_port 50 + auth_type mschap + timeout 10 + passkey testing789 + + TACPLUS_SERVER address 10.0.0.9 + priority 1 + tcp_port 49 + ``` + +#### TACACS+ config commands + +This sub-section explains the command "config tacacs" and its sub-commands that are used to configure the following tacacs+ parameters. +Some of the parameters like authtype, passkey and timeout can be either configured at per server level or at global level (global value will be applied if there no server level configuration) + +1) Add/Delete the tacacs+ server details. +2) authtype - global configuration that is applied to all servers if there is no server specific configuration. +3) default - reset the authtype or passkey or timeout to the default values. +4) passkey - global configuration that is applied to all servers if there is no server specific configuration. +5) timeout - global configuration that is applied to all servers if there is no server specific configuration. + +**config tacacs add** + +This command is used to add a TACACS+ server to the tacacs server list. +Note that more than one tacacs+ (maximum of seven) can be added in the device. +When user tries to login, tacacs client shall contact the servers one by one. +When any server times out, device will try the next server one by one based on the priority value configured for that server. +When this command is executed, the configured tacacs+ server addresses are updated in /etc/pam.d/common-auth-sonic configuration file which is being used by tacacs service. + +- Usage: + ``` + config tacacs add [-t|--timeout ] [-k|--key ] [-a|--type ] [-o|--port ] [-p|--pri ] [-m|--use-mgmt-vrf] + ``` + + - Parameters: + - ip_address: TACACS+ server IP address. + - timeout: Transmission timeout interval in seconds, range 1 to 60, default 5 + - key: Shared secret + - type: Authentication type, "chap" or "pap" or "mschap" or "login", default is "pap". + - port: TCP port range is 1 to 65535, default 49 + - pri: Priority, priority range 1 to 64, default 1. + - use-mgmt-vrf: This means that the server is part of Management vrf, default is "no vrf" + + +- Example: + ``` + admin@sonic:~$ sudo config tacacs add 10.11.12.13 -t 10 -k testing789 -a mschap -o 50 -p 9 + ``` + + - Example Server Configuration in /etc/pam.d/common-auth-sonic configuration file: + ``` + auth [success=done new_authtok_reqd=done default=ignore] pam_tacplus.so server=10.11.12.14:50 secret=testing789 login=mschap timeout=10 try_first_pass + auth [success=done new_authtok_reqd=done default=ignore] pam_tacplus.so server=10.11.12.24:50 secret=testing789 login=mschap timeout=987654321098765433211 + 0987 try_first_pass + auth [success=done new_authtok_reqd=done default=ignore] pam_tacplus.so server=10.0.0.9:49 secret= login=mschap timeout=5 try_first_pass + auth [success=done new_authtok_reqd=done default=ignore] pam_tacplus.so server=10.0.0.8:49 secret= login=mschap timeout=5 try_first_pass + auth [success=done new_authtok_reqd=done default=ignore] pam_tacplus.so server=10.11.12.13:50 secret=testing789 login=mschap timeout=10 try_first_pass + auth [success=1 default=ignore] pam_unix.so nullok try_first_pass + ``` + + *NOTE: In the above example, the servers are stored (sorted) based on the priority value configured for the server.* + +**config tacacs delete** + +This command is used to delete the tacacs+ servers configured. + +- Usage: + ``` + config tacacs delete + ``` + +- Example: + ``` + admin@sonic:~$ sudo config tacacs delete 10.11.12.13 + ``` + +**config tacacs authtype** + +This command is used to modify the global value for the TACACS+ authtype. +When user has not configured server specific authtype, this global value shall be used for that server. + +- Usage: + ``` + config tacacs authtype (chap | pap | mschap | login) + ``` + +- Example: + ``` + admin@sonic:~$ sudo config tacacs authtype mschap + ``` + +**config tacacs default** + +This command is used to reset the global value for authtype or passkey or timeout to default value. +Default for authtype is "pap", default for passkey is EMPTY_STRING and default for timeout is 5 seconds. + +- Usage: + ``` + config tacacs default (authtype | passkey | timeout) + ``` + +- Example (This will reset the global authtype back to the default value "pap"): + ``` + admin@sonic:~$ sudo config tacacs default authtype + ``` + +**config tacacs passkey** + +This command is used to modify the global value for the TACACS+ passkey. +When user has not configured server specific passkey, this global value shall be used for that server. + +- Usage: + ``` + config tacacs passkey + ``` + +- Example: + ``` + admin@sonic:~$ sudo config tacacs passkey testing123 + ``` + +**config tacacs timeout** + +This command is used to modify the global value for the TACACS+ timeout. +When user has not configured server specific timeout, this global value shall be used for that server. + + +- Usage: + ``` + config tacacs [default] timeout [] + ``` + + - Options: + - Valid values for timeout is 1 to 60 seconds. + - When the optional keyword "default" is specified, timeout_value_in_seconds parameter wont be used; default value of 5 is used. + - Configuration using the keyword "default" is introduced in 201904 release. + +- Example: To configure non-default timeout value + ``` + admin@sonic:~$ sudo config tacacs timeout 60 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#aaa--tacacs) + + + +## ACL + +This section explains the various show commands and configuration commands available for users. + +### ACL show commands + +**show acl table** + +This command displays either all the ACL tables that are configured or only the specified "TABLE_NAME". +Output from the command displays the table name, type of the table, the list of interface(s) to which the table is bound and the description about the table. + +- Usage: + ``` + show acl table [] + ``` + +- Example: + ``` + admin@sonic:~$ show acl table + Name Type Binding Description Stage + -------- --------- --------------- ---------------- ------- + EVERFLOW MIRROR Ethernet16 EVERFLOW ingress + Ethernet96 + Ethernet108 + Ethernet112 + PortChannel0001 + PortChannel0002 + SNMP_ACL CTRLPLANE SNMP SNMP_ACL ingress + DT_ACL_T1 L3 Ethernet0 DATA_ACL_TABLE_1 egress + Ethernet4 + Ethernet112 + Ethernet116 + SSH_ONLY CTRLPLANE SSH SSH_ONLY ingress + ``` + +**show acl rule** + +This command displays all the ACL rules present in all the ACL tables or only the rules present in specified table "TABLE_NAME" or only the rule matching the RULE_ID option. +Output from the command gives the following information about the rules +1) Table name - ACL table name to which the rule belongs to. +2) Rule name - ACL rule name +3) Priority - Priority for this rule. +4) Action - Action to be performed if the packet matches with this ACL rule. + +It can be: +- "DROP"/"FORWARD"("ACCEPT" for control plane ACL) +- "REDIRECT: redirect-object" for redirect rule, where "redirect-object" is either: + - physical interface name, e.g. "Ethernet10" + - port channel name, e.g. "PortChannel0002" + - next-hop IP address, e.g. "10.0.0.1" + - next-hop group set of IP addresses with comma seperator, e.g. "10.0.0.1,10.0.0.3" +- "MIRROR INGRESS|EGRESS: session-name" for mirror rules, where "session-name" refers to mirror session + +Users can choose to have a default permit rule or default deny rule. In case of default "deny all" rule, add the permitted rules on top of the deny rule. In case of the default "permit all" rule, users can add the deny rules on top of it. If users have not confgured any rule, SONiC allows all traffic (which is "permit all"). + +5) Match - The fields from the packet header that need to be matched against the same present in the incoming traffic. + +- Usage: + ``` + show acl rule [] [] + ``` + +- Example: + ``` + admin@sonic:~$ show acl rule + Table Rule Priority Action Match + -------- ------------ ---------- ------------------------- ---------------------------- + SNMP_ACL RULE_1 9999 ACCEPT IP_PROTOCOL: 17 + SRC_IP: 1.1.1.1/32 + SSH_ONLY RULE_2 9998 ACCEPT IP_PROTOCOL: 6 + SRC_IP: 1.1.1.1/32 + EVERFLOW RULE_3 9997 MIRROR INGRESS: everflow0 SRC_IP: 20.0.0.2/32 + EVERFLOW RULE_4 9996 MIRROR EGRESS : everflow1 L4_SRC_PORT: 4621 + DATAACL RULE_5 9995 REDIRECT: Ethernet8 IP_PROTOCOL: 126 + DATAACL RULE_6 9994 FORWARD L4_SRC_PORT: 179 + DATAACL RULE_7 9993 FORWARD L4_DST_PORT: 179 + SNMP_ACL DEFAULT_RULE 1 DROP ETHER_TYPE: 2048 + SSH_ONLY DEFAULT_RULE 1 DROP ETHER_TYPE: 2048 + ``` + + +### ACL config commands +This sub-section explains the list of configuration options available for ACL module. +Note that there is no direct command to add or delete or modify the ACL table and ACL rule. +Existing ACL tables and ACL rules can be updated by specifying the ACL rules in json file formats and configure those files using this CLI command. + +**config acl update full** + +This command is to update the rules in all the tables or in one specific table in full. If a table_name is provided, the operation will be restricted in the specified table. All existing rules in the specified table or all tables will be removed. New rules loaded from file will be installed. If the table_name is specified, only rules within that table will be removed and new rules in that table will be installed. If the table_name is not specified, all rules from all tables will be removed and only the rules present in the input file will be added. + +The command does not modify anything in the list of acl tables. It modifies only the rules present in those pre-existing tables. + +In order to create acl tables, either follow the config_db.json method or minigraph method to populate the list of ACL tables. + +After creating tables, either the config_db.json method or the minigraph method or the CLI method (explained here) can be used to populate the rules in those ACL tables. + +This command updates only the ACL rules and it does not disturb the ACL tables; i.e. the output of "show acl table" is not alterted by using this command; only the output of "show acl rule" will be changed after this command. + +When "--session_name" optional argument is specified, command sets the session_name for the ACL table with this mirror session name. It fails if the specified mirror session name does not exist. + +When "--mirror_stage" optional argument is specified, command sets the mirror action to ingress/egress based on this parameter. By default command sets ingress mirror action in case argument is not specified. + +When the optional argument "max_priority" is specified, each rule’s priority is calculated by subtracting its “sequence_id” value from the “max_priority”. If this value is not passed, the default “max_priority” 10000 is used. + +- Usage: + ``` + config acl update full [--table_name ] [--session_name ] [--mirror_stage (ingress | egress)] [--max_priority ] + ``` + + - Parameters: + - table_name: Specifiy the name of the ACL table to load. Example: config acl update full "--table_name DT_ACL_T1 /etc/sonic/acl_table_1.json" + - session_name: Specifiy the name of the ACL session to load. Example: config acl update full "--session_name mirror_ses1 /etc/sonic/acl_table_1.json" + - priority_value: Specify the maximum priority to use when loading ACL rules. Example: config acl update full "--max-priority 100 /etc/sonic/acl_table_1.json" + + *NOTE 1: All these optional parameters should be inside double quotes. If none of the options are provided, double quotes are not required for specifying filename alone.* + *NOTE 2: Any number of optional parameters can be configured in the same command.* + +- Examples: + ``` + admin@sonic:~$ sudo config acl update full /etc/sonic/acl_full_snmp_1_2_ssh_4.json + admin@sonic:~$ sudo config acl update full "--table_name SNMP-ACL /etc/sonic/acl_full_snmp_1_2_ssh_4.json" + admin@sonic:~$ sudo config acl update full "--session_name everflow0 /etc/sonic/acl_full_snmp_1_2_ssh_4.json" + ``` + + This command will remove all rules from all the ACL tables and insert all the rules present in this input file. + Refer the example file [acl_full_snmp_1_2_ssh_4.json](#) that adds two rules for SNMP (Rule1 and Rule2) and one rule for SSH (Rule4) + Refer an example for input file format [here](https://github.com/Azure/sonic-mgmt/blob/master/ansible/roles/test/files/helpers/config_service_acls.sh) + Refer another example [here](https://github.com/Azure/sonic-mgmt/blob/master/ansible/roles/test/tasks/acl/acltb_test_rules_part_1.json) + +**config acl update incremental** + +This command is used to perform incremental update of ACL rule table. This command gets existing rules from Config DB and compares with rules specified in input file and performs corresponding modifications. + +With respect to DATA ACLs, the command does not assume that new dataplane ACLs can be inserted in betweeen by shifting existing ACLs in all ASICs. Therefore, this command performs a full update on dataplane ACLs. +With respect to control plane ACLs, this command performs an incremental update. +If we assume that "file1.json" is the already loaded ACL rules file and if "file2.json" is the input file that is passed as parameter for this command, the following requirements are valid for the input file. +1) First copy the file1.json to file2.json. +2) Remove the unwanted ACL rules from file2.json +3) Add the newly required ACL rules into file2.json. +4) Modify the existing ACL rules (that require changes) in file2.json. + +NOTE: If any ACL rule that is already available in file1.json is required even after this command execution, such rules should remain unalterted in file2.json. Don't remove them. +Note that "incremental" is working like "full". + +When "--session_name" optional argument is specified, command sets the session_name for the ACL table with this mirror session name. It fails if the specified mirror session name does not exist. + +When "--mirror_stage" optional argument is specified, command sets the mirror action to ingress/egress based on this parameter. By default command sets ingress mirror action in case argument is not specified. + +When the optional argument "max_priority" is specified, each rule’s priority is calculated by subtracting its “sequence_id” value from the “max_priority”. If this value is not passed, the default “max_priority” 10000 is used. + +- Usage: + ``` + config acl update incremental [--session_name ] [--mirror_stage (ingress | egress)] [--max_priority ] + ``` + + - Parameters: + - table_name: Specifiy the name of the ACL table to load. Example: config acl update full "--table_name DT_ACL_T1 /etc/sonic/acl_table_1.json" + - session_name: Specifiy the name of the ACL session to load. Example: config acl update full "--session_name mirror_ses1 /etc/sonic/acl_table_1.json" + - priority_value: Specify the maximum priority to use when loading ACL rules. Example: config acl update full "--max-priority 100 /etc/sonic/acl_table_1.json" + + *NOTE 1: All these optional parameters should be inside double quotes. If none of the options are provided, double quotes are not required for specifying filename alone.* + *NOTE 2: Any number of optional parameters can be configured in the same command.* + +- Examples: + ``` + admin@sonic:~$ sudo config acl update incremental /etc/sonic/acl_incremental_snmp_1_3_ssh_4.json + ``` + ``` + admin@sonic:~$ sudo config acl update incremental "--session_name everflow0 /etc/sonic/acl_incremental_snmp_1_3_ssh_4.json" + ``` + + Refer the example file [acl_incremental_snmp_1_3_ssh_4.json](#) that adds two rules for SNMP (Rule1 and Rule3) and one rule for SSH (Rule4) + When this "incremental" command is executed after "full" command, it has removed SNMP Rule2 and added SNMP Rule3 in the example. + File "acl_full_snmp_1_2_ssh_4.json" has got SNMP Rule1, SNMP Rule2 and SSH Rule4. + File "acl_incremental_snmp_1_3_ssh_4.json" has got SNMP Rule1, SNMP Rule3 and SSH Rule4. + This file is created by copying the file "acl_full_snmp_1_2_ssh_4.json" to "acl_incremental_snmp_1_3_ssh_4.json" and then removing SNMP Rule2 and adding SNMP Rule3. + +Go Back To [Beginning of the document](#) or [Beginning of this section](#acl) + +**config acl add table** + +This command is used to create new ACL tables. + +- Usage: + ``` + config acl add table [OPTIONS] [-d ] [-p ] [-s (ingress | egress)] + ``` + +- Parameters: + - table_name: The name of the ACL table to create. + - table_type: The type of ACL table to create (e.g. "L3", "L3V6", "MIRROR") + - description: A description of the table for the user. (default is the table_name) + - ports: A comma-separated list of ports/interfaces to add to the table. The behavior is as follows: + - Physical ports will be bound as physical ports + - Portchannels will be bound as portchannels - passing a portchannel member is invalid + - VLANs will be expanded into their members (e.g. "Vlan1000" will become "Ethernet0,Ethernet2,Ethernet4...") + - stage: The stage this ACL table will be applied to, either ingress or egress. (default is ingress) + +- Examples: + ``` + admin@sonic:~$ sudo config acl add table EXAMPLE L3 -p Ethernet0,Ethernet4 -s ingress + ``` + ``` + admin@sonic:~$ sudo config acl add table EXAMPLE_2 L3V6 -p Vlan1000,PortChannel0001,Ethernet128 -s egress + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#acl) + + +## ARP & NDP + +### ARP show commands + +**show arp** + +This command displays the ARP entries in the device with following options. +1) Display the entire table. +2) Display the ARP entries learnt on a specific interface. +3) Display the ARP of a specific ip-address. + +- Usage: + ``` + show arp [-if ] [] + ``` + +- Details: + - show arp: Displays all entries + - show arp -if : Displays the ARP specific to the specified interface. + - show arp : Displays the ARP specific to the specicied ip-address. + + +- Example: + ``` + admin@sonic:~$ show arp + Address MacAddress Iface Vlan + ------------- ----------------- ------- ------ + 192.168.1.183 88:5a:92:fb:bf:41 Ethernet44 - + 192.168.1.175 88:5a:92:fc:95:81 Ethernet28 - + 192.168.1.181 e4:c7:22:c1:07:7c Ethernet40 - + 192.168.1.179 88:5a:92:de:a8:bc Ethernet36 - + 192.168.1.118 00:1c:73:3c:de:43 Ethernet64 - + 192.168.1.11 00:1c:73:3c:e1:38 Ethernet88 - + 192.168.1.161 24:e9:b3:71:3a:01 Ethernet0 - + 192.168.1.189 24:e9:b3:9d:57:41 Ethernet56 - + 192.168.1.187 74:26:ac:8b:8f:c1 Ethernet52 - + 192.168.1.165 88:5a:92:de:a0:7c Ethernet8 - + + Total number of entries 10 + ``` + +Optionally, you can specify the interface in order to display the ARPs learnt on that particular interface + +- Example: + ``` + admin@sonic:~$ show arp -if Ethernet40 + Address MacAddress Iface Vlan + ------------- ----------------- ---------- ------ + 192.168.1.181 e4:c7:22:c1:07:7c Ethernet40 - + Total number of entries 1 + ``` + +Optionally, you can specify an IP address in order to display only that particular entry + +- Example: + ``` + admin@sonic:~$ show arp 192.168.1.181 + Address MacAddress Iface Vlan + ------------- ----------------- ---------- ------ + 192.168.1.181 e4:c7:22:c1:07:7c Ethernet40 - + Total number of entries 1 + ``` + +### NDP show commands + +**show ndp** + +This command displays either all the IPv6 neighbor mac addresses, or for a particular IPv6 neighbor, or for all IPv6 neighbors reachable via a specific interface. + +- Usage: + ``` + show ndp [-if|--iface ] + ``` + +- Example (show all IPv6 neighbors): + ``` + admin@sonic:~$ show ndp + Address MacAddress Iface Vlan Status + ------------------------ ----------------- ------- ------ --------- + fe80::20c:29ff:feb8:b11e 00:0c:29:b8:b1:1e eth0 - REACHABLE + fe80::20c:29ff:feb8:cff0 00:0c:29:b8:cf:f0 eth0 - REACHABLE + fe80::20c:29ff:fef9:324 00:0c:29:f9:03:24 eth0 - REACHABLE + Total number of entries 3 + ``` + +- Example (show specific IPv6 neighbor): + ``` + admin@sonic:~$ show ndp fe80::20c:29ff:feb8:b11e + Address MacAddress Iface Vlan Status + ------------------------ ----------------- ------- ------ --------- + fe80::20c:29ff:feb8:b11e 00:0c:29:b8:b1:1e eth0 - REACHABLE + Total number of entries 1 + ``` + +- Example (show IPv6 neighbors learned on a specific interface): + ``` + admin@sonic:~$ show ndp -if eth0 + Address MacAddress Iface Vlan Status + ------------------------ ----------------- ------- ------ --------- + fe80::20c:29ff:feb8:b11e 00:0c:29:b8:b1:1e eth0 - REACHABLE + fe80::20c:29ff:feb8:cff0 00:0c:29:b8:cf:f0 eth0 - REACHABLE + fe80::20c:29ff:fef9:324 00:0c:29:f9:03:24 eth0 - REACHABLE + Total number of entries 3 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#arp--ndp) + +## BFD + +### BFD show commands + +**show bfd summary** + +This command displays the state and key parameters of all BFD sessions. + +- Usage: + ``` + show bgp summary + ``` +- Example: + ``` + >> show bfd summary + Total number of BFD sessions: 3 + Peer Addr Interface Vrf State Type Local Addr TX Interval RX Interval Multiplier Multihop + ----------- ----------- ------- ------- ------------ ------------ ------------- ------------- ------------ ---------- + 10.0.1.1 default default DOWN async_active 10.0.0.1 300 500 3 true + 10.0.2.1 Ethernet12 default UP async_active 10.0.0.1 200 600 3 false + 2000::10:1 default default UP async_active 2000::1 100 700 3 false + ``` + +**show bfd peer** + +This command displays the state and key parameters of all BFD sessions that match an IP address. + +- Usage: + ``` + show bgp peer + ``` +- Example: + ``` + >> show bfd peer 10.0.1.1 + Total number of BFD sessions for peer IP 10.0.1.1: 1 + Peer Addr Interface Vrf State Type Local Addr TX Interval RX Interval Multiplier Multihop + ----------- ----------- ------- ------- ------------ ------------ ------------- ------------- ------------ ---------- + 10.0.1.1 default default DOWN async_active 10.0.0.1 300 500 3 true + ``` + +## BGP + +This section explains all the BGP show commands and BGP configuation commands in both "Quagga" and "FRR" routing software that are supported in SONiC. +In 201811 and older verisons "Quagga" was enabled by default. In current version "FRR" is enabled by default. +Most of the FRR show commands start with "show bgp". Similar commands in Quagga starts with "show ip bgp". All sub-options supported in all these show commands are common for FRR and Quagga. +Detailed show commands examples for Quagga are provided at the end of this document.This section captures only the commands supported by FRR. + +### BGP show commands + + +**show bgp summary (Versions >= 201904 using default FRR routing stack)** + +**show ip bgp summary (Versions <= 201811 using Quagga routing stack)** + +This command displays the summary of all IPv4 & IPv6 bgp neighbors that are configured and the corresponding states. + +- Usage: + + *Versions >= 201904 using default FRR routing stack* + ``` + show bgp summary + ``` + *Versions <= 201811 using Quagga routing stack* + ``` + show ip bgp summary + ``` + +- Example: + ``` + admin@sonic:~$ show ip bgp summary + + IPv4 Unicast Summary: + BGP router identifier 10.1.0.32, local AS number 65100 vrf-id 0 + BGP table version 6465 + RIB entries 12807, using 2001 KiB of memory + Peers 4, using 83 KiB of memory + Peer groups 2, using 128 bytes of memory + + Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd NeighborName + 10.0.0.57 4 64600 3995 4001 0 0 0 00:39:32 6400 Lab-T1-01 + 10.0.0.59 4 64600 3995 3998 0 0 0 00:39:32 6400 Lab-T1-02 + 10.0.0.61 4 64600 3995 4001 0 0 0 00:39:32 6400 Lab-T1-03 + 10.0.0.63 4 64600 3995 3998 0 0 0 00:39:32 6400 NotAvailable + + Total number of neighbors 4 + ``` + +- Example: + ``` + admin@sonic:~$ show bgp summary + + IPv4 Unicast Summary: + BGP router identifier 10.1.0.32, local AS number 65100 vrf-id 0 + BGP table version 6465 + RIB entries 12807, using 2001 KiB of memory + Peers 4, using 83 KiB of memory + Peer groups 2, using 128 bytes of memory + + Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd + 10.0.0.57 4 64600 3995 4001 0 0 0 00:39:32 6400 + 10.0.0.59 4 64600 3995 3998 0 0 0 00:39:32 6400 + 10.0.0.61 4 64600 3995 4001 0 0 0 00:39:32 6400 + 10.0.0.63 4 64600 3995 3998 0 0 0 00:39:32 6400 + + Total number of neighbors 4 + + IPv6 Unicast Summary: + BGP router identifier 10.1.0.32, local AS number 65100 vrf-id 0 + BGP table version 12803 + RIB entries 12805, using 2001 KiB of memory + Peers 4, using 83 KiB of memory + Peer groups 2, using 128 bytes of memory + + Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd + fc00::72 4 64600 3995 5208 0 0 0 00:39:30 6400 + fc00::76 4 64600 3994 5208 0 0 0 00:39:30 6400 + fc00::7a 4 64600 3993 5208 0 0 0 00:39:30 6400 + fc00::7e 4 64600 3993 5208 0 0 0 00:39:30 6400 + + Total number of neighbors 4 + ``` + Click [here](#Quagga-BGP-Show-Commands) to see the example for "show ip bgp summary" for Quagga. + + + +**show bgp neighbors (Versions >= 201904 using default FRR routing stack)** + +**show ip bgp neighbors (Versions <= 201811 using Quagga routing stack)** + +This command displays all the details of IPv4 & IPv6 BGP neighbors when no optional argument is specified. + +When the optional argument IPv4_address is specified, it displays the detailed neighbor information about that specific IPv4 neighbor. + +Command has got additional optional arguments to display only the advertised routes, or the received routes, or all routes. + +In order to get details for an IPv6 neigbor, use "show bgp ipv6 neighbor " command. + + +- Usage: + + *Versions >= 201904 using default FRR routing stack* + ``` + show bgp neighbors [ [advertised-routes | received-routes | routes]] + ``` + *Versions <= 201811 using Quagga routing stack* + ``` + show ip bgp neighbors [ [advertised-routes | received-routes | routes]] + ``` + +- Example: + ``` + admin@sonic:~$ show bgp neighbors + BGP neighbor is 10.0.0.57, remote AS 64600, local AS 65100, external link + Description: ARISTA01T1 + BGP version 4, remote router ID 100.1.0.29, local router ID 10.1.0.32 + BGP state = Established, up for 00:42:15 + Last read 00:00:00, Last write 00:00:03 + Hold time is 10, keepalive interval is 3 seconds + Configured hold time is 10, keepalive interval is 3 seconds + Neighbor capabilities: + 4 Byte AS: advertised and received + AddPath: + IPv4 Unicast: RX advertised IPv4 Unicast and received + Route refresh: advertised and received(new) + Address Family IPv4 Unicast: advertised and received + Hostname Capability: advertised (name: sonic-z9264f-9251,domain name: n/a) not received + Graceful Restart Capabilty: advertised and received + Remote Restart timer is 300 seconds + Address families by peer: + none + Graceful restart information: + End-of-RIB send: IPv4 Unicast + End-of-RIB received: IPv4 Unicast + Message statistics: + Inq depth is 0 + Outq depth is 0 + Sent Rcvd + Opens: 2 1 + Notifications: 2 0 + Updates: 3206 3202 + Keepalives: 845 847 + Route Refresh: 0 0 + Capability: 0 0 + Total: 4055 4050 + Minimum time between advertisement runs is 0 seconds + + For address family: IPv4 Unicast + Update group 1, subgroup 1 + Packet Queue length 0 + Inbound soft reconfiguration allowed + Community attribute sent to this neighbor(all) + 6400 accepted prefixes + + Connections established 1; dropped 0 + Last reset 00:42:37, due to NOTIFICATION sent (Cease/Connection collision resolution) + Local host: 10.0.0.56, Local port: 179 + Foreign host: 10.0.0.57, Foreign port: 46419 + Nexthop: 10.0.0.56 + Nexthop global: fc00::71 + Nexthop local: fe80::2204:fff:fe36:9449 + BGP connection: shared network + BGP Connect Retry Timer in Seconds: 120 + Read thread: on Write thread: on + ``` + +Optionally, you can specify an IP address in order to display only that particular neighbor. In this mode, you can optionally specify whether you want to display all routes advertised to the specified neighbor, all routes received from the specified neighbor or all routes (received and accepted) from the specified neighbor. + +- Example: + ``` + admin@sonic:~$ show bgp neighbors 10.0.0.57 + + admin@sonic:~$ show bgp neighbors 10.0.0.57 advertised-routes + + admin@sonic:~$ show bgp neighbors 10.0.0.57 received-routes + + admin@sonic:~$ show bgp neighbors 10.0.0.57 routes + ``` + + Click [here](#Quagga-BGP-Show-Commands) to see the example for "show ip bgp neighbors" for Quagga. + + +**show ip bgp network [[|] [(bestpath | multipath | longer-prefixes | json)]] + +This command displays all the details of IPv4 Border Gateway Protocol (BGP) prefixes. + +- Usage: + + + ``` + show ip bgp network [[|] [(bestpath | multipath | longer-prefixes | json)]] + ``` + +- Example: + + NOTE: The "longer-prefixes" option is only available when a network prefix with a "/" notation is used. + + ``` + admin@sonic:~$ show ip bgp network + + admin@sonic:~$ show ip bgp network 10.1.0.32 bestpath + + admin@sonic:~$ show ip bgp network 10.1.0.32 multipath + + admin@sonic:~$ show ip bgp network 10.1.0.32 json + + admin@sonic:~$ show ip bgp network 10.1.0.32/32 bestpath + + admin@sonic:~$ show ip bgp network 10.1.0.32/32 multipath + + admin@sonic:~$ show ip bgp network 10.1.0.32/32 json + + admin@sonic:~$ show ip bgp network 10.1.0.32/32 longer-prefixes + ``` + +**show bgp ipv6 summary (Versions >= 201904 using default FRR routing stack)** + +**show ipv6 bgp summary (Versions <= 201811 using Quagga routing stack)** + +This command displays the summary of all IPv6 bgp neighbors that are configured and the corresponding states. + +- Usage: + + *Versions >= 201904 using default FRR routing stack* + ``` + show bgp ipv6 summary + ``` + *Versions <= 201811 using Quagga routing stack* + ``` + show ipv6 bgp summary + ``` + +- Example: + ``` + admin@sonic:~$ show bgp ipv6 summary + BGP router identifier 10.1.0.32, local AS number 65100 vrf-id 0 + BGP table version 12803 + RIB entries 12805, using 2001 KiB of memory + Peers 4, using 83 KiB of memory + Peer groups 2, using 128 bytes of memory + + Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd NeighborName + fc00::72 4 64600 3995 5208 0 0 0 00:39:30 6400 Lab-T1-01 + fc00::76 4 64600 3994 5208 0 0 0 00:39:30 6400 Lab-T1-02 + fc00::7a 4 64600 3993 5208 0 0 0 00:39:30 6400 Lab-T1-03 + fc00::7e 4 64600 3993 5208 0 0 0 00:39:30 6400 Lab-T1-04 + + Total number of neighbors 4 + ``` + Click [here](#Quagga-BGP-Show-Commands) to see the example for "show ipv6 bgp summary" for Quagga. + + + +**show bgp ipv6 neighbors (Versions >= 201904 using default FRR routing stack)** + +**show ipv6 bgp neighbors (Versions <= 201811 using Quagga routing stack)** + +This command displays all the details of one particular IPv6 Border Gateway Protocol (BGP) neighbor. Option is also available to display only the advertised routes, or the received routes, or all routes. + + +- Usage: + + *Versions >= 201904 using default FRR routing stack* + ``` + show bgp ipv6 neighbors [ [(advertised-routes | received-routes | routes)]] + ``` + *Versions <= 201811 using Quagga routing stack* + ``` + show ipv6 bgp neighbors [ [(advertised-routes | received-routes | routes)]] + ``` + +- Example: + ``` + admin@sonic:~$ show bgp ipv6 neighbors fc00::72 advertised-routes + + admin@sonic:~$ show bgp ipv6 neighbors fc00::72 received-routes + + admin@sonic:~$ show bgp ipv6 neighbors fc00::72 routes + ``` + Click [here](#Quagga-BGP-Show-Commands) to see the example for "show ip bgp summary" for Quagga. + + +**show ipv6 bgp network [[|] [(bestpath | multipath | longer-prefixes | json)]] + +This command displays all the details of IPv6 Border Gateway Protocol (BGP) prefixes. + +- Usage: + + + ``` + show ipv6 bgp network [[|] [(bestpath | multipath | longer-prefixes | json)]] + ``` + +- Example: + + NOTE: The "longer-prefixes" option is only available when a network prefix with a "/" notation is used. + + ``` + admin@sonic:~$ show ipv6 bgp network + + admin@sonic:~$ show ipv6 bgp network fc00::72 bestpath + + admin@sonic:~$ show ipv6 bgp network fc00::72 multipath + + admin@sonic:~$ show ipv6 bgp network fc00::72 json + + admin@sonic:~$ show ipv6 bgp network fc00::72/64 bestpath + + admin@sonic:~$ show ipv6 bgp network fc00::72/64 multipath + + admin@sonic:~$ show ipv6 bgp network fc00::72/64 json + + admin@sonic:~$ show ipv6 bgp network fc00::72/64 longer-prefixes + ``` + + + + +**show route-map** + +This command displays the routing policy that takes precedence over the other route processes that are configured. + +- Usage: + ``` + show route-map + ``` + +- Example: + ``` + admin@sonic:~$ show route-map + ZEBRA: + route-map RM_SET_SRC, permit, sequence 10 + Match clauses: + Set clauses: + src 10.12.0.102 + Call clause: + Action: + Exit routemap + ZEBRA: + route-map RM_SET_SRC6, permit, sequence 10 + Match clauses: + Set clauses: + src fc00:1::102 + Call clause: + Action: + Exit routemap + BGP: + route-map FROM_BGP_SPEAKER_V4, permit, sequence 10 + Match clauses: + Set clauses: + Call clause: + Action: + Exit routemap + BGP: + route-map TO_BGP_SPEAKER_V4, deny, sequence 10 + Match clauses: + Set clauses: + Call clause: + Action: + Exit routemap + BGP: + route-map ISOLATE, permit, sequence 10 + Match clauses: + Set clauses: + as-path prepend 65000 + Call clause: + Action: + Exit routemap + ``` + + +### BGP config commands + +This sub-section explains the list of configuration options available for BGP module for both IPv4 and IPv6 BGP neighbors. + +**config bgp shutdown all** + +This command is used to shutdown all the BGP IPv4 & IPv6 sessions. +When the session is shutdown using this command, BGP state in "show ip bgp summary" is displayed as "Idle (Admin)" + +- Usage: + ``` + config bgp shutdown all + ``` + +- Example: + ``` + admin@sonic:~$ sudo config bgp shutdown all + ``` + +**config bgp shutdown neighbor** + +This command is to shut down a BGP session with a neighbor by that neighbor's IP address or hostname + +- Usage: + ``` + sudo config bgp shutdown neighbor ( | ) + ``` + +- Examples: + ``` + admin@sonic:~$ sudo config bgp shutdown neighbor 192.168.1.124 + ``` + ``` + admin@sonic:~$ sudo config bgp shutdown neighbor SONIC02SPINE + ``` + + +**config bgp startup all** + +This command is used to start up all the IPv4 & IPv6 BGP neighbors + +- Usage: + ``` + config bgp startup all + ``` + +- Example: + ``` + admin@sonic:~$ sudo config bgp startup all + ``` + + +**config bgp startup neighbor** + +This command is used to start up the particular IPv4 or IPv6 BGP neighbor using either the IP address or hostname. + +- Usage: + ``` + config bgp startup neighbor ( | ) + ``` + +- Examples: + ``` + admin@sonic:~$ sudo config bgp startup neighbor 192.168.1.124 + ``` + ``` + admin@sonic:~$ sudo config bgp startup neighbor SONIC02SPINE + ``` + + +**config bgp remove neighbor** + +This command is used to remove particular IPv4 or IPv6 BGP neighbor configuration using either the IP address or hostname. + +- Usage: + ``` + config bgp remove neighbor + ``` + +- Examples: + ``` + admin@sonic:~$ sudo config bgp remove neighbor 192.168.1.124 + ``` + ``` + admin@sonic:~$ sudo config bgp remove neighbor 2603:10b0:b0f:346::4a + ``` + ``` + admin@sonic:~$ sudo config bgp remove neighbor SONIC02SPINE + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#bgp) + +## Console + +This section explains all Console show commands and configuration options that are supported in SONiC. + +All commands are used only when SONiC is used as console switch. + +All commands under this section are not applicable when SONiC used as regular switch. + +### Console show commands + +**show line** + +This command displays serial port or a virtual network connection status. + +- Usage: + ``` + show line (-b|--breif) + ``` + +- Example: + ``` + admin@sonic:~$ show line + Line Baud Flow Control PID Start Time Device + ------ ------ -------------- ----- ------------ -------- + 1 9600 Enabled - - switch1 + 2 - Disabled - - + 3 - Disabled - - + 4 - Disabled - - + 5 - Disabled - - + ``` + +Optionally, you can display configured console ports only by specifying the `-b` or `--breif` flag. + +- Example: + ``` + admin@sonic:~$ show line -b + Line Baud Flow Control PID Start Time Device + ------ ------ -------------- ----- ------------ -------- + 1 9600 Enabled - - switch1 + ``` + +## Console config commands + +This sub-section explains the list of configuration options available for console management module. + +**config console enable** + +This command is used to enable SONiC console switch feature. + +- Usage: + ``` + config console enable + ``` + +- Example: + ``` + admin@sonic:~$ sudo config console enable + ``` + +**config console disable** + +This command is used to disable SONiC console switch feature. + +- Usage: + ``` + config console disable + ``` + +- Example: + ``` + admin@sonic:~$ sudo config console disable + ``` + +**config console add** + +This command is used to add a console port setting. + +- Usage: + ``` + config console add [--baud|-b ] [--flowcontrol|-f] [--devicename|-d ] + ``` + +- Example: + ``` + admin@sonic:~$ config console add 1 --baud 9600 --devicename switch1 + ``` + +**config console del** + +This command is used to remove a console port setting. + +- Usage: + ``` + config console del + ``` + +- Example: + ``` + admin@sonic:~$ sudo config console del 1 + ``` + +**config console remote_device** + +This command is used to update the remote device name for a console port. + +- Usage: + ``` + config console remote_device + ``` + +- Example: + ``` + admin@sonic:~$ sudo config console remote_device 1 switch1 + ``` + +**config console baud** + +This command is used to update the baud rate for a console port. + +- Usage: + ``` + config console baud + ``` + +- Example: + ``` + admin@sonic:~$ sudo config console baud 1 9600 + ``` + +**config console flow_control** + +This command is used to enable or disable flow control feature for a console port. + +- Usage: + ``` + config console flow_control {enable|disable} + ``` + +- Example: + ``` + admin@sonic:~$ sudo config console flow_control enable 1 + ``` + +### Console connect commands + +**connect line** + +This command allows user to connect to a remote device via console line with an interactive cli. + +- Usage: + ``` + connect line (-d|--devicename) + ``` + +By default, the target is `port_name`. + +- Example: + ``` + admin@sonic:~$ connect line 1 + Successful connection to line 1 + Press ^A ^X to disconnect + ``` + +Optionally, you can connect with a remote device name by specifying the `-d` or `--devicename` flag. + +- Example: + ``` + admin@sonic:~$ connect line --devicename switch1 + Successful connection to line 1 + Press ^A ^X to disconnect + ``` + +**connect device** + +This command allows user to connect to a remote device via console line with an interactive cli. + +- Usage: + ``` + connect device + ``` + +The command is same with `connect line --devicename ` + +- Example: + ``` + admin@sonic:~$ connect line 1 + Successful connection to line 1 + Press ^A ^X to disconnect + ``` + +### Console clear commands + +**sonic-clear line** + +This command allows user to connect to a remote device via console line with an interactive cli. + +- Usage: + ``` + sonc-clear line (-d|--devicename) + ``` + +By default, the target is `port_name`. + +- Example: + ``` + admin@sonic:~$ sonic-clear line 1 + ``` + +Optionally, you can clear with a remote device name by specifying the `-d` or `--devicename` flag. + +- Example: + ``` + admin@sonic:~$ sonic-clear --devicename switch1 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#console) + + +## DHCP Relay + +### DHCP Relay config commands + +This sub-section of commands is used to add or remove the DHCP Relay Destination IP address(es) for a VLAN interface. + +**config vlan dhcp_relay add** + +This command is used to add a DHCP Relay Destination IP address or multiple IP addresses to a VLAN. Note that more than one DHCP Relay Destination IP address can be added on a VLAN interface. + +- Usage: + ``` + config vlan dhcp_relay add + ``` + +- Example: + ``` + admin@sonic:~$ sudo config vlan dhcp_relay add 1000 7.7.7.7 + Added DHCP relay destination address ['7.7.7.7'] to Vlan1000 + Restarting DHCP relay service... + ``` + ``` + admin@sonic:~$ sudo config vlan dhcp_relay add 1000 7.7.7.7 1.1.1.1 + Added DHCP relay destination address ['7.7.7.7', '1.1.1.1'] to Vlan1000 + Restarting DHCP relay service... + ``` + +**config vlan dhcp_relay delete** + +This command is used to delete a configured DHCP Relay Destination IP address or multiple IP addresses from a VLAN interface. + +- Usage: + ``` + config vlan dhcp_relay del + ``` + +- Example: + ``` + admin@sonic:~$ sudo config vlan dhcp_relay del 1000 7.7.7.7 + Removed DHCP relay destination address 7.7.7.7 from Vlan1000 + Restarting DHCP relay service... + ``` + ``` + admin@sonic:~$ sudo config vlan dhcp_relay del 1000 7.7.7.7 1.1.1.1 + Removed DHCP relay destination address ('7.7.7.7', '1.1.1.1') from Vlan1000 + Restarting DHCP relay service... + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#dhcp-relay) + + +## Drop Counters + +This section explains all the Configurable Drop Counters show commands and configuration options that are supported in SONiC. + +### Drop Counters show commands + +**show dropcounters capabilities** + +This command is used to show the drop counter capabilities that are available on this device. It displays the total number of drop counters that can be configured on this device as well as the drop reasons that can be configured for the counters. + +- Usage: + ``` + show dropcounters capabilities + ``` + +- Examples: + ``` + admin@sonic:~$ show dropcounters capabilities + Counter Type Total + -------------------- ------- + PORT_INGRESS_DROPS 3 + SWITCH_EGRESS_DROPS 2 + + PORT_INGRESS_DROPS: + L2_ANY + SMAC_MULTICAST + SMAC_EQUALS_DMAC + INGRESS_VLAN_FILTER + EXCEEDS_L2_MTU + SIP_CLASS_E + SIP_LINK_LOCAL + DIP_LINK_LOCAL + UNRESOLVED_NEXT_HOP + DECAP_ERROR + + SWITCH_EGRESS_DROPS: + L2_ANY + L3_ANY + A_CUSTOM_REASON + ``` + +**show dropcounters configuration** + +This command is used to show the current running configuration of the drop counters on this device. + +- Usage: + ``` + show dropcounters configuration [-g ] + ``` + +- Examples: + ``` + admin@sonic:~$ show dropcounters configuration + Counter Alias Group Type Reasons Description + -------- -------- ----- ------------------ ------------------- -------------- + DEBUG_0 RX_LEGIT LEGIT PORT_INGRESS_DROPS SMAC_EQUALS_DMAC Legitimate port-level RX pipeline drops + INGRESS_VLAN_FILTER + DEBUG_1 TX_LEGIT None SWITCH_EGRESS_DROPS EGRESS_VLAN_FILTER Legitimate switch-level TX pipeline drops + + admin@sonic:~$ show dropcounters configuration -g LEGIT + Counter Alias Group Type Reasons Description + -------- -------- ----- ------------------ ------------------- -------------- + DEBUG_0 RX_LEGIT LEGIT PORT_INGRESS_DROPS SMAC_EQUALS_DMAC Legitimate port-level RX pipeline drops + INGRESS_VLAN_FILTER + ``` + +**show dropcounters counts** + +This command is used to show the current statistics for the configured drop counters. Standard drop counters are displayed as well for convenience. + +Because clear (see below) is handled on a per-user basis different users may see different drop counts. + +- Usage: + ``` + show dropcounters counts [-g ] [-t ] + ``` + +- Example: + ``` + admin@sonic:~$ show dropcounters counts + IFACE STATE RX_ERR RX_DROPS TX_ERR TX_DROPS RX_LEGIT + --------- ------- -------- ---------- -------- ---------- --------- + Ethernet0 U 10 100 0 0 20 + Ethernet4 U 0 1000 0 0 100 + Ethernet8 U 100 10 0 0 0 + + DEVICE TX_LEGIT + ------ -------- + sonic 1000 + + admin@sonic:~$ show dropcounters counts -g LEGIT + IFACE STATE RX_ERR RX_DROPS TX_ERR TX_DROPS RX_LEGIT + --------- ------- -------- ---------- -------- ---------- --------- + Ethernet0 U 10 100 0 0 20 + Ethernet4 U 0 1000 0 0 100 + Ethernet8 U 100 10 0 0 0 + + admin@sonic:~$ show dropcounters counts -t SWITCH_EGRESS_DROPS + DEVICE TX_LEGIT + ------ -------- + sonic 1000 + ``` + +### Drop Counters config commands + +**config dropcounters install** + +This command is used to initialize a new drop counter. The user must specify a name, type, and initial list of drop reasons. + +This command will fail if the given name is already in use, if the type of counter is not supported, or if any of the specified drop reasons are not supported. It will also fail if all avaialble counters are already in use on the device. + +- Usage: + ``` + config dropcounters install [-d ] [-g ] [-a ] + ``` + +- Example: + ``` + admin@sonic:~$ sudo config dropcounters install DEBUG_2 PORT_INGRESS_DROPS [EXCEEDS_L2_MTU,DECAP_ERROR] -d "More port ingress drops" -g BAD -a BAD_DROPS + ``` + +**config dropcounters add_reasons** + +This command is used to add drop reasons to an already initialized counter. + +This command will fail if any of the specified drop reasons are not supported. + +- Usage: + ``` + config dropcounters add_reasons + ``` + +- Example: + ``` + admin@sonic:~$ sudo config dropcounters add_reasons DEBUG_2 [SIP_CLASS_E] + ``` + +**config dropcounters remove_reasons** + +This command is used to remove drop reasons from an already initialized counter. + +- Usage: + ``` + config dropcounters remove_reasons + ``` + +- Example: + ``` + admin@sonic:~$ sudo config dropcounters remove_reasons DEBUG_2 [SIP_CLASS_E] + ``` + +**config dropcounters delete** + +This command is used to delete a drop counter. + +- Usage: + ``` + config dropcounters delete + ``` + +- Example: + ``` + admin@sonic:~$ sudo config dropcounters delete DEBUG_2 + ``` + +### Drop Counters clear commands + +**sonic-clear dropcounters** + +This comnmand is used to clear drop counters. This is done on a per-user basis. + +- Usage: + ``` + sonic-clear dropcounters + ``` + +- Example: + ``` + admin@sonic:~$ sonic-clear dropcounters + Cleared drop counters + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](##drop-counters) + +## Dynamic Buffer Management + +This section explains all the show and configuration commands regarding the dynamic buffer management. + +Dynamic buffer management is responsible for calculating buffer size according to the ports' configured speed and administrative state. In order to enable dynamic buffer management feature, the ports' speed must be configured. For this please refer [Interface naming mode config commands](#interface-naming-mode-config-commands) + +### Configuration commands + +**configure shared headroom pool** + +This command is used to configure the shared headroom pool. The shared headroom pool can be enabled in the following ways: + +- Configure the over subscribe ratio. In this case, the size of shared headroom pool is calculated as the accumulative xoff of all of the lossless PG divided by the over subscribe ratio. +- Configure the size. + +In case both of the above parameters have been configured, the `size` will take effect. To disable shared headroom pool, configure both parameters to zero. + +- Usage: + + ``` + config buffer shared-headroom-pool over-subscribe-ratio + config buffer shared-headroom-pool size + ``` + + The range of over-subscribe-ratio is from 1 to number of ports inclusive. + +- Example: + + ``` + admin@sonic:~$ sudo config shared-headroom-pool over-subscribe-ratio 2 + admin@sonic:~$ sudo config shared-headroom-pool size 1024000 + ``` + +**configure a lossless buffer profile** + +This command is used to configure a lossless buffer profile. + +- Usage: + + ``` + config buffer profile add --xon --xoff [-size ] [-dynamic_th ] [-pool ] + config buffer profile set --xon --xoff [-size ] [-dynamic_th ] [-pool ] + config buffer profile remove + ``` + + All the parameters are devided to two groups, one for headroom and one for dynamic_th. For any command at lease one group of parameters should be provided. + For headroom parameters: + + - `xon` is madantory. + - If shared headroom pool is disabled: + - At lease one of `xoff` and `size` should be provided and the other will be optional and conducted via the formula `xon + xoff = size`. + - `xon` + `xoff` <= `size`; For Mellanox platform xon + xoff == size + - If shared headroom pool is enabled: + - `xoff` should be provided. + - `size` = `xoff` if it is not provided. + + If only headroom parameters are provided, the `dynamic_th` will be taken from `CONFIG_DB.DEFAULT_LOSSLESS_BUFFER_PARAMETER.default_dynamic_th`. + + If only dynamic_th parameter is provided, the `headroom_type` will be set as `dynamic` and `xon`, `xoff` and `size` won't be set. This is only used for non default dynamic_th. In this case, the profile won't be deployed to ASIC directly. It can be configured to a lossless PG and then a dynamic profile will be generated based on the port's speed, cable length, and MTU and deployed to the ASIC. + + The subcommand `add` is designed for adding a new buffer profile to the system. + + The subcommand `set` is designed for modifying an existing buffer profile in the system. + For a profile with dynamically calculated headroom information, only `dynamic_th` can be modified. + + The subcommand `remove` is designed for removing an existing buffer profile from the system. When removing a profile, it shouldn't be referenced by any entry in `CONFIG_DB.BUFFER_PG`. + +- Example: + + ``` + admin@sonic:~$ sudo config buffer profile add profile1 --xon 18432 --xoff 18432 + admin@sonic:~$ sudo config buffer profile remove profile1 + ``` + +**config interface cable_length** + +This command is used to configure the length of the cable connected to a port. The cable_length is in unit of meters and must be suffixed with "m". + +- Usage: + + ``` + config interface cable_length + ``` + +- Example: + + ``` + admin@sonic:~$ sudo config interface cable_length Ethernet0 40m + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#dynamic-buffer-management) + +**config interface buffer priority-group lossless** + +This command is used to configure the priority groups on which lossless traffic runs. + +- Usage: + + ``` + config interface buffer priority-group lossless add [profile] + config interface buffer priority-group lossless set [profile] + config interface buffer priority-group lossless remove [] + ``` + + The can be in one of the following two forms: + + - For a range of priorities, the lower bound and upper bound connected by a dash, like `3-4` + - For a single priority, the number, like `6` + + The `pg-map` represents the map of priorities for lossless traffic. It should be a string and in form of a bit map like `3-4`. The `-` connects the lower bound and upper bound of a range of priorities. + + The subcommand `add` is designed for adding a new lossless PG on top of current PGs. The new PG range must be disjoint with all existing PGs. + + For example, currently the PG range 3-4 exist on port Ethernet4, to add PG range 4-5 will fail because it isn't disjoint with 3-4. To add PG range 5-6 will succeed. After that both range 3-4 and 5-6 will work as lossless PG. + + The `override-profile` parameter is optional. When provided, it represents the predefined buffer profile for headroom override. + + The subcommand `set` is designed for modifying an existing PG from dynamic calculation to headroom override or vice versa. The `pg-map` must be an existing PG. + + The subcommand `remove` is designed for removing an existing PG. The option `pg-map` must be an existing PG. All lossless PGs will be removed in case no `pg-map` provided. + +- Example: + + To configure lossless_pg on a port: + + ``` + admin@sonic:~$ sudo config interface buffer priority-group lossless add Ethernet0 3-4 + ``` + + To change the profile used for lossless_pg on a port: + + ``` + admin@sonic:~$ sudo config interface buffer priority-group lossless set Ethernet0 3-4 new-profile + ``` + + To remove one lossless priority from a port: + + ``` + admin@sonic:~$ sudo config interface buffer priority-group lossless remove Ethernet0 6 + ``` + + To remove all lossless priorities from a port: + + ``` + admin@sonic:~$ sudo config interface buffer priority-group lossless remove Ethernet0 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#dynamic-buffer-management) + +**config interface buffer queue** + +This command is used to configure the buffer profiles for queues. + +- Usage: + + ``` + config interface buffer queue add + config interface buffer queue set + config interface buffer queue remove + ``` + + The represents the map of queues. It can be in one of the following two forms: + + - For a range of priorities, the lower bound and upper bound connected by a dash, like `3-4` + - For a single priority, the number, like `6` + + The subcommand `add` is designed for adding a buffer profile for a group of queues. The new queue range must be disjoint with all queues with buffer profile configured. + + For example, currently the buffer profile configured on queue 3-4 on port Ethernet4, to configure buffer profile on queue 4-5 will fail because it isn't disjoint with 3-4. To configure it on range 5-6 will succeed. + + The `profile` parameter represents a predefined egress buffer profile to be configured on the queues. + + The subcommand `set` is designed for modifying an existing group of queues. + + The subcommand `remove` is designed for removing buffer profile on an existing group of queues. + +- Example: + + To configure buffer profiles for queues on a port: + + ``` + admin@sonic:~$ sudo config interface buffer queue add Ethernet0 3-4 egress_lossless_profile + ``` + + To change the profile used for queues on a port: + + ``` + admin@sonic:~$ sudo config interface buffer queue set Ethernet0 3-4 new-profile + ``` + + To remove a group of queues from a port: + + ``` + admin@sonic:~$ sudo config interface buffer queue remove Ethernet0 3-4 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#dynamic-buffer-management) + +### Show commands + +**show buffer information** + +This command is used to display the status of buffer pools and profiles currently deployed to the ASIC. + +- Usage: + + ``` + show buffer information + ``` + +- Example: + + ``` + admin@sonic:~$ show buffer information + Pool: ingress_lossless_pool + ---- -------- + type ingress + mode dynamic + size 17170432 + ---- -------- + + Pool: egress_lossless_pool + ---- -------- + type egress + mode dynamic + size 34340822 + ---- -------- + + Pool: ingress_lossy_pool + ---- -------- + type ingress + mode dynamic + size 17170432 + ---- -------- + + Pool: egress_lossy_pool + ---- -------- + type egress + mode dynamic + size 17170432 + ---- -------- + + Profile: pg_lossless_100000_5m_profile + ---------- ----------------------------------- + xon 18432 + dynamic_th 0 + xoff 18432 + pool [BUFFER_POOL:ingress_lossless_pool] + size 36864 + ---------- ----------------------------------- + + Profile: q_lossy_profile + ---------- ------------------------------- + dynamic_th 3 + pool [BUFFER_POOL:egress_lossy_pool] + size 0 + ---------- ------------------------------- + + Profile: egress_lossy_profile + ---------- ------------------------------- + dynamic_th 3 + pool [BUFFER_POOL:egress_lossy_pool] + size 4096 + ---------- ------------------------------- + + Profile: egress_lossless_profile + ---------- ---------------------------------- + dynamic_th 7 + pool [BUFFER_POOL:egress_lossless_pool] + size 0 + ---------- ---------------------------------- + + Profile: ingress_lossless_profile + ---------- ----------------------------------- + dynamic_th 0 + pool [BUFFER_POOL:ingress_lossless_pool] + size 0 + ---------- ----------------------------------- + + Profile: pg_lossless_100000_79m_profile + ---------- ----------------------------------- + xon 18432 + dynamic_th 0 + xoff 60416 + pool [BUFFER_POOL:ingress_lossless_pool] + size 78848 + ---------- ----------------------------------- + + Profile: pg_lossless_100000_40m_profile + ---------- ----------------------------------- + xon 18432 + dynamic_th 0 + xoff 38912 + pool [BUFFER_POOL:ingress_lossless_pool] + size 57344 + ---------- ----------------------------------- + + Profile: ingress_lossy_profile + ---------- -------------------------------- + dynamic_th 3 + pool [BUFFER_POOL:ingress_lossy_pool] + size 0 + ---------- -------------------------------- + ``` + +**show buffer configuration** + +This command is used to display the status of buffer pools and profiles currently configured. + +- Usage: + + ``` + show buffer configuration + ``` + +- Example: + + ``` + admin@sonic:~$ show buffer configuration + Lossless traffic pattern: + -------------------- - + default_dynamic_th 0 + over_subscribe_ratio 0 + -------------------- - + + Pool: ingress_lossless_pool + ---- -------- + type ingress + mode dynamic + ---- -------- + + Pool: egress_lossless_pool + ---- -------- + type egress + mode dynamic + size 34340822 + ---- -------- + + Pool: ingress_lossy_pool + ---- -------- + type ingress + mode dynamic + ---- -------- + + Pool: egress_lossy_pool + ---- -------- + type egress + mode dynamic + ---- -------- + + Profile: q_lossy_profile + ---------- ------------------------------- + dynamic_th 3 + pool [BUFFER_POOL:egress_lossy_pool] + size 0 + ---------- ------------------------------- + + Profile: egress_lossy_profile + ---------- ------------------------------- + dynamic_th 3 + pool [BUFFER_POOL:egress_lossy_pool] + size 4096 + ---------- ------------------------------- + + Profile: egress_lossless_profile + ---------- ---------------------------------- + dynamic_th 7 + pool [BUFFER_POOL:egress_lossless_pool] + size 0 + ---------- ---------------------------------- + + Profile: ingress_lossless_profile + ---------- ----------------------------------- + dynamic_th 0 + pool [BUFFER_POOL:ingress_lossless_pool] + size 0 + ---------- ----------------------------------- + + Profile: ingress_lossy_profile + ---------- -------------------------------- + dynamic_th 3 + pool [BUFFER_POOL:ingress_lossy_pool] + size 0 + ---------- -------------------------------- + ``` + +## ECN + +This section explains all the Explicit Congestion Notification (ECN) show commands and ECN configuation options that are supported in SONiC. + +### ECN show commands +This sub-section contains the show commands that are supported in ECN. + +**show ecn** + +This command displays all the WRED profiles that are configured in the device. + +- Usage: + ``` + show ecn + ``` + +- Example: + ``` + admin@sonic:~$ show ecn + Profile: **AZURE_LOSSLESS** + ----------------------- ------- + red_max_threshold 2097152 + red_drop_probability 5 + yellow_max_threshold 2097152 + ecn ecn_all + green_min_threshold 1048576 + red_min_threshold 1048576 + wred_yellow_enable true + yellow_min_threshold 1048576 + green_max_threshold 2097152 + green_drop_probability 5 + wred_green_enable true + yellow_drop_probability 5 + wred_red_enable true + ----------------------- ------- + + Profile: **wredprofileabcd** + ----------------- --- + red_max_threshold 100 + ----------------- --- + ``` + +### ECN config commands + +This sub-section contains the configuration commands that can configure the WRED profiles. + +**config ecn** + +This command configures the possible fields in a particular WRED profile that is specified using "-profile " argument. +The list of the WRED profile fields that are configurable is listed in the below "Usage". + +- Usage: + ``` + config ecn -profile [-rmax ] [-rmin ] [-ymax ] [-ymin ] [-gmax ] [-gmin ] [-v|--verbose] + ``` + + - Parameters: + - profile_name Profile name + - red_threshold_max Set red max threshold + - red_threshold_min Set red min threshold + - yellow_threshold_max Set yellow max threshold + - yellow_threshold_min Set yellow min threshold + - green_threshold_max Set green max threshold + - green_threshold_min Set green min threshold + +- Example (Configures the "red max threshold" for the WRED profile name "wredprofileabcd". It will create the WRED profile if it does not exist.): + ``` + admin@sonic:~$ sudo config ecn -profile wredprofileabcd -rmax 100 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#ecn) + +## Feature + +SONiC includes a capability in which Feature state can be enabled/disabled +which will make corresponding feature docker container to start/stop. + +Also SONiC provide capability in which Feature docker container can be automatically shut +down and restarted if one of critical processes running in the container exits +unexpectedly. Restarting the entire feature container ensures that configuration is +reloaded and all processes in the feature container get restarted, thus increasing the +likelihood of entering a healthy state. + +### Feature show commands + +**show feature config** + +Shows the config of given feature or all if no feature is given. The "fallback" is shown only if configured. The fallback defaults to "true" when not configured. + +- Usage: + ``` + show feature config [] + ``` + +- Example: + ``` + admin@sonic:~$ show feature config + Feature State AutoRestart Owner fallback + -------------- -------- ------------- ------- ---------- + bgp enabled enabled local + database enabled disabled local + dhcp_relay enabled enabled kube + lldp enabled enabled kube true + mgmt-framework enabled enabled local + nat disabled enabled local + pmon enabled enabled kube + radv enabled enabled kube + sflow disabled enabled local + snmp enabled enabled kube + swss enabled enabled local + syncd enabled enabled local + teamd enabled enabled local + telemetry enabled enabled kube + ``` + +**show feature status** + +Shows the status of given feature or all if no feature is given. The "fallback" defaults to "true" when not configured. +The subset of features are configurable for remote management and only those report additional data. + +- Usage: + ``` + show feature status [] + ``` + +- Example: + ``` + admin@sonic:~$ show feature status + Feature State AutoRestart SystemState UpdateTime ContainerId ContainerVersion SetOwner CurrentOwner RemoteState + -------------- -------- ------------- ------------- ------------------- ------------- ------------------ ---------- -------------- ------------- + bgp enabled enabled up local local none + database enabled disabled local + dhcp_relay enabled enabled up 2020-11-15 18:21:09 249e70102f55 20201230.100 kube local + lldp enabled enabled up 2020-11-15 18:21:09 779c2d55ee12 20201230.100 kube local + mgmt-framework enabled enabled up local local none + nat disabled enabled local + pmon enabled enabled up 2020-11-15 18:20:27 a2b9ffa8aba3 20201230.100 kube local + radv enabled enabled up 2020-11-15 18:21:05 d8ff27dcfe46 20201230.100 kube local + sflow disabled enabled local + snmp enabled enabled up 2020-11-15 18:25:51 8b7d5529e306 20201230.111 kube kube running + swss enabled enabled up local local none + syncd enabled enabled up local local none + teamd enabled enabled up local local none + telemetry enabled enabled down 2020-11-15 18:24:59 20201230.100 kube none + ``` + +**config feature owner** + +Configures the owner for a feature as "local" or "kube". The "local" implies starting the feature container from local image. The "kube" implies that kubernetes server is made eligible to deploy the feature. The deployment of a feature by kubernetes is conditional based on many factors like, whether the kube server is configured or not, connected-to-kube-server or not and if that master has manifest for this feature for this switch or not and more. At some point in future, the deployment *could* happen and till that point the feature can run from local image, called "fallback". The fallback is allowed by default and it could be toggled to "not allowed". When fallback is not allowed, the feature would run only upon deployment by kubernetes master. + +- Usage: + ``` + config feature owner [] [local/kube] + ``` + +- Example: + ``` + admin@sonic:~$ sudo config feature owner snmp kube + ``` + +**config feature fallback** + +Features configured for "kube" deployment could be allowed to fallback to using local image, until the point of successful kube deployment. The fallback is allowed by default. + +- Usage: + ``` + config feature fallback [] [on/off] + ``` + +- Example: + ``` + admin@sonic:~$ sudo config feature fallback snmp on + ``` + +**show feature autorestart** + +This command will display the status of auto-restart for feature container. + +- Usage: + ``` + show feature autorestart [] + admin@sonic:~$ show feature autorestart + Feature AutoRestart + ---------- -------------- + bgp enabled + database always_enabled + dhcp_relay enabled + lldp enabled + pmon enabled + radv enabled + snmp enabled + swss enabled + syncd enabled + teamd enabled + telemetry enabled + ``` + +Optionally, you can specify a feature name in order to display +status for that feature + +### Feature config commands + +**config feature state ** + +This command will configure the state for a specific feature. + +- Usage: + ``` + config feature state (enabled | disabled) + admin@sonic:~$ sudo config feature state bgp disabled + ``` + +**config feature autorestart ** + +This command will configure the status of auto-restart for a specific feature container. + +- Usage: + ``` + config feature autorestart (enabled | disabled) + admin@sonic:~$ sudo config feature autorestart bgp disabled + ``` +NOTE: If the existing state or auto-restart value for a feature is "always_enabled" then config +commands are don't care and will not update state/auto-restart value. + +Go Back To [Beginning of the document](#) or [Beginning of this section](#feature) + +## Flow Counters + +This section explains all the Flow Counters show commands, clear commands and config commands that are supported in SONiC. Flow counters are usually used for debugging, troubleshooting and performance enhancement processes. Flow counters supports case like: + + - Host interface traps (number of received traps per Trap ID) + - Routes matching the configured prefix pattern (number of hits and number of bytes) + +### Flow Counters show commands + +**show flowcnt-trap stats** + +This command is used to show the current statistics for the registered host interface traps. + +Because clear (see below) is handled on a per-user basis different users may see different counts. + +- Usage: + ``` + show flowcnt-trap stats + ``` + +- Example: + ``` + admin@sonic:~$ show flowcnt-trap stats + Trap Name Packets Bytes PPS + --------- --------- ------- ------- + dhcp 100 2,000 50.25/s + + For multi-ASIC: + admin@sonic:~$ show flowcnt-trap stats + ASIC ID Trap Name Packets Bytes PPS + ------- ----------- --------- ------- ------- + asic0 dhcp 100 2,000 50.25/s + asic1 dhcp 200 3,000 45.25/s + ``` + +**show flowcnt-route stats** + +This command is used to show the current statistics for route flow patterns. + +Because clear (see below) is handled on a per-user basis different users may see different counts. + +- Usage: + ``` + show flowcnt-route stats + show flowcnt-route stats pattern [--vrf ] + show flowcnt-route stats route [--vrf ] + ``` + +- Example: + ``` + admin@sonic:~$ show flowcnt-route stats + Route pattern VRF Matched routes Packets Bytes + -------------------------------------------------------------------------------------- + 3.3.0.0/16 default 3.3.1.0/24 100 4543 + 3.3.2.3/32 3443 929229 + 3.3.0.0/16 0 0 + 2000::/64 default 2000::1/128 100 4543 + ``` + +The "pattern" subcommand is used to display the route flow counter statistics by route pattern. + +- Example: + ``` + admin@sonic:~$ show flowcnt-route stats pattern 3.3.0.0/16 + Route pattern VRF Matched routes Packets Bytes + -------------------------------------------------------------------------------------- + 3.3.0.0/16 default 3.3.1.0/24 100 4543 + 3.3.2.3/32 3443 929229 + 3.3.0.0/16 0 0 + ``` + +The "route" subcommand is used to display the route flow counter statistics by route prefix. + ``` + admin@sonic:~$ show flowcnt-route stats route 3.3.3.2/32 --vrf Vrf_1 + Route VRF Route Pattern Packets Bytes + ----------------------------------------------------------------------------------------- + 3.3.3.2/32 Vrf_1 3.3.0.0/16 100 4543 + ``` + +### Flow Counters clear commands + +**sonic-clear flowcnt-trap** + +This command is used to clear the current statistics for the registered host interface traps. This is done on a per-user basis. + +- Usage: + ``` + sonic-clear flowcnt-trap + ``` + +- Example: + ``` + admin@sonic:~$ sonic-clear flowcnt-trap + Trap Flow Counters were successfully cleared + ``` + +**sonic-clear flowcnt-route** + +This command is used to clear the current statistics for the route flow counter. This is done on a per-user basis. + +- Usage: + ``` + sonic-clear flowcnt-route + sonic-clear flowcnt-route pattern [--vrf ] + sonic-clear flowcnt-route route [--vrf ] + ``` + +- Example: + ``` + admin@sonic:~$ sonic-clear flowcnt-route + Route Flow Counters were successfully cleared + ``` + +The "pattern" subcommand is used to clear the route flow counter statistics by route pattern. + +- Example: + ``` + admin@sonic:~$ sonic-clear flowcnt-route pattern 3.3.0.0/16 --vrf Vrf_1 + Flow Counters of all routes matching the configured route pattern were successfully cleared + ``` + +The "route" subcommand is used to clear the route flow counter statistics by route prefix. + +- Example: + ``` + admin@sonic:~$ sonic-clear flowcnt-route route 3.3.3.2/32 --vrf Vrf_1 + Flow Counters of the specified route were successfully cleared + ``` + +### Flow Counters config commands + +**config flowcnt-route pattern add** + +This command is used to add or update the route pattern which is used by route flow counter to match route entries. + +- Usage: + ``` + config flowcnt-route pattern add [--vrf ] [--max ] + ``` + +- Example: + ``` + admin@sonic:~$ config flowcnt-route pattern add 2.2.0.0/16 --vrf Vrf_1 --max 50 + ``` + +**config flowcnt-route pattern remove** + +This command is used to remove the route pattern which is used by route flow counter to match route entries. + +- Usage: + ``` + config flowcnt-route pattern remove [--vrf ] + ``` + +- Example: + ``` + admin@sonic:~$ config flowcnt-route pattern remove 2.2.0.0/16 --vrf Vrf_1 + ``` + + +Go Back To [Beginning of the document](#) or [Beginning of this section](#flow-counters) +## Gearbox + +This section explains all the Gearbox PHY show commands that are supported in SONiC. + +### Gearbox show commands +This sub-section contains the show commands that are supported for gearbox phy. + +**show gearbox interfaces status** + +This command displays information about the gearbox phy interface lanes, speeds and status. Data is displayed for both MAC side and line side of the gearbox phy + +- Usage: + ``` + show gearbox interfaces status + ``` + +- Example: + +``` +home/admin# show gearbox interfaces status + PHY Id Interface MAC Lanes MAC Lane Speed PHY Lanes PHY Lane Speed Line Lanes Line Lane Speed Oper Admin +-------- ----------- ----------- ---------------- ----------- ---------------- ------------ ----------------- ------ ------- + 1 Ethernet0 25,26,27,28 10G 200,201 20G 206 40G up up + 1 Ethernet4 29,30,31,32 10G 202,203 20G 207 40G up up + 1 Ethernet8 33,34,35,36 10G 204,205 20G 208 40G up up + + ``` + +**show gearbox phys status** + +This command displays basic information about the gearbox phys configured on the switch. + +- Usage: + ``` + show gearbox phys status + ``` + +- Example: + +``` +/home/admin# show gearbox phys status + PHY Id Name Firmware +-------- ------- ---------- + 1 sesto-1 v0.1 + + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#gearbox) + + +## Update Device Hostname Configuration Commands + +This sub-section of commands is used to change device hostname without traffic being impacted. + +**config hostname** + +This command is used to change device hostname without traffic being impacted. + +- Usage: + ``` + config hostname + ``` + +- Example: + ``` + admin@sonic:~$ sudo config hostname CSW06 + Please note loaded setting will be lost after system reboot. To preserve setting, run `config save`. + ``` + +## Generic Configuration Update and Rollback + +The below command displays the brief summary of apply-patch, rollback, replace, checkpoint, delete-checkpoint, list-checkpoints functionality. This GCU feature is an initial version in 202111 release and may not function properly. + +### Apply-patch command + +Usage: + +``` + +admin@sonic:~$ sudo config apply-patch --help +Usage: config apply-patch [OPTIONS] PATCH_FILE_PATH + + Apply given patch of updates to Config. A patch is a JsonPatch which + follows rfc6902. This command can be used do partial updates to the config + with minimum disruption to running processes. It allows addition as well + as deletion of configs. The patch file represents a diff of ConfigDb(ABNF) + format or SonicYang format. + + : Path to the patch file on the file-system. + +Options: + -f, --format [CONFIGDB|SONICYANG] + format of config of the patch is either + ConfigDb(ABNF) or SonicYang + -d, --dry-run test out the command without affecting + config state + -v, --verbose print additional details of what the + operation is doing + -h, -?, --help Show this message and exit. + +``` + +### Replace Command + + +Usage : + +``` + +admin@sonic:~$ sudo config replace --help +Usage: config replace [OPTIONS] TARGET_FILE_PATH + + Replace the whole config with the specified config. The config is replaced + with minimum disruption e.g. if ACL config is different between current + and target config only ACL config is updated, and other config/services + such as DHCP will not be affected. **WARNING** The target config file + should be the whole config, not just the part intended to be updated. + + : Path to the target file on the file-system. + +Options: + -f, --format [CONFIGDB|SONICYANG] + format of target config is either + ConfigDb(ABNF) or SonicYang + -d, --dry-run test out the command without affecting + config state + -v, --verbose print additional details of what the + operation is doing + -h, -?, --help Show this message and exit. + +``` + +### Rollback Command + + +Usage : + +``` +admin@sonic:~$ sudo config rollback --help +Usage: config rollback [OPTIONS] CHECKPOINT_NAME + + Rollback the whole config to the specified checkpoint. The config is + rolled back with minimum disruption e.g. if ACL config is different + between current and checkpoint config only ACL config is updated, and + other config/services such as DHCP will not be affected. + + : The checkpoint name, use `config list-checkpoints` + command to see available checkpoints. + +Options: + -d, --dry-run test out the command without affecting config state + -v, --verbose print additional details of what the operation is doing + -?, -h, --help Show this message and exit. + +``` + +### Checkpoint Command + + +Usage : + +``` +admin@sonic:~$ sudo config checkpoint --help +Usage: config checkpoint [OPTIONS] CHECKPOINT_NAME + + Take a checkpoint of the whole current config with the specified + checkpoint name. + + : The checkpoint name, use `config list-checkpoints` + command to see available checkpoints. + +Options: + -v, --verbose print additional details of what the operation is doing + -h, -?, --help Show this message and exit. + +``` + +### Delete-checkpoint Command + + +Usage : + +``` +admin@sonic:~$ sudo config delete-checkpoint --help +Usage: config delete-checkpoint [OPTIONS] CHECKPOINT_NAME + + Delete a checkpoint with the specified checkpoint name. + + : The checkpoint name, use `config list-checkpoints` + command to see available checkpoints. + +Options: + -v, --verbose print additional details of what the operation is doing + -h, -?, --help Show this message and exit. + +``` + +### List-checkpoints Command + +Usage : + +``` +admin@sonic:~$ sudo config list-checkpoints --help +Usage: config list-checkpoints [OPTIONS] + + List the config checkpoints available. + +Options: + -v, --verbose print additional details of what the operation is doing + -?, -h, --help Show this message and exit. + +``` + +## Interfaces + +### Interface Show Commands + +This sub-section lists all the possible show commands for the interfaces available in the device. Following example gives the list of possible shows on interfaces. +Subsequent pages explain each of these commands in detail. + +- Example: + ``` + admin@sonic:~$ show interfaces -? + + Show details of the network interfaces + + Options: + -?, -h, --help Show this message and exit. + + Commands: + autoneg Show interface autoneg information + breakout Show Breakout Mode information by interfaces + counters Show interface counters + description Show interface status, protocol and... + mpls Show Interface MPLS status + naming_mode Show interface naming_mode status + neighbor Show neighbor related information + portchannel Show PortChannel information + status Show Interface status information + tpid Show Interface tpid information + transceiver Show SFP Transceiver information + ``` + +**show interfaces autoneg** + +This show command displays the port auto negotiation status for all interfaces i.e. interface name, auto negotiation mode, speed, advertised speeds, interface type, advertised interface types, operational status, admin status. For a single interface, provide the interface name with the sub-command. + +- Usage: + ``` + show interfaces autoneg status + show interfaces autoneg status + ``` + +- Example: + ``` + admin@sonic:~$ show interfaces autoneg status + Interface Auto-Neg Mode Speed Adv Speeds Type Adv Types Oper Admin + ----------- --------------- ------- ------------ ------ ----------- ------ ------- + Ethernet0 enabled 25G 10G,25G CR CR,CR4 up up + Ethernet4 disabled 100G all CR4 all up up + + admin@sonic:~$ show interfaces autoneg status Ethernet8 + Interface Auto-Neg Mode Speed Adv Speeds Type Adv Types Oper Admin + ----------- --------------- ------- ------------ ------ ----------- ------ ------- + Ethernet8 disabled 100G N/A CR4 N/A up up + ``` + +**show interfaces breakout (Versions >= 202006)** + +This show command displays the port capability for all interfaces i.e. index, lanes, default_brkout_mode, breakout_modes(i.e. available breakout modes) and brkout_mode (i.e. current breakout mode). To display current breakout mode, "current-mode" subcommand can be used.For a single interface, provide the interface name with the sub-command. + +- Usage: + ``` + show interfaces breakout + show interfaces breakout current-mode + show interfaces breakout current-mode + ``` + +- Example: + ``` + admin@lnos-x1-a-fab01:~$ show interfaces breakout + { + "Ethernet0": { + "index": "1,1,1,1", + "default_brkout_mode": "1x100G[40G]", + "child ports": "Ethernet0", + "child port speed": "100G", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]", + "Current Breakout Mode": "1x100G[40G]", + "lanes": "65,66,67,68", + "alias_at_lanes": "Eth1/1, Eth1/2, Eth1/3, Eth1/4" + },... continue + } + ``` +The "current-mode" subcommand is used to display current breakout mode for all interfaces. + ``` + admin@lnos-x1-a-fab01:~$ show interfaces breakout current-mode + +-------------+-------------------------+ + | Interface | Current Breakout Mode | + +=============+=========================+ + | Ethernet0 | 4x25G[10G] | + +-------------+-------------------------+ + | Ethernet4 | 4x25G[10G] | + +-------------+-------------------------+ + | Ethernet8 | 4x25G[10G] | + +-------------+-------------------------+ + | Ethernet12 | 4x25G[10G] | + +-------------+-------------------------+ + + admin@lnos-x1-a-fab01:~$ show interfaces breakout current-mode Ethernet0 + +-------------+-------------------------+ + | Interface | Current Breakout Mode | + +=============+=========================+ + | Ethernet0 | 4x25G[10G] | + +-------------+-------------------------+ + ``` + +**show interfaces counters** + +This show command displays packet counters for all interfaces since the last time the counters were cleared. To display l3 counters "rif" subcommand can be used. There is no facility to display counters for one specific l2 interface. For l3 interfaces a single interface output mode is present. Optional argument "-a" provides two additional columns - RX-PPS and TX_PPS. +Optional argument "-p" specify a period (in seconds) with which to gather counters over. + +- Usage: + ``` + show interfaces counters [-a|--printall] [-p|--period ] + show interfaces counters errors + show interfaces counters rates + show interfaces counters rif [-p|--period ] [-i ] + ``` + +- Example: + ``` + admin@sonic:~$ show interfaces counters + IFACE STATE RX_OK RX_BPS RX_UTIL RX_ERR RX_DRP RX_OVR TX_OK TX_BPS TX_UTIL TX_ERR TX_DRP TX_OVR + ----------- ------- --------------- ----------- --------- -------- -------- -------- --------------- ----------- --------- -------- -------- -------- + Ethernet0 U 471,729,839,997 653.87 MB/s 12.77% 0 18,682 0 409,682,385,925 556.84 MB/s 10.88% 0 0 0 + Ethernet4 U 453,838,006,636 632.97 MB/s 12.36% 0 1,636 0 388,299,875,056 529.34 MB/s 10.34% 0 0 0 + Ethernet8 U 549,034,764,539 761.15 MB/s 14.87% 0 18,274 0 457,603,227,659 615.20 MB/s 12.02% 0 0 0 + Ethernet12 U 458,052,204,029 636.84 MB/s 12.44% 0 17,614 0 388,341,776,615 527.37 MB/s 10.30% 0 0 0 + Ethernet16 U 16,679,692,972 13.83 MB/s 0.27% 0 17,605 0 18,206,586,265 17.51 MB/s 0.34% 0 0 0 + Ethernet20 U 47,983,339,172 35.89 MB/s 0.70% 0 2,174 0 58,986,354,359 51.83 MB/s 1.01% 0 0 0 + Ethernet24 U 33,543,533,441 36.59 MB/s 0.71% 0 1,613 0 43,066,076,370 49.92 MB/s 0.97% 0 0 0 + + admin@sonic:~$ show interfaces counters -i Ethernet4,Ethernet12-16 + IFACE STATE RX_OK RX_BPS RX_UTIL RX_ERR RX_DRP RX_OVR TX_OK TX_BPS TX_UTIL TX_ERR TX_DRP TX_OVR + ----------- ------- --------------- ----------- --------- -------- -------- -------- --------------- ----------- --------- -------- -------- -------- + Ethernet4 U 453,838,006,636 632.97 MB/s 12.36% 0 1,636 0 388,299,875,056 529.34 MB/s 10.34% 0 0 0 + Ethernet12 U 458,052,204,029 636.84 MB/s 12.44% 0 17,614 0 388,341,776,615 527.37 MB/s 10.30% 0 0 0 + Ethernet16 U 16,679,692,972 13.83 MB/s 0.27% 0 17,605 0 18,206,586,265 17.51 MB/s 0.34% 0 0 0 + ``` + +The "errors" subcommand is used to display the interface errors. + +- Example: + ``` + admin@str-s6000-acs-11:~$ show interface counters errors + IFACE STATE RX_ERR RX_DRP RX_OVR TX_ERR TX_DRP TX_OVR + ----------- ------- -------- -------- -------- -------- -------- -------- + Ethernet0 U 0 4 0 0 0 0 + Ethernet4 U 0 0 0 0 0 0 + Ethernet8 U 0 1 0 0 0 0 + Ethernet12 U 0 0 0 0 0 0 + ``` + +The "rates" subcommand is used to disply only the interface rates. + +- Example: + ``` + admin@str-s6000-acs-11:/usr/bin$ show int counters rates + IFACE STATE RX_OK RX_BPS RX_PPS RX_UTIL TX_OK TX_BPS TX_PPS TX_UTIL + ----------- ------- ------- -------- -------- --------- ------- -------- -------- --------- + Ethernet0 U 467510 N/A N/A N/A 466488 N/A N/A N/A + Ethernet4 U 469679 N/A N/A N/A 469245 N/A N/A N/A + Ethernet8 U 466660 N/A N/A N/A 465982 N/A N/A N/A + Ethernet12 U 466579 N/A N/A N/A 466318 N/A N/A N/A + ``` + + +The "rif" subcommand is used to display l3 interface counters. Layer 3 interfaces include router interfaces, portchannels and vlan interfaces. + +- Example: + +``` + admin@sonic:~$ show interfaces counters rif + IFACE RX_OK RX_BPS RX_PPS RX_ERR TX_OK TX_BPS TX_PPS TX_ERR +--------------- ------- ---------- -------- -------- ------- -------- -------- -------- +PortChannel0001 62,668 107.81 B/s 1.34/s 3 6 0.02 B/s 0.00/s 0 +PortChannel0002 62,645 107.77 B/s 1.34/s 3 2 0.01 B/s 0.00/s 0 +PortChannel0003 62,481 107.56 B/s 1.34/s 3 3 0.01 B/s 0.00/s 0 +PortChannel0004 62,732 107.88 B/s 1.34/s 2 3 0.01 B/s 0.00/s 0 + Vlan1000 0 0.00 B/s 0.00/s 0 0 0.00 B/s 0.00/s 0 +``` + + +Optionally, you can specify a layer 3 interface name to display the counters in single interface mode. + +- Example: + +``` + admin@sonic:~$ show interfaces counters rif PortChannel0001 + PortChannel0001 + --------------- + + RX: + 3269 packets + 778494 bytesq + 3 error packets + 292 error bytes + TX: + 0 packets + 0 bytes + 0 error packets + 0 error bytes +``` + + +Optionally, you can specify a period (in seconds) with which to gather counters over. Note that this function will take `` seconds to execute. + +- Example: + +``` + admin@sonic:~$ show interfaces counters -p 5 + IFACE STATE RX_OK RX_BPS RX_UTIL RX_ERR RX_DRP RX_OVR TX_OK TX_BPS TX_UTIL TX_ERR TX_DRP TX_OVR + ----------- ------- ------- ----------- --------- -------- -------- -------- ------- ----------- --------- -------- -------- -------- + Ethernet0 U 515 59.14 KB/s 0.00% 0 0 0 1,305 127.60 KB/s 0.00% 0 0 0 + Ethernet4 U 305 26.54 KB/s 0.00% 0 0 0 279 39.12 KB/s 0.00% 0 0 0 + Ethernet8 U 437 42.96 KB/s 0.00% 0 0 0 182 18.37 KB/s 0.00% 0 0 0 + Ethernet12 U 284 40.79 KB/s 0.00% 0 0 0 160 13.03 KB/s 0.00% 0 0 0 + Ethernet16 U 377 32.64 KB/s 0.00% 0 0 0 214 18.01 KB/s 0.00% 0 0 0 + Ethernet20 U 284 36.81 KB/s 0.00% 0 0 0 138 8758.25 B/s 0.00% 0 0 0 + Ethernet24 U 173 16.09 KB/s 0.00% 0 0 0 169 11.39 KB/s 0.00% 0 0 0 +``` + +- NOTE: Interface counters can be cleared by the user with the following command: + + ``` + admin@sonic:~$ sonic-clear counters + ``` + +- NOTE: Layer 3 interface counters can be cleared by the user with the following command: + + ``` + admin@sonic:~$ sonic-clear rifcounters + ``` + +**show interfaces description** + +This command displays the key fields of the interfaces such as Operational Status, Administrative Status, Alias and Description. + +- Usage: + ``` + show interfaces description [] + ``` + +- Example: + ``` + admin@sonic:~$ show interfaces description + Interface Oper Admin Alias Description + ----------- ------ ------- --------------- -------------------- + Ethernet0 down up hundredGigE1/1 T0-1:hundredGigE1/30 + Ethernet4 down up hundredGigE1/2 T0-2:hundredGigE1/30 + Ethernet8 down down hundredGigE1/3 hundredGigE1/3 + Ethernet12 down down hundredGigE1/4 hundredGigE1/4 + ``` + +- Example (to only display the description for interface Ethernet4): + + ``` + admin@sonic:~$ show interfaces description Ethernet4 + Interface Oper Admin Alias Description + ----------- ------ ------- -------------- -------------------- + Ethernet4 down up hundredGigE1/2 T0-2:hundredGigE1/30 + ``` + +**show interfaces mpls** + +This command is used to display the configured MPLS state for the list of configured interfaces. + +- Usage: + ``` + show interfaces mpls [] + ``` + +- Example: + ``` + admin@sonic:~$ show interfaces mpls + Interface MPLS State + ----------- ------------ + Ethernet0 disable + Ethernet4 enable + Ethernet8 enable + Ethernet12 disable + Ethernet16 disable + Ethernet20 disable + ``` + +- Example (to only display the MPLS state for interface Ethernet4): + ``` + admin@sonic:~$ show interfaces mpls Ethernet4 + Interface MPLS State + ----------- ------------ + Ethernet4 enable + ``` + +**show interfaces loopback-action** + +This command displays the configured loopback action + +- Usage: + ``` + show ip interfaces loopback-action + ``` + +- Example: + ``` + root@sonic:~# show ip interfaces loopback-action + Interface Action + ------------ ---------- + Ethernet232 drop + Vlan100 forward + ``` + + +**show interfaces tpid** + +This command displays the key fields of the interfaces such as Operational Status, Administrative Status, Alias and TPID. + +- Usage: + ``` + show interfaces tpid [] + ``` + +- Example: + ``` + admin@sonic:~$ show interfaces tpid + Interface Alias Oper Admin TPID + --------------- --------------- ------ ------- ------ + Ethernet0 fortyGigE1/1/1 up up 0x8100 + Ethernet1 fortyGigE1/1/2 up up 0x8100 + Ethernet2 fortyGigE1/1/3 down down 0x8100 + Ethernet3 fortyGigE1/1/4 down down 0x8100 + Ethernet4 fortyGigE1/1/5 up up 0x8100 + Ethernet5 fortyGigE1/1/6 up up 0x8100 + Ethernet6 fortyGigE1/1/7 up up 0x9200 + Ethernet7 fortyGigE1/1/8 up up 0x88A8 + Ethernet8 fortyGigE1/1/9 up up 0x8100 + ... + Ethernet63 fortyGigE1/4/16 down down 0x8100 + PortChannel0001 N/A up up 0x8100 + PortChannel0002 N/A up up 0x8100 + PortChannel0003 N/A up up 0x8100 + PortChannel0004 N/A up up 0x8100 + admin@sonic:~$ + ``` + +- Example (to only display the TPID for interface Ethernet6): + + ``` + admin@sonic:~$ show interfaces tpid Ethernet6 + Interface Alias Oper Admin TPID + ----------- -------------- ------ ------- ------ + Ethernet6 fortyGigE1/1/7 up up 0x9200 + admin@sonic:~$ + ``` + +**show interfaces naming_mode** + +Refer sub-section [Interface-Naming-Mode](#Interface-Naming-Mode) + + +**show interfaces neighbor** + +This command is used to display the list of expected neighbors for all interfaces (or for a particular interface) that is configured. + +- Usage: + ``` + show interfaces neighbor expected [] + ``` + +- Example: + ``` + admin@sonic:~$ show interfaces neighbor expected + LocalPort Neighbor NeighborPort NeighborLoopback NeighborMgmt NeighborType + ----------- ---------- -------------- ------------------ -------------- -------------- + Ethernet112 ARISTA01T1 Ethernet1 None 10.16.205.100 ToRRouter + Ethernet116 ARISTA02T1 Ethernet1 None 10.16.205.101 SpineRouter + Ethernet120 ARISTA03T1 Ethernet1 None 10.16.205.102 LeafRouter + Ethernet124 ARISTA04T1 Ethernet1 None 10.16.205.103 LeafRouter + ``` + +**show interfaces portchannel** + +This command displays information regarding port-channel interfaces + +- Usage: + ``` + show interfaces portchannel + ``` + +- Example: + ``` + admin@sonic:~$ show interfaces portchannel + Flags: A - active, I - inactive, Up - up, Dw - Down, N/A - not available, S - selected, D - deselected + No. Team Dev Protocol Ports + ----- ------------- ----------- --------------------------- + 24 PortChannel24 LACP(A)(Up) Ethernet28(S) Ethernet24(S) + 48 PortChannel48 LACP(A)(Up) Ethernet52(S) Ethernet48(S) + 40 PortChannel40 LACP(A)(Up) Ethernet44(S) Ethernet40(S) + 0 PortChannel0 LACP(A)(Up) Ethernet0(S) Ethernet4(S) + 8 PortChannel8 LACP(A)(Up) Ethernet8(S) Ethernet12(S) + ``` + +**show interface status** + +This command displays some more fields such as Lanes, Speed, MTU, Type, Asymmetric PFC status and also the operational and administrative status of the interfaces + +- Usage: + ``` + show interfaces status [] + ``` + +- Example (show interface status of all interfaces): + ``` + admin@sonic:~$ show interfaces status + Interface Lanes Speed MTU Alias Oper Admin Type Asym PFC + ----------- --------------- ------- ----- --------------- ------ ------- ------ ---------- + Ethernet0 49,50,51,52 100G 9100 hundredGigE1/1 down up N/A off + Ethernet4 53,54,55,56 100G 9100 hundredGigE1/2 down up N/A off + Ethernet8 57,58,59,60 100G 9100 hundredGigE1/3 down down N/A off + + ``` + +- Example (to only display the status for interface Ethernet0): + ``` + admin@sonic:~$ show interface status Ethernet0 + Interface Lanes Speed MTU Alias Oper Admin + ----------- -------- ------- ----- -------------- ------ ------- + Ethernet0 101,102 40G 9100 fortyGigE1/1/1 up up + ``` + +- Example (to only display the status for range of interfaces): + ``` + admin@sonic:~$ show interfaces status Ethernet8,Ethernet168-180 + Interface Lanes Speed MTU Alias Oper Admin Type Asym PFC + ----------- ----------------- ------- ----- --------------- ------ ------- ------ ---------- + Ethernet8 49,50,51,52 100G 9100 hundredGigE3 down down N/A N/A + Ethernet168 9,10,11,12 100G 9100 hundredGigE43 down down N/A N/A + Ethernet172 13,14,15,16 100G 9100 hundredGigE44 down down N/A N/A + Ethernet176 109,110,111,112 100G 9100 hundredGigE45 down down N/A N/A + Ethernet180 105,106,107,108 100G 9100 hundredGigE46 down down N/A N/A + ``` + +**show interfaces transceiver** + +This command is already explained [here](#Transceivers) + +### Interface Config Commands +This sub-section explains the following list of configuration on the interfaces. +1) ip - To add or remove IP address for the interface +2) pfc - to set the PFC configuration for the interface +3) shutdown - to administratively shut down the interface +4) speed - to set the interface speed +5) startup - to bring up the administratively shutdown interface +6) breakout - to set interface breakout mode +7) autoneg - to set interface auto negotiation mode +8) advertised-speeds - to set interface advertised speeds +9) advertised-types - to set interface advertised types +10) type - to set interface type +11) mpls - To add or remove MPLS operation for the interface +12) loopback-action - to set action for packet that ingress and gets routed on the same IP interface + +From 201904 release onwards, the “config interface” command syntax is changed and the format is as follows: + +- config interface interface_subcommand +i.e Interface name comes after the subcommand +- Ex: config interface startup Ethernet63 + +The syntax for all such interface_subcommands are given below under each command + +NOTE: In older versions of SONiC until 201811 release, the command syntax was `config interface interface_subcommand` + + +**config interface ip add [default_gw] (Versions >= 201904)** + +**config interface ip add (Versions <= 201811)** + +This command is used for adding the IP address for an interface. +IP address for either physical interface or for portchannel or for VLAN interface or for Loopback interface can be configured using this command. +While configuring the IP address for the management interface "eth0", users can provide the default gateway IP address as an optional parameter from release 201911. + + +- Usage: + + *Versions >= 201904* + ``` + config interface ip add + ``` + *Versions <= 201811* + ``` + config interface ip add + ``` + +- Example: + + *Versions >= 201904* + ``` + admin@sonic:~$ sudo config interface ip add Ethernet63 10.11.12.13/24 + admin@sonic:~$ sudo config interface ip add eth0 20.11.12.13/24 20.11.12.254 + ``` + *Versions <= 201811* + ``` + admin@sonic:~$ sudo config interface Ethernet63 ip add 10.11.12.13/24 + ``` + +VLAN interface names take the form of `vlan`. E.g., VLAN 100 will be named `vlan100` + +- Example: + + *Versions >= 201904* + ``` + admin@sonic:~$ sudo config interface ip add Vlan100 10.11.12.13/24 + ``` + *Versions <= 201811* + ``` + admin@sonic:~$ sudo config interface vlan100 ip add 10.11.12.13/24 + ``` + + +**config interface ip remove (Versions >= 201904)** + +**config interface ip remove (Versions <= 201811)** + +- Usage: + + *Versions >= 201904* + ``` + config interface ip remove + ``` + *Versions <= 201811* + ``` + config interface ip remove + ``` + +- Example: + + *Versions >= 201904* + ``` + admin@sonic:~$ sudo config interface ip remove Ethernet63 10.11.12.13/24 + admin@sonic:~$ sudo config interface ip remove eth0 20.11.12.13/24 + ``` + *Versions <= 201811* + ``` + admin@sonic:~$ sudo config interface Ethernet63 ip remove 10.11.12.13/24 + ``` + +VLAN interface names take the form of `vlan`. E.g., VLAN 100 will be named `vlan100` + +- Example: + + *Versions >= 201904* + ``` + admin@sonic:~$ sudo config interface ip remove vlan100 10.11.12.13/24 + ``` + *Versions <= 201811* + ``` + admin@sonic:~$ sudo config interface vlan100 ip remove 10.11.12.13/24 + ``` + +**config interface pfc priority (on | off)** + +This command is used to set PFC on a given priority of a given interface to either "on" or "off". Once it is successfully configured, it will show current losses priorities on the given interface. Otherwise, it will show error information + +- Example: + *Versions >= 201904* + ``` + admin@sonic:~$ sudo config interface pfc priority Ethernet0 3 off + + Interface Lossless priorities + ----------- --------------------- + Ethernet0 4 + + admin@sonic:~$ sudo config interface pfc priority Ethernet0 8 off + Usage: pfc config priority [OPTIONS] STATUS INTERFACE PRIORITY + + Error: Invalid value for "priority": invalid choice: 8. (choose from 0, 1, 2, 3, 4, 5, 6, 7) + + admin@sonic:~$ sudo config interface pfc priority Ethernet101 3 off + Cannot find interface Ethernet101 + + admin@sonic:~$ sudo config interface pfc priority Ethernet0 3 on + + Interface Lossless priorities + ----------- --------------------- + Ethernet0 3,4 + ``` + +**config interface pfc asymmetric (Versions >= 201904)** + +**config interface pfc asymmetric (Versions <= 201811)** + +This command is used for setting the asymmetric PFC for an interface to either "on" or "off". Once if it is configured, use "show interfaces status" to check the same. + +- Usage: + + *Versions >= 201904* + ``` + config interface pfc asymmetric on/off (for 201904+ version) + ``` + *Versions <= 201811* + ``` + config interface pfc asymmetric on/off (for 201811- version) + ``` + +- Example: + + *Versions >= 201904* + ``` + admin@sonic:~$ sudo config interface pfc asymmetric Ethernet60 on + ``` + *Versions <= 201811* + ``` + admin@sonic:~$ sudo config interface Ethernet60 pfc asymmetric on + ``` + +**config interface shutdown (Versions >= 201904)** + +**config interface shutdown (Versions <= 201811)** + +This command is used to administratively shut down either the Physical interface or port channel interface. Once if it is configured, use "show interfaces status" to check the same. + +- Usage: + + *Versions >= 201904* + ``` + config interface shutdown (for 201904+ version) + ``` + *Versions <= 201811* + ``` + config interface shutdown (for 201811- version) + ``` + +- Example: + + *Versions >= 201904* + ``` + admin@sonic:~$ sudo config interface shutdown Ethernet63 + ``` + *Versions <= 201811* + ``` + admin@sonic:~$ sudo config interface Ethernet63 shutdown + ``` + + shutdown multiple interfaces + ``` + admin@sonic:~$ sudo config interface shutdown Ethernet8,Ethernet16-20,Ethernet32 + ``` + +**config interface startup (Versions >= 201904)** + +**config interface startup (Versions <= 201811)** + +This command is used for administratively bringing up the Physical interface or port channel interface.Once if it is configured, use "show interfaces status" to check the same. + +- Usage: + + *Versions >= 201904* + ``` + config interface startup (for 201904+ version) + ``` + *Versions <= 201811* + ``` + config interface startup (for 201811- version) + ``` + +- Example: + + *Versions >= 201904* + ``` + admin@sonic:~$ sudo config interface startup Ethernet63 + ``` + *Versions <= 201811* + ``` + admin@sonic:~$ sudo config interface Ethernet63 startup + ``` + + startup multiple interfaces + ``` + admin@sonic:~$ sudo config interface startup Ethernet8,Ethernet16-20,Ethernet32 + ``` + +**config interface speed (Versions >= 202006)** + +Dynamic breakout feature is supported in SONiC from 202006 version. +User can configure any speed specified under "breakout_modes" keys for the parent interface in the platform-specific port configuration file (i.e. platform.json). + +For example for a breakout mode of 2x50G[25G,10G] the default speed is 50G but the interface also supports 25G and 10G. + +Refer [DPB HLD DOC](https://github.com/Azure/SONiC/blob/master/doc/dynamic-port-breakout/sonic-dynamic-port-breakout-HLD.md#cli-design) to know more about this command. + +**config interface speed (Versions >= 201904)** + +**config interface speed (Versions <= 201811)** + +This command is used to configure the speed for the Physical interface. Use the value 40000 for setting it to 40G and 100000 for 100G. Users need to know the device to configure it properly. + +- Usage: + + *Versions >= 201904* + ``` + config interface speed + ``` + *Versions <= 201811* + ``` + config interface speed + ``` + +- Example (Versions >= 201904): + ``` + admin@sonic:~$ sudo config interface speed Ethernet63 40000 + ``` + +- Example (Versions <= 201811): + ``` + admin@sonic:~$ sudo config interface Ethernet63 speed 40000 + + ``` + +**config interface transceiver lpmode** + +This command is used to enable or disable low-power mode for an SFP transceiver + +- Usage: + + ``` + config interface transceiver lpmode (enable | disable) + ``` + +- Examples: + + ``` + user@sonic~$ sudo config interface transceiver lpmode Ethernet0 enable + Enabling low-power mode for port Ethernet0... OK + + user@sonic~$ sudo config interface transceiver lpmode Ethernet0 disable + Disabling low-power mode for port Ethernet0... OK + ``` + +**config interface transceiver reset** + +This command is used to reset an SFP transceiver + +- Usage: + + ``` + config interface transceiver reset + ``` + +- Examples: + + ``` + user@sonic~$ sudo config interface transceiver reset Ethernet0 + Resetting port Ethernet0... OK + ``` + +**config interface mtu (Versions >= 201904)** + +This command is used to configure the mtu for the Physical interface. Use the value 1500 for setting max transfer unit size to 1500 bytes. + +- Usage: + + *Versions >= 201904* + ``` + config interface mtu + ``` + +- Example (Versions >= 201904): + ``` + admin@sonic:~$ sudo config interface mtu Ethernet64 1500 + ``` + +**config interface tpid (Versions >= 202106)** + +This command is used to configure the TPID for the Physical/PortChannel interface. default is 0x8100. Other allowed values if supported by HW SKU (0x9100, 0x9200, 0x88A8). + +- Usage: + + *Versions >= 202106* + ``` + config interface tpid + ``` + +- Example (Versions >= 202106): + ``` + admin@sonic:~$ sudo config interface tpid Ethernet64 0x9200 + ``` + +**config interface breakout (Versions >= 202006)** + +This command is used to set active breakout mode available for user-specified interface based on the platform-specific port configuration file(i.e. platform.json) +and the current mode set for the interface. + +Based on the platform.json and the current mode set in interface, this command acts on setting breakout mode for the interface. + +Double tab i.e. to see the available breakout option customized for each interface provided by the user. + +- Usage: + ``` + sudo config interface breakout --help + Usage: config interface breakout [OPTIONS] MODE + + Set interface breakout mode + + Options: + -f, --force-remove-dependencies + Clear all depenedecies internally first. + -l, --load-predefined-config load predefied user configuration (alias, + lanes, speed etc) first. + -y, --yes + -v, --verbose Enable verbose output + -?, -h, --help Show this message and exit. + ``` +- Example : + ``` + admin@sonic:~$ sudo config interface breakout Ethernet0 + + 1x100G[40G] 2x50G 4x25G[10G] + ``` + + This command also provides "--force-remove-dependencies/-f" option to CLI, which will automatically determine and remove the configuration dependencies using Yang models. + + ``` + admin@sonic:~$ sudo config interface breakout Ethernet0 4x25G[10G] -f -l -v -y + ``` + +For details please refer [DPB HLD DOC](https://github.com/Azure/SONiC/blob/master/doc/dynamic-port-breakout/sonic-dynamic-port-breakout-HLD.md#cli-design) to know more about this command. + +Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces) + +**config interface autoneg (Versions >= 202106)** + +This command is used to set port auto negotiation mode. + +- Usage: + ``` + sudo config interface autoneg --help + Usage: config interface autoneg [OPTIONS] + + Set interface auto negotiation mode + + Options: + -v, --verbose Enable verbose output + -h, -?, --help Show this message and exit. + ``` + +- Example: + ``` + admin@sonic:~$ sudo config interface autoneg Ethernet0 enabled + + admin@sonic:~$ sudo config interface autoneg Ethernet0 disabled + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces) + +**config interface advertised-speeds (Versions >= 202106)** + +This command is used to set port advertised speed. + +- Usage: + ``` + sudo config interface advertised-speeds --help + Usage: config interface advertised-speeds [OPTIONS] + + Set interface advertised speeds + + Options: + -v, --verbose Enable verbose output + -h, -?, --help Show this message and exit. + ``` + +- Example: + ``` + admin@sonic:~$ sudo config interface advertised-speeds Ethernet0 all + + admin@sonic:~$ sudo config interface advertised-speeds Ethernet0 50000,100000 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces) + +**config interface advertised-types (Versions >= 202106)** + +This command is used to set port advertised interface types. + +- Usage: + ``` + sudo config interface advertised-types --help + Usage: config interface advertised-types [OPTIONS] + + Set interface advertised types + + Options: + -v, --verbose Enable verbose output + -h, -?, --help Show this message and exit. + ``` + +- Example: + ``` + admin@sonic:~$ sudo config interface advertised-types Ethernet0 all + + admin@sonic:~$ sudo config interface advertised-types Ethernet0 CR,CR4 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces) + +**config interface type (Versions >= 202106)** + +This command is used to set port interface type. + +- Usage: + ``` + sudo config interface type --help + Usage: config interface type [OPTIONS] + + Set interface type + + Options: + -v, --verbose Enable verbose output + -h, -?, --help Show this message and exit. + ``` + +- Example: + ``` + admin@sonic:~$ sudo config interface type Ethernet0 CR4 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces) + +**config interface cable_length (Versions >= 202006)** + +This command is used to configure the length of the cable connected to a port. The cable_length is in unit of meters and must be suffixed with "m". + +For details please refer [dynamic buffer management](#dynamic-buffer-management) + +Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces) + +**config interface lossless_pg (Versions >= 202006)** + +This command is used to configure the priority groups on which lossless traffic runs. + +For details please refer [dynamic buffer management](#dynamic-buffer-management) + +Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces) + +**config interface headroom_override (Versions >= 202006)** + +This command is used to configure a static buffer profile on a port's lossless priorities. There shouldn't be any `lossless_pg` configured on the port when configuring `headroom_override`. The port's headroom won't be updated after `headroom_override` has been configured on the port. + +For details please refer [dynamic buffer management](#dynamic-buffer-management) + +Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces) + +**config interface mpls add (Versions >= 202106)** + +This command is used for adding MPLS operation on the interface. +MPLS operation for either physical, portchannel, or VLAN interface can be configured using this command. + + +- Usage: + ``` + sudo config interface mpls add --help + Usage: config interface mpls add [OPTIONS] + + Add MPLS operation on the interface + + Options: + -?, -h, --help Show this message and exit. + ``` + +- Example: + ``` + admin@sonic:~$ sudo config interface mpls add Ethernet4 + ``` + +**config interface mpls remove (Versions >= 202106)** + +This command is used for removing MPLS operation on the interface. +MPLS operation for either physical, portchannel, or VLAN interface can be configured using this command. + +- Usage: + ``` + sudo config interface mpls remove --help + Usage: config interface mpls remove [OPTIONS] + + Remove MPLS operation from the interface + + Options: + -?, -h, --help Show this message and exit. + ``` + +- Example: + ``` + admin@sonic:~$ sudo config interface mpls remove Ethernet4 + ``` + +**config interface ip loopback-action (Versions >= 202205)** + +This command is used for setting the action being taken on packets that ingress and get routed on the same IP interface. +Loopback action can be set on IP interface from type physical, portchannel, VLAN interface and VLAN subinterface. +Loopback action can be drop or forward. + +- Usage: + ``` + config interface ip loopback-action --help + Usage: config interface ip loopback-action [OPTIONS] + + Set IP interface loopback action + + Options: + -?, -h, --help Show this message and exit. + ``` + +- Example: + ``` + admin@sonic:~$ config interface ip loopback-action Ethernet0 drop + admin@sonic:~$ config interface ip loopback-action Ethernet0 forward + + ``` +Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces) + +## Interface Naming Mode + +### Interface naming mode show commands +This command displays the current interface naming mode. Interface naming mode originally set to 'default'. Interfaces are referenced by default SONiC interface names. +Users can change the naming_mode using "config interface_naming_mode" command. + +**show interfaces naming_mode** + +This command displays the current interface naming mode + +- Usage: + ``` + show interfaces naming_mode + ``` + +- Examples: + ``` + admin@sonic:~$ show interfaces naming_mode + default + ``` + + - "default" naming mode will display all SONiC interface names in 'show' commands and accept SONiC interface names as parameters in 'config commands + + ``` + admin@sonic:~$ show interfaces naming_mode + alias + ``` + + - "alias" naming mode will display all hardware vendor interface aliases in 'show' commands and accept hardware vendor interface aliases as parameters in 'config commands + + +### Interface naming mode config commands + +**config interface_naming_ mode** + +This command is used to change the interface naming mode. +Users can select between default mode (SONiC interface names) or alias mode (Hardware vendor names). +The user must log out and log back in for changes to take effect. Note that the newly-applied interface mode will affect all interface-related show/config commands. + + +*NOTE: Some platforms do not support alias mapping. In such cases, this command is not applicable. Such platforms always use the same SONiC interface names.* + +- Usage: + ``` + config interface_naming_mode (default | alias) + ``` + + - Interface naming mode is originally set to 'default'. Interfaces are referenced by default SONiC interface names: + +- Example: + ``` + admin@sonic:~$ show interfaces naming_mode + default + + admin@sonic:~$ show interface status Ethernet0 + Interface Lanes Speed MTU Alias Oper Admin + ----------- -------- ------- ----- -------------- ------ ------- + Ethernet0 101,102 40G 9100 fortyGigE1/1/1 up up + + admin@sonic:~$ sudo config interface_naming_mode alias + Please logout and log back in for changes take effect. + ``` + + - After user logs out and logs back in again, interfaces will then referenced by hardware vendor aliases: + + ``` + admin@sonic:~$ show interfaces naming_mode + alias + + admin@sonic:~$ sudo config interface fortyGigE1/1/1 shutdown + admin@sonic:~$ show interface status fortyGigE1/1/1 + Interface Lanes Speed MTU Alias Oper Admin + ----------- -------- ------- ----- -------------- ------ ------- + Ethernet0 101,102 40G 9100 fortyGigE1/1/1 down down + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#interface-naming-mode) + +## Interface Vrf binding + +### Interface vrf bind & unbind config commands + +**config interface vrf bind** + +This command is used to bind a interface to a vrf. +By default, all L3 interfaces will be in default vrf. Above vrf bind command will let users bind interface to a vrf. + +- Usage: + ``` + config interface vrf bind + ``` + +**config interface vrf unbind** + +This command is used to ubind a interface from a vrf. +This will move the interface to default vrf. + +- Usage: + ``` + config interface vrf unbind + ``` + + ### Interface vrf binding show commands + + To display interface vrf binding information, user can use show vrf command. Please refer sub-section [Vrf-show-command](#vrf-show-commands). + +Go Back To [Beginning of the document](#) or [Beginning of this section](#interface-vrf-binding) + +## IP / IPv6 + +### IP show commands + +This sub-section explains the various IP protocol specific show commands that are used to display the following. +1) routes +2) bgp details - Explained in the [bgp section](#show-bgp) +3) IP interfaces +4) prefix-list +5) protocol + +#### show ip route + +This command displays either all the route entries from the routing table or a specific route. + +- Usage: + ``` + show ip route [] [] + ``` + +- Example: + ``` + admin@sonic:~$ show ip route + Codes: K - kernel route, C - connected, S - static, R - RIP, + O - OSPF, I - IS-IS, B - BGP, P - PIM, A - Babel, + > - selected route, * - FIB route + S>* 0.0.0.0/0 [200/0] via 10.11.162.254, eth0 + C>* 1.1.0.0/16 is directly connected, Vlan100 + C>* 10.1.1.0/31 is directly connected, Ethernet112 + C>* 10.1.1.2/31 is directly connected, Ethernet116 + C>* 10.11.162.0/24 is directly connected, eth0 + C>* 127.0.0.0/8 is directly connected, lo + C>* 240.127.1.0/24 is directly connected, docker0 + ``` + + - Optionally, you can specify an IP address in order to display only routes to that particular IP address + +- Example: + ``` + admin@sonic:~$ show ip route 10.1.1.0 + Routing entry for 10.1.1.0/31 + Known via "connected", distance 0, metric 0, best + * directly connected, Ethernet112 + ``` + + - Vrf-name can also be specified to get IPv4 routes programmed in the vrf. + + - Example: + ``` + admin@sonic:~$ show ip route vrf Vrf-red + Codes: K - kernel route, C - connected, S - static, R - RIP, + O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, + T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, + F - PBR, f - OpenFabric, + > - selected route, * - FIB route + VRF Vrf-red: + C>* 11.1.1.1/32 is directly connected, Loopback11, 21:50:47 + C>* 100.1.1.0/24 is directly connected, Vlan100, 03w1d06h + + admin@sonic:~$ show ip route vrf Vrf-red 11.1.1.1/32 + Routing entry for 11.1.1.1/32 + Known via "connected", distance 0, metric 0, vrf Vrf-red, best + Last update 21:57:53 ago + * directly connected, Loopback11 + ``` + +#### show ip interfaces + +This command displays the details about all the Layer3 IP interfaces in the device for which IP address has been assigned. +The type of interfaces include the following. +1) Front panel physical ports. +2) PortChannel. +3) VLAN interface. +4) Loopback interfaces +5) docker interface and +6) management interface + +- Usage: + ``` + show ip interfaces + ``` + +- Example: + ``` + admin@sonic:~$ show ip interfaces + Interface Master IPv4 address/mask Admin/Oper BGP Neighbor Neighbor IP Flags + ------------- ------------ ------------------ -------------- ------------- ------------- ------- + Loopback0 1.0.0.1/32 up/up N/A N/A + Loopback11 Vrf-red 11.1.1.1/32 up/up N/A N/A + Loopback100 Vrf-blue 100.0.0.1/32 up/up N/A N/A + PortChannel01 10.0.0.56/31 up/down DEVICE1 10.0.0.57 + PortChannel02 10.0.0.58/31 up/down DEVICE2 10.0.0.59 + PortChannel03 10.0.0.60/31 up/down DEVICE3 10.0.0.61 + PortChannel04 10.0.0.62/31 up/down DEVICE4 10.0.0.63 + Vlan100 Vrf-red 1001.1.1/24 up/up N/A N/A + Vlan1000 192.168.0.1/27 up/up N/A N/A + docker0 240.127.1.1/24 up/down N/A N/A + eth0 10.3.147.252/23 up/up N/A N/A + lo 127.0.0.1/8 up/up N/A N/A + ``` + +#### show ip protocol + +This command displays the route-map that is configured for the routing protocol. +Refer the routing stack [Quagga Command Reference](https://www.quagga.net/docs/quagga.pdf) or [FRR Command Reference](https://buildmedia.readthedocs.org/media/pdf/frrouting/latest/frrouting.pdf) to know more about this command. + +- Usage: + ``` + show ip protocol + ``` + +- Example: + ``` + admin@sonic:~$ show ip protocol + Protocol : route-map + ------------------------ + system : none + kernel : none + connected : none + static : none + rip : none + ripng : none + ospf : none + ospf6 : none + isis : none + bgp : RM_SET_SRC + pim : none + hsls : none + olsr : none + babel : none + any : none + ``` + +### IPv6 show commands + +This sub-section explains the various IPv6 protocol specific show commands that are used to display the following. +1) routes +2) IPv6 bgp details - Explained in the [bgp section](#show-bgp) +3) IP interfaces +4) protocol + +**show ipv6 route** + +This command displays either all the IPv6 route entries from the routing table or a specific IPv6 route. + +- Usage: + ``` + show ipv6 route [] [] + ``` + +- Example: + ``` + admin@sonic:~$ show ipv6 route + Codes: K - kernel route, C - connected, S - static, R - RIPng, + O - OSPFv6, I - IS-IS, B - BGP, A - Babel, + > - selected route, * - FIB route + + C>* ::1/128 is directly connected, lo + C>* 2018:2001::/126 is directly connected, Ethernet112 + C>* 2018:2002::/126 is directly connected, Ethernet116 + C>* fc00:1::32/128 is directly connected, lo + C>* fc00:1::102/128 is directly connected, lo + C>* fc00:2::102/128 is directly connected, eth0 + C * fe80::/64 is directly connected, Vlan100 + C * fe80::/64 is directly connected, Ethernet112 + C * fe80::/64 is directly connected, Ethernet116 + C * fe80::/64 is directly connected, Bridge + C * fe80::/64 is directly connected, PortChannel0011 + C>* fe80::/64 is directly connected, eth0 + ``` + - Optionally, you can specify an IPv6 address in order to display only routes to that particular IPv6 address + + +- Example: + ``` + admin@sonic:~$ show ipv6 route fc00:1::32 + Routing entry for fc00:1::32/128 + Known via "connected", distance 0, metric 0, best + * directly connected, lo + ``` + + Vrf-name can also be specified to get IPv6 routes programmed in the vrf. + + - Example: + ``` + admin@sonic:~$ show ipv6 route vrf Vrf-red + Codes: K - kernel route, C - connected, S - static, R - RIP, + O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, + T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, + F - PBR, f - OpenFabric, + > - selected route, * - FIB route + VRF Vrf-red: + C>* 1100::1/128 is directly connected, Loopback11, 21:50:47 + C>* 100::/112 is directly connected, Vlan100, 03w1d06h + C>* fe80::/64 is directly connected, Loopback11, 21:50:47 + C>* fe80::/64 is directly connected, Vlan100, 03w1d06h + + admin@sonic:~$ show ipv6 route vrf Vrf-red 1100::1/128 + Routing entry for 1100::1/128 + Known via "connected", distance 0, metric 0, vrf Vrf-red, best + Last update 21:57:53 ago + * directly connected, Loopback11 + ``` + +**show ipv6 interfaces** + +This command displays the details about all the Layer3 IPv6 interfaces in the device for which IPv6 address has been assigned. +The type of interfaces include the following. +1) Front panel physical ports. +2) PortChannel. +3) VLAN interface. +4) Loopback interfaces +5) management interface + +- Usage: + ``` + show ipv6 interfaces + ``` + +- Example: + ``` + admin@sonic:~$ show ipv6 interfaces + Interface Master IPv6 address/mask Admin/Oper BGP Neighbor Neighbor IP + ----------- -------- ---------------------------------------- ------------ -------------- ------------- + Bridge fe80::7c45:1dff:fe08:cdd%Bridge/64 up/up N/A N/A + Loopback11 Vrf-red 1100::1/128 up/up + PortChannel01 fc00::71/126 up/down DEVICE1 fc00::72 + PortChannel02 fc00::75/126 up/down DEVICE2 fc00::76 + PortChannel03 fc00::79/126 up/down DEVICE3 fc00::7a + PortChannel04 fc00::7d/126 up/down DEVICE4 fc00::7e + Vlan100 Vrf-red 100::1/112 up/up N/A N/A + fe80::eef4:bbff:fefe:880a%Vlan100/64 + eth0 fe80::eef4:bbff:fefe:880a%eth0/64 up/up N/A N/A + lo fc00:1::32/128 up/up N/A N/A + ``` + +**show ipv6 protocol** + +This command displays the route-map that is configured for the IPv6 routing protocol. +Refer the routing stack [Quagga Command Reference](https://www.quagga.net/docs/quagga.pdf) or [FRR Command Reference](https://buildmedia.readthedocs.org/media/pdf/frrouting/latest/frrouting.pdf) to know more about this command. + + +- Usage: + ``` + show ipv6 protocol + ``` + +- Example: + ``` + admin@sonic:~$ show ipv6 protocol + Protocol : route-map + ------------------------ + system : none + kernel : none + connected : none + static : none + rip : none + ripng : none + ospf : none + ospf6 : none + isis : none + bgp : RM_SET_SRC6 + pim : none + hsls : none + olsr : none + babel : none + any : none + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#ip--ipv6) + +## IPv6 Link Local + +### IPv6 Link Local config commands + +This section explains all the commands that are supported in SONiC to configure IPv6 Link-local. + +**config interface ipv6 enable use-link-local-only ** + +This command enables user to enable an interface to forward L3 traffic with out configuring an address. This command creates the routing interface based on the auto generated IPv6 link-local address. This command can be used even if an address is configured on the interface. + +- Usage: + ``` + config interface ipv6 enable use-link-local-only + ``` + +- Example: + ``` + admin@sonic:~$ sudo config interface ipv6 enable use-link-local-only Vlan206 + admin@sonic:~$ sudo config interface ipv6 enable use-link-local-only PortChannel007 + admin@sonic:~$ sudo config interface ipv6 enable use-link-local-only Ethernet52 + ``` + +**config interface ipv6 disable use-link-local-only ** + +This command enables user to disable use-link-local-only configuration on an interface. + +- Usage: + ``` + config interface ipv6 disable use-link-local-only + ``` + +- Example: + ``` + admin@sonic:~$ sudo config interface ipv6 disable use-link-local-only Vlan206 + admin@sonic:~$ sudo config interface ipv6 disable use-link-local-only PortChannel007 + admin@sonic:~$ sudo config interface ipv6 disable use-link-local-only Ethernet52 + ``` + +**config ipv6 enable link-local** + +This command enables user to enable use-link-local-only command on all the interfaces globally. + +- Usage: + ``` + sudo config ipv6 enable link-local + ``` + +- Example: + ``` + admin@sonic:~$ sudo config ipv6 enable link-local + ``` + +**config ipv6 disable link-local** + +This command enables user to disable use-link-local-only command on all the interfaces globally. + +- Usage: + ``` + sudo config ipv6 disable link-local + ``` + +- Example: + ``` + admin@sonic:~$ sudo config ipv6 disable link-local + ``` + +### IPv6 Link Local show commands + +**show ipv6 link-local-mode** + +This command displays the link local mode of all the interfaces. + +- Usage: + ``` + show ipv6 link-local-mode + ``` + +- Example: + ``` + root@sonic:/home/admin# show ipv6 link-local-mode + +------------------+----------+ + | Interface Name | Mode | + +==================+==========+ + | Ethernet16 | Disabled | + +------------------+----------+ + | Ethernet18 | Enabled | + +------------------+----------+ + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#ipv6-link-local) + +## Kubernetes + +### Kubernetes show commands + +**show kubernetes server config** + +This command displays the kubernetes server configuration, if any, else would report as not configured. + +- Usage: + ``` + show kubernetes server config + ``` + +- Example: + ``` + admin@sonic:~$ show kubernetes server config + ip port insecure disable + ----------- ------ ---------- --------- + 10.3.157.24 6443 True False + ``` + +**show kubernetes server status** + +This command displays the kubernetes server status. + +- Usage: + ``` + show kubernetes server status + ``` + +- Example: + ``` + admin@sonic:~$ show kubernetes server status + ip port connected update-time + ----------- ------ ----------- ------------------- + 10.3.157.24 6443 true 2020-11-15 18:25:05 + ``` +Go Back To [Beginning of the document](#) or [Beginning of this section](#Kubernetes) + +## Linux Kernel Dump + +This section demonstrates the show commands and configuration commands of Linux kernel dump mechanism in SONiC. + +### Linux Kernel Dump show commands + +**show kdump config** + +This command shows the configuration of Linux kernel dump. + +- Usage: + ``` + show kdump config + ``` + +- Example: + ``` + admin@sonic:$ show kdump config + Kdump administrative mode: Disabled + Kdump operational mode: Unready + Kdump memory researvation: 0M-2G:256M,2G-4G:320M,4G-8G:384M,8G-:448M + Maximum number of Kdump files: 3 + ``` + +**show kdump files** + +This command shows the Linux kernel core dump files and dmesg files which are +generated by kernel dump tool. + +- Usage: + ``` + show kdump files + ``` + +- Example: + ``` + admin@sonic:~$ show kdump files + Kernel core dump files Kernel dmesg files + ------------------------------------------ ------------------------------------------ + /var/crash/202106242344/kdump.202106242344 /var/crash/202106242344/dmesg.202106242344 + /var/crash/202106242337/kdump.202106242337 /var/crash/202106242337/dmesg.202106242337 + ``` + +**show kdump logging ** + +By default, this command will show the last 10 lines of latest dmesg file. +This command can also accept a specific file name and number of lines as arguments. + +- Usage: + ``` + show kdump logging + ``` + +- Example: + ``` + admin@sonic:~$ show kdump logging + [ 157.642053] RSP: 002b:00007fff1beee708 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 + [ 157.732635] RAX: ffffffffffffffda RBX: 0000000000000002 RCX: 00007fc3887d4504 + [ 157.818015] RDX: 0000000000000002 RSI: 000055d388eceb40 RDI: 0000000000000001 + [ 157.903401] RBP: 000055d388eceb40 R08: 000000000000000a R09: 00007fc3888255f0 + [ 157.988784] R10: 000000000000000a R11: 0000000000000246 R12: 00007fc3888a6760 + [ 158.074166] R13: 0000000000000002 R14: 00007fc3888a1760 R15: 0000000000000002 + [ 158.159553] Modules linked in: nft_chain_route_ipv6(E) nft_chain_route_ipv4(E) xt_TCPMSS(E) dummy(E) team_mode_loadbalance(E) team(E) sx_bfd(OE) sx_netdev(OE) psample(E) sx_core(OE) 8021q(E) garp(E) mrp(E) mst_pciconf(OE) mst_pci(OE) xt_hl(E) xt_tcpudp(E) ip6_tables(E) nft_compat(E) nft_chain_nat_ipv4(E) nf_nat_ipv4(E) nft_counter(E) xt_conntrack(E) nf_nat(E) jc42(E) nf_conntrack_netlink(E) nf_conntrack(E) nf_defrag_ipv6(E) nf_defrag_ipv4(E) libcrc32c(E) xfrm_user(E) xfrm_algo(E) mlxsw_minimal(E) mlxsw_i2c(E) i2c_mux_reg(E) i2c_mux(E) i2c_mlxcpld(E) leds_mlxreg(E) mlxreg_io(E) mlxreg_hotplug(E) mei_wdt(E) evdev(E) intel_rapl(E) x86_pkg_temp_thermal(E) intel_powerclamp(E) kvm_intel(E) mlx_platform(E) kvm(E) irqbypass(E) crct10dif_pclmul(E) crc32_pclmul(E) ghash_clmulni_intel(E) intel_cstate(E) intel_uncore(E) + [ 159.016731] intel_rapl_perf(E) pcspkr(E) sg(E) iTCO_wdt(E) iTCO_vendor_support(E) mei_me(E) mei(E) bonding(E) pcc_cpufreq(E) video(E) button(E) ebt_vlan(E) ebtable_broute(E) bridge(E) stp(E) llc(E) ebtable_nat(E) ebtable_filter(E) ebtables(E) nf_tables(E) nfnetlink(E) xdpe12284(E) at24(E) ledtrig_timer(E) tmp102(E) lm75(E) drm(E) coretemp(E) max1363(E) industrialio_triggered_buffer(E) kfifo_buf(E) industrialio(E) tps53679(E) fuse(E) pmbus(E) pmbus_core(E) i2c_dev(E) configfs(E) ip_tables(E) x_tables(E) autofs4(E) loop(E) ext4(E) crc16(E) mbcache(E) jbd2(E) crc32c_generic(E) fscrypto(E) ecb(E) crypto_simd(E) cryptd(E) glue_helper(E) aes_x86_64(E) nvme(E) nvme_core(E) nls_utf8(E) nls_cp437(E) nls_ascii(E) vfat(E) fat(E) overlay(E) squashfs(E) zstd_decompress(E) xxhash(E) sd_mod(E) gpio_ich(E) ahci(E) + [ 159.864532] libahci(E) mlxsw_core(E) devlink(E) ehci_pci(E) ehci_hcd(E) crc32c_intel(E) libata(E) i2c_i801(E) scsi_mod(E) usbcore(E) usb_common(E) lpc_ich(E) mfd_core(E) e1000e(E) fan(E) thermal(E) + [ 160.075846] CR2: 0000000000000000 + ``` +You can specify a file name in order to show its +last 10 lines. + +- Example: + ``` + admin@sonic:~$ show kdump logging dmesg.202106242337 + [ 654.120195] RSP: 002b:00007ffe697690f8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 + [ 654.210778] RAX: ffffffffffffffda RBX: 0000000000000002 RCX: 00007fcfca27b504 + [ 654.296157] RDX: 0000000000000002 RSI: 000055a6e4d1b3f0 RDI: 0000000000000001 + [ 654.381543] RBP: 000055a6e4d1b3f0 R08: 000000000000000a R09: 00007fcfca2cc5f0 + [ 654.466925] R10: 000000000000000a R11: 0000000000000246 R12: 00007fcfca34d760 + [ 654.552310] R13: 0000000000000002 R14: 00007fcfca348760 R15: 0000000000000002 + [ 654.637694] Modules linked in: binfmt_misc(E) nft_chain_route_ipv6(E) nft_chain_route_ipv4(E) xt_TCPMSS(E) dummy(E) team_mode_loadbalance(E) team(E) sx_bfd(OE) sx_netdev(OE) psample(E) sx_core(OE) 8021q(E) garp(E) mrp(E) mst_pciconf(OE) mst_pci(OE) xt_hl(E) xt_tcpudp(E) ip6_tables(E) nft_chain_nat_ipv4(E) nf_nat_ipv4(E) nft_compat(E) nft_counter(E) xt_conntrack(E) nf_nat(E) jc42(E) nf_conntrack_netlink(E) nf_conntrack(E) nf_defrag_ipv6(E) nf_defrag_ipv4(E) libcrc32c(E) xfrm_user(E) xfrm_algo(E) mlxsw_minimal(E) mlxsw_i2c(E) i2c_mux_reg(E) i2c_mux(E) mlxreg_hotplug(E) mlxreg_io(E) i2c_mlxcpld(E) leds_mlxreg(E) mei_wdt(E) evdev(E) intel_rapl(E) x86_pkg_temp_thermal(E) intel_powerclamp(E) kvm_intel(E) kvm(E) mlx_platform(E) irqbypass(E) crct10dif_pclmul(E) crc32_pclmul(E) ghash_clmulni_intel(E) intel_cstate(E) + [ 655.493833] intel_uncore(E) intel_rapl_perf(E) pcspkr(E) sg(E) iTCO_wdt(E) iTCO_vendor_support(E) mei_me(E) mei(E) bonding(E) video(E) button(E) pcc_cpufreq(E) ebt_vlan(E) ebtable_broute(E) bridge(E) stp(E) llc(E) ebtable_nat(E) ebtable_filter(E) ebtables(E) nf_tables(E) nfnetlink(E) xdpe12284(E) at24(E) ledtrig_timer(E) tmp102(E) drm(E) lm75(E) coretemp(E) max1363(E) industrialio_triggered_buffer(E) kfifo_buf(E) industrialio(E) fuse(E) tps53679(E) pmbus(E) pmbus_core(E) i2c_dev(E) configfs(E) ip_tables(E) x_tables(E) autofs4(E) loop(E) ext4(E) crc16(E) mbcache(E) jbd2(E) crc32c_generic(E) fscrypto(E) ecb(E) crypto_simd(E) cryptd(E) glue_helper(E) aes_x86_64(E) nvme(E) nvme_core(E) nls_utf8(E) nls_cp437(E) nls_ascii(E) vfat(E) fat(E) overlay(E) squashfs(E) zstd_decompress(E) xxhash(E) sd_mod(E) + [ 656.337476] gpio_ich(E) ahci(E) mlxsw_core(E) libahci(E) devlink(E) crc32c_intel(E) libata(E) i2c_i801(E) scsi_mod(E) lpc_ich(E) mfd_core(E) ehci_pci(E) ehci_hcd(E) usbcore(E) e1000e(E) usb_common(E) fan(E) thermal(E) + [ 656.569590] CR2: 0000000000000000 + ``` +You can also specify a file name and number of lines in order to show the +last number of lines. + +- Example: + ``` + admin@sonic:~$ show kdump logging dmesg.202106242337 -l 20 + [ 653.525427] __handle_sysrq.cold.9+0x45/0xf2 + [ 653.576487] write_sysrq_trigger+0x2b/0x30 + [ 653.625472] proc_reg_write+0x39/0x60 + [ 653.669252] vfs_write+0xa5/0x1a0 + [ 653.708881] ksys_write+0x57/0xd0 + [ 653.748501] do_syscall_64+0x53/0x110 + [ 653.792287] entry_SYSCALL_64_after_hwframe+0x44/0xa9 + [ 653.852707] RIP: 0033:0x7fcfca27b504 + [ 653.895452] Code: 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b3 0f 1f 80 00 00 00 00 48 8d 05 f9 61 0d 00 8b 00 85 c0 75 13 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 54 c3 0f 1f 00 41 54 49 89 d4 55 48 89 f5 53 + [ 654.120195] RSP: 002b:00007ffe697690f8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 + [ 654.210778] RAX: ffffffffffffffda RBX: 0000000000000002 RCX: 00007fcfca27b504 + [ 654.296157] RDX: 0000000000000002 RSI: 000055a6e4d1b3f0 RDI: 0000000000000001 + [ 654.381543] RBP: 000055a6e4d1b3f0 R08: 000000000000000a R09: 00007fcfca2cc5f0 + [ 654.466925] R10: 000000000000000a R11: 0000000000000246 R12: 00007fcfca34d760 + [ 654.552310] R13: 0000000000000002 R14: 00007fcfca348760 R15: 0000000000000002 + [ 654.637694] Modules linked in: binfmt_misc(E) nft_chain_route_ipv6(E) nft_chain_route_ipv4(E) xt_TCPMSS(E) dummy(E) team_mode_loadbalance(E) team(E) sx_bfd(OE) sx_netdev(OE) psample(E) sx_core(OE) 8021q(E) garp(E) mrp(E) mst_pciconf(OE) mst_pci(OE) xt_hl(E) xt_tcpudp(E) ip6_tables(E) nft_chain_nat_ipv4(E) nf_nat_ipv4(E) nft_compat(E) nft_counter(E) xt_conntrack(E) nf_nat(E) jc42(E) nf_conntrack_netlink(E) nf_conntrack(E) nf_defrag_ipv6(E) nf_defrag_ipv4(E) libcrc32c(E) xfrm_user(E) xfrm_algo(E) mlxsw_minimal(E) mlxsw_i2c(E) i2c_mux_reg(E) i2c_mux(E) mlxreg_hotplug(E) mlxreg_io(E) i2c_mlxcpld(E) leds_mlxreg(E) mei_wdt(E) evdev(E) intel_rapl(E) x86_pkg_temp_thermal(E) intel_powerclamp(E) kvm_intel(E) kvm(E) mlx_platform(E) irqbypass(E) crct10dif_pclmul(E) crc32_pclmul(E) ghash_clmulni_intel(E) intel_cstate(E) + [ 655.493833] intel_uncore(E) intel_rapl_perf(E) pcspkr(E) sg(E) iTCO_wdt(E) iTCO_vendor_support(E) mei_me(E) mei(E) bonding(E) video(E) button(E) pcc_cpufreq(E) ebt_vlan(E) ebtable_broute(E) bridge(E) stp(E) llc(E) ebtable_nat(E) ebtable_filter(E) ebtables(E) nf_tables(E) nfnetlink(E) xdpe12284(E) at24(E) ledtrig_timer(E) tmp102(E) drm(E) lm75(E) coretemp(E) max1363(E) industrialio_triggered_buffer(E) kfifo_buf(E) industrialio(E) fuse(E) tps53679(E) pmbus(E) pmbus_core(E) i2c_dev(E) configfs(E) ip_tables(E) x_tables(E) autofs4(E) loop(E) ext4(E) crc16(E) mbcache(E) jbd2(E) crc32c_generic(E) fscrypto(E) ecb(E) crypto_simd(E) cryptd(E) glue_helper(E) aes_x86_64(E) nvme(E) nvme_core(E) nls_utf8(E) nls_cp437(E) nls_ascii(E) vfat(E) fat(E) overlay(E) squashfs(E) zstd_decompress(E) xxhash(E) sd_mod(E) + [ 656.337476] gpio_ich(E) ahci(E) mlxsw_core(E) libahci(E) devlink(E) crc32c_intel(E) libata(E) i2c_i801(E) scsi_mod(E) lpc_ich(E) mfd_core(E) ehci_pci(E) ehci_hcd(E) usbcore(E) e1000e(E) usb_common(E) fan(E) thermal(E) + [ 656.569590] CR2: 0000000000000000 + ``` +Go Back To [Beginning of the document](#) or [Beginning of this section](#kdump) + +## LLDP + +### LLDP show commands + +**show lldp table** + +This command displays the brief summary of all LLDP neighbors. + +- Usage: + ``` + show lldp table + ``` + +- Example: + ``` + admin@sonic:~$ show lldp table + Capability codes: (R) Router, (B) Bridge, (O) Other + LocalPort RemoteDevice RemotePortID Capability RemotePortDescr + ----------- ----------------- ------------------- ------------ -------------------- + Ethernet112 T1-1 hundredGigE1/2 BR T0-2:hundredGigE1/29 + Ethernet116 T1-2 hundredGigE1/2 BR T0-2:hundredGigE1/30 + eth0 swtor-b2lab2-1610 GigabitEthernet 0/2 OBR + -------------------------------------------------- + Total entries displayed: 3 + ``` + +**show lldp neighbors** + +This command displays more details about all LLDP neighbors or only the neighbors connected to a specific interface. + +- Usage: + ``` + show lldp neighbors + ``` + +- Example1: To display all neighbors in all interfaces + ``` + admin@sonic:~$ show lldp neighbors + ------------------------------------------------------------------------------- + LLDP neighbors: + ------------------------------------------------------------------------------- + Interface: eth0, via: LLDP, RID: 1, Time: 0 day, 12:21:21 + Chassis: + ChassisID: mac 00:01:e8:81:e3:45 + SysName: swtor-b2lab2-1610 + SysDescr: Dell Force10 Networks Real Time Operating System Software. Dell Force10 Operating System Version: 1.0. Dell Force10 Application Software Version: 8.3.3.10d. Copyright (c) 1999-2012 by Dell Inc. All Rights Reserved.Build Time: Tue Sep 22 11:21:54 PDT 2015 + TTL: 20 + Capability: Repeater, on + Capability: Bridge, on + Capability: Router, on + Port: + PortID: ifname GigabitEthernet 0/2 + VLAN: 162, pvid: yes + ------------------------------------------------------------------------------- + Interface: Ethernet116, via: LLDP, RID: 3, Time: 0 day, 12:20:49 + Chassis: + ChassisID: mac 4c:76:25:e7:f0:c0 + SysName: T1-2 + SysDescr: Debian GNU/Linux 8 (jessie) Linux 4.9.0-8-amd64 #1 SMP Debian 4.9.110-3+deb9u6 (2015-12-19) x86_64 + TTL: 120 + MgmtIP: 10.11.162.40 + Capability: Bridge, on + Capability: Router, on + Capability: Wlan, off + Capability: Station, off + Port: + PortID: local hundredGigE1/2 + PortDescr: T0-2:hundredGigE1/30 + ------------------------------------------------------------------------------- + ``` + +Optionally, you can specify an interface name in order to display only that particular interface + +- Example2: + ``` + admin@sonic:~$ show lldp neighbors Ethernet112 + show lldp neighbors Ethernet112 + ------------------------------------------------------------------------------- + LLDP neighbors: + ------------------------------------------------------------------------------- + Interface: Ethernet112, via: LLDP, RID: 2, Time: 0 day, 19:24:17 + Chassis: + ChassisID: mac 4c:76:25:e5:e6:c0 + SysName: T1-1 + SysDescr: Debian GNU/Linux 8 (jessie) Linux 4.9.0-8-amd64 #1 SMP Debian 4.9.110-3+deb9u6 (2015-12-19) x86_64 + TTL: 120 + MgmtIP: 10.11.162.41 + Capability: Bridge, on + Capability: Router, on + Capability: Wlan, off + Capability: Station, off + Port: + PortID: local hundredGigE1/2 + PortDescr: T0-2:hundredGigE1/29 + ------------------------------------------------------------------------------- + ``` +Go Back To [Beginning of the document](#) or [Beginning of this section](#lldp) + + +## Loading, Reloading And Saving Configuration + +This section explains the commands that are used to load the configuration from either the ConfigDB or from the minigraph. + +### Loading configuration from JSON file + +**config load** + +This command is used to load the configuration from a JSON file like the file which SONiC saves its configuration to, `/etc/sonic/config_db.json` +This command loads the configuration from the input file (if user specifies this optional filename, it will use that input file. Otherwise, it will use the default `/etc/sonic/config_db.json` file as the input file) into CONFIG_DB. +The configuration present in the input file is applied on top of the already running configuration. +This command does not flush the config DB before loading the new configuration (i.e., If the configuration present in the input file is same as the current running configuration, nothing happens) +If the config present in the input file is not present in running configuration, it will be added. +If the config present in the input file differs (when key matches) from that of the running configuration, it will be modified as per the new values for those keys. + +When user specifies the optional argument "-y" or "--yes", this command forces the loading without prompting the user for confirmation. +If the argument is not specified, it prompts the user to confirm whether user really wants to load this configuration file. + +- Usage: + ``` + config load [-y|--yes] [] + ``` + +- Example: + ``` + admin@sonic:~$ sudo config load + Load config from the file /etc/sonic/config_db.json? [y/N]: y + Running command: /usr/local/bin/sonic-cfggen -j /etc/sonic/config_db.json --write-to-db + ``` + +### Loading configuration from minigraph (XML) file + +**config load_minigraph** + +This command is used to load the configuration from /etc/sonic/minigraph.xml. +When users do not want to use configuration from config_db.json, they can copy the minigraph.xml configuration file to the device and load it using this command. +This command restarts various services running in the device and it takes some time to complete the command. + +NOTE: If the user had logged in using SSH, users might get disconnected and some configuration failures might happen which might be hard to recover. Users need to reconnect their SSH sessions after configuring the management IP address. It is recommended to execute this command from console port +NOTE: Management interface IP address and default route (or specific route) may require reconfiguration in case if those parameters are not part of the minigraph.xml. + +When user specifies the optional argument "-y" or "--yes", this command forces the loading without prompting the user for confirmation. +If the argument is not specified, it prompts the user to confirm whether user really wants to load this configuration file. + +When user specifies the optional argument "-n" or "--no-service-restart", this command loads the configuration without restarting dependent services +running on the device. One use case for this option is during boot time when config-setup service loads minigraph configuration and there is no services +running on the device. + +When user specifies the optional argument "-t" or "--traffic-shift-away", this command executes TSA command at the end to ensure the device remains in maintenance after loading minigraph. + +- Usage: + ``` + config load_minigraph [-y|--yes] [-n|--no-service-restart] [-t|--traffic-shift-away] + ``` + +- Example: + ``` + admin@sonic:~$ sudo config load_minigraph + Reload config from minigraph? [y/N]: y + Running command: /usr/local/bin/sonic-cfggen -j /etc/sonic/config_db.json --write-to-db + ``` + +### Reloading Configuration + +**config reload** + +This command is used to clear current configuration and import new configurationn from the input file or from /etc/sonic/config_db.json. +This command shall stop all services before clearing the configuration and it then restarts those services. + +This command restarts various services running in the device and it takes some time to complete the command. +NOTE: If the user had logged in using SSH, users **might get disconnected** depending upon the new management IP address. Users need to reconnect their SSH sessions. +In general, it is recommended to execute this command from console port after disconnecting all SSH sessions to the device. +When users to do “config reload” the newly loaded config may have management IP address, or it may not have management IP address. +If mgmtIP is there in the newly loaded config file, that mgmtIP might be same as previously configured value or it might be different. +This difference in mgmtIP address values results in following possible behaviours. + +Case1: Previously configured mgmtIP is same as newly loaded mgmtIP. The SSH session may not be affected at all, but it’s possible that there will be a brief interruption in the SSH session. But, assuming the client’s timeout value isn’t on the order of a couple of seconds, the session would most likely just resume again as soon as the interface is reconfigured and up with the same IP. +Case2: Previously configured mgmtIP is different from newly loaded mgmtIP. Users will lose their SSH connections. +Case3: Newly loaded config does not have any mgmtIP. Users will lose their SSH connections. + +NOTE: Management interface IP address and default route (or specific route) may require reconfiguration in case if those parameters are not part of the minigraph.xml. + +When user specifies the optional argument "-y" or "--yes", this command forces the loading without prompting the user for confirmation. +If the argument is not specified, it prompts the user to confirm whether user really wants to load this configuration file. + +When user specifies the optional argument "-n" or "--no-service-restart", this command clear and loads the configuration without restarting dependent services +running on the device. One use case for this option is during boot time when config-setup service loads existing old configuration and there is no services +running on the device. + +When user specifies the optional argument "-f" or "--force", this command ignores the system sanity checks. By default a list of sanity checks are performed and if one of the checks fail, the command will not execute. The sanity checks include ensuring the system status is not starting, all the essential services are up and swss is in ready state. + +- Usage: + ``` + config reload [-y|--yes] [-l|--load-sysinfo] [] [-n|--no-service-restart] [-f|--force] + ``` + +- Example: + ``` + admin@sonic:~$ sudo config reload + Clear current config and reload config from the file /etc/sonic/config_db.json? [y/N]: y + Running command: systemctl stop dhcp_relay + Running command: systemctl stop swss + Running command: systemctl stop snmp + Warning: Stopping snmp.service, but it can still be activated by: + snmp.timer + Running command: systemctl stop lldp + Running command: systemctl stop pmon + Running command: systemctl stop bgp + Running command: systemctl stop teamd + Running command: /usr/local/bin/sonic-cfggen -H -k Force10-Z9100-C32 --write-to-db + Running command: /usr/local/bin/sonic-cfggen -j /etc/sonic/config_db.json --write-to-db + Running command: systemctl restart hostname-config + Running command: systemctl restart interfaces-config + Timeout, server 10.11.162.42 not responding. + ``` + When some sanity checks fail below error messages can be seen + ``` + admin@sonic:~$ sudo config reload -y + System is not up. Retry later or use -f to avoid system checks + ``` + ``` + admin@sonic:~$ sudo config reload -y + Relevant services are not up. Retry later or use -f to avoid system checks + ``` + ``` + admin@sonic:~$ sudo config reload -y + SwSS container is not ready. Retry later or use -f to avoid system checks + ``` + + +### Loading Management Configuration + +**config load_mgmt_config** + +This command is used to reconfigure hostname and mgmt interface based on device description file. +This command either uses the optional file specified as arguement or looks for the file "/etc/sonic/device_desc.xml". +If the file does not exist or if the file does not have valid fields for "hostname" and "ManagementAddress" (or "ManagementAddressV6"), it fails. + +When user specifies the optional argument "-y" or "--yes", this command forces the loading without prompting the user for confirmation. +If the argument is not specified, it prompts the user to confirm whether user really wants to load this configuration file. + +- Usage: + ``` + config load_mgmt_config [-y|--yes] [] + ``` + +- Example: + ``` + admin@sonic:~$ sudo config load_mgmt_config + Reload config from minigraph? [y/N]: y + Running command: /usr/local/bin/sonic-cfggen -M /etc/sonic/device_desc.xml --write-to-db + ``` + + +### Saving Configuration to a File for Persistence + +**config save** + +This command is to save the config DB configuration into the user-specified filename or into the default /etc/sonic/config_db.json. This saves the configuration into the disk which is available even after reboots. +Saved file can be transferred to remote machines for debugging. If users wants to load the configuration from this new file at any point of time, they can use "config load" command and provide this newly generated file as input. If users wants this newly generated file to be used during reboot, they need to copy this file to /etc/sonic/config_db.json. + +- Usage: + ``` + config save [-y|--yes] [] + ``` + +- Example (Save configuration to /etc/sonic/config_db.json): + ``` + admin@sonic:~$ sudo config save -y + ``` + +- Example (Save configuration to a specified file): + ``` + admin@sonic:~$ sudo config save -y /etc/sonic/config2.json + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#loading-reloading-and-saving-configuration) + +## Loopback Interfaces + +### Loopback show commands + +Please check [show ip interfaces](#show-ip-interfaces) + +### Loopback config commands + +This sub-section explains how to create and delete loopback interfaces. + +**config interface loopback** + +This command is used to add or delete loopback interfaces. +It is recommended to use loopback names in the format "Loopbackxxx", where "xxx" is number of 1 to 3 digits. Ex: "Loopback11". + +- Usage: + ``` + config loopback (add | del) + ``` + +- Example (Create the loopback with name "Loopback11"): + ``` + admin@sonic:~$ sudo config loopback add Loopback11 + ``` + +# MACsec Commands + +This sub-section explains the list of the configuration options available for MACsec. MACsec feature is as a plugin to SONiC, So please install MACsec package before using MACsec commands. + +## MACsec config command + +- Add MACsec profile +``` +admin@sonic:~$ sudo config macsec profile add --help +Usage: config macsec profile add [OPTIONS] + + Add MACsec profile + +Options: + --priority For Key server election. In 0-255 range with + 0 being the highest priority. [default: + 255] + --cipher_suite The cipher suite for MACsec. [default: GCM- + AES-128] + --primary_cak Primary Connectivity Association Key. + [required] + --primary_ckn Primary CAK Name. [required] + --policy MACsec policy. INTEGRITY_ONLY: All traffic, + except EAPOL, will be converted to MACsec + packets without encryption. SECURITY: All + traffic, except EAPOL, will be encrypted by + SecY. [default: security] + --enable_replay_protect / --disable_replay_protect + Whether enable replay protect. [default: + False] + --replay_window + Replay window size that is the number of + packets that could be out of order. This + field works only if ENABLE_REPLAY_PROTECT is + true. [default: 0] + --send_sci / --no_send_sci Send SCI in SecTAG field of MACsec header. + [default: True] + --rekey_period The period of proactively refresh (Unit + second). [default: 0] + -?, -h, --help Show this message and exit. +``` + +- Delete MACsec profile +``` +admin@sonic:~$ sudo config macsec profile del --help +Usage: config macsec profile del [OPTIONS] + + Delete MACsec profile + +Options: + -?, -h, --help Show this message and exit. +``` + +- Enable MACsec on the port +``` +admin@sonic:~$ sudo config macsec port add --help +Usage: config macsec port add [OPTIONS] + + Add MACsec port + +Options: + -?, -h, --help Show this message and exit. +``` + + +- Disable MACsec on the port +``` +admin@sonic:~$ sudo config macsec port del --help +Usage: config macsec port del [OPTIONS] + + Delete MACsec port + +Options: + -?, -h, --help Show this message and exit. + +``` + + +## MACsec show command + +- Show MACsec + +``` +admin@vlab-02:~$ show macsec --help +Usage: show macsec [OPTIONS] [INTERFACE_NAME] + +Options: + -d, --display [all] Show internal interfaces [default: all] + -n, --namespace [] Namespace name or all + -h, -?, --help Show this message and exit. + +``` + +``` +admin@vlab-02:~$ show macsec +MACsec port(Ethernet0) +--------------------- ----------- +cipher_suite GCM-AES-256 +enable true +enable_encrypt true +enable_protect true +enable_replay_protect false +replay_window 0 +send_sci true +--------------------- ----------- + MACsec Egress SC (5254008f4f1c0001) + ----------- - + encoding_an 2 + ----------- - + MACsec Egress SA (1) + ------------------------------------- ---------------------------------------------------------------- + auth_key 849B69D363E2B0AA154BEBBD7C1D9487 + next_pn 1 + sak AE8C9BB36EA44B60375E84BC8E778596289E79240FDFA6D7BA33D3518E705A5E + salt 000000000000000000000000 + ssci 0 + SAI_MACSEC_SA_ATTR_CURRENT_XPN 179 + SAI_MACSEC_SA_STAT_OCTETS_ENCRYPTED 0 + SAI_MACSEC_SA_STAT_OCTETS_PROTECTED 0 + SAI_MACSEC_SA_STAT_OUT_PKTS_ENCRYPTED 0 + SAI_MACSEC_SA_STAT_OUT_PKTS_PROTECTED 0 + ------------------------------------- ---------------------------------------------------------------- + MACsec Egress SA (2) + ------------------------------------- ---------------------------------------------------------------- + auth_key 5A8B8912139551D3678B43DD0F10FFA5 + next_pn 1 + sak 7F2651140F12C434F782EF9AD7791EE2CFE2BF315A568A48785E35FC803C9DB6 + salt 000000000000000000000000 + ssci 0 + SAI_MACSEC_SA_ATTR_CURRENT_XPN 87185 + SAI_MACSEC_SA_STAT_OCTETS_ENCRYPTED 0 + SAI_MACSEC_SA_STAT_OCTETS_PROTECTED 0 + SAI_MACSEC_SA_STAT_OUT_PKTS_ENCRYPTED 0 + SAI_MACSEC_SA_STAT_OUT_PKTS_PROTECTED 0 + ------------------------------------- ---------------------------------------------------------------- + MACsec Ingress SC (525400edac5b0001) + MACsec Ingress SA (1) + --------------------------------------- ---------------------------------------------------------------- + active true + auth_key 849B69D363E2B0AA154BEBBD7C1D9487 + lowest_acceptable_pn 1 + sak AE8C9BB36EA44B60375E84BC8E778596289E79240FDFA6D7BA33D3518E705A5E + salt 000000000000000000000000 + ssci 0 + SAI_MACSEC_SA_ATTR_CURRENT_XPN 103 + SAI_MACSEC_SA_STAT_IN_PKTS_DELAYED 0 + SAI_MACSEC_SA_STAT_IN_PKTS_INVALID 0 + SAI_MACSEC_SA_STAT_IN_PKTS_LATE 0 + SAI_MACSEC_SA_STAT_IN_PKTS_NOT_USING_SA 0 + SAI_MACSEC_SA_STAT_IN_PKTS_NOT_VALID 0 + SAI_MACSEC_SA_STAT_IN_PKTS_OK 0 + SAI_MACSEC_SA_STAT_IN_PKTS_UNCHECKED 0 + SAI_MACSEC_SA_STAT_IN_PKTS_UNUSED_SA 0 + SAI_MACSEC_SA_STAT_OCTETS_ENCRYPTED 0 + SAI_MACSEC_SA_STAT_OCTETS_PROTECTED 0 + --------------------------------------- ---------------------------------------------------------------- + MACsec Ingress SA (2) + --------------------------------------- ---------------------------------------------------------------- + active true + auth_key 5A8B8912139551D3678B43DD0F10FFA5 + lowest_acceptable_pn 1 + sak 7F2651140F12C434F782EF9AD7791EE2CFE2BF315A568A48785E35FC803C9DB6 + salt 000000000000000000000000 + ssci 0 + SAI_MACSEC_SA_ATTR_CURRENT_XPN 91824 + SAI_MACSEC_SA_STAT_IN_PKTS_DELAYED 0 + SAI_MACSEC_SA_STAT_IN_PKTS_INVALID 0 + SAI_MACSEC_SA_STAT_IN_PKTS_LATE 0 + SAI_MACSEC_SA_STAT_IN_PKTS_NOT_USING_SA 0 + SAI_MACSEC_SA_STAT_IN_PKTS_NOT_VALID 0 + SAI_MACSEC_SA_STAT_IN_PKTS_OK 0 + SAI_MACSEC_SA_STAT_IN_PKTS_UNCHECKED 0 + SAI_MACSEC_SA_STAT_IN_PKTS_UNUSED_SA 0 + SAI_MACSEC_SA_STAT_OCTETS_ENCRYPTED 0 + SAI_MACSEC_SA_STAT_OCTETS_PROTECTED 0 + --------------------------------------- ---------------------------------------------------------------- +MACsec port(Ethernet1) +--------------------- ----------- +cipher_suite GCM-AES-256 +enable true +enable_encrypt true +enable_protect true +enable_replay_protect false +replay_window 0 +send_sci true +--------------------- ----------- + MACsec Egress SC (5254008f4f1c0001) + ----------- - + encoding_an 1 + ----------- - + MACsec Egress SA (1) + ------------------------------------- ---------------------------------------------------------------- + auth_key 35FC8F2C81BCA28A95845A4D2A1EE6EF + next_pn 1 + sak 1EC8572B75A840BA6B3833DC550C620D2C65BBDDAD372D27A1DFEB0CD786671B + salt 000000000000000000000000 + ssci 0 + SAI_MACSEC_SA_ATTR_CURRENT_XPN 4809 + SAI_MACSEC_SA_STAT_OCTETS_ENCRYPTED 0 + SAI_MACSEC_SA_STAT_OCTETS_PROTECTED 0 + SAI_MACSEC_SA_STAT_OUT_PKTS_ENCRYPTED 0 + SAI_MACSEC_SA_STAT_OUT_PKTS_PROTECTED 0 + ------------------------------------- ---------------------------------------------------------------- + MACsec Ingress SC (525400edac5b0001) + MACsec Ingress SA (1) + --------------------------------------- ---------------------------------------------------------------- + active true + auth_key 35FC8F2C81BCA28A95845A4D2A1EE6EF + lowest_acceptable_pn 1 + sak 1EC8572B75A840BA6B3833DC550C620D2C65BBDDAD372D27A1DFEB0CD786671B + salt 000000000000000000000000 + ssci 0 + SAI_MACSEC_SA_ATTR_CURRENT_XPN 5033 + SAI_MACSEC_SA_STAT_IN_PKTS_DELAYED 0 + SAI_MACSEC_SA_STAT_IN_PKTS_INVALID 0 + SAI_MACSEC_SA_STAT_IN_PKTS_LATE 0 + SAI_MACSEC_SA_STAT_IN_PKTS_NOT_USING_SA 0 + SAI_MACSEC_SA_STAT_IN_PKTS_NOT_VALID 0 + SAI_MACSEC_SA_STAT_IN_PKTS_OK 0 + SAI_MACSEC_SA_STAT_IN_PKTS_UNCHECKED 0 + SAI_MACSEC_SA_STAT_IN_PKTS_UNUSED_SA 0 + SAI_MACSEC_SA_STAT_OCTETS_ENCRYPTED 0 + SAI_MACSEC_SA_STAT_OCTETS_PROTECTED 0 + --------------------------------------- ---------------------------------------------------------------- +``` + +## MACsec clear command + +Clear MACsec counters which is to reset all MACsec counters to ZERO. + +``` +admin@sonic:~$ sonic-clear macsec --help +Usage: sonic-clear macsec [OPTIONS] + + Clear MACsec counts. This clear command will generated a cache for next + show commands which will base on this cache as the zero baseline to show + the increment of counters. + +Options: + --clean-cache BOOLEAN If the option of clean cache is true, next show + commands will show the raw counters which based on + the service booted instead of the last clear command. + -h, -?, --help Show this message and exit. +``` + +## VRF Configuration + +### VRF show commands + +**show vrf** + +This command displays all vrfs configured on the system along with interface binding to the vrf. +If vrf-name is also provided as part of the command, if the vrf is created it will display all interfaces binding to the vrf, if vrf is not created nothing will be displayed. + +- Usage: + ``` + show vrf [] + ``` + +- Example: + ```` + admin@sonic:~$ show vrf + VRF Interfaces + ------- ------------ + default Vlan20 + Vrf-red Vlan100 + Loopback11 + Eth0.100 + Vrf-blue Loopback100 + Loopback102 + Ethernet0.10 + PortChannel101 + ```` + +### VRF config commands + +**config vrf add ** + +This command creates vrf in SONiC system with provided vrf-name. + +- Usage: + ``` +config vrf add +``` +Note: vrf-name should always start with keyword "Vrf" + +**config vrf del ** + +This command deletes vrf with name vrf-name. + +- Usage: + ``` +config vrf del +``` + +## Management VRF + +### Management VRF Show commands + +**show mgmt-vrf** + +This command displays whether the management VRF is enabled or disabled. It also displays the details about the the links (eth0, mgmt, lo-m) that are related to management VRF. + +- Usage: + ``` + show mgmt-vrf + ``` + +- Example: + ``` + admin@sonic:~$ show mgmt-vrf + + ManagementVRF : Enabled + + Management VRF interfaces in Linux: + 348: mgmt: mtu 65536 qdisc noqueue state UP mode DEFAULT group default qlen 1000 + link/ether f2:2a:d9:bc:e8:f0 brd ff:ff:ff:ff:ff:ff + 2: eth0: mtu 1500 qdisc mq master mgmt state UP mode DEFAULT group default qlen 1000 + link/ether 4c:76:25:f4:f9:f3 brd ff:ff:ff:ff:ff:ff + 350: lo-m: mtu 1500 qdisc noqueue master mgmt state UNKNOWN mode DEFAULT group default qlen 1000 + link/ether b2:4c:c6:f3:e9:92 brd ff:ff:ff:ff:ff:ff + + NOTE: The management interface "eth0" shows the "master" as "mgmt" since it is part of management VRF. + ``` + +**show mgmt-vrf routes** + +This command displays the routes that are present in the routing table 5000 that is meant for management VRF. + +- Usage: + ``` + show mgmt-vrf routes + ``` + +- Example: + ``` + admin@sonic:~$ show mgmt-vrf routes + + Routes in Management VRF Routing Table: + default via 10.16.210.254 dev eth0 metric 201 + broadcast 10.16.210.0 dev eth0 proto kernel scope link src 10.16.210.75 + 10.16.210.0/24 dev eth0 proto kernel scope link src 10.16.210.75 + local 10.16.210.75 dev eth0 proto kernel scope host src 10.16.210.75 + broadcast 10.16.210.255 dev eth0 proto kernel scope link src 10.16.210.75 + broadcast 127.0.0.0 dev lo-m proto kernel scope link src 127.0.0.1 + 127.0.0.0/8 dev lo-m proto kernel scope link src 127.0.0.1 + local 127.0.0.1 dev lo-m proto kernel scope host src 127.0.0.1 + broadcast 127.255.255.255 dev lo-m proto kernel scope link src 127.0.0.1 + ``` + +**show management_interface address** + +This command displays the IP address(es) configured for the management interface "eth0" and the management network default gateway. + +- Usage: + ``` + show management_interface address + ``` + +- Example: + ``` + admin@sonic:~$ show management_interface address + Management IP address = 10.16.210.75/24 + Management NetWork Default Gateway = 10.16.210.254 + Management IP address = FC00:2::32/64 + Management Network Default Gateway = fc00:2::1 + ``` + +**show snmpagentaddress** + +This command displays the configured SNMP agent IP addresses. + +- Usage: + ``` + show snmpagentaddress + ``` + +- Example: + ``` + admin@sonic:~$ show snmpagentaddress + ListenIP ListenPort ListenVrf + ---------- ------------ ----------- + 1.2.3.4 787 mgmt + ``` + +**show snmptrap** + +This command displays the configured SNMP Trap server IP addresses. + +- Usage: + ``` + show snmptrap + ``` + +- Example: + ``` + admin@sonic:~$ show snmptrap + Version TrapReceiverIP Port VRF Community + --------- ---------------- ------ ----- ----------- + 2 31.31.31.31 456 mgmt public + ``` + +### Management VRF Config commands + +**config vrf add mgmt** + +This command enables the management VRF in the system. This command restarts the "interfaces-config" service which in turn regenerates the /etc/network/interfaces file and restarts the "networking" service. This creates a new interface and l3mdev CGROUP with the name as "mgmt" and enslaves the management interface "eth0" into this master interface "mgmt". Note that the VRFName "mgmt" (or "management") is reserved for management VRF. i.e. Data VRFs should not use these reserved VRF names. + +- Usage: + ``` + config vrf add mgmt + ``` + +- Example: + ``` + admin@sonic:~$ sudo config vrf add mgmt + ``` + +**config vrf del mgmt** + +This command disables the management VRF in the system. This command restarts the "interfaces-config" service which in turn regenerates the /etc/network/interfaces file and restarts the "networking" service. This deletes the interface "mgmt" and deletes the l3mdev CGROUP named "mgmt" and puts back the management interface "eth0" into the default VRF. Note that the VRFName "mgmt" (or "management") is reserved for management VRF. i.e. Data VRFs should not use these reserved VRF names. + +- Usage: + ``` + config vrf del mgmt + ``` + +- Example: + ``` + admin@sonic:~$ sudo config vrf del mgmt + ``` + +**config snmpagentaddress add** + +This command adds the SNMP agent IP address on which the SNMP agent is expected to listen. When SNMP agent is expected to work as part of management VRF, users should specify the optional vrf_name parameter as "mgmt". This configuration goes into snmpd.conf that is used by SNMP agent. SNMP service is restarted to make this configuration effective in SNMP agent. + +- Usage: + ``` + config snmpagentaddress add [-p ] [-v ] agentip + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmpagentaddress add -v mgmt -p 123 21.22.13.14 + + Note: For this example, configuration goes into /etc/snmp/snmpd.conf inside snmp docker as follows. When "-v" parameter is not used, the additional "%" in the following line will not be present. + + agentAddress 21.22.13.14:123%mgmt + ``` + +**config snmpagentaddress del** + +This command deletes the SNMP agent IP address on which the SNMP agent is expected to listen. When users had added the agent IP as part of "mgmt" VRF, users should specify the optional vrf_name parameter as "mgmt" while deleting as well. This configuration is removed from snmpd.conf that is used by SNMP agent. SNMP service is restarted to make this configuration effective in SNMP agent. + +- Usage: + ``` + config snmpagentaddress del [-p ] [-v ] agentip + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmpagentaddress del -v mgmt -p 123 21.22.13.14 + + ``` + +**config snmptrap modify** + +This command modifies the SNMP trap server IP address to which the SNMP agent is expected to send the traps. Users can configure one server IP addrss for each SNMP version to send the traps. When SNMP agent is expected to send traps as part of management VRF, users should specify the optional vrf_name parameter as "mgmt". This configuration goes into snmpd.conf that is used by SNMP agent. SNMP service is restarted to make this configuration effective in SNMP agent. + +- Usage: + ``` + config snmptrap modify [-p ] [-v ] [-c ] trapserverip + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmptrap modify 2 -p 456 -v mgmt 21.21.21.21 + + For this example, configuration goes into /etc/snmp/snmpd.conf inside snmp docker as follows. When "-v" parameter is not used, the additional "%" in the following line will not be present. In case of SNMPv1, "trapsink" will be updated, in case of v2, "trap2sink" will be updated and in case of v3, "informsink" will be updated. + + trap2sink 31.31.31.31:456%mgmt public + + ``` + +**config snmptrap del** + +This command deletes the SNMP Trap server IP address to which SNMP agent is expected to send TRAPs. When users had added the trap server IP as part of "mgmt" VRF, users should specify the optional vrf_name parameter as "mgmt" while deleting as well. This configuration is removed from snmpd.conf that is used by SNMP agent. SNMP service is restarted to make this configuration effective in SNMP agent. + +- Usage: + ``` + config snmptrap del [-p ] [-v ] [-c ] trapserverip + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmptrap del -v mgmt -p 123 21.22.13.14 + + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#management-vrf) + +## Muxcable + +### Muxcable Show commands + +**show muxcable status** + +This command displays all the status of either all the ports which are connected to muxcable or any individual port selected by the user. The resultant table or json output will show the current status of muxcable on the port (auto/active) and also the health of the muxcable. + +- Usage: + ``` + show muxcable status [OPTIONS] [PORT] + ``` + +While displaying the muxcable status, users can configure the following fields + +- PORT optional - Port name should be a valid port +- --json optional - -- option to display the result in json format. By default output will be in tabular format. + +With no optional argument, all the ports muxcable status will be displayed in tabular form, or user can pass --json option to display in json format + +- Example: + ``` + admin@sonic:~$ show muxcable status + PORT STATUS HEALTH + ---------- -------- -------- + Ethernet32 active HEALTHY + Ethernet0 auto HEALTHY + ``` + ``` + admin@sonic:~$ show muxcable status --json + ``` + ```json + { + "MUX_CABLE": { + "Ethernet32": { + "STATUS": "active", + "HEALTH": "HEALTHY" + }, + "Ethernet0": { + "STATUS": "auto", + "HEALTH": "HEALTHY" + } + } + } + + ``` + ``` + admin@sonic:~$ show muxcable status Ethernet0 + PORT STATUS HEALTH + --------- -------- -------- + Ethernet0 auto HEALTHY + ``` + ``` + admin@sonic:~$ show muxcable status Ethernet0 --json + ``` + ```json + { + "MUX_CABLE": { + "Ethernet0": { + "STATUS": "auto", + "HEALTH": "HEALTHY" + } + } + } + ``` + +**show muxcable config** + +This command displays all the configurations of either all the ports which are connected to muxcable or any individual port selected by the user. The resultant table or json output will show the current configurations of muxcable on the port(active/standby) and also the ipv4 and ipv6 address of the port as well as peer TOR ip address with the hostname. + +- Usage: + ``` + show muxcable config [OPTIONS] [PORT] + ``` + +With no optional argument, all the ports muxcable configuration will be displayed in tabular form +While displaying the muxcable configuration, users can configure the following fields + +- PORT optional - Port name should be a valid port +- --json optional - option to display the result in json format. By default output will be in tabular format. + +- Example: + ``` + admin@sonic:~$ show muxcable config + SWITCH_NAME PEER_TOR + ------------- ---------- + sonic 10.1.1.1 + port state ipv4 ipv6 + --------- ------- -------- -------- + Ethernet0 active 10.1.1.1 fc00::75 + ``` + ``` + admin@sonic:~$ show muxcable config --json + ``` + ```json + { + "MUX_CABLE": { + "PEER_TOR": "10.1.1.1", + "PORTS": { + "Ethernet0": { + "STATE": "active", + "SERVER": { + "IPv4": "10.1.1.1", + "IPv6": "fc00::75" + } + } + } + } + } + ``` + ``` + admin@sonic:~$ show muxcable config Ethernet0 + SWITCH_NAME PEER_TOR + ------------- ---------- + sonic 10.1.1.1 + port state ipv4 ipv6 + --------- ------- -------- -------- + Ethernet0 active 10.1.1.1 fc00::75 + ``` + ``` + admin@sonic:~$ show muxcable config Ethernet0 --json + ``` + ```json + { + "MUX_CABLE": { + "PORTS": { + "Ethernet0": { + "STATE": "active", + "SERVER": { + "IPv4": "10.1.1.1", + "IPv6": "fc00::75" + } + } + } + } + } + ``` + +**show muxcable ber-info** + +This command displays the ber(Bit error rate) of the port user provides on the target user provides. The target provided as an integer corresponds to actual target as. +0 -> local +1 -> tor 1 +2 -> tor 2 +3 -> nic + +- Usage: + ``` + Usage: show muxcable ber-info [OPTIONS] PORT TARGET + ``` + + +- PORT required - Port number should be a valid port +- TARGET required - the actual target to get the ber info of. + +- Example: + ``` + admin@sonic:~$ show muxcable ber-info 1 1 + Lane1 Lane2 + ------- ------- + 0 0 + ``` + +**show muxcable ber-info** + +This command displays the eye info in mv(milli volts) of the port user provides on the target user provides. The target provided as an integer corresponds to actual target as. +0 -> local +1 -> tor 1 +2 -> tor 2 +3 -> nic + +- Usage: + ``` + Usage: show muxcable eye-info [OPTIONS] PORT TARGET + ``` + +- PORT required - Port number should be a valid port +- TARGET required - the actual target to get the eye info of. + +- Example: + ``` + admin@sonic:~$ show muxcable ber-info 1 1 + Lane1 Lane2 + ------- ------- + 632 622 + ``` + +### Muxcable Config commands + + +**config muxcable mode** + +This command is used for setting the configuration of a muxcable Port/all ports to be active or auto. The user has to enter a port number or else all to make the muxcable config operation on all the ports. Depending on the status of the muxcable port state the resultant output could be OK or INPROGRESS . OK would imply no change on the state, INPROGRESS would mean the toggle is happening in the background. + +- Usage: + ``` + config muxcable mode [OPTIONS] + ``` + +While configuring the muxcable, users needs to configure the following fields for the operation + +- operation_state, permitted operation to be configured which can only be auto or active +- PORT optional - Port name should be a valid port +- --json optional - option to display the result in json format. By default output will be in tabular format. + + +- Example: + ``` + admin@sonic:~$ sudo config muxcable mode active Ethernet0 + port state + --------- ------- + Ethernet0 OK + ``` + ``` + admin@sonic:~$ sudo config muxcable mode --json active Ethernet0 + ``` + ```json + { + "Ethernet0": "OK" + } + ``` + ``` + admin@sonic:~$ sudo config muxcable mode active all + port state + ---------- ---------- + Ethernet0 OK + Ethernet32 INPROGRESS + ``` + ``` + admin@sonic:~$ sudo config muxcable mode active all --json + ``` + ```json + { + "Ethernet32": "INPROGRESS", + "Ethernet0": "OK" + } + ``` +**config muxcable prbs enable/disable** + +This command is used for setting the configuration and enable/diable of prbs on a port user provides. While enabling in addition to port the user also needs to provides the target, prbs mode and lane map on which the user intends to run prbs on. The target reflects where the enable/dsiable will happen. + +- Usage: + ``` + config muxcable prbs enable [OPTIONS] PORT TARGET MODE_VALUE LANE_MAP + config muxcable prbs disable [OPTIONS] PORT TARGET + ``` + +While configuring the muxcable, users needs to configure the following fields for the operation + +- PORT required - Port number should be a valid port +- TARGET required - the actual target to run the prbs on + 0 -> local side, + 1 -> TOR 1 + 2 -> TOR 2 + 3 -> NIC +- MODE_VALUE required - the mode/type for configuring the PRBS mode. + 0x00 = PRBS 9, 0x01 = PRBS 15, 0x02 = PRBS 23, 0x03 = PRBS 31 +- LANE_MAP required - an integer representing the lane_map to be run PRBS on + 0bit for lane 0, 1bit for lane1 and so on. + for example 3 -> 0b'0011 , means running on lane0 and lane1 +- Example: + ``` + admin@sonic:~$ sudo config muxcable prbs enable 1 1 3 3 + PRBS config sucessful + admin@sonic:~$ sudo config muxcable prbs disable 1 0 + PRBS disable sucessful + ``` + +**config muxcable loopback enable/disable** + +This command is used for setting the configuration and enable/disable of loopback on a port user provides. While enabling in addition to port the user also needs to provides the target and lane map on which the user intends to run loopback on. The target reflects where the enable/dsiable will happen. + +- Usage: + ``` + config muxcable loopback enable [OPTIONS] PORT TARGET LANE_MAP + config muxcable loopback disable [OPTIONS] PORT TARGET + ``` + +While configuring the muxcable, users needs to configure the following fields for the operation + +- PORT required - Port number should be a valid port +- TARGET required - the actual target to run the loopback on + 0 -> local side, + 1 -> TOR 1 + 2 -> TOR 2 + 3 -> NIC +- LANE_MAP required - an integer representing the lane_map to be run loopback on + 0bit for lane 0, 1bit for lane1 and so on. + for example 3 -> 0b'0011 , means running on lane0 and lane1 + +- Example: + ``` + admin@sonic:~$ sudo config muxcable loopback enable 1 1 3 + loopback config sucessful + admin@sonic:~$ sudo config muxcable loopback disable 1 0 + loopback disable sucessfull + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#muxcable) + +## Mirroring + +### Mirroring Show commands + +**show mirror_session** + +This command displays all the mirror sessions that are configured. + +- Usage: + ``` + show mirror_session + ``` + +- Example: + ``` + admin@sonic:~$ show mirror_session + ERSPAN Sessions + Name Status SRC IP DST IP GRE DSCP TTL Queue Policer Monitor Port SRC Port Direction + ------ -------- -------- -------- ----- ------ ----- ------- --------- -------------- ---------- ----------- + everflow0 active 10.1.0.32 10.0.0.7 + + SPAN Sessions + Name Status DST Port SRC Port Direction + ------ -------- ---------- ------------- ----------- + port0 active Ethernet0 PortChannel10 rx + ``` + +### Mirroring Config commands + +**config mirror_session** + +This command is used to add or remove mirroring sessions. Mirror session is identified by "session_name". +This command supports configuring both SPAN/ERSPAN sessions. +In SPAN user can configure mirroring of list of source ports/LAG to destination port in ingress/egress/both directions. +In ERSPAN user can configure mirroring of list of source ports/LAG to a destination IP. +Both SPAN/ERSPAN support ACL based mirroring and can be used in ACL configurations. + +While adding a new ERSPAN session, users need to configure the following fields that are used while forwarding the mirrored packets. + +1) source IP address, +2) destination IP address, +3) DSCP (QoS) value with which mirrored packets are forwarded +4) TTL value +5) optional - GRE Type in case if user wants to send the packet via GRE tunnel. GRE type could be anything; it could also be left as empty; by default, it is 0x8949 for Mellanox; and 0x88be for the rest of the chips. +6) optional - Queue in which packets shall be sent out of the device. Valid values 0 to 7 for most of the devices. Users need to know their device and the number of queues supported in that device. +7) optional - Policer which will be used to control the rate at which frames are mirrored. +8) optional - List of source ports which can have both Ethernet and LAG ports. +9) optional - Direction - Mirror session direction when configured along with Source port. (Supported rx/tx/both. default direction is both) + +- Usage: + ``` + config mirror_session erspan add [gre_type] [queue] [policer ] [source-port-list] [direction] + ``` + + The following command is also supported to be backward compatible. + This command will be deprecated in future releases. + ``` + config mirror_session add [gre_type] [queue] + ``` + +- Example: + ``` + root@T1-2:~# config mirror_session add mrr_legacy 1.2.3.4 20.21.22.23 8 100 0x6558 0 + root@T1-2:~# show mirror_session + Name Status SRC IP DST IP GRE DSCP TTL Queue Policer Monitor Port SRC Port Direction + --------- -------- -------- ----------- ------ ------ ----- ------- --------- -------------- ---------- ----------- + mrr_legacy inactive 1.2.3.4 20.21.22.23 0x6558 8 100 0 + + + root@T1-2:~# config mirror_session erspan add mrr_abcd 1.2.3.4 20.21.22.23 8 100 0x6558 0 + root@T1-2:~# show mirror_session + Name Status SRC IP DST IP GRE DSCP TTL Queue Policer Monitor Port SRC Port Direction + --------- -------- -------- ----------- ------ ------ ----- ------- --------- -------------- ---------- ----------- + mrr_abcd inactive 1.2.3.4 20.21.22.23 0x6558 8 100 0 + root@T1-2:~# + + root@T1-2:~# config mirror_session erspan add mrr_port 1.2.3.4 20.21.22.23 8 100 0x6558 0 Ethernet0 + root@T1-2:~# show mirror_session + Name Status SRC IP DST IP GRE DSCP TTL Queue Policer Monitor Port SRC Port Direction + --------- -------- -------- ----------- ------ ------ ----- ------- --------- -------------- ---------- ----------- + mrr_port inactive 1.2.3.4 20.21.22.23 0x6558 8 100 0 Ethernet0 both + root@T1-2:~# + ``` + +While adding a new SPAN session, users need to configure the following fields that are used while forwarding the mirrored packets. +1) destination port, +2) optional - List of source ports- List of source ports which can have both Ethernet and LAG ports. +3) optional - Direction - Mirror session direction when configured along with Source port. (Supported rx/tx/both. default direction is both) +4) optional - Queue in which packets shall be sent out of the device. Valid values 0 to 7 for most of the devices. Users need to know their device and the number of queues supported in that device. +5) optional - Policer which will be used to control the rate at which frames are mirrored. + +- Usage: + ``` + config mirror_session span add [source-port-list] [direction] [queue] [policer ] + ``` + +- Example: + ``` + root@T1-2:~# config mirror_session span add port0 Ethernet0 Ethernet4,PortChannel001,Ethernet8 + root@T1-2:~# show mirror_session + Name Status DST Port SRC Port Direction + ------ -------- ---------- --------------------------------- ----------- + port0 active Ethernet0 Ethernet4,PortChannel10,Ethernet8 both + root@T1-2:~# + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#mirroring) + +## NAT + +### NAT Show commands + +**show nat config** + +This command displays the NAT configuration. + +- Usage: + ``` + show nat config [static | pool | bindings | globalvalues | zones] + ``` + +With no optional arguments, the whole NAT configuration is displayed. + +- Example: + ``` + admin@sonic:~$ show nat config static + + Nat Type IP Protocol Global IP Global L4 Port Local IP Local L4 Port Twice-Nat Id + -------- ----------- ------------ -------------- ------------- ------------- ------------ + dnat all 65.55.45.5 --- 10.0.0.1 --- --- + dnat all 65.55.45.6 --- 10.0.0.2 --- --- + dnat tcp 65.55.45.7 2000 20.0.0.1 4500 1 + snat tcp 20.0.0.2 4000 65.55.45.8 1030 1 + + admin@sonic:~$ show nat config pool + + Pool Name Global IP Range Global L4 Port Range + ------------ ------------------------- -------------------- + Pool1 65.55.45.5 1024-65535 + Pool2 65.55.45.6-65.55.45.8 --- + Pool3 65.55.45.10-65.55.45.15 500-1000 + + admin@sonic:~$ show nat config bindings + + Binding Name Pool Name Access-List Nat Type Twice-Nat Id + ------------ ------------ ------------ -------- ------------ + Bind1 Pool1 --- snat --- + Bind2 Pool2 1 snat 1 + Bind3 Pool3 2 snat -- + + admin@sonic:~$ show nat config globalvalues + + Admin Mode : enabled + Global Timeout : 600 secs + TCP Timeout : 86400 secs + UDP Timeout : 300 secs + + admin@sonic:~$ show nat config zones + + Port Zone + ---- ---- + Ethernet2 0 + Vlan100 1 + ``` + +**show nat statistics** + +This command displays the NAT translation statistics for each entry. + +- Usage: + ``` + show nat statistics + ``` + +- Example: + ``` + admin@sonic:~$ show nat statistics + + Protocol Source Destination Packets Bytes + -------- --------- -------------- ------------- ------------- + all 10.0.0.1 --- 802 1009280 + all 10.0.0.2 --- 23 5590 + tcp 20.0.0.1:4500 --- 110 12460 + udp 20.0.0.1:4000 --- 1156 789028 + tcp 20.0.0.1:6000 --- 30 34800 + tcp 20.0.0.1:5000 65.55.42.1:2000 128 110204 + tcp 20.0.0.1:5500 65.55.42.1:2000 8 3806 + ``` + +**show nat translations** + +This command displays the NAT translation entries. + +- Usage: + ``` + show nat translations [count] + ``` +Giving the optional count argument displays only the details about the number of translation entries. +- Example: + ``` + admin@sonic:~$ show nat translations + + Static NAT Entries ................. 4 + Static NAPT Entries ................. 2 + Dynamic NAT Entries ................. 0 + Dynamic NAPT Entries ................. 4 + Static Twice NAT Entries ................. 0 + Static Twice NAPT Entries ................. 4 + Dynamic Twice NAT Entries ................ 0 + Dynamic Twice NAPT Entries ................ 0 + Total SNAT/SNAPT Entries ................ 9 + Total DNAT/DNAPT Entries ................ 9 + Total Entries ................ 14 + + Protocol Source Destination Translated Source Translated Destination + -------- --------- -------------- ----------------- ---------------------- + all 10.0.0.1 --- 65.55.42.2 --- + all --- 65.55.42.2 --- 10.0.0.1 + all 10.0.0.2 --- 65.55.42.3 --- + all --- 65.55.42.3 --- 10.0.0.2 + tcp 20.0.0.1:4500 --- 65.55.42.1:2000 --- + tcp --- 65.55.42.1:2000 --- 20.0.0.1:4500 + udp 20.0.0.1:4000 --- 65.55.42.1:1030 --- + udp --- 65.55.42.1:1030 --- 20.0.0.1:4000 + tcp 20.0.0.1:6000 --- 65.55.42.1:1024 --- + tcp --- 65.55.42.1:1024 --- 20.0.0.1:6000 + tcp 20.0.0.1:5000 65.55.42.1:2000 65.55.42.1:1025 20.0.0.1:4500 + tcp 20.0.0.1:4500 65.55.42.1:1025 65.55.42.1:2000 20.0.0.1:5000 + tcp 20.0.0.1:5500 65.55.42.1:2000 65.55.42.1:1026 20.0.0.1:4500 + tcp 20.0.0.1:4500 65.55.42.1:1026 65.55.42.1:2000 20.0.0.1:5500 + + admin@sonic:~$ show nat translations count + + Static NAT Entries ................. 4 + Static NAPT Entries ................. 2 + Dynamic NAT Entries ................. 0 + Dynamic NAPT Entries ................. 4 + Static Twice NAT Entries ................. 0 + Static Twice NAPT Entries ................. 4 + Dynamic Twice NAT Entries ................ 0 + Dynamic Twice NAPT Entries ................ 0 + Total SNAT/SNAPT Entries ................ 9 + Total DNAT/DNAPT Entries ................ 9 + Total Entries ................ 14 + ``` + +### NAT Config commands + +**config nat add static** + +This command is used to add a static NAT or NAPT entry. +When configuring the Static NAT entry, user has to specify the following fields with 'basic' keyword. + +1. Global IP address, +2. Local IP address, +3. NAT type (snat / dnat) to be applied on the Global IP address. Default value is dnat. This is optinoal argument. +4. Twice NAT Id. This is optional argument used in case of twice nat configuration. + +When configuring the Static NAPT entry, user has to specify the following fields. + +1. IP protocol type (tcp / udp) +2. Global IP address + Port +3. Local IP address + Port +4. NAT type (snat / dnat) to be applied on the Global IP address + Port. Default value is dnat. This is optional argument. +5. Twicw NAT Id. This is optional argument used in case of twice nat configuration. + +- Usage: + ``` + config nat add static /{/{basic (global-ip) (local-ip)/} | /{/{tcp | udp/} (global-ip) (global-port) (local-ip) (local-port)/}/} [-nat_type /{snat | dnat/}] [-twice_nat_id (value) ] + ``` + +To delete a static NAT or NAPT entry, use the command below. Giving the all argument deletes all the configured static NAT and NAPT entries. +``` +config nat remove static /{/{basic (global-ip) (local-ip)/} | /{/{tcp | udp/} (global-ip) (global-port) (local-ip) (local-port)/} | all/} +``` +- Example: + ``` + admin@sonic:~$ sudo config nat add static basic 65.55.45.1 12.12.12.14 -nat_type dnat + admin@sonic:~$ sudo config nat add static tcp 65.55.45.2 100 12.12.12.15 200 -nat_type dnat + + admin@sonic:~$ show nat translations + + Static NAT Entries ................. 2 + Static NAPT Entries ................. 2 + Dynamic NAT Entries ................. 0 + Dynamic NAPT Entries ................. 0 + Static Twice NAT Entries ................. 0 + Static Twice NAPT Entries ................. 0 + Dynamic Twice NAT Entries ................ 0 + Dynamic Twice NAPT Entries ................ 0 + Total SNAT/SNAPT Entries ................ 2 + Total DNAT/DNAPT Entries ................ 2 + Total Entries ................ 4 + + Protocol Source Destination Translated Source Translated Destination + -------- --------- -------------- ----------------- ---------------------- + all 12.12.12.14 --- 65.55.42.1 --- + all --- 65.55.42.1 --- 12.12.12.14 + tcp 12.12.12.15:200 --- 65.55.42.2:100 --- + tcp --- 65.55.42.2:100 --- 12.12.12.15:200 + ``` + +**config nat add pool** + +This command is used to create a NAT pool used for dynamic Source NAT or NAPT translations. +Pool can be configured in one of the following combinations. + +1. Global IP address range (or) +2. Global IP address + L4 port range (or) +3. Global IP address range + L4 port range. + +- Usage: + ``` + config nat add pool (pool-name) (global-ip-range) (global-port-range) + ``` +To delete a NAT pool, use the command. Pool cannot be removed if it is referenced by a NAT binding. Giving the pools argument removes all the configured pools. +``` +config nat remove {pool (pool-name) | pools} +``` +- Example: + ``` + admin@sonic:~$ sudo config nat add pool pool1 65.55.45.2-65.55.45.10 + admin@sonic:~$ sudo config nat add pool pool2 65.55.45.3 100-1024 + + admin@sonic:~$ show nat config pool + + Pool Name Global IP Range Global Port Range + ----------- ---------------------- ------------------- + pool1 65.55.45.2-65.55.45.10 --- + pool2 65.55.45.3 100-1024 + ``` + +**config nat add binding** + +This command is used to create a NAT binding between a pool and an ACL. The following fields are needed for configuring the binding. + + 1. ACL is an optional argument. If ACL argument is not given, the NAT binding is applicable to match all traffic. + 2. NAT type is an optional argument. Only DNAT type is supoprted for binding. + 3. Twice NAT Id is an optional argument. This Id is used to form a twice nat grouping with the static NAT/NAPT entry configured with the same Id. + +- Usage: + ``` + config nat add binding (binding-name) [(pool-name)] [(acl-name)] [-nat_type {snat | dnat}] [-twice_nat_id (value)] + ``` +To delete a NAT binding, use the command below. Giving the bindings argument removes all the configured bindings. +``` +config nat remove {binding (binding-name) | bindings} +``` +- Example: + ``` + admin@sonic:~$ sudo config nat add binding bind1 pool1 acl1 + admin@sonic:~$ sudo config nat add binding bind2 pool2 + + admin@sonic:~$ show nat config bindings + + Binding Name Pool Name Access-List Nat Type Twice-NAT Id + -------------- ----------- ------------- ---------- -------------- + bind1 pool1 acl1 snat --- + bind2 pool2 snat --- + ``` + +**config nat add interface** + +This command is used to configure NAT zone on an L3 interface. Default value of NAT zone on an L3 interface is 0. Valid range of zone values is 0-3. + +- Usage: + ``` + config nat add interface (interface-name) -nat_zone (value) + ``` +To reset the NAT zone on an interface, use the command below. Giving the interfaces argument resets the NAT zone on all the L3 interfaces to 0. +``` +config nat remove {interface (interface-name) | interfaces} +``` +- Example: + ``` + admin@sonic:~$ sudo config nat add interface Ethernet28 -nat_zone 1 + + admin@sonic:~$ show nat config zones + + Port Zone + ---------- ------ + Ethernet0 0 + Ethernet28 1 + Ethernet22 0 + Vlan2091 0 + ``` + +**config nat set** + +This command is used to set the NAT timeout values. Different timeout values can be configured for the NAT entry timeout, NAPT TCP entry timeout, NAPT UDP entry timeout. +Range for Global NAT entry timeout is 300 sec to 432000 sec, default value is 600 sec. +Range for TCP NAT/NAPT entry timeout is 300 sec to 432000 sec, default value is 86400 sec. +Range for UDP NAT/NAPT entry timeout is 120 sec to 600 sec, default value is 300 sec. + +- Usage: + ``` + config nat set {tcp-timeout (value) | timeout (value) | udp-timeout (value)} + ``` +To reset the timeout values to the default values, use the command +``` +config nat reset {tcp-timeout | timeout | udp-timeout} +``` +- Example: + ``` + admin@sonic:~$ sudo config nat add set tcp-timeout 3600 + + admin@sonic:~$ show nat config globalvalues + + Admin Mode : enabled + Global Timeout : 600 secs + TCP Timeout : 600 secs + UDP Timeout : 300 secs + ``` + +**config nat feature** + +This command is used to enable or disable the NAT feature. + +- Usage: + ``` + config nat feature {enable | disable} + ``` + +- Example: + ``` + admin@sonic:~$ sudo config nat feature enable + admin@sonic:~$ sudo config nat feature disable + ``` + +### NAT Clear commands + +**sonic-clear nat translations** + +This command is used to clear the dynamic NAT and NAPT translation entries. + +- Usage: + ``` + sonic-clear nat translations + ``` + +**sonic-clear nat statistics** + +This command is used to clear the statistics of all the NAT and NAPT entries. + +- Usage: + ``` + sonic-clear nat statistics + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#nat) + + +## NTP + +### NTP show commands + +**show ntp** + +This command displays a list of NTP peers known to the server as well as a summary of their state. + +- Usage: + ``` + show ntp + ``` + +- Example: + ``` + admin@sonic:~$ show ntp + synchronised to NTP server (204.2.134.164) at stratum 3 + time correct to within 326797 ms + polling server every 1024 s + + remote refid st t when poll reach delay offset jitter + ============================================================================== + 23.92.29.245 .XFAC. 16 u - 1024 0 0.000 0.000 0.000 + *204.2.134.164 46.233.231.73 2 u 916 1024 377 3.079 0.394 0.128 + ``` + + +### NTP Config Commands + +This sub-section of commands is used to add or remove the configured NTP servers. + +**config ntp add** + +This command is used to add a NTP server IP address to the NTP server list. Note that more that one NTP server IP address can be added in the device. + +- Usage: + ``` + config ntp add + ``` + +- Example: + ``` + admin@sonic:~$ sudo config ntp add 9.9.9.9 + NTP server 9.9.9.9 added to configuration + Restarting ntp-config service... + ``` + +**config ntp delete** + +This command is used to delete a configured NTP server IP address. + +- Usage: + ``` + config ntp del + ``` + +- Example: + ``` + admin@sonic:~$ sudo config ntp del 9.9.9.9 + NTP server 9.9.9.9 removed from configuration + Restarting ntp-config service... + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#NTP) + +# PFC Watchdog Commands +Detailed description of the PFC Watchdog could be fount on the [this wiki page](https://github.com/Azure/SONiC/wiki/PFC-Watchdog) + +**config pfcwd start \** + +This command starts PFC Watchdog + +- Usage: + ``` + config pfcwd start --action drop all 400 --restoration-time 400 + config pfcwd start --action forward Ethernet0 Ethernet8 400 + ``` + +**config pfcwd stop** + +This command stops PFC Watchdog + +- Usage: + ``` + config pfcwd stop + ``` + +**config pfcwd interval \** + +This command sets PFC Watchdog counter polling interval (in ms) + +- Usage: + ``` + config pfcwd interval 200 + ``` + +**config pfcwd counter_poll \** + +This command enables or disables PFCWD related counters polling + +- Usage: + ``` + config pfcwd counter_poll disable + ``` + +**config pfcwd big_red_switch \** + +This command enables or disables PFCWD's "BIG RED SWITCH"(BRS). After enabling BRS PFC Watchdog will be activated on all ports/queues it is configured for no matter whether the storm was detected or not + +- Usage: + ``` + config pfcwd big_red_switch enable + ``` + +**config pfcwd start_default** + +This command starts PFC Watchdog with the default settings. + +- Usage: + ``` + config pfcwd start_default + ``` + +Default values are the following: + + - detection time - 200ms + - restoration time - 200ms + - polling interval - 200ms + - action - 'drop' + +Additionally if number of ports in the system exceeds 32, all times will be multiplied by roughly /32. + + +**show pfcwd config** + +This command shows current PFC Watchdog configuration + +- Usage: + ``` + show pfcwd config + ``` + +**show pfcwd stats** + +This command shows current PFC Watchdog statistics (storms detected, packets dropped, etc) + +- Usage: + ``` + show pfcwd stats + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#pfc-watchdog-commands) + +## Platform Component Firmware + +### Platform Component Firmware show commands + +**show platform firmware status** + +This command displays platform components firmware status information. + +- Usage: +```bash +show platform firmware status +``` + +- Example: +```bash +admin@sonic:~$ sudo show platform firmware status +Chassis Module Component Version Description +--------- -------- ----------- ----------------------- ---------------------------------------- +MSN3800 N/A ONIE 2020.11-5.2.0022-9600 ONIE - Open Network Install Environment + SSD 0202-000 SSD - Solid-State Drive + BIOS 0ACLH004_02.02.008_9600 BIOS - Basic Input/Output System + CPLD1 CPLD000120_REV0900 CPLD - Complex Programmable Logic Device + CPLD2 CPLD000165_REV0500 CPLD - Complex Programmable Logic Device + CPLD3 CPLD000166_REV0300 CPLD - Complex Programmable Logic Device + CPLD4 CPLD000167_REV0100 CPLD - Complex Programmable Logic Device +``` + +**show platform firmware updates** + +This command displays platform components firmware updates information. + +- Usage: +```bash +show platform firmware updates [-i|--image] +``` + +- Options: + - _-i|--image_: show updates using current/next SONiC image + + Valid values: + - current + - next + + Default: + - current + +- Example: +```bash +admin@sonic:~$ sudo show platform firmware updates +Chassis Module Component Firmware Version (Current/Available) Status +--------- -------- ----------- ------------------------------------------ ------------------------------------------------- ------------------ +MSN3800 N/A ONIE /usr/local/lib/firmware/mellanox/onie.bin 2020.11-5.2.0022-9600 / 2020.11-5.2.0024-9600 update is required + SSD /usr/local/lib/firmware/mellanox/ssd.bin 0202-000 / 0204-000 update is required + BIOS /usr/local/lib/firmware/mellanox/bios.bin 0ACLH004_02.02.008_9600 / 0ACLH004_02.02.010_9600 update is required + CPLD1 /usr/local/lib/firmware/mellanox/cpld.mpfa CPLD000120_REV0900 / CPLD000120_REV0900 up-to-date + CPLD2 /usr/local/lib/firmware/mellanox/cpld.mpfa CPLD000165_REV0500 / CPLD000165_REV0500 up-to-date + CPLD3 /usr/local/lib/firmware/mellanox/cpld.mpfa CPLD000166_REV0300 / CPLD000166_REV0300 up-to-date + CPLD4 /usr/local/lib/firmware/mellanox/cpld.mpfa CPLD000167_REV0100 / CPLD000167_REV0100 up-to-date +``` + +- Note: + - current/next values for _-i|--image_ are taken from `sonic-installer list` + ```bash + admin@sonic:~$ sudo sonic-installer list + Current: SONiC-OS-202012.0-fb89c28c9 + Next: SONiC-OS-201911.0-2bec3004e + Available: + SONiC-OS-202012.0-fb89c28c9 + SONiC-OS-201911.0-2bec3004e + ``` + +**show platform firmware version** + +This command displays platform components firmware utility version. + +- Usage: +```bash +show platform firmware version +``` + +- Example: +```bash +admin@sonic:~$ show platform firmware version +fwutil version 2.0.0.0 +``` + +### Platform Component Firmware config commands + +**config platform firmware install** + +This command is used to install a platform component firmware. +Both modular and non modular chassis platforms are supported. + +- Usage: +```bash +config platform firmware install chassis component fw [-y|--yes] +config platform firmware install module component fw [-y|--yes] +``` + +- Options: + - _-y|--yes_: automatic yes to prompts. Assume "yes" as answer to all prompts and run non-interactively + +- Example: +```bash +admin@sonic:~$ sudo config platform firmware install chassis component BIOS fw /usr/local/lib/firmware/mellanox/sn3800/chassis1/bios.bin +Warning: Immediate cold reboot is required to complete BIOS firmware update. +New firmware will be installed, continue? [y/N]: y +Installing firmware: + /usr/local/lib/firmware/mellanox/sn3800/chassis1/bios.bin + +admin@sonic:~$ sudo config platform firmware install module Module1 component BIOS fw https://www.mellanox.com/fw/sn3800/module1/bios.bin +Warning: Immediate cold reboot is required to complete BIOS firmware update. +New firmware will be installed, continue? [y/N]: y +Downloading firmware: + [##################################################] 100% +Installing firmware: + /tmp/bios.bin +``` + +- Note: + - can be absolute path or URL + +**config platform firmware update** + +This command is used to update a platform component firmware from current/next SONiC image. +Both modular and non modular chassis platforms are supported. + +FW update requires `platform_components.json` to be created and placed at: +sonic-buildimage/device///platform_components.json + +Example: +1. Non modular chassis platform +```json +{ + "chassis": { + "Chassis1": { + "component": { + "BIOS": { + "firmware": "/usr/local/lib/firmware///chassis1/bios.bin", + "version": "" + }, + "CPLD": { + "firmware": "/usr/local/lib/firmware///chassis1/cpld.bin", + "version": "" + }, + "FPGA": { + "firmware": "/usr/local/lib/firmware///chassis1/fpga.bin", + "version": "" + } + } + } + } +} +``` + +2. Modular chassis platform +```json +{ + "chassis": { + "Chassis1": { + "component": { + "BIOS": { + "firmware": "/usr/local/lib/firmware///chassis1/bios.bin", + "version": "" + }, + "CPLD": { + "firmware": "/usr/local/lib/firmware///chassis1/cpld.bin", + "version": "" + }, + "FPGA": { + "firmware": "/usr/local/lib/firmware///chassis1/fpga.bin", + "version": "" + } + } + } + }, + "module": { + "Module1": { + "component": { + "CPLD": { + "firmware": "/usr/local/lib/firmware///module1/cpld.bin", + "version": "" + }, + "FPGA": { + "firmware": "/usr/local/lib/firmware///module1/fpga.bin", + "version": "" + } + } + } + } +} +``` + +- Usage: +```bash +config platform firmware update chassis component fw [-y|--yes] [-f|--force] [-i|--image] +config platform firmware update module component fw [-y|--yes] [-f|--force] [-i|--image] +``` + +- Options: + - _-y|--yes_: automatic yes to prompts. Assume "yes" as answer to all prompts and run non-interactively + - _-f|--force_: update FW regardless the current version + - _-i|--image_: update FW using current/next SONiC image + + Valid values: + - current + - next + + Default: + - current + +- Example: +```bash +admin@sonic:~$ sudo config platform firmware update chassis component BIOS fw +Warning: Immediate cold reboot is required to complete BIOS firmware update. +New firmware will be installed, continue? [y/N]: y +Updating firmware: + /usr/local/lib/firmware/mellanox/x86_64-mlnx_msn3800-r0/chassis1/bios.bin + +admin@sonic:~$ sudo config platform firmware update module Module1 component BIOS fw +Warning: Immediate cold reboot is required to complete BIOS firmware update. +New firmware will be installed, continue? [y/N]: y +Updating firmware: + /usr/local/lib/firmware/mellanox/x86_64-mlnx_msn3800-r0/module1/bios.bin +``` + +- Note: + - FW update will be disabled if component definition is not provided (e.g., 'BIOS': { }) + - FW version will be read from image if `version` field is not provided + - current/next values for _-i|--image_ are taken from `sonic-installer list` + ```bash + admin@sonic:~$ sudo sonic-installer list + Current: SONiC-OS-202012.0-fb89c28c9 + Next: SONiC-OS-201911.0-2bec3004e + Available: + SONiC-OS-202012.0-fb89c28c9 + SONiC-OS-201911.0-2bec3004e + ``` + +### Platform Component Firmware vendor specific behaviour + +#### Mellanox + +**CPLD update** + +On Mellanox platforms CPLD update can be done either for single or for all components at once. +The second approach is preferred. In this case an aggregated `vme` binary is used and +CPLD component can be specified arbitrary. + +- Example: +```bash +root@sonic:/home/admin# show platform firmware +Chassis Module Component Version Description +---------------------- -------- ----------- ----------------------- ---------------------------------------- +x86_64-mlnx_msn3800-r0 N/A BIOS 0ACLH004_02.02.007_9600 BIOS - Basic Input/Output System + CPLD1 CPLD000000_REV0400 CPLD - Complex Programmable Logic Device + CPLD2 CPLD000000_REV0300 CPLD - Complex Programmable Logic Device + CPLD3 CPLD000000_REV0300 CPLD - Complex Programmable Logic Device + CPLD4 CPLD000000_REV0100 CPLD - Complex Programmable Logic Device + +root@sonic:/home/admin# BURN_VME="$(pwd)/FUI000091_Burn_SN3800_CPLD000120_REV0600_CPLD000165_REV0400_CPLD000166_REV0300_CPLD000167_REV0100.vme" +root@sonic:/home/admin# REFRESH_VME="$(pwd)/FUI000091_Refresh_SN3800_CPLD000120_REV0600_CPLD000165_REV0400_CPLD000166_REV0300_CPLD000167_REV0100.vme" + +root@sonic:/home/admin# config platform firmware install chassis component CPLD1 fw -y ${BURN_VME} +root@sonic:/home/admin# config platform firmware install chassis component CPLD1 fw -y ${REFRESH_VME} + +root@sonic:/home/admin# show platform firmware +Chassis Module Component Version Description +---------------------- -------- ----------- ----------------------- ---------------------------------------- +x86_64-mlnx_msn3800-r0 N/A BIOS 0ACLH004_02.02.007_9600 BIOS - Basic Input/Output System + CPLD1 CPLD000000_REV0600 CPLD - Complex Programmable Logic Device + CPLD2 CPLD000000_REV0400 CPLD - Complex Programmable Logic Device + CPLD3 CPLD000000_REV0300 CPLD - Complex Programmable Logic Device + CPLD4 CPLD000000_REV0100 CPLD - Complex Programmable Logic Device +``` + +Note: the update will have the same effect if any of CPLD1/CPLD2/CPLD3/CPLD4 will be used + +Go Back To [Beginning of the document](#) or [Beginning of this section](#platform-component-firmware) + + +## 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** + +This command shows the SDK sniffer status + +- Usage: + ``` + show platform mlnx sniffer + ``` + +- Example: + ``` + admin@sonic:~$ show platform mlnx sniffer + sdk sniffer is disabled + ``` + +**show platform mlnx sniffer** + +Another show command available on ‘show platform mlnx’ which is the issu status. +This means if ISSU is enabled on this SKU or not. A warm boot command can be executed only when ISSU is enabled on the SKU. + +- Usage: + ``` + show platform mlnx issu + ``` + +- Example: + ``` + admin@sonic:~$ show platform mlnx issu + ISSU is enabled + ``` + +In the case ISSU is disabled and warm-boot is called, the user will get a notification message explaining that the command cannot be invoked. + +- Example: + ``` + admin@sonic:~$ sudo warm-reboot + ISSU is not enabled on this HWSKU + Warm reboot is not supported + ``` + +**config platform mlnx** + +This command is valid only on mellanox devices. The sub-commands for "config platform" gets populated only on mellanox platforms. +There are no other subcommands on non-Mellanox devices and hence this command appears empty and useless in other platforms. +The platform mellanox command currently includes a single sub command which is the SDK sniffer. +The SDK sniffer is a troubleshooting tool which records the RPC calls from the Mellanox SDK user API library to the sx_sdk task into a .pcap file. +This .pcap file can be replayed afterward to get the exact same configuration state on SDK and FW to reproduce and investigate issues. + +A new folder will be created to store the sniffer files: "/var/log/mellanox/sniffer/". The result file will be stored in a .pcap file, which includes a time stamp of the starting time in the file name, for example, "sx_sdk_sniffer_20180224081306.pcap" +In order to have a complete .pcap file with all the RPC calls, the user should disable the SDK sniffer. Swss service will be restarted and no capturing is taken place from that moment. +It is recommended to review the .pcap file while sniffing is disabled. +Once SDK sniffer is enabled/disabled, the user is requested to approve that swss service will be restarted. +For example: To change SDK sniffer status, swss service will be restarted, continue? [y/N]: +In order to avoid that confirmation the -y / --yes option should be used. + +- Usage: + ``` + config platform mlnx sniffer sdk [-y|--yes] + ``` + +- Example: + ``` + admin@sonic:~$ config platform mlnx sniffer sdk + To change SDK sniffer status, swss service will be restarted, continue? [y/N]: y + 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) + + +## PortChannels + +### PortChannel Show commands + +**show interfaces portchannel** + +This command displays all the port channels that are configured in the device and its current status. + +- Usage: + ``` + show interfaces portchannel + ``` + +- Example: + ``` + admin@sonic:~$ show interfaces portchannel + Flags: A - active, I - inactive, Up - up, Dw - Down, N/A - not available, S - selected, D - deselected + No. Team Dev Protocol Ports + ----- ------------- ----------- --------------------------- + 24 PortChannel24 LACP(A)(Up) Ethernet28(S) Ethernet24(S) + 48 PortChannel48 LACP(A)(Up) Ethernet52(S) Ethernet48(S) + 40 PortChannel40 LACP(A)(Up) Ethernet44(S) Ethernet40(S) + 0 PortChannel0 LACP(A)(Up) Ethernet0(S) Ethernet4(S) + 8 PortChannel8 LACP(A)(Up) Ethernet8(S) Ethernet12(S) + ``` + + +### PortChannel Config commands + +This sub-section explains how to configure the portchannel and its member ports. + +**config portchannel** + +This command is used to add or delete the portchannel. +It is recommended to use portchannel names in the format "PortChannelxxxx", where "xxxx" is number of 1 to 4 digits. Ex: "PortChannel0002". + +NOTE: If users specify any other name like "pc99", command will succeed, but such names are not supported. Such names are not printed properly in the "show interface portchannel" command. It is recommended not to use such names. + +When any port is already member of any other portchannel and if user tries to add the same port in some other portchannel (without deleting it from the current portchannel), the command fails internally. But, it does not print any error message. In such cases, remove the member from current portchannel and then add it to new portchannel. + +Command takes two optional arguements given below. +1) min-links - minimum number of links required to bring up the portchannel +2. fallback - true/false. LACP fallback feature can be enabled / disabled. When it is set to true, only one member port will be selected as active per portchannel during fallback mode. Refer https://github.com/Azure/SONiC/blob/master/doc/lag/LACP%20Fallback%20Feature%20for%20SONiC_v0.5.md for more details about fallback feature. + +A port channel can be deleted only if it does not have any members or the members are already deleted. When a user tries to delete a port channel and the port channel still has one or more members that exist, the deletion of port channel is blocked. + +- Usage: + ``` + config portchannel (add | del) [--min-links ] [--fallback (true | false)] + ``` + +- Example (Create the portchannel with name "PortChannel0011"): + ``` + admin@sonic:~$ sudo config portchannel add PortChannel0011 + ``` + +**config portchannel member** + +This command adds or deletes a member port to/from the already created portchannel. + +- Usage: + ``` + config portchannel member (add | del) + ``` + +- Example (Add interface Ethernet4 as member of the portchannel "PortChannel0011"): + ``` + admin@sonic:~$ sudo config portchannel member add PortChannel0011 Ethernet4 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#portchannels) + +## NVGRE + +This section explains the various show commands and configuration commands available for users. + +### NVGRE show commands + +This subsection explains how to display the NVGRE configuration. + +**show nvgre-tunnel** + +This command displays the NVGRE tunnel configuration. + +- Usage: +```bash +show nvgre-tunnel +``` + +- Example: +```bash +admin@sonic:~$ show nvgre-tunnel +TUNNEL NAME SRC IP +------------- -------- +tunnel_1 10.0.0.1 +``` + +**show nvgre-tunnel-map** + +This command displays the NVGRE tunnel map configuration. + +- Usage: +```bash +show nvgre-tunnel-map +``` + +- Example: +```bash +admin@sonic:~$ show nvgre-tunnel-map +TUNNEL NAME TUNNEL MAP NAME VLAN ID VSID +------------- ----------------- --------- ------ +tunnel_1 Vlan1000 1000 5000 +tunnel_1 Vlan2000 2000 6000 +``` + +### NVGRE config commands + +This subsection explains how to configure the NVGRE. + +**config nvgre-tunnel** + +This command is used to manage the NVGRE tunnel objects. +It supports add/delete operations. + +- Usage: +```bash +config nvgre-tunnel add --src-ip +config nvgre-tunnel delete +``` + +- Parameters: + - _tunnel-name_: the name of the NVGRE tunnel + - _src-ip_: source ip address + +- Examples: +```bash +config nvgre-tunnel add 'tunnel_1' --src-ip '10.0.0.1' +config nvgre-tunnel delete 'tunnel_1' +``` + +**config nvgre-tunnel-map** + +This command is used to manage the NVGRE tunnel map objects. +It supports add/delete operations. + +- Usage: +```bash +config nvgre-tunnel-map add --vlan-id --vsid +config nvgre-tunnel-map delete +``` + +- Parameters: + - _tunnel-name_: the name of the NVGRE tunnel + - _tunnel-map-name_: the name of the NVGRE tunnel map + - _vlan-id_: VLAN identifier + - _vsid_: Virtual Subnet Identifier + +- Examples: +```bash +config nvgre-tunnel-map add 'tunnel_1' 'Vlan2000' --vlan-id '2000' --vsid '6000' +config nvgre-tunnel-map delete 'tunnel_1' 'Vlan2000' +``` + +## Password Hardening + +### PW config commands + +**pw enable** + +Passwoed Hardening enable feature, set configuration: + +``` +root@r-panther-13:/home/admin# config passwh policies state --help +Usage: config passwh policies state [OPTIONS] STATE + + state of the feature + +Options: + -?, -h, --help Show this message and exit. +``` + +**pw classes** + +PW class is the type of characters the user is required to enter when setting/updating a PW. + +There are 4 classes. (see description in arc section) + +The user will be able to choose whether to enforce all PW class characters in the PW or only a subset of the characters. + +A CLI command will be available to the user for this configuration. Once a user has selected the class types he wants to enforce (from a pre-defined options list), this will enforce the PW selected by the user to have at least 1 character from each class in the selected option. + +The CLI classes options will be as follows: + +None - Meaning no required classes. + +lower- lowerLowercase Characters + +upper - Uppercase + +digit - Numbers + +special - Special symbols (seen in requirement chapter) + +multiple char enforcement + +There will be no enforcement of multiple characters from a specific class or a specific character (be either letter or symbol) to appear in the PW. + +The CLI command to configure the PW class type will be along the following lines: + +Set classes configuration: +``` +------------------------------------------------------------ +root@r-panther-13:/home/admin# config passwh policies lower-class --help +Usage: config passwh policies lower-class [OPTIONS] LOWER_CLASS + + password lower chars policy + +Options: + -?, -h, --help Show this message and exit. +------------------------------------------------------------ +root@r-panther-13:/home/admin# config passwh policies upper-class --help +Usage: config passwh policies upper-class [OPTIONS] UPPER_CLASS + + password upper chars policy + +Options: + -h, -?, --help Show this message and exit. +------------------------------------------------------------ +root@r-panther-13:/home/admin# config passwh policies digits-class --help +Usage: config passwh policies digits-class [OPTIONS] DIGITS_CLASS + + password digits chars policy + +Options: + -h, -?, --help Show this message and exit. +------------------------------------------------------------ +root@r-panther-13:/home/admin# config passwh policies special-class --help +Usage: config passwh policies special-class [OPTIONS] SPECIAL_CLASS + + password special chars policy + +Options: + -?, -h, --help Show this message and exit. +------------------------------------------------------------ +``` + +Note: Meaning: no must use of lower, no must use of upper, must use digit, must use special characters + +**pw length** + +Set len-min configuration: +``` +root@r-panther-13:/home/admin# config passwh policies len-min --help +Usage: config passwh policies len-min [OPTIONS] LEN_MIN + + password min length + +Options: + -?, -h, --help Show this message and exit. +``` + +Note: Where length is a number between 0 and 32. + +Once the user changed the minimum password length - the settings will be applied to the config node and will be enforced on the next pw change + +**pw age** + +* PW age expire + +Set configuration: +``` +root@r-panther-13:/home/admin# config passwh policies expiration --help +Usage: config passwh policies expiration [OPTIONS] EXPIRATION + + expiration time (days unit) + +Options: + -h, -?, --help Show this message and exit. +``` + +Notes: Where age is in days and between 1 and 365 days (default 180). +* PW Age Change Warning + +Set configuration: +``` +root@r-panther-13:/home/admin# config passwh policies expiration-warning --help +Usage: config passwh policies expiration-warning [OPTIONS] EXPIRATION_WARNING + + expiration warning time (days unit) + +Options: + -?, -h, --help Show this message and exit. +``` + +Notes: The warning_days can be configured between 1 and 30 days (default 15). + + +**pw username-match** + +Set configuration: + +``` +root@r-panther-13:/home/admin# config passwh policies username-passw-match --help +Usage: config passwh policies username-passw-match [OPTIONS] + USERNAME_PASSW_MATCH + + username password match + +Options: + -h, -?, --help Show this message and exit. +``` + +**pw saving** +Set configuration: + +``` +root@r-panther-13:/home/admin# config passwh policies history --help +Usage: config passwh policies history [OPTIONS] HISTORY + + num of old password that the system will recorded + +Options: + -h, -?, --help Show this message and exit. +``` + +### PW show commands + +**show passwh** + +Show command should be extended in order to add "passwh" alias: + +``` +root@r-panther-13:/home/admin# show passwh policies +STATE EXPIRATION EXPIRATION WARNING HISTORY LEN MAX LEN MIN USERNAME PASSW MATCH LOWER CLASS UPPER CLASS DIGITS CLASS SPECIAL CLASS +------- ------------ -------------------- --------- --------- --------- ---------------------- ------------- ------------- -------------- --------------- +enabled 30 10 4 100 30 false true true true true +``` + +## PBH + +This section explains the various show commands and configuration commands available for users. + +### PBH show commands + +This subsection explains how to display PBH configuration and statistics. + +**show pbh table** + +This command displays PBH table configuration. + +- Usage: +```bash +show pbh table +``` + +- Example: +```bash +admin@sonic:~$ show pbh table +NAME INTERFACE DESCRIPTION +--------- --------------- --------------- +pbh_table Ethernet0 NVGRE and VxLAN + Ethernet4 + PortChannel0001 + PortChannel0002 +``` + +**show pbh rule** + +This command displays PBH rule configuration. + +- Usage: +```bash +show pbh rule +``` + +- Example: +```bash +admin@sonic:~$ show pbh rule +TABLE RULE PRIORITY MATCH HASH ACTION COUNTER +--------- ------ ---------- ------------------------------------ ------------- ------------- --------- +pbh_table nvgre 2 ether_type: 0x0800 inner_v6_hash SET_ECMP_HASH DISABLED + ip_protocol: 0x2f + gre_key: 0x2500/0xffffff00 + inner_ether_type: 0x86dd +pbh_table vxlan 1 ether_type: 0x0800 inner_v4_hash SET_LAG_HASH ENABLED + ip_protocol: 0x11 + l4_dst_port: 0x12b5 + inner_ether_type: 0x0800 +``` + +**show pbh hash** + +This command displays PBH hash configuration. + +- Usage: +```bash +show pbh hash +``` + +- Example: +```bash +admin@sonic:~$ show pbh hash +NAME HASH FIELD +------------- ----------------- +inner_v4_hash inner_ip_proto + inner_l4_dst_port + inner_l4_src_port + inner_dst_ipv4 + inner_src_ipv4 +inner_v6_hash inner_ip_proto + inner_l4_dst_port + inner_l4_src_port + inner_dst_ipv6 + inner_src_ipv6 +``` + +**show pbh hash-field** + +This command displays PBH hash field configuration. + +- Usage: +```bash +show pbh hash-field +``` + +- Example: +```bash +admin@sonic:~$ show pbh hash-field +NAME FIELD MASK SEQUENCE SYMMETRIC +----------------- ----------------- --------- ---------- ----------- +inner_ip_proto INNER_IP_PROTOCOL N/A 1 No +inner_l4_dst_port INNER_L4_DST_PORT N/A 2 Yes +inner_l4_src_port INNER_L4_SRC_PORT N/A 2 Yes +inner_dst_ipv4 INNER_DST_IPV4 255.0.0.0 3 Yes +inner_src_ipv4 INNER_SRC_IPV4 0.0.0.255 3 Yes +inner_dst_ipv6 INNER_DST_IPV6 ffff:: 4 Yes +inner_src_ipv6 INNER_SRC_IPV6 ::ffff 4 Yes +``` + +- Note: + - _SYMMETRIC_ is an artificial column and is only used to indicate fields symmetry + +**show pbh statistics** + +This command displays PBH statistics. + +- Usage: +```bash +show pbh statistics +``` + +- Example: +```bash +admin@sonic:~$ show pbh statistics +TABLE RULE RX PACKETS COUNT RX BYTES COUNT +--------- ------ ------------------ ---------------- +pbh_table nvgre 0 0 +pbh_table vxlan 0 0 +``` + +- Note: + - _RX PACKETS COUNT_ and _RX BYTES COUNT_ can be cleared by user: + ```bash + admin@sonic:~$ sonic-clear pbh statistics + ``` + +### PBH config commands + +This subsection explains how to configure PBH. + +**config pbh table** + +This command is used to manage PBH table objects. +It supports add/update/remove operations. + +- Usage: +```bash +config pbh table add --interface-list --description +config pbh table update [ --interface-list ] [ --description ] +config pbh table delete +``` + +- Parameters: + - _table_name_: the name of the PBH table + - _interface_list_: interfaces to which PBH table is applied + - _description_: the description of the PBH table + +- Examples: +```bash +config pbh table add 'pbh_table' \ +--interface-list 'Ethernet0,Ethernet4,PortChannel0001,PortChannel0002' \ +--description 'NVGRE and VxLAN' +config pbh table update 'pbh_table' \ +--interface-list 'Ethernet0' +config pbh table delete 'pbh_table' +``` + +**config pbh rule** + +This command is used to manage PBH rule objects. +It supports add/update/remove operations. + +- Usage: +```bash +config pbh rule add --priority \ +[ --gre-key ] [ --ether-type ] [ --ip-protocol ] \ +[ --ipv6-next-header ] [ --l4-dst-port ] [ --inner-ether-type ] \ +--hash [ --packet-action ] [ --flow-counter ] +config pbh rule update [ --priority ] \ +[ --gre-key ] [ --ether-type ] [ --ip-protocol ] \ +[ --ipv6-next-header ] [ --l4-dst-port ] [ --inner-ether-type ] \ +[ --hash ] [ --packet-action ] [ --flow-counter ] +config pbh rule delete +``` + +- Parameters: + - _table_name_: the name of the PBH table + - _rule_name_: the name of the PBH rule + - _priority_: the priority of the PBH rule + - _gre_key_: packet match for the PBH rule: GRE key (value/mask) + - _ether_type_: packet match for the PBH rule: EtherType (IANA Ethertypes) + - _ip_protocol_: packet match for the PBH rule: IP protocol (IANA Protocol Numbers) + - _ipv6_next_header_: packet match for the PBH rule: IPv6 Next header (IANA Protocol Numbers) + - _l4_dst_port_: packet match for the PBH rule: L4 destination port + - _inner_ether_type_: packet match for the PBH rule: inner EtherType (IANA Ethertypes) + - _hash_: _hash_ object to apply with the PBH rule + - _packet_action_: packet action for the PBH rule + + Valid values: + - SET_ECMP_HASH + - SET_LAG_HASH + + Default: + - SET_ECMP_HASH + + - _flow_counter_: packet/byte counter for the PBH rule + + Valid values: + - DISABLED + - ENABLED + + Default: + - DISABLED + +- Examples: +```bash +config pbh rule add 'pbh_table' 'nvgre' \ +--priority '2' \ +--ether-type '0x0800' \ +--ip-protocol '0x2f' \ +--gre-key '0x2500/0xffffff00' \ +--inner-ether-type '0x86dd' \ +--hash 'inner_v6_hash' \ +--packet-action 'SET_ECMP_HASH' \ +--flow-counter 'DISABLED' +config pbh rule update 'pbh_table' 'nvgre' \ +--flow-counter 'ENABLED' +config pbh rule delete 'pbh_table' 'nvgre' +``` + +**config pbh hash** + +This command is used to manage PBH hash objects. +It supports add/update/remove operations. + +- Usage: +```bash +config pbh hash add --hash-field-list +config pbh hash update [ --hash-field-list ] +config pbh hash delete +``` + +- Parameters: + - _hash_name_: the name of the PBH hash + - _hash_field_list_: list of _hash-field_ objects to apply with the PBH hash + +- Examples: +```bash +config pbh hash add 'inner_v6_hash' \ +--hash-field-list 'inner_ip_proto,inner_l4_dst_port,inner_l4_src_port,inner_dst_ipv6,inner_src_ipv6' +config pbh hash update 'inner_v6_hash' \ +--hash-field-list 'inner_ip_proto' +config pbh hash delete 'inner_v6_hash' +``` + +**config pbh hash-field** + +This command is used to manage PBH hash field objects. +It supports add/update/remove operations. + +- Usage: +```bash +config pbh hash-field add \ +--hash-field [ --ip-mask ] --sequence-id +config pbh hash-field update \ +[ --hash-field ] [ --ip-mask ] [ --sequence-id ] +config pbh hash-field delete +``` + +- Parameters: + - _hash_field_name_: the name of the PBH hash field + - _hash_field_: native hash field for the PBH hash field + + Valid values: + - INNER_IP_PROTOCOL + - INNER_L4_DST_PORT + - INNER_L4_SRC_PORT + - INNER_DST_IPV4 + - INNER_SRC_IPV4 + - INNER_DST_IPV6 + - INNER_SRC_IPV6 + + - _ip_mask_: IPv4/IPv6 address mask for the PBH hash field + + Valid only: _hash_field_ is: + - INNER_DST_IPV4 + - INNER_SRC_IPV4 + - INNER_DST_IPV6 + - INNER_SRC_IPV6 + + - _sequence_id_: the order in which fields are hashed + +- Examples: +```bash +config pbh hash-field add 'inner_dst_ipv6' \ +--hash-field 'INNER_DST_IPV6' \ +--ip-mask 'ffff::' \ +--sequence-id '4' +config pbh hash-field update 'inner_dst_ipv6' \ +--ip-mask 'ffff:ffff::' +config pbh hash-field delete 'inner_dst_ipv6' +``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#pbh) + +## QoS + +### QoS Show commands + +#### PFC + +**show pfc counters** + +This command displays the details of Rx & Tx priority-flow-control (pfc) for all ports. This command can be used to clear the counters using -c option. + +- Usage: + ``` + show pfc counters + ``` + +- Example: + ``` + admin@sonic:~$ show pfc counters + Port Rx PFC0 PFC1 PFC2 PFC3 PFC4 PFC5 PFC6 PFC7 + ----------- ------ ------ ------ ------ ------ ------ ------ ------ + Ethernet0 0 0 0 0 0 0 0 0 + Ethernet4 0 0 0 0 0 0 0 0 + Ethernet8 0 0 0 0 0 0 0 0 + Ethernet12 0 0 0 0 0 0 0 0 + + Port Tx PFC0 PFC1 PFC2 PFC3 PFC4 PFC5 PFC6 PFC7 + ----------- ------ ------ ------ ------ ------ ------ ------ ------ + Ethernet0 0 0 0 0 0 0 0 0 + Ethernet4 0 0 0 0 0 0 0 0 + Ethernet8 0 0 0 0 0 0 0 0 + Ethernet12 0 0 0 0 0 0 0 0 + + ... + ``` + + +- NOTE: PFC counters can be cleared by the user with the following command: + ``` + admin@sonic:~$ sonic-clear pfccounters + ``` + +**show pfc asymmetric** + +This command displays the status of asymmetric PFC for all interfaces or a given interface. + +- Usage: + ``` + show pfc asymmetric [] + ``` + +- Example: + ``` + admin@sonic:~$ show pfc asymmetric + + Interface Asymmetric + ----------- ------------ + Ethernet0 off + Ethernet2 off + Ethernet4 off + Ethernet6 off + Ethernet8 off + Ethernet10 off + Ethernet12 off + Ethernet14 off + + admin@sonic:~$ show pfc asymmetric Ethernet0 + + Interface Asymmetric + ----------- ------------ + Ethernet0 off + ``` + +**show pfc priority** + +This command displays the lossless priorities for all interfaces or a given interface. + +- Usage: + ``` + show pfc priority [] + ``` + +- Example: + ``` + admin@sonic:~$ show pfc priority + + Interface Lossless priorities + ----------- --------------------- + Ethernet0 3,4 + Ethernet2 3,4 + Ethernet8 3,4 + Ethernet10 3,4 + Ethernet16 3,4 + + admin@sonic:~$ show pfc priority Ethernet0 + + Interface Lossless priorities + ----------- --------------------- + Ethernet0 3,4 + ``` + +#### Queue And Priority-Group + +This sub-section explains the following queue parameters that can be displayed using "show queue" command. +1) queue counters +2) queue watermark +3) priority-group watermark +4) queue persistent-watermark + + +**show queue counters** + +This command displays packet and byte counters for all queues of all ports or one specific-port given as arguement. +This command can be used to clear the counters for all queues of all ports. Note that port specific clear is not supported. + +- Usage: + ``` + show queue counters [] + ``` + +- Example: + ``` + admin@sonic:~$ show queue counters + Port TxQ Counter/pkts Counter/bytes Drop/pkts Drop/bytes + --------- ----- -------------- --------------- ----------- ------------ + Ethernet0 UC0 0 0 0 0 + Ethernet0 UC1 0 0 0 0 + Ethernet0 UC2 0 0 0 0 + Ethernet0 UC3 0 0 0 0 + Ethernet0 UC4 0 0 0 0 + Ethernet0 UC5 0 0 0 0 + Ethernet0 UC6 0 0 0 0 + Ethernet0 UC7 0 0 0 0 + Ethernet0 UC8 0 0 0 0 + Ethernet0 UC9 0 0 0 0 + Ethernet0 MC0 0 0 0 0 + Ethernet0 MC1 0 0 0 0 + Ethernet0 MC2 0 0 0 0 + Ethernet0 MC3 0 0 0 0 + Ethernet0 MC4 0 0 0 0 + Ethernet0 MC5 0 0 0 0 + Ethernet0 MC6 0 0 0 0 + Ethernet0 MC7 0 0 0 0 + Ethernet0 MC8 0 0 0 0 + Ethernet0 MC9 0 0 0 0 + + Port TxQ Counter/pkts Counter/bytes Drop/pkts Drop/bytes + --------- ----- -------------- --------------- ----------- ------------ + Ethernet4 UC0 0 0 0 0 + Ethernet4 UC1 0 0 0 0 + Ethernet4 UC2 0 0 0 0 + Ethernet4 UC3 0 0 0 0 + Ethernet4 UC4 0 0 0 0 + Ethernet4 UC5 0 0 0 0 + Ethernet4 UC6 0 0 0 0 + Ethernet4 UC7 0 0 0 0 + Ethernet4 UC8 0 0 0 0 + Ethernet4 UC9 0 0 0 0 + Ethernet4 MC0 0 0 0 0 + Ethernet4 MC1 0 0 0 0 + Ethernet4 MC2 0 0 0 0 + Ethernet4 MC3 0 0 0 0 + Ethernet4 MC4 0 0 0 0 + Ethernet4 MC5 0 0 0 0 + Ethernet4 MC6 0 0 0 0 + Ethernet4 MC7 0 0 0 0 + Ethernet4 MC8 0 0 0 0 + Ethernet4 MC9 0 0 0 0 + + ... + ``` + +Optionally, you can specify an interface name in order to display only that particular interface + +- Example: + ``` + admin@sonic:~$ show queue counters Ethernet72 + ``` + +- NOTE: Queue counters can be cleared by the user with the following command: + ``` + admin@sonic:~$ sonic-clear queuecounters + ``` + +**show queue watermark** + +This command displays the user watermark for the queues (Egress shared pool occupancy per queue) for either the unicast queues or multicast queues for all ports + +- Usage: + ``` + show queue watermark (multicast | unicast) + ``` + +- Example: + ``` + admin@sonic:~$ show queue watermark unicast + Egress shared pool occupancy per unicast queue: + Port UC0 UC1 UC2 UC3 UC4 UC5 UC6 UC7 + ----------- ----- ----- ----- ----- ----- ----- ----- ----- + Ethernet0 0 0 0 0 0 0 0 0 + Ethernet4 0 0 0 0 0 0 0 0 + Ethernet8 0 0 0 0 0 0 0 0 + Ethernet12 0 0 0 0 0 0 0 0 + + admin@sonic:~$ show queue watermark multicast (Egress shared pool occupancy per multicast queue) + ``` + +**show priority-group** + +This command displays: +1) The user watermark or persistent-watermark for the Ingress "headroom" or "shared pool occupancy" per priority-group for all ports. +2) Dropped packets per priority-group for all ports + +- Usage: + ``` + show priority-group (watermark | persistent-watermark) (headroom | shared) + show priority-group drop counters + ``` + +- Example: + ``` + admin@sonic:~$ show priority-group watermark shared + Ingress shared pool occupancy per PG: + Port PG0 PG1 PG2 PG3 PG4 PG5 PG6 PG7 + ----------- ----- ----- ----- ----- ----- ----- ----- ----- + Ethernet0 0 0 0 0 0 0 0 0 + Ethernet4 0 0 0 0 0 0 0 0 + Ethernet8 0 0 0 0 0 0 0 0 + Ethernet12 0 0 0 0 0 0 0 0 + ``` + +- Example (Ingress headroom per PG): + ``` + admin@sonic:~$ show priority-group watermark headroom + ``` + +- Example (Ingress shared pool occupancy per PG): + ``` + admin@sonic:~$ show priority-group persistent-watermark shared + ``` + +- Example (Ingress headroom per PG): + ``` + admin@sonic:~$ show priority-group persistent-watermark headroom + ``` + +- Example (Ingress dropped packets per PG): + ``` + admin@sonic:~$ show priority-group drop counters + Ingress PG dropped packets: + Port PG0 PG1 PG2 PG3 PG4 PG5 PG6 PG7 + ----------- ----- ----- ----- ----- ----- ----- ----- ----- + Ethernet0 0 0 0 0 0 0 0 0 + Ethernet4 0 0 0 0 0 0 0 0 + Ethernet8 0 0 0 0 0 0 0 0 + Ethernet12 0 0 0 0 0 0 0 0 + ``` + +In addition to user watermark("show queue|priority-group watermark ..."), a persistent watermark is available. +It hold values independently of user watermark. This way user can use "user watermark" for debugging, clear it, etc, but the "persistent watermark" will not be affected. + +**show queue persistent-watermark** + +This command displays the user persistet-watermark for the queues (Egress shared pool occupancy per queue) for either the unicast queues or multicast queues for all ports + +- Usage: + ``` + show queue persistent-watermark (unicast | multicast) + ``` + +- Example: + ``` + admin@sonic:~$ show queue persistent-watermark unicast + Egress shared pool occupancy per unicast queue: + Port UC0 UC1 UC2 UC3 UC4 UC5 UC6 UC7 + ----------- ----- ----- ----- ----- ----- ----- ----- ----- + Ethernet0 N/A N/A N/A N/A N/A N/A N/A N/A + Ethernet4 N/A N/A N/A N/A N/A N/A N/A N/A + Ethernet8 N/A N/A N/A N/A N/A N/A N/A N/A + Ethernet12 N/A N/A N/A N/A N/A N/A N/A N/A + ``` + +- Example (Egress shared pool occupancy per multicast queue): + ``` + admin@sonic:~$ show queue persistent-watermark multicast + ``` + +- NOTE: "user watermark", "persistent watermark" and "ingress dropped packets" can be cleared by user: + + ``` + admin@sonic:~$ sonic-clear queue persistent-watermark unicast + + admin@sonic:~$ sonic-clear queue persistent-watermark multicast + + admin@sonic:~$ sonic-clear priority-group persistent-watermark shared + + admin@sonic:~$ sonic-clear priority-group persistent-watermark headroom + + admin@sonic:~$ sonic-clear priority-group drop counters + ``` + +#### Buffer Pool + +This sub-section explains the following buffer pool parameters that can be displayed using "show buffer_pool" command. +1) buffer pool watermark +2) buffer pool persistent-watermark + +**show buffer_pool watermark** + +This command displays the user watermark for all the buffer pools + +- Usage: + ``` + show buffer_pool watermark + ``` + +- Example: + ``` + admin@sonic:~$ show buffer_pool watermark + Shared pool maximum occupancy: + Pool Bytes + --------------------- ------- + ingress_lossless_pool 0 + lossy_pool 2464 + ``` + + +**show buffer_pool persistent-watermark** + +This command displays the user persistent-watermark for all the buffer pools + +- Usage: + ``` + show buffer_pool persistent-watermark + ``` + +- Example: + ``` + admin@sonic:~$ show buffer_pool persistent-watermark + Shared pool maximum occupancy: + Pool Bytes + --------------------- ------- + ingress_lossless_pool 0 + lossy_pool 2464 + ``` + + + +### QoS config commands + +**config qos clear** + +This command is used to clear all the QoS configuration from all the following QOS Tables in ConfigDB. + +1) TC_TO_PRIORITY_GROUP_MAP, +2) MAP_PFC_PRIORITY_TO_QUEUE, +3) TC_TO_QUEUE_MAP, +4) DSCP_TO_TC_MAP, +5) MPLS_TC_TO_TC_MAP, +6) SCHEDULER, +7) PFC_PRIORITY_TO_PRIORITY_GROUP_MAP, +8) PORT_QOS_MAP, +9) WRED_PROFILE, +10) QUEUE, +11) CABLE_LENGTH, +12) BUFFER_POOL, +13) BUFFER_PROFILE, +14) BUFFER_PG, +15) BUFFER_QUEUE + +- Usage: + ``` + config qos clear + ``` + +- Example: + ``` + admin@sonic:~$ sudo config qos clear + ``` + +**config qos reload** + +This command is used to reload the QoS configuration. +QoS configuration has got two sets of configurations. +1) Generic QOS Configuration - This gives complete list of all possible QOS configuration. Its given in the file /usr/share/sonic/templates/qos_config.j2 in the device. + Reference: https://github.com/Azure/sonic-buildimage/blob/master/files/build_templates/qos_config.j2 + Users have flexibility to have platform specific qos configuration by placing the qos_config.j2 file at /usr/share/sonic/device///. + If users want to modify any of this loaded QOS configuration, they can modify this file in the device and then issue the "config qos reload" command. + +2) Platform specific buffer configuration. Every platform has got platform specific and topology specific (T0 or T1 or T2) buffer configuration at /usr/share/sonic/device///buffers_defaults_tx.j2 + In addition to platform specific configuration file, a generic configuration file is also present at /usr/share/sonic/templates/buffers_config.j2. + Reference: https://github.com/Azure/sonic-buildimage/blob/master/files/build_templates/buffers_config.j2 + Users can either modify the platform specific configuration file, or the generic configuration file and then issue this "config qos reload" command. + +These configuration files are already loaded in the device as part of the reboot process. In case if users wants to modify any of these configurations, they need to modify the appropriate QOS tables and fields in these files and then use this reload command. +This command uses those modified buffers.json.j2 file & qos.json.j2 file and reloads the new QOS configuration. +If users have not made any changes in these configuration files, this command need not be executed. + +Some of the example QOS configurations that users can modify are given below. +1) TC_TO_PRIORITY_GROUP_MAP +2) MAP_PFC_PRIORITY_TO_QUEUE +3) TC_TO_QUEUE_MAP +4) DSCP_TO_TC_MAP +5) MPLS_TC_TO_TC_MAP +6) SCHEDULER +7) PFC_PRIORITY_TO_PRIORITY_GROUP_MAP +8) PORT_QOS_MAP +9) WRED_PROFILE +10) CABLE_LENGTH +11) BUFFER_QUEUE + +- Usage: + ``` + config qos reload + ``` + +- Example: + ``` + admin@sonic:~$ sudo config qos reload + Running command: /usr/local/bin/sonic-cfggen -d -t /usr/share/sonic/device/x86_64-dell_z9100_c2538-r0/Force10-Z9100-C32/buffers.json.j2 >/tmp/buffers.json + Running command: /usr/local/bin/sonic-cfggen -d -t /usr/share/sonic/device/x86_64-dell_z9100_c2538-r0/Force10-Z9100-C32/qos.json.j2 -y /etc/sonic/sonic_version.yml >/tmp/qos.json + Running command: /usr/local/bin/sonic-cfggen -j /tmp/buffers.json --write-to-db + Running command: /usr/local/bin/sonic-cfggen -j /tmp/qos.json --write-to-db + + In this example, it uses the buffers.json.j2 file and qos.json.j2 file from platform specific folders. + When there are no changes in the platform specific configutation files, they internally use the file "/usr/share/sonic/templates/buffers_config.j2" and "/usr/share/sonic/templates/qos_config.j2" to generate the configuration. + ``` + +**config qos reload --ports port_list** + +This command is used to reload the default QoS configuration on a group of ports. +Typically, the default QoS configuration is in the following tables. +1) PORT_QOS_MAP +2) QUEUE +3) BUFFER_PG +4) BUFFER_QUEUE +5) BUFFER_PORT_INGRESS_PROFILE_LIST +6) BUFFER_PORT_EGRESS_PROFILE_LIST +7) CABLE_LENGTH + +If there was QoS configuration in the above tables for the ports: + + - if `--force` option is provied, the existing QoS configuration will be replaced by the default QoS configuration, + - otherwise, the command will exit with nothing updated. + +- Usage: + ``` + config qos reload --ports [,port] + ``` + +- Example: + ``` + admin@sonic:~$ sudo config qos reload --ports Ethernet0,Ethernet4 + + In this example, it updates the QoS configuration on port Ethernet0 and Ethernet4 to default. + If there was QoS configuration on the ports, the command will clear the existing QoS configuration on the port and reload to default. + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#qos) + +## Radius + +### show radius commands + +This command displays the global radius configuration that includes the auth_type, retransmit, timeout and passkey. + +- Usage: + ``` + show radius + ``` +- Example: + + ``` + admin@sonic:~$ show radius + RADIUS global auth_type pap (default) + RADIUS global retransmit 3 (default) + RADIUS global timeout 5 (default) + RADIUS global passkey (default) + + ``` + +### Radius config commands + +This command is to config the radius server for various parameter listed. + + - Usage: + ``` + config radius + ``` +- Example: + ``` + admin@sonic:~$ config radius + + add Specify a RADIUS server + authtype Specify RADIUS server global auth_type [chap | pap | mschapv2] + default set its default configuration + delete Delete a RADIUS server + nasip Specify RADIUS server global NAS-IP|IPV6-Address + passkey Specify RADIUS server global passkey + retransmit Specify RADIUS server global retry attempts <0 - 10> + sourceip Specify RADIUS server global source ip + statistics Specify RADIUS server global statistics [enable | disable |... + timeout Specify RADIUS server global timeout <1 - 60> + + ``` + +## sFlow + +### sFlow Show commands + +**show sflow** + +This command displays the global sFlow configuration that includes the admin state, collectors, the Agent ID and counter polling interval. + +- Usage: + ``` + show sflow + ``` + +- Example: + ``` + admin@sonic:~# show sflow + sFlow Global Information: + sFlow Admin State: up + sFlow Polling Interval: default + sFlow AgentID: lo + + 2 Collectors configured: + Name: collector_A IP addr: 10.11.46.2 UDP port: 6343 + Name: collector_lo IP addr: 127.0.0.1 UDP port: 6343 + ``` + + +**show sflow interface** + +This command displays the per-interface sflow admin status and the sampling rate. + +- Usage: + ``` + show sflow interface + ``` + +- Example: + ``` + admin@sonic:~# show sflow interface + + sFlow interface configurations + +-------------+---------------+-----------------+ + | Interface | Admin State | Sampling Rate | + +=============+===============+=================+ + | Ethernet0 | up | 4000 | + +-------------+---------------+-----------------+ + | Ethernet1 | up | 4000 | + +-------------+---------------+-----------------+ + ... + +-------------+---------------+-----------------+ + | Ethernet61 | up | 4000 | + +-------------+---------------+-----------------+ + | Ethernet62 | up | 4000 | + +-------------+---------------+-----------------+ + | Ethernet63 | up | 4000 | + +-------------+---------------+-----------------+ + + ``` + +### sFlow Config commands + +**config sflow collector add** + +This command is used to add a sFlow collector. Note that a maximum of 2 collectors is allowed. + +- Usage: + ``` + config sflow collector add [port ] + ``` + + - Parameters: + - collector-name: unique name of the sFlow collector + - ipv4-address : IP address of the collector in dotted decimal format for IPv4 + - ipv6-address : x: x: x: x::x format for IPv6 address of the collector (where :: notation specifies successive hexadecimal fields of zeros) + - port (OPTIONAL): specifies the UDP port of the collector (the range is from 0 to 65535. The default is 6343.) + +- Example: + ``` + admin@sonic:~# sudo config sflow collector add collector_A 10.11.46.2 + ``` + +**config sflow collector del** + +This command is used to delete a sFlow collector with the given name. + +- Usage: + ``` + config sflow collector del + ``` + + - Parameters: + - collector-name: unique name of the sFlow collector + +- Example: + ``` + admin@sonic:~# sudo config sflow collector del collector_A + ``` + +**config sflow agent-id** + +This command is used to add/delete the sFlow agent-id. This setting is global (applicable to both collectors) and optional. Only a single agent-id is allowed. If agent-id is not specified (with this CLI), an appropriate IP that belongs to the switch is used as the agent-id based on some simple heuristics. + +- Usage: + ``` + config sflow agent-id + ``` + + - Parameters: + - interface-name: specify the interface name whose ipv4 or ipv6 address will be used as the agent-id in sFlow datagrams. + +- Example: + ``` + admin@sonic:~# sudo config sflow agent-id add lo + ``` + +**config sflow** + +Globally, sFlow is disabled by default. When sFlow is enabled globally, the sflow deamon is started and sampling will start on all interfaces which have sFlow enabled at the interface level (see “config sflow interface…”). When sflow is disabled globally, sampling is stopped on all relevant interfaces and sflow daemon is stopped. + +- Usage: + ``` + config sflow + ``` +- Example: + ``` + admin@sonic:~# sudo config sflow enable + ``` +**config sflow interface** + +Enable/disable sflow at an interface level. By default, sflow is enabled on all interfaces at the interface level. Use this command to explicitly disable sFlow for a specific interface. An interface is sampled if sflow is enabled globally as well as at the interface level. Note that this configuration deals only with sFlow flow samples and not counter samples. + +- Usage: + ``` + config sflow interface + ``` + + - Parameters: + - interface-name: specify the interface for which sFlow flow samples have to be enabled/disabled. The “all” keyword is used as a convenience to enable/disable sflow at the interface level for all the interfaces. + +- Example: + ``` + admin@sonic:~# sudo config sflow interface disable Ethernet40 + ``` + +**config sflow interface sample-rate** + +Configure the sample-rate for a specific interface. + +The default sample rate for any interface is (ifSpeed / 1e6) where ifSpeed is in bits/sec. So, the default sample rate based on interface speed is: + + 1-in-1000 for a 1G link + 1-in-10,000 for a 10G link + 1-in-40,000 for a 40G link + 1-in-50,000 for a 50G link + 1-in-100,000 for a 100G link + +It is recommended not to change the defaults. This CLI is to be used only in case of exceptions (e.g., to set the sample-rate to the nearest power-of-2 if there are hardware restrictions in using the defaults) + +- Usage: + ``` + config sflow interface sample-rate + ``` + + - Parameters: + - interface-name: specify the interface for which the sampling rate value is to be set + - value: value is the average number of packets skipped before the sample is taken. "The sampling rate specifies random sampling probability as the ratio of packets observed to samples generated. For example a sampling rate of 256 specifies that, on average, 1 sample will be generated for every 256 packets observed." Valid range 256:8388608. + +- Example: + ``` + admin@sonic:~# sudo config sflow interface sample-rate Ethernet32 1000 + ``` +**config sflow polling-interval** + +This command is used to set the counter polling interval. Default is 20 seconds. + +- Usage: + ``` + config sflow polling-interval + ``` + + - Parameters: + - value: 0-300 seconds. Set polling-interval to 0 to disable counter polling + +- Example: + ``` + admin@sonic:~# sudo config sflow polling-interval 30 + ``` + + +Go Back To [Beginning of the document](#) or [Beginning of this section](#sflow) + +## SNMP + +### SNMP Show commands + +**show runningconfiguration snmp** + +This command displays the global SNMP configuration that includes the location, contact, community, and user settings. + +- Usage: + ``` + show runningconfiguration snmp + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration snmp + Location + ------------ + Emerald City + + + SNMP_CONTACT SNMP_CONTACT_EMAIL + -------------- -------------------- + joe joe@contoso.com + + + Community String Community Type + ------------------ ---------------- + Jack RW + + + User Permission Type Type Auth Type Auth Password Encryption Type Encryption Password + ------ ----------------- ------ ----------- --------------- ----------------- --------------------- + Travis RO Priv SHA TravisAuthPass AES TravisEncryptPass + ``` + +**show runningconfiguration snmp location** + +This command displays the SNMP location setting. + +- Usage: + ``` + show runningconfiguration snmp location + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration snmp location + Location + ------------ + Emerald City + ``` + +- Usage: + ``` + show runningconfiguration snmp location --json + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration snmp location --json + {'Location': 'Emerald City'} + ``` + +**show runningconfiguration snmp contact** + +This command displays the SNMP contact setting. + +- Usage: + ``` + show runningconfiguration snmp contact + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration snmp contact + Contact Contact Email + --------- --------------- + joe joe@contoso.com + ``` + +- Usage: + ``` + show runningconfiguration snmp contact --json + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration snmp contact --json + {'joe': 'joe@contoso.com'} + ``` + +**show runningconfiguration snmp community** + +This command display the SNMP community settings. + +- Usage: + ``` + show runningconfiguration snmp community + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration snmp community + Community String Community Type + ------------------ ---------------- + Jack RW + ``` + +- Usage: + ``` + show runningconfiguration snmp community --json + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration snmp community --json + {'Jack': {'TYPE': 'RW'}} + ``` + +**show runningconfiguration snmp user** + +This command display the SNMP user settings. + +- Usage: + ``` + show runningconfiguration snmp user + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration snmp user + User Permission Type Type Auth Type Auth Password Encryption Type Encryption Password + ------ ----------------- ------ ----------- --------------- ----------------- --------------------- + Travis RO Priv SHA TravisAuthPass AES TravisEncryptPass + ``` + +- Usage: + ``` + show runningconfiguration snmp user --json + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration snmp user --json + {'Travis': {'SNMP_USER_TYPE': 'Priv', 'SNMP_USER_PERMISSION': 'RO', 'SNMP_USER_AUTH_TYPE': 'SHA', 'SNMP_USER_AUTH_PASSWORD': 'TravisAuthPass', 'SNMP_USER_ENCRYPTION_TYPE': 'AES', 'SNMP_USER_ENCRYPTION_PASSWORD': 'TravisEncryptPass'}} + ``` + + +### SNMP Config commands + +This sub-section explains how to configure SNMP. + +**config snmp location add/del/modify** + +This command is used to add, delete, or modify the SNMP location. + +- Usage: + ``` + config snmp location (add | del | modify) + ``` + +- Example (Add new SNMP location "Emerald City" if it does not already exist): + ``` + admin@sonic:~$ sudo config snmp location add Emerald City + SNMP Location Emerald City has been added to configuration + Restarting SNMP service... + ``` + +- Example (Delete SNMP location "Emerald City" if it already exists): + ``` + admin@sonic:~$ sudo config snmp location del Emerald City + SNMP Location Emerald City removed from configuration + Restarting SNMP service... + ``` + +- Example (Modify SNMP location "Emerald City" to "Redmond"): + ``` + admin@sonic:~$ sudo config snmp location modify Redmond + SNMP location Redmond modified in configuration + Restarting SNMP service... + ``` + +**config snmp contact add/del/modify** + +This command is used to add, delete, or modify the SNMP contact. + +- Usage: + ``` + config snmp contact add + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmp contact add joe joe@contoso.com + Contact name joe and contact email joe@contoso.com have been added to configuration + Restarting SNMP service... + ``` + +- Usage: + ``` + config snmp contact del + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmp contact del joe + SNMP contact joe removed from configuration + Restarting SNMP service... + ``` + +- Usage: + ``` + config snmp contact modify + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmp contact modify test test@contoso.com + SNMP contact test and contact email test@contoso.com updated + Restarting SNMP service... + ``` + +**config snmp community add/del/replace** + +This command is used to add, delete, or replace the SNMP community. + +- Usage: + ``` + config snmp community add (RO | RW) + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmp community add testcomm ro + SNMP community testcomm added to configuration + Restarting SNMP service... + ``` + +- Usage: + ``` + config snmp community del + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmp community del testcomm + SNMP community testcomm removed from configuration + Restarting SNMP service... + ``` + +- Usage: + ``` + config snmp community replace + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmp community replace testcomm newtestcomm + SNMP community newtestcomm added to configuration + SNMP community newtestcomm replace community testcomm + Restarting SNMP service... + ``` + +**config snmp user add/del** + +This command is used to add or delete the SNMP user for SNMPv3. + +- Usage: + ``` + config snmp user add (noAuthNoPriv | AuthNoPriv | Priv) (RO | RW) [[(MD5 | SHA | MMAC-SHA-2) ] [(DES |AES) ]] + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmp user add testuser1 noauthnopriv ro + SNMP user testuser1 added to configuration + Restarting SNMP service... + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmp user add testuser2 authnopriv ro sha testuser2_auth_pass + SNMP user testuser2 added to configuration + Restarting SNMP service... + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmp user add testuser3 priv rw md5 testuser3_auth_pass aes testuser3_encrypt_pass + SNMP user testuser3 added to configuration + Restarting SNMP service... + ``` + +- Usage: + ``` + config snmp user del + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmp user del testuser1 + SNMP user testuser1 removed from configuration + Restarting SNMP service... + ``` + +## Startup & Running Configuration + +### Startup Configuration + +**show startupconfiguration bgp** + +This command is used to display the startup configuration for the BGP module. + +- Usage: + ``` + show startupconfiguration bgp + ``` + +- Example: + ``` + admin@sonic:~$ show startupconfiguration bgp + Routing-Stack is: quagga + ! + ! =========== Managed by sonic-cfggen DO NOT edit manually! ==================== + ! generated by templates/quagga/bgpd.conf.j2 with config DB data + ! file: bgpd.conf + ! + ! + hostname T1-2 + password zebra + log syslog informational + log facility local4 + ! enable password ! + ! + ! bgp multiple-instance + ! + route-map FROM_BGP_SPEAKER_V4 permit 10 + ! + route-map TO_BGP_SPEAKER_V4 deny 10 + ! + router bgp 65000 + bgp log-neighbor-changes + bgp bestpath as-path multipath-relax + no bgp default ipv4-unicast + bgp graceful-restart restart-time 180 + + + ``` + +### Running Configuration +This sub-section explains the show commands for displaying the running configuration for the following modules. +1) bgp +2) interfaces +3) ntp +4) snmp +5) all +6) acl +7) ports +8) syslog + +**show runningconfiguration all** + +This command displays the entire running configuration. + +- Usage: + ``` + show runningconfiguration all + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration all + ``` + +**show runningconfiguration bgp** + +This command displays the running configuration of the BGP module. + +- Usage: + ``` + show runningconfiguration bgp + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration bgp + ``` + +**show runningconfiguration interfaces** + +This command displays the running configuration for the "interfaces". + +- Usage: + ``` + show runningconfiguration interfaces + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration interfaces + ``` + +**show runningconfiguration ntp** + +This command displays the running configuration of the ntp module. + +- Usage: + ``` + show runningconfiguration ntp + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration ntp + NTP Servers + ------------- + 1.1.1.1 + 2.2.2.2 + ``` + +**show runningconfiguration syslog** + +This command displays the running configuration of the syslog module. + +- Usage: + ``` + show runningconfiguration syslog + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration syslog + Syslog Servers + ---------------- + 4.4.4.4 + 5.5.5.5 + ``` + + +**show runningconfiguration snmp** + +This command displays the running configuration of the snmp module. + +- Usage: + ``` + show runningconfiguration snmp + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration snmp + ``` + +**show runningconfiguration acl** + + This command displays the running configuration of the acls + +- Usage: + ``` + show runningconfiguration acl + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration acl + ``` + + **show runningconfiguration ports** + + This command displays the running configuration of the ports + +- Usage: + ``` + show runningconfiguration ports [] + ``` + +- Examples: + ``` + admin@sonic:~$ show runningconfiguration ports + ``` + + ``` + admin@sonic:~$ show runningconfiguration ports Ethernet0 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#Startup--Running-Configuration) + + +## Static routing + +### Static routing Config Commands + +This sub-section explains of commands is used to add or remove the static route. + +**config route add** + +This command is used to add a static route. Note that prefix /nexthop vrf`s and interface name are optional. + +- Usage: + + ``` + config route add prefix [vrf ] nexthop [vrf ] dev + ``` + +- Example: + + ``` + admin@sonic:~$ config route add prefix 2.2.3.4/32 nexthop 30.0.0.9 + admin@sonic:~$ config route add prefix 4.0.0.0/24 nexthop dev Ethernet32.10 + ``` + +It also supports ECMP, and adding a new nexthop to the existing prefix will complement it and not overwrite them. + +- Example: + + ``` + admin@sonic:~$ sudo config route add prefix 2.2.3.4/32 nexthop vrf Vrf-RED 30.0.0.9 + admin@sonic:~$ sudo config route add prefix 2.2.3.4/32 nexthop vrf Vrf-BLUE 30.0.0.10 + ``` + +**config route del** + +This command is used to remove a static route. Note that prefix /nexthop vrf`s and interface name are optional. + +- Usage: + + ``` + config route del prefix [vrf ] nexthop [vrf ] dev + ``` + +- Example: + + ``` + admin@sonic:~$ sudo config route del prefix 2.2.3.4/32 nexthop vrf Vrf-RED 30.0.0.9 + admin@sonic:~$ sudo config route del prefix 2.2.3.4/32 nexthop vrf Vrf-BLUE 30.0.0.10 + ``` + +This sub-section explains of command is used to show current routes. + +**show ip route** + +- Usage: + + ``` + show ip route + ``` + +- Example: + + ``` + admin@sonic:~$ show ip route + Codes: K - kernel route, C - connected, S - static, R - RIP, + O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, + T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, + F - PBR, f - OpenFabric, + > - selected route, * - FIB route, q - queued, r - rejected, b - backup + + S>* 0.0.0.0/0 [200/0] via 192.168.111.3, eth0, weight 1, 3d03h58m + S> 1.2.3.4/32 [1/0] via 30.0.0.7, weight 1, 00:00:06 + C>* 10.0.0.18/31 is directly connected, Ethernet36, 3d03h57m + C>* 10.0.0.20/31 is directly connected, Ethernet40, 3d03h57m + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#static-routing) + +## Subinterfaces + +### Subinterfaces Show Commands + +**show subinterfaces status** + +This command displays all the subinterfaces that are configured on the device and its current status. + +- Usage: +``` +show subinterfaces status +``` + +- Example: +``` +admin@sonic:~$ show subinterfaces status +Sub port interface Speed MTU Vlan Admin Type +------------------ ------- ----- ------ ------- ------------------- + Eth64.10 100G 9100 100 up dot1q-encapsulation + Ethernet0.100 100G 9100 100 up dot1q-encapsulation +``` + +### Subinterfaces Config Commands + +This sub-section explains how to configure subinterfaces. + +**config subinterface** + +- Usage: +``` +config subinterface (add | del) [vlan <1-4094>] +``` + +- Example (Create the subinterfces with name "Ethernet0.100"): +``` +admin@sonic:~$ sudo config subinterface add Ethernet0.100 +``` + +- Example (Create the subinterfces with name "Eth64.100"): +``` +admin@sonic:~$ sudo config subinterface add Eth64.100 100 +``` + +- Example (Delete the subinterfces with name "Ethernet0.100"): +``` +admin@sonic:~$ sudo config subinterface del Ethernet0.100 +``` + +- Example (Delete the subinterfces with name "Eth64.100"): +``` +admin@sonic:~$ sudo config subinterface del Eth64.100 100 +``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#static-routing) + +## Syslog + +### Syslog Config Commands + +This sub-section of commands is used to add or remove the configured syslog servers. + +**config syslog add** + +This command is used to add a SYSLOG server to the syslog server list. Note that more that one syslog server can be added in the device. + +- Usage: + ``` + config syslog add + ``` + +- Example: + ``` + admin@sonic:~$ sudo config syslog add 1.1.1.1 + Syslog server 1.1.1.1 added to configuration + Restarting rsyslog-config service... + ``` + +**config syslog delete** + +This command is used to delete the syslog server configured. + +- Usage: + ``` + config syslog del + ``` + +- Example: + ``` + admin@sonic:~$ sudo config syslog del 1.1.1.1 + Syslog server 1.1.1.1 removed from configuration + Restarting rsyslog-config service... + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#syslog) + +## System State + +### Processes + +This command is used to determine the CPU utilization. It also lists the active processes along with their corresponding process ID and other relevant parameters. + +This sub-section explains the various "processes" specific data that includes the following. +1) cpu Show processes CPU info +2) memory Show processes memory info +3) summary Show processes info + +“show processes” commands provide a wrapper over linux’s “top” command. “show process cpu” sorts the processes being displayed by cpu-utilization, whereas “show process memory” does it attending to processes’ memory-utilization. + +**show processes cpu** + +This command displays the current CPU usage by process. This command uses linux's "top -bn 1 -o %CPU" command to display the output. + +- Usage: + ``` + show processes cpu + ``` + +*TIP: Users can pipe the output to "head" to display only the "n" number of lines (e.g., `show processes cpu | head -n 10`)* + +- Example: + ``` + admin@sonic:~$ show processes cpu + top - 23:50:08 up 1:18, 1 user, load average: 0.25, 0.29, 0.25 + Tasks: 161 total, 1 running, 160 sleeping, 0 stopped, 0 zombie + %Cpu(s): 3.8 us, 1.0 sy, 0.0 ni, 95.1 id, 0.1 wa, 0.0 hi, 0.0 si, 0.0 st + KiB Mem: 8181216 total, 1161060 used, 7020156 free, 105656 buffers + KiB Swap: 0 total, 0 used, 0 free. 557560 cached Mem + + PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND + 2047 root 20 0 683772 109288 39652 S 23.8 1.3 7:44.79 syncd + 1351 root 20 0 43360 5616 2844 S 11.9 0.1 1:41.56 redis-server + 10093 root 20 0 21944 2476 2088 R 5.9 0.0 0:00.03 top + 1 root 20 0 28992 5508 3236 S 0.0 0.1 0:06.42 systemd + 2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd + 3 root 20 0 0 0 0 S 0.0 0.0 0:00.56 ksoftirqd/0 + 5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H + ... + ``` + +*TIP: Advanced users can view individual processes using variations of the `ps` command (e.g., `ps -ax | grep `)* + +**show processes memory** + +This command displays the current memory usage by processes. This command uses linux's "top -bn 1 -o %MEM" command to display the output. + +- Usage: + ``` + show processes memory + ``` + +*NOTE that pipe option can be used using " | head -n" to display only the "n" number of lines* + +- Example: + ``` + admin@sonic:~$ show processes memory + top - 23:41:24 up 7 days, 39 min, 2 users, load average: 1.21, 1.19, 1.18 + Tasks: 191 total, 2 running, 189 sleeping, 0 stopped, 0 zombie + %Cpu(s): 2.8 us, 20.7 sy, 0.0 ni, 76.3 id, 0.0 wa, 0.0 hi, 0.2 si, 0.0 st + KiB Mem : 8162264 total, 5720412 free, 945516 used, 1496336 buff/cache + KiB Swap: 0 total, 0 free, 0 used. 6855632 avail Mem + + PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND + 18051 root 20 0 851540 274784 8344 S 0.0 3.4 0:02.77 syncd + 17760 root 20 0 1293428 259212 58732 S 5.9 3.2 96:46.22 syncd + 508 root 20 0 725364 76244 38220 S 0.0 0.9 4:54.49 dockerd + 30853 root 20 0 96348 56824 7880 S 0.0 0.7 0:00.98 show + 17266 root 20 0 509876 49772 30640 S 0.0 0.6 0:06.36 docker + 24891 admin 20 0 515864 49560 30644 S 0.0 0.6 0:05.54 docker + 17643 admin 20 0 575668 49428 30628 S 0.0 0.6 0:06.29 docker + 23885 admin 20 0 369552 49344 30840 S 0.0 0.6 0:05.57 docker + 18055 root 20 0 509076 49260 30296 S 0.0 0.6 0:06.36 docker + 17268 root 20 0 371120 49052 30372 S 0.0 0.6 0:06.45 docker + 1227 root 20 0 443284 48640 30100 S 0.0 0.6 0:41.91 docker + 23785 admin 20 0 443796 48552 30128 S 0.0 0.6 0:05.58 docker + 17820 admin 20 0 435088 48144 29480 S 0.0 0.6 0:06.33 docker + 506 root 20 0 1151040 43140 23964 S 0.0 0.5 8:51.08 containerd + 18437 root 20 0 84852 26388 7380 S 0.0 0.3 65:59.76 python3.6 + ``` + + +**show processes summary** + +This command displays the current summary information about all the processes + +- Usage: + ``` + show processes summary + ``` + +- Example: + ``` + admin@sonic:~$ show processes summary + PID PPID CMD %MEM %CPU + 1 0 /sbin/init 0.0 0.0 + 2 0 [kthreadd] 0.0 0.0 + 3 2 [ksoftirqd/0] 0.0 0.0 + 5 2 [kworker/0:0H] 0.0 0.0 + ... + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#System-State) + +### Services & Memory + +These commands are used to know the services that are running and the memory that is utilized currently. + + +**show services** + +This command displays the state of all the SONiC processes running inside a docker container. This helps to identify the status of SONiC’s critical processes. + +- Usage: + ``` + show services + ``` + +- Example: + ``` + admin@sonic:~$ show services + dhcp_relay docker + --------------------------- + UID PID PPID C STIME TTY TIME CMD + root 1 0 0 05:26 ? 00:00:12 /usr/bin/python /usr/bin/supervi + root 24 1 0 05:26 ? 00:00:00 /usr/sbin/rsyslogd -n + + nat docker + --------------------------- + USER PID PPID C STIME TTY TIME CMD + root 1 0 0 05:26 ? 00:00:12 /usr/bin/python /usr/bin/supervisord + root 18 1 0 05:26 ? 00:00:00 /usr/sbin/rsyslogd -n + root 23 1 0 05:26 ? 00:00:01 /usr/bin/natmgrd + root 34 1 0 05:26 ? 00:00:00 /usr/bin/natsyncd + + snmp docker + --------------------------- + UID PID PPID C STIME TTY TIME CMD + root 1 0 0 05:26 ? 00:00:16 /usr/bin/python /usr/bin/supervi + root 24 1 0 05:26 ? 00:00:02 /usr/sbin/rsyslogd -n + Debian-+ 29 1 0 05:26 ? 00:00:04 /usr/sbin/snmpd -f -LS4d -u Debi + root 31 1 1 05:26 ? 00:15:10 python3.6 -m sonic_ax_impl + + syncd docker + --------------------------- + UID PID PPID C STIME TTY TIME CMD + root 1 0 0 05:26 ? 00:00:13 /usr/bin/python /usr/bin/supervi + root 12 1 0 05:26 ? 00:00:00 /usr/sbin/rsyslogd -n + root 17 1 0 05:26 ? 00:00:00 /usr/bin/dsserve /usr/bin/syncd + root 27 17 22 05:26 ? 04:09:30 /usr/bin/syncd --diag -p /usr/sh + root 51 27 0 05:26 ? 00:00:01 /usr/bin/syncd --diag -p /usr/sh + + swss docker + --------------------------- + UID PID PPID C STIME TTY TIME CMD + root 1 0 0 05:26 ? 00:00:29 /usr/bin/python /usr/bin/supervi + root 25 1 0 05:26 ? 00:00:00 /usr/sbin/rsyslogd -n + root 30 1 0 05:26 ? 00:00:13 /usr/bin/orchagent -d /var/log/s + root 42 1 1 05:26 ? 00:12:40 /usr/bin/portsyncd -p /usr/share + root 45 1 0 05:26 ? 00:00:00 /usr/bin/intfsyncd + root 48 1 0 05:26 ? 00:00:03 /usr/bin/neighsyncd + root 59 1 0 05:26 ? 00:00:01 /usr/bin/vlanmgrd + root 92 1 0 05:26 ? 00:00:01 /usr/bin/intfmgrd + root 3606 1 0 23:36 ? 00:00:00 bash -c /usr/bin/arp_update; sle + root 3621 3606 0 23:36 ? 00:00:00 sleep 300 + + ... + ``` + +**show system-memory** + +This command displays the system-wide memory utilization information – just a wrapper over linux native “free” command + +- Usage: + ``` + show system-memory + ``` + +- Example: + ``` + admin@sonic:~$ show system-memory + Command: free -m -h + total used free shared buffers cached + Mem: 3.9G 2.0G 1.8G 33M 324M 791M + -/+ buffers/cache: 951M 2.9G + Swap: 0B 0B 0B + ``` + +**show mmu** + +This command displays virtual address to the physical address translation status of the Memory Management Unit (MMU). + +- Usage: + ``` + show mmu + ``` + +- Example: + ``` + admin@sonic:~$ show mmu + Pool: ingress_lossless_pool + ---- -------- + xoff 4194112 + type ingress + mode dynamic + size 10875072 + ---- -------- + + Pool: egress_lossless_pool + ---- -------- + type egress + mode static + size 15982720 + ---- -------- + + Pool: egress_lossy_pool + ---- ------- + type egress + mode dynamic + size 9243812 + ---- ------- + + Profile: egress_lossy_profile + ---------- ------------------------------- + dynamic_th 3 + pool [BUFFER_POOL|egress_lossy_pool] + size 1518 + ---------- ------------------------------- + + Profile: pg_lossless_100000_300m_profile + ---------- ----------------------------------- + xon_offset 2288 + dynamic_th -3 + xon 2288 + xoff 268736 + pool [BUFFER_POOL|ingress_lossless_pool] + size 1248 + ---------- ----------------------------------- + + Profile: egress_lossless_profile + --------- ---------------------------------- + static_th 3995680 + pool [BUFFER_POOL|egress_lossless_pool] + size 1518 + --------- ---------------------------------- + + Profile: pg_lossless_100000_40m_profile + ---------- ----------------------------------- + xon_offset 2288 + dynamic_th -3 + xon 2288 + xoff 177632 + pool [BUFFER_POOL|ingress_lossless_pool] + size 1248 + ---------- ----------------------------------- + + Profile: ingress_lossy_profile + ---------- ----------------------------------- + dynamic_th 3 + pool [BUFFER_POOL|ingress_lossless_pool] + size 0 + ---------- ----------------------------------- + + Profile: pg_lossless_40000_40m_profile + ---------- ----------------------------------- + xon_offset 2288 + dynamic_th -3 + xon 2288 + xoff 71552 + pool [BUFFER_POOL|ingress_lossless_pool] + size 1248 + ---------- ----------------------------------- + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#System-State) + +Go Back To [Beginning of the document](#) or [Beginning of this section](#System-Health) + +### System-Health + +These commands are used to monitor the system current running services and hardware state. + +**show system-health summary** + +This command displays the current status of 'Services' and 'Hardware' under monitoring. +If any of the elements under each of these two sections is 'Not OK' a proper message will appear under the relevant section. + +- Usage: + ``` + show system-health summary + ``` + +- Example: + ``` + admin@sonic:~$ show system-health summary + System status summary + + System status LED red + Services: + Status: Not OK + Not Running: 'telemetry', 'sflowmgrd' + Hardware: + Status: OK + ``` + ``` + admin@sonic:~$ show system-health summary + System status summary + + System status LED green + Services: + Status: OK + Hardware: + Status: OK + ``` + +**show system-health monitor-list** + +This command displays a list of all current 'Services' and 'Hardware' being monitored, their status and type. + +- Usage: + ``` + show system-health monitor-list + ``` + +- Example: + ``` + admin@sonic:~$ show system-health monitor-list + System services and devices monitor list + + Name Status Type + -------------- -------- ---------- + telemetry Not OK Process + orchagent Not OK Process + neighsyncd OK Process + vrfmgrd OK Process + dialout_client OK Process + zebra OK Process + rsyslog OK Process + snmpd OK Process + redis_server OK Process + intfmgrd OK Process + vxlanmgrd OK Process + lldpd_monitor OK Process + portsyncd OK Process + var-log OK Filesystem + lldpmgrd OK Process + syncd OK Process + sonic OK System + buffermgrd OK Process + portmgrd OK Process + staticd OK Process + bgpd OK Process + lldp_syncd OK Process + bgpcfgd OK Process + snmp_subagent OK Process + root-overlay OK Filesystem + fpmsyncd OK Process + sflowmgrd OK Process + vlanmgrd OK Process + nbrmgrd OK Process + PSU 2 OK PSU + psu_1_fan_1 OK Fan + psu_2_fan_1 OK Fan + fan11 OK Fan + fan10 OK Fan + fan12 OK Fan + ASIC OK ASIC + fan1 OK Fan + PSU 1 OK PSU + fan3 OK Fan + fan2 OK Fan + fan5 OK Fan + fan4 OK Fan + fan7 OK Fan + fan6 OK Fan + fan9 OK Fan + fan8 OK Fan + ``` + +**show system-health detail** + +This command displays the current status of 'Services' and 'Hardware' under monitoring. +If any of the elements under each of these two sections is 'Not OK' a proper message will appear under the relevant section. +In addition, displays a list of all current 'Services' and 'Hardware' being monitored and a list of ignored elements. + +- Usage: + ``` + show system-health detail + ``` + +- Example: + ``` + admin@sonic:~$ show system-health detail + System status summary + + System status LED red + Services: + Status: Not OK + Not Running: 'telemetry', 'orchagent' + Hardware: + Status: OK + + System services and devices monitor list + + Name Status Type + -------------- -------- ---------- + telemetry Not OK Process + orchagent Not OK Process + neighsyncd OK Process + vrfmgrd OK Process + dialout_client OK Process + zebra OK Process + rsyslog OK Process + snmpd OK Process + redis_server OK Process + intfmgrd OK Process + vxlanmgrd OK Process + lldpd_monitor OK Process + portsyncd OK Process + var-log OK Filesystem + lldpmgrd OK Process + syncd OK Process + sonic OK System + buffermgrd OK Process + portmgrd OK Process + staticd OK Process + bgpd OK Process + lldp_syncd OK Process + bgpcfgd OK Process + snmp_subagent OK Process + root-overlay OK Filesystem + fpmsyncd OK Process + sflowmgrd OK Process + vlanmgrd OK Process + nbrmgrd OK Process + PSU 2 OK PSU + psu_1_fan_1 OK Fan + psu_2_fan_1 OK Fan + fan11 OK Fan + fan10 OK Fan + fan12 OK Fan + ASIC OK ASIC + fan1 OK Fan + PSU 1 OK PSU + fan3 OK Fan + fan2 OK Fan + fan5 OK Fan + fan4 OK Fan + fan7 OK Fan + fan6 OK Fan + fan9 OK Fan + fan8 OK Fan + + System services and devices ignore list + + Name Status Type + ----------- -------- ------ + psu.voltage Ignored Device + ``` +Go Back To [Beginning of the document](#) or [Beginning of this section](#System-Health) + +## VLAN & FDB + +### VLAN + +#### VLAN show commands + +**show vlan brief** + +This command displays brief information about all the vlans configured in the device. It displays the vlan ID, IP address (if configured for the vlan), list of vlan member ports, whether the port is tagged or in untagged mode, the DHCP Helper Address, and the proxy ARP status + +- Usage: + ``` + show vlan brief + ``` + +- Example: + ``` + admin@sonic:~$ show vlan brief + + +-----------+--------------+-----------+----------------+-----------------------+-------------+ + | VLAN ID | IP Address | Ports | Port Tagging | DHCP Helper Address | Proxy ARP | + +===========+==============+===========+================+=======================+=============+ + | 100 | 1.1.2.2/16 | Ethernet0 | tagged | 192.0.0.1 | disabled | + | | | Ethernet4 | tagged | 192.0.0.2 | | + | | | | | 192.0.0.3 | | + +-----------+--------------+-----------+----------------+-----------------------+-------------+ + ``` + +**show vlan config** + +This command displays all the vlan configuration. + +- Usage: + ``` + show vlan config + ``` + +- Example: + ``` + admin@sonic:~$ show vlan config + Name VID Member Mode + ------- ----- --------- ------ + Vlan100 100 Ethernet0 tagged + Vlan100 100 Ethernet4 tagged + ``` + + +#### VLAN Config commands + +This sub-section explains how to configure the vlan and its member ports. + +**config vlan add/del** + +This command is used to add or delete the vlan. + +- Usage: + ``` + config vlan (add | del) + ``` + +- Example (Create the VLAN "Vlan100" if it does not already exist): + ``` + admin@sonic:~$ sudo config vlan add 100 + ``` + +**config vlan member add/del** + +This command is to add or delete a member port into the already created vlan. + +- Usage: + ``` + config vlan member add/del [-u|--untagged] + ``` + +*NOTE: Adding the -u or --untagged flag will set the member in "untagged" mode* + + +- Example: + ``` + admin@sonic:~$ sudo config vlan member add 100 Ethernet0 + This command will add Ethernet0 as member of the vlan 100 + + admin@sonic:~$ sudo config vlan member add 100 Ethernet4 + This command will add Ethernet4 as member of the vlan 100. + ``` + +**config proxy_arp enabled/disabled** + +This command is used to enable or disable proxy ARP for a VLAN interface + +- Usage: + ``` + config vlan proxy_arp enabled/disabled + ``` + +- Example: + ``` + admin@sonic:~$ sudo config vlan proxy_arp 1000 enabled + This command will enable proxy ARP for the interface 'Vlan1000' + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#vlan--FDB) + +### FDB + +#### FDB show commands + +**show mac** + +This command displays the MAC (FDB) entries either in full or partial as given below. +1) show mac - displays the full table +2) show mac -v - displays the MACs learnt on the particular VLAN ID. +3) show mac -p - displays the MACs learnt on the particular port. +4) show mac -a - display the MACs that match a specific mac-address +5) show mac -t - display the MACs that match a specific type (static/dynamic) +6) show mac -c - display the count of MAC addresses + +To show the default MAC address aging time on the switch. + +- Usage: + ``` + show mac [-v ] [-p ] [-a ] [-t ] [-c] + ``` + +- Example: + ``` + admin@sonic:~$ show mac + No. Vlan MacAddress Port Type + ----- ------ ----------------- ----------- ------- + 1 1000 E2:8C:56:85:4A:CD Ethernet192 Dynamic + 2 1000 A0:1B:5E:47:C9:76 Ethernet192 Dynamic + 3 1000 AA:54:EF:2C:EE:30 Ethernet192 Dynamic + 4 1000 A4:3F:F2:17:A3:FC Ethernet192 Dynamic + 5 1000 0C:FC:01:72:29:91 Ethernet192 Dynamic + 6 1000 48:6D:01:7E:C9:FD Ethernet192 Dynamic + 7 1000 1C:6B:7E:34:5F:A6 Ethernet192 Dynamic + 8 1000 EE:81:D9:7B:93:A9 Ethernet192 Dynamic + 9 1000 CC:F8:8D:BB:85:E2 Ethernet192 Dynamic + 10 1000 0A:52:B3:9C:FB:6C Ethernet192 Dynamic + 11 1000 C6:E2:72:02:D1:23 Ethernet192 Dynamic + 12 1000 8A:C9:5C:25:E9:28 Ethernet192 Dynamic + 13 1000 5E:CD:34:E4:94:18 Ethernet192 Dynamic + 14 1000 7E:49:1F:B5:91:B5 Ethernet192 Dynamic + 15 1000 AE:DD:67:F3:09:5A Ethernet192 Dynamic + 16 1000 DC:2F:D1:08:4B:DE Ethernet192 Dynamic + 17 1000 50:96:23:AD:F1:65 Ethernet192 Static + 18 1000 C6:C9:5E:AE:24:42 Ethernet192 Static + Total number of entries 18 + ``` + +Optionally, you can specify a VLAN ID or interface name or type or mac-address in order to display only that particular entries + +- Examples: + ``` + admin@sonic:~$ show mac -v 1000 + No. Vlan MacAddress Port Type + ----- ------ ----------------- ----------- ------- + 1 1000 E2:8C:56:85:4A:CD Ethernet192 Dynamic + 2 1000 A0:1B:5E:47:C9:76 Ethernet192 Dynamic + 3 1000 AA:54:EF:2C:EE:30 Ethernet192 Dynamic + 4 1000 A4:3F:F2:17:A3:FC Ethernet192 Dynamic + 5 1000 0C:FC:01:72:29:91 Ethernet192 Dynamic + 6 1000 48:6D:01:7E:C9:FD Ethernet192 Dynamic + 7 1000 1C:6B:7E:34:5F:A6 Ethernet192 Dynamic + 8 1000 EE:81:D9:7B:93:A9 Ethernet192 Dynamic + 9 1000 CC:F8:8D:BB:85:E2 Ethernet192 Dynamic + 10 1000 0A:52:B3:9C:FB:6C Ethernet192 Dynamic + 11 1000 C6:E2:72:02:D1:23 Ethernet192 Dynamic + 12 1000 8A:C9:5C:25:E9:28 Ethernet192 Dynamic + 13 1000 5E:CD:34:E4:94:18 Ethernet192 Dynamic + 14 1000 7E:49:1F:B5:91:B5 Ethernet192 Dynamic + 15 1000 AE:DD:67:F3:09:5A Ethernet192 Dynamic + 16 1000 DC:2F:D1:08:4B:DE Ethernet192 Dynamic + 17 1000 50:96:23:AD:F1:65 Ethernet192 Static + 18 1000 C6:C9:5E:AE:24:42 Ethernet192 Static + Total number of entries 18 + ``` + ``` + admin@sonic:~$ show mac -p Ethernet192 + No. Vlan MacAddress Port Type + ----- ------ ----------------- ----------- ------- + 1 1000 E2:8C:56:85:4A:CD Ethernet192 Dynamic + 2 1000 A0:1B:5E:47:C9:76 Ethernet192 Dynamic + 3 1000 AA:54:EF:2C:EE:30 Ethernet192 Dynamic + 4 1000 A4:3F:F2:17:A3:FC Ethernet192 Dynamic + 5 1000 0C:FC:01:72:29:91 Ethernet192 Dynamic + 6 1000 48:6D:01:7E:C9:FD Ethernet192 Dynamic + 7 1000 1C:6B:7E:34:5F:A6 Ethernet192 Dynamic + 8 1000 EE:81:D9:7B:93:A9 Ethernet192 Dynamic + 9 1000 CC:F8:8D:BB:85:E2 Ethernet192 Dynamic + 10 1000 0A:52:B3:9C:FB:6C Ethernet192 Dynamic + 11 1000 C6:E2:72:02:D1:23 Ethernet192 Dynamic + 12 1000 8A:C9:5C:25:E9:28 Ethernet192 Dynamic + 13 1000 5E:CD:34:E4:94:18 Ethernet192 Dynamic + 14 1000 7E:49:1F:B5:91:B5 Ethernet192 Dynamic + 15 1000 AE:DD:67:F3:09:5A Ethernet192 Dynamic + 16 1000 DC:2F:D1:08:4B:DE Ethernet192 Dynamic + 17 1000 50:96:23:AD:F1:65 Ethernet192 Static + 18 1000 C6:C9:5E:AE:24:42 Ethernet192 Static + Total number of entries 18 + ``` + ``` + admin@sonic:~$ show mac -a E2:8C:56:85:4A:CD + No. Vlan MacAddress Port Type + ----- ------ ----------------- ----------- ------- + 1 1000 E2:8C:56:85:4A:CD Ethernet192 Dynamic + Total number of entries 1 + ``` + ``` + admin@sonic:~$ show mac -t Static + No. Vlan MacAddress Port Type + ----- ------ ----------------- ----------- ------- + 2 1000 50:96:23:AD:F1:65 Ethernet192 Static + 2 1000 C6:C9:5E:AE:24:42 Ethernet192 Static + Total number of entries 2 + ``` + ``` + admin@sonic:~$ show mac -c + Total number of entries 18 + ``` + +**show mac aging-time** + +This command displays the default mac aging time on the switch + + ``` + admin@sonic:~$ show mac aging-time + Aging time for switch is 600 seconds + ``` + +**sonic-clear fdb all** + +Clear the FDB table + +- Usage: + ``` + sonic-clear fdb all + ``` +- Example: + ``` + admin@sonic:~$ sonic-clear fdb all + FDB entries are cleared. + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#vlan--FDB) + +## VxLAN & Vnet + +### VxLAN + +#### VxLAN show commands + +**show vxlan tunnel** + +This command displays brief information about all the vxlans configured in the device. It displays the vxlan tunnel name, source IP address, destination IP address (if configured), tunnel map name and mapping. + +- Usage: + + ``` + show vxlan tunnel + ``` + +- Example: + + ``` + admin@sonic:~$ show vxlan tunnel + vxlan tunnel name source ip destination ip tunnel map name tunnel map mapping(vni -> vlan) + ------------------- ----------- ---------------- ----------------- --------------------------------- + tunnel1 10.10.10.10 + tunnel2 10.10.10.10 20.10.10.10 tmap1 1234 -> 100 + tunnel3 10.10.10.10 30.10.10.10 tmap2 1235 -> 200 + ``` + +**show vxlan name ** + +This command displays configuration. + +- Usage: + + ``` + show vxlan name + ``` + +- Example: + + ``` + admin@sonic:~$ show vxlan name tunnel3 + vxlan tunnel name source ip destination ip tunnel map name tunnel map mapping(vni -> vlan) + ------------------- ----------- ---------------- ----------------- --------------------------------- + tunnel3 10.10.10.10 30.10.10.10 tmap2 1235 -> 200 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#vxlan--vnet) + +### Vnet + +#### Vnet show commands + +**show vnet brief** + +This command displays brief information about all the vnets configured in the device. It displays the vnet name, vxlan tunnel name, vni and peer list (if configured). + +- Usage: + + ``` + show vnet brief + ``` + +- Example: + + ``` + admin@sonic:~$ show vnet brief + vnet name vxlan tunnel vni peer list + ----------- -------------- ----- ------------------ + Vnet_2000 tunnel1 2000 + Vnet_3000 tunnel1 3000 Vnet_2000,Vnet4000 + ``` + +**show vnet name ** + +This command displays brief information about configured in the device. + +- Usage: + + ``` + show vnet name + ``` + +- Example: + + ``` + admin@sonic:~$ show vnet name Vnet_3000 + vnet name vxlan tunnel vni peer list + ----------- -------------- ----- ------------------ + Vnet_3000 tunnel1 3000 Vnet_2000,Vnet4000 + ``` + +**show vnet interfaces** + +This command displays vnet interfaces information about all the vnets configured in the device. + +- Usage: + + ``` + show vnet interfaces + ``` + +- Example: + + ``` + admin@sonic:~$ show vnet interfaces + vnet name interfaces + ----------- ------------ + Vnet_2000 Ethernet1 + Vnet_3000 Vlan2000 + ``` + +**show vnet neighbors** + +This command displays vnet neighbor information about all the vnets configured in the device. It displays the vnet name, neighbor IP address, neighbor mac address (if configured) and interface. + +- Usage: + + ``` + show vnet neighbors + ``` + +- Example: + + ``` + admin@sonic:~$ show vnet neighbors + Vnet_2000 neighbor mac_address interfaces + ----------- ----------- ------------- ------------ + 11.11.11.11 Ethernet1 + 11.11.11.12 Ethernet1 + + Vnet_3000 neighbor mac_address interfaces + ----------- ----------- ----------------- ------------ + 20.20.20.20 aa:bb:cc:dd:ee:ff Vlan2000 + ``` + +**show vnet routes all** + +This command displays all routes information about all the vnets configured in the device. + +- Usage: + + ``` + show vnet routes all + ``` + +- Example: + + ``` + admin@sonic:~$ show vnet routes all + vnet name prefix nexthop interface + ----------- -------------- --------- ----------- + Vnet_2000 100.100.3.0/24 Ethernet52 + Vnet_3000 100.100.4.0/24 Vlan2000 + + vnet name prefix endpoint mac address vni + ----------- -------------- ---------- ----------------- ----- + Vnet_2000 100.100.1.1/32 10.10.10.1 + Vnet_3000 100.100.2.1/32 10.10.10.2 00:00:00:00:03:04 + ``` + +**show vnet routes tunnel** + +This command displays tunnel routes information about all the vnets configured in the device. + +- Usage: + + ``` + show vnet routes tunnel + ``` + +- Example: + + ``` + admin@sonic:~$ show vnet routes tunnel + vnet name prefix endpoint mac address vni + ----------- -------------- ---------- ----------------- ----- + Vnet_2000 100.100.1.1/32 10.10.10.1 + Vnet_3000 100.100.2.1/32 10.10.10.2 00:00:00:00:03:04 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#vxlan--vnet) + +## Warm Reboot + +warm-reboot command initiates a warm reboot of the device. + +warm-reboot command doesn't require setting warm restart configuration. The +command will setup everything needed to perform warm reboot. + +This command requires root privilege. + +- Usage: + ``` + warm-reboot [-h|-?|-v|-f|-r|-k|-x|-c |-s|-D] + ``` + +- Parameters: + ``` + -h,-? : get this help + -v : turn on verbose mode + -f : force execution + -r : reboot with /sbin/reboot + -k : reboot with /sbin/kexec -e [default] + -x : execute script with -x flag + -c : specify control plane assistant IP list + -s : strict mode: do not proceed without: + - control plane assistant IP list. + -D : detached mode - closing terminal will not cause stopping reboot + ``` + +- Example: + ``` + admin@sonic:~$ sudo warm-reboot -v + Tue Oct 22 23:20:53 UTC 2019 Pausing orchagent ... + Tue Oct 22 23:20:53 UTC 2019 Stopping radv ... + Tue Oct 22 23:20:54 UTC 2019 Stopping bgp ... + Tue Oct 22 23:20:54 UTC 2019 Stopped bgp ... + Tue Oct 22 23:20:57 UTC 2019 Initialize pre-shutdown ... + Tue Oct 22 23:20:58 UTC 2019 Requesting pre-shutdown ... + Tue Oct 22 23:20:58 UTC 2019 Waiting for pre-shutdown ... + Tue Oct 22 23:20:59 UTC 2019 Pre-shutdown succeeded ... + Tue Oct 22 23:20:59 UTC 2019 Backing up database ... + Tue Oct 22 23:21:00 UTC 2019 Stopping teamd ... + Tue Oct 22 23:21:00 UTC 2019 Stopped teamd ... + Tue Oct 22 23:21:00 UTC 2019 Stopping syncd ... + Tue Oct 22 23:21:11 UTC 2019 Stopped syncd ... + Tue Oct 22 23:21:11 UTC 2019 Stopping all remaining containers ... + Tue Oct 22 23:21:13 UTC 2019 Stopped all remaining containers ... + Tue Oct 22 23:21:15 UTC 2019 Rebooting with /sbin/kexec -e to SONiC-OS-20191021.01 ... + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#Warm-Reboot) + +## Warm Restart + +Besides device level warm reboot, SONiC also provides docker based warm restart. This feature is currently supported by following dockers: BGP, teamD, and SWSS. A user can manage to restart a particular docker, with no interruption on packet forwarding and no effect on other services. This helps to reduce operational costs as well as development efforts. For example, to fix a bug in BGP routing stack, only the BGP docker image needs to be built, tested and upgraded. + +To achieve uninterrupted packet forwarding during the restarting stage and database reconciliation at the post restarting stage, warm restart enabled dockers with adjacency state machine facilitate standardized protocols. For example, a BGP restarting switch must have BGP "Graceful Restart" enabled, and its BGP neighbors must be "Graceful Restart Helper Capable", as specified in [IETF RFC4724](https://tools.ietf.org/html/rfc4724). + +Before warm restart BGP docker, the following BGP commands should be enabled: + ``` + bgp graceful-restart + bgp graceful-restart preserve-fw-state + ``` +In current SONiC release, the above two commands are enabled by default. + +It should be aware that during a warm restart, certain BGP fast convergence feature and black hole avoidance feature should either be disabled or be set to a lower preference to avoid conflicts with BGP graceful restart. + +For example, BGP BFD could be disabled via: + + ``` + no neighbor bfd + ``` + +otherwise, the fast failure detection would cause packet drop during warm reboot. + +Another commonly deployed blackhole avoidance feature: dynamic route priority adjustment, could be disabled via: + + ``` + no bgp max-med on-peerup + ``` + +to avoid large routes churn during BGP restart. + + +### Warm Restart show commands + +**show warm_restart config** + +This command displays all the configuration related to warm_restart. + +- Usage: + ``` + show warm_restart config + ``` + +- Example: + ``` + admin@sonic:~$ show warm_restart config + name enable timer_name timer_duration + ------ -------- ---------------- ---------------- + bgp true bgp_timer 100 + teamd false teamsyncd_timer 300 + swss false neighsyncd_timer 200 + system true NULL NULL + ``` + +**show warm_restart state** + +This command displays the warm_restart state. + +- Usage: + ``` + show warm_restart state + ``` + +- Example: + ``` + admin@sonic:~$ show warm_restart state + name restore_count state + ---------- --------------- ---------- + orchagent 0 + vlanmgrd 0 + bgp 1 reconciled + portsyncd 0 + teammgrd 1 + neighsyncd 0 + teamsyncd 1 + syncd 0 + natsyncd 0 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#warm-restart) + +### Warm Restart Config commands + +This sub-section explains the various configuration related to warm restart feature. Following parameters can be configured using this command. +1) bgp_timer +2) disable +3) enable +4) neighsyncd_timer +5) teamsyncd_timer +Each of these sub-commands are explained in the following section. + +Users can use an optional parameter "-s" to use the unix domain socket for communicating with the RedisDB which will be faster when compared to using the default network sockets. +All these commands have the following option. + +Options: + -s, --redis-unix-socket-path TEXT + unix socket path for redis connection + + +**config warm_restart bgp_timer** + +This command is used to set the bgp_timer value for warm_restart of BGP service. +bgp_timer holds the time interval utilized by fpmsyncd during warm-restart episodes. +During this interval fpmsyncd will recover all the routing state previously pushed to AppDB, as well as all the new state coming from zebra/bgpd. +Upon expiration of this timer, fpmsyncd will execute the reconciliation logic to eliminate all the stale entries from AppDB. +This timer should match the BGP-GR restart-timer configured within the elected routing-stack. +Supported range: 1-3600. + +- Usage: + ``` + config warm_restart [-s|--redis-unix-socket-path ] bgp_timer + ``` + + - Parameters: + - seconds: Range from 1 to 3600 + +- Example: + ``` + admin@sonic:~$ sudo config warm_restart bgp_timer 1000 + ``` + +**config warm_restart enable/disable** + +This command is used to enable or disable the warm_restart for a particular service that supports warm reboot. +Following four services support warm reboot. When user restarts the particular service using "systemctl restart ", this configured value will be checked for whether it is enabled or disabled. +If this configuration is enabled for that service, it will perform warm reboot for that service. Otherwise, it will do cold restart of the service. + +- Usage: + ``` + config warm_restart [-s|--redis-unix-socket-path ] enable [] + ``` + + - Parameters: + - module_name: Can be either system or swss or bgp or teamd. If "module_name" argument is not specified, it will enable "system" module. + +- Example (Set warm_restart as "enable" for the "system" service): + ``` + admin@sonic:~$ sudo config warm_restart enable + ``` + +- Example (Set warm_restart as "enable" for the "swss" service. When user does "systemctl restart swss", it will perform warm reboot instead of cold reboot) + ``` + admin@sonic:~$ sudo config warm_restart enable swss + ``` + +- Example (Set warm_restart as "enable" for the "teamd" service. When user does "systemctl restart teamd", it will perform warm reboot instead of cold reboot) + ``` + admin@sonic:~$ sudo config warm_restart enable teamd + ``` + + +**config warm_restart neighsyncd_timer** + +This command is used to set the neighsyncd_timer value for warm_restart of "swss" service. +neighsyncd_timer is the timer used for "swss" (neighsyncd) service during the warm restart. +Timer is started after the neighborTable is restored to internal data structures. +neighborsyncd then starts to read all Linux kernel entries and mark the entries in the data structures accordingly. +Once the timer is expired, reconciliation is done and the delta is pushed to appDB +Valid value is 1-9999. 0 is invalid. + +- Usage: + ``` + config warm_restart [-s|--redis-unix-socket-path ] neighsyncd_timer + ``` + + - Parameters: + - seconds: Range from 1 to 9999 + +- Example: + ``` + admin@sonic:~$ sudo config warm_restart neighsyncd_timer 2000 + ``` + + +**config warm_restart bgp_timer** + +This command is used to set the bgp_timer value for warm_restart of "bgp" service. +bgp_timer is the timer used for "bgp" service during the warm restart. +Timer is started after the BGP table is restored to internal data structures. +BGP services then start to read all Linux kernel entries and mark the entries in the data structures accordingly. +Once the timer is expired, reconciliation is done and the delta is pushed to appDB +Valid value is 1-9999. 0 is invalid. + +- Usage: + ``` + config warm_restart [-s|--redis-unix-socket-path ] bgp_timer + ``` + + - Parameters: + - seconds: Range from 1 to 9999 + +- Example: + ``` + admin@sonic:~$ sudo config warm_restart bgp_timer 2000 + ``` + +**config warm_restart teamsyncd_timer** + +This command is used to set the teamsyncd_timer value for warm_restart of teamd service. +teamsyncd_timer holds the time interval utilized by teamsyncd during warm-restart episodes. +The timer is started when teamsyncd starts. During the timer interval, teamsyncd will preserve all LAG interface changes, but it will not apply them. +The changes will only be applied when the timer expires. +When the changes are applied, the stale LAG entries will be removed, the new LAG entries will be created. +Supported range: 1-9999. 0 is invalid + +- Usage: + ``` + config warm_restart teamsyncd_timer + ``` + + - Parameters: + - seconds: Range from 1 to 9999 + +- Example: + ``` + admin@sonic:~$ sudo config warm_restart teamsyncd_timer 3000 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#warm-restart) + + +## Watermark + +### Watermark Show commands + +**show watermark telemetry interval** + +This command displays the configured interval for the telemetry. + +- Usage: + ``` + show watermark telemetry interval + ``` + +- Example: + ``` + admin@sonic:~$ show watermark telemetry interval + + Telemetry interval 120 second(s) + ``` + +### Watermark Config commands + +**config watermark telemetry interval** + +This command is used to configure the interval for telemetry. +The default interval is 120 seconds. +There is no regulation on the valid range of values; it leverages linux timer. + +- Usage: + ``` + config watermark telemetry interval + ``` + +- Example: + ``` + admin@sonic:~$ sudo config watermark telemetry interval 999 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#watermark) + + + +## Software Installation and Management + +SONiC images can be installed in one of two methods: +1. From within a running SONiC image using the `sonic-installer` utility +2. From the vendor's bootloader (E.g., ONIE, Aboot, etc.) + +SONiC packages are available as prebuilt Docker images and meant to be installed with the *sonic-package-manager* utility. + +### SONiC Package Manager + +The *sonic-package-manager* is a command line tool to manage (e.g. install, upgrade or uninstall) SONiC Packages. + +**sonic-package-manager list** + +This command lists all available SONiC packages, their desription, installed version and installation status. +SONiC package status can be *Installed*, *Not installed* or *Built-In*. "Built-In" status means that a feature is built-in to SONiC image and can't be upgraded or uninstalled. + +- Usage: + ``` + sonic-package-manager list + ``` + +- Example: + ``` + admin@sonic:~$ sonic-package-manager list + Name Repository Description Version Status + -------------- --------------------------- ---------------------------- --------- -------------- + cpu-report azure/cpu-report CPU report package N/A Not Installed + database docker-database SONiC database package 1.0.0 Built-In + dhcp-relay azure/docker-dhcp-relay SONiC dhcp-relay package 1.0.0 Installed + fpm-frr docker-fpm-frr SONiC fpm-frr package 1.0.0 Built-In + lldp docker-lldp SONiC lldp package 1.0.0 Built-In + macsec docker-macsec SONiC macsec package 1.0.0 Built-In + mgmt-framework docker-sonic-mgmt-framework SONiC mgmt-framework package 1.0.0 Built-In + nat docker-nat SONiC nat package 1.0.0 Built-In + pmon docker-platform-monitor SONiC pmon package 1.0.0 Built-In + radv docker-router-advertiser SONiC radv package 1.0.0 Built-In + sflow docker-sflow SONiC sflow package 1.0.0 Built-In + snmp docker-snmp SONiC snmp package 1.0.0 Built-In + swss docker-orchagent SONiC swss package 1.0.0 Built-In + syncd docker-syncd-mlnx SONiC syncd package 1.0.0 Built-In + teamd docker-teamd SONiC teamd package 1.0.0 Built-In + telemetry docker-sonic-telemetry SONiC telemetry package 1.0.0 Built-In + ``` + +**sonic-package-manager repository add** + +This command will add a new repository as source for SONiC packages to the database. *NOTE*: requires elevated (root) privileges to run + +- Usage: + ``` + Usage: sonic-package-manager repository add [OPTIONS] NAME REPOSITORY + + Add a new repository to database. + + NOTE: This command requires elevated (root) privileges to run. + + Options: + --default-reference TEXT Default installation reference. Can be a tag or + sha256 digest in repository. + --description TEXT Optional package entry description. + --help Show this message and exit. + ``` +- Example: + ``` + admin@sonic:~$ sudo sonic-package-manager repository add \ + cpu-report azure/sonic-cpu-report --default-reference 1.0.0 + ``` + +**sonic-package-manager repository remove** + +This command will remove a repository as source for SONiC packages from the database . The package has to be *Not Installed* in order to be removed from package database. *NOTE*: requires elevated (root) privileges to run + +- Usage: + ``` + Usage: sonic-package-manager repository remove [OPTIONS] NAME + + Remove repository from database. + + NOTE: This command requires elevated (root) privileges to run. + + Options: + --help Show this message and exit. + ``` +- Example: + ``` + admin@sonic:~$ sudo sonic-package-manager repository remove cpu-report + ``` + +**sonic-package-manager install** + +This command pulls and installs a package on SONiC host. *NOTE*: this command requires elevated (root) privileges to run + +- Usage: + ``` + Usage: sonic-package-manager install [OPTIONS] [PACKAGE_EXPR] + + Install/Upgrade package using [PACKAGE_EXPR] in format + "[=|@]". + + The repository to pull the package from is resolved by lookup in + package database, thus the package has to be added via "sonic- + package-manager repository add" command. + + In case when [PACKAGE_EXPR] is a package name "" this command + will install or upgrade to a version referenced by "default- + reference" in package database. + + NOTE: This command requires elevated (root) privileges to run. + + Options: + --enable Set the default state of the feature to enabled + and enable feature right after installation. NOTE: + user needs to execute "config save -y" to make + this setting persistent. + --set-owner [local|kube] Default owner configuration setting for a feature. + --from-repository TEXT Fetch package directly from image registry + repository. NOTE: This argument is mutually + exclusive with arguments: [package_expr, + from_tarball]. + --from-tarball FILE Fetch package from saved image tarball. NOTE: This + argument is mutually exclusive with arguments: + [package_expr, from_repository]. + -f, --force Force operation by ignoring package dependency + tree and package manifest validation failures. + -y, --yes Automatically answer yes on prompts. + -v, --verbosity LVL Either CRITICAL, ERROR, WARNING, INFO or DEBUG. + Default is INFO. + --skip-host-plugins Do not install host OS plugins provided by the + package (CLI, etc). NOTE: In case when package + host OS plugins are set as mandatory in package + manifest this option will fail the installation. + --allow-downgrade Allow package downgrade. By default an attempt to + downgrade the package will result in a failure + since downgrade might not be supported by the + package, thus requires explicit request from the + user. + --help Show this message and exit.. + ``` +- Example: + ``` + admin@sonic:~$ sudo sonic-package-manager install dhcp-relay=1.0.2 + ``` + ``` + admin@sonic:~$ sudo sonic-package-manager install dhcp-relay@latest + ``` + ``` + admin@sonic:~$ sudo sonic-package-manager install dhcp-relay@sha256:9780f6d83e45878749497a6297ed9906c19ee0cc48cc88dc63827564bb8768fd + ``` + ``` + admin@sonic:~$ sudo sonic-package-manager install --from-repository azure/sonic-cpu-report:latest + ``` + ``` + admin@sonic:~$ sudo sonic-package-manager install --from-tarball sonic-docker-image.gz + ``` + +**sonic-package-manager uninstall** + +This command uninstalls package from SONiC host. User needs to stop the feature prior to uninstalling it. +*NOTE*: this command requires elevated (root) privileges to run. + +- Usage: + ``` + Usage: sonic-package-manager uninstall [OPTIONS] NAME + + Uninstall package. + + NOTE: This command requires elevated (root) privileges to run. + + Options: + -f, --force Force operation by ignoring package dependency tree and + package manifest validation failures. + -y, --yes Automatically answer yes on prompts. + -v, --verbosity LVL Either CRITICAL, ERROR, WARNING, INFO or DEBUG. Default + is INFO. + --help Show this message and exit. + ``` +- Example: + ``` + admin@sonic:~$ sudo sonic-package-manager uninstall dhcp-relay + ``` + +**sonic-package-manager reset** + +This comamnd resets the package by reinstalling it to its default version. *NOTE*: this command requires elevated (root) privileges to run. + +- Usage: + ``` + Usage: sonic-package-manager reset [OPTIONS] NAME + + Reset package to the default version. + + NOTE: This command requires elevated (root) privileges to run. + + Options: + -f, --force Force operation by ignoring package dependency tree and + package manifest validation failures. + -y, --yes Automatically answer yes on prompts. + -v, --verbosity LVL Either CRITICAL, ERROR, WARNING, INFO or DEBUG. Default + is INFO. + --skip-host-plugins Do not install host OS plugins provided by the package + (CLI, etc). NOTE: In case when package host OS plugins + are set as mandatory in package manifest this option + will fail the installation. + --help Show this message and exit. + ``` +- Example: + ``` + admin@sonic:~$ sudo sonic-package-manager reset dhcp-relay + ``` + +**sonic-package-manager show package versions** + +This command will retrieve a list of all available versions for the given package from the configured upstream repository + +- Usage: + ``` + Usage: sonic-package-manager show package versions [OPTIONS] NAME + + Show available versions. + + Options: + --all Show all available tags in repository. + --plain Plain output. + --help Show this message and exit. + ``` +- Example: + ``` + admin@sonic:~$ sonic-package-manager show package versions dhcp-relay + • 1.0.0 + • 1.0.2 + • 2.0.0 + ``` + ``` + admin@sonic:~$ sonic-package-manager show package versions dhcp-relay --plain + 1.0.0 + 1.0.2 + 2.0.0 + ``` + ``` + admin@sonic:~$ sonic-package-manager show package versions dhcp-relay --all + • 1.0.0 + • 1.0.2 + • 2.0.0 + • latest + ``` + +**sonic-package-manager show package changelog** + +This command fetches the changelog from the package manifest and displays it. *NOTE*: package changelog can be retrieved from registry or read from image tarball without installing it. + +- Usage: + ``` + Usage: sonic-package-manager show package changelog [OPTIONS] [PACKAGE_EXPR] + + Show package changelog. + + Options: + --from-repository TEXT Fetch package directly from image registry + repository NOTE: This argument is mutually exclusive + with arguments: [from_tarball, package_expr]. + --from-tarball FILE Fetch package from saved image tarball NOTE: This + argument is mutually exclusive with arguments: + [package_expr, from_repository]. + --help Show this message and exit. + ``` +- Example: + ``` + admin@sonic:~$ sonic-package-manager show package changelog dhcp-relay + 1.0.0: + + • Initial release + + Author (author@email.com) Mon, 25 May 2020 12:25:00 +0300 + ``` + +**sonic-package-manager show package manifest** + +This command fetches the package manifest and displays it. *NOTE*: package manifest can be retrieved from registry or read from image tarball without installing it. + +- Usage: + ``` + Usage: sonic-package-manager show package manifest [OPTIONS] [PACKAGE_EXPR] + + Show package manifest. + + Options: + --from-repository TEXT Fetch package directly from image registry + repository NOTE: This argument is mutually exclusive + with arguments: [package_expr, from_tarball]. + --from-tarball FILE Fetch package from saved image tarball NOTE: This + argument is mutually exclusive with arguments: + [from_repository, package_expr]. + -v, --verbosity LVL Either CRITICAL, ERROR, WARNING, INFO or DEBUG + --help Show this message and exit. + ``` +- Example: + ``` + admin@sonic:~$ sonic-package-manager show package manifest dhcp-relay=2.0.0 + { + "version": "1.0.0", + "package": { + "version": "2.0.0", + "depends": [ + "database>=1.0.0,<2.0.0" + ] + }, + "service": { + "name": "dhcp_relay" + } + } + ``` + +### SONiC Installer +This is a command line tool available as part of the SONiC software; If the device is already running the SONiC software, this tool can be used to install an alternate image in the partition. +This tool has facility to install an alternate image, list the available images and to set the next reboot image. +This command requires elevated (root) privileges to run. + +**sonic-installer list** + +This command displays information about currently installed images. It displays a list of installed images, currently running image and image set to be loaded in next reboot. + +- Usage: + ``` + sonic-installer list + ``` + +- Example: + ``` + admin@sonic:~$ sudo sonic-installer list + Current: SONiC-OS-HEAD.XXXX + Next: SONiC-OS-HEAD.XXXX + Available: + SONiC-OS-HEAD.XXXX + SONiC-OS-HEAD.YYYY + ``` + +TIP: This output can be obtained without evelated privileges by running the `show boot` command. See [here](#show-system-status) for details. + +**sonic-installer install** + +This command is used to install a new image on the alternate image partition. This command takes a path to an installable SONiC image or URL and installs the image. + +- Usage: + ``` + sonic-installer install + ``` + +- Example: + ``` + admin@sonic:~$ sudo sonic-installer install https://sonic-jenkins.westus.cloudapp.azure.com/job/xxxx/job/buildimage-xxxx-all/xxx/artifact/target/sonic-xxxx.bin + New image will be installed, continue? [y/N]: y + Downloading image... + ...100%, 480 MB, 3357 KB/s, 146 seconds passed + Command: /tmp/sonic_image + Verifying image checksum ... OK. + Preparing image archive ... OK. + ONIE Installer: platform: XXXX + onie_platform: + Installing SONiC in SONiC + Installing SONiC to /host/image-xxxx + Directory /host/image-xxxx/ already exists. Cleaning up... + Archive: fs.zip + creating: /host/image-xxxx/boot/ + inflating: /host/image-xxxx/boot/vmlinuz-3.16.0-4-amd64 + inflating: /host/image-xxxx/boot/config-3.16.0-4-amd64 + inflating: /host/image-xxxx/boot/System.map-3.16.0-4-amd64 + inflating: /host/image-xxxx/boot/initrd.img-3.16.0-4-amd64 + creating: /host/image-xxxx/platform/ + extracting: /host/image-xxxx/platform/firsttime + inflating: /host/image-xxxx/fs.squashfs + inflating: /host/image-xxxx/dockerfs.tar.gz + Log file system already exists. Size: 4096MB + Installed SONiC base image SONiC-OS successfully + + Command: cp /etc/sonic/minigraph.xml /host/ + + Command: grub-set-default --boot-directory=/host 0 + + Done + ``` + +Installing a new image using the sonic-installer will keep using the packages installed on the currently running SONiC image and automatically migrate those. In order to perform clean SONiC installation use the *--skip-package-migration* option: + +- Example: + ``` + admin@sonic:~$ sudo sonic-installer install https://sonic-jenkins.westus.cloudapp.azure.com/job/xxxx/job/buildimage-xxxx-all/xxx/artifact/target/sonic-xxxx.bin --skip-package-migration + ``` + +**sonic-installer set_default** + +This command is be used to change the image which can be loaded by default in all the subsequent reboots. + +- Usage: + ``` + sonic-installer set_default + ``` + +- Example: + ``` + admin@sonic:~$ sudo sonic-installer set_default SONiC-OS-HEAD.XXXX + ``` + +**sonic-installer set_next_boot** + +This command is used to change the image that can be loaded in the *next* reboot only. Note that it will fallback to current image in all other subsequent reboots after the next reboot. + +- Usage: + ``` + sonic-installer set_next_boot + ``` + +- Example: + ``` + admin@sonic:~$ sudo sonic-installer set_next_boot SONiC-OS-HEAD.XXXX + ``` + +**sonic-installer remove** + +This command is used to remove the unused SONiC image from the disk. Note that it's *not* allowed to remove currently running image. + +- Usage: + ``` + sonic-installer remove [-y|--yes] + ``` + +- Example: + ``` + admin@sonic:~$ sudo sonic-installer remove SONiC-OS-HEAD.YYYY + Image will be removed, continue? [y/N]: y + Updating GRUB... + Done + Removing image root filesystem... + Done + Command: grub-set-default --boot-directory=/host 0 + + Image removed + ``` + +**sonic-installer cleanup** + +This command removes all unused images from the device, leaving only the currently active image and the image which will be booted into next (if different) installed. If there are no images which can be removed, the command will output `No image(s) to remove` + +- Usage: + ``` + sonic-installer cleanup [-y|--yes] + ``` + +- Example: + ``` + admin@sonic:~$ sudo sonic-installer cleanup + Remove images which are not current and next, continue? [y/N]: y + No image(s) to remove + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#software-installation-and-management) + + + +## Troubleshooting Commands + +For troubleshooting and debugging purposes, this command gathers pertinent information about the state of the device; information is as diverse as syslog entries, database state, routing-stack state, etc., It then compresses it into an archive file. This archive file can be sent to the SONiC development team for examination. +Resulting archive file is saved as `/var/dump/_YYYYMMDD_HHMMSS.tar.gz` + +- Usage: + ``` + show techsupport + ``` + +- Example: + ``` + admin@sonic:~$ show techsupport [--since=] + ``` + +If the SONiC system was running for quite some time `show techsupport` will produce a large dump file. To reduce the amount of syslog and core files gathered during system dump use `--since` option: + +- Examples: + ``` + admin@sonic:~$ show techsupport --since=yesterday # Will collect syslog and core files for the last 24 hours + ``` + ``` + admin@sonic:~$ show techsupport --since='hour ago' # Will collect syslog and core files for the last one hour + ``` + +### Debug Dumps + +In SONiC, there usually exists a set of tables related/relevant to a particular module. All of these might have to be looked at to confirm whether any configuration update is properly applied and propagated. This utility comes in handy because it prints a unified view of the redis-state for a given module + +- Usage: + ``` + Usage: dump state [OPTIONS] MODULE IDENTIFIER + Dump the redis-state of the identifier for the module specified + + Options: + -s, --show Display Modules Available + -d, --db TEXT Only dump from these Databases + -t, --table Print in tabular format [default: False] + -k, --key-map Only fetch the keys matched, don't extract field-value dumps [default: False] + -v, --verbose Prints any intermediate output to stdout useful for dev & troubleshooting [default: False] + -n, --namespace TEXT Dump the redis-state for this namespace. [default: DEFAULT_NAMESPACE] + --help Show this message and exit. + ``` + + +- Examples: + ``` + root@sonic# dump state --show + Module Identifier + -------- ------------ + port port_name + copp trap_id + ``` + + ``` + admin@sonic:~$ dump state copp arp_req --key-map --db ASIC_DB + { + "arp_req": { + "ASIC_DB": { + "keys": [ + "ASIC_STATE:SAI_OBJECT_TYPE_HOSTIF_TRAP:oid:0x22000000000c5b", + "ASIC_STATE:SAI_OBJECT_TYPE_HOSTIF_TRAP_GROUP:oid:0x11000000000c59", + "ASIC_STATE:SAI_OBJECT_TYPE_POLICER:oid:0x12000000000c5a", + "ASIC_STATE:SAI_OBJECT_TYPE_QUEUE:oid:0x15000000000626" + ], + "tables_not_found": [], + "vidtorid": { + "oid:0x22000000000c5b": "oid:0x200000000022", + "oid:0x11000000000c59": "oid:0x300000011", + "oid:0x12000000000c5a": "oid:0x200000012", + "oid:0x15000000000626": "oid:0x12e0000040015" + } + } + } + } + ``` + +### Event Driven Techsupport Invocation + +This feature/capability makes the techsupport invocation event-driven based on core dump generation. This feature is only applicable for the processes running in the containers. More detailed explanation can be found in the HLD https://github.com/Azure/SONiC/blob/master/doc/auto_techsupport_and_coredump_mgmt.md + +#### config auto-techsupport global commands + +**config auto-techsupport global state** + +- Usage: + ``` + config auto-techsupport global state + ``` + +- Example: + ``` + config auto-techsupport global state enabled + ``` + +**config auto-techsupport global rate-limit-interval ** + +- Usage: + ``` + config auto-techsupport global rate-limit-interval + ``` + - Parameters: + - rate-limit-interval: Minimum time in seconds to wait after the last techsupport creation time before invoking a new one. + +- Example: + ``` + config auto-techsupport global rate-limit-interval 200 + ``` + +**config auto-techsupport global max-techsupport-limit ** + +- Usage: + ``` + config auto-techsupport global max-techsupport-limit + ``` + - Parameters: + - max-techsupport-limit: A percentage value should be specified. This signifies maximum size to which /var/dump/ directory can be grown until. + +- Example: + ``` + config auto-techsupport global max-techsupport-limit 10.15 + ``` + +**config auto-techsupport global max-core-limit ** + +- Usage: + ``` + config auto-techsupport global max-core-limit + ``` + - Parameters: + - max-core-limit: A percentage value should be specified. This signifies maximum size to which /var/core/ directory can be grown until. + +- Example: + ``` + config auto-techsupport global max-core-limit 10.15 + ``` + +**config auto-techsupport global since** + +- Usage: + ``` + config auto-techsupport global since + ``` + - Parameters: + - since: This limits the auto-invoked techsupport to only collect the logs & core-dumps generated since the time provided. Any valid date string of the formats specified here can be used. (https://www.gnu.org/software/coreutils/manual/html_node/Date-input-formats.html). If this value is not explicitly configured or a non-valid string is provided, a default value of "2 days ago" is used. + +- Example: + ``` + config auto-techsupport global since + ``` + + +#### config auto-techsupport-feature commands + +**config auto-techsupport-feature add** + +- Usage: + ``` + config auto-techsupport-feature add --state --rate-limit-interval + ``` + - Parameters: + - state: enable/disable the capability for the specific feature/container. + - rate-limit-interval: Rate limit interval for the corresponding feature. Configure 0 to explicitly disable. For the techsupport to be generated by auto-techsupport, both the global and feature specific rate-limit-interval has to be passed + +- Example: + ``` + config auto-techsupport-feature add bgp --state enabled --rate-limit-interval 200 + ``` + + +**config auto-techsupport-feature delete** + +- Usage: + ``` + config auto-techsupport-feature delete + ``` + +- Example: + ``` + config auto-techsupport-feature delete swss + ``` + +**config auto-techsupport-feature update** + +- Usage: + ``` + config auto-techsupport-feature update --state + config auto-techsupport-feature update --rate-limit-interval + ``` + +- Example: + ``` + config auto-techsupport-feature update snmp --state enabled + config auto-techsupport-feature update swss --rate-limit-interval 200 + ``` + +#### Show CLI: + +**show auto-techsupport global** + +- Usage: + ``` + show auto-techsupport global + ``` + +- Example: + ``` + admin@sonic:~$ show auto-techsupport global + STATE RATE LIMIT INTERVAL (sec) MAX TECHSUPPORT LIMIT (%) MAX CORE LIMIT (%) SINCE + ------- --------------------------- -------------------------- ------------------ ---------- + enabled 180 10.0 5.0 2 days ago + ``` + +**show auto-techsupport-feature** + +- Usage: + ``` + show auto-techsupport-feature + ``` + +- Example: + ``` + admin@sonic:~$ show auto-techsupport-feature + FEATURE NAME STATE RATE LIMIT INTERVAL (sec) + -------------- -------- -------------------------- + bgp enabled 600 + database enabled 600 + dhcp_relay enabled 600 + lldp enabled 600 + swss disabled 800 + ``` + +**show auto-techsupport history** + +- Usage: + ``` + show auto-techsupport history + ``` + +- Example: + ``` + admin@sonic:~$ show auto-techsupport history + TECHSUPPORT DUMP TRIGGERED BY CORE DUMP + ---------------------------------------- -------------- ----------------------------- + sonic_dump_r-lionfish-16_20210901_221402 bgp bgpcfgd.1630534439.55.core.gz + sonic_dump_r-lionfish-16_20210901_203725 snmp python3.1630528642.23.core.gz + sonic_dump_r-lionfish-16_20210901_222408 teamd python3.1630535045.34.core.gz + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#troubleshooting-commands) + +## Routing Stack + +SONiC software is agnostic of the routing software that is being used in the device. For example, users can use either Quagga or FRR routing stack as per their requirement. +A separate shell (vtysh) is provided to configure such routing stacks. +Once if users go to "vtysh", they can use the routing stack specific commands as given in the following example. + +- Example (Quagga Routing Stack): + ``` + admin@sonic:~$ vtysh + + Hello, this is Quagga (version 0.99.24.1). + Copyright 1996-2005 Kunihiro Ishiguro, et al. + + sonic# show route-map (This command displays the route-map that is configured for the routing protocol.) + ZEBRA: + route-map RM_SET_SRC, permit, sequence 10 + Match clauses: + Set clauses: + src 10.12.0.102 + Call clause: + Action: + Exit routemap + ``` + +Refer the routing stack [Quagga Command Reference](https://www.quagga.net/docs/quagga.pdf) or [FRR Command Reference](https://buildmedia.readthedocs.org/media/pdf/frrouting/latest/frrouting.pdf) to know more about about the routing stack configuration. + + +Go Back To [Beginning of the document](#) or [Beginning of this section](#routing-stack) + + +## Quagga BGP Show Commands + +**show ip bgp summary** + +This command displays the summary of all IPv4 bgp neighbors that are configured and the corresponding states. + +- Usage: + ``` + show ip bgp summary + ``` + +- Example: + ``` + admin@sonic:~$ show ip bgp summary + BGP router identifier 1.2.3.4, local AS number 65061 + RIB entries 6124, using 670 KiB of memory + Peers 2, using 143 KiB of memory + + Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd + 192.168.1.161 4 65501 88698 102781 0 0 0 08w5d14h 2 + 192.168.1.163 4 65502 88698 102780 0 0 0 08w5d14h 2 + + Total number of neighbors 2 + ``` + +**show ip bgp neighbors** + +This command displays all the details of IPv4 & IPv6 BGP neighbors when no optional argument is specified. + +When the optional argument IPv4_address is specified, it displays the detailed neighbor information about that specific IPv4 neighbor. + +Command has got additional optional arguments to display only the advertised routes, or the received routes, or all routes. + +In order to get details for an IPv6 neigbor, use "show ipv6 bgp neighbor " command. + +- Usage: + ``` + show ip bgp neighbors [ [advertised-routes | received-routes | routes]] + ``` + +- Example: + ``` + admin@sonic:~$ show ip bgp neighbors + BGP neighbor is 192.168.1.161, remote AS 65501, local AS 65061, external link + Description: ARISTA01T0 + BGP version 4, remote router ID 1.2.3.4 + BGP state = Established, up for 08w5d14h + Last read 00:00:46, hold time is 180, keepalive interval is 60 seconds + Neighbor capabilities: + 4 Byte AS: advertised and received + Dynamic: received + Route refresh: advertised and received(old & new) + Address family IPv4 Unicast: advertised and received + Graceful Restart Capabilty: advertised and received + Remote Restart timer is 120 seconds + Address families by peer: + IPv4 Unicast(not preserved) + Graceful restart informations: + End-of-RIB send: IPv4 Unicast + End-of-RIB received: IPv4 Unicast + Message statistics: + Inq depth is 0 + Outq depth is 0 + Sent Rcvd + Opens: 1 1 + Notifications: 0 0 + Updates: 14066 3 + Keepalives: 88718 88698 + Route Refresh: 0 0 + Capability: 0 0 + Total: 102785 88702 + Minimum time between advertisement runs is 30 seconds + + For address family: IPv4 Unicast + Community attribute sent to this neighbor(both) + 2 accepted prefixes + + Connections established 1; dropped 0 + Last reset never + Local host: 192.168.1.160, Local port: 32961 + Foreign host: 192.168.1.161, Foreign port: 179 + Nexthop: 192.168.1.160 + Nexthop global: fe80::f60f:1bff:fe89:bc00 + Nexthop local: :: + BGP connection: non shared network + Read thread: on Write thread: off + ``` + +Optionally, you can specify an IP address in order to display only that particular neighbor. In this mode, you can optionally specify whether you want to display all routes advertised to the specified neighbor, all routes received from the specified neighbor or all routes (received and accepted) from the specified neighbor. + + +- Examples: + ``` + admin@sonic:~$ show ip bgp neighbors 192.168.1.161 + + admin@sonic:~$ show ip bgp neighbors 192.168.1.161 advertised-routes + + admin@sonic:~$ show ip bgp neighbors 192.168.1.161 received-routes + + admin@sonic:~$ show ip bgp neighbors 192.168.1.161 routes + ``` + +**show ipv6 bgp summary** + +This command displays the summary of all IPv4 bgp neighbors that are configured and the corresponding states. + +- Usage: + ``` + show ipv6 bgp summary + ``` + +- Example: + ``` + admin@sonic:~$ show ipv6 bgp summary + BGP router identifier 10.1.0.32, local AS number 65100 + RIB entries 12809, using 1401 KiB of memory + Peers 8, using 36 KiB of memory + + Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd + fc00::72 4 64600 12588 12591 0 0 0 06:51:17 6402 + fc00::76 4 64600 12587 6190 0 0 0 06:51:28 6402 + fc00::7a 4 64600 12587 9391 0 0 0 06:51:23 6402 + fc00::7e 4 64600 12589 12592 0 0 0 06:51:25 6402 + + Total number of neighbors 4 + ``` + +**show ipv6 bgp neighbors** + +This command displays all the details of one particular IPv6 Border Gateway Protocol (BGP) neighbor. Option is also available to display only the advertised routes, or the received routes, or all routes. + +- Usage: + ``` + show ipv6 bgp neighbors (advertised-routes | received-routes | routes) + ``` + +- Examples: + ``` + admin@sonic:~$ show ipv6 bgp neighbors fc00::72 advertised-routes + + admin@sonic:~$ show ipv6 bgp neighbors fc00::72 received-routes + + admin@sonic:~$ show ipv6 bgp neighbors fc00::72 routes + ``` + +**show route-map** + +This command displays the routing policy that takes precedence over the other route processes that are configured. + +- Usage: + ``` + show route-map + ``` + +- Example: + ``` + admin@sonic:~$ show route-map + ZEBRA: + route-map RM_SET_SRC, permit, sequence 10 + Match clauses: + Set clauses: + src 10.12.0.102 + Call clause: + Action: + Exit routemap + ZEBRA: + route-map RM_SET_SRC6, permit, sequence 10 + Match clauses: + Set clauses: + src fc00:1::102 + Call clause: + Action: + Exit routemap + BGP: + route-map FROM_BGP_SPEAKER_V4, permit, sequence 10 + Match clauses: + Set clauses: + Call clause: + Action: + Exit routemap + BGP: + route-map TO_BGP_SPEAKER_V4, deny, sequence 10 + Match clauses: + Set clauses: + Call clause: + Action: + Exit routemap + BGP: + route-map ISOLATE, permit, sequence 10 + Match clauses: + Set clauses: + as-path prepend 65000 + Call clause: + Action: + Exit routemap + ``` +Go Back To [Beginning of the document](#) or [Beginning of this section](#quagga-bgp-show-commands) + +# ZTP Configuration And Show Commands + +This section explains all the Zero Touch Provisioning commands that are supported in SONiC. + +## ZTP show commands + + +This command displays the current ZTP configuration of the switch. It also displays detailed information about current state of a ZTP session. It displays information related to all configuration sections as defined in the switch provisioning information discovered in a particular ZTP session. + +- Usage: + show ztp status + + show ztp status --verbose + +- Example: + +``` +root@B1-SP1-7712:/home/admin# show ztp status +ZTP Admin Mode : True +ZTP Service : Inactive +ZTP Status : SUCCESS +ZTP Source : dhcp-opt67 (eth0) +Runtime : 05m 31s +Timestamp : 2019-09-11 19:12:24 UTC + +ZTP Service is not running + +01-configdb-json: SUCCESS +02-connectivity-check: SUCCESS +``` +Use the verbose option to display more detailed information. + +``` +root@B1-SP1-7712:/home/admin# show ztp status --verbose +Command: ztp status --verbose +------------------------------------- +ZTP +------------------------------------- +ZTP Admin Mode : True +ZTP Service : Inactive +ZTP Status : SUCCESS +ZTP Source : dhcp-opt67 (eth0) +Runtime : 05m 31s +Timestamp : 2019-09-11 19:12:16 UTC +ZTP JSON Version : 1.0 + +ZTP Service is not running + +---------------------------------------- +01-configdb-json +---------------------------------------- +Status : SUCCESS +Runtime : 02m 48s +Timestamp : 2019-09-11 19:11:55 UTC +Exit Code : 0 +Ignore Result : False + +---------------------------------------- +02-connectivity-check +---------------------------------------- +Status : SUCCESS +Runtime : 04s +Timestamp : 2019-09-11 19:12:16 UTC +Exit Code : 0 +Ignore Result : False +``` + +- Description + + - **ZTP Admin Mode** - Displays if the ZTP feature is administratively enabled or disabled. Possible values are True or False. This value is configurable using "config ztp enabled" and "config ztp disable" commands. + - **ZTP Service** - Displays the ZTP service status. The following are possible values this field can display: + - *Active Discovery*: ZTP service is operational and is performing DHCP discovery to learn switch provisioning information + - *Processing*: ZTP service has discovered switch provisioning information and is processing it + - **ZTP Status** - Displays the current state and result of ZTP session. The following are possible values this field can display: + - *IN-PROGRESS*: ZTP session is currently in progress. ZTP service is processing switch provisioning information. + - *SUCCESS*: ZTP service has successfully processed the switch provisioning information. + - *FAILED*: ZTP service has failed to process the switch provisioning information. + - *Not Started*: ZTP service has not started processing the discovered switch provisioning information. + - **ZTP Source** - Displays the DHCP option and then interface name from which switch provisioning information has been discovered. + - **Runtime** - Displays the time taken for ZTP process to complete from start to finish. For individual configuration sections it indicates the time taken to process the associated configuration section. + - **Timestamp** - Displays the date/time stamp when the status field has last changed. + - **ZTP JSON Version** - Version of ZTP JSON file used for describing switch provisioning information. + - **Status** - Displays the current state and result of a configuration section. The following are possible values this field can display: + - *IN-PROGRESS*: Corresponding configuration section is currently being processed. + - *SUCCESS*: Corresponding configuration section was processed successfully. + - *FAILED*: Corresponding configuration section failed to execute successfully. + - *Not Started*: ZTP service has not started processing the corresponding configuration section. + - *DISABLED*: Corresponding configuration section has been marked as disabled and will not be processed. + - **Exit Code** - Displays the program exit code of the configuration section executed. Non-zero exit code indicates that the configuration section has failed to execute successfully. + - **Ignore Result** - If this value is True, the result of the corresponding configuration section is ignored and not used to evaluate the overall ZTP result. + - **Activity String** - In addition to above information an activity string is displayed indicating the current action being performed by the ZTP service and how much time it has been performing the mentioned activity. Below is an example. + - (04m 12s) Discovering provisioning data + +## ZTP configuration commands + +This sub-section explains the list of the configuration options available for ZTP. + + + +**config ztp enable** + +Use this command to enable ZTP administrative mode + +- Example: + +``` +root@sonic:/home/admin# config ztp enable +Running command: ztp enable +``` + + + +**config ztp disable** + +Use this command to disable ZTP administrative mode. This command can also be used to abort a current ZTP session and load the factory default switch configuration. + +- Usage: + config ztp disable + + config ztp disable -y + +- Example: + +``` +root@sonic:/home/admin# config ztp disable +Active ZTP session will be stopped and disabled, continue? [y/N]: y +Running command: ztp disable -y +``` + + +**config ztp run** + +Use this command to manually restart a new ZTP session. This command deletes the existing */etc/sonic/config_db.json* file and stats ZTP service. It also erases the previous ZTP session data. ZTP configuration is loaded on to the switch and ZTP discovery is performed. + +- Usage: + config ztp run + + config ztp run -y + +- Example: + +``` +root@sonic:/home/admin# config ztp run +ZTP will be restarted. You may lose switch data and connectivity, continue? [y/N]: y +Running command: ztp run -y +``` + +Go Back To [Beginning of the document](#SONiC-COMMAND-LINE-INTERFACE-GUIDE) or [Beginning of this section](#ztp-configuration-and-show-commands) +---------------- +# SONiC Command Line Interface Guide + +## Table of Contents + +* [Document History](#document-history) +* [Introduction](#introduction) +* [Basic Tasks](#basic-tasks) + * [SSH Login](#ssh-login) + * [Show Management Interface](#show-management-interface) + * [Configuring Management Interface](#configuring-management-interface) +* [Getting Help](#getting-help) + * [Help for Config Commands](#help-for-config-commands) + * [Help for Show Commands](#help-for-show-commands) +* [Basic Show Commands](#basic-show-commands) + * [Show Versions](#show-versions) + * [Show System Status](#show-system-status) + * [Show Hardware Platform](#show-hardware-platform) + * [Transceivers](#transceivers) +* [AAA & TACACS+](#aaa--tacacs) + * [AAA](#aaa) + * [AAA show commands](#aaa-show-commands) + * [AAA config commands](#aaa-config-commands) + * [TACACS+](#tacacs) + * [TACACS+ show commands](#tacacs-show-commands) + * [TACACS+ config commands](#tacacs-config-commands) +* [ACL](#acl) + * [ACL show commands](#acl-show-commands) + * [ACL config commands](#acl-config-commands) +* [ARP & NDP](#arp--ndp) + * [ARP show commands](#arp-show-commands) + * [NDP show commands](#ndp-show-commands) +* [BFD](#bfd) + * [BFD show commands](#bfd-show-commands) +* [BGP](#bgp) + * [BGP show commands](#bgp-show-commands) + * [BGP config commands](#bgp-config-commands) +* [Console](#console) + * [Console show commands](#console-show-commands) + * [Console config commands](#console-config-commands) + * [Console connect commands](#console-connect-commands) + * [Console clear commands](#console-clear-commands) +* [DHCP Relay](#dhcp-relay) + * [DHCP Relay config commands](#dhcp-relay-config-commands) +* [Drop Counters](#drop-counters) + * [Drop Counter show commands](#drop-counters-show-commands) + * [Drop Counter config commands](#drop-counters-config-commands) + * [Drop Counter clear commands](#drop-counters-clear-commands) +* [Dynamic Buffer Management](#dynamic-buffer-management) + * [Configuration commands](#configuration-commands) + * [Show commands](#show-commands) +* [ECN](#ecn) + * [ECN show commands](#ecn-show-commands) + * [ECN config commands](#ecn-config-commands) +* [Feature](#feature) + * [Feature show commands](#feature-show-commands) + * [Feature config commands](#feature-config-commands) +* [Flow Counters](#flow-counters) + * [Flow Counters show commands](#flow-counters-show-commands) + * [Flow Counters clear commands](#flow-counters-clear-commands) + * [Flow Counters config commands](#flow-counters-config-commands) +* [Gearbox](#gearbox) + * [Gearbox show commands](#gearbox-show-commands) +* [Interfaces](#interfaces) + * [Interface Show Commands](#interface-show-commands) + * [Interface Config Commands](#interface-config-commands) +* [Interface Naming Mode](#interface-naming-mode) + * [Interface naming mode show commands](#interface-naming-mode-show-commands) + * [Interface naming mode config commands](#interface-naming-mode-config-commands) + * [Interface Vrf binding](#interface-vrf-binding) + * [Interface vrf bind & unbind config commands](#interface-vrf-bind-&-unbind-config-commands) + * [Interface vrf binding show commands](#interface-vrf-binding-show-commands) +* [IP / IPv6](#ip--ipv6) + * [IP show commands](#ip-show-commands) + * [IPv6 show commands](#ipv6-show-commands) +* [IPv6 Link Local](#ipv6-link-local) + * [IPv6 Link Local config commands](#ipv6-link-local-config-commands) + * [IPv6 Link Local show commands](#ipv6-link-local-show-commands) +* [Kubernetes](#Kubernetes) + * [Kubernetes show commands](#Kubernetes-show-commands) + * [Kubernetes config commands](#Kubernetes-config-commands) +* [Linux Kernel Dump](#kdump) + * [Linux Kernel Dump show commands](#kdump-show-commands) + * [Linux Kernel Dump config commands](#kdump-config-commands) +* [LLDP](#lldp) + * [LLDP show commands](#lldp-show-commands) +* [Loading, Reloading And Saving Configuration](#loading-reloading-and-saving-configuration) + * [Loading configuration from JSON file](#loading-configuration-from-json-file) + * [Loading configuration from minigraph (XML) file](#loading-configuration-from-minigraph-xml-file) + * [Reloading Configuration](#reloading-configuration) + * [Loading Management Configuration](#loading-management-configuration) + * [Saving Configuration to a File for Persistence](saving-configuration-to-a-file-for-persistence) + * [Loopback Interfaces](#loopback-interfaces) + * [Loopback show commands](#loopback-show-commands) + * [Loopback config commands](#loopback-config-commands) +* [VRF Configuration](#vrf-configuration) + * [VRF show commands](#vrf-show-commands) + * [VRF config commands](#vrf-config-commands) +* [Management VRF](#Management-VRF) + * [Management VRF Show commands](#management-vrf-show-commands) + * [Management VRF Config commands](#management-vrf-config-commands) +* [Mirroring](#mirroring) + * [Mirroring Show commands](#mirroring-show-commands) + * [Mirroring Config commands](#mirroring-config-commands) +* [Muxcable](#muxcable) + * [Muxcable Show commands](#muxcable-show-commands) + * [Muxcable Config commands](#muxcable-config-commands) +* [NAT](#nat) + * [NAT Show commands](#nat-show-commands) + * [NAT Config commands](#nat-config-commands) + * [NAT Clear commands](#nat-clear-commands) +* [NTP](#ntp) + * [NTP show commands](#ntp-show-commands) + * [NTP config commands](#ntp-config-commands) +* [NVGRE](#nvgre) + * [NVGRE show commands](#nvgre-show-commands) + * [NVGRE config commands](#nvgre-config-commands) +* [PBH](#pbh) + * [PBH show commands](#pbh-show-commands) + * [PBH config commands](#pbh-config-commands) +* [PFC Watchdog Commands](#pfc-watchdog-commands) +* [Platform Component Firmware](#platform-component-firmware) + * [Platform Component Firmware show commands](#platform-component-firmware-show-commands) + * [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) +* [QoS](#qos) + * [QoS Show commands](#qos-show-commands) + * [PFC](#pfc) + * [Queue And Priority-Group](#queue-and-priority-group) + * [Buffer Pool](#buffer-pool) + * [QoS config commands](#qos-config-commands) +* [sFlow](#sflow) + * [sFlow Show commands](#sflow-show-commands) + * [sFlow Config commands](#sflow-config-commands) +* [SNMP](#snmp) + * [SNMP Show commands](#snmp-show-commands) + * [SNMP Config commands](#snmp-config-commands) +* [Startup & Running Configuration](#startup--running-configuration) + * [Startup Configuration](#startup-configuration) + * [Running Configuration](#running-configuration) +* [Static routing](#static-routing) +* [Subinterfaces](#subinterfaces) + * [Subinterfaces Show Commands](#subinterfaces-show-commands) + * [Subinterfaces Config Commands](#subinterfaces-config-commands) +* [Syslog](#syslog) + * [Syslog config commands](#syslog-config-commands) +* [System State](#system-state) + * [Processes](#processes) + * [Services & Memory](#services--memory) +* [System-Health](#System-Health) +* [VLAN & FDB](#vlan--fdb) + * [VLAN](#vlan) + * [VLAN show commands](#vlan-show-commands) + * [VLAN Config commands](#vlan-config-commands) + * [FDB](#fdb) + * [FDB show commands](#fdb-show-commands) +* [VxLAN & Vnet](#vxlan--vnet) + * [VxLAN](#vxlan) + * [VxLAN show commands](#vxlan-show-commands) + * [Vnet](#vnet) + * [Vnet show commands](#vnet-show-commands) +* [Warm Reboot](#warm-reboot) +* [Warm Restart](#warm-restart) + * [Warm Restart show commands](#warm-restart-show-commands) + * [Warm Restart Config commands](#warm-restart-config-commands) +* [Watermark](#watermark) + * [Watermark Show commands](#watermark-show-commands) + * [Watermark Config commands](#watermark-config-commands) +* [Software Installation and Management](#software-installation-and-management) + * [SONiC Package Manager](#sonic-package-manager) + * [SONiC Installer](#sonic-installer) +* [Troubleshooting Commands](#troubleshooting-commands) + * [Debug Dumps](#debug-dumps) + * [Event Driven Techsupport Invocation](#event-driven-techsupport-invocation) +* [Routing Stack](#routing-stack) +* [Quagga BGP Show Commands](#Quagga-BGP-Show-Commands) +* [ZTP Configuration And Show Commands](#ztp-configuration-and-show-commands) + * [ ZTP show commands](#ztp-show-commands) + * [ZTP configuration commands](#ztp-configuration-commands) + +## Document History + +| Version | Modification Date | Details | +| --- | --- | --- | +| v6 | May-06-2021 | Add SNMP show and config commands | +| v5 | Nov-05-2020 | Add document for console commands | +| v4 | Oct-17-2019 | Unify usage statements and other formatting; Replace tabs with spaces; Modify heading sizes; Fix spelling, grammar and other errors; Fix organization of new commands | +| v3 | Jun-26-2019 | Update based on 201904 (build#19) release, "config interface" command changes related to interfacename order, FRR/Quagga show command changes, platform specific changes, ACL show changes and few formatting changes | +| v2 | Apr-22-2019 | CLI Guide for SONiC 201811 version (build#32) with complete "config" command set | +| v1 | Mar-23-2019 | Initial version of CLI Guide with minimal command set | + +## Introduction +SONiC is an open source network operating system based on Linux that runs on switches from multiple vendors and ASICs. SONiC offers a full-suite of network functionality, like BGP and RDMA, that has been production-hardened in the data centers of some of the largest cloud-service providers. It offers teams the flexibility to create the network solutions they need while leveraging the collective strength of a large ecosystem and community. + +SONiC software shall be loaded in these [supported devices](https://github.com/Azure/SONiC/wiki/Supported-Devices-and-Platforms) and this CLI guide shall be used to configure the devices as well as to display the configuration, state and status. + +Follow the [Quick Start Guide](https://github.com/Azure/SONiC/wiki/Quick-Start) to boot the device in ONIE mode, install the SONiC software using the steps specified in the document and login to the device using the default username and password. + +After logging into the device, SONiC software can be configured in following three methods. + 1. Command Line Interface (CLI) + 2. [config_db.json](https://github.com/Azure/SONiC/wiki/Configuration) + 3. [minigraph.xml](https://github.com/Azure/SONiC/wiki/Configuration-with-Minigraph-(~Sep-2017)) + +This document explains the first method and gives the complete list of commands that are supported in SONiC 201904 version (build#19). +All the configuration commands need root privileges to execute them. Note that show commands can be executed by all users without the root privileges. +Root privileges can be obtained either by using "sudo" keyword in front of all config commands, or by going to root prompt using "sudo -i". +Note that all commands are case sensitive. + +- Example: + ``` + admin@sonic:~$ sudo config aaa authentication login tacacs+ + + OR + + admin@sonic:~$ sudo -i + root@sonic:~# config aaa authentication login tacacs+ + ``` + +Note that the command list given in this document is just a subset of all possible configurations in SONiC. +Please follow config_db.json based configuration for the complete list of configuration options. + +**Scope of this Document** + +It is assumed that all configuration commands start with the keyword “config” as prefix. +Any other scripts/utilities/commands that need user configuration control are wrapped as sub-commands under the “config” command. +The direct scripts/utilities/commands (examples given below) that are not wrapped under the "config" command are not in the scope of this document. + 1. acl_loader – This script is already wrapped inside “config acl” command; i.e. any ACL configuration that user is allowed to do is already part of “config acl” command; users are not expected to use the acl_loader script directly and hence this document need not explain the “acl_loader” script. + 2. crm – this command is not explained in this document. + 3. sonic-clear, sfputil, etc., This document does not explain these scripts also. + +## Basic Tasks + +This section covers the basic configurations related to the following: + 1. [SSH login](#SSH-Login) + 2. [Configuring the Management Interface](#Configuring-Management-Interface) + +### SSH Login + +All SONiC devices support both the serial console based login and the SSH based login by default. +The default credential (if not modified at image build time) for login is `admin/YourPaSsWoRd`. +In case of SSH login, users can login to the management interface (eth0) IP address after configuring the same using serial console. +Refer the following section for configuring the IP address for management interface. + +- Example: + ``` + At Console: + Debian GNU/Linux 9 sonic ttyS1 + + sonic login: admin + Password: YourPaSsWoRd + + SSH from any remote server to sonic can be done by connecting to SONiC IP + user@debug:~$ ssh admin@sonic_ip_address(or SONIC DNS Name) + admin@sonic's password: + ``` + +By default, login takes the user to the default prompt from which all the show commands can be executed. + +Go Back To [Beginning of the document](#) or [Beginning of this section](#basic-tasks) + +### Show Management Interface + +Please check [show ip interfaces](#show-ip-interfaces) + +### Configuring Management Interface + +The management interface (eth0) in SONiC is configured (by default) to use DHCP client to get the IP address from the DHCP server. Connect the management interface to the same network in which your DHCP server is connected and get the IP address from DHCP server. +The IP address received from DHCP server can be verified using the `/sbin/ifconfig eth0` Linux command. + +SONiC provides a CLI to configure the static IP for the management interface. There are few ways by which a static IP address can be configured for the management interface. + 1. Use the `config interface ip add eth0` command. + - Example: + ``` + admin@sonic:~$ sudo config interface ip add eth0 20.11.12.13/24 20.11.12.254 + ``` + 2. Use config_db.json and configure the MGMT_INTERFACE key with the appropriate values. Refer [here](https://github.com/Azure/SONiC/wiki/Configuration#Management-Interface) + 3. Use minigraph.xml and configure "ManagementIPInterfaces" tag inside "DpgDesc" tag as given at the [page](https://github.com/Azure/SONiC/wiki/Configuration-with-Minigraph-(~Sep-2017)) + +Once the IP address is configured, the same can be verified using either `show management_interface address` command or the `/sbin/ifconfig eth0` linux command. +Users can SSH login to this management interface IP address from their management network. + +- Example: + ``` + admin@sonic:~$ /sbin/ifconfig eth0 + eth0: flags=4163 mtu 1500 + inet 10.11.11.13 netmask 255.255.255.0 broadcast 10.11.12.255 + ``` +Go Back To [Beginning of the document](#) or [Beginning of this section](#basic-tasks) + +## Getting Help + +Subsections: + 1. [Help for Config Commands](#Config-Help) + 2. [Help for Show Commands](#Show-Help) + 3. [Show Versions](#Show-Versions) + 4. [Show System Status](#Show-System-Status) + 5. [Show Hardware Platform](#Show-Hardware-Platform) + +### Help for Config Commands + +All commands have in-built help that aids the user in understanding the command as well as the possible sub-commands and options. +"--help" can be used at any level of the command; i.e. it can be used at the command level, or sub-command level or at argument level. The in-built help will display the available possibilities corresponding to that particular command/sub-command. + +**config --help** + +This command lists all the possible configuration commands at the top level. + +- Usage: + ``` + config --help + ``` + +- Example: + ``` + admin@sonic:~$ config --help + Usage: config [OPTIONS] COMMAND [ARGS] + SONiC command line - 'config' command + + Options: + --help Show this message and exit. + + Commands: + aaa AAA command line + acl ACL-related configuration tasks + bgp BGP-related configuration tasks + ecn ECN-related configuration tasks + feature Modify configuration of features + hostname Change device hostname without impacting traffic + interface Interface-related configuration tasks + interface_naming_mode Modify interface naming mode for interacting... + kubernetes Kubernetes server related configuration + load Import a previous saved config DB dump file. + load_mgmt_config Reconfigure hostname and mgmt interface based... + load_minigraph Reconfigure based on minigraph. + loopback Loopback-related configuration tasks. + mirror_session + nat NAT-related configuration tasks + platform Platform-related configuration tasks + portchannel + qos + reload Clear current configuration and import a... + route route-related configuration tasks + save Export current config DB to a file on disk. + tacacs TACACS+ server configuration + vlan VLAN-related configuration tasks + vrf VRF-related configuration tasks + warm_restart warm_restart-related configuration tasks + watermark Configure watermark + ``` +Go Back To [Beginning of the document](#) or [Beginning of this section](#getting-help) + +### Help For Show Commands + +**show help** + +This command displays the full list of show commands available in the software; the output of each of those show commands can be used to analyze, debug or troubleshoot the network node. + +- Usage: + ``` + show (-?|-h|--help) + ``` + +- Example: + ``` + admin@sonic:~$ show -? + Usage: show [OPTIONS] COMMAND [ARGS]... + SONiC command line - 'show' command + + Options: + -?, -h, --help Show this message and exit. + + Commands: + aaa Show AAA configuration + acl Show ACL related information + arp Show IP ARP table + buffer_pool Show details of the Buffer-pools + clock Show date and time + ecn Show ECN configuration + environment Show environmentals (voltages, fans, temps) + feature Show feature status + interfaces Show details of the network interfaces + ip Show IP (IPv4) commands + ipv6 Show IPv6 commands + kubernetes Show kubernetes commands + line Show all /dev/ttyUSB lines and their info + lldp Show LLDP information + logging Show system log + mac Show MAC (FDB) entries + mirror_session Show existing everflow sessions + mmu Show mmu configuration + muxcable Show muxcable information + nat Show details of the nat + ndp Show IPv6 Neighbour table + ntp Show NTP information + pfc Show details of the priority-flow-control... + platform Show platform-specific hardware info + priority-group Show details of the PGs + processes Show process information + queue Show details of the queues + reboot-cause Show cause of most recent reboot + route-map Show route-map + runningconfiguration Show current running configuration... + services Show all daemon services + startupconfiguration Show startup configuration information + subinterfaces Show details of the sub port interfaces + system-memory Show memory information + tacacs Show TACACS+ configuration + techsupport Gather information for troubleshooting + uptime Show system uptime + users Show users + version Show version information + vlan Show VLAN information + vrf Show vrf config + warm_restart Show warm restart configuration and state + watermark Show details of watermark + ``` + +The same syntax applies to all subgroups of `show` which themselves contain subcommands, and subcommands which accept options/arguments. + +- Example: + ``` + admin@sonic:~$ show interfaces -? + + Show details of the network interfaces + + Options: + -?, -h, --help Show this message and exit. + + Commands: + counters Show interface counters + description Show interface status, protocol and... + naming_mode Show interface naming_mode status + neighbor Show neighbor related information + portchannel Show PortChannel information + status Show Interface status information + tpid Show Interface tpid information + transceiver Show SFP Transceiver information + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#getting-help) + +## Basic Show Commands + +Subsections: + 1. [Show Versions](#Show-Versions) + 2. [Show System Status](#Show-System-Status) + 3. [Show Hardware Platform](#Show-Hardware-Platform) + +### Show Versions + +**show version** + +This command displays software component versions of the currently running SONiC image. This includes the SONiC image version as well as Docker image versions. +This command displays relevant information as the SONiC and Linux kernel version being utilized, as well as the ID of the commit used to build the SONiC image. The second section of the output displays the various docker images and their associated IDs. + +- Usage: + ``` + show version + ``` + +- Example: + ``` + admin@sonic:~$ show version + SONiC Software Version: SONiC.HEAD.32-21ea29a + Distribution: Debian 9.8 + Kernel: 4.9.0-8-amd64 + Build commit: 21ea29a + Build date: Fri Mar 22 01:55:48 UTC 2019 + Built by: johnar@jenkins-worker-4 + + Platform: x86_64-mlnx_msn2700-r0 + HwSKU: Mellanox-SN2700 + ASIC: mellanox + ASIC Count: 1 + Serial Number: MT1822K07815 + Model Number: MSN2700-CS2FO + Hardware Rev: A1 + Uptime: 14:40:15 up 3 min, 1 user, load average: 1.26, 1.45, 0.66 + Date: Fri 22 Mar 2019 14:40:15 + + Docker images: + REPOSITORY TAG IMAGE ID SIZE + docker-syncd-brcm HEAD.32-21ea29a 434240daff6e 362MB + docker-syncd-brcm latest 434240daff6e 362MB + docker-orchagent-brcm HEAD.32-21ea29a e4f9c4631025 287MB + docker-orchagent-brcm latest e4f9c4631025 287MB + docker-nat HEAD.32-21ea29a 46075edc1c69 305MB + docker-nat latest 46075edc1c69 305MB + docker-lldp-sv2 HEAD.32-21ea29a 9681bbfea3ac 275MB + docker-lldp-sv2 latest 9681bbfea3ac 275MB + docker-dhcp-relay HEAD.32-21ea29a 2db34c7bc6f4 257MB + docker-dhcp-relay latest 2db34c7bc6f4 257MB + docker-database HEAD.32-21ea29a badc6fc84cdb 256MB + docker-database latest badc6fc84cdb 256MB + docker-snmp-sv2 HEAD.32-21ea29a e2776e2a30b7 295MB + docker-snmp-sv2 latest e2776e2a30b7 295MB + docker-teamd HEAD.32-21ea29a caf957cd2ad1 275MB + docker-teamd latest caf957cd2ad1 275MB + docker-router-advertiser HEAD.32-21ea29a b1a62023958c 255MB + docker-router-advertiser latest b1a62023958c 255MB + docker-platform-monitor HEAD.32-21ea29a 40b40a4b2164 287MB + docker-platform-monitor latest 40b40a4b2164 287MB + docker-fpm-quagga HEAD.32-21ea29a 546036fe6838 282MB + docker-fpm-quagga latest 546036fe6838 282MB + ``` +Go Back To [Beginning of the document](#) or [Beginning of this section](#basic-show-commands) + + +### Show System Status +This sub-section explains some set of sub-commands that are used to display the status of various parameters pertaining to the physical state of the network node. + +**show clock** + +This command displays the current date and time configured on the system + +- Usage: + ``` + show clock + ``` + +- Example: + ``` + admin@sonic:~$ show clock + Mon Mar 25 20:25:16 UTC 2019 + ``` + +**show boot** + +This command displays the current OS image, the image to be loaded on next reboot, and lists all the available images installed on the device + +- Usage: + ``` + show boot + ``` + +- Example: + ``` + admin@sonic:~$ show boot + Current: SONiC-OS-20181130.31 + Next: SONiC-OS-20181130.31 + Available: + SONiC-OS-20181130.31 + ``` + +**show environment** + +This command displays the platform environmentals, such as voltages, temperatures and fan speeds + +- Usage: + ``` + show environment + ``` + +- Example: + ``` + admin@sonic:~$ show environment + coretemp-isa-0000 + Adapter: ISA adapter + Core 0: +28.0 C (high = +98.0 C, crit = +98.0 C) + Core 1: +28.0 C (high = +98.0 C, crit = +98.0 C) + Core 2: +28.0 C (high = +98.0 C, crit = +98.0 C) + Core 3: +28.0 C (high = +98.0 C, crit = +98.0 C) + SMF_Z9100_ON-isa-0000 + Adapter: ISA adapter + CPU XP3R3V_EARLY: +3.22 V + <... few more things ...> + + Onboard Temperature Sensors: + CPU: 30 C + BCM56960 (PSU side): 35 C + <... few more things ...> + + Onboard Voltage Sensors: + CPU XP3R3V_EARLY 3.22 V + <... few more things ...> + + Fan Trays: + Fan Tray 1: + Fan1 Speed: 6192 RPM + Fan2 Speed: 6362 RPM + Fan1 State: Normal + Fan2 State: Normal + Air Flow: F2B + <... few more things ...> + + PSUs: + PSU 1: + Input: AC + <... few more things ...> + ``` +NOTE: The show output has got lot of information; only the sample output is given in the above example. +Though the displayed output slightly differs from one platform to another platform, the overall content will be similar to the example mentioned above. + +**show reboot-cause** + +This command displays the cause of the previous reboot + +- Usage: + ``` + show reboot-cause + ``` + +- Example: + ``` + admin@sonic:~$ show reboot-cause + User issued reboot command [User: admin, Time: Mon Mar 25 01:02:03 UTC 2019] + ``` + +**show reboot-cause history** + +This command displays the history of the previous reboots up to 10 entry + +- Usage: + ``` + show reboot-cause history + ``` + +- Example: + ``` + admin@sonic:~$ show reboot-cause history + Name Cause Time User Comment + ------------------- ----------- ---------------------------- ------ --------- + 2020_10_09_02_33_06 reboot Fri Oct 9 02:29:44 UTC 2020 admin + 2020_10_09_01_56_59 reboot Fri Oct 9 01:53:49 UTC 2020 admin + 2020_10_09_02_00_53 fast-reboot Fri Oct 9 01:58:04 UTC 2020 admin + 2020_10_09_04_53_58 warm-reboot Fri Oct 9 04:51:47 UTC 2020 admin + ``` + +**show uptime** + +This command displays the current system uptime + +- Usage: + ``` + show uptime + ``` + +- Example: + ``` + admin@sonic:~$ show uptime + up 2 days, 21 hours, 30 minutes + ``` + +**show logging** + +This command displays all the currently stored log messages. +All the latest processes and corresponding transactions are stored in the "syslog" file. +This file is saved in the path `/var/log` and can be viewed by giving the command ` sudo cat syslog` as this requires root login. + +- Usage: + ``` + show logging [( [-l|--lines ]) | (-f|--follow)] + ``` + +- Example: + ``` + admin@sonic:~$ show logging + ``` + +It can be useful to pipe the output from `show logging` to the command `more` in order to examine one screenful of log messages at a time + +- Example: + ``` + admin@sonic:~$ show logging | more + ``` + +Optionally, you can specify a process name in order to display only log messages mentioning that process + +- Example: + ``` + admin@sonic:~$ show logging sensord + ``` + +Optionally, you can specify a number of lines to display using the `-l` or `--lines` option. Only the most recent N lines will be displayed. Also note that this option can be combined with a process name. + +- Examples: + ``` + admin@sonic:~$ show logging --lines 50 + ``` + ``` + admin@sonic:~$ show logging sensord --lines 50 + ``` + +Optionally, you can follow the log live as entries are written to it by specifying the `-f` or `--follow` flag + +- Example: + ``` + admin@sonic:~$ show logging --follow + ``` + +**show users** + +This command displays a list of users currently logged in to the device + +- Usage: + ``` + show users + ``` + +- Examples: + ``` + admin@sonic:~$ show users + admin pts/9 Mar 25 20:31 (100.127.20.23) + + admin@sonic:~$ show users + admin ttyS1 2019-03-25 20:31 + ``` +Go Back To [Beginning of the document](#) or [Beginning of this section](#basic-show-commands) + +### Show Hardware Platform + +The information displayed in this set of commands partially overlaps with the one generated by “show envinronment” instruction. In this case though, the information is presented in a more succinct fashion. In the future these two CLI stanzas may end up getting combined. + +**show platform summary** + +This command displays a summary of the device's hardware platform + +- Usage: + ``` + show platform summary + ``` + +- Example: + ``` + admin@sonic:~$ show platform summary + Platform: x86_64-mlnx_msn2700-r0 + HwSKU: Mellanox-SN2700 + ASIC: mellanox + ASIC Count: 1 + Serial Number: MT1822K07815 + Model Number: MSN2700-CS2FO + Hardware Rev: A1 + ``` + +**show platform syseeprom** + +This command displays information stored on the system EEPROM. +Note that the output of this command is not the same for all vendor's platforms. +Couple of example outputs are given below. + +- Usage: + ``` + show platform syseeprom + ``` + +- Example: + ``` + admin@sonic:~$ show platform syseeprom + lsTLV Name Len Value + -------------------- --- ----- + PPID 20 XX-XXXXXX-00000-000-0000 + DPN Rev 3 XXX + Service Tag 7 XXXXXXX + Part Number 10 XXXXXX + Part Number Rev 3 XXX + Mfg Test Results 2 FF + Card ID 2 0x0000 + Module ID 2 0 + Base MAC Address 12 FE:EC:BA:AB:CD:EF + (checksum valid) + ``` + + ``` + admin@sonic:~$ show platform syseeprom + TlvInfo Header: + Id String: TlvInfo + Version: 1 + Total Length: 527 + TLV Name Code Len Value + ---- --- ----- + Product Name 0x21 64 MSN2700 + Part Number 0x22 20 MSN2700-CS2FO + Serial Number 0x23 24 MT1822K07815 + Base MAC Address 0x24 6 50:6B:4B:8F:CE:40 + Manufacture Date 0x25 19 05/28/2018 23:56:02 + Device Version 0x26 1 16 + MAC Addresses 0x2A 2 128 + Manufacturer 0x2B 8 Mellanox + Vendor Extension 0xFD 36 + Vendor Extension 0xFD 164 + Vendor Extension 0xFD 36 + Vendor Extension 0xFD 36 + Vendor Extension 0xFD 36 + Platform Name 0x28 18 x86_64-mlnx_x86-r0 + ONIE Version 0x29 21 2018.08-5.2.0006-9600 + CRC-32 0xFE 4 0x11C017E1 + + (checksum valid) + ``` + +**show platform ssdhealth** + +This command displays health parameters of the device's SSD + +- Usage: + ``` + show platform ssdhealth [--vendor] + ``` + +- Example: + ``` + admin@sonic:~$ show platform ssdhealth + Device Model : M.2 (S42) 3IE3 + Health : 99.665% + Temperature : 30C + ``` + +**show platform psustatus** + +This command displays the status of the device's power supply units + +- Usage: + ``` + show platform psustatus + ``` + +- Example: + ``` + admin@sonic:~$ show platform psustatus + PSU Model Serial HW Rev Voltage (V) Current (A) Power (W) Status LED + ----- ------------- ------------ -------- ------------- ------------- ----------- -------- ----- + PSU 1 MTEF-PSF-AC-A MT1621X15246 A3 11.97 4.56 54.56 OK green + ``` + +**show platform fan** + +This command displays the status of the device's fans + +- Usage: + ``` + show platform fan + ``` + +- Example: + ``` + admin@sonic:~$ show platform fan + FAN Speed Direction Presence Status Timestamp + ----------- -------- ----------- ---------- -------- ----------------- + fan1 34% intake Present OK 20200302 06:58:56 + fan2 43% intake Present OK 20200302 06:58:56 + fan3 38% intake Present OK 20200302 06:58:56 + fan4 49% intake Present OK 20200302 06:58:57 + fan5 38% exhaust Present OK 20200302 06:58:57 + fan6 48% exhaust Present OK 20200302 06:58:57 + fan7 39% exhaust Present OK 20200302 06:58:57 + fan8 48% exhaust Present OK 20200302 06:58:57 + ``` + +**show platform temperature** + +This command displays the status of the device's thermal sensors + +- Usage: + ``` + show platform temperature + ``` + +- Example: + ``` + admin@sonic:~$ show platform temperature + NAME Temperature High Th Low Th Crit High Th Crit Low Th Warning Timestamp + ---------------------- ------------- --------- -------- -------------- ------------- --------- ----------------- + Ambient ASIC Temp 37.0 100.0 N/A 120.0 N/A False 20200302 06:58:57 + Ambient Fan Side Temp 28.5 100.0 N/A 120.0 N/A False 20200302 06:58:57 + Ambient Port Side Temp 31.0 100.0 N/A 120.0 N/A False 20200302 06:58:57 + CPU Core 0 Temp 36.0 87.0 N/A 105.0 N/A False 20200302 06:59:57 + CPU Core 1 Temp 38.0 87.0 N/A 105.0 N/A False 20200302 06:59:57 + CPU Pack Temp 38.0 87.0 N/A 105.0 N/A False 20200302 06:59:57 + PSU-1 Temp 28.0 100.0 N/A 120.0 N/A False 20200302 06:59:58 + PSU-2 Temp 28.0 100.0 N/A 120.0 N/A False 20200302 06:59:58 + xSFP module 1 Temp 31.5 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 2 Temp 35.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 3 Temp 32.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 4 Temp 33.5 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 5 Temp 34.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 6 Temp 36.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 7 Temp 33.5 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 8 Temp 33.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 9 Temp 32.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 10 Temp 38.5 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 11 Temp 38.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 12 Temp 39.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 13 Temp 35.5 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 14 Temp 37.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 15 Temp 36.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 16 Temp 36.5 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 17 Temp 32.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 18 Temp 34.5 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 19 Temp 30.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 20 Temp 31.5 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 21 Temp 34.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 22 Temp 34.4 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 23 Temp 34.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 24 Temp 35.6 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 25 Temp 38.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 26 Temp 32.2 70.0 N/A 90.0 N/A False 20200302 06:59:58 + xSFP module 27 Temp 39.0 70.0 N/A 90.0 N/A False 20200302 06:59:58 + xSFP module 28 Temp 30.1 70.0 N/A 90.0 N/A False 20200302 06:59:58 + xSFP module 29 Temp 32.0 70.0 N/A 90.0 N/A False 20200302 06:59:58 + xSFP module 30 Temp 35.3 70.0 N/A 90.0 N/A False 20200302 06:59:58 + xSFP module 31 Temp 31.0 70.0 N/A 90.0 N/A False 20200302 06:59:58 + xSFP module 32 Temp 39.5 70.0 N/A 90.0 N/A False 20200302 06:59:58 + ``` + +#### Transceivers +Displays diagnostic monitoring information of the transceivers + +**show interfaces transceiver** + +This command displays information for all the interfaces for the transceiver requested or a specific interface if the optional "interface_name" is specified. + +- Usage: + ``` + show interfaces transceiver (eeprom [-d|--dom] | lpmode | presence | error-status [-hw|--fetch-from-hardware]) [] + ``` + +- Example (Decode and display information stored on the EEPROM of SFP transceiver connected to Ethernet0): + ``` + admin@sonic:~$ show interfaces transceiver eeprom --dom Ethernet0 + Ethernet0: SFP detected + Connector : No separable connector + Encoding : Unspecified + Extended Identifier : Unknown + Extended RateSelect Compliance : QSFP+ Rate Select Version 1 + Identifier : QSFP+ + Length Cable Assembly(m) : 1 + Specification compliance : + 10/40G Ethernet Compliance Code : 40GBASE-CR4 + Fibre Channel Speed : 1200 Mbytes/Sec + Fibre Channel link length/Transmitter Technology : Electrical inter-enclosure (EL) + Fibre Channel transmission media : Twin Axial Pair (TW) + Vendor Date Code(YYYY-MM-DD Lot) : 2015-10-31 + Vendor Name : XXXXX + Vendor OUI : XX-XX-XX + Vendor PN : 1111111111 + Vendor Rev : + Vendor SN : 111111111 + ChannelMonitorValues: + RX1Power: -1.1936dBm + RX2Power: -1.1793dBm + RX3Power: -0.9388dBm + RX4Power: -1.0729dBm + TX1Bias: 4.0140mA + TX2Bias: 4.0140mA + TX3Bias: 4.0140mA + TX4Bias: 4.0140mA + ModuleMonitorValues : + Temperature : 1.1111C + Vcc : 0.0000Volts + ``` + +- Example (Display status of low-power mode of SFP transceiver connected to Ethernet100): + ``` + admin@sonic:~$ show interfaces transceiver lpmode Ethernet100 + Port Low-power Mode + ----------- ---------------- + Ethernet100 On + ``` + + +- Example (Display presence of SFP transceiver connected to Ethernet100): + ``` + admin@sonic:~$ show interfaces transceiver presence Ethernet100 + Port Presence + ----------- ---------- + Ethernet100 Present + ``` + +- Example (Display error status of SFP transceiver connected to Ethernet100): + ``` + admin@sonic:~$ show interfaces transceiver error-status Ethernet100 + Port Error Status + ----------- -------------- + Ethernet100 OK + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#basic-show-commands) + +## AAA & TACACS+ +This section captures the various show commands & configuration commands that are applicable for the AAA (Authentication, Authorization, and Accounting) module. +Admins can configure the type of authentication (local or remote tacacs based) required for the users and also the authentication failthrough and fallback options. +Following show command displays the current running configuration related to the AAA. + +### AAA + +#### AAA show commands + +This command is used to view the Authentication, Authorization & Accounting settings that are configured in the network node. + +**show aaa** + +This command displays the AAA settings currently present in the network node + +- Usage: + ``` + show aaa + ``` + +- Example: + ``` + admin@sonic:~$ show aaa + AAA authentication login local (default) + AAA authentication failthrough True (default) + AAA authentication fallback True (default) + ``` + +#### AAA config commands + +This sub-section explains all the possible CLI based configuration options for the AAA module. The list of commands/sub-commands possible for aaa is given below. + + Command: aaa authentication + sub-commands: + - aaa authentication failthrough + - aaa authentication fallback + - aaa authentication login + +**aaa authentication failthrough** + +This command is used to either enable or disable the failthrough option. +This command is useful when user has configured more than one tacacs+ server and when user has enabled tacacs+ authentication. +When authentication request to the first server fails, this configuration allows to continue the request to the next server. +When this configuration is enabled, authentication process continues through all servers configured. +When this is disabled and if the authentication request fails on first server, authentication process will stop and the login will be disallowed. + + +- Usage: + ``` + config aaa authentication failthrough (enable | disable | default) + ``` + + - Parameters: + - enable: This allows the AAA module to process with local authentication if remote authentication fails. + - disable: This disallows the AAA module to proceed further if remote authentication fails. + - default: This re-configures the default value, which is "enable". + + +- Example: + ``` + admin@sonic:~$ sudo config aaa authentication failthrough enable + ``` +**aaa authentication fallback** + +The command is not used at the moment. +When the tacacs+ authentication fails, it falls back to local authentication by default. + +- Usage: + ``` + config aaa authentication fallback (enable | disable | default) + ``` + +- Example: + ``` + admin@sonic:~$ sudo config aaa authentication fallback enable + ``` + +**aaa authentication login** + +This command is used to either configure whether AAA should use local database or remote tacacs+ database for user authentication. +By default, AAA uses local database for authentication. New users can be added/deleted using the linux commands (Note that the configuration done using linux commands are not preserved during reboot). +Admin can enable remote tacacs+ server based authentication by selecting the AUTH_PROTOCOL as tacacs+ in this command. +Admins need to configure the tacacs+ server accordingly and ensure that the connectivity to tacacas+ server is available via the management interface. +Once if the admins choose the remote authentication based on tacacs+ server, all user logins will be authenticated by the tacacs+ server. +If the authentication fails, AAA will check the "failthrough" configuration and authenticates the user based on local database if failthrough is enabled. + +- Usage: + ``` + config aaa authentication (tacacs+ | local | default) + ``` + + - Parameters: + - tacacs+: Enables remote authentication based on tacacs+ + - local: Disables remote authentication and uses local authentication + - default: Reset back to default value, which is only "local" authentication + + +- Example: + ``` + admin@sonic:~$ sudo config aaa authentication login tacacs+ + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#aaa--tacacs) + +### TACACS+ + +#### TACACS+ show commands + +**show tacacs** + +This command displays the global configuration fields and the list of all tacacs servers and their correponding configurations. + +- Usage: + ``` + show tacacs + ``` + +- Example: + ``` + admin@sonic:~$ show tacacs + TACPLUS global auth_type pap (default) + TACPLUS global timeout 99 + TACPLUS global passkey (default) + + TACPLUS_SERVER address 10.11.12.14 + priority 9 + tcp_port 50 + auth_type mschap + timeout 10 + passkey testing789 + + TACPLUS_SERVER address 10.0.0.9 + priority 1 + tcp_port 49 + ``` + +#### TACACS+ config commands + +This sub-section explains the command "config tacacs" and its sub-commands that are used to configure the following tacacs+ parameters. +Some of the parameters like authtype, passkey and timeout can be either configured at per server level or at global level (global value will be applied if there no server level configuration) + +1) Add/Delete the tacacs+ server details. +2) authtype - global configuration that is applied to all servers if there is no server specific configuration. +3) default - reset the authtype or passkey or timeout to the default values. +4) passkey - global configuration that is applied to all servers if there is no server specific configuration. +5) timeout - global configuration that is applied to all servers if there is no server specific configuration. + +**config tacacs add** + +This command is used to add a TACACS+ server to the tacacs server list. +Note that more than one tacacs+ (maximum of seven) can be added in the device. +When user tries to login, tacacs client shall contact the servers one by one. +When any server times out, device will try the next server one by one based on the priority value configured for that server. +When this command is executed, the configured tacacs+ server addresses are updated in /etc/pam.d/common-auth-sonic configuration file which is being used by tacacs service. + +- Usage: + ``` + config tacacs add [-t|--timeout ] [-k|--key ] [-a|--type ] [-o|--port ] [-p|--pri ] [-m|--use-mgmt-vrf] + ``` + + - Parameters: + - ip_address: TACACS+ server IP address. + - timeout: Transmission timeout interval in seconds, range 1 to 60, default 5 + - key: Shared secret + - type: Authentication type, "chap" or "pap" or "mschap" or "login", default is "pap". + - port: TCP port range is 1 to 65535, default 49 + - pri: Priority, priority range 1 to 64, default 1. + - use-mgmt-vrf: This means that the server is part of Management vrf, default is "no vrf" + + +- Example: + ``` + admin@sonic:~$ sudo config tacacs add 10.11.12.13 -t 10 -k testing789 -a mschap -o 50 -p 9 + ``` + + - Example Server Configuration in /etc/pam.d/common-auth-sonic configuration file: + ``` + auth [success=done new_authtok_reqd=done default=ignore] pam_tacplus.so server=10.11.12.14:50 secret=testing789 login=mschap timeout=10 try_first_pass + auth [success=done new_authtok_reqd=done default=ignore] pam_tacplus.so server=10.11.12.24:50 secret=testing789 login=mschap timeout=987654321098765433211 + 0987 try_first_pass + auth [success=done new_authtok_reqd=done default=ignore] pam_tacplus.so server=10.0.0.9:49 secret= login=mschap timeout=5 try_first_pass + auth [success=done new_authtok_reqd=done default=ignore] pam_tacplus.so server=10.0.0.8:49 secret= login=mschap timeout=5 try_first_pass + auth [success=done new_authtok_reqd=done default=ignore] pam_tacplus.so server=10.11.12.13:50 secret=testing789 login=mschap timeout=10 try_first_pass + auth [success=1 default=ignore] pam_unix.so nullok try_first_pass + ``` + + *NOTE: In the above example, the servers are stored (sorted) based on the priority value configured for the server.* + +**config tacacs delete** + +This command is used to delete the tacacs+ servers configured. + +- Usage: + ``` + config tacacs delete + ``` + +- Example: + ``` + admin@sonic:~$ sudo config tacacs delete 10.11.12.13 + ``` + +**config tacacs authtype** + +This command is used to modify the global value for the TACACS+ authtype. +When user has not configured server specific authtype, this global value shall be used for that server. + +- Usage: + ``` + config tacacs authtype (chap | pap | mschap | login) + ``` + +- Example: + ``` + admin@sonic:~$ sudo config tacacs authtype mschap + ``` + +**config tacacs default** + +This command is used to reset the global value for authtype or passkey or timeout to default value. +Default for authtype is "pap", default for passkey is EMPTY_STRING and default for timeout is 5 seconds. + +- Usage: + ``` + config tacacs default (authtype | passkey | timeout) + ``` + +- Example (This will reset the global authtype back to the default value "pap"): + ``` + admin@sonic:~$ sudo config tacacs default authtype + ``` + +**config tacacs passkey** + +This command is used to modify the global value for the TACACS+ passkey. +When user has not configured server specific passkey, this global value shall be used for that server. + +- Usage: + ``` + config tacacs passkey + ``` + +- Example: + ``` + admin@sonic:~$ sudo config tacacs passkey testing123 + ``` + +**config tacacs timeout** + +This command is used to modify the global value for the TACACS+ timeout. +When user has not configured server specific timeout, this global value shall be used for that server. + + +- Usage: + ``` + config tacacs [default] timeout [] + ``` + + - Options: + - Valid values for timeout is 1 to 60 seconds. + - When the optional keyword "default" is specified, timeout_value_in_seconds parameter wont be used; default value of 5 is used. + - Configuration using the keyword "default" is introduced in 201904 release. + +- Example: To configure non-default timeout value + ``` + admin@sonic:~$ sudo config tacacs timeout 60 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#aaa--tacacs) + + + +## ACL + +This section explains the various show commands and configuration commands available for users. + +### ACL show commands + +**show acl table** + +This command displays either all the ACL tables that are configured or only the specified "TABLE_NAME". +Output from the command displays the table name, type of the table, the list of interface(s) to which the table is bound and the description about the table. + +- Usage: + ``` + show acl table [] + ``` + +- Example: + ``` + admin@sonic:~$ show acl table + Name Type Binding Description Stage + -------- --------- --------------- ---------------- ------- + EVERFLOW MIRROR Ethernet16 EVERFLOW ingress + Ethernet96 + Ethernet108 + Ethernet112 + PortChannel0001 + PortChannel0002 + SNMP_ACL CTRLPLANE SNMP SNMP_ACL ingress + DT_ACL_T1 L3 Ethernet0 DATA_ACL_TABLE_1 egress + Ethernet4 + Ethernet112 + Ethernet116 + SSH_ONLY CTRLPLANE SSH SSH_ONLY ingress + ``` + +**show acl rule** + +This command displays all the ACL rules present in all the ACL tables or only the rules present in specified table "TABLE_NAME" or only the rule matching the RULE_ID option. +Output from the command gives the following information about the rules +1) Table name - ACL table name to which the rule belongs to. +2) Rule name - ACL rule name +3) Priority - Priority for this rule. +4) Action - Action to be performed if the packet matches with this ACL rule. + +It can be: +- "DROP"/"FORWARD"("ACCEPT" for control plane ACL) +- "REDIRECT: redirect-object" for redirect rule, where "redirect-object" is either: + - physical interface name, e.g. "Ethernet10" + - port channel name, e.g. "PortChannel0002" + - next-hop IP address, e.g. "10.0.0.1" + - next-hop group set of IP addresses with comma seperator, e.g. "10.0.0.1,10.0.0.3" +- "MIRROR INGRESS|EGRESS: session-name" for mirror rules, where "session-name" refers to mirror session + +Users can choose to have a default permit rule or default deny rule. In case of default "deny all" rule, add the permitted rules on top of the deny rule. In case of the default "permit all" rule, users can add the deny rules on top of it. If users have not confgured any rule, SONiC allows all traffic (which is "permit all"). + +5) Match - The fields from the packet header that need to be matched against the same present in the incoming traffic. + +- Usage: + ``` + show acl rule [] [] + ``` + +- Example: + ``` + admin@sonic:~$ show acl rule + Table Rule Priority Action Match + -------- ------------ ---------- ------------------------- ---------------------------- + SNMP_ACL RULE_1 9999 ACCEPT IP_PROTOCOL: 17 + SRC_IP: 1.1.1.1/32 + SSH_ONLY RULE_2 9998 ACCEPT IP_PROTOCOL: 6 + SRC_IP: 1.1.1.1/32 + EVERFLOW RULE_3 9997 MIRROR INGRESS: everflow0 SRC_IP: 20.0.0.2/32 + EVERFLOW RULE_4 9996 MIRROR EGRESS : everflow1 L4_SRC_PORT: 4621 + DATAACL RULE_5 9995 REDIRECT: Ethernet8 IP_PROTOCOL: 126 + DATAACL RULE_6 9994 FORWARD L4_SRC_PORT: 179 + DATAACL RULE_7 9993 FORWARD L4_DST_PORT: 179 + SNMP_ACL DEFAULT_RULE 1 DROP ETHER_TYPE: 2048 + SSH_ONLY DEFAULT_RULE 1 DROP ETHER_TYPE: 2048 + ``` + + +### ACL config commands +This sub-section explains the list of configuration options available for ACL module. +Note that there is no direct command to add or delete or modify the ACL table and ACL rule. +Existing ACL tables and ACL rules can be updated by specifying the ACL rules in json file formats and configure those files using this CLI command. + +**config acl update full** + +This command is to update the rules in all the tables or in one specific table in full. If a table_name is provided, the operation will be restricted in the specified table. All existing rules in the specified table or all tables will be removed. New rules loaded from file will be installed. If the table_name is specified, only rules within that table will be removed and new rules in that table will be installed. If the table_name is not specified, all rules from all tables will be removed and only the rules present in the input file will be added. + +The command does not modify anything in the list of acl tables. It modifies only the rules present in those pre-existing tables. + +In order to create acl tables, either follow the config_db.json method or minigraph method to populate the list of ACL tables. + +After creating tables, either the config_db.json method or the minigraph method or the CLI method (explained here) can be used to populate the rules in those ACL tables. + +This command updates only the ACL rules and it does not disturb the ACL tables; i.e. the output of "show acl table" is not alterted by using this command; only the output of "show acl rule" will be changed after this command. + +When "--session_name" optional argument is specified, command sets the session_name for the ACL table with this mirror session name. It fails if the specified mirror session name does not exist. + +When "--mirror_stage" optional argument is specified, command sets the mirror action to ingress/egress based on this parameter. By default command sets ingress mirror action in case argument is not specified. + +When the optional argument "max_priority" is specified, each rule’s priority is calculated by subtracting its “sequence_id” value from the “max_priority”. If this value is not passed, the default “max_priority” 10000 is used. + +- Usage: + ``` + config acl update full [--table_name ] [--session_name ] [--mirror_stage (ingress | egress)] [--max_priority ] + ``` + + - Parameters: + - table_name: Specifiy the name of the ACL table to load. Example: config acl update full "--table_name DT_ACL_T1 /etc/sonic/acl_table_1.json" + - session_name: Specifiy the name of the ACL session to load. Example: config acl update full "--session_name mirror_ses1 /etc/sonic/acl_table_1.json" + - priority_value: Specify the maximum priority to use when loading ACL rules. Example: config acl update full "--max-priority 100 /etc/sonic/acl_table_1.json" + + *NOTE 1: All these optional parameters should be inside double quotes. If none of the options are provided, double quotes are not required for specifying filename alone.* + *NOTE 2: Any number of optional parameters can be configured in the same command.* + +- Examples: + ``` + admin@sonic:~$ sudo config acl update full /etc/sonic/acl_full_snmp_1_2_ssh_4.json + admin@sonic:~$ sudo config acl update full "--table_name SNMP-ACL /etc/sonic/acl_full_snmp_1_2_ssh_4.json" + admin@sonic:~$ sudo config acl update full "--session_name everflow0 /etc/sonic/acl_full_snmp_1_2_ssh_4.json" + ``` + + This command will remove all rules from all the ACL tables and insert all the rules present in this input file. + Refer the example file [acl_full_snmp_1_2_ssh_4.json](#) that adds two rules for SNMP (Rule1 and Rule2) and one rule for SSH (Rule4) + Refer an example for input file format [here](https://github.com/Azure/sonic-mgmt/blob/master/ansible/roles/test/files/helpers/config_service_acls.sh) + Refer another example [here](https://github.com/Azure/sonic-mgmt/blob/master/ansible/roles/test/tasks/acl/acltb_test_rules_part_1.json) + +**config acl update incremental** + +This command is used to perform incremental update of ACL rule table. This command gets existing rules from Config DB and compares with rules specified in input file and performs corresponding modifications. + +With respect to DATA ACLs, the command does not assume that new dataplane ACLs can be inserted in betweeen by shifting existing ACLs in all ASICs. Therefore, this command performs a full update on dataplane ACLs. +With respect to control plane ACLs, this command performs an incremental update. +If we assume that "file1.json" is the already loaded ACL rules file and if "file2.json" is the input file that is passed as parameter for this command, the following requirements are valid for the input file. +1) First copy the file1.json to file2.json. +2) Remove the unwanted ACL rules from file2.json +3) Add the newly required ACL rules into file2.json. +4) Modify the existing ACL rules (that require changes) in file2.json. + +NOTE: If any ACL rule that is already available in file1.json is required even after this command execution, such rules should remain unalterted in file2.json. Don't remove them. +Note that "incremental" is working like "full". + +When "--session_name" optional argument is specified, command sets the session_name for the ACL table with this mirror session name. It fails if the specified mirror session name does not exist. + +When "--mirror_stage" optional argument is specified, command sets the mirror action to ingress/egress based on this parameter. By default command sets ingress mirror action in case argument is not specified. + +When the optional argument "max_priority" is specified, each rule’s priority is calculated by subtracting its “sequence_id” value from the “max_priority”. If this value is not passed, the default “max_priority” 10000 is used. + +- Usage: + ``` + config acl update incremental [--session_name ] [--mirror_stage (ingress | egress)] [--max_priority ] + ``` + + - Parameters: + - table_name: Specifiy the name of the ACL table to load. Example: config acl update full "--table_name DT_ACL_T1 /etc/sonic/acl_table_1.json" + - session_name: Specifiy the name of the ACL session to load. Example: config acl update full "--session_name mirror_ses1 /etc/sonic/acl_table_1.json" + - priority_value: Specify the maximum priority to use when loading ACL rules. Example: config acl update full "--max-priority 100 /etc/sonic/acl_table_1.json" + + *NOTE 1: All these optional parameters should be inside double quotes. If none of the options are provided, double quotes are not required for specifying filename alone.* + *NOTE 2: Any number of optional parameters can be configured in the same command.* + +- Examples: + ``` + admin@sonic:~$ sudo config acl update incremental /etc/sonic/acl_incremental_snmp_1_3_ssh_4.json + ``` + ``` + admin@sonic:~$ sudo config acl update incremental "--session_name everflow0 /etc/sonic/acl_incremental_snmp_1_3_ssh_4.json" + ``` + + Refer the example file [acl_incremental_snmp_1_3_ssh_4.json](#) that adds two rules for SNMP (Rule1 and Rule3) and one rule for SSH (Rule4) + When this "incremental" command is executed after "full" command, it has removed SNMP Rule2 and added SNMP Rule3 in the example. + File "acl_full_snmp_1_2_ssh_4.json" has got SNMP Rule1, SNMP Rule2 and SSH Rule4. + File "acl_incremental_snmp_1_3_ssh_4.json" has got SNMP Rule1, SNMP Rule3 and SSH Rule4. + This file is created by copying the file "acl_full_snmp_1_2_ssh_4.json" to "acl_incremental_snmp_1_3_ssh_4.json" and then removing SNMP Rule2 and adding SNMP Rule3. + +Go Back To [Beginning of the document](#) or [Beginning of this section](#acl) + +**config acl add table** + +This command is used to create new ACL tables. + +- Usage: + ``` + config acl add table [OPTIONS] [-d ] [-p ] [-s (ingress | egress)] + ``` + +- Parameters: + - table_name: The name of the ACL table to create. + - table_type: The type of ACL table to create (e.g. "L3", "L3V6", "MIRROR") + - description: A description of the table for the user. (default is the table_name) + - ports: A comma-separated list of ports/interfaces to add to the table. The behavior is as follows: + - Physical ports will be bound as physical ports + - Portchannels will be bound as portchannels - passing a portchannel member is invalid + - VLANs will be expanded into their members (e.g. "Vlan1000" will become "Ethernet0,Ethernet2,Ethernet4...") + - stage: The stage this ACL table will be applied to, either ingress or egress. (default is ingress) + +- Examples: + ``` + admin@sonic:~$ sudo config acl add table EXAMPLE L3 -p Ethernet0,Ethernet4 -s ingress + ``` + ``` + admin@sonic:~$ sudo config acl add table EXAMPLE_2 L3V6 -p Vlan1000,PortChannel0001,Ethernet128 -s egress + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#acl) + + +## ARP & NDP + +### ARP show commands + +**show arp** + +This command displays the ARP entries in the device with following options. +1) Display the entire table. +2) Display the ARP entries learnt on a specific interface. +3) Display the ARP of a specific ip-address. + +- Usage: + ``` + show arp [-if ] [] + ``` + +- Details: + - show arp: Displays all entries + - show arp -if : Displays the ARP specific to the specified interface. + - show arp : Displays the ARP specific to the specicied ip-address. + + +- Example: + ``` + admin@sonic:~$ show arp + Address MacAddress Iface Vlan + ------------- ----------------- ------- ------ + 192.168.1.183 88:5a:92:fb:bf:41 Ethernet44 - + 192.168.1.175 88:5a:92:fc:95:81 Ethernet28 - + 192.168.1.181 e4:c7:22:c1:07:7c Ethernet40 - + 192.168.1.179 88:5a:92:de:a8:bc Ethernet36 - + 192.168.1.118 00:1c:73:3c:de:43 Ethernet64 - + 192.168.1.11 00:1c:73:3c:e1:38 Ethernet88 - + 192.168.1.161 24:e9:b3:71:3a:01 Ethernet0 - + 192.168.1.189 24:e9:b3:9d:57:41 Ethernet56 - + 192.168.1.187 74:26:ac:8b:8f:c1 Ethernet52 - + 192.168.1.165 88:5a:92:de:a0:7c Ethernet8 - + + Total number of entries 10 + ``` + +Optionally, you can specify the interface in order to display the ARPs learnt on that particular interface + +- Example: + ``` + admin@sonic:~$ show arp -if Ethernet40 + Address MacAddress Iface Vlan + ------------- ----------------- ---------- ------ + 192.168.1.181 e4:c7:22:c1:07:7c Ethernet40 - + Total number of entries 1 + ``` + +Optionally, you can specify an IP address in order to display only that particular entry + +- Example: + ``` + admin@sonic:~$ show arp 192.168.1.181 + Address MacAddress Iface Vlan + ------------- ----------------- ---------- ------ + 192.168.1.181 e4:c7:22:c1:07:7c Ethernet40 - + Total number of entries 1 + ``` + +### NDP show commands + +**show ndp** + +This command displays either all the IPv6 neighbor mac addresses, or for a particular IPv6 neighbor, or for all IPv6 neighbors reachable via a specific interface. + +- Usage: + ``` + show ndp [-if|--iface ] + ``` + +- Example (show all IPv6 neighbors): + ``` + admin@sonic:~$ show ndp + Address MacAddress Iface Vlan Status + ------------------------ ----------------- ------- ------ --------- + fe80::20c:29ff:feb8:b11e 00:0c:29:b8:b1:1e eth0 - REACHABLE + fe80::20c:29ff:feb8:cff0 00:0c:29:b8:cf:f0 eth0 - REACHABLE + fe80::20c:29ff:fef9:324 00:0c:29:f9:03:24 eth0 - REACHABLE + Total number of entries 3 + ``` + +- Example (show specific IPv6 neighbor): + ``` + admin@sonic:~$ show ndp fe80::20c:29ff:feb8:b11e + Address MacAddress Iface Vlan Status + ------------------------ ----------------- ------- ------ --------- + fe80::20c:29ff:feb8:b11e 00:0c:29:b8:b1:1e eth0 - REACHABLE + Total number of entries 1 + ``` + +- Example (show IPv6 neighbors learned on a specific interface): + ``` + admin@sonic:~$ show ndp -if eth0 + Address MacAddress Iface Vlan Status + ------------------------ ----------------- ------- ------ --------- + fe80::20c:29ff:feb8:b11e 00:0c:29:b8:b1:1e eth0 - REACHABLE + fe80::20c:29ff:feb8:cff0 00:0c:29:b8:cf:f0 eth0 - REACHABLE + fe80::20c:29ff:fef9:324 00:0c:29:f9:03:24 eth0 - REACHABLE + Total number of entries 3 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#arp--ndp) + +## BFD + +### BFD show commands + +**show bfd summary** + +This command displays the state and key parameters of all BFD sessions. + +- Usage: + ``` + show bgp summary + ``` +- Example: + ``` + >> show bfd summary + Total number of BFD sessions: 3 + Peer Addr Interface Vrf State Type Local Addr TX Interval RX Interval Multiplier Multihop + ----------- ----------- ------- ------- ------------ ------------ ------------- ------------- ------------ ---------- + 10.0.1.1 default default DOWN async_active 10.0.0.1 300 500 3 true + 10.0.2.1 Ethernet12 default UP async_active 10.0.0.1 200 600 3 false + 2000::10:1 default default UP async_active 2000::1 100 700 3 false + ``` + +**show bfd peer** + +This command displays the state and key parameters of all BFD sessions that match an IP address. + +- Usage: + ``` + show bgp peer + ``` +- Example: + ``` + >> show bfd peer 10.0.1.1 + Total number of BFD sessions for peer IP 10.0.1.1: 1 + Peer Addr Interface Vrf State Type Local Addr TX Interval RX Interval Multiplier Multihop + ----------- ----------- ------- ------- ------------ ------------ ------------- ------------- ------------ ---------- + 10.0.1.1 default default DOWN async_active 10.0.0.1 300 500 3 true + ``` + +## BGP + +This section explains all the BGP show commands and BGP configuation commands in both "Quagga" and "FRR" routing software that are supported in SONiC. +In 201811 and older verisons "Quagga" was enabled by default. In current version "FRR" is enabled by default. +Most of the FRR show commands start with "show bgp". Similar commands in Quagga starts with "show ip bgp". All sub-options supported in all these show commands are common for FRR and Quagga. +Detailed show commands examples for Quagga are provided at the end of this document.This section captures only the commands supported by FRR. + +### BGP show commands + + +**show bgp summary (Versions >= 201904 using default FRR routing stack)** + +**show ip bgp summary (Versions <= 201811 using Quagga routing stack)** + +This command displays the summary of all IPv4 & IPv6 bgp neighbors that are configured and the corresponding states. + +- Usage: + + *Versions >= 201904 using default FRR routing stack* + ``` + show bgp summary + ``` + *Versions <= 201811 using Quagga routing stack* + ``` + show ip bgp summary + ``` + +- Example: + ``` + admin@sonic:~$ show ip bgp summary + + IPv4 Unicast Summary: + BGP router identifier 10.1.0.32, local AS number 65100 vrf-id 0 + BGP table version 6465 + RIB entries 12807, using 2001 KiB of memory + Peers 4, using 83 KiB of memory + Peer groups 2, using 128 bytes of memory + + Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd NeighborName + 10.0.0.57 4 64600 3995 4001 0 0 0 00:39:32 6400 Lab-T1-01 + 10.0.0.59 4 64600 3995 3998 0 0 0 00:39:32 6400 Lab-T1-02 + 10.0.0.61 4 64600 3995 4001 0 0 0 00:39:32 6400 Lab-T1-03 + 10.0.0.63 4 64600 3995 3998 0 0 0 00:39:32 6400 NotAvailable + + Total number of neighbors 4 + ``` + +- Example: + ``` + admin@sonic:~$ show bgp summary + + IPv4 Unicast Summary: + BGP router identifier 10.1.0.32, local AS number 65100 vrf-id 0 + BGP table version 6465 + RIB entries 12807, using 2001 KiB of memory + Peers 4, using 83 KiB of memory + Peer groups 2, using 128 bytes of memory + + Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd + 10.0.0.57 4 64600 3995 4001 0 0 0 00:39:32 6400 + 10.0.0.59 4 64600 3995 3998 0 0 0 00:39:32 6400 + 10.0.0.61 4 64600 3995 4001 0 0 0 00:39:32 6400 + 10.0.0.63 4 64600 3995 3998 0 0 0 00:39:32 6400 + + Total number of neighbors 4 + + IPv6 Unicast Summary: + BGP router identifier 10.1.0.32, local AS number 65100 vrf-id 0 + BGP table version 12803 + RIB entries 12805, using 2001 KiB of memory + Peers 4, using 83 KiB of memory + Peer groups 2, using 128 bytes of memory + + Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd + fc00::72 4 64600 3995 5208 0 0 0 00:39:30 6400 + fc00::76 4 64600 3994 5208 0 0 0 00:39:30 6400 + fc00::7a 4 64600 3993 5208 0 0 0 00:39:30 6400 + fc00::7e 4 64600 3993 5208 0 0 0 00:39:30 6400 + + Total number of neighbors 4 + ``` + Click [here](#Quagga-BGP-Show-Commands) to see the example for "show ip bgp summary" for Quagga. + + + +**show bgp neighbors (Versions >= 201904 using default FRR routing stack)** + +**show ip bgp neighbors (Versions <= 201811 using Quagga routing stack)** + +This command displays all the details of IPv4 & IPv6 BGP neighbors when no optional argument is specified. + +When the optional argument IPv4_address is specified, it displays the detailed neighbor information about that specific IPv4 neighbor. + +Command has got additional optional arguments to display only the advertised routes, or the received routes, or all routes. + +In order to get details for an IPv6 neigbor, use "show bgp ipv6 neighbor " command. + + +- Usage: + + *Versions >= 201904 using default FRR routing stack* + ``` + show bgp neighbors [ [advertised-routes | received-routes | routes]] + ``` + *Versions <= 201811 using Quagga routing stack* + ``` + show ip bgp neighbors [ [advertised-routes | received-routes | routes]] + ``` + +- Example: + ``` + admin@sonic:~$ show bgp neighbors + BGP neighbor is 10.0.0.57, remote AS 64600, local AS 65100, external link + Description: ARISTA01T1 + BGP version 4, remote router ID 100.1.0.29, local router ID 10.1.0.32 + BGP state = Established, up for 00:42:15 + Last read 00:00:00, Last write 00:00:03 + Hold time is 10, keepalive interval is 3 seconds + Configured hold time is 10, keepalive interval is 3 seconds + Neighbor capabilities: + 4 Byte AS: advertised and received + AddPath: + IPv4 Unicast: RX advertised IPv4 Unicast and received + Route refresh: advertised and received(new) + Address Family IPv4 Unicast: advertised and received + Hostname Capability: advertised (name: sonic-z9264f-9251,domain name: n/a) not received + Graceful Restart Capabilty: advertised and received + Remote Restart timer is 300 seconds + Address families by peer: + none + Graceful restart information: + End-of-RIB send: IPv4 Unicast + End-of-RIB received: IPv4 Unicast + Message statistics: + Inq depth is 0 + Outq depth is 0 + Sent Rcvd + Opens: 2 1 + Notifications: 2 0 + Updates: 3206 3202 + Keepalives: 845 847 + Route Refresh: 0 0 + Capability: 0 0 + Total: 4055 4050 + Minimum time between advertisement runs is 0 seconds + + For address family: IPv4 Unicast + Update group 1, subgroup 1 + Packet Queue length 0 + Inbound soft reconfiguration allowed + Community attribute sent to this neighbor(all) + 6400 accepted prefixes + + Connections established 1; dropped 0 + Last reset 00:42:37, due to NOTIFICATION sent (Cease/Connection collision resolution) + Local host: 10.0.0.56, Local port: 179 + Foreign host: 10.0.0.57, Foreign port: 46419 + Nexthop: 10.0.0.56 + Nexthop global: fc00::71 + Nexthop local: fe80::2204:fff:fe36:9449 + BGP connection: shared network + BGP Connect Retry Timer in Seconds: 120 + Read thread: on Write thread: on + ``` + +Optionally, you can specify an IP address in order to display only that particular neighbor. In this mode, you can optionally specify whether you want to display all routes advertised to the specified neighbor, all routes received from the specified neighbor or all routes (received and accepted) from the specified neighbor. + +- Example: + ``` + admin@sonic:~$ show bgp neighbors 10.0.0.57 + + admin@sonic:~$ show bgp neighbors 10.0.0.57 advertised-routes + + admin@sonic:~$ show bgp neighbors 10.0.0.57 received-routes + + admin@sonic:~$ show bgp neighbors 10.0.0.57 routes + ``` + + Click [here](#Quagga-BGP-Show-Commands) to see the example for "show ip bgp neighbors" for Quagga. + + +**show ip bgp network [[|] [(bestpath | multipath | longer-prefixes | json)]] + +This command displays all the details of IPv4 Border Gateway Protocol (BGP) prefixes. + +- Usage: + + + ``` + show ip bgp network [[|] [(bestpath | multipath | longer-prefixes | json)]] + ``` + +- Example: + + NOTE: The "longer-prefixes" option is only available when a network prefix with a "/" notation is used. + + ``` + admin@sonic:~$ show ip bgp network + + admin@sonic:~$ show ip bgp network 10.1.0.32 bestpath + + admin@sonic:~$ show ip bgp network 10.1.0.32 multipath + + admin@sonic:~$ show ip bgp network 10.1.0.32 json + + admin@sonic:~$ show ip bgp network 10.1.0.32/32 bestpath + + admin@sonic:~$ show ip bgp network 10.1.0.32/32 multipath + + admin@sonic:~$ show ip bgp network 10.1.0.32/32 json + + admin@sonic:~$ show ip bgp network 10.1.0.32/32 longer-prefixes + ``` + +**show bgp ipv6 summary (Versions >= 201904 using default FRR routing stack)** + +**show ipv6 bgp summary (Versions <= 201811 using Quagga routing stack)** + +This command displays the summary of all IPv6 bgp neighbors that are configured and the corresponding states. + +- Usage: + + *Versions >= 201904 using default FRR routing stack* + ``` + show bgp ipv6 summary + ``` + *Versions <= 201811 using Quagga routing stack* + ``` + show ipv6 bgp summary + ``` + +- Example: + ``` + admin@sonic:~$ show bgp ipv6 summary + BGP router identifier 10.1.0.32, local AS number 65100 vrf-id 0 + BGP table version 12803 + RIB entries 12805, using 2001 KiB of memory + Peers 4, using 83 KiB of memory + Peer groups 2, using 128 bytes of memory + + Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd NeighborName + fc00::72 4 64600 3995 5208 0 0 0 00:39:30 6400 Lab-T1-01 + fc00::76 4 64600 3994 5208 0 0 0 00:39:30 6400 Lab-T1-02 + fc00::7a 4 64600 3993 5208 0 0 0 00:39:30 6400 Lab-T1-03 + fc00::7e 4 64600 3993 5208 0 0 0 00:39:30 6400 Lab-T1-04 + + Total number of neighbors 4 + ``` + Click [here](#Quagga-BGP-Show-Commands) to see the example for "show ipv6 bgp summary" for Quagga. + + + +**show bgp ipv6 neighbors (Versions >= 201904 using default FRR routing stack)** + +**show ipv6 bgp neighbors (Versions <= 201811 using Quagga routing stack)** + +This command displays all the details of one particular IPv6 Border Gateway Protocol (BGP) neighbor. Option is also available to display only the advertised routes, or the received routes, or all routes. + + +- Usage: + + *Versions >= 201904 using default FRR routing stack* + ``` + show bgp ipv6 neighbors [ [(advertised-routes | received-routes | routes)]] + ``` + *Versions <= 201811 using Quagga routing stack* + ``` + show ipv6 bgp neighbors [ [(advertised-routes | received-routes | routes)]] + ``` + +- Example: + ``` + admin@sonic:~$ show bgp ipv6 neighbors fc00::72 advertised-routes + + admin@sonic:~$ show bgp ipv6 neighbors fc00::72 received-routes + + admin@sonic:~$ show bgp ipv6 neighbors fc00::72 routes + ``` + Click [here](#Quagga-BGP-Show-Commands) to see the example for "show ip bgp summary" for Quagga. + + +**show ipv6 bgp network [[|] [(bestpath | multipath | longer-prefixes | json)]] + +This command displays all the details of IPv6 Border Gateway Protocol (BGP) prefixes. + +- Usage: + + + ``` + show ipv6 bgp network [[|] [(bestpath | multipath | longer-prefixes | json)]] + ``` + +- Example: + + NOTE: The "longer-prefixes" option is only available when a network prefix with a "/" notation is used. + + ``` + admin@sonic:~$ show ipv6 bgp network + + admin@sonic:~$ show ipv6 bgp network fc00::72 bestpath + + admin@sonic:~$ show ipv6 bgp network fc00::72 multipath + + admin@sonic:~$ show ipv6 bgp network fc00::72 json + + admin@sonic:~$ show ipv6 bgp network fc00::72/64 bestpath + + admin@sonic:~$ show ipv6 bgp network fc00::72/64 multipath + + admin@sonic:~$ show ipv6 bgp network fc00::72/64 json + + admin@sonic:~$ show ipv6 bgp network fc00::72/64 longer-prefixes + ``` + + + + +**show route-map** + +This command displays the routing policy that takes precedence over the other route processes that are configured. + +- Usage: + ``` + show route-map + ``` + +- Example: + ``` + admin@sonic:~$ show route-map + ZEBRA: + route-map RM_SET_SRC, permit, sequence 10 + Match clauses: + Set clauses: + src 10.12.0.102 + Call clause: + Action: + Exit routemap + ZEBRA: + route-map RM_SET_SRC6, permit, sequence 10 + Match clauses: + Set clauses: + src fc00:1::102 + Call clause: + Action: + Exit routemap + BGP: + route-map FROM_BGP_SPEAKER_V4, permit, sequence 10 + Match clauses: + Set clauses: + Call clause: + Action: + Exit routemap + BGP: + route-map TO_BGP_SPEAKER_V4, deny, sequence 10 + Match clauses: + Set clauses: + Call clause: + Action: + Exit routemap + BGP: + route-map ISOLATE, permit, sequence 10 + Match clauses: + Set clauses: + as-path prepend 65000 + Call clause: + Action: + Exit routemap + ``` + + +### BGP config commands + +This sub-section explains the list of configuration options available for BGP module for both IPv4 and IPv6 BGP neighbors. + +**config bgp shutdown all** + +This command is used to shutdown all the BGP IPv4 & IPv6 sessions. +When the session is shutdown using this command, BGP state in "show ip bgp summary" is displayed as "Idle (Admin)" + +- Usage: + ``` + config bgp shutdown all + ``` + +- Example: + ``` + admin@sonic:~$ sudo config bgp shutdown all + ``` + +**config bgp shutdown neighbor** + +This command is to shut down a BGP session with a neighbor by that neighbor's IP address or hostname + +- Usage: + ``` + sudo config bgp shutdown neighbor ( | ) + ``` + +- Examples: + ``` + admin@sonic:~$ sudo config bgp shutdown neighbor 192.168.1.124 + ``` + ``` + admin@sonic:~$ sudo config bgp shutdown neighbor SONIC02SPINE + ``` + + +**config bgp startup all** + +This command is used to start up all the IPv4 & IPv6 BGP neighbors + +- Usage: + ``` + config bgp startup all + ``` + +- Example: + ``` + admin@sonic:~$ sudo config bgp startup all + ``` + + +**config bgp startup neighbor** + +This command is used to start up the particular IPv4 or IPv6 BGP neighbor using either the IP address or hostname. + +- Usage: + ``` + config bgp startup neighbor ( | ) + ``` + +- Examples: + ``` + admin@sonic:~$ sudo config bgp startup neighbor 192.168.1.124 + ``` + ``` + admin@sonic:~$ sudo config bgp startup neighbor SONIC02SPINE + ``` + + +**config bgp remove neighbor** + +This command is used to remove particular IPv4 or IPv6 BGP neighbor configuration using either the IP address or hostname. + +- Usage: + ``` + config bgp remove neighbor + ``` + +- Examples: + ``` + admin@sonic:~$ sudo config bgp remove neighbor 192.168.1.124 + ``` + ``` + admin@sonic:~$ sudo config bgp remove neighbor 2603:10b0:b0f:346::4a + ``` + ``` + admin@sonic:~$ sudo config bgp remove neighbor SONIC02SPINE + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#bgp) + +## Console + +This section explains all Console show commands and configuration options that are supported in SONiC. + +All commands are used only when SONiC is used as console switch. + +All commands under this section are not applicable when SONiC used as regular switch. + +### Console show commands + +**show line** + +This command displays serial port or a virtual network connection status. + +- Usage: + ``` + show line (-b|--breif) + ``` + +- Example: + ``` + admin@sonic:~$ show line + Line Baud Flow Control PID Start Time Device + ------ ------ -------------- ----- ------------ -------- + 1 9600 Enabled - - switch1 + 2 - Disabled - - + 3 - Disabled - - + 4 - Disabled - - + 5 - Disabled - - + ``` + +Optionally, you can display configured console ports only by specifying the `-b` or `--breif` flag. + +- Example: + ``` + admin@sonic:~$ show line -b + Line Baud Flow Control PID Start Time Device + ------ ------ -------------- ----- ------------ -------- + 1 9600 Enabled - - switch1 + ``` + +## Console config commands + +This sub-section explains the list of configuration options available for console management module. + +**config console enable** + +This command is used to enable SONiC console switch feature. + +- Usage: + ``` + config console enable + ``` + +- Example: + ``` + admin@sonic:~$ sudo config console enable + ``` + +**config console disable** + +This command is used to disable SONiC console switch feature. + +- Usage: + ``` + config console disable + ``` + +- Example: + ``` + admin@sonic:~$ sudo config console disable + ``` + +**config console add** + +This command is used to add a console port setting. + +- Usage: + ``` + config console add [--baud|-b ] [--flowcontrol|-f] [--devicename|-d ] + ``` + +- Example: + ``` + admin@sonic:~$ config console add 1 --baud 9600 --devicename switch1 + ``` + +**config console del** + +This command is used to remove a console port setting. + +- Usage: + ``` + config console del + ``` + +- Example: + ``` + admin@sonic:~$ sudo config console del 1 + ``` + +**config console remote_device** + +This command is used to update the remote device name for a console port. + +- Usage: + ``` + config console remote_device + ``` + +- Example: + ``` + admin@sonic:~$ sudo config console remote_device 1 switch1 + ``` + +**config console baud** + +This command is used to update the baud rate for a console port. + +- Usage: + ``` + config console baud + ``` + +- Example: + ``` + admin@sonic:~$ sudo config console baud 1 9600 + ``` + +**config console flow_control** + +This command is used to enable or disable flow control feature for a console port. + +- Usage: + ``` + config console flow_control {enable|disable} + ``` + +- Example: + ``` + admin@sonic:~$ sudo config console flow_control enable 1 + ``` + +### Console connect commands + +**connect line** + +This command allows user to connect to a remote device via console line with an interactive cli. + +- Usage: + ``` + connect line (-d|--devicename) + ``` + +By default, the target is `port_name`. + +- Example: + ``` + admin@sonic:~$ connect line 1 + Successful connection to line 1 + Press ^A ^X to disconnect + ``` + +Optionally, you can connect with a remote device name by specifying the `-d` or `--devicename` flag. + +- Example: + ``` + admin@sonic:~$ connect line --devicename switch1 + Successful connection to line 1 + Press ^A ^X to disconnect + ``` + +**connect device** + +This command allows user to connect to a remote device via console line with an interactive cli. + +- Usage: + ``` + connect device + ``` + +The command is same with `connect line --devicename ` + +- Example: + ``` + admin@sonic:~$ connect line 1 + Successful connection to line 1 + Press ^A ^X to disconnect + ``` + +### Console clear commands + +**sonic-clear line** + +This command allows user to connect to a remote device via console line with an interactive cli. + +- Usage: + ``` + sonc-clear line (-d|--devicename) + ``` + +By default, the target is `port_name`. + +- Example: + ``` + admin@sonic:~$ sonic-clear line 1 + ``` + +Optionally, you can clear with a remote device name by specifying the `-d` or `--devicename` flag. + +- Example: + ``` + admin@sonic:~$ sonic-clear --devicename switch1 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#console) + + +## DHCP Relay + +### DHCP Relay config commands + +This sub-section of commands is used to add or remove the DHCP Relay Destination IP address(es) for a VLAN interface. + +**config vlan dhcp_relay add** + +This command is used to add a DHCP Relay Destination IP address or multiple IP addresses to a VLAN. Note that more than one DHCP Relay Destination IP address can be added on a VLAN interface. + +- Usage: + ``` + config vlan dhcp_relay add + ``` + +- Example: + ``` + admin@sonic:~$ sudo config vlan dhcp_relay add 1000 7.7.7.7 + Added DHCP relay destination address ['7.7.7.7'] to Vlan1000 + Restarting DHCP relay service... + ``` + ``` + admin@sonic:~$ sudo config vlan dhcp_relay add 1000 7.7.7.7 1.1.1.1 + Added DHCP relay destination address ['7.7.7.7', '1.1.1.1'] to Vlan1000 + Restarting DHCP relay service... + ``` + +**config vlan dhcp_relay delete** + +This command is used to delete a configured DHCP Relay Destination IP address or multiple IP addresses from a VLAN interface. + +- Usage: + ``` + config vlan dhcp_relay del + ``` + +- Example: + ``` + admin@sonic:~$ sudo config vlan dhcp_relay del 1000 7.7.7.7 + Removed DHCP relay destination address 7.7.7.7 from Vlan1000 + Restarting DHCP relay service... + ``` + ``` + admin@sonic:~$ sudo config vlan dhcp_relay del 1000 7.7.7.7 1.1.1.1 + Removed DHCP relay destination address ('7.7.7.7', '1.1.1.1') from Vlan1000 + Restarting DHCP relay service... + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#dhcp-relay) + + +## Drop Counters + +This section explains all the Configurable Drop Counters show commands and configuration options that are supported in SONiC. + +### Drop Counters show commands + +**show dropcounters capabilities** + +This command is used to show the drop counter capabilities that are available on this device. It displays the total number of drop counters that can be configured on this device as well as the drop reasons that can be configured for the counters. + +- Usage: + ``` + show dropcounters capabilities + ``` + +- Examples: + ``` + admin@sonic:~$ show dropcounters capabilities + Counter Type Total + -------------------- ------- + PORT_INGRESS_DROPS 3 + SWITCH_EGRESS_DROPS 2 + + PORT_INGRESS_DROPS: + L2_ANY + SMAC_MULTICAST + SMAC_EQUALS_DMAC + INGRESS_VLAN_FILTER + EXCEEDS_L2_MTU + SIP_CLASS_E + SIP_LINK_LOCAL + DIP_LINK_LOCAL + UNRESOLVED_NEXT_HOP + DECAP_ERROR + + SWITCH_EGRESS_DROPS: + L2_ANY + L3_ANY + A_CUSTOM_REASON + ``` + +**show dropcounters configuration** + +This command is used to show the current running configuration of the drop counters on this device. + +- Usage: + ``` + show dropcounters configuration [-g ] + ``` + +- Examples: + ``` + admin@sonic:~$ show dropcounters configuration + Counter Alias Group Type Reasons Description + -------- -------- ----- ------------------ ------------------- -------------- + DEBUG_0 RX_LEGIT LEGIT PORT_INGRESS_DROPS SMAC_EQUALS_DMAC Legitimate port-level RX pipeline drops + INGRESS_VLAN_FILTER + DEBUG_1 TX_LEGIT None SWITCH_EGRESS_DROPS EGRESS_VLAN_FILTER Legitimate switch-level TX pipeline drops + + admin@sonic:~$ show dropcounters configuration -g LEGIT + Counter Alias Group Type Reasons Description + -------- -------- ----- ------------------ ------------------- -------------- + DEBUG_0 RX_LEGIT LEGIT PORT_INGRESS_DROPS SMAC_EQUALS_DMAC Legitimate port-level RX pipeline drops + INGRESS_VLAN_FILTER + ``` + +**show dropcounters counts** + +This command is used to show the current statistics for the configured drop counters. Standard drop counters are displayed as well for convenience. + +Because clear (see below) is handled on a per-user basis different users may see different drop counts. + +- Usage: + ``` + show dropcounters counts [-g ] [-t ] + ``` + +- Example: + ``` + admin@sonic:~$ show dropcounters counts + IFACE STATE RX_ERR RX_DROPS TX_ERR TX_DROPS RX_LEGIT + --------- ------- -------- ---------- -------- ---------- --------- + Ethernet0 U 10 100 0 0 20 + Ethernet4 U 0 1000 0 0 100 + Ethernet8 U 100 10 0 0 0 + + DEVICE TX_LEGIT + ------ -------- + sonic 1000 + + admin@sonic:~$ show dropcounters counts -g LEGIT + IFACE STATE RX_ERR RX_DROPS TX_ERR TX_DROPS RX_LEGIT + --------- ------- -------- ---------- -------- ---------- --------- + Ethernet0 U 10 100 0 0 20 + Ethernet4 U 0 1000 0 0 100 + Ethernet8 U 100 10 0 0 0 + + admin@sonic:~$ show dropcounters counts -t SWITCH_EGRESS_DROPS + DEVICE TX_LEGIT + ------ -------- + sonic 1000 + ``` + +### Drop Counters config commands + +**config dropcounters install** + +This command is used to initialize a new drop counter. The user must specify a name, type, and initial list of drop reasons. + +This command will fail if the given name is already in use, if the type of counter is not supported, or if any of the specified drop reasons are not supported. It will also fail if all avaialble counters are already in use on the device. + +- Usage: + ``` + config dropcounters install [-d ] [-g ] [-a ] + ``` + +- Example: + ``` + admin@sonic:~$ sudo config dropcounters install DEBUG_2 PORT_INGRESS_DROPS [EXCEEDS_L2_MTU,DECAP_ERROR] -d "More port ingress drops" -g BAD -a BAD_DROPS + ``` + +**config dropcounters add_reasons** + +This command is used to add drop reasons to an already initialized counter. + +This command will fail if any of the specified drop reasons are not supported. + +- Usage: + ``` + config dropcounters add_reasons + ``` + +- Example: + ``` + admin@sonic:~$ sudo config dropcounters add_reasons DEBUG_2 [SIP_CLASS_E] + ``` + +**config dropcounters remove_reasons** + +This command is used to remove drop reasons from an already initialized counter. + +- Usage: + ``` + config dropcounters remove_reasons + ``` + +- Example: + ``` + admin@sonic:~$ sudo config dropcounters remove_reasons DEBUG_2 [SIP_CLASS_E] + ``` + +**config dropcounters delete** + +This command is used to delete a drop counter. + +- Usage: + ``` + config dropcounters delete + ``` + +- Example: + ``` + admin@sonic:~$ sudo config dropcounters delete DEBUG_2 + ``` + +### Drop Counters clear commands + +**sonic-clear dropcounters** + +This comnmand is used to clear drop counters. This is done on a per-user basis. + +- Usage: + ``` + sonic-clear dropcounters + ``` + +- Example: + ``` + admin@sonic:~$ sonic-clear dropcounters + Cleared drop counters + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](##drop-counters) + +## Dynamic Buffer Management + +This section explains all the show and configuration commands regarding the dynamic buffer management. + +Dynamic buffer management is responsible for calculating buffer size according to the ports' configured speed and administrative state. In order to enable dynamic buffer management feature, the ports' speed must be configured. For this please refer [Interface naming mode config commands](#interface-naming-mode-config-commands) + +### Configuration commands + +**configure shared headroom pool** + +This command is used to configure the shared headroom pool. The shared headroom pool can be enabled in the following ways: + +- Configure the over subscribe ratio. In this case, the size of shared headroom pool is calculated as the accumulative xoff of all of the lossless PG divided by the over subscribe ratio. +- Configure the size. + +In case both of the above parameters have been configured, the `size` will take effect. To disable shared headroom pool, configure both parameters to zero. + +- Usage: + + ``` + config buffer shared-headroom-pool over-subscribe-ratio + config buffer shared-headroom-pool size + ``` + + The range of over-subscribe-ratio is from 1 to number of ports inclusive. + +- Example: + + ``` + admin@sonic:~$ sudo config shared-headroom-pool over-subscribe-ratio 2 + admin@sonic:~$ sudo config shared-headroom-pool size 1024000 + ``` + +**configure a lossless buffer profile** + +This command is used to configure a lossless buffer profile. + +- Usage: + + ``` + config buffer profile add --xon --xoff [-size ] [-dynamic_th ] [-pool ] + config buffer profile set --xon --xoff [-size ] [-dynamic_th ] [-pool ] + config buffer profile remove + ``` + + All the parameters are devided to two groups, one for headroom and one for dynamic_th. For any command at lease one group of parameters should be provided. + For headroom parameters: + + - `xon` is madantory. + - If shared headroom pool is disabled: + - At lease one of `xoff` and `size` should be provided and the other will be optional and conducted via the formula `xon + xoff = size`. + - `xon` + `xoff` <= `size`; For Mellanox platform xon + xoff == size + - If shared headroom pool is enabled: + - `xoff` should be provided. + - `size` = `xoff` if it is not provided. + + If only headroom parameters are provided, the `dynamic_th` will be taken from `CONFIG_DB.DEFAULT_LOSSLESS_BUFFER_PARAMETER.default_dynamic_th`. + + If only dynamic_th parameter is provided, the `headroom_type` will be set as `dynamic` and `xon`, `xoff` and `size` won't be set. This is only used for non default dynamic_th. In this case, the profile won't be deployed to ASIC directly. It can be configured to a lossless PG and then a dynamic profile will be generated based on the port's speed, cable length, and MTU and deployed to the ASIC. + + The subcommand `add` is designed for adding a new buffer profile to the system. + + The subcommand `set` is designed for modifying an existing buffer profile in the system. + For a profile with dynamically calculated headroom information, only `dynamic_th` can be modified. + + The subcommand `remove` is designed for removing an existing buffer profile from the system. When removing a profile, it shouldn't be referenced by any entry in `CONFIG_DB.BUFFER_PG`. + +- Example: + + ``` + admin@sonic:~$ sudo config buffer profile add profile1 --xon 18432 --xoff 18432 + admin@sonic:~$ sudo config buffer profile remove profile1 + ``` + +**config interface cable_length** + +This command is used to configure the length of the cable connected to a port. The cable_length is in unit of meters and must be suffixed with "m". + +- Usage: + + ``` + config interface cable_length + ``` + +- Example: + + ``` + admin@sonic:~$ sudo config interface cable_length Ethernet0 40m + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#dynamic-buffer-management) + +**config interface buffer priority-group lossless** + +This command is used to configure the priority groups on which lossless traffic runs. + +- Usage: + + ``` + config interface buffer priority-group lossless add [profile] + config interface buffer priority-group lossless set [profile] + config interface buffer priority-group lossless remove [] + ``` + + The can be in one of the following two forms: + + - For a range of priorities, the lower bound and upper bound connected by a dash, like `3-4` + - For a single priority, the number, like `6` + + The `pg-map` represents the map of priorities for lossless traffic. It should be a string and in form of a bit map like `3-4`. The `-` connects the lower bound and upper bound of a range of priorities. + + The subcommand `add` is designed for adding a new lossless PG on top of current PGs. The new PG range must be disjoint with all existing PGs. + + For example, currently the PG range 3-4 exist on port Ethernet4, to add PG range 4-5 will fail because it isn't disjoint with 3-4. To add PG range 5-6 will succeed. After that both range 3-4 and 5-6 will work as lossless PG. + + The `override-profile` parameter is optional. When provided, it represents the predefined buffer profile for headroom override. + + The subcommand `set` is designed for modifying an existing PG from dynamic calculation to headroom override or vice versa. The `pg-map` must be an existing PG. + + The subcommand `remove` is designed for removing an existing PG. The option `pg-map` must be an existing PG. All lossless PGs will be removed in case no `pg-map` provided. + +- Example: + + To configure lossless_pg on a port: + + ``` + admin@sonic:~$ sudo config interface buffer priority-group lossless add Ethernet0 3-4 + ``` + + To change the profile used for lossless_pg on a port: + + ``` + admin@sonic:~$ sudo config interface buffer priority-group lossless set Ethernet0 3-4 new-profile + ``` + + To remove one lossless priority from a port: + + ``` + admin@sonic:~$ sudo config interface buffer priority-group lossless remove Ethernet0 6 + ``` + + To remove all lossless priorities from a port: + + ``` + admin@sonic:~$ sudo config interface buffer priority-group lossless remove Ethernet0 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#dynamic-buffer-management) + +**config interface buffer queue** + +This command is used to configure the buffer profiles for queues. + +- Usage: + + ``` + config interface buffer queue add + config interface buffer queue set + config interface buffer queue remove + ``` + + The represents the map of queues. It can be in one of the following two forms: + + - For a range of priorities, the lower bound and upper bound connected by a dash, like `3-4` + - For a single priority, the number, like `6` + + The subcommand `add` is designed for adding a buffer profile for a group of queues. The new queue range must be disjoint with all queues with buffer profile configured. + + For example, currently the buffer profile configured on queue 3-4 on port Ethernet4, to configure buffer profile on queue 4-5 will fail because it isn't disjoint with 3-4. To configure it on range 5-6 will succeed. + + The `profile` parameter represents a predefined egress buffer profile to be configured on the queues. + + The subcommand `set` is designed for modifying an existing group of queues. + + The subcommand `remove` is designed for removing buffer profile on an existing group of queues. + +- Example: + + To configure buffer profiles for queues on a port: + + ``` + admin@sonic:~$ sudo config interface buffer queue add Ethernet0 3-4 egress_lossless_profile + ``` + + To change the profile used for queues on a port: + + ``` + admin@sonic:~$ sudo config interface buffer queue set Ethernet0 3-4 new-profile + ``` + + To remove a group of queues from a port: + + ``` + admin@sonic:~$ sudo config interface buffer queue remove Ethernet0 3-4 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#dynamic-buffer-management) + +### Show commands + +**show buffer information** + +This command is used to display the status of buffer pools and profiles currently deployed to the ASIC. + +- Usage: + + ``` + show buffer information + ``` + +- Example: + + ``` + admin@sonic:~$ show buffer information + Pool: ingress_lossless_pool + ---- -------- + type ingress + mode dynamic + size 17170432 + ---- -------- + + Pool: egress_lossless_pool + ---- -------- + type egress + mode dynamic + size 34340822 + ---- -------- + + Pool: ingress_lossy_pool + ---- -------- + type ingress + mode dynamic + size 17170432 + ---- -------- + + Pool: egress_lossy_pool + ---- -------- + type egress + mode dynamic + size 17170432 + ---- -------- + + Profile: pg_lossless_100000_5m_profile + ---------- ----------------------------------- + xon 18432 + dynamic_th 0 + xoff 18432 + pool [BUFFER_POOL:ingress_lossless_pool] + size 36864 + ---------- ----------------------------------- + + Profile: q_lossy_profile + ---------- ------------------------------- + dynamic_th 3 + pool [BUFFER_POOL:egress_lossy_pool] + size 0 + ---------- ------------------------------- + + Profile: egress_lossy_profile + ---------- ------------------------------- + dynamic_th 3 + pool [BUFFER_POOL:egress_lossy_pool] + size 4096 + ---------- ------------------------------- + + Profile: egress_lossless_profile + ---------- ---------------------------------- + dynamic_th 7 + pool [BUFFER_POOL:egress_lossless_pool] + size 0 + ---------- ---------------------------------- + + Profile: ingress_lossless_profile + ---------- ----------------------------------- + dynamic_th 0 + pool [BUFFER_POOL:ingress_lossless_pool] + size 0 + ---------- ----------------------------------- + + Profile: pg_lossless_100000_79m_profile + ---------- ----------------------------------- + xon 18432 + dynamic_th 0 + xoff 60416 + pool [BUFFER_POOL:ingress_lossless_pool] + size 78848 + ---------- ----------------------------------- + + Profile: pg_lossless_100000_40m_profile + ---------- ----------------------------------- + xon 18432 + dynamic_th 0 + xoff 38912 + pool [BUFFER_POOL:ingress_lossless_pool] + size 57344 + ---------- ----------------------------------- + + Profile: ingress_lossy_profile + ---------- -------------------------------- + dynamic_th 3 + pool [BUFFER_POOL:ingress_lossy_pool] + size 0 + ---------- -------------------------------- + ``` + +**show buffer configuration** + +This command is used to display the status of buffer pools and profiles currently configured. + +- Usage: + + ``` + show buffer configuration + ``` + +- Example: + + ``` + admin@sonic:~$ show buffer configuration + Lossless traffic pattern: + -------------------- - + default_dynamic_th 0 + over_subscribe_ratio 0 + -------------------- - + + Pool: ingress_lossless_pool + ---- -------- + type ingress + mode dynamic + ---- -------- + + Pool: egress_lossless_pool + ---- -------- + type egress + mode dynamic + size 34340822 + ---- -------- + + Pool: ingress_lossy_pool + ---- -------- + type ingress + mode dynamic + ---- -------- + + Pool: egress_lossy_pool + ---- -------- + type egress + mode dynamic + ---- -------- + + Profile: q_lossy_profile + ---------- ------------------------------- + dynamic_th 3 + pool [BUFFER_POOL:egress_lossy_pool] + size 0 + ---------- ------------------------------- + + Profile: egress_lossy_profile + ---------- ------------------------------- + dynamic_th 3 + pool [BUFFER_POOL:egress_lossy_pool] + size 4096 + ---------- ------------------------------- + + Profile: egress_lossless_profile + ---------- ---------------------------------- + dynamic_th 7 + pool [BUFFER_POOL:egress_lossless_pool] + size 0 + ---------- ---------------------------------- + + Profile: ingress_lossless_profile + ---------- ----------------------------------- + dynamic_th 0 + pool [BUFFER_POOL:ingress_lossless_pool] + size 0 + ---------- ----------------------------------- + + Profile: ingress_lossy_profile + ---------- -------------------------------- + dynamic_th 3 + pool [BUFFER_POOL:ingress_lossy_pool] + size 0 + ---------- -------------------------------- + ``` + +## ECN + +This section explains all the Explicit Congestion Notification (ECN) show commands and ECN configuation options that are supported in SONiC. + +### ECN show commands +This sub-section contains the show commands that are supported in ECN. + +**show ecn** + +This command displays all the WRED profiles that are configured in the device. + +- Usage: + ``` + show ecn + ``` + +- Example: + ``` + admin@sonic:~$ show ecn + Profile: **AZURE_LOSSLESS** + ----------------------- ------- + red_max_threshold 2097152 + red_drop_probability 5 + yellow_max_threshold 2097152 + ecn ecn_all + green_min_threshold 1048576 + red_min_threshold 1048576 + wred_yellow_enable true + yellow_min_threshold 1048576 + green_max_threshold 2097152 + green_drop_probability 5 + wred_green_enable true + yellow_drop_probability 5 + wred_red_enable true + ----------------------- ------- + + Profile: **wredprofileabcd** + ----------------- --- + red_max_threshold 100 + ----------------- --- + ``` + +### ECN config commands + +This sub-section contains the configuration commands that can configure the WRED profiles. + +**config ecn** + +This command configures the possible fields in a particular WRED profile that is specified using "-profile " argument. +The list of the WRED profile fields that are configurable is listed in the below "Usage". + +- Usage: + ``` + config ecn -profile [-rmax ] [-rmin ] [-ymax ] [-ymin ] [-gmax ] [-gmin ] [-v|--verbose] + ``` + + - Parameters: + - profile_name Profile name + - red_threshold_max Set red max threshold + - red_threshold_min Set red min threshold + - yellow_threshold_max Set yellow max threshold + - yellow_threshold_min Set yellow min threshold + - green_threshold_max Set green max threshold + - green_threshold_min Set green min threshold + +- Example (Configures the "red max threshold" for the WRED profile name "wredprofileabcd". It will create the WRED profile if it does not exist.): + ``` + admin@sonic:~$ sudo config ecn -profile wredprofileabcd -rmax 100 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#ecn) + +## Feature + +SONiC includes a capability in which Feature state can be enabled/disabled +which will make corresponding feature docker container to start/stop. + +Also SONiC provide capability in which Feature docker container can be automatically shut +down and restarted if one of critical processes running in the container exits +unexpectedly. Restarting the entire feature container ensures that configuration is +reloaded and all processes in the feature container get restarted, thus increasing the +likelihood of entering a healthy state. + +### Feature show commands + +**show feature config** + +Shows the config of given feature or all if no feature is given. The "fallback" is shown only if configured. The fallback defaults to "true" when not configured. + +- Usage: + ``` + show feature config [] + ``` + +- Example: + ``` + admin@sonic:~$ show feature config + Feature State AutoRestart Owner fallback + -------------- -------- ------------- ------- ---------- + bgp enabled enabled local + database enabled disabled local + dhcp_relay enabled enabled kube + lldp enabled enabled kube true + mgmt-framework enabled enabled local + nat disabled enabled local + pmon enabled enabled kube + radv enabled enabled kube + sflow disabled enabled local + snmp enabled enabled kube + swss enabled enabled local + syncd enabled enabled local + teamd enabled enabled local + telemetry enabled enabled kube + ``` + +**show feature status** + +Shows the status of given feature or all if no feature is given. The "fallback" defaults to "true" when not configured. +The subset of features are configurable for remote management and only those report additional data. + +- Usage: + ``` + show feature status [] + ``` + +- Example: + ``` + admin@sonic:~$ show feature status + Feature State AutoRestart SystemState UpdateTime ContainerId ContainerVersion SetOwner CurrentOwner RemoteState + -------------- -------- ------------- ------------- ------------------- ------------- ------------------ ---------- -------------- ------------- + bgp enabled enabled up local local none + database enabled disabled local + dhcp_relay enabled enabled up 2020-11-15 18:21:09 249e70102f55 20201230.100 kube local + lldp enabled enabled up 2020-11-15 18:21:09 779c2d55ee12 20201230.100 kube local + mgmt-framework enabled enabled up local local none + nat disabled enabled local + pmon enabled enabled up 2020-11-15 18:20:27 a2b9ffa8aba3 20201230.100 kube local + radv enabled enabled up 2020-11-15 18:21:05 d8ff27dcfe46 20201230.100 kube local + sflow disabled enabled local + snmp enabled enabled up 2020-11-15 18:25:51 8b7d5529e306 20201230.111 kube kube running + swss enabled enabled up local local none + syncd enabled enabled up local local none + teamd enabled enabled up local local none + telemetry enabled enabled down 2020-11-15 18:24:59 20201230.100 kube none + ``` + +**config feature owner** + +Configures the owner for a feature as "local" or "kube". The "local" implies starting the feature container from local image. The "kube" implies that kubernetes server is made eligible to deploy the feature. The deployment of a feature by kubernetes is conditional based on many factors like, whether the kube server is configured or not, connected-to-kube-server or not and if that master has manifest for this feature for this switch or not and more. At some point in future, the deployment *could* happen and till that point the feature can run from local image, called "fallback". The fallback is allowed by default and it could be toggled to "not allowed". When fallback is not allowed, the feature would run only upon deployment by kubernetes master. + +- Usage: + ``` + config feature owner [] [local/kube] + ``` + +- Example: + ``` + admin@sonic:~$ sudo config feature owner snmp kube + ``` + +**config feature fallback** + +Features configured for "kube" deployment could be allowed to fallback to using local image, until the point of successful kube deployment. The fallback is allowed by default. + +- Usage: + ``` + config feature fallback [] [on/off] + ``` + +- Example: + ``` + admin@sonic:~$ sudo config feature fallback snmp on + ``` + +**show feature autorestart** + +This command will display the status of auto-restart for feature container. + +- Usage: + ``` + show feature autorestart [] + admin@sonic:~$ show feature autorestart + Feature AutoRestart + ---------- -------------- + bgp enabled + database always_enabled + dhcp_relay enabled + lldp enabled + pmon enabled + radv enabled + snmp enabled + swss enabled + syncd enabled + teamd enabled + telemetry enabled + ``` + +Optionally, you can specify a feature name in order to display +status for that feature + +### Feature config commands + +**config feature state ** + +This command will configure the state for a specific feature. + +- Usage: + ``` + config feature state (enabled | disabled) + admin@sonic:~$ sudo config feature state bgp disabled + ``` + +To make the command wait until the corresponding feature container stops(starts) use ```--block``` options: + +- Usage: + ``` + admin@sonic:~$ config feature state bgp enabled --block + ``` + +**config feature autorestart ** + +This command will configure the status of auto-restart for a specific feature container. + +- Usage: + ``` + config feature autorestart (enabled | disabled) + admin@sonic:~$ sudo config feature autorestart bgp disabled + ``` +NOTE: If the existing state or auto-restart value for a feature is "always_enabled" then config +commands are don't care and will not update state/auto-restart value. + +Go Back To [Beginning of the document](#) or [Beginning of this section](#feature) + +## Flow Counters + +This section explains all the Flow Counters show commands, clear commands and config commands that are supported in SONiC. Flow counters are usually used for debugging, troubleshooting and performance enhancement processes. Flow counters supports case like: + + - Host interface traps (number of received traps per Trap ID) + - Routes matching the configured prefix pattern (number of hits and number of bytes) + +### Flow Counters show commands + +**show flowcnt-trap stats** + +This command is used to show the current statistics for the registered host interface traps. + +Because clear (see below) is handled on a per-user basis different users may see different counts. + +- Usage: + ``` + show flowcnt-trap stats + ``` + +- Example: + ``` + admin@sonic:~$ show flowcnt-trap stats + Trap Name Packets Bytes PPS + --------- --------- ------- ------- + dhcp 100 2,000 50.25/s + + For multi-ASIC: + admin@sonic:~$ show flowcnt-trap stats + ASIC ID Trap Name Packets Bytes PPS + ------- ----------- --------- ------- ------- + asic0 dhcp 100 2,000 50.25/s + asic1 dhcp 200 3,000 45.25/s + ``` + +**show flowcnt-route stats** + +This command is used to show the current statistics for route flow patterns. + +Because clear (see below) is handled on a per-user basis different users may see different counts. + +- Usage: + ``` + show flowcnt-route stats + show flowcnt-route stats pattern [--vrf ] + show flowcnt-route stats route [--vrf ] + ``` + +- Example: + ``` + admin@sonic:~$ show flowcnt-route stats + Route pattern VRF Matched routes Packets Bytes + -------------------------------------------------------------------------------------- + 3.3.0.0/16 default 3.3.1.0/24 100 4543 + 3.3.2.3/32 3443 929229 + 3.3.0.0/16 0 0 + 2000::/64 default 2000::1/128 100 4543 + ``` + +The "pattern" subcommand is used to display the route flow counter statistics by route pattern. + +- Example: + ``` + admin@sonic:~$ show flowcnt-route stats pattern 3.3.0.0/16 + Route pattern VRF Matched routes Packets Bytes + -------------------------------------------------------------------------------------- + 3.3.0.0/16 default 3.3.1.0/24 100 4543 + 3.3.2.3/32 3443 929229 + 3.3.0.0/16 0 0 + ``` + +The "route" subcommand is used to display the route flow counter statistics by route prefix. + ``` + admin@sonic:~$ show flowcnt-route stats route 3.3.3.2/32 --vrf Vrf_1 + Route VRF Route Pattern Packets Bytes + ----------------------------------------------------------------------------------------- + 3.3.3.2/32 Vrf_1 3.3.0.0/16 100 4543 + ``` + +### Flow Counters clear commands + +**sonic-clear flowcnt-trap** + +This command is used to clear the current statistics for the registered host interface traps. This is done on a per-user basis. + +- Usage: + ``` + sonic-clear flowcnt-trap + ``` + +- Example: + ``` + admin@sonic:~$ sonic-clear flowcnt-trap + Trap Flow Counters were successfully cleared + ``` + +**sonic-clear flowcnt-route** + +This command is used to clear the current statistics for the route flow counter. This is done on a per-user basis. + +- Usage: + ``` + sonic-clear flowcnt-route + sonic-clear flowcnt-route pattern [--vrf ] + sonic-clear flowcnt-route route [--vrf ] + ``` + +- Example: + ``` + admin@sonic:~$ sonic-clear flowcnt-route + Route Flow Counters were successfully cleared + ``` + +The "pattern" subcommand is used to clear the route flow counter statistics by route pattern. + +- Example: + ``` + admin@sonic:~$ sonic-clear flowcnt-route pattern 3.3.0.0/16 --vrf Vrf_1 + Flow Counters of all routes matching the configured route pattern were successfully cleared + ``` + +The "route" subcommand is used to clear the route flow counter statistics by route prefix. + +- Example: + ``` + admin@sonic:~$ sonic-clear flowcnt-route route 3.3.3.2/32 --vrf Vrf_1 + Flow Counters of the specified route were successfully cleared + ``` + +### Flow Counters config commands + +**config flowcnt-route pattern add** + +This command is used to add or update the route pattern which is used by route flow counter to match route entries. + +- Usage: + ``` + config flowcnt-route pattern add [--vrf ] [--max ] + ``` + +- Example: + ``` + admin@sonic:~$ config flowcnt-route pattern add 2.2.0.0/16 --vrf Vrf_1 --max 50 + ``` + +**config flowcnt-route pattern remove** + +This command is used to remove the route pattern which is used by route flow counter to match route entries. + +- Usage: + ``` + config flowcnt-route pattern remove [--vrf ] + ``` + +- Example: + ``` + admin@sonic:~$ config flowcnt-route pattern remove 2.2.0.0/16 --vrf Vrf_1 + ``` + + +Go Back To [Beginning of the document](#) or [Beginning of this section](#flow-counters) +## Gearbox + +This section explains all the Gearbox PHY show commands that are supported in SONiC. + +### Gearbox show commands +This sub-section contains the show commands that are supported for gearbox phy. + +**show gearbox interfaces status** + +This command displays information about the gearbox phy interface lanes, speeds and status. Data is displayed for both MAC side and line side of the gearbox phy + +- Usage: + ``` + show gearbox interfaces status + ``` + +- Example: + +``` +home/admin# show gearbox interfaces status + PHY Id Interface MAC Lanes MAC Lane Speed PHY Lanes PHY Lane Speed Line Lanes Line Lane Speed Oper Admin +-------- ----------- ----------- ---------------- ----------- ---------------- ------------ ----------------- ------ ------- + 1 Ethernet0 25,26,27,28 10G 200,201 20G 206 40G up up + 1 Ethernet4 29,30,31,32 10G 202,203 20G 207 40G up up + 1 Ethernet8 33,34,35,36 10G 204,205 20G 208 40G up up + + ``` + +**show gearbox phys status** + +This command displays basic information about the gearbox phys configured on the switch. + +- Usage: + ``` + show gearbox phys status + ``` + +- Example: + +``` +/home/admin# show gearbox phys status + PHY Id Name Firmware +-------- ------- ---------- + 1 sesto-1 v0.1 + + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#gearbox) + + +## Update Device Hostname Configuration Commands + +This sub-section of commands is used to change device hostname without traffic being impacted. + +**config hostname** + +This command is used to change device hostname without traffic being impacted. + +- Usage: + ``` + config hostname + ``` + +- Example: + ``` + admin@sonic:~$ sudo config hostname CSW06 + Please note loaded setting will be lost after system reboot. To preserve setting, run `config save`. + ``` + +## Interfaces + +### Interface Show Commands + +This sub-section lists all the possible show commands for the interfaces available in the device. Following example gives the list of possible shows on interfaces. +Subsequent pages explain each of these commands in detail. + +- Example: + ``` + admin@sonic:~$ show interfaces -? + + Show details of the network interfaces + + Options: + -?, -h, --help Show this message and exit. + + Commands: + autoneg Show interface autoneg information + breakout Show Breakout Mode information by interfaces + counters Show interface counters + description Show interface status, protocol and... + mpls Show Interface MPLS status + naming_mode Show interface naming_mode status + neighbor Show neighbor related information + portchannel Show PortChannel information + status Show Interface status information + tpid Show Interface tpid information + transceiver Show SFP Transceiver information + ``` + +**show interfaces autoneg** + +This show command displays the port auto negotiation status for all interfaces i.e. interface name, auto negotiation mode, speed, advertised speeds, interface type, advertised interface types, operational status, admin status. For a single interface, provide the interface name with the sub-command. + +- Usage: + ``` + show interfaces autoneg status + show interfaces autoneg status + ``` + +- Example: + ``` + admin@sonic:~$ show interfaces autoneg status + Interface Auto-Neg Mode Speed Adv Speeds Type Adv Types Oper Admin + ----------- --------------- ------- ------------ ------ ----------- ------ ------- + Ethernet0 enabled 25G 10G,25G CR CR,CR4 up up + Ethernet4 disabled 100G all CR4 all up up + + admin@sonic:~$ show interfaces autoneg status Ethernet8 + Interface Auto-Neg Mode Speed Adv Speeds Type Adv Types Oper Admin + ----------- --------------- ------- ------------ ------ ----------- ------ ------- + Ethernet8 disabled 100G N/A CR4 N/A up up + ``` + +**show interfaces breakout (Versions >= 202006)** + +This show command displays the port capability for all interfaces i.e. index, lanes, default_brkout_mode, breakout_modes(i.e. available breakout modes) and brkout_mode (i.e. current breakout mode). To display current breakout mode, "current-mode" subcommand can be used.For a single interface, provide the interface name with the sub-command. + +- Usage: + ``` + show interfaces breakout + show interfaces breakout current-mode + show interfaces breakout current-mode + ``` + +- Example: + ``` + admin@lnos-x1-a-fab01:~$ show interfaces breakout + { + "Ethernet0": { + "index": "1,1,1,1", + "default_brkout_mode": "1x100G[40G]", + "child ports": "Ethernet0", + "child port speed": "100G", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]", + "Current Breakout Mode": "1x100G[40G]", + "lanes": "65,66,67,68", + "alias_at_lanes": "Eth1/1, Eth1/2, Eth1/3, Eth1/4" + },... continue + } + ``` +The "current-mode" subcommand is used to display current breakout mode for all interfaces. + ``` + admin@lnos-x1-a-fab01:~$ show interfaces breakout current-mode + +-------------+-------------------------+ + | Interface | Current Breakout Mode | + +=============+=========================+ + | Ethernet0 | 4x25G[10G] | + +-------------+-------------------------+ + | Ethernet4 | 4x25G[10G] | + +-------------+-------------------------+ + | Ethernet8 | 4x25G[10G] | + +-------------+-------------------------+ + | Ethernet12 | 4x25G[10G] | + +-------------+-------------------------+ + + admin@lnos-x1-a-fab01:~$ show interfaces breakout current-mode Ethernet0 + +-------------+-------------------------+ + | Interface | Current Breakout Mode | + +=============+=========================+ + | Ethernet0 | 4x25G[10G] | + +-------------+-------------------------+ + ``` + +**show interfaces counters** + +This show command displays packet counters for all interfaces since the last time the counters were cleared. To display l3 counters "rif" subcommand can be used. There is no facility to display counters for one specific l2 interface. For l3 interfaces a single interface output mode is present. Optional argument "-a" provides two additional columns - RX-PPS and TX_PPS. +Optional argument "-p" specify a period (in seconds) with which to gather counters over. + +- Usage: + ``` + show interfaces counters [-a|--printall] [-p|--period ] + show interfaces counters errors + show interfaces counters rates + show interfaces counters rif [-p|--period ] [-i ] + ``` + +- Example: + ``` + admin@sonic:~$ show interfaces counters + IFACE STATE RX_OK RX_BPS RX_UTIL RX_ERR RX_DRP RX_OVR TX_OK TX_BPS TX_UTIL TX_ERR TX_DRP TX_OVR + ----------- ------- --------------- ----------- --------- -------- -------- -------- --------------- ----------- --------- -------- -------- -------- + Ethernet0 U 471,729,839,997 653.87 MB/s 12.77% 0 18,682 0 409,682,385,925 556.84 MB/s 10.88% 0 0 0 + Ethernet4 U 453,838,006,636 632.97 MB/s 12.36% 0 1,636 0 388,299,875,056 529.34 MB/s 10.34% 0 0 0 + Ethernet8 U 549,034,764,539 761.15 MB/s 14.87% 0 18,274 0 457,603,227,659 615.20 MB/s 12.02% 0 0 0 + Ethernet12 U 458,052,204,029 636.84 MB/s 12.44% 0 17,614 0 388,341,776,615 527.37 MB/s 10.30% 0 0 0 + Ethernet16 U 16,679,692,972 13.83 MB/s 0.27% 0 17,605 0 18,206,586,265 17.51 MB/s 0.34% 0 0 0 + Ethernet20 U 47,983,339,172 35.89 MB/s 0.70% 0 2,174 0 58,986,354,359 51.83 MB/s 1.01% 0 0 0 + Ethernet24 U 33,543,533,441 36.59 MB/s 0.71% 0 1,613 0 43,066,076,370 49.92 MB/s 0.97% 0 0 0 + + admin@sonic:~$ show interfaces counters -i Ethernet4,Ethernet12-16 + IFACE STATE RX_OK RX_BPS RX_UTIL RX_ERR RX_DRP RX_OVR TX_OK TX_BPS TX_UTIL TX_ERR TX_DRP TX_OVR + ----------- ------- --------------- ----------- --------- -------- -------- -------- --------------- ----------- --------- -------- -------- -------- + Ethernet4 U 453,838,006,636 632.97 MB/s 12.36% 0 1,636 0 388,299,875,056 529.34 MB/s 10.34% 0 0 0 + Ethernet12 U 458,052,204,029 636.84 MB/s 12.44% 0 17,614 0 388,341,776,615 527.37 MB/s 10.30% 0 0 0 + Ethernet16 U 16,679,692,972 13.83 MB/s 0.27% 0 17,605 0 18,206,586,265 17.51 MB/s 0.34% 0 0 0 + ``` + +The "errors" subcommand is used to display the interface errors. + +- Example: + ``` + admin@str-s6000-acs-11:~$ show interface counters errors + IFACE STATE RX_ERR RX_DRP RX_OVR TX_ERR TX_DRP TX_OVR + ----------- ------- -------- -------- -------- -------- -------- -------- + Ethernet0 U 0 4 0 0 0 0 + Ethernet4 U 0 0 0 0 0 0 + Ethernet8 U 0 1 0 0 0 0 + Ethernet12 U 0 0 0 0 0 0 + ``` + +The "rates" subcommand is used to disply only the interface rates. + +- Example: + ``` + admin@str-s6000-acs-11:/usr/bin$ show int counters rates + IFACE STATE RX_OK RX_BPS RX_PPS RX_UTIL TX_OK TX_BPS TX_PPS TX_UTIL + ----------- ------- ------- -------- -------- --------- ------- -------- -------- --------- + Ethernet0 U 467510 N/A N/A N/A 466488 N/A N/A N/A + Ethernet4 U 469679 N/A N/A N/A 469245 N/A N/A N/A + Ethernet8 U 466660 N/A N/A N/A 465982 N/A N/A N/A + Ethernet12 U 466579 N/A N/A N/A 466318 N/A N/A N/A + ``` + + +The "rif" subcommand is used to display l3 interface counters. Layer 3 interfaces include router interfaces, portchannels and vlan interfaces. + +- Example: + +``` + admin@sonic:~$ show interfaces counters rif + IFACE RX_OK RX_BPS RX_PPS RX_ERR TX_OK TX_BPS TX_PPS TX_ERR +--------------- ------- ---------- -------- -------- ------- -------- -------- -------- +PortChannel0001 62,668 107.81 B/s 1.34/s 3 6 0.02 B/s 0.00/s 0 +PortChannel0002 62,645 107.77 B/s 1.34/s 3 2 0.01 B/s 0.00/s 0 +PortChannel0003 62,481 107.56 B/s 1.34/s 3 3 0.01 B/s 0.00/s 0 +PortChannel0004 62,732 107.88 B/s 1.34/s 2 3 0.01 B/s 0.00/s 0 + Vlan1000 0 0.00 B/s 0.00/s 0 0 0.00 B/s 0.00/s 0 +``` + + +Optionally, you can specify a layer 3 interface name to display the counters in single interface mode. + +- Example: + +``` + admin@sonic:~$ show interfaces counters rif PortChannel0001 + PortChannel0001 + --------------- + + RX: + 3269 packets + 778494 bytesq + 3 error packets + 292 error bytes + TX: + 0 packets + 0 bytes + 0 error packets + 0 error bytes +``` + + +Optionally, you can specify a period (in seconds) with which to gather counters over. Note that this function will take `` seconds to execute. + +- Example: + +``` + admin@sonic:~$ show interfaces counters -p 5 + IFACE STATE RX_OK RX_BPS RX_UTIL RX_ERR RX_DRP RX_OVR TX_OK TX_BPS TX_UTIL TX_ERR TX_DRP TX_OVR + ----------- ------- ------- ----------- --------- -------- -------- -------- ------- ----------- --------- -------- -------- -------- + Ethernet0 U 515 59.14 KB/s 0.00% 0 0 0 1,305 127.60 KB/s 0.00% 0 0 0 + Ethernet4 U 305 26.54 KB/s 0.00% 0 0 0 279 39.12 KB/s 0.00% 0 0 0 + Ethernet8 U 437 42.96 KB/s 0.00% 0 0 0 182 18.37 KB/s 0.00% 0 0 0 + Ethernet12 U 284 40.79 KB/s 0.00% 0 0 0 160 13.03 KB/s 0.00% 0 0 0 + Ethernet16 U 377 32.64 KB/s 0.00% 0 0 0 214 18.01 KB/s 0.00% 0 0 0 + Ethernet20 U 284 36.81 KB/s 0.00% 0 0 0 138 8758.25 B/s 0.00% 0 0 0 + Ethernet24 U 173 16.09 KB/s 0.00% 0 0 0 169 11.39 KB/s 0.00% 0 0 0 +``` + +- NOTE: Interface counters can be cleared by the user with the following command: + + ``` + admin@sonic:~$ sonic-clear counters + ``` + +- NOTE: Layer 3 interface counters can be cleared by the user with the following command: + + ``` + admin@sonic:~$ sonic-clear rifcounters + ``` + +**show interfaces description** + +This command displays the key fields of the interfaces such as Operational Status, Administrative Status, Alias and Description. + +- Usage: + ``` + show interfaces description [] + ``` + +- Example: + ``` + admin@sonic:~$ show interfaces description + Interface Oper Admin Alias Description + ----------- ------ ------- --------------- -------------------- + Ethernet0 down up hundredGigE1/1 T0-1:hundredGigE1/30 + Ethernet4 down up hundredGigE1/2 T0-2:hundredGigE1/30 + Ethernet8 down down hundredGigE1/3 hundredGigE1/3 + Ethernet12 down down hundredGigE1/4 hundredGigE1/4 + ``` + +- Example (to only display the description for interface Ethernet4): + + ``` + admin@sonic:~$ show interfaces description Ethernet4 + Interface Oper Admin Alias Description + ----------- ------ ------- -------------- -------------------- + Ethernet4 down up hundredGigE1/2 T0-2:hundredGigE1/30 + ``` + +**show interfaces mpls** + +This command is used to display the configured MPLS state for the list of configured interfaces. + +- Usage: + ``` + show interfaces mpls [] + ``` + +- Example: + ``` + admin@sonic:~$ show interfaces mpls + Interface MPLS State + ----------- ------------ + Ethernet0 disable + Ethernet4 enable + Ethernet8 enable + Ethernet12 disable + Ethernet16 disable + Ethernet20 disable + ``` + +- Example (to only display the MPLS state for interface Ethernet4): + ``` + admin@sonic:~$ show interfaces mpls Ethernet4 + Interface MPLS State + ----------- ------------ + Ethernet4 enable + ``` + +**show interfaces loopback-action** + +This command displays the configured loopback action + +- Usage: + ``` + show ip interfaces loopback-action + ``` + +- Example: + ``` + root@sonic:~# show ip interfaces loopback-action + Interface Action + ------------ ---------- + Ethernet232 drop + Vlan100 forward + ``` + + +**show interfaces tpid** + +This command displays the key fields of the interfaces such as Operational Status, Administrative Status, Alias and TPID. + +- Usage: + ``` + show interfaces tpid [] + ``` + +- Example: + ``` + admin@sonic:~$ show interfaces tpid + Interface Alias Oper Admin TPID + --------------- --------------- ------ ------- ------ + Ethernet0 fortyGigE1/1/1 up up 0x8100 + Ethernet1 fortyGigE1/1/2 up up 0x8100 + Ethernet2 fortyGigE1/1/3 down down 0x8100 + Ethernet3 fortyGigE1/1/4 down down 0x8100 + Ethernet4 fortyGigE1/1/5 up up 0x8100 + Ethernet5 fortyGigE1/1/6 up up 0x8100 + Ethernet6 fortyGigE1/1/7 up up 0x9200 + Ethernet7 fortyGigE1/1/8 up up 0x88A8 + Ethernet8 fortyGigE1/1/9 up up 0x8100 + ... + Ethernet63 fortyGigE1/4/16 down down 0x8100 + PortChannel0001 N/A up up 0x8100 + PortChannel0002 N/A up up 0x8100 + PortChannel0003 N/A up up 0x8100 + PortChannel0004 N/A up up 0x8100 + admin@sonic:~$ + ``` + +- Example (to only display the TPID for interface Ethernet6): + + ``` + admin@sonic:~$ show interfaces tpid Ethernet6 + Interface Alias Oper Admin TPID + ----------- -------------- ------ ------- ------ + Ethernet6 fortyGigE1/1/7 up up 0x9200 + admin@sonic:~$ + ``` + +**show interfaces naming_mode** + +Refer sub-section [Interface-Naming-Mode](#Interface-Naming-Mode) + + +**show interfaces neighbor** + +This command is used to display the list of expected neighbors for all interfaces (or for a particular interface) that is configured. + +- Usage: + ``` + show interfaces neighbor expected [] + ``` + +- Example: + ``` + admin@sonic:~$ show interfaces neighbor expected + LocalPort Neighbor NeighborPort NeighborLoopback NeighborMgmt NeighborType + ----------- ---------- -------------- ------------------ -------------- -------------- + Ethernet112 ARISTA01T1 Ethernet1 None 10.16.205.100 ToRRouter + Ethernet116 ARISTA02T1 Ethernet1 None 10.16.205.101 SpineRouter + Ethernet120 ARISTA03T1 Ethernet1 None 10.16.205.102 LeafRouter + Ethernet124 ARISTA04T1 Ethernet1 None 10.16.205.103 LeafRouter + ``` + +**show interfaces portchannel** + +This command displays information regarding port-channel interfaces + +- Usage: + ``` + show interfaces portchannel + ``` + +- Example: + ``` + admin@sonic:~$ show interfaces portchannel + Flags: A - active, I - inactive, Up - up, Dw - Down, N/A - not available, S - selected, D - deselected + No. Team Dev Protocol Ports + ----- ------------- ----------- --------------------------- + 24 PortChannel24 LACP(A)(Up) Ethernet28(S) Ethernet24(S) + 48 PortChannel48 LACP(A)(Up) Ethernet52(S) Ethernet48(S) + 40 PortChannel40 LACP(A)(Up) Ethernet44(S) Ethernet40(S) + 0 PortChannel0 LACP(A)(Up) Ethernet0(S) Ethernet4(S) + 8 PortChannel8 LACP(A)(Up) Ethernet8(S) Ethernet12(S) + ``` + +**show interface status** + +This command displays some more fields such as Lanes, Speed, MTU, Type, Asymmetric PFC status and also the operational and administrative status of the interfaces + +- Usage: + ``` + show interfaces status [] + ``` + +- Example (show interface status of all interfaces): + ``` + admin@sonic:~$ show interfaces status + Interface Lanes Speed MTU Alias Oper Admin Type Asym PFC + ----------- --------------- ------- ----- --------------- ------ ------- ------ ---------- + Ethernet0 49,50,51,52 100G 9100 hundredGigE1/1 down up N/A off + Ethernet4 53,54,55,56 100G 9100 hundredGigE1/2 down up N/A off + Ethernet8 57,58,59,60 100G 9100 hundredGigE1/3 down down N/A off + + ``` + +- Example (to only display the status for interface Ethernet0): + ``` + admin@sonic:~$ show interface status Ethernet0 + Interface Lanes Speed MTU Alias Oper Admin + ----------- -------- ------- ----- -------------- ------ ------- + Ethernet0 101,102 40G 9100 fortyGigE1/1/1 up up + ``` + +- Example (to only display the status for range of interfaces): + ``` + admin@sonic:~$ show interfaces status Ethernet8,Ethernet168-180 + Interface Lanes Speed MTU Alias Oper Admin Type Asym PFC + ----------- ----------------- ------- ----- --------------- ------ ------- ------ ---------- + Ethernet8 49,50,51,52 100G 9100 hundredGigE3 down down N/A N/A + Ethernet168 9,10,11,12 100G 9100 hundredGigE43 down down N/A N/A + Ethernet172 13,14,15,16 100G 9100 hundredGigE44 down down N/A N/A + Ethernet176 109,110,111,112 100G 9100 hundredGigE45 down down N/A N/A + Ethernet180 105,106,107,108 100G 9100 hundredGigE46 down down N/A N/A + ``` + +**show interfaces transceiver** + +This command is already explained [here](#Transceivers) + +### Interface Config Commands +This sub-section explains the following list of configuration on the interfaces. +1) ip - To add or remove IP address for the interface +2) pfc - to set the PFC configuration for the interface +3) shutdown - to administratively shut down the interface +4) speed - to set the interface speed +5) startup - to bring up the administratively shutdown interface +6) breakout - to set interface breakout mode +7) autoneg - to set interface auto negotiation mode +8) advertised-speeds - to set interface advertised speeds +9) advertised-types - to set interface advertised types +10) type - to set interface type +11) mpls - To add or remove MPLS operation for the interface +12) loopback-action - to set action for packet that ingress and gets routed on the same IP interface + +From 201904 release onwards, the “config interface” command syntax is changed and the format is as follows: + +- config interface interface_subcommand +i.e Interface name comes after the subcommand +- Ex: config interface startup Ethernet63 + +The syntax for all such interface_subcommands are given below under each command + +NOTE: In older versions of SONiC until 201811 release, the command syntax was `config interface interface_subcommand` + + +**config interface ip add [default_gw] (Versions >= 201904)** + +**config interface ip add (Versions <= 201811)** + +This command is used for adding the IP address for an interface. +IP address for either physical interface or for portchannel or for VLAN interface or for Loopback interface can be configured using this command. +While configuring the IP address for the management interface "eth0", users can provide the default gateway IP address as an optional parameter from release 201911. + + +- Usage: + + *Versions >= 201904* + ``` + config interface ip add + ``` + *Versions <= 201811* + ``` + config interface ip add + ``` + +- Example: + + *Versions >= 201904* + ``` + admin@sonic:~$ sudo config interface ip add Ethernet63 10.11.12.13/24 + admin@sonic:~$ sudo config interface ip add eth0 20.11.12.13/24 20.11.12.254 + ``` + *Versions <= 201811* + ``` + admin@sonic:~$ sudo config interface Ethernet63 ip add 10.11.12.13/24 + ``` + +VLAN interface names take the form of `vlan`. E.g., VLAN 100 will be named `vlan100` + +- Example: + + *Versions >= 201904* + ``` + admin@sonic:~$ sudo config interface ip add Vlan100 10.11.12.13/24 + ``` + *Versions <= 201811* + ``` + admin@sonic:~$ sudo config interface vlan100 ip add 10.11.12.13/24 + ``` + + +**config interface ip remove (Versions >= 201904)** + +**config interface ip remove (Versions <= 201811)** + +- Usage: + + *Versions >= 201904* + ``` + config interface ip remove + ``` + *Versions <= 201811* + ``` + config interface ip remove + ``` + +- Example: + + *Versions >= 201904* + ``` + admin@sonic:~$ sudo config interface ip remove Ethernet63 10.11.12.13/24 + admin@sonic:~$ sudo config interface ip remove eth0 20.11.12.13/24 + ``` + *Versions <= 201811* + ``` + admin@sonic:~$ sudo config interface Ethernet63 ip remove 10.11.12.13/24 + ``` + +VLAN interface names take the form of `vlan`. E.g., VLAN 100 will be named `vlan100` + +- Example: + + *Versions >= 201904* + ``` + admin@sonic:~$ sudo config interface ip remove vlan100 10.11.12.13/24 + ``` + *Versions <= 201811* + ``` + admin@sonic:~$ sudo config interface vlan100 ip remove 10.11.12.13/24 + ``` + +**config interface pfc priority (on | off)** + +This command is used to set PFC on a given priority of a given interface to either "on" or "off". Once it is successfully configured, it will show current losses priorities on the given interface. Otherwise, it will show error information + +- Example: + *Versions >= 201904* + ``` + admin@sonic:~$ sudo config interface pfc priority Ethernet0 3 off + + Interface Lossless priorities + ----------- --------------------- + Ethernet0 4 + + admin@sonic:~$ sudo config interface pfc priority Ethernet0 8 off + Usage: pfc config priority [OPTIONS] STATUS INTERFACE PRIORITY + + Error: Invalid value for "priority": invalid choice: 8. (choose from 0, 1, 2, 3, 4, 5, 6, 7) + + admin@sonic:~$ sudo config interface pfc priority Ethernet101 3 off + Cannot find interface Ethernet101 + + admin@sonic:~$ sudo config interface pfc priority Ethernet0 3 on + + Interface Lossless priorities + ----------- --------------------- + Ethernet0 3,4 + ``` + +**config interface pfc asymmetric (Versions >= 201904)** + +**config interface pfc asymmetric (Versions <= 201811)** + +This command is used for setting the asymmetric PFC for an interface to either "on" or "off". Once if it is configured, use "show interfaces status" to check the same. + +- Usage: + + *Versions >= 201904* + ``` + config interface pfc asymmetric on/off (for 201904+ version) + ``` + *Versions <= 201811* + ``` + config interface pfc asymmetric on/off (for 201811- version) + ``` + +- Example: + + *Versions >= 201904* + ``` + admin@sonic:~$ sudo config interface pfc asymmetric Ethernet60 on + ``` + *Versions <= 201811* + ``` + admin@sonic:~$ sudo config interface Ethernet60 pfc asymmetric on + ``` + +**config interface shutdown (Versions >= 201904)** + +**config interface shutdown (Versions <= 201811)** + +This command is used to administratively shut down either the Physical interface or port channel interface. Once if it is configured, use "show interfaces status" to check the same. + +- Usage: + + *Versions >= 201904* + ``` + config interface shutdown (for 201904+ version) + ``` + *Versions <= 201811* + ``` + config interface shutdown (for 201811- version) + ``` + +- Example: + + *Versions >= 201904* + ``` + admin@sonic:~$ sudo config interface shutdown Ethernet63 + ``` + *Versions <= 201811* + ``` + admin@sonic:~$ sudo config interface Ethernet63 shutdown + ``` + + shutdown multiple interfaces + ``` + admin@sonic:~$ sudo config interface shutdown Ethernet8,Ethernet16-20,Ethernet32 + ``` + +**config interface startup (Versions >= 201904)** + +**config interface startup (Versions <= 201811)** + +This command is used for administratively bringing up the Physical interface or port channel interface.Once if it is configured, use "show interfaces status" to check the same. + +- Usage: + + *Versions >= 201904* + ``` + config interface startup (for 201904+ version) + ``` + *Versions <= 201811* + ``` + config interface startup (for 201811- version) + ``` + +- Example: + + *Versions >= 201904* + ``` + admin@sonic:~$ sudo config interface startup Ethernet63 + ``` + *Versions <= 201811* + ``` + admin@sonic:~$ sudo config interface Ethernet63 startup + ``` + + startup multiple interfaces + ``` + admin@sonic:~$ sudo config interface startup Ethernet8,Ethernet16-20,Ethernet32 + ``` + +**config interface speed (Versions >= 202006)** + +Dynamic breakout feature is supported in SONiC from 202006 version. +User can configure any speed specified under "breakout_modes" keys for the parent interface in the platform-specific port configuration file (i.e. platform.json). + +For example for a breakout mode of 2x50G[25G,10G] the default speed is 50G but the interface also supports 25G and 10G. + +Refer [DPB HLD DOC](https://github.com/Azure/SONiC/blob/master/doc/dynamic-port-breakout/sonic-dynamic-port-breakout-HLD.md#cli-design) to know more about this command. + +**config interface speed (Versions >= 201904)** + +**config interface speed (Versions <= 201811)** + +This command is used to configure the speed for the Physical interface. Use the value 40000 for setting it to 40G and 100000 for 100G. Users need to know the device to configure it properly. + +- Usage: + + *Versions >= 201904* + ``` + config interface speed + ``` + *Versions <= 201811* + ``` + config interface speed + ``` + +- Example (Versions >= 201904): + ``` + admin@sonic:~$ sudo config interface speed Ethernet63 40000 + ``` + +- Example (Versions <= 201811): + ``` + admin@sonic:~$ sudo config interface Ethernet63 speed 40000 + + ``` + +**config interface transceiver lpmode** + +This command is used to enable or disable low-power mode for an SFP transceiver + +- Usage: + + ``` + config interface transceiver lpmode (enable | disable) + ``` + +- Examples: + + ``` + user@sonic~$ sudo config interface transceiver lpmode Ethernet0 enable + Enabling low-power mode for port Ethernet0... OK + + user@sonic~$ sudo config interface transceiver lpmode Ethernet0 disable + Disabling low-power mode for port Ethernet0... OK + ``` + +**config interface transceiver reset** + +This command is used to reset an SFP transceiver + +- Usage: + + ``` + config interface transceiver reset + ``` + +- Examples: + + ``` + user@sonic~$ sudo config interface transceiver reset Ethernet0 + Resetting port Ethernet0... OK + ``` + +**config interface mtu (Versions >= 201904)** + +This command is used to configure the mtu for the Physical interface. Use the value 1500 for setting max transfer unit size to 1500 bytes. + +- Usage: + + *Versions >= 201904* + ``` + config interface mtu + ``` + +- Example (Versions >= 201904): + ``` + admin@sonic:~$ sudo config interface mtu Ethernet64 1500 + ``` + +**config interface tpid (Versions >= 202106)** + +This command is used to configure the TPID for the Physical/PortChannel interface. default is 0x8100. Other allowed values if supported by HW SKU (0x9100, 0x9200, 0x88A8). + +- Usage: + + *Versions >= 202106* + ``` + config interface tpid + ``` + +- Example (Versions >= 202106): + ``` + admin@sonic:~$ sudo config interface tpid Ethernet64 0x9200 + ``` + +**config interface breakout (Versions >= 202006)** + +This command is used to set active breakout mode available for user-specified interface based on the platform-specific port configuration file(i.e. platform.json) +and the current mode set for the interface. + +Based on the platform.json and the current mode set in interface, this command acts on setting breakout mode for the interface. + +Double tab i.e. to see the available breakout option customized for each interface provided by the user. + +- Usage: + ``` + sudo config interface breakout --help + Usage: config interface breakout [OPTIONS] MODE + + Set interface breakout mode + + Options: + -f, --force-remove-dependencies + Clear all depenedecies internally first. + -l, --load-predefined-config load predefied user configuration (alias, + lanes, speed etc) first. + -y, --yes + -v, --verbose Enable verbose output + -?, -h, --help Show this message and exit. + ``` +- Example : + ``` + admin@sonic:~$ sudo config interface breakout Ethernet0 + + 1x100G[40G] 2x50G 4x25G[10G] + ``` + + This command also provides "--force-remove-dependencies/-f" option to CLI, which will automatically determine and remove the configuration dependencies using Yang models. + + ``` + admin@sonic:~$ sudo config interface breakout Ethernet0 4x25G[10G] -f -l -v -y + ``` + +For details please refer [DPB HLD DOC](https://github.com/Azure/SONiC/blob/master/doc/dynamic-port-breakout/sonic-dynamic-port-breakout-HLD.md#cli-design) to know more about this command. + +Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces) + +**config interface autoneg (Versions >= 202106)** + +This command is used to set port auto negotiation mode. + +- Usage: + ``` + sudo config interface autoneg --help + Usage: config interface autoneg [OPTIONS] + + Set interface auto negotiation mode + + Options: + -v, --verbose Enable verbose output + -h, -?, --help Show this message and exit. + ``` + +- Example: + ``` + admin@sonic:~$ sudo config interface autoneg Ethernet0 enabled + + admin@sonic:~$ sudo config interface autoneg Ethernet0 disabled + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces) + +**config interface advertised-speeds (Versions >= 202106)** + +This command is used to set port advertised speed. + +- Usage: + ``` + sudo config interface advertised-speeds --help + Usage: config interface advertised-speeds [OPTIONS] + + Set interface advertised speeds + + Options: + -v, --verbose Enable verbose output + -h, -?, --help Show this message and exit. + ``` + +- Example: + ``` + admin@sonic:~$ sudo config interface advertised-speeds Ethernet0 all + + admin@sonic:~$ sudo config interface advertised-speeds Ethernet0 50000,100000 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces) + +**config interface advertised-types (Versions >= 202106)** + +This command is used to set port advertised interface types. + +- Usage: + ``` + sudo config interface advertised-types --help + Usage: config interface advertised-types [OPTIONS] + + Set interface advertised types + + Options: + -v, --verbose Enable verbose output + -h, -?, --help Show this message and exit. + ``` + +- Example: + ``` + admin@sonic:~$ sudo config interface advertised-types Ethernet0 all + + admin@sonic:~$ sudo config interface advertised-types Ethernet0 CR,CR4 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces) + +**config interface type (Versions >= 202106)** + +This command is used to set port interface type. + +- Usage: + ``` + sudo config interface type --help + Usage: config interface type [OPTIONS] + + Set interface type + + Options: + -v, --verbose Enable verbose output + -h, -?, --help Show this message and exit. + ``` + +- Example: + ``` + admin@sonic:~$ sudo config interface type Ethernet0 CR4 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces) + +**config interface cable_length (Versions >= 202006)** + +This command is used to configure the length of the cable connected to a port. The cable_length is in unit of meters and must be suffixed with "m". + +For details please refer [dynamic buffer management](#dynamic-buffer-management) + +Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces) + +**config interface lossless_pg (Versions >= 202006)** + +This command is used to configure the priority groups on which lossless traffic runs. + +For details please refer [dynamic buffer management](#dynamic-buffer-management) + +Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces) + +**config interface headroom_override (Versions >= 202006)** + +This command is used to configure a static buffer profile on a port's lossless priorities. There shouldn't be any `lossless_pg` configured on the port when configuring `headroom_override`. The port's headroom won't be updated after `headroom_override` has been configured on the port. + +For details please refer [dynamic buffer management](#dynamic-buffer-management) + +Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces) + +**config interface mpls add (Versions >= 202106)** + +This command is used for adding MPLS operation on the interface. +MPLS operation for either physical, portchannel, or VLAN interface can be configured using this command. + + +- Usage: + ``` + sudo config interface mpls add --help + Usage: config interface mpls add [OPTIONS] + + Add MPLS operation on the interface + + Options: + -?, -h, --help Show this message and exit. + ``` + +- Example: + ``` + admin@sonic:~$ sudo config interface mpls add Ethernet4 + ``` + +**config interface mpls remove (Versions >= 202106)** + +This command is used for removing MPLS operation on the interface. +MPLS operation for either physical, portchannel, or VLAN interface can be configured using this command. + +- Usage: + ``` + sudo config interface mpls remove --help + Usage: config interface mpls remove [OPTIONS] + + Remove MPLS operation from the interface + + Options: + -?, -h, --help Show this message and exit. + ``` + +- Example: + ``` + admin@sonic:~$ sudo config interface mpls remove Ethernet4 + ``` + +**config interface ip loopback-action (Versions >= 202205)** + +This command is used for setting the action being taken on packets that ingress and get routed on the same IP interface. +Loopback action can be set on IP interface from type physical, portchannel, VLAN interface and VLAN subinterface. +Loopback action can be drop or forward. + +- Usage: + ``` + config interface ip loopback-action --help + Usage: config interface ip loopback-action [OPTIONS] + + Set IP interface loopback action + + Options: + -?, -h, --help Show this message and exit. + ``` + +- Example: + ``` + admin@sonic:~$ config interface ip loopback-action Ethernet0 drop + admin@sonic:~$ config interface ip loopback-action Ethernet0 forward + + ``` +Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces) + +## Interface Naming Mode + +### Interface naming mode show commands +This command displays the current interface naming mode. Interface naming mode originally set to 'default'. Interfaces are referenced by default SONiC interface names. +Users can change the naming_mode using "config interface_naming_mode" command. + +**show interfaces naming_mode** + +This command displays the current interface naming mode + +- Usage: + ``` + show interfaces naming_mode + ``` + +- Examples: + ``` + admin@sonic:~$ show interfaces naming_mode + default + ``` + + - "default" naming mode will display all SONiC interface names in 'show' commands and accept SONiC interface names as parameters in 'config commands + + ``` + admin@sonic:~$ show interfaces naming_mode + alias + ``` + + - "alias" naming mode will display all hardware vendor interface aliases in 'show' commands and accept hardware vendor interface aliases as parameters in 'config commands + + +### Interface naming mode config commands + +**config interface_naming_ mode** + +This command is used to change the interface naming mode. +Users can select between default mode (SONiC interface names) or alias mode (Hardware vendor names). +The user must log out and log back in for changes to take effect. Note that the newly-applied interface mode will affect all interface-related show/config commands. + + +*NOTE: Some platforms do not support alias mapping. In such cases, this command is not applicable. Such platforms always use the same SONiC interface names.* + +- Usage: + ``` + config interface_naming_mode (default | alias) + ``` + + - Interface naming mode is originally set to 'default'. Interfaces are referenced by default SONiC interface names: + +- Example: + ``` + admin@sonic:~$ show interfaces naming_mode + default + + admin@sonic:~$ show interface status Ethernet0 + Interface Lanes Speed MTU Alias Oper Admin + ----------- -------- ------- ----- -------------- ------ ------- + Ethernet0 101,102 40G 9100 fortyGigE1/1/1 up up + + admin@sonic:~$ sudo config interface_naming_mode alias + Please logout and log back in for changes take effect. + ``` + + - After user logs out and logs back in again, interfaces will then referenced by hardware vendor aliases: + + ``` + admin@sonic:~$ show interfaces naming_mode + alias + + admin@sonic:~$ sudo config interface fortyGigE1/1/1 shutdown + admin@sonic:~$ show interface status fortyGigE1/1/1 + Interface Lanes Speed MTU Alias Oper Admin + ----------- -------- ------- ----- -------------- ------ ------- + Ethernet0 101,102 40G 9100 fortyGigE1/1/1 down down + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#interface-naming-mode) + +## Interface Vrf binding + +### Interface vrf bind & unbind config commands + +**config interface vrf bind** + +This command is used to bind a interface to a vrf. +By default, all L3 interfaces will be in default vrf. Above vrf bind command will let users bind interface to a vrf. + +- Usage: + ``` + config interface vrf bind + ``` + +**config interface vrf unbind** + +This command is used to ubind a interface from a vrf. +This will move the interface to default vrf. + +- Usage: + ``` + config interface vrf unbind + ``` + + ### Interface vrf binding show commands + + To display interface vrf binding information, user can use show vrf command. Please refer sub-section [Vrf-show-command](#vrf-show-commands). + +Go Back To [Beginning of the document](#) or [Beginning of this section](#interface-vrf-binding) + +## IP / IPv6 + +### IP show commands + +This sub-section explains the various IP protocol specific show commands that are used to display the following. +1) routes +2) bgp details - Explained in the [bgp section](#show-bgp) +3) IP interfaces +4) prefix-list +5) protocol + +#### show ip route + +This command displays either all the route entries from the routing table or a specific route. + +- Usage: + ``` + show ip route [] [] + ``` + +- Example: + ``` + admin@sonic:~$ show ip route + Codes: K - kernel route, C - connected, S - static, R - RIP, + O - OSPF, I - IS-IS, B - BGP, P - PIM, A - Babel, + > - selected route, * - FIB route + S>* 0.0.0.0/0 [200/0] via 10.11.162.254, eth0 + C>* 1.1.0.0/16 is directly connected, Vlan100 + C>* 10.1.1.0/31 is directly connected, Ethernet112 + C>* 10.1.1.2/31 is directly connected, Ethernet116 + C>* 10.11.162.0/24 is directly connected, eth0 + C>* 127.0.0.0/8 is directly connected, lo + C>* 240.127.1.0/24 is directly connected, docker0 + ``` + + - Optionally, you can specify an IP address in order to display only routes to that particular IP address + +- Example: + ``` + admin@sonic:~$ show ip route 10.1.1.0 + Routing entry for 10.1.1.0/31 + Known via "connected", distance 0, metric 0, best + * directly connected, Ethernet112 + ``` + + - Vrf-name can also be specified to get IPv4 routes programmed in the vrf. + + - Example: + ``` + admin@sonic:~$ show ip route vrf Vrf-red + Codes: K - kernel route, C - connected, S - static, R - RIP, + O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, + T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, + F - PBR, f - OpenFabric, + > - selected route, * - FIB route + VRF Vrf-red: + C>* 11.1.1.1/32 is directly connected, Loopback11, 21:50:47 + C>* 100.1.1.0/24 is directly connected, Vlan100, 03w1d06h + + admin@sonic:~$ show ip route vrf Vrf-red 11.1.1.1/32 + Routing entry for 11.1.1.1/32 + Known via "connected", distance 0, metric 0, vrf Vrf-red, best + Last update 21:57:53 ago + * directly connected, Loopback11 + ``` + +#### show ip interfaces + +This command displays the details about all the Layer3 IP interfaces in the device for which IP address has been assigned. +The type of interfaces include the following. +1) Front panel physical ports. +2) PortChannel. +3) VLAN interface. +4) Loopback interfaces +5) docker interface and +6) management interface + +- Usage: + ``` + show ip interfaces + ``` + +- Example: + ``` + admin@sonic:~$ show ip interfaces + Interface Master IPv4 address/mask Admin/Oper BGP Neighbor Neighbor IP Flags + ------------- ------------ ------------------ -------------- ------------- ------------- ------- + Loopback0 1.0.0.1/32 up/up N/A N/A + Loopback11 Vrf-red 11.1.1.1/32 up/up N/A N/A + Loopback100 Vrf-blue 100.0.0.1/32 up/up N/A N/A + PortChannel01 10.0.0.56/31 up/down DEVICE1 10.0.0.57 + PortChannel02 10.0.0.58/31 up/down DEVICE2 10.0.0.59 + PortChannel03 10.0.0.60/31 up/down DEVICE3 10.0.0.61 + PortChannel04 10.0.0.62/31 up/down DEVICE4 10.0.0.63 + Vlan100 Vrf-red 1001.1.1/24 up/up N/A N/A + Vlan1000 192.168.0.1/27 up/up N/A N/A + docker0 240.127.1.1/24 up/down N/A N/A + eth0 10.3.147.252/23 up/up N/A N/A + lo 127.0.0.1/8 up/up N/A N/A + ``` + +#### show ip protocol + +This command displays the route-map that is configured for the routing protocol. +Refer the routing stack [Quagga Command Reference](https://www.quagga.net/docs/quagga.pdf) or [FRR Command Reference](https://buildmedia.readthedocs.org/media/pdf/frrouting/latest/frrouting.pdf) to know more about this command. + +- Usage: + ``` + show ip protocol + ``` + +- Example: + ``` + admin@sonic:~$ show ip protocol + Protocol : route-map + ------------------------ + system : none + kernel : none + connected : none + static : none + rip : none + ripng : none + ospf : none + ospf6 : none + isis : none + bgp : RM_SET_SRC + pim : none + hsls : none + olsr : none + babel : none + any : none + ``` + +### IPv6 show commands + +This sub-section explains the various IPv6 protocol specific show commands that are used to display the following. +1) routes +2) IPv6 bgp details - Explained in the [bgp section](#show-bgp) +3) IP interfaces +4) protocol + +**show ipv6 route** + +This command displays either all the IPv6 route entries from the routing table or a specific IPv6 route. + +- Usage: + ``` + show ipv6 route [] [] + ``` + +- Example: + ``` + admin@sonic:~$ show ipv6 route + Codes: K - kernel route, C - connected, S - static, R - RIPng, + O - OSPFv6, I - IS-IS, B - BGP, A - Babel, + > - selected route, * - FIB route + + C>* ::1/128 is directly connected, lo + C>* 2018:2001::/126 is directly connected, Ethernet112 + C>* 2018:2002::/126 is directly connected, Ethernet116 + C>* fc00:1::32/128 is directly connected, lo + C>* fc00:1::102/128 is directly connected, lo + C>* fc00:2::102/128 is directly connected, eth0 + C * fe80::/64 is directly connected, Vlan100 + C * fe80::/64 is directly connected, Ethernet112 + C * fe80::/64 is directly connected, Ethernet116 + C * fe80::/64 is directly connected, Bridge + C * fe80::/64 is directly connected, PortChannel0011 + C>* fe80::/64 is directly connected, eth0 + ``` + - Optionally, you can specify an IPv6 address in order to display only routes to that particular IPv6 address + + +- Example: + ``` + admin@sonic:~$ show ipv6 route fc00:1::32 + Routing entry for fc00:1::32/128 + Known via "connected", distance 0, metric 0, best + * directly connected, lo + ``` + + Vrf-name can also be specified to get IPv6 routes programmed in the vrf. + + - Example: + ``` + admin@sonic:~$ show ipv6 route vrf Vrf-red + Codes: K - kernel route, C - connected, S - static, R - RIP, + O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, + T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, + F - PBR, f - OpenFabric, + > - selected route, * - FIB route + VRF Vrf-red: + C>* 1100::1/128 is directly connected, Loopback11, 21:50:47 + C>* 100::/112 is directly connected, Vlan100, 03w1d06h + C>* fe80::/64 is directly connected, Loopback11, 21:50:47 + C>* fe80::/64 is directly connected, Vlan100, 03w1d06h + + admin@sonic:~$ show ipv6 route vrf Vrf-red 1100::1/128 + Routing entry for 1100::1/128 + Known via "connected", distance 0, metric 0, vrf Vrf-red, best + Last update 21:57:53 ago + * directly connected, Loopback11 + ``` + +**show ipv6 interfaces** + +This command displays the details about all the Layer3 IPv6 interfaces in the device for which IPv6 address has been assigned. +The type of interfaces include the following. +1) Front panel physical ports. +2) PortChannel. +3) VLAN interface. +4) Loopback interfaces +5) management interface + +- Usage: + ``` + show ipv6 interfaces + ``` + +- Example: + ``` + admin@sonic:~$ show ipv6 interfaces + Interface Master IPv6 address/mask Admin/Oper BGP Neighbor Neighbor IP + ----------- -------- ---------------------------------------- ------------ -------------- ------------- + Bridge fe80::7c45:1dff:fe08:cdd%Bridge/64 up/up N/A N/A + Loopback11 Vrf-red 1100::1/128 up/up + PortChannel01 fc00::71/126 up/down DEVICE1 fc00::72 + PortChannel02 fc00::75/126 up/down DEVICE2 fc00::76 + PortChannel03 fc00::79/126 up/down DEVICE3 fc00::7a + PortChannel04 fc00::7d/126 up/down DEVICE4 fc00::7e + Vlan100 Vrf-red 100::1/112 up/up N/A N/A + fe80::eef4:bbff:fefe:880a%Vlan100/64 + eth0 fe80::eef4:bbff:fefe:880a%eth0/64 up/up N/A N/A + lo fc00:1::32/128 up/up N/A N/A + ``` + +**show ipv6 protocol** + +This command displays the route-map that is configured for the IPv6 routing protocol. +Refer the routing stack [Quagga Command Reference](https://www.quagga.net/docs/quagga.pdf) or [FRR Command Reference](https://buildmedia.readthedocs.org/media/pdf/frrouting/latest/frrouting.pdf) to know more about this command. + + +- Usage: + ``` + show ipv6 protocol + ``` + +- Example: + ``` + admin@sonic:~$ show ipv6 protocol + Protocol : route-map + ------------------------ + system : none + kernel : none + connected : none + static : none + rip : none + ripng : none + ospf : none + ospf6 : none + isis : none + bgp : RM_SET_SRC6 + pim : none + hsls : none + olsr : none + babel : none + any : none + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#ip--ipv6) + +## IPv6 Link Local + +### IPv6 Link Local config commands + +This section explains all the commands that are supported in SONiC to configure IPv6 Link-local. + +**config interface ipv6 enable use-link-local-only ** + +This command enables user to enable an interface to forward L3 traffic with out configuring an address. This command creates the routing interface based on the auto generated IPv6 link-local address. This command can be used even if an address is configured on the interface. + +- Usage: + ``` + config interface ipv6 enable use-link-local-only + ``` + +- Example: + ``` + admin@sonic:~$ sudo config interface ipv6 enable use-link-local-only Vlan206 + admin@sonic:~$ sudo config interface ipv6 enable use-link-local-only PortChannel007 + admin@sonic:~$ sudo config interface ipv6 enable use-link-local-only Ethernet52 + ``` + +**config interface ipv6 disable use-link-local-only ** + +This command enables user to disable use-link-local-only configuration on an interface. + +- Usage: + ``` + config interface ipv6 disable use-link-local-only + ``` + +- Example: + ``` + admin@sonic:~$ sudo config interface ipv6 disable use-link-local-only Vlan206 + admin@sonic:~$ sudo config interface ipv6 disable use-link-local-only PortChannel007 + admin@sonic:~$ sudo config interface ipv6 disable use-link-local-only Ethernet52 + ``` + +**config ipv6 enable link-local** + +This command enables user to enable use-link-local-only command on all the interfaces globally. + +- Usage: + ``` + sudo config ipv6 enable link-local + ``` + +- Example: + ``` + admin@sonic:~$ sudo config ipv6 enable link-local + ``` + +**config ipv6 disable link-local** + +This command enables user to disable use-link-local-only command on all the interfaces globally. + +- Usage: + ``` + sudo config ipv6 disable link-local + ``` + +- Example: + ``` + admin@sonic:~$ sudo config ipv6 disable link-local + ``` + +### IPv6 Link Local show commands + +**show ipv6 link-local-mode** + +This command displays the link local mode of all the interfaces. + +- Usage: + ``` + show ipv6 link-local-mode + ``` + +- Example: + ``` + root@sonic:/home/admin# show ipv6 link-local-mode + +------------------+----------+ + | Interface Name | Mode | + +==================+==========+ + | Ethernet16 | Disabled | + +------------------+----------+ + | Ethernet18 | Enabled | + +------------------+----------+ + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#ipv6-link-local) + +## Kubernetes + +### Kubernetes show commands + +**show kubernetes server config** + +This command displays the kubernetes server configuration, if any, else would report as not configured. + +- Usage: + ``` + show kubernetes server config + ``` + +- Example: + ``` + admin@sonic:~$ show kubernetes server config + ip port insecure disable + ----------- ------ ---------- --------- + 10.3.157.24 6443 True False + ``` + +**show kubernetes server status** + +This command displays the kubernetes server status. + +- Usage: + ``` + show kubernetes server status + ``` + +- Example: + ``` + admin@sonic:~$ show kubernetes server status + ip port connected update-time + ----------- ------ ----------- ------------------- + 10.3.157.24 6443 true 2020-11-15 18:25:05 + ``` +Go Back To [Beginning of the document](#) or [Beginning of this section](#Kubernetes) + +## Linux Kernel Dump + +This section demonstrates the show commands and configuration commands of Linux kernel dump mechanism in SONiC. + +### Linux Kernel Dump show commands + +**show kdump config** + +This command shows the configuration of Linux kernel dump. + +- Usage: + ``` + show kdump config + ``` + +- Example: + ``` + admin@sonic:$ show kdump config + Kdump administrative mode: Disabled + Kdump operational mode: Unready + Kdump memory researvation: 0M-2G:256M,2G-4G:320M,4G-8G:384M,8G-:448M + Maximum number of Kdump files: 3 + ``` + +**show kdump files** + +This command shows the Linux kernel core dump files and dmesg files which are +generated by kernel dump tool. + +- Usage: + ``` + show kdump files + ``` + +- Example: + ``` + admin@sonic:~$ show kdump files + Kernel core dump files Kernel dmesg files + ------------------------------------------ ------------------------------------------ + /var/crash/202106242344/kdump.202106242344 /var/crash/202106242344/dmesg.202106242344 + /var/crash/202106242337/kdump.202106242337 /var/crash/202106242337/dmesg.202106242337 + ``` + +**show kdump logging ** + +By default, this command will show the last 10 lines of latest dmesg file. +This command can also accept a specific file name and number of lines as arguments. + +- Usage: + ``` + show kdump logging + ``` + +- Example: + ``` + admin@sonic:~$ show kdump logging + [ 157.642053] RSP: 002b:00007fff1beee708 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 + [ 157.732635] RAX: ffffffffffffffda RBX: 0000000000000002 RCX: 00007fc3887d4504 + [ 157.818015] RDX: 0000000000000002 RSI: 000055d388eceb40 RDI: 0000000000000001 + [ 157.903401] RBP: 000055d388eceb40 R08: 000000000000000a R09: 00007fc3888255f0 + [ 157.988784] R10: 000000000000000a R11: 0000000000000246 R12: 00007fc3888a6760 + [ 158.074166] R13: 0000000000000002 R14: 00007fc3888a1760 R15: 0000000000000002 + [ 158.159553] Modules linked in: nft_chain_route_ipv6(E) nft_chain_route_ipv4(E) xt_TCPMSS(E) dummy(E) team_mode_loadbalance(E) team(E) sx_bfd(OE) sx_netdev(OE) psample(E) sx_core(OE) 8021q(E) garp(E) mrp(E) mst_pciconf(OE) mst_pci(OE) xt_hl(E) xt_tcpudp(E) ip6_tables(E) nft_compat(E) nft_chain_nat_ipv4(E) nf_nat_ipv4(E) nft_counter(E) xt_conntrack(E) nf_nat(E) jc42(E) nf_conntrack_netlink(E) nf_conntrack(E) nf_defrag_ipv6(E) nf_defrag_ipv4(E) libcrc32c(E) xfrm_user(E) xfrm_algo(E) mlxsw_minimal(E) mlxsw_i2c(E) i2c_mux_reg(E) i2c_mux(E) i2c_mlxcpld(E) leds_mlxreg(E) mlxreg_io(E) mlxreg_hotplug(E) mei_wdt(E) evdev(E) intel_rapl(E) x86_pkg_temp_thermal(E) intel_powerclamp(E) kvm_intel(E) mlx_platform(E) kvm(E) irqbypass(E) crct10dif_pclmul(E) crc32_pclmul(E) ghash_clmulni_intel(E) intel_cstate(E) intel_uncore(E) + [ 159.016731] intel_rapl_perf(E) pcspkr(E) sg(E) iTCO_wdt(E) iTCO_vendor_support(E) mei_me(E) mei(E) bonding(E) pcc_cpufreq(E) video(E) button(E) ebt_vlan(E) ebtable_broute(E) bridge(E) stp(E) llc(E) ebtable_nat(E) ebtable_filter(E) ebtables(E) nf_tables(E) nfnetlink(E) xdpe12284(E) at24(E) ledtrig_timer(E) tmp102(E) lm75(E) drm(E) coretemp(E) max1363(E) industrialio_triggered_buffer(E) kfifo_buf(E) industrialio(E) tps53679(E) fuse(E) pmbus(E) pmbus_core(E) i2c_dev(E) configfs(E) ip_tables(E) x_tables(E) autofs4(E) loop(E) ext4(E) crc16(E) mbcache(E) jbd2(E) crc32c_generic(E) fscrypto(E) ecb(E) crypto_simd(E) cryptd(E) glue_helper(E) aes_x86_64(E) nvme(E) nvme_core(E) nls_utf8(E) nls_cp437(E) nls_ascii(E) vfat(E) fat(E) overlay(E) squashfs(E) zstd_decompress(E) xxhash(E) sd_mod(E) gpio_ich(E) ahci(E) + [ 159.864532] libahci(E) mlxsw_core(E) devlink(E) ehci_pci(E) ehci_hcd(E) crc32c_intel(E) libata(E) i2c_i801(E) scsi_mod(E) usbcore(E) usb_common(E) lpc_ich(E) mfd_core(E) e1000e(E) fan(E) thermal(E) + [ 160.075846] CR2: 0000000000000000 + ``` +You can specify a file name in order to show its +last 10 lines. + +- Example: + ``` + admin@sonic:~$ show kdump logging dmesg.202106242337 + [ 654.120195] RSP: 002b:00007ffe697690f8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 + [ 654.210778] RAX: ffffffffffffffda RBX: 0000000000000002 RCX: 00007fcfca27b504 + [ 654.296157] RDX: 0000000000000002 RSI: 000055a6e4d1b3f0 RDI: 0000000000000001 + [ 654.381543] RBP: 000055a6e4d1b3f0 R08: 000000000000000a R09: 00007fcfca2cc5f0 + [ 654.466925] R10: 000000000000000a R11: 0000000000000246 R12: 00007fcfca34d760 + [ 654.552310] R13: 0000000000000002 R14: 00007fcfca348760 R15: 0000000000000002 + [ 654.637694] Modules linked in: binfmt_misc(E) nft_chain_route_ipv6(E) nft_chain_route_ipv4(E) xt_TCPMSS(E) dummy(E) team_mode_loadbalance(E) team(E) sx_bfd(OE) sx_netdev(OE) psample(E) sx_core(OE) 8021q(E) garp(E) mrp(E) mst_pciconf(OE) mst_pci(OE) xt_hl(E) xt_tcpudp(E) ip6_tables(E) nft_chain_nat_ipv4(E) nf_nat_ipv4(E) nft_compat(E) nft_counter(E) xt_conntrack(E) nf_nat(E) jc42(E) nf_conntrack_netlink(E) nf_conntrack(E) nf_defrag_ipv6(E) nf_defrag_ipv4(E) libcrc32c(E) xfrm_user(E) xfrm_algo(E) mlxsw_minimal(E) mlxsw_i2c(E) i2c_mux_reg(E) i2c_mux(E) mlxreg_hotplug(E) mlxreg_io(E) i2c_mlxcpld(E) leds_mlxreg(E) mei_wdt(E) evdev(E) intel_rapl(E) x86_pkg_temp_thermal(E) intel_powerclamp(E) kvm_intel(E) kvm(E) mlx_platform(E) irqbypass(E) crct10dif_pclmul(E) crc32_pclmul(E) ghash_clmulni_intel(E) intel_cstate(E) + [ 655.493833] intel_uncore(E) intel_rapl_perf(E) pcspkr(E) sg(E) iTCO_wdt(E) iTCO_vendor_support(E) mei_me(E) mei(E) bonding(E) video(E) button(E) pcc_cpufreq(E) ebt_vlan(E) ebtable_broute(E) bridge(E) stp(E) llc(E) ebtable_nat(E) ebtable_filter(E) ebtables(E) nf_tables(E) nfnetlink(E) xdpe12284(E) at24(E) ledtrig_timer(E) tmp102(E) drm(E) lm75(E) coretemp(E) max1363(E) industrialio_triggered_buffer(E) kfifo_buf(E) industrialio(E) fuse(E) tps53679(E) pmbus(E) pmbus_core(E) i2c_dev(E) configfs(E) ip_tables(E) x_tables(E) autofs4(E) loop(E) ext4(E) crc16(E) mbcache(E) jbd2(E) crc32c_generic(E) fscrypto(E) ecb(E) crypto_simd(E) cryptd(E) glue_helper(E) aes_x86_64(E) nvme(E) nvme_core(E) nls_utf8(E) nls_cp437(E) nls_ascii(E) vfat(E) fat(E) overlay(E) squashfs(E) zstd_decompress(E) xxhash(E) sd_mod(E) + [ 656.337476] gpio_ich(E) ahci(E) mlxsw_core(E) libahci(E) devlink(E) crc32c_intel(E) libata(E) i2c_i801(E) scsi_mod(E) lpc_ich(E) mfd_core(E) ehci_pci(E) ehci_hcd(E) usbcore(E) e1000e(E) usb_common(E) fan(E) thermal(E) + [ 656.569590] CR2: 0000000000000000 + ``` +You can also specify a file name and number of lines in order to show the +last number of lines. + +- Example: + ``` + admin@sonic:~$ show kdump logging dmesg.202106242337 -l 20 + [ 653.525427] __handle_sysrq.cold.9+0x45/0xf2 + [ 653.576487] write_sysrq_trigger+0x2b/0x30 + [ 653.625472] proc_reg_write+0x39/0x60 + [ 653.669252] vfs_write+0xa5/0x1a0 + [ 653.708881] ksys_write+0x57/0xd0 + [ 653.748501] do_syscall_64+0x53/0x110 + [ 653.792287] entry_SYSCALL_64_after_hwframe+0x44/0xa9 + [ 653.852707] RIP: 0033:0x7fcfca27b504 + [ 653.895452] Code: 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b3 0f 1f 80 00 00 00 00 48 8d 05 f9 61 0d 00 8b 00 85 c0 75 13 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 54 c3 0f 1f 00 41 54 49 89 d4 55 48 89 f5 53 + [ 654.120195] RSP: 002b:00007ffe697690f8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 + [ 654.210778] RAX: ffffffffffffffda RBX: 0000000000000002 RCX: 00007fcfca27b504 + [ 654.296157] RDX: 0000000000000002 RSI: 000055a6e4d1b3f0 RDI: 0000000000000001 + [ 654.381543] RBP: 000055a6e4d1b3f0 R08: 000000000000000a R09: 00007fcfca2cc5f0 + [ 654.466925] R10: 000000000000000a R11: 0000000000000246 R12: 00007fcfca34d760 + [ 654.552310] R13: 0000000000000002 R14: 00007fcfca348760 R15: 0000000000000002 + [ 654.637694] Modules linked in: binfmt_misc(E) nft_chain_route_ipv6(E) nft_chain_route_ipv4(E) xt_TCPMSS(E) dummy(E) team_mode_loadbalance(E) team(E) sx_bfd(OE) sx_netdev(OE) psample(E) sx_core(OE) 8021q(E) garp(E) mrp(E) mst_pciconf(OE) mst_pci(OE) xt_hl(E) xt_tcpudp(E) ip6_tables(E) nft_chain_nat_ipv4(E) nf_nat_ipv4(E) nft_compat(E) nft_counter(E) xt_conntrack(E) nf_nat(E) jc42(E) nf_conntrack_netlink(E) nf_conntrack(E) nf_defrag_ipv6(E) nf_defrag_ipv4(E) libcrc32c(E) xfrm_user(E) xfrm_algo(E) mlxsw_minimal(E) mlxsw_i2c(E) i2c_mux_reg(E) i2c_mux(E) mlxreg_hotplug(E) mlxreg_io(E) i2c_mlxcpld(E) leds_mlxreg(E) mei_wdt(E) evdev(E) intel_rapl(E) x86_pkg_temp_thermal(E) intel_powerclamp(E) kvm_intel(E) kvm(E) mlx_platform(E) irqbypass(E) crct10dif_pclmul(E) crc32_pclmul(E) ghash_clmulni_intel(E) intel_cstate(E) + [ 655.493833] intel_uncore(E) intel_rapl_perf(E) pcspkr(E) sg(E) iTCO_wdt(E) iTCO_vendor_support(E) mei_me(E) mei(E) bonding(E) video(E) button(E) pcc_cpufreq(E) ebt_vlan(E) ebtable_broute(E) bridge(E) stp(E) llc(E) ebtable_nat(E) ebtable_filter(E) ebtables(E) nf_tables(E) nfnetlink(E) xdpe12284(E) at24(E) ledtrig_timer(E) tmp102(E) drm(E) lm75(E) coretemp(E) max1363(E) industrialio_triggered_buffer(E) kfifo_buf(E) industrialio(E) fuse(E) tps53679(E) pmbus(E) pmbus_core(E) i2c_dev(E) configfs(E) ip_tables(E) x_tables(E) autofs4(E) loop(E) ext4(E) crc16(E) mbcache(E) jbd2(E) crc32c_generic(E) fscrypto(E) ecb(E) crypto_simd(E) cryptd(E) glue_helper(E) aes_x86_64(E) nvme(E) nvme_core(E) nls_utf8(E) nls_cp437(E) nls_ascii(E) vfat(E) fat(E) overlay(E) squashfs(E) zstd_decompress(E) xxhash(E) sd_mod(E) + [ 656.337476] gpio_ich(E) ahci(E) mlxsw_core(E) libahci(E) devlink(E) crc32c_intel(E) libata(E) i2c_i801(E) scsi_mod(E) lpc_ich(E) mfd_core(E) ehci_pci(E) ehci_hcd(E) usbcore(E) e1000e(E) usb_common(E) fan(E) thermal(E) + [ 656.569590] CR2: 0000000000000000 + ``` +Go Back To [Beginning of the document](#) or [Beginning of this section](#kdump) + +## LLDP + +### LLDP show commands + +**show lldp table** + +This command displays the brief summary of all LLDP neighbors. + +- Usage: + ``` + show lldp table + ``` + +- Example: + ``` + admin@sonic:~$ show lldp table + Capability codes: (R) Router, (B) Bridge, (O) Other + LocalPort RemoteDevice RemotePortID Capability RemotePortDescr + ----------- ----------------- ------------------- ------------ -------------------- + Ethernet112 T1-1 hundredGigE1/2 BR T0-2:hundredGigE1/29 + Ethernet116 T1-2 hundredGigE1/2 BR T0-2:hundredGigE1/30 + eth0 swtor-b2lab2-1610 GigabitEthernet 0/2 OBR + -------------------------------------------------- + Total entries displayed: 3 + ``` + +**show lldp neighbors** + +This command displays more details about all LLDP neighbors or only the neighbors connected to a specific interface. + +- Usage: + ``` + show lldp neighbors + ``` + +- Example1: To display all neighbors in all interfaces + ``` + admin@sonic:~$ show lldp neighbors + ------------------------------------------------------------------------------- + LLDP neighbors: + ------------------------------------------------------------------------------- + Interface: eth0, via: LLDP, RID: 1, Time: 0 day, 12:21:21 + Chassis: + ChassisID: mac 00:01:e8:81:e3:45 + SysName: swtor-b2lab2-1610 + SysDescr: Dell Force10 Networks Real Time Operating System Software. Dell Force10 Operating System Version: 1.0. Dell Force10 Application Software Version: 8.3.3.10d. Copyright (c) 1999-2012 by Dell Inc. All Rights Reserved.Build Time: Tue Sep 22 11:21:54 PDT 2015 + TTL: 20 + Capability: Repeater, on + Capability: Bridge, on + Capability: Router, on + Port: + PortID: ifname GigabitEthernet 0/2 + VLAN: 162, pvid: yes + ------------------------------------------------------------------------------- + Interface: Ethernet116, via: LLDP, RID: 3, Time: 0 day, 12:20:49 + Chassis: + ChassisID: mac 4c:76:25:e7:f0:c0 + SysName: T1-2 + SysDescr: Debian GNU/Linux 8 (jessie) Linux 4.9.0-8-amd64 #1 SMP Debian 4.9.110-3+deb9u6 (2015-12-19) x86_64 + TTL: 120 + MgmtIP: 10.11.162.40 + Capability: Bridge, on + Capability: Router, on + Capability: Wlan, off + Capability: Station, off + Port: + PortID: local hundredGigE1/2 + PortDescr: T0-2:hundredGigE1/30 + ------------------------------------------------------------------------------- + ``` + +Optionally, you can specify an interface name in order to display only that particular interface + +- Example2: + ``` + admin@sonic:~$ show lldp neighbors Ethernet112 + show lldp neighbors Ethernet112 + ------------------------------------------------------------------------------- + LLDP neighbors: + ------------------------------------------------------------------------------- + Interface: Ethernet112, via: LLDP, RID: 2, Time: 0 day, 19:24:17 + Chassis: + ChassisID: mac 4c:76:25:e5:e6:c0 + SysName: T1-1 + SysDescr: Debian GNU/Linux 8 (jessie) Linux 4.9.0-8-amd64 #1 SMP Debian 4.9.110-3+deb9u6 (2015-12-19) x86_64 + TTL: 120 + MgmtIP: 10.11.162.41 + Capability: Bridge, on + Capability: Router, on + Capability: Wlan, off + Capability: Station, off + Port: + PortID: local hundredGigE1/2 + PortDescr: T0-2:hundredGigE1/29 + ------------------------------------------------------------------------------- + ``` +Go Back To [Beginning of the document](#) or [Beginning of this section](#lldp) + + +## Loading, Reloading And Saving Configuration + +This section explains the commands that are used to load the configuration from either the ConfigDB or from the minigraph. + +### Loading configuration from JSON file + +**config load** + +This command is used to load the configuration from a JSON file like the file which SONiC saves its configuration to, `/etc/sonic/config_db.json` +This command loads the configuration from the input file (if user specifies this optional filename, it will use that input file. Otherwise, it will use the default `/etc/sonic/config_db.json` file as the input file) into CONFIG_DB. +The configuration present in the input file is applied on top of the already running configuration. +This command does not flush the config DB before loading the new configuration (i.e., If the configuration present in the input file is same as the current running configuration, nothing happens) +If the config present in the input file is not present in running configuration, it will be added. +If the config present in the input file differs (when key matches) from that of the running configuration, it will be modified as per the new values for those keys. + +When user specifies the optional argument "-y" or "--yes", this command forces the loading without prompting the user for confirmation. +If the argument is not specified, it prompts the user to confirm whether user really wants to load this configuration file. + +- Usage: + ``` + config load [-y|--yes] [] + ``` + +- Example: + ``` + admin@sonic:~$ sudo config load + Load config from the file /etc/sonic/config_db.json? [y/N]: y + Running command: /usr/local/bin/sonic-cfggen -j /etc/sonic/config_db.json --write-to-db + ``` + +### Loading configuration from minigraph (XML) file + +**config load_minigraph** + +This command is used to load the configuration from /etc/sonic/minigraph.xml. +When users do not want to use configuration from config_db.json, they can copy the minigraph.xml configuration file to the device and load it using this command. +This command restarts various services running in the device and it takes some time to complete the command. + +NOTE: If the user had logged in using SSH, users might get disconnected and some configuration failures might happen which might be hard to recover. Users need to reconnect their SSH sessions after configuring the management IP address. It is recommended to execute this command from console port +NOTE: Management interface IP address and default route (or specific route) may require reconfiguration in case if those parameters are not part of the minigraph.xml. + +When user specifies the optional argument "-y" or "--yes", this command forces the loading without prompting the user for confirmation. +If the argument is not specified, it prompts the user to confirm whether user really wants to load this configuration file. + +When user specifies the optional argument "-n" or "--no-service-restart", this command loads the configuration without restarting dependent services +running on the device. One use case for this option is during boot time when config-setup service loads minigraph configuration and there is no services +running on the device. + +When user specifies the optional argument "-t" or "--traffic-shift-away", this command executes TSA command at the end to ensure the device remains in maintenance after loading minigraph. + +- Usage: + ``` + config load_minigraph [-y|--yes] [-n|--no-service-restart] [-t|--traffic-shift-away] + ``` + +- Example: + ``` + admin@sonic:~$ sudo config load_minigraph + Reload config from minigraph? [y/N]: y + Running command: /usr/local/bin/sonic-cfggen -j /etc/sonic/config_db.json --write-to-db + ``` + +### Reloading Configuration + +**config reload** + +This command is used to clear current configuration and import new configurationn from the input file or from /etc/sonic/config_db.json. +This command shall stop all services before clearing the configuration and it then restarts those services. + +This command restarts various services running in the device and it takes some time to complete the command. +NOTE: If the user had logged in using SSH, users **might get disconnected** depending upon the new management IP address. Users need to reconnect their SSH sessions. +In general, it is recommended to execute this command from console port after disconnecting all SSH sessions to the device. +When users to do “config reload” the newly loaded config may have management IP address, or it may not have management IP address. +If mgmtIP is there in the newly loaded config file, that mgmtIP might be same as previously configured value or it might be different. +This difference in mgmtIP address values results in following possible behaviours. + +Case1: Previously configured mgmtIP is same as newly loaded mgmtIP. The SSH session may not be affected at all, but it’s possible that there will be a brief interruption in the SSH session. But, assuming the client’s timeout value isn’t on the order of a couple of seconds, the session would most likely just resume again as soon as the interface is reconfigured and up with the same IP. +Case2: Previously configured mgmtIP is different from newly loaded mgmtIP. Users will lose their SSH connections. +Case3: Newly loaded config does not have any mgmtIP. Users will lose their SSH connections. + +NOTE: Management interface IP address and default route (or specific route) may require reconfiguration in case if those parameters are not part of the minigraph.xml. + +When user specifies the optional argument "-y" or "--yes", this command forces the loading without prompting the user for confirmation. +If the argument is not specified, it prompts the user to confirm whether user really wants to load this configuration file. + +When user specifies the optional argument "-n" or "--no-service-restart", this command clear and loads the configuration without restarting dependent services +running on the device. One use case for this option is during boot time when config-setup service loads existing old configuration and there is no services +running on the device. + +When user specifies the optional argument "-f" or "--force", this command ignores the system sanity checks. By default a list of sanity checks are performed and if one of the checks fail, the command will not execute. The sanity checks include ensuring the system status is not starting, all the essential services are up and swss is in ready state. + +- Usage: + ``` + config reload [-y|--yes] [-l|--load-sysinfo] [] [-n|--no-service-restart] [-f|--force] + ``` + +- Example: + ``` + admin@sonic:~$ sudo config reload + Clear current config and reload config from the file /etc/sonic/config_db.json? [y/N]: y + Running command: systemctl stop dhcp_relay + Running command: systemctl stop swss + Running command: systemctl stop snmp + Warning: Stopping snmp.service, but it can still be activated by: + snmp.timer + Running command: systemctl stop lldp + Running command: systemctl stop pmon + Running command: systemctl stop bgp + Running command: systemctl stop teamd + Running command: /usr/local/bin/sonic-cfggen -H -k Force10-Z9100-C32 --write-to-db + Running command: /usr/local/bin/sonic-cfggen -j /etc/sonic/config_db.json --write-to-db + Running command: systemctl restart hostname-config + Running command: systemctl restart interfaces-config + Timeout, server 10.11.162.42 not responding. + ``` + When some sanity checks fail below error messages can be seen + ``` + admin@sonic:~$ sudo config reload -y + System is not up. Retry later or use -f to avoid system checks + ``` + ``` + admin@sonic:~$ sudo config reload -y + Relevant services are not up. Retry later or use -f to avoid system checks + ``` + ``` + admin@sonic:~$ sudo config reload -y + SwSS container is not ready. Retry later or use -f to avoid system checks + ``` + + +### Loading Management Configuration + +**config load_mgmt_config** + +This command is used to reconfigure hostname and mgmt interface based on device description file. +This command either uses the optional file specified as arguement or looks for the file "/etc/sonic/device_desc.xml". +If the file does not exist or if the file does not have valid fields for "hostname" and "ManagementAddress" (or "ManagementAddressV6"), it fails. + +When user specifies the optional argument "-y" or "--yes", this command forces the loading without prompting the user for confirmation. +If the argument is not specified, it prompts the user to confirm whether user really wants to load this configuration file. + +- Usage: + ``` + config load_mgmt_config [-y|--yes] [] + ``` + +- Example: + ``` + admin@sonic:~$ sudo config load_mgmt_config + Reload config from minigraph? [y/N]: y + Running command: /usr/local/bin/sonic-cfggen -M /etc/sonic/device_desc.xml --write-to-db + ``` + + +### Saving Configuration to a File for Persistence + +**config save** + +This command is to save the config DB configuration into the user-specified filename or into the default /etc/sonic/config_db.json. This saves the configuration into the disk which is available even after reboots. +Saved file can be transferred to remote machines for debugging. If users wants to load the configuration from this new file at any point of time, they can use "config load" command and provide this newly generated file as input. If users wants this newly generated file to be used during reboot, they need to copy this file to /etc/sonic/config_db.json. + +- Usage: + ``` + config save [-y|--yes] [] + ``` + +- Example (Save configuration to /etc/sonic/config_db.json): + ``` + admin@sonic:~$ sudo config save -y + ``` + +- Example (Save configuration to a specified file): + ``` + admin@sonic:~$ sudo config save -y /etc/sonic/config2.json + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#loading-reloading-and-saving-configuration) + +## Loopback Interfaces + +### Loopback show commands + +Please check [show ip interfaces](#show-ip-interfaces) + +### Loopback config commands + +This sub-section explains how to create and delete loopback interfaces. + +**config interface loopback** + +This command is used to add or delete loopback interfaces. +It is recommended to use loopback names in the format "Loopbackxxx", where "xxx" is number of 1 to 3 digits. Ex: "Loopback11". + +- Usage: + ``` + config loopback (add | del) + ``` + +- Example (Create the loopback with name "Loopback11"): + ``` + admin@sonic:~$ sudo config loopback add Loopback11 + ``` + +## VRF Configuration + +### VRF show commands + +**show vrf** + +This command displays all vrfs configured on the system along with interface binding to the vrf. +If vrf-name is also provided as part of the command, if the vrf is created it will display all interfaces binding to the vrf, if vrf is not created nothing will be displayed. + +- Usage: + ``` + show vrf [] + ``` + +- Example: + ```` + admin@sonic:~$ show vrf + VRF Interfaces + ------- ------------ + default Vlan20 + Vrf-red Vlan100 + Loopback11 + Eth0.100 + Vrf-blue Loopback100 + Loopback102 + Ethernet0.10 + PortChannel101 + ```` + +### VRF config commands + +**config vrf add ** + +This command creates vrf in SONiC system with provided vrf-name. + +- Usage: + ``` +config vrf add +``` +Note: vrf-name should always start with keyword "Vrf" + +**config vrf del ** + +This command deletes vrf with name vrf-name. + +- Usage: + ``` +config vrf del +``` + +## Management VRF + +### Management VRF Show commands + +**show mgmt-vrf** + +This command displays whether the management VRF is enabled or disabled. It also displays the details about the the links (eth0, mgmt, lo-m) that are related to management VRF. + +- Usage: + ``` + show mgmt-vrf + ``` + +- Example: + ``` + admin@sonic:~$ show mgmt-vrf + + ManagementVRF : Enabled + + Management VRF interfaces in Linux: + 348: mgmt: mtu 65536 qdisc noqueue state UP mode DEFAULT group default qlen 1000 + link/ether f2:2a:d9:bc:e8:f0 brd ff:ff:ff:ff:ff:ff + 2: eth0: mtu 1500 qdisc mq master mgmt state UP mode DEFAULT group default qlen 1000 + link/ether 4c:76:25:f4:f9:f3 brd ff:ff:ff:ff:ff:ff + 350: lo-m: mtu 1500 qdisc noqueue master mgmt state UNKNOWN mode DEFAULT group default qlen 1000 + link/ether b2:4c:c6:f3:e9:92 brd ff:ff:ff:ff:ff:ff + + NOTE: The management interface "eth0" shows the "master" as "mgmt" since it is part of management VRF. + ``` + +**show mgmt-vrf routes** + +This command displays the routes that are present in the routing table 5000 that is meant for management VRF. + +- Usage: + ``` + show mgmt-vrf routes + ``` + +- Example: + ``` + admin@sonic:~$ show mgmt-vrf routes + + Routes in Management VRF Routing Table: + default via 10.16.210.254 dev eth0 metric 201 + broadcast 10.16.210.0 dev eth0 proto kernel scope link src 10.16.210.75 + 10.16.210.0/24 dev eth0 proto kernel scope link src 10.16.210.75 + local 10.16.210.75 dev eth0 proto kernel scope host src 10.16.210.75 + broadcast 10.16.210.255 dev eth0 proto kernel scope link src 10.16.210.75 + broadcast 127.0.0.0 dev lo-m proto kernel scope link src 127.0.0.1 + 127.0.0.0/8 dev lo-m proto kernel scope link src 127.0.0.1 + local 127.0.0.1 dev lo-m proto kernel scope host src 127.0.0.1 + broadcast 127.255.255.255 dev lo-m proto kernel scope link src 127.0.0.1 + ``` + +**show management_interface address** + +This command displays the IP address(es) configured for the management interface "eth0" and the management network default gateway. + +- Usage: + ``` + show management_interface address + ``` + +- Example: + ``` + admin@sonic:~$ show management_interface address + Management IP address = 10.16.210.75/24 + Management NetWork Default Gateway = 10.16.210.254 + Management IP address = FC00:2::32/64 + Management Network Default Gateway = fc00:2::1 + ``` + +**show snmpagentaddress** + +This command displays the configured SNMP agent IP addresses. + +- Usage: + ``` + show snmpagentaddress + ``` + +- Example: + ``` + admin@sonic:~$ show snmpagentaddress + ListenIP ListenPort ListenVrf + ---------- ------------ ----------- + 1.2.3.4 787 mgmt + ``` + +**show snmptrap** + +This command displays the configured SNMP Trap server IP addresses. + +- Usage: + ``` + show snmptrap + ``` + +- Example: + ``` + admin@sonic:~$ show snmptrap + Version TrapReceiverIP Port VRF Community + --------- ---------------- ------ ----- ----------- + 2 31.31.31.31 456 mgmt public + ``` + +### Management VRF Config commands + +**config vrf add mgmt** + +This command enables the management VRF in the system. This command restarts the "interfaces-config" service which in turn regenerates the /etc/network/interfaces file and restarts the "networking" service. This creates a new interface and l3mdev CGROUP with the name as "mgmt" and enslaves the management interface "eth0" into this master interface "mgmt". Note that the VRFName "mgmt" (or "management") is reserved for management VRF. i.e. Data VRFs should not use these reserved VRF names. + +- Usage: + ``` + config vrf add mgmt + ``` + +- Example: + ``` + admin@sonic:~$ sudo config vrf add mgmt + ``` + +**config vrf del mgmt** + +This command disables the management VRF in the system. This command restarts the "interfaces-config" service which in turn regenerates the /etc/network/interfaces file and restarts the "networking" service. This deletes the interface "mgmt" and deletes the l3mdev CGROUP named "mgmt" and puts back the management interface "eth0" into the default VRF. Note that the VRFName "mgmt" (or "management") is reserved for management VRF. i.e. Data VRFs should not use these reserved VRF names. + +- Usage: + ``` + config vrf del mgmt + ``` + +- Example: + ``` + admin@sonic:~$ sudo config vrf del mgmt + ``` + +**config snmpagentaddress add** + +This command adds the SNMP agent IP address on which the SNMP agent is expected to listen. When SNMP agent is expected to work as part of management VRF, users should specify the optional vrf_name parameter as "mgmt". This configuration goes into snmpd.conf that is used by SNMP agent. SNMP service is restarted to make this configuration effective in SNMP agent. + +- Usage: + ``` + config snmpagentaddress add [-p ] [-v ] agentip + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmpagentaddress add -v mgmt -p 123 21.22.13.14 + + Note: For this example, configuration goes into /etc/snmp/snmpd.conf inside snmp docker as follows. When "-v" parameter is not used, the additional "%" in the following line will not be present. + + agentAddress 21.22.13.14:123%mgmt + ``` + +**config snmpagentaddress del** + +This command deletes the SNMP agent IP address on which the SNMP agent is expected to listen. When users had added the agent IP as part of "mgmt" VRF, users should specify the optional vrf_name parameter as "mgmt" while deleting as well. This configuration is removed from snmpd.conf that is used by SNMP agent. SNMP service is restarted to make this configuration effective in SNMP agent. + +- Usage: + ``` + config snmpagentaddress del [-p ] [-v ] agentip + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmpagentaddress del -v mgmt -p 123 21.22.13.14 + + ``` + +**config snmptrap modify** + +This command modifies the SNMP trap server IP address to which the SNMP agent is expected to send the traps. Users can configure one server IP addrss for each SNMP version to send the traps. When SNMP agent is expected to send traps as part of management VRF, users should specify the optional vrf_name parameter as "mgmt". This configuration goes into snmpd.conf that is used by SNMP agent. SNMP service is restarted to make this configuration effective in SNMP agent. + +- Usage: + ``` + config snmptrap modify [-p ] [-v ] [-c ] trapserverip + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmptrap modify 2 -p 456 -v mgmt 21.21.21.21 + + For this example, configuration goes into /etc/snmp/snmpd.conf inside snmp docker as follows. When "-v" parameter is not used, the additional "%" in the following line will not be present. In case of SNMPv1, "trapsink" will be updated, in case of v2, "trap2sink" will be updated and in case of v3, "informsink" will be updated. + + trap2sink 31.31.31.31:456%mgmt public + + ``` + +**config snmptrap del** + +This command deletes the SNMP Trap server IP address to which SNMP agent is expected to send TRAPs. When users had added the trap server IP as part of "mgmt" VRF, users should specify the optional vrf_name parameter as "mgmt" while deleting as well. This configuration is removed from snmpd.conf that is used by SNMP agent. SNMP service is restarted to make this configuration effective in SNMP agent. + +- Usage: + ``` + config snmptrap del [-p ] [-v ] [-c ] trapserverip + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmptrap del -v mgmt -p 123 21.22.13.14 + + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#management-vrf) + +## Muxcable + +### Muxcable Show commands + +**show muxcable status** + +This command displays all the status of either all the ports which are connected to muxcable or any individual port selected by the user. The resultant table or json output will show the current status of muxcable on the port (auto/active) and also the health of the muxcable. + +- Usage: + ``` + show muxcable status [OPTIONS] [PORT] + ``` + +While displaying the muxcable status, users can configure the following fields + +- PORT optional - Port name should be a valid port +- --json optional - -- option to display the result in json format. By default output will be in tabular format. + +With no optional argument, all the ports muxcable status will be displayed in tabular form, or user can pass --json option to display in json format + +- Example: + ``` + admin@sonic:~$ show muxcable status + PORT STATUS HEALTH + ---------- -------- -------- + Ethernet32 active HEALTHY + Ethernet0 auto HEALTHY + ``` + ``` + admin@sonic:~$ show muxcable status --json + ``` + ```json + { + "MUX_CABLE": { + "Ethernet32": { + "STATUS": "active", + "HEALTH": "HEALTHY" + }, + "Ethernet0": { + "STATUS": "auto", + "HEALTH": "HEALTHY" + } + } + } + + ``` + ``` + admin@sonic:~$ show muxcable status Ethernet0 + PORT STATUS HEALTH + --------- -------- -------- + Ethernet0 auto HEALTHY + ``` + ``` + admin@sonic:~$ show muxcable status Ethernet0 --json + ``` + ```json + { + "MUX_CABLE": { + "Ethernet0": { + "STATUS": "auto", + "HEALTH": "HEALTHY" + } + } + } + ``` + +**show muxcable config** + +This command displays all the configurations of either all the ports which are connected to muxcable or any individual port selected by the user. The resultant table or json output will show the current configurations of muxcable on the port(active/standby) and also the ipv4 and ipv6 address of the port as well as peer TOR ip address with the hostname. + +- Usage: + ``` + show muxcable config [OPTIONS] [PORT] + ``` + +With no optional argument, all the ports muxcable configuration will be displayed in tabular form +While displaying the muxcable configuration, users can configure the following fields + +- PORT optional - Port name should be a valid port +- --json optional - option to display the result in json format. By default output will be in tabular format. + +- Example: + ``` + admin@sonic:~$ show muxcable config + SWITCH_NAME PEER_TOR + ------------- ---------- + sonic 10.1.1.1 + port state ipv4 ipv6 + --------- ------- -------- -------- + Ethernet0 active 10.1.1.1 fc00::75 + ``` + ``` + admin@sonic:~$ show muxcable config --json + ``` + ```json + { + "MUX_CABLE": { + "PEER_TOR": "10.1.1.1", + "PORTS": { + "Ethernet0": { + "STATE": "active", + "SERVER": { + "IPv4": "10.1.1.1", + "IPv6": "fc00::75" + } + } + } + } + } + ``` + ``` + admin@sonic:~$ show muxcable config Ethernet0 + SWITCH_NAME PEER_TOR + ------------- ---------- + sonic 10.1.1.1 + port state ipv4 ipv6 + --------- ------- -------- -------- + Ethernet0 active 10.1.1.1 fc00::75 + ``` + ``` + admin@sonic:~$ show muxcable config Ethernet0 --json + ``` + ```json + { + "MUX_CABLE": { + "PORTS": { + "Ethernet0": { + "STATE": "active", + "SERVER": { + "IPv4": "10.1.1.1", + "IPv6": "fc00::75" + } + } + } + } + } + ``` + +**show muxcable ber-info** + +This command displays the ber(Bit error rate) of the port user provides on the target user provides. The target provided as an integer corresponds to actual target as. +0 -> local +1 -> tor 1 +2 -> tor 2 +3 -> nic + +- Usage: + ``` + Usage: show muxcable ber-info [OPTIONS] PORT TARGET + ``` + + +- PORT required - Port number should be a valid port +- TARGET required - the actual target to get the ber info of. + +- Example: + ``` + admin@sonic:~$ show muxcable ber-info 1 1 + Lane1 Lane2 + ------- ------- + 0 0 + ``` + +**show muxcable ber-info** + +This command displays the eye info in mv(milli volts) of the port user provides on the target user provides. The target provided as an integer corresponds to actual target as. +0 -> local +1 -> tor 1 +2 -> tor 2 +3 -> nic + +- Usage: + ``` + Usage: show muxcable eye-info [OPTIONS] PORT TARGET + ``` + +- PORT required - Port number should be a valid port +- TARGET required - the actual target to get the eye info of. + +- Example: + ``` + admin@sonic:~$ show muxcable ber-info 1 1 + Lane1 Lane2 + ------- ------- + 632 622 + ``` + +### Muxcable Config commands + + +**config muxcable mode** + +This command is used for setting the configuration of a muxcable Port/all ports to be active or auto. The user has to enter a port number or else all to make the muxcable config operation on all the ports. Depending on the status of the muxcable port state the resultant output could be OK or INPROGRESS . OK would imply no change on the state, INPROGRESS would mean the toggle is happening in the background. + +- Usage: + ``` + config muxcable mode [OPTIONS] + ``` + +While configuring the muxcable, users needs to configure the following fields for the operation + +- operation_state, permitted operation to be configured which can only be auto or active +- PORT optional - Port name should be a valid port +- --json optional - option to display the result in json format. By default output will be in tabular format. + + +- Example: + ``` + admin@sonic:~$ sudo config muxcable mode active Ethernet0 + port state + --------- ------- + Ethernet0 OK + ``` + ``` + admin@sonic:~$ sudo config muxcable mode --json active Ethernet0 + ``` + ```json + { + "Ethernet0": "OK" + } + ``` + ``` + admin@sonic:~$ sudo config muxcable mode active all + port state + ---------- ---------- + Ethernet0 OK + Ethernet32 INPROGRESS + ``` + ``` + admin@sonic:~$ sudo config muxcable mode active all --json + ``` + ```json + { + "Ethernet32": "INPROGRESS", + "Ethernet0": "OK" + } + ``` +**config muxcable prbs enable/disable** + +This command is used for setting the configuration and enable/diable of prbs on a port user provides. While enabling in addition to port the user also needs to provides the target, prbs mode and lane map on which the user intends to run prbs on. The target reflects where the enable/dsiable will happen. + +- Usage: + ``` + config muxcable prbs enable [OPTIONS] PORT TARGET MODE_VALUE LANE_MAP + config muxcable prbs disable [OPTIONS] PORT TARGET + ``` + +While configuring the muxcable, users needs to configure the following fields for the operation + +- PORT required - Port number should be a valid port +- TARGET required - the actual target to run the prbs on + 0 -> local side, + 1 -> TOR 1 + 2 -> TOR 2 + 3 -> NIC +- MODE_VALUE required - the mode/type for configuring the PRBS mode. + 0x00 = PRBS 9, 0x01 = PRBS 15, 0x02 = PRBS 23, 0x03 = PRBS 31 +- LANE_MAP required - an integer representing the lane_map to be run PRBS on + 0bit for lane 0, 1bit for lane1 and so on. + for example 3 -> 0b'0011 , means running on lane0 and lane1 +- Example: + ``` + admin@sonic:~$ sudo config muxcable prbs enable 1 1 3 3 + PRBS config sucessful + admin@sonic:~$ sudo config muxcable prbs disable 1 0 + PRBS disable sucessful + ``` + +**config muxcable loopback enable/disable** + +This command is used for setting the configuration and enable/disable of loopback on a port user provides. While enabling in addition to port the user also needs to provides the target and lane map on which the user intends to run loopback on. The target reflects where the enable/dsiable will happen. + +- Usage: + ``` + config muxcable loopback enable [OPTIONS] PORT TARGET LANE_MAP + config muxcable loopback disable [OPTIONS] PORT TARGET + ``` + +While configuring the muxcable, users needs to configure the following fields for the operation + +- PORT required - Port number should be a valid port +- TARGET required - the actual target to run the loopback on + 0 -> local side, + 1 -> TOR 1 + 2 -> TOR 2 + 3 -> NIC +- LANE_MAP required - an integer representing the lane_map to be run loopback on + 0bit for lane 0, 1bit for lane1 and so on. + for example 3 -> 0b'0011 , means running on lane0 and lane1 + +- Example: + ``` + admin@sonic:~$ sudo config muxcable loopback enable 1 1 3 + loopback config sucessful + admin@sonic:~$ sudo config muxcable loopback disable 1 0 + loopback disable sucessfull + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#muxcable) + +## Mirroring + +### Mirroring Show commands + +**show mirror_session** + +This command displays all the mirror sessions that are configured. + +- Usage: + ``` + show mirror_session + ``` + +- Example: + ``` + admin@sonic:~$ show mirror_session + ERSPAN Sessions + Name Status SRC IP DST IP GRE DSCP TTL Queue Policer Monitor Port SRC Port Direction + ------ -------- -------- -------- ----- ------ ----- ------- --------- -------------- ---------- ----------- + everflow0 active 10.1.0.32 10.0.0.7 + + SPAN Sessions + Name Status DST Port SRC Port Direction + ------ -------- ---------- ------------- ----------- + port0 active Ethernet0 PortChannel10 rx + ``` + +### Mirroring Config commands + +**config mirror_session** + +This command is used to add or remove mirroring sessions. Mirror session is identified by "session_name". +This command supports configuring both SPAN/ERSPAN sessions. +In SPAN user can configure mirroring of list of source ports/LAG to destination port in ingress/egress/both directions. +In ERSPAN user can configure mirroring of list of source ports/LAG to a destination IP. +Both SPAN/ERSPAN support ACL based mirroring and can be used in ACL configurations. + +While adding a new ERSPAN session, users need to configure the following fields that are used while forwarding the mirrored packets. + +1) source IP address, +2) destination IP address, +3) DSCP (QoS) value with which mirrored packets are forwarded +4) TTL value +5) optional - GRE Type in case if user wants to send the packet via GRE tunnel. GRE type could be anything; it could also be left as empty; by default, it is 0x8949 for Mellanox; and 0x88be for the rest of the chips. +6) optional - Queue in which packets shall be sent out of the device. Valid values 0 to 7 for most of the devices. Users need to know their device and the number of queues supported in that device. +7) optional - Policer which will be used to control the rate at which frames are mirrored. +8) optional - List of source ports which can have both Ethernet and LAG ports. +9) optional - Direction - Mirror session direction when configured along with Source port. (Supported rx/tx/both. default direction is both) + +- Usage: + ``` + config mirror_session erspan add [gre_type] [queue] [policer ] [source-port-list] [direction] + ``` + + The following command is also supported to be backward compatible. + This command will be deprecated in future releases. + ``` + config mirror_session add [gre_type] [queue] + ``` + +- Example: + ``` + root@T1-2:~# config mirror_session add mrr_legacy 1.2.3.4 20.21.22.23 8 100 0x6558 0 + root@T1-2:~# show mirror_session + Name Status SRC IP DST IP GRE DSCP TTL Queue Policer Monitor Port SRC Port Direction + --------- -------- -------- ----------- ------ ------ ----- ------- --------- -------------- ---------- ----------- + mrr_legacy inactive 1.2.3.4 20.21.22.23 0x6558 8 100 0 + + + root@T1-2:~# config mirror_session erspan add mrr_abcd 1.2.3.4 20.21.22.23 8 100 0x6558 0 + root@T1-2:~# show mirror_session + Name Status SRC IP DST IP GRE DSCP TTL Queue Policer Monitor Port SRC Port Direction + --------- -------- -------- ----------- ------ ------ ----- ------- --------- -------------- ---------- ----------- + mrr_abcd inactive 1.2.3.4 20.21.22.23 0x6558 8 100 0 + root@T1-2:~# + + root@T1-2:~# config mirror_session erspan add mrr_port 1.2.3.4 20.21.22.23 8 100 0x6558 0 Ethernet0 + root@T1-2:~# show mirror_session + Name Status SRC IP DST IP GRE DSCP TTL Queue Policer Monitor Port SRC Port Direction + --------- -------- -------- ----------- ------ ------ ----- ------- --------- -------------- ---------- ----------- + mrr_port inactive 1.2.3.4 20.21.22.23 0x6558 8 100 0 Ethernet0 both + root@T1-2:~# + ``` + +While adding a new SPAN session, users need to configure the following fields that are used while forwarding the mirrored packets. +1) destination port, +2) optional - List of source ports- List of source ports which can have both Ethernet and LAG ports. +3) optional - Direction - Mirror session direction when configured along with Source port. (Supported rx/tx/both. default direction is both) +4) optional - Queue in which packets shall be sent out of the device. Valid values 0 to 7 for most of the devices. Users need to know their device and the number of queues supported in that device. +5) optional - Policer which will be used to control the rate at which frames are mirrored. + +- Usage: + ``` + config mirror_session span add [source-port-list] [direction] [queue] [policer ] + ``` + +- Example: + ``` + root@T1-2:~# config mirror_session span add port0 Ethernet0 Ethernet4,PortChannel001,Ethernet8 + root@T1-2:~# show mirror_session + Name Status DST Port SRC Port Direction + ------ -------- ---------- --------------------------------- ----------- + port0 active Ethernet0 Ethernet4,PortChannel10,Ethernet8 both + root@T1-2:~# + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#mirroring) + +## NAT + +### NAT Show commands + +**show nat config** + +This command displays the NAT configuration. + +- Usage: + ``` + show nat config [static | pool | bindings | globalvalues | zones] + ``` + +With no optional arguments, the whole NAT configuration is displayed. + +- Example: + ``` + admin@sonic:~$ show nat config static + + Nat Type IP Protocol Global IP Global L4 Port Local IP Local L4 Port Twice-Nat Id + -------- ----------- ------------ -------------- ------------- ------------- ------------ + dnat all 65.55.45.5 --- 10.0.0.1 --- --- + dnat all 65.55.45.6 --- 10.0.0.2 --- --- + dnat tcp 65.55.45.7 2000 20.0.0.1 4500 1 + snat tcp 20.0.0.2 4000 65.55.45.8 1030 1 + + admin@sonic:~$ show nat config pool + + Pool Name Global IP Range Global L4 Port Range + ------------ ------------------------- -------------------- + Pool1 65.55.45.5 1024-65535 + Pool2 65.55.45.6-65.55.45.8 --- + Pool3 65.55.45.10-65.55.45.15 500-1000 + + admin@sonic:~$ show nat config bindings + + Binding Name Pool Name Access-List Nat Type Twice-Nat Id + ------------ ------------ ------------ -------- ------------ + Bind1 Pool1 --- snat --- + Bind2 Pool2 1 snat 1 + Bind3 Pool3 2 snat -- + + admin@sonic:~$ show nat config globalvalues + + Admin Mode : enabled + Global Timeout : 600 secs + TCP Timeout : 86400 secs + UDP Timeout : 300 secs + + admin@sonic:~$ show nat config zones + + Port Zone + ---- ---- + Ethernet2 0 + Vlan100 1 + ``` + +**show nat statistics** + +This command displays the NAT translation statistics for each entry. + +- Usage: + ``` + show nat statistics + ``` + +- Example: + ``` + admin@sonic:~$ show nat statistics + + Protocol Source Destination Packets Bytes + -------- --------- -------------- ------------- ------------- + all 10.0.0.1 --- 802 1009280 + all 10.0.0.2 --- 23 5590 + tcp 20.0.0.1:4500 --- 110 12460 + udp 20.0.0.1:4000 --- 1156 789028 + tcp 20.0.0.1:6000 --- 30 34800 + tcp 20.0.0.1:5000 65.55.42.1:2000 128 110204 + tcp 20.0.0.1:5500 65.55.42.1:2000 8 3806 + ``` + +**show nat translations** + +This command displays the NAT translation entries. + +- Usage: + ``` + show nat translations [count] + ``` +Giving the optional count argument displays only the details about the number of translation entries. +- Example: + ``` + admin@sonic:~$ show nat translations + + Static NAT Entries ................. 4 + Static NAPT Entries ................. 2 + Dynamic NAT Entries ................. 0 + Dynamic NAPT Entries ................. 4 + Static Twice NAT Entries ................. 0 + Static Twice NAPT Entries ................. 4 + Dynamic Twice NAT Entries ................ 0 + Dynamic Twice NAPT Entries ................ 0 + Total SNAT/SNAPT Entries ................ 9 + Total DNAT/DNAPT Entries ................ 9 + Total Entries ................ 14 + + Protocol Source Destination Translated Source Translated Destination + -------- --------- -------------- ----------------- ---------------------- + all 10.0.0.1 --- 65.55.42.2 --- + all --- 65.55.42.2 --- 10.0.0.1 + all 10.0.0.2 --- 65.55.42.3 --- + all --- 65.55.42.3 --- 10.0.0.2 + tcp 20.0.0.1:4500 --- 65.55.42.1:2000 --- + tcp --- 65.55.42.1:2000 --- 20.0.0.1:4500 + udp 20.0.0.1:4000 --- 65.55.42.1:1030 --- + udp --- 65.55.42.1:1030 --- 20.0.0.1:4000 + tcp 20.0.0.1:6000 --- 65.55.42.1:1024 --- + tcp --- 65.55.42.1:1024 --- 20.0.0.1:6000 + tcp 20.0.0.1:5000 65.55.42.1:2000 65.55.42.1:1025 20.0.0.1:4500 + tcp 20.0.0.1:4500 65.55.42.1:1025 65.55.42.1:2000 20.0.0.1:5000 + tcp 20.0.0.1:5500 65.55.42.1:2000 65.55.42.1:1026 20.0.0.1:4500 + tcp 20.0.0.1:4500 65.55.42.1:1026 65.55.42.1:2000 20.0.0.1:5500 + + admin@sonic:~$ show nat translations count + + Static NAT Entries ................. 4 + Static NAPT Entries ................. 2 + Dynamic NAT Entries ................. 0 + Dynamic NAPT Entries ................. 4 + Static Twice NAT Entries ................. 0 + Static Twice NAPT Entries ................. 4 + Dynamic Twice NAT Entries ................ 0 + Dynamic Twice NAPT Entries ................ 0 + Total SNAT/SNAPT Entries ................ 9 + Total DNAT/DNAPT Entries ................ 9 + Total Entries ................ 14 + ``` + +### NAT Config commands + +**config nat add static** + +This command is used to add a static NAT or NAPT entry. +When configuring the Static NAT entry, user has to specify the following fields with 'basic' keyword. + +1. Global IP address, +2. Local IP address, +3. NAT type (snat / dnat) to be applied on the Global IP address. Default value is dnat. This is optinoal argument. +4. Twice NAT Id. This is optional argument used in case of twice nat configuration. + +When configuring the Static NAPT entry, user has to specify the following fields. + +1. IP protocol type (tcp / udp) +2. Global IP address + Port +3. Local IP address + Port +4. NAT type (snat / dnat) to be applied on the Global IP address + Port. Default value is dnat. This is optional argument. +5. Twicw NAT Id. This is optional argument used in case of twice nat configuration. + +- Usage: + ``` + config nat add static /{/{basic (global-ip) (local-ip)/} | /{/{tcp | udp/} (global-ip) (global-port) (local-ip) (local-port)/}/} [-nat_type /{snat | dnat/}] [-twice_nat_id (value)] + ``` + +To delete a static NAT or NAPT entry, use the command below. Giving the all argument deletes all the configured static NAT and NAPT entries. +``` +config nat remove static /{/{basic (global-ip) (local-ip)/} | /{/{tcp | udp/} (global-ip) (global-port) (local-ip) (local-port)/} | all/} +``` +- Example: + ``` + admin@sonic:~$ sudo config nat add static basic 65.55.45.1 12.12.12.14 -nat_type dnat + admin@sonic:~$ sudo config nat add static tcp 65.55.45.2 100 12.12.12.15 200 -nat_type dnat + + admin@sonic:~$ show nat translations + + Static NAT Entries ................. 2 + Static NAPT Entries ................. 2 + Dynamic NAT Entries ................. 0 + Dynamic NAPT Entries ................. 0 + Static Twice NAT Entries ................. 0 + Static Twice NAPT Entries ................. 0 + Dynamic Twice NAT Entries ................ 0 + Dynamic Twice NAPT Entries ................ 0 + Total SNAT/SNAPT Entries ................ 2 + Total DNAT/DNAPT Entries ................ 2 + Total Entries ................ 4 + + Protocol Source Destination Translated Source Translated Destination + -------- --------- -------------- ----------------- ---------------------- + all 12.12.12.14 --- 65.55.42.1 --- + all --- 65.55.42.1 --- 12.12.12.14 + tcp 12.12.12.15:200 --- 65.55.42.2:100 --- + tcp --- 65.55.42.2:100 --- 12.12.12.15:200 + ``` + +**config nat add pool** + +This command is used to create a NAT pool used for dynamic Source NAT or NAPT translations. +Pool can be configured in one of the following combinations. + +1. Global IP address range (or) +2. Global IP address + L4 port range (or) +3. Global IP address range + L4 port range. + +- Usage: + ``` + config nat add pool (pool-name) (global-ip-range) (global-port-range) + ``` +To delete a NAT pool, use the command. Pool cannot be removed if it is referenced by a NAT binding. Giving the pools argument removes all the configured pools. +``` +config nat remove {pool (pool-name) | pools} +``` +- Example: + ``` + admin@sonic:~$ sudo config nat add pool pool1 65.55.45.2-65.55.45.10 + admin@sonic:~$ sudo config nat add pool pool2 65.55.45.3 100-1024 + + admin@sonic:~$ show nat config pool + + Pool Name Global IP Range Global Port Range + ----------- ---------------------- ------------------- + pool1 65.55.45.2-65.55.45.10 --- + pool2 65.55.45.3 100-1024 + ``` + +**config nat add binding** + +This command is used to create a NAT binding between a pool and an ACL. The following fields are needed for configuring the binding. + + 1. ACL is an optional argument. If ACL argument is not given, the NAT binding is applicable to match all traffic. + 2. NAT type is an optional argument. Only DNAT type is supoprted for binding. + 3. Twice NAT Id is an optional argument. This Id is used to form a twice nat grouping with the static NAT/NAPT entry configured with the same Id. + +- Usage: + ``` + config nat add binding (binding-name) [(pool-name)] [(acl-name)] [-nat_type {snat | dnat}] [-twice_nat_id (value)] + ``` +To delete a NAT binding, use the command below. Giving the bindings argument removes all the configured bindings. +``` +config nat remove {binding (binding-name) | bindings} +``` +- Example: + ``` + admin@sonic:~$ sudo config nat add binding bind1 pool1 acl1 + admin@sonic:~$ sudo config nat add binding bind2 pool2 + + admin@sonic:~$ show nat config bindings + + Binding Name Pool Name Access-List Nat Type Twice-NAT Id + -------------- ----------- ------------- ---------- -------------- + bind1 pool1 acl1 snat --- + bind2 pool2 snat --- + ``` + +**config nat add interface** + +This command is used to configure NAT zone on an L3 interface. Default value of NAT zone on an L3 interface is 0. Valid range of zone values is 0-3. + +- Usage: + ``` + config nat add interface (interface-name) -nat_zone (value) + ``` +To reset the NAT zone on an interface, use the command below. Giving the interfaces argument resets the NAT zone on all the L3 interfaces to 0. +``` +config nat remove {interface (interface-name) | interfaces} +``` +- Example: + ``` + admin@sonic:~$ sudo config nat add interface Ethernet28 -nat_zone 1 + + admin@sonic:~$ show nat config zones + + Port Zone + ---------- ------ + Ethernet0 0 + Ethernet28 1 + Ethernet22 0 + Vlan2091 0 + ``` + +**config nat set** + +This command is used to set the NAT timeout values. Different timeout values can be configured for the NAT entry timeout, NAPT TCP entry timeout, NAPT UDP entry timeout. +Range for Global NAT entry timeout is 300 sec to 432000 sec, default value is 600 sec. +Range for TCP NAT/NAPT entry timeout is 300 sec to 432000 sec, default value is 86400 sec. +Range for UDP NAT/NAPT entry timeout is 120 sec to 600 sec, default value is 300 sec. + +- Usage: + ``` + config nat set {tcp-timeout (value) | timeout (value) | udp-timeout (value)} + ``` +To reset the timeout values to the default values, use the command +``` +config nat reset {tcp-timeout | timeout | udp-timeout} +``` +- Example: + ``` + admin@sonic:~$ sudo config nat add set tcp-timeout 3600 + + admin@sonic:~$ show nat config globalvalues + + Admin Mode : enabled + Global Timeout : 600 secs + TCP Timeout : 600 secs + UDP Timeout : 300 secs + ``` + +**config nat feature** + +This command is used to enable or disable the NAT feature. + +- Usage: + ``` + config nat feature {enable | disable} + ``` + +- Example: + ``` + admin@sonic:~$ sudo config nat feature enable + admin@sonic:~$ sudo config nat feature disable + ``` + +### NAT Clear commands + +**sonic-clear nat translations** + +This command is used to clear the dynamic NAT and NAPT translation entries. + +- Usage: + ``` + sonic-clear nat translations + ``` + +**sonic-clear nat statistics** + +This command is used to clear the statistics of all the NAT and NAPT entries. + +- Usage: + ``` + sonic-clear nat statistics + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#nat) + + +## NTP + +### NTP show commands + +**show ntp** + +This command displays a list of NTP peers known to the server as well as a summary of their state. + +- Usage: + ``` + show ntp + ``` + +- Example: + ``` + admin@sonic:~$ show ntp + synchronised to NTP server (204.2.134.164) at stratum 3 + time correct to within 326797 ms + polling server every 1024 s + + remote refid st t when poll reach delay offset jitter + ============================================================================== + 23.92.29.245 .XFAC. 16 u - 1024 0 0.000 0.000 0.000 + *204.2.134.164 46.233.231.73 2 u 916 1024 377 3.079 0.394 0.128 + ``` + + +### NTP Config Commands + +This sub-section of commands is used to add or remove the configured NTP servers. + +**config ntp add** + +This command is used to add a NTP server IP address to the NTP server list. Note that more that one NTP server IP address can be added in the device. + +- Usage: + ``` + config ntp add + ``` + +- Example: + ``` + admin@sonic:~$ sudo config ntp add 9.9.9.9 + NTP server 9.9.9.9 added to configuration + Restarting ntp-config service... + ``` + +**config ntp delete** + +This command is used to delete a configured NTP server IP address. + +- Usage: + ``` + config ntp del + ``` + +- Example: + ``` + admin@sonic:~$ sudo config ntp del 9.9.9.9 + NTP server 9.9.9.9 removed from configuration + Restarting ntp-config service... + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#NTP) + +# PFC Watchdog Commands +Detailed description of the PFC Watchdog could be fount on the [this wiki page](https://github.com/Azure/SONiC/wiki/PFC-Watchdog) + +**config pfcwd start \** + +This command starts PFC Watchdog + +- Usage: + ``` + config pfcwd start --action drop all 400 --restoration-time 400 + config pfcwd start --action forward Ethernet0 Ethernet8 400 + ``` + +**config pfcwd stop** + +This command stops PFC Watchdog + +- Usage: + ``` + config pfcwd stop + ``` + +**config pfcwd interval \** + +This command sets PFC Watchdog counter polling interval (in ms) + +- Usage: + ``` + config pfcwd interval 200 + ``` + +**config pfcwd counter_poll \** + +This command enables or disables PFCWD related counters polling + +- Usage: + ``` + config pfcwd counter_poll disable + ``` + +**config pfcwd big_red_switch \** + +This command enables or disables PFCWD's "BIG RED SWITCH"(BRS). After enabling BRS PFC Watchdog will be activated on all ports/queues it is configured for no matter whether the storm was detected or not + +- Usage: + ``` + config pfcwd big_red_switch enable + ``` + +**config pfcwd start_default** + +This command starts PFC Watchdog with the default settings. + +- Usage: + ``` + config pfcwd start_default + ``` + +Default values are the following: + + - detection time - 200ms + - restoration time - 200ms + - polling interval - 200ms + - action - 'drop' + +Additionally if number of ports in the system exceeds 32, all times will be multiplied by roughly /32. + + +**show pfcwd config** + +This command shows current PFC Watchdog configuration + +- Usage: + ``` + show pfcwd config + ``` + +**show pfcwd stats** + +This command shows current PFC Watchdog statistics (storms detected, packets dropped, etc) + +- Usage: + ``` + show pfcwd stats + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#pfc-watchdog-commands) + +## Platform Component Firmware + +### Platform Component Firmware show commands + +**show platform firmware status** + +This command displays platform components firmware status information. + +- Usage: +```bash +show platform firmware status +``` + +- Example: +```bash +admin@sonic:~$ sudo show platform firmware status +Chassis Module Component Version Description +--------- -------- ----------- ----------------------- ---------------------------------------- +MSN3800 N/A ONIE 2020.11-5.2.0022-9600 ONIE - Open Network Install Environment + SSD 0202-000 SSD - Solid-State Drive + BIOS 0ACLH004_02.02.008_9600 BIOS - Basic Input/Output System + CPLD1 CPLD000120_REV0900 CPLD - Complex Programmable Logic Device + CPLD2 CPLD000165_REV0500 CPLD - Complex Programmable Logic Device + CPLD3 CPLD000166_REV0300 CPLD - Complex Programmable Logic Device + CPLD4 CPLD000167_REV0100 CPLD - Complex Programmable Logic Device +``` + +**show platform firmware updates** + +This command displays platform components firmware updates information. + +- Usage: +```bash +show platform firmware updates [-i|--image] +``` + +- Options: + - _-i|--image_: show updates using current/next SONiC image + + Valid values: + - current + - next + + Default: + - current + +- Example: +```bash +admin@sonic:~$ sudo show platform firmware updates +Chassis Module Component Firmware Version (Current/Available) Status +--------- -------- ----------- ------------------------------------------ ------------------------------------------------- ------------------ +MSN3800 N/A ONIE /usr/local/lib/firmware/mellanox/onie.bin 2020.11-5.2.0022-9600 / 2020.11-5.2.0024-9600 update is required + SSD /usr/local/lib/firmware/mellanox/ssd.bin 0202-000 / 0204-000 update is required + BIOS /usr/local/lib/firmware/mellanox/bios.bin 0ACLH004_02.02.008_9600 / 0ACLH004_02.02.010_9600 update is required + CPLD1 /usr/local/lib/firmware/mellanox/cpld.mpfa CPLD000120_REV0900 / CPLD000120_REV0900 up-to-date + CPLD2 /usr/local/lib/firmware/mellanox/cpld.mpfa CPLD000165_REV0500 / CPLD000165_REV0500 up-to-date + CPLD3 /usr/local/lib/firmware/mellanox/cpld.mpfa CPLD000166_REV0300 / CPLD000166_REV0300 up-to-date + CPLD4 /usr/local/lib/firmware/mellanox/cpld.mpfa CPLD000167_REV0100 / CPLD000167_REV0100 up-to-date +``` + +- Note: + - current/next values for _-i|--image_ are taken from `sonic-installer list` + ```bash + admin@sonic:~$ sudo sonic-installer list + Current: SONiC-OS-202012.0-fb89c28c9 + Next: SONiC-OS-201911.0-2bec3004e + Available: + SONiC-OS-202012.0-fb89c28c9 + SONiC-OS-201911.0-2bec3004e + ``` + +**show platform firmware version** + +This command displays platform components firmware utility version. + +- Usage: +```bash +show platform firmware version +``` + +- Example: +```bash +admin@sonic:~$ show platform firmware version +fwutil version 2.0.0.0 +``` + +### Platform Component Firmware config commands + +**config platform firmware install** + +This command is used to install a platform component firmware. +Both modular and non modular chassis platforms are supported. + +- Usage: +```bash +config platform firmware install chassis component fw [-y|--yes] +config platform firmware install module component fw [-y|--yes] +``` + +- Options: + - _-y|--yes_: automatic yes to prompts. Assume "yes" as answer to all prompts and run non-interactively + +- Example: +```bash +admin@sonic:~$ sudo config platform firmware install chassis component BIOS fw /usr/local/lib/firmware/mellanox/sn3800/chassis1/bios.bin +Warning: Immediate cold reboot is required to complete BIOS firmware update. +New firmware will be installed, continue? [y/N]: y +Installing firmware: + /usr/local/lib/firmware/mellanox/sn3800/chassis1/bios.bin + +admin@sonic:~$ sudo config platform firmware install module Module1 component BIOS fw https://www.mellanox.com/fw/sn3800/module1/bios.bin +Warning: Immediate cold reboot is required to complete BIOS firmware update. +New firmware will be installed, continue? [y/N]: y +Downloading firmware: + [##################################################] 100% +Installing firmware: + /tmp/bios.bin +``` + +- Note: + - can be absolute path or URL + +**config platform firmware update** + +This command is used to update a platform component firmware from current/next SONiC image. +Both modular and non modular chassis platforms are supported. + +FW update requires `platform_components.json` to be created and placed at: +sonic-buildimage/device///platform_components.json + +Example: +1. Non modular chassis platform +```json +{ + "chassis": { + "Chassis1": { + "component": { + "BIOS": { + "firmware": "/usr/local/lib/firmware///chassis1/bios.bin", + "version": "" + }, + "CPLD": { + "firmware": "/usr/local/lib/firmware///chassis1/cpld.bin", + "version": "" + }, + "FPGA": { + "firmware": "/usr/local/lib/firmware///chassis1/fpga.bin", + "version": "" + } + } + } + } +} +``` + +2. Modular chassis platform +```json +{ + "chassis": { + "Chassis1": { + "component": { + "BIOS": { + "firmware": "/usr/local/lib/firmware///chassis1/bios.bin", + "version": "" + }, + "CPLD": { + "firmware": "/usr/local/lib/firmware///chassis1/cpld.bin", + "version": "" + }, + "FPGA": { + "firmware": "/usr/local/lib/firmware///chassis1/fpga.bin", + "version": "" + } + } + } + }, + "module": { + "Module1": { + "component": { + "CPLD": { + "firmware": "/usr/local/lib/firmware///module1/cpld.bin", + "version": "" + }, + "FPGA": { + "firmware": "/usr/local/lib/firmware///module1/fpga.bin", + "version": "" + } + } + } + } +} +``` + +- Usage: +```bash +config platform firmware update chassis component fw [-y|--yes] [-f|--force] [-i|--image] +config platform firmware update module component fw [-y|--yes] [-f|--force] [-i|--image] +``` + +- Options: + - _-y|--yes_: automatic yes to prompts. Assume "yes" as answer to all prompts and run non-interactively + - _-f|--force_: update FW regardless the current version + - _-i|--image_: update FW using current/next SONiC image + + Valid values: + - current + - next + + Default: + - current + +- Example: +```bash +admin@sonic:~$ sudo config platform firmware update chassis component BIOS fw +Warning: Immediate cold reboot is required to complete BIOS firmware update. +New firmware will be installed, continue? [y/N]: y +Updating firmware: + /usr/local/lib/firmware/mellanox/x86_64-mlnx_msn3800-r0/chassis1/bios.bin + +admin@sonic:~$ sudo config platform firmware update module Module1 component BIOS fw +Warning: Immediate cold reboot is required to complete BIOS firmware update. +New firmware will be installed, continue? [y/N]: y +Updating firmware: + /usr/local/lib/firmware/mellanox/x86_64-mlnx_msn3800-r0/module1/bios.bin +``` + +- Note: + - FW update will be disabled if component definition is not provided (e.g., 'BIOS': { }) + - FW version will be read from image if `version` field is not provided + - current/next values for _-i|--image_ are taken from `sonic-installer list` + ```bash + admin@sonic:~$ sudo sonic-installer list + Current: SONiC-OS-202012.0-fb89c28c9 + Next: SONiC-OS-201911.0-2bec3004e + Available: + SONiC-OS-202012.0-fb89c28c9 + SONiC-OS-201911.0-2bec3004e + ``` + +### Platform Component Firmware vendor specific behaviour + +#### Mellanox + +**CPLD update** + +On Mellanox platforms CPLD update can be done either for single or for all components at once. +The second approach is preferred. In this case an aggregated `vme` binary is used and +CPLD component can be specified arbitrary. + +- Example: +```bash +root@sonic:/home/admin# show platform firmware +Chassis Module Component Version Description +---------------------- -------- ----------- ----------------------- ---------------------------------------- +x86_64-mlnx_msn3800-r0 N/A BIOS 0ACLH004_02.02.007_9600 BIOS - Basic Input/Output System + CPLD1 CPLD000000_REV0400 CPLD - Complex Programmable Logic Device + CPLD2 CPLD000000_REV0300 CPLD - Complex Programmable Logic Device + CPLD3 CPLD000000_REV0300 CPLD - Complex Programmable Logic Device + CPLD4 CPLD000000_REV0100 CPLD - Complex Programmable Logic Device + +root@sonic:/home/admin# BURN_VME="$(pwd)/FUI000091_Burn_SN3800_CPLD000120_REV0600_CPLD000165_REV0400_CPLD000166_REV0300_CPLD000167_REV0100.vme" +root@sonic:/home/admin# REFRESH_VME="$(pwd)/FUI000091_Refresh_SN3800_CPLD000120_REV0600_CPLD000165_REV0400_CPLD000166_REV0300_CPLD000167_REV0100.vme" + +root@sonic:/home/admin# config platform firmware install chassis component CPLD1 fw -y ${BURN_VME} +root@sonic:/home/admin# config platform firmware install chassis component CPLD1 fw -y ${REFRESH_VME} + +root@sonic:/home/admin# show platform firmware +Chassis Module Component Version Description +---------------------- -------- ----------- ----------------------- ---------------------------------------- +x86_64-mlnx_msn3800-r0 N/A BIOS 0ACLH004_02.02.007_9600 BIOS - Basic Input/Output System + CPLD1 CPLD000000_REV0600 CPLD - Complex Programmable Logic Device + CPLD2 CPLD000000_REV0400 CPLD - Complex Programmable Logic Device + CPLD3 CPLD000000_REV0300 CPLD - Complex Programmable Logic Device + CPLD4 CPLD000000_REV0100 CPLD - Complex Programmable Logic Device +``` + +Note: the update will have the same effect if any of CPLD1/CPLD2/CPLD3/CPLD4 will be used + +Go Back To [Beginning of the document](#) or [Beginning of this section](#platform-component-firmware) + + +## 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** + +This command shows the SDK sniffer status + +- Usage: + ``` + show platform mlnx sniffer + ``` + +- Example: + ``` + admin@sonic:~$ show platform mlnx sniffer + sdk sniffer is disabled + ``` + +**show platform mlnx sniffer** + +Another show command available on ‘show platform mlnx’ which is the issu status. +This means if ISSU is enabled on this SKU or not. A warm boot command can be executed only when ISSU is enabled on the SKU. + +- Usage: + ``` + show platform mlnx issu + ``` + +- Example: + ``` + admin@sonic:~$ show platform mlnx issu + ISSU is enabled + ``` + +In the case ISSU is disabled and warm-boot is called, the user will get a notification message explaining that the command cannot be invoked. + +- Example: + ``` + admin@sonic:~$ sudo warm-reboot + ISSU is not enabled on this HWSKU + Warm reboot is not supported + ``` + +**config platform mlnx** + +This command is valid only on mellanox devices. The sub-commands for "config platform" gets populated only on mellanox platforms. +There are no other subcommands on non-Mellanox devices and hence this command appears empty and useless in other platforms. +The platform mellanox command currently includes a single sub command which is the SDK sniffer. +The SDK sniffer is a troubleshooting tool which records the RPC calls from the Mellanox SDK user API library to the sx_sdk task into a .pcap file. +This .pcap file can be replayed afterward to get the exact same configuration state on SDK and FW to reproduce and investigate issues. + +A new folder will be created to store the sniffer files: "/var/log/mellanox/sniffer/". The result file will be stored in a .pcap file, which includes a time stamp of the starting time in the file name, for example, "sx_sdk_sniffer_20180224081306.pcap" +In order to have a complete .pcap file with all the RPC calls, the user should disable the SDK sniffer. Swss service will be restarted and no capturing is taken place from that moment. +It is recommended to review the .pcap file while sniffing is disabled. +Once SDK sniffer is enabled/disabled, the user is requested to approve that swss service will be restarted. +For example: To change SDK sniffer status, swss service will be restarted, continue? [y/N]: +In order to avoid that confirmation the -y / --yes option should be used. + +- Usage: + ``` + config platform mlnx sniffer sdk [-y|--yes] + ``` + +- Example: + ``` + admin@sonic:~$ config platform mlnx sniffer sdk + To change SDK sniffer status, swss service will be restarted, continue? [y/N]: y + 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) + + +## PortChannels + +### PortChannel Show commands + +**show interfaces portchannel** + +This command displays all the port channels that are configured in the device and its current status. + +- Usage: + ``` + show interfaces portchannel + ``` + +- Example: + ``` + admin@sonic:~$ show interfaces portchannel + Flags: A - active, I - inactive, Up - up, Dw - Down, N/A - not available, S - selected, D - deselected + No. Team Dev Protocol Ports + ----- ------------- ----------- --------------------------- + 24 PortChannel24 LACP(A)(Up) Ethernet28(S) Ethernet24(S) + 48 PortChannel48 LACP(A)(Up) Ethernet52(S) Ethernet48(S) + 40 PortChannel40 LACP(A)(Up) Ethernet44(S) Ethernet40(S) + 0 PortChannel0 LACP(A)(Up) Ethernet0(S) Ethernet4(S) + 8 PortChannel8 LACP(A)(Up) Ethernet8(S) Ethernet12(S) + ``` + + +### PortChannel Config commands + +This sub-section explains how to configure the portchannel and its member ports. + +**config portchannel** + +This command is used to add or delete the portchannel. +It is recommended to use portchannel names in the format "PortChannelxxxx", where "xxxx" is number of 1 to 4 digits. Ex: "PortChannel0002". + +NOTE: If users specify any other name like "pc99", command will succeed, but such names are not supported. Such names are not printed properly in the "show interface portchannel" command. It is recommended not to use such names. + +When any port is already member of any other portchannel and if user tries to add the same port in some other portchannel (without deleting it from the current portchannel), the command fails internally. But, it does not print any error message. In such cases, remove the member from current portchannel and then add it to new portchannel. + +Command takes two optional arguements given below. +1) min-links - minimum number of links required to bring up the portchannel +2) fallback - true/false. LACP fallback feature can be enabled / disabled. When it is set to true, only one member port will be selected as active per portchannel during fallback mode. Refer https://github.com/Azure/SONiC/blob/master/doc/lag/LACP%20Fallback%20Feature%20for%20SONiC_v0.5.md for more details about fallback feature. + +A port channel can be deleted only if it does not have any members or the members are already deleted. When a user tries to delete a port channel and the port channel still has one or more members that exist, the deletion of port channel is blocked. + +- Usage: + ``` + config portchannel (add | del) [--min-links ] [--fallback (true | false)] + ``` + +- Example (Create the portchannel with name "PortChannel0011"): + ``` + admin@sonic:~$ sudo config portchannel add PortChannel0011 + ``` + +**config portchannel member** + +This command adds or deletes a member port to/from the already created portchannel. + +- Usage: + ``` + config portchannel member (add | del) + ``` + +- Example (Add interface Ethernet4 as member of the portchannel "PortChannel0011"): + ``` + admin@sonic:~$ sudo config portchannel member add PortChannel0011 Ethernet4 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#portchannels) + +## NVGRE + +This section explains the various show commands and configuration commands available for users. + +### NVGRE show commands + +This subsection explains how to display the NVGRE configuration. + +**show nvgre-tunnel** + +This command displays the NVGRE tunnel configuration. + +- Usage: +```bash +show nvgre-tunnel +``` + +- Example: +```bash +admin@sonic:~$ show nvgre-tunnel +TUNNEL NAME SRC IP +------------- -------- +tunnel_1 10.0.0.1 +``` + +**show nvgre-tunnel-map** + +This command displays the NVGRE tunnel map configuration. + +- Usage: +```bash +show nvgre-tunnel-map +``` + +- Example: +```bash +admin@sonic:~$ show nvgre-tunnel-map +TUNNEL NAME TUNNEL MAP NAME VLAN ID VSID +------------- ----------------- --------- ------ +tunnel_1 Vlan1000 1000 5000 +tunnel_1 Vlan2000 2000 6000 +``` + +### NVGRE config commands + +This subsection explains how to configure the NVGRE. + +**config nvgre-tunnel** + +This command is used to manage the NVGRE tunnel objects. +It supports add/delete operations. + +- Usage: +```bash +config nvgre-tunnel add --src-ip +config nvgre-tunnel delete +``` + +- Parameters: + - _tunnel-name_: the name of the NVGRE tunnel + - _src-ip_: source ip address + +- Examples: +```bash +config nvgre-tunnel add 'tunnel_1' --src-ip '10.0.0.1' +config nvgre-tunnel delete 'tunnel_1' +``` + +**config nvgre-tunnel-map** + +This command is used to manage the NVGRE tunnel map objects. +It supports add/delete operations. + +- Usage: +```bash +config nvgre-tunnel-map add --vlan-id --vsid +config nvgre-tunnel-map delete +``` + +- Parameters: + - _tunnel-name_: the name of the NVGRE tunnel + - _tunnel-map-name_: the name of the NVGRE tunnel map + - _vlan-id_: VLAN identifier + - _vsid_: Virtual Subnet Identifier + +- Examples: +```bash +config nvgre-tunnel-map add 'tunnel_1' 'Vlan2000' --vlan-id '2000' --vsid '6000' +config nvgre-tunnel-map delete 'tunnel_1' 'Vlan2000' +``` + +## PBH + +This section explains the various show commands and configuration commands available for users. + +### PBH show commands + +This subsection explains how to display PBH configuration and statistics. + +**show pbh table** + +This command displays PBH table configuration. + +- Usage: +```bash +show pbh table +``` + +- Example: +```bash +admin@sonic:~$ show pbh table +NAME INTERFACE DESCRIPTION +--------- --------------- --------------- +pbh_table Ethernet0 NVGRE and VxLAN + Ethernet4 + PortChannel0001 + PortChannel0002 +``` + +**show pbh rule** + +This command displays PBH rule configuration. + +- Usage: +```bash +show pbh rule +``` + +- Example: +```bash +admin@sonic:~$ show pbh rule +TABLE RULE PRIORITY MATCH HASH ACTION COUNTER +--------- ------ ---------- ------------------------------------ ------------- ------------- --------- +pbh_table nvgre 2 ether_type: 0x0800 inner_v6_hash SET_ECMP_HASH DISABLED + ip_protocol: 0x2f + gre_key: 0x2500/0xffffff00 + inner_ether_type: 0x86dd +pbh_table vxlan 1 ether_type: 0x0800 inner_v4_hash SET_LAG_HASH ENABLED + ip_protocol: 0x11 + l4_dst_port: 0x12b5 + inner_ether_type: 0x0800 +``` + +**show pbh hash** + +This command displays PBH hash configuration. + +- Usage: +```bash +show pbh hash +``` + +- Example: +```bash +admin@sonic:~$ show pbh hash +NAME HASH FIELD +------------- ----------------- +inner_v4_hash inner_ip_proto + inner_l4_dst_port + inner_l4_src_port + inner_dst_ipv4 + inner_src_ipv4 +inner_v6_hash inner_ip_proto + inner_l4_dst_port + inner_l4_src_port + inner_dst_ipv6 + inner_src_ipv6 +``` + +**show pbh hash-field** + +This command displays PBH hash field configuration. + +- Usage: +```bash +show pbh hash-field +``` + +- Example: +```bash +admin@sonic:~$ show pbh hash-field +NAME FIELD MASK SEQUENCE SYMMETRIC +----------------- ----------------- --------- ---------- ----------- +inner_ip_proto INNER_IP_PROTOCOL N/A 1 No +inner_l4_dst_port INNER_L4_DST_PORT N/A 2 Yes +inner_l4_src_port INNER_L4_SRC_PORT N/A 2 Yes +inner_dst_ipv4 INNER_DST_IPV4 255.0.0.0 3 Yes +inner_src_ipv4 INNER_SRC_IPV4 0.0.0.255 3 Yes +inner_dst_ipv6 INNER_DST_IPV6 ffff:: 4 Yes +inner_src_ipv6 INNER_SRC_IPV6 ::ffff 4 Yes +``` + +- Note: + - _SYMMETRIC_ is an artificial column and is only used to indicate fields symmetry + +**show pbh statistics** + +This command displays PBH statistics. + +- Usage: +```bash +show pbh statistics +``` + +- Example: +```bash +admin@sonic:~$ show pbh statistics +TABLE RULE RX PACKETS COUNT RX BYTES COUNT +--------- ------ ------------------ ---------------- +pbh_table nvgre 0 0 +pbh_table vxlan 0 0 +``` + +- Note: + - _RX PACKETS COUNT_ and _RX BYTES COUNT_ can be cleared by user: + ```bash + admin@sonic:~$ sonic-clear pbh statistics + ``` + +### PBH config commands + +This subsection explains how to configure PBH. + +**config pbh table** + +This command is used to manage PBH table objects. +It supports add/update/remove operations. + +- Usage: +```bash +config pbh table add --interface-list --description +config pbh table update [ --interface-list ] [ --description ] +config pbh table delete +``` + +- Parameters: + - _table_name_: the name of the PBH table + - _interface_list_: interfaces to which PBH table is applied + - _description_: the description of the PBH table + +- Examples: +```bash +config pbh table add 'pbh_table' \ +--interface-list 'Ethernet0,Ethernet4,PortChannel0001,PortChannel0002' \ +--description 'NVGRE and VxLAN' +config pbh table update 'pbh_table' \ +--interface-list 'Ethernet0' +config pbh table delete 'pbh_table' +``` + +**config pbh rule** + +This command is used to manage PBH rule objects. +It supports add/update/remove operations. + +- Usage: +```bash +config pbh rule add --priority \ +[ --gre-key ] [ --ether-type ] [ --ip-protocol ] \ +[ --ipv6-next-header ] [ --l4-dst-port ] [ --inner-ether-type ] \ +--hash [ --packet-action ] [ --flow-counter ] +config pbh rule update [ --priority ] \ +[ --gre-key ] [ --ether-type ] [ --ip-protocol ] \ +[ --ipv6-next-header ] [ --l4-dst-port ] [ --inner-ether-type ] \ +[ --hash ] [ --packet-action ] [ --flow-counter ] +config pbh rule delete +``` + +- Parameters: + - _table_name_: the name of the PBH table + - _rule_name_: the name of the PBH rule + - _priority_: the priority of the PBH rule + - _gre_key_: packet match for the PBH rule: GRE key (value/mask) + - _ether_type_: packet match for the PBH rule: EtherType (IANA Ethertypes) + - _ip_protocol_: packet match for the PBH rule: IP protocol (IANA Protocol Numbers) + - _ipv6_next_header_: packet match for the PBH rule: IPv6 Next header (IANA Protocol Numbers) + - _l4_dst_port_: packet match for the PBH rule: L4 destination port + - _inner_ether_type_: packet match for the PBH rule: inner EtherType (IANA Ethertypes) + - _hash_: _hash_ object to apply with the PBH rule + - _packet_action_: packet action for the PBH rule + + Valid values: + - SET_ECMP_HASH + - SET_LAG_HASH + + Default: + - SET_ECMP_HASH + + - _flow_counter_: packet/byte counter for the PBH rule + + Valid values: + - DISABLED + - ENABLED + + Default: + - DISABLED + +- Examples: +```bash +config pbh rule add 'pbh_table' 'nvgre' \ +--priority '2' \ +--ether-type '0x0800' \ +--ip-protocol '0x2f' \ +--gre-key '0x2500/0xffffff00' \ +--inner-ether-type '0x86dd' \ +--hash 'inner_v6_hash' \ +--packet-action 'SET_ECMP_HASH' \ +--flow-counter 'DISABLED' +config pbh rule update 'pbh_table' 'nvgre' \ +--flow-counter 'ENABLED' +config pbh rule delete 'pbh_table' 'nvgre' +``` + +**config pbh hash** + +This command is used to manage PBH hash objects. +It supports add/update/remove operations. + +- Usage: +```bash +config pbh hash add --hash-field-list +config pbh hash update [ --hash-field-list ] +config pbh hash delete +``` + +- Parameters: + - _hash_name_: the name of the PBH hash + - _hash_field_list_: list of _hash-field_ objects to apply with the PBH hash + +- Examples: +```bash +config pbh hash add 'inner_v6_hash' \ +--hash-field-list 'inner_ip_proto,inner_l4_dst_port,inner_l4_src_port,inner_dst_ipv6,inner_src_ipv6' +config pbh hash update 'inner_v6_hash' \ +--hash-field-list 'inner_ip_proto' +config pbh hash delete 'inner_v6_hash' +``` + +**config pbh hash-field** + +This command is used to manage PBH hash field objects. +It supports add/update/remove operations. + +- Usage: +```bash +config pbh hash-field add \ +--hash-field [ --ip-mask ] --sequence-id +config pbh hash-field update \ +[ --hash-field ] [ --ip-mask ] [ --sequence-id ] +config pbh hash-field delete +``` + +- Parameters: + - _hash_field_name_: the name of the PBH hash field + - _hash_field_: native hash field for the PBH hash field + + Valid values: + - INNER_IP_PROTOCOL + - INNER_L4_DST_PORT + - INNER_L4_SRC_PORT + - INNER_DST_IPV4 + - INNER_SRC_IPV4 + - INNER_DST_IPV6 + - INNER_SRC_IPV6 + + - _ip_mask_: IPv4/IPv6 address mask for the PBH hash field + + Valid only: _hash_field_ is: + - INNER_DST_IPV4 + - INNER_SRC_IPV4 + - INNER_DST_IPV6 + - INNER_SRC_IPV6 + + - _sequence_id_: the order in which fields are hashed + +- Examples: +```bash +config pbh hash-field add 'inner_dst_ipv6' \ +--hash-field 'INNER_DST_IPV6' \ +--ip-mask 'ffff::' \ +--sequence-id '4' +config pbh hash-field update 'inner_dst_ipv6' \ +--ip-mask 'ffff:ffff::' +config pbh hash-field delete 'inner_dst_ipv6' +``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#pbh) + +## QoS + +### QoS Show commands + +#### PFC + +**show pfc counters** + +This command displays the details of Rx & Tx priority-flow-control (pfc) for all ports. This command can be used to clear the counters using -c option. + +- Usage: + ``` + show pfc counters + ``` + +- Example: + ``` + admin@sonic:~$ show pfc counters + Port Rx PFC0 PFC1 PFC2 PFC3 PFC4 PFC5 PFC6 PFC7 + ----------- ------ ------ ------ ------ ------ ------ ------ ------ + Ethernet0 0 0 0 0 0 0 0 0 + Ethernet4 0 0 0 0 0 0 0 0 + Ethernet8 0 0 0 0 0 0 0 0 + Ethernet12 0 0 0 0 0 0 0 0 + + Port Tx PFC0 PFC1 PFC2 PFC3 PFC4 PFC5 PFC6 PFC7 + ----------- ------ ------ ------ ------ ------ ------ ------ ------ + Ethernet0 0 0 0 0 0 0 0 0 + Ethernet4 0 0 0 0 0 0 0 0 + Ethernet8 0 0 0 0 0 0 0 0 + Ethernet12 0 0 0 0 0 0 0 0 + + ... + ``` + + +- NOTE: PFC counters can be cleared by the user with the following command: + ``` + admin@sonic:~$ sonic-clear pfccounters + ``` + +**show pfc asymmetric** + +This command displays the status of asymmetric PFC for all interfaces or a given interface. + +- Usage: + ``` + show pfc asymmetric [] + ``` + +- Example: + ``` + admin@sonic:~$ show pfc asymmetric + + Interface Asymmetric + ----------- ------------ + Ethernet0 off + Ethernet2 off + Ethernet4 off + Ethernet6 off + Ethernet8 off + Ethernet10 off + Ethernet12 off + Ethernet14 off + + admin@sonic:~$ show pfc asymmetric Ethernet0 + + Interface Asymmetric + ----------- ------------ + Ethernet0 off + ``` + +**show pfc priority** + +This command displays the lossless priorities for all interfaces or a given interface. + +- Usage: + ``` + show pfc priority [] + ``` + +- Example: + ``` + admin@sonic:~$ show pfc priority + + Interface Lossless priorities + ----------- --------------------- + Ethernet0 3,4 + Ethernet2 3,4 + Ethernet8 3,4 + Ethernet10 3,4 + Ethernet16 3,4 + + admin@sonic:~$ show pfc priority Ethernet0 + + Interface Lossless priorities + ----------- --------------------- + Ethernet0 3,4 + ``` + +#### Queue And Priority-Group + +This sub-section explains the following queue parameters that can be displayed using "show queue" command. +1) queue counters +2) queue watermark +3) priority-group watermark +4) queue persistent-watermark + + +**show queue counters** + +This command displays packet and byte counters for all queues of all ports or one specific-port given as arguement. +This command can be used to clear the counters for all queues of all ports. Note that port specific clear is not supported. + +- Usage: + ``` + show queue counters [] + ``` + +- Example: + ``` + admin@sonic:~$ show queue counters + Port TxQ Counter/pkts Counter/bytes Drop/pkts Drop/bytes + --------- ----- -------------- --------------- ----------- ------------ + Ethernet0 UC0 0 0 0 0 + Ethernet0 UC1 0 0 0 0 + Ethernet0 UC2 0 0 0 0 + Ethernet0 UC3 0 0 0 0 + Ethernet0 UC4 0 0 0 0 + Ethernet0 UC5 0 0 0 0 + Ethernet0 UC6 0 0 0 0 + Ethernet0 UC7 0 0 0 0 + Ethernet0 UC8 0 0 0 0 + Ethernet0 UC9 0 0 0 0 + Ethernet0 MC0 0 0 0 0 + Ethernet0 MC1 0 0 0 0 + Ethernet0 MC2 0 0 0 0 + Ethernet0 MC3 0 0 0 0 + Ethernet0 MC4 0 0 0 0 + Ethernet0 MC5 0 0 0 0 + Ethernet0 MC6 0 0 0 0 + Ethernet0 MC7 0 0 0 0 + Ethernet0 MC8 0 0 0 0 + Ethernet0 MC9 0 0 0 0 + + Port TxQ Counter/pkts Counter/bytes Drop/pkts Drop/bytes + --------- ----- -------------- --------------- ----------- ------------ + Ethernet4 UC0 0 0 0 0 + Ethernet4 UC1 0 0 0 0 + Ethernet4 UC2 0 0 0 0 + Ethernet4 UC3 0 0 0 0 + Ethernet4 UC4 0 0 0 0 + Ethernet4 UC5 0 0 0 0 + Ethernet4 UC6 0 0 0 0 + Ethernet4 UC7 0 0 0 0 + Ethernet4 UC8 0 0 0 0 + Ethernet4 UC9 0 0 0 0 + Ethernet4 MC0 0 0 0 0 + Ethernet4 MC1 0 0 0 0 + Ethernet4 MC2 0 0 0 0 + Ethernet4 MC3 0 0 0 0 + Ethernet4 MC4 0 0 0 0 + Ethernet4 MC5 0 0 0 0 + Ethernet4 MC6 0 0 0 0 + Ethernet4 MC7 0 0 0 0 + Ethernet4 MC8 0 0 0 0 + Ethernet4 MC9 0 0 0 0 + + ... + ``` + +Optionally, you can specify an interface name in order to display only that particular interface + +- Example: + ``` + admin@sonic:~$ show queue counters Ethernet72 + ``` + +- NOTE: Queue counters can be cleared by the user with the following command: + ``` + admin@sonic:~$ sonic-clear queuecounters + ``` + +**show queue watermark** + +This command displays the user watermark for the queues (Egress shared pool occupancy per queue) for either the unicast queues or multicast queues for all ports + +- Usage: + ``` + show queue watermark (multicast | unicast) + ``` + +- Example: + ``` + admin@sonic:~$ show queue watermark unicast + Egress shared pool occupancy per unicast queue: + Port UC0 UC1 UC2 UC3 UC4 UC5 UC6 UC7 + ----------- ----- ----- ----- ----- ----- ----- ----- ----- + Ethernet0 0 0 0 0 0 0 0 0 + Ethernet4 0 0 0 0 0 0 0 0 + Ethernet8 0 0 0 0 0 0 0 0 + Ethernet12 0 0 0 0 0 0 0 0 + + admin@sonic:~$ show queue watermark multicast (Egress shared pool occupancy per multicast queue) + ``` + +**show priority-group** + +This command displays: +1) The user watermark or persistent-watermark for the Ingress "headroom" or "shared pool occupancy" per priority-group for all ports. +2) Dropped packets per priority-group for all ports + +- Usage: + ``` + show priority-group (watermark | persistent-watermark) (headroom | shared) + show priority-group drop counters + ``` + +- Example: + ``` + admin@sonic:~$ show priority-group watermark shared + Ingress shared pool occupancy per PG: + Port PG0 PG1 PG2 PG3 PG4 PG5 PG6 PG7 + ----------- ----- ----- ----- ----- ----- ----- ----- ----- + Ethernet0 0 0 0 0 0 0 0 0 + Ethernet4 0 0 0 0 0 0 0 0 + Ethernet8 0 0 0 0 0 0 0 0 + Ethernet12 0 0 0 0 0 0 0 0 + ``` + +- Example (Ingress headroom per PG): + ``` + admin@sonic:~$ show priority-group watermark headroom + ``` + +- Example (Ingress shared pool occupancy per PG): + ``` + admin@sonic:~$ show priority-group persistent-watermark shared + ``` + +- Example (Ingress headroom per PG): + ``` + admin@sonic:~$ show priority-group persistent-watermark headroom + ``` + +- Example (Ingress dropped packets per PG): + ``` + admin@sonic:~$ show priority-group drop counters + Ingress PG dropped packets: + Port PG0 PG1 PG2 PG3 PG4 PG5 PG6 PG7 + ----------- ----- ----- ----- ----- ----- ----- ----- ----- + Ethernet0 0 0 0 0 0 0 0 0 + Ethernet4 0 0 0 0 0 0 0 0 + Ethernet8 0 0 0 0 0 0 0 0 + Ethernet12 0 0 0 0 0 0 0 0 + ``` + +In addition to user watermark("show queue|priority-group watermark ..."), a persistent watermark is available. +It hold values independently of user watermark. This way user can use "user watermark" for debugging, clear it, etc, but the "persistent watermark" will not be affected. + +**show queue persistent-watermark** + +This command displays the user persistet-watermark for the queues (Egress shared pool occupancy per queue) for either the unicast queues or multicast queues for all ports + +- Usage: + ``` + show queue persistent-watermark (unicast | multicast) + ``` + +- Example: + ``` + admin@sonic:~$ show queue persistent-watermark unicast + Egress shared pool occupancy per unicast queue: + Port UC0 UC1 UC2 UC3 UC4 UC5 UC6 UC7 + ----------- ----- ----- ----- ----- ----- ----- ----- ----- + Ethernet0 N/A N/A N/A N/A N/A N/A N/A N/A + Ethernet4 N/A N/A N/A N/A N/A N/A N/A N/A + Ethernet8 N/A N/A N/A N/A N/A N/A N/A N/A + Ethernet12 N/A N/A N/A N/A N/A N/A N/A N/A + ``` + +- Example (Egress shared pool occupancy per multicast queue): + ``` + admin@sonic:~$ show queue persistent-watermark multicast + ``` + +- NOTE: "user watermark", "persistent watermark" and "ingress dropped packets" can be cleared by user: + + ``` + admin@sonic:~$ sonic-clear queue persistent-watermark unicast + + admin@sonic:~$ sonic-clear queue persistent-watermark multicast + + admin@sonic:~$ sonic-clear priority-group persistent-watermark shared + + admin@sonic:~$ sonic-clear priority-group persistent-watermark headroom + + admin@sonic:~$ sonic-clear priority-group drop counters + ``` + +#### Buffer Pool + +This sub-section explains the following buffer pool parameters that can be displayed using "show buffer_pool" command. +1) buffer pool watermark +2) buffer pool persistent-watermark + +**show buffer_pool watermark** + +This command displays the user watermark for all the buffer pools + +- Usage: + ``` + show buffer_pool watermark + ``` + +- Example: + ``` + admin@sonic:~$ show buffer_pool watermark + Shared pool maximum occupancy: + Pool Bytes + --------------------- ------- + ingress_lossless_pool 0 + lossy_pool 2464 + ``` + + +**show buffer_pool persistent-watermark** + +This command displays the user persistent-watermark for all the buffer pools + +- Usage: + ``` + show buffer_pool persistent-watermark + ``` + +- Example: + ``` + admin@sonic:~$ show buffer_pool persistent-watermark + Shared pool maximum occupancy: + Pool Bytes + --------------------- ------- + ingress_lossless_pool 0 + lossy_pool 2464 + ``` + + + +### QoS config commands + +**config qos clear** + +This command is used to clear all the QoS configuration from all the following QOS Tables in ConfigDB. + +1) TC_TO_PRIORITY_GROUP_MAP, +2) MAP_PFC_PRIORITY_TO_QUEUE, +3) TC_TO_QUEUE_MAP, +4) DSCP_TO_TC_MAP, +5) MPLS_TC_TO_TC_MAP, +6) SCHEDULER, +7) PFC_PRIORITY_TO_PRIORITY_GROUP_MAP, +8) PORT_QOS_MAP, +9) WRED_PROFILE, +10) QUEUE, +11) CABLE_LENGTH, +12) BUFFER_POOL, +13) BUFFER_PROFILE, +14) BUFFER_PG, +15) BUFFER_QUEUE + +- Usage: + ``` + config qos clear + ``` + +- Example: + ``` + admin@sonic:~$ sudo config qos clear + ``` + +**config qos reload** + +This command is used to reload the QoS configuration. +QoS configuration has got two sets of configurations. +1) Generic QOS Configuration - This gives complete list of all possible QOS configuration. Its given in the file /usr/share/sonic/templates/qos_config.j2 in the device. + Reference: https://github.com/Azure/sonic-buildimage/blob/master/files/build_templates/qos_config.j2 + Users have flexibility to have platform specific qos configuration by placing the qos_config.j2 file at /usr/share/sonic/device///. + If users want to modify any of this loaded QOS configuration, they can modify this file in the device and then issue the "config qos reload" command. + +2) Platform specific buffer configuration. Every platform has got platform specific and topology specific (T0 or T1 or T2) buffer configuration at /usr/share/sonic/device///buffers_defaults_tx.j2 + In addition to platform specific configuration file, a generic configuration file is also present at /usr/share/sonic/templates/buffers_config.j2. + Reference: https://github.com/Azure/sonic-buildimage/blob/master/files/build_templates/buffers_config.j2 + Users can either modify the platform specific configuration file, or the generic configuration file and then issue this "config qos reload" command. + +These configuration files are already loaded in the device as part of the reboot process. In case if users wants to modify any of these configurations, they need to modify the appropriate QOS tables and fields in these files and then use this reload command. +This command uses those modified buffers.json.j2 file & qos.json.j2 file and reloads the new QOS configuration. +If users have not made any changes in these configuration files, this command need not be executed. + +Some of the example QOS configurations that users can modify are given below. +1) TC_TO_PRIORITY_GROUP_MAP +2) MAP_PFC_PRIORITY_TO_QUEUE +3) TC_TO_QUEUE_MAP +4) DSCP_TO_TC_MAP +5) MPLS_TC_TO_TC_MAP +6) SCHEDULER +7) PFC_PRIORITY_TO_PRIORITY_GROUP_MAP +8) PORT_QOS_MAP +9) WRED_PROFILE +10) CABLE_LENGTH +11) BUFFER_QUEUE + +- Usage: + ``` + config qos reload + ``` + +- Example: + ``` + admin@sonic:~$ sudo config qos reload + Running command: /usr/local/bin/sonic-cfggen -d -t /usr/share/sonic/device/x86_64-dell_z9100_c2538-r0/Force10-Z9100-C32/buffers.json.j2 >/tmp/buffers.json + Running command: /usr/local/bin/sonic-cfggen -d -t /usr/share/sonic/device/x86_64-dell_z9100_c2538-r0/Force10-Z9100-C32/qos.json.j2 -y /etc/sonic/sonic_version.yml >/tmp/qos.json + Running command: /usr/local/bin/sonic-cfggen -j /tmp/buffers.json --write-to-db + Running command: /usr/local/bin/sonic-cfggen -j /tmp/qos.json --write-to-db + + In this example, it uses the buffers.json.j2 file and qos.json.j2 file from platform specific folders. + When there are no changes in the platform specific configutation files, they internally use the file "/usr/share/sonic/templates/buffers_config.j2" and "/usr/share/sonic/templates/qos_config.j2" to generate the configuration. + ``` + +**config qos reload --ports port_list** + +This command is used to reload the default QoS configuration on a group of ports. +Typically, the default QoS configuration is in the following tables. +1) PORT_QOS_MAP +2) QUEUE +3) BUFFER_PG +4) BUFFER_QUEUE +5) BUFFER_PORT_INGRESS_PROFILE_LIST +6) BUFFER_PORT_EGRESS_PROFILE_LIST +7) CABLE_LENGTH + +If there was QoS configuration in the above tables for the ports: + + - if `--force` option is provied, the existing QoS configuration will be replaced by the default QoS configuration, + - otherwise, the command will exit with nothing updated. + +- Usage: + ``` + config qos reload --ports [,port] + ``` + +- Example: + ``` + admin@sonic:~$ sudo config qos reload --ports Ethernet0,Ethernet4 + + In this example, it updates the QoS configuration on port Ethernet0 and Ethernet4 to default. + If there was QoS configuration on the ports, the command will clear the existing QoS configuration on the port and reload to default. + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#qos) + +## sFlow + +### sFlow Show commands + +**show sflow** + +This command displays the global sFlow configuration that includes the admin state, collectors, the Agent ID and counter polling interval. + +- Usage: + ``` + show sflow + ``` + +- Example: + ``` + admin@sonic:~# show sflow + sFlow Global Information: + sFlow Admin State: up + sFlow Polling Interval: default + sFlow AgentID: lo + + 2 Collectors configured: + Name: collector_A IP addr: 10.11.46.2 UDP port: 6343 + Name: collector_lo IP addr: 127.0.0.1 UDP port: 6343 + ``` + + +**show sflow interface** + +This command displays the per-interface sflow admin status and the sampling rate. + +- Usage: + ``` + show sflow interface + ``` + +- Example: + ``` + admin@sonic:~# show sflow interface + + sFlow interface configurations + +-------------+---------------+-----------------+ + | Interface | Admin State | Sampling Rate | + +=============+===============+=================+ + | Ethernet0 | up | 4000 | + +-------------+---------------+-----------------+ + | Ethernet1 | up | 4000 | + +-------------+---------------+-----------------+ + ... + +-------------+---------------+-----------------+ + | Ethernet61 | up | 4000 | + +-------------+---------------+-----------------+ + | Ethernet62 | up | 4000 | + +-------------+---------------+-----------------+ + | Ethernet63 | up | 4000 | + +-------------+---------------+-----------------+ + + ``` + +### sFlow Config commands + +**config sflow collector add** + +This command is used to add a sFlow collector. Note that a maximum of 2 collectors is allowed. + +- Usage: + ``` + config sflow collector add [port ] + ``` + + - Parameters: + - collector-name: unique name of the sFlow collector + - ipv4-address : IP address of the collector in dotted decimal format for IPv4 + - ipv6-address : x: x: x: x::x format for IPv6 address of the collector (where :: notation specifies successive hexadecimal fields of zeros) + - port (OPTIONAL): specifies the UDP port of the collector (the range is from 0 to 65535. The default is 6343.) + +- Example: + ``` + admin@sonic:~# sudo config sflow collector add collector_A 10.11.46.2 + ``` + +**config sflow collector del** + +This command is used to delete a sFlow collector with the given name. + +- Usage: + ``` + config sflow collector del + ``` + + - Parameters: + - collector-name: unique name of the sFlow collector + +- Example: + ``` + admin@sonic:~# sudo config sflow collector del collector_A + ``` + +**config sflow agent-id** + +This command is used to add/delete the sFlow agent-id. This setting is global (applicable to both collectors) and optional. Only a single agent-id is allowed. If agent-id is not specified (with this CLI), an appropriate IP that belongs to the switch is used as the agent-id based on some simple heuristics. + +- Usage: + ``` + config sflow agent-id + ``` + + - Parameters: + - interface-name: specify the interface name whose ipv4 or ipv6 address will be used as the agent-id in sFlow datagrams. + +- Example: + ``` + admin@sonic:~# sudo config sflow agent-id add lo + ``` + +**config sflow** + +Globally, sFlow is disabled by default. When sFlow is enabled globally, the sflow deamon is started and sampling will start on all interfaces which have sFlow enabled at the interface level (see “config sflow interface…”). When sflow is disabled globally, sampling is stopped on all relevant interfaces and sflow daemon is stopped. + +- Usage: + ``` + config sflow + ``` +- Example: + ``` + admin@sonic:~# sudo config sflow enable + ``` +**config sflow interface** + +Enable/disable sflow at an interface level. By default, sflow is enabled on all interfaces at the interface level. Use this command to explicitly disable sFlow for a specific interface. An interface is sampled if sflow is enabled globally as well as at the interface level. Note that this configuration deals only with sFlow flow samples and not counter samples. + +- Usage: + ``` + config sflow interface + ``` + + - Parameters: + - interface-name: specify the interface for which sFlow flow samples have to be enabled/disabled. The “all” keyword is used as a convenience to enable/disable sflow at the interface level for all the interfaces. + +- Example: + ``` + admin@sonic:~# sudo config sflow interface disable Ethernet40 + ``` + +**config sflow interface sample-rate** + +Configure the sample-rate for a specific interface. + +The default sample rate for any interface is (ifSpeed / 1e6) where ifSpeed is in bits/sec. So, the default sample rate based on interface speed is: + + 1-in-1000 for a 1G link + 1-in-10,000 for a 10G link + 1-in-40,000 for a 40G link + 1-in-50,000 for a 50G link + 1-in-100,000 for a 100G link + +It is recommended not to change the defaults. This CLI is to be used only in case of exceptions (e.g., to set the sample-rate to the nearest power-of-2 if there are hardware restrictions in using the defaults) + +- Usage: + ``` + config sflow interface sample-rate + ``` + + - Parameters: + - interface-name: specify the interface for which the sampling rate value is to be set + - value: value is the average number of packets skipped before the sample is taken. "The sampling rate specifies random sampling probability as the ratio of packets observed to samples generated. For example a sampling rate of 256 specifies that, on average, 1 sample will be generated for every 256 packets observed." Valid range 256:8388608. + +- Example: + ``` + admin@sonic:~# sudo config sflow interface sample-rate Ethernet32 1000 + ``` +**config sflow polling-interval** + +This command is used to set the counter polling interval. Default is 20 seconds. + +- Usage: + ``` + config sflow polling-interval + ``` + + - Parameters: + - value: 0-300 seconds. Set polling-interval to 0 to disable counter polling + +- Example: + ``` + admin@sonic:~# sudo config sflow polling-interval 30 + ``` + + +Go Back To [Beginning of the document](#) or [Beginning of this section](#sflow) + +## SNMP + +### SNMP Show commands + +**show runningconfiguration snmp** + +This command displays the global SNMP configuration that includes the location, contact, community, and user settings. + +- Usage: + ``` + show runningconfiguration snmp + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration snmp + Location + ------------ + Emerald City + + + SNMP_CONTACT SNMP_CONTACT_EMAIL + -------------- -------------------- + joe joe@contoso.com + + + Community String Community Type + ------------------ ---------------- + Jack RW + + + User Permission Type Type Auth Type Auth Password Encryption Type Encryption Password + ------ ----------------- ------ ----------- --------------- ----------------- --------------------- + Travis RO Priv SHA TravisAuthPass AES TravisEncryptPass + ``` + +**show runningconfiguration snmp location** + +This command displays the SNMP location setting. + +- Usage: + ``` + show runningconfiguration snmp location + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration snmp location + Location + ------------ + Emerald City + ``` + +- Usage: + ``` + show runningconfiguration snmp location --json + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration snmp location --json + {'Location': 'Emerald City'} + ``` + +**show runningconfiguration snmp contact** + +This command displays the SNMP contact setting. + +- Usage: + ``` + show runningconfiguration snmp contact + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration snmp contact + Contact Contact Email + --------- --------------- + joe joe@contoso.com + ``` + +- Usage: + ``` + show runningconfiguration snmp contact --json + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration snmp contact --json + {'joe': 'joe@contoso.com'} + ``` + +**show runningconfiguration snmp community** + +This command display the SNMP community settings. + +- Usage: + ``` + show runningconfiguration snmp community + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration snmp community + Community String Community Type + ------------------ ---------------- + Jack RW + ``` + +- Usage: + ``` + show runningconfiguration snmp community --json + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration snmp community --json + {'Jack': {'TYPE': 'RW'}} + ``` + +**show runningconfiguration snmp user** + +This command display the SNMP user settings. + +- Usage: + ``` + show runningconfiguration snmp user + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration snmp user + User Permission Type Type Auth Type Auth Password Encryption Type Encryption Password + ------ ----------------- ------ ----------- --------------- ----------------- --------------------- + Travis RO Priv SHA TravisAuthPass AES TravisEncryptPass + ``` + +- Usage: + ``` + show runningconfiguration snmp user --json + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration snmp user --json + {'Travis': {'SNMP_USER_TYPE': 'Priv', 'SNMP_USER_PERMISSION': 'RO', 'SNMP_USER_AUTH_TYPE': 'SHA', 'SNMP_USER_AUTH_PASSWORD': 'TravisAuthPass', 'SNMP_USER_ENCRYPTION_TYPE': 'AES', 'SNMP_USER_ENCRYPTION_PASSWORD': 'TravisEncryptPass'}} + ``` + + +### SNMP Config commands + +This sub-section explains how to configure SNMP. + +**config snmp location add/del/modify** + +This command is used to add, delete, or modify the SNMP location. + +- Usage: + ``` + config snmp location (add | del | modify) + ``` + +- Example (Add new SNMP location "Emerald City" if it does not already exist): + ``` + admin@sonic:~$ sudo config snmp location add Emerald City + SNMP Location Emerald City has been added to configuration + Restarting SNMP service... + ``` + +- Example (Delete SNMP location "Emerald City" if it already exists): + ``` + admin@sonic:~$ sudo config snmp location del Emerald City + SNMP Location Emerald City removed from configuration + Restarting SNMP service... + ``` + +- Example (Modify SNMP location "Emerald City" to "Redmond"): + ``` + admin@sonic:~$ sudo config snmp location modify Redmond + SNMP location Redmond modified in configuration + Restarting SNMP service... + ``` + +**config snmp contact add/del/modify** + +This command is used to add, delete, or modify the SNMP contact. + +- Usage: + ``` + config snmp contact add + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmp contact add joe joe@contoso.com + Contact name joe and contact email joe@contoso.com have been added to configuration + Restarting SNMP service... + ``` + +- Usage: + ``` + config snmp contact del + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmp contact del joe + SNMP contact joe removed from configuration + Restarting SNMP service... + ``` + +- Usage: + ``` + config snmp contact modify + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmp contact modify test test@contoso.com + SNMP contact test and contact email test@contoso.com updated + Restarting SNMP service... + ``` + +**config snmp community add/del/replace** + +This command is used to add, delete, or replace the SNMP community. + +- Usage: + ``` + config snmp community add (RO | RW) + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmp community add testcomm ro + SNMP community testcomm added to configuration + Restarting SNMP service... + ``` + +- Usage: + ``` + config snmp community del + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmp community del testcomm + SNMP community testcomm removed from configuration + Restarting SNMP service... + ``` + +- Usage: + ``` + config snmp community replace + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmp community replace testcomm newtestcomm + SNMP community newtestcomm added to configuration + SNMP community newtestcomm replace community testcomm + Restarting SNMP service... + ``` + +**config snmp user add/del** + +This command is used to add or delete the SNMP user for SNMPv3. + +- Usage: + ``` + config snmp user add (noAuthNoPriv | AuthNoPriv | Priv) (RO | RW) [[(MD5 | SHA | MMAC-SHA-2) ] [(DES |AES) ]] + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmp user add testuser1 noauthnopriv ro + SNMP user testuser1 added to configuration + Restarting SNMP service... + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmp user add testuser2 authnopriv ro sha testuser2_auth_pass + SNMP user testuser2 added to configuration + Restarting SNMP service... + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmp user add testuser3 priv rw md5 testuser3_auth_pass aes testuser3_encrypt_pass + SNMP user testuser3 added to configuration + Restarting SNMP service... + ``` + +- Usage: + ``` + config snmp user del + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmp user del testuser1 + SNMP user testuser1 removed from configuration + Restarting SNMP service... + ``` + +## Startup & Running Configuration + +### Startup Configuration + +**show startupconfiguration bgp** + +This command is used to display the startup configuration for the BGP module. + +- Usage: + ``` + show startupconfiguration bgp + ``` + +- Example: + ``` + admin@sonic:~$ show startupconfiguration bgp + Routing-Stack is: quagga + ! + ! =========== Managed by sonic-cfggen DO NOT edit manually! ==================== + ! generated by templates/quagga/bgpd.conf.j2 with config DB data + ! file: bgpd.conf + ! + ! + hostname T1-2 + password zebra + log syslog informational + log facility local4 + ! enable password ! + ! + ! bgp multiple-instance + ! + route-map FROM_BGP_SPEAKER_V4 permit 10 + ! + route-map TO_BGP_SPEAKER_V4 deny 10 + ! + router bgp 65000 + bgp log-neighbor-changes + bgp bestpath as-path multipath-relax + no bgp default ipv4-unicast + bgp graceful-restart restart-time 180 + + + ``` + +### Running Configuration +This sub-section explains the show commands for displaying the running configuration for the following modules. +1) bgp +2) interfaces +3) ntp +4) snmp +5) all +6) acl +7) ports +8) syslog + +**show runningconfiguration all** + +This command displays the entire running configuration. + +- Usage: + ``` + show runningconfiguration all + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration all + ``` + +**show runningconfiguration bgp** + +This command displays the running configuration of the BGP module. + +- Usage: + ``` + show runningconfiguration bgp + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration bgp + ``` + +**show runningconfiguration interfaces** + +This command displays the running configuration for the "interfaces". + +- Usage: + ``` + show runningconfiguration interfaces + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration interfaces + ``` + +**show runningconfiguration ntp** + +This command displays the running configuration of the ntp module. + +- Usage: + ``` + show runningconfiguration ntp + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration ntp + NTP Servers + ------------- + 1.1.1.1 + 2.2.2.2 + ``` + +**show runningconfiguration syslog** + +This command displays the running configuration of the syslog module. + +- Usage: + ``` + show runningconfiguration syslog + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration syslog + Syslog Servers + ---------------- + 4.4.4.4 + 5.5.5.5 + ``` + + +**show runningconfiguration snmp** + +This command displays the running configuration of the snmp module. + +- Usage: + ``` + show runningconfiguration snmp + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration snmp + ``` + +**show runningconfiguration acl** + + This command displays the running configuration of the acls + +- Usage: + ``` + show runningconfiguration acl + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration acl + ``` + + **show runningconfiguration ports** + + This command displays the running configuration of the ports + +- Usage: + ``` + show runningconfiguration ports [] + ``` + +- Examples: + ``` + admin@sonic:~$ show runningconfiguration ports + ``` + + ``` + admin@sonic:~$ show runningconfiguration ports Ethernet0 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#Startup--Running-Configuration) + + +## Static routing + +### Static routing Config Commands + +This sub-section explains of commands is used to add or remove the static route. + +**config route add** + +This command is used to add a static route. Note that prefix /nexthop vrf`s and interface name are optional. + +- Usage: + + ``` + config route add prefix [vrf ] nexthop [vrf ] dev + ``` + +- Example: + + ``` + admin@sonic:~$ config route add prefix 2.2.3.4/32 nexthop 30.0.0.9 + admin@sonic:~$ config route add prefix 4.0.0.0/24 nexthop dev Ethernet32.10 + ``` + +It also supports ECMP, and adding a new nexthop to the existing prefix will complement it and not overwrite them. + +- Example: + + ``` + admin@sonic:~$ sudo config route add prefix 2.2.3.4/32 nexthop vrf Vrf-RED 30.0.0.9 + admin@sonic:~$ sudo config route add prefix 2.2.3.4/32 nexthop vrf Vrf-BLUE 30.0.0.10 + ``` + +**config route del** + +This command is used to remove a static route. Note that prefix /nexthop vrf`s and interface name are optional. + +- Usage: + + ``` + config route del prefix [vrf ] nexthop [vrf ] dev + ``` + +- Example: + + ``` + admin@sonic:~$ sudo config route del prefix 2.2.3.4/32 nexthop vrf Vrf-RED 30.0.0.9 + admin@sonic:~$ sudo config route del prefix 2.2.3.4/32 nexthop vrf Vrf-BLUE 30.0.0.10 + ``` + +This sub-section explains of command is used to show current routes. + +**show ip route** + +- Usage: + + ``` + show ip route + ``` + +- Example: + + ``` + admin@sonic:~$ show ip route + Codes: K - kernel route, C - connected, S - static, R - RIP, + O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, + T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, + F - PBR, f - OpenFabric, + > - selected route, * - FIB route, q - queued, r - rejected, b - backup + + S>* 0.0.0.0/0 [200/0] via 192.168.111.3, eth0, weight 1, 3d03h58m + S> 1.2.3.4/32 [1/0] via 30.0.0.7, weight 1, 00:00:06 + C>* 10.0.0.18/31 is directly connected, Ethernet36, 3d03h57m + C>* 10.0.0.20/31 is directly connected, Ethernet40, 3d03h57m + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#static-routing) + +## Subinterfaces + +### Subinterfaces Show Commands + +**show subinterfaces status** + +This command displays all the subinterfaces that are configured on the device and its current status. + +- Usage: +``` +show subinterfaces status +``` + +- Example: +``` +admin@sonic:~$ show subinterfaces status +Sub port interface Speed MTU Vlan Admin Type +------------------ ------- ----- ------ ------- ------------------- + Eth64.10 100G 9100 100 up dot1q-encapsulation + Ethernet0.100 100G 9100 100 up dot1q-encapsulation +``` + +### Subinterfaces Config Commands + +This sub-section explains how to configure subinterfaces. + +**config subinterface** + +- Usage: +``` +config subinterface (add | del) [vlan <1-4094>] +``` + +- Example (Create the subinterfces with name "Ethernet0.100"): +``` +admin@sonic:~$ sudo config subinterface add Ethernet0.100 +``` + +- Example (Create the subinterfces with name "Eth64.100"): +``` +admin@sonic:~$ sudo config subinterface add Eth64.100 100 +``` + +- Example (Delete the subinterfces with name "Ethernet0.100"): +``` +admin@sonic:~$ sudo config subinterface del Ethernet0.100 +``` + +- Example (Delete the subinterfces with name "Eth64.100"): +``` +admin@sonic:~$ sudo config subinterface del Eth64.100 100 +``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#static-routing) + +## Syslog + +### Syslog Config Commands + +This sub-section of commands is used to add or remove the configured syslog servers. + +**config syslog add** + +This command is used to add a SYSLOG server to the syslog server list. Note that more that one syslog server can be added in the device. + +- Usage: + ``` + config syslog add + ``` + +- Example: + ``` + admin@sonic:~$ sudo config syslog add 1.1.1.1 + Syslog server 1.1.1.1 added to configuration + Restarting rsyslog-config service... + ``` + +**config syslog delete** + +This command is used to delete the syslog server configured. + +- Usage: + ``` + config syslog del + ``` + +- Example: + ``` + admin@sonic:~$ sudo config syslog del 1.1.1.1 + Syslog server 1.1.1.1 removed from configuration + Restarting rsyslog-config service... + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#syslog) + +## System State + +### Processes + +This command is used to determine the CPU utilization. It also lists the active processes along with their corresponding process ID and other relevant parameters. + +This sub-section explains the various "processes" specific data that includes the following. +1) cpu Show processes CPU info +2) memory Show processes memory info +3) summary Show processes info + +“show processes” commands provide a wrapper over linux’s “top” command. “show process cpu” sorts the processes being displayed by cpu-utilization, whereas “show process memory” does it attending to processes’ memory-utilization. + +**show processes cpu** + +This command displays the current CPU usage by process. This command uses linux's "top -bn 1 -o %CPU" command to display the output. + +- Usage: + ``` + show processes cpu + ``` + +*TIP: Users can pipe the output to "head" to display only the "n" number of lines (e.g., `show processes cpu | head -n 10`)* + +- Example: + ``` + admin@sonic:~$ show processes cpu + top - 23:50:08 up 1:18, 1 user, load average: 0.25, 0.29, 0.25 + Tasks: 161 total, 1 running, 160 sleeping, 0 stopped, 0 zombie + %Cpu(s): 3.8 us, 1.0 sy, 0.0 ni, 95.1 id, 0.1 wa, 0.0 hi, 0.0 si, 0.0 st + KiB Mem: 8181216 total, 1161060 used, 7020156 free, 105656 buffers + KiB Swap: 0 total, 0 used, 0 free. 557560 cached Mem + + PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND + 2047 root 20 0 683772 109288 39652 S 23.8 1.3 7:44.79 syncd + 1351 root 20 0 43360 5616 2844 S 11.9 0.1 1:41.56 redis-server + 10093 root 20 0 21944 2476 2088 R 5.9 0.0 0:00.03 top + 1 root 20 0 28992 5508 3236 S 0.0 0.1 0:06.42 systemd + 2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd + 3 root 20 0 0 0 0 S 0.0 0.0 0:00.56 ksoftirqd/0 + 5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H + ... + ``` + +*TIP: Advanced users can view individual processes using variations of the `ps` command (e.g., `ps -ax | grep `)* + +**show processes memory** + +This command displays the current memory usage by processes. This command uses linux's "top -bn 1 -o %MEM" command to display the output. + +- Usage: + ``` + show processes memory + ``` + +*NOTE that pipe option can be used using " | head -n" to display only the "n" number of lines* + +- Example: + ``` + admin@sonic:~$ show processes memory + top - 23:41:24 up 7 days, 39 min, 2 users, load average: 1.21, 1.19, 1.18 + Tasks: 191 total, 2 running, 189 sleeping, 0 stopped, 0 zombie + %Cpu(s): 2.8 us, 20.7 sy, 0.0 ni, 76.3 id, 0.0 wa, 0.0 hi, 0.2 si, 0.0 st + KiB Mem : 8162264 total, 5720412 free, 945516 used, 1496336 buff/cache + KiB Swap: 0 total, 0 free, 0 used. 6855632 avail Mem + + PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND + 18051 root 20 0 851540 274784 8344 S 0.0 3.4 0:02.77 syncd + 17760 root 20 0 1293428 259212 58732 S 5.9 3.2 96:46.22 syncd + 508 root 20 0 725364 76244 38220 S 0.0 0.9 4:54.49 dockerd + 30853 root 20 0 96348 56824 7880 S 0.0 0.7 0:00.98 show + 17266 root 20 0 509876 49772 30640 S 0.0 0.6 0:06.36 docker + 24891 admin 20 0 515864 49560 30644 S 0.0 0.6 0:05.54 docker + 17643 admin 20 0 575668 49428 30628 S 0.0 0.6 0:06.29 docker + 23885 admin 20 0 369552 49344 30840 S 0.0 0.6 0:05.57 docker + 18055 root 20 0 509076 49260 30296 S 0.0 0.6 0:06.36 docker + 17268 root 20 0 371120 49052 30372 S 0.0 0.6 0:06.45 docker + 1227 root 20 0 443284 48640 30100 S 0.0 0.6 0:41.91 docker + 23785 admin 20 0 443796 48552 30128 S 0.0 0.6 0:05.58 docker + 17820 admin 20 0 435088 48144 29480 S 0.0 0.6 0:06.33 docker + 506 root 20 0 1151040 43140 23964 S 0.0 0.5 8:51.08 containerd + 18437 root 20 0 84852 26388 7380 S 0.0 0.3 65:59.76 python3.6 + ``` + + +**show processes summary** + +This command displays the current summary information about all the processes + +- Usage: + ``` + show processes summary + ``` + +- Example: + ``` + admin@sonic:~$ show processes summary + PID PPID CMD %MEM %CPU + 1 0 /sbin/init 0.0 0.0 + 2 0 [kthreadd] 0.0 0.0 + 3 2 [ksoftirqd/0] 0.0 0.0 + 5 2 [kworker/0:0H] 0.0 0.0 + ... + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#System-State) + +### Services & Memory + +These commands are used to know the services that are running and the memory that is utilized currently. + + +**show services** + +This command displays the state of all the SONiC processes running inside a docker container. This helps to identify the status of SONiC’s critical processes. + +- Usage: + ``` + show services + ``` + +- Example: + ``` + admin@sonic:~$ show services + dhcp_relay docker + --------------------------- + UID PID PPID C STIME TTY TIME CMD + root 1 0 0 05:26 ? 00:00:12 /usr/bin/python /usr/bin/supervi + root 24 1 0 05:26 ? 00:00:00 /usr/sbin/rsyslogd -n + + nat docker + --------------------------- + USER PID PPID C STIME TTY TIME CMD + root 1 0 0 05:26 ? 00:00:12 /usr/bin/python /usr/bin/supervisord + root 18 1 0 05:26 ? 00:00:00 /usr/sbin/rsyslogd -n + root 23 1 0 05:26 ? 00:00:01 /usr/bin/natmgrd + root 34 1 0 05:26 ? 00:00:00 /usr/bin/natsyncd + + snmp docker + --------------------------- + UID PID PPID C STIME TTY TIME CMD + root 1 0 0 05:26 ? 00:00:16 /usr/bin/python /usr/bin/supervi + root 24 1 0 05:26 ? 00:00:02 /usr/sbin/rsyslogd -n + Debian-+ 29 1 0 05:26 ? 00:00:04 /usr/sbin/snmpd -f -LS4d -u Debi + root 31 1 1 05:26 ? 00:15:10 python3.6 -m sonic_ax_impl + + syncd docker + --------------------------- + UID PID PPID C STIME TTY TIME CMD + root 1 0 0 05:26 ? 00:00:13 /usr/bin/python /usr/bin/supervi + root 12 1 0 05:26 ? 00:00:00 /usr/sbin/rsyslogd -n + root 17 1 0 05:26 ? 00:00:00 /usr/bin/dsserve /usr/bin/syncd + root 27 17 22 05:26 ? 04:09:30 /usr/bin/syncd --diag -p /usr/sh + root 51 27 0 05:26 ? 00:00:01 /usr/bin/syncd --diag -p /usr/sh + + swss docker + --------------------------- + UID PID PPID C STIME TTY TIME CMD + root 1 0 0 05:26 ? 00:00:29 /usr/bin/python /usr/bin/supervi + root 25 1 0 05:26 ? 00:00:00 /usr/sbin/rsyslogd -n + root 30 1 0 05:26 ? 00:00:13 /usr/bin/orchagent -d /var/log/s + root 42 1 1 05:26 ? 00:12:40 /usr/bin/portsyncd -p /usr/share + root 45 1 0 05:26 ? 00:00:00 /usr/bin/intfsyncd + root 48 1 0 05:26 ? 00:00:03 /usr/bin/neighsyncd + root 59 1 0 05:26 ? 00:00:01 /usr/bin/vlanmgrd + root 92 1 0 05:26 ? 00:00:01 /usr/bin/intfmgrd + root 3606 1 0 23:36 ? 00:00:00 bash -c /usr/bin/arp_update; sle + root 3621 3606 0 23:36 ? 00:00:00 sleep 300 + + ... + ``` + +**show system-memory** + +This command displays the system-wide memory utilization information – just a wrapper over linux native “free” command + +- Usage: + ``` + show system-memory + ``` + +- Example: + ``` + admin@sonic:~$ show system-memory + Command: free -m -h + total used free shared buffers cached + Mem: 3.9G 2.0G 1.8G 33M 324M 791M + -/+ buffers/cache: 951M 2.9G + Swap: 0B 0B 0B + ``` + +**show mmu** + +This command displays virtual address to the physical address translation status of the Memory Management Unit (MMU). + +- Usage: + ``` + show mmu + ``` + +- Example: + ``` + admin@sonic:~$ show mmu + Pool: ingress_lossless_pool + ---- -------- + xoff 4194112 + type ingress + mode dynamic + size 10875072 + ---- -------- + + Pool: egress_lossless_pool + ---- -------- + type egress + mode static + size 15982720 + ---- -------- + + Pool: egress_lossy_pool + ---- ------- + type egress + mode dynamic + size 9243812 + ---- ------- + + Profile: egress_lossy_profile + ---------- ------------------------------- + dynamic_th 3 + pool [BUFFER_POOL|egress_lossy_pool] + size 1518 + ---------- ------------------------------- + + Profile: pg_lossless_100000_300m_profile + ---------- ----------------------------------- + xon_offset 2288 + dynamic_th -3 + xon 2288 + xoff 268736 + pool [BUFFER_POOL|ingress_lossless_pool] + size 1248 + ---------- ----------------------------------- + + Profile: egress_lossless_profile + --------- ---------------------------------- + static_th 3995680 + pool [BUFFER_POOL|egress_lossless_pool] + size 1518 + --------- ---------------------------------- + + Profile: pg_lossless_100000_40m_profile + ---------- ----------------------------------- + xon_offset 2288 + dynamic_th -3 + xon 2288 + xoff 177632 + pool [BUFFER_POOL|ingress_lossless_pool] + size 1248 + ---------- ----------------------------------- + + Profile: ingress_lossy_profile + ---------- ----------------------------------- + dynamic_th 3 + pool [BUFFER_POOL|ingress_lossless_pool] + size 0 + ---------- ----------------------------------- + + Profile: pg_lossless_40000_40m_profile + ---------- ----------------------------------- + xon_offset 2288 + dynamic_th -3 + xon 2288 + xoff 71552 + pool [BUFFER_POOL|ingress_lossless_pool] + size 1248 + ---------- ----------------------------------- + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#System-State) + +Go Back To [Beginning of the document](#) or [Beginning of this section](#System-Health) + +### System-Health + +These commands are used to monitor the system current running services and hardware state. + +**show system-health summary** + +This command displays the current status of 'Services' and 'Hardware' under monitoring. +If any of the elements under each of these two sections is 'Not OK' a proper message will appear under the relevant section. + +- Usage: + ``` + show system-health summary + ``` + +- Example: + ``` + admin@sonic:~$ show system-health summary + System status summary + + System status LED red + Services: + Status: Not OK + Not Running: 'telemetry', 'sflowmgrd' + Hardware: + Status: OK + ``` + ``` + admin@sonic:~$ show system-health summary + System status summary + + System status LED green + Services: + Status: OK + Hardware: + Status: OK + ``` + +**show system-health monitor-list** + +This command displays a list of all current 'Services' and 'Hardware' being monitored, their status and type. + +- Usage: + ``` + show system-health monitor-list + ``` + +- Example: + ``` + admin@sonic:~$ show system-health monitor-list + System services and devices monitor list + + Name Status Type + -------------- -------- ---------- + telemetry Not OK Process + orchagent Not OK Process + neighsyncd OK Process + vrfmgrd OK Process + dialout_client OK Process + zebra OK Process + rsyslog OK Process + snmpd OK Process + redis_server OK Process + intfmgrd OK Process + vxlanmgrd OK Process + lldpd_monitor OK Process + portsyncd OK Process + var-log OK Filesystem + lldpmgrd OK Process + syncd OK Process + sonic OK System + buffermgrd OK Process + portmgrd OK Process + staticd OK Process + bgpd OK Process + lldp_syncd OK Process + bgpcfgd OK Process + snmp_subagent OK Process + root-overlay OK Filesystem + fpmsyncd OK Process + sflowmgrd OK Process + vlanmgrd OK Process + nbrmgrd OK Process + PSU 2 OK PSU + psu_1_fan_1 OK Fan + psu_2_fan_1 OK Fan + fan11 OK Fan + fan10 OK Fan + fan12 OK Fan + ASIC OK ASIC + fan1 OK Fan + PSU 1 OK PSU + fan3 OK Fan + fan2 OK Fan + fan5 OK Fan + fan4 OK Fan + fan7 OK Fan + fan6 OK Fan + fan9 OK Fan + fan8 OK Fan + ``` + +**show system-health detail** + +This command displays the current status of 'Services' and 'Hardware' under monitoring. +If any of the elements under each of these two sections is 'Not OK' a proper message will appear under the relevant section. +In addition, displays a list of all current 'Services' and 'Hardware' being monitored and a list of ignored elements. + +- Usage: + ``` + show system-health detail + ``` + +- Example: + ``` + admin@sonic:~$ show system-health detail + System status summary + + System status LED red + Services: + Status: Not OK + Not Running: 'telemetry', 'orchagent' + Hardware: + Status: OK + + System services and devices monitor list + + Name Status Type + -------------- -------- ---------- + telemetry Not OK Process + orchagent Not OK Process + neighsyncd OK Process + vrfmgrd OK Process + dialout_client OK Process + zebra OK Process + rsyslog OK Process + snmpd OK Process + redis_server OK Process + intfmgrd OK Process + vxlanmgrd OK Process + lldpd_monitor OK Process + portsyncd OK Process + var-log OK Filesystem + lldpmgrd OK Process + syncd OK Process + sonic OK System + buffermgrd OK Process + portmgrd OK Process + staticd OK Process + bgpd OK Process + lldp_syncd OK Process + bgpcfgd OK Process + snmp_subagent OK Process + root-overlay OK Filesystem + fpmsyncd OK Process + sflowmgrd OK Process + vlanmgrd OK Process + nbrmgrd OK Process + PSU 2 OK PSU + psu_1_fan_1 OK Fan + psu_2_fan_1 OK Fan + fan11 OK Fan + fan10 OK Fan + fan12 OK Fan + ASIC OK ASIC + fan1 OK Fan + PSU 1 OK PSU + fan3 OK Fan + fan2 OK Fan + fan5 OK Fan + fan4 OK Fan + fan7 OK Fan + fan6 OK Fan + fan9 OK Fan + fan8 OK Fan + + System services and devices ignore list + + Name Status Type + ----------- -------- ------ + psu.voltage Ignored Device + ``` +Go Back To [Beginning of the document](#) or [Beginning of this section](#System-Health) + +## VLAN & FDB + +### VLAN + +#### VLAN show commands + +**show vlan brief** + +This command displays brief information about all the vlans configured in the device. It displays the vlan ID, IP address (if configured for the vlan), list of vlan member ports, whether the port is tagged or in untagged mode, the DHCP Helper Address, and the proxy ARP status + +- Usage: + ``` + show vlan brief + ``` + +- Example: + ``` + admin@sonic:~$ show vlan brief + + +-----------+--------------+-----------+----------------+-----------------------+-------------+ + | VLAN ID | IP Address | Ports | Port Tagging | DHCP Helper Address | Proxy ARP | + +===========+==============+===========+================+=======================+=============+ + | 100 | 1.1.2.2/16 | Ethernet0 | tagged | 192.0.0.1 | disabled | + | | | Ethernet4 | tagged | 192.0.0.2 | | + | | | | | 192.0.0.3 | | + +-----------+--------------+-----------+----------------+-----------------------+-------------+ + ``` + +**show vlan config** + +This command displays all the vlan configuration. + +- Usage: + ``` + show vlan config + ``` + +- Example: + ``` + admin@sonic:~$ show vlan config + Name VID Member Mode + ------- ----- --------- ------ + Vlan100 100 Ethernet0 tagged + Vlan100 100 Ethernet4 tagged + ``` + + +#### VLAN Config commands + +This sub-section explains how to configure the vlan and its member ports. + +**config vlan add/del** + +This command is used to add or delete the vlan. + +- Usage: + ``` + config vlan (add | del) + ``` + +- Example (Create the VLAN "Vlan100" if it does not already exist): + ``` + admin@sonic:~$ sudo config vlan add 100 + ``` + +**config vlan member add/del** + +This command is to add or delete a member port into the already created vlan. + +- Usage: + ``` + config vlan member add/del [-u|--untagged] + ``` + +*NOTE: Adding the -u or --untagged flag will set the member in "untagged" mode* + + +- Example: + ``` + admin@sonic:~$ sudo config vlan member add 100 Ethernet0 + This command will add Ethernet0 as member of the vlan 100 + + admin@sonic:~$ sudo config vlan member add 100 Ethernet4 + This command will add Ethernet4 as member of the vlan 100. + ``` + +**config proxy_arp enabled/disabled** + +This command is used to enable or disable proxy ARP for a VLAN interface + +- Usage: + ``` + config vlan proxy_arp enabled/disabled + ``` + +- Example: + ``` + admin@sonic:~$ sudo config vlan proxy_arp 1000 enabled + This command will enable proxy ARP for the interface 'Vlan1000' + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#vlan--FDB) + +### FDB + +#### FDB show commands + +**show mac** + +This command displays the MAC (FDB) entries either in full or partial as given below. +1) show mac - displays the full table +2) show mac -v - displays the MACs learnt on the particular VLAN ID. +3) show mac -p - displays the MACs learnt on the particular port. +4) show mac -a - display the MACs that match a specific mac-address +5) show mac -t - display the MACs that match a specific type (static/dynamic) +6) show mac -c - display the count of MAC addresses + +To show the default MAC address aging time on the switch. + +- Usage: + ``` + show mac [-v ] [-p ] [-a ] [-t ] [-c] + ``` + +- Example: + ``` + admin@sonic:~$ show mac + No. Vlan MacAddress Port Type + ----- ------ ----------------- ----------- ------- + 1 1000 E2:8C:56:85:4A:CD Ethernet192 Dynamic + 2 1000 A0:1B:5E:47:C9:76 Ethernet192 Dynamic + 3 1000 AA:54:EF:2C:EE:30 Ethernet192 Dynamic + 4 1000 A4:3F:F2:17:A3:FC Ethernet192 Dynamic + 5 1000 0C:FC:01:72:29:91 Ethernet192 Dynamic + 6 1000 48:6D:01:7E:C9:FD Ethernet192 Dynamic + 7 1000 1C:6B:7E:34:5F:A6 Ethernet192 Dynamic + 8 1000 EE:81:D9:7B:93:A9 Ethernet192 Dynamic + 9 1000 CC:F8:8D:BB:85:E2 Ethernet192 Dynamic + 10 1000 0A:52:B3:9C:FB:6C Ethernet192 Dynamic + 11 1000 C6:E2:72:02:D1:23 Ethernet192 Dynamic + 12 1000 8A:C9:5C:25:E9:28 Ethernet192 Dynamic + 13 1000 5E:CD:34:E4:94:18 Ethernet192 Dynamic + 14 1000 7E:49:1F:B5:91:B5 Ethernet192 Dynamic + 15 1000 AE:DD:67:F3:09:5A Ethernet192 Dynamic + 16 1000 DC:2F:D1:08:4B:DE Ethernet192 Dynamic + 17 1000 50:96:23:AD:F1:65 Ethernet192 Static + 18 1000 C6:C9:5E:AE:24:42 Ethernet192 Static + Total number of entries 18 + ``` + +Optionally, you can specify a VLAN ID or interface name or type or mac-address in order to display only that particular entries + +- Examples: + ``` + admin@sonic:~$ show mac -v 1000 + No. Vlan MacAddress Port Type + ----- ------ ----------------- ----------- ------- + 1 1000 E2:8C:56:85:4A:CD Ethernet192 Dynamic + 2 1000 A0:1B:5E:47:C9:76 Ethernet192 Dynamic + 3 1000 AA:54:EF:2C:EE:30 Ethernet192 Dynamic + 4 1000 A4:3F:F2:17:A3:FC Ethernet192 Dynamic + 5 1000 0C:FC:01:72:29:91 Ethernet192 Dynamic + 6 1000 48:6D:01:7E:C9:FD Ethernet192 Dynamic + 7 1000 1C:6B:7E:34:5F:A6 Ethernet192 Dynamic + 8 1000 EE:81:D9:7B:93:A9 Ethernet192 Dynamic + 9 1000 CC:F8:8D:BB:85:E2 Ethernet192 Dynamic + 10 1000 0A:52:B3:9C:FB:6C Ethernet192 Dynamic + 11 1000 C6:E2:72:02:D1:23 Ethernet192 Dynamic + 12 1000 8A:C9:5C:25:E9:28 Ethernet192 Dynamic + 13 1000 5E:CD:34:E4:94:18 Ethernet192 Dynamic + 14 1000 7E:49:1F:B5:91:B5 Ethernet192 Dynamic + 15 1000 AE:DD:67:F3:09:5A Ethernet192 Dynamic + 16 1000 DC:2F:D1:08:4B:DE Ethernet192 Dynamic + 17 1000 50:96:23:AD:F1:65 Ethernet192 Static + 18 1000 C6:C9:5E:AE:24:42 Ethernet192 Static + Total number of entries 18 + ``` + ``` + admin@sonic:~$ show mac -p Ethernet192 + No. Vlan MacAddress Port Type + ----- ------ ----------------- ----------- ------- + 1 1000 E2:8C:56:85:4A:CD Ethernet192 Dynamic + 2 1000 A0:1B:5E:47:C9:76 Ethernet192 Dynamic + 3 1000 AA:54:EF:2C:EE:30 Ethernet192 Dynamic + 4 1000 A4:3F:F2:17:A3:FC Ethernet192 Dynamic + 5 1000 0C:FC:01:72:29:91 Ethernet192 Dynamic + 6 1000 48:6D:01:7E:C9:FD Ethernet192 Dynamic + 7 1000 1C:6B:7E:34:5F:A6 Ethernet192 Dynamic + 8 1000 EE:81:D9:7B:93:A9 Ethernet192 Dynamic + 9 1000 CC:F8:8D:BB:85:E2 Ethernet192 Dynamic + 10 1000 0A:52:B3:9C:FB:6C Ethernet192 Dynamic + 11 1000 C6:E2:72:02:D1:23 Ethernet192 Dynamic + 12 1000 8A:C9:5C:25:E9:28 Ethernet192 Dynamic + 13 1000 5E:CD:34:E4:94:18 Ethernet192 Dynamic + 14 1000 7E:49:1F:B5:91:B5 Ethernet192 Dynamic + 15 1000 AE:DD:67:F3:09:5A Ethernet192 Dynamic + 16 1000 DC:2F:D1:08:4B:DE Ethernet192 Dynamic + 17 1000 50:96:23:AD:F1:65 Ethernet192 Static + 18 1000 C6:C9:5E:AE:24:42 Ethernet192 Static + Total number of entries 18 + ``` + ``` + admin@sonic:~$ show mac -a E2:8C:56:85:4A:CD + No. Vlan MacAddress Port Type + ----- ------ ----------------- ----------- ------- + 1 1000 E2:8C:56:85:4A:CD Ethernet192 Dynamic + Total number of entries 1 + ``` + ``` + admin@sonic:~$ show mac -t Static + No. Vlan MacAddress Port Type + ----- ------ ----------------- ----------- ------- + 2 1000 50:96:23:AD:F1:65 Ethernet192 Static + 2 1000 C6:C9:5E:AE:24:42 Ethernet192 Static + Total number of entries 2 + ``` + ``` + admin@sonic:~$ show mac -c + Total number of entries 18 + ``` + +**show mac aging-time** + +This command displays the default mac aging time on the switch + + ``` + admin@sonic:~$ show mac aging-time + Aging time for switch is 600 seconds + ``` + +**sonic-clear fdb all** + +Clear the FDB table + +- Usage: + ``` + sonic-clear fdb all + ``` +- Example: + ``` + admin@sonic:~$ sonic-clear fdb all + FDB entries are cleared. + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#vlan--FDB) + +## VxLAN & Vnet + +### VxLAN + +#### VxLAN show commands + +**show vxlan tunnel** + +This command displays brief information about all the vxlans configured in the device. It displays the vxlan tunnel name, source IP address, destination IP address (if configured), tunnel map name and mapping. + +- Usage: + + ``` + show vxlan tunnel + ``` + +- Example: + + ``` + admin@sonic:~$ show vxlan tunnel + vxlan tunnel name source ip destination ip tunnel map name tunnel map mapping(vni -> vlan) + ------------------- ----------- ---------------- ----------------- --------------------------------- + tunnel1 10.10.10.10 + tunnel2 10.10.10.10 20.10.10.10 tmap1 1234 -> 100 + tunnel3 10.10.10.10 30.10.10.10 tmap2 1235 -> 200 + ``` + +**show vxlan name ** + +This command displays configuration. + +- Usage: + + ``` + show vxlan name + ``` + +- Example: + + ``` + admin@sonic:~$ show vxlan name tunnel3 + vxlan tunnel name source ip destination ip tunnel map name tunnel map mapping(vni -> vlan) + ------------------- ----------- ---------------- ----------------- --------------------------------- + tunnel3 10.10.10.10 30.10.10.10 tmap2 1235 -> 200 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#vxlan--vnet) + +### Vnet + +#### Vnet show commands + +**show vnet brief** + +This command displays brief information about all the vnets configured in the device. It displays the vnet name, vxlan tunnel name, vni and peer list (if configured). + +- Usage: + + ``` + show vnet brief + ``` + +- Example: + + ``` + admin@sonic:~$ show vnet brief + vnet name vxlan tunnel vni peer list + ----------- -------------- ----- ------------------ + Vnet_2000 tunnel1 2000 + Vnet_3000 tunnel1 3000 Vnet_2000,Vnet4000 + ``` + +**show vnet endpoint ** + +This command displays the list or vxlan tunnel endpoints and their status. In addition it also shows the number of prefixes associated with each endpoints in the tunnels. If an IP address of an endpoint is provided, this command also shows the associated prefixes a well. + +- Usage: + + ``` + show vnet endpoint + + ``` + +- Example: + + ``` + admin@sonic:~$ show vnet endpoint + Endpoint prefix count status + --------------------- -------------- -------- + fddd:a100:a251::a10:1 1 Down + fddd:a101:a251::a10:1 1 Up + 100.251.7.1 3 Up + + or + + admin@sonic:~$ show vnet endpoint fddd:a101:a251::a10:1 + Endpoint prefix status + --------------------- ---------------------------- -------- + fddd:a101:a251::a10:1 ['fddd:a150:a251::a6:1/128'] Up + + or + + admin@sonic:~$ show vnet endpoint 100.251.7.1 + Endpoint prefix status + ----------- --------------------------------------------------------- -------- + 100.251.7.1 ['160.62.191.1/32', '160.63.191.1/32', '160.64.191.1/32'] Up + ``` + +**show vnet name ** + +This command displays brief information about configured in the device. + +- Usage: + + ``` + show vnet name + ``` + +- Example: + + ``` + admin@sonic:~$ show vnet name Vnet_3000 + vnet name vxlan tunnel vni peer list + ----------- -------------- ----- ------------------ + Vnet_3000 tunnel1 3000 Vnet_2000,Vnet4000 + ``` + +**show vnet interfaces** + +This command displays vnet interfaces information about all the vnets configured in the device. + +- Usage: + + ``` + show vnet interfaces + ``` + +- Example: + + ``` + admin@sonic:~$ show vnet interfaces + vnet name interfaces + ----------- ------------ + Vnet_2000 Ethernet1 + Vnet_3000 Vlan2000 + ``` + +**show vnet neighbors** + +This command displays vnet neighbor information about all the vnets configured in the device. It displays the vnet name, neighbor IP address, neighbor mac address (if configured) and interface. + +- Usage: + + ``` + show vnet neighbors + ``` + +- Example: + + ``` + admin@sonic:~$ show vnet neighbors + Vnet_2000 neighbor mac_address interfaces + ----------- ----------- ------------- ------------ + 11.11.11.11 Ethernet1 + 11.11.11.12 Ethernet1 + + Vnet_3000 neighbor mac_address interfaces + ----------- ----------- ----------------- ------------ + 20.20.20.20 aa:bb:cc:dd:ee:ff Vlan2000 + ``` + +**show vnet routes all** + +This command displays all routes information about all the vnets configured in the device. It also shows the status of the routes which may or may not be active. + +- Usage: + + ``` + show vnet routes all + ``` + +- Example: + + ``` + admin@sonic:~$ show vnet routes all + vnet name prefix nexthop interface + ----------- -------------- --------- ----------- + Vnet_2000 100.100.3.0/24 Ethernet52 + Vnet_3000 100.100.4.0/24 Vlan2000 + + vnet name prefix endpoint mac address vni status + ----------- -------------- ---------- ----------------- ----- ------- + Vnet_2000 100.100.1.1/32 10.10.10.1 active + Vnet_3000 100.100.2.1/32 10.10.10.2 00:00:00:00:03:04 inactive + Vnet_3000 100.100.2.3/32 10.10.10.6 00:00:00:00:03:04 + ``` + +**show vnet routes tunnel** + +This command displays tunnel routes information about all the vnets configured in the device. + +- Usage: + + ``` + show vnet routes tunnel + ``` + +- Example: + + ``` + admin@sonic:~$ show vnet routes tunnel + vnet name prefix endpoint mac address vni + ----------- -------------- ---------- ----------------- ----- + Vnet_2000 100.100.1.1/32 10.10.10.1 + Vnet_3000 100.100.2.1/32 10.10.10.2 00:00:00:00:03:04 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#vxlan--vnet) + +## Warm Reboot + +warm-reboot command initiates a warm reboot of the device. + +warm-reboot command doesn't require setting warm restart configuration. The +command will setup everything needed to perform warm reboot. + +This command requires root privilege. + +- Usage: + ``` + warm-reboot [-h|-?|-v|-f|-r|-k|-x|-c |-s|-D] + ``` + +- Parameters: + ``` + -h,-? : get this help + -v : turn on verbose mode + -f : force execution + -r : reboot with /sbin/reboot + -k : reboot with /sbin/kexec -e [default] + -x : execute script with -x flag + -c : specify control plane assistant IP list + -s : strict mode: do not proceed without: + - control plane assistant IP list. + -D : detached mode - closing terminal will not cause stopping reboot + ``` + +- Example: + ``` + admin@sonic:~$ sudo warm-reboot -v + Tue Oct 22 23:20:53 UTC 2019 Pausing orchagent ... + Tue Oct 22 23:20:53 UTC 2019 Stopping radv ... + Tue Oct 22 23:20:54 UTC 2019 Stopping bgp ... + Tue Oct 22 23:20:54 UTC 2019 Stopped bgp ... + Tue Oct 22 23:20:57 UTC 2019 Initialize pre-shutdown ... + Tue Oct 22 23:20:58 UTC 2019 Requesting pre-shutdown ... + Tue Oct 22 23:20:58 UTC 2019 Waiting for pre-shutdown ... + Tue Oct 22 23:20:59 UTC 2019 Pre-shutdown succeeded ... + Tue Oct 22 23:20:59 UTC 2019 Backing up database ... + Tue Oct 22 23:21:00 UTC 2019 Stopping teamd ... + Tue Oct 22 23:21:00 UTC 2019 Stopped teamd ... + Tue Oct 22 23:21:00 UTC 2019 Stopping syncd ... + Tue Oct 22 23:21:11 UTC 2019 Stopped syncd ... + Tue Oct 22 23:21:11 UTC 2019 Stopping all remaining containers ... + Tue Oct 22 23:21:13 UTC 2019 Stopped all remaining containers ... + Tue Oct 22 23:21:15 UTC 2019 Rebooting with /sbin/kexec -e to SONiC-OS-20191021.01 ... + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#Warm-Reboot) + +## Warm Restart + +Besides device level warm reboot, SONiC also provides docker based warm restart. This feature is currently supported by following dockers: BGP, teamD, and SWSS. A user can manage to restart a particular docker, with no interruption on packet forwarding and no effect on other services. This helps to reduce operational costs as well as development efforts. For example, to fix a bug in BGP routing stack, only the BGP docker image needs to be built, tested and upgraded. + +To achieve uninterrupted packet forwarding during the restarting stage and database reconciliation at the post restarting stage, warm restart enabled dockers with adjacency state machine facilitate standardized protocols. For example, a BGP restarting switch must have BGP "Graceful Restart" enabled, and its BGP neighbors must be "Graceful Restart Helper Capable", as specified in [IETF RFC4724](https://tools.ietf.org/html/rfc4724). + +Before warm restart BGP docker, the following BGP commands should be enabled: + ``` + bgp graceful-restart + bgp graceful-restart preserve-fw-state + ``` +In current SONiC release, the above two commands are enabled by default. + +It should be aware that during a warm restart, certain BGP fast convergence feature and black hole avoidance feature should either be disabled or be set to a lower preference to avoid conflicts with BGP graceful restart. + +For example, BGP BFD could be disabled via: + + ``` + no neighbor bfd + ``` + +otherwise, the fast failure detection would cause packet drop during warm reboot. + +Another commonly deployed blackhole avoidance feature: dynamic route priority adjustment, could be disabled via: + + ``` + no bgp max-med on-peerup + ``` + +to avoid large routes churn during BGP restart. + + +### Warm Restart show commands + +**show warm_restart config** + +This command displays all the configuration related to warm_restart. + +- Usage: + ``` + show warm_restart config + ``` + +- Example: + ``` + admin@sonic:~$ show warm_restart config + name enable timer_name timer_duration + ------ -------- ---------------- ---------------- + bgp true bgp_timer 100 + teamd false teamsyncd_timer 300 + swss false neighsyncd_timer 200 + system true NULL NULL + ``` + +**show warm_restart state** + +This command displays the warm_restart state. + +- Usage: + ``` + show warm_restart state + ``` + +- Example: + ``` + admin@sonic:~$ show warm_restart state + name restore_count state + ---------- --------------- ---------- + orchagent 0 + vlanmgrd 0 + bgp 1 reconciled + portsyncd 0 + teammgrd 1 + neighsyncd 0 + teamsyncd 1 + syncd 0 + natsyncd 0 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#warm-restart) + +### Warm Restart Config commands + +This sub-section explains the various configuration related to warm restart feature. Following parameters can be configured using this command. +1) bgp_timer +2) disable +3) enable +4) neighsyncd_timer +5) teamsyncd_timer +Each of these sub-commands are explained in the following section. + +Users can use an optional parameter "-s" to use the unix domain socket for communicating with the RedisDB which will be faster when compared to using the default network sockets. +All these commands have the following option. + +Options: + -s, --redis-unix-socket-path TEXT + unix socket path for redis connection + + +**config warm_restart bgp_timer** + +This command is used to set the bgp_timer value for warm_restart of BGP service. +bgp_timer holds the time interval utilized by fpmsyncd during warm-restart episodes. +During this interval fpmsyncd will recover all the routing state previously pushed to AppDB, as well as all the new state coming from zebra/bgpd. +Upon expiration of this timer, fpmsyncd will execute the reconciliation logic to eliminate all the stale entries from AppDB. +This timer should match the BGP-GR restart-timer configured within the elected routing-stack. +Supported range: 1-3600. + +- Usage: + ``` + config warm_restart [-s|--redis-unix-socket-path ] bgp_timer + ``` + + - Parameters: + - seconds: Range from 1 to 3600 + +- Example: + ``` + admin@sonic:~$ sudo config warm_restart bgp_timer 1000 + ``` + +**config warm_restart enable/disable** + +This command is used to enable or disable the warm_restart for a particular service that supports warm reboot. +Following four services support warm reboot. When user restarts the particular service using "systemctl restart ", this configured value will be checked for whether it is enabled or disabled. +If this configuration is enabled for that service, it will perform warm reboot for that service. Otherwise, it will do cold restart of the service. + +- Usage: + ``` + config warm_restart [-s|--redis-unix-socket-path ] enable [] + ``` + + - Parameters: + - module_name: Can be either system or swss or bgp or teamd. If "module_name" argument is not specified, it will enable "system" module. + +- Example (Set warm_restart as "enable" for the "system" service): + ``` + admin@sonic:~$ sudo config warm_restart enable + ``` + +- Example (Set warm_restart as "enable" for the "swss" service. When user does "systemctl restart swss", it will perform warm reboot instead of cold reboot) + ``` + admin@sonic:~$ sudo config warm_restart enable swss + ``` + +- Example (Set warm_restart as "enable" for the "teamd" service. When user does "systemctl restart teamd", it will perform warm reboot instead of cold reboot) + ``` + admin@sonic:~$ sudo config warm_restart enable teamd + ``` + + +**config warm_restart neighsyncd_timer** + +This command is used to set the neighsyncd_timer value for warm_restart of "swss" service. +neighsyncd_timer is the timer used for "swss" (neighsyncd) service during the warm restart. +Timer is started after the neighborTable is restored to internal data structures. +neighborsyncd then starts to read all Linux kernel entries and mark the entries in the data structures accordingly. +Once the timer is expired, reconciliation is done and the delta is pushed to appDB +Valid value is 1-9999. 0 is invalid. + +- Usage: + ``` + config warm_restart [-s|--redis-unix-socket-path ] neighsyncd_timer + ``` + + - Parameters: + - seconds: Range from 1 to 9999 + +- Example: + ``` + admin@sonic:~$ sudo config warm_restart neighsyncd_timer 2000 + ``` + + +**config warm_restart bgp_timer** + +This command is used to set the bgp_timer value for warm_restart of "bgp" service. +bgp_timer is the timer used for "bgp" service during the warm restart. +Timer is started after the BGP table is restored to internal data structures. +BGP services then start to read all Linux kernel entries and mark the entries in the data structures accordingly. +Once the timer is expired, reconciliation is done and the delta is pushed to appDB +Valid value is 1-9999. 0 is invalid. + +- Usage: + ``` + config warm_restart [-s|--redis-unix-socket-path ] bgp_timer + ``` + + - Parameters: + - seconds: Range from 1 to 9999 + +- Example: + ``` + admin@sonic:~$ sudo config warm_restart bgp_timer 2000 + ``` + +**config warm_restart teamsyncd_timer** + +This command is used to set the teamsyncd_timer value for warm_restart of teamd service. +teamsyncd_timer holds the time interval utilized by teamsyncd during warm-restart episodes. +The timer is started when teamsyncd starts. During the timer interval, teamsyncd will preserve all LAG interface changes, but it will not apply them. +The changes will only be applied when the timer expires. +When the changes are applied, the stale LAG entries will be removed, the new LAG entries will be created. +Supported range: 1-9999. 0 is invalid + +- Usage: + ``` + config warm_restart teamsyncd_timer + ``` + + - Parameters: + - seconds: Range from 1 to 9999 + +- Example: + ``` + admin@sonic:~$ sudo config warm_restart teamsyncd_timer 3000 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#warm-restart) + + +## Watermark + +### Watermark Show commands + +**show watermark telemetry interval** + +This command displays the configured interval for the telemetry. + +- Usage: + ``` + show watermark telemetry interval + ``` + +- Example: + ``` + admin@sonic:~$ show watermark telemetry interval + + Telemetry interval 120 second(s) + ``` + +### Watermark Config commands + +**config watermark telemetry interval** + +This command is used to configure the interval for telemetry. +The default interval is 120 seconds. +There is no regulation on the valid range of values; it leverages linux timer. + +- Usage: + ``` + config watermark telemetry interval + ``` + +- Example: + ``` + admin@sonic:~$ sudo config watermark telemetry interval 999 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#watermark) + + + +## Software Installation and Management + +SONiC images can be installed in one of two methods: +1. From within a running SONiC image using the `sonic-installer` utility +2. From the vendor's bootloader (E.g., ONIE, Aboot, etc.) + +SONiC packages are available as prebuilt Docker images and meant to be installed with the *sonic-package-manager* utility. + +### SONiC Package Manager + +The *sonic-package-manager* is a command line tool to manage (e.g. install, upgrade or uninstall) SONiC Packages. + +**sonic-package-manager list** + +This command lists all available SONiC packages, their desription, installed version and installation status. +SONiC package status can be *Installed*, *Not installed* or *Built-In*. "Built-In" status means that a feature is built-in to SONiC image and can't be upgraded or uninstalled. + +- Usage: + ``` + sonic-package-manager list + ``` + +- Example: + ``` + admin@sonic:~$ sonic-package-manager list + Name Repository Description Version Status + -------------- --------------------------- ---------------------------- --------- -------------- + cpu-report azure/cpu-report CPU report package N/A Not Installed + database docker-database SONiC database package 1.0.0 Built-In + dhcp-relay azure/docker-dhcp-relay SONiC dhcp-relay package 1.0.0 Installed + fpm-frr docker-fpm-frr SONiC fpm-frr package 1.0.0 Built-In + lldp docker-lldp SONiC lldp package 1.0.0 Built-In + macsec docker-macsec SONiC macsec package 1.0.0 Built-In + mgmt-framework docker-sonic-mgmt-framework SONiC mgmt-framework package 1.0.0 Built-In + nat docker-nat SONiC nat package 1.0.0 Built-In + pmon docker-platform-monitor SONiC pmon package 1.0.0 Built-In + radv docker-router-advertiser SONiC radv package 1.0.0 Built-In + sflow docker-sflow SONiC sflow package 1.0.0 Built-In + snmp docker-snmp SONiC snmp package 1.0.0 Built-In + swss docker-orchagent SONiC swss package 1.0.0 Built-In + syncd docker-syncd-mlnx SONiC syncd package 1.0.0 Built-In + teamd docker-teamd SONiC teamd package 1.0.0 Built-In + telemetry docker-sonic-telemetry SONiC telemetry package 1.0.0 Built-In + ``` + +**sonic-package-manager repository add** + +This command will add a new repository as source for SONiC packages to the database. *NOTE*: requires elevated (root) privileges to run + +- Usage: + ``` + Usage: sonic-package-manager repository add [OPTIONS] NAME REPOSITORY + + Add a new repository to database. + + NOTE: This command requires elevated (root) privileges to run. + + Options: + --default-reference TEXT Default installation reference. Can be a tag or + sha256 digest in repository. + --description TEXT Optional package entry description. + --help Show this message and exit. + ``` +- Example: + ``` + admin@sonic:~$ sudo sonic-package-manager repository add \ + cpu-report azure/sonic-cpu-report --default-reference 1.0.0 + ``` + +**sonic-package-manager repository remove** + +This command will remove a repository as source for SONiC packages from the database . The package has to be *Not Installed* in order to be removed from package database. *NOTE*: requires elevated (root) privileges to run + +- Usage: + ``` + Usage: sonic-package-manager repository remove [OPTIONS] NAME + + Remove repository from database. + + NOTE: This command requires elevated (root) privileges to run. + + Options: + --help Show this message and exit. + ``` +- Example: + ``` + admin@sonic:~$ sudo sonic-package-manager repository remove cpu-report + ``` + +**sonic-package-manager install** + +This command pulls and installs a package on SONiC host. *NOTE*: this command requires elevated (root) privileges to run + +- Usage: + ``` + Usage: sonic-package-manager install [OPTIONS] [PACKAGE_EXPR] + + Install/Upgrade package using [PACKAGE_EXPR] in format + "[=|@]". + + The repository to pull the package from is resolved by lookup in + package database, thus the package has to be added via "sonic- + package-manager repository add" command. + + In case when [PACKAGE_EXPR] is a package name "" this command + will install or upgrade to a version referenced by "default- + reference" in package database. + + NOTE: This command requires elevated (root) privileges to run. + + Options: + --enable Set the default state of the feature to enabled + and enable feature right after installation. NOTE: + user needs to execute "config save -y" to make + this setting persistent. + --set-owner [local|kube] Default owner configuration setting for a feature. + --from-repository TEXT Fetch package directly from image registry + repository. NOTE: This argument is mutually + exclusive with arguments: [package_expr, + from_tarball]. + --from-tarball FILE Fetch package from saved image tarball. NOTE: This + argument is mutually exclusive with arguments: + [package_expr, from_repository]. + -f, --force Force operation by ignoring package dependency + tree and package manifest validation failures. + -y, --yes Automatically answer yes on prompts. + -v, --verbosity LVL Either CRITICAL, ERROR, WARNING, INFO or DEBUG. + Default is INFO. + --skip-host-plugins Do not install host OS plugins provided by the + package (CLI, etc). NOTE: In case when package + host OS plugins are set as mandatory in package + manifest this option will fail the installation. + --allow-downgrade Allow package downgrade. By default an attempt to + downgrade the package will result in a failure + since downgrade might not be supported by the + package, thus requires explicit request from the + user. + --help Show this message and exit.. + ``` +- Example: + ``` + admin@sonic:~$ sudo sonic-package-manager install dhcp-relay=1.0.2 + ``` + ``` + admin@sonic:~$ sudo sonic-package-manager install dhcp-relay@latest + ``` + ``` + admin@sonic:~$ sudo sonic-package-manager install dhcp-relay@sha256:9780f6d83e45878749497a6297ed9906c19ee0cc48cc88dc63827564bb8768fd + ``` + ``` + admin@sonic:~$ sudo sonic-package-manager install --from-repository azure/sonic-cpu-report:latest + ``` + ``` + admin@sonic:~$ sudo sonic-package-manager install --from-tarball sonic-docker-image.gz + ``` + +**sonic-package-manager uninstall** + +This command uninstalls package from SONiC host. User needs to stop the feature prior to uninstalling it. +*NOTE*: this command requires elevated (root) privileges to run. + +- Usage: + ``` + Usage: sonic-package-manager uninstall [OPTIONS] NAME + + Uninstall package. + + NOTE: This command requires elevated (root) privileges to run. + + Options: + -f, --force Force operation by ignoring package dependency tree and + package manifest validation failures. + -y, --yes Automatically answer yes on prompts. + -v, --verbosity LVL Either CRITICAL, ERROR, WARNING, INFO or DEBUG. Default + is INFO. + --help Show this message and exit. + ``` +- Example: + ``` + admin@sonic:~$ sudo sonic-package-manager uninstall dhcp-relay + ``` + +**sonic-package-manager reset** + +This comamnd resets the package by reinstalling it to its default version. *NOTE*: this command requires elevated (root) privileges to run. + +- Usage: + ``` + Usage: sonic-package-manager reset [OPTIONS] NAME + + Reset package to the default version. + + NOTE: This command requires elevated (root) privileges to run. + + Options: + -f, --force Force operation by ignoring package dependency tree and + package manifest validation failures. + -y, --yes Automatically answer yes on prompts. + -v, --verbosity LVL Either CRITICAL, ERROR, WARNING, INFO or DEBUG. Default + is INFO. + --skip-host-plugins Do not install host OS plugins provided by the package + (CLI, etc). NOTE: In case when package host OS plugins + are set as mandatory in package manifest this option + will fail the installation. + --help Show this message and exit. + ``` +- Example: + ``` + admin@sonic:~$ sudo sonic-package-manager reset dhcp-relay + ``` + +**sonic-package-manager show package versions** + +This command will retrieve a list of all available versions for the given package from the configured upstream repository + +- Usage: + ``` + Usage: sonic-package-manager show package versions [OPTIONS] NAME + + Show available versions. + + Options: + --all Show all available tags in repository. + --plain Plain output. + --help Show this message and exit. + ``` +- Example: + ``` + admin@sonic:~$ sonic-package-manager show package versions dhcp-relay + • 1.0.0 + • 1.0.2 + • 2.0.0 + ``` + ``` + admin@sonic:~$ sonic-package-manager show package versions dhcp-relay --plain + 1.0.0 + 1.0.2 + 2.0.0 + ``` + ``` + admin@sonic:~$ sonic-package-manager show package versions dhcp-relay --all + • 1.0.0 + • 1.0.2 + • 2.0.0 + • latest + ``` + +**sonic-package-manager show package changelog** + +This command fetches the changelog from the package manifest and displays it. *NOTE*: package changelog can be retrieved from registry or read from image tarball without installing it. + +- Usage: + ``` + Usage: sonic-package-manager show package changelog [OPTIONS] [PACKAGE_EXPR] + + Show package changelog. + + Options: + --from-repository TEXT Fetch package directly from image registry + repository NOTE: This argument is mutually exclusive + with arguments: [from_tarball, package_expr]. + --from-tarball FILE Fetch package from saved image tarball NOTE: This + argument is mutually exclusive with arguments: + [package_expr, from_repository]. + --help Show this message and exit. + ``` +- Example: + ``` + admin@sonic:~$ sonic-package-manager show package changelog dhcp-relay + 1.0.0: + + • Initial release + + Author (author@email.com) Mon, 25 May 2020 12:25:00 +0300 + ``` + +**sonic-package-manager show package manifest** + +This command fetches the package manifest and displays it. *NOTE*: package manifest can be retrieved from registry or read from image tarball without installing it. + +- Usage: + ``` + Usage: sonic-package-manager show package manifest [OPTIONS] [PACKAGE_EXPR] + + Show package manifest. + + Options: + --from-repository TEXT Fetch package directly from image registry + repository NOTE: This argument is mutually exclusive + with arguments: [package_expr, from_tarball]. + --from-tarball FILE Fetch package from saved image tarball NOTE: This + argument is mutually exclusive with arguments: + [from_repository, package_expr]. + -v, --verbosity LVL Either CRITICAL, ERROR, WARNING, INFO or DEBUG + --help Show this message and exit. + ``` +- Example: + ``` + admin@sonic:~$ sonic-package-manager show package manifest dhcp-relay=2.0.0 + { + "version": "1.0.0", + "package": { + "version": "2.0.0", + "depends": [ + "database>=1.0.0,<2.0.0" + ] + }, + "service": { + "name": "dhcp_relay" + } + } + ``` + +### SONiC Installer +This is a command line tool available as part of the SONiC software; If the device is already running the SONiC software, this tool can be used to install an alternate image in the partition. +This tool has facility to install an alternate image, list the available images and to set the next reboot image. +This command requires elevated (root) privileges to run. + +**sonic-installer list** + +This command displays information about currently installed images. It displays a list of installed images, currently running image and image set to be loaded in next reboot. + +- Usage: + ``` + sonic-installer list + ``` + +- Example: + ``` + admin@sonic:~$ sudo sonic-installer list + Current: SONiC-OS-HEAD.XXXX + Next: SONiC-OS-HEAD.XXXX + Available: + SONiC-OS-HEAD.XXXX + SONiC-OS-HEAD.YYYY + ``` + +TIP: This output can be obtained without evelated privileges by running the `show boot` command. See [here](#show-system-status) for details. + +**sonic-installer install** + +This command is used to install a new image on the alternate image partition. This command takes a path to an installable SONiC image or URL and installs the image. + +- Usage: + ``` + sonic-installer install + ``` + +- Example: + ``` + admin@sonic:~$ sudo sonic-installer install https://sonic-jenkins.westus.cloudapp.azure.com/job/xxxx/job/buildimage-xxxx-all/xxx/artifact/target/sonic-xxxx.bin + New image will be installed, continue? [y/N]: y + Downloading image... + ...100%, 480 MB, 3357 KB/s, 146 seconds passed + Command: /tmp/sonic_image + Verifying image checksum ... OK. + Preparing image archive ... OK. + ONIE Installer: platform: XXXX + onie_platform: + Installing SONiC in SONiC + Installing SONiC to /host/image-xxxx + Directory /host/image-xxxx/ already exists. Cleaning up... + Archive: fs.zip + creating: /host/image-xxxx/boot/ + inflating: /host/image-xxxx/boot/vmlinuz-3.16.0-4-amd64 + inflating: /host/image-xxxx/boot/config-3.16.0-4-amd64 + inflating: /host/image-xxxx/boot/System.map-3.16.0-4-amd64 + inflating: /host/image-xxxx/boot/initrd.img-3.16.0-4-amd64 + creating: /host/image-xxxx/platform/ + extracting: /host/image-xxxx/platform/firsttime + inflating: /host/image-xxxx/fs.squashfs + inflating: /host/image-xxxx/dockerfs.tar.gz + Log file system already exists. Size: 4096MB + Installed SONiC base image SONiC-OS successfully + + Command: cp /etc/sonic/minigraph.xml /host/ + + Command: grub-set-default --boot-directory=/host 0 + + Done + ``` + +Installing a new image using the sonic-installer will keep using the packages installed on the currently running SONiC image and automatically migrate those. In order to perform clean SONiC installation use the *--skip-package-migration* option: + +- Example: + ``` + admin@sonic:~$ sudo sonic-installer install https://sonic-jenkins.westus.cloudapp.azure.com/job/xxxx/job/buildimage-xxxx-all/xxx/artifact/target/sonic-xxxx.bin --skip-package-migration + ``` + +**sonic-installer set_default** + +This command is be used to change the image which can be loaded by default in all the subsequent reboots. + +- Usage: + ``` + sonic-installer set_default + ``` + +- Example: + ``` + admin@sonic:~$ sudo sonic-installer set_default SONiC-OS-HEAD.XXXX + ``` + +**sonic-installer set_next_boot** + +This command is used to change the image that can be loaded in the *next* reboot only. Note that it will fallback to current image in all other subsequent reboots after the next reboot. + +- Usage: + ``` + sonic-installer set_next_boot + ``` + +- Example: + ``` + admin@sonic:~$ sudo sonic-installer set_next_boot SONiC-OS-HEAD.XXXX + ``` + +**sonic-installer remove** + +This command is used to remove the unused SONiC image from the disk. Note that it's *not* allowed to remove currently running image. + +- Usage: + ``` + sonic-installer remove [-y|--yes] + ``` + +- Example: + ``` + admin@sonic:~$ sudo sonic-installer remove SONiC-OS-HEAD.YYYY + Image will be removed, continue? [y/N]: y + Updating GRUB... + Done + Removing image root filesystem... + Done + Command: grub-set-default --boot-directory=/host 0 + + Image removed + ``` + +**sonic-installer cleanup** + +This command removes all unused images from the device, leaving only the currently active image and the image which will be booted into next (if different) installed. If there are no images which can be removed, the command will output `No image(s) to remove` + +- Usage: + ``` + sonic-installer cleanup [-y|--yes] + ``` + +- Example: + ``` + admin@sonic:~$ sudo sonic-installer cleanup + Remove images which are not current and next, continue? [y/N]: y + No image(s) to remove + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#software-installation-and-management) + + + +## Troubleshooting Commands + +For troubleshooting and debugging purposes, this command gathers pertinent information about the state of the device; information is as diverse as syslog entries, database state, routing-stack state, etc., It then compresses it into an archive file. This archive file can be sent to the SONiC development team for examination. +Resulting archive file is saved as `/var/dump/_YYYYMMDD_HHMMSS.tar.gz` + +- Usage: + ``` + show techsupport + ``` + +- Example: + ``` + admin@sonic:~$ show techsupport [--since=] + ``` + +If the SONiC system was running for quite some time `show techsupport` will produce a large dump file. To reduce the amount of syslog and core files gathered during system dump use `--since` option: + +- Examples: + ``` + admin@sonic:~$ show techsupport --since=yesterday # Will collect syslog and core files for the last 24 hours + ``` + ``` + admin@sonic:~$ show techsupport --since='hour ago' # Will collect syslog and core files for the last one hour + ``` + +### Debug Dumps + +In SONiC, there usually exists a set of tables related/relevant to a particular module. All of these might have to be looked at to confirm whether any configuration update is properly applied and propagated. This utility comes in handy because it prints a unified view of the redis-state for a given module + +- Usage: + ``` + Usage: dump state [OPTIONS] MODULE IDENTIFIER + Dump the redis-state of the identifier for the module specified + + Options: + -s, --show Display Modules Available + -d, --db TEXT Only dump from these Databases + -t, --table Print in tabular format [default: False] + -k, --key-map Only fetch the keys matched, don't extract field-value dumps [default: False] + -v, --verbose Prints any intermediate output to stdout useful for dev & troubleshooting [default: False] + -n, --namespace TEXT Dump the redis-state for this namespace. [default: DEFAULT_NAMESPACE] + --help Show this message and exit. + ``` + + +- Examples: + ``` + root@sonic# dump state --show + Module Identifier + -------- ------------ + port port_name + copp trap_id + ``` + + ``` + admin@sonic:~$ dump state copp arp_req --key-map --db ASIC_DB + { + "arp_req": { + "ASIC_DB": { + "keys": [ + "ASIC_STATE:SAI_OBJECT_TYPE_HOSTIF_TRAP:oid:0x22000000000c5b", + "ASIC_STATE:SAI_OBJECT_TYPE_HOSTIF_TRAP_GROUP:oid:0x11000000000c59", + "ASIC_STATE:SAI_OBJECT_TYPE_POLICER:oid:0x12000000000c5a", + "ASIC_STATE:SAI_OBJECT_TYPE_QUEUE:oid:0x15000000000626" + ], + "tables_not_found": [], + "vidtorid": { + "oid:0x22000000000c5b": "oid:0x200000000022", + "oid:0x11000000000c59": "oid:0x300000011", + "oid:0x12000000000c5a": "oid:0x200000012", + "oid:0x15000000000626": "oid:0x12e0000040015" + } + } + } + } + ``` + +### Event Driven Techsupport Invocation + +This feature/capability makes the techsupport invocation event-driven based on system events like core dump generation or low RAM availability. +This feature is only applicable for the processes running in the containers. More detailed explanation can be found in the HLD https://github.com/Azure/SONiC/blob/master/doc/auto_techsupport_and_coredump_mgmt.md + +#### config auto-techsupport global commands + +**config auto-techsupport global state** + +- Usage: + ``` + config auto-techsupport global state + ``` + +- Example: + ``` + config auto-techsupport global state enabled + ``` + +**config auto-techsupport global rate-limit-interval ** + +- Usage: + ``` + config auto-techsupport global rate-limit-interval + ``` + - Parameters: + - rate-limit-interval: Minimum time in seconds to wait after the last techsupport creation time before invoking a new one. + +- Example: + ``` + config auto-techsupport global rate-limit-interval 200 + ``` + +**config auto-techsupport global max-techsupport-limit ** + +- Usage: + ``` + config auto-techsupport global max-techsupport-limit + ``` + - Parameters: + - max-techsupport-limit: A percentage value should be specified. This signifies maximum size to which /var/dump/ directory can be grown until. + +- Example: + ``` + config auto-techsupport global max-techsupport-limit 10.15 + ``` + +**config auto-techsupport global max-core-limit ** + +- Usage: + ``` + config auto-techsupport global max-core-limit + ``` + - Parameters: + - max-core-limit: A percentage value should be specified. This signifies maximum size to which /var/core/ directory can be grown until. + +- Example: + ``` + config auto-techsupport global max-core-limit 10.15 + ``` + +**config auto-techsupport global since** + +- Usage: + ``` + config auto-techsupport global since + ``` + - Parameters: + - since: This limits the auto-invoked techsupport to only collect the logs & core-dumps generated since the time provided. Any valid date string of the formats specified here can be used. (https://www.gnu.org/software/coreutils/manual/html_node/Date-input-formats.html). If this value is not explicitly configured or a non-valid string is provided, a default value of "2 days ago" is used. + +- Example: + ``` + config auto-techsupport global since + ``` + +**config auto-techsupport global available-mem-threshold** + +Configure available memory threshold in %. System will automatically generate a techsupport dump when available memory goes below the configured threshold. Setting this field to 0 will disable techsupport invokation. + +- Usage: + ``` + config auto-techsupport global available-mem-threshold + ``` + - Parameters: + - available-mem-threshold: Memory threshold. Configure 0 to disable techsupport invocation on memory usage threshold crossing +- Example: + ``` + config auto-techsupport global available-mem-threshold 20 + ``` + +**config auto-techsupport global min-available-mem** + +Configure minimum available memory in MB. System will automatically generate a techsupport dump when available memory goes below the configured threshold. + +- Usage: + ``` + config auto-techsupport global min-available-mem + ``` + - Parameters: + - min-available-mem: Minimum free memory amount in MB to trigger techsupport dump +- Example: + ``` + config auto-techsupport global min-available-mem 200 + ``` + +#### config auto-techsupport-feature commands + +**config auto-techsupport-feature add** + +- Usage: + ``` + config auto-techsupport-feature add --state --rate-limit-interval --available-mem-threshold + ``` + - Parameters: + - state: enable/disable the capability for the specific feature/container. + - rate-limit-interval: Rate limit interval for the corresponding feature. Configure 0 to explicitly disable. For the techsupport to be generated by auto-techsupport, both the global and feature specific rate-limit-interval has to be passed + - available-mem-threshold: Memory threshold. Configure 0 to disable techsupport invocation on memory usage threshold crossing. + +- Example: + ``` + config auto-techsupport-feature add bgp --state enabled --rate-limit-interval 200 --available-mem-threshold 50 + ``` + + +**config auto-techsupport-feature delete** + +- Usage: + ``` + config auto-techsupport-feature delete + ``` + +- Example: + ``` + config auto-techsupport-feature delete swss + ``` + +**config auto-techsupport-feature update** + +- Usage: + ``` + config auto-techsupport-feature update --state + config auto-techsupport-feature update --rate-limit-interval + config auto-techsupport-feature update --available-mem-threshold + ``` + +- Example: + ``` + config auto-techsupport-feature update snmp --state enabled + config auto-techsupport-feature update swss --rate-limit-interval 200 + ``` + +#### Show CLI: + +**show auto-techsupport global** + +- Usage: + ``` + show auto-techsupport global + ``` + +- Example: + ``` + admin@sonic:~$ show auto-techsupport global + STATE RATE LIMIT INTERVAL (sec) MAX TECHSUPPORT LIMIT (%) MAX CORE LIMIT (%) AVAILABLE MEM THRESHOLD (%) MIN AVAILABLE MEM (Kb) SINCE + ------- --------------------------- --------------------------- -------------------- ----------------------------- ------------------------ ------------ + enabled 180 10 5 10 200 2 days ago + ``` + +**show auto-techsupport-feature** + +- Usage: + ``` + show auto-techsupport-feature + ``` + +- Example: + ``` + admin@sonic:~$ show auto-techsupport-feature + FEATURE NAME STATE RATE LIMIT INTERVAL (sec) AVAILABLE MEM THRESHOLD (%) + -------------- -------- -------------------------- ------------------------------ + bgp enabled 600 10 + database enabled 600 10 + dhcp_relay enabled 600 10 + lldp enabled 600 10 + swss disabled 800 10 + ``` + +**show auto-techsupport history** + +- Usage: + ``` + show auto-techsupport history + ``` + +- Example: + ``` + admin@sonic:~$ show auto-techsupport history + TECHSUPPORT DUMP TRIGGERED BY EVENT TYPE CORE DUMP + ---------------------------------------- -------------- -------------- ----------------------------- + sonic_dump_r-lionfish-16_20210901_221402 bgp core bgpcfgd.1630534439.55.core.gz + sonic_dump_r-lionfish-16_20210901_203725 snmp core python3.1630528642.23.core.gz + sonic_dump_r-lionfish-16_20210901_222408 teamd core python3.1630535045.34.core.gz + sonic_dump_r-lionfish-16_20210901_222511 N/A memory N/A + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#troubleshooting-commands) + +## Routing Stack + +SONiC software is agnostic of the routing software that is being used in the device. For example, users can use either Quagga or FRR routing stack as per their requirement. +A separate shell (vtysh) is provided to configure such routing stacks. +Once if users go to "vtysh", they can use the routing stack specific commands as given in the following example. + +- Example (Quagga Routing Stack): + ``` + admin@sonic:~$ vtysh + + Hello, this is Quagga (version 0.99.24.1). + Copyright 1996-2005 Kunihiro Ishiguro, et al. + + sonic# show route-map (This command displays the route-map that is configured for the routing protocol.) + ZEBRA: + route-map RM_SET_SRC, permit, sequence 10 + Match clauses: + Set clauses: + src 10.12.0.102 + Call clause: + Action: + Exit routemap + ``` + +Refer the routing stack [Quagga Command Reference](https://www.quagga.net/docs/quagga.pdf) or [FRR Command Reference](https://buildmedia.readthedocs.org/media/pdf/frrouting/latest/frrouting.pdf) to know more about about the routing stack configuration. + + +Go Back To [Beginning of the document](#) or [Beginning of this section](#routing-stack) + + +## Quagga BGP Show Commands + +**show ip bgp summary** + +This command displays the summary of all IPv4 bgp neighbors that are configured and the corresponding states. + +- Usage: + ``` + show ip bgp summary + ``` + +- Example: + ``` + admin@sonic:~$ show ip bgp summary + BGP router identifier 1.2.3.4, local AS number 65061 + RIB entries 6124, using 670 KiB of memory + Peers 2, using 143 KiB of memory + + Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd + 192.168.1.161 4 65501 88698 102781 0 0 0 08w5d14h 2 + 192.168.1.163 4 65502 88698 102780 0 0 0 08w5d14h 2 + + Total number of neighbors 2 + ``` + +**show ip bgp neighbors** + +This command displays all the details of IPv4 & IPv6 BGP neighbors when no optional argument is specified. + +When the optional argument IPv4_address is specified, it displays the detailed neighbor information about that specific IPv4 neighbor. + +Command has got additional optional arguments to display only the advertised routes, or the received routes, or all routes. + +In order to get details for an IPv6 neigbor, use "show ipv6 bgp neighbor " command. + +- Usage: + ``` + show ip bgp neighbors [ [advertised-routes | received-routes | routes]] + ``` + +- Example: + ``` + admin@sonic:~$ show ip bgp neighbors + BGP neighbor is 192.168.1.161, remote AS 65501, local AS 65061, external link + Description: ARISTA01T0 + BGP version 4, remote router ID 1.2.3.4 + BGP state = Established, up for 08w5d14h + Last read 00:00:46, hold time is 180, keepalive interval is 60 seconds + Neighbor capabilities: + 4 Byte AS: advertised and received + Dynamic: received + Route refresh: advertised and received(old & new) + Address family IPv4 Unicast: advertised and received + Graceful Restart Capabilty: advertised and received + Remote Restart timer is 120 seconds + Address families by peer: + IPv4 Unicast(not preserved) + Graceful restart informations: + End-of-RIB send: IPv4 Unicast + End-of-RIB received: IPv4 Unicast + Message statistics: + Inq depth is 0 + Outq depth is 0 + Sent Rcvd + Opens: 1 1 + Notifications: 0 0 + Updates: 14066 3 + Keepalives: 88718 88698 + Route Refresh: 0 0 + Capability: 0 0 + Total: 102785 88702 + Minimum time between advertisement runs is 30 seconds + + For address family: IPv4 Unicast + Community attribute sent to this neighbor(both) + 2 accepted prefixes + + Connections established 1; dropped 0 + Last reset never + Local host: 192.168.1.160, Local port: 32961 + Foreign host: 192.168.1.161, Foreign port: 179 + Nexthop: 192.168.1.160 + Nexthop global: fe80::f60f:1bff:fe89:bc00 + Nexthop local: :: + BGP connection: non shared network + Read thread: on Write thread: off + ``` + +Optionally, you can specify an IP address in order to display only that particular neighbor. In this mode, you can optionally specify whether you want to display all routes advertised to the specified neighbor, all routes received from the specified neighbor or all routes (received and accepted) from the specified neighbor. + + +- Examples: + ``` + admin@sonic:~$ show ip bgp neighbors 192.168.1.161 + + admin@sonic:~$ show ip bgp neighbors 192.168.1.161 advertised-routes + + admin@sonic:~$ show ip bgp neighbors 192.168.1.161 received-routes + + admin@sonic:~$ show ip bgp neighbors 192.168.1.161 routes + ``` + +**show ipv6 bgp summary** + +This command displays the summary of all IPv4 bgp neighbors that are configured and the corresponding states. + +- Usage: + ``` + show ipv6 bgp summary + ``` + +- Example: + ``` + admin@sonic:~$ show ipv6 bgp summary + BGP router identifier 10.1.0.32, local AS number 65100 + RIB entries 12809, using 1401 KiB of memory + Peers 8, using 36 KiB of memory + + Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd + fc00::72 4 64600 12588 12591 0 0 0 06:51:17 6402 + fc00::76 4 64600 12587 6190 0 0 0 06:51:28 6402 + fc00::7a 4 64600 12587 9391 0 0 0 06:51:23 6402 + fc00::7e 4 64600 12589 12592 0 0 0 06:51:25 6402 + + Total number of neighbors 4 + ``` + +**show ipv6 bgp neighbors** + +This command displays all the details of one particular IPv6 Border Gateway Protocol (BGP) neighbor. Option is also available to display only the advertised routes, or the received routes, or all routes. + +- Usage: + ``` + show ipv6 bgp neighbors (advertised-routes | received-routes | routes) + ``` + +- Examples: + ``` + admin@sonic:~$ show ipv6 bgp neighbors fc00::72 advertised-routes + + admin@sonic:~$ show ipv6 bgp neighbors fc00::72 received-routes + + admin@sonic:~$ show ipv6 bgp neighbors fc00::72 routes + ``` + +**show route-map** + +This command displays the routing policy that takes precedence over the other route processes that are configured. + +- Usage: + ``` + show route-map + ``` + +- Example: + ``` + admin@sonic:~$ show route-map + ZEBRA: + route-map RM_SET_SRC, permit, sequence 10 + Match clauses: + Set clauses: + src 10.12.0.102 + Call clause: + Action: + Exit routemap + ZEBRA: + route-map RM_SET_SRC6, permit, sequence 10 + Match clauses: + Set clauses: + src fc00:1::102 + Call clause: + Action: + Exit routemap + BGP: + route-map FROM_BGP_SPEAKER_V4, permit, sequence 10 + Match clauses: + Set clauses: + Call clause: + Action: + Exit routemap + BGP: + route-map TO_BGP_SPEAKER_V4, deny, sequence 10 + Match clauses: + Set clauses: + Call clause: + Action: + Exit routemap + BGP: + route-map ISOLATE, permit, sequence 10 + Match clauses: + Set clauses: + as-path prepend 65000 + Call clause: + Action: + Exit routemap + ``` +Go Back To [Beginning of the document](#) or [Beginning of this section](#quagga-bgp-show-commands) + +# ZTP Configuration And Show Commands + +This section explains all the Zero Touch Provisioning commands that are supported in SONiC. + +## ZTP show commands + + +This command displays the current ZTP configuration of the switch. It also displays detailed information about current state of a ZTP session. It displays information related to all configuration sections as defined in the switch provisioning information discovered in a particular ZTP session. + +- Usage: + show ztp status + + show ztp status --verbose + +- Example: + +``` +root@B1-SP1-7712:/home/admin# show ztp status +ZTP Admin Mode : True +ZTP Service : Inactive +ZTP Status : SUCCESS +ZTP Source : dhcp-opt67 (eth0) +Runtime : 05m 31s +Timestamp : 2019-09-11 19:12:24 UTC + +ZTP Service is not running + +01-configdb-json: SUCCESS +02-connectivity-check: SUCCESS +``` +Use the verbose option to display more detailed information. + +``` +root@B1-SP1-7712:/home/admin# show ztp status --verbose +Command: ztp status --verbose + +ZTP + +ZTP Admin Mode : True +ZTP Service : Inactive +ZTP Status : SUCCESS +ZTP Source : dhcp-opt67 (eth0) +Runtime : 05m 31s +Timestamp : 2019-09-11 19:12:16 UTC +ZTP JSON Version : 1.0 + +ZTP Service is not running + +---------------------------------------- +01-configdb-json +---------------------------------------- +Status : SUCCESS +Runtime : 02m 48s +Timestamp : 2019-09-11 19:11:55 UTC +Exit Code : 0 +Ignore Result : False + +---------------------------------------- +02-connectivity-check +---------------------------------------- +Status : SUCCESS +Runtime : 04s +Timestamp : 2019-09-11 19:12:16 UTC +Exit Code : 0 +Ignore Result : False +``` + +- Description + + - **ZTP Admin Mode** - Displays if the ZTP feature is administratively enabled or disabled. Possible values are True or False. This value is configurable using "config ztp enabled" and "config ztp disable" commands. + - **ZTP Service** - Displays the ZTP service status. The following are possible values this field can display: + - *Active Discovery*: ZTP service is operational and is performing DHCP discovery to learn switch provisioning information + - *Processing*: ZTP service has discovered switch provisioning information and is processing it + - **ZTP Status** - Displays the current state and result of ZTP session. The following are possible values this field can display: + - *IN-PROGRESS*: ZTP session is currently in progress. ZTP service is processing switch provisioning information. + - *SUCCESS*: ZTP service has successfully processed the switch provisioning information. + - *FAILED*: ZTP service has failed to process the switch provisioning information. + - *Not Started*: ZTP service has not started processing the discovered switch provisioning information. + - **ZTP Source** - Displays the DHCP option and then interface name from which switch provisioning information has been discovered. + - **Runtime** - Displays the time taken for ZTP process to complete from start to finish. For individual configuration sections it indicates the time taken to process the associated configuration section. + - **Timestamp** - Displays the date/time stamp when the status field has last changed. + - **ZTP JSON Version** - Version of ZTP JSON file used for describing switch provisioning information. + - **Status** - Displays the current state and result of a configuration section. The following are possible values this field can display: + - *IN-PROGRESS*: Corresponding configuration section is currently being processed. + - *SUCCESS*: Corresponding configuration section was processed successfully. + - *FAILED*: Corresponding configuration section failed to execute successfully. + - *Not Started*: ZTP service has not started processing the corresponding configuration section. + - *DISABLED*: Corresponding configuration section has been marked as disabled and will not be processed. + - **Exit Code** - Displays the program exit code of the configuration section executed. Non-zero exit code indicates that the configuration section has failed to execute successfully. + - **Ignore Result** - If this value is True, the result of the corresponding configuration section is ignored and not used to evaluate the overall ZTP result. + - **Activity String** - In addition to above information an activity string is displayed indicating the current action being performed by the ZTP service and how much time it has been performing the mentioned activity. Below is an example. + - (04m 12s) Discovering provisioning data + +## ZTP configuration commands + +This sub-section explains the list of the configuration options available for ZTP. + + + +**config ztp enable** + +Use this command to enable ZTP administrative mode + +- Example: + +``` +root@sonic:/home/admin# config ztp enable +Running command: ztp enable +``` + + + +**config ztp disable** + +Use this command to disable ZTP administrative mode. This command can also be used to abort a current ZTP session and load the factory default switch configuration. + +- Usage: + config ztp disable + + config ztp disable -y + +- Example: + +``` +root@sonic:/home/admin# config ztp disable +Active ZTP session will be stopped and disabled, continue? [y/N]: y +Running command: ztp disable -y +``` + + +**config ztp run** + +Use this command to manually restart a new ZTP session. This command deletes the existing */etc/sonic/config_db.json* file and stats ZTP service. It also erases the previous ZTP session data. ZTP configuration is loaded on to the switch and ZTP discovery is performed. + +- Usage: + config ztp run + + config ztp run -y + +- Example: + +``` +root@sonic:/home/admin# config ztp run +ZTP will be restarted. You may lose switch data and connectivity, continue? [y/N]: y +Running command: ztp run -y +``` + +Go Back To [Beginning of the document](#SONiC-COMMAND-LINE-INTERFACE-GUIDE) or [Beginning of this section](#ztp-configuration-and-show-commands) +>>>>>>> 202205 +======= +# SONiC Command Line Interface Guide + +## Table of Contents + +* [Document History](#document-history) +* [Introduction](#introduction) +* [Basic Tasks](#basic-tasks) + * [SSH Login](#ssh-login) + * [Show Management Interface](#show-management-interface) + * [Configuring Management Interface](#configuring-management-interface) +* [Getting Help](#getting-help) + * [Help for Config Commands](#help-for-config-commands) + * [Help for Show Commands](#help-for-show-commands) +* [Basic Show Commands](#basic-show-commands) + * [Show Versions](#show-versions) + * [Show System Status](#show-system-status) + * [Show Hardware Platform](#show-hardware-platform) + * [Transceivers](#transceivers) +* [AAA & TACACS+](#aaa--tacacs) + * [AAA](#aaa) + * [AAA show commands](#aaa-show-commands) + * [AAA config commands](#aaa-config-commands) + * [TACACS+](#tacacs) + * [TACACS+ show commands](#tacacs-show-commands) + * [TACACS+ config commands](#tacacs-config-commands) +* [ACL](#acl) + * [ACL show commands](#acl-show-commands) + * [ACL config commands](#acl-config-commands) +* [ARP & NDP](#arp--ndp) + * [ARP show commands](#arp-show-commands) + * [NDP show commands](#ndp-show-commands) +* [BFD](#bfd) + * [BFD show commands](#bfd-show-commands) +* [BGP](#bgp) + * [BGP show commands](#bgp-show-commands) + * [BGP config commands](#bgp-config-commands) +* [Console](#console) + * [Console show commands](#console-show-commands) + * [Console config commands](#console-config-commands) + * [Console connect commands](#console-connect-commands) + * [Console clear commands](#console-clear-commands) +* [DHCP Relay](#dhcp-relay) + * [DHCP Relay config commands](#dhcp-relay-config-commands) +* [Drop Counters](#drop-counters) + * [Drop Counter show commands](#drop-counters-show-commands) + * [Drop Counter config commands](#drop-counters-config-commands) + * [Drop Counter clear commands](#drop-counters-clear-commands) +* [Dynamic Buffer Management](#dynamic-buffer-management) + * [Configuration commands](#configuration-commands) + * [Show commands](#show-commands) +* [ECN](#ecn) + * [ECN show commands](#ecn-show-commands) + * [ECN config commands](#ecn-config-commands) +* [Feature](#feature) + * [Feature show commands](#feature-show-commands) + * [Feature config commands](#feature-config-commands) +* [Flow Counters](#flow-counters) + * [Flow Counters show commands](#flow-counters-show-commands) + * [Flow Counters clear commands](#flow-counters-clear-commands) + * [Flow Counters config commands](#flow-counters-config-commands) +* [Gearbox](#gearbox) + * [Gearbox show commands](#gearbox-show-commands) +* [Interfaces](#interfaces) + * [Interface Show Commands](#interface-show-commands) + * [Interface Config Commands](#interface-config-commands) +* [Interface Naming Mode](#interface-naming-mode) + * [Interface naming mode show commands](#interface-naming-mode-show-commands) + * [Interface naming mode config commands](#interface-naming-mode-config-commands) + * [Interface Vrf binding](#interface-vrf-binding) + * [Interface vrf bind & unbind config commands](#interface-vrf-bind-&-unbind-config-commands) + * [Interface vrf binding show commands](#interface-vrf-binding-show-commands) +* [IP / IPv6](#ip--ipv6) + * [IP show commands](#ip-show-commands) + * [IPv6 show commands](#ipv6-show-commands) +* [IPv6 Link Local](#ipv6-link-local) + * [IPv6 Link Local config commands](#ipv6-link-local-config-commands) + * [IPv6 Link Local show commands](#ipv6-link-local-show-commands) +* [Kubernetes](#Kubernetes) + * [Kubernetes show commands](#Kubernetes-show-commands) + * [Kubernetes config commands](#Kubernetes-config-commands) +* [Linux Kernel Dump](#kdump) + * [Linux Kernel Dump show commands](#kdump-show-commands) + * [Linux Kernel Dump config commands](#kdump-config-commands) +* [LLDP](#lldp) + * [LLDP show commands](#lldp-show-commands) +* [Loading, Reloading And Saving Configuration](#loading-reloading-and-saving-configuration) + * [Loading configuration from JSON file](#loading-configuration-from-json-file) + * [Loading configuration from minigraph (XML) file](#loading-configuration-from-minigraph-xml-file) + * [Reloading Configuration](#reloading-configuration) + * [Loading Management Configuration](#loading-management-configuration) + * [Saving Configuration to a File for Persistence](saving-configuration-to-a-file-for-persistence) + * [Loopback Interfaces](#loopback-interfaces) + * [Loopback show commands](#loopback-show-commands) + * [Loopback config commands](#loopback-config-commands) +* [VRF Configuration](#vrf-configuration) + * [VRF show commands](#vrf-show-commands) + * [VRF config commands](#vrf-config-commands) +* [Management VRF](#Management-VRF) + * [Management VRF Show commands](#management-vrf-show-commands) + * [Management VRF Config commands](#management-vrf-config-commands) +* [Mirroring](#mirroring) + * [Mirroring Show commands](#mirroring-show-commands) + * [Mirroring Config commands](#mirroring-config-commands) +* [Muxcable](#muxcable) + * [Muxcable Show commands](#muxcable-show-commands) + * [Muxcable Config commands](#muxcable-config-commands) +* [NAT](#nat) + * [NAT Show commands](#nat-show-commands) + * [NAT Config commands](#nat-config-commands) + * [NAT Clear commands](#nat-clear-commands) +* [NTP](#ntp) + * [NTP show commands](#ntp-show-commands) + * [NTP config commands](#ntp-config-commands) +* [NVGRE](#nvgre) + * [NVGRE show commands](#nvgre-show-commands) + * [NVGRE config commands](#nvgre-config-commands) +* [PBH](#pbh) + * [PBH show commands](#pbh-show-commands) + * [PBH config commands](#pbh-config-commands) +* [PFC Watchdog Commands](#pfc-watchdog-commands) +* [Platform Component Firmware](#platform-component-firmware) + * [Platform Component Firmware show commands](#platform-component-firmware-show-commands) + * [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) +* [QoS](#qos) + * [QoS Show commands](#qos-show-commands) + * [PFC](#pfc) + * [Queue And Priority-Group](#queue-and-priority-group) + * [Buffer Pool](#buffer-pool) + * [QoS config commands](#qos-config-commands) +* [sFlow](#sflow) + * [sFlow Show commands](#sflow-show-commands) + * [sFlow Config commands](#sflow-config-commands) +* [SNMP](#snmp) + * [SNMP Show commands](#snmp-show-commands) + * [SNMP Config commands](#snmp-config-commands) +* [Startup & Running Configuration](#startup--running-configuration) + * [Startup Configuration](#startup-configuration) + * [Running Configuration](#running-configuration) +* [Static routing](#static-routing) +* [Subinterfaces](#subinterfaces) + * [Subinterfaces Show Commands](#subinterfaces-show-commands) + * [Subinterfaces Config Commands](#subinterfaces-config-commands) +* [Syslog](#syslog) + * [Syslog config commands](#syslog-config-commands) +* [System State](#system-state) + * [Processes](#processes) + * [Services & Memory](#services--memory) +* [System-Health](#System-Health) +* [VLAN & FDB](#vlan--fdb) + * [VLAN](#vlan) + * [VLAN show commands](#vlan-show-commands) + * [VLAN Config commands](#vlan-config-commands) + * [FDB](#fdb) + * [FDB show commands](#fdb-show-commands) +* [VxLAN & Vnet](#vxlan--vnet) + * [VxLAN](#vxlan) + * [VxLAN show commands](#vxlan-show-commands) + * [Vnet](#vnet) + * [Vnet show commands](#vnet-show-commands) +* [Warm Reboot](#warm-reboot) +* [Warm Restart](#warm-restart) + * [Warm Restart show commands](#warm-restart-show-commands) + * [Warm Restart Config commands](#warm-restart-config-commands) +* [Watermark](#watermark) + * [Watermark Show commands](#watermark-show-commands) + * [Watermark Config commands](#watermark-config-commands) +* [Software Installation and Management](#software-installation-and-management) + * [SONiC Package Manager](#sonic-package-manager) + * [SONiC Installer](#sonic-installer) +* [Troubleshooting Commands](#troubleshooting-commands) + * [Debug Dumps](#debug-dumps) + * [Event Driven Techsupport Invocation](#event-driven-techsupport-invocation) +* [Routing Stack](#routing-stack) +* [Quagga BGP Show Commands](#Quagga-BGP-Show-Commands) +* [ZTP Configuration And Show Commands](#ztp-configuration-and-show-commands) + * [ ZTP show commands](#ztp-show-commands) + * [ZTP configuration commands](#ztp-configuration-commands) + +## Document History + +| Version | Modification Date | Details | +| --- | --- | --- | +| v6 | May-06-2021 | Add SNMP show and config commands | +| v5 | Nov-05-2020 | Add document for console commands | +| v4 | Oct-17-2019 | Unify usage statements and other formatting; Replace tabs with spaces; Modify heading sizes; Fix spelling, grammar and other errors; Fix organization of new commands | +| v3 | Jun-26-2019 | Update based on 201904 (build#19) release, "config interface" command changes related to interfacename order, FRR/Quagga show command changes, platform specific changes, ACL show changes and few formatting changes | +| v2 | Apr-22-2019 | CLI Guide for SONiC 201811 version (build#32) with complete "config" command set | +| v1 | Mar-23-2019 | Initial version of CLI Guide with minimal command set | + +## Introduction +SONiC is an open source network operating system based on Linux that runs on switches from multiple vendors and ASICs. SONiC offers a full-suite of network functionality, like BGP and RDMA, that has been production-hardened in the data centers of some of the largest cloud-service providers. It offers teams the flexibility to create the network solutions they need while leveraging the collective strength of a large ecosystem and community. + +SONiC software shall be loaded in these [supported devices](https://github.com/Azure/SONiC/wiki/Supported-Devices-and-Platforms) and this CLI guide shall be used to configure the devices as well as to display the configuration, state and status. + +Follow the [Quick Start Guide](https://github.com/Azure/SONiC/wiki/Quick-Start) to boot the device in ONIE mode, install the SONiC software using the steps specified in the document and login to the device using the default username and password. + +After logging into the device, SONiC software can be configured in following three methods. + 1. Command Line Interface (CLI) + 2. [config_db.json](https://github.com/Azure/SONiC/wiki/Configuration) + 3. [minigraph.xml](https://github.com/Azure/SONiC/wiki/Configuration-with-Minigraph-(~Sep-2017)) + +This document explains the first method and gives the complete list of commands that are supported in SONiC 201904 version (build#19). +All the configuration commands need root privileges to execute them. Note that show commands can be executed by all users without the root privileges. +Root privileges can be obtained either by using "sudo" keyword in front of all config commands, or by going to root prompt using "sudo -i". +Note that all commands are case sensitive. + +- Example: + ``` + admin@sonic:~$ sudo config aaa authentication login tacacs+ + + OR + + admin@sonic:~$ sudo -i + root@sonic:~# config aaa authentication login tacacs+ + ``` + +Note that the command list given in this document is just a subset of all possible configurations in SONiC. +Please follow config_db.json based configuration for the complete list of configuration options. + +**Scope of this Document** + +It is assumed that all configuration commands start with the keyword “config” as prefix. +Any other scripts/utilities/commands that need user configuration control are wrapped as sub-commands under the “config” command. +The direct scripts/utilities/commands (examples given below) that are not wrapped under the "config" command are not in the scope of this document. + 1. acl_loader – This script is already wrapped inside “config acl” command; i.e. any ACL configuration that user is allowed to do is already part of “config acl” command; users are not expected to use the acl_loader script directly and hence this document need not explain the “acl_loader” script. + 2. crm – this command is not explained in this document. + 3. sonic-clear, sfputil, etc., This document does not explain these scripts also. + +## Basic Tasks + +This section covers the basic configurations related to the following: + 1. [SSH login](#SSH-Login) + 2. [Configuring the Management Interface](#Configuring-Management-Interface) + +### SSH Login + +All SONiC devices support both the serial console based login and the SSH based login by default. +The default credential (if not modified at image build time) for login is `admin/YourPaSsWoRd`. +In case of SSH login, users can login to the management interface (eth0) IP address after configuring the same using serial console. +Refer the following section for configuring the IP address for management interface. + +- Example: + ``` + At Console: + Debian GNU/Linux 9 sonic ttyS1 + + sonic login: admin + Password: YourPaSsWoRd + + SSH from any remote server to sonic can be done by connecting to SONiC IP + user@debug:~$ ssh admin@sonic_ip_address(or SONIC DNS Name) + admin@sonic's password: + ``` + +By default, login takes the user to the default prompt from which all the show commands can be executed. + +Go Back To [Beginning of the document](#) or [Beginning of this section](#basic-tasks) + +### Show Management Interface + +Please check [show ip interfaces](#show-ip-interfaces) + +### Configuring Management Interface + +The management interface (eth0) in SONiC is configured (by default) to use DHCP client to get the IP address from the DHCP server. Connect the management interface to the same network in which your DHCP server is connected and get the IP address from DHCP server. +The IP address received from DHCP server can be verified using the `/sbin/ifconfig eth0` Linux command. + +SONiC provides a CLI to configure the static IP for the management interface. There are few ways by which a static IP address can be configured for the management interface. + 1. Use the `config interface ip add eth0` command. + - Example: + ``` + admin@sonic:~$ sudo config interface ip add eth0 20.11.12.13/24 20.11.12.254 + ``` + 2. Use config_db.json and configure the MGMT_INTERFACE key with the appropriate values. Refer [here](https://github.com/Azure/SONiC/wiki/Configuration#Management-Interface) + 3. Use minigraph.xml and configure "ManagementIPInterfaces" tag inside "DpgDesc" tag as given at the [page](https://github.com/Azure/SONiC/wiki/Configuration-with-Minigraph-(~Sep-2017)) + +Once the IP address is configured, the same can be verified using either `show management_interface address` command or the `/sbin/ifconfig eth0` linux command. +Users can SSH login to this management interface IP address from their management network. + +- Example: + ``` + admin@sonic:~$ /sbin/ifconfig eth0 + eth0: flags=4163 mtu 1500 + inet 10.11.11.13 netmask 255.255.255.0 broadcast 10.11.12.255 + ``` +Go Back To [Beginning of the document](#) or [Beginning of this section](#basic-tasks) + +## Getting Help + +Subsections: + 1. [Help for Config Commands](#Config-Help) + 2. [Help for Show Commands](#Show-Help) + 3. [Show Versions](#Show-Versions) + 4. [Show System Status](#Show-System-Status) + 5. [Show Hardware Platform](#Show-Hardware-Platform) + +### Help for Config Commands + +All commands have in-built help that aids the user in understanding the command as well as the possible sub-commands and options. +"--help" can be used at any level of the command; i.e. it can be used at the command level, or sub-command level or at argument level. The in-built help will display the available possibilities corresponding to that particular command/sub-command. + +**config --help** + +This command lists all the possible configuration commands at the top level. + +- Usage: + ``` + config --help + ``` + +- Example: + ``` + admin@sonic:~$ config --help + Usage: config [OPTIONS] COMMAND [ARGS] + SONiC command line - 'config' command + + Options: + --help Show this message and exit. + + Commands: + aaa AAA command line + acl ACL-related configuration tasks + bgp BGP-related configuration tasks + ecn ECN-related configuration tasks + feature Modify configuration of features + hostname Change device hostname without impacting traffic + interface Interface-related configuration tasks + interface_naming_mode Modify interface naming mode for interacting... + kubernetes Kubernetes server related configuration + load Import a previous saved config DB dump file. + load_mgmt_config Reconfigure hostname and mgmt interface based... + load_minigraph Reconfigure based on minigraph. + loopback Loopback-related configuration tasks. + mirror_session + nat NAT-related configuration tasks + platform Platform-related configuration tasks + portchannel + qos + reload Clear current configuration and import a... + route route-related configuration tasks + save Export current config DB to a file on disk. + tacacs TACACS+ server configuration + vlan VLAN-related configuration tasks + vrf VRF-related configuration tasks + warm_restart warm_restart-related configuration tasks + watermark Configure watermark + ``` +Go Back To [Beginning of the document](#) or [Beginning of this section](#getting-help) + +### Help For Show Commands + +**show help** + +This command displays the full list of show commands available in the software; the output of each of those show commands can be used to analyze, debug or troubleshoot the network node. + +- Usage: + ``` + show (-?|-h|--help) + ``` + +- Example: + ``` + admin@sonic:~$ show -? + Usage: show [OPTIONS] COMMAND [ARGS]... + SONiC command line - 'show' command + + Options: + -?, -h, --help Show this message and exit. + + Commands: + aaa Show AAA configuration + acl Show ACL related information + arp Show IP ARP table + buffer_pool Show details of the Buffer-pools + clock Show date and time + ecn Show ECN configuration + environment Show environmentals (voltages, fans, temps) + feature Show feature status + interfaces Show details of the network interfaces + ip Show IP (IPv4) commands + ipv6 Show IPv6 commands + kubernetes Show kubernetes commands + line Show all /dev/ttyUSB lines and their info + lldp Show LLDP information + logging Show system log + mac Show MAC (FDB) entries + mirror_session Show existing everflow sessions + mmu Show mmu configuration + muxcable Show muxcable information + nat Show details of the nat + ndp Show IPv6 Neighbour table + ntp Show NTP information + pfc Show details of the priority-flow-control... + platform Show platform-specific hardware info + priority-group Show details of the PGs + processes Show process information + queue Show details of the queues + reboot-cause Show cause of most recent reboot + route-map Show route-map + runningconfiguration Show current running configuration... + services Show all daemon services + startupconfiguration Show startup configuration information + subinterfaces Show details of the sub port interfaces + system-memory Show memory information + tacacs Show TACACS+ configuration + techsupport Gather information for troubleshooting + uptime Show system uptime + users Show users + version Show version information + vlan Show VLAN information + vrf Show vrf config + warm_restart Show warm restart configuration and state + watermark Show details of watermark + ``` + +The same syntax applies to all subgroups of `show` which themselves contain subcommands, and subcommands which accept options/arguments. + +- Example: + ``` + admin@sonic:~$ show interfaces -? + + Show details of the network interfaces + + Options: + -?, -h, --help Show this message and exit. + + Commands: + counters Show interface counters + description Show interface status, protocol and... + naming_mode Show interface naming_mode status + neighbor Show neighbor related information + portchannel Show PortChannel information + status Show Interface status information + tpid Show Interface tpid information + transceiver Show SFP Transceiver information + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#getting-help) + +## Basic Show Commands + +Subsections: + 1. [Show Versions](#Show-Versions) + 2. [Show System Status](#Show-System-Status) + 3. [Show Hardware Platform](#Show-Hardware-Platform) + +### Show Versions + +**show version** + +This command displays software component versions of the currently running SONiC image. This includes the SONiC image version as well as Docker image versions. +This command displays relevant information as the SONiC and Linux kernel version being utilized, as well as the ID of the commit used to build the SONiC image. The second section of the output displays the various docker images and their associated IDs. + +- Usage: + ``` + show version + ``` + +- Example: + ``` + admin@sonic:~$ show version + SONiC Software Version: SONiC.HEAD.32-21ea29a + Distribution: Debian 9.8 + Kernel: 4.9.0-8-amd64 + Build commit: 21ea29a + Build date: Fri Mar 22 01:55:48 UTC 2019 + Built by: johnar@jenkins-worker-4 + + Platform: x86_64-mlnx_msn2700-r0 + HwSKU: Mellanox-SN2700 + ASIC: mellanox + ASIC Count: 1 + Serial Number: MT1822K07815 + Model Number: MSN2700-CS2FO + Hardware Rev: A1 + Uptime: 14:40:15 up 3 min, 1 user, load average: 1.26, 1.45, 0.66 + Date: Fri 22 Mar 2019 14:40:15 + + Docker images: + REPOSITORY TAG IMAGE ID SIZE + docker-syncd-brcm HEAD.32-21ea29a 434240daff6e 362MB + docker-syncd-brcm latest 434240daff6e 362MB + docker-orchagent-brcm HEAD.32-21ea29a e4f9c4631025 287MB + docker-orchagent-brcm latest e4f9c4631025 287MB + docker-nat HEAD.32-21ea29a 46075edc1c69 305MB + docker-nat latest 46075edc1c69 305MB + docker-lldp-sv2 HEAD.32-21ea29a 9681bbfea3ac 275MB + docker-lldp-sv2 latest 9681bbfea3ac 275MB + docker-dhcp-relay HEAD.32-21ea29a 2db34c7bc6f4 257MB + docker-dhcp-relay latest 2db34c7bc6f4 257MB + docker-database HEAD.32-21ea29a badc6fc84cdb 256MB + docker-database latest badc6fc84cdb 256MB + docker-snmp-sv2 HEAD.32-21ea29a e2776e2a30b7 295MB + docker-snmp-sv2 latest e2776e2a30b7 295MB + docker-teamd HEAD.32-21ea29a caf957cd2ad1 275MB + docker-teamd latest caf957cd2ad1 275MB + docker-router-advertiser HEAD.32-21ea29a b1a62023958c 255MB + docker-router-advertiser latest b1a62023958c 255MB + docker-platform-monitor HEAD.32-21ea29a 40b40a4b2164 287MB + docker-platform-monitor latest 40b40a4b2164 287MB + docker-fpm-quagga HEAD.32-21ea29a 546036fe6838 282MB + docker-fpm-quagga latest 546036fe6838 282MB + ``` +Go Back To [Beginning of the document](#) or [Beginning of this section](#basic-show-commands) + + +### Show System Status +This sub-section explains some set of sub-commands that are used to display the status of various parameters pertaining to the physical state of the network node. + +**show clock** + +This command displays the current date and time configured on the system + +- Usage: + ``` + show clock + ``` + +- Example: + ``` + admin@sonic:~$ show clock + Mon Mar 25 20:25:16 UTC 2019 + ``` + +**show boot** + +This command displays the current OS image, the image to be loaded on next reboot, and lists all the available images installed on the device + +- Usage: + ``` + show boot + ``` + +- Example: + ``` + admin@sonic:~$ show boot + Current: SONiC-OS-20181130.31 + Next: SONiC-OS-20181130.31 + Available: + SONiC-OS-20181130.31 + ``` + +**show environment** + +This command displays the platform environmentals, such as voltages, temperatures and fan speeds + +- Usage: + ``` + show environment + ``` + +- Example: + ``` + admin@sonic:~$ show environment + coretemp-isa-0000 + Adapter: ISA adapter + Core 0: +28.0 C (high = +98.0 C, crit = +98.0 C) + Core 1: +28.0 C (high = +98.0 C, crit = +98.0 C) + Core 2: +28.0 C (high = +98.0 C, crit = +98.0 C) + Core 3: +28.0 C (high = +98.0 C, crit = +98.0 C) + SMF_Z9100_ON-isa-0000 + Adapter: ISA adapter + CPU XP3R3V_EARLY: +3.22 V + <... few more things ...> + + Onboard Temperature Sensors: + CPU: 30 C + BCM56960 (PSU side): 35 C + <... few more things ...> + + Onboard Voltage Sensors: + CPU XP3R3V_EARLY 3.22 V + <... few more things ...> + + Fan Trays: + Fan Tray 1: + Fan1 Speed: 6192 RPM + Fan2 Speed: 6362 RPM + Fan1 State: Normal + Fan2 State: Normal + Air Flow: F2B + <... few more things ...> + + PSUs: + PSU 1: + Input: AC + <... few more things ...> + ``` +NOTE: The show output has got lot of information; only the sample output is given in the above example. +Though the displayed output slightly differs from one platform to another platform, the overall content will be similar to the example mentioned above. + +**show reboot-cause** + +This command displays the cause of the previous reboot + +- Usage: + ``` + show reboot-cause + ``` + +- Example: + ``` + admin@sonic:~$ show reboot-cause + User issued reboot command [User: admin, Time: Mon Mar 25 01:02:03 UTC 2019] + ``` + +**show reboot-cause history** + +This command displays the history of the previous reboots up to 10 entry + +- Usage: + ``` + show reboot-cause history + ``` + +- Example: + ``` + admin@sonic:~$ show reboot-cause history + Name Cause Time User Comment + ------------------- ----------- ---------------------------- ------ --------- + 2020_10_09_02_33_06 reboot Fri Oct 9 02:29:44 UTC 2020 admin + 2020_10_09_01_56_59 reboot Fri Oct 9 01:53:49 UTC 2020 admin + 2020_10_09_02_00_53 fast-reboot Fri Oct 9 01:58:04 UTC 2020 admin + 2020_10_09_04_53_58 warm-reboot Fri Oct 9 04:51:47 UTC 2020 admin + ``` + +**show uptime** + +This command displays the current system uptime + +- Usage: + ``` + show uptime + ``` + +- Example: + ``` + admin@sonic:~$ show uptime + up 2 days, 21 hours, 30 minutes + ``` + +**show logging** + +This command displays all the currently stored log messages. +All the latest processes and corresponding transactions are stored in the "syslog" file. +This file is saved in the path `/var/log` and can be viewed by giving the command ` sudo cat syslog` as this requires root login. + +- Usage: + ``` + show logging [( [-l|--lines ]) | (-f|--follow)] + ``` + +- Example: + ``` + admin@sonic:~$ show logging + ``` + +It can be useful to pipe the output from `show logging` to the command `more` in order to examine one screenful of log messages at a time + +- Example: + ``` + admin@sonic:~$ show logging | more + ``` + +Optionally, you can specify a process name in order to display only log messages mentioning that process + +- Example: + ``` + admin@sonic:~$ show logging sensord + ``` + +Optionally, you can specify a number of lines to display using the `-l` or `--lines` option. Only the most recent N lines will be displayed. Also note that this option can be combined with a process name. + +- Examples: + ``` + admin@sonic:~$ show logging --lines 50 + ``` + ``` + admin@sonic:~$ show logging sensord --lines 50 + ``` + +Optionally, you can follow the log live as entries are written to it by specifying the `-f` or `--follow` flag + +- Example: + ``` + admin@sonic:~$ show logging --follow + ``` + +**show users** + +This command displays a list of users currently logged in to the device + +- Usage: + ``` + show users + ``` + +- Examples: + ``` + admin@sonic:~$ show users + admin pts/9 Mar 25 20:31 (100.127.20.23) + + admin@sonic:~$ show users + admin ttyS1 2019-03-25 20:31 + ``` +Go Back To [Beginning of the document](#) or [Beginning of this section](#basic-show-commands) + +### Show Hardware Platform + +The information displayed in this set of commands partially overlaps with the one generated by “show envinronment” instruction. In this case though, the information is presented in a more succinct fashion. In the future these two CLI stanzas may end up getting combined. + +**show platform summary** + +This command displays a summary of the device's hardware platform + +- Usage: + ``` + show platform summary + ``` + +- Example: + ``` + admin@sonic:~$ show platform summary + Platform: x86_64-mlnx_msn2700-r0 + HwSKU: Mellanox-SN2700 + ASIC: mellanox + ASIC Count: 1 + Serial Number: MT1822K07815 + Model Number: MSN2700-CS2FO + Hardware Rev: A1 + ``` + +**show platform syseeprom** + +This command displays information stored on the system EEPROM. +Note that the output of this command is not the same for all vendor's platforms. +Couple of example outputs are given below. + +- Usage: + ``` + show platform syseeprom + ``` + +- Example: + ``` + admin@sonic:~$ show platform syseeprom + lsTLV Name Len Value + -------------------- --- ----- + PPID 20 XX-XXXXXX-00000-000-0000 + DPN Rev 3 XXX + Service Tag 7 XXXXXXX + Part Number 10 XXXXXX + Part Number Rev 3 XXX + Mfg Test Results 2 FF + Card ID 2 0x0000 + Module ID 2 0 + Base MAC Address 12 FE:EC:BA:AB:CD:EF + (checksum valid) + ``` + + ``` + admin@sonic:~$ show platform syseeprom + TlvInfo Header: + Id String: TlvInfo + Version: 1 + Total Length: 527 + TLV Name Code Len Value + ---- --- ----- + Product Name 0x21 64 MSN2700 + Part Number 0x22 20 MSN2700-CS2FO + Serial Number 0x23 24 MT1822K07815 + Base MAC Address 0x24 6 50:6B:4B:8F:CE:40 + Manufacture Date 0x25 19 05/28/2018 23:56:02 + Device Version 0x26 1 16 + MAC Addresses 0x2A 2 128 + Manufacturer 0x2B 8 Mellanox + Vendor Extension 0xFD 36 + Vendor Extension 0xFD 164 + Vendor Extension 0xFD 36 + Vendor Extension 0xFD 36 + Vendor Extension 0xFD 36 + Platform Name 0x28 18 x86_64-mlnx_x86-r0 + ONIE Version 0x29 21 2018.08-5.2.0006-9600 + CRC-32 0xFE 4 0x11C017E1 + + (checksum valid) + ``` + +**show platform ssdhealth** + +This command displays health parameters of the device's SSD + +- Usage: + ``` + show platform ssdhealth [--vendor] + ``` + +- Example: + ``` + admin@sonic:~$ show platform ssdhealth + Device Model : M.2 (S42) 3IE3 + Health : 99.665% + Temperature : 30C + ``` + +**show platform psustatus** + +This command displays the status of the device's power supply units + +- Usage: + ``` + show platform psustatus + ``` + +- Example: + ``` + admin@sonic:~$ show platform psustatus + PSU Model Serial HW Rev Voltage (V) Current (A) Power (W) Status LED + ----- ------------- ------------ -------- ------------- ------------- ----------- -------- ----- + PSU 1 MTEF-PSF-AC-A MT1621X15246 A3 11.97 4.56 54.56 OK green + ``` + +**show platform fan** + +This command displays the status of the device's fans + +- Usage: + ``` + show platform fan + ``` + +- Example: + ``` + admin@sonic:~$ show platform fan + FAN Speed Direction Presence Status Timestamp + ----------- -------- ----------- ---------- -------- ----------------- + fan1 34% intake Present OK 20200302 06:58:56 + fan2 43% intake Present OK 20200302 06:58:56 + fan3 38% intake Present OK 20200302 06:58:56 + fan4 49% intake Present OK 20200302 06:58:57 + fan5 38% exhaust Present OK 20200302 06:58:57 + fan6 48% exhaust Present OK 20200302 06:58:57 + fan7 39% exhaust Present OK 20200302 06:58:57 + fan8 48% exhaust Present OK 20200302 06:58:57 + ``` + +**show platform temperature** + +This command displays the status of the device's thermal sensors + +- Usage: + ``` + show platform temperature + ``` + +- Example: + ``` + admin@sonic:~$ show platform temperature + NAME Temperature High Th Low Th Crit High Th Crit Low Th Warning Timestamp + ---------------------- ------------- --------- -------- -------------- ------------- --------- ----------------- + Ambient ASIC Temp 37.0 100.0 N/A 120.0 N/A False 20200302 06:58:57 + Ambient Fan Side Temp 28.5 100.0 N/A 120.0 N/A False 20200302 06:58:57 + Ambient Port Side Temp 31.0 100.0 N/A 120.0 N/A False 20200302 06:58:57 + CPU Core 0 Temp 36.0 87.0 N/A 105.0 N/A False 20200302 06:59:57 + CPU Core 1 Temp 38.0 87.0 N/A 105.0 N/A False 20200302 06:59:57 + CPU Pack Temp 38.0 87.0 N/A 105.0 N/A False 20200302 06:59:57 + PSU-1 Temp 28.0 100.0 N/A 120.0 N/A False 20200302 06:59:58 + PSU-2 Temp 28.0 100.0 N/A 120.0 N/A False 20200302 06:59:58 + xSFP module 1 Temp 31.5 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 2 Temp 35.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 3 Temp 32.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 4 Temp 33.5 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 5 Temp 34.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 6 Temp 36.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 7 Temp 33.5 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 8 Temp 33.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 9 Temp 32.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 10 Temp 38.5 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 11 Temp 38.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 12 Temp 39.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 13 Temp 35.5 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 14 Temp 37.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 15 Temp 36.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 16 Temp 36.5 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 17 Temp 32.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 18 Temp 34.5 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 19 Temp 30.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 20 Temp 31.5 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 21 Temp 34.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 22 Temp 34.4 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 23 Temp 34.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 24 Temp 35.6 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 25 Temp 38.0 70.0 N/A 90.0 N/A False 20200302 06:59:57 + xSFP module 26 Temp 32.2 70.0 N/A 90.0 N/A False 20200302 06:59:58 + xSFP module 27 Temp 39.0 70.0 N/A 90.0 N/A False 20200302 06:59:58 + xSFP module 28 Temp 30.1 70.0 N/A 90.0 N/A False 20200302 06:59:58 + xSFP module 29 Temp 32.0 70.0 N/A 90.0 N/A False 20200302 06:59:58 + xSFP module 30 Temp 35.3 70.0 N/A 90.0 N/A False 20200302 06:59:58 + xSFP module 31 Temp 31.0 70.0 N/A 90.0 N/A False 20200302 06:59:58 + xSFP module 32 Temp 39.5 70.0 N/A 90.0 N/A False 20200302 06:59:58 + ``` + +#### Transceivers +Displays diagnostic monitoring information of the transceivers + +**show interfaces transceiver** + +This command displays information for all the interfaces for the transceiver requested or a specific interface if the optional "interface_name" is specified. + +- Usage: + ``` + show interfaces transceiver (eeprom [-d|--dom] | lpmode | presence | error-status [-hw|--fetch-from-hardware]) [] + ``` + +- Example (Decode and display information stored on the EEPROM of SFP transceiver connected to Ethernet0): + ``` + admin@sonic:~$ show interfaces transceiver eeprom --dom Ethernet0 + Ethernet0: SFP detected + Connector : No separable connector + Encoding : Unspecified + Extended Identifier : Unknown + Extended RateSelect Compliance : QSFP+ Rate Select Version 1 + Identifier : QSFP+ + Length Cable Assembly(m) : 1 + Specification compliance : + 10/40G Ethernet Compliance Code : 40GBASE-CR4 + Fibre Channel Speed : 1200 Mbytes/Sec + Fibre Channel link length/Transmitter Technology : Electrical inter-enclosure (EL) + Fibre Channel transmission media : Twin Axial Pair (TW) + Vendor Date Code(YYYY-MM-DD Lot) : 2015-10-31 + Vendor Name : XXXXX + Vendor OUI : XX-XX-XX + Vendor PN : 1111111111 + Vendor Rev : + Vendor SN : 111111111 + ChannelMonitorValues: + RX1Power: -1.1936dBm + RX2Power: -1.1793dBm + RX3Power: -0.9388dBm + RX4Power: -1.0729dBm + TX1Bias: 4.0140mA + TX2Bias: 4.0140mA + TX3Bias: 4.0140mA + TX4Bias: 4.0140mA + ModuleMonitorValues : + Temperature : 1.1111C + Vcc : 0.0000Volts + ``` + +- Example (Display status of low-power mode of SFP transceiver connected to Ethernet100): + ``` + admin@sonic:~$ show interfaces transceiver lpmode Ethernet100 + Port Low-power Mode + ----------- ---------------- + Ethernet100 On + ``` + + +- Example (Display presence of SFP transceiver connected to Ethernet100): + ``` + admin@sonic:~$ show interfaces transceiver presence Ethernet100 + Port Presence + ----------- ---------- + Ethernet100 Present + ``` + +- Example (Display error status of SFP transceiver connected to Ethernet100): + ``` + admin@sonic:~$ show interfaces transceiver error-status Ethernet100 + Port Error Status + ----------- -------------- + Ethernet100 OK + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#basic-show-commands) + +## AAA & TACACS+ +This section captures the various show commands & configuration commands that are applicable for the AAA (Authentication, Authorization, and Accounting) module. +Admins can configure the type of authentication (local or remote tacacs based) required for the users and also the authentication failthrough and fallback options. +Following show command displays the current running configuration related to the AAA. + +### AAA + +#### AAA show commands + +This command is used to view the Authentication, Authorization & Accounting settings that are configured in the network node. + +**show aaa** + +This command displays the AAA settings currently present in the network node + +- Usage: + ``` + show aaa + ``` + +- Example: + ``` + admin@sonic:~$ show aaa + AAA authentication login local (default) + AAA authentication failthrough True (default) + AAA authentication fallback True (default) + ``` + +#### AAA config commands + +This sub-section explains all the possible CLI based configuration options for the AAA module. The list of commands/sub-commands possible for aaa is given below. + + Command: aaa authentication + sub-commands: + - aaa authentication failthrough + - aaa authentication fallback + - aaa authentication login + +**aaa authentication failthrough** + +This command is used to either enable or disable the failthrough option. +This command is useful when user has configured more than one tacacs+ server and when user has enabled tacacs+ authentication. +When authentication request to the first server fails, this configuration allows to continue the request to the next server. +When this configuration is enabled, authentication process continues through all servers configured. +When this is disabled and if the authentication request fails on first server, authentication process will stop and the login will be disallowed. + + +- Usage: + ``` + config aaa authentication failthrough (enable | disable | default) + ``` + + - Parameters: + - enable: This allows the AAA module to process with local authentication if remote authentication fails. + - disable: This disallows the AAA module to proceed further if remote authentication fails. + - default: This re-configures the default value, which is "enable". + + +- Example: + ``` + admin@sonic:~$ sudo config aaa authentication failthrough enable + ``` +**aaa authentication fallback** + +The command is not used at the moment. +When the tacacs+ authentication fails, it falls back to local authentication by default. + +- Usage: + ``` + config aaa authentication fallback (enable | disable | default) + ``` + +- Example: + ``` + admin@sonic:~$ sudo config aaa authentication fallback enable + ``` + +**aaa authentication login** + +This command is used to either configure whether AAA should use local database or remote tacacs+ database for user authentication. +By default, AAA uses local database for authentication. New users can be added/deleted using the linux commands (Note that the configuration done using linux commands are not preserved during reboot). +Admin can enable remote tacacs+ server based authentication by selecting the AUTH_PROTOCOL as tacacs+ in this command. +Admins need to configure the tacacs+ server accordingly and ensure that the connectivity to tacacas+ server is available via the management interface. +Once if the admins choose the remote authentication based on tacacs+ server, all user logins will be authenticated by the tacacs+ server. +If the authentication fails, AAA will check the "failthrough" configuration and authenticates the user based on local database if failthrough is enabled. + +- Usage: + ``` + config aaa authentication (tacacs+ | local | default) + ``` + + - Parameters: + - tacacs+: Enables remote authentication based on tacacs+ + - local: Disables remote authentication and uses local authentication + - default: Reset back to default value, which is only "local" authentication + + +- Example: + ``` + admin@sonic:~$ sudo config aaa authentication login tacacs+ + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#aaa--tacacs) + +### TACACS+ + +#### TACACS+ show commands + +**show tacacs** + +This command displays the global configuration fields and the list of all tacacs servers and their correponding configurations. + +- Usage: + ``` + show tacacs + ``` + +- Example: + ``` + admin@sonic:~$ show tacacs + TACPLUS global auth_type pap (default) + TACPLUS global timeout 99 + TACPLUS global passkey (default) + + TACPLUS_SERVER address 10.11.12.14 + priority 9 + tcp_port 50 + auth_type mschap + timeout 10 + passkey testing789 + + TACPLUS_SERVER address 10.0.0.9 + priority 1 + tcp_port 49 + ``` + +#### TACACS+ config commands + +This sub-section explains the command "config tacacs" and its sub-commands that are used to configure the following tacacs+ parameters. +Some of the parameters like authtype, passkey and timeout can be either configured at per server level or at global level (global value will be applied if there no server level configuration) + +1) Add/Delete the tacacs+ server details. +2) authtype - global configuration that is applied to all servers if there is no server specific configuration. +3) default - reset the authtype or passkey or timeout to the default values. +4) passkey - global configuration that is applied to all servers if there is no server specific configuration. +5) timeout - global configuration that is applied to all servers if there is no server specific configuration. + +**config tacacs add** + +This command is used to add a TACACS+ server to the tacacs server list. +Note that more than one tacacs+ (maximum of seven) can be added in the device. +When user tries to login, tacacs client shall contact the servers one by one. +When any server times out, device will try the next server one by one based on the priority value configured for that server. +When this command is executed, the configured tacacs+ server addresses are updated in /etc/pam.d/common-auth-sonic configuration file which is being used by tacacs service. + +- Usage: + ``` + config tacacs add [-t|--timeout ] [-k|--key ] [-a|--type ] [-o|--port ] [-p|--pri ] [-m|--use-mgmt-vrf] + ``` + + - Parameters: + - ip_address: TACACS+ server IP address. + - timeout: Transmission timeout interval in seconds, range 1 to 60, default 5 + - key: Shared secret + - type: Authentication type, "chap" or "pap" or "mschap" or "login", default is "pap". + - port: TCP port range is 1 to 65535, default 49 + - pri: Priority, priority range 1 to 64, default 1. + - use-mgmt-vrf: This means that the server is part of Management vrf, default is "no vrf" + + +- Example: + ``` + admin@sonic:~$ sudo config tacacs add 10.11.12.13 -t 10 -k testing789 -a mschap -o 50 -p 9 + ``` + + - Example Server Configuration in /etc/pam.d/common-auth-sonic configuration file: + ``` + auth [success=done new_authtok_reqd=done default=ignore] pam_tacplus.so server=10.11.12.14:50 secret=testing789 login=mschap timeout=10 try_first_pass + auth [success=done new_authtok_reqd=done default=ignore] pam_tacplus.so server=10.11.12.24:50 secret=testing789 login=mschap timeout=987654321098765433211 + 0987 try_first_pass + auth [success=done new_authtok_reqd=done default=ignore] pam_tacplus.so server=10.0.0.9:49 secret= login=mschap timeout=5 try_first_pass + auth [success=done new_authtok_reqd=done default=ignore] pam_tacplus.so server=10.0.0.8:49 secret= login=mschap timeout=5 try_first_pass + auth [success=done new_authtok_reqd=done default=ignore] pam_tacplus.so server=10.11.12.13:50 secret=testing789 login=mschap timeout=10 try_first_pass + auth [success=1 default=ignore] pam_unix.so nullok try_first_pass + ``` + + *NOTE: In the above example, the servers are stored (sorted) based on the priority value configured for the server.* + +**config tacacs delete** + +This command is used to delete the tacacs+ servers configured. + +- Usage: + ``` + config tacacs delete + ``` + +- Example: + ``` + admin@sonic:~$ sudo config tacacs delete 10.11.12.13 + ``` + +**config tacacs authtype** + +This command is used to modify the global value for the TACACS+ authtype. +When user has not configured server specific authtype, this global value shall be used for that server. + +- Usage: + ``` + config tacacs authtype (chap | pap | mschap | login) + ``` + +- Example: + ``` + admin@sonic:~$ sudo config tacacs authtype mschap + ``` + +**config tacacs default** + +This command is used to reset the global value for authtype or passkey or timeout to default value. +Default for authtype is "pap", default for passkey is EMPTY_STRING and default for timeout is 5 seconds. + +- Usage: + ``` + config tacacs default (authtype | passkey | timeout) + ``` + +- Example (This will reset the global authtype back to the default value "pap"): + ``` + admin@sonic:~$ sudo config tacacs default authtype + ``` + +**config tacacs passkey** + +This command is used to modify the global value for the TACACS+ passkey. +When user has not configured server specific passkey, this global value shall be used for that server. + +- Usage: + ``` + config tacacs passkey + ``` + +- Example: + ``` + admin@sonic:~$ sudo config tacacs passkey testing123 + ``` + +**config tacacs timeout** + +This command is used to modify the global value for the TACACS+ timeout. +When user has not configured server specific timeout, this global value shall be used for that server. + + +- Usage: + ``` + config tacacs [default] timeout [] + ``` + + - Options: + - Valid values for timeout is 1 to 60 seconds. + - When the optional keyword "default" is specified, timeout_value_in_seconds parameter wont be used; default value of 5 is used. + - Configuration using the keyword "default" is introduced in 201904 release. + +- Example: To configure non-default timeout value + ``` + admin@sonic:~$ sudo config tacacs timeout 60 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#aaa--tacacs) + + + +## ACL + +This section explains the various show commands and configuration commands available for users. + +### ACL show commands + +**show acl table** + +This command displays either all the ACL tables that are configured or only the specified "TABLE_NAME". +Output from the command displays the table name, type of the table, the list of interface(s) to which the table is bound and the description about the table. + +- Usage: + ``` + show acl table [] + ``` + +- Example: + ``` + admin@sonic:~$ show acl table + Name Type Binding Description Stage + -------- --------- --------------- ---------------- ------- + EVERFLOW MIRROR Ethernet16 EVERFLOW ingress + Ethernet96 + Ethernet108 + Ethernet112 + PortChannel0001 + PortChannel0002 + SNMP_ACL CTRLPLANE SNMP SNMP_ACL ingress + DT_ACL_T1 L3 Ethernet0 DATA_ACL_TABLE_1 egress + Ethernet4 + Ethernet112 + Ethernet116 + SSH_ONLY CTRLPLANE SSH SSH_ONLY ingress + ``` + +**show acl rule** + +This command displays all the ACL rules present in all the ACL tables or only the rules present in specified table "TABLE_NAME" or only the rule matching the RULE_ID option. +Output from the command gives the following information about the rules +1) Table name - ACL table name to which the rule belongs to. +2) Rule name - ACL rule name +3) Priority - Priority for this rule. +4) Action - Action to be performed if the packet matches with this ACL rule. + +It can be: +- "DROP"/"FORWARD"("ACCEPT" for control plane ACL) +- "REDIRECT: redirect-object" for redirect rule, where "redirect-object" is either: + - physical interface name, e.g. "Ethernet10" + - port channel name, e.g. "PortChannel0002" + - next-hop IP address, e.g. "10.0.0.1" + - next-hop group set of IP addresses with comma seperator, e.g. "10.0.0.1,10.0.0.3" +- "MIRROR INGRESS|EGRESS: session-name" for mirror rules, where "session-name" refers to mirror session + +Users can choose to have a default permit rule or default deny rule. In case of default "deny all" rule, add the permitted rules on top of the deny rule. In case of the default "permit all" rule, users can add the deny rules on top of it. If users have not confgured any rule, SONiC allows all traffic (which is "permit all"). + +5) Match - The fields from the packet header that need to be matched against the same present in the incoming traffic. + +- Usage: + ``` + show acl rule [] [] + ``` + +- Example: + ``` + admin@sonic:~$ show acl rule + Table Rule Priority Action Match + -------- ------------ ---------- ------------------------- ---------------------------- + SNMP_ACL RULE_1 9999 ACCEPT IP_PROTOCOL: 17 + SRC_IP: 1.1.1.1/32 + SSH_ONLY RULE_2 9998 ACCEPT IP_PROTOCOL: 6 + SRC_IP: 1.1.1.1/32 + EVERFLOW RULE_3 9997 MIRROR INGRESS: everflow0 SRC_IP: 20.0.0.2/32 + EVERFLOW RULE_4 9996 MIRROR EGRESS : everflow1 L4_SRC_PORT: 4621 + DATAACL RULE_5 9995 REDIRECT: Ethernet8 IP_PROTOCOL: 126 + DATAACL RULE_6 9994 FORWARD L4_SRC_PORT: 179 + DATAACL RULE_7 9993 FORWARD L4_DST_PORT: 179 + SNMP_ACL DEFAULT_RULE 1 DROP ETHER_TYPE: 2048 + SSH_ONLY DEFAULT_RULE 1 DROP ETHER_TYPE: 2048 + ``` + + +### ACL config commands +This sub-section explains the list of configuration options available for ACL module. +Note that there is no direct command to add or delete or modify the ACL table and ACL rule. +Existing ACL tables and ACL rules can be updated by specifying the ACL rules in json file formats and configure those files using this CLI command. + +**config acl update full** + +This command is to update the rules in all the tables or in one specific table in full. If a table_name is provided, the operation will be restricted in the specified table. All existing rules in the specified table or all tables will be removed. New rules loaded from file will be installed. If the table_name is specified, only rules within that table will be removed and new rules in that table will be installed. If the table_name is not specified, all rules from all tables will be removed and only the rules present in the input file will be added. + +The command does not modify anything in the list of acl tables. It modifies only the rules present in those pre-existing tables. + +In order to create acl tables, either follow the config_db.json method or minigraph method to populate the list of ACL tables. + +After creating tables, either the config_db.json method or the minigraph method or the CLI method (explained here) can be used to populate the rules in those ACL tables. + +This command updates only the ACL rules and it does not disturb the ACL tables; i.e. the output of "show acl table" is not alterted by using this command; only the output of "show acl rule" will be changed after this command. + +When "--session_name" optional argument is specified, command sets the session_name for the ACL table with this mirror session name. It fails if the specified mirror session name does not exist. + +When "--mirror_stage" optional argument is specified, command sets the mirror action to ingress/egress based on this parameter. By default command sets ingress mirror action in case argument is not specified. + +When the optional argument "max_priority" is specified, each rule’s priority is calculated by subtracting its “sequence_id” value from the “max_priority”. If this value is not passed, the default “max_priority” 10000 is used. + +- Usage: + ``` + config acl update full [--table_name ] [--session_name ] [--mirror_stage (ingress | egress)] [--max_priority ] + ``` + + - Parameters: + - table_name: Specifiy the name of the ACL table to load. Example: config acl update full "--table_name DT_ACL_T1 /etc/sonic/acl_table_1.json" + - session_name: Specifiy the name of the ACL session to load. Example: config acl update full "--session_name mirror_ses1 /etc/sonic/acl_table_1.json" + - priority_value: Specify the maximum priority to use when loading ACL rules. Example: config acl update full "--max-priority 100 /etc/sonic/acl_table_1.json" + + *NOTE 1: All these optional parameters should be inside double quotes. If none of the options are provided, double quotes are not required for specifying filename alone.* + *NOTE 2: Any number of optional parameters can be configured in the same command.* + +- Examples: + ``` + admin@sonic:~$ sudo config acl update full /etc/sonic/acl_full_snmp_1_2_ssh_4.json + admin@sonic:~$ sudo config acl update full "--table_name SNMP-ACL /etc/sonic/acl_full_snmp_1_2_ssh_4.json" + admin@sonic:~$ sudo config acl update full "--session_name everflow0 /etc/sonic/acl_full_snmp_1_2_ssh_4.json" + ``` + + This command will remove all rules from all the ACL tables and insert all the rules present in this input file. + Refer the example file [acl_full_snmp_1_2_ssh_4.json](#) that adds two rules for SNMP (Rule1 and Rule2) and one rule for SSH (Rule4) + Refer an example for input file format [here](https://github.com/Azure/sonic-mgmt/blob/master/ansible/roles/test/files/helpers/config_service_acls.sh) + Refer another example [here](https://github.com/Azure/sonic-mgmt/blob/master/ansible/roles/test/tasks/acl/acltb_test_rules_part_1.json) + +**config acl update incremental** + +This command is used to perform incremental update of ACL rule table. This command gets existing rules from Config DB and compares with rules specified in input file and performs corresponding modifications. + +With respect to DATA ACLs, the command does not assume that new dataplane ACLs can be inserted in betweeen by shifting existing ACLs in all ASICs. Therefore, this command performs a full update on dataplane ACLs. +With respect to control plane ACLs, this command performs an incremental update. +If we assume that "file1.json" is the already loaded ACL rules file and if "file2.json" is the input file that is passed as parameter for this command, the following requirements are valid for the input file. +1) First copy the file1.json to file2.json. +2) Remove the unwanted ACL rules from file2.json +3) Add the newly required ACL rules into file2.json. +4) Modify the existing ACL rules (that require changes) in file2.json. + +NOTE: If any ACL rule that is already available in file1.json is required even after this command execution, such rules should remain unalterted in file2.json. Don't remove them. +Note that "incremental" is working like "full". + +When "--session_name" optional argument is specified, command sets the session_name for the ACL table with this mirror session name. It fails if the specified mirror session name does not exist. + +When "--mirror_stage" optional argument is specified, command sets the mirror action to ingress/egress based on this parameter. By default command sets ingress mirror action in case argument is not specified. + +When the optional argument "max_priority" is specified, each rule’s priority is calculated by subtracting its “sequence_id” value from the “max_priority”. If this value is not passed, the default “max_priority” 10000 is used. + +- Usage: + ``` + config acl update incremental [--session_name ] [--mirror_stage (ingress | egress)] [--max_priority ] + ``` + + - Parameters: + - table_name: Specifiy the name of the ACL table to load. Example: config acl update full "--table_name DT_ACL_T1 /etc/sonic/acl_table_1.json" + - session_name: Specifiy the name of the ACL session to load. Example: config acl update full "--session_name mirror_ses1 /etc/sonic/acl_table_1.json" + - priority_value: Specify the maximum priority to use when loading ACL rules. Example: config acl update full "--max-priority 100 /etc/sonic/acl_table_1.json" + + *NOTE 1: All these optional parameters should be inside double quotes. If none of the options are provided, double quotes are not required for specifying filename alone.* + *NOTE 2: Any number of optional parameters can be configured in the same command.* + +- Examples: + ``` + admin@sonic:~$ sudo config acl update incremental /etc/sonic/acl_incremental_snmp_1_3_ssh_4.json + ``` + ``` + admin@sonic:~$ sudo config acl update incremental "--session_name everflow0 /etc/sonic/acl_incremental_snmp_1_3_ssh_4.json" + ``` + + Refer the example file [acl_incremental_snmp_1_3_ssh_4.json](#) that adds two rules for SNMP (Rule1 and Rule3) and one rule for SSH (Rule4) + When this "incremental" command is executed after "full" command, it has removed SNMP Rule2 and added SNMP Rule3 in the example. + File "acl_full_snmp_1_2_ssh_4.json" has got SNMP Rule1, SNMP Rule2 and SSH Rule4. + File "acl_incremental_snmp_1_3_ssh_4.json" has got SNMP Rule1, SNMP Rule3 and SSH Rule4. + This file is created by copying the file "acl_full_snmp_1_2_ssh_4.json" to "acl_incremental_snmp_1_3_ssh_4.json" and then removing SNMP Rule2 and adding SNMP Rule3. + +Go Back To [Beginning of the document](#) or [Beginning of this section](#acl) + +**config acl add table** + +This command is used to create new ACL tables. + +- Usage: + ``` + config acl add table [OPTIONS] [-d ] [-p ] [-s (ingress | egress)] + ``` + +- Parameters: + - table_name: The name of the ACL table to create. + - table_type: The type of ACL table to create (e.g. "L3", "L3V6", "MIRROR") + - description: A description of the table for the user. (default is the table_name) + - ports: A comma-separated list of ports/interfaces to add to the table. The behavior is as follows: + - Physical ports will be bound as physical ports + - Portchannels will be bound as portchannels - passing a portchannel member is invalid + - VLANs will be expanded into their members (e.g. "Vlan1000" will become "Ethernet0,Ethernet2,Ethernet4...") + - stage: The stage this ACL table will be applied to, either ingress or egress. (default is ingress) + +- Examples: + ``` + admin@sonic:~$ sudo config acl add table EXAMPLE L3 -p Ethernet0,Ethernet4 -s ingress + ``` + ``` + admin@sonic:~$ sudo config acl add table EXAMPLE_2 L3V6 -p Vlan1000,PortChannel0001,Ethernet128 -s egress + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#acl) + + +## ARP & NDP + +### ARP show commands + +**show arp** + +This command displays the ARP entries in the device with following options. +1) Display the entire table. +2) Display the ARP entries learnt on a specific interface. +3) Display the ARP of a specific ip-address. + +- Usage: + ``` + show arp [-if ] [] + ``` + +- Details: + - show arp: Displays all entries + - show arp -if : Displays the ARP specific to the specified interface. + - show arp : Displays the ARP specific to the specicied ip-address. + + +- Example: + ``` + admin@sonic:~$ show arp + Address MacAddress Iface Vlan + ------------- ----------------- ------- ------ + 192.168.1.183 88:5a:92:fb:bf:41 Ethernet44 - + 192.168.1.175 88:5a:92:fc:95:81 Ethernet28 - + 192.168.1.181 e4:c7:22:c1:07:7c Ethernet40 - + 192.168.1.179 88:5a:92:de:a8:bc Ethernet36 - + 192.168.1.118 00:1c:73:3c:de:43 Ethernet64 - + 192.168.1.11 00:1c:73:3c:e1:38 Ethernet88 - + 192.168.1.161 24:e9:b3:71:3a:01 Ethernet0 - + 192.168.1.189 24:e9:b3:9d:57:41 Ethernet56 - + 192.168.1.187 74:26:ac:8b:8f:c1 Ethernet52 - + 192.168.1.165 88:5a:92:de:a0:7c Ethernet8 - + + Total number of entries 10 + ``` + +Optionally, you can specify the interface in order to display the ARPs learnt on that particular interface + +- Example: + ``` + admin@sonic:~$ show arp -if Ethernet40 + Address MacAddress Iface Vlan + ------------- ----------------- ---------- ------ + 192.168.1.181 e4:c7:22:c1:07:7c Ethernet40 - + Total number of entries 1 + ``` + +Optionally, you can specify an IP address in order to display only that particular entry + +- Example: + ``` + admin@sonic:~$ show arp 192.168.1.181 + Address MacAddress Iface Vlan + ------------- ----------------- ---------- ------ + 192.168.1.181 e4:c7:22:c1:07:7c Ethernet40 - + Total number of entries 1 + ``` + +### NDP show commands + +**show ndp** + +This command displays either all the IPv6 neighbor mac addresses, or for a particular IPv6 neighbor, or for all IPv6 neighbors reachable via a specific interface. + +- Usage: + ``` + show ndp [-if|--iface ] + ``` + +- Example (show all IPv6 neighbors): + ``` + admin@sonic:~$ show ndp + Address MacAddress Iface Vlan Status + ------------------------ ----------------- ------- ------ --------- + fe80::20c:29ff:feb8:b11e 00:0c:29:b8:b1:1e eth0 - REACHABLE + fe80::20c:29ff:feb8:cff0 00:0c:29:b8:cf:f0 eth0 - REACHABLE + fe80::20c:29ff:fef9:324 00:0c:29:f9:03:24 eth0 - REACHABLE + Total number of entries 3 + ``` + +- Example (show specific IPv6 neighbor): + ``` + admin@sonic:~$ show ndp fe80::20c:29ff:feb8:b11e + Address MacAddress Iface Vlan Status + ------------------------ ----------------- ------- ------ --------- + fe80::20c:29ff:feb8:b11e 00:0c:29:b8:b1:1e eth0 - REACHABLE + Total number of entries 1 + ``` + +- Example (show IPv6 neighbors learned on a specific interface): + ``` + admin@sonic:~$ show ndp -if eth0 + Address MacAddress Iface Vlan Status + ------------------------ ----------------- ------- ------ --------- + fe80::20c:29ff:feb8:b11e 00:0c:29:b8:b1:1e eth0 - REACHABLE + fe80::20c:29ff:feb8:cff0 00:0c:29:b8:cf:f0 eth0 - REACHABLE + fe80::20c:29ff:fef9:324 00:0c:29:f9:03:24 eth0 - REACHABLE + Total number of entries 3 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#arp--ndp) + +## BFD + +### BFD show commands + +**show bfd summary** + +This command displays the state and key parameters of all BFD sessions. + +- Usage: + ``` + show bgp summary + ``` +- Example: + ``` + >> show bfd summary + Total number of BFD sessions: 3 + Peer Addr Interface Vrf State Type Local Addr TX Interval RX Interval Multiplier Multihop + ----------- ----------- ------- ------- ------------ ------------ ------------- ------------- ------------ ---------- + 10.0.1.1 default default DOWN async_active 10.0.0.1 300 500 3 true + 10.0.2.1 Ethernet12 default UP async_active 10.0.0.1 200 600 3 false + 2000::10:1 default default UP async_active 2000::1 100 700 3 false + ``` + +**show bfd peer** + +This command displays the state and key parameters of all BFD sessions that match an IP address. + +- Usage: + ``` + show bgp peer + ``` +- Example: + ``` + >> show bfd peer 10.0.1.1 + Total number of BFD sessions for peer IP 10.0.1.1: 1 + Peer Addr Interface Vrf State Type Local Addr TX Interval RX Interval Multiplier Multihop + ----------- ----------- ------- ------- ------------ ------------ ------------- ------------- ------------ ---------- + 10.0.1.1 default default DOWN async_active 10.0.0.1 300 500 3 true + ``` + +## BGP + +This section explains all the BGP show commands and BGP configuation commands in both "Quagga" and "FRR" routing software that are supported in SONiC. +In 201811 and older verisons "Quagga" was enabled by default. In current version "FRR" is enabled by default. +Most of the FRR show commands start with "show bgp". Similar commands in Quagga starts with "show ip bgp". All sub-options supported in all these show commands are common for FRR and Quagga. +Detailed show commands examples for Quagga are provided at the end of this document.This section captures only the commands supported by FRR. + +### BGP show commands + + +**show bgp summary (Versions >= 201904 using default FRR routing stack)** + +**show ip bgp summary (Versions <= 201811 using Quagga routing stack)** + +This command displays the summary of all IPv4 & IPv6 bgp neighbors that are configured and the corresponding states. + +- Usage: + + *Versions >= 201904 using default FRR routing stack* + ``` + show bgp summary + ``` + *Versions <= 201811 using Quagga routing stack* + ``` + show ip bgp summary + ``` + +- Example: + ``` + admin@sonic:~$ show ip bgp summary + + IPv4 Unicast Summary: + BGP router identifier 10.1.0.32, local AS number 65100 vrf-id 0 + BGP table version 6465 + RIB entries 12807, using 2001 KiB of memory + Peers 4, using 83 KiB of memory + Peer groups 2, using 128 bytes of memory + + Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd NeighborName + 10.0.0.57 4 64600 3995 4001 0 0 0 00:39:32 6400 Lab-T1-01 + 10.0.0.59 4 64600 3995 3998 0 0 0 00:39:32 6400 Lab-T1-02 + 10.0.0.61 4 64600 3995 4001 0 0 0 00:39:32 6400 Lab-T1-03 + 10.0.0.63 4 64600 3995 3998 0 0 0 00:39:32 6400 NotAvailable + + Total number of neighbors 4 + ``` + +- Example: + ``` + admin@sonic:~$ show bgp summary + + IPv4 Unicast Summary: + BGP router identifier 10.1.0.32, local AS number 65100 vrf-id 0 + BGP table version 6465 + RIB entries 12807, using 2001 KiB of memory + Peers 4, using 83 KiB of memory + Peer groups 2, using 128 bytes of memory + + Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd + 10.0.0.57 4 64600 3995 4001 0 0 0 00:39:32 6400 + 10.0.0.59 4 64600 3995 3998 0 0 0 00:39:32 6400 + 10.0.0.61 4 64600 3995 4001 0 0 0 00:39:32 6400 + 10.0.0.63 4 64600 3995 3998 0 0 0 00:39:32 6400 + + Total number of neighbors 4 + + IPv6 Unicast Summary: + BGP router identifier 10.1.0.32, local AS number 65100 vrf-id 0 + BGP table version 12803 + RIB entries 12805, using 2001 KiB of memory + Peers 4, using 83 KiB of memory + Peer groups 2, using 128 bytes of memory + + Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd + fc00::72 4 64600 3995 5208 0 0 0 00:39:30 6400 + fc00::76 4 64600 3994 5208 0 0 0 00:39:30 6400 + fc00::7a 4 64600 3993 5208 0 0 0 00:39:30 6400 + fc00::7e 4 64600 3993 5208 0 0 0 00:39:30 6400 + + Total number of neighbors 4 + ``` + Click [here](#Quagga-BGP-Show-Commands) to see the example for "show ip bgp summary" for Quagga. + + + +**show bgp neighbors (Versions >= 201904 using default FRR routing stack)** + +**show ip bgp neighbors (Versions <= 201811 using Quagga routing stack)** + +This command displays all the details of IPv4 & IPv6 BGP neighbors when no optional argument is specified. + +When the optional argument IPv4_address is specified, it displays the detailed neighbor information about that specific IPv4 neighbor. + +Command has got additional optional arguments to display only the advertised routes, or the received routes, or all routes. + +In order to get details for an IPv6 neigbor, use "show bgp ipv6 neighbor " command. + + +- Usage: + + *Versions >= 201904 using default FRR routing stack* + ``` + show bgp neighbors [ [advertised-routes | received-routes | routes]] + ``` + *Versions <= 201811 using Quagga routing stack* + ``` + show ip bgp neighbors [ [advertised-routes | received-routes | routes]] + ``` + +- Example: + ``` + admin@sonic:~$ show bgp neighbors + BGP neighbor is 10.0.0.57, remote AS 64600, local AS 65100, external link + Description: ARISTA01T1 + BGP version 4, remote router ID 100.1.0.29, local router ID 10.1.0.32 + BGP state = Established, up for 00:42:15 + Last read 00:00:00, Last write 00:00:03 + Hold time is 10, keepalive interval is 3 seconds + Configured hold time is 10, keepalive interval is 3 seconds + Neighbor capabilities: + 4 Byte AS: advertised and received + AddPath: + IPv4 Unicast: RX advertised IPv4 Unicast and received + Route refresh: advertised and received(new) + Address Family IPv4 Unicast: advertised and received + Hostname Capability: advertised (name: sonic-z9264f-9251,domain name: n/a) not received + Graceful Restart Capabilty: advertised and received + Remote Restart timer is 300 seconds + Address families by peer: + none + Graceful restart information: + End-of-RIB send: IPv4 Unicast + End-of-RIB received: IPv4 Unicast + Message statistics: + Inq depth is 0 + Outq depth is 0 + Sent Rcvd + Opens: 2 1 + Notifications: 2 0 + Updates: 3206 3202 + Keepalives: 845 847 + Route Refresh: 0 0 + Capability: 0 0 + Total: 4055 4050 + Minimum time between advertisement runs is 0 seconds + + For address family: IPv4 Unicast + Update group 1, subgroup 1 + Packet Queue length 0 + Inbound soft reconfiguration allowed + Community attribute sent to this neighbor(all) + 6400 accepted prefixes + + Connections established 1; dropped 0 + Last reset 00:42:37, due to NOTIFICATION sent (Cease/Connection collision resolution) + Local host: 10.0.0.56, Local port: 179 + Foreign host: 10.0.0.57, Foreign port: 46419 + Nexthop: 10.0.0.56 + Nexthop global: fc00::71 + Nexthop local: fe80::2204:fff:fe36:9449 + BGP connection: shared network + BGP Connect Retry Timer in Seconds: 120 + Read thread: on Write thread: on + ``` + +Optionally, you can specify an IP address in order to display only that particular neighbor. In this mode, you can optionally specify whether you want to display all routes advertised to the specified neighbor, all routes received from the specified neighbor or all routes (received and accepted) from the specified neighbor. + +- Example: + ``` + admin@sonic:~$ show bgp neighbors 10.0.0.57 + + admin@sonic:~$ show bgp neighbors 10.0.0.57 advertised-routes + + admin@sonic:~$ show bgp neighbors 10.0.0.57 received-routes + + admin@sonic:~$ show bgp neighbors 10.0.0.57 routes + ``` + + Click [here](#Quagga-BGP-Show-Commands) to see the example for "show ip bgp neighbors" for Quagga. + + +**show ip bgp network [[|] [(bestpath | multipath | longer-prefixes | json)]] + +This command displays all the details of IPv4 Border Gateway Protocol (BGP) prefixes. + +- Usage: + + + ``` + show ip bgp network [[|] [(bestpath | multipath | longer-prefixes | json)]] + ``` + +- Example: + + NOTE: The "longer-prefixes" option is only available when a network prefix with a "/" notation is used. + + ``` + admin@sonic:~$ show ip bgp network + + admin@sonic:~$ show ip bgp network 10.1.0.32 bestpath + + admin@sonic:~$ show ip bgp network 10.1.0.32 multipath + + admin@sonic:~$ show ip bgp network 10.1.0.32 json + + admin@sonic:~$ show ip bgp network 10.1.0.32/32 bestpath + + admin@sonic:~$ show ip bgp network 10.1.0.32/32 multipath + + admin@sonic:~$ show ip bgp network 10.1.0.32/32 json + + admin@sonic:~$ show ip bgp network 10.1.0.32/32 longer-prefixes + ``` + +**show bgp ipv6 summary (Versions >= 201904 using default FRR routing stack)** + +**show ipv6 bgp summary (Versions <= 201811 using Quagga routing stack)** + +This command displays the summary of all IPv6 bgp neighbors that are configured and the corresponding states. + +- Usage: + + *Versions >= 201904 using default FRR routing stack* + ``` + show bgp ipv6 summary + ``` + *Versions <= 201811 using Quagga routing stack* + ``` + show ipv6 bgp summary + ``` + +- Example: + ``` + admin@sonic:~$ show bgp ipv6 summary + BGP router identifier 10.1.0.32, local AS number 65100 vrf-id 0 + BGP table version 12803 + RIB entries 12805, using 2001 KiB of memory + Peers 4, using 83 KiB of memory + Peer groups 2, using 128 bytes of memory + + Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd NeighborName + fc00::72 4 64600 3995 5208 0 0 0 00:39:30 6400 Lab-T1-01 + fc00::76 4 64600 3994 5208 0 0 0 00:39:30 6400 Lab-T1-02 + fc00::7a 4 64600 3993 5208 0 0 0 00:39:30 6400 Lab-T1-03 + fc00::7e 4 64600 3993 5208 0 0 0 00:39:30 6400 Lab-T1-04 + + Total number of neighbors 4 + ``` + Click [here](#Quagga-BGP-Show-Commands) to see the example for "show ipv6 bgp summary" for Quagga. + + + +**show bgp ipv6 neighbors (Versions >= 201904 using default FRR routing stack)** + +**show ipv6 bgp neighbors (Versions <= 201811 using Quagga routing stack)** + +This command displays all the details of one particular IPv6 Border Gateway Protocol (BGP) neighbor. Option is also available to display only the advertised routes, or the received routes, or all routes. + + +- Usage: + + *Versions >= 201904 using default FRR routing stack* + ``` + show bgp ipv6 neighbors [ [(advertised-routes | received-routes | routes)]] + ``` + *Versions <= 201811 using Quagga routing stack* + ``` + show ipv6 bgp neighbors [ [(advertised-routes | received-routes | routes)]] + ``` + +- Example: + ``` + admin@sonic:~$ show bgp ipv6 neighbors fc00::72 advertised-routes + + admin@sonic:~$ show bgp ipv6 neighbors fc00::72 received-routes + + admin@sonic:~$ show bgp ipv6 neighbors fc00::72 routes + ``` + Click [here](#Quagga-BGP-Show-Commands) to see the example for "show ip bgp summary" for Quagga. + + +**show ipv6 bgp network [[|] [(bestpath | multipath | longer-prefixes | json)]] + +This command displays all the details of IPv6 Border Gateway Protocol (BGP) prefixes. + +- Usage: + + + ``` + show ipv6 bgp network [[|] [(bestpath | multipath | longer-prefixes | json)]] + ``` + +- Example: + + NOTE: The "longer-prefixes" option is only available when a network prefix with a "/" notation is used. + + ``` + admin@sonic:~$ show ipv6 bgp network + + admin@sonic:~$ show ipv6 bgp network fc00::72 bestpath + + admin@sonic:~$ show ipv6 bgp network fc00::72 multipath + + admin@sonic:~$ show ipv6 bgp network fc00::72 json + + admin@sonic:~$ show ipv6 bgp network fc00::72/64 bestpath + + admin@sonic:~$ show ipv6 bgp network fc00::72/64 multipath + + admin@sonic:~$ show ipv6 bgp network fc00::72/64 json + + admin@sonic:~$ show ipv6 bgp network fc00::72/64 longer-prefixes + ``` + + + + +**show route-map** + +This command displays the routing policy that takes precedence over the other route processes that are configured. + +- Usage: + ``` + show route-map + ``` + +- Example: + ``` + admin@sonic:~$ show route-map + ZEBRA: + route-map RM_SET_SRC, permit, sequence 10 + Match clauses: + Set clauses: + src 10.12.0.102 + Call clause: + Action: + Exit routemap + ZEBRA: + route-map RM_SET_SRC6, permit, sequence 10 + Match clauses: + Set clauses: + src fc00:1::102 + Call clause: + Action: + Exit routemap + BGP: + route-map FROM_BGP_SPEAKER_V4, permit, sequence 10 + Match clauses: + Set clauses: + Call clause: + Action: + Exit routemap + BGP: + route-map TO_BGP_SPEAKER_V4, deny, sequence 10 + Match clauses: + Set clauses: + Call clause: + Action: + Exit routemap + BGP: + route-map ISOLATE, permit, sequence 10 + Match clauses: + Set clauses: + as-path prepend 65000 + Call clause: + Action: + Exit routemap + ``` + + +### BGP config commands + +This sub-section explains the list of configuration options available for BGP module for both IPv4 and IPv6 BGP neighbors. + +**config bgp shutdown all** + +This command is used to shutdown all the BGP IPv4 & IPv6 sessions. +When the session is shutdown using this command, BGP state in "show ip bgp summary" is displayed as "Idle (Admin)" + +- Usage: + ``` + config bgp shutdown all + ``` + +- Example: + ``` + admin@sonic:~$ sudo config bgp shutdown all + ``` + +**config bgp shutdown neighbor** + +This command is to shut down a BGP session with a neighbor by that neighbor's IP address or hostname + +- Usage: + ``` + sudo config bgp shutdown neighbor ( | ) + ``` + +- Examples: + ``` + admin@sonic:~$ sudo config bgp shutdown neighbor 192.168.1.124 + ``` + ``` + admin@sonic:~$ sudo config bgp shutdown neighbor SONIC02SPINE + ``` + + +**config bgp startup all** + +This command is used to start up all the IPv4 & IPv6 BGP neighbors + +- Usage: + ``` + config bgp startup all + ``` + +- Example: + ``` + admin@sonic:~$ sudo config bgp startup all + ``` + + +**config bgp startup neighbor** + +This command is used to start up the particular IPv4 or IPv6 BGP neighbor using either the IP address or hostname. + +- Usage: + ``` + config bgp startup neighbor ( | ) + ``` + +- Examples: + ``` + admin@sonic:~$ sudo config bgp startup neighbor 192.168.1.124 + ``` + ``` + admin@sonic:~$ sudo config bgp startup neighbor SONIC02SPINE + ``` + + +**config bgp remove neighbor** + +This command is used to remove particular IPv4 or IPv6 BGP neighbor configuration using either the IP address or hostname. + +- Usage: + ``` + config bgp remove neighbor + ``` + +- Examples: + ``` + admin@sonic:~$ sudo config bgp remove neighbor 192.168.1.124 + ``` + ``` + admin@sonic:~$ sudo config bgp remove neighbor 2603:10b0:b0f:346::4a + ``` + ``` + admin@sonic:~$ sudo config bgp remove neighbor SONIC02SPINE + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#bgp) + +## Console + +This section explains all Console show commands and configuration options that are supported in SONiC. + +All commands are used only when SONiC is used as console switch. + +All commands under this section are not applicable when SONiC used as regular switch. + +### Console show commands + +**show line** + +This command displays serial port or a virtual network connection status. + +- Usage: + ``` + show line (-b|--breif) + ``` + +- Example: + ``` + admin@sonic:~$ show line + Line Baud Flow Control PID Start Time Device + ------ ------ -------------- ----- ------------ -------- + 1 9600 Enabled - - switch1 + 2 - Disabled - - + 3 - Disabled - - + 4 - Disabled - - + 5 - Disabled - - + ``` + +Optionally, you can display configured console ports only by specifying the `-b` or `--breif` flag. + +- Example: + ``` + admin@sonic:~$ show line -b + Line Baud Flow Control PID Start Time Device + ------ ------ -------------- ----- ------------ -------- + 1 9600 Enabled - - switch1 + ``` + +## Console config commands + +This sub-section explains the list of configuration options available for console management module. + +**config console enable** + +This command is used to enable SONiC console switch feature. + +- Usage: + ``` + config console enable + ``` + +- Example: + ``` + admin@sonic:~$ sudo config console enable + ``` + +**config console disable** + +This command is used to disable SONiC console switch feature. + +- Usage: + ``` + config console disable + ``` + +- Example: + ``` + admin@sonic:~$ sudo config console disable + ``` + +**config console add** + +This command is used to add a console port setting. + +- Usage: + ``` + config console add [--baud|-b ] [--flowcontrol|-f] [--devicename|-d ] + ``` + +- Example: + ``` + admin@sonic:~$ config console add 1 --baud 9600 --devicename switch1 + ``` + +**config console del** + +This command is used to remove a console port setting. + +- Usage: + ``` + config console del + ``` + +- Example: + ``` + admin@sonic:~$ sudo config console del 1 + ``` + +**config console remote_device** + +This command is used to update the remote device name for a console port. + +- Usage: + ``` + config console remote_device + ``` + +- Example: + ``` + admin@sonic:~$ sudo config console remote_device 1 switch1 + ``` + +**config console baud** + +This command is used to update the baud rate for a console port. + +- Usage: + ``` + config console baud + ``` + +- Example: + ``` + admin@sonic:~$ sudo config console baud 1 9600 + ``` + +**config console flow_control** + +This command is used to enable or disable flow control feature for a console port. + +- Usage: + ``` + config console flow_control {enable|disable} + ``` + +- Example: + ``` + admin@sonic:~$ sudo config console flow_control enable 1 + ``` + +### Console connect commands + +**connect line** + +This command allows user to connect to a remote device via console line with an interactive cli. + +- Usage: + ``` + connect line (-d|--devicename) + ``` + +By default, the target is `port_name`. + +- Example: + ``` + admin@sonic:~$ connect line 1 + Successful connection to line 1 + Press ^A ^X to disconnect + ``` + +Optionally, you can connect with a remote device name by specifying the `-d` or `--devicename` flag. + +- Example: + ``` + admin@sonic:~$ connect line --devicename switch1 + Successful connection to line 1 + Press ^A ^X to disconnect + ``` + +**connect device** + +This command allows user to connect to a remote device via console line with an interactive cli. + +- Usage: + ``` + connect device + ``` + +The command is same with `connect line --devicename ` + +- Example: + ``` + admin@sonic:~$ connect line 1 + Successful connection to line 1 + Press ^A ^X to disconnect + ``` + +### Console clear commands + +**sonic-clear line** + +This command allows user to connect to a remote device via console line with an interactive cli. + +- Usage: + ``` + sonc-clear line (-d|--devicename) + ``` + +By default, the target is `port_name`. + +- Example: + ``` + admin@sonic:~$ sonic-clear line 1 + ``` + +Optionally, you can clear with a remote device name by specifying the `-d` or `--devicename` flag. + +- Example: + ``` + admin@sonic:~$ sonic-clear --devicename switch1 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#console) + + +## DHCP Relay + +### DHCP Relay config commands + +This sub-section of commands is used to add or remove the DHCP Relay Destination IP address(es) for a VLAN interface. + +**config vlan dhcp_relay add** + +This command is used to add a DHCP Relay Destination IP address or multiple IP addresses to a VLAN. Note that more than one DHCP Relay Destination IP address can be added on a VLAN interface. + +- Usage: + ``` + config vlan dhcp_relay add + ``` + +- Example: + ``` + admin@sonic:~$ sudo config vlan dhcp_relay add 1000 7.7.7.7 + Added DHCP relay destination address ['7.7.7.7'] to Vlan1000 + Restarting DHCP relay service... + ``` + ``` + admin@sonic:~$ sudo config vlan dhcp_relay add 1000 7.7.7.7 1.1.1.1 + Added DHCP relay destination address ['7.7.7.7', '1.1.1.1'] to Vlan1000 + Restarting DHCP relay service... + ``` + +**config vlan dhcp_relay delete** + +This command is used to delete a configured DHCP Relay Destination IP address or multiple IP addresses from a VLAN interface. + +- Usage: + ``` + config vlan dhcp_relay del + ``` + +- Example: + ``` + admin@sonic:~$ sudo config vlan dhcp_relay del 1000 7.7.7.7 + Removed DHCP relay destination address 7.7.7.7 from Vlan1000 + Restarting DHCP relay service... + ``` + ``` + admin@sonic:~$ sudo config vlan dhcp_relay del 1000 7.7.7.7 1.1.1.1 + Removed DHCP relay destination address ('7.7.7.7', '1.1.1.1') from Vlan1000 + Restarting DHCP relay service... + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#dhcp-relay) + + +## Drop Counters + +This section explains all the Configurable Drop Counters show commands and configuration options that are supported in SONiC. + +### Drop Counters show commands + +**show dropcounters capabilities** + +This command is used to show the drop counter capabilities that are available on this device. It displays the total number of drop counters that can be configured on this device as well as the drop reasons that can be configured for the counters. + +- Usage: + ``` + show dropcounters capabilities + ``` + +- Examples: + ``` + admin@sonic:~$ show dropcounters capabilities + Counter Type Total + -------------------- ------- + PORT_INGRESS_DROPS 3 + SWITCH_EGRESS_DROPS 2 + + PORT_INGRESS_DROPS: + L2_ANY + SMAC_MULTICAST + SMAC_EQUALS_DMAC + INGRESS_VLAN_FILTER + EXCEEDS_L2_MTU + SIP_CLASS_E + SIP_LINK_LOCAL + DIP_LINK_LOCAL + UNRESOLVED_NEXT_HOP + DECAP_ERROR + + SWITCH_EGRESS_DROPS: + L2_ANY + L3_ANY + A_CUSTOM_REASON + ``` + +**show dropcounters configuration** + +This command is used to show the current running configuration of the drop counters on this device. + +- Usage: + ``` + show dropcounters configuration [-g ] + ``` + +- Examples: + ``` + admin@sonic:~$ show dropcounters configuration + Counter Alias Group Type Reasons Description + -------- -------- ----- ------------------ ------------------- -------------- + DEBUG_0 RX_LEGIT LEGIT PORT_INGRESS_DROPS SMAC_EQUALS_DMAC Legitimate port-level RX pipeline drops + INGRESS_VLAN_FILTER + DEBUG_1 TX_LEGIT None SWITCH_EGRESS_DROPS EGRESS_VLAN_FILTER Legitimate switch-level TX pipeline drops + + admin@sonic:~$ show dropcounters configuration -g LEGIT + Counter Alias Group Type Reasons Description + -------- -------- ----- ------------------ ------------------- -------------- + DEBUG_0 RX_LEGIT LEGIT PORT_INGRESS_DROPS SMAC_EQUALS_DMAC Legitimate port-level RX pipeline drops + INGRESS_VLAN_FILTER + ``` + +**show dropcounters counts** + +This command is used to show the current statistics for the configured drop counters. Standard drop counters are displayed as well for convenience. + +Because clear (see below) is handled on a per-user basis different users may see different drop counts. + +- Usage: + ``` + show dropcounters counts [-g ] [-t ] + ``` + +- Example: + ``` + admin@sonic:~$ show dropcounters counts + IFACE STATE RX_ERR RX_DROPS TX_ERR TX_DROPS RX_LEGIT + --------- ------- -------- ---------- -------- ---------- --------- + Ethernet0 U 10 100 0 0 20 + Ethernet4 U 0 1000 0 0 100 + Ethernet8 U 100 10 0 0 0 + + DEVICE TX_LEGIT + ------ -------- + sonic 1000 + + admin@sonic:~$ show dropcounters counts -g LEGIT + IFACE STATE RX_ERR RX_DROPS TX_ERR TX_DROPS RX_LEGIT + --------- ------- -------- ---------- -------- ---------- --------- + Ethernet0 U 10 100 0 0 20 + Ethernet4 U 0 1000 0 0 100 + Ethernet8 U 100 10 0 0 0 + + admin@sonic:~$ show dropcounters counts -t SWITCH_EGRESS_DROPS + DEVICE TX_LEGIT + ------ -------- + sonic 1000 + ``` + +### Drop Counters config commands + +**config dropcounters install** + +This command is used to initialize a new drop counter. The user must specify a name, type, and initial list of drop reasons. + +This command will fail if the given name is already in use, if the type of counter is not supported, or if any of the specified drop reasons are not supported. It will also fail if all avaialble counters are already in use on the device. + +- Usage: + ``` + config dropcounters install [-d ] [-g ] [-a ] + ``` + +- Example: + ``` + admin@sonic:~$ sudo config dropcounters install DEBUG_2 PORT_INGRESS_DROPS [EXCEEDS_L2_MTU,DECAP_ERROR] -d "More port ingress drops" -g BAD -a BAD_DROPS + ``` + +**config dropcounters add_reasons** + +This command is used to add drop reasons to an already initialized counter. + +This command will fail if any of the specified drop reasons are not supported. + +- Usage: + ``` + config dropcounters add_reasons + ``` + +- Example: + ``` + admin@sonic:~$ sudo config dropcounters add_reasons DEBUG_2 [SIP_CLASS_E] + ``` + +**config dropcounters remove_reasons** + +This command is used to remove drop reasons from an already initialized counter. + +- Usage: + ``` + config dropcounters remove_reasons + ``` + +- Example: + ``` + admin@sonic:~$ sudo config dropcounters remove_reasons DEBUG_2 [SIP_CLASS_E] + ``` + +**config dropcounters delete** + +This command is used to delete a drop counter. + +- Usage: + ``` + config dropcounters delete + ``` + +- Example: + ``` + admin@sonic:~$ sudo config dropcounters delete DEBUG_2 + ``` + +### Drop Counters clear commands + +**sonic-clear dropcounters** + +This comnmand is used to clear drop counters. This is done on a per-user basis. + +- Usage: + ``` + sonic-clear dropcounters + ``` + +- Example: + ``` + admin@sonic:~$ sonic-clear dropcounters + Cleared drop counters + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](##drop-counters) + +## Dynamic Buffer Management + +This section explains all the show and configuration commands regarding the dynamic buffer management. + +Dynamic buffer management is responsible for calculating buffer size according to the ports' configured speed and administrative state. In order to enable dynamic buffer management feature, the ports' speed must be configured. For this please refer [Interface naming mode config commands](#interface-naming-mode-config-commands) + +### Configuration commands + +**configure shared headroom pool** + +This command is used to configure the shared headroom pool. The shared headroom pool can be enabled in the following ways: + +- Configure the over subscribe ratio. In this case, the size of shared headroom pool is calculated as the accumulative xoff of all of the lossless PG divided by the over subscribe ratio. +- Configure the size. + +In case both of the above parameters have been configured, the `size` will take effect. To disable shared headroom pool, configure both parameters to zero. + +- Usage: + + ``` + config buffer shared-headroom-pool over-subscribe-ratio + config buffer shared-headroom-pool size + ``` + + The range of over-subscribe-ratio is from 1 to number of ports inclusive. + +- Example: + + ``` + admin@sonic:~$ sudo config shared-headroom-pool over-subscribe-ratio 2 + admin@sonic:~$ sudo config shared-headroom-pool size 1024000 + ``` + +**configure a lossless buffer profile** + +This command is used to configure a lossless buffer profile. + +- Usage: + + ``` + config buffer profile add --xon --xoff [-size ] [-dynamic_th ] [-pool ] + config buffer profile set --xon --xoff [-size ] [-dynamic_th ] [-pool ] + config buffer profile remove + ``` + + All the parameters are devided to two groups, one for headroom and one for dynamic_th. For any command at lease one group of parameters should be provided. + For headroom parameters: + + - `xon` is madantory. + - If shared headroom pool is disabled: + - At lease one of `xoff` and `size` should be provided and the other will be optional and conducted via the formula `xon + xoff = size`. + - `xon` + `xoff` <= `size`; For Mellanox platform xon + xoff == size + - If shared headroom pool is enabled: + - `xoff` should be provided. + - `size` = `xoff` if it is not provided. + + If only headroom parameters are provided, the `dynamic_th` will be taken from `CONFIG_DB.DEFAULT_LOSSLESS_BUFFER_PARAMETER.default_dynamic_th`. + + If only dynamic_th parameter is provided, the `headroom_type` will be set as `dynamic` and `xon`, `xoff` and `size` won't be set. This is only used for non default dynamic_th. In this case, the profile won't be deployed to ASIC directly. It can be configured to a lossless PG and then a dynamic profile will be generated based on the port's speed, cable length, and MTU and deployed to the ASIC. + + The subcommand `add` is designed for adding a new buffer profile to the system. + + The subcommand `set` is designed for modifying an existing buffer profile in the system. + For a profile with dynamically calculated headroom information, only `dynamic_th` can be modified. + + The subcommand `remove` is designed for removing an existing buffer profile from the system. When removing a profile, it shouldn't be referenced by any entry in `CONFIG_DB.BUFFER_PG`. + +- Example: + + ``` + admin@sonic:~$ sudo config buffer profile add profile1 --xon 18432 --xoff 18432 + admin@sonic:~$ sudo config buffer profile remove profile1 + ``` + +**config interface cable_length** + +This command is used to configure the length of the cable connected to a port. The cable_length is in unit of meters and must be suffixed with "m". + +- Usage: + + ``` + config interface cable_length + ``` + +- Example: + + ``` + admin@sonic:~$ sudo config interface cable_length Ethernet0 40m + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#dynamic-buffer-management) + +**config interface buffer priority-group lossless** + +This command is used to configure the priority groups on which lossless traffic runs. + +- Usage: + + ``` + config interface buffer priority-group lossless add [profile] + config interface buffer priority-group lossless set [profile] + config interface buffer priority-group lossless remove [] + ``` + + The can be in one of the following two forms: + + - For a range of priorities, the lower bound and upper bound connected by a dash, like `3-4` + - For a single priority, the number, like `6` + + The `pg-map` represents the map of priorities for lossless traffic. It should be a string and in form of a bit map like `3-4`. The `-` connects the lower bound and upper bound of a range of priorities. + + The subcommand `add` is designed for adding a new lossless PG on top of current PGs. The new PG range must be disjoint with all existing PGs. + + For example, currently the PG range 3-4 exist on port Ethernet4, to add PG range 4-5 will fail because it isn't disjoint with 3-4. To add PG range 5-6 will succeed. After that both range 3-4 and 5-6 will work as lossless PG. + + The `override-profile` parameter is optional. When provided, it represents the predefined buffer profile for headroom override. + + The subcommand `set` is designed for modifying an existing PG from dynamic calculation to headroom override or vice versa. The `pg-map` must be an existing PG. + + The subcommand `remove` is designed for removing an existing PG. The option `pg-map` must be an existing PG. All lossless PGs will be removed in case no `pg-map` provided. + +- Example: + + To configure lossless_pg on a port: + + ``` + admin@sonic:~$ sudo config interface buffer priority-group lossless add Ethernet0 3-4 + ``` + + To change the profile used for lossless_pg on a port: + + ``` + admin@sonic:~$ sudo config interface buffer priority-group lossless set Ethernet0 3-4 new-profile + ``` + + To remove one lossless priority from a port: + + ``` + admin@sonic:~$ sudo config interface buffer priority-group lossless remove Ethernet0 6 + ``` + + To remove all lossless priorities from a port: + + ``` + admin@sonic:~$ sudo config interface buffer priority-group lossless remove Ethernet0 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#dynamic-buffer-management) + +**config interface buffer queue** + +This command is used to configure the buffer profiles for queues. + +- Usage: + + ``` + config interface buffer queue add + config interface buffer queue set + config interface buffer queue remove + ``` + + The represents the map of queues. It can be in one of the following two forms: + + - For a range of priorities, the lower bound and upper bound connected by a dash, like `3-4` + - For a single priority, the number, like `6` + + The subcommand `add` is designed for adding a buffer profile for a group of queues. The new queue range must be disjoint with all queues with buffer profile configured. + + For example, currently the buffer profile configured on queue 3-4 on port Ethernet4, to configure buffer profile on queue 4-5 will fail because it isn't disjoint with 3-4. To configure it on range 5-6 will succeed. + + The `profile` parameter represents a predefined egress buffer profile to be configured on the queues. + + The subcommand `set` is designed for modifying an existing group of queues. + + The subcommand `remove` is designed for removing buffer profile on an existing group of queues. + +- Example: + + To configure buffer profiles for queues on a port: + + ``` + admin@sonic:~$ sudo config interface buffer queue add Ethernet0 3-4 egress_lossless_profile + ``` + + To change the profile used for queues on a port: + + ``` + admin@sonic:~$ sudo config interface buffer queue set Ethernet0 3-4 new-profile + ``` + + To remove a group of queues from a port: + + ``` + admin@sonic:~$ sudo config interface buffer queue remove Ethernet0 3-4 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#dynamic-buffer-management) + +### Show commands + +**show buffer information** + +This command is used to display the status of buffer pools and profiles currently deployed to the ASIC. + +- Usage: + + ``` + show buffer information + ``` + +- Example: + + ``` + admin@sonic:~$ show buffer information + Pool: ingress_lossless_pool + ---- -------- + type ingress + mode dynamic + size 17170432 + ---- -------- + + Pool: egress_lossless_pool + ---- -------- + type egress + mode dynamic + size 34340822 + ---- -------- + + Pool: ingress_lossy_pool + ---- -------- + type ingress + mode dynamic + size 17170432 + ---- -------- + + Pool: egress_lossy_pool + ---- -------- + type egress + mode dynamic + size 17170432 + ---- -------- + + Profile: pg_lossless_100000_5m_profile + ---------- ----------------------------------- + xon 18432 + dynamic_th 0 + xoff 18432 + pool [BUFFER_POOL:ingress_lossless_pool] + size 36864 + ---------- ----------------------------------- + + Profile: q_lossy_profile + ---------- ------------------------------- + dynamic_th 3 + pool [BUFFER_POOL:egress_lossy_pool] + size 0 + ---------- ------------------------------- + + Profile: egress_lossy_profile + ---------- ------------------------------- + dynamic_th 3 + pool [BUFFER_POOL:egress_lossy_pool] + size 4096 + ---------- ------------------------------- + + Profile: egress_lossless_profile + ---------- ---------------------------------- + dynamic_th 7 + pool [BUFFER_POOL:egress_lossless_pool] + size 0 + ---------- ---------------------------------- + + Profile: ingress_lossless_profile + ---------- ----------------------------------- + dynamic_th 0 + pool [BUFFER_POOL:ingress_lossless_pool] + size 0 + ---------- ----------------------------------- + + Profile: pg_lossless_100000_79m_profile + ---------- ----------------------------------- + xon 18432 + dynamic_th 0 + xoff 60416 + pool [BUFFER_POOL:ingress_lossless_pool] + size 78848 + ---------- ----------------------------------- + + Profile: pg_lossless_100000_40m_profile + ---------- ----------------------------------- + xon 18432 + dynamic_th 0 + xoff 38912 + pool [BUFFER_POOL:ingress_lossless_pool] + size 57344 + ---------- ----------------------------------- + + Profile: ingress_lossy_profile + ---------- -------------------------------- + dynamic_th 3 + pool [BUFFER_POOL:ingress_lossy_pool] + size 0 + ---------- -------------------------------- + ``` + +**show buffer configuration** + +This command is used to display the status of buffer pools and profiles currently configured. + +- Usage: + + ``` + show buffer configuration + ``` + +- Example: + + ``` + admin@sonic:~$ show buffer configuration + Lossless traffic pattern: + -------------------- - + default_dynamic_th 0 + over_subscribe_ratio 0 + -------------------- - + + Pool: ingress_lossless_pool + ---- -------- + type ingress + mode dynamic + ---- -------- + + Pool: egress_lossless_pool + ---- -------- + type egress + mode dynamic + size 34340822 + ---- -------- + + Pool: ingress_lossy_pool + ---- -------- + type ingress + mode dynamic + ---- -------- + + Pool: egress_lossy_pool + ---- -------- + type egress + mode dynamic + ---- -------- + + Profile: q_lossy_profile + ---------- ------------------------------- + dynamic_th 3 + pool [BUFFER_POOL:egress_lossy_pool] + size 0 + ---------- ------------------------------- + + Profile: egress_lossy_profile + ---------- ------------------------------- + dynamic_th 3 + pool [BUFFER_POOL:egress_lossy_pool] + size 4096 + ---------- ------------------------------- + + Profile: egress_lossless_profile + ---------- ---------------------------------- + dynamic_th 7 + pool [BUFFER_POOL:egress_lossless_pool] + size 0 + ---------- ---------------------------------- + + Profile: ingress_lossless_profile + ---------- ----------------------------------- + dynamic_th 0 + pool [BUFFER_POOL:ingress_lossless_pool] + size 0 + ---------- ----------------------------------- + + Profile: ingress_lossy_profile + ---------- -------------------------------- + dynamic_th 3 + pool [BUFFER_POOL:ingress_lossy_pool] + size 0 + ---------- -------------------------------- + ``` + +## ECN + +This section explains all the Explicit Congestion Notification (ECN) show commands and ECN configuation options that are supported in SONiC. + +### ECN show commands +This sub-section contains the show commands that are supported in ECN. + +**show ecn** + +This command displays all the WRED profiles that are configured in the device. + +- Usage: + ``` + show ecn + ``` + +- Example: + ``` + admin@sonic:~$ show ecn + Profile: **AZURE_LOSSLESS** + ----------------------- ------- + red_max_threshold 2097152 + red_drop_probability 5 + yellow_max_threshold 2097152 + ecn ecn_all + green_min_threshold 1048576 + red_min_threshold 1048576 + wred_yellow_enable true + yellow_min_threshold 1048576 + green_max_threshold 2097152 + green_drop_probability 5 + wred_green_enable true + yellow_drop_probability 5 + wred_red_enable true + ----------------------- ------- + + Profile: **wredprofileabcd** + ----------------- --- + red_max_threshold 100 + ----------------- --- + ``` + +### ECN config commands + +This sub-section contains the configuration commands that can configure the WRED profiles. + +**config ecn** + +This command configures the possible fields in a particular WRED profile that is specified using "-profile " argument. +The list of the WRED profile fields that are configurable is listed in the below "Usage". + +- Usage: + ``` + config ecn -profile [-rmax ] [-rmin ] [-ymax ] [-ymin ] [-gmax ] [-gmin ] [-v|--verbose] + ``` + + - Parameters: + - profile_name Profile name + - red_threshold_max Set red max threshold + - red_threshold_min Set red min threshold + - yellow_threshold_max Set yellow max threshold + - yellow_threshold_min Set yellow min threshold + - green_threshold_max Set green max threshold + - green_threshold_min Set green min threshold + +- Example (Configures the "red max threshold" for the WRED profile name "wredprofileabcd". It will create the WRED profile if it does not exist.): + ``` + admin@sonic:~$ sudo config ecn -profile wredprofileabcd -rmax 100 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#ecn) + +## Feature + +SONiC includes a capability in which Feature state can be enabled/disabled +which will make corresponding feature docker container to start/stop. + +Also SONiC provide capability in which Feature docker container can be automatically shut +down and restarted if one of critical processes running in the container exits +unexpectedly. Restarting the entire feature container ensures that configuration is +reloaded and all processes in the feature container get restarted, thus increasing the +likelihood of entering a healthy state. + +### Feature show commands + +**show feature config** + +Shows the config of given feature or all if no feature is given. The "fallback" is shown only if configured. The fallback defaults to "true" when not configured. + +- Usage: + ``` + show feature config [] + ``` + +- Example: + ``` + admin@sonic:~$ show feature config + Feature State AutoRestart Owner fallback + -------------- -------- ------------- ------- ---------- + bgp enabled enabled local + database enabled disabled local + dhcp_relay enabled enabled kube + lldp enabled enabled kube true + mgmt-framework enabled enabled local + nat disabled enabled local + pmon enabled enabled kube + radv enabled enabled kube + sflow disabled enabled local + snmp enabled enabled kube + swss enabled enabled local + syncd enabled enabled local + teamd enabled enabled local + telemetry enabled enabled kube + ``` + +**show feature status** + +Shows the status of given feature or all if no feature is given. The "fallback" defaults to "true" when not configured. +The subset of features are configurable for remote management and only those report additional data. + +- Usage: + ``` + show feature status [] + ``` + +- Example: + ``` + admin@sonic:~$ show feature status + Feature State AutoRestart SystemState UpdateTime ContainerId ContainerVersion SetOwner CurrentOwner RemoteState + -------------- -------- ------------- ------------- ------------------- ------------- ------------------ ---------- -------------- ------------- + bgp enabled enabled up local local none + database enabled disabled local + dhcp_relay enabled enabled up 2020-11-15 18:21:09 249e70102f55 20201230.100 kube local + lldp enabled enabled up 2020-11-15 18:21:09 779c2d55ee12 20201230.100 kube local + mgmt-framework enabled enabled up local local none + nat disabled enabled local + pmon enabled enabled up 2020-11-15 18:20:27 a2b9ffa8aba3 20201230.100 kube local + radv enabled enabled up 2020-11-15 18:21:05 d8ff27dcfe46 20201230.100 kube local + sflow disabled enabled local + snmp enabled enabled up 2020-11-15 18:25:51 8b7d5529e306 20201230.111 kube kube running + swss enabled enabled up local local none + syncd enabled enabled up local local none + teamd enabled enabled up local local none + telemetry enabled enabled down 2020-11-15 18:24:59 20201230.100 kube none + ``` + +**config feature owner** + +Configures the owner for a feature as "local" or "kube". The "local" implies starting the feature container from local image. The "kube" implies that kubernetes server is made eligible to deploy the feature. The deployment of a feature by kubernetes is conditional based on many factors like, whether the kube server is configured or not, connected-to-kube-server or not and if that master has manifest for this feature for this switch or not and more. At some point in future, the deployment *could* happen and till that point the feature can run from local image, called "fallback". The fallback is allowed by default and it could be toggled to "not allowed". When fallback is not allowed, the feature would run only upon deployment by kubernetes master. + +- Usage: + ``` + config feature owner [] [local/kube] + ``` + +- Example: + ``` + admin@sonic:~$ sudo config feature owner snmp kube + ``` + +**config feature fallback** + +Features configured for "kube" deployment could be allowed to fallback to using local image, until the point of successful kube deployment. The fallback is allowed by default. + +- Usage: + ``` + config feature fallback [] [on/off] + ``` + +- Example: + ``` + admin@sonic:~$ sudo config feature fallback snmp on + ``` + +**show feature autorestart** + +This command will display the status of auto-restart for feature container. + +- Usage: + ``` + show feature autorestart [] + admin@sonic:~$ show feature autorestart + Feature AutoRestart + ---------- -------------- + bgp enabled + database always_enabled + dhcp_relay enabled + lldp enabled + pmon enabled + radv enabled + snmp enabled + swss enabled + syncd enabled + teamd enabled + telemetry enabled + ``` + +Optionally, you can specify a feature name in order to display +status for that feature + +### Feature config commands + +**config feature state ** + +This command will configure the state for a specific feature. + +- Usage: + ``` + config feature state (enabled | disabled) + admin@sonic:~$ sudo config feature state bgp disabled + ``` + +To make the command wait until the corresponding feature container stops(starts) use ```--block``` options: + +- Usage: + ``` + admin@sonic:~$ config feature state bgp enabled --block + ``` + +**config feature autorestart ** + +This command will configure the status of auto-restart for a specific feature container. + +- Usage: + ``` + config feature autorestart (enabled | disabled) + admin@sonic:~$ sudo config feature autorestart bgp disabled + ``` +NOTE: If the existing state or auto-restart value for a feature is "always_enabled" then config +commands are don't care and will not update state/auto-restart value. + +Go Back To [Beginning of the document](#) or [Beginning of this section](#feature) + +## Flow Counters + +This section explains all the Flow Counters show commands, clear commands and config commands that are supported in SONiC. Flow counters are usually used for debugging, troubleshooting and performance enhancement processes. Flow counters supports case like: + + - Host interface traps (number of received traps per Trap ID) + - Routes matching the configured prefix pattern (number of hits and number of bytes) + +### Flow Counters show commands + +**show flowcnt-trap stats** + +This command is used to show the current statistics for the registered host interface traps. + +Because clear (see below) is handled on a per-user basis different users may see different counts. + +- Usage: + ``` + show flowcnt-trap stats + ``` + +- Example: + ``` + admin@sonic:~$ show flowcnt-trap stats + Trap Name Packets Bytes PPS + --------- --------- ------- ------- + dhcp 100 2,000 50.25/s + + For multi-ASIC: + admin@sonic:~$ show flowcnt-trap stats + ASIC ID Trap Name Packets Bytes PPS + ------- ----------- --------- ------- ------- + asic0 dhcp 100 2,000 50.25/s + asic1 dhcp 200 3,000 45.25/s + ``` + +**show flowcnt-route stats** + +This command is used to show the current statistics for route flow patterns. + +Because clear (see below) is handled on a per-user basis different users may see different counts. + +- Usage: + ``` + show flowcnt-route stats + show flowcnt-route stats pattern [--vrf ] + show flowcnt-route stats route [--vrf ] + ``` + +- Example: + ``` + admin@sonic:~$ show flowcnt-route stats + Route pattern VRF Matched routes Packets Bytes + -------------------------------------------------------------------------------------- + 3.3.0.0/16 default 3.3.1.0/24 100 4543 + 3.3.2.3/32 3443 929229 + 3.3.0.0/16 0 0 + 2000::/64 default 2000::1/128 100 4543 + ``` + +The "pattern" subcommand is used to display the route flow counter statistics by route pattern. + +- Example: + ``` + admin@sonic:~$ show flowcnt-route stats pattern 3.3.0.0/16 + Route pattern VRF Matched routes Packets Bytes + -------------------------------------------------------------------------------------- + 3.3.0.0/16 default 3.3.1.0/24 100 4543 + 3.3.2.3/32 3443 929229 + 3.3.0.0/16 0 0 + ``` + +The "route" subcommand is used to display the route flow counter statistics by route prefix. + ``` + admin@sonic:~$ show flowcnt-route stats route 3.3.3.2/32 --vrf Vrf_1 + Route VRF Route Pattern Packets Bytes + ----------------------------------------------------------------------------------------- + 3.3.3.2/32 Vrf_1 3.3.0.0/16 100 4543 + ``` + +### Flow Counters clear commands + +**sonic-clear flowcnt-trap** + +This command is used to clear the current statistics for the registered host interface traps. This is done on a per-user basis. + +- Usage: + ``` + sonic-clear flowcnt-trap + ``` + +- Example: + ``` + admin@sonic:~$ sonic-clear flowcnt-trap + Trap Flow Counters were successfully cleared + ``` + +**sonic-clear flowcnt-route** + +This command is used to clear the current statistics for the route flow counter. This is done on a per-user basis. + +- Usage: + ``` + sonic-clear flowcnt-route + sonic-clear flowcnt-route pattern [--vrf ] + sonic-clear flowcnt-route route [--vrf ] + ``` + +- Example: + ``` + admin@sonic:~$ sonic-clear flowcnt-route + Route Flow Counters were successfully cleared + ``` + +The "pattern" subcommand is used to clear the route flow counter statistics by route pattern. + +- Example: + ``` + admin@sonic:~$ sonic-clear flowcnt-route pattern 3.3.0.0/16 --vrf Vrf_1 + Flow Counters of all routes matching the configured route pattern were successfully cleared + ``` + +The "route" subcommand is used to clear the route flow counter statistics by route prefix. + +- Example: + ``` + admin@sonic:~$ sonic-clear flowcnt-route route 3.3.3.2/32 --vrf Vrf_1 + Flow Counters of the specified route were successfully cleared + ``` + +### Flow Counters config commands + +**config flowcnt-route pattern add** + +This command is used to add or update the route pattern which is used by route flow counter to match route entries. + +- Usage: + ``` + config flowcnt-route pattern add [--vrf ] [--max ] + ``` + +- Example: + ``` + admin@sonic:~$ config flowcnt-route pattern add 2.2.0.0/16 --vrf Vrf_1 --max 50 + ``` + +**config flowcnt-route pattern remove** + +This command is used to remove the route pattern which is used by route flow counter to match route entries. + +- Usage: + ``` + config flowcnt-route pattern remove [--vrf ] + ``` + +- Example: + ``` + admin@sonic:~$ config flowcnt-route pattern remove 2.2.0.0/16 --vrf Vrf_1 + ``` + + +Go Back To [Beginning of the document](#) or [Beginning of this section](#flow-counters) +## Gearbox + +This section explains all the Gearbox PHY show commands that are supported in SONiC. + +### Gearbox show commands +This sub-section contains the show commands that are supported for gearbox phy. + +**show gearbox interfaces status** + +This command displays information about the gearbox phy interface lanes, speeds and status. Data is displayed for both MAC side and line side of the gearbox phy + +- Usage: + ``` + show gearbox interfaces status + ``` + +- Example: + +``` +home/admin# show gearbox interfaces status + PHY Id Interface MAC Lanes MAC Lane Speed PHY Lanes PHY Lane Speed Line Lanes Line Lane Speed Oper Admin +-------- ----------- ----------- ---------------- ----------- ---------------- ------------ ----------------- ------ ------- + 1 Ethernet0 25,26,27,28 10G 200,201 20G 206 40G up up + 1 Ethernet4 29,30,31,32 10G 202,203 20G 207 40G up up + 1 Ethernet8 33,34,35,36 10G 204,205 20G 208 40G up up + + ``` + +**show gearbox phys status** + +This command displays basic information about the gearbox phys configured on the switch. + +- Usage: + ``` + show gearbox phys status + ``` + +- Example: + +``` +/home/admin# show gearbox phys status + PHY Id Name Firmware +-------- ------- ---------- + 1 sesto-1 v0.1 + + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#gearbox) + + +## Update Device Hostname Configuration Commands + +This sub-section of commands is used to change device hostname without traffic being impacted. + +**config hostname** + +This command is used to change device hostname without traffic being impacted. + +- Usage: + ``` + config hostname + ``` + +- Example: + ``` + admin@sonic:~$ sudo config hostname CSW06 + Please note loaded setting will be lost after system reboot. To preserve setting, run `config save`. + ``` + +## Interfaces + +### Interface Show Commands + +This sub-section lists all the possible show commands for the interfaces available in the device. Following example gives the list of possible shows on interfaces. +Subsequent pages explain each of these commands in detail. + +- Example: + ``` + admin@sonic:~$ show interfaces -? + + Show details of the network interfaces + + Options: + -?, -h, --help Show this message and exit. + + Commands: + autoneg Show interface autoneg information + breakout Show Breakout Mode information by interfaces + counters Show interface counters + description Show interface status, protocol and... + mpls Show Interface MPLS status + naming_mode Show interface naming_mode status + neighbor Show neighbor related information + portchannel Show PortChannel information + status Show Interface status information + tpid Show Interface tpid information + transceiver Show SFP Transceiver information + ``` + +**show interfaces autoneg** + +This show command displays the port auto negotiation status for all interfaces i.e. interface name, auto negotiation mode, speed, advertised speeds, interface type, advertised interface types, operational status, admin status. For a single interface, provide the interface name with the sub-command. + +- Usage: + ``` + show interfaces autoneg status + show interfaces autoneg status + ``` + +- Example: + ``` + admin@sonic:~$ show interfaces autoneg status + Interface Auto-Neg Mode Speed Adv Speeds Type Adv Types Oper Admin + ----------- --------------- ------- ------------ ------ ----------- ------ ------- + Ethernet0 enabled 25G 10G,25G CR CR,CR4 up up + Ethernet4 disabled 100G all CR4 all up up + + admin@sonic:~$ show interfaces autoneg status Ethernet8 + Interface Auto-Neg Mode Speed Adv Speeds Type Adv Types Oper Admin + ----------- --------------- ------- ------------ ------ ----------- ------ ------- + Ethernet8 disabled 100G N/A CR4 N/A up up + ``` + +**show interfaces breakout (Versions >= 202006)** + +This show command displays the port capability for all interfaces i.e. index, lanes, default_brkout_mode, breakout_modes(i.e. available breakout modes) and brkout_mode (i.e. current breakout mode). To display current breakout mode, "current-mode" subcommand can be used.For a single interface, provide the interface name with the sub-command. + +- Usage: + ``` + show interfaces breakout + show interfaces breakout current-mode + show interfaces breakout current-mode + ``` + +- Example: + ``` + admin@lnos-x1-a-fab01:~$ show interfaces breakout + { + "Ethernet0": { + "index": "1,1,1,1", + "default_brkout_mode": "1x100G[40G]", + "child ports": "Ethernet0", + "child port speed": "100G", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]", + "Current Breakout Mode": "1x100G[40G]", + "lanes": "65,66,67,68", + "alias_at_lanes": "Eth1/1, Eth1/2, Eth1/3, Eth1/4" + },... continue + } + ``` +The "current-mode" subcommand is used to display current breakout mode for all interfaces. + ``` + admin@lnos-x1-a-fab01:~$ show interfaces breakout current-mode + +-------------+-------------------------+ + | Interface | Current Breakout Mode | + +=============+=========================+ + | Ethernet0 | 4x25G[10G] | + +-------------+-------------------------+ + | Ethernet4 | 4x25G[10G] | + +-------------+-------------------------+ + | Ethernet8 | 4x25G[10G] | + +-------------+-------------------------+ + | Ethernet12 | 4x25G[10G] | + +-------------+-------------------------+ + + admin@lnos-x1-a-fab01:~$ show interfaces breakout current-mode Ethernet0 + +-------------+-------------------------+ + | Interface | Current Breakout Mode | + +=============+=========================+ + | Ethernet0 | 4x25G[10G] | + +-------------+-------------------------+ + ``` + +**show interfaces counters** + +This show command displays packet counters for all interfaces since the last time the counters were cleared. To display l3 counters "rif" subcommand can be used. There is no facility to display counters for one specific l2 interface. For l3 interfaces a single interface output mode is present. Optional argument "-a" provides two additional columns - RX-PPS and TX_PPS. +Optional argument "-p" specify a period (in seconds) with which to gather counters over. + +- Usage: + ``` + show interfaces counters [-a|--printall] [-p|--period ] + show interfaces counters errors + show interfaces counters rates + show interfaces counters rif [-p|--period ] [-i ] + ``` + +- Example: + ``` + admin@sonic:~$ show interfaces counters + IFACE STATE RX_OK RX_BPS RX_UTIL RX_ERR RX_DRP RX_OVR TX_OK TX_BPS TX_UTIL TX_ERR TX_DRP TX_OVR + ----------- ------- --------------- ----------- --------- -------- -------- -------- --------------- ----------- --------- -------- -------- -------- + Ethernet0 U 471,729,839,997 653.87 MB/s 12.77% 0 18,682 0 409,682,385,925 556.84 MB/s 10.88% 0 0 0 + Ethernet4 U 453,838,006,636 632.97 MB/s 12.36% 0 1,636 0 388,299,875,056 529.34 MB/s 10.34% 0 0 0 + Ethernet8 U 549,034,764,539 761.15 MB/s 14.87% 0 18,274 0 457,603,227,659 615.20 MB/s 12.02% 0 0 0 + Ethernet12 U 458,052,204,029 636.84 MB/s 12.44% 0 17,614 0 388,341,776,615 527.37 MB/s 10.30% 0 0 0 + Ethernet16 U 16,679,692,972 13.83 MB/s 0.27% 0 17,605 0 18,206,586,265 17.51 MB/s 0.34% 0 0 0 + Ethernet20 U 47,983,339,172 35.89 MB/s 0.70% 0 2,174 0 58,986,354,359 51.83 MB/s 1.01% 0 0 0 + Ethernet24 U 33,543,533,441 36.59 MB/s 0.71% 0 1,613 0 43,066,076,370 49.92 MB/s 0.97% 0 0 0 + + admin@sonic:~$ show interfaces counters -i Ethernet4,Ethernet12-16 + IFACE STATE RX_OK RX_BPS RX_UTIL RX_ERR RX_DRP RX_OVR TX_OK TX_BPS TX_UTIL TX_ERR TX_DRP TX_OVR + ----------- ------- --------------- ----------- --------- -------- -------- -------- --------------- ----------- --------- -------- -------- -------- + Ethernet4 U 453,838,006,636 632.97 MB/s 12.36% 0 1,636 0 388,299,875,056 529.34 MB/s 10.34% 0 0 0 + Ethernet12 U 458,052,204,029 636.84 MB/s 12.44% 0 17,614 0 388,341,776,615 527.37 MB/s 10.30% 0 0 0 + Ethernet16 U 16,679,692,972 13.83 MB/s 0.27% 0 17,605 0 18,206,586,265 17.51 MB/s 0.34% 0 0 0 + ``` + +The "errors" subcommand is used to display the interface errors. + +- Example: + ``` + admin@str-s6000-acs-11:~$ show interface counters errors + IFACE STATE RX_ERR RX_DRP RX_OVR TX_ERR TX_DRP TX_OVR + ----------- ------- -------- -------- -------- -------- -------- -------- + Ethernet0 U 0 4 0 0 0 0 + Ethernet4 U 0 0 0 0 0 0 + Ethernet8 U 0 1 0 0 0 0 + Ethernet12 U 0 0 0 0 0 0 + ``` + +The "rates" subcommand is used to disply only the interface rates. + +- Example: + ``` + admin@str-s6000-acs-11:/usr/bin$ show int counters rates + IFACE STATE RX_OK RX_BPS RX_PPS RX_UTIL TX_OK TX_BPS TX_PPS TX_UTIL + ----------- ------- ------- -------- -------- --------- ------- -------- -------- --------- + Ethernet0 U 467510 N/A N/A N/A 466488 N/A N/A N/A + Ethernet4 U 469679 N/A N/A N/A 469245 N/A N/A N/A + Ethernet8 U 466660 N/A N/A N/A 465982 N/A N/A N/A + Ethernet12 U 466579 N/A N/A N/A 466318 N/A N/A N/A + ``` + + +The "rif" subcommand is used to display l3 interface counters. Layer 3 interfaces include router interfaces, portchannels and vlan interfaces. + +- Example: + +``` + admin@sonic:~$ show interfaces counters rif + IFACE RX_OK RX_BPS RX_PPS RX_ERR TX_OK TX_BPS TX_PPS TX_ERR +--------------- ------- ---------- -------- -------- ------- -------- -------- -------- +PortChannel0001 62,668 107.81 B/s 1.34/s 3 6 0.02 B/s 0.00/s 0 +PortChannel0002 62,645 107.77 B/s 1.34/s 3 2 0.01 B/s 0.00/s 0 +PortChannel0003 62,481 107.56 B/s 1.34/s 3 3 0.01 B/s 0.00/s 0 +PortChannel0004 62,732 107.88 B/s 1.34/s 2 3 0.01 B/s 0.00/s 0 + Vlan1000 0 0.00 B/s 0.00/s 0 0 0.00 B/s 0.00/s 0 +``` + + +Optionally, you can specify a layer 3 interface name to display the counters in single interface mode. + +- Example: + +``` + admin@sonic:~$ show interfaces counters rif PortChannel0001 + PortChannel0001 + --------------- + + RX: + 3269 packets + 778494 bytesq + 3 error packets + 292 error bytes + TX: + 0 packets + 0 bytes + 0 error packets + 0 error bytes +``` + + +Optionally, you can specify a period (in seconds) with which to gather counters over. Note that this function will take `` seconds to execute. + +- Example: + +``` + admin@sonic:~$ show interfaces counters -p 5 + IFACE STATE RX_OK RX_BPS RX_UTIL RX_ERR RX_DRP RX_OVR TX_OK TX_BPS TX_UTIL TX_ERR TX_DRP TX_OVR + ----------- ------- ------- ----------- --------- -------- -------- -------- ------- ----------- --------- -------- -------- -------- + Ethernet0 U 515 59.14 KB/s 0.00% 0 0 0 1,305 127.60 KB/s 0.00% 0 0 0 + Ethernet4 U 305 26.54 KB/s 0.00% 0 0 0 279 39.12 KB/s 0.00% 0 0 0 + Ethernet8 U 437 42.96 KB/s 0.00% 0 0 0 182 18.37 KB/s 0.00% 0 0 0 + Ethernet12 U 284 40.79 KB/s 0.00% 0 0 0 160 13.03 KB/s 0.00% 0 0 0 + Ethernet16 U 377 32.64 KB/s 0.00% 0 0 0 214 18.01 KB/s 0.00% 0 0 0 + Ethernet20 U 284 36.81 KB/s 0.00% 0 0 0 138 8758.25 B/s 0.00% 0 0 0 + Ethernet24 U 173 16.09 KB/s 0.00% 0 0 0 169 11.39 KB/s 0.00% 0 0 0 +``` + +- NOTE: Interface counters can be cleared by the user with the following command: + + ``` + admin@sonic:~$ sonic-clear counters + ``` + +- NOTE: Layer 3 interface counters can be cleared by the user with the following command: + + ``` + admin@sonic:~$ sonic-clear rifcounters + ``` + +**show interfaces description** + +This command displays the key fields of the interfaces such as Operational Status, Administrative Status, Alias and Description. + +- Usage: + ``` + show interfaces description [] + ``` + +- Example: + ``` + admin@sonic:~$ show interfaces description + Interface Oper Admin Alias Description + ----------- ------ ------- --------------- -------------------- + Ethernet0 down up hundredGigE1/1 T0-1:hundredGigE1/30 + Ethernet4 down up hundredGigE1/2 T0-2:hundredGigE1/30 + Ethernet8 down down hundredGigE1/3 hundredGigE1/3 + Ethernet12 down down hundredGigE1/4 hundredGigE1/4 + ``` + +- Example (to only display the description for interface Ethernet4): + + ``` + admin@sonic:~$ show interfaces description Ethernet4 + Interface Oper Admin Alias Description + ----------- ------ ------- -------------- -------------------- + Ethernet4 down up hundredGigE1/2 T0-2:hundredGigE1/30 + ``` + +**show interfaces mpls** + +This command is used to display the configured MPLS state for the list of configured interfaces. + +- Usage: + ``` + show interfaces mpls [] + ``` + +- Example: + ``` + admin@sonic:~$ show interfaces mpls + Interface MPLS State + ----------- ------------ + Ethernet0 disable + Ethernet4 enable + Ethernet8 enable + Ethernet12 disable + Ethernet16 disable + Ethernet20 disable + ``` + +- Example (to only display the MPLS state for interface Ethernet4): + ``` + admin@sonic:~$ show interfaces mpls Ethernet4 + Interface MPLS State + ----------- ------------ + Ethernet4 enable + ``` + +**show interfaces loopback-action** + +This command displays the configured loopback action + +- Usage: + ``` + show ip interfaces loopback-action + ``` + +- Example: + ``` + root@sonic:~# show ip interfaces loopback-action + Interface Action + ------------ ---------- + Ethernet232 drop + Vlan100 forward + ``` + + +**show interfaces tpid** + +This command displays the key fields of the interfaces such as Operational Status, Administrative Status, Alias and TPID. + +- Usage: + ``` + show interfaces tpid [] + ``` + +- Example: + ``` + admin@sonic:~$ show interfaces tpid + Interface Alias Oper Admin TPID + --------------- --------------- ------ ------- ------ + Ethernet0 fortyGigE1/1/1 up up 0x8100 + Ethernet1 fortyGigE1/1/2 up up 0x8100 + Ethernet2 fortyGigE1/1/3 down down 0x8100 + Ethernet3 fortyGigE1/1/4 down down 0x8100 + Ethernet4 fortyGigE1/1/5 up up 0x8100 + Ethernet5 fortyGigE1/1/6 up up 0x8100 + Ethernet6 fortyGigE1/1/7 up up 0x9200 + Ethernet7 fortyGigE1/1/8 up up 0x88A8 + Ethernet8 fortyGigE1/1/9 up up 0x8100 + ... + Ethernet63 fortyGigE1/4/16 down down 0x8100 + PortChannel0001 N/A up up 0x8100 + PortChannel0002 N/A up up 0x8100 + PortChannel0003 N/A up up 0x8100 + PortChannel0004 N/A up up 0x8100 + admin@sonic:~$ + ``` + +- Example (to only display the TPID for interface Ethernet6): + + ``` + admin@sonic:~$ show interfaces tpid Ethernet6 + Interface Alias Oper Admin TPID + ----------- -------------- ------ ------- ------ + Ethernet6 fortyGigE1/1/7 up up 0x9200 + admin@sonic:~$ + ``` + +**show interfaces naming_mode** + +Refer sub-section [Interface-Naming-Mode](#Interface-Naming-Mode) + + +**show interfaces neighbor** + +This command is used to display the list of expected neighbors for all interfaces (or for a particular interface) that is configured. + +- Usage: + ``` + show interfaces neighbor expected [] + ``` + +- Example: + ``` + admin@sonic:~$ show interfaces neighbor expected + LocalPort Neighbor NeighborPort NeighborLoopback NeighborMgmt NeighborType + ----------- ---------- -------------- ------------------ -------------- -------------- + Ethernet112 ARISTA01T1 Ethernet1 None 10.16.205.100 ToRRouter + Ethernet116 ARISTA02T1 Ethernet1 None 10.16.205.101 SpineRouter + Ethernet120 ARISTA03T1 Ethernet1 None 10.16.205.102 LeafRouter + Ethernet124 ARISTA04T1 Ethernet1 None 10.16.205.103 LeafRouter + ``` + +**show interfaces portchannel** + +This command displays information regarding port-channel interfaces + +- Usage: + ``` + show interfaces portchannel + ``` + +- Example: + ``` + admin@sonic:~$ show interfaces portchannel + Flags: A - active, I - inactive, Up - up, Dw - Down, N/A - not available, S - selected, D - deselected + No. Team Dev Protocol Ports + ----- ------------- ----------- --------------------------- + 24 PortChannel24 LACP(A)(Up) Ethernet28(S) Ethernet24(S) + 48 PortChannel48 LACP(A)(Up) Ethernet52(S) Ethernet48(S) + 40 PortChannel40 LACP(A)(Up) Ethernet44(S) Ethernet40(S) + 0 PortChannel0 LACP(A)(Up) Ethernet0(S) Ethernet4(S) + 8 PortChannel8 LACP(A)(Up) Ethernet8(S) Ethernet12(S) + ``` + +**show interface status** + +This command displays some more fields such as Lanes, Speed, MTU, Type, Asymmetric PFC status and also the operational and administrative status of the interfaces + +- Usage: + ``` + show interfaces status [] + ``` + +- Example (show interface status of all interfaces): + ``` + admin@sonic:~$ show interfaces status + Interface Lanes Speed MTU Alias Oper Admin Type Asym PFC + ----------- --------------- ------- ----- --------------- ------ ------- ------ ---------- + Ethernet0 49,50,51,52 100G 9100 hundredGigE1/1 down up N/A off + Ethernet4 53,54,55,56 100G 9100 hundredGigE1/2 down up N/A off + Ethernet8 57,58,59,60 100G 9100 hundredGigE1/3 down down N/A off + + ``` + +- Example (to only display the status for interface Ethernet0): + ``` + admin@sonic:~$ show interface status Ethernet0 + Interface Lanes Speed MTU Alias Oper Admin + ----------- -------- ------- ----- -------------- ------ ------- + Ethernet0 101,102 40G 9100 fortyGigE1/1/1 up up + ``` + +- Example (to only display the status for range of interfaces): + ``` + admin@sonic:~$ show interfaces status Ethernet8,Ethernet168-180 + Interface Lanes Speed MTU Alias Oper Admin Type Asym PFC + ----------- ----------------- ------- ----- --------------- ------ ------- ------ ---------- + Ethernet8 49,50,51,52 100G 9100 hundredGigE3 down down N/A N/A + Ethernet168 9,10,11,12 100G 9100 hundredGigE43 down down N/A N/A + Ethernet172 13,14,15,16 100G 9100 hundredGigE44 down down N/A N/A + Ethernet176 109,110,111,112 100G 9100 hundredGigE45 down down N/A N/A + Ethernet180 105,106,107,108 100G 9100 hundredGigE46 down down N/A N/A + ``` + +**show interfaces transceiver** + +This command is already explained [here](#Transceivers) + +### Interface Config Commands +This sub-section explains the following list of configuration on the interfaces. +1) ip - To add or remove IP address for the interface +2) pfc - to set the PFC configuration for the interface +3) shutdown - to administratively shut down the interface +4) speed - to set the interface speed +5) startup - to bring up the administratively shutdown interface +6) breakout - to set interface breakout mode +7) autoneg - to set interface auto negotiation mode +8) advertised-speeds - to set interface advertised speeds +9) advertised-types - to set interface advertised types +10) type - to set interface type +11) mpls - To add or remove MPLS operation for the interface +12) loopback-action - to set action for packet that ingress and gets routed on the same IP interface + +From 201904 release onwards, the “config interface” command syntax is changed and the format is as follows: + +- config interface interface_subcommand +i.e Interface name comes after the subcommand +- Ex: config interface startup Ethernet63 + +The syntax for all such interface_subcommands are given below under each command + +NOTE: In older versions of SONiC until 201811 release, the command syntax was `config interface interface_subcommand` + + +**config interface ip add [default_gw] (Versions >= 201904)** + +**config interface ip add (Versions <= 201811)** + +This command is used for adding the IP address for an interface. +IP address for either physical interface or for portchannel or for VLAN interface or for Loopback interface can be configured using this command. +While configuring the IP address for the management interface "eth0", users can provide the default gateway IP address as an optional parameter from release 201911. + + +- Usage: + + *Versions >= 201904* + ``` + config interface ip add + ``` + *Versions <= 201811* + ``` + config interface ip add + ``` + +- Example: + + *Versions >= 201904* + ``` + admin@sonic:~$ sudo config interface ip add Ethernet63 10.11.12.13/24 + admin@sonic:~$ sudo config interface ip add eth0 20.11.12.13/24 20.11.12.254 + ``` + *Versions <= 201811* + ``` + admin@sonic:~$ sudo config interface Ethernet63 ip add 10.11.12.13/24 + ``` + +VLAN interface names take the form of `vlan`. E.g., VLAN 100 will be named `vlan100` + +- Example: + + *Versions >= 201904* + ``` + admin@sonic:~$ sudo config interface ip add Vlan100 10.11.12.13/24 + ``` + *Versions <= 201811* + ``` + admin@sonic:~$ sudo config interface vlan100 ip add 10.11.12.13/24 + ``` + + +**config interface ip remove (Versions >= 201904)** + +**config interface ip remove (Versions <= 201811)** + +- Usage: + + *Versions >= 201904* + ``` + config interface ip remove + ``` + *Versions <= 201811* + ``` + config interface ip remove + ``` + +- Example: + + *Versions >= 201904* + ``` + admin@sonic:~$ sudo config interface ip remove Ethernet63 10.11.12.13/24 + admin@sonic:~$ sudo config interface ip remove eth0 20.11.12.13/24 + ``` + *Versions <= 201811* + ``` + admin@sonic:~$ sudo config interface Ethernet63 ip remove 10.11.12.13/24 + ``` + +VLAN interface names take the form of `vlan`. E.g., VLAN 100 will be named `vlan100` + +- Example: + + *Versions >= 201904* + ``` + admin@sonic:~$ sudo config interface ip remove vlan100 10.11.12.13/24 + ``` + *Versions <= 201811* + ``` + admin@sonic:~$ sudo config interface vlan100 ip remove 10.11.12.13/24 + ``` + +**config interface pfc priority (on | off)** + +This command is used to set PFC on a given priority of a given interface to either "on" or "off". Once it is successfully configured, it will show current losses priorities on the given interface. Otherwise, it will show error information + +- Example: + *Versions >= 201904* + ``` + admin@sonic:~$ sudo config interface pfc priority Ethernet0 3 off + + Interface Lossless priorities + ----------- --------------------- + Ethernet0 4 + + admin@sonic:~$ sudo config interface pfc priority Ethernet0 8 off + Usage: pfc config priority [OPTIONS] STATUS INTERFACE PRIORITY + + Error: Invalid value for "priority": invalid choice: 8. (choose from 0, 1, 2, 3, 4, 5, 6, 7) + + admin@sonic:~$ sudo config interface pfc priority Ethernet101 3 off + Cannot find interface Ethernet101 + + admin@sonic:~$ sudo config interface pfc priority Ethernet0 3 on + + Interface Lossless priorities + ----------- --------------------- + Ethernet0 3,4 + ``` + +**config interface pfc asymmetric (Versions >= 201904)** + +**config interface pfc asymmetric (Versions <= 201811)** + +This command is used for setting the asymmetric PFC for an interface to either "on" or "off". Once if it is configured, use "show interfaces status" to check the same. + +- Usage: + + *Versions >= 201904* + ``` + config interface pfc asymmetric on/off (for 201904+ version) + ``` + *Versions <= 201811* + ``` + config interface pfc asymmetric on/off (for 201811- version) + ``` + +- Example: + + *Versions >= 201904* + ``` + admin@sonic:~$ sudo config interface pfc asymmetric Ethernet60 on + ``` + *Versions <= 201811* + ``` + admin@sonic:~$ sudo config interface Ethernet60 pfc asymmetric on + ``` + +**config interface shutdown (Versions >= 201904)** + +**config interface shutdown (Versions <= 201811)** + +This command is used to administratively shut down either the Physical interface or port channel interface. Once if it is configured, use "show interfaces status" to check the same. + +- Usage: + + *Versions >= 201904* + ``` + config interface shutdown (for 201904+ version) + ``` + *Versions <= 201811* + ``` + config interface shutdown (for 201811- version) + ``` + +- Example: + + *Versions >= 201904* + ``` + admin@sonic:~$ sudo config interface shutdown Ethernet63 + ``` + *Versions <= 201811* + ``` + admin@sonic:~$ sudo config interface Ethernet63 shutdown + ``` + + shutdown multiple interfaces + ``` + admin@sonic:~$ sudo config interface shutdown Ethernet8,Ethernet16-20,Ethernet32 + ``` + +**config interface startup (Versions >= 201904)** + +**config interface startup (Versions <= 201811)** + +This command is used for administratively bringing up the Physical interface or port channel interface.Once if it is configured, use "show interfaces status" to check the same. + +- Usage: + + *Versions >= 201904* + ``` + config interface startup (for 201904+ version) + ``` + *Versions <= 201811* + ``` + config interface startup (for 201811- version) + ``` + +- Example: + + *Versions >= 201904* + ``` + admin@sonic:~$ sudo config interface startup Ethernet63 + ``` + *Versions <= 201811* + ``` + admin@sonic:~$ sudo config interface Ethernet63 startup + ``` + + startup multiple interfaces + ``` + admin@sonic:~$ sudo config interface startup Ethernet8,Ethernet16-20,Ethernet32 + ``` + +**config interface speed (Versions >= 202006)** + +Dynamic breakout feature is supported in SONiC from 202006 version. +User can configure any speed specified under "breakout_modes" keys for the parent interface in the platform-specific port configuration file (i.e. platform.json). + +For example for a breakout mode of 2x50G[25G,10G] the default speed is 50G but the interface also supports 25G and 10G. + +Refer [DPB HLD DOC](https://github.com/Azure/SONiC/blob/master/doc/dynamic-port-breakout/sonic-dynamic-port-breakout-HLD.md#cli-design) to know more about this command. + +**config interface speed (Versions >= 201904)** + +**config interface speed (Versions <= 201811)** + +This command is used to configure the speed for the Physical interface. Use the value 40000 for setting it to 40G and 100000 for 100G. Users need to know the device to configure it properly. + +- Usage: + + *Versions >= 201904* + ``` + config interface speed + ``` + *Versions <= 201811* + ``` + config interface speed + ``` + +- Example (Versions >= 201904): + ``` + admin@sonic:~$ sudo config interface speed Ethernet63 40000 + ``` + +- Example (Versions <= 201811): + ``` + admin@sonic:~$ sudo config interface Ethernet63 speed 40000 + + ``` + +**config interface transceiver lpmode** + +This command is used to enable or disable low-power mode for an SFP transceiver + +- Usage: + + ``` + config interface transceiver lpmode (enable | disable) + ``` + +- Examples: + + ``` + user@sonic~$ sudo config interface transceiver lpmode Ethernet0 enable + Enabling low-power mode for port Ethernet0... OK + + user@sonic~$ sudo config interface transceiver lpmode Ethernet0 disable + Disabling low-power mode for port Ethernet0... OK + ``` + +**config interface transceiver reset** + +This command is used to reset an SFP transceiver + +- Usage: + + ``` + config interface transceiver reset + ``` + +- Examples: + + ``` + user@sonic~$ sudo config interface transceiver reset Ethernet0 + Resetting port Ethernet0... OK + ``` + +**config interface mtu (Versions >= 201904)** + +This command is used to configure the mtu for the Physical interface. Use the value 1500 for setting max transfer unit size to 1500 bytes. + +- Usage: + + *Versions >= 201904* + ``` + config interface mtu + ``` + +- Example (Versions >= 201904): + ``` + admin@sonic:~$ sudo config interface mtu Ethernet64 1500 + ``` + +**config interface tpid (Versions >= 202106)** + +This command is used to configure the TPID for the Physical/PortChannel interface. default is 0x8100. Other allowed values if supported by HW SKU (0x9100, 0x9200, 0x88A8). + +- Usage: + + *Versions >= 202106* + ``` + config interface tpid + ``` + +- Example (Versions >= 202106): + ``` + admin@sonic:~$ sudo config interface tpid Ethernet64 0x9200 + ``` + +**config interface breakout (Versions >= 202006)** + +This command is used to set active breakout mode available for user-specified interface based on the platform-specific port configuration file(i.e. platform.json) +and the current mode set for the interface. + +Based on the platform.json and the current mode set in interface, this command acts on setting breakout mode for the interface. + +Double tab i.e. to see the available breakout option customized for each interface provided by the user. + +- Usage: + ``` + sudo config interface breakout --help + Usage: config interface breakout [OPTIONS] MODE + + Set interface breakout mode + + Options: + -f, --force-remove-dependencies + Clear all depenedecies internally first. + -l, --load-predefined-config load predefied user configuration (alias, + lanes, speed etc) first. + -y, --yes + -v, --verbose Enable verbose output + -?, -h, --help Show this message and exit. + ``` +- Example : + ``` + admin@sonic:~$ sudo config interface breakout Ethernet0 + + 1x100G[40G] 2x50G 4x25G[10G] + ``` + + This command also provides "--force-remove-dependencies/-f" option to CLI, which will automatically determine and remove the configuration dependencies using Yang models. + + ``` + admin@sonic:~$ sudo config interface breakout Ethernet0 4x25G[10G] -f -l -v -y + ``` + +For details please refer [DPB HLD DOC](https://github.com/Azure/SONiC/blob/master/doc/dynamic-port-breakout/sonic-dynamic-port-breakout-HLD.md#cli-design) to know more about this command. + +Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces) + +**config interface autoneg (Versions >= 202106)** + +This command is used to set port auto negotiation mode. + +- Usage: + ``` + sudo config interface autoneg --help + Usage: config interface autoneg [OPTIONS] + + Set interface auto negotiation mode + + Options: + -v, --verbose Enable verbose output + -h, -?, --help Show this message and exit. + ``` + +- Example: + ``` + admin@sonic:~$ sudo config interface autoneg Ethernet0 enabled + + admin@sonic:~$ sudo config interface autoneg Ethernet0 disabled + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces) + +**config interface advertised-speeds (Versions >= 202106)** + +This command is used to set port advertised speed. + +- Usage: + ``` + sudo config interface advertised-speeds --help + Usage: config interface advertised-speeds [OPTIONS] + + Set interface advertised speeds + + Options: + -v, --verbose Enable verbose output + -h, -?, --help Show this message and exit. + ``` + +- Example: + ``` + admin@sonic:~$ sudo config interface advertised-speeds Ethernet0 all + + admin@sonic:~$ sudo config interface advertised-speeds Ethernet0 50000,100000 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces) + +**config interface advertised-types (Versions >= 202106)** + +This command is used to set port advertised interface types. + +- Usage: + ``` + sudo config interface advertised-types --help + Usage: config interface advertised-types [OPTIONS] + + Set interface advertised types + + Options: + -v, --verbose Enable verbose output + -h, -?, --help Show this message and exit. + ``` + +- Example: + ``` + admin@sonic:~$ sudo config interface advertised-types Ethernet0 all + + admin@sonic:~$ sudo config interface advertised-types Ethernet0 CR,CR4 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces) + +**config interface type (Versions >= 202106)** + +This command is used to set port interface type. + +- Usage: + ``` + sudo config interface type --help + Usage: config interface type [OPTIONS] + + Set interface type + + Options: + -v, --verbose Enable verbose output + -h, -?, --help Show this message and exit. + ``` + +- Example: + ``` + admin@sonic:~$ sudo config interface type Ethernet0 CR4 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces) + +**config interface cable_length (Versions >= 202006)** + +This command is used to configure the length of the cable connected to a port. The cable_length is in unit of meters and must be suffixed with "m". + +For details please refer [dynamic buffer management](#dynamic-buffer-management) + +Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces) + +**config interface lossless_pg (Versions >= 202006)** + +This command is used to configure the priority groups on which lossless traffic runs. + +For details please refer [dynamic buffer management](#dynamic-buffer-management) + +Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces) + +**config interface headroom_override (Versions >= 202006)** + +This command is used to configure a static buffer profile on a port's lossless priorities. There shouldn't be any `lossless_pg` configured on the port when configuring `headroom_override`. The port's headroom won't be updated after `headroom_override` has been configured on the port. + +For details please refer [dynamic buffer management](#dynamic-buffer-management) + +Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces) + +**config interface mpls add (Versions >= 202106)** + +This command is used for adding MPLS operation on the interface. +MPLS operation for either physical, portchannel, or VLAN interface can be configured using this command. + + +- Usage: + ``` + sudo config interface mpls add --help + Usage: config interface mpls add [OPTIONS] + + Add MPLS operation on the interface + + Options: + -?, -h, --help Show this message and exit. + ``` + +- Example: + ``` + admin@sonic:~$ sudo config interface mpls add Ethernet4 + ``` + +**config interface mpls remove (Versions >= 202106)** + +This command is used for removing MPLS operation on the interface. +MPLS operation for either physical, portchannel, or VLAN interface can be configured using this command. + +- Usage: + ``` + sudo config interface mpls remove --help + Usage: config interface mpls remove [OPTIONS] + + Remove MPLS operation from the interface + + Options: + -?, -h, --help Show this message and exit. + ``` + +- Example: + ``` + admin@sonic:~$ sudo config interface mpls remove Ethernet4 + ``` + +**config interface ip loopback-action (Versions >= 202205)** + +This command is used for setting the action being taken on packets that ingress and get routed on the same IP interface. +Loopback action can be set on IP interface from type physical, portchannel, VLAN interface and VLAN subinterface. +Loopback action can be drop or forward. + +- Usage: + ``` + config interface ip loopback-action --help + Usage: config interface ip loopback-action [OPTIONS] + + Set IP interface loopback action + + Options: + -?, -h, --help Show this message and exit. + ``` + +- Example: + ``` + admin@sonic:~$ config interface ip loopback-action Ethernet0 drop + admin@sonic:~$ config interface ip loopback-action Ethernet0 forward + + ``` +Go Back To [Beginning of the document](#) or [Beginning of this section](#interfaces) + +## Interface Naming Mode + +### Interface naming mode show commands +This command displays the current interface naming mode. Interface naming mode originally set to 'default'. Interfaces are referenced by default SONiC interface names. +Users can change the naming_mode using "config interface_naming_mode" command. + +**show interfaces naming_mode** + +This command displays the current interface naming mode + +- Usage: + ``` + show interfaces naming_mode + ``` + +- Examples: + ``` + admin@sonic:~$ show interfaces naming_mode + default + ``` + + - "default" naming mode will display all SONiC interface names in 'show' commands and accept SONiC interface names as parameters in 'config commands + + ``` + admin@sonic:~$ show interfaces naming_mode + alias + ``` + + - "alias" naming mode will display all hardware vendor interface aliases in 'show' commands and accept hardware vendor interface aliases as parameters in 'config commands + + +### Interface naming mode config commands + +**config interface_naming_ mode** + +This command is used to change the interface naming mode. +Users can select between default mode (SONiC interface names) or alias mode (Hardware vendor names). +The user must log out and log back in for changes to take effect. Note that the newly-applied interface mode will affect all interface-related show/config commands. + + +*NOTE: Some platforms do not support alias mapping. In such cases, this command is not applicable. Such platforms always use the same SONiC interface names.* + +- Usage: + ``` + config interface_naming_mode (default | alias) + ``` + + - Interface naming mode is originally set to 'default'. Interfaces are referenced by default SONiC interface names: + +- Example: + ``` + admin@sonic:~$ show interfaces naming_mode + default + + admin@sonic:~$ show interface status Ethernet0 + Interface Lanes Speed MTU Alias Oper Admin + ----------- -------- ------- ----- -------------- ------ ------- + Ethernet0 101,102 40G 9100 fortyGigE1/1/1 up up + + admin@sonic:~$ sudo config interface_naming_mode alias + Please logout and log back in for changes take effect. + ``` + + - After user logs out and logs back in again, interfaces will then referenced by hardware vendor aliases: + + ``` + admin@sonic:~$ show interfaces naming_mode + alias + + admin@sonic:~$ sudo config interface fortyGigE1/1/1 shutdown + admin@sonic:~$ show interface status fortyGigE1/1/1 + Interface Lanes Speed MTU Alias Oper Admin + ----------- -------- ------- ----- -------------- ------ ------- + Ethernet0 101,102 40G 9100 fortyGigE1/1/1 down down + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#interface-naming-mode) + +## Interface Vrf binding + +### Interface vrf bind & unbind config commands + +**config interface vrf bind** + +This command is used to bind a interface to a vrf. +By default, all L3 interfaces will be in default vrf. Above vrf bind command will let users bind interface to a vrf. + +- Usage: + ``` + config interface vrf bind + ``` + +**config interface vrf unbind** + +This command is used to ubind a interface from a vrf. +This will move the interface to default vrf. + +- Usage: + ``` + config interface vrf unbind + ``` + + ### Interface vrf binding show commands + + To display interface vrf binding information, user can use show vrf command. Please refer sub-section [Vrf-show-command](#vrf-show-commands). + +Go Back To [Beginning of the document](#) or [Beginning of this section](#interface-vrf-binding) + +## IP / IPv6 + +### IP show commands + +This sub-section explains the various IP protocol specific show commands that are used to display the following. +1) routes +2) bgp details - Explained in the [bgp section](#show-bgp) +3) IP interfaces +4) prefix-list +5) protocol + +#### show ip route + +This command displays either all the route entries from the routing table or a specific route. + +- Usage: + ``` + show ip route [] [] + ``` + +- Example: + ``` + admin@sonic:~$ show ip route + Codes: K - kernel route, C - connected, S - static, R - RIP, + O - OSPF, I - IS-IS, B - BGP, P - PIM, A - Babel, + > - selected route, * - FIB route + S>* 0.0.0.0/0 [200/0] via 10.11.162.254, eth0 + C>* 1.1.0.0/16 is directly connected, Vlan100 + C>* 10.1.1.0/31 is directly connected, Ethernet112 + C>* 10.1.1.2/31 is directly connected, Ethernet116 + C>* 10.11.162.0/24 is directly connected, eth0 + C>* 127.0.0.0/8 is directly connected, lo + C>* 240.127.1.0/24 is directly connected, docker0 + ``` + + - Optionally, you can specify an IP address in order to display only routes to that particular IP address + +- Example: + ``` + admin@sonic:~$ show ip route 10.1.1.0 + Routing entry for 10.1.1.0/31 + Known via "connected", distance 0, metric 0, best + * directly connected, Ethernet112 + ``` + + - Vrf-name can also be specified to get IPv4 routes programmed in the vrf. + + - Example: + ``` + admin@sonic:~$ show ip route vrf Vrf-red + Codes: K - kernel route, C - connected, S - static, R - RIP, + O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, + T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, + F - PBR, f - OpenFabric, + > - selected route, * - FIB route + VRF Vrf-red: + C>* 11.1.1.1/32 is directly connected, Loopback11, 21:50:47 + C>* 100.1.1.0/24 is directly connected, Vlan100, 03w1d06h + + admin@sonic:~$ show ip route vrf Vrf-red 11.1.1.1/32 + Routing entry for 11.1.1.1/32 + Known via "connected", distance 0, metric 0, vrf Vrf-red, best + Last update 21:57:53 ago + * directly connected, Loopback11 + ``` + +#### show ip interfaces + +This command displays the details about all the Layer3 IP interfaces in the device for which IP address has been assigned. +The type of interfaces include the following. +1) Front panel physical ports. +2) PortChannel. +3) VLAN interface. +4) Loopback interfaces +5) docker interface and +6) management interface + +- Usage: + ``` + show ip interfaces + ``` + +- Example: + ``` + admin@sonic:~$ show ip interfaces + Interface Master IPv4 address/mask Admin/Oper BGP Neighbor Neighbor IP Flags + ------------- ------------ ------------------ -------------- ------------- ------------- ------- + Loopback0 1.0.0.1/32 up/up N/A N/A + Loopback11 Vrf-red 11.1.1.1/32 up/up N/A N/A + Loopback100 Vrf-blue 100.0.0.1/32 up/up N/A N/A + PortChannel01 10.0.0.56/31 up/down DEVICE1 10.0.0.57 + PortChannel02 10.0.0.58/31 up/down DEVICE2 10.0.0.59 + PortChannel03 10.0.0.60/31 up/down DEVICE3 10.0.0.61 + PortChannel04 10.0.0.62/31 up/down DEVICE4 10.0.0.63 + Vlan100 Vrf-red 1001.1.1/24 up/up N/A N/A + Vlan1000 192.168.0.1/27 up/up N/A N/A + docker0 240.127.1.1/24 up/down N/A N/A + eth0 10.3.147.252/23 up/up N/A N/A + lo 127.0.0.1/8 up/up N/A N/A + ``` + +#### show ip protocol + +This command displays the route-map that is configured for the routing protocol. +Refer the routing stack [Quagga Command Reference](https://www.quagga.net/docs/quagga.pdf) or [FRR Command Reference](https://buildmedia.readthedocs.org/media/pdf/frrouting/latest/frrouting.pdf) to know more about this command. + +- Usage: + ``` + show ip protocol + ``` + +- Example: + ``` + admin@sonic:~$ show ip protocol + Protocol : route-map + ------------------------ + system : none + kernel : none + connected : none + static : none + rip : none + ripng : none + ospf : none + ospf6 : none + isis : none + bgp : RM_SET_SRC + pim : none + hsls : none + olsr : none + babel : none + any : none + ``` + +### IPv6 show commands + +This sub-section explains the various IPv6 protocol specific show commands that are used to display the following. +1) routes +2) IPv6 bgp details - Explained in the [bgp section](#show-bgp) +3) IP interfaces +4) protocol + +**show ipv6 route** + +This command displays either all the IPv6 route entries from the routing table or a specific IPv6 route. + +- Usage: + ``` + show ipv6 route [] [] + ``` + +- Example: + ``` + admin@sonic:~$ show ipv6 route + Codes: K - kernel route, C - connected, S - static, R - RIPng, + O - OSPFv6, I - IS-IS, B - BGP, A - Babel, + > - selected route, * - FIB route + + C>* ::1/128 is directly connected, lo + C>* 2018:2001::/126 is directly connected, Ethernet112 + C>* 2018:2002::/126 is directly connected, Ethernet116 + C>* fc00:1::32/128 is directly connected, lo + C>* fc00:1::102/128 is directly connected, lo + C>* fc00:2::102/128 is directly connected, eth0 + C * fe80::/64 is directly connected, Vlan100 + C * fe80::/64 is directly connected, Ethernet112 + C * fe80::/64 is directly connected, Ethernet116 + C * fe80::/64 is directly connected, Bridge + C * fe80::/64 is directly connected, PortChannel0011 + C>* fe80::/64 is directly connected, eth0 + ``` + - Optionally, you can specify an IPv6 address in order to display only routes to that particular IPv6 address + + +- Example: + ``` + admin@sonic:~$ show ipv6 route fc00:1::32 + Routing entry for fc00:1::32/128 + Known via "connected", distance 0, metric 0, best + * directly connected, lo + ``` + + Vrf-name can also be specified to get IPv6 routes programmed in the vrf. + + - Example: + ``` + admin@sonic:~$ show ipv6 route vrf Vrf-red + Codes: K - kernel route, C - connected, S - static, R - RIP, + O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, + T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, + F - PBR, f - OpenFabric, + > - selected route, * - FIB route + VRF Vrf-red: + C>* 1100::1/128 is directly connected, Loopback11, 21:50:47 + C>* 100::/112 is directly connected, Vlan100, 03w1d06h + C>* fe80::/64 is directly connected, Loopback11, 21:50:47 + C>* fe80::/64 is directly connected, Vlan100, 03w1d06h + + admin@sonic:~$ show ipv6 route vrf Vrf-red 1100::1/128 + Routing entry for 1100::1/128 + Known via "connected", distance 0, metric 0, vrf Vrf-red, best + Last update 21:57:53 ago + * directly connected, Loopback11 + ``` + +**show ipv6 interfaces** + +This command displays the details about all the Layer3 IPv6 interfaces in the device for which IPv6 address has been assigned. +The type of interfaces include the following. +1) Front panel physical ports. +2) PortChannel. +3) VLAN interface. +4) Loopback interfaces +5) management interface + +- Usage: + ``` + show ipv6 interfaces + ``` + +- Example: + ``` + admin@sonic:~$ show ipv6 interfaces + Interface Master IPv6 address/mask Admin/Oper BGP Neighbor Neighbor IP + ----------- -------- ---------------------------------------- ------------ -------------- ------------- + Bridge fe80::7c45:1dff:fe08:cdd%Bridge/64 up/up N/A N/A + Loopback11 Vrf-red 1100::1/128 up/up + PortChannel01 fc00::71/126 up/down DEVICE1 fc00::72 + PortChannel02 fc00::75/126 up/down DEVICE2 fc00::76 + PortChannel03 fc00::79/126 up/down DEVICE3 fc00::7a + PortChannel04 fc00::7d/126 up/down DEVICE4 fc00::7e + Vlan100 Vrf-red 100::1/112 up/up N/A N/A + fe80::eef4:bbff:fefe:880a%Vlan100/64 + eth0 fe80::eef4:bbff:fefe:880a%eth0/64 up/up N/A N/A + lo fc00:1::32/128 up/up N/A N/A + ``` + +**show ipv6 protocol** + +This command displays the route-map that is configured for the IPv6 routing protocol. +Refer the routing stack [Quagga Command Reference](https://www.quagga.net/docs/quagga.pdf) or [FRR Command Reference](https://buildmedia.readthedocs.org/media/pdf/frrouting/latest/frrouting.pdf) to know more about this command. + + +- Usage: + ``` + show ipv6 protocol + ``` + +- Example: + ``` + admin@sonic:~$ show ipv6 protocol + Protocol : route-map + ------------------------ + system : none + kernel : none + connected : none + static : none + rip : none + ripng : none + ospf : none + ospf6 : none + isis : none + bgp : RM_SET_SRC6 + pim : none + hsls : none + olsr : none + babel : none + any : none + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#ip--ipv6) + +## IPv6 Link Local + +### IPv6 Link Local config commands + +This section explains all the commands that are supported in SONiC to configure IPv6 Link-local. + +**config interface ipv6 enable use-link-local-only ** + +This command enables user to enable an interface to forward L3 traffic with out configuring an address. This command creates the routing interface based on the auto generated IPv6 link-local address. This command can be used even if an address is configured on the interface. + +- Usage: + ``` + config interface ipv6 enable use-link-local-only + ``` + +- Example: + ``` + admin@sonic:~$ sudo config interface ipv6 enable use-link-local-only Vlan206 + admin@sonic:~$ sudo config interface ipv6 enable use-link-local-only PortChannel007 + admin@sonic:~$ sudo config interface ipv6 enable use-link-local-only Ethernet52 + ``` + +**config interface ipv6 disable use-link-local-only ** + +This command enables user to disable use-link-local-only configuration on an interface. + +- Usage: + ``` + config interface ipv6 disable use-link-local-only + ``` + +- Example: + ``` + admin@sonic:~$ sudo config interface ipv6 disable use-link-local-only Vlan206 + admin@sonic:~$ sudo config interface ipv6 disable use-link-local-only PortChannel007 + admin@sonic:~$ sudo config interface ipv6 disable use-link-local-only Ethernet52 + ``` + +**config ipv6 enable link-local** + +This command enables user to enable use-link-local-only command on all the interfaces globally. + +- Usage: + ``` + sudo config ipv6 enable link-local + ``` + +- Example: + ``` + admin@sonic:~$ sudo config ipv6 enable link-local + ``` + +**config ipv6 disable link-local** + +This command enables user to disable use-link-local-only command on all the interfaces globally. + +- Usage: + ``` + sudo config ipv6 disable link-local + ``` + +- Example: + ``` + admin@sonic:~$ sudo config ipv6 disable link-local + ``` + +### IPv6 Link Local show commands + +**show ipv6 link-local-mode** + +This command displays the link local mode of all the interfaces. + +- Usage: + ``` + show ipv6 link-local-mode + ``` + +- Example: + ``` + root@sonic:/home/admin# show ipv6 link-local-mode + +------------------+----------+ + | Interface Name | Mode | + +==================+==========+ + | Ethernet16 | Disabled | + +------------------+----------+ + | Ethernet18 | Enabled | + +------------------+----------+ + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#ipv6-link-local) + +## Kubernetes + +### Kubernetes show commands + +**show kubernetes server config** + +This command displays the kubernetes server configuration, if any, else would report as not configured. + +- Usage: + ``` + show kubernetes server config + ``` + +- Example: + ``` + admin@sonic:~$ show kubernetes server config + ip port insecure disable + ----------- ------ ---------- --------- + 10.3.157.24 6443 True False + ``` + +**show kubernetes server status** + +This command displays the kubernetes server status. + +- Usage: + ``` + show kubernetes server status + ``` + +- Example: + ``` + admin@sonic:~$ show kubernetes server status + ip port connected update-time + ----------- ------ ----------- ------------------- + 10.3.157.24 6443 true 2020-11-15 18:25:05 + ``` +Go Back To [Beginning of the document](#) or [Beginning of this section](#Kubernetes) + +## Linux Kernel Dump + +This section demonstrates the show commands and configuration commands of Linux kernel dump mechanism in SONiC. + +### Linux Kernel Dump show commands + +**show kdump config** + +This command shows the configuration of Linux kernel dump. + +- Usage: + ``` + show kdump config + ``` + +- Example: + ``` + admin@sonic:$ show kdump config + Kdump administrative mode: Disabled + Kdump operational mode: Unready + Kdump memory researvation: 0M-2G:256M,2G-4G:320M,4G-8G:384M,8G-:448M + Maximum number of Kdump files: 3 + ``` + +**show kdump files** + +This command shows the Linux kernel core dump files and dmesg files which are +generated by kernel dump tool. + +- Usage: + ``` + show kdump files + ``` + +- Example: + ``` + admin@sonic:~$ show kdump files + Kernel core dump files Kernel dmesg files + ------------------------------------------ ------------------------------------------ + /var/crash/202106242344/kdump.202106242344 /var/crash/202106242344/dmesg.202106242344 + /var/crash/202106242337/kdump.202106242337 /var/crash/202106242337/dmesg.202106242337 + ``` + +**show kdump logging ** + +By default, this command will show the last 10 lines of latest dmesg file. +This command can also accept a specific file name and number of lines as arguments. + +- Usage: + ``` + show kdump logging + ``` + +- Example: + ``` + admin@sonic:~$ show kdump logging + [ 157.642053] RSP: 002b:00007fff1beee708 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 + [ 157.732635] RAX: ffffffffffffffda RBX: 0000000000000002 RCX: 00007fc3887d4504 + [ 157.818015] RDX: 0000000000000002 RSI: 000055d388eceb40 RDI: 0000000000000001 + [ 157.903401] RBP: 000055d388eceb40 R08: 000000000000000a R09: 00007fc3888255f0 + [ 157.988784] R10: 000000000000000a R11: 0000000000000246 R12: 00007fc3888a6760 + [ 158.074166] R13: 0000000000000002 R14: 00007fc3888a1760 R15: 0000000000000002 + [ 158.159553] Modules linked in: nft_chain_route_ipv6(E) nft_chain_route_ipv4(E) xt_TCPMSS(E) dummy(E) team_mode_loadbalance(E) team(E) sx_bfd(OE) sx_netdev(OE) psample(E) sx_core(OE) 8021q(E) garp(E) mrp(E) mst_pciconf(OE) mst_pci(OE) xt_hl(E) xt_tcpudp(E) ip6_tables(E) nft_compat(E) nft_chain_nat_ipv4(E) nf_nat_ipv4(E) nft_counter(E) xt_conntrack(E) nf_nat(E) jc42(E) nf_conntrack_netlink(E) nf_conntrack(E) nf_defrag_ipv6(E) nf_defrag_ipv4(E) libcrc32c(E) xfrm_user(E) xfrm_algo(E) mlxsw_minimal(E) mlxsw_i2c(E) i2c_mux_reg(E) i2c_mux(E) i2c_mlxcpld(E) leds_mlxreg(E) mlxreg_io(E) mlxreg_hotplug(E) mei_wdt(E) evdev(E) intel_rapl(E) x86_pkg_temp_thermal(E) intel_powerclamp(E) kvm_intel(E) mlx_platform(E) kvm(E) irqbypass(E) crct10dif_pclmul(E) crc32_pclmul(E) ghash_clmulni_intel(E) intel_cstate(E) intel_uncore(E) + [ 159.016731] intel_rapl_perf(E) pcspkr(E) sg(E) iTCO_wdt(E) iTCO_vendor_support(E) mei_me(E) mei(E) bonding(E) pcc_cpufreq(E) video(E) button(E) ebt_vlan(E) ebtable_broute(E) bridge(E) stp(E) llc(E) ebtable_nat(E) ebtable_filter(E) ebtables(E) nf_tables(E) nfnetlink(E) xdpe12284(E) at24(E) ledtrig_timer(E) tmp102(E) lm75(E) drm(E) coretemp(E) max1363(E) industrialio_triggered_buffer(E) kfifo_buf(E) industrialio(E) tps53679(E) fuse(E) pmbus(E) pmbus_core(E) i2c_dev(E) configfs(E) ip_tables(E) x_tables(E) autofs4(E) loop(E) ext4(E) crc16(E) mbcache(E) jbd2(E) crc32c_generic(E) fscrypto(E) ecb(E) crypto_simd(E) cryptd(E) glue_helper(E) aes_x86_64(E) nvme(E) nvme_core(E) nls_utf8(E) nls_cp437(E) nls_ascii(E) vfat(E) fat(E) overlay(E) squashfs(E) zstd_decompress(E) xxhash(E) sd_mod(E) gpio_ich(E) ahci(E) + [ 159.864532] libahci(E) mlxsw_core(E) devlink(E) ehci_pci(E) ehci_hcd(E) crc32c_intel(E) libata(E) i2c_i801(E) scsi_mod(E) usbcore(E) usb_common(E) lpc_ich(E) mfd_core(E) e1000e(E) fan(E) thermal(E) + [ 160.075846] CR2: 0000000000000000 + ``` +You can specify a file name in order to show its +last 10 lines. + +- Example: + ``` + admin@sonic:~$ show kdump logging dmesg.202106242337 + [ 654.120195] RSP: 002b:00007ffe697690f8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 + [ 654.210778] RAX: ffffffffffffffda RBX: 0000000000000002 RCX: 00007fcfca27b504 + [ 654.296157] RDX: 0000000000000002 RSI: 000055a6e4d1b3f0 RDI: 0000000000000001 + [ 654.381543] RBP: 000055a6e4d1b3f0 R08: 000000000000000a R09: 00007fcfca2cc5f0 + [ 654.466925] R10: 000000000000000a R11: 0000000000000246 R12: 00007fcfca34d760 + [ 654.552310] R13: 0000000000000002 R14: 00007fcfca348760 R15: 0000000000000002 + [ 654.637694] Modules linked in: binfmt_misc(E) nft_chain_route_ipv6(E) nft_chain_route_ipv4(E) xt_TCPMSS(E) dummy(E) team_mode_loadbalance(E) team(E) sx_bfd(OE) sx_netdev(OE) psample(E) sx_core(OE) 8021q(E) garp(E) mrp(E) mst_pciconf(OE) mst_pci(OE) xt_hl(E) xt_tcpudp(E) ip6_tables(E) nft_chain_nat_ipv4(E) nf_nat_ipv4(E) nft_compat(E) nft_counter(E) xt_conntrack(E) nf_nat(E) jc42(E) nf_conntrack_netlink(E) nf_conntrack(E) nf_defrag_ipv6(E) nf_defrag_ipv4(E) libcrc32c(E) xfrm_user(E) xfrm_algo(E) mlxsw_minimal(E) mlxsw_i2c(E) i2c_mux_reg(E) i2c_mux(E) mlxreg_hotplug(E) mlxreg_io(E) i2c_mlxcpld(E) leds_mlxreg(E) mei_wdt(E) evdev(E) intel_rapl(E) x86_pkg_temp_thermal(E) intel_powerclamp(E) kvm_intel(E) kvm(E) mlx_platform(E) irqbypass(E) crct10dif_pclmul(E) crc32_pclmul(E) ghash_clmulni_intel(E) intel_cstate(E) + [ 655.493833] intel_uncore(E) intel_rapl_perf(E) pcspkr(E) sg(E) iTCO_wdt(E) iTCO_vendor_support(E) mei_me(E) mei(E) bonding(E) video(E) button(E) pcc_cpufreq(E) ebt_vlan(E) ebtable_broute(E) bridge(E) stp(E) llc(E) ebtable_nat(E) ebtable_filter(E) ebtables(E) nf_tables(E) nfnetlink(E) xdpe12284(E) at24(E) ledtrig_timer(E) tmp102(E) drm(E) lm75(E) coretemp(E) max1363(E) industrialio_triggered_buffer(E) kfifo_buf(E) industrialio(E) fuse(E) tps53679(E) pmbus(E) pmbus_core(E) i2c_dev(E) configfs(E) ip_tables(E) x_tables(E) autofs4(E) loop(E) ext4(E) crc16(E) mbcache(E) jbd2(E) crc32c_generic(E) fscrypto(E) ecb(E) crypto_simd(E) cryptd(E) glue_helper(E) aes_x86_64(E) nvme(E) nvme_core(E) nls_utf8(E) nls_cp437(E) nls_ascii(E) vfat(E) fat(E) overlay(E) squashfs(E) zstd_decompress(E) xxhash(E) sd_mod(E) + [ 656.337476] gpio_ich(E) ahci(E) mlxsw_core(E) libahci(E) devlink(E) crc32c_intel(E) libata(E) i2c_i801(E) scsi_mod(E) lpc_ich(E) mfd_core(E) ehci_pci(E) ehci_hcd(E) usbcore(E) e1000e(E) usb_common(E) fan(E) thermal(E) + [ 656.569590] CR2: 0000000000000000 + ``` +You can also specify a file name and number of lines in order to show the +last number of lines. + +- Example: + ``` + admin@sonic:~$ show kdump logging dmesg.202106242337 -l 20 + [ 653.525427] __handle_sysrq.cold.9+0x45/0xf2 + [ 653.576487] write_sysrq_trigger+0x2b/0x30 + [ 653.625472] proc_reg_write+0x39/0x60 + [ 653.669252] vfs_write+0xa5/0x1a0 + [ 653.708881] ksys_write+0x57/0xd0 + [ 653.748501] do_syscall_64+0x53/0x110 + [ 653.792287] entry_SYSCALL_64_after_hwframe+0x44/0xa9 + [ 653.852707] RIP: 0033:0x7fcfca27b504 + [ 653.895452] Code: 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b3 0f 1f 80 00 00 00 00 48 8d 05 f9 61 0d 00 8b 00 85 c0 75 13 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 54 c3 0f 1f 00 41 54 49 89 d4 55 48 89 f5 53 + [ 654.120195] RSP: 002b:00007ffe697690f8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 + [ 654.210778] RAX: ffffffffffffffda RBX: 0000000000000002 RCX: 00007fcfca27b504 + [ 654.296157] RDX: 0000000000000002 RSI: 000055a6e4d1b3f0 RDI: 0000000000000001 + [ 654.381543] RBP: 000055a6e4d1b3f0 R08: 000000000000000a R09: 00007fcfca2cc5f0 + [ 654.466925] R10: 000000000000000a R11: 0000000000000246 R12: 00007fcfca34d760 + [ 654.552310] R13: 0000000000000002 R14: 00007fcfca348760 R15: 0000000000000002 + [ 654.637694] Modules linked in: binfmt_misc(E) nft_chain_route_ipv6(E) nft_chain_route_ipv4(E) xt_TCPMSS(E) dummy(E) team_mode_loadbalance(E) team(E) sx_bfd(OE) sx_netdev(OE) psample(E) sx_core(OE) 8021q(E) garp(E) mrp(E) mst_pciconf(OE) mst_pci(OE) xt_hl(E) xt_tcpudp(E) ip6_tables(E) nft_chain_nat_ipv4(E) nf_nat_ipv4(E) nft_compat(E) nft_counter(E) xt_conntrack(E) nf_nat(E) jc42(E) nf_conntrack_netlink(E) nf_conntrack(E) nf_defrag_ipv6(E) nf_defrag_ipv4(E) libcrc32c(E) xfrm_user(E) xfrm_algo(E) mlxsw_minimal(E) mlxsw_i2c(E) i2c_mux_reg(E) i2c_mux(E) mlxreg_hotplug(E) mlxreg_io(E) i2c_mlxcpld(E) leds_mlxreg(E) mei_wdt(E) evdev(E) intel_rapl(E) x86_pkg_temp_thermal(E) intel_powerclamp(E) kvm_intel(E) kvm(E) mlx_platform(E) irqbypass(E) crct10dif_pclmul(E) crc32_pclmul(E) ghash_clmulni_intel(E) intel_cstate(E) + [ 655.493833] intel_uncore(E) intel_rapl_perf(E) pcspkr(E) sg(E) iTCO_wdt(E) iTCO_vendor_support(E) mei_me(E) mei(E) bonding(E) video(E) button(E) pcc_cpufreq(E) ebt_vlan(E) ebtable_broute(E) bridge(E) stp(E) llc(E) ebtable_nat(E) ebtable_filter(E) ebtables(E) nf_tables(E) nfnetlink(E) xdpe12284(E) at24(E) ledtrig_timer(E) tmp102(E) drm(E) lm75(E) coretemp(E) max1363(E) industrialio_triggered_buffer(E) kfifo_buf(E) industrialio(E) fuse(E) tps53679(E) pmbus(E) pmbus_core(E) i2c_dev(E) configfs(E) ip_tables(E) x_tables(E) autofs4(E) loop(E) ext4(E) crc16(E) mbcache(E) jbd2(E) crc32c_generic(E) fscrypto(E) ecb(E) crypto_simd(E) cryptd(E) glue_helper(E) aes_x86_64(E) nvme(E) nvme_core(E) nls_utf8(E) nls_cp437(E) nls_ascii(E) vfat(E) fat(E) overlay(E) squashfs(E) zstd_decompress(E) xxhash(E) sd_mod(E) + [ 656.337476] gpio_ich(E) ahci(E) mlxsw_core(E) libahci(E) devlink(E) crc32c_intel(E) libata(E) i2c_i801(E) scsi_mod(E) lpc_ich(E) mfd_core(E) ehci_pci(E) ehci_hcd(E) usbcore(E) e1000e(E) usb_common(E) fan(E) thermal(E) + [ 656.569590] CR2: 0000000000000000 + ``` +Go Back To [Beginning of the document](#) or [Beginning of this section](#kdump) + +## LLDP + +### LLDP show commands + +**show lldp table** + +This command displays the brief summary of all LLDP neighbors. + +- Usage: + ``` + show lldp table + ``` + +- Example: + ``` + admin@sonic:~$ show lldp table + Capability codes: (R) Router, (B) Bridge, (O) Other + LocalPort RemoteDevice RemotePortID Capability RemotePortDescr + ----------- ----------------- ------------------- ------------ -------------------- + Ethernet112 T1-1 hundredGigE1/2 BR T0-2:hundredGigE1/29 + Ethernet116 T1-2 hundredGigE1/2 BR T0-2:hundredGigE1/30 + eth0 swtor-b2lab2-1610 GigabitEthernet 0/2 OBR + -------------------------------------------------- + Total entries displayed: 3 + ``` + +**show lldp neighbors** + +This command displays more details about all LLDP neighbors or only the neighbors connected to a specific interface. + +- Usage: + ``` + show lldp neighbors + ``` + +- Example1: To display all neighbors in all interfaces + ``` + admin@sonic:~$ show lldp neighbors + ------------------------------------------------------------------------------- + LLDP neighbors: + ------------------------------------------------------------------------------- + Interface: eth0, via: LLDP, RID: 1, Time: 0 day, 12:21:21 + Chassis: + ChassisID: mac 00:01:e8:81:e3:45 + SysName: swtor-b2lab2-1610 + SysDescr: Dell Force10 Networks Real Time Operating System Software. Dell Force10 Operating System Version: 1.0. Dell Force10 Application Software Version: 8.3.3.10d. Copyright (c) 1999-2012 by Dell Inc. All Rights Reserved.Build Time: Tue Sep 22 11:21:54 PDT 2015 + TTL: 20 + Capability: Repeater, on + Capability: Bridge, on + Capability: Router, on + Port: + PortID: ifname GigabitEthernet 0/2 + VLAN: 162, pvid: yes + ------------------------------------------------------------------------------- + Interface: Ethernet116, via: LLDP, RID: 3, Time: 0 day, 12:20:49 + Chassis: + ChassisID: mac 4c:76:25:e7:f0:c0 + SysName: T1-2 + SysDescr: Debian GNU/Linux 8 (jessie) Linux 4.9.0-8-amd64 #1 SMP Debian 4.9.110-3+deb9u6 (2015-12-19) x86_64 + TTL: 120 + MgmtIP: 10.11.162.40 + Capability: Bridge, on + Capability: Router, on + Capability: Wlan, off + Capability: Station, off + Port: + PortID: local hundredGigE1/2 + PortDescr: T0-2:hundredGigE1/30 + ------------------------------------------------------------------------------- + ``` + +Optionally, you can specify an interface name in order to display only that particular interface + +- Example2: + ``` + admin@sonic:~$ show lldp neighbors Ethernet112 + show lldp neighbors Ethernet112 + ------------------------------------------------------------------------------- + LLDP neighbors: + ------------------------------------------------------------------------------- + Interface: Ethernet112, via: LLDP, RID: 2, Time: 0 day, 19:24:17 + Chassis: + ChassisID: mac 4c:76:25:e5:e6:c0 + SysName: T1-1 + SysDescr: Debian GNU/Linux 8 (jessie) Linux 4.9.0-8-amd64 #1 SMP Debian 4.9.110-3+deb9u6 (2015-12-19) x86_64 + TTL: 120 + MgmtIP: 10.11.162.41 + Capability: Bridge, on + Capability: Router, on + Capability: Wlan, off + Capability: Station, off + Port: + PortID: local hundredGigE1/2 + PortDescr: T0-2:hundredGigE1/29 + ------------------------------------------------------------------------------- + ``` +Go Back To [Beginning of the document](#) or [Beginning of this section](#lldp) + + +## Loading, Reloading And Saving Configuration + +This section explains the commands that are used to load the configuration from either the ConfigDB or from the minigraph. + +### Loading configuration from JSON file + +**config load** + +This command is used to load the configuration from a JSON file like the file which SONiC saves its configuration to, `/etc/sonic/config_db.json` +This command loads the configuration from the input file (if user specifies this optional filename, it will use that input file. Otherwise, it will use the default `/etc/sonic/config_db.json` file as the input file) into CONFIG_DB. +The configuration present in the input file is applied on top of the already running configuration. +This command does not flush the config DB before loading the new configuration (i.e., If the configuration present in the input file is same as the current running configuration, nothing happens) +If the config present in the input file is not present in running configuration, it will be added. +If the config present in the input file differs (when key matches) from that of the running configuration, it will be modified as per the new values for those keys. + +When user specifies the optional argument "-y" or "--yes", this command forces the loading without prompting the user for confirmation. +If the argument is not specified, it prompts the user to confirm whether user really wants to load this configuration file. + +- Usage: + ``` + config load [-y|--yes] [] + ``` + +- Example: + ``` + admin@sonic:~$ sudo config load + Load config from the file /etc/sonic/config_db.json? [y/N]: y + Running command: /usr/local/bin/sonic-cfggen -j /etc/sonic/config_db.json --write-to-db + ``` + +### Loading configuration from minigraph (XML) file + +**config load_minigraph** + +This command is used to load the configuration from /etc/sonic/minigraph.xml. +When users do not want to use configuration from config_db.json, they can copy the minigraph.xml configuration file to the device and load it using this command. +This command restarts various services running in the device and it takes some time to complete the command. + +NOTE: If the user had logged in using SSH, users might get disconnected and some configuration failures might happen which might be hard to recover. Users need to reconnect their SSH sessions after configuring the management IP address. It is recommended to execute this command from console port +NOTE: Management interface IP address and default route (or specific route) may require reconfiguration in case if those parameters are not part of the minigraph.xml. + +When user specifies the optional argument "-y" or "--yes", this command forces the loading without prompting the user for confirmation. +If the argument is not specified, it prompts the user to confirm whether user really wants to load this configuration file. + +When user specifies the optional argument "-n" or "--no-service-restart", this command loads the configuration without restarting dependent services +running on the device. One use case for this option is during boot time when config-setup service loads minigraph configuration and there is no services +running on the device. + +When user specifies the optional argument "-t" or "--traffic-shift-away", this command executes TSA command at the end to ensure the device remains in maintenance after loading minigraph. + +- Usage: + ``` + config load_minigraph [-y|--yes] [-n|--no-service-restart] [-t|--traffic-shift-away] + ``` + +- Example: + ``` + admin@sonic:~$ sudo config load_minigraph + Reload config from minigraph? [y/N]: y + Running command: /usr/local/bin/sonic-cfggen -j /etc/sonic/config_db.json --write-to-db + ``` + +### Reloading Configuration + +**config reload** + +This command is used to clear current configuration and import new configurationn from the input file or from /etc/sonic/config_db.json. +This command shall stop all services before clearing the configuration and it then restarts those services. + +This command restarts various services running in the device and it takes some time to complete the command. +NOTE: If the user had logged in using SSH, users **might get disconnected** depending upon the new management IP address. Users need to reconnect their SSH sessions. +In general, it is recommended to execute this command from console port after disconnecting all SSH sessions to the device. +When users to do “config reload” the newly loaded config may have management IP address, or it may not have management IP address. +If mgmtIP is there in the newly loaded config file, that mgmtIP might be same as previously configured value or it might be different. +This difference in mgmtIP address values results in following possible behaviours. + +Case1: Previously configured mgmtIP is same as newly loaded mgmtIP. The SSH session may not be affected at all, but it’s possible that there will be a brief interruption in the SSH session. But, assuming the client’s timeout value isn’t on the order of a couple of seconds, the session would most likely just resume again as soon as the interface is reconfigured and up with the same IP. +Case2: Previously configured mgmtIP is different from newly loaded mgmtIP. Users will lose their SSH connections. +Case3: Newly loaded config does not have any mgmtIP. Users will lose their SSH connections. + +NOTE: Management interface IP address and default route (or specific route) may require reconfiguration in case if those parameters are not part of the minigraph.xml. + +When user specifies the optional argument "-y" or "--yes", this command forces the loading without prompting the user for confirmation. +If the argument is not specified, it prompts the user to confirm whether user really wants to load this configuration file. + +When user specifies the optional argument "-n" or "--no-service-restart", this command clear and loads the configuration without restarting dependent services +running on the device. One use case for this option is during boot time when config-setup service loads existing old configuration and there is no services +running on the device. + +When user specifies the optional argument "-f" or "--force", this command ignores the system sanity checks. By default a list of sanity checks are performed and if one of the checks fail, the command will not execute. The sanity checks include ensuring the system status is not starting, all the essential services are up and swss is in ready state. + +- Usage: + ``` + config reload [-y|--yes] [-l|--load-sysinfo] [] [-n|--no-service-restart] [-f|--force] + ``` + +- Example: + ``` + admin@sonic:~$ sudo config reload + Clear current config and reload config from the file /etc/sonic/config_db.json? [y/N]: y + Running command: systemctl stop dhcp_relay + Running command: systemctl stop swss + Running command: systemctl stop snmp + Warning: Stopping snmp.service, but it can still be activated by: + snmp.timer + Running command: systemctl stop lldp + Running command: systemctl stop pmon + Running command: systemctl stop bgp + Running command: systemctl stop teamd + Running command: /usr/local/bin/sonic-cfggen -H -k Force10-Z9100-C32 --write-to-db + Running command: /usr/local/bin/sonic-cfggen -j /etc/sonic/config_db.json --write-to-db + Running command: systemctl restart hostname-config + Running command: systemctl restart interfaces-config + Timeout, server 10.11.162.42 not responding. + ``` + When some sanity checks fail below error messages can be seen + ``` + admin@sonic:~$ sudo config reload -y + System is not up. Retry later or use -f to avoid system checks + ``` + ``` + admin@sonic:~$ sudo config reload -y + Relevant services are not up. Retry later or use -f to avoid system checks + ``` + ``` + admin@sonic:~$ sudo config reload -y + SwSS container is not ready. Retry later or use -f to avoid system checks + ``` + + +### Loading Management Configuration + +**config load_mgmt_config** + +This command is used to reconfigure hostname and mgmt interface based on device description file. +This command either uses the optional file specified as arguement or looks for the file "/etc/sonic/device_desc.xml". +If the file does not exist or if the file does not have valid fields for "hostname" and "ManagementAddress" (or "ManagementAddressV6"), it fails. + +When user specifies the optional argument "-y" or "--yes", this command forces the loading without prompting the user for confirmation. +If the argument is not specified, it prompts the user to confirm whether user really wants to load this configuration file. + +- Usage: + ``` + config load_mgmt_config [-y|--yes] [] + ``` + +- Example: + ``` + admin@sonic:~$ sudo config load_mgmt_config + Reload config from minigraph? [y/N]: y + Running command: /usr/local/bin/sonic-cfggen -M /etc/sonic/device_desc.xml --write-to-db + ``` + + +### Saving Configuration to a File for Persistence + +**config save** + +This command is to save the config DB configuration into the user-specified filename or into the default /etc/sonic/config_db.json. This saves the configuration into the disk which is available even after reboots. +Saved file can be transferred to remote machines for debugging. If users wants to load the configuration from this new file at any point of time, they can use "config load" command and provide this newly generated file as input. If users wants this newly generated file to be used during reboot, they need to copy this file to /etc/sonic/config_db.json. + +- Usage: + ``` + config save [-y|--yes] [] + ``` + +- Example (Save configuration to /etc/sonic/config_db.json): + ``` + admin@sonic:~$ sudo config save -y + ``` + +- Example (Save configuration to a specified file): + ``` + admin@sonic:~$ sudo config save -y /etc/sonic/config2.json + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#loading-reloading-and-saving-configuration) + +## Loopback Interfaces + +### Loopback show commands + +Please check [show ip interfaces](#show-ip-interfaces) + +### Loopback config commands + +This sub-section explains how to create and delete loopback interfaces. + +**config interface loopback** + +This command is used to add or delete loopback interfaces. +It is recommended to use loopback names in the format "Loopbackxxx", where "xxx" is number of 1 to 3 digits. Ex: "Loopback11". + +- Usage: + ``` + config loopback (add | del) + ``` + +- Example (Create the loopback with name "Loopback11"): + ``` + admin@sonic:~$ sudo config loopback add Loopback11 + ``` + +## VRF Configuration + +### VRF show commands + +**show vrf** + +This command displays all vrfs configured on the system along with interface binding to the vrf. +If vrf-name is also provided as part of the command, if the vrf is created it will display all interfaces binding to the vrf, if vrf is not created nothing will be displayed. + +- Usage: + ``` + show vrf [] + ``` + +- Example: + ```` + admin@sonic:~$ show vrf + VRF Interfaces + ------- ------------ + default Vlan20 + Vrf-red Vlan100 + Loopback11 + Eth0.100 + Vrf-blue Loopback100 + Loopback102 + Ethernet0.10 + PortChannel101 + ```` + +### VRF config commands + +**config vrf add ** + +This command creates vrf in SONiC system with provided vrf-name. + +- Usage: + ``` +config vrf add +``` +Note: vrf-name should always start with keyword "Vrf" + +**config vrf del ** + +This command deletes vrf with name vrf-name. + +- Usage: + ``` +config vrf del +``` + +## Management VRF + +### Management VRF Show commands + +**show mgmt-vrf** + +This command displays whether the management VRF is enabled or disabled. It also displays the details about the the links (eth0, mgmt, lo-m) that are related to management VRF. + +- Usage: + ``` + show mgmt-vrf + ``` + +- Example: + ``` + admin@sonic:~$ show mgmt-vrf + + ManagementVRF : Enabled + + Management VRF interfaces in Linux: + 348: mgmt: mtu 65536 qdisc noqueue state UP mode DEFAULT group default qlen 1000 + link/ether f2:2a:d9:bc:e8:f0 brd ff:ff:ff:ff:ff:ff + 2: eth0: mtu 1500 qdisc mq master mgmt state UP mode DEFAULT group default qlen 1000 + link/ether 4c:76:25:f4:f9:f3 brd ff:ff:ff:ff:ff:ff + 350: lo-m: mtu 1500 qdisc noqueue master mgmt state UNKNOWN mode DEFAULT group default qlen 1000 + link/ether b2:4c:c6:f3:e9:92 brd ff:ff:ff:ff:ff:ff + + NOTE: The management interface "eth0" shows the "master" as "mgmt" since it is part of management VRF. + ``` + +**show mgmt-vrf routes** + +This command displays the routes that are present in the routing table 5000 that is meant for management VRF. + +- Usage: + ``` + show mgmt-vrf routes + ``` + +- Example: + ``` + admin@sonic:~$ show mgmt-vrf routes + + Routes in Management VRF Routing Table: + default via 10.16.210.254 dev eth0 metric 201 + broadcast 10.16.210.0 dev eth0 proto kernel scope link src 10.16.210.75 + 10.16.210.0/24 dev eth0 proto kernel scope link src 10.16.210.75 + local 10.16.210.75 dev eth0 proto kernel scope host src 10.16.210.75 + broadcast 10.16.210.255 dev eth0 proto kernel scope link src 10.16.210.75 + broadcast 127.0.0.0 dev lo-m proto kernel scope link src 127.0.0.1 + 127.0.0.0/8 dev lo-m proto kernel scope link src 127.0.0.1 + local 127.0.0.1 dev lo-m proto kernel scope host src 127.0.0.1 + broadcast 127.255.255.255 dev lo-m proto kernel scope link src 127.0.0.1 + ``` + +**show management_interface address** + +This command displays the IP address(es) configured for the management interface "eth0" and the management network default gateway. + +- Usage: + ``` + show management_interface address + ``` + +- Example: + ``` + admin@sonic:~$ show management_interface address + Management IP address = 10.16.210.75/24 + Management NetWork Default Gateway = 10.16.210.254 + Management IP address = FC00:2::32/64 + Management Network Default Gateway = fc00:2::1 + ``` + +**show snmpagentaddress** + +This command displays the configured SNMP agent IP addresses. + +- Usage: + ``` + show snmpagentaddress + ``` + +- Example: + ``` + admin@sonic:~$ show snmpagentaddress + ListenIP ListenPort ListenVrf + ---------- ------------ ----------- + 1.2.3.4 787 mgmt + ``` + +**show snmptrap** + +This command displays the configured SNMP Trap server IP addresses. + +- Usage: + ``` + show snmptrap + ``` + +- Example: + ``` + admin@sonic:~$ show snmptrap + Version TrapReceiverIP Port VRF Community + --------- ---------------- ------ ----- ----------- + 2 31.31.31.31 456 mgmt public + ``` + +### Management VRF Config commands + +**config vrf add mgmt** + +This command enables the management VRF in the system. This command restarts the "interfaces-config" service which in turn regenerates the /etc/network/interfaces file and restarts the "networking" service. This creates a new interface and l3mdev CGROUP with the name as "mgmt" and enslaves the management interface "eth0" into this master interface "mgmt". Note that the VRFName "mgmt" (or "management") is reserved for management VRF. i.e. Data VRFs should not use these reserved VRF names. + +- Usage: + ``` + config vrf add mgmt + ``` + +- Example: + ``` + admin@sonic:~$ sudo config vrf add mgmt + ``` + +**config vrf del mgmt** + +This command disables the management VRF in the system. This command restarts the "interfaces-config" service which in turn regenerates the /etc/network/interfaces file and restarts the "networking" service. This deletes the interface "mgmt" and deletes the l3mdev CGROUP named "mgmt" and puts back the management interface "eth0" into the default VRF. Note that the VRFName "mgmt" (or "management") is reserved for management VRF. i.e. Data VRFs should not use these reserved VRF names. + +- Usage: + ``` + config vrf del mgmt + ``` + +- Example: + ``` + admin@sonic:~$ sudo config vrf del mgmt + ``` + +**config snmpagentaddress add** + +This command adds the SNMP agent IP address on which the SNMP agent is expected to listen. When SNMP agent is expected to work as part of management VRF, users should specify the optional vrf_name parameter as "mgmt". This configuration goes into snmpd.conf that is used by SNMP agent. SNMP service is restarted to make this configuration effective in SNMP agent. + +- Usage: + ``` + config snmpagentaddress add [-p ] [-v ] agentip + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmpagentaddress add -v mgmt -p 123 21.22.13.14 + + Note: For this example, configuration goes into /etc/snmp/snmpd.conf inside snmp docker as follows. When "-v" parameter is not used, the additional "%" in the following line will not be present. + + agentAddress 21.22.13.14:123%mgmt + ``` + +**config snmpagentaddress del** + +This command deletes the SNMP agent IP address on which the SNMP agent is expected to listen. When users had added the agent IP as part of "mgmt" VRF, users should specify the optional vrf_name parameter as "mgmt" while deleting as well. This configuration is removed from snmpd.conf that is used by SNMP agent. SNMP service is restarted to make this configuration effective in SNMP agent. + +- Usage: + ``` + config snmpagentaddress del [-p ] [-v ] agentip + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmpagentaddress del -v mgmt -p 123 21.22.13.14 + + ``` + +**config snmptrap modify** + +This command modifies the SNMP trap server IP address to which the SNMP agent is expected to send the traps. Users can configure one server IP addrss for each SNMP version to send the traps. When SNMP agent is expected to send traps as part of management VRF, users should specify the optional vrf_name parameter as "mgmt". This configuration goes into snmpd.conf that is used by SNMP agent. SNMP service is restarted to make this configuration effective in SNMP agent. + +- Usage: + ``` + config snmptrap modify [-p ] [-v ] [-c ] trapserverip + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmptrap modify 2 -p 456 -v mgmt 21.21.21.21 + + For this example, configuration goes into /etc/snmp/snmpd.conf inside snmp docker as follows. When "-v" parameter is not used, the additional "%" in the following line will not be present. In case of SNMPv1, "trapsink" will be updated, in case of v2, "trap2sink" will be updated and in case of v3, "informsink" will be updated. + + trap2sink 31.31.31.31:456%mgmt public + + ``` + +**config snmptrap del** + +This command deletes the SNMP Trap server IP address to which SNMP agent is expected to send TRAPs. When users had added the trap server IP as part of "mgmt" VRF, users should specify the optional vrf_name parameter as "mgmt" while deleting as well. This configuration is removed from snmpd.conf that is used by SNMP agent. SNMP service is restarted to make this configuration effective in SNMP agent. + +- Usage: + ``` + config snmptrap del [-p ] [-v ] [-c ] trapserverip + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmptrap del -v mgmt -p 123 21.22.13.14 + + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#management-vrf) + +## Muxcable + +### Muxcable Show commands + +**show muxcable status** + +This command displays all the status of either all the ports which are connected to muxcable or any individual port selected by the user. The resultant table or json output will show the current status of muxcable on the port (auto/active) and also the health of the muxcable. + +- Usage: + ``` + show muxcable status [OPTIONS] [PORT] + ``` + +While displaying the muxcable status, users can configure the following fields + +- PORT optional - Port name should be a valid port +- --json optional - -- option to display the result in json format. By default output will be in tabular format. + +With no optional argument, all the ports muxcable status will be displayed in tabular form, or user can pass --json option to display in json format + +- Example: + ``` + admin@sonic:~$ show muxcable status + PORT STATUS HEALTH + ---------- -------- -------- + Ethernet32 active HEALTHY + Ethernet0 auto HEALTHY + ``` + ``` + admin@sonic:~$ show muxcable status --json + ``` + ```json + { + "MUX_CABLE": { + "Ethernet32": { + "STATUS": "active", + "HEALTH": "HEALTHY" + }, + "Ethernet0": { + "STATUS": "auto", + "HEALTH": "HEALTHY" + } + } + } + + ``` + ``` + admin@sonic:~$ show muxcable status Ethernet0 + PORT STATUS HEALTH + --------- -------- -------- + Ethernet0 auto HEALTHY + ``` + ``` + admin@sonic:~$ show muxcable status Ethernet0 --json + ``` + ```json + { + "MUX_CABLE": { + "Ethernet0": { + "STATUS": "auto", + "HEALTH": "HEALTHY" + } + } + } + ``` + +**show muxcable config** + +This command displays all the configurations of either all the ports which are connected to muxcable or any individual port selected by the user. The resultant table or json output will show the current configurations of muxcable on the port(active/standby) and also the ipv4 and ipv6 address of the port as well as peer TOR ip address with the hostname. + +- Usage: + ``` + show muxcable config [OPTIONS] [PORT] + ``` + +With no optional argument, all the ports muxcable configuration will be displayed in tabular form +While displaying the muxcable configuration, users can configure the following fields + +- PORT optional - Port name should be a valid port +- --json optional - option to display the result in json format. By default output will be in tabular format. + +- Example: + ``` + admin@sonic:~$ show muxcable config + SWITCH_NAME PEER_TOR + ------------- ---------- + sonic 10.1.1.1 + port state ipv4 ipv6 + --------- ------- -------- -------- + Ethernet0 active 10.1.1.1 fc00::75 + ``` + ``` + admin@sonic:~$ show muxcable config --json + ``` + ```json + { + "MUX_CABLE": { + "PEER_TOR": "10.1.1.1", + "PORTS": { + "Ethernet0": { + "STATE": "active", + "SERVER": { + "IPv4": "10.1.1.1", + "IPv6": "fc00::75" + } + } + } + } + } + ``` + ``` + admin@sonic:~$ show muxcable config Ethernet0 + SWITCH_NAME PEER_TOR + ------------- ---------- + sonic 10.1.1.1 + port state ipv4 ipv6 + --------- ------- -------- -------- + Ethernet0 active 10.1.1.1 fc00::75 + ``` + ``` + admin@sonic:~$ show muxcable config Ethernet0 --json + ``` + ```json + { + "MUX_CABLE": { + "PORTS": { + "Ethernet0": { + "STATE": "active", + "SERVER": { + "IPv4": "10.1.1.1", + "IPv6": "fc00::75" + } + } + } + } + } + ``` + +**show muxcable ber-info** + +This command displays the ber(Bit error rate) of the port user provides on the target user provides. The target provided as an integer corresponds to actual target as. +0 -> local +1 -> tor 1 +2 -> tor 2 +3 -> nic + +- Usage: + ``` + Usage: show muxcable ber-info [OPTIONS] PORT TARGET + ``` + + +- PORT required - Port number should be a valid port +- TARGET required - the actual target to get the ber info of. + +- Example: + ``` + admin@sonic:~$ show muxcable ber-info 1 1 + Lane1 Lane2 + ------- ------- + 0 0 + ``` + +**show muxcable ber-info** + +This command displays the eye info in mv(milli volts) of the port user provides on the target user provides. The target provided as an integer corresponds to actual target as. +0 -> local +1 -> tor 1 +2 -> tor 2 +3 -> nic + +- Usage: + ``` + Usage: show muxcable eye-info [OPTIONS] PORT TARGET + ``` + +- PORT required - Port number should be a valid port +- TARGET required - the actual target to get the eye info of. + +- Example: + ``` + admin@sonic:~$ show muxcable ber-info 1 1 + Lane1 Lane2 + ------- ------- + 632 622 + ``` + +### Muxcable Config commands + + +**config muxcable mode** + +This command is used for setting the configuration of a muxcable Port/all ports to be active or auto. The user has to enter a port number or else all to make the muxcable config operation on all the ports. Depending on the status of the muxcable port state the resultant output could be OK or INPROGRESS . OK would imply no change on the state, INPROGRESS would mean the toggle is happening in the background. + +- Usage: + ``` + config muxcable mode [OPTIONS] + ``` + +While configuring the muxcable, users needs to configure the following fields for the operation + +- operation_state, permitted operation to be configured which can only be auto or active +- PORT optional - Port name should be a valid port +- --json optional - option to display the result in json format. By default output will be in tabular format. + + +- Example: + ``` + admin@sonic:~$ sudo config muxcable mode active Ethernet0 + port state + --------- ------- + Ethernet0 OK + ``` + ``` + admin@sonic:~$ sudo config muxcable mode --json active Ethernet0 + ``` + ```json + { + "Ethernet0": "OK" + } + ``` + ``` + admin@sonic:~$ sudo config muxcable mode active all + port state + ---------- ---------- + Ethernet0 OK + Ethernet32 INPROGRESS + ``` + ``` + admin@sonic:~$ sudo config muxcable mode active all --json + ``` + ```json + { + "Ethernet32": "INPROGRESS", + "Ethernet0": "OK" + } + ``` +**config muxcable prbs enable/disable** + +This command is used for setting the configuration and enable/diable of prbs on a port user provides. While enabling in addition to port the user also needs to provides the target, prbs mode and lane map on which the user intends to run prbs on. The target reflects where the enable/dsiable will happen. + +- Usage: + ``` + config muxcable prbs enable [OPTIONS] PORT TARGET MODE_VALUE LANE_MAP + config muxcable prbs disable [OPTIONS] PORT TARGET + ``` + +While configuring the muxcable, users needs to configure the following fields for the operation + +- PORT required - Port number should be a valid port +- TARGET required - the actual target to run the prbs on + 0 -> local side, + 1 -> TOR 1 + 2 -> TOR 2 + 3 -> NIC +- MODE_VALUE required - the mode/type for configuring the PRBS mode. + 0x00 = PRBS 9, 0x01 = PRBS 15, 0x02 = PRBS 23, 0x03 = PRBS 31 +- LANE_MAP required - an integer representing the lane_map to be run PRBS on + 0bit for lane 0, 1bit for lane1 and so on. + for example 3 -> 0b'0011 , means running on lane0 and lane1 +- Example: + ``` + admin@sonic:~$ sudo config muxcable prbs enable 1 1 3 3 + PRBS config sucessful + admin@sonic:~$ sudo config muxcable prbs disable 1 0 + PRBS disable sucessful + ``` + +**config muxcable loopback enable/disable** + +This command is used for setting the configuration and enable/disable of loopback on a port user provides. While enabling in addition to port the user also needs to provides the target and lane map on which the user intends to run loopback on. The target reflects where the enable/dsiable will happen. + +- Usage: + ``` + config muxcable loopback enable [OPTIONS] PORT TARGET LANE_MAP + config muxcable loopback disable [OPTIONS] PORT TARGET + ``` + +While configuring the muxcable, users needs to configure the following fields for the operation + +- PORT required - Port number should be a valid port +- TARGET required - the actual target to run the loopback on + 0 -> local side, + 1 -> TOR 1 + 2 -> TOR 2 + 3 -> NIC +- LANE_MAP required - an integer representing the lane_map to be run loopback on + 0bit for lane 0, 1bit for lane1 and so on. + for example 3 -> 0b'0011 , means running on lane0 and lane1 + +- Example: + ``` + admin@sonic:~$ sudo config muxcable loopback enable 1 1 3 + loopback config sucessful + admin@sonic:~$ sudo config muxcable loopback disable 1 0 + loopback disable sucessfull + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#muxcable) + +## Mirroring + +### Mirroring Show commands + +**show mirror_session** + +This command displays all the mirror sessions that are configured. + +- Usage: + ``` + show mirror_session + ``` + +- Example: + ``` + admin@sonic:~$ show mirror_session + ERSPAN Sessions + Name Status SRC IP DST IP GRE DSCP TTL Queue Policer Monitor Port SRC Port Direction + ------ -------- -------- -------- ----- ------ ----- ------- --------- -------------- ---------- ----------- + everflow0 active 10.1.0.32 10.0.0.7 + + SPAN Sessions + Name Status DST Port SRC Port Direction + ------ -------- ---------- ------------- ----------- + port0 active Ethernet0 PortChannel10 rx + ``` + +### Mirroring Config commands + +**config mirror_session** + +This command is used to add or remove mirroring sessions. Mirror session is identified by "session_name". +This command supports configuring both SPAN/ERSPAN sessions. +In SPAN user can configure mirroring of list of source ports/LAG to destination port in ingress/egress/both directions. +In ERSPAN user can configure mirroring of list of source ports/LAG to a destination IP. +Both SPAN/ERSPAN support ACL based mirroring and can be used in ACL configurations. + +While adding a new ERSPAN session, users need to configure the following fields that are used while forwarding the mirrored packets. + +1) source IP address, +2) destination IP address, +3) DSCP (QoS) value with which mirrored packets are forwarded +4) TTL value +5) optional - GRE Type in case if user wants to send the packet via GRE tunnel. GRE type could be anything; it could also be left as empty; by default, it is 0x8949 for Mellanox; and 0x88be for the rest of the chips. +6) optional - Queue in which packets shall be sent out of the device. Valid values 0 to 7 for most of the devices. Users need to know their device and the number of queues supported in that device. +7) optional - Policer which will be used to control the rate at which frames are mirrored. +8) optional - List of source ports which can have both Ethernet and LAG ports. +9) optional - Direction - Mirror session direction when configured along with Source port. (Supported rx/tx/both. default direction is both) + +- Usage: + ``` + config mirror_session erspan add [gre_type] [queue] [policer ] [source-port-list] [direction] + ``` + + The following command is also supported to be backward compatible. + This command will be deprecated in future releases. + ``` + config mirror_session add [gre_type] [queue] + ``` + +- Example: + ``` + root@T1-2:~# config mirror_session add mrr_legacy 1.2.3.4 20.21.22.23 8 100 0x6558 0 + root@T1-2:~# show mirror_session + Name Status SRC IP DST IP GRE DSCP TTL Queue Policer Monitor Port SRC Port Direction + --------- -------- -------- ----------- ------ ------ ----- ------- --------- -------------- ---------- ----------- + mrr_legacy inactive 1.2.3.4 20.21.22.23 0x6558 8 100 0 + + + root@T1-2:~# config mirror_session erspan add mrr_abcd 1.2.3.4 20.21.22.23 8 100 0x6558 0 + root@T1-2:~# show mirror_session + Name Status SRC IP DST IP GRE DSCP TTL Queue Policer Monitor Port SRC Port Direction + --------- -------- -------- ----------- ------ ------ ----- ------- --------- -------------- ---------- ----------- + mrr_abcd inactive 1.2.3.4 20.21.22.23 0x6558 8 100 0 + root@T1-2:~# + + root@T1-2:~# config mirror_session erspan add mrr_port 1.2.3.4 20.21.22.23 8 100 0x6558 0 Ethernet0 + root@T1-2:~# show mirror_session + Name Status SRC IP DST IP GRE DSCP TTL Queue Policer Monitor Port SRC Port Direction + --------- -------- -------- ----------- ------ ------ ----- ------- --------- -------------- ---------- ----------- + mrr_port inactive 1.2.3.4 20.21.22.23 0x6558 8 100 0 Ethernet0 both + root@T1-2:~# + ``` + +While adding a new SPAN session, users need to configure the following fields that are used while forwarding the mirrored packets. +1) destination port, +2) optional - List of source ports- List of source ports which can have both Ethernet and LAG ports. +3) optional - Direction - Mirror session direction when configured along with Source port. (Supported rx/tx/both. default direction is both) +4) optional - Queue in which packets shall be sent out of the device. Valid values 0 to 7 for most of the devices. Users need to know their device and the number of queues supported in that device. +5) optional - Policer which will be used to control the rate at which frames are mirrored. + +- Usage: + ``` + config mirror_session span add [source-port-list] [direction] [queue] [policer ] + ``` + +- Example: + ``` + root@T1-2:~# config mirror_session span add port0 Ethernet0 Ethernet4,PortChannel001,Ethernet8 + root@T1-2:~# show mirror_session + Name Status DST Port SRC Port Direction + ------ -------- ---------- --------------------------------- ----------- + port0 active Ethernet0 Ethernet4,PortChannel10,Ethernet8 both + root@T1-2:~# + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#mirroring) + +## NAT + +### NAT Show commands + +**show nat config** + +This command displays the NAT configuration. + +- Usage: + ``` + show nat config [static | pool | bindings | globalvalues | zones] + ``` + +With no optional arguments, the whole NAT configuration is displayed. + +- Example: + ``` + admin@sonic:~$ show nat config static + + Nat Type IP Protocol Global IP Global L4 Port Local IP Local L4 Port Twice-Nat Id + -------- ----------- ------------ -------------- ------------- ------------- ------------ + dnat all 65.55.45.5 --- 10.0.0.1 --- --- + dnat all 65.55.45.6 --- 10.0.0.2 --- --- + dnat tcp 65.55.45.7 2000 20.0.0.1 4500 1 + snat tcp 20.0.0.2 4000 65.55.45.8 1030 1 + + admin@sonic:~$ show nat config pool + + Pool Name Global IP Range Global L4 Port Range + ------------ ------------------------- -------------------- + Pool1 65.55.45.5 1024-65535 + Pool2 65.55.45.6-65.55.45.8 --- + Pool3 65.55.45.10-65.55.45.15 500-1000 + + admin@sonic:~$ show nat config bindings + + Binding Name Pool Name Access-List Nat Type Twice-Nat Id + ------------ ------------ ------------ -------- ------------ + Bind1 Pool1 --- snat --- + Bind2 Pool2 1 snat 1 + Bind3 Pool3 2 snat -- + + admin@sonic:~$ show nat config globalvalues + + Admin Mode : enabled + Global Timeout : 600 secs + TCP Timeout : 86400 secs + UDP Timeout : 300 secs + + admin@sonic:~$ show nat config zones + + Port Zone + ---- ---- + Ethernet2 0 + Vlan100 1 + ``` + +**show nat statistics** + +This command displays the NAT translation statistics for each entry. + +- Usage: + ``` + show nat statistics + ``` + +- Example: + ``` + admin@sonic:~$ show nat statistics + + Protocol Source Destination Packets Bytes + -------- --------- -------------- ------------- ------------- + all 10.0.0.1 --- 802 1009280 + all 10.0.0.2 --- 23 5590 + tcp 20.0.0.1:4500 --- 110 12460 + udp 20.0.0.1:4000 --- 1156 789028 + tcp 20.0.0.1:6000 --- 30 34800 + tcp 20.0.0.1:5000 65.55.42.1:2000 128 110204 + tcp 20.0.0.1:5500 65.55.42.1:2000 8 3806 + ``` + +**show nat translations** + +This command displays the NAT translation entries. + +- Usage: + ``` + show nat translations [count] + ``` +Giving the optional count argument displays only the details about the number of translation entries. +- Example: + ``` + admin@sonic:~$ show nat translations + + Static NAT Entries ................. 4 + Static NAPT Entries ................. 2 + Dynamic NAT Entries ................. 0 + Dynamic NAPT Entries ................. 4 + Static Twice NAT Entries ................. 0 + Static Twice NAPT Entries ................. 4 + Dynamic Twice NAT Entries ................ 0 + Dynamic Twice NAPT Entries ................ 0 + Total SNAT/SNAPT Entries ................ 9 + Total DNAT/DNAPT Entries ................ 9 + Total Entries ................ 14 + + Protocol Source Destination Translated Source Translated Destination + -------- --------- -------------- ----------------- ---------------------- + all 10.0.0.1 --- 65.55.42.2 --- + all --- 65.55.42.2 --- 10.0.0.1 + all 10.0.0.2 --- 65.55.42.3 --- + all --- 65.55.42.3 --- 10.0.0.2 + tcp 20.0.0.1:4500 --- 65.55.42.1:2000 --- + tcp --- 65.55.42.1:2000 --- 20.0.0.1:4500 + udp 20.0.0.1:4000 --- 65.55.42.1:1030 --- + udp --- 65.55.42.1:1030 --- 20.0.0.1:4000 + tcp 20.0.0.1:6000 --- 65.55.42.1:1024 --- + tcp --- 65.55.42.1:1024 --- 20.0.0.1:6000 + tcp 20.0.0.1:5000 65.55.42.1:2000 65.55.42.1:1025 20.0.0.1:4500 + tcp 20.0.0.1:4500 65.55.42.1:1025 65.55.42.1:2000 20.0.0.1:5000 + tcp 20.0.0.1:5500 65.55.42.1:2000 65.55.42.1:1026 20.0.0.1:4500 + tcp 20.0.0.1:4500 65.55.42.1:1026 65.55.42.1:2000 20.0.0.1:5500 + + admin@sonic:~$ show nat translations count + + Static NAT Entries ................. 4 + Static NAPT Entries ................. 2 + Dynamic NAT Entries ................. 0 + Dynamic NAPT Entries ................. 4 + Static Twice NAT Entries ................. 0 + Static Twice NAPT Entries ................. 4 + Dynamic Twice NAT Entries ................ 0 + Dynamic Twice NAPT Entries ................ 0 + Total SNAT/SNAPT Entries ................ 9 + Total DNAT/DNAPT Entries ................ 9 + Total Entries ................ 14 + ``` + +### NAT Config commands + +**config nat add static** + +This command is used to add a static NAT or NAPT entry. +When configuring the Static NAT entry, user has to specify the following fields with 'basic' keyword. + +1. Global IP address, +2. Local IP address, +3. NAT type (snat / dnat) to be applied on the Global IP address. Default value is dnat. This is optinoal argument. +4. Twice NAT Id. This is optional argument used in case of twice nat configuration. + +When configuring the Static NAPT entry, user has to specify the following fields. + +1. IP protocol type (tcp / udp) +2. Global IP address + Port +3. Local IP address + Port +4. NAT type (snat / dnat) to be applied on the Global IP address + Port. Default value is dnat. This is optional argument. +5. Twicw NAT Id. This is optional argument used in case of twice nat configuration. + +- Usage: + ``` + config nat add static /{/{basic (global-ip) (local-ip)/} | /{/{tcp | udp/} (global-ip) (global-port) (local-ip) (local-port)/}/} [-nat_type /{snat | dnat/}] [-twice_nat_id (value)] + ``` + +To delete a static NAT or NAPT entry, use the command below. Giving the all argument deletes all the configured static NAT and NAPT entries. +``` +config nat remove static /{/{basic (global-ip) (local-ip)/} | /{/{tcp | udp/} (global-ip) (global-port) (local-ip) (local-port)/} | all/} +``` +- Example: + ``` + admin@sonic:~$ sudo config nat add static basic 65.55.45.1 12.12.12.14 -nat_type dnat + admin@sonic:~$ sudo config nat add static tcp 65.55.45.2 100 12.12.12.15 200 -nat_type dnat + + admin@sonic:~$ show nat translations + + Static NAT Entries ................. 2 + Static NAPT Entries ................. 2 + Dynamic NAT Entries ................. 0 + Dynamic NAPT Entries ................. 0 + Static Twice NAT Entries ................. 0 + Static Twice NAPT Entries ................. 0 + Dynamic Twice NAT Entries ................ 0 + Dynamic Twice NAPT Entries ................ 0 + Total SNAT/SNAPT Entries ................ 2 + Total DNAT/DNAPT Entries ................ 2 + Total Entries ................ 4 + + Protocol Source Destination Translated Source Translated Destination + -------- --------- -------------- ----------------- ---------------------- + all 12.12.12.14 --- 65.55.42.1 --- + all --- 65.55.42.1 --- 12.12.12.14 + tcp 12.12.12.15:200 --- 65.55.42.2:100 --- + tcp --- 65.55.42.2:100 --- 12.12.12.15:200 + ``` + +**config nat add pool** + +This command is used to create a NAT pool used for dynamic Source NAT or NAPT translations. +Pool can be configured in one of the following combinations. + +1. Global IP address range (or) +2. Global IP address + L4 port range (or) +3. Global IP address range + L4 port range. + +- Usage: + ``` + config nat add pool (pool-name) (global-ip-range) (global-port-range) + ``` +To delete a NAT pool, use the command. Pool cannot be removed if it is referenced by a NAT binding. Giving the pools argument removes all the configured pools. +``` +config nat remove {pool (pool-name) | pools} +``` +- Example: + ``` + admin@sonic:~$ sudo config nat add pool pool1 65.55.45.2-65.55.45.10 + admin@sonic:~$ sudo config nat add pool pool2 65.55.45.3 100-1024 + + admin@sonic:~$ show nat config pool + + Pool Name Global IP Range Global Port Range + ----------- ---------------------- ------------------- + pool1 65.55.45.2-65.55.45.10 --- + pool2 65.55.45.3 100-1024 + ``` + +**config nat add binding** + +This command is used to create a NAT binding between a pool and an ACL. The following fields are needed for configuring the binding. + + 1. ACL is an optional argument. If ACL argument is not given, the NAT binding is applicable to match all traffic. + 2. NAT type is an optional argument. Only DNAT type is supoprted for binding. + 3. Twice NAT Id is an optional argument. This Id is used to form a twice nat grouping with the static NAT/NAPT entry configured with the same Id. + +- Usage: + ``` + config nat add binding (binding-name) [(pool-name)] [(acl-name)] [-nat_type {snat | dnat}] [-twice_nat_id (value)] + ``` +To delete a NAT binding, use the command below. Giving the bindings argument removes all the configured bindings. +``` +config nat remove {binding (binding-name) | bindings} +``` +- Example: + ``` + admin@sonic:~$ sudo config nat add binding bind1 pool1 acl1 + admin@sonic:~$ sudo config nat add binding bind2 pool2 + + admin@sonic:~$ show nat config bindings + + Binding Name Pool Name Access-List Nat Type Twice-NAT Id + -------------- ----------- ------------- ---------- -------------- + bind1 pool1 acl1 snat --- + bind2 pool2 snat --- + ``` + +**config nat add interface** + +This command is used to configure NAT zone on an L3 interface. Default value of NAT zone on an L3 interface is 0. Valid range of zone values is 0-3. + +- Usage: + ``` + config nat add interface (interface-name) -nat_zone (value) + ``` +To reset the NAT zone on an interface, use the command below. Giving the interfaces argument resets the NAT zone on all the L3 interfaces to 0. +``` +config nat remove {interface (interface-name) | interfaces} +``` +- Example: + ``` + admin@sonic:~$ sudo config nat add interface Ethernet28 -nat_zone 1 + + admin@sonic:~$ show nat config zones + + Port Zone + ---------- ------ + Ethernet0 0 + Ethernet28 1 + Ethernet22 0 + Vlan2091 0 + ``` + +**config nat set** + +This command is used to set the NAT timeout values. Different timeout values can be configured for the NAT entry timeout, NAPT TCP entry timeout, NAPT UDP entry timeout. +Range for Global NAT entry timeout is 300 sec to 432000 sec, default value is 600 sec. +Range for TCP NAT/NAPT entry timeout is 300 sec to 432000 sec, default value is 86400 sec. +Range for UDP NAT/NAPT entry timeout is 120 sec to 600 sec, default value is 300 sec. + +- Usage: + ``` + config nat set {tcp-timeout (value) | timeout (value) | udp-timeout (value)} + ``` +To reset the timeout values to the default values, use the command +``` +config nat reset {tcp-timeout | timeout | udp-timeout} +``` +- Example: + ``` + admin@sonic:~$ sudo config nat add set tcp-timeout 3600 + + admin@sonic:~$ show nat config globalvalues + + Admin Mode : enabled + Global Timeout : 600 secs + TCP Timeout : 600 secs + UDP Timeout : 300 secs + ``` + +**config nat feature** + +This command is used to enable or disable the NAT feature. + +- Usage: + ``` + config nat feature {enable | disable} + ``` + +- Example: + ``` + admin@sonic:~$ sudo config nat feature enable + admin@sonic:~$ sudo config nat feature disable + ``` + +### NAT Clear commands + +**sonic-clear nat translations** + +This command is used to clear the dynamic NAT and NAPT translation entries. + +- Usage: + ``` + sonic-clear nat translations + ``` + +**sonic-clear nat statistics** + +This command is used to clear the statistics of all the NAT and NAPT entries. + +- Usage: + ``` + sonic-clear nat statistics + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#nat) + + +## NTP + +### NTP show commands + +**show ntp** + +This command displays a list of NTP peers known to the server as well as a summary of their state. + +- Usage: + ``` + show ntp + ``` + +- Example: + ``` + admin@sonic:~$ show ntp + synchronised to NTP server (204.2.134.164) at stratum 3 + time correct to within 326797 ms + polling server every 1024 s + + remote refid st t when poll reach delay offset jitter + ============================================================================== + 23.92.29.245 .XFAC. 16 u - 1024 0 0.000 0.000 0.000 + *204.2.134.164 46.233.231.73 2 u 916 1024 377 3.079 0.394 0.128 + ``` + + +### NTP Config Commands + +This sub-section of commands is used to add or remove the configured NTP servers. + +**config ntp add** + +This command is used to add a NTP server IP address to the NTP server list. Note that more that one NTP server IP address can be added in the device. + +- Usage: + ``` + config ntp add + ``` + +- Example: + ``` + admin@sonic:~$ sudo config ntp add 9.9.9.9 + NTP server 9.9.9.9 added to configuration + Restarting ntp-config service... + ``` + +**config ntp delete** + +This command is used to delete a configured NTP server IP address. + +- Usage: + ``` + config ntp del + ``` + +- Example: + ``` + admin@sonic:~$ sudo config ntp del 9.9.9.9 + NTP server 9.9.9.9 removed from configuration + Restarting ntp-config service... + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#NTP) + +# PFC Watchdog Commands +Detailed description of the PFC Watchdog could be fount on the [this wiki page](https://github.com/Azure/SONiC/wiki/PFC-Watchdog) + +**config pfcwd start \** + +This command starts PFC Watchdog + +- Usage: + ``` + config pfcwd start --action drop all 400 --restoration-time 400 + config pfcwd start --action forward Ethernet0 Ethernet8 400 + ``` + +**config pfcwd stop** + +This command stops PFC Watchdog + +- Usage: + ``` + config pfcwd stop + ``` + +**config pfcwd interval \** + +This command sets PFC Watchdog counter polling interval (in ms) + +- Usage: + ``` + config pfcwd interval 200 + ``` + +**config pfcwd counter_poll \** + +This command enables or disables PFCWD related counters polling + +- Usage: + ``` + config pfcwd counter_poll disable + ``` + +**config pfcwd big_red_switch \** + +This command enables or disables PFCWD's "BIG RED SWITCH"(BRS). After enabling BRS PFC Watchdog will be activated on all ports/queues it is configured for no matter whether the storm was detected or not + +- Usage: + ``` + config pfcwd big_red_switch enable + ``` + +**config pfcwd start_default** + +This command starts PFC Watchdog with the default settings. + +- Usage: + ``` + config pfcwd start_default + ``` + +Default values are the following: + + - detection time - 200ms + - restoration time - 200ms + - polling interval - 200ms + - action - 'drop' + +Additionally if number of ports in the system exceeds 32, all times will be multiplied by roughly /32. + + +**show pfcwd config** + +This command shows current PFC Watchdog configuration + +- Usage: + ``` + show pfcwd config + ``` + +**show pfcwd stats** + +This command shows current PFC Watchdog statistics (storms detected, packets dropped, etc) + +- Usage: + ``` + show pfcwd stats + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#pfc-watchdog-commands) + +## Platform Component Firmware + +### Platform Component Firmware show commands + +**show platform firmware status** + +This command displays platform components firmware status information. + +- Usage: +```bash +show platform firmware status +``` + +- Example: +```bash +admin@sonic:~$ sudo show platform firmware status +Chassis Module Component Version Description +--------- -------- ----------- ----------------------- ---------------------------------------- +MSN3800 N/A ONIE 2020.11-5.2.0022-9600 ONIE - Open Network Install Environment + SSD 0202-000 SSD - Solid-State Drive + BIOS 0ACLH004_02.02.008_9600 BIOS - Basic Input/Output System + CPLD1 CPLD000120_REV0900 CPLD - Complex Programmable Logic Device + CPLD2 CPLD000165_REV0500 CPLD - Complex Programmable Logic Device + CPLD3 CPLD000166_REV0300 CPLD - Complex Programmable Logic Device + CPLD4 CPLD000167_REV0100 CPLD - Complex Programmable Logic Device +``` + +**show platform firmware updates** + +This command displays platform components firmware updates information. + +- Usage: +```bash +show platform firmware updates [-i|--image] +``` + +- Options: + - _-i|--image_: show updates using current/next SONiC image + + Valid values: + - current + - next + + Default: + - current + +- Example: +```bash +admin@sonic:~$ sudo show platform firmware updates +Chassis Module Component Firmware Version (Current/Available) Status +--------- -------- ----------- ------------------------------------------ ------------------------------------------------- ------------------ +MSN3800 N/A ONIE /usr/local/lib/firmware/mellanox/onie.bin 2020.11-5.2.0022-9600 / 2020.11-5.2.0024-9600 update is required + SSD /usr/local/lib/firmware/mellanox/ssd.bin 0202-000 / 0204-000 update is required + BIOS /usr/local/lib/firmware/mellanox/bios.bin 0ACLH004_02.02.008_9600 / 0ACLH004_02.02.010_9600 update is required + CPLD1 /usr/local/lib/firmware/mellanox/cpld.mpfa CPLD000120_REV0900 / CPLD000120_REV0900 up-to-date + CPLD2 /usr/local/lib/firmware/mellanox/cpld.mpfa CPLD000165_REV0500 / CPLD000165_REV0500 up-to-date + CPLD3 /usr/local/lib/firmware/mellanox/cpld.mpfa CPLD000166_REV0300 / CPLD000166_REV0300 up-to-date + CPLD4 /usr/local/lib/firmware/mellanox/cpld.mpfa CPLD000167_REV0100 / CPLD000167_REV0100 up-to-date +``` + +- Note: + - current/next values for _-i|--image_ are taken from `sonic-installer list` + ```bash + admin@sonic:~$ sudo sonic-installer list + Current: SONiC-OS-202012.0-fb89c28c9 + Next: SONiC-OS-201911.0-2bec3004e + Available: + SONiC-OS-202012.0-fb89c28c9 + SONiC-OS-201911.0-2bec3004e + ``` + +**show platform firmware version** + +This command displays platform components firmware utility version. + +- Usage: +```bash +show platform firmware version +``` + +- Example: +```bash +admin@sonic:~$ show platform firmware version +fwutil version 2.0.0.0 +``` + +### Platform Component Firmware config commands + +**config platform firmware install** + +This command is used to install a platform component firmware. +Both modular and non modular chassis platforms are supported. + +- Usage: +```bash +config platform firmware install chassis component fw [-y|--yes] +config platform firmware install module component fw [-y|--yes] +``` + +- Options: + - _-y|--yes_: automatic yes to prompts. Assume "yes" as answer to all prompts and run non-interactively + +- Example: +```bash +admin@sonic:~$ sudo config platform firmware install chassis component BIOS fw /usr/local/lib/firmware/mellanox/sn3800/chassis1/bios.bin +Warning: Immediate cold reboot is required to complete BIOS firmware update. +New firmware will be installed, continue? [y/N]: y +Installing firmware: + /usr/local/lib/firmware/mellanox/sn3800/chassis1/bios.bin + +admin@sonic:~$ sudo config platform firmware install module Module1 component BIOS fw https://www.mellanox.com/fw/sn3800/module1/bios.bin +Warning: Immediate cold reboot is required to complete BIOS firmware update. +New firmware will be installed, continue? [y/N]: y +Downloading firmware: + [##################################################] 100% +Installing firmware: + /tmp/bios.bin +``` + +- Note: + - can be absolute path or URL + +**config platform firmware update** + +This command is used to update a platform component firmware from current/next SONiC image. +Both modular and non modular chassis platforms are supported. + +FW update requires `platform_components.json` to be created and placed at: +sonic-buildimage/device///platform_components.json + +Example: +1. Non modular chassis platform +```json +{ + "chassis": { + "Chassis1": { + "component": { + "BIOS": { + "firmware": "/usr/local/lib/firmware///chassis1/bios.bin", + "version": "" + }, + "CPLD": { + "firmware": "/usr/local/lib/firmware///chassis1/cpld.bin", + "version": "" + }, + "FPGA": { + "firmware": "/usr/local/lib/firmware///chassis1/fpga.bin", + "version": "" + } + } + } + } +} +``` + +2. Modular chassis platform +```json +{ + "chassis": { + "Chassis1": { + "component": { + "BIOS": { + "firmware": "/usr/local/lib/firmware///chassis1/bios.bin", + "version": "" + }, + "CPLD": { + "firmware": "/usr/local/lib/firmware///chassis1/cpld.bin", + "version": "" + }, + "FPGA": { + "firmware": "/usr/local/lib/firmware///chassis1/fpga.bin", + "version": "" + } + } + } + }, + "module": { + "Module1": { + "component": { + "CPLD": { + "firmware": "/usr/local/lib/firmware///module1/cpld.bin", + "version": "" + }, + "FPGA": { + "firmware": "/usr/local/lib/firmware///module1/fpga.bin", + "version": "" + } + } + } + } +} +``` + +- Usage: +```bash +config platform firmware update chassis component fw [-y|--yes] [-f|--force] [-i|--image] +config platform firmware update module component fw [-y|--yes] [-f|--force] [-i|--image] +``` + +- Options: + - _-y|--yes_: automatic yes to prompts. Assume "yes" as answer to all prompts and run non-interactively + - _-f|--force_: update FW regardless the current version + - _-i|--image_: update FW using current/next SONiC image + + Valid values: + - current + - next + + Default: + - current + +- Example: +```bash +admin@sonic:~$ sudo config platform firmware update chassis component BIOS fw +Warning: Immediate cold reboot is required to complete BIOS firmware update. +New firmware will be installed, continue? [y/N]: y +Updating firmware: + /usr/local/lib/firmware/mellanox/x86_64-mlnx_msn3800-r0/chassis1/bios.bin + +admin@sonic:~$ sudo config platform firmware update module Module1 component BIOS fw +Warning: Immediate cold reboot is required to complete BIOS firmware update. +New firmware will be installed, continue? [y/N]: y +Updating firmware: + /usr/local/lib/firmware/mellanox/x86_64-mlnx_msn3800-r0/module1/bios.bin +``` + +- Note: + - FW update will be disabled if component definition is not provided (e.g., 'BIOS': { }) + - FW version will be read from image if `version` field is not provided + - current/next values for _-i|--image_ are taken from `sonic-installer list` + ```bash + admin@sonic:~$ sudo sonic-installer list + Current: SONiC-OS-202012.0-fb89c28c9 + Next: SONiC-OS-201911.0-2bec3004e + Available: + SONiC-OS-202012.0-fb89c28c9 + SONiC-OS-201911.0-2bec3004e + ``` + +### Platform Component Firmware vendor specific behaviour + +#### Mellanox + +**CPLD update** + +On Mellanox platforms CPLD update can be done either for single or for all components at once. +The second approach is preferred. In this case an aggregated `vme` binary is used and +CPLD component can be specified arbitrary. + +- Example: +```bash +root@sonic:/home/admin# show platform firmware +Chassis Module Component Version Description +---------------------- -------- ----------- ----------------------- ---------------------------------------- +x86_64-mlnx_msn3800-r0 N/A BIOS 0ACLH004_02.02.007_9600 BIOS - Basic Input/Output System + CPLD1 CPLD000000_REV0400 CPLD - Complex Programmable Logic Device + CPLD2 CPLD000000_REV0300 CPLD - Complex Programmable Logic Device + CPLD3 CPLD000000_REV0300 CPLD - Complex Programmable Logic Device + CPLD4 CPLD000000_REV0100 CPLD - Complex Programmable Logic Device + +root@sonic:/home/admin# BURN_VME="$(pwd)/FUI000091_Burn_SN3800_CPLD000120_REV0600_CPLD000165_REV0400_CPLD000166_REV0300_CPLD000167_REV0100.vme" +root@sonic:/home/admin# REFRESH_VME="$(pwd)/FUI000091_Refresh_SN3800_CPLD000120_REV0600_CPLD000165_REV0400_CPLD000166_REV0300_CPLD000167_REV0100.vme" + +root@sonic:/home/admin# config platform firmware install chassis component CPLD1 fw -y ${BURN_VME} +root@sonic:/home/admin# config platform firmware install chassis component CPLD1 fw -y ${REFRESH_VME} + +root@sonic:/home/admin# show platform firmware +Chassis Module Component Version Description +---------------------- -------- ----------- ----------------------- ---------------------------------------- +x86_64-mlnx_msn3800-r0 N/A BIOS 0ACLH004_02.02.007_9600 BIOS - Basic Input/Output System + CPLD1 CPLD000000_REV0600 CPLD - Complex Programmable Logic Device + CPLD2 CPLD000000_REV0400 CPLD - Complex Programmable Logic Device + CPLD3 CPLD000000_REV0300 CPLD - Complex Programmable Logic Device + CPLD4 CPLD000000_REV0100 CPLD - Complex Programmable Logic Device +``` + +Note: the update will have the same effect if any of CPLD1/CPLD2/CPLD3/CPLD4 will be used + +Go Back To [Beginning of the document](#) or [Beginning of this section](#platform-component-firmware) + + +## 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** + +This command shows the SDK sniffer status + +- Usage: + ``` + show platform mlnx sniffer + ``` + +- Example: + ``` + admin@sonic:~$ show platform mlnx sniffer + sdk sniffer is disabled + ``` + +**show platform mlnx sniffer** + +Another show command available on ‘show platform mlnx’ which is the issu status. +This means if ISSU is enabled on this SKU or not. A warm boot command can be executed only when ISSU is enabled on the SKU. + +- Usage: + ``` + show platform mlnx issu + ``` + +- Example: + ``` + admin@sonic:~$ show platform mlnx issu + ISSU is enabled + ``` + +In the case ISSU is disabled and warm-boot is called, the user will get a notification message explaining that the command cannot be invoked. + +- Example: + ``` + admin@sonic:~$ sudo warm-reboot + ISSU is not enabled on this HWSKU + Warm reboot is not supported + ``` + +**config platform mlnx** + +This command is valid only on mellanox devices. The sub-commands for "config platform" gets populated only on mellanox platforms. +There are no other subcommands on non-Mellanox devices and hence this command appears empty and useless in other platforms. +The platform mellanox command currently includes a single sub command which is the SDK sniffer. +The SDK sniffer is a troubleshooting tool which records the RPC calls from the Mellanox SDK user API library to the sx_sdk task into a .pcap file. +This .pcap file can be replayed afterward to get the exact same configuration state on SDK and FW to reproduce and investigate issues. + +A new folder will be created to store the sniffer files: "/var/log/mellanox/sniffer/". The result file will be stored in a .pcap file, which includes a time stamp of the starting time in the file name, for example, "sx_sdk_sniffer_20180224081306.pcap" +In order to have a complete .pcap file with all the RPC calls, the user should disable the SDK sniffer. Swss service will be restarted and no capturing is taken place from that moment. +It is recommended to review the .pcap file while sniffing is disabled. +Once SDK sniffer is enabled/disabled, the user is requested to approve that swss service will be restarted. +For example: To change SDK sniffer status, swss service will be restarted, continue? [y/N]: +In order to avoid that confirmation the -y / --yes option should be used. + +- Usage: + ``` + config platform mlnx sniffer sdk [-y|--yes] + ``` + +- Example: + ``` + admin@sonic:~$ config platform mlnx sniffer sdk + To change SDK sniffer status, swss service will be restarted, continue? [y/N]: y + 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) + + +## PortChannels + +### PortChannel Show commands + +**show interfaces portchannel** + +This command displays all the port channels that are configured in the device and its current status. + +- Usage: + ``` + show interfaces portchannel + ``` + +- Example: + ``` + admin@sonic:~$ show interfaces portchannel + Flags: A - active, I - inactive, Up - up, Dw - Down, N/A - not available, S - selected, D - deselected + No. Team Dev Protocol Ports + ----- ------------- ----------- --------------------------- + 24 PortChannel24 LACP(A)(Up) Ethernet28(S) Ethernet24(S) + 48 PortChannel48 LACP(A)(Up) Ethernet52(S) Ethernet48(S) + 40 PortChannel40 LACP(A)(Up) Ethernet44(S) Ethernet40(S) + 0 PortChannel0 LACP(A)(Up) Ethernet0(S) Ethernet4(S) + 8 PortChannel8 LACP(A)(Up) Ethernet8(S) Ethernet12(S) + ``` + + +### PortChannel Config commands + +This sub-section explains how to configure the portchannel and its member ports. + +**config portchannel** + +This command is used to add or delete the portchannel. +It is recommended to use portchannel names in the format "PortChannelxxxx", where "xxxx" is number of 1 to 4 digits. Ex: "PortChannel0002". + +NOTE: If users specify any other name like "pc99", command will succeed, but such names are not supported. Such names are not printed properly in the "show interface portchannel" command. It is recommended not to use such names. + +When any port is already member of any other portchannel and if user tries to add the same port in some other portchannel (without deleting it from the current portchannel), the command fails internally. But, it does not print any error message. In such cases, remove the member from current portchannel and then add it to new portchannel. + +Command takes two optional arguements given below. +1) min-links - minimum number of links required to bring up the portchannel +2) fallback - true/false. LACP fallback feature can be enabled / disabled. When it is set to true, only one member port will be selected as active per portchannel during fallback mode. Refer https://github.com/Azure/SONiC/blob/master/doc/lag/LACP%20Fallback%20Feature%20for%20SONiC_v0.5.md for more details about fallback feature. + +A port channel can be deleted only if it does not have any members or the members are already deleted. When a user tries to delete a port channel and the port channel still has one or more members that exist, the deletion of port channel is blocked. + +- Usage: + ``` + config portchannel (add | del) [--min-links ] [--fallback (true | false)] + ``` + +- Example (Create the portchannel with name "PortChannel0011"): + ``` + admin@sonic:~$ sudo config portchannel add PortChannel0011 + ``` + +**config portchannel member** + +This command adds or deletes a member port to/from the already created portchannel. + +- Usage: + ``` + config portchannel member (add | del) + ``` + +- Example (Add interface Ethernet4 as member of the portchannel "PortChannel0011"): + ``` + admin@sonic:~$ sudo config portchannel member add PortChannel0011 Ethernet4 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#portchannels) + +## NVGRE + +This section explains the various show commands and configuration commands available for users. + +### NVGRE show commands + +This subsection explains how to display the NVGRE configuration. + +**show nvgre-tunnel** + +This command displays the NVGRE tunnel configuration. + +- Usage: +```bash +show nvgre-tunnel +``` + +- Example: +```bash +admin@sonic:~$ show nvgre-tunnel +TUNNEL NAME SRC IP +------------- -------- +tunnel_1 10.0.0.1 +``` + +**show nvgre-tunnel-map** + +This command displays the NVGRE tunnel map configuration. + +- Usage: +```bash +show nvgre-tunnel-map +``` + +- Example: +```bash +admin@sonic:~$ show nvgre-tunnel-map +TUNNEL NAME TUNNEL MAP NAME VLAN ID VSID +------------- ----------------- --------- ------ +tunnel_1 Vlan1000 1000 5000 +tunnel_1 Vlan2000 2000 6000 +``` + +### NVGRE config commands + +This subsection explains how to configure the NVGRE. + +**config nvgre-tunnel** + +This command is used to manage the NVGRE tunnel objects. +It supports add/delete operations. + +- Usage: +```bash +config nvgre-tunnel add --src-ip +config nvgre-tunnel delete +``` + +- Parameters: + - _tunnel-name_: the name of the NVGRE tunnel + - _src-ip_: source ip address + +- Examples: +```bash +config nvgre-tunnel add 'tunnel_1' --src-ip '10.0.0.1' +config nvgre-tunnel delete 'tunnel_1' +``` + +**config nvgre-tunnel-map** + +This command is used to manage the NVGRE tunnel map objects. +It supports add/delete operations. + +- Usage: +```bash +config nvgre-tunnel-map add --vlan-id --vsid +config nvgre-tunnel-map delete +``` + +- Parameters: + - _tunnel-name_: the name of the NVGRE tunnel + - _tunnel-map-name_: the name of the NVGRE tunnel map + - _vlan-id_: VLAN identifier + - _vsid_: Virtual Subnet Identifier + +- Examples: +```bash +config nvgre-tunnel-map add 'tunnel_1' 'Vlan2000' --vlan-id '2000' --vsid '6000' +config nvgre-tunnel-map delete 'tunnel_1' 'Vlan2000' +``` + +## PBH + +This section explains the various show commands and configuration commands available for users. + +### PBH show commands + +This subsection explains how to display PBH configuration and statistics. + +**show pbh table** + +This command displays PBH table configuration. + +- Usage: +```bash +show pbh table +``` + +- Example: +```bash +admin@sonic:~$ show pbh table +NAME INTERFACE DESCRIPTION +--------- --------------- --------------- +pbh_table Ethernet0 NVGRE and VxLAN + Ethernet4 + PortChannel0001 + PortChannel0002 +``` + +**show pbh rule** + +This command displays PBH rule configuration. + +- Usage: +```bash +show pbh rule +``` + +- Example: +```bash +admin@sonic:~$ show pbh rule +TABLE RULE PRIORITY MATCH HASH ACTION COUNTER +--------- ------ ---------- ------------------------------------ ------------- ------------- --------- +pbh_table nvgre 2 ether_type: 0x0800 inner_v6_hash SET_ECMP_HASH DISABLED + ip_protocol: 0x2f + gre_key: 0x2500/0xffffff00 + inner_ether_type: 0x86dd +pbh_table vxlan 1 ether_type: 0x0800 inner_v4_hash SET_LAG_HASH ENABLED + ip_protocol: 0x11 + l4_dst_port: 0x12b5 + inner_ether_type: 0x0800 +``` + +**show pbh hash** + +This command displays PBH hash configuration. + +- Usage: +```bash +show pbh hash +``` + +- Example: +```bash +admin@sonic:~$ show pbh hash +NAME HASH FIELD +------------- ----------------- +inner_v4_hash inner_ip_proto + inner_l4_dst_port + inner_l4_src_port + inner_dst_ipv4 + inner_src_ipv4 +inner_v6_hash inner_ip_proto + inner_l4_dst_port + inner_l4_src_port + inner_dst_ipv6 + inner_src_ipv6 +``` + +**show pbh hash-field** + +This command displays PBH hash field configuration. + +- Usage: +```bash +show pbh hash-field +``` + +- Example: +```bash +admin@sonic:~$ show pbh hash-field +NAME FIELD MASK SEQUENCE SYMMETRIC +----------------- ----------------- --------- ---------- ----------- +inner_ip_proto INNER_IP_PROTOCOL N/A 1 No +inner_l4_dst_port INNER_L4_DST_PORT N/A 2 Yes +inner_l4_src_port INNER_L4_SRC_PORT N/A 2 Yes +inner_dst_ipv4 INNER_DST_IPV4 255.0.0.0 3 Yes +inner_src_ipv4 INNER_SRC_IPV4 0.0.0.255 3 Yes +inner_dst_ipv6 INNER_DST_IPV6 ffff:: 4 Yes +inner_src_ipv6 INNER_SRC_IPV6 ::ffff 4 Yes +``` + +- Note: + - _SYMMETRIC_ is an artificial column and is only used to indicate fields symmetry + +**show pbh statistics** + +This command displays PBH statistics. + +- Usage: +```bash +show pbh statistics +``` + +- Example: +```bash +admin@sonic:~$ show pbh statistics +TABLE RULE RX PACKETS COUNT RX BYTES COUNT +--------- ------ ------------------ ---------------- +pbh_table nvgre 0 0 +pbh_table vxlan 0 0 +``` + +- Note: + - _RX PACKETS COUNT_ and _RX BYTES COUNT_ can be cleared by user: + ```bash + admin@sonic:~$ sonic-clear pbh statistics + ``` + +### PBH config commands + +This subsection explains how to configure PBH. + +**config pbh table** + +This command is used to manage PBH table objects. +It supports add/update/remove operations. + +- Usage: +```bash +config pbh table add --interface-list --description +config pbh table update [ --interface-list ] [ --description ] +config pbh table delete +``` + +- Parameters: + - _table_name_: the name of the PBH table + - _interface_list_: interfaces to which PBH table is applied + - _description_: the description of the PBH table + +- Examples: +```bash +config pbh table add 'pbh_table' \ +--interface-list 'Ethernet0,Ethernet4,PortChannel0001,PortChannel0002' \ +--description 'NVGRE and VxLAN' +config pbh table update 'pbh_table' \ +--interface-list 'Ethernet0' +config pbh table delete 'pbh_table' +``` + +**config pbh rule** + +This command is used to manage PBH rule objects. +It supports add/update/remove operations. + +- Usage: +```bash +config pbh rule add --priority \ +[ --gre-key ] [ --ether-type ] [ --ip-protocol ] \ +[ --ipv6-next-header ] [ --l4-dst-port ] [ --inner-ether-type ] \ +--hash [ --packet-action ] [ --flow-counter ] +config pbh rule update [ --priority ] \ +[ --gre-key ] [ --ether-type ] [ --ip-protocol ] \ +[ --ipv6-next-header ] [ --l4-dst-port ] [ --inner-ether-type ] \ +[ --hash ] [ --packet-action ] [ --flow-counter ] +config pbh rule delete +``` + +- Parameters: + - _table_name_: the name of the PBH table + - _rule_name_: the name of the PBH rule + - _priority_: the priority of the PBH rule + - _gre_key_: packet match for the PBH rule: GRE key (value/mask) + - _ether_type_: packet match for the PBH rule: EtherType (IANA Ethertypes) + - _ip_protocol_: packet match for the PBH rule: IP protocol (IANA Protocol Numbers) + - _ipv6_next_header_: packet match for the PBH rule: IPv6 Next header (IANA Protocol Numbers) + - _l4_dst_port_: packet match for the PBH rule: L4 destination port + - _inner_ether_type_: packet match for the PBH rule: inner EtherType (IANA Ethertypes) + - _hash_: _hash_ object to apply with the PBH rule + - _packet_action_: packet action for the PBH rule + + Valid values: + - SET_ECMP_HASH + - SET_LAG_HASH + + Default: + - SET_ECMP_HASH + + - _flow_counter_: packet/byte counter for the PBH rule + + Valid values: + - DISABLED + - ENABLED + + Default: + - DISABLED + +- Examples: +```bash +config pbh rule add 'pbh_table' 'nvgre' \ +--priority '2' \ +--ether-type '0x0800' \ +--ip-protocol '0x2f' \ +--gre-key '0x2500/0xffffff00' \ +--inner-ether-type '0x86dd' \ +--hash 'inner_v6_hash' \ +--packet-action 'SET_ECMP_HASH' \ +--flow-counter 'DISABLED' +config pbh rule update 'pbh_table' 'nvgre' \ +--flow-counter 'ENABLED' +config pbh rule delete 'pbh_table' 'nvgre' +``` + +**config pbh hash** + +This command is used to manage PBH hash objects. +It supports add/update/remove operations. + +- Usage: +```bash +config pbh hash add --hash-field-list +config pbh hash update [ --hash-field-list ] +config pbh hash delete +``` + +- Parameters: + - _hash_name_: the name of the PBH hash + - _hash_field_list_: list of _hash-field_ objects to apply with the PBH hash + +- Examples: +```bash +config pbh hash add 'inner_v6_hash' \ +--hash-field-list 'inner_ip_proto,inner_l4_dst_port,inner_l4_src_port,inner_dst_ipv6,inner_src_ipv6' +config pbh hash update 'inner_v6_hash' \ +--hash-field-list 'inner_ip_proto' +config pbh hash delete 'inner_v6_hash' +``` + +**config pbh hash-field** + +This command is used to manage PBH hash field objects. +It supports add/update/remove operations. + +- Usage: +```bash +config pbh hash-field add \ +--hash-field [ --ip-mask ] --sequence-id +config pbh hash-field update \ +[ --hash-field ] [ --ip-mask ] [ --sequence-id ] +config pbh hash-field delete +``` + +- Parameters: + - _hash_field_name_: the name of the PBH hash field + - _hash_field_: native hash field for the PBH hash field + + Valid values: + - INNER_IP_PROTOCOL + - INNER_L4_DST_PORT + - INNER_L4_SRC_PORT + - INNER_DST_IPV4 + - INNER_SRC_IPV4 + - INNER_DST_IPV6 + - INNER_SRC_IPV6 + + - _ip_mask_: IPv4/IPv6 address mask for the PBH hash field + + Valid only: _hash_field_ is: + - INNER_DST_IPV4 + - INNER_SRC_IPV4 + - INNER_DST_IPV6 + - INNER_SRC_IPV6 + + - _sequence_id_: the order in which fields are hashed + +- Examples: +```bash +config pbh hash-field add 'inner_dst_ipv6' \ +--hash-field 'INNER_DST_IPV6' \ +--ip-mask 'ffff::' \ +--sequence-id '4' +config pbh hash-field update 'inner_dst_ipv6' \ +--ip-mask 'ffff:ffff::' +config pbh hash-field delete 'inner_dst_ipv6' +``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#pbh) + +## QoS + +### QoS Show commands + +#### PFC + +**show pfc counters** + +This command displays the details of Rx & Tx priority-flow-control (pfc) for all ports. This command can be used to clear the counters using -c option. + +- Usage: + ``` + show pfc counters + ``` + +- Example: + ``` + admin@sonic:~$ show pfc counters + Port Rx PFC0 PFC1 PFC2 PFC3 PFC4 PFC5 PFC6 PFC7 + ----------- ------ ------ ------ ------ ------ ------ ------ ------ + Ethernet0 0 0 0 0 0 0 0 0 + Ethernet4 0 0 0 0 0 0 0 0 + Ethernet8 0 0 0 0 0 0 0 0 + Ethernet12 0 0 0 0 0 0 0 0 + + Port Tx PFC0 PFC1 PFC2 PFC3 PFC4 PFC5 PFC6 PFC7 + ----------- ------ ------ ------ ------ ------ ------ ------ ------ + Ethernet0 0 0 0 0 0 0 0 0 + Ethernet4 0 0 0 0 0 0 0 0 + Ethernet8 0 0 0 0 0 0 0 0 + Ethernet12 0 0 0 0 0 0 0 0 + + ... + ``` + + +- NOTE: PFC counters can be cleared by the user with the following command: + ``` + admin@sonic:~$ sonic-clear pfccounters + ``` + +**show pfc asymmetric** + +This command displays the status of asymmetric PFC for all interfaces or a given interface. + +- Usage: + ``` + show pfc asymmetric [] + ``` + +- Example: + ``` + admin@sonic:~$ show pfc asymmetric + + Interface Asymmetric + ----------- ------------ + Ethernet0 off + Ethernet2 off + Ethernet4 off + Ethernet6 off + Ethernet8 off + Ethernet10 off + Ethernet12 off + Ethernet14 off + + admin@sonic:~$ show pfc asymmetric Ethernet0 + + Interface Asymmetric + ----------- ------------ + Ethernet0 off + ``` + +**show pfc priority** + +This command displays the lossless priorities for all interfaces or a given interface. + +- Usage: + ``` + show pfc priority [] + ``` + +- Example: + ``` + admin@sonic:~$ show pfc priority + + Interface Lossless priorities + ----------- --------------------- + Ethernet0 3,4 + Ethernet2 3,4 + Ethernet8 3,4 + Ethernet10 3,4 + Ethernet16 3,4 + + admin@sonic:~$ show pfc priority Ethernet0 + + Interface Lossless priorities + ----------- --------------------- + Ethernet0 3,4 + ``` + +#### Queue And Priority-Group + +This sub-section explains the following queue parameters that can be displayed using "show queue" command. +1) queue counters +2) queue watermark +3) priority-group watermark +4) queue persistent-watermark + + +**show queue counters** + +This command displays packet and byte counters for all queues of all ports or one specific-port given as arguement. +This command can be used to clear the counters for all queues of all ports. Note that port specific clear is not supported. + +- Usage: + ``` + show queue counters [] + ``` + +- Example: + ``` + admin@sonic:~$ show queue counters + Port TxQ Counter/pkts Counter/bytes Drop/pkts Drop/bytes + --------- ----- -------------- --------------- ----------- ------------ + Ethernet0 UC0 0 0 0 0 + Ethernet0 UC1 0 0 0 0 + Ethernet0 UC2 0 0 0 0 + Ethernet0 UC3 0 0 0 0 + Ethernet0 UC4 0 0 0 0 + Ethernet0 UC5 0 0 0 0 + Ethernet0 UC6 0 0 0 0 + Ethernet0 UC7 0 0 0 0 + Ethernet0 UC8 0 0 0 0 + Ethernet0 UC9 0 0 0 0 + Ethernet0 MC0 0 0 0 0 + Ethernet0 MC1 0 0 0 0 + Ethernet0 MC2 0 0 0 0 + Ethernet0 MC3 0 0 0 0 + Ethernet0 MC4 0 0 0 0 + Ethernet0 MC5 0 0 0 0 + Ethernet0 MC6 0 0 0 0 + Ethernet0 MC7 0 0 0 0 + Ethernet0 MC8 0 0 0 0 + Ethernet0 MC9 0 0 0 0 + + Port TxQ Counter/pkts Counter/bytes Drop/pkts Drop/bytes + --------- ----- -------------- --------------- ----------- ------------ + Ethernet4 UC0 0 0 0 0 + Ethernet4 UC1 0 0 0 0 + Ethernet4 UC2 0 0 0 0 + Ethernet4 UC3 0 0 0 0 + Ethernet4 UC4 0 0 0 0 + Ethernet4 UC5 0 0 0 0 + Ethernet4 UC6 0 0 0 0 + Ethernet4 UC7 0 0 0 0 + Ethernet4 UC8 0 0 0 0 + Ethernet4 UC9 0 0 0 0 + Ethernet4 MC0 0 0 0 0 + Ethernet4 MC1 0 0 0 0 + Ethernet4 MC2 0 0 0 0 + Ethernet4 MC3 0 0 0 0 + Ethernet4 MC4 0 0 0 0 + Ethernet4 MC5 0 0 0 0 + Ethernet4 MC6 0 0 0 0 + Ethernet4 MC7 0 0 0 0 + Ethernet4 MC8 0 0 0 0 + Ethernet4 MC9 0 0 0 0 + + ... + ``` + +Optionally, you can specify an interface name in order to display only that particular interface + +- Example: + ``` + admin@sonic:~$ show queue counters Ethernet72 + ``` + +- NOTE: Queue counters can be cleared by the user with the following command: + ``` + admin@sonic:~$ sonic-clear queuecounters + ``` + +**show queue watermark** + +This command displays the user watermark for the queues (Egress shared pool occupancy per queue) for either the unicast queues or multicast queues for all ports + +- Usage: + ``` + show queue watermark (multicast | unicast) + ``` + +- Example: + ``` + admin@sonic:~$ show queue watermark unicast + Egress shared pool occupancy per unicast queue: + Port UC0 UC1 UC2 UC3 UC4 UC5 UC6 UC7 + ----------- ----- ----- ----- ----- ----- ----- ----- ----- + Ethernet0 0 0 0 0 0 0 0 0 + Ethernet4 0 0 0 0 0 0 0 0 + Ethernet8 0 0 0 0 0 0 0 0 + Ethernet12 0 0 0 0 0 0 0 0 + + admin@sonic:~$ show queue watermark multicast (Egress shared pool occupancy per multicast queue) + ``` + +**show priority-group** + +This command displays: +1) The user watermark or persistent-watermark for the Ingress "headroom" or "shared pool occupancy" per priority-group for all ports. +2) Dropped packets per priority-group for all ports + +- Usage: + ``` + show priority-group (watermark | persistent-watermark) (headroom | shared) + show priority-group drop counters + ``` + +- Example: + ``` + admin@sonic:~$ show priority-group watermark shared + Ingress shared pool occupancy per PG: + Port PG0 PG1 PG2 PG3 PG4 PG5 PG6 PG7 + ----------- ----- ----- ----- ----- ----- ----- ----- ----- + Ethernet0 0 0 0 0 0 0 0 0 + Ethernet4 0 0 0 0 0 0 0 0 + Ethernet8 0 0 0 0 0 0 0 0 + Ethernet12 0 0 0 0 0 0 0 0 + ``` + +- Example (Ingress headroom per PG): + ``` + admin@sonic:~$ show priority-group watermark headroom + ``` + +- Example (Ingress shared pool occupancy per PG): + ``` + admin@sonic:~$ show priority-group persistent-watermark shared + ``` + +- Example (Ingress headroom per PG): + ``` + admin@sonic:~$ show priority-group persistent-watermark headroom + ``` + +- Example (Ingress dropped packets per PG): + ``` + admin@sonic:~$ show priority-group drop counters + Ingress PG dropped packets: + Port PG0 PG1 PG2 PG3 PG4 PG5 PG6 PG7 + ----------- ----- ----- ----- ----- ----- ----- ----- ----- + Ethernet0 0 0 0 0 0 0 0 0 + Ethernet4 0 0 0 0 0 0 0 0 + Ethernet8 0 0 0 0 0 0 0 0 + Ethernet12 0 0 0 0 0 0 0 0 + ``` + +In addition to user watermark("show queue|priority-group watermark ..."), a persistent watermark is available. +It hold values independently of user watermark. This way user can use "user watermark" for debugging, clear it, etc, but the "persistent watermark" will not be affected. + +**show queue persistent-watermark** + +This command displays the user persistet-watermark for the queues (Egress shared pool occupancy per queue) for either the unicast queues or multicast queues for all ports + +- Usage: + ``` + show queue persistent-watermark (unicast | multicast) + ``` + +- Example: + ``` + admin@sonic:~$ show queue persistent-watermark unicast + Egress shared pool occupancy per unicast queue: + Port UC0 UC1 UC2 UC3 UC4 UC5 UC6 UC7 + ----------- ----- ----- ----- ----- ----- ----- ----- ----- + Ethernet0 N/A N/A N/A N/A N/A N/A N/A N/A + Ethernet4 N/A N/A N/A N/A N/A N/A N/A N/A + Ethernet8 N/A N/A N/A N/A N/A N/A N/A N/A + Ethernet12 N/A N/A N/A N/A N/A N/A N/A N/A + ``` + +- Example (Egress shared pool occupancy per multicast queue): + ``` + admin@sonic:~$ show queue persistent-watermark multicast + ``` + +- NOTE: "user watermark", "persistent watermark" and "ingress dropped packets" can be cleared by user: + + ``` + admin@sonic:~$ sonic-clear queue persistent-watermark unicast + + admin@sonic:~$ sonic-clear queue persistent-watermark multicast + + admin@sonic:~$ sonic-clear priority-group persistent-watermark shared + + admin@sonic:~$ sonic-clear priority-group persistent-watermark headroom + + admin@sonic:~$ sonic-clear priority-group drop counters + ``` + +#### Buffer Pool + +This sub-section explains the following buffer pool parameters that can be displayed using "show buffer_pool" command. +1) buffer pool watermark +2) buffer pool persistent-watermark + +**show buffer_pool watermark** + +This command displays the user watermark for all the buffer pools + +- Usage: + ``` + show buffer_pool watermark + ``` + +- Example: + ``` + admin@sonic:~$ show buffer_pool watermark + Shared pool maximum occupancy: + Pool Bytes + --------------------- ------- + ingress_lossless_pool 0 + lossy_pool 2464 + ``` + + +**show buffer_pool persistent-watermark** + +This command displays the user persistent-watermark for all the buffer pools + +- Usage: + ``` + show buffer_pool persistent-watermark + ``` + +- Example: + ``` + admin@sonic:~$ show buffer_pool persistent-watermark + Shared pool maximum occupancy: + Pool Bytes + --------------------- ------- + ingress_lossless_pool 0 + lossy_pool 2464 + ``` + + + +### QoS config commands + +**config qos clear** + +This command is used to clear all the QoS configuration from all the following QOS Tables in ConfigDB. + +1) TC_TO_PRIORITY_GROUP_MAP, +2) MAP_PFC_PRIORITY_TO_QUEUE, +3) TC_TO_QUEUE_MAP, +4) DSCP_TO_TC_MAP, +5) MPLS_TC_TO_TC_MAP, +6) SCHEDULER, +7) PFC_PRIORITY_TO_PRIORITY_GROUP_MAP, +8) PORT_QOS_MAP, +9) WRED_PROFILE, +10) QUEUE, +11) CABLE_LENGTH, +12) BUFFER_POOL, +13) BUFFER_PROFILE, +14) BUFFER_PG, +15) BUFFER_QUEUE + +- Usage: + ``` + config qos clear + ``` + +- Example: + ``` + admin@sonic:~$ sudo config qos clear + ``` + +**config qos reload** + +This command is used to reload the QoS configuration. +QoS configuration has got two sets of configurations. +1) Generic QOS Configuration - This gives complete list of all possible QOS configuration. Its given in the file /usr/share/sonic/templates/qos_config.j2 in the device. + Reference: https://github.com/Azure/sonic-buildimage/blob/master/files/build_templates/qos_config.j2 + Users have flexibility to have platform specific qos configuration by placing the qos_config.j2 file at /usr/share/sonic/device///. + If users want to modify any of this loaded QOS configuration, they can modify this file in the device and then issue the "config qos reload" command. + +2) Platform specific buffer configuration. Every platform has got platform specific and topology specific (T0 or T1 or T2) buffer configuration at /usr/share/sonic/device///buffers_defaults_tx.j2 + In addition to platform specific configuration file, a generic configuration file is also present at /usr/share/sonic/templates/buffers_config.j2. + Reference: https://github.com/Azure/sonic-buildimage/blob/master/files/build_templates/buffers_config.j2 + Users can either modify the platform specific configuration file, or the generic configuration file and then issue this "config qos reload" command. + +These configuration files are already loaded in the device as part of the reboot process. In case if users wants to modify any of these configurations, they need to modify the appropriate QOS tables and fields in these files and then use this reload command. +This command uses those modified buffers.json.j2 file & qos.json.j2 file and reloads the new QOS configuration. +If users have not made any changes in these configuration files, this command need not be executed. + +Some of the example QOS configurations that users can modify are given below. +1) TC_TO_PRIORITY_GROUP_MAP +2) MAP_PFC_PRIORITY_TO_QUEUE +3) TC_TO_QUEUE_MAP +4) DSCP_TO_TC_MAP +5) MPLS_TC_TO_TC_MAP +6) SCHEDULER +7) PFC_PRIORITY_TO_PRIORITY_GROUP_MAP +8) PORT_QOS_MAP +9) WRED_PROFILE +10) CABLE_LENGTH +11) BUFFER_QUEUE + +- Usage: + ``` + config qos reload + ``` + +- Example: + ``` + admin@sonic:~$ sudo config qos reload + Running command: /usr/local/bin/sonic-cfggen -d -t /usr/share/sonic/device/x86_64-dell_z9100_c2538-r0/Force10-Z9100-C32/buffers.json.j2 >/tmp/buffers.json + Running command: /usr/local/bin/sonic-cfggen -d -t /usr/share/sonic/device/x86_64-dell_z9100_c2538-r0/Force10-Z9100-C32/qos.json.j2 -y /etc/sonic/sonic_version.yml >/tmp/qos.json + Running command: /usr/local/bin/sonic-cfggen -j /tmp/buffers.json --write-to-db + Running command: /usr/local/bin/sonic-cfggen -j /tmp/qos.json --write-to-db + + In this example, it uses the buffers.json.j2 file and qos.json.j2 file from platform specific folders. + When there are no changes in the platform specific configutation files, they internally use the file "/usr/share/sonic/templates/buffers_config.j2" and "/usr/share/sonic/templates/qos_config.j2" to generate the configuration. + ``` + +**config qos reload --ports port_list** + +This command is used to reload the default QoS configuration on a group of ports. +Typically, the default QoS configuration is in the following tables. +1) PORT_QOS_MAP +2) QUEUE +3) BUFFER_PG +4) BUFFER_QUEUE +5) BUFFER_PORT_INGRESS_PROFILE_LIST +6) BUFFER_PORT_EGRESS_PROFILE_LIST +7) CABLE_LENGTH + +If there was QoS configuration in the above tables for the ports: + + - if `--force` option is provied, the existing QoS configuration will be replaced by the default QoS configuration, + - otherwise, the command will exit with nothing updated. + +- Usage: + ``` + config qos reload --ports [,port] + ``` + +- Example: + ``` + admin@sonic:~$ sudo config qos reload --ports Ethernet0,Ethernet4 + + In this example, it updates the QoS configuration on port Ethernet0 and Ethernet4 to default. + If there was QoS configuration on the ports, the command will clear the existing QoS configuration on the port and reload to default. + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#qos) + +## sFlow + +### sFlow Show commands + +**show sflow** + +This command displays the global sFlow configuration that includes the admin state, collectors, the Agent ID and counter polling interval. + +- Usage: + ``` + show sflow + ``` + +- Example: + ``` + admin@sonic:~# show sflow + sFlow Global Information: + sFlow Admin State: up + sFlow Polling Interval: default + sFlow AgentID: lo + + 2 Collectors configured: + Name: collector_A IP addr: 10.11.46.2 UDP port: 6343 + Name: collector_lo IP addr: 127.0.0.1 UDP port: 6343 + ``` + + +**show sflow interface** + +This command displays the per-interface sflow admin status and the sampling rate. + +- Usage: + ``` + show sflow interface + ``` + +- Example: + ``` + admin@sonic:~# show sflow interface + + sFlow interface configurations + +-------------+---------------+-----------------+ + | Interface | Admin State | Sampling Rate | + +=============+===============+=================+ + | Ethernet0 | up | 4000 | + +-------------+---------------+-----------------+ + | Ethernet1 | up | 4000 | + +-------------+---------------+-----------------+ + ... + +-------------+---------------+-----------------+ + | Ethernet61 | up | 4000 | + +-------------+---------------+-----------------+ + | Ethernet62 | up | 4000 | + +-------------+---------------+-----------------+ + | Ethernet63 | up | 4000 | + +-------------+---------------+-----------------+ + + ``` + +### sFlow Config commands + +**config sflow collector add** + +This command is used to add a sFlow collector. Note that a maximum of 2 collectors is allowed. + +- Usage: + ``` + config sflow collector add [port ] + ``` + + - Parameters: + - collector-name: unique name of the sFlow collector + - ipv4-address : IP address of the collector in dotted decimal format for IPv4 + - ipv6-address : x: x: x: x::x format for IPv6 address of the collector (where :: notation specifies successive hexadecimal fields of zeros) + - port (OPTIONAL): specifies the UDP port of the collector (the range is from 0 to 65535. The default is 6343.) + +- Example: + ``` + admin@sonic:~# sudo config sflow collector add collector_A 10.11.46.2 + ``` + +**config sflow collector del** + +This command is used to delete a sFlow collector with the given name. + +- Usage: + ``` + config sflow collector del + ``` + + - Parameters: + - collector-name: unique name of the sFlow collector + +- Example: + ``` + admin@sonic:~# sudo config sflow collector del collector_A + ``` + +**config sflow agent-id** + +This command is used to add/delete the sFlow agent-id. This setting is global (applicable to both collectors) and optional. Only a single agent-id is allowed. If agent-id is not specified (with this CLI), an appropriate IP that belongs to the switch is used as the agent-id based on some simple heuristics. + +- Usage: + ``` + config sflow agent-id + ``` + + - Parameters: + - interface-name: specify the interface name whose ipv4 or ipv6 address will be used as the agent-id in sFlow datagrams. + +- Example: + ``` + admin@sonic:~# sudo config sflow agent-id add lo + ``` + +**config sflow** + +Globally, sFlow is disabled by default. When sFlow is enabled globally, the sflow deamon is started and sampling will start on all interfaces which have sFlow enabled at the interface level (see “config sflow interface…”). When sflow is disabled globally, sampling is stopped on all relevant interfaces and sflow daemon is stopped. + +- Usage: + ``` + config sflow + ``` +- Example: + ``` + admin@sonic:~# sudo config sflow enable + ``` +**config sflow interface** + +Enable/disable sflow at an interface level. By default, sflow is enabled on all interfaces at the interface level. Use this command to explicitly disable sFlow for a specific interface. An interface is sampled if sflow is enabled globally as well as at the interface level. Note that this configuration deals only with sFlow flow samples and not counter samples. + +- Usage: + ``` + config sflow interface + ``` + + - Parameters: + - interface-name: specify the interface for which sFlow flow samples have to be enabled/disabled. The “all” keyword is used as a convenience to enable/disable sflow at the interface level for all the interfaces. + +- Example: + ``` + admin@sonic:~# sudo config sflow interface disable Ethernet40 + ``` + +**config sflow interface sample-rate** + +Configure the sample-rate for a specific interface. + +The default sample rate for any interface is (ifSpeed / 1e6) where ifSpeed is in bits/sec. So, the default sample rate based on interface speed is: + + 1-in-1000 for a 1G link + 1-in-10,000 for a 10G link + 1-in-40,000 for a 40G link + 1-in-50,000 for a 50G link + 1-in-100,000 for a 100G link + +It is recommended not to change the defaults. This CLI is to be used only in case of exceptions (e.g., to set the sample-rate to the nearest power-of-2 if there are hardware restrictions in using the defaults) + +- Usage: + ``` + config sflow interface sample-rate + ``` + + - Parameters: + - interface-name: specify the interface for which the sampling rate value is to be set + - value: value is the average number of packets skipped before the sample is taken. "The sampling rate specifies random sampling probability as the ratio of packets observed to samples generated. For example a sampling rate of 256 specifies that, on average, 1 sample will be generated for every 256 packets observed." Valid range 256:8388608. + +- Example: + ``` + admin@sonic:~# sudo config sflow interface sample-rate Ethernet32 1000 + ``` +**config sflow polling-interval** + +This command is used to set the counter polling interval. Default is 20 seconds. + +- Usage: + ``` + config sflow polling-interval + ``` + + - Parameters: + - value: 0-300 seconds. Set polling-interval to 0 to disable counter polling + +- Example: + ``` + admin@sonic:~# sudo config sflow polling-interval 30 + ``` + + +Go Back To [Beginning of the document](#) or [Beginning of this section](#sflow) + +## SNMP + +### SNMP Show commands + +**show runningconfiguration snmp** + +This command displays the global SNMP configuration that includes the location, contact, community, and user settings. + +- Usage: + ``` + show runningconfiguration snmp + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration snmp + Location + ------------ + Emerald City + + + SNMP_CONTACT SNMP_CONTACT_EMAIL + -------------- -------------------- + joe joe@contoso.com + + + Community String Community Type + ------------------ ---------------- + Jack RW + + + User Permission Type Type Auth Type Auth Password Encryption Type Encryption Password + ------ ----------------- ------ ----------- --------------- ----------------- --------------------- + Travis RO Priv SHA TravisAuthPass AES TravisEncryptPass + ``` + +**show runningconfiguration snmp location** + +This command displays the SNMP location setting. + +- Usage: + ``` + show runningconfiguration snmp location + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration snmp location + Location + ------------ + Emerald City + ``` + +- Usage: + ``` + show runningconfiguration snmp location --json + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration snmp location --json + {'Location': 'Emerald City'} + ``` + +**show runningconfiguration snmp contact** + +This command displays the SNMP contact setting. + +- Usage: + ``` + show runningconfiguration snmp contact + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration snmp contact + Contact Contact Email + --------- --------------- + joe joe@contoso.com + ``` + +- Usage: + ``` + show runningconfiguration snmp contact --json + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration snmp contact --json + {'joe': 'joe@contoso.com'} + ``` + +**show runningconfiguration snmp community** + +This command display the SNMP community settings. + +- Usage: + ``` + show runningconfiguration snmp community + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration snmp community + Community String Community Type + ------------------ ---------------- + Jack RW + ``` + +- Usage: + ``` + show runningconfiguration snmp community --json + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration snmp community --json + {'Jack': {'TYPE': 'RW'}} + ``` + +**show runningconfiguration snmp user** + +This command display the SNMP user settings. + +- Usage: + ``` + show runningconfiguration snmp user + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration snmp user + User Permission Type Type Auth Type Auth Password Encryption Type Encryption Password + ------ ----------------- ------ ----------- --------------- ----------------- --------------------- + Travis RO Priv SHA TravisAuthPass AES TravisEncryptPass + ``` + +- Usage: + ``` + show runningconfiguration snmp user --json + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration snmp user --json + {'Travis': {'SNMP_USER_TYPE': 'Priv', 'SNMP_USER_PERMISSION': 'RO', 'SNMP_USER_AUTH_TYPE': 'SHA', 'SNMP_USER_AUTH_PASSWORD': 'TravisAuthPass', 'SNMP_USER_ENCRYPTION_TYPE': 'AES', 'SNMP_USER_ENCRYPTION_PASSWORD': 'TravisEncryptPass'}} + ``` + + +### SNMP Config commands + +This sub-section explains how to configure SNMP. + +**config snmp location add/del/modify** + +This command is used to add, delete, or modify the SNMP location. + +- Usage: + ``` + config snmp location (add | del | modify) + ``` + +- Example (Add new SNMP location "Emerald City" if it does not already exist): + ``` + admin@sonic:~$ sudo config snmp location add Emerald City + SNMP Location Emerald City has been added to configuration + Restarting SNMP service... + ``` + +- Example (Delete SNMP location "Emerald City" if it already exists): + ``` + admin@sonic:~$ sudo config snmp location del Emerald City + SNMP Location Emerald City removed from configuration + Restarting SNMP service... + ``` + +- Example (Modify SNMP location "Emerald City" to "Redmond"): + ``` + admin@sonic:~$ sudo config snmp location modify Redmond + SNMP location Redmond modified in configuration + Restarting SNMP service... + ``` + +**config snmp contact add/del/modify** + +This command is used to add, delete, or modify the SNMP contact. + +- Usage: + ``` + config snmp contact add + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmp contact add joe joe@contoso.com + Contact name joe and contact email joe@contoso.com have been added to configuration + Restarting SNMP service... + ``` + +- Usage: + ``` + config snmp contact del + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmp contact del joe + SNMP contact joe removed from configuration + Restarting SNMP service... + ``` + +- Usage: + ``` + config snmp contact modify + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmp contact modify test test@contoso.com + SNMP contact test and contact email test@contoso.com updated + Restarting SNMP service... + ``` + +**config snmp community add/del/replace** + +This command is used to add, delete, or replace the SNMP community. + +- Usage: + ``` + config snmp community add (RO | RW) + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmp community add testcomm ro + SNMP community testcomm added to configuration + Restarting SNMP service... + ``` + +- Usage: + ``` + config snmp community del + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmp community del testcomm + SNMP community testcomm removed from configuration + Restarting SNMP service... + ``` + +- Usage: + ``` + config snmp community replace + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmp community replace testcomm newtestcomm + SNMP community newtestcomm added to configuration + SNMP community newtestcomm replace community testcomm + Restarting SNMP service... + ``` + +**config snmp user add/del** + +This command is used to add or delete the SNMP user for SNMPv3. + +- Usage: + ``` + config snmp user add (noAuthNoPriv | AuthNoPriv | Priv) (RO | RW) [[(MD5 | SHA | MMAC-SHA-2) ] [(DES |AES) ]] + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmp user add testuser1 noauthnopriv ro + SNMP user testuser1 added to configuration + Restarting SNMP service... + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmp user add testuser2 authnopriv ro sha testuser2_auth_pass + SNMP user testuser2 added to configuration + Restarting SNMP service... + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmp user add testuser3 priv rw md5 testuser3_auth_pass aes testuser3_encrypt_pass + SNMP user testuser3 added to configuration + Restarting SNMP service... + ``` + +- Usage: + ``` + config snmp user del + ``` + +- Example: + ``` + admin@sonic:~$ sudo config snmp user del testuser1 + SNMP user testuser1 removed from configuration + Restarting SNMP service... + ``` + +## Startup & Running Configuration + +### Startup Configuration + +**show startupconfiguration bgp** + +This command is used to display the startup configuration for the BGP module. + +- Usage: + ``` + show startupconfiguration bgp + ``` + +- Example: + ``` + admin@sonic:~$ show startupconfiguration bgp + Routing-Stack is: quagga + ! + ! =========== Managed by sonic-cfggen DO NOT edit manually! ==================== + ! generated by templates/quagga/bgpd.conf.j2 with config DB data + ! file: bgpd.conf + ! + ! + hostname T1-2 + password zebra + log syslog informational + log facility local4 + ! enable password ! + ! + ! bgp multiple-instance + ! + route-map FROM_BGP_SPEAKER_V4 permit 10 + ! + route-map TO_BGP_SPEAKER_V4 deny 10 + ! + router bgp 65000 + bgp log-neighbor-changes + bgp bestpath as-path multipath-relax + no bgp default ipv4-unicast + bgp graceful-restart restart-time 180 + + + ``` + +### Running Configuration +This sub-section explains the show commands for displaying the running configuration for the following modules. +1) bgp +2) interfaces +3) ntp +4) snmp +5) all +6) acl +7) ports +8) syslog + +**show runningconfiguration all** + +This command displays the entire running configuration. + +- Usage: + ``` + show runningconfiguration all + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration all + ``` + +**show runningconfiguration bgp** + +This command displays the running configuration of the BGP module. + +- Usage: + ``` + show runningconfiguration bgp + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration bgp + ``` + +**show runningconfiguration interfaces** + +This command displays the running configuration for the "interfaces". + +- Usage: + ``` + show runningconfiguration interfaces + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration interfaces + ``` + +**show runningconfiguration ntp** + +This command displays the running configuration of the ntp module. + +- Usage: + ``` + show runningconfiguration ntp + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration ntp + NTP Servers + ------------- + 1.1.1.1 + 2.2.2.2 + ``` + +**show runningconfiguration syslog** + +This command displays the running configuration of the syslog module. + +- Usage: + ``` + show runningconfiguration syslog + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration syslog + Syslog Servers + ---------------- + 4.4.4.4 + 5.5.5.5 + ``` + + +**show runningconfiguration snmp** + +This command displays the running configuration of the snmp module. + +- Usage: + ``` + show runningconfiguration snmp + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration snmp + ``` + +**show runningconfiguration acl** + + This command displays the running configuration of the acls + +- Usage: + ``` + show runningconfiguration acl + ``` + +- Example: + ``` + admin@sonic:~$ show runningconfiguration acl + ``` + + **show runningconfiguration ports** + + This command displays the running configuration of the ports + +- Usage: + ``` + show runningconfiguration ports [] + ``` + +- Examples: + ``` + admin@sonic:~$ show runningconfiguration ports + ``` + + ``` + admin@sonic:~$ show runningconfiguration ports Ethernet0 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#Startup--Running-Configuration) + + +## Static routing + +### Static routing Config Commands + +This sub-section explains of commands is used to add or remove the static route. + +**config route add** + +This command is used to add a static route. Note that prefix /nexthop vrf`s and interface name are optional. + +- Usage: + + ``` + config route add prefix [vrf ] nexthop [vrf ] dev + ``` + +- Example: + + ``` + admin@sonic:~$ config route add prefix 2.2.3.4/32 nexthop 30.0.0.9 + admin@sonic:~$ config route add prefix 4.0.0.0/24 nexthop dev Ethernet32.10 + ``` + +It also supports ECMP, and adding a new nexthop to the existing prefix will complement it and not overwrite them. + +- Example: + + ``` + admin@sonic:~$ sudo config route add prefix 2.2.3.4/32 nexthop vrf Vrf-RED 30.0.0.9 + admin@sonic:~$ sudo config route add prefix 2.2.3.4/32 nexthop vrf Vrf-BLUE 30.0.0.10 + ``` + +**config route del** + +This command is used to remove a static route. Note that prefix /nexthop vrf`s and interface name are optional. + +- Usage: + + ``` + config route del prefix [vrf ] nexthop [vrf ] dev + ``` + +- Example: + + ``` + admin@sonic:~$ sudo config route del prefix 2.2.3.4/32 nexthop vrf Vrf-RED 30.0.0.9 + admin@sonic:~$ sudo config route del prefix 2.2.3.4/32 nexthop vrf Vrf-BLUE 30.0.0.10 + ``` + +This sub-section explains of command is used to show current routes. + +**show ip route** + +- Usage: + + ``` + show ip route + ``` + +- Example: + + ``` + admin@sonic:~$ show ip route + Codes: K - kernel route, C - connected, S - static, R - RIP, + O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, + T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, + F - PBR, f - OpenFabric, + > - selected route, * - FIB route, q - queued, r - rejected, b - backup + + S>* 0.0.0.0/0 [200/0] via 192.168.111.3, eth0, weight 1, 3d03h58m + S> 1.2.3.4/32 [1/0] via 30.0.0.7, weight 1, 00:00:06 + C>* 10.0.0.18/31 is directly connected, Ethernet36, 3d03h57m + C>* 10.0.0.20/31 is directly connected, Ethernet40, 3d03h57m + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#static-routing) + +## Subinterfaces + +### Subinterfaces Show Commands + +**show subinterfaces status** + +This command displays all the subinterfaces that are configured on the device and its current status. + +- Usage: +``` +show subinterfaces status +``` + +- Example: +``` +admin@sonic:~$ show subinterfaces status +Sub port interface Speed MTU Vlan Admin Type +------------------ ------- ----- ------ ------- ------------------- + Eth64.10 100G 9100 100 up dot1q-encapsulation + Ethernet0.100 100G 9100 100 up dot1q-encapsulation +``` + +### Subinterfaces Config Commands + +This sub-section explains how to configure subinterfaces. + +**config subinterface** + +- Usage: +``` +config subinterface (add | del) [vlan <1-4094>] +``` + +- Example (Create the subinterfces with name "Ethernet0.100"): +``` +admin@sonic:~$ sudo config subinterface add Ethernet0.100 +``` + +- Example (Create the subinterfces with name "Eth64.100"): +``` +admin@sonic:~$ sudo config subinterface add Eth64.100 100 +``` + +- Example (Delete the subinterfces with name "Ethernet0.100"): +``` +admin@sonic:~$ sudo config subinterface del Ethernet0.100 +``` + +- Example (Delete the subinterfces with name "Eth64.100"): +``` +admin@sonic:~$ sudo config subinterface del Eth64.100 100 +``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#static-routing) + +## Syslog + +### Syslog Config Commands + +This sub-section of commands is used to add or remove the configured syslog servers. + +**config syslog add** + +This command is used to add a SYSLOG server to the syslog server list. Note that more that one syslog server can be added in the device. + +- Usage: + ``` + config syslog add + ``` + +- Example: + ``` + admin@sonic:~$ sudo config syslog add 1.1.1.1 + Syslog server 1.1.1.1 added to configuration + Restarting rsyslog-config service... + ``` + +**config syslog delete** + +This command is used to delete the syslog server configured. + +- Usage: + ``` + config syslog del + ``` + +- Example: + ``` + admin@sonic:~$ sudo config syslog del 1.1.1.1 + Syslog server 1.1.1.1 removed from configuration + Restarting rsyslog-config service... + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#syslog) + +## System State + +### Processes + +This command is used to determine the CPU utilization. It also lists the active processes along with their corresponding process ID and other relevant parameters. + +This sub-section explains the various "processes" specific data that includes the following. +1) cpu Show processes CPU info +2) memory Show processes memory info +3) summary Show processes info + +“show processes” commands provide a wrapper over linux’s “top” command. “show process cpu” sorts the processes being displayed by cpu-utilization, whereas “show process memory” does it attending to processes’ memory-utilization. + +**show processes cpu** + +This command displays the current CPU usage by process. This command uses linux's "top -bn 1 -o %CPU" command to display the output. + +- Usage: + ``` + show processes cpu + ``` + +*TIP: Users can pipe the output to "head" to display only the "n" number of lines (e.g., `show processes cpu | head -n 10`)* + +- Example: + ``` + admin@sonic:~$ show processes cpu + top - 23:50:08 up 1:18, 1 user, load average: 0.25, 0.29, 0.25 + Tasks: 161 total, 1 running, 160 sleeping, 0 stopped, 0 zombie + %Cpu(s): 3.8 us, 1.0 sy, 0.0 ni, 95.1 id, 0.1 wa, 0.0 hi, 0.0 si, 0.0 st + KiB Mem: 8181216 total, 1161060 used, 7020156 free, 105656 buffers + KiB Swap: 0 total, 0 used, 0 free. 557560 cached Mem + + PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND + 2047 root 20 0 683772 109288 39652 S 23.8 1.3 7:44.79 syncd + 1351 root 20 0 43360 5616 2844 S 11.9 0.1 1:41.56 redis-server + 10093 root 20 0 21944 2476 2088 R 5.9 0.0 0:00.03 top + 1 root 20 0 28992 5508 3236 S 0.0 0.1 0:06.42 systemd + 2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd + 3 root 20 0 0 0 0 S 0.0 0.0 0:00.56 ksoftirqd/0 + 5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H + ... + ``` + +*TIP: Advanced users can view individual processes using variations of the `ps` command (e.g., `ps -ax | grep `)* + +**show processes memory** + +This command displays the current memory usage by processes. This command uses linux's "top -bn 1 -o %MEM" command to display the output. + +- Usage: + ``` + show processes memory + ``` + +*NOTE that pipe option can be used using " | head -n" to display only the "n" number of lines* + +- Example: + ``` + admin@sonic:~$ show processes memory + top - 23:41:24 up 7 days, 39 min, 2 users, load average: 1.21, 1.19, 1.18 + Tasks: 191 total, 2 running, 189 sleeping, 0 stopped, 0 zombie + %Cpu(s): 2.8 us, 20.7 sy, 0.0 ni, 76.3 id, 0.0 wa, 0.0 hi, 0.2 si, 0.0 st + KiB Mem : 8162264 total, 5720412 free, 945516 used, 1496336 buff/cache + KiB Swap: 0 total, 0 free, 0 used. 6855632 avail Mem + + PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND + 18051 root 20 0 851540 274784 8344 S 0.0 3.4 0:02.77 syncd + 17760 root 20 0 1293428 259212 58732 S 5.9 3.2 96:46.22 syncd + 508 root 20 0 725364 76244 38220 S 0.0 0.9 4:54.49 dockerd + 30853 root 20 0 96348 56824 7880 S 0.0 0.7 0:00.98 show + 17266 root 20 0 509876 49772 30640 S 0.0 0.6 0:06.36 docker + 24891 admin 20 0 515864 49560 30644 S 0.0 0.6 0:05.54 docker + 17643 admin 20 0 575668 49428 30628 S 0.0 0.6 0:06.29 docker + 23885 admin 20 0 369552 49344 30840 S 0.0 0.6 0:05.57 docker + 18055 root 20 0 509076 49260 30296 S 0.0 0.6 0:06.36 docker + 17268 root 20 0 371120 49052 30372 S 0.0 0.6 0:06.45 docker + 1227 root 20 0 443284 48640 30100 S 0.0 0.6 0:41.91 docker + 23785 admin 20 0 443796 48552 30128 S 0.0 0.6 0:05.58 docker + 17820 admin 20 0 435088 48144 29480 S 0.0 0.6 0:06.33 docker + 506 root 20 0 1151040 43140 23964 S 0.0 0.5 8:51.08 containerd + 18437 root 20 0 84852 26388 7380 S 0.0 0.3 65:59.76 python3.6 + ``` + + +**show processes summary** + +This command displays the current summary information about all the processes + +- Usage: + ``` + show processes summary + ``` + +- Example: + ``` + admin@sonic:~$ show processes summary + PID PPID CMD %MEM %CPU + 1 0 /sbin/init 0.0 0.0 + 2 0 [kthreadd] 0.0 0.0 + 3 2 [ksoftirqd/0] 0.0 0.0 + 5 2 [kworker/0:0H] 0.0 0.0 + ... + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#System-State) + +### Services & Memory + +These commands are used to know the services that are running and the memory that is utilized currently. + + +**show services** + +This command displays the state of all the SONiC processes running inside a docker container. This helps to identify the status of SONiC’s critical processes. + +- Usage: + ``` + show services + ``` + +- Example: + ``` + admin@sonic:~$ show services + dhcp_relay docker + --------------------------- + UID PID PPID C STIME TTY TIME CMD + root 1 0 0 05:26 ? 00:00:12 /usr/bin/python /usr/bin/supervi + root 24 1 0 05:26 ? 00:00:00 /usr/sbin/rsyslogd -n + + nat docker + --------------------------- + USER PID PPID C STIME TTY TIME CMD + root 1 0 0 05:26 ? 00:00:12 /usr/bin/python /usr/bin/supervisord + root 18 1 0 05:26 ? 00:00:00 /usr/sbin/rsyslogd -n + root 23 1 0 05:26 ? 00:00:01 /usr/bin/natmgrd + root 34 1 0 05:26 ? 00:00:00 /usr/bin/natsyncd + + snmp docker + --------------------------- + UID PID PPID C STIME TTY TIME CMD + root 1 0 0 05:26 ? 00:00:16 /usr/bin/python /usr/bin/supervi + root 24 1 0 05:26 ? 00:00:02 /usr/sbin/rsyslogd -n + Debian-+ 29 1 0 05:26 ? 00:00:04 /usr/sbin/snmpd -f -LS4d -u Debi + root 31 1 1 05:26 ? 00:15:10 python3.6 -m sonic_ax_impl + + syncd docker + --------------------------- + UID PID PPID C STIME TTY TIME CMD + root 1 0 0 05:26 ? 00:00:13 /usr/bin/python /usr/bin/supervi + root 12 1 0 05:26 ? 00:00:00 /usr/sbin/rsyslogd -n + root 17 1 0 05:26 ? 00:00:00 /usr/bin/dsserve /usr/bin/syncd + root 27 17 22 05:26 ? 04:09:30 /usr/bin/syncd --diag -p /usr/sh + root 51 27 0 05:26 ? 00:00:01 /usr/bin/syncd --diag -p /usr/sh + + swss docker + --------------------------- + UID PID PPID C STIME TTY TIME CMD + root 1 0 0 05:26 ? 00:00:29 /usr/bin/python /usr/bin/supervi + root 25 1 0 05:26 ? 00:00:00 /usr/sbin/rsyslogd -n + root 30 1 0 05:26 ? 00:00:13 /usr/bin/orchagent -d /var/log/s + root 42 1 1 05:26 ? 00:12:40 /usr/bin/portsyncd -p /usr/share + root 45 1 0 05:26 ? 00:00:00 /usr/bin/intfsyncd + root 48 1 0 05:26 ? 00:00:03 /usr/bin/neighsyncd + root 59 1 0 05:26 ? 00:00:01 /usr/bin/vlanmgrd + root 92 1 0 05:26 ? 00:00:01 /usr/bin/intfmgrd + root 3606 1 0 23:36 ? 00:00:00 bash -c /usr/bin/arp_update; sle + root 3621 3606 0 23:36 ? 00:00:00 sleep 300 + + ... + ``` + +**show system-memory** + +This command displays the system-wide memory utilization information – just a wrapper over linux native “free” command + +- Usage: + ``` + show system-memory + ``` + +- Example: + ``` + admin@sonic:~$ show system-memory + Command: free -m -h + total used free shared buffers cached + Mem: 3.9G 2.0G 1.8G 33M 324M 791M + -/+ buffers/cache: 951M 2.9G + Swap: 0B 0B 0B + ``` + +**show mmu** + +This command displays virtual address to the physical address translation status of the Memory Management Unit (MMU). + +- Usage: + ``` + show mmu + ``` + +- Example: + ``` + admin@sonic:~$ show mmu + Pool: ingress_lossless_pool + ---- -------- + xoff 4194112 + type ingress + mode dynamic + size 10875072 + ---- -------- + + Pool: egress_lossless_pool + ---- -------- + type egress + mode static + size 15982720 + ---- -------- + + Pool: egress_lossy_pool + ---- ------- + type egress + mode dynamic + size 9243812 + ---- ------- + + Profile: egress_lossy_profile + ---------- ------------------------------- + dynamic_th 3 + pool [BUFFER_POOL|egress_lossy_pool] + size 1518 + ---------- ------------------------------- + + Profile: pg_lossless_100000_300m_profile + ---------- ----------------------------------- + xon_offset 2288 + dynamic_th -3 + xon 2288 + xoff 268736 + pool [BUFFER_POOL|ingress_lossless_pool] + size 1248 + ---------- ----------------------------------- + + Profile: egress_lossless_profile + --------- ---------------------------------- + static_th 3995680 + pool [BUFFER_POOL|egress_lossless_pool] + size 1518 + --------- ---------------------------------- + + Profile: pg_lossless_100000_40m_profile + ---------- ----------------------------------- + xon_offset 2288 + dynamic_th -3 + xon 2288 + xoff 177632 + pool [BUFFER_POOL|ingress_lossless_pool] + size 1248 + ---------- ----------------------------------- + + Profile: ingress_lossy_profile + ---------- ----------------------------------- + dynamic_th 3 + pool [BUFFER_POOL|ingress_lossless_pool] + size 0 + ---------- ----------------------------------- + + Profile: pg_lossless_40000_40m_profile + ---------- ----------------------------------- + xon_offset 2288 + dynamic_th -3 + xon 2288 + xoff 71552 + pool [BUFFER_POOL|ingress_lossless_pool] + size 1248 + ---------- ----------------------------------- + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#System-State) + +Go Back To [Beginning of the document](#) or [Beginning of this section](#System-Health) + +### System-Health + +These commands are used to monitor the system current running services and hardware state. + +**show system-health summary** + +This command displays the current status of 'Services' and 'Hardware' under monitoring. +If any of the elements under each of these two sections is 'Not OK' a proper message will appear under the relevant section. + +- Usage: + ``` + show system-health summary + ``` + +- Example: + ``` + admin@sonic:~$ show system-health summary + System status summary + + System status LED red + Services: + Status: Not OK + Not Running: 'telemetry', 'sflowmgrd' + Hardware: + Status: OK + ``` + ``` + admin@sonic:~$ show system-health summary + System status summary + + System status LED green + Services: + Status: OK + Hardware: + Status: OK + ``` + +**show system-health monitor-list** + +This command displays a list of all current 'Services' and 'Hardware' being monitored, their status and type. + +- Usage: + ``` + show system-health monitor-list + ``` + +- Example: + ``` + admin@sonic:~$ show system-health monitor-list + System services and devices monitor list + + Name Status Type + -------------- -------- ---------- + telemetry Not OK Process + orchagent Not OK Process + neighsyncd OK Process + vrfmgrd OK Process + dialout_client OK Process + zebra OK Process + rsyslog OK Process + snmpd OK Process + redis_server OK Process + intfmgrd OK Process + vxlanmgrd OK Process + lldpd_monitor OK Process + portsyncd OK Process + var-log OK Filesystem + lldpmgrd OK Process + syncd OK Process + sonic OK System + buffermgrd OK Process + portmgrd OK Process + staticd OK Process + bgpd OK Process + lldp_syncd OK Process + bgpcfgd OK Process + snmp_subagent OK Process + root-overlay OK Filesystem + fpmsyncd OK Process + sflowmgrd OK Process + vlanmgrd OK Process + nbrmgrd OK Process + PSU 2 OK PSU + psu_1_fan_1 OK Fan + psu_2_fan_1 OK Fan + fan11 OK Fan + fan10 OK Fan + fan12 OK Fan + ASIC OK ASIC + fan1 OK Fan + PSU 1 OK PSU + fan3 OK Fan + fan2 OK Fan + fan5 OK Fan + fan4 OK Fan + fan7 OK Fan + fan6 OK Fan + fan9 OK Fan + fan8 OK Fan + ``` + +**show system-health detail** + +This command displays the current status of 'Services' and 'Hardware' under monitoring. +If any of the elements under each of these two sections is 'Not OK' a proper message will appear under the relevant section. +In addition, displays a list of all current 'Services' and 'Hardware' being monitored and a list of ignored elements. + +- Usage: + ``` + show system-health detail + ``` + +- Example: + ``` + admin@sonic:~$ show system-health detail + System status summary + + System status LED red + Services: + Status: Not OK + Not Running: 'telemetry', 'orchagent' + Hardware: + Status: OK + + System services and devices monitor list + + Name Status Type + -------------- -------- ---------- + telemetry Not OK Process + orchagent Not OK Process + neighsyncd OK Process + vrfmgrd OK Process + dialout_client OK Process + zebra OK Process + rsyslog OK Process + snmpd OK Process + redis_server OK Process + intfmgrd OK Process + vxlanmgrd OK Process + lldpd_monitor OK Process + portsyncd OK Process + var-log OK Filesystem + lldpmgrd OK Process + syncd OK Process + sonic OK System + buffermgrd OK Process + portmgrd OK Process + staticd OK Process + bgpd OK Process + lldp_syncd OK Process + bgpcfgd OK Process + snmp_subagent OK Process + root-overlay OK Filesystem + fpmsyncd OK Process + sflowmgrd OK Process + vlanmgrd OK Process + nbrmgrd OK Process + PSU 2 OK PSU + psu_1_fan_1 OK Fan + psu_2_fan_1 OK Fan + fan11 OK Fan + fan10 OK Fan + fan12 OK Fan + ASIC OK ASIC + fan1 OK Fan + PSU 1 OK PSU + fan3 OK Fan + fan2 OK Fan + fan5 OK Fan + fan4 OK Fan + fan7 OK Fan + fan6 OK Fan + fan9 OK Fan + fan8 OK Fan + + System services and devices ignore list + + Name Status Type + ----------- -------- ------ + psu.voltage Ignored Device + ``` +Go Back To [Beginning of the document](#) or [Beginning of this section](#System-Health) + +## VLAN & FDB + +### VLAN + +#### VLAN show commands + +**show vlan brief** + +This command displays brief information about all the vlans configured in the device. It displays the vlan ID, IP address (if configured for the vlan), list of vlan member ports, whether the port is tagged or in untagged mode, the DHCP Helper Address, and the proxy ARP status + +- Usage: + ``` + show vlan brief + ``` + +- Example: + ``` + admin@sonic:~$ show vlan brief + + +-----------+--------------+-----------+----------------+-----------------------+-------------+ + | VLAN ID | IP Address | Ports | Port Tagging | DHCP Helper Address | Proxy ARP | + +===========+==============+===========+================+=======================+=============+ + | 100 | 1.1.2.2/16 | Ethernet0 | tagged | 192.0.0.1 | disabled | + | | | Ethernet4 | tagged | 192.0.0.2 | | + | | | | | 192.0.0.3 | | + +-----------+--------------+-----------+----------------+-----------------------+-------------+ + ``` + +**show vlan config** + +This command displays all the vlan configuration. + +- Usage: + ``` + show vlan config + ``` + +- Example: + ``` + admin@sonic:~$ show vlan config + Name VID Member Mode + ------- ----- --------- ------ + Vlan100 100 Ethernet0 tagged + Vlan100 100 Ethernet4 tagged + ``` + + +#### VLAN Config commands + +This sub-section explains how to configure the vlan and its member ports. + +**config vlan add/del** + +This command is used to add or delete the vlan. + +- Usage: + ``` + config vlan (add | del) + ``` + +- Example (Create the VLAN "Vlan100" if it does not already exist): + ``` + admin@sonic:~$ sudo config vlan add 100 + ``` + +**config vlan member add/del** + +This command is to add or delete a member port into the already created vlan. + +- Usage: + ``` + config vlan member add/del [-u|--untagged] + ``` + +*NOTE: Adding the -u or --untagged flag will set the member in "untagged" mode* + + +- Example: + ``` + admin@sonic:~$ sudo config vlan member add 100 Ethernet0 + This command will add Ethernet0 as member of the vlan 100 + + admin@sonic:~$ sudo config vlan member add 100 Ethernet4 + This command will add Ethernet4 as member of the vlan 100. + ``` + +**config proxy_arp enabled/disabled** + +This command is used to enable or disable proxy ARP for a VLAN interface + +- Usage: + ``` + config vlan proxy_arp enabled/disabled + ``` + +- Example: + ``` + admin@sonic:~$ sudo config vlan proxy_arp 1000 enabled + This command will enable proxy ARP for the interface 'Vlan1000' + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#vlan--FDB) + +### FDB + +#### FDB show commands + +**show mac** + +This command displays the MAC (FDB) entries either in full or partial as given below. +1) show mac - displays the full table +2) show mac -v - displays the MACs learnt on the particular VLAN ID. +3) show mac -p - displays the MACs learnt on the particular port. +4) show mac -a - display the MACs that match a specific mac-address +5) show mac -t - display the MACs that match a specific type (static/dynamic) +6) show mac -c - display the count of MAC addresses + +To show the default MAC address aging time on the switch. + +- Usage: + ``` + show mac [-v ] [-p ] [-a ] [-t ] [-c] + ``` + +- Example: + ``` + admin@sonic:~$ show mac + No. Vlan MacAddress Port Type + ----- ------ ----------------- ----------- ------- + 1 1000 E2:8C:56:85:4A:CD Ethernet192 Dynamic + 2 1000 A0:1B:5E:47:C9:76 Ethernet192 Dynamic + 3 1000 AA:54:EF:2C:EE:30 Ethernet192 Dynamic + 4 1000 A4:3F:F2:17:A3:FC Ethernet192 Dynamic + 5 1000 0C:FC:01:72:29:91 Ethernet192 Dynamic + 6 1000 48:6D:01:7E:C9:FD Ethernet192 Dynamic + 7 1000 1C:6B:7E:34:5F:A6 Ethernet192 Dynamic + 8 1000 EE:81:D9:7B:93:A9 Ethernet192 Dynamic + 9 1000 CC:F8:8D:BB:85:E2 Ethernet192 Dynamic + 10 1000 0A:52:B3:9C:FB:6C Ethernet192 Dynamic + 11 1000 C6:E2:72:02:D1:23 Ethernet192 Dynamic + 12 1000 8A:C9:5C:25:E9:28 Ethernet192 Dynamic + 13 1000 5E:CD:34:E4:94:18 Ethernet192 Dynamic + 14 1000 7E:49:1F:B5:91:B5 Ethernet192 Dynamic + 15 1000 AE:DD:67:F3:09:5A Ethernet192 Dynamic + 16 1000 DC:2F:D1:08:4B:DE Ethernet192 Dynamic + 17 1000 50:96:23:AD:F1:65 Ethernet192 Static + 18 1000 C6:C9:5E:AE:24:42 Ethernet192 Static + Total number of entries 18 + ``` + +Optionally, you can specify a VLAN ID or interface name or type or mac-address in order to display only that particular entries + +- Examples: + ``` + admin@sonic:~$ show mac -v 1000 + No. Vlan MacAddress Port Type + ----- ------ ----------------- ----------- ------- + 1 1000 E2:8C:56:85:4A:CD Ethernet192 Dynamic + 2 1000 A0:1B:5E:47:C9:76 Ethernet192 Dynamic + 3 1000 AA:54:EF:2C:EE:30 Ethernet192 Dynamic + 4 1000 A4:3F:F2:17:A3:FC Ethernet192 Dynamic + 5 1000 0C:FC:01:72:29:91 Ethernet192 Dynamic + 6 1000 48:6D:01:7E:C9:FD Ethernet192 Dynamic + 7 1000 1C:6B:7E:34:5F:A6 Ethernet192 Dynamic + 8 1000 EE:81:D9:7B:93:A9 Ethernet192 Dynamic + 9 1000 CC:F8:8D:BB:85:E2 Ethernet192 Dynamic + 10 1000 0A:52:B3:9C:FB:6C Ethernet192 Dynamic + 11 1000 C6:E2:72:02:D1:23 Ethernet192 Dynamic + 12 1000 8A:C9:5C:25:E9:28 Ethernet192 Dynamic + 13 1000 5E:CD:34:E4:94:18 Ethernet192 Dynamic + 14 1000 7E:49:1F:B5:91:B5 Ethernet192 Dynamic + 15 1000 AE:DD:67:F3:09:5A Ethernet192 Dynamic + 16 1000 DC:2F:D1:08:4B:DE Ethernet192 Dynamic + 17 1000 50:96:23:AD:F1:65 Ethernet192 Static + 18 1000 C6:C9:5E:AE:24:42 Ethernet192 Static + Total number of entries 18 + ``` + ``` + admin@sonic:~$ show mac -p Ethernet192 + No. Vlan MacAddress Port Type + ----- ------ ----------------- ----------- ------- + 1 1000 E2:8C:56:85:4A:CD Ethernet192 Dynamic + 2 1000 A0:1B:5E:47:C9:76 Ethernet192 Dynamic + 3 1000 AA:54:EF:2C:EE:30 Ethernet192 Dynamic + 4 1000 A4:3F:F2:17:A3:FC Ethernet192 Dynamic + 5 1000 0C:FC:01:72:29:91 Ethernet192 Dynamic + 6 1000 48:6D:01:7E:C9:FD Ethernet192 Dynamic + 7 1000 1C:6B:7E:34:5F:A6 Ethernet192 Dynamic + 8 1000 EE:81:D9:7B:93:A9 Ethernet192 Dynamic + 9 1000 CC:F8:8D:BB:85:E2 Ethernet192 Dynamic + 10 1000 0A:52:B3:9C:FB:6C Ethernet192 Dynamic + 11 1000 C6:E2:72:02:D1:23 Ethernet192 Dynamic + 12 1000 8A:C9:5C:25:E9:28 Ethernet192 Dynamic + 13 1000 5E:CD:34:E4:94:18 Ethernet192 Dynamic + 14 1000 7E:49:1F:B5:91:B5 Ethernet192 Dynamic + 15 1000 AE:DD:67:F3:09:5A Ethernet192 Dynamic + 16 1000 DC:2F:D1:08:4B:DE Ethernet192 Dynamic + 17 1000 50:96:23:AD:F1:65 Ethernet192 Static + 18 1000 C6:C9:5E:AE:24:42 Ethernet192 Static + Total number of entries 18 + ``` + ``` + admin@sonic:~$ show mac -a E2:8C:56:85:4A:CD + No. Vlan MacAddress Port Type + ----- ------ ----------------- ----------- ------- + 1 1000 E2:8C:56:85:4A:CD Ethernet192 Dynamic + Total number of entries 1 + ``` + ``` + admin@sonic:~$ show mac -t Static + No. Vlan MacAddress Port Type + ----- ------ ----------------- ----------- ------- + 2 1000 50:96:23:AD:F1:65 Ethernet192 Static + 2 1000 C6:C9:5E:AE:24:42 Ethernet192 Static + Total number of entries 2 + ``` + ``` + admin@sonic:~$ show mac -c + Total number of entries 18 + ``` + +**show mac aging-time** + +This command displays the default mac aging time on the switch + + ``` + admin@sonic:~$ show mac aging-time + Aging time for switch is 600 seconds + ``` + +**sonic-clear fdb all** + +Clear the FDB table + +- Usage: + ``` + sonic-clear fdb all + ``` +- Example: + ``` + admin@sonic:~$ sonic-clear fdb all + FDB entries are cleared. + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#vlan--FDB) + +## VxLAN & Vnet + +### VxLAN + +#### VxLAN show commands + +**show vxlan tunnel** + +This command displays brief information about all the vxlans configured in the device. It displays the vxlan tunnel name, source IP address, destination IP address (if configured), tunnel map name and mapping. + +- Usage: + + ``` + show vxlan tunnel + ``` + +- Example: + + ``` + admin@sonic:~$ show vxlan tunnel + vxlan tunnel name source ip destination ip tunnel map name tunnel map mapping(vni -> vlan) + ------------------- ----------- ---------------- ----------------- --------------------------------- + tunnel1 10.10.10.10 + tunnel2 10.10.10.10 20.10.10.10 tmap1 1234 -> 100 + tunnel3 10.10.10.10 30.10.10.10 tmap2 1235 -> 200 + ``` + +**show vxlan name ** + +This command displays configuration. + +- Usage: + + ``` + show vxlan name + ``` + +- Example: + + ``` + admin@sonic:~$ show vxlan name tunnel3 + vxlan tunnel name source ip destination ip tunnel map name tunnel map mapping(vni -> vlan) + ------------------- ----------- ---------------- ----------------- --------------------------------- + tunnel3 10.10.10.10 30.10.10.10 tmap2 1235 -> 200 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#vxlan--vnet) + +### Vnet + +#### Vnet show commands + +**show vnet brief** + +This command displays brief information about all the vnets configured in the device. It displays the vnet name, vxlan tunnel name, vni and peer list (if configured). + +- Usage: + + ``` + show vnet brief + ``` + +- Example: + + ``` + admin@sonic:~$ show vnet brief + vnet name vxlan tunnel vni peer list + ----------- -------------- ----- ------------------ + Vnet_2000 tunnel1 2000 + Vnet_3000 tunnel1 3000 Vnet_2000,Vnet4000 + ``` + +**show vnet endpoint ** + +This command displays the list or vxlan tunnel endpoints and their status. In addition it also shows the number of prefixes associated with each endpoints in the tunnels. If an IP address of an endpoint is provided, this command also shows the associated prefixes a well. + +- Usage: + + ``` + show vnet endpoint + + ``` + +- Example: + + ``` + admin@sonic:~$ show vnet endpoint + Endpoint prefix count status + --------------------- -------------- -------- + fddd:a100:a251::a10:1 1 Down + fddd:a101:a251::a10:1 1 Up + 100.251.7.1 3 Up + + or + + admin@sonic:~$ show vnet endpoint fddd:a101:a251::a10:1 + Endpoint prefix status + --------------------- ---------------------------- -------- + fddd:a101:a251::a10:1 ['fddd:a150:a251::a6:1/128'] Up + + or + + admin@sonic:~$ show vnet endpoint 100.251.7.1 + Endpoint prefix status + ----------- --------------------------------------------------------- -------- + 100.251.7.1 ['160.62.191.1/32', '160.63.191.1/32', '160.64.191.1/32'] Up + ``` + +**show vnet name ** + +This command displays brief information about configured in the device. + +- Usage: + + ``` + show vnet name + ``` + +- Example: + + ``` + admin@sonic:~$ show vnet name Vnet_3000 + vnet name vxlan tunnel vni peer list + ----------- -------------- ----- ------------------ + Vnet_3000 tunnel1 3000 Vnet_2000,Vnet4000 + ``` + +**show vnet interfaces** + +This command displays vnet interfaces information about all the vnets configured in the device. + +- Usage: + + ``` + show vnet interfaces + ``` + +- Example: + + ``` + admin@sonic:~$ show vnet interfaces + vnet name interfaces + ----------- ------------ + Vnet_2000 Ethernet1 + Vnet_3000 Vlan2000 + ``` + +**show vnet neighbors** + +This command displays vnet neighbor information about all the vnets configured in the device. It displays the vnet name, neighbor IP address, neighbor mac address (if configured) and interface. + +- Usage: + + ``` + show vnet neighbors + ``` + +- Example: + + ``` + admin@sonic:~$ show vnet neighbors + Vnet_2000 neighbor mac_address interfaces + ----------- ----------- ------------- ------------ + 11.11.11.11 Ethernet1 + 11.11.11.12 Ethernet1 + + Vnet_3000 neighbor mac_address interfaces + ----------- ----------- ----------------- ------------ + 20.20.20.20 aa:bb:cc:dd:ee:ff Vlan2000 + ``` + +**show vnet routes all** + +This command displays all routes information about all the vnets configured in the device. It also shows the status of the routes which may or may not be active. + +- Usage: + + ``` + show vnet routes all + ``` + +- Example: + + ``` + admin@sonic:~$ show vnet routes all + vnet name prefix nexthop interface + ----------- -------------- --------- ----------- + Vnet_2000 100.100.3.0/24 Ethernet52 + Vnet_3000 100.100.4.0/24 Vlan2000 + + vnet name prefix endpoint mac address vni status + ----------- -------------- ---------- ----------------- ----- ------- + Vnet_2000 100.100.1.1/32 10.10.10.1 active + Vnet_3000 100.100.2.1/32 10.10.10.2 00:00:00:00:03:04 inactive + Vnet_3000 100.100.2.3/32 10.10.10.6 00:00:00:00:03:04 + ``` + +**show vnet routes tunnel** + +This command displays tunnel routes information about all the vnets configured in the device. + +- Usage: + + ``` + show vnet routes tunnel + ``` + +- Example: + + ``` + admin@sonic:~$ show vnet routes tunnel + vnet name prefix endpoint mac address vni + ----------- -------------- ---------- ----------------- ----- + Vnet_2000 100.100.1.1/32 10.10.10.1 + Vnet_3000 100.100.2.1/32 10.10.10.2 00:00:00:00:03:04 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#vxlan--vnet) + +## Warm Reboot + +warm-reboot command initiates a warm reboot of the device. + +warm-reboot command doesn't require setting warm restart configuration. The +command will setup everything needed to perform warm reboot. + +This command requires root privilege. + +- Usage: + ``` + warm-reboot [-h|-?|-v|-f|-r|-k|-x|-c |-s|-D] + ``` + +- Parameters: + ``` + -h,-? : get this help + -v : turn on verbose mode + -f : force execution + -r : reboot with /sbin/reboot + -k : reboot with /sbin/kexec -e [default] + -x : execute script with -x flag + -c : specify control plane assistant IP list + -s : strict mode: do not proceed without: + - control plane assistant IP list. + -D : detached mode - closing terminal will not cause stopping reboot + ``` + +- Example: + ``` + admin@sonic:~$ sudo warm-reboot -v + Tue Oct 22 23:20:53 UTC 2019 Pausing orchagent ... + Tue Oct 22 23:20:53 UTC 2019 Stopping radv ... + Tue Oct 22 23:20:54 UTC 2019 Stopping bgp ... + Tue Oct 22 23:20:54 UTC 2019 Stopped bgp ... + Tue Oct 22 23:20:57 UTC 2019 Initialize pre-shutdown ... + Tue Oct 22 23:20:58 UTC 2019 Requesting pre-shutdown ... + Tue Oct 22 23:20:58 UTC 2019 Waiting for pre-shutdown ... + Tue Oct 22 23:20:59 UTC 2019 Pre-shutdown succeeded ... + Tue Oct 22 23:20:59 UTC 2019 Backing up database ... + Tue Oct 22 23:21:00 UTC 2019 Stopping teamd ... + Tue Oct 22 23:21:00 UTC 2019 Stopped teamd ... + Tue Oct 22 23:21:00 UTC 2019 Stopping syncd ... + Tue Oct 22 23:21:11 UTC 2019 Stopped syncd ... + Tue Oct 22 23:21:11 UTC 2019 Stopping all remaining containers ... + Tue Oct 22 23:21:13 UTC 2019 Stopped all remaining containers ... + Tue Oct 22 23:21:15 UTC 2019 Rebooting with /sbin/kexec -e to SONiC-OS-20191021.01 ... + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#Warm-Reboot) + +## Warm Restart + +Besides device level warm reboot, SONiC also provides docker based warm restart. This feature is currently supported by following dockers: BGP, teamD, and SWSS. A user can manage to restart a particular docker, with no interruption on packet forwarding and no effect on other services. This helps to reduce operational costs as well as development efforts. For example, to fix a bug in BGP routing stack, only the BGP docker image needs to be built, tested and upgraded. + +To achieve uninterrupted packet forwarding during the restarting stage and database reconciliation at the post restarting stage, warm restart enabled dockers with adjacency state machine facilitate standardized protocols. For example, a BGP restarting switch must have BGP "Graceful Restart" enabled, and its BGP neighbors must be "Graceful Restart Helper Capable", as specified in [IETF RFC4724](https://tools.ietf.org/html/rfc4724). + +Before warm restart BGP docker, the following BGP commands should be enabled: + ``` + bgp graceful-restart + bgp graceful-restart preserve-fw-state + ``` +In current SONiC release, the above two commands are enabled by default. + +It should be aware that during a warm restart, certain BGP fast convergence feature and black hole avoidance feature should either be disabled or be set to a lower preference to avoid conflicts with BGP graceful restart. + +For example, BGP BFD could be disabled via: + + ``` + no neighbor bfd + ``` + +otherwise, the fast failure detection would cause packet drop during warm reboot. + +Another commonly deployed blackhole avoidance feature: dynamic route priority adjustment, could be disabled via: + + ``` + no bgp max-med on-peerup + ``` + +to avoid large routes churn during BGP restart. + + +### Warm Restart show commands + +**show warm_restart config** + +This command displays all the configuration related to warm_restart. + +- Usage: + ``` + show warm_restart config + ``` + +- Example: + ``` + admin@sonic:~$ show warm_restart config + name enable timer_name timer_duration + ------ -------- ---------------- ---------------- + bgp true bgp_timer 100 + teamd false teamsyncd_timer 300 + swss false neighsyncd_timer 200 + system true NULL NULL + ``` + +**show warm_restart state** + +This command displays the warm_restart state. + +- Usage: + ``` + show warm_restart state + ``` + +- Example: + ``` + admin@sonic:~$ show warm_restart state + name restore_count state + ---------- --------------- ---------- + orchagent 0 + vlanmgrd 0 + bgp 1 reconciled + portsyncd 0 + teammgrd 1 + neighsyncd 0 + teamsyncd 1 + syncd 0 + natsyncd 0 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#warm-restart) + +### Warm Restart Config commands + +This sub-section explains the various configuration related to warm restart feature. Following parameters can be configured using this command. +1) bgp_timer +2) disable +3) enable +4) neighsyncd_timer +5) teamsyncd_timer +Each of these sub-commands are explained in the following section. + +Users can use an optional parameter "-s" to use the unix domain socket for communicating with the RedisDB which will be faster when compared to using the default network sockets. +All these commands have the following option. + +Options: + -s, --redis-unix-socket-path TEXT + unix socket path for redis connection + + +**config warm_restart bgp_timer** + +This command is used to set the bgp_timer value for warm_restart of BGP service. +bgp_timer holds the time interval utilized by fpmsyncd during warm-restart episodes. +During this interval fpmsyncd will recover all the routing state previously pushed to AppDB, as well as all the new state coming from zebra/bgpd. +Upon expiration of this timer, fpmsyncd will execute the reconciliation logic to eliminate all the stale entries from AppDB. +This timer should match the BGP-GR restart-timer configured within the elected routing-stack. +Supported range: 1-3600. + +- Usage: + ``` + config warm_restart [-s|--redis-unix-socket-path ] bgp_timer + ``` + + - Parameters: + - seconds: Range from 1 to 3600 + +- Example: + ``` + admin@sonic:~$ sudo config warm_restart bgp_timer 1000 + ``` + +**config warm_restart enable/disable** + +This command is used to enable or disable the warm_restart for a particular service that supports warm reboot. +Following four services support warm reboot. When user restarts the particular service using "systemctl restart ", this configured value will be checked for whether it is enabled or disabled. +If this configuration is enabled for that service, it will perform warm reboot for that service. Otherwise, it will do cold restart of the service. + +- Usage: + ``` + config warm_restart [-s|--redis-unix-socket-path ] enable [] + ``` + + - Parameters: + - module_name: Can be either system or swss or bgp or teamd. If "module_name" argument is not specified, it will enable "system" module. + +- Example (Set warm_restart as "enable" for the "system" service): + ``` + admin@sonic:~$ sudo config warm_restart enable + ``` + +- Example (Set warm_restart as "enable" for the "swss" service. When user does "systemctl restart swss", it will perform warm reboot instead of cold reboot) + ``` + admin@sonic:~$ sudo config warm_restart enable swss + ``` + +- Example (Set warm_restart as "enable" for the "teamd" service. When user does "systemctl restart teamd", it will perform warm reboot instead of cold reboot) + ``` + admin@sonic:~$ sudo config warm_restart enable teamd + ``` + + +**config warm_restart neighsyncd_timer** + +This command is used to set the neighsyncd_timer value for warm_restart of "swss" service. +neighsyncd_timer is the timer used for "swss" (neighsyncd) service during the warm restart. +Timer is started after the neighborTable is restored to internal data structures. +neighborsyncd then starts to read all Linux kernel entries and mark the entries in the data structures accordingly. +Once the timer is expired, reconciliation is done and the delta is pushed to appDB +Valid value is 1-9999. 0 is invalid. + +- Usage: + ``` + config warm_restart [-s|--redis-unix-socket-path ] neighsyncd_timer + ``` + + - Parameters: + - seconds: Range from 1 to 9999 + +- Example: + ``` + admin@sonic:~$ sudo config warm_restart neighsyncd_timer 2000 + ``` + + +**config warm_restart bgp_timer** + +This command is used to set the bgp_timer value for warm_restart of "bgp" service. +bgp_timer is the timer used for "bgp" service during the warm restart. +Timer is started after the BGP table is restored to internal data structures. +BGP services then start to read all Linux kernel entries and mark the entries in the data structures accordingly. +Once the timer is expired, reconciliation is done and the delta is pushed to appDB +Valid value is 1-9999. 0 is invalid. + +- Usage: + ``` + config warm_restart [-s|--redis-unix-socket-path ] bgp_timer + ``` + + - Parameters: + - seconds: Range from 1 to 9999 + +- Example: + ``` + admin@sonic:~$ sudo config warm_restart bgp_timer 2000 + ``` + +**config warm_restart teamsyncd_timer** + +This command is used to set the teamsyncd_timer value for warm_restart of teamd service. +teamsyncd_timer holds the time interval utilized by teamsyncd during warm-restart episodes. +The timer is started when teamsyncd starts. During the timer interval, teamsyncd will preserve all LAG interface changes, but it will not apply them. +The changes will only be applied when the timer expires. +When the changes are applied, the stale LAG entries will be removed, the new LAG entries will be created. +Supported range: 1-9999. 0 is invalid + +- Usage: + ``` + config warm_restart teamsyncd_timer + ``` + + - Parameters: + - seconds: Range from 1 to 9999 + +- Example: + ``` + admin@sonic:~$ sudo config warm_restart teamsyncd_timer 3000 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#warm-restart) + + +## Watermark + +### Watermark Show commands + +**show watermark telemetry interval** + +This command displays the configured interval for the telemetry. + +- Usage: + ``` + show watermark telemetry interval + ``` + +- Example: + ``` + admin@sonic:~$ show watermark telemetry interval + + Telemetry interval 120 second(s) + ``` + +### Watermark Config commands + +**config watermark telemetry interval** + +This command is used to configure the interval for telemetry. +The default interval is 120 seconds. +There is no regulation on the valid range of values; it leverages linux timer. + +- Usage: + ``` + config watermark telemetry interval + ``` + +- Example: + ``` + admin@sonic:~$ sudo config watermark telemetry interval 999 + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#watermark) + + + +## Software Installation and Management + +SONiC images can be installed in one of two methods: +1. From within a running SONiC image using the `sonic-installer` utility +2. From the vendor's bootloader (E.g., ONIE, Aboot, etc.) + +SONiC packages are available as prebuilt Docker images and meant to be installed with the *sonic-package-manager* utility. + +### SONiC Package Manager + +The *sonic-package-manager* is a command line tool to manage (e.g. install, upgrade or uninstall) SONiC Packages. + +**sonic-package-manager list** + +This command lists all available SONiC packages, their desription, installed version and installation status. +SONiC package status can be *Installed*, *Not installed* or *Built-In*. "Built-In" status means that a feature is built-in to SONiC image and can't be upgraded or uninstalled. + +- Usage: + ``` + sonic-package-manager list + ``` + +- Example: + ``` + admin@sonic:~$ sonic-package-manager list + Name Repository Description Version Status + -------------- --------------------------- ---------------------------- --------- -------------- + cpu-report azure/cpu-report CPU report package N/A Not Installed + database docker-database SONiC database package 1.0.0 Built-In + dhcp-relay azure/docker-dhcp-relay SONiC dhcp-relay package 1.0.0 Installed + fpm-frr docker-fpm-frr SONiC fpm-frr package 1.0.0 Built-In + lldp docker-lldp SONiC lldp package 1.0.0 Built-In + macsec docker-macsec SONiC macsec package 1.0.0 Built-In + mgmt-framework docker-sonic-mgmt-framework SONiC mgmt-framework package 1.0.0 Built-In + nat docker-nat SONiC nat package 1.0.0 Built-In + pmon docker-platform-monitor SONiC pmon package 1.0.0 Built-In + radv docker-router-advertiser SONiC radv package 1.0.0 Built-In + sflow docker-sflow SONiC sflow package 1.0.0 Built-In + snmp docker-snmp SONiC snmp package 1.0.0 Built-In + swss docker-orchagent SONiC swss package 1.0.0 Built-In + syncd docker-syncd-mlnx SONiC syncd package 1.0.0 Built-In + teamd docker-teamd SONiC teamd package 1.0.0 Built-In + telemetry docker-sonic-telemetry SONiC telemetry package 1.0.0 Built-In + ``` + +**sonic-package-manager repository add** + +This command will add a new repository as source for SONiC packages to the database. *NOTE*: requires elevated (root) privileges to run + +- Usage: + ``` + Usage: sonic-package-manager repository add [OPTIONS] NAME REPOSITORY + + Add a new repository to database. + + NOTE: This command requires elevated (root) privileges to run. + + Options: + --default-reference TEXT Default installation reference. Can be a tag or + sha256 digest in repository. + --description TEXT Optional package entry description. + --help Show this message and exit. + ``` +- Example: + ``` + admin@sonic:~$ sudo sonic-package-manager repository add \ + cpu-report azure/sonic-cpu-report --default-reference 1.0.0 + ``` + +**sonic-package-manager repository remove** + +This command will remove a repository as source for SONiC packages from the database . The package has to be *Not Installed* in order to be removed from package database. *NOTE*: requires elevated (root) privileges to run + +- Usage: + ``` + Usage: sonic-package-manager repository remove [OPTIONS] NAME + + Remove repository from database. + + NOTE: This command requires elevated (root) privileges to run. + + Options: + --help Show this message and exit. + ``` +- Example: + ``` + admin@sonic:~$ sudo sonic-package-manager repository remove cpu-report + ``` + +**sonic-package-manager install** + +This command pulls and installs a package on SONiC host. *NOTE*: this command requires elevated (root) privileges to run + +- Usage: + ``` + Usage: sonic-package-manager install [OPTIONS] [PACKAGE_EXPR] + + Install/Upgrade package using [PACKAGE_EXPR] in format + "[=|@]". + + The repository to pull the package from is resolved by lookup in + package database, thus the package has to be added via "sonic- + package-manager repository add" command. + + In case when [PACKAGE_EXPR] is a package name "" this command + will install or upgrade to a version referenced by "default- + reference" in package database. + + NOTE: This command requires elevated (root) privileges to run. + + Options: + --enable Set the default state of the feature to enabled + and enable feature right after installation. NOTE: + user needs to execute "config save -y" to make + this setting persistent. + --set-owner [local|kube] Default owner configuration setting for a feature. + --from-repository TEXT Fetch package directly from image registry + repository. NOTE: This argument is mutually + exclusive with arguments: [package_expr, + from_tarball]. + --from-tarball FILE Fetch package from saved image tarball. NOTE: This + argument is mutually exclusive with arguments: + [package_expr, from_repository]. + -f, --force Force operation by ignoring package dependency + tree and package manifest validation failures. + -y, --yes Automatically answer yes on prompts. + -v, --verbosity LVL Either CRITICAL, ERROR, WARNING, INFO or DEBUG. + Default is INFO. + --skip-host-plugins Do not install host OS plugins provided by the + package (CLI, etc). NOTE: In case when package + host OS plugins are set as mandatory in package + manifest this option will fail the installation. + --allow-downgrade Allow package downgrade. By default an attempt to + downgrade the package will result in a failure + since downgrade might not be supported by the + package, thus requires explicit request from the + user. + --help Show this message and exit.. + ``` +- Example: + ``` + admin@sonic:~$ sudo sonic-package-manager install dhcp-relay=1.0.2 + ``` + ``` + admin@sonic:~$ sudo sonic-package-manager install dhcp-relay@latest + ``` + ``` + admin@sonic:~$ sudo sonic-package-manager install dhcp-relay@sha256:9780f6d83e45878749497a6297ed9906c19ee0cc48cc88dc63827564bb8768fd + ``` + ``` + admin@sonic:~$ sudo sonic-package-manager install --from-repository azure/sonic-cpu-report:latest + ``` + ``` + admin@sonic:~$ sudo sonic-package-manager install --from-tarball sonic-docker-image.gz + ``` + +**sonic-package-manager uninstall** + +This command uninstalls package from SONiC host. User needs to stop the feature prior to uninstalling it. +*NOTE*: this command requires elevated (root) privileges to run. + +- Usage: + ``` + Usage: sonic-package-manager uninstall [OPTIONS] NAME + + Uninstall package. + + NOTE: This command requires elevated (root) privileges to run. + + Options: + -f, --force Force operation by ignoring package dependency tree and + package manifest validation failures. + -y, --yes Automatically answer yes on prompts. + -v, --verbosity LVL Either CRITICAL, ERROR, WARNING, INFO or DEBUG. Default + is INFO. + --help Show this message and exit. + ``` +- Example: + ``` + admin@sonic:~$ sudo sonic-package-manager uninstall dhcp-relay + ``` + +**sonic-package-manager reset** + +This comamnd resets the package by reinstalling it to its default version. *NOTE*: this command requires elevated (root) privileges to run. + +- Usage: + ``` + Usage: sonic-package-manager reset [OPTIONS] NAME + + Reset package to the default version. + + NOTE: This command requires elevated (root) privileges to run. + + Options: + -f, --force Force operation by ignoring package dependency tree and + package manifest validation failures. + -y, --yes Automatically answer yes on prompts. + -v, --verbosity LVL Either CRITICAL, ERROR, WARNING, INFO or DEBUG. Default + is INFO. + --skip-host-plugins Do not install host OS plugins provided by the package + (CLI, etc). NOTE: In case when package host OS plugins + are set as mandatory in package manifest this option + will fail the installation. + --help Show this message and exit. + ``` +- Example: + ``` + admin@sonic:~$ sudo sonic-package-manager reset dhcp-relay + ``` + +**sonic-package-manager show package versions** + +This command will retrieve a list of all available versions for the given package from the configured upstream repository + +- Usage: + ``` + Usage: sonic-package-manager show package versions [OPTIONS] NAME + + Show available versions. + + Options: + --all Show all available tags in repository. + --plain Plain output. + --help Show this message and exit. + ``` +- Example: + ``` + admin@sonic:~$ sonic-package-manager show package versions dhcp-relay + • 1.0.0 + • 1.0.2 + • 2.0.0 + ``` + ``` + admin@sonic:~$ sonic-package-manager show package versions dhcp-relay --plain + 1.0.0 + 1.0.2 + 2.0.0 + ``` + ``` + admin@sonic:~$ sonic-package-manager show package versions dhcp-relay --all + • 1.0.0 + • 1.0.2 + • 2.0.0 + • latest + ``` + +**sonic-package-manager show package changelog** + +This command fetches the changelog from the package manifest and displays it. *NOTE*: package changelog can be retrieved from registry or read from image tarball without installing it. + +- Usage: + ``` + Usage: sonic-package-manager show package changelog [OPTIONS] [PACKAGE_EXPR] + + Show package changelog. + + Options: + --from-repository TEXT Fetch package directly from image registry + repository NOTE: This argument is mutually exclusive + with arguments: [from_tarball, package_expr]. + --from-tarball FILE Fetch package from saved image tarball NOTE: This + argument is mutually exclusive with arguments: + [package_expr, from_repository]. + --help Show this message and exit. + ``` +- Example: + ``` + admin@sonic:~$ sonic-package-manager show package changelog dhcp-relay + 1.0.0: + + • Initial release + + Author (author@email.com) Mon, 25 May 2020 12:25:00 +0300 + ``` + +**sonic-package-manager show package manifest** + +This command fetches the package manifest and displays it. *NOTE*: package manifest can be retrieved from registry or read from image tarball without installing it. + +- Usage: + ``` + Usage: sonic-package-manager show package manifest [OPTIONS] [PACKAGE_EXPR] + + Show package manifest. + + Options: + --from-repository TEXT Fetch package directly from image registry + repository NOTE: This argument is mutually exclusive + with arguments: [package_expr, from_tarball]. + --from-tarball FILE Fetch package from saved image tarball NOTE: This + argument is mutually exclusive with arguments: + [from_repository, package_expr]. + -v, --verbosity LVL Either CRITICAL, ERROR, WARNING, INFO or DEBUG + --help Show this message and exit. + ``` +- Example: + ``` + admin@sonic:~$ sonic-package-manager show package manifest dhcp-relay=2.0.0 + { + "version": "1.0.0", + "package": { + "version": "2.0.0", + "depends": [ + "database>=1.0.0,<2.0.0" + ] + }, + "service": { + "name": "dhcp_relay" + } + } + ``` + +### SONiC Installer +This is a command line tool available as part of the SONiC software; If the device is already running the SONiC software, this tool can be used to install an alternate image in the partition. +This tool has facility to install an alternate image, list the available images and to set the next reboot image. +This command requires elevated (root) privileges to run. + +**sonic-installer list** + +This command displays information about currently installed images. It displays a list of installed images, currently running image and image set to be loaded in next reboot. + +- Usage: + ``` + sonic-installer list + ``` + +- Example: + ``` + admin@sonic:~$ sudo sonic-installer list + Current: SONiC-OS-HEAD.XXXX + Next: SONiC-OS-HEAD.XXXX + Available: + SONiC-OS-HEAD.XXXX + SONiC-OS-HEAD.YYYY + ``` + +TIP: This output can be obtained without evelated privileges by running the `show boot` command. See [here](#show-system-status) for details. + +**sonic-installer install** + +This command is used to install a new image on the alternate image partition. This command takes a path to an installable SONiC image or URL and installs the image. + +- Usage: + ``` + sonic-installer install + ``` + +- Example: + ``` + admin@sonic:~$ sudo sonic-installer install https://sonic-jenkins.westus.cloudapp.azure.com/job/xxxx/job/buildimage-xxxx-all/xxx/artifact/target/sonic-xxxx.bin + New image will be installed, continue? [y/N]: y + Downloading image... + ...100%, 480 MB, 3357 KB/s, 146 seconds passed + Command: /tmp/sonic_image + Verifying image checksum ... OK. + Preparing image archive ... OK. + ONIE Installer: platform: XXXX + onie_platform: + Installing SONiC in SONiC + Installing SONiC to /host/image-xxxx + Directory /host/image-xxxx/ already exists. Cleaning up... + Archive: fs.zip + creating: /host/image-xxxx/boot/ + inflating: /host/image-xxxx/boot/vmlinuz-3.16.0-4-amd64 + inflating: /host/image-xxxx/boot/config-3.16.0-4-amd64 + inflating: /host/image-xxxx/boot/System.map-3.16.0-4-amd64 + inflating: /host/image-xxxx/boot/initrd.img-3.16.0-4-amd64 + creating: /host/image-xxxx/platform/ + extracting: /host/image-xxxx/platform/firsttime + inflating: /host/image-xxxx/fs.squashfs + inflating: /host/image-xxxx/dockerfs.tar.gz + Log file system already exists. Size: 4096MB + Installed SONiC base image SONiC-OS successfully + + Command: cp /etc/sonic/minigraph.xml /host/ + + Command: grub-set-default --boot-directory=/host 0 + + Done + ``` + +Installing a new image using the sonic-installer will keep using the packages installed on the currently running SONiC image and automatically migrate those. In order to perform clean SONiC installation use the *--skip-package-migration* option: + +- Example: + ``` + admin@sonic:~$ sudo sonic-installer install https://sonic-jenkins.westus.cloudapp.azure.com/job/xxxx/job/buildimage-xxxx-all/xxx/artifact/target/sonic-xxxx.bin --skip-package-migration + ``` + +**sonic-installer set_default** + +This command is be used to change the image which can be loaded by default in all the subsequent reboots. + +- Usage: + ``` + sonic-installer set_default + ``` + +- Example: + ``` + admin@sonic:~$ sudo sonic-installer set_default SONiC-OS-HEAD.XXXX + ``` + +**sonic-installer set_next_boot** + +This command is used to change the image that can be loaded in the *next* reboot only. Note that it will fallback to current image in all other subsequent reboots after the next reboot. + +- Usage: + ``` + sonic-installer set_next_boot + ``` + +- Example: + ``` + admin@sonic:~$ sudo sonic-installer set_next_boot SONiC-OS-HEAD.XXXX + ``` + +**sonic-installer remove** + +This command is used to remove the unused SONiC image from the disk. Note that it's *not* allowed to remove currently running image. + +- Usage: + ``` + sonic-installer remove [-y|--yes] + ``` + +- Example: + ``` + admin@sonic:~$ sudo sonic-installer remove SONiC-OS-HEAD.YYYY + Image will be removed, continue? [y/N]: y + Updating GRUB... + Done + Removing image root filesystem... + Done + Command: grub-set-default --boot-directory=/host 0 + + Image removed + ``` + +**sonic-installer cleanup** + +This command removes all unused images from the device, leaving only the currently active image and the image which will be booted into next (if different) installed. If there are no images which can be removed, the command will output `No image(s) to remove` + +- Usage: + ``` + sonic-installer cleanup [-y|--yes] + ``` + +- Example: + ``` + admin@sonic:~$ sudo sonic-installer cleanup + Remove images which are not current and next, continue? [y/N]: y + No image(s) to remove + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#software-installation-and-management) + + + +## Troubleshooting Commands + +For troubleshooting and debugging purposes, this command gathers pertinent information about the state of the device; information is as diverse as syslog entries, database state, routing-stack state, etc., It then compresses it into an archive file. This archive file can be sent to the SONiC development team for examination. +Resulting archive file is saved as `/var/dump/_YYYYMMDD_HHMMSS.tar.gz` + +- Usage: + ``` + show techsupport + ``` + +- Example: + ``` + admin@sonic:~$ show techsupport [--since=] + ``` + +If the SONiC system was running for quite some time `show techsupport` will produce a large dump file. To reduce the amount of syslog and core files gathered during system dump use `--since` option: + +- Examples: + ``` + admin@sonic:~$ show techsupport --since=yesterday # Will collect syslog and core files for the last 24 hours + ``` + ``` + admin@sonic:~$ show techsupport --since='hour ago' # Will collect syslog and core files for the last one hour + ``` + +### Debug Dumps + +In SONiC, there usually exists a set of tables related/relevant to a particular module. All of these might have to be looked at to confirm whether any configuration update is properly applied and propagated. This utility comes in handy because it prints a unified view of the redis-state for a given module + +- Usage: + ``` + Usage: dump state [OPTIONS] MODULE IDENTIFIER + Dump the redis-state of the identifier for the module specified + + Options: + -s, --show Display Modules Available + -d, --db TEXT Only dump from these Databases + -t, --table Print in tabular format [default: False] + -k, --key-map Only fetch the keys matched, don't extract field-value dumps [default: False] + -v, --verbose Prints any intermediate output to stdout useful for dev & troubleshooting [default: False] + -n, --namespace TEXT Dump the redis-state for this namespace. [default: DEFAULT_NAMESPACE] + --help Show this message and exit. + ``` + + +- Examples: + ``` + root@sonic# dump state --show + Module Identifier + -------- ------------ + port port_name + copp trap_id + ``` + + ``` + admin@sonic:~$ dump state copp arp_req --key-map --db ASIC_DB + { + "arp_req": { + "ASIC_DB": { + "keys": [ + "ASIC_STATE:SAI_OBJECT_TYPE_HOSTIF_TRAP:oid:0x22000000000c5b", + "ASIC_STATE:SAI_OBJECT_TYPE_HOSTIF_TRAP_GROUP:oid:0x11000000000c59", + "ASIC_STATE:SAI_OBJECT_TYPE_POLICER:oid:0x12000000000c5a", + "ASIC_STATE:SAI_OBJECT_TYPE_QUEUE:oid:0x15000000000626" + ], + "tables_not_found": [], + "vidtorid": { + "oid:0x22000000000c5b": "oid:0x200000000022", + "oid:0x11000000000c59": "oid:0x300000011", + "oid:0x12000000000c5a": "oid:0x200000012", + "oid:0x15000000000626": "oid:0x12e0000040015" + } + } + } + } + ``` + +### Event Driven Techsupport Invocation + +This feature/capability makes the techsupport invocation event-driven based on system events like core dump generation or low RAM availability. +This feature is only applicable for the processes running in the containers. More detailed explanation can be found in the HLD https://github.com/Azure/SONiC/blob/master/doc/auto_techsupport_and_coredump_mgmt.md + +#### config auto-techsupport global commands + +**config auto-techsupport global state** + +- Usage: + ``` + config auto-techsupport global state + ``` + +- Example: + ``` + config auto-techsupport global state enabled + ``` + +**config auto-techsupport global rate-limit-interval ** + +- Usage: + ``` + config auto-techsupport global rate-limit-interval + ``` + - Parameters: + - rate-limit-interval: Minimum time in seconds to wait after the last techsupport creation time before invoking a new one. + +- Example: + ``` + config auto-techsupport global rate-limit-interval 200 + ``` + +**config auto-techsupport global max-techsupport-limit ** + +- Usage: + ``` + config auto-techsupport global max-techsupport-limit + ``` + - Parameters: + - max-techsupport-limit: A percentage value should be specified. This signifies maximum size to which /var/dump/ directory can be grown until. + +- Example: + ``` + config auto-techsupport global max-techsupport-limit 10.15 + ``` + +**config auto-techsupport global max-core-limit ** + +- Usage: + ``` + config auto-techsupport global max-core-limit + ``` + - Parameters: + - max-core-limit: A percentage value should be specified. This signifies maximum size to which /var/core/ directory can be grown until. + +- Example: + ``` + config auto-techsupport global max-core-limit 10.15 + ``` + +**config auto-techsupport global since** + +- Usage: + ``` + config auto-techsupport global since + ``` + - Parameters: + - since: This limits the auto-invoked techsupport to only collect the logs & core-dumps generated since the time provided. Any valid date string of the formats specified here can be used. (https://www.gnu.org/software/coreutils/manual/html_node/Date-input-formats.html). If this value is not explicitly configured or a non-valid string is provided, a default value of "2 days ago" is used. + +- Example: + ``` + config auto-techsupport global since + ``` + +**config auto-techsupport global available-mem-threshold** + +Configure available memory threshold in %. System will automatically generate a techsupport dump when available memory goes below the configured threshold. Setting this field to 0 will disable techsupport invokation. + +- Usage: + ``` + config auto-techsupport global available-mem-threshold + ``` + - Parameters: + - available-mem-threshold: Memory threshold. Configure 0 to disable techsupport invocation on memory usage threshold crossing +- Example: + ``` + config auto-techsupport global available-mem-threshold 20 + ``` + +**config auto-techsupport global min-available-mem** + +Configure minimum available memory in MB. System will automatically generate a techsupport dump when available memory goes below the configured threshold. + +- Usage: + ``` + config auto-techsupport global min-available-mem + ``` + - Parameters: + - min-available-mem: Minimum free memory amount in MB to trigger techsupport dump +- Example: + ``` + config auto-techsupport global min-available-mem 200 + ``` + +#### config auto-techsupport-feature commands + +**config auto-techsupport-feature add** + +- Usage: + ``` + config auto-techsupport-feature add --state --rate-limit-interval --available-mem-threshold + ``` + - Parameters: + - state: enable/disable the capability for the specific feature/container. + - rate-limit-interval: Rate limit interval for the corresponding feature. Configure 0 to explicitly disable. For the techsupport to be generated by auto-techsupport, both the global and feature specific rate-limit-interval has to be passed + - available-mem-threshold: Memory threshold. Configure 0 to disable techsupport invocation on memory usage threshold crossing. + +- Example: + ``` + config auto-techsupport-feature add bgp --state enabled --rate-limit-interval 200 --available-mem-threshold 50 + ``` + + +**config auto-techsupport-feature delete** + +- Usage: + ``` + config auto-techsupport-feature delete + ``` + +- Example: + ``` + config auto-techsupport-feature delete swss + ``` + +**config auto-techsupport-feature update** + +- Usage: + ``` + config auto-techsupport-feature update --state + config auto-techsupport-feature update --rate-limit-interval + config auto-techsupport-feature update --available-mem-threshold + ``` + +- Example: + ``` + config auto-techsupport-feature update snmp --state enabled + config auto-techsupport-feature update swss --rate-limit-interval 200 + ``` + +#### Show CLI: + +**show auto-techsupport global** + +- Usage: + ``` + show auto-techsupport global + ``` + +- Example: + ``` + admin@sonic:~$ show auto-techsupport global + STATE RATE LIMIT INTERVAL (sec) MAX TECHSUPPORT LIMIT (%) MAX CORE LIMIT (%) AVAILABLE MEM THRESHOLD (%) MIN AVAILABLE MEM (Kb) SINCE + ------- --------------------------- --------------------------- -------------------- ----------------------------- ------------------------ ------------ + enabled 180 10 5 10 200 2 days ago + ``` + +**show auto-techsupport-feature** + +- Usage: + ``` + show auto-techsupport-feature + ``` + +- Example: + ``` + admin@sonic:~$ show auto-techsupport-feature + FEATURE NAME STATE RATE LIMIT INTERVAL (sec) AVAILABLE MEM THRESHOLD (%) + -------------- -------- -------------------------- ------------------------------ + bgp enabled 600 10 + database enabled 600 10 + dhcp_relay enabled 600 10 + lldp enabled 600 10 + swss disabled 800 10 + ``` + +**show auto-techsupport history** + +- Usage: + ``` + show auto-techsupport history + ``` + +- Example: + ``` + admin@sonic:~$ show auto-techsupport history + TECHSUPPORT DUMP TRIGGERED BY EVENT TYPE CORE DUMP + ---------------------------------------- -------------- -------------- ----------------------------- + sonic_dump_r-lionfish-16_20210901_221402 bgp core bgpcfgd.1630534439.55.core.gz + sonic_dump_r-lionfish-16_20210901_203725 snmp core python3.1630528642.23.core.gz + sonic_dump_r-lionfish-16_20210901_222408 teamd core python3.1630535045.34.core.gz + sonic_dump_r-lionfish-16_20210901_222511 N/A memory N/A + ``` + +Go Back To [Beginning of the document](#) or [Beginning of this section](#troubleshooting-commands) + +## Routing Stack + +SONiC software is agnostic of the routing software that is being used in the device. For example, users can use either Quagga or FRR routing stack as per their requirement. +A separate shell (vtysh) is provided to configure such routing stacks. +Once if users go to "vtysh", they can use the routing stack specific commands as given in the following example. + +- Example (Quagga Routing Stack): + ``` + admin@sonic:~$ vtysh + + Hello, this is Quagga (version 0.99.24.1). + Copyright 1996-2005 Kunihiro Ishiguro, et al. + + sonic# show route-map (This command displays the route-map that is configured for the routing protocol.) + ZEBRA: + route-map RM_SET_SRC, permit, sequence 10 + Match clauses: + Set clauses: + src 10.12.0.102 + Call clause: + Action: + Exit routemap + ``` + +Refer the routing stack [Quagga Command Reference](https://www.quagga.net/docs/quagga.pdf) or [FRR Command Reference](https://buildmedia.readthedocs.org/media/pdf/frrouting/latest/frrouting.pdf) to know more about about the routing stack configuration. + + +Go Back To [Beginning of the document](#) or [Beginning of this section](#routing-stack) + + +## Quagga BGP Show Commands + +**show ip bgp summary** + +This command displays the summary of all IPv4 bgp neighbors that are configured and the corresponding states. + +- Usage: + ``` + show ip bgp summary + ``` + +- Example: + ``` + admin@sonic:~$ show ip bgp summary + BGP router identifier 1.2.3.4, local AS number 65061 + RIB entries 6124, using 670 KiB of memory + Peers 2, using 143 KiB of memory + + Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd + 192.168.1.161 4 65501 88698 102781 0 0 0 08w5d14h 2 + 192.168.1.163 4 65502 88698 102780 0 0 0 08w5d14h 2 + + Total number of neighbors 2 + ``` + +**show ip bgp neighbors** + +This command displays all the details of IPv4 & IPv6 BGP neighbors when no optional argument is specified. + +When the optional argument IPv4_address is specified, it displays the detailed neighbor information about that specific IPv4 neighbor. + +Command has got additional optional arguments to display only the advertised routes, or the received routes, or all routes. + +In order to get details for an IPv6 neigbor, use "show ipv6 bgp neighbor " command. + +- Usage: + ``` + show ip bgp neighbors [ [advertised-routes | received-routes | routes]] + ``` + +- Example: + ``` + admin@sonic:~$ show ip bgp neighbors + BGP neighbor is 192.168.1.161, remote AS 65501, local AS 65061, external link + Description: ARISTA01T0 + BGP version 4, remote router ID 1.2.3.4 + BGP state = Established, up for 08w5d14h + Last read 00:00:46, hold time is 180, keepalive interval is 60 seconds + Neighbor capabilities: + 4 Byte AS: advertised and received + Dynamic: received + Route refresh: advertised and received(old & new) + Address family IPv4 Unicast: advertised and received + Graceful Restart Capabilty: advertised and received + Remote Restart timer is 120 seconds + Address families by peer: + IPv4 Unicast(not preserved) + Graceful restart informations: + End-of-RIB send: IPv4 Unicast + End-of-RIB received: IPv4 Unicast + Message statistics: + Inq depth is 0 + Outq depth is 0 + Sent Rcvd + Opens: 1 1 + Notifications: 0 0 + Updates: 14066 3 + Keepalives: 88718 88698 + Route Refresh: 0 0 + Capability: 0 0 + Total: 102785 88702 + Minimum time between advertisement runs is 30 seconds + + For address family: IPv4 Unicast + Community attribute sent to this neighbor(both) + 2 accepted prefixes + + Connections established 1; dropped 0 + Last reset never + Local host: 192.168.1.160, Local port: 32961 + Foreign host: 192.168.1.161, Foreign port: 179 + Nexthop: 192.168.1.160 + Nexthop global: fe80::f60f:1bff:fe89:bc00 + Nexthop local: :: + BGP connection: non shared network + Read thread: on Write thread: off + ``` + +Optionally, you can specify an IP address in order to display only that particular neighbor. In this mode, you can optionally specify whether you want to display all routes advertised to the specified neighbor, all routes received from the specified neighbor or all routes (received and accepted) from the specified neighbor. + + +- Examples: + ``` + admin@sonic:~$ show ip bgp neighbors 192.168.1.161 + + admin@sonic:~$ show ip bgp neighbors 192.168.1.161 advertised-routes + + admin@sonic:~$ show ip bgp neighbors 192.168.1.161 received-routes + + admin@sonic:~$ show ip bgp neighbors 192.168.1.161 routes + ``` + +**show ipv6 bgp summary** + +This command displays the summary of all IPv4 bgp neighbors that are configured and the corresponding states. + +- Usage: + ``` + show ipv6 bgp summary + ``` + +- Example: + ``` + admin@sonic:~$ show ipv6 bgp summary + BGP router identifier 10.1.0.32, local AS number 65100 + RIB entries 12809, using 1401 KiB of memory + Peers 8, using 36 KiB of memory + + Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd + fc00::72 4 64600 12588 12591 0 0 0 06:51:17 6402 + fc00::76 4 64600 12587 6190 0 0 0 06:51:28 6402 + fc00::7a 4 64600 12587 9391 0 0 0 06:51:23 6402 + fc00::7e 4 64600 12589 12592 0 0 0 06:51:25 6402 + + Total number of neighbors 4 + ``` + +**show ipv6 bgp neighbors** + +This command displays all the details of one particular IPv6 Border Gateway Protocol (BGP) neighbor. Option is also available to display only the advertised routes, or the received routes, or all routes. + +- Usage: + ``` + show ipv6 bgp neighbors (advertised-routes | received-routes | routes) + ``` + +- Examples: + ``` + admin@sonic:~$ show ipv6 bgp neighbors fc00::72 advertised-routes + + admin@sonic:~$ show ipv6 bgp neighbors fc00::72 received-routes + + admin@sonic:~$ show ipv6 bgp neighbors fc00::72 routes + ``` + +**show route-map** + +This command displays the routing policy that takes precedence over the other route processes that are configured. + +- Usage: + ``` + show route-map + ``` + +- Example: + ``` + admin@sonic:~$ show route-map + ZEBRA: + route-map RM_SET_SRC, permit, sequence 10 + Match clauses: + Set clauses: + src 10.12.0.102 + Call clause: + Action: + Exit routemap + ZEBRA: + route-map RM_SET_SRC6, permit, sequence 10 + Match clauses: + Set clauses: + src fc00:1::102 + Call clause: + Action: + Exit routemap + BGP: + route-map FROM_BGP_SPEAKER_V4, permit, sequence 10 + Match clauses: + Set clauses: + Call clause: + Action: + Exit routemap + BGP: + route-map TO_BGP_SPEAKER_V4, deny, sequence 10 + Match clauses: + Set clauses: + Call clause: + Action: + Exit routemap + BGP: + route-map ISOLATE, permit, sequence 10 + Match clauses: + Set clauses: + as-path prepend 65000 + Call clause: + Action: + Exit routemap + ``` +Go Back To [Beginning of the document](#) or [Beginning of this section](#quagga-bgp-show-commands) + +# ZTP Configuration And Show Commands + +This section explains all the Zero Touch Provisioning commands that are supported in SONiC. + +## ZTP show commands + + +This command displays the current ZTP configuration of the switch. It also displays detailed information about current state of a ZTP session. It displays information related to all configuration sections as defined in the switch provisioning information discovered in a particular ZTP session. + +- Usage: + show ztp status + + show ztp status --verbose + +- Example: + +``` +root@B1-SP1-7712:/home/admin# show ztp status +ZTP Admin Mode : True +ZTP Service : Inactive +ZTP Status : SUCCESS +ZTP Source : dhcp-opt67 (eth0) +Runtime : 05m 31s +Timestamp : 2019-09-11 19:12:24 UTC + +ZTP Service is not running + +01-configdb-json: SUCCESS +02-connectivity-check: SUCCESS +``` +Use the verbose option to display more detailed information. + +``` +root@B1-SP1-7712:/home/admin# show ztp status --verbose +Command: ztp status --verbose +======================================== +ZTP +======================================== +ZTP Admin Mode : True +ZTP Service : Inactive +ZTP Status : SUCCESS +ZTP Source : dhcp-opt67 (eth0) +Runtime : 05m 31s +Timestamp : 2019-09-11 19:12:16 UTC +ZTP JSON Version : 1.0 + +ZTP Service is not running + +---------------------------------------- +01-configdb-json +---------------------------------------- +Status : SUCCESS +Runtime : 02m 48s +Timestamp : 2019-09-11 19:11:55 UTC +Exit Code : 0 +Ignore Result : False + +---------------------------------------- +02-connectivity-check +---------------------------------------- +Status : SUCCESS +Runtime : 04s +Timestamp : 2019-09-11 19:12:16 UTC +Exit Code : 0 +Ignore Result : False +``` + +- Description + + - **ZTP Admin Mode** - Displays if the ZTP feature is administratively enabled or disabled. Possible values are True or False. This value is configurable using "config ztp enabled" and "config ztp disable" commands. + - **ZTP Service** - Displays the ZTP service status. The following are possible values this field can display: + - *Active Discovery*: ZTP service is operational and is performing DHCP discovery to learn switch provisioning information + - *Processing*: ZTP service has discovered switch provisioning information and is processing it + - **ZTP Status** - Displays the current state and result of ZTP session. The following are possible values this field can display: + - *IN-PROGRESS*: ZTP session is currently in progress. ZTP service is processing switch provisioning information. + - *SUCCESS*: ZTP service has successfully processed the switch provisioning information. + - *FAILED*: ZTP service has failed to process the switch provisioning information. + - *Not Started*: ZTP service has not started processing the discovered switch provisioning information. + - **ZTP Source** - Displays the DHCP option and then interface name from which switch provisioning information has been discovered. + - **Runtime** - Displays the time taken for ZTP process to complete from start to finish. For individual configuration sections it indicates the time taken to process the associated configuration section. + - **Timestamp** - Displays the date/time stamp when the status field has last changed. + - **ZTP JSON Version** - Version of ZTP JSON file used for describing switch provisioning information. + - **Status** - Displays the current state and result of a configuration section. The following are possible values this field can display: + - *IN-PROGRESS*: Corresponding configuration section is currently being processed. + - *SUCCESS*: Corresponding configuration section was processed successfully. + - *FAILED*: Corresponding configuration section failed to execute successfully. + - *Not Started*: ZTP service has not started processing the corresponding configuration section. + - *DISABLED*: Corresponding configuration section has been marked as disabled and will not be processed. + - **Exit Code** - Displays the program exit code of the configuration section executed. Non-zero exit code indicates that the configuration section has failed to execute successfully. + - **Ignore Result** - If this value is True, the result of the corresponding configuration section is ignored and not used to evaluate the overall ZTP result. + - **Activity String** - In addition to above information an activity string is displayed indicating the current action being performed by the ZTP service and how much time it has been performing the mentioned activity. Below is an example. + - (04m 12s) Discovering provisioning data + +## ZTP configuration commands + +This sub-section explains the list of the configuration options available for ZTP. + + + +**config ztp enable** + +Use this command to enable ZTP administrative mode + +- Example: + +``` +root@sonic:/home/admin# config ztp enable +Running command: ztp enable +``` + + + +**config ztp disable** + +Use this command to disable ZTP administrative mode. This command can also be used to abort a current ZTP session and load the factory default switch configuration. + +- Usage: + config ztp disable + + config ztp disable -y + +- Example: + +``` +root@sonic:/home/admin# config ztp disable +Active ZTP session will be stopped and disabled, continue? [y/N]: y +Running command: ztp disable -y +``` + + +**config ztp run** + +Use this command to manually restart a new ZTP session. This command deletes the existing */etc/sonic/config_db.json* file and stats ZTP service. It also erases the previous ZTP session data. ZTP configuration is loaded on to the switch and ZTP discovery is performed. + +- Usage: + config ztp run + + config ztp run -y + +- Example: + +``` +root@sonic:/home/admin# config ztp run +ZTP will be restarted. You may lose switch data and connectivity, continue? [y/N]: y +Running command: ztp run -y +``` + +Go Back To [Beginning of the document](#SONiC-COMMAND-LINE-INTERFACE-GUIDE) or [Beginning of this section](#ztp-configuration-and-show-commands) +>>>>>>> 202205 diff --git a/generic_config_updater/change_applier.py b/generic_config_updater/change_applier.py index 63ca98049c..f5a365d59f 100644 --- a/generic_config_updater/change_applier.py +++ b/generic_config_updater/change_applier.py @@ -65,12 +65,21 @@ def apply(self, change): self.config_wrapper.apply_change_to_config_db(change) + def remove_backend_tables_from_config(self, data): + return data + + class ChangeApplier: updater_conf = None def __init__(self): self.config_db = get_config_db() + self.backend_tables = [ + "BUFFER_PG", + "BUFFER_PROFILE", + "FLEX_COUNTER_TABLE" + ] if (not ChangeApplier.updater_conf) and os.path.exists(UPDATER_CONF_FILE): with open(UPDATER_CONF_FILE, "r") as s: ChangeApplier.updater_conf = json.load(s) @@ -142,6 +151,8 @@ def apply(self, change): ret = self._services_validate(run_data, upd_data, upd_keys) if not ret: run_data = self._get_running_config() + self.remove_backend_tables_from_config(upd_data) + self.remove_backend_tables_from_config(run_data) if upd_data != run_data: self._report_mismatch(run_data, upd_data) ret = -1 @@ -150,6 +161,11 @@ def apply(self, change): return ret + def remove_backend_tables_from_config(self, data): + for key in self.backend_tables: + data.pop(key, None) + + def _get_running_config(self): (_, fname) = tempfile.mkstemp(suffix="_changeApplier") os.system("sonic-cfggen -d --print-data > {}".format(fname)) diff --git a/generic_config_updater/generic_config_updater.conf.json b/generic_config_updater/generic_config_updater.conf.json index 417da035cd..907b5a6863 100644 --- a/generic_config_updater/generic_config_updater.conf.json +++ b/generic_config_updater/generic_config_updater.conf.json @@ -45,6 +45,9 @@ }, "ACL_RULE": { "services_to_validate": [ "caclmgrd-service" ] + }, + "NTP_SERVER": { + "services_to_validate": [ "ntp-service" ] } }, "services": { @@ -65,6 +68,9 @@ }, "caclmgrd-service": { "validate_commands": [ "generic_config_updater.services_validator.caclmgrd_validator" ] + }, + "ntp-service": { + "validate_commands": [ "generic_config_updater.services_validator.ntp_validator" ] } } } diff --git a/generic_config_updater/generic_updater.py b/generic_config_updater/generic_updater.py index ee7af65620..56297039aa 100644 --- a/generic_config_updater/generic_updater.py +++ b/generic_config_updater/generic_updater.py @@ -77,6 +77,8 @@ def apply(self, patch): # Validate config updated successfully self.logger.log_notice("Verifying patch updates are reflected on ConfigDB.") new_config = self.config_wrapper.get_config_db_as_json() + self.changeapplier.remove_backend_tables_from_config(target_config) + self.changeapplier.remove_backend_tables_from_config(new_config) if not(self.patch_wrapper.verify_same_json(target_config, new_config)): raise GenericConfigUpdaterError(f"After applying patch to config, there are still some parts not updated") diff --git a/generic_config_updater/gu_common.py b/generic_config_updater/gu_common.py index 356bff3435..87fb4adfd7 100644 --- a/generic_config_updater/gu_common.py +++ b/generic_config_updater/gu_common.py @@ -2,6 +2,7 @@ import jsonpatch from jsonpointer import JsonPointer import sonic_yang +import sonic_yang_ext import subprocess import yang as ly import copy @@ -47,7 +48,9 @@ def __init__(self, yang_dir = YANG_DIR): def get_config_db_as_json(self): text = self._get_config_db_as_text() - return json.loads(text) + config_db_json = json.loads(text) + config_db_json.pop("bgpraw", None) + return config_db_json def _get_config_db_as_text(self): # TODO: Getting configs from CLI is very slow, need to get it from sonic-cffgen directly @@ -112,16 +115,86 @@ def validate_sonic_yang_config(self, sonic_yang_as_json): def validate_config_db_config(self, config_db_as_json): sy = self.create_sonic_yang_with_loaded_models() + # TODO: Move these validators to YANG models + supplemental_yang_validators = [self.validate_bgp_peer_group, + self.validate_lanes] + try: tmp_config_db_as_json = copy.deepcopy(config_db_as_json) sy.loadData(tmp_config_db_as_json) sy.validate_data_tree() - return True, None + + for supplemental_yang_validator in supplemental_yang_validators: + success, error = supplemental_yang_validator(config_db_as_json) + if not success: + return success, error except sonic_yang.SonicYangException as ex: return False, ex + return True, None + + def validate_lanes(self, config_db): + if "PORT" not in config_db: + return True, None + + ports = config_db["PORT"] + + # Validate each lane separately, make sure it is not empty, and is a number + port_to_lanes_map = {} + for port in ports: + attrs = ports[port] + if "lanes" in attrs: + lanes_str = attrs["lanes"] + lanes_with_whitespaces = lanes_str.split(",") + lanes = [lane.strip() for lane in lanes_with_whitespaces] + for lane in lanes: + if not lane: + return False, f"PORT '{port}' has an empty lane" + if not lane.isdigit(): + return False, f"PORT '{port}' has an invalid lane '{lane}'" + port_to_lanes_map[port] = lanes + + # Validate lanes are unique + # TODO: Move this attribute (platform with duplicated lanes in ports) to YANG models + dup_lanes_platforms = [ + 'x86_64-arista_7050cx3_32s', + 'x86_64-dellemc_s5232f_c3538-r0', + ] + metadata = config_db.get("DEVICE_METADATA", {}) + platform = metadata.get("localhost", {}).get("platform", None) + if platform not in dup_lanes_platforms: + existing = {} + for port in port_to_lanes_map: + lanes = port_to_lanes_map[port] + for lane in lanes: + if lane in existing: + return False, f"'{lane}' lane is used multiple times in PORT: {set([port, existing[lane]])}" + existing[lane] = port + return True, None + + def validate_bgp_peer_group(self, config_db): + if "BGP_PEER_RANGE" not in config_db: + return True, None + + visited = {} + table = config_db["BGP_PEER_RANGE"] + for peer_group_name in table: + peer_group = table[peer_group_name] + if "ip_range" not in peer_group: + continue + + # TODO: convert string to IpAddress object for better handling of IPs + # TODO: validate range intersection + ip_range = peer_group["ip_range"] + for ip in ip_range: + if ip in visited: + return False, f"{ip} is duplicated in BGP_PEER_RANGE: {set([peer_group_name, visited[ip]])}" + visited[ip] = peer_group_name + + return True, None + def crop_tables_without_yang(self, config_db_as_json): sy = self.create_sonic_yang_with_loaded_models() @@ -132,14 +205,14 @@ def crop_tables_without_yang(self, config_db_as_json): sy._cropConfigDB() return sy.jIn - + def get_empty_tables(self, config): empty_tables = [] for key in config.keys(): if not(config[key]): empty_tables.append(key) return empty_tables - + def remove_empty_tables(self, config): config_with_non_empty_tables = {} for table in config: @@ -375,7 +448,7 @@ def find_ref_paths(self, path, config): Finds the paths referencing any line under the given 'path' within the given 'config'. Example: path: /PORT - config: + config: { "VLAN_MEMBER": { "Vlan1000|Ethernet0": {}, @@ -520,10 +593,25 @@ def _get_xpath_tokens_from_list(self, model, token_index, path_tokens, config): if len(path_tokens)-1 == token_index: return xpath_tokens + type_1_list_model = self._get_type_1_list_model(model) + if type_1_list_model: + new_xpath_tokens = self._get_xpath_tokens_from_type_1_list(type_1_list_model, token_index+1, path_tokens, config[path_tokens[token_index]]) + xpath_tokens.extend(new_xpath_tokens) + return xpath_tokens + new_xpath_tokens = self._get_xpath_tokens_from_leaf(model, token_index+1, path_tokens,config[path_tokens[token_index]]) xpath_tokens.extend(new_xpath_tokens) return xpath_tokens + def _get_xpath_tokens_from_type_1_list(self, model, token_index, path_tokens, config): + type_1_list_name = model['@name'] + keyName = model['key']['@value'] + value = path_tokens[token_index] + keyToken = f"[{keyName}='{value}']" + itemToken = f"{type_1_list_name}{keyToken}" + + return [itemToken] + def _get_xpath_tokens_from_leaf(self, model, token_index, path_tokens, config): token = path_tokens[token_index] @@ -557,7 +645,7 @@ def _get_xpath_tokens_from_leaf(self, model, token_index, path_tokens, config): # /module-name:container/leaf-list[.='val'] # Source: Check examples in https://netopeer.liberouter.org/doc/libyang/master/html/howto_x_path.html return [f"{token}[.='{value}']"] - + # checking 'uses' statement if not isinstance(config[token], list): # leaf-list under uses is not supported yet in sonic_yang table = path_tokens[0] @@ -585,7 +673,7 @@ def _extractKey(self, tableKey, keys): def _get_list_model(self, model, token_index, path_tokens): parent_container_name = path_tokens[token_index] clist = model.get('list') - # Container contains a single list, just return it + # Container contains a single list, just return it # TODO: check if matching also by name is necessary if isinstance(clist, dict): return clist @@ -607,6 +695,15 @@ def _get_list_model(self, model, token_index, path_tokens): return None + def _get_type_1_list_model(self, model): + list_name = model['@name'] + if list_name not in sonic_yang_ext.Type_1_list_maps_model: + return None + + # Type 1 list is expected to have a single inner list model. + # No need to check if it is a dictionary of list models. + return model.get('list') + def convert_xpath_to_path(self, xpath, config, sy): """ Converts the given XPATH to JsonPatch path (i.e. JsonPointer). @@ -688,10 +785,66 @@ def _get_path_tokens_from_list(self, model, token_index, xpath_tokens, config): if next_token in key_dict: return path_tokens + type_1_list_model = self._get_type_1_list_model(model) + if type_1_list_model: + new_path_tokens = self._get_path_tokens_from_type_1_list(type_1_list_model, token_index+1, xpath_tokens, config[path_token]) + path_tokens.extend(new_path_tokens) + return path_tokens + new_path_tokens = self._get_path_tokens_from_leaf(model, token_index+1, xpath_tokens, config[path_token]) path_tokens.extend(new_path_tokens) return path_tokens + def _get_path_tokens_from_type_1_list(self, model, token_index, xpath_tokens, config): + type_1_inner_list_name = model['@name'] + + token = xpath_tokens[token_index] + list_tokens = token.split("[", 1) # split once on the first '[', first element will be the inner list name + inner_list_name = list_tokens[0] + + if type_1_inner_list_name != inner_list_name: + raise GenericConfigUpdaterError(f"Type 1 inner list name '{type_1_inner_list_name}' does match xpath inner list name '{inner_list_name}'.") + + key_dict = self._extract_key_dict(token) + + # If no keys specified return empty tokens, as we are already inside the correct table. + # Also note that the type 1 inner list name in SonicYang has no correspondence in ConfigDb and is ignored. + # Example where VLAN_MEMBER_LIST has no specific key/value: + # xpath: /sonic-dot1p-tc-map:sonic-dot1p-tc-map/DOT1P_TO_TC_MAP/DOT1P_TO_TC_MAP_LIST[name='Dot1p_to_tc_map1']/DOT1P_TO_TC_MAP + # path: /DOT1P_TO_TC_MAP/Dot1p_to_tc_map1 + if not(key_dict): + return [] + + if len(key_dict) > 1: + raise GenericConfigUpdaterError(f"Type 1 inner list should have only 1 key in xpath, {len(key_dict)} specified. Key dictionary: {key_dict}") + + keyName = next(iter(key_dict.keys())) + value = key_dict[keyName] + + path_tokens = [value] + + # If this is the last xpath token, return the path tokens we have built so far, no need for futher checks + # Example: + # xpath: /sonic-dot1p-tc-map:sonic-dot1p-tc-map/DOT1P_TO_TC_MAP/DOT1P_TO_TC_MAP_LIST[name='Dot1p_to_tc_map1']/DOT1P_TO_TC_MAP[dot1p='2'] + # path: /DOT1P_TO_TC_MAP/Dot1p_to_tc_map1/2 + if token_index+1 >= len(xpath_tokens): + return path_tokens + + # Checking if the next_token is actually a child leaf of the inner type 1 list, for which case + # just ignore the token, and return the already created ConfigDb path pointing to the whole object + # Example where the leaf specified is the key: + # xpath: /sonic-dot1p-tc-map:sonic-dot1p-tc-map/DOT1P_TO_TC_MAP/DOT1P_TO_TC_MAP_LIST[name='Dot1p_to_tc_map1']/DOT1P_TO_TC_MAP[dot1p='2']/dot1p + # path: /DOT1P_TO_TC_MAP/Dot1p_to_tc_map1/2 + # Example where the leaf specified is not the key: + # xpath: /sonic-dot1p-tc-map:sonic-dot1p-tc-map/DOT1P_TO_TC_MAP/DOT1P_TO_TC_MAP_LIST[name='Dot1p_to_tc_map1']/DOT1P_TO_TC_MAP[dot1p='2']/tc + # path: /DOT1P_TO_TC_MAP/Dot1p_to_tc_map1/2 + next_token = xpath_tokens[token_index+1] + leaf_model = self._get_model(model.get('leaf'), next_token) + if leaf_model: + return path_tokens + + raise GenericConfigUpdaterError(f"Type 1 inner list '{type_1_inner_list_name}' does not have a child leaf named '{next_token}'") + def _get_path_tokens_from_leaf(self, model, token_index, xpath_tokens, config): token = xpath_tokens[token_index] @@ -727,6 +880,19 @@ def _get_path_tokens_from_leaf(self, model, token_index, xpath_tokens, config): # leaf_list_name = match.group(1) leaf_list_value = match.group(1) list_config = config[leaf_list_name] + # Workaround for those fields who is defined as leaf-list in YANG model but have string value in config DB + # No need to lookup the item index in ConfigDb since the list is represented as a string, return path to string immediately + # Example: + # xpath: /sonic-buffer-port-egress-profile-list:sonic-buffer-port-egress-profile-list/BUFFER_PORT_EGRESS_PROFILE_LIST/BUFFER_PORT_EGRESS_PROFILE_LIST_LIST[port='Ethernet9']/profile_list[.='egress_lossy_profile'] + # path: /BUFFER_PORT_EGRESS_PROFILE_LIST/Ethernet9/profile_list + if isinstance(list_config, str): + return [leaf_list_name] + + if not isinstance(list_config, list): + raise ValueError(f"list_config is expected to be of type list or string. Found {type(list_config)}.\n " + \ + f"model: {model}\n token_index: {token_index}\n " + \ + f"xpath_tokens: {xpath_tokens}\n config: {config}") + list_idx = list_config.index(leaf_list_value) return [leaf_list_name, list_idx] diff --git a/generic_config_updater/patch_sorter.py b/generic_config_updater/patch_sorter.py index f23b347bde..528e3d5151 100644 --- a/generic_config_updater/patch_sorter.py +++ b/generic_config_updater/patch_sorter.py @@ -399,10 +399,10 @@ def _get_paths_recursive(self, config, pattern_tokens, matching_tokens, idx, com if token == "*": matching_keys = config.keys() elif token.startswith("*|"): - suffix = token[2:] + suffix = token[1:] matching_keys = [key for key in config.keys() if key.endswith(suffix)] elif token.endswith("|*"): - prefix = token[:-2] + prefix = token[:-1] matching_keys = [key for key in config.keys() if key.startswith(prefix)] elif token in config: matching_keys = [token] @@ -544,6 +544,125 @@ def _get_default_value_from_settings(self, parent_path, field_name): return None +class CreateOnlyFilter: + """ + A filtering class for create-only fields. + """ + def __init__(self, path_addressing): + # TODO: create-only fields are hard-coded for now, it should be moved to YANG model + self.path_addressing = path_addressing + self.patterns = [ + ["PORT", "*", "lanes"], + ["LOOPBACK_INTERFACE", "*", "vrf_name"], + ["BGP_NEIGHBOR", "*", "holdtime"], + ["BGP_NEIGHBOR", "*", "keepalive"], + ["BGP_NEIGHBOR", "*", "name"], + ["BGP_NEIGHBOR", "*", "asn"], + ["BGP_NEIGHBOR", "*", "local_addr"], + ["BGP_NEIGHBOR", "*", "nhopself"], + ["BGP_NEIGHBOR", "*", "rrclient"], + ["BGP_PEER_RANGE", "*", "*"], + ["BGP_MONITORS", "*", "holdtime"], + ["BGP_MONITORS", "*", "keepalive"], + ["BGP_MONITORS", "*", "name"], + ["BGP_MONITORS", "*", "asn"], + ["BGP_MONITORS", "*", "local_addr"], + ["BGP_MONITORS", "*", "nhopself"], + ["BGP_MONITORS", "*", "rrclient"], + ["MIRROR_SESSION", "*", "*"], + ] + + def get_filter(self): + return JsonPointerFilter(self.patterns, + self.path_addressing) + +class RemoveCreateOnlyDependencyMoveValidator: + """ + A class to validate all dependencies of create-only fields have been removed before + modifying the create-only fields. + """ + def __init__(self, path_addressing): + self.path_addressing = path_addressing + self.create_only_filter = CreateOnlyFilter(path_addressing).get_filter() + + def validate(self, move, diff): + current_config = diff.current_config + target_config = diff.target_config # Final config after applying whole patch + + processed_tables = set() + for path in self.create_only_filter.get_paths(current_config): + tokens = self.path_addressing.get_path_tokens(path) + table_to_check = tokens[0] + + if table_to_check in processed_tables: + continue + else: + processed_tables.add(table_to_check) + + if table_to_check not in current_config: + continue + + current_members = current_config[table_to_check] + if not current_members: + continue + + if table_to_check not in target_config: + continue + + target_members = target_config[table_to_check] + if not target_members: + continue + + simulated_config = move.apply(current_config) # Config after applying just this move + + for member_name in current_members: + if member_name not in target_members: + continue + + if not self._validate_member(tokens, member_name, + current_config, target_config, simulated_config): + return False + + return True + + def _validate_member(self, tokens, member_name, current_config, target_config, simulated_config): + table_to_check, create_only_field = tokens[0], tokens[-1] + + current_field = self._get_create_only_field( + current_config, table_to_check, member_name, create_only_field) + target_field = self._get_create_only_field( + target_config, table_to_check, member_name, create_only_field) + + if current_field == target_field: + return True + + simulated_member = self.path_addressing.get_from_path( + simulated_config, f"/{table_to_check}/{member_name}") + + if simulated_member is None: + return True + + if table_to_check == "PORT": + current_admin_status = self.path_addressing.get_from_path( + current_config, f"/{table_to_check}/{member_name}/admin_status" + ) + simulated_admin_status = self.path_addressing.get_from_path( + simulated_config, f"/{table_to_check}/{member_name}/admin_status" + ) + if current_admin_status != simulated_admin_status and current_admin_status != "up": + return False + + member_path = f"/{table_to_check}/{member_name}" + for ref_path in self.path_addressing.find_ref_paths(member_path, simulated_config): + if not self.path_addressing.has_path(current_config, ref_path): + return False + + return True + + def _get_create_only_field(self, config, table_to_check, + member_name, create_only_field): + return config[table_to_check][member_name].get(create_only_field, None) + class DeleteWholeConfigMoveValidator: """ A class to validate not deleting whole config as it is not supported by JsonPatch lib. @@ -565,30 +684,6 @@ def validate(self, move, diff): is_valid, error = self.config_wrapper.validate_config_db_config(simulated_config) return is_valid -# TODO: Add this validation to YANG models instead -class UniqueLanesMoveValidator: - """ - A class to validate lanes and any port are unique between all ports. - """ - def validate(self, move, diff): - simulated_config = move.apply(diff.current_config) - - if "PORT" not in simulated_config: - return True - - ports = simulated_config["PORT"] - existing = set() - for port in ports: - attrs = ports[port] - if "lanes" in attrs: - lanes_str = attrs["lanes"] - lanes = lanes_str.split(", ") - for lane in lanes: - if lane in existing: - return False - existing.add(lane) - return True - class CreateOnlyMoveValidator: """ A class to validate create-only fields are only created, but never modified/updated. In other words: @@ -600,27 +695,7 @@ def __init__(self, path_addressing): self.path_addressing = path_addressing # TODO: create-only fields are hard-coded for now, it should be moved to YANG models - self.create_only_filter = JsonPointerFilter([ - ["PORT", "*", "lanes"], - ["LOOPBACK_INTERFACE", "*", "vrf_name"], - ["BGP_NEIGHBOR", "*", "holdtime"], - ["BGP_NEIGHBOR", "*", "keepalive"], - ["BGP_NEIGHBOR", "*", "name"], - ["BGP_NEIGHBOR", "*", "asn"], - ["BGP_NEIGHBOR", "*", "local_addr"], - ["BGP_NEIGHBOR", "*", "nhopself"], - ["BGP_NEIGHBOR", "*", "rrclient"], - ["BGP_PEER_RANGE", "*", "*"], - ["BGP_MONITORS", "*", "holdtime"], - ["BGP_MONITORS", "*", "keepalive"], - ["BGP_MONITORS", "*", "name"], - ["BGP_MONITORS", "*", "asn"], - ["BGP_MONITORS", "*", "local_addr"], - ["BGP_MONITORS", "*", "nhopself"], - ["BGP_MONITORS", "*", "rrclient"], - ["MIRROR_SESSION", "*", "*"], - ], - path_addressing) + self.create_only_filter = CreateOnlyFilter(path_addressing).get_filter() def validate(self, move, diff): simulated_config = move.apply(diff.current_config) @@ -945,6 +1020,8 @@ def validate(self, move, diff): for required_path, required_value in data[path]: current_value = self.identifier.get_value_or_default(current_config, required_path) simulated_value = self.identifier.get_value_or_default(simulated_config, required_path) + if simulated_value is None: # Simulated config does not have this value at all. + continue if current_value != simulated_value and simulated_value != required_value: return False @@ -1024,6 +1101,65 @@ def generate(self, diff): for move in single_run_generator.generate(): yield move +class RemoveCreateOnlyDependencyMoveGenerator: + """ + A class to generate the create-only fields' dependency removing moves + """ + def __init__(self, path_addressing): + self.path_addressing = path_addressing + self.create_only_filter = CreateOnlyFilter(path_addressing).get_filter() + + def generate(self, diff): + current_config = diff.current_config + target_config = diff.target_config # Final config after applying whole patch + + processed_tables = set() + for path in self.create_only_filter.get_paths(current_config): + tokens = self.path_addressing.get_path_tokens(path) + table_to_check, create_only_field = tokens[0], tokens[-1] + + if table_to_check in processed_tables: + continue + else: + processed_tables.add(table_to_check) + + if table_to_check not in current_config: + continue + + current_members = current_config[table_to_check] + if not current_members: + continue + + if table_to_check not in target_config: + continue + + target_members = target_config[table_to_check] + if not target_members: + continue + + for member_name in current_members: + if member_name not in target_members: + continue + + current_field = self._get_create_only_field( + current_config, table_to_check, member_name, create_only_field) + target_field = self._get_create_only_field( + target_config, table_to_check, member_name, create_only_field) + + if current_field == target_field: + continue + + member_path = f"/{table_to_check}/{member_name}" + + for ref_path in self.path_addressing.find_ref_paths(member_path, current_config): + yield JsonMove(diff, OperationType.REMOVE, + self.path_addressing.get_path_tokens(ref_path)) + + def _get_create_only_field(self, config, table_to_check, + member_name, create_only_field): + return config[table_to_check][member_name].get(create_only_field, None) + + class SingleRunLowLevelMoveGenerator: """ A class that can only run once to assist LowLevelMoveGenerator with generating the moves. @@ -1295,6 +1431,8 @@ def extend(self, move, diff): for required_path, required_value in data[path]: current_value = self.identifier.get_value_or_default(current_config, required_path) simulated_value = self.identifier.get_value_or_default(simulated_config, required_path) + if simulated_value is None: # Simulated config does not have this value at all. + continue if current_value != simulated_value and simulated_value != required_value: flip_path_value_tuples.add((required_path, required_value)) @@ -1497,7 +1635,8 @@ def __init__(self, operation_wrapper, config_wrapper, path_addressing): self.path_addressing = path_addressing def create(self, algorithm=Algorithm.DFS): - move_generators = [LowLevelMoveGenerator(self.path_addressing)] + move_generators = [RemoveCreateOnlyDependencyMoveGenerator(self.path_addressing), + LowLevelMoveGenerator(self.path_addressing)] # TODO: Enable TableLevelMoveGenerator once it is confirmed whole table can be updated at the same time move_non_extendable_generators = [KeyLevelMoveGenerator()] move_extenders = [RequiredValueMoveExtender(self.path_addressing, self.operation_wrapper), @@ -1507,9 +1646,9 @@ def create(self, algorithm=Algorithm.DFS): move_validators = [DeleteWholeConfigMoveValidator(), FullConfigMoveValidator(self.config_wrapper), NoDependencyMoveValidator(self.path_addressing, self.config_wrapper), - UniqueLanesMoveValidator(), CreateOnlyMoveValidator(self.path_addressing), RequiredValueMoveValidator(self.path_addressing), + RemoveCreateOnlyDependencyMoveValidator(self.path_addressing), NoEmptyTableMoveValidator(self.path_addressing)] move_wrapper = MoveWrapper(move_generators, move_non_extendable_generators, move_extenders, move_validators) diff --git a/generic_config_updater/services_validator.py b/generic_config_updater/services_validator.py index b059677c59..44a9e095eb 100644 --- a/generic_config_updater/services_validator.py +++ b/generic_config_updater/services_validator.py @@ -98,3 +98,6 @@ def caclmgrd_validator(old_config, upd_config, keys): # No update to ACL_RULE. return True + +def ntp_validator(old_config, upd_config, keys): + return _service_restart("ntp-config") diff --git a/pfcwd/main.py b/pfcwd/main.py index 4d3e73fb75..76fa31b4fb 100644 --- a/pfcwd/main.py +++ b/pfcwd/main.py @@ -9,6 +9,7 @@ from tabulate import tabulate from utilities_common import multi_asic as multi_asic_util from utilities_common import constants +from utilities_common.general import load_db_config from sonic_py_common import logger SYSLOG_IDENTIFIER = "config" @@ -62,7 +63,7 @@ @click.group() def cli(): """ SONiC PFC Watchdog """ - + load_db_config() def get_all_queues(db, namespace=None, display=constants.DISPLAY_ALL): queue_names = db.get_all(db.COUNTERS_DB, 'COUNTERS_QUEUE_NAME_MAP') diff --git a/scripts/aclshow b/scripts/aclshow index db0cc40ddf..db922a6cce 100755 --- a/scripts/aclshow +++ b/scripts/aclshow @@ -20,15 +20,13 @@ optional arguments: import argparse import json import os -from swsscommon.swsscommon import SonicV2Connector, ConfigDBConnector import sys +from swsscommon.swsscommon import SonicV2Connector, ConfigDBConnector +from utilities_common.cli import UserCache + from tabulate import tabulate -### temp file to save counter positions when doing clear counter action. -### if we could have a SAI command to clear counters will be better, so no need to maintain -### counters in temp loaction for clear conter action -COUNTER_POSITION = '/tmp/.counters_acl.p' COUNTERS = "COUNTERS" ACL_COUNTER_RULE_MAP = "ACL_COUNTER_RULE_MAP" @@ -38,6 +36,9 @@ ACL_HEADER = ["RULE NAME", "TABLE NAME", "PRIO", "PACKETS COUNT", "BYTES COUNT"] COUNTER_PACKETS_ATTR = "SAI_ACL_COUNTER_ATTR_PACKETS" COUNTER_BYTES_ATTR = "SAI_ACL_COUNTER_ATTR_BYTES" +USER_CACHE = UserCache() +COUNTERS_CACHE_DIR = USER_CACHE.get_directory() +COUNTERS_CACHE = os.path.join(COUNTERS_CACHE_DIR, 'aclstat') class AclStat(object): """ @@ -78,9 +79,9 @@ class AclStat(object): res[e['key'][0], e['key'][1]] = e['value'] return res - if os.path.isfile(COUNTER_POSITION): + if os.path.isfile(COUNTERS_CACHE): try: - with open(COUNTER_POSITION) as fp: + with open(COUNTERS_CACHE) as fp: self.saved_acl_counters = remap_keys(json.load(fp)) except Exception: pass @@ -207,7 +208,7 @@ class AclStat(object): def remap_keys(dict): return [{'key': k, 'value': v} for k, v in dict.items()] - with open(COUNTER_POSITION, 'w') as fp: + with open(COUNTERS_CACHE, 'w') as fp: json.dump(remap_keys(self.acl_counters), fp) def main(): diff --git a/scripts/coredump_gen_handler.py b/scripts/coredump_gen_handler.py index 03ba2de89e..55dd1ee644 100644 --- a/scripts/coredump_gen_handler.py +++ b/scripts/coredump_gen_handler.py @@ -5,18 +5,11 @@ For more info, refer to the Event Driven TechSupport & CoreDump Mgmt HLD """ import os -import time import argparse import syslog -import re from swsscommon.swsscommon import SonicV2Connector from utilities_common.auto_techsupport_helper import * -# Explicity Pass this to the subprocess invoking techsupport -ENV_VAR = os.environ -PATH_PREV = ENV_VAR["PATH"] if "PATH" in ENV_VAR else "" -ENV_VAR["PATH"] = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:" + PATH_PREV - def handle_coredump_cleanup(dump_name, db): _, num_bytes = get_stats(os.path.join(CORE_DUMP_DIR, CORE_DUMP_PTRN)) @@ -49,8 +42,6 @@ def __init__(self, core_name, container_name, db): self.core_name = core_name self.container = container_name self.db = db - self.proc_mp = {} - self.core_ts_map = {} def handle_core_dump_creation_event(self): if self.db.get(CFG_DB, AUTO_TS, CFG_STATE) != "enabled": @@ -66,112 +57,8 @@ def handle_core_dump_creation_event(self): syslog.syslog(syslog.LOG_NOTICE, msg.format(self.container, self.core_name)) return - global_cooloff = self.db.get(CFG_DB, AUTO_TS, COOLOFF) - container_cooloff = self.db.get(CFG_DB, FEATURE_KEY, COOLOFF) - - try: - global_cooloff = float(global_cooloff) - except ValueError: - global_cooloff = 0.0 - - try: - container_cooloff = float(container_cooloff) - except ValueError: - container_cooloff = 0.0 - - cooloff_passed = self.verify_rate_limit_intervals(global_cooloff, container_cooloff) - if cooloff_passed: - since_cfg = self.get_since_arg() - new_file = self.invoke_ts_cmd(since_cfg) - if new_file: - self.write_to_state_db(int(time.time()), new_file) - - def write_to_state_db(self, timestamp, ts_dump): - name = strip_ts_ext(ts_dump) - key = TS_MAP + "|" + name - self.db.set(STATE_DB, key, CORE_DUMP, self.core_name) - self.db.set(STATE_DB, key, TIMESTAMP, str(timestamp)) - self.db.set(STATE_DB, key, CONTAINER, self.container) - - def get_since_arg(self): - since_cfg = self.db.get(CFG_DB, AUTO_TS, CFG_SINCE) - if not since_cfg: - return SINCE_DEFAULT - rc, _, stderr = subprocess_exec(["date", "--date={}".format(since_cfg)], env=ENV_VAR) - if rc == 0: - return since_cfg - return SINCE_DEFAULT - - def parse_ts_dump_name(self, ts_stdout): - """ Figure out the ts_dump name from the techsupport stdout """ - matches = re.findall(TS_PTRN, ts_stdout) - if matches: - return matches[-1] - syslog.syslog(syslog.LOG_ERR, "stdout of the 'show techsupport' cmd doesn't have the dump name") - return "" - - def invoke_ts_cmd(self, since_cfg, num_retry=0): - cmd_opts = ["show", "techsupport", "--silent", "--since", since_cfg] - cmd = " ".join(cmd_opts) - rc, stdout, stderr = subprocess_exec(cmd_opts, env=ENV_VAR) - new_dump = "" - if rc == EXT_LOCKFAIL: - syslog.syslog(syslog.LOG_NOTICE, "Another instance of techsupport running, aborting this. stderr: {}".format(stderr)) - elif rc == EXT_RETRY: - if num_retry <= MAX_RETRY_LIMIT: - return self.invoke_ts_cmd(since_cfg, num_retry+1) - else: - syslog.syslog(syslog.LOG_ERR, "MAX_RETRY_LIMIT for show techsupport invocation exceeded, stderr: {}".format(stderr)) - elif rc != EXT_SUCCESS: - syslog.syslog(syslog.LOG_ERR, "show techsupport failed with exit code {}, stderr: {}".format(rc, stderr)) - else: # EXT_SUCCESS - new_dump = self.parse_ts_dump_name(stdout) # Parse the dump name - if not new_dump: - syslog.syslog(syslog.LOG_ERR, "{} was run, but no techsupport dump is found".format(cmd)) - else: - syslog.syslog(syslog.LOG_INFO, "{} is successful, {} is created".format(cmd, new_dump)) - return new_dump - - def verify_rate_limit_intervals(self, global_cooloff, container_cooloff): - """Verify both the global and per-proc rate_limit_intervals have passed""" - curr_ts_list = get_ts_dumps(True) - if global_cooloff and curr_ts_list: - last_ts_dump_creation = os.path.getmtime(curr_ts_list[-1]) - if time.time() - last_ts_dump_creation < global_cooloff: - msg = "Global rate_limit_interval period has not passed. Techsupport Invocation is skipped. Core: {}" - syslog.syslog(syslog.LOG_INFO, msg.format(self.core_name)) - return False - - self.parse_ts_map() - if container_cooloff and self.container in self.core_ts_map: - last_creation_time = self.core_ts_map[self.container][0][0] - if time.time() - last_creation_time < container_cooloff: - msg = "Per Container rate_limit_interval for {} has not passed. Techsupport Invocation is skipped. Core: {}" - syslog.syslog(syslog.LOG_INFO, msg.format(self.container, self.core_name)) - return False - return True - - def parse_ts_map(self): - """Create proc_name, ts_dump & creation_time map""" - ts_keys = self.db.keys(STATE_DB, TS_MAP+"*") - if not ts_keys: - return - for ts_key in ts_keys: - data = self.db.get_all(STATE_DB, ts_key) - if not data: - continue - container_name = data.get(CONTAINER, "") - creation_time = data.get(TIMESTAMP, "") - try: - creation_time = int(creation_time) - except Exception: - continue # if the creation time is invalid, skip the entry - ts_dump = ts_key.split("|")[-1] - if container_name and container_name not in self.core_ts_map: - self.core_ts_map[container_name] = [] - self.core_ts_map[container_name].append((int(creation_time), ts_dump)) - for container_name in self.core_ts_map: - self.core_ts_map[container_name].sort() + invoke_ts_command_rate_limited(self.db, EVENT_TYPE_CORE, {CORE_DUMP: self.core_name}, self.container) + def main(): parser = argparse.ArgumentParser(description='Auto Techsupport Invocation and CoreDump Mgmt Script') diff --git a/scripts/db_migrator.py b/scripts/db_migrator.py index e41bef1334..33060b99a1 100755 --- a/scripts/db_migrator.py +++ b/scripts/db_migrator.py @@ -8,7 +8,9 @@ import re from sonic_py_common import device_info, logger +from swsssdk import ConfigDBConnector, SonicDBConfig from swsscommon.swsscommon import SonicV2Connector, ConfigDBConnector, SonicDBConfig +from db_migrator_constants import RESTAPI, TELEMETRY, CONSOLE_SWITCH INIT_CFG_FILE = '/etc/sonic/init_cfg.json' @@ -44,7 +46,7 @@ def __init__(self, namespace, socket=None): none-zero values. build: sequentially increase within a minor version domain. """ - self.CURRENT_VERSION = 'version_2_0_5' + self.CURRENT_VERSION = 'version_3_0_5' self.TABLE_NAME = 'VERSIONS' self.TABLE_KEY = 'DATABASE' @@ -173,22 +175,39 @@ def migrate_intf_table(self): if self.appDB is None: return - data = self.appDB.keys(self.appDB.APPL_DB, "INTF_TABLE:*") - - if data is None: + # Get Lo interface corresponding to IP(v4/v6) address from CONFIG_DB. + configdb_data = self.configDB.get_keys('LOOPBACK_INTERFACE') + lo_addr_to_int = dict() + for int_data in configdb_data: + if type(int_data) == tuple and len(int_data) > 1: + intf_name = int_data[0] + intf_addr = int_data[1] + lo_addr_to_int.update({intf_addr: intf_name}) + + lo_data = self.appDB.keys(self.appDB.APPL_DB, "INTF_TABLE:*") + if lo_data is None: return if_db = [] - for key in data: - if_name = key.split(":")[1] - if if_name == "lo": - self.appDB.delete(self.appDB.APPL_DB, key) - key = key.replace(if_name, "Loopback0") - log.log_info('Migrating lo entry to ' + key) - self.appDB.set(self.appDB.APPL_DB, key, 'NULL', 'NULL') - - if '/' not in key: - if_db.append(key.split(":")[1]) + for lo_row in lo_data: + # Example of lo_row: 'INTF_TABLE:lo:10.1.0.32/32' + # Delete the old row with name as 'lo'. A new row with name as Loopback will be added + lo_name_appdb = lo_row.split(":")[1] + if lo_name_appdb == "lo": + self.appDB.delete(self.appDB.APPL_DB, lo_row) + lo_addr = lo_row.split('INTF_TABLE:lo:')[1] + lo_name_configdb = lo_addr_to_int.get(lo_addr) + if lo_name_configdb is None or lo_name_configdb == '': + # an unlikely case where a Loopback address is present in APPLDB, but + # there is no corresponding interface for this address in CONFIGDB: + # Default to legacy implementation: hardcode interface name as Loopback0 + lo_new_row = lo_row.replace(lo_name_appdb, "Loopback0") + else: + lo_new_row = lo_row.replace(lo_name_appdb, lo_name_configdb) + self.appDB.set(self.appDB.APPL_DB, lo_new_row, 'NULL', 'NULL') + + if '/' not in lo_row: + if_db.append(lo_row.split(":")[1]) continue data = self.appDB.keys(self.appDB.APPL_DB, "INTF_TABLE:*") @@ -485,6 +504,78 @@ def migrate_qos_fieldval_reference_format(self): self.migrate_qos_db_fieldval_reference_remove(qos_table_list, self.configDB, self.configDB.CONFIG_DB, '|') return True + def migrate_vxlan_config(self): + log.log_notice('Migrate VXLAN table config') + # Collect VXLAN data from config DB + vxlan_data = self.configDB.keys(self.configDB.CONFIG_DB, "VXLAN_TUNNEL*") + if not vxlan_data: + # do nothing if vxlan entries are not present in configdb + return + for vxlan_table in vxlan_data: + vxlan_map_mapping = self.configDB.get_all(self.configDB.CONFIG_DB, vxlan_table) + tunnel_keys = vxlan_table.split(self.configDB.KEY_SEPARATOR) + tunnel_keys[0] = tunnel_keys[0] + "_TABLE" + vxlan_table = self.appDB.get_db_separator(self.appDB.APPL_DB).join(tunnel_keys) + for field, value in vxlan_map_mapping.items(): + # add entries from configdb to appdb only when they are missing + if not self.appDB.hexists(self.appDB.APPL_DB, vxlan_table, field): + log.log_notice('Copying vxlan entries from configdb to appdb: updated {} with {}:{}'.format( + vxlan_table, field, value)) + self.appDB.set(self.appDB.APPL_DB, vxlan_table, field, value) + + def migrate_restapi(self): + # RESTAPI - add missing key + log.log_notice('Migrate RESTAPI configuration') + config = self.configDB.get_entry('RESTAPI', 'config') + if not config: + self.configDB.set_entry("RESTAPI", "config", RESTAPI.get("config")) + certs = self.configDB.get_entry('RESTAPI', 'certs') + if not certs: + self.configDB.set_entry("RESTAPI", "certs", RESTAPI.get("certs")) + + def migrate_telemetry(self): + # TELEMETRY - add missing key + log.log_notice('Migrate TELEMETRY configuration') + gnmi = self.configDB.get_entry('TELEMETRY', 'gnmi') + if not gnmi: + self.configDB.set_entry("TELEMETRY", "gnmi", TELEMETRY.get("gnmi")) + certs = self.configDB.get_entry('TELEMETRY', 'certs') + if not certs: + self.configDB.set_entry("TELEMETRY", "certs", TELEMETRY.get("certs")) + + def migrate_console_switch(self): + # CONSOLE_SWITCH - add missing key + log.log_notice('Migrate CONSOLE_SWITCH configuration') + console_mgmt = self.configDB.get_entry('CONSOLE_SWITCH', 'console_mgmt') + if not console_mgmt: + self.configDB.set_entry("CONSOLE_SWITCH", "console_mgmt", + CONSOLE_SWITCH.get("console_mgmt")) + + def migrate_device_metadata(self): + # DEVICE_METADATA - synchronous_mode entry + log.log_notice('Migrate DEVICE_METADATA missing configuration (synchronous_mode=enable)') + metadata = self.configDB.get_entry('DEVICE_METADATA', 'localhost') + if 'synchronous_mode' not in metadata: + metadata['synchronous_mode'] = 'enable' + self.configDB.set_entry('DEVICE_METADATA', 'localhost', metadata) + + def migrate_port_qos_map_global(self): + """ + Generate dscp_to_tc_map for switch. + """ + asics_require_global_dscp_to_tc_map = ["broadcom"] + if self.asic_type not in asics_require_global_dscp_to_tc_map: + return + dscp_to_tc_map_table_names = self.configDB.get_keys('DSCP_TO_TC_MAP') + if len(dscp_to_tc_map_table_names) == 0: + return + + qos_maps = self.configDB.get_table('PORT_QOS_MAP') + if 'global' not in qos_maps.keys(): + # We are unlikely to have more than 1 DSCP_TO_TC_MAP in previous versions + self.configDB.set_entry('PORT_QOS_MAP', 'global', {"dscp_to_tc_map": dscp_to_tc_map_table_names[0]}) + log.log_info("Created entry for global DSCP_TO_TC_MAP {}".format(dscp_to_tc_map_table_names[0])) + def version_unknown(self): """ version_unknown tracks all SONiC versions that doesn't have a version @@ -621,18 +712,51 @@ def version_1_0_6(self): def version_2_0_0(self): """ - Version 2_0_0. + Version 2_0_0 """ log.log_info('Handling version_2_0_0') - self.migrate_config_db_port_table_for_auto_neg() + self.migrate_port_qos_map_global() self.set_version('version_2_0_1') return 'version_2_0_1' def version_2_0_1(self): """ - Version 2_0_1. + Handle and migrate missing config that results from cross branch upgrade to + 202012 as target. """ log.log_info('Handling version_2_0_1') + self.migrate_vxlan_config() + self.migrate_restapi() + self.migrate_telemetry() + self.migrate_console_switch() + self.migrate_device_metadata() + + self.set_version('version_2_0_2') + return 'version_2_0_2' + + def version_2_0_2(self): + """ + Version 2_0_2 + This is the latest version for 202012 branch + """ + log.log_info('Handling version_2_0_2') + self.set_version('version_3_0_0') + return 'version_3_0_0' + + def version_3_0_0(self): + """ + Version 3_0_0. + """ + log.log_info('Handling version_3_0_0') + self.migrate_config_db_port_table_for_auto_neg() + self.set_version('version_3_0_1') + return 'version_3_0_1' + + def version_3_0_1(self): + """ + Version 3_0_1. + """ + log.log_info('Handling version_3_0_1') warmreboot_state = self.stateDB.get(self.stateDB.STATE_DB, 'WARM_RESTART_ENABLE_TABLE|system', 'enable') if warmreboot_state != 'true': @@ -640,34 +764,34 @@ def version_2_0_1(self): for name, data in portchannel_table.items(): data['lacp_key'] = 'auto' self.configDB.set_entry('PORTCHANNEL', name, data) - self.set_version('version_2_0_2') - return 'version_2_0_2' + self.set_version('version_3_0_2') + return 'version_3_0_2' - def version_2_0_2(self): + def version_3_0_2(self): """ - Version 2_0_2. + Version 3_0_2. """ - log.log_info('Handling version_2_0_2') + log.log_info('Handling version_3_0_2') self.migrate_qos_fieldval_reference_format() - self.set_version('version_2_0_3') - return 'version_2_0_3' + self.set_version('version_3_0_3') + return 'version_3_0_3' - def version_2_0_3(self): + def version_3_0_3(self): """ - Version 2_0_3 + Version 3_0_3 """ - log.log_info('Handling version_2_0_3') + log.log_info('Handling version_3_0_3') if self.asic_type == "mellanox": self.mellanox_buffer_migrator.mlnx_reclaiming_unused_buffer() - self.set_version('version_2_0_4') - return 'version_2_0_4' + self.set_version('version_3_0_4') + return 'version_3_0_4' - def version_2_0_4(self): + def version_3_0_4(self): """ - Version 2_0_4 + Version 3_0_4 """ - log.log_info('Handling version_2_0_4') + log.log_info('Handling version_3_0_4') # Migrate "pfc_enable" to "pfc_enable" and "pfcwd_sw_enable" # 1. pfc_enable means enable pfc on certain queues # 2. pfcwd_sw_enable means enable PFC software watchdog on certain queues @@ -677,14 +801,14 @@ def version_2_0_4(self): if 'pfc_enable' in v: v['pfcwd_sw_enable'] = v['pfc_enable'] self.configDB.set_entry('PORT_QOS_MAP', k, v) + self.set_version('version_3_0_5') + return 'version_3_0_5' - return 'version_2_0_5' - - def version_2_0_5(self): + def version_3_0_5(self): """ Current latest version. Nothing to do here. """ - log.log_info('Handling version_2_0_5') + log.log_info('Handling version_3_0_5') return None def get_version(self): @@ -720,7 +844,8 @@ def common_migration_ops(self): new_cfg = {**init_cfg, **curr_cfg} self.configDB.set_entry(init_cfg_table, key, new_cfg) - self.migrate_copp_table() + if self.asic_type != "mellanox": + self.migrate_copp_table() if self.asic_type == "broadcom" and 'Force10-S6100' in self.hwsku: self.migrate_mgmt_ports_on_s6100() else: diff --git a/scripts/db_migrator_constants.py b/scripts/db_migrator_constants.py new file mode 100644 index 0000000000..71237a5655 --- /dev/null +++ b/scripts/db_migrator_constants.py @@ -0,0 +1,32 @@ +RESTAPI = { + "config": { + "client_auth": "true", + "log_level": "info", + "allow_insecure": "false" + }, + "certs": { + "server_key": "/etc/sonic/credentials/restapiserver.key", + "ca_crt": "/etc/sonic/credentials/AME_ROOT_CERTIFICATE.pem", + "server_crt": "/etc/sonic/credentials/restapiserver.crt", + "client_crt_cname": "client.restapi.sonic.gbl" + } + } + +TELEMETRY = { + "gnmi": { + "client_auth": "true", + "log_level": "2", + "port": "50051" + }, + "certs": { + "server_key": "/etc/sonic/telemetry/streamingtelemetryserver.key", + "ca_crt": "/etc/sonic/telemetry/dsmsroot.cer", + "server_crt": "/etc/sonic/telemetry/streamingtelemetryserver.cer" + } +} + +CONSOLE_SWITCH = { + "console_mgmt": { + "enabled": "no" + } +} diff --git a/scripts/decode-syseeprom b/scripts/decode-syseeprom index eeb38306b0..3d0b8d1db9 100755 --- a/scripts/decode-syseeprom +++ b/scripts/decode-syseeprom @@ -228,8 +228,6 @@ def main(): (opts, args) = get_cmdline_opts() - use_db = opts.db and support_eeprom_db - # Get platform name platform = device_info.get_platform() @@ -238,6 +236,8 @@ def main(): if any(re.match(p, platform) for p in platforms_without_eeprom_db): support_eeprom_db = False + use_db = opts.db and support_eeprom_db + if opts.mgmtmac: print_mgmt_mac(use_db) elif opts.serial: diff --git a/scripts/dropstat b/scripts/dropstat index 6766d2a2c1..f98fc29197 100755 --- a/scripts/dropstat +++ b/scripts/dropstat @@ -35,6 +35,7 @@ except KeyError: pass from swsscommon.swsscommon import SonicV2Connector, ConfigDBConnector +from utilities_common.cli import UserCache # COUNTERS_DB Tables @@ -80,8 +81,7 @@ std_switch_description_header = ['DEVICE'] def get_dropstat_dir(): - dropstat_dir_prefix = '/tmp/dropstat' - return "{}-{}/".format(dropstat_dir_prefix, os.getuid()) + return UserCache().get_directory() class DropStat(object): @@ -411,18 +411,7 @@ Examples: group = args.group counter_type = args.type - dropstat_dir = get_dropstat_dir() - - # Create the directory to hold clear results - if not os.path.exists(dropstat_dir): - try: - os.makedirs(dropstat_dir) - except IOError as e: - print(e) - sys.exit(e.errno) - dcstat = DropStat() - if command == 'clear': dcstat.clear_drop_counts() elif command == 'show': diff --git a/scripts/fabricstat b/scripts/fabricstat new file mode 100755 index 0000000000..18200785ff --- /dev/null +++ b/scripts/fabricstat @@ -0,0 +1,217 @@ +#!/usr/bin/env python3 + +import argparse +from collections import OrderedDict, namedtuple +import os +import sys + +from utilities_common import constants +from natsort import natsorted +from tabulate import tabulate +from sonic_py_common import multi_asic +from swsscommon.swsscommon import APP_FABRIC_PORT_TABLE_NAME, COUNTERS_TABLE, COUNTERS_FABRIC_PORT_NAME_MAP, COUNTERS_FABRIC_QUEUE_NAME_MAP +import utilities_common.multi_asic as multi_asic_util + +# mock the redis for unit test purposes # +try: + if os.environ["UTILITIES_UNIT_TESTING"] == "2": + modules_path = os.path.join(os.path.dirname(__file__), "..") + tests_path = os.path.join(modules_path, "tests") + sys.path.insert(0, modules_path) + sys.path.insert(0, tests_path) + import mock_tables.dbconnector + if os.environ["UTILITIES_UNIT_TESTING_TOPOLOGY"] == "multi_asic": + import mock_tables.mock_multi_asic + mock_tables.dbconnector.load_namespace_config() +except KeyError: + pass + +PORT_NAME_PREFIX = 'PORT' +COUNTER_TABLE_PREFIX = COUNTERS_TABLE+":" +FABRIC_PORT_STATUS_TABLE_PREFIX = APP_FABRIC_PORT_TABLE_NAME+"|" +FABRIC_PORT_STATUS_FIELD = "STATUS" +STATUS_NA = 'N/A' + +class FabricStat(object): + def __init__(self, namespace): + self.db = None + self.namespace = namespace + self.multi_asic = multi_asic_util.MultiAsic(constants.DISPLAY_ALL, namespace) + + def get_cnstat_dict(self): + self.cnstat_dict = OrderedDict() + self.collect_stat() + return self.cnstat_dict + + @multi_asic_util.run_on_multi_asic + def collect_stat(self): + """ + Collect the statisitics from all the asics present on the + device and store in a dict + """ + self.cnstat_dict.update(self.get_cnstat()) + + def get_port_state(self, port_name): + """ + Get the port state + """ + full_table_id = FABRIC_PORT_STATUS_TABLE_PREFIX + port_name + oper_state = self.db.get(self.db.STATE_DB, full_table_id, FABRIC_PORT_STATUS_FIELD) + if oper_state is not None: + return oper_state + return STATUS_NA + + def get_counters(self, counter_bucket_dict, table_id): + fields = ["0"] * len(counter_bucket_dict) + for pos, counter_name in counter_bucket_dict.items(): + full_table_id = COUNTER_TABLE_PREFIX + table_id + counter_data = self.db.get(self.db.COUNTERS_DB, full_table_id, counter_name) + if counter_data is None: + fields[pos] = STATUS_NA + elif fields[pos] != STATUS_NA: + fields[pos] = str(int(fields[pos]) + int(counter_data)) + return fields + + def get_cnstat(self): + """ + Get the counters info from database. + """ + assert False, 'Need to override this method' + + def cnstat_print(self, cnstat_dict, errors_only=False): + """ + Print the counter stat. + """ + assert False, 'Need to override this method' + +PortStat = namedtuple("PortStat", "in_cell, in_octet, out_cell, out_octet,\ + crc, fec_correctable, fec_uncorrectable, symbol_err") +port_counter_bucket_list = [ + 'SAI_PORT_STAT_IF_IN_FABRIC_DATA_UNITS', + 'SAI_PORT_STAT_IF_IN_OCTETS', + 'SAI_PORT_STAT_IF_OUT_FABRIC_DATA_UNITS', + 'SAI_PORT_STAT_IF_OUT_OCTETS', + 'SAI_PORT_STAT_IF_IN_ERRORS', + 'SAI_PORT_STAT_IF_IN_FEC_CORRECTABLE_FRAMES', + 'SAI_PORT_STAT_IF_IN_FEC_NOT_CORRECTABLE_FRAMES', + 'SAI_PORT_STAT_IF_IN_FEC_SYMBOL_ERRORS', + ] +port_counter_bucket_dict = {k : v for k, v in enumerate(port_counter_bucket_list)} + +portstat_header_all = ['ASIC', 'PORT', 'STATE', + 'IN_CELL', 'IN_OCTET', 'OUT_CELL', 'OUT_OCTET', + 'CRC', 'FEC_CORRECTABLE', 'FEC_UNCORRECTABLE', 'SYMBOL_ERR'] +portstat_header_errors_only = ['ASIC', 'PORT', 'STATE', + 'CRC', 'FEC_CORRECTABLE', 'FEC_UNCORRECTABLE', 'SYMBOL_ERR'] + +class FabricPortStat(FabricStat): + def get_cnstat(self): + counter_port_name_map = self.db.get_all(self.db.COUNTERS_DB, COUNTERS_FABRIC_PORT_NAME_MAP) + cnstat_dict = OrderedDict() + if counter_port_name_map is None: + return cnstat_dict + for port_name in natsorted(counter_port_name_map): + cntr = self.get_counters(port_counter_bucket_dict, counter_port_name_map[port_name]) + cnstat_dict[port_name] = PortStat._make(cntr) + return cnstat_dict + + def cnstat_print(self, cnstat_dict, errors_only=False): + if len(cnstat_dict) == 0: + print("Counters %s empty" % self.namespace) + return + + table = [] + header = None + asic = multi_asic.get_asic_id_from_name(self.namespace) + for key, data in cnstat_dict.items(): + port_id = key[len(PORT_NAME_PREFIX):] + if errors_only: + header = portstat_header_errors_only + table.append((asic, port_id, self.get_port_state(key), + data.crc, data.fec_correctable, data.fec_uncorrectable, + data.symbol_err)) + else: + header = portstat_header_all + table.append((asic, port_id, self.get_port_state(key), + data.in_cell, data.in_octet, data.out_cell, data.out_octet, + data.crc, data.fec_correctable, data.fec_uncorrectable, + data.symbol_err)) + + print(tabulate(table, header, tablefmt='simple', stralign='right')) + print() + +QueueStat = namedtuple("QueueStat", "curlevel, watermarklevel, curbyte") + +queue_counter_bucket_list = [ + 'SAI_QUEUE_STAT_CURR_OCCUPANCY_LEVEL', + 'SAI_QUEUE_STAT_WATERMARK_LEVEL', + 'SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES', +] +queue_counter_bucket_dict = {k : v for k, v in enumerate(queue_counter_bucket_list)} + +queuestat_header = ['ASIC', 'PORT', 'STATE', 'QUEUE_ID', 'CURRENT_BYTE', 'CURRENT_LEVEL', 'WATERMARK_LEVEL'] + +class FabricQueueStat(FabricStat): + def get_cnstat(self): + counter_queue_name_map = self.db.get_all(self.db.COUNTERS_DB, COUNTERS_FABRIC_QUEUE_NAME_MAP) + cnstat_dict = OrderedDict() + if counter_queue_name_map is None: + return cnstat_dict + for port_queue_name in natsorted(counter_queue_name_map): + cntr = self.get_counters(queue_counter_bucket_dict, counter_queue_name_map[port_queue_name]) + cnstat_dict[port_queue_name] = QueueStat._make(cntr) + return cnstat_dict + + def cnstat_print(self, cnstat_dict, errors_only=False): + if len(cnstat_dict) == 0: + print("Counters %s empty" % self.namespace) + return + + table = [] + asic = multi_asic.get_asic_id_from_name(self.namespace) + for key, data in cnstat_dict.items(): + port_name, queue_id = key.split(':') + port_id = port_name[len(PORT_NAME_PREFIX):] + table.append((asic, port_id, self.get_port_state(port_name), queue_id, + data.curbyte, data.curlevel, data.watermarklevel)) + + print(tabulate(table, queuestat_header, tablefmt='simple', stralign='right')) + print() + +def main(): + parser = argparse.ArgumentParser(description='Display the fabric port state and counters', + formatter_class=argparse.RawTextHelpFormatter, + epilog=""" +Examples: + fabricstat + fabricstat --namespace asic0 + fabricstat -p -n asic0 -e + fabricstat -q + fabricstat -q -n asic0 +""") + + parser.add_argument('-q','--queue', action='store_true', help='Display fabric queue stat, otherwise port stat') + parser.add_argument('-n','--namespace', default=None, help='Display fabric ports counters for specific namespace') + parser.add_argument('-e', '--errors', action='store_true', help='Display errors') + + args = parser.parse_args() + queue = args.queue + namespace = args.namespace + errors_only = args.errors + + def nsStat(ns, errors_only): + stat = FabricQueueStat(ns) if queue else FabricPortStat(ns) + cnstat_dict = stat.get_cnstat_dict() + stat.cnstat_print(cnstat_dict, errors_only) + + if namespace is None: + # All asics or all fabric asics + multi_asic = multi_asic_util.MultiAsic() + for ns in multi_asic.get_ns_list_based_on_options(): + nsStat(ns, errors_only) + else: + # Asic with namespace + nsStat(namespace, errors_only) + +if __name__ == "__main__": + main() diff --git a/scripts/fast-reboot b/scripts/fast-reboot index 5749e3745a..d81f9d8188 100755 --- a/scripts/fast-reboot +++ b/scripts/fast-reboot @@ -40,8 +40,6 @@ EXIT_FILE_SYSTEM_FULL=3 EXIT_NEXT_IMAGE_NOT_EXISTS=4 EXIT_ORCHAGENT_SHUTDOWN=10 EXIT_SYNCD_SHUTDOWN=11 -EXIT_FAST_REBOOT_DUMP_FAILURE=12 -EXIT_FILTER_FDB_ENTRIES_FAILURE=13 EXIT_COUNTERPOLL_DELAY_FAILURE=14 EXIT_DB_INTEGRITY_FAILURE=15 EXIT_NO_CONTROL_PLANE_ASSISTANT=20 @@ -125,26 +123,16 @@ function parseOptions() done } -function common_clear() +function clear_boot() { + # common_clear debug "${REBOOT_TYPE} failure ($?) cleanup ..." /sbin/kexec -u || /bin/true teardown_control_plane_assistant -} - -function clear_fast_boot() -{ - common_clear - - sonic-db-cli STATE_DB DEL "FAST_REBOOT|system" &>/dev/null || /bin/true -} - -function clear_warm_boot() -{ - common_clear + #clear_warm_boot result=$(timeout 10s config warm_restart disable; res=$?; if [[ $res == 124 ]]; then echo timeout; else echo "code ($res)"; fi) || /bin/true debug "Cancel warm-reboot: ${result}" @@ -152,6 +140,11 @@ function clear_warm_boot() if [[ -f ${WARM_DIR}/${REDIS_FILE} ]]; then mv -f ${WARM_DIR}/${REDIS_FILE} ${WARM_DIR}/${REDIS_FILE}.${TIMESTAMP} || /bin/true fi + + #clear_fast_boot + if [[ "$REBOOT_TYPE" = "fast-reboot" ]]; then + sonic-db-cli STATE_DB DEL "FAST_REBOOT|system" &>/dev/null || /bin/true + fi } function init_warm_reboot_states() @@ -159,7 +152,7 @@ function init_warm_reboot_states() # If the current running instance was booted up with warm reboot. Then # the current DB contents will likely mark warm reboot is done. # Clear these states so that the next boot up image won't get confused. - if [[ "$REBOOT_TYPE" = "warm-reboot" || "$REBOOT_TYPE" = "fastfast-reboot" ]]; then + if [[ "$REBOOT_TYPE" = "warm-reboot" || "$REBOOT_TYPE" = "fastfast-reboot" || "$REBOOT_TYPE" = "fast-reboot" ]]; then sonic-db-cli STATE_DB eval " for _, key in ipairs(redis.call('keys', 'WARM_RESTART_TABLE|*')) do redis.call('hdel', key, 'state') @@ -266,7 +259,8 @@ function backup_database() and not string.match(k, 'FG_ROUTE_TABLE|') \ and not string.match(k, 'WARM_RESTART_ENABLE_TABLE|') \ and not string.match(k, 'VXLAN_TUNNEL_TABLE|') \ - and not string.match(k, 'BUFFER_MAX_PARAM_TABLE|') then + and not string.match(k, 'BUFFER_MAX_PARAM_TABLE|') \ + and not string.match(k, 'FAST_REBOOT|') then redis.call('del', k) end end @@ -371,7 +365,7 @@ function check_docker_exec() function check_db_integrity() { - if [[ "$REBOOT_TYPE" = "warm-reboot" || "$REBOOT_TYPE" = "fastfast-reboot" ]]; then + if [[ "$REBOOT_TYPE" = "warm-reboot" || "$REBOOT_TYPE" = "fastfast-reboot" || "$REBOOT_TYPE" = "fast-reboot" ]]; then CHECK_DB_INTEGRITY=0 /usr/local/bin/check_db_integrity.py || CHECK_DB_INTEGRITY=$? if [[ CHECK_DB_INTEGRITY -ne 0 ]]; then @@ -452,21 +446,13 @@ function unload_kernel() } function save_counters_folder() { - debug "Saving counters folder before warmboot..." - - counters_folder="/host/counters" - if [[ ! -d $counters_folder ]]; then - mkdir $counters_folder - fi - if [[ "$REBOOT_TYPE" = "warm-reboot" || "$REBOOT_TYPE" = "fastfast-reboot" ]]; then - modules=("portstat-0" "dropstat" "pfcstat-0" "queuestat-0" "intfstat-0") - for module in ${modules[@]} - do - statfile="/tmp/$module" - if [[ -d $statfile ]]; then - cp -rf $statfile $counters_folder - fi - done + if [[ "$REBOOT_TYPE" = "warm-reboot" ]]; then + debug "Saving counters folder before warmboot..." + counters_folder="/host/counters" + if [[ ! -d $counters_folder ]]; then + mkdir $counters_folder + fi + cp -rf /tmp/cache $counters_folder fi } @@ -530,9 +516,11 @@ sonic_asic_type=$(sonic-cfggen -y /etc/sonic/sonic_version.yml -v asic_type) BOOT_TYPE_ARG="cold" case "$REBOOT_TYPE" in "fast-reboot") + check_warm_restart_in_progress BOOT_TYPE_ARG=$REBOOT_TYPE - trap clear_fast_boot EXIT HUP INT QUIT TERM KILL ABRT ALRM - sonic-db-cli STATE_DB SET "FAST_REBOOT|system" "1" "EX" "180" &>/dev/null + trap clear_boot EXIT HUP INT QUIT TERM KILL ABRT ALRM + sonic-db-cli STATE_DB SET "FAST_REBOOT|system" "1" "EX" "210" &>/dev/null + config warm_restart enable system ;; "warm-reboot") check_warm_restart_in_progress @@ -545,7 +533,7 @@ case "$REBOOT_TYPE" in else BOOT_TYPE_ARG="warm" fi - trap clear_warm_boot EXIT HUP INT QUIT TERM KILL ABRT ALRM + trap clear_boot EXIT HUP INT QUIT TERM KILL ABRT ALRM config warm_restart enable system ;; *) @@ -603,34 +591,11 @@ else load_kernel fi -if [[ "$REBOOT_TYPE" = "fast-reboot" ]]; then - # Dump the ARP and FDB tables to files also as default routes for both IPv4 and IPv6 - # into /host/fast-reboot - DUMP_DIR=/host/fast-reboot - mkdir -p $DUMP_DIR - FAST_REBOOT_DUMP_RC=0 - /usr/local/bin/fast-reboot-dump.py -t $DUMP_DIR || FAST_REBOOT_DUMP_RC=$? - if [[ FAST_REBOOT_DUMP_RC -ne 0 ]]; then - error "Failed to run fast-reboot-dump.py. Exit code: $FAST_REBOOT_DUMP_RC" - unload_kernel - exit "${EXIT_FAST_REBOOT_DUMP_FAILURE}" - fi - - FILTER_FDB_ENTRIES_RC=0 - # Filter FDB entries using MAC addresses from ARP table - /usr/local/bin/filter_fdb_entries -f $DUMP_DIR/fdb.json -a $DUMP_DIR/arp.json -c $CONFIG_DB_FILE || FILTER_FDB_ENTRIES_RC=$? - if [[ FILTER_FDB_ENTRIES_RC -ne 0 ]]; then - error "Failed to filter FDb entries. Exit code: $FILTER_FDB_ENTRIES_RC" - unload_kernel - exit "${EXIT_FILTER_FDB_ENTRIES_FAILURE}" - fi -fi - init_warm_reboot_states setup_control_plane_assistant -if [[ "$REBOOT_TYPE" = "warm-reboot" || "$REBOOT_TYPE" = "fastfast-reboot" ]]; then +if [[ "$REBOOT_TYPE" = "warm-reboot" || "$REBOOT_TYPE" = "fastfast-reboot" || "$REBOOT_TYPE" = "fast-reboot" ]]; then # Freeze orchagent for warm restart # Ask orchagent_restart_check to try freeze 5 times with interval of 2 seconds, # it is possible that the orchagent is in transient state and no opportunity to freeze @@ -662,6 +627,17 @@ fi # service will go down and we cannot recover from it. set +e +if [[ "$REBOOT_TYPE" = "fast-reboot" ]]; then + # Clear all routes except of default routes for faster reconciliation time. + sonic-db-cli APPL_DB eval " + for _, k in ipairs(redis.call('keys', '*')) do + if string.match(k, 'ROUTE_TABLE:') and not string.match(k, 'ROUTE_TABLE:0.0.0.0/0') and not string.match(k, 'ROUTE_TABLE:::/0') then \ + redis.call('del', k) + end + end + " 0 > /dev/null +fi + # disable trap-handlers which were set before trap '' EXIT HUP INT QUIT TERM KILL ABRT ALRM @@ -686,6 +662,12 @@ else fi for service in ${SERVICES_TO_STOP}; do + # Skip the masked services + state=$(systemctl is-enabled ${service}) + if [[ $state == "masked" ]]; then + continue + fi + debug "Stopping ${service} ..." # TODO: These exceptions for nat, sflow, lldp @@ -723,41 +705,22 @@ for service in ${SERVICES_TO_STOP}; do if [[ "x$sonic_asic_type" == x"mellanox" ]]; then check_issu_bank_file fi + fi - # Warm reboot: dump state to host disk - if [[ "$REBOOT_TYPE" = "fastfast-reboot" ]]; then - sonic-db-cli ASIC_DB FLUSHDB > /dev/null - sonic-db-cli COUNTERS_DB FLUSHDB > /dev/null - sonic-db-cli FLEX_COUNTER_DB FLUSHDB > /dev/null - fi - - # TODO: backup_database preserves FDB_TABLE - # need to cleanup as well for fastfast boot case - backup_database + if [[ "$REBOOT_TYPE" = "fastfast-reboot" || "$REBOOT_TYPE" = "fast-reboot" ]]; then + # Advanced reboot: dump state to host disk + sonic-db-cli ASIC_DB FLUSHDB > /dev/null + sonic-db-cli COUNTERS_DB FLUSHDB > /dev/null + sonic-db-cli FLEX_COUNTER_DB FLUSHDB > /dev/null fi + + # TODO: backup_database preserves FDB_TABLE + # need to cleanup as well for fastfast boot case + backup_database + fi done -# Kill other containers to make the reboot faster -# We call `docker kill ...` to ensure the container stops as quickly as possible, -# then immediately call `systemctl stop ...` to prevent the service from -# restarting the container automatically. -debug "Stopping all remaining containers ..." -if test -f /usr/local/bin/ctrmgr_tools.py -then - /usr/local/bin/ctrmgr_tools.py kill-all -else - for CONTAINER_NAME in $(docker ps --format '{{.Names}}'); do - CONTAINER_STOP_RC=0 - docker kill $CONTAINER_NAME &> /dev/null || CONTAINER_STOP_RC=$? - systemctl stop $CONTAINER_NAME || debug "Ignore stopping $CONTAINER_NAME error $?" - if [[ CONTAINER_STOP_RC -ne 0 ]]; then - debug "Failed killing container $CONTAINER_NAME RC $CONTAINER_STOP_RC ." - fi - done -fi -debug "Stopped all remaining containers ..." - # Stop the docker container engine. Otherwise we will have a broken docker storage systemctl stop docker.service || debug "Ignore stopping docker service error $?" diff --git a/scripts/flow_counters_stat b/scripts/flow_counters_stat index 61c754e333..ac5ef94beb 100755 --- a/scripts/flow_counters_stat +++ b/scripts/flow_counters_stat @@ -27,6 +27,7 @@ import utilities_common.multi_asic as multi_asic_util from flow_counter_util.route import build_route_pattern, extract_route_pattern, exit_if_route_flow_counter_not_support, DEFAULT_VRF, COUNTERS_ROUTE_TO_PATTERN_MAP from utilities_common import constants from utilities_common.netstat import format_number_with_comma, table_as_json, ns_diff, format_prate +from utilities_common.cli import UserCache # Flow counter meta data, new type of flow counters can extend this dictinary to reuse existing logic flow_counter_meta = { @@ -57,9 +58,10 @@ class FlowCounterStats(object): meta_data = flow_counter_meta[args.type] self.name_map = meta_data['name_map'] self.headers = meta_data['headers'] - self.data_file = os.path.join('/tmp/{}-stats-{}'.format(args.type, os.getuid())) - if self.args.delete and os.path.exists(self.data_file): - os.remove(self.data_file) + self.cache = UserCache() + self.data_file = os.path.join(self.cache.get_directory(), "flow-counter-stats") + if self.args.delete: + self.cache.remove() self.data = {} def show(self): diff --git a/scripts/generate_dump b/scripts/generate_dump index 9223314955..9e42cc7f1c 100755 --- a/scripts/generate_dump +++ b/scripts/generate_dump @@ -527,6 +527,40 @@ save_bgp_neighbor() { done } +############################################################################### +# Iterates all EVPN neighbors and runs save_vtysh to save each neighbor's +# advertised-routes and received-routes +# On multi ASIC platform, collects information from all namespaces +# Globals: +# None +# Arguments: +# Optional arg namespace +# Returns: +# None +############################################################################### +save_bgp_evpn_neighbor() { + trap 'handle_error $? $LINENO' ERR + local timeout_cmd="timeout --foreground ${TIMEOUT_MIN}m" + local asic_id=${1:-""} + local ns=$(get_vtysh_namespace $asic_id) + + evpn_neighbors=$(${timeout_cmd} bash -c "vtysh -c 'show bgp l2vpn evpn summary' | cut -d ' ' -f1") + local parse_neighbors=false + for word in $evpn_neighbors; do + if [[ $word == "Neighbor" ]]; then + parse_neighbors=true + continue + elif [[ $word == "Total" ]]; then + parse_neighbors=false + continue + fi + if [ "$parse_neighbors" = true ]; then + save_cmd "vtysh $ns -c \"show bgp l2vpn evpn neighbors $word advertised-routes\"" "bgp.evpn.neighbor.$word.adv$asic_id" + save_cmd "vtysh $ns -c \"show bgp l2vpn evpn neighbors $word routes\"" "bgp.evpn.neighbor.$word.rcv$asic_id" + fi + done +} + ############################################################################### # Iterates all ASIC namespaces on multi ASIC platform and on default (host) # namespace on single ASIC platform @@ -549,6 +583,28 @@ save_bgp_neighbor_all_ns() { fi } +############################################################################### +# Iterates all ASIC namespaces on multi ASIC platform and on default (host) +# namespace on single ASIC platform +# Globals: +# NUM_ASICS +# Arguments: +# None +# Returns: +# None +############################################################################### +save_bgp_evpn_neighbor_all_ns() { + trap 'handle_error $? $LINENO' ERR + if [[ ( "$NUM_ASICS" == 1 ) ]] ; then + save_bgp_evpn_neighbor + else + for (( i=0; i<$NUM_ASICS; i++ )) + do + save_bgp_evpn_neighbor $i + done + fi +} + ############################################################################### # Dump the nat config, iptables rules and conntrack nat entries # Globals: @@ -624,6 +680,23 @@ save_bgp_info() { save_bgp_neighbor_all_ns } +############################################################################### +# Save EVPN related info +# Globals: +# None +# Arguments: +# None +# Returns: +# None +############################################################################### +save_evpn_info() { + trap 'handle_error $? $LINENO' ERR + save_vtysh "show bgp l2vpn evpn" "bgp.l2vpn.evpn" + save_vtysh "show bgp l2vpn evpn route detail" "bgp.evpn.route" + save_vtysh "show evpn vni detail" "bgp.evpn.vni" + save_vtysh "show evpn arp-cache vni all" "bgp.evpn.arp" + save_bgp_evpn_neighbor_all_ns +} ############################################################################### # Save FRR related info # Globals: @@ -866,6 +939,49 @@ enable_logrotate() { sed -i '/\/usr\/sbin\/logrotate/s/^#*//g' /etc/cron.d/logrotate } +############################################################################### +# Create a relative symbolic link of an existing file +# Globals: +# BASE +# MKDIR +# TAR +# TARFILE +# DUMPDIR +# V +# RM +# NOOP +# Arguments: +# filename: the full path of the file +# dest_dir: destination dir where the link is created +# src_sir: directory under $TARDIR where the actual file exists +# Returns: +# None +############################################################################### +save_symlink() { + trap 'handle_error $? $LINENO' ERR + local start_t=$(date +%s%3N) + local end_t=0 + local filename=$1 + local dest_dir=$2 + local src_dir=$3 + local do_tar_append=${4:-true} + local file_basename=$(basename $filename) + local tar_path="$BASE/$dest_dir/$file_basename" + + $MKDIR $V -p "$TARDIR/$dest_dir" + + ${CMD_PREFIX}pushd $TARDIR/$dest_dir + ${CMD_PREFIX}ln -s ../$src_dir/$file_basename $file_basename + ${CMD_PREFIX}popd + + if $do_tar_append; then + ($TAR $V -rf $TARFILE -C $DUMPDIR "$tar_path" \ + || abort "${EXT_PROCFS_SAVE_FAILED}" "tar append operation failed. Aborting to prevent data loss.") \ + && $RM $V -f "$DUMPDIR/$tar_path" + fi + end_t=$(date +%s%3N) + echo "[ save_symlink:$filename] : $(($end_t-$start_t)) msec" >> $TECHSUPPORT_TIME_INFO +} ############################################################################### # Collect Mellanox specific information @@ -885,6 +1001,10 @@ collect_mellanox() { ${CMD_PREFIX}docker exec syncd mkdir -p $sai_dump_folder ${CMD_PREFIX}docker exec syncd saisdkdump -f $sai_dump_filename + if [ $? != 0 ]; then + echo "Failed to collect saisdkdump." + fi + copy_from_docker syncd $sai_dump_folder $sai_dump_folder echo "$sai_dump_folder" for file in `ls $sai_dump_folder`; do @@ -894,16 +1014,6 @@ collect_mellanox() { ${CMD_PREFIX}rm -rf $sai_dump_folder ${CMD_PREFIX}docker exec syncd rm -rf $sai_dump_folder - # Save SDK error dumps - local sdk_dump_path=`${CMD_PREFIX}docker exec syncd cat /tmp/sai.profile|grep "SAI_DUMP_STORE_PATH"|cut -d = -f2` - if [[ -d $sdk_dump_path ]]; then - copy_from_docker syncd $sdk_dump_path /tmp/sdk-dumps - for file in $(find /tmp/sdk-dumps -type f); do - save_file ${file} sai_sdk_dump false - done - rm -rf /tmp/sdk-dumps - fi - # run 'hw-management-generate-dump.sh' script and save the result file HW_DUMP_FILE=/usr/bin/hw-management-generate-dump.sh if [ -f "$HW_DUMP_FILE" ]; then @@ -925,6 +1035,53 @@ collect_mellanox() { } +############################################################################### +# Collect dfw dumps if any. Applies to only MLNX platform +# Globals: +# CMD_PREFIX +# Arguments: +# None +# Returns: +# None +############################################################################### +collect_mellanox_dfw_dumps() { + trap 'handle_error $? $LINENO' ERR + local platform=$(python3 -c "from sonic_py_common import device_info; print(device_info.get_platform())") + local hwsku=$(python3 -c "from sonic_py_common import device_info; print(device_info.get_hwsku())") + local sdk_dump_path=`cat /usr/share/sonic/device/${platform}/${hwsku}/sai.profile|grep "SAI_DUMP_STORE_PATH"|cut -d = -f2` + + if [[ ! -d $sdk_dump_path ]]; then + # This would mean the SAI_DUMP_STORE_PATH is not mounted on the host and is only accessible though the container + # This is a bad design and not recommended But there is nothing which restricts against it and thus the special handling + if [[ "$( docker container inspect -f '{{.State.Running}}' syncd )" == "true" ]]; then + $RM $V -rf /tmp/dfw-sdk-dumps + $MKDIR $V -p /tmp/dfw-sdk-dumps + copy_from_docker syncd $sdk_dump_path /tmp/dfw-sdk-dumps + else + echo "ERROR: dfw dumps cannot be collected" + fi + sdk_dump_path="/tmp/dfw-sdk-dumps" + fi + + for file in $(find_files "$sdk_dump_path"); do + if $TAR -tf $TARFILE | grep $BASE/log/$(basename $file); then + # If this path sits under "/var/log/" dir, the files + # would've already been collected and thus just add a sym link + if [ ! -z "${file##*.gz}" ]; then + # files saved under log/ are zipped with gz + file=$file.gz + fi + ${CMD_PREFIX}save_symlink ${file} sai_sdk_dump log + else + if [ ! -z "${file##*.gz}" ]; then + ${CMD_PREFIX}save_file ${file} sai_sdk_dump true + else + ${CMD_PREFIX}save_file ${file} sai_sdk_dump false + fi + fi + done +} + ############################################################################### # Collect Broadcom specific information # Globals: @@ -985,33 +1142,109 @@ collect_broadcom() { save_bcmcmd_all_ns "-t5 version" "broadcom.version" save_bcmcmd_all_ns "-t5 soc" "broadcom.soc" save_bcmcmd_all_ns "-t5 ps" "broadcom.ps" - save_bcmcmd_all_ns "\"l3 nat_ingress show\"" "broadcom.nat.ingress" - save_bcmcmd_all_ns "\"l3 nat_egress show\"" "broadcom.nat.egress" - save_bcmcmd_all_ns "\"ipmc table show\"" "broadcom.ipmc" - save_bcmcmd_all_ns "\"multicast show\"" "broadcom.multicast" - save_bcmcmd_all_ns "\"conf show\"" "conf.summary" - save_bcmcmd_all_ns "\"fp show\"" "fp.summary" - save_bcmcmd_all_ns "\"pvlan show\"" "pvlan.summary" - save_bcmcmd_all_ns "\"l2 show\"" "l2.summary" - save_bcmcmd_all_ns "\"l3 intf show\"" "l3.intf.summary" - save_bcmcmd_all_ns "\"l3 defip show\"" "l3.defip.summary" - save_bcmcmd_all_ns "\"l3 l3table show\"" "l3.l3table.summary" - save_bcmcmd_all_ns "\"l3 egress show\"" "l3.egress.summary" - save_bcmcmd_all_ns "\"l3 ecmp egress show\"" "l3.ecmp.egress.summary" - save_bcmcmd_all_ns "\"l3 multipath show\"" "l3.multipath.summary" - save_bcmcmd_all_ns "\"l3 ip6host show\"" "l3.ip6host.summary" - save_bcmcmd_all_ns "\"l3 ip6route show\"" "l3.ip6route.summary" - save_bcmcmd_all_ns "\"mc show\"" "multicast.summary" - save_bcmcmd_all_ns "\"cstat *\"" "cstat.summary" - save_bcmcmd_all_ns "\"mirror show\"" "mirror.summary" - save_bcmcmd_all_ns "\"mirror dest show\"" "mirror.dest.summary" - save_bcmcmd_all_ns "\"port *\"" "port.summary" - save_bcmcmd_all_ns "\"d chg my_station_tcam\"" "mystation.tcam.summary" + if [ -e /usr/share/sonic/device/${platform}/platform_asic ]; then + bcm_family=`cat /usr/share/sonic/device/${platform}/platform_asic` + else + echo "'/usr/share/sonic/device/${platform}/platform_asic' does not exist" > /tmp/error + save_file /tmp/error sai false + return + fi + + if [ "$bcm_family" == "broadcom-dnx" ]; then + save_bcmcmd_all_ns "\"l2 show\"" "l2.summary" + save_bcmcmd_all_ns "\"field group list\"" "fpgroup.list.summary" + total_fp_groups=34 + for (( fp_grp=0; fp_grp<$total_fp_groups; fp_grp++ )) + do + save_bcmcmd_all_ns "\"field group info group=$fp_grp\"" "fpgroup$fp_grp.info.summary" + done + save_bcmcmd_all_ns "\"dbal table dump table=IPV4_UNICAST_PRIVATE_LPM_FORWARD\"" "l3.ipv4.lpm.summary" + save_bcmcmd_all_ns "\"dbal table dump table=IPV6_UNICAST_PRIVATE_LPM_FORWARD\"" "l3.ipv6.lpm.summary" + save_bcmcmd_all_ns "\"dbal table dump table=IPV4_UNICAST_PRIVATE_HOST\"" "l3.ipv4.host.summary" + save_bcmcmd_all_ns "\"dbal table dump table=IPV6_UNICAST_PRIVATE_HOST\"" "l3.ipv6.host.summary" + save_bcmcmd_all_ns "\"dbal table dump table=SUPER_FEC_1ST_HIERARCHY\"" "l3.egress.fec.summary" + save_bcmcmd_all_ns "\"dbal table dump table=ECMP_TABLE\"" "ecmp.table.summary" + save_bcmcmd_all_ns "\"dbal table dump table=ECMP_GROUP_PROFILE_TABLE\"" "ecmp.group.summary" + save_bcmcmd_all_ns "\"dbal table dump table=ING_VSI_INFO_DB\"" "ing.vsi.summary" + save_bcmcmd_all_ns "\"dbal table dump table=L3_MY_MAC_DA_PREFIXES\"" "l3.mymac.summary" + save_bcmcmd_all_ns "\"dbal table dump table=INGRESS_VLAN_MEMBERSHIP\"" "ing.vlan.summary" + save_bcmcmd_all_ns "\"dbal table dump table=LOCAL_SBC_IN_LIF_MATCH_INFO_SW\"" "sbc.inlif.summary" + save_bcmcmd_all_ns "\"dbal table dump table=SNIF_COMMAND_TABLE\"" "snif.command.summary" + save_bcmcmd_all_ns "\"port mgmt dump full\"" "port.mgmt.summary" + save_bcmcmd_all_ns "\"tm lag\"" "tm.lag.summary" + save_bcmcmd_all_ns "\"pp info fec\"" "pp.fec.summary" + save_bcmcmd_all_ns "\"nif sts\"" "nif.sts.summary" + save_bcmcmd_all_ns "\"port pm info\"" "port.pm.summary" + save_bcmcmd_all_ns "\"conf show\"" "conf.show.summary" + save_bcmcmd_all_ns "\"show counters\"" "show.counters.summary" + save_bcmcmd_all_ns "\"diag counter g\"" "diag.counter.summary" + save_bcmcmd_all_ns "\"tm ing q map\"" "tm.ingress.qmap.summary" + save_bcmcmd_all_ns "\"tm ing vsq resources\"" "tm.ing.vsq.res.summary" + for group in {a..f} + do + save_bcmcmd_all_ns "\"tm ing vsq non g=$group\"" "tm.ing.vsq.non.group-$group.summary" + done + save_bcmcmd_all_ns "\"fabric connectivity\"" "fabric.connect.summary" + save_bcmcmd_all_ns "\"port status\"" "port.status.summary" + else + save_bcmcmd_all_ns "\"l3 nat_ingress show\"" "broadcom.nat.ingress" + save_bcmcmd_all_ns "\"l3 nat_egress show\"" "broadcom.nat.egress" + save_bcmcmd_all_ns "\"ipmc table show\"" "broadcom.ipmc" + save_bcmcmd_all_ns "\"multicast show\"" "broadcom.multicast" + save_bcmcmd_all_ns "\"conf show\"" "conf.summary" + save_bcmcmd_all_ns "\"fp show\"" "fp.summary" + save_bcmcmd_all_ns "\"pvlan show\"" "pvlan.summary" + save_bcmcmd_all_ns "\"l2 show\"" "l2.summary" + save_bcmcmd_all_ns "\"l3 intf show\"" "l3.intf.summary" + save_bcmcmd_all_ns "\"l3 defip show\"" "l3.defip.summary" + save_bcmcmd_all_ns "\"l3 l3table show\"" "l3.l3table.summary" + save_bcmcmd_all_ns "\"l3 egress show\"" "l3.egress.summary" + save_bcmcmd_all_ns "\"l3 ecmp egress show\"" "l3.ecmp.egress.summary" + save_bcmcmd_all_ns "\"l3 multipath show\"" "l3.multipath.summary" + save_bcmcmd_all_ns "\"l3 ip6host show\"" "l3.ip6host.summary" + save_bcmcmd_all_ns "\"l3 ip6route show\"" "l3.ip6route.summary" + save_bcmcmd_all_ns "\"mc show\"" "multicast.summary" + save_bcmcmd_all_ns "\"cstat *\"" "cstat.summary" + save_bcmcmd_all_ns "\"mirror show\"" "mirror.summary" + save_bcmcmd_all_ns "\"mirror dest show\"" "mirror.dest.summary" + save_bcmcmd_all_ns "\"port *\"" "port.summary" + save_bcmcmd_all_ns "\"d chg my_station_tcam\"" "mystation.tcam.summary" + fi copy_from_masic_docker "syncd" "/var/log/diagrun.log" "/var/log/diagrun.log" copy_from_masic_docker "syncd" "/var/log/bcm_diag_post" "/var/log/bcm_diag_post" } +############################################################################### +# Collect Cisco-8000 specific information +# Globals: +# None +# Arguments: +# None +# Returns: +# None +############################################################################### +collect_cisco_8000() { + trap 'handle_error $? $LINENO' ERR + local platform=$(show platform summary --json | python -c 'import sys, json; \ + print(json.load(sys.stdin)["platform"])') + + if [ -d /usr/share/sonic/device/${platform} ]; then + pushd /usr/share/sonic/device/${platform} > /dev/null + for file in $(find . -path "./*plugin*" -prune -o -path "./*.xml" -prune -o -path "./*.yaml" -prune -o -print); do + if [ -f ${file} ]; then + save_file ${file} sai false + fi + done + popd > /dev/null + else + echo "'/usr/share/sonic/device/${platform}' does not exist" > /tmp/error + save_file /tmp/error sai false + fi + + save_cmd "show platform versions" "platform.versions" +} + ############################################################################### # Save log file # Globals: @@ -1241,11 +1474,6 @@ main() { end_t=$(date +%s%3N) echo "[ Capture Proc State ] : $(($end_t-$start_t)) msec" >> $TECHSUPPORT_TIME_INFO - # Save logs and cores early - save_log_files - save_crash_files - save_warmboot_files - # Save all the processes within each docker save_cmd "show services" services.summary @@ -1278,6 +1506,7 @@ main() { save_frr_info save_bgp_info + save_evpn_info save_cmd "show interface status -d all" "interface.status" save_cmd "show interface transceiver presence" "interface.xcvrs.presence" @@ -1338,6 +1567,10 @@ main() { collect_broadcom fi + if [ "$asic" = "cisco-8000" ]; then + collect_cisco_8000 + fi + # 2nd counter snapshot late. Need 2 snapshots to make sense of counters trend. save_counter_snapshot $asic 2 @@ -1380,6 +1613,14 @@ main() { end_t=$(date +%s%3N) echo "[ TAR /etc Files ] : $(($end_t-$start_t)) msec" >> $TECHSUPPORT_TIME_INFO + save_log_files + save_crash_files + save_warmboot_files + + if [[ "$asic" = "mellanox" ]]; then + collect_mellanox_dfw_dumps + fi + finalize } diff --git a/scripts/intfstat b/scripts/intfstat index 1d5da781b6..30cfbf084d 100755 --- a/scripts/intfstat +++ b/scripts/intfstat @@ -28,6 +28,7 @@ from collections import namedtuple, OrderedDict from natsort import natsorted from tabulate import tabulate from utilities_common.netstat import ns_diff, table_as_json, STATUS_NA, format_brate, format_prate +from utilities_common.cli import UserCache from swsscommon.swsscommon import SonicV2Connector nstat_fields = ( @@ -274,63 +275,34 @@ def main(): delete_saved_stats = args.delete delete_all_stats = args.delete_all use_json = args.json - tag_name = args.tag if args.tag else "" - uid = str(os.getuid()) + tag_name = args.tag wait_time_in_seconds = args.period interface_name = args.interface if args.interface else "" - # fancy filename with dashes: uid-tag / uid etc - filename_components = [uid, tag_name] + cnstat_file = "intfstat" - cnstat_file = "-".join(filter(None, filename_components)) + cache = UserCache(tag=tag_name) - cnstat_dir = "/tmp/intfstat-" + uid + cache_general = UserCache() + cnstat_dir = cache.get_directory() + cnstat_general_dir = cache_general.get_directory() + + cnstat_fqn_general_file = cnstat_general_dir + "/" + cnstat_file cnstat_fqn_file = cnstat_dir + "/" + cnstat_file if delete_all_stats: - # There is nothing to delete - if not os.path.isdir(cnstat_dir): - sys.exit(0) - - for file in os.listdir(cnstat_dir): - os.remove(cnstat_dir + "/" + file) - - try: - os.rmdir(cnstat_dir) - sys.exit(0) - except IOError as e: - print(e.errno, e) - sys.exit(e) + cache.remove_all() if delete_saved_stats: - try: - os.remove(cnstat_fqn_file) - except IOError as e: - if e.errno != ENOENT: - print(e.errno, e) - sys.exit(1) - finally: - if os.listdir(cnstat_dir) == []: - os.rmdir(cnstat_dir) - sys.exit(0) + cache.remove() intfstat = Intfstat() cnstat_dict, ratestat_dict = intfstat.get_cnstat(rif=interface_name) - # At this point, either we'll create a file or open an existing one. - if not os.path.exists(cnstat_dir): - try: - os.makedirs(cnstat_dir) - except IOError as e: - print(e.errno, e) - sys.exit(1) - if save_fresh_stats: try: # Add the information also to the general file - i.e. without the tag name - if tag_name != '' and tag_name in cnstat_fqn_file.split('/')[-1]: - gen_index = cnstat_fqn_file.rfind('/') - cnstat_fqn_general_file = cnstat_fqn_file[:gen_index] + cnstat_fqn_file[gen_index:].split('-')[0] + if tag_name is not None: if os.path.isfile(cnstat_fqn_general_file): try: general_data = pickle.load(open(cnstat_fqn_general_file, 'rb')) @@ -354,9 +326,6 @@ def main(): sys.exit(0) if wait_time_in_seconds == 0: - gen_index = cnstat_fqn_file.rfind('/') - cnstat_fqn_general_file = cnstat_fqn_file[:gen_index] + cnstat_fqn_file[gen_index:].split('-')[0] - if os.path.isfile(cnstat_fqn_file) or (os.path.isfile(cnstat_fqn_general_file)): try: cnstat_cached_dict = {} diff --git a/scripts/intfutil b/scripts/intfutil index 375e2c1d9d..fb351687a8 100755 --- a/scripts/intfutil +++ b/scripts/intfutil @@ -5,13 +5,6 @@ import os import re import sys -from natsort import natsorted -from tabulate import tabulate -from utilities_common import constants -from utilities_common import multi_asic as multi_asic_util -from utilities_common.intf_filter import parse_interface_in_filter -from sonic_py_common.interface import get_intf_longname - # mock the redis for unit test purposes # try: if os.environ["UTILITIES_UNIT_TESTING"] == "2": @@ -20,6 +13,8 @@ try: sys.path.insert(0, modules_path) sys.path.insert(0, tests_path) import mock_tables.dbconnector + from mock_platform_sfputil.mock_platform_sfputil import mock_platform_sfputil_helper + mock_platform_sfputil_helper() if os.environ["UTILITIES_UNIT_TESTING_TOPOLOGY"] == "multi_asic": import mock_tables.mock_multi_asic mock_tables.dbconnector.load_namespace_config() @@ -27,6 +22,14 @@ try: except KeyError: pass +from natsort import natsorted +from tabulate import tabulate +from utilities_common import constants +from utilities_common import multi_asic as multi_asic_util +from utilities_common.intf_filter import parse_interface_in_filter +from utilities_common.platform_sfputil_helper import is_rj45_port, RJ45_PORT_TYPE +from sonic_py_common.interface import get_intf_longname + # ========================== Common interface-utils logic ========================== @@ -49,7 +52,9 @@ PORT_RMT_ADV_SPEEDS = 'rmt_adv_speeds' PORT_INTERFACE_TYPE = 'interface_type' PORT_ADV_INTERFACE_TYPES = 'adv_interface_types' PORT_TPID = "tpid" -OPTICS_TYPE_RJ45 = 'RJ45' +OPTICS_TYPE_RJ45 = RJ45_PORT_TYPE +PORT_LINK_TRAINING = 'link_training' +PORT_LINK_TRAINING_STATUS = 'link_training_status' VLAN_SUB_INTERFACE_SEPARATOR = "." VLAN_SUB_INTERFACE_TYPE = "802.1q-encapsulation" @@ -159,10 +164,10 @@ def appl_db_port_status_get(appl_db, intf_name, status_type): if status is None: return "N/A" if status_type == PORT_SPEED and status != "N/A": - optics_type = state_db_port_optics_get(appl_db, intf_name, PORT_OPTICS_TYPE) + optics_type = port_optics_get(appl_db, intf_name, PORT_OPTICS_TYPE) status = port_speed_parse(status, optics_type) elif status_type == PORT_ADV_SPEEDS and status != "N/A" and status != "all": - optics_type = state_db_port_optics_get(appl_db, intf_name, PORT_OPTICS_TYPE) + optics_type = port_optics_get(appl_db, intf_name, PORT_OPTICS_TYPE) speed_list = status.split(',') new_speed_list = [] for s in natsorted(speed_list): @@ -179,7 +184,7 @@ def state_db_port_status_get(db, intf_name, field): if not status: return "N/A" if field in [PORT_RMT_ADV_SPEEDS] and status not in ["N/A", "all"]: - optics_type = state_db_port_optics_get(db, intf_name, PORT_OPTICS_TYPE) + optics_type = port_optics_get(db, intf_name, PORT_OPTICS_TYPE) speed_list = status.split(',') new_speed_list = [] for s in natsorted(speed_list): @@ -196,7 +201,7 @@ def port_oper_speed_get(db, intf_name): if oper_speed is None or oper_speed == "N/A" or oper_status != "up": return appl_db_port_status_get(db, intf_name, PORT_SPEED) else: - optics_type = state_db_port_optics_get(db, intf_name, PORT_OPTICS_TYPE) + optics_type = port_optics_get(db, intf_name, PORT_OPTICS_TYPE) return port_speed_parse(oper_speed, optics_type) def port_oper_speed_get_raw(db, intf_name): @@ -209,14 +214,17 @@ def port_oper_speed_get_raw(db, intf_name): speed = db.get(db.APPL_DB, PORT_STATUS_TABLE_PREFIX + intf_name, PORT_SPEED) return speed -def state_db_port_optics_get(state_db, intf_name, type): +def port_optics_get(state_db, intf_name, type): """ Get optic type info for port """ full_table_id = PORT_TRANSCEIVER_TABLE_PREFIX + intf_name optics_type = state_db.get(state_db.STATE_DB, full_table_id, type) if optics_type is None: - return "N/A" + if is_rj45_port(intf_name): + return OPTICS_TYPE_RJ45 + else: + return "N/A" return optics_type def merge_dicts(x,y): @@ -323,13 +331,13 @@ def po_speed_dict(po_int_dict, appl_db): # If no speed was returned, append None without format po_list.append(None) else: - optics_type = state_db_port_optics_get(appl_db, value[0], PORT_OPTICS_TYPE) + optics_type = port_optics_get(appl_db, value[0], PORT_OPTICS_TYPE) interface_speed = port_speed_parse(interface_speed, optics_type) po_list.append(interface_speed) elif len(value) > 1: for intf in value: temp_speed = port_oper_speed_get_raw(appl_db, intf) - optics_type = state_db_port_optics_get(appl_db, intf, PORT_OPTICS_TYPE) + optics_type = port_optics_get(appl_db, intf, PORT_OPTICS_TYPE) temp_speed = int(temp_speed) if temp_speed else 0 agg_speed_list.append(temp_speed) interface_speed = sum(agg_speed_list) @@ -475,7 +483,7 @@ class IntfStatus(object): config_db_vlan_port_keys_get(self.combined_int_to_vlan_po_dict, self.front_panel_ports_list, key), appl_db_port_status_get(self.db, key, PORT_OPER_STATUS), appl_db_port_status_get(self.db, key, PORT_ADMIN_STATUS), - state_db_port_optics_get(self.db, key, PORT_OPTICS_TYPE), + port_optics_get(self.db, key, PORT_OPTICS_TYPE), appl_db_port_status_get(self.db, key, PORT_PFC_ASYM_STATUS))) for po, value in self.portchannel_speed_dict.items(): @@ -739,6 +747,67 @@ class IntfTpid(object): self.table += self.generate_intf_tpid() +# ========================== interface-link-training logic ========================== +header_link_training = ['Interface', 'LT Oper', 'LT Admin', 'Oper', 'Admin'] + +class IntfLinkTrainingStatus(object): + + def __init__(self, intf_name, namespace_option, display_option): + self.db = None + self.config_db = None + self.table = [] + self.multi_asic = multi_asic_util.MultiAsic( + display_option, namespace_option) + + if intf_name is not None and intf_name == SUB_PORT: + self.intf_name = None + else: + self.intf_name = intf_name + + def display_link_training_status(self): + self.get_intf_link_training_status() + # Sorting and tabulating the result table. + sorted_table = natsorted(self.table) + print(tabulate(sorted_table, header_link_training, tablefmt="simple", stralign='right')) + + @multi_asic_util.run_on_multi_asic + def get_intf_link_training_status(self): + self.front_panel_ports_list = get_frontpanel_port_list(self.config_db) + self.appl_db_keys = appl_db_keys_get(self.db, self.front_panel_ports_list, self.intf_name) + if self.appl_db_keys: + self.table += self.generate_link_training_status() + + def generate_link_training_status(self): + """ + Generate interface-link-training output + """ + + i = {} + table = [] + key = [] + + # + # Iterate through all the keys and append port's associated state to + # the result table. + # + for i in self.appl_db_keys: + key = re.split(':', i, maxsplit=1)[-1].strip() + if key in self.front_panel_ports_list: + if self.multi_asic.skip_display(constants.PORT_OBJ, key): + continue + lt_admin = appl_db_port_status_get(self.db, key, PORT_LINK_TRAINING) + if lt_admin not in ['on', 'off']: + lt_admin = '-' + lt_status = state_db_port_status_get(self.db, key, PORT_LINK_TRAINING_STATUS) + if lt_status in ['N/A', '', None]: + lt_status = 'off' + table.append((key, + lt_status.replace('_', ' '), + lt_admin, + appl_db_port_status_get(self.db, key, PORT_OPER_STATUS), + appl_db_port_status_get(self.db, key, PORT_ADMIN_STATUS))) + return table + def main(): parser = argparse.ArgumentParser(description='Display Interface information', formatter_class=argparse.RawTextHelpFormatter) @@ -759,6 +828,9 @@ def main(): elif args.command == "tpid": interface_tpid = IntfTpid(args.interface, args.namespace, args.display) interface_tpid.display_intf_tpid() + elif args.command == "link_training": + interface_lt_status = IntfLinkTrainingStatus(args.interface, args.namespace, args.display) + interface_lt_status.display_link_training_status() sys.exit(0) diff --git a/scripts/ipintutil b/scripts/ipintutil index 5eb1f66524..c61c622a87 100755 --- a/scripts/ipintutil +++ b/scripts/ipintutil @@ -193,9 +193,13 @@ def get_ip_intfs_in_namespace(af, namespace, display): return ip_intfs -def display_ip_intfs(ip_intfs): +def display_ip_intfs(ip_intfs,address_family): header = ['Interface', 'Master', 'IPv4 address/mask', 'Admin/Oper', 'BGP Neighbor', 'Neighbor IP'] + + if address_family == 'ipv6': + header[2] = 'IPv6 address/mask' + data = [] for ip_intf, v in natsorted(ip_intfs.items()): ip_address = v['ipaddr'][0][1] @@ -265,7 +269,7 @@ def main(): load_db_config() ip_intfs = get_ip_intfs(af, namespace, display) - display_ip_intfs(ip_intfs) + display_ip_intfs(ip_intfs,args.address_family) sys.exit(0) diff --git a/scripts/mellanox_buffer_migrator.py b/scripts/mellanox_buffer_migrator.py index 6706969be1..187e77afd0 100755 --- a/scripts/mellanox_buffer_migrator.py +++ b/scripts/mellanox_buffer_migrator.py @@ -101,7 +101,7 @@ def __init__(self, configDB, appDB, stateDB): self.sku = device_data.get('hwsku') self.ready = True if not self.platform or not self.sku: - log.log_error("Trying to get DEVICE_METADATA from DB but doesn't exist, skip migration") + log.log_notice("Trying to get DEVICE_METADATA from DB but doesn't exist, skip migration") self.ready = False self.spc1_platforms = ["x86_64-mlnx_msn2010-r0", "x86_64-mlnx_msn2100-r0", "x86_64-mlnx_msn2410-r0", "x86_64-mlnx_msn2700-r0", "x86_64-mlnx_msn2740-r0"] diff --git a/scripts/memory_threshold_check.py b/scripts/memory_threshold_check.py new file mode 100644 index 0000000000..ba54c7296a --- /dev/null +++ b/scripts/memory_threshold_check.py @@ -0,0 +1,243 @@ +#!/usr/bin/env python3 + +import sys + +import sonic_py_common.logger +from swsscommon.swsscommon import ConfigDBConnector, SonicV2Connector +from utilities_common.auto_techsupport_helper import STATE_DB + +# Exit codes +EXIT_SUCCESS = 0 # Success +EXIT_FAILURE = 1 # General failure occurred, no techsupport is invoked +EXIT_THRESHOLD_CROSSED = 2 # Memory threshold crossed, techsupport is invoked + +SYSLOG_IDENTIFIER = "memory_threshold_check" + +# Config DB tables +AUTO_TECHSUPPORT = "AUTO_TECHSUPPORT" +AUTO_TECHSUPPORT_FEATURE = "AUTO_TECHSUPPORT_FEATURE" + +# State DB docker stats table +DOCKER_STATS = "DOCKER_STATS" + +# (%) Default value for available memory left in the system +DEFAULT_MEMORY_AVAILABLE_THRESHOLD = 10 +# (MB) Default value for minimum available memory in the system to run techsupport +DEFAULT_MEMORY_AVAILABLE_MIN_THRESHOLD = 200 +# (%) Default value for available memory inside container +DEFAULT_MEMORY_AVAILABLE_FEATURE_THRESHOLD = 0 + +MB_TO_KB_MULTIPLIER = 1024 + +# Global logger instance +logger = sonic_py_common.logger.Logger(SYSLOG_IDENTIFIER) + + +class MemoryCheckerException(Exception): + """General memory checker exception""" + + pass + + +class MemoryStats: + """MemoryStats provides an interface to query memory statistics of the system and per feature.""" + + def __init__(self, state_db): + """Initialize MemoryStats + + Args: + state_db (swsscommon.DBConnector): state DB connector instance + """ + self.state_db = state_db + + def get_sys_memory_stats(self): + """Returns system memory statistic dictionary, reflects the /proc/meminfo + + Returns: + Dictionary of strings to integers where integer values + represent memory amount in Kb, e.g: + { + "MemTotal": 8104856, + "MemAvailable": 6035192, + ... + } + """ + with open("/proc/meminfo") as fd: + lines = fd.read().split("\n") + rows = [line.split() for line in lines] + + # e.g row is ('MemTotal:', '8104860', 'kB') + # key is the first element with removed remove last ':'. + # value is the second element converted to int. + def row_to_key(row): + return row[0][:-1] + + def row_to_value(row): + return int(row[1]) + + return {row_to_key(row): row_to_value(row) for row in rows if len(row) >= 2} + + def get_containers_memory_usage(self): + """Returns per container memory usage, reflects the DOCKER_STATS state DB table + + Returns: + Dictionary of strings to floats where floating point values + represent memory usage of the feature container which is carefully + calculated for us by the dockerd and published by procdockerstatsd, e.g: + + { + "swss": 1.5, + "teamd": 10.92, + ... + } + """ + result = {} + dockers = self.state_db.keys(STATE_DB, DOCKER_STATS + "|*") + stats = [ + stat for stat in [self.state_db.get_all(STATE_DB, key) for key in dockers] if stat is not None + ] + + for stat in stats: + try: + name = stat["NAME"] + mem_usage = float(stat["MEM%"]) + except KeyError as err: + continue + except ValueError as err: + logger.log_error(f'Failed to parse memory usage for "{stat}": {err}') + raise MemoryCheckerException(err) + + result[name] = mem_usage + + return result + + +class Config: + def __init__(self, cfg_db): + self.table = cfg_db.get_table(AUTO_TECHSUPPORT) + self.feature_table = cfg_db.get_table(AUTO_TECHSUPPORT_FEATURE) + + config = self.table.get("GLOBAL") + + self.memory_available_threshold = self.parse_value_from_db( + config, + "available_mem_threshold", + float, + DEFAULT_MEMORY_AVAILABLE_THRESHOLD, + ) + self.memory_available_min_threshold = self.parse_value_from_db( + config, + "min_available_mem", + float, + DEFAULT_MEMORY_AVAILABLE_MIN_THRESHOLD, + ) * MB_TO_KB_MULTIPLIER + + keys = self.feature_table.keys() + self.feature_config = {} + for key in keys: + config = self.feature_table.get(key) + + self.feature_config[key] = self.parse_value_from_db( + config, + "available_mem_threshold", + float, + DEFAULT_MEMORY_AVAILABLE_FEATURE_THRESHOLD, + ) + + @staticmethod + def parse_value_from_db(config, key, converter, default): + value = config.get(key) + if not value: + return default + try: + return converter(value) + except ValueError as err: + logger.log_error(f'Failed to parse {key} value "{value}": {err}') + raise MemoryCheckerException(err) + + +class MemoryChecker: + """Business logic of the memory checker""" + + def __init__(self, stats, config): + """Initialize MemoryChecker""" + self.stats = stats + self.config = config + + def run_check(self): + """Runs the checks and returns a tuple of check result boolean + and a container name or empty string if the check failed for the host. + + Returns: + (bool, str) + """ + # don't bother getting stats if available memory threshold is set to 0 + if self.config.memory_available_threshold: + memory_stats = self.stats.get_sys_memory_stats() + memory_free = memory_stats["MemAvailable"] + memory_total = memory_stats["MemTotal"] + memory_free_threshold = ( + memory_total * self.config.memory_available_threshold / 100 + ) + memory_min_free_threshold = self.config.memory_available_min_threshold + + # free memory amount is less then configured minimum required memory for + # running "show techsupport" + if memory_free <= memory_min_free_threshold: + logger.log_error( + f"Free memory {memory_free} is less then " + f"min free memory threshold {memory_min_free_threshold}" + ) + return (False, "") + + # free memory amount is less then configured threshold + if memory_free <= memory_free_threshold: + logger.log_error( + f"Free memory {memory_free} is less then " + f"free memory threshold {memory_free_threshold}" + ) + return (False, "") + + container_memory_usage = self.stats.get_containers_memory_usage() + for feature, memory_available_threshold in self.config.feature_config.items(): + for container, memory_usage in container_memory_usage.items(): + # startswith to handle multi asic instances + if not container.startswith(feature): + continue + + # free memory amount is less then configured threshold + if (100 - memory_usage) <= memory_available_threshold: + logger.log_error( + f"Available {100 - memory_usage} for {feature} is less " + f"then free memory threshold {memory_available_threshold}" + ) + return (False, feature) + + return (True, "") + + +def main(): + cfg_db = ConfigDBConnector(use_unix_socket_path=True) + cfg_db.connect() + state_db = SonicV2Connector(use_unix_socket_path=True) + state_db.connect(STATE_DB) + + config = Config(cfg_db) + mem_stats = MemoryStats(state_db) + mem_checker = MemoryChecker(mem_stats, config) + + try: + passed, name = mem_checker.run_check() + if not passed: + return EXIT_THRESHOLD_CROSSED, name + except MemoryCheckerException as err: + logger.log_error(f"Failure occurred {err}") + return EXIT_FAILURE, "" + + return EXIT_SUCCESS, "" + + +if __name__ == "__main__": + rc, component = main() + print(component) + sys.exit(rc) diff --git a/scripts/memory_threshold_check_handler.py b/scripts/memory_threshold_check_handler.py new file mode 100644 index 0000000000..1d8a82fb2f --- /dev/null +++ b/scripts/memory_threshold_check_handler.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python3 + +import sys +import os +import syslog +from swsscommon.swsscommon import SonicV2Connector +from utilities_common.auto_techsupport_helper import * + +# Exit codes +EXIT_SUCCESS = 0 # Success +EXIT_FAILURE = 1 # General failure occurred, no techsupport is invoked + +def main(): + output = os.environ.get("MONIT_DESCRIPTION") + syslog.openlog(logoption=syslog.LOG_PID) + db = SonicV2Connector(use_unix_socket_path=True) + db.connect(CFG_DB) + db.connect(STATE_DB) + if not output: + syslog.syslog( + syslog.LOG_ERR, + "Expected to get output from environment variable MONIT_DESCRIPTION" + ) + return EXIT_FAILURE + if "--" not in output: + syslog.syslog(syslog.LOG_ERR, "Unexpected value in environment variable MONIT_DESCRIPTION") + return EXIT_FAILURE + + monit_output = output.split("--")[1].strip() + # If the output of memory_threshold_check is empty + # that means that memory threshold check failed for the host. + # In this case monit inserts "no output" string in MONIT_DESCRIPTION + if monit_output == "no output": + container = None + else: + container = monit_output + invoke_ts_command_rate_limited(db, EVENT_TYPE_MEMORY, container) + + return EXIT_SUCCESS + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/scripts/neighbor_advertiser b/scripts/neighbor_advertiser index 131c172165..f8a119ab05 100644 --- a/scripts/neighbor_advertiser +++ b/scripts/neighbor_advertiser @@ -43,7 +43,7 @@ MIRROR_ACL_TABLE_NAME = 'EVERFLOW' MIRROR_ACL_TABLEV6_NAME = 'EVERFLOWV6' MIRROR_ACL_RULE_NAME = 'rule_arp' MIRROR_ACL_RULEV6_NAME = 'rule_nd' -VXLAN_TUNNEL_NAME = 'neighbor_advertiser' +VXLAN_TUNNEL_NAME = 'neigh_adv' VXLAN_TUNNEL_MAP_PREFIX = 'map_' diff --git a/scripts/pfcstat b/scripts/pfcstat index 6d11361527..fb7e6018b6 100755 --- a/scripts/pfcstat +++ b/scripts/pfcstat @@ -18,9 +18,6 @@ from natsort import natsorted from tabulate import tabulate from sonic_py_common.multi_asic import get_external_ports -from utilities_common.netstat import ns_diff, STATUS_NA, format_number_with_comma -from utilities_common import multi_asic as multi_asic_util -from utilities_common import constants # mock the redis for unit test purposes # try: @@ -37,6 +34,12 @@ try: except KeyError: pass +from utilities_common.netstat import ns_diff, STATUS_NA, format_number_with_comma +from utilities_common import multi_asic as multi_asic_util +from utilities_common import constants +from utilities_common.cli import UserCache + + PStats = namedtuple("PStats", "pfc0, pfc1, pfc2, pfc3, pfc4, pfc5, pfc6, pfc7") header_Rx = ['Port Rx', 'PFC0', 'PFC1', 'PFC2', 'PFC3', 'PFC4', 'PFC5', 'PFC6', 'PFC7'] @@ -224,10 +227,10 @@ Examples: save_fresh_stats = args.clear delete_all_stats = args.delete - uid = str(os.getuid()) - cnstat_file = uid + cache = UserCache() + cnstat_file = 'pfcstat' - cnstat_dir = os.path.join(os.sep, "tmp", "pfcstat-{}".format(uid)) + cnstat_dir = cache.get_directory() cnstat_fqn_file_rx = os.path.join(cnstat_dir, "{}rx".format(cnstat_file)) cnstat_fqn_file_tx = os.path.join(cnstat_dir, "{}tx".format(cnstat_file)) @@ -239,15 +242,7 @@ Examples: pfcstat = Pfcstat(args.namespace, args.show) if delete_all_stats: - for file in os.listdir(cnstat_dir): - os.remove(os.path.join(cnstat_dir, file)) - - try: - os.rmdir(cnstat_dir) - sys.exit(0) - except IOError as e: - print(e.errno, e) - sys.exit(e) + cache.remove() """ Get the counters of pfc rx counter @@ -259,14 +254,6 @@ Examples: """ cnstat_dict_tx = deepcopy(pfcstat.get_cnstat(False)) - # At this point, either we'll create a file or open an existing one. - if not os.path.exists(cnstat_dir): - try: - os.makedirs(cnstat_dir) - except IOError as e: - print(e.errno, e) - sys.exit(1) - if save_fresh_stats: try: pickle.dump(cnstat_dict_rx, open(cnstat_fqn_file_rx, 'wb')) diff --git a/scripts/pg-drop b/scripts/pg-drop index b437e53bba..40b4e863d3 100755 --- a/scripts/pg-drop +++ b/scripts/pg-drop @@ -26,6 +26,7 @@ try: except KeyError: pass +from utilities_common.cli import UserCache from swsscommon.swsscommon import ConfigDBConnector, SonicV2Connector STATUS_NA = 'N/A' @@ -38,8 +39,7 @@ COUNTERS_PG_PORT_MAP = "COUNTERS_PG_PORT_MAP" COUNTERS_PG_INDEX_MAP = "COUNTERS_PG_INDEX_MAP" def get_dropstat_dir(): - dropstat_dir_prefix = '/tmp/dropstat' - return "{}-{}/".format(dropstat_dir_prefix, os.getuid()) + return UserCache().get_directory() class PgDropStat(object): @@ -58,15 +58,15 @@ class PgDropStat(object): Get port ID using object ID """ port_id = self.counters_db.get(self.counters_db.COUNTERS_DB, COUNTERS_PG_PORT_MAP, oid) - if port_id is None: - print("Port is not available for oid '{}'".format(oid), file=sys.stderr) + if not port_id: + print("Port is not available for oid '{}'".format(oid)) sys.exit(1) return port_id # Get all ports self.counter_port_name_map = self.counters_db.get_all(self.counters_db.COUNTERS_DB, COUNTERS_PORT_NAME_MAP) - if self.counter_port_name_map is None: - print("COUNTERS_PORT_NAME_MAP is empty!", file=sys.stderr) + if not self.counter_port_name_map: + print("COUNTERS_PORT_NAME_MAP is empty!") sys.exit(1) self.port_pg_map = {} @@ -78,8 +78,8 @@ class PgDropStat(object): # Get PGs for each port counter_pg_name_map = self.counters_db.get_all(self.counters_db.COUNTERS_DB, COUNTERS_PG_NAME_MAP) - if counter_pg_name_map is None: - print("COUNTERS_PG_NAME_MAP is empty!", file=sys.stderr) + if not counter_pg_name_map: + print("COUNTERS_PG_NAME_MAP is empty!") sys.exit(1) for pg in counter_pg_name_map: @@ -101,8 +101,8 @@ class PgDropStat(object): oid - object ID for entry in redis """ pg_index = self.counters_db.get(self.counters_db.COUNTERS_DB, COUNTERS_PG_INDEX_MAP, oid) - if pg_index is None: - print("Priority group index is not available for oid '{}'".format(table_id), file=sys.stderr) + if not pg_index: + print("Priority group index is not available for oid '{}'".format(oid)) sys.exit(1) return pg_index @@ -111,21 +111,31 @@ class PgDropStat(object): Construct header for table with PG counters """ if pg_drop_type is None: - print("Header info is not available!", file=sys.stderr) + print("Header info is not available!") sys.exit(1) self.header_list = ['Port'] header_map = pg_drop_type["obj_map"] - single_key = list(header_map.keys())[0] - header_len = len(header_map[single_key]) - min_idx = sys.maxsize - for name, counter_oid in header_map[single_key].items(): - curr_idx = int(pg_drop_type["idx_func"](counter_oid)) - min_idx = min(min_idx, curr_idx) + header_idx_set = set() + for port in header_map.keys(): + for element in header_map[port].keys(): + element_idx = int(element.split(':')[1]) + header_idx_set.add(element_idx) - self.min_idx = min_idx - self.header_list += ["{}{}".format(pg_drop_type["header_prefix"], idx) for idx in range(self.min_idx, self.min_idx + header_len)] + if len(header_idx_set) == 0: + print("Header info is not available!") + sys.exit(1) + + header_idx_list = list(header_idx_set) + header_idx_list.sort() + + self.header_idx_to_pos = {} + for i in header_idx_list: + self.header_idx_to_pos[i] = header_idx_list.index(i) + + self.min_idx = header_idx_list[0] + self.header_list += ["{}{}".format(pg_drop_type["header_prefix"], idx) for idx in header_idx_list] def get_counters(self, table_prefix, port_obj, idx_func, counter_name): """ @@ -143,7 +153,7 @@ class PgDropStat(object): full_table_id = table_prefix + obj_id old_collected_data = port_drop_ckpt.get(name,{})[full_table_id] if len(port_drop_ckpt) > 0 else 0 idx = int(idx_func(obj_id)) - pos = idx - self.min_idx + pos = self.header_idx_to_pos[idx] counter_data = self.counters_db.get(self.counters_db.COUNTERS_DB, full_table_id, counter_name) if counter_data is None: fields[pos] = STATUS_NA diff --git a/scripts/portconfig b/scripts/portconfig index 25647cc45c..8dc68d4e0a 100755 --- a/scripts/portconfig +++ b/scripts/portconfig @@ -21,9 +21,13 @@ optional arguments: -S --adv-speeds port advertised speeds -t --interface-type port interface type -T --adv-interface-types port advertised interface types + -lt --link-training port link training mode + -P --tx-power 400G ZR modulet target Tx output power (dBm) + -F --laser-freq 400G ZR module 75GHz grid frequency (GHz) """ import os import sys +import decimal import argparse # mock the redis for unit test purposes # @@ -49,6 +53,9 @@ PORT_AUTONEG_CONFIG_FIELD_NAME = "autoneg" PORT_ADV_SPEEDS_CONFIG_FIELD_NAME = "adv_speeds" PORT_INTERFACE_TYPE_CONFIG_FIELD_NAME = "interface_type" PORT_ADV_INTERFACE_TYPES_CONFIG_FIELD_NAME = "adv_interface_types" +PORT_LINK_TRAINING_CONFIG_FIELD_NAME = "link_training" +PORT_XCVR_LASER_FREQ_FIELD_NAME = "laser_freq" +PORT_XCVR_TX_POWER_FIELD_NAME = "tx_power" PORT_CHANNEL_TABLE_NAME = "PORTCHANNEL" PORT_CHANNEL_MBR_TABLE_NAME = "PORTCHANNEL_MEMBER" TPID_CONFIG_FIELD_NAME = "tpid" @@ -58,7 +65,7 @@ SWITCH_CAPABILITY = "SWITCH_CAPABILITY|switch" # STATE_DB constants PORT_STATE_TABLE_NAME = "PORT_TABLE" PORT_STATE_SUPPORTED_SPEEDS = "supported_speeds" - +PORT_STATE_SUPPORTED_FECS = "supported_fecs" VALID_INTERFACE_TYPE_SET = set(['CR','CR2','CR4','SR','SR2','SR4', 'LR','LR4','KR','KR4','CAUI','GMII', @@ -111,6 +118,9 @@ class portconfig(object): print(port_tables[port]) def set_speed(self, port, speed): + if self.is_lag: + raise Exception("Invalid port %s" % (port)) + if self.verbose: print("Setting speed %s on port %s" % (speed, port)) supported_speeds_str = self.get_supported_speeds(port) or '' @@ -122,22 +132,68 @@ class portconfig(object): self.db.mod_entry(PORT_TABLE_NAME, port, {PORT_SPEED_CONFIG_FIELD_NAME: speed}) def set_fec(self, port, fec): + if self.is_lag: + raise Exception("Invalid port %s" % (port)) + if self.verbose: print("Setting fec %s on port %s" % (fec, port)) + supported_fecs = self.get_supported_fecs(port) + if fec not in supported_fecs: + if supported_fecs: + print('fec {} is not in {}'.format(fec, supported_fecs)) + else: + print('Setting fec is not supported on port {}'.format(port)) + exit(1) self.db.mod_entry(PORT_TABLE_NAME, port, {PORT_FEC_CONFIG_FIELD_NAME: fec}) def set_mtu(self, port, mtu): + if self.is_lag: + raise Exception("Invalid port %s" % (port)) + if self.verbose: print("Setting mtu %s on port %s" % (mtu, port)) self.db.mod_entry(PORT_TABLE_NAME, port, {PORT_MTU_CONFIG_FIELD_NAME: mtu}) + def set_link_training(self, port, mode): + if self.is_lag: + raise Exception("Invalid port %s" % (port)) + + if self.verbose: + print("Setting link-training %s on port %s" % (mode, port)) + lt_modes = ['on', 'off'] + if mode not in lt_modes: + print('Invalid mode specified: {}'.format(mode)) + print('Valid modes: {}'.format(','.join(lt_modes))) + exit(1) + self.db.mod_entry(PORT_TABLE_NAME, port, {PORT_LINK_TRAINING_CONFIG_FIELD_NAME: mode}) + def set_autoneg(self, port, mode): + if self.is_lag: + raise Exception("Invalid port %s" % (port)) + if self.verbose: print("Setting autoneg %s on port %s" % (mode, port)) mode = 'on' if mode == 'enabled' else 'off' self.db.mod_entry(PORT_TABLE_NAME, port, {PORT_AUTONEG_CONFIG_FIELD_NAME: mode}) + def set_tx_power(self, port, tx_power): + if self.is_lag: + raise Exception("Invalid port %s" % (port)) + + print("Setting target Tx output power to %s dBm on port %s" % (tx_power, port)) + self.db.mod_entry(PORT_TABLE_NAME, port, {PORT_XCVR_TX_POWER_FIELD_NAME: tx_power}) + + def set_laser_freq(self, port, laser_freq): + if self.is_lag: + raise Exception("Invalid port %s" % (port)) + + print("Setting laser frequency to %s GHz on port %s" % (laser_freq, port)) + self.db.mod_entry(PORT_TABLE_NAME, port, {PORT_XCVR_LASER_FREQ_FIELD_NAME: laser_freq}) + def set_adv_speeds(self, port, adv_speeds): + if self.is_lag: + raise Exception("Invalid port %s" % (port)) + if self.verbose: print("Setting adv_speeds %s on port %s" % (adv_speeds, port)) @@ -159,6 +215,9 @@ class portconfig(object): self.db.mod_entry(PORT_TABLE_NAME, port, {PORT_ADV_SPEEDS_CONFIG_FIELD_NAME: adv_speeds}) def set_interface_type(self, port, interface_type): + if self.is_lag: + raise Exception("Invalid port %s" % (port)) + if self.is_rj45_port: print("Setting RJ45 ports' type is not supported") exit(1) @@ -171,6 +230,9 @@ class portconfig(object): self.db.mod_entry(PORT_TABLE_NAME, port, {PORT_INTERFACE_TYPE_CONFIG_FIELD_NAME: interface_type}) def set_adv_interface_types(self, port, adv_interface_types): + if self.is_lag: + raise Exception("Invalid port %s" % (port)) + if self.is_rj45_port: print("Setting RJ45 ports' advertised types is not supported") exit(1) @@ -198,6 +260,26 @@ class portconfig(object): state_db.connect(state_db.STATE_DB) return state_db.get(state_db.STATE_DB, '{}|{}'.format(PORT_STATE_TABLE_NAME, port), PORT_STATE_SUPPORTED_SPEEDS) + def get_supported_fecs(self, port): + # If there is supported_fecs exposed in STATE_DB, let's use it. + # Otherwise, take the default + if not self.namespace: + state_db = SonicV2Connector(host="127.0.0.1") + else: + state_db = SonicV2Connector(host="127.0.0.1", namespace=self.namespace, use_unix_socket_path=True) + state_db.connect(state_db.STATE_DB) + + supported_fecs_str = state_db.get(state_db.STATE_DB, '{}|{}'.format(PORT_STATE_TABLE_NAME, port), PORT_STATE_SUPPORTED_FECS) + if supported_fecs_str: + if supported_fecs_str != 'N/A': + supported_fecs_list = supported_fecs_str.split(',') + else: + supported_fecs_list = [] + else: + supported_fecs_list = ["rs", "fc", "none"] + + return supported_fecs_list + def set_tpid(self, port, tpid): if self.verbose: print("Setting tpid %s on port %s" % (tpid, port)) @@ -248,7 +330,7 @@ def main(): parser.add_argument('-p', '--port', type=str, help='port name (e.g. Ethernet0)', required=True, default=None) parser.add_argument('-l', '--list', action='store_true', help='list port parametars', default=False) parser.add_argument('-s', '--speed', type=int, help='port speed value in Mbit', default=None) - parser.add_argument('-f', '--fec', type=str, help='port fec mode value in (none, rs, fc)', default=None) + parser.add_argument('-f', '--fec', type=str, help='port fec mode value (default is: none, rs, fc)', default=None) parser.add_argument('-m', '--mtu', type=int, help='port mtu value in bytes', default=None) parser.add_argument('-tp', '--tpid', type=str, help='port TPID value in hex (e.g. 0x8100)', default=None) parser.add_argument('-v', '--version', action='version', version='%(prog)s 1.0') @@ -263,6 +345,12 @@ def main(): help = 'port interface type', default=None) parser.add_argument('-T', '--adv-interface-types', type = str, required = False, help = 'port advertised interface types', default=None) + parser.add_argument('-lt', '--link-training', type = str, required = False, + help = 'port link training mode', default=None) + parser.add_argument('-P', '--tx-power', type=float, required=False, + help='Tx output power(dBm)', default=None) + parser.add_argument('-F', '--laser-freq', type=int, required=False, + help='Laser frequency(GHz)', default=None) args = parser.parse_args() # Load database config files @@ -271,13 +359,17 @@ def main(): port = portconfig(args.verbose, args.port, args.namespace) if args.list: port.list_params(args.port) - elif args.speed or args.fec or args.mtu or args.autoneg or args.adv_speeds or args.interface_type or args.adv_interface_types or args.tpid: + elif args.speed or args.fec or args.mtu or args.link_training or args.autoneg or args.adv_speeds or \ + args.interface_type or args.adv_interface_types or args.tpid or \ + args.tx_power or args.laser_freq: if args.speed: port.set_speed(args.port, args.speed) if args.fec: port.set_fec(args.port, args.fec) if args.mtu: port.set_mtu(args.port, args.mtu) + if args.link_training: + port.set_link_training(args.port, args.link_training) if args.autoneg: port.set_autoneg(args.port, args.autoneg) if args.adv_speeds: @@ -288,6 +380,17 @@ def main(): port.set_adv_interface_types(args.port, args.adv_interface_types) if args.tpid: port.set_tpid(args.port, args.tpid) + if args.tx_power: + d = decimal.Decimal(str(args.tx_power)) + if d.as_tuple().exponent < -1: + print("Error: tx power must be with single decimal place") + sys.exit(1) + port.set_tx_power(args.port, args.tx_power) + if args.laser_freq: + if args.laser_freq <= 0: + print("Error: Frequency must be > 0") + sys.exit(1) + port.set_laser_freq(args.port, args.laser_freq) else: parser.print_help() sys.exit(1) diff --git a/scripts/portstat b/scripts/portstat index 24c085e9c1..8f4b65321d 100755 --- a/scripts/portstat +++ b/scripts/portstat @@ -38,6 +38,8 @@ from utilities_common.intf_filter import parse_interface_in_filter import utilities_common.multi_asic as multi_asic_util from utilities_common.netstat import ns_diff, table_as_json, format_brate, format_prate, format_util, format_number_with_comma +from utilities_common.cli import UserCache + """ The order and count of statistics mentioned below needs to be in sync with the values in portstat script So, any fields added/deleted in here should be reflected in portstat script also @@ -322,6 +324,8 @@ class Portstat(object): print(table_as_json(table, header)) else: print(tabulate(table, header, tablefmt='simple', stralign='right')) + if multi_asic.is_multi_asic(): + print("\nReminder: Please execute 'show interface counters -d all' to include internal links\n") def cnstat_intf_diff_print(self, cnstat_new_dict, cnstat_old_dict, intf_list): """ @@ -522,7 +526,8 @@ class Portstat(object): print(table_as_json(table, header)) else: print(tabulate(table, header, tablefmt='simple', stralign='right')) - + if multi_asic.is_multi_asic(): + print("\nReminder: Please execute 'show interface counters -d all' to include internal links\n") def main(): parser = argparse.ArgumentParser(description='Display the ports state and counters', @@ -567,7 +572,6 @@ Examples: use_json = args.json raw_stats = args.raw tag_name = args.tag - uid = str(os.getuid()) wait_time_in_seconds = args.period print_all = args.all intf_fs = args.interface @@ -575,36 +579,17 @@ Examples: display_option = args.show detail = args.detail - if tag_name is not None: - cnstat_file = uid + "-" + tag_name - else: - cnstat_file = uid + cache = UserCache(tag=tag_name) - cnstat_dir = "/tmp/portstat-" + uid + cnstat_file = "portstat" + cnstat_dir = cache.get_directory() cnstat_fqn_file = cnstat_dir + "/" + cnstat_file if delete_all_stats: - for file in os.listdir(cnstat_dir): - os.remove(cnstat_dir + "/" + file) - - try: - os.rmdir(cnstat_dir) - sys.exit(0) - except IOError as e: - print(e.errno, e) - sys.exit(e) + cache.remove_all() if delete_saved_stats: - try: - os.remove(cnstat_fqn_file) - except IOError as e: - if e.errno != ENOENT: - print(e.errno, e) - sys.exit(1) - finally: - if os.listdir(cnstat_dir) == []: - os.rmdir(cnstat_dir) - sys.exit(0) + cache.remove() intf_list = parse_interface_in_filter(intf_fs) @@ -622,15 +607,6 @@ Examples: portstat.cnstat_print(cnstat_dict, ratestat_dict, intf_list, use_json, print_all, errors_only, rates_only) sys.exit(0) - # At this point, either we'll create a file or open an existing one. - if not os.path.exists(cnstat_dir): - try: - os.makedirs(cnstat_dir) - except IOError as e: - print(e.errno, e) - sys.exit(1) - - if save_fresh_stats: try: pickle.dump(cnstat_dict, open(cnstat_fqn_file, 'wb')) diff --git a/scripts/queuestat b/scripts/queuestat index b7f4f1d382..19fdca6ae4 100755 --- a/scripts/queuestat +++ b/scripts/queuestat @@ -15,6 +15,7 @@ import sys from collections import namedtuple, OrderedDict from natsort import natsorted from tabulate import tabulate +from sonic_py_common import multi_asic # mock the redis for unit test purposes # try: @@ -24,14 +25,21 @@ try: sys.path.insert(0, modules_path) sys.path.insert(0, tests_path) import mock_tables.dbconnector # lgtm [py/unused-import] + if os.environ["UTILITIES_UNIT_TESTING_TOPOLOGY"] == "multi_asic": + import mock_tables.mock_multi_asic + mock_tables.dbconnector.load_namespace_config() except KeyError: pass from swsscommon.swsscommon import SonicV2Connector +from utilities_common.cli import UserCache +from utilities_common import constants +import utilities_common.multi_asic as multi_asic_util QueueStats = namedtuple("QueueStats", "queueindex, queuetype, totalpacket, totalbytes, droppacket, dropbytes") header = ['Port', 'TxQ', 'Counter/pkts', 'Counter/bytes', 'Drop/pkts', 'Drop/bytes'] +voq_header = ['Port', 'Voq', 'Counter/pkts', 'Counter/bytes', 'Drop/pkts', 'Drop/bytes'] counter_bucket_dict = { 'SAI_QUEUE_STAT_PACKETS': 2, @@ -46,13 +54,17 @@ from utilities_common.netstat import ns_diff, STATUS_NA QUEUE_TYPE_MC = 'MC' QUEUE_TYPE_UC = 'UC' QUEUE_TYPE_ALL = 'ALL' +QUEUE_TYPE_VOQ = 'VOQ' SAI_QUEUE_TYPE_MULTICAST = "SAI_QUEUE_TYPE_MULTICAST" SAI_QUEUE_TYPE_UNICAST = "SAI_QUEUE_TYPE_UNICAST" +SAI_QUEUE_TYPE_UNICAST_VOQ = "SAI_QUEUE_TYPE_UNICAST_VOQ" SAI_QUEUE_TYPE_ALL = "SAI_QUEUE_TYPE_ALL" COUNTER_TABLE_PREFIX = "COUNTERS:" COUNTERS_PORT_NAME_MAP = "COUNTERS_PORT_NAME_MAP" +COUNTERS_SYSTEM_PORT_NAME_MAP = "COUNTERS_SYSTEM_PORT_NAME_MAP" COUNTERS_QUEUE_NAME_MAP = "COUNTERS_QUEUE_NAME_MAP" +COUNTERS_VOQ_NAME_MAP= "COUNTERS_VOQ_NAME_MAP" COUNTERS_QUEUE_TYPE_MAP = "COUNTERS_QUEUE_TYPE_MAP" COUNTERS_QUEUE_INDEX_MAP = "COUNTERS_QUEUE_INDEX_MAP" COUNTERS_QUEUE_PORT_MAP = "COUNTERS_QUEUE_PORT_MAP" @@ -79,9 +91,16 @@ def build_json(port, cnstat): class Queuestat(object): - def __init__(self): - self.db = SonicV2Connector(use_unix_socket_path=False) - self.db.connect(self.db.COUNTERS_DB) + def __init__(self, namespace, voq=False): + self.db = None + self.multi_asic = multi_asic_util.MultiAsic(constants.DISPLAY_ALL, namespace) + if namespace is not None: + for ns in self.multi_asic.get_ns_list_based_on_options(): + self.db = multi_asic.connect_to_all_dbs_for_ns(ns) + else: + self.db = SonicV2Connector(use_unix_socket_path=False) + self.db.connect(self.db.COUNTERS_DB) + self.voq = voq def get_queue_port(table_id): port_table_id = self.db.get(self.db.COUNTERS_DB, COUNTERS_QUEUE_PORT_MAP, table_id) @@ -92,7 +111,11 @@ class Queuestat(object): return port_table_id # Get all ports - self.counter_port_name_map = self.db.get_all(self.db.COUNTERS_DB, COUNTERS_PORT_NAME_MAP) + if voq: + self.counter_port_name_map = self.db.get_all(self.db.COUNTERS_DB, COUNTERS_SYSTEM_PORT_NAME_MAP) + else: + self.counter_port_name_map = self.db.get_all(self.db.COUNTERS_DB, COUNTERS_PORT_NAME_MAP) + if self.counter_port_name_map is None: print("COUNTERS_PORT_NAME_MAP is empty!") sys.exit(1) @@ -104,8 +127,13 @@ class Queuestat(object): self.port_queues_map[port] = {} self.port_name_map[self.counter_port_name_map[port]] = port + counter_queue_name_map = None # Get Queues for each port - counter_queue_name_map = self.db.get_all(self.db.COUNTERS_DB, COUNTERS_QUEUE_NAME_MAP) + if voq: + counter_queue_name_map = self.db.get_all(self.db.COUNTERS_DB, COUNTERS_VOQ_NAME_MAP) + else: + counter_queue_name_map = self.db.get_all(self.db.COUNTERS_DB, COUNTERS_QUEUE_NAME_MAP) + if counter_queue_name_map is None: print("COUNTERS_QUEUE_NAME_MAP is empty!") sys.exit(1) @@ -139,6 +167,8 @@ class Queuestat(object): return QUEUE_TYPE_MC elif queue_type == SAI_QUEUE_TYPE_UNICAST: return QUEUE_TYPE_UC + elif queue_type == SAI_QUEUE_TYPE_UNICAST_VOQ: + return QUEUE_TYPE_VOQ elif queue_type == SAI_QUEUE_TYPE_ALL: return QUEUE_TYPE_ALL else: @@ -189,7 +219,8 @@ class Queuestat(object): json_output[port].update(build_json(port, table)) return json_output else: - print(tabulate(table, header, tablefmt='simple', stralign='right')) + hdr = voq_header if self.voq else header + print(tabulate(table, hdr, tablefmt='simple', stralign='right')) print() def cnstat_diff_print(self, port, cnstat_new_dict, cnstat_old_dict, json_opt): @@ -224,7 +255,8 @@ class Queuestat(object): json_output[port].update(build_json(port, table)) return json_output else: - print(tabulate(table, header, tablefmt='simple', stralign='right')) + hdr = voq_header if self.voq else header + print(tabulate(table, hdr, tablefmt='simple', stralign='right')) print() def get_print_all_stat(self, json_opt): @@ -294,13 +326,6 @@ class Queuestat(object): print(json_dump(json_output)) def save_fresh_stats(self): - if not os.path.exists(cnstat_dir): - try: - os.makedirs(cnstat_dir) - except IOError as e: - print(e.errno, e) - sys.exit(1) - # Get stat for each port and save for port in natsorted(self.counter_port_name_map): cnstat_dict = self.get_cnstat(self.port_queues_map[port]) @@ -331,32 +356,27 @@ Examples: parser.add_argument('-d', '--delete', action='store_true', help='Delete saved stats') parser.add_argument('-v', '--version', action='version', version='%(prog)s 1.0') parser.add_argument('-j', '--json_opt', action='store_true', help='Print in JSON format') + parser.add_argument('-V', '--voq', action='store_true', help='display voq stats') + parser.add_argument('-n','--namespace', default=None, help='Display queue counters for specific namespace') args = parser.parse_args() save_fresh_stats = args.clear - delete_all_stats = args.delete + delete_stats = args.delete json_opt = args.json_opt + voq = args.voq + namespace = args.namespace port_to_show_stats = args.port - uid = str(os.getuid()) - cnstat_file = uid - - cnstat_dir = "/tmp/queuestat-" + uid - cnstat_fqn_file = cnstat_dir + "/" + cnstat_file + cache = UserCache() - if delete_all_stats: - for file in os.listdir(cnstat_dir): - os.remove(cnstat_dir + "/" + file) + cnstat_dir = cache.get_directory() + cnstat_fqn_file = os.path.join(cnstat_dir, 'queuestat') - try: - os.rmdir(cnstat_dir) - sys.exit(0) - except IOError as e: - print(e.errno, e) - sys.exit(e) + if delete_stats: + cache.remove() - queuestat = Queuestat() + queuestat = Queuestat( namespace, voq ) if save_fresh_stats: queuestat.save_fresh_stats() diff --git a/scripts/reboot b/scripts/reboot index fa7315b3b9..7d30c05bda 100755 --- a/scripts/reboot +++ b/scripts/reboot @@ -33,7 +33,7 @@ EXIT_PLATFORM_FW_AU_FAILURE=22 PLATFORM_FWUTIL_AU_REBOOT_HANDLE="platform_fw_au_reboot_handle" REBOOT_SCRIPT_NAME=$(basename $0) REBOOT_TYPE="${REBOOT_SCRIPT_NAME}" -TAG_LATEST=yes +TAG_LATEST=no function debug() { @@ -72,8 +72,21 @@ function stop_sonic_services() fi if [[ x"$ASIC_TYPE" != x"mellanox" ]]; then - debug "Stopping syncd process..." - docker exec -i syncd /usr/bin/syncd_request_shutdown --cold > /dev/null + ASIC_CONF=${DEVPATH}/$PLATFORM/asic.conf + if [ -f "$ASIC_CONF" ]; then + source $ASIC_CONF + fi + if [[ ($NUM_ASIC -gt 1) ]]; then + asic_num=0 + while [[ ($asic_num -lt $NUM_ASIC) ]]; do + debug "Stopping syncd$asic_num process..." + docker exec -i syncd$asic_num /usr/bin/syncd_request_shutdown --cold > /dev/null + ((asic_num = asic_num + 1)) + done + else + debug "Stopping syncd process..." + docker exec -i syncd /usr/bin/syncd_request_shutdown --cold > /dev/null + fi sleep 3 fi stop_pmon_service diff --git a/scripts/route_check.py b/scripts/route_check.py index fdbdd0a5f8..b69c78c06b 100755 --- a/scripts/route_check.py +++ b/scripts/route_check.py @@ -447,6 +447,88 @@ def filter_out_vnet_routes(routes): return updated_routes +def is_dualtor(config_db): + device_metadata = config_db.get_table('DEVICE_METADATA') + subtype = device_metadata['localhost'].get('subtype', '') + return subtype.lower() == 'dualtor' + + +def filter_out_standalone_tunnel_routes(routes): + config_db = swsscommon.ConfigDBConnector() + config_db.connect() + + if not is_dualtor(config_db): + return routes + + app_db = swsscommon.DBConnector('APPL_DB', 0) + neigh_table = swsscommon.Table(app_db, 'NEIGH_TABLE') + neigh_keys = neigh_table.getKeys() + standalone_tunnel_route_ips = [] + updated_routes = [] + + for neigh in neigh_keys: + _, mac = neigh_table.hget(neigh, 'neigh') + if mac == '00:00:00:00:00:00': + # remove preceding 'VlanXXXX' to get just the neighbor IP + neigh_ip = ':'.join(neigh.split(':')[1:]) + standalone_tunnel_route_ips.append(neigh_ip) + + if not standalone_tunnel_route_ips: + return routes + + for route in routes: + ip, subnet = route.split('/') + ip_version = ipaddress.ip_address(ip).version + + # we want to keep the route if it is not a standalone tunnel route. + # if the route subnet contains more than one address, it is not a + # standalone tunnel route + if (ip not in standalone_tunnel_route_ips) or \ + ((ip_version == 6 and subnet != '128') or (ip_version == 4 and subnet != '32')): + updated_routes.append(route) + + return updated_routes + + +def get_soc_ips(config_db): + mux_table = config_db.get_table('MUX_CABLE') + soc_ips = [] + for _, mux_entry in mux_table.items(): + if mux_entry.get("cable_type", "") == "active-active" and "soc_ipv4" in mux_entry: + soc_ips.append(mux_entry["soc_ipv4"]) + + return soc_ips + + +def filter_out_soc_ip_routes(routes): + """ + Ignore ASIC only routes for SOC IPs + + For active-active cables, we want the tunnel route for SOC IPs + to only be programmed to the ASIC and not to the kernel. This is to allow + gRPC connections coming from ycabled to always use the direct link (since this + will use the kernel routing table), but still provide connectivity to any external + traffic in case of a link issue (since this traffic will be forwarded by the ASIC). + """ + config_db = swsscommon.ConfigDBConnector() + config_db.connect() + + if not is_dualtor(config_db): + return routes + + soc_ips = get_soc_ips(config_db) + + if not soc_ips: + return routes + + updated_routes = [] + for route in routes: + if route not in soc_ips: + updated_routes.append(route) + + return updated_routes + + def check_routes(): """ The heart of this script which runs the checks. @@ -483,6 +565,8 @@ def check_routes(): _, rt_asic_miss = diff_sorted_lists(intf_appl, rt_asic_miss) rt_asic_miss = filter_out_default_routes(rt_asic_miss) rt_asic_miss = filter_out_vnet_routes(rt_asic_miss) + rt_asic_miss = filter_out_standalone_tunnel_routes(rt_asic_miss) + rt_asic_miss = filter_out_soc_ip_routes(rt_asic_miss) # Check APPL-DB INTF_TABLE with ASIC table route entries intf_appl_miss, _ = diff_sorted_lists(intf_appl, rt_asic) diff --git a/scripts/route_check_test.sh b/scripts/route_check_test.sh index 505253863e..989cbfae0b 100755 --- a/scripts/route_check_test.sh +++ b/scripts/route_check_test.sh @@ -2,22 +2,36 @@ # add a route, interface & route-entry to simulate error # -sonic-db-cli APPL_DB hmset "ROUTE_TABLE:20c0:d9b8:99:80::/64" "nexthop" "fc00::72,fc00::76,fc00::7a,fc00::7e" "ifname" "PortChannel01,PortChannel02,PortChannel03,PortChannel04" +sonic-db-cli APPL_DB hmset "ROUTE_TABLE:20c0:d9b8:99:80::/64" "nexthop" "fc00::72,fc00::76,fc00::7a,fc00::7e" "ifname" "PortChannel01,PortChannel02,PortChannel03,PortChannel04" > /dev/null +sonic-db-cli ASIC_DB hmset "ASIC_STATE:SAI_OBJECT_TYPE_ROUTE_ENTRY:{\"dest\":\"192.193.120.255/25\",\"switch_id\":\"oid:0x21000000000000\",\"vr\":\"oid:0x3000000000022\"}" "SAI_ROUTE_ENTRY_ATTR_NEXT_HOP_ID" "oid:0x5000000000614" > /dev/null +sonic-db-cli APPL_DB hmset "INTF_TABLE:PortChannel01:10.0.0.99/31" "scope" "global" "family" "IPv4" > /dev/null +echo "------" +echo "expect errors!" +echo "Running Route Check..." +./route_check.py +echo "return value: $?" -sonic-db-cli ASIC_DB hmset "ASIC_STATE:SAI_OBJECT_TYPE_ROUTE_ENTRY:{\"dest\":\"192.193.120.255/25\",\"switch_id\":\"oid:0x21000000000000\",\"vr\":\"oid:0x3000000000022\"}" "SAI_ROUTE_ENTRY_ATTR_NEXT_HOP_ID" "oid:0x5000000000614" +sonic-db-cli APPL_DB del "ROUTE_TABLE:20c0:d9b8:99:80::/64" > /dev/null +sonic-db-cli ASIC_DB del "ASIC_STATE:SAI_OBJECT_TYPE_ROUTE_ENTRY:{\"dest\":\"192.193.120.255/25\",\"switch_id\":\"oid:0x21000000000000\",\"vr\":\"oid:0x3000000000022\"}" > /dev/null +sonic-db-cli APPL_DB del "INTF_TABLE:PortChannel01:10.0.0.99/31" > /dev/null -sonic-db-cli APPL_DB hmset "INTF_TABLE:PortChannel01:10.0.0.99/31" "scope" "global" "family" "IPv4" +# add standalone tunnel route to simulate unreachable neighbor scenario on dual ToR +# in this scenario, we expect the route mismatch to be ignored +sonic-db-cli APPL_DB hmset "NEIGH_TABLE:Vlan1000:fc02:1000::99" "neigh" "00:00:00:00:00:00" "family" "IPv6" > /dev/null +sonic-db-cli ASIC_DB hmset 'ASIC_STATE:SAI_OBJECT_TYPE_ROUTE_ENTRY:{"dest":"fc02:1000::99/128","switch_id":"oid:0x21000000000000","vr":"oid:0x300000000007c"}' "SAI_ROUTE_ENTRY_ATTR_NEXT_HOP_ID" "oid:0x400000000167d" "SAI_ROUTE_ENTRY_ATTR_PACKET_ACTION" "SAI_PACKET_ACTION_FORWARD" > /dev/null -echo "expect errors!\n------\nRunning Route Check...\n" +echo "------" +echo "expect success on dualtor, expect error on all other devices!" +echo "Running Route Check..." ./route_check.py echo "return value: $?" -sonic-db-cli APPL_DB del "ROUTE_TABLE:20c0:d9b8:99:80::/64" -sonic-db-cli ASIC_DB del "ASIC_STATE:SAI_OBJECT_TYPE_ROUTE_ENTRY:{\"dest\":\"192.193.120.255/25\",\"switch_id\":\"oid:0x21000000000000\",\"vr\":\"oid:0x3000000000022\"}" -sonic-db-cli APPL_DB del "INTF_TABLE:PortChannel01:10.0.0.99/31" - +sonic-db-cli APPL_DB del "NEIGH_TABLE:Vlan1000:fc02:1000::99" > /dev/null +sonic-db-cli ASIC_DB del 'ASIC_STATE:SAI_OBJECT_TYPE_ROUTE_ENTRY:{"dest":"fc02:1000::99/128","switch_id":"oid:0x21000000000000","vr":"oid:0x300000000007c"}' > /dev/null -echo "expect success!\n------\nRunning Route Check...\n" +echo "------" +echo "expect success!" +echo "Running Route Check..." ./route_check.py echo "return value: $?" diff --git a/scripts/sfpshow b/scripts/sfpshow index 9e06333277..0787688903 100755 --- a/scripts/sfpshow +++ b/scripts/sfpshow @@ -16,8 +16,9 @@ import click from natsort import natsorted from sonic_py_common.interface import front_panel_prefix, backplane_prefix, inband_prefix, recirc_prefix from sonic_py_common import multi_asic +from utilities_common.sfp_helper import covert_application_advertisement_to_output_string +from utilities_common.sfp_helper import QSFP_DATA_MAP from tabulate import tabulate -from utilities_common import multi_asic as multi_asic_util # Mock the redis DB for unit test purposes try: @@ -27,32 +28,18 @@ try: sys.path.insert(0, modules_path) sys.path.insert(0, test_path) import mock_tables.dbconnector + from mock_platform_sfputil.mock_platform_sfputil import mock_platform_sfputil_helper + mock_platform_sfputil_helper() if os.environ["UTILITIES_UNIT_TESTING_TOPOLOGY"] == "multi_asic": import mock_tables.mock_multi_asic mock_tables.dbconnector.load_namespace_config() except KeyError: pass -# TODO: We should share these maps and the formatting functions between sfputil and sfpshow -QSFP_DATA_MAP = { - 'model': 'Vendor PN', - 'vendor_oui': 'Vendor OUI', - 'vendor_date': 'Vendor Date Code(YYYY-MM-DD Lot)', - 'manufacturer': 'Vendor Name', - 'vendor_rev': 'Vendor Rev', - 'serial': 'Vendor SN', - 'type': 'Identifier', - 'ext_identifier': 'Extended Identifier', - 'ext_rateselect_compliance': 'Extended RateSelect Compliance', - 'cable_length': 'cable_length', - 'cable_type': 'Length', - 'nominal_bit_rate': 'Nominal Bit Rate(100Mbs)', - 'specification_compliance': 'Specification compliance', - 'encoding': 'Encoding', - 'connector': 'Connector', - 'application_advertisement': 'Application Advertisement' -} +from utilities_common import multi_asic as multi_asic_util +from utilities_common.platform_sfputil_helper import is_rj45_port, RJ45_PORT_TYPE +# TODO: We should share these maps and the formatting functions between sfputil and sfpshow SFP_DOM_CHANNEL_MONITOR_MAP = { 'rx1power': 'RXPower', 'tx1bias': 'TXBias', @@ -229,7 +216,6 @@ def display_invalid_intf_presence(intf_name): class SFPShow(object): - def __init__(self, intf_name, namespace_option, dump_dom=False): super(SFPShow, self).__init__() self.db = None @@ -284,6 +270,8 @@ class SFPShow(object): output += '{}{}: {}\n'.format((indent * 2), compliance_key, spec_compliance_dict[compliance_key]) except ValueError as e: output += '{}N/A\n'.format((indent * 2)) + elif key == 'application_advertisement': + output += covert_application_advertisement_to_output_string(indent, sfp_info_dict) else: output += '{}{}: {}\n'.format(indent, QSFP_DATA_MAP[key], sfp_info_dict[key]) @@ -392,38 +380,48 @@ class SFPShow(object): output = '' sfp_info_dict = state_db.get_all(state_db.STATE_DB, 'TRANSCEIVER_INFO|{}'.format(interface_name)) - output = 'SFP EEPROM detected\n' - sfp_info_output = self.convert_sfp_info_to_output_string(sfp_info_dict) - output += sfp_info_output - - if dump_dom: - sfp_type = sfp_info_dict['type'] - dom_info_dict = state_db.get_all(state_db.STATE_DB, 'TRANSCEIVER_DOM_SENSOR|{}'.format(interface_name)) - dom_output = self.convert_dom_to_output_string(sfp_type, dom_info_dict) - output += dom_output + if sfp_info_dict: + if sfp_info_dict['type'] == RJ45_PORT_TYPE: + output = 'SFP EEPROM is not applicable for RJ45 port\n' + else: + output = 'SFP EEPROM detected\n' + sfp_info_output = self.convert_sfp_info_to_output_string(sfp_info_dict) + output += sfp_info_output + + if dump_dom: + sfp_type = sfp_info_dict['type'] + dom_info_dict = state_db.get_all(state_db.STATE_DB, 'TRANSCEIVER_DOM_SENSOR|{}'.format(interface_name)) + dom_info_dict.update(state_db.get_all(state_db.STATE_DB, 'TRANSCEIVER_DOM_THRESHOLD|{}'.format(interface_name))) + dom_output = self.convert_dom_to_output_string(sfp_type, dom_info_dict) + output += dom_output + else: + if is_rj45_port(interface_name): + output = 'SFP EEPROM is not applicable for RJ45 port\n' + else: + output = "SFP EEPROM Not detected\n" return output @multi_asic_util.run_on_multi_asic def get_eeprom(self): if self.intf_name is not None: - presence = self.db.exists(self.db.STATE_DB, 'TRANSCEIVER_INFO|{}'.format(self.intf_name)) - if presence: - self.intf_eeprom[self.intf_name] = self.convert_interface_sfp_info_to_cli_output_string( - self.db, self.intf_name, self.dump_dom) - else: - self.intf_eeprom[self.intf_name] = "SFP EEPROM Not detected\n" + self.intf_eeprom[self.intf_name] = self.convert_interface_sfp_info_to_cli_output_string( + self.db, self.intf_name, self.dump_dom) else: port_table_keys = self.db.keys(self.db.APPL_DB, "PORT_TABLE:*") for i in port_table_keys: interface = re.split(':', i, maxsplit=1)[-1].strip() if interface and interface.startswith(front_panel_prefix()) and not interface.startswith((backplane_prefix(), inband_prefix(), recirc_prefix())): - presence = self.db.exists(self.db.STATE_DB, 'TRANSCEIVER_INFO|{}'.format(interface)) - if presence: - self.intf_eeprom[interface] = self.convert_interface_sfp_info_to_cli_output_string( - self.db, interface, self.dump_dom) - else: - self.intf_eeprom[interface] = "SFP EEPROM Not detected\n" + self.intf_eeprom[interface] = self.convert_interface_sfp_info_to_cli_output_string( + self.db, interface, self.dump_dom) + + def convert_interface_sfp_presence_state_to_cli_output_string(self, state_db, interface_name): + sfp_info_dict = state_db.get_all(self.db.STATE_DB, 'TRANSCEIVER_INFO|{}'.format(interface_name)) + if sfp_info_dict: + output = 'Present' + else: + output = 'Not present' + return output @multi_asic_util.run_on_multi_asic @@ -431,21 +429,15 @@ class SFPShow(object): port_table = [] if self.intf_name is not None: - presence = self.db.exists(self.db.STATE_DB, 'TRANSCEIVER_INFO|{}'.format(self.intf_name)) - if presence: - port_table.append((self.intf_name, 'Present')) - else: - port_table.append((self.intf_name, 'Not present')) + presence_string = self.convert_interface_sfp_presence_state_to_cli_output_string(self.db, self.intf_name) + port_table.append((self.intf_name, presence_string)) else: port_table_keys = self.db.keys(self.db.APPL_DB, "PORT_TABLE:*") for i in port_table_keys: key = re.split(':', i, maxsplit=1)[-1].strip() if key and key.startswith(front_panel_prefix()) and not key.startswith((backplane_prefix(), inband_prefix(), recirc_prefix())): - presence = self.db.exists(self.db.STATE_DB, 'TRANSCEIVER_INFO|{}'.format(key)) - if presence: - port_table.append((key, 'Present')) - else: - port_table.append((key, 'Not present')) + presence_string = self.convert_interface_sfp_presence_state_to_cli_output_string(self.db, key) + port_table.append((key, presence_string)) self.table += port_table diff --git a/scripts/storyteller b/scripts/storyteller index b342c722c5..5d1420673f 100755 --- a/scripts/storyteller +++ b/scripts/storyteller @@ -20,6 +20,7 @@ regex_dict = { 'lag' : r'link becomes\|addLag\|PortChannel.*oper state', 'reboot' : r'BOOT\|rc.local\|old_config\|minigraph.xml\|Rebooting\|reboot\|executeOperationsOnAsic\|getAsicView\|dumpVidToAsicOperatioId\|neighbor_adv\|Pausing\|shutdown\|warm', 'service' : r'Starting\|Stopping\|Started\|Stopped', + 'linkprober': r'Received link prober event, new state' } @@ -86,7 +87,7 @@ def main(): parser.add_argument('-l', '--log', help='log file prefix, e.g. syslog; default: syslog', type=str, required=False, default='syslog') - parser.add_argument('-c', '--category', help='Categories: bgp, crash, interface, lag, reboot, service Specify multiple categories as c1,c2,c3; default: reboot', + parser.add_argument('-c', '--category', help='Categories: bgp, crash, interface, lag, reboot, service, linkprober Specify multiple categories as c1,c2,c3; default: reboot', type=str, required=False, default='reboot') parser.add_argument('-p', '--logpath', help='log file path, e.g. /var/log; default: /var/log', type=str, required=False, default='/var/log') diff --git a/scripts/tunnelstat b/scripts/tunnelstat index 00aab5d832..8b045ec684 100755 --- a/scripts/tunnelstat +++ b/scripts/tunnelstat @@ -29,6 +29,7 @@ from collections import namedtuple, OrderedDict from natsort import natsorted from tabulate import tabulate from utilities_common.netstat import ns_diff, table_as_json, STATUS_NA, format_prate +from utilities_common.cli import UserCache from swsscommon.swsscommon import SonicV2Connector @@ -112,12 +113,12 @@ class Tunnelstat(object): if counter_tunnel_type_map is None: print("No %s in the DB!" % COUNTERS_TUNNEL_TYPE_MAP) - sys.exit(1) + sys.exit(1) if tun_type and tun_type not in counter_types: print("Unknown tunnel type %s" % tun_type) sys.exit(1) - + if tunnel and not tunnel in counter_tunnel_name_map: print("Interface %s missing from %s! Make sure it exists" % (tunnel, COUNTERS_TUNNEL_NAME_MAP)) sys.exit(2) @@ -250,56 +251,26 @@ def main(): delete_all_stats = args.delete_all use_json = args.json tag_name = args.tag if args.tag else "" - uid = str(os.getuid()) wait_time_in_seconds = args.period tunnel_name = args.tunnel if args.tunnel else "" tunnel_type = args.type if args.type else "" - # fancy filename with dashes: uid-tag-tunnel / uid-tunnel / uid-tag etc - filename_components = [uid, tag_name] - cnstat_file = "-".join(filter(None, filename_components)) + cache = UserCache(tag=tag_name) + + cnstat_file = "tunnelstat" - cnstat_dir = "/tmp/tunnelstat-" + uid + cnstat_dir = cache.get_directory() cnstat_fqn_file = cnstat_dir + "/" + cnstat_file if delete_all_stats: - # There is nothing to delete - if not os.path.isdir(cnstat_dir): - sys.exit(0) - - for file in os.listdir(cnstat_dir): - os.remove(cnstat_dir + "/" + file) - - try: - os.rmdir(cnstat_dir) - sys.exit(0) - except IOError as e: - print(e.errno, e) - sys.exit(e) + cache.remove_all() if delete_saved_stats: - try: - os.remove(cnstat_fqn_file) - except IOError as e: - if e.errno != ENOENT: - print(e.errno, e) - sys.exit(1) - finally: - if os.listdir(cnstat_dir) == []: - os.rmdir(cnstat_dir) - sys.exit(0) + cache.remove() tunnelstat = Tunnelstat() cnstat_dict,ratestat_dict = tunnelstat.get_cnstat(tunnel=tunnel_name, tun_type=tunnel_type) - # At this point, either we'll create a file or open an existing one. - if not os.path.exists(cnstat_dir): - try: - os.makedirs(cnstat_dir) - except IOError as e: - print(e.errno, e) - sys.exit(1) - if save_fresh_stats: try: pickle.dump(cnstat_dict, open(cnstat_fqn_file, 'wb')) diff --git a/scripts/vnet_route_check.py b/scripts/vnet_route_check.py index b2c798dfb0..dcd56af186 100755 --- a/scripts/vnet_route_check.py +++ b/scripts/vnet_route_check.py @@ -47,7 +47,7 @@ RC_OK = 0 RC_ERR = -1 - +default_vrf_oid = "" report_level = syslog.LOG_ERR write_to_syslog = True @@ -93,7 +93,7 @@ def get_vnet_intfs(): vnet_intfs = {} for intf_key in intfs_keys: - intf_attrs = intfs_table.get(intf_key)[1] + intf_attrs = dict(intfs_table.get(intf_key)[1]) if 'vnet_name' in intf_attrs: vnet_name = intf_attrs['vnet_name'] @@ -110,14 +110,9 @@ def get_all_rifs_oids(): Format: { : } ''' db = swsscommon.DBConnector('COUNTERS_DB', 0) - rif_table = swsscommon.Table(db, 'COUNTERS_RIF_NAME_MAP') - rif_keys = rif_table.getKeys() - - rif_name_oid_map = {} - for rif_name in rif_keys: - rif_name_oid_map[rif_name] = rif_table.get(rif_name)[1] + rif_name_oid_map = dict(rif_table.get('')[1]) return rif_name_oid_map @@ -156,8 +151,8 @@ def get_vrf_entries(): db_keys = rif_table.getKeys() for db_key in db_keys: - if 'SAI_OBJECT_TYPE_ROUTER_INTERFACE' in db_key: - rif_attrs = rif_table.get(db_key)[1] + if (db_key == f'SAI_OBJECT_TYPE_ROUTER_INTERFACE:{vnet_rifs_oids[vnet_rif_name]}'): + rif_attrs = dict(rif_table.get(db_key)[1]) rif_vrf_map[vnet_rif_name] = rif_attrs['SAI_ROUTER_INTERFACE_ATTR_VIRTUAL_ROUTER_ID'] return rif_vrf_map @@ -216,7 +211,7 @@ def get_vnet_routes_from_app_db(): vnet_routes = {} for vnet_route_db_key in vnet_routes_db_keys: - vnet_route_list = vnet_route_db_key.split(':') + vnet_route_list = vnet_route_db_key.split(':',1) vnet_name = vnet_route_list[0] vnet_route = vnet_route_list[1] @@ -224,8 +219,22 @@ def get_vnet_routes_from_app_db(): vnet_routes[vnet_name] = {} vnet_routes[vnet_name]['routes'] = [] - intf = vnet_intfs[vnet_name][0] - vnet_routes[vnet_name]['vrf_oid'] = vnet_vrfs.get(intf, 'None') + if vnet_name not in vnet_intfs: + # this route has no vnet_intf and may be part of default VRF. + vnet_table = swsscommon.Table(db, 'VNET_TABLE') + scope_value = "" + # "Vnet_v4_in_v4-0": [("vxlan_tunnel", "tunnel_v4"), ("scope", "default"), ("vni", "10000"), ("peer_list", "")] + for key,value in vnet_table.get(vnet_name)[1]: + if key == "scope": + scope_value = value + break + if scope_value == 'default': + vnet_routes[vnet_name]['vrf_oid'] = default_vrf_oid + else: + assert "Non-default VRF route present without vnet interface." + else: + intf = vnet_intfs[vnet_name][0] + vnet_routes[vnet_name]['vrf_oid'] = vnet_vrfs.get(intf, 'None') vnet_routes[vnet_name]['routes'].append(vnet_route) @@ -242,10 +251,12 @@ def get_vnet_routes_from_asic_db(): vnet_vrfs = get_vrf_entries() vnet_vrfs_oids = [vnet_vrfs[k] for k in vnet_vrfs] + vnet_vrfs_oids.append(default_vrf_oid) vnet_intfs = get_vnet_intfs() vrf_oid_to_vnet_map = {} + vrf_oid_to_vnet_map[default_vrf_oid] = 'default_VRF' for vnet_name, vnet_rifs in vnet_intfs.items(): for vnet_rif, vrf_oid in vnet_vrfs.items(): @@ -281,7 +292,22 @@ def get_vnet_routes_from_asic_db(): return vnet_routes -def get_vnet_routes_diff(routes_1, routes_2): +def check_routes_with_default_vrf(vnet_name, vnet_attrs, routes_1, routes): + for vnet_route in vnet_attrs['routes']: + ispresent = False + for vnet_name_other, vnet_attrs_other in routes_1.items(): + if vnet_route in vnet_attrs_other['routes']: + ispresent = True + if not ispresent: + if vnet_name not in routes: + routes[vnet_name] = {} + routes[vnet_name]['routes'] = [] + routes[vnet_name]['routes'].append(vnet_route) + + return + + +def get_vnet_routes_diff(routes_1, routes_2, verify_default_vrf_routes = False): ''' Returns all routes present in routes_2 dictionary but missed in routes_1 Format: { : { 'routes': [ ] } } ''' @@ -289,15 +315,21 @@ def get_vnet_routes_diff(routes_1, routes_2): routes = {} for vnet_name, vnet_attrs in routes_2.items(): - if vnet_name not in routes_1: - routes[vnet_name] = routes + if vnet_attrs['vrf_oid'] == default_vrf_oid: + if verify_default_vrf_routes: + check_routes_with_default_vrf(vnet_name, vnet_attrs, routes_1, routes) + else: + continue else: - for vnet_route in vnet_attrs['routes']: - if vnet_route not in routes_1[vnet_name]['routes']: - if vnet_name not in routes: - routes[vnet_name] = {} - routes[vnet_name]['routes'] = [] - routes[vnet_name]['routes'].append(vnet_route) + if vnet_name not in routes_1: + routes[vnet_name] = vnet_attrs['routes'].copy() + else: + for vnet_route in vnet_attrs['routes']: + if vnet_route not in routes_1[vnet_name]['routes']: + if vnet_name not in routes: + routes[vnet_name] = {} + routes[vnet_name]['routes'] = [] + routes[vnet_name]['routes'].append(vnet_route) return routes @@ -331,11 +363,16 @@ def main(): # Don't run VNET routes consistancy logic if there is no VNET configuration if not check_vnet_cfg(): return rc + asic_db = swsscommon.DBConnector('ASIC_DB', 0) + virtual_router = swsscommon.Table(asic_db, 'ASIC_STATE:SAI_OBJECT_TYPE_VIRTUAL_ROUTER') + if virtual_router.getKeys() != []: + global default_vrf_oid + default_vrf_oid = virtual_router.getKeys()[0] app_db_vnet_routes = get_vnet_routes_from_app_db() asic_db_vnet_routes = get_vnet_routes_from_asic_db() - missed_in_asic_db_routes = get_vnet_routes_diff(asic_db_vnet_routes, app_db_vnet_routes) + missed_in_asic_db_routes = get_vnet_routes_diff(asic_db_vnet_routes, app_db_vnet_routes,True) missed_in_app_db_routes = get_vnet_routes_diff(app_db_vnet_routes, asic_db_vnet_routes) missed_in_sdk_routes = get_sdk_vnet_routes_diff(asic_db_vnet_routes) @@ -356,8 +393,8 @@ def main(): rc = RC_ERR print_message(syslog.LOG_ERR, json.dumps(res, indent=4)) print_message(syslog.LOG_ERR, 'Vnet Route Mismatch reported') - - return rc, res + return rc, res + return rc if __name__ == "__main__": diff --git a/scripts/watermarkstat b/scripts/watermarkstat index ffcec56fa9..6ff3587e75 100755 --- a/scripts/watermarkstat +++ b/scripts/watermarkstat @@ -21,8 +21,16 @@ try: tests_path = os.path.join(modules_path, "tests") sys.path.insert(0, modules_path) sys.path.insert(0, tests_path) - import mock_tables.dbconnector + from mock_tables import dbconnector + if os.environ["WATERMARKSTAT_UNIT_TESTING"] == "1": + input_path = os.path.join(tests_path, "wm_input") + mock_db_path = os.path.join(input_path, "mock_db") + + for mock_db in os.listdir(mock_db_path): + name, ext = os.path.splitext(mock_db) + if ext == ".json": + dbconnector.dedicated_dbs[name.upper()] = os.path.join(mock_db_path, name) except KeyError: pass @@ -201,23 +209,37 @@ class Watermarkstat(object): return pg_index - def build_header(self, wm_type): + def build_header(self, wm_type, counter_type): if wm_type is None: print("Header info is not available!", file=sys.stderr) sys.exit(1) self.header_list = ['Port'] header_map = wm_type["obj_map"] - single_key = list(header_map.keys())[0] - header_len = len(header_map[single_key]) - min_idx = sys.maxsize - for name, counter_oid in header_map[single_key].items(): - curr_idx = int(wm_type["idx_func"](counter_oid)) - min_idx = min(min_idx, curr_idx) + header_idx_set = set() + for port in header_map.keys(): + for element in header_map[port].keys(): + element_idx = int(element.split(':')[1]) + header_idx_set.add(element_idx) + + if len(header_idx_set) == 0: + if counter_type != 'q_shared_multi': + print("Object map is empty!", file=sys.stderr) + sys.exit(1) + else: + print("Object map from the COUNTERS_DB is empty because the multicast queues are not configured in the CONFIG_DB!") + sys.exit(0) + + header_idx_list = list(header_idx_set) + header_idx_list.sort() + + self.header_idx_to_pos = {} + for i in header_idx_list: + self.header_idx_to_pos[i] = header_idx_list.index(i) - self.min_idx = min_idx - self.header_list += ["{}{}".format(wm_type["header_prefix"], idx) for idx in range(self.min_idx, self.min_idx + header_len)] + self.min_idx = header_idx_list[0] + self.header_list += ["{}{}".format(wm_type["header_prefix"], idx) for idx in header_idx_list] def get_counters(self, table_prefix, port_obj, idx_func, watermark): """ @@ -230,7 +252,7 @@ class Watermarkstat(object): for name, obj_id in port_obj.items(): full_table_id = table_prefix + obj_id idx = int(idx_func(obj_id)) - pos = idx - self.min_idx + pos = self.header_idx_to_pos[idx] counter_data = self.counters_db.get(self.counters_db.COUNTERS_DB, full_table_id, watermark) if counter_data is None or counter_data == '': fields[pos] = STATUS_NA @@ -254,7 +276,7 @@ class Watermarkstat(object): data = STATUS_NA table.append((buf_pool, data)) else: - self.build_header(type) + self.build_header(type, key) # Get stat for each port for port in natsorted(self.counter_port_name_map): row_data = list() diff --git a/setup.py b/setup.py index 7ee1eb8574..d5140e16f1 100644 --- a/setup.py +++ b/setup.py @@ -90,6 +90,7 @@ 'scripts/coredump-compress', 'scripts/configlet', 'scripts/db_migrator.py', + 'scripts/db_migrator_constants.py', 'scripts/decode-syseeprom', 'scripts/dropcheck', 'scripts/disk_check.py', @@ -97,6 +98,7 @@ 'scripts/dropstat', 'scripts/dump_nat_entries.py', 'scripts/ecnconfig', + 'scripts/fabricstat', 'scripts/fanshow', 'scripts/fast-reboot', 'scripts/fast-reboot-dump.py', @@ -146,6 +148,8 @@ 'scripts/centralize_database', 'scripts/null_route_helper', 'scripts/coredump_gen_handler.py', + 'scripts/memory_threshold_check.py', + 'scripts/memory_threshold_check_handler.py', 'scripts/techsupport_cleanup.py', 'scripts/check_db_integrity.py' ], @@ -212,6 +216,7 @@ 'toposort==1.6', 'www-authenticate==0.9.2', 'xmltodict==0.12.0', + 'lazy-object-proxy', ], setup_requires= [ 'pytest-runner', diff --git a/sfputil/main.py b/sfputil/main.py index 91cb372bac..b3bf001b71 100644 --- a/sfputil/main.py +++ b/sfputil/main.py @@ -16,9 +16,12 @@ import click import sonic_platform import sonic_platform_base.sonic_sfp.sfputilhelper +from sonic_platform_base.sfp_base import SfpBase from swsscommon.swsscommon import SonicV2Connector from natsort import natsorted from sonic_py_common import device_info, logger, multi_asic +from utilities_common.sfp_helper import covert_application_advertisement_to_output_string +from utilities_common.sfp_helper import QSFP_DATA_MAP from tabulate import tabulate VERSION = '3.0' @@ -43,26 +46,12 @@ MAX_LPL_FIRMWARE_BLOCK_SIZE = 116 #Bytes -# TODO: We should share these maps and the formatting functions between sfputil and sfpshow -QSFP_DATA_MAP = { - 'model': 'Vendor PN', - 'vendor_oui': 'Vendor OUI', - 'vendor_date': 'Vendor Date Code(YYYY-MM-DD Lot)', - 'manufacturer': 'Vendor Name', - 'vendor_rev': 'Vendor Rev', - 'serial': 'Vendor SN', - 'type': 'Identifier', - 'ext_identifier': 'Extended Identifier', - 'ext_rateselect_compliance': 'Extended RateSelect Compliance', - 'cable_length': 'cable_length', - 'cable_type': 'Length', - 'nominal_bit_rate': 'Nominal Bit Rate(100Mbs)', - 'specification_compliance': 'Specification compliance', - 'encoding': 'Encoding', - 'connector': 'Connector', - 'application_advertisement': 'Application Advertisement' -} +PAGE_SIZE = 128 +PAGE_OFFSET = 128 + +SFF8472_A0_SIZE = 256 +# TODO: We should share these maps and the formatting functions between sfputil and sfpshow QSFP_DD_DATA_MAP = { 'model': 'Vendor PN', 'vendor_oui': 'Vendor OUI', @@ -267,6 +256,7 @@ 'voltage': 'Volts' } +RJ45_PORT_TYPE = 'RJ45' # Global platform-specific Chassis class instance platform_chassis = None @@ -289,6 +279,17 @@ def is_sfp_present(port_name): return bool(presence) + +def is_port_type_rj45(port_name): + physical_port = logical_port_to_physical_port_index(port_name) + + try: + port_types = platform_chassis.get_port_or_cage_type(physical_port) + return SfpBase.SFP_PORT_TYPE_BIT_RJ45 == port_types + except NotImplementedError: + pass + + return False # ========================== Methods for formatting output ========================== # Convert dict values to cli output string @@ -325,27 +326,15 @@ def convert_sfp_info_to_output_string(sfp_info_dict): elif key == 'cable_length': pass elif key == 'specification_compliance': - if sfp_info_dict['type'] == "QSFP-DD Double Density 8X Pluggable Transceiver" or \ - sfp_info_dict['type'] == "OSFP 8X Pluggable Transceiver" or \ - sfp_info_dict['type'] == "QSFP+ or later with CMIS": - output += '{}{}: {}\n'.format(indent, QSFP_DD_DATA_MAP[key], sfp_info_dict[key]) - else: - output += '{}{}:\n'.format(indent, QSFP_DD_DATA_MAP['specification_compliance']) - - spec_compliance_dict = {} - try: - spec_compliance_dict = ast.literal_eval(sfp_info_dict['specification_compliance']) - sorted_compliance_key_table = natsorted(spec_compliance_dict) - for compliance_key in sorted_compliance_key_table: - output += '{}{}: {}\n'.format((indent * 2), compliance_key, spec_compliance_dict[compliance_key]) - except ValueError as e: - output += '{}N/A\n'.format((indent * 2)) - elif key == 'application_advertisement': - pass + output += '{}{}: {}\n'.format(indent, QSFP_DD_DATA_MAP[key], sfp_info_dict[key]) elif key == 'supported_max_tx_power' or key == 'supported_min_tx_power': - output += '{}{}: {}dBm\n'.format(indent, QSFP_DD_DATA_MAP[key], sfp_info_dict[key]) + if key in sfp_info_dict: # C-CMIS compliant / coherent modules + output += '{}{}: {}dBm\n'.format(indent, QSFP_DD_DATA_MAP[key], sfp_info_dict[key]) elif key == 'supported_max_laser_freq' or key == 'supported_min_laser_freq': - output += '{}{}: {}GHz\n'.format(indent, QSFP_DD_DATA_MAP[key], sfp_info_dict[key]) + if key in sfp_info_dict: # C-CMIS compliant / coherent modules + output += '{}{}: {}GHz\n'.format(indent, QSFP_DD_DATA_MAP[key], sfp_info_dict[key]) + elif key == 'application_advertisement': + output += covert_application_advertisement_to_output_string(indent, sfp_info_dict) else: try: output += '{}{}: {}\n'.format(indent, QSFP_DD_DATA_MAP[key], sfp_info_dict[key]) @@ -360,21 +349,16 @@ def convert_sfp_info_to_output_string(sfp_info_dict): elif key == 'cable_length': pass elif key == 'specification_compliance': - if sfp_info_dict['type'] == "QSFP-DD Double Density 8X Pluggable Transceiver" or \ - sfp_info_dict['type'] == "OSFP 8X Pluggable Transceiver" or \ - sfp_info_dict['type'] == "QSFP+ or later with CMIS": - output += '{}{}: {}\n'.format(indent, QSFP_DATA_MAP[key], sfp_info_dict[key]) - else: - output += '{}{}:\n'.format(indent, QSFP_DATA_MAP['specification_compliance']) + output += '{}{}:\n'.format(indent, QSFP_DATA_MAP['specification_compliance']) - spec_compliance_dict = {} - try: - spec_compliance_dict = ast.literal_eval(sfp_info_dict['specification_compliance']) - sorted_compliance_key_table = natsorted(spec_compliance_dict) - for compliance_key in sorted_compliance_key_table: - output += '{}{}: {}\n'.format((indent * 2), compliance_key, spec_compliance_dict[compliance_key]) - except ValueError as e: - output += '{}N/A\n'.format((indent * 2)) + spec_compliance_dict = {} + try: + spec_compliance_dict = ast.literal_eval(sfp_info_dict['specification_compliance']) + sorted_compliance_key_table = natsorted(spec_compliance_dict) + for compliance_key in sorted_compliance_key_table: + output += '{}{}: {}\n'.format((indent * 2), compliance_key, spec_compliance_dict[compliance_key]) + except ValueError as e: + output += '{}N/A\n'.format((indent * 2)) else: output += '{}{}: {}\n'.format(indent, QSFP_DATA_MAP[key], sfp_info_dict[key]) @@ -649,6 +633,11 @@ def eeprom(port, dump_dom, namespace): for physical_port in physical_port_list: port_name = get_physical_port_name(logical_port_name, i, ganged) + if is_port_type_rj45(port_name): + output += "{}: SFP EEPROM is not applicable for RJ45 port\n".format(port_name) + output += '\n' + continue + try: presence = platform_chassis.get_sfp(physical_port).get_presence() except NotImplementedError: @@ -689,6 +678,148 @@ def eeprom(port, dump_dom, namespace): click.echo(output) +# 'eeprom-hexdump' subcommand +@show.command() +@click.option('-p', '--port', metavar='', required=True, help="Display SFP EEPROM hexdump for port ") +@click.option('-n', '--page', metavar='', help="Display SFP EEEPROM hexdump for ") +def eeprom_hexdump(port, page): + """Display EEPROM hexdump of SFP transceiver(s) for a given port name and page number""" + output = "" + + if platform_sfputil.is_logical_port(port) == 0: + click.echo("Error: invalid port {}".format(port)) + print_all_valid_port_values() + sys.exit(ERROR_INVALID_PORT) + + if page is None: + page = '0' + + logical_port_name = port + physical_port = logical_port_to_physical_port_index(logical_port_name) + + if is_port_type_rj45(logical_port_name): + click.echo("{}: SFP EEPROM Hexdump is not applicable for RJ45 port".format(port)) + sys.exit(ERROR_INVALID_PORT) + + try: + presence = platform_chassis.get_sfp(physical_port).get_presence() + except NotImplementedError: + click.echo("Sfp.get_presence() is currently not implemented for this platform") + sys.exit(ERROR_NOT_IMPLEMENTED) + + if not presence: + click.echo("SFP EEPROM not detected") + sys.exit(ERROR_NOT_IMPLEMENTED) + else: + try: + id = platform_chassis.get_sfp(physical_port).read_eeprom(0, 1) + if id is None: + click.echo("Error: Failed to read EEPROM for offset 0!") + sys.exit(ERROR_NOT_IMPLEMENTED) + except NotImplementedError: + click.echo("Sfp.read_eeprom() is currently not implemented for this platform") + sys.exit(ERROR_NOT_IMPLEMENTED) + + if id[0] == 0x3: + output = eeprom_hexdump_sff8472(port, physical_port, page) + else: + output = eeprom_hexdump_sff8636(port, physical_port, page) + + output += '\n' + + click.echo(output) + +def eeprom_hexdump_sff8472(port, physical_port, page): + try: + output = "" + indent = ' ' * 8 + output += 'EEPROM hexdump for port {} page {}h'.format(port, page) + output += '\n{}A0h dump'.format(indent) + page_dump = platform_chassis.get_sfp(physical_port).read_eeprom(0, SFF8472_A0_SIZE) + if page_dump is None: + click.echo("Error: Failed to read EEPROM for A0h!") + sys.exit(ERROR_NOT_IMPLEMENTED) + + output += hexdump(indent, page_dump, 0) + page_dump = platform_chassis.get_sfp(physical_port).read_eeprom(SFF8472_A0_SIZE, PAGE_SIZE) + if page_dump is None: + click.echo("Error: Failed to read EEPROM for A2h!") + sys.exit(ERROR_NOT_IMPLEMENTED) + else: + output += '\n\n{}A2h dump (lower 128 bytes)'.format(indent) + output += hexdump(indent, page_dump, 0) + + page_dump = platform_chassis.get_sfp(physical_port).read_eeprom(SFF8472_A0_SIZE + PAGE_OFFSET + (int(page, base=16) * PAGE_SIZE), PAGE_SIZE) + if page_dump is None: + click.echo("Error: Failed to read EEPROM for A2h upper page!") + sys.exit(ERROR_NOT_IMPLEMENTED) + else: + output += '\n\n{}A2h dump (upper 128 bytes) page {}h'.format(indent, page) + output += hexdump(indent, page_dump, PAGE_OFFSET) + except NotImplementedError: + click.echo("Sfp.read_eeprom() is currently not implemented for this platform") + sys.exit(ERROR_NOT_IMPLEMENTED) + except ValueError: + click.echo("Please enter a numeric page number") + sys.exit(ERROR_NOT_IMPLEMENTED) + + return output + +def eeprom_hexdump_sff8636(port, physical_port, page): + try: + output = "" + indent = ' ' * 8 + output += 'EEPROM hexdump for port {} page {}h'.format(port, page) + output += '\n{}Lower page 0h'.format(indent) + page_dump = platform_chassis.get_sfp(physical_port).read_eeprom(0, PAGE_SIZE) + if page_dump is None: + click.echo("Error: Failed to read EEPROM for page 0!") + sys.exit(ERROR_NOT_IMPLEMENTED) + + output += hexdump(indent, page_dump, 0) + page_dump = platform_chassis.get_sfp(physical_port).read_eeprom(int(page, base=16) * PAGE_SIZE + PAGE_OFFSET, PAGE_SIZE) + if page_dump is None: + click.echo("Error: Failed to read EEPROM!") + sys.exit(ERROR_NOT_IMPLEMENTED) + else: + output += '\n\n{}Upper page {}h'.format(indent, page) + output += hexdump(indent, page_dump, PAGE_OFFSET) + except NotImplementedError: + click.echo("Sfp.read_eeprom() is currently not implemented for this platform") + sys.exit(ERROR_NOT_IMPLEMENTED) + except ValueError: + click.echo("Please enter a numeric page number") + sys.exit(ERROR_NOT_IMPLEMENTED) + + return output + +def convert_byte_to_valid_ascii_char(byte): + if byte < 32 or 126 < byte: + return '.' + else: + return chr(byte) + +def hexdump(indent, data, mem_address): + ascii_string = '' + result = '' + for byte in data: + ascii_string = ascii_string + convert_byte_to_valid_ascii_char(byte) + byte_string = "{:02x}".format(byte) + if mem_address % 16 == 0: + mem_address_string = "{:08x}".format(mem_address) + result += '\n{}{} '.format(indent, mem_address_string) + result += '{} '.format(byte_string) + elif mem_address % 16 == 15: + result += '{} '.format(byte_string) + result += '|{}|'.format(ascii_string) + ascii_string = "" + elif mem_address % 16 == 7: + result += ' {} '.format(byte_string) + else: + result += '{} '.format(byte_string) + mem_address += 1 + + return result # 'presence' subcommand @show.command() @@ -710,6 +841,7 @@ def presence(port): logical_port_list = [port] + logical_port_list = natsort.natsorted(logical_port_list) for logical_port_name in logical_port_list: ganged = False i = 1 @@ -802,7 +934,10 @@ def fetch_error_status_from_platform_api(port): physical_port_list = logical_port_name_to_physical_port_list(logical_port_name) port_name = get_physical_port_name(logical_port_name, 1, False) - output.append([port_name, output_dict.get(physical_port_list[0])]) + if is_port_type_rj45(logical_port_name): + output.append([port_name, "N/A"]) + else: + output.append([port_name, output_dict.get(physical_port_list[0])]) return output @@ -825,15 +960,18 @@ def fetch_error_status_from_state_db(port, state_db): sorted_ports = natsort.natsorted(status) output = [] for port in sorted_ports: - statestring = status[port].get('status') - description = status[port].get('error') - if statestring == '1': - description = 'OK' - elif statestring == '0': - description = 'Unplugged' - elif description == 'N/A': - log.log_error("Inconsistent state found for port {}: state is {} but error description is N/A".format(port, statestring)) - description = 'Unknown state: {}'.format(statestring) + if is_port_type_rj45(port): + description = "N/A" + else: + statestring = status[port].get('status') + description = status[port].get('error') + if statestring == '1': + description = 'OK' + elif statestring == '0': + description = 'Unplugged' + elif description == 'N/A': + log.log_error("Inconsistent state found for port {}: state is {} but error description is N/A".format(port, statestring)) + description = 'Unknown state: {}'.format(statestring) output.append([port, description]) @@ -856,15 +994,15 @@ def error_status(port, fetch_from_hardware): if fetch_from_hardware: output_table = fetch_error_status_from_platform_api(port) else: - # Connect to STATE_DB - state_db = SonicV2Connector(host='127.0.0.1') - if state_db is not None: - state_db.connect(state_db.STATE_DB) - else: - click.echo("Failed to connect to STATE_DB") - return - - output_table = fetch_error_status_from_state_db(port, state_db) + namespaces = multi_asic.get_front_end_namespaces() + for namespace in namespaces: + state_db = SonicV2Connector(use_unix_socket_path=False, namespace=namespace) + if state_db is not None: + state_db.connect(state_db.STATE_DB) + output_table.extend(fetch_error_status_from_state_db(port, state_db)) + else: + click.echo("Failed to connect to STATE_DB") + return click.echo(tabulate(output_table, table_header, tablefmt='simple')) @@ -898,24 +1036,27 @@ def lpmode(port): click.echo("Error: No physical ports found for logical port '{}'".format(logical_port_name)) return - if len(physical_port_list) > 1: - ganged = True + if is_port_type_rj45(logical_port_name): + output_table.append([logical_port_name, "N/A"]) + else: + if len(physical_port_list) > 1: + ganged = True - for physical_port in physical_port_list: - port_name = get_physical_port_name(logical_port_name, i, ganged) + for physical_port in physical_port_list: + port_name = get_physical_port_name(logical_port_name, i, ganged) - try: - lpmode = platform_chassis.get_sfp(physical_port).get_lpmode() - except NotImplementedError: - click.echo("This functionality is currently not implemented for this platform") - sys.exit(ERROR_NOT_IMPLEMENTED) + try: + lpmode = platform_chassis.get_sfp(physical_port).get_lpmode() + except NotImplementedError: + click.echo("This functionality is currently not implemented for this platform") + sys.exit(ERROR_NOT_IMPLEMENTED) - if lpmode: - output_table.append([port_name, "On"]) - else: - output_table.append([port_name, "Off"]) + if lpmode: + output_table.append([port_name, "On"]) + else: + output_table.append([port_name, "Off"]) - i += 1 + i += 1 click.echo(tabulate(output_table, table_header, tablefmt='simple')) @@ -938,6 +1079,10 @@ def fwversion(port_name): physical_port = logical_port_to_physical_port_index(port_name) sfp = platform_chassis.get_sfp(physical_port) + if is_port_type_rj45(port_name): + click.echo("Show firmware version is not applicable for RJ45 port {}.".format(port_name)) + sys.exit(EXIT_FAIL) + try: presence = sfp.get_presence() except NotImplementedError: @@ -973,6 +1118,10 @@ def set_lpmode(logical_port, enable): click.echo("Error: No physical ports found for logical port '{}'".format(logical_port)) return + if is_port_type_rj45(logical_port): + click.echo("{} low-power mode is not applicable for RJ45 port {}.".format("Enabling" if enable else "Disabling", logical_port)) + sys.exit(EXIT_FAIL) + if len(physical_port_list) > 1: ganged = True @@ -1029,6 +1178,10 @@ def reset(port_name): click.echo("Error: No physical ports found for logical port '{}'".format(port_name)) return + if is_port_type_rj45(port_name): + click.echo("Reset is not applicable for RJ45 port {}.".format(port_name)) + sys.exit(EXIT_FAIL) + if len(physical_port_list) > 1: ganged = True @@ -1190,6 +1343,10 @@ def download_firmware(port_name, filepath): def run(port_name, mode): """Run the firmware with default mode=1""" + if is_port_type_rj45(port_name): + click.echo("This functionality is not applicable for RJ45 port {}.".format(port_name)) + sys.exit(EXIT_FAIL) + if not is_sfp_present(port_name): click.echo("{}: SFP EEPROM not detected\n".format(port_name)) sys.exit(EXIT_FAIL) @@ -1207,6 +1364,10 @@ def run(port_name, mode): def commit(port_name): """Commit the running firmware""" + if is_port_type_rj45(port_name): + click.echo("This functionality is not applicable for RJ45 port {}.".format(port_name)) + sys.exit(EXIT_FAIL) + if not is_sfp_present(port_name): click.echo("{}: SFP EEPROM not detected\n".format(port_name)) sys.exit(EXIT_FAIL) @@ -1227,6 +1388,10 @@ def upgrade(port_name, filepath): physical_port = logical_port_to_physical_port_index(port_name) + if is_port_type_rj45(port_name): + click.echo("This functionality is not applicable for RJ45 port {}.".format(port_name)) + sys.exit(EXIT_FAIL) + if not is_sfp_present(port_name): click.echo("{}: SFP EEPROM not detected\n".format(port_name)) sys.exit(EXIT_FAIL) @@ -1261,6 +1426,10 @@ def upgrade(port_name, filepath): def download(port_name, filepath): """Download firmware on the transceiver""" + if is_port_type_rj45(port_name): + click.echo("This functionality is not applicable for RJ45 port {}.".format(port_name)) + sys.exit(EXIT_FAIL) + if not is_sfp_present(port_name): click.echo("{}: SFP EEPROM not detected\n".format(port_name)) sys.exit(EXIT_FAIL) @@ -1285,6 +1454,10 @@ def unlock(port_name, password): physical_port = logical_port_to_physical_port_index(port_name) sfp = platform_chassis.get_sfp(physical_port) + if is_port_type_rj45(port_name): + click.echo("This functionality is not applicable for RJ45 port {}.".format(port_name)) + sys.exit(EXIT_FAIL) + if not is_sfp_present(port_name): click.echo("{}: SFP EEPROM not detected\n".format(port_name)) sys.exit(EXIT_FAIL) diff --git a/show/bgp_common.py b/show/bgp_common.py index 6bf332859a..b51e9f1879 100644 --- a/show/bgp_common.py +++ b/show/bgp_common.py @@ -367,21 +367,15 @@ def show_routes(args, namespace, display, verbose, ipver): # Not ip address just ignore it found_other_parms = 1 - if multi_asic.is_multi_asic(): - if not found_json and not found_other_parms: - arg_strg += "json" + # using the same format for both multiasic or non-multiasic + if not found_json and not found_other_parms: + arg_strg += "json" combined_route = {} for ns in ns_l: # Need to add "ns" to form bgpX so it is sent to the correct bgpX docker to handle the request - # If not MultiASIC, skip namespace argument cmd = "show {} route {}".format(ipver, arg_strg) - if multi_asic.is_multi_asic(): - output = bgp_util.run_bgp_show_command(cmd, ns) - else: - output = bgp_util.run_bgp_show_command(cmd) - print("{}".format(output)) - return + output = bgp_util.run_bgp_show_command(cmd, ns) # in case no output or something went wrong with user specified cmd argument(s) error it out # error from FRR always start with character "%" diff --git a/show/fabric.py b/show/fabric.py new file mode 100644 index 0000000000..8dfbc50f7a --- /dev/null +++ b/show/fabric.py @@ -0,0 +1,35 @@ +import click + +import utilities_common.multi_asic as multi_asic_util +import utilities_common.cli as clicommon + +@click.group(cls=clicommon.AliasedGroup) +def fabric(): + """Show fabric information""" + pass + +@fabric.group(invoke_without_command=True) +def counters(): + """Show fabric port counters""" + pass + +@counters.command() +@multi_asic_util.multi_asic_click_option_namespace +@click.option('-e', '--errors', is_flag=True) +def port(namespace, errors): + """Show fabric port stat""" + cmd = "fabricstat" + if namespace is not None: + cmd += " -n {}".format(namespace) + if errors: + cmd += " -e" + clicommon.run_command(cmd) + +@counters.command() +@multi_asic_util.multi_asic_click_option_namespace +def queue(namespace): + """Show fabric queue stat""" + cmd = "fabricstat -q" + if namespace is not None: + cmd += " -n {}".format(namespace) + clicommon.run_command(cmd) diff --git a/show/feature.py b/show/feature.py index 547d8d1729..60ff80321a 100644 --- a/show/feature.py +++ b/show/feature.py @@ -156,11 +156,11 @@ def feature_autorestart(db, feature_name): feature_table = db.cfgdb.get_table('FEATURE') if feature_name: if feature_table and feature_name in feature_table: - body.append([feature_name, feature_table[feature_name]['auto_restart']]) + body.append([feature_name, feature_table[ feature_name ].get('auto_restart', 'unknown')]) else: click.echo("Can not find feature {}".format(feature_name)) sys.exit(1) else: for name in natsorted(list(feature_table.keys())): - body.append([name, feature_table[name]['auto_restart']]) + body.append([name, feature_table[ name ].get('auto_restart', 'unknown')]) click.echo(tabulate(body, header)) diff --git a/show/interfaces/__init__.py b/show/interfaces/__init__.py index 75dbdfd1ee..7f218f41db 100644 --- a/show/interfaces/__init__.py +++ b/show/interfaces/__init__.py @@ -639,3 +639,36 @@ def autoneg_status(interfacename, namespace, display, verbose): cmd += " -n {}".format(namespace) clicommon.run_command(cmd, display_cmd=verbose) + +# +# link-training group (show interfaces link-training ...) +# +@interfaces.group(name='link-training', cls=clicommon.AliasedGroup) +def link_training(): + """Show interface link-training information""" + pass + +# 'link-training status' subcommand ("show interfaces link-training status") +@link_training.command(name='status') +@click.argument('interfacename', required=False) +@multi_asic_util.multi_asic_click_options +@click.option('--verbose', is_flag=True, help="Enable verbose output") +def link_training_status(interfacename, namespace, display, verbose): + """Show interface link-training status""" + + ctx = click.get_current_context() + + cmd = "intfutil -c link_training" + + #ignore the display option when interface name is passed + if interfacename is not None: + interfacename = try_convert_interfacename_from_alias(ctx, interfacename) + + cmd += " -i {}".format(interfacename) + else: + cmd += " -d {}".format(display) + + if namespace is not None: + cmd += " -n {}".format(namespace) + + clicommon.run_command(cmd, display_cmd=verbose) diff --git a/show/kdump.py b/show/kdump.py index 2d93154c64..e5ce7cde74 100644 --- a/show/kdump.py +++ b/show/kdump.py @@ -49,7 +49,7 @@ def get_kdump_oper_mode(): returns "Not Ready"; """ oper_mode = "Not Ready" - command_stdout = clicommon.run_command("/usr/sbin/kdump-config status", return_cmd=True) + command_stdout, _ = clicommon.run_command("/usr/sbin/kdump-config status", return_cmd=True) for line in command_stdout.splitlines(): if ": ready to kdump" in line: @@ -99,7 +99,7 @@ def get_kdump_core_files(): dump_file_list = [] cmd_message = None - command_stdout = clicommon.run_command(find_core_dump_files, return_cmd=True) + command_stdout, _ = clicommon.run_command(find_core_dump_files, return_cmd=True) dump_file_list = command_stdout.splitlines() if not dump_file_list: @@ -123,7 +123,7 @@ def get_kdump_dmesg_files(): dmesg_file_list = [] cmd_message = None - command_stdout = clicommon.run_command(find_dmesg_files, return_cmd=True) + command_stdout, _ = clicommon.run_command(find_dmesg_files, return_cmd=True) dmesg_file_list = command_stdout.splitlines() if not dmesg_file_list: diff --git a/show/kube.py b/show/kube.py index 5ab8cf3f6f..a120c46296 100644 --- a/show/kube.py +++ b/show/kube.py @@ -45,7 +45,7 @@ def config(db): # (
, , ) ("ip", "ip" "", False), ("port", "port", "6443"), - ("insecure", "insecure", "False"), + ("insecure", "insecure", "True"), ("disable","disable", "False") ] diff --git a/show/main.py b/show/main.py index 198940bc3e..429da2fcf6 100755 --- a/show/main.py +++ b/show/main.py @@ -5,11 +5,12 @@ import re import click +import lazy_object_proxy import utilities_common.cli as clicommon import utilities_common.multi_asic as multi_asic_util from importlib import reload from natsort import natsorted -from sonic_py_common import device_info +from sonic_py_common import device_info, multi_asic from swsscommon.swsscommon import SonicV2Connector, ConfigDBConnector from tabulate import tabulate from utilities_common import util_base @@ -17,6 +18,7 @@ from datetime import datetime import utilities_common.constants as constants from utilities_common.general import load_db_config +from json.decoder import JSONDecodeError # mock the redis for unit test purposes # try: @@ -39,6 +41,7 @@ from . import bgp_common from . import chassis_modules from . import dropcounters +from . import fabric from . import feature from . import fgnhg from . import flow_counters @@ -125,8 +128,12 @@ def run_command(command, display_cmd=False, return_cmd=False): if rc != 0: sys.exit(rc) -# Global class instance for SONiC interface name to alias conversion -iface_alias_converter = clicommon.InterfaceAliasConverter() +def get_cmd_output(cmd): + proc = subprocess.Popen(cmd, text=True, stdout=subprocess.PIPE) + return proc.communicate()[0], proc.returncode + +# Lazy global class instance for SONiC interface name to alias conversion +iface_alias_converter = lazy_object_proxy.Proxy(lambda: clicommon.InterfaceAliasConverter()) @@ -175,6 +182,7 @@ def cli(ctx): cli.add_command(acl.acl) cli.add_command(chassis_modules.chassis) cli.add_command(dropcounters.dropcounters) +cli.add_command(fabric.fabric) cli.add_command(feature.feature) cli.add_command(fgnhg.fgnhg) cli.add_command(flow_counters.flowcnt_route) @@ -542,9 +550,11 @@ def queue(): # 'counters' subcommand ("show queue counters") @queue.command() @click.argument('interfacename', required=False) +@multi_asic_util.multi_asic_click_options @click.option('--verbose', is_flag=True, help="Enable verbose output") @click.option('--json', is_flag=True, help="JSON output") -def counters(interfacename, verbose, json): +@click.option('--voq', is_flag=True, help="VOQ counters") +def counters(interfacename, namespace, display, verbose, json, voq): """Show queue counters""" cmd = "queuestat" @@ -556,9 +566,15 @@ def counters(interfacename, verbose, json): if interfacename is not None: cmd += " -p {}".format(interfacename) + if namespace is not None: + cmd += " -n {}".format(namespace) + if json: cmd += " -j" + if voq: + cmd += " -V" + run_command(cmd, display_cmd=verbose) # @@ -805,15 +821,49 @@ def ip(): # Addresses from all scopes are included. Interfaces with no addresses are # excluded. # -@ip.command() + +@ip.group(invoke_without_command=True) @multi_asic_util.multi_asic_click_options -def interfaces(namespace, display): - cmd = "sudo ipintutil -a ipv4" - if namespace is not None: - cmd += " -n {}".format(namespace) +@click.pass_context +def interfaces(ctx, namespace, display): + if ctx.invoked_subcommand is None: + cmd = "sudo ipintutil -a ipv4" + if namespace is not None: + cmd += " -n {}".format(namespace) - cmd += " -d {}".format(display) - clicommon.run_command(cmd) + cmd += " -d {}".format(display) + clicommon.run_command(cmd) + +# +# 'show ip interfaces loopback-action' command +# + +@interfaces.command() +def loopback_action(): + """show ip interfaces loopback-action""" + config_db = ConfigDBConnector() + config_db.connect() + header = ['Interface', 'Action'] + body = [] + + if_tbl = config_db.get_table('INTERFACE') + vlan_if_tbl = config_db.get_table('VLAN_INTERFACE') + po_if_tbl = config_db.get_table('PORTCHANNEL_INTERFACE') + sub_if_tbl = config_db.get_table('VLAN_SUB_INTERFACE') + + all_tables = {} + for tbl in [if_tbl, vlan_if_tbl, po_if_tbl, sub_if_tbl]: + all_tables.update(tbl) + + if all_tables: + ifs_action = [] + ifs = list(all_tables.keys()) + for iface in ifs: + if 'loopback_action' in all_tables[iface]: + action = all_tables[iface]['loopback_action'] + ifs_action.append([iface, action]) + body = natsorted(ifs_action) + click.echo(tabulate(body, header)) # # 'route' subcommand ("show ip route") @@ -1053,14 +1103,18 @@ def table(verbose): @click.option('--verbose', is_flag=True, help="Enable verbose output") def logging(process, lines, follow, verbose): """Show system log""" + if os.path.exists("/var/log.tmpfs"): + log_path = "/var/log.tmpfs" + else: + log_path = "/var/log" if follow: - cmd = "sudo tail -F /var/log/syslog" + cmd = "sudo tail -F {}/syslog".format(log_path) run_command(cmd, display_cmd=verbose) else: - if os.path.isfile("/var/log/syslog.1"): - cmd = "sudo cat /var/log/syslog.1 /var/log/syslog" + if os.path.isfile("{}/syslog.1".format(log_path)): + cmd = "sudo cat {}/syslog.1 {}/syslog".format(log_path, log_path) else: - cmd = "sudo cat /var/log/syslog" + cmd = "sudo cat {}/syslog".format(log_path) if process is not None: cmd += " | grep '{}'".format(process) @@ -1138,7 +1192,7 @@ def users(verbose): @cli.command() @click.option('--since', required=False, help="Collect logs and core files since given date") -@click.option('-g', '--global-timeout', default=30, type=int, help="Global timeout in minutes. Default 30 mins") +@click.option('-g', '--global-timeout', required=False, type=int, help="Global timeout in minutes. WARN: Dump might be incomplete if enforced") @click.option('-c', '--cmd-timeout', default=5, type=int, help="Individual command timeout in minutes. Default 5 mins") @click.option('--verbose', is_flag=True, help="Enable verbose output") @click.option('--allow-process-stop', is_flag=True, help="Dump additional data which may require system interruption") @@ -1147,7 +1201,10 @@ def users(verbose): @click.option('--redirect-stderr', '-r', is_flag=True, help="Redirect an intermediate errors to STDERR") def techsupport(since, global_timeout, cmd_timeout, verbose, allow_process_stop, silent, debug_dump, redirect_stderr): """Gather information for troubleshooting""" - cmd = "sudo timeout --kill-after={}s -s SIGTERM --foreground {}m".format(COMMAND_TIMEOUT, global_timeout) + cmd = "sudo" + + if global_timeout: + cmd += " timeout --kill-after={}s -s SIGTERM --foreground {}m".format(COMMAND_TIMEOUT, global_timeout) if allow_process_stop: cmd += " -a" @@ -1185,8 +1242,25 @@ def runningconfiguration(): @click.option('--verbose', is_flag=True, help="Enable verbose output") def all(verbose): """Show full running configuration""" - cmd = "sonic-cfggen -d --print-data" - run_command(cmd, display_cmd=verbose) + cmd = ['sonic-cfggen', '-d', '--print-data'] + stdout, rc = get_cmd_output(cmd) + if rc: + click.echo("Failed to get cmd output '{}':rc {}".format(cmd, rc)) + raise click.Abort() + + try: + output = json.loads(stdout) + except JSONDecodeError as e: + click.echo("Failed to load output '{}':{}".format(cmd, e)) + raise click.Abort() + + if not multi_asic.is_multi_asic(): + bgpraw_cmd = [constants.RVTYSH_COMMAND, '-c', 'show running-config'] + bgpraw, rc = get_cmd_output(bgpraw_cmd) + if rc: + bgpraw = "" + output['bgpraw'] = bgpraw + click.echo(json.dumps(output, indent=4)) # 'acl' subcommand ("show runningconfiguration acl") @@ -1794,7 +1868,7 @@ def bfd(): def summary(db): """Show bfd session information""" bfd_headers = ["Peer Addr", "Interface", "Vrf", "State", "Type", "Local Addr", - "TX Interval", "RX Interval", "Multiplier", "Multihop"] + "TX Interval", "RX Interval", "Multiplier", "Multihop", "Local Discriminator"] bfd_keys = db.db.keys(db.db.STATE_DB, "BFD_SESSION_TABLE|*") @@ -1805,8 +1879,10 @@ def summary(db): for key in bfd_keys: key_values = key.split('|') values = db.db.get_all(db.db.STATE_DB, key) + if "local_discriminator" not in values.keys(): + values["local_discriminator"] = "NA" bfd_body.append([key_values[3], key_values[2], key_values[1], values["state"], values["type"], values["local_addr"], - values["tx_interval"], values["rx_interval"], values["multiplier"], values["multihop"]]) + values["tx_interval"], values["rx_interval"], values["multiplier"], values["multihop"], values["local_discriminator"]]) click.echo(tabulate(bfd_body, bfd_headers)) @@ -1818,7 +1894,7 @@ def summary(db): def peer(db, peer_ip): """Show bfd session information for BFD peer""" bfd_headers = ["Peer Addr", "Interface", "Vrf", "State", "Type", "Local Addr", - "TX Interval", "RX Interval", "Multiplier", "Multihop"] + "TX Interval", "RX Interval", "Multiplier", "Multihop", "Local Discriminator"] bfd_keys = db.db.keys(db.db.STATE_DB, "BFD_SESSION_TABLE|*|{}".format(peer_ip)) delimiter = db.db.get_db_separator(db.db.STATE_DB) @@ -1834,8 +1910,10 @@ def peer(db, peer_ip): for key in bfd_keys: key_values = key.split(delimiter) values = db.db.get_all(db.db.STATE_DB, key) + if "local_discriminator" not in values.keys(): + values["local_discriminator"] = "NA" bfd_body.append([key_values[3], key_values[2], key_values[1], values.get("state"), values.get("type"), values.get("local_addr"), - values.get("tx_interval"), values.get("rx_interval"), values.get("multiplier"), values.get("multihop")]) + values.get("tx_interval"), values.get("rx_interval"), values.get("multiplier"), values.get("multihop"), values.get("local_discriminator")]) click.echo(tabulate(bfd_body, bfd_headers)) diff --git a/show/muxcable.py b/show/muxcable.py index a6cd008c2a..d9f0a94f15 100644 --- a/show/muxcable.py +++ b/show/muxcable.py @@ -1,3 +1,4 @@ + import json import sys import time @@ -13,6 +14,7 @@ from swsscommon import swsscommon from tabulate import tabulate from utilities_common import platform_sfputil_helper +from utilities_common.general import get_optional_value_for_key_in_config_tbl platform_sfputil = None @@ -96,6 +98,51 @@ def check_port_in_mux_cable_table(port): return False + +def get_per_port_firmware(port): + + state_db = {} + mux_info_dict = {} + mux_info_full_dict = {} + + # Getting all front asic namespace and correspding config and state DB connector + + namespaces = multi_asic.get_front_end_namespaces() + for namespace in namespaces: + asic_id = multi_asic.get_asic_index_from_namespace(namespace) + state_db[asic_id] = swsscommon.SonicV2Connector(use_unix_socket_path=False, namespace=namespace) + state_db[asic_id].connect(state_db[asic_id].STATE_DB) + + if platform_sfputil is not None: + asic_index = platform_sfputil_helper.get_asic_id_for_logical_port(port) + + if asic_index is None: + # TODO this import is only for unit test purposes, and should be removed once sonic_platform_base + # is fully mocked + import sonic_platform_base.sonic_sfp.sfputilhelper + asic_index = sonic_platform_base.sonic_sfp.sfputilhelper.SfpUtilHelper().get_asic_id_for_logical_port(port) + if asic_index is None: + click.echo("Got invalid asic index for port {}, cant retrieve mux cable table entries".format(port)) + return False + + + mux_info_full_dict[asic_index] = state_db[asic_index].get_all( + state_db[asic_index].STATE_DB, 'MUX_CABLE_INFO|{}'.format(port)) + + res_dir = {} + res_dir = mux_info_full_dict[asic_index] + mux_info_dict["version_nic_active"] = res_dir.get("version_nic_active", None) + mux_info_dict["version_nic_inactive"] = res_dir.get("version_nic_inactive", None) + mux_info_dict["version_nic_next"] = res_dir.get("version_nic_next", None) + mux_info_dict["version_peer_active"] = res_dir.get("version_peer_active", None) + mux_info_dict["version_peer_inactive"] = res_dir.get("version_peer_inactive", None) + mux_info_dict["version_peer_next"] = res_dir.get("version_peer_next", None) + mux_info_dict["version_self_active"] = res_dir.get("version_self_active", None) + mux_info_dict["version_self_inactive"] = res_dir.get("version_self_inactive", None) + mux_info_dict["version_self_next"] = res_dir.get("version_self_next", None) + + return mux_info_dict + def get_response_for_version(port, mux_info_dict): state_db = {} xcvrd_show_fw_res_tbl = {} @@ -400,13 +447,15 @@ def get_switch_name(config_db): sys.exit(STATUS_FAIL) -def create_json_dump_per_port_status(db, port_status_dict, muxcable_info_dict, muxcable_health_dict, muxcable_metrics_dict, asic_index, port): +def create_json_dump_per_port_status(db, port_status_dict, muxcable_info_dict, muxcable_grpc_dict, muxcable_health_dict, muxcable_metrics_dict, asic_index, port): res_dict = {} status_value = get_value_for_key_in_dict(muxcable_info_dict[asic_index], port, "state", "MUX_CABLE_TABLE") port_name = platform_sfputil_helper.get_interface_alias(port, db) port_status_dict["MUX_CABLE"][port_name] = {} port_status_dict["MUX_CABLE"][port_name]["STATUS"] = status_value + gRPC_value = get_value_for_key_in_dict(muxcable_grpc_dict[asic_index], port, "state", "MUX_CABLE_TABLE") + port_status_dict["MUX_CABLE"][port_name]["SERVER_STATUS"] = gRPC_value health_value = get_value_for_key_in_dict(muxcable_health_dict[asic_index], port, "state", "MUX_LINKMGR_TABLE") port_status_dict["MUX_CABLE"][port_name]["HEALTH"] = health_value res_dict = get_hwmode_mux_direction_port(db, port) @@ -427,7 +476,7 @@ def create_json_dump_per_port_status(db, port_status_dict, muxcable_info_dict, m last_switch_end_time = muxcable_metrics_dict[asic_index].get("linkmgrd_switch_active_end") port_status_dict["MUX_CABLE"][port_name]["LAST_SWITCHOVER_TIME"] = last_switch_end_time -def create_table_dump_per_port_status(db, print_data, muxcable_info_dict, muxcable_health_dict, muxcable_metrics_dict, asic_index, port): +def create_table_dump_per_port_status(db, print_data, muxcable_info_dict, muxcable_grpc_dict, muxcable_health_dict, muxcable_metrics_dict, asic_index, port): print_port_data = [] res_dict = {} @@ -435,6 +484,7 @@ def create_table_dump_per_port_status(db, print_data, muxcable_info_dict, muxcab res_dict = get_hwmode_mux_direction_port(db, port) status_value = get_value_for_key_in_dict(muxcable_info_dict[asic_index], port, "state", "MUX_CABLE_TABLE") #status_value = get_value_for_key_in_tbl(y_cable_asic_table, port, "status") + gRPC_value = get_value_for_key_in_dict(muxcable_grpc_dict[asic_index], port, "state", "MUX_CABLE_TABLE") health_value = get_value_for_key_in_dict(muxcable_health_dict[asic_index], port, "state", "MUX_LINKMGR_TABLE") last_switch_end_time = "" @@ -446,6 +496,7 @@ def create_table_dump_per_port_status(db, print_data, muxcable_info_dict, muxcab port_name = platform_sfputil_helper.get_interface_alias(port, db) print_port_data.append(port_name) print_port_data.append(status_value) + print_port_data.append(gRPC_value) print_port_data.append(health_value) if res_dict[2] == "False": hwstatus = "absent" @@ -460,7 +511,7 @@ def create_table_dump_per_port_status(db, print_data, muxcable_info_dict, muxcab print_data.append(print_port_data) -def create_table_dump_per_port_config(db ,print_data, per_npu_configdb, asic_id, port): +def create_table_dump_per_port_config(db ,print_data, per_npu_configdb, asic_id, port, is_dualtor_active_active): port_list = [] port_name = platform_sfputil_helper.get_interface_alias(port, db) @@ -471,6 +522,13 @@ def create_table_dump_per_port_config(db ,print_data, per_npu_configdb, asic_id, port_list.append(ipv4_value) ipv6_value = get_value_for_key_in_config_tbl(per_npu_configdb[asic_id], port, "server_ipv6", "MUX_CABLE") port_list.append(ipv6_value) + cable_type = get_optional_value_for_key_in_config_tbl(per_npu_configdb[asic_id], port, "cable_type", "MUX_CABLE") + if cable_type is not None: + port_list.append(cable_type) + soc_ipv4_value = get_optional_value_for_key_in_config_tbl(per_npu_configdb[asic_id], port, "soc_ipv4", "MUX_CABLE") + if soc_ipv4_value is not None: + port_list.append(soc_ipv4_value) + is_dualtor_active_active[0] = True print_data.append(port_list) @@ -484,7 +542,58 @@ def create_json_dump_per_port_config(db, port_status_dict, per_npu_configdb, asi port_status_dict["MUX_CABLE"]["PORTS"][port_name]["SERVER"]["IPv4"] = ipv4_value ipv6_value = get_value_for_key_in_config_tbl(per_npu_configdb[asic_id], port, "server_ipv6", "MUX_CABLE") port_status_dict["MUX_CABLE"]["PORTS"][port_name]["SERVER"]["IPv6"] = ipv6_value + cable_type = get_optional_value_for_key_in_config_tbl(per_npu_configdb[asic_id], port, "cable_type", "MUX_CABLE") + if cable_type is not None: + port_status_dict["MUX_CABLE"]["PORTS"][port_name]["SERVER"]["cable_type"] = cable_type + soc_ipv4_value = get_optional_value_for_key_in_config_tbl(per_npu_configdb[asic_id], port, "soc_ipv4", "MUX_CABLE") + if soc_ipv4_value is not None: + port_status_dict["MUX_CABLE"]["PORTS"][port_name]["SERVER"]["soc_ipv4"] = soc_ipv4_value + +def get_tunnel_route_per_port(db, port_tunnel_route, per_npu_configdb, per_npu_appl_db, per_npu_asic_db, asic_id, port): + + mux_cfg_dict = per_npu_configdb[asic_id].get_all( + per_npu_configdb[asic_id].CONFIG_DB, 'MUX_CABLE|{}'.format(port)) + dest_names = ["server_ipv4", "server_ipv6", "soc_ipv4"] + + for name in dest_names: + dest_address = mux_cfg_dict.get(name, None) + if dest_address is not None: + kernel_route_keys = per_npu_appl_db[asic_id].keys( + per_npu_appl_db[asic_id].APPL_DB, 'TUNNEL_ROUTE_TABLE:*{}'.format(dest_address)) + if_kernel_tunnel_route_programed = kernel_route_keys is not None and len(kernel_route_keys) + + asic_route_keys = per_npu_asic_db[asic_id].keys( + per_npu_asic_db[asic_id].ASIC_DB, 'ASIC_STATE:SAI_OBJECT_TYPE_ROUTE_ENTRY:*{}*'.format(dest_address)) + if_asic_tunnel_route_programed = asic_route_keys is not None and len(asic_route_keys) + + if if_kernel_tunnel_route_programed or if_asic_tunnel_route_programed: + port_tunnel_route["TUNNEL_ROUTE"][port] = port_tunnel_route["TUNNEL_ROUTE"].get(port, {}) + port_tunnel_route["TUNNEL_ROUTE"][port][name] = {} + port_tunnel_route["TUNNEL_ROUTE"][port][name]['DEST'] = dest_address + + port_tunnel_route["TUNNEL_ROUTE"][port][name]['kernel'] = if_kernel_tunnel_route_programed + port_tunnel_route["TUNNEL_ROUTE"][port][name]['asic'] = if_asic_tunnel_route_programed + +def create_json_dump_per_port_tunnel_route(db, port_tunnel_route, per_npu_configdb, per_npu_appl_db, per_npu_asic_db, asic_id, port): + + get_tunnel_route_per_port(db, port_tunnel_route, per_npu_configdb, per_npu_appl_db, per_npu_asic_db, asic_id, port) + +def create_table_dump_per_port_tunnel_route(db, print_data, per_npu_configdb, per_npu_appl_db, per_npu_asic_db, asic_id, port): + + port_tunnel_route = {} + port_tunnel_route["TUNNEL_ROUTE"] = {} + get_tunnel_route_per_port(db, port_tunnel_route, per_npu_configdb, per_npu_appl_db, per_npu_asic_db, asic_id, port) + + for port, route in port_tunnel_route["TUNNEL_ROUTE"].items(): + for dest_name, values in route.items(): + print_line = [] + print_line.append(port) + print_line.append(dest_name) + print_line.append(values['DEST']) + print_line.append('added' if values['kernel'] else '-') + print_line.append('added' if values['asic'] else '-') + print_data.append(print_line) @muxcable.command() @click.argument('port', required=False, default=None) @@ -496,10 +605,13 @@ def status(db, port, json_output): port = platform_sfputil_helper.get_interface_name(port, db) port_table_keys = {} + appl_db_muxcable_tbl_keys = {} port_health_table_keys = {} port_metrics_table_keys = {} per_npu_statedb = {} + per_npu_appl_db = {} muxcable_info_dict = {} + muxcable_grpc_dict = {} muxcable_health_dict = {} muxcable_metrics_dict = {} @@ -511,6 +623,11 @@ def status(db, port, json_output): per_npu_statedb[asic_id] = SonicV2Connector(use_unix_socket_path=False, namespace=namespace) per_npu_statedb[asic_id].connect(per_npu_statedb[asic_id].STATE_DB) + per_npu_appl_db[asic_id] = swsscommon.SonicV2Connector(use_unix_socket_path=False, namespace=namespace) + per_npu_appl_db[asic_id].connect(per_npu_appl_db[asic_id].APPL_DB) + + appl_db_muxcable_tbl_keys[asic_id] = per_npu_appl_db[asic_id].keys( + per_npu_appl_db[asic_id].APPL_DB, 'MUX_CABLE_TABLE:*') port_table_keys[asic_id] = per_npu_statedb[asic_id].keys( per_npu_statedb[asic_id].STATE_DB, 'MUX_CABLE_TABLE|*') port_health_table_keys[asic_id] = per_npu_statedb[asic_id].keys( @@ -532,17 +649,20 @@ def status(db, port, json_output): click.echo("Got invalid asic index for port {}, cant retreive mux status".format(port_name)) sys.exit(STATUS_FAIL) - muxcable_info_dict[asic_index] = per_npu_statedb[asic_index].get_all( + muxcable_info_dict[asic_index] = per_npu_appl_db[asic_index].get_all( + per_npu_appl_db[asic_index].APPL_DB, 'MUX_CABLE_TABLE:{}'.format(port)) + muxcable_grpc_dict[asic_index] = per_npu_statedb[asic_index].get_all( per_npu_statedb[asic_index].STATE_DB, 'MUX_CABLE_TABLE|{}'.format(port)) muxcable_health_dict[asic_index] = per_npu_statedb[asic_index].get_all( per_npu_statedb[asic_index].STATE_DB, 'MUX_LINKMGR_TABLE|{}'.format(port)) muxcable_metrics_dict[asic_index] = per_npu_statedb[asic_index].get_all( per_npu_statedb[asic_index].STATE_DB, 'MUX_METRICS_TABLE|{}'.format(port)) + if muxcable_info_dict[asic_index] is not None: - logical_key = "MUX_CABLE_TABLE|{}".format(port) + logical_key = "MUX_CABLE_TABLE:{}".format(port) logical_health_key = "MUX_LINKMGR_TABLE|{}".format(port) logical_metrics_key = "MUX_METRICS_TABLE|{}".format(port) - if logical_key in port_table_keys[asic_index] and logical_health_key in port_health_table_keys[asic_index]: + if logical_key in appl_db_muxcable_tbl_keys[asic_index] and logical_health_key in port_health_table_keys[asic_index]: if logical_metrics_key not in port_metrics_table_keys[asic_index]: muxcable_metrics_dict[asic_index] = {} @@ -551,7 +671,7 @@ def status(db, port, json_output): port_status_dict = {} port_status_dict["MUX_CABLE"] = {} - create_json_dump_per_port_status(db, port_status_dict, muxcable_info_dict, + create_json_dump_per_port_status(db, port_status_dict, muxcable_info_dict, muxcable_grpc_dict, muxcable_health_dict, muxcable_metrics_dict, asic_index, port) click.echo("{}".format(json.dumps(port_status_dict, indent=4))) @@ -559,10 +679,10 @@ def status(db, port, json_output): else: print_data = [] - create_table_dump_per_port_status(db, print_data, muxcable_info_dict, + create_table_dump_per_port_status(db, print_data, muxcable_info_dict, muxcable_grpc_dict, muxcable_health_dict, muxcable_metrics_dict, asic_index, port) - headers = ['PORT', 'STATUS', 'HEALTH', 'HWSTATUS', 'LAST_SWITCHOVER_TIME'] + headers = ['PORT', 'STATUS', 'SERVER_STATUS', 'HEALTH', 'HWSTATUS', 'LAST_SWITCHOVER_TIME'] click.echo(tabulate(print_data, headers=headers)) sys.exit(STATUS_SUCCESSFUL) @@ -581,9 +701,11 @@ def status(db, port, json_output): port_status_dict["MUX_CABLE"] = {} for namespace in namespaces: asic_id = multi_asic.get_asic_index_from_namespace(namespace) - for key in natsorted(port_table_keys[asic_id]): - port = key.split("|")[1] - muxcable_info_dict[asic_id] = per_npu_statedb[asic_id].get_all( + for key in natsorted(appl_db_muxcable_tbl_keys[asic_id]): + port = key.split(":")[1] + muxcable_info_dict[asic_id] = per_npu_appl_db[asic_id].get_all( + per_npu_appl_db[asic_id].APPL_DB, 'MUX_CABLE_TABLE:{}'.format(port)) + muxcable_grpc_dict[asic_id] = per_npu_statedb[asic_id].get_all( per_npu_statedb[asic_id].STATE_DB, 'MUX_CABLE_TABLE|{}'.format(port)) muxcable_health_dict[asic_id] = per_npu_statedb[asic_id].get_all( per_npu_statedb[asic_id].STATE_DB, 'MUX_LINKMGR_TABLE|{}'.format(port)) @@ -591,7 +713,7 @@ def status(db, port, json_output): per_npu_statedb[asic_id].STATE_DB, 'MUX_METRICS_TABLE|{}'.format(port)) if not muxcable_metrics_dict[asic_id]: muxcable_metrics_dict[asic_id] = {} - create_json_dump_per_port_status(db, port_status_dict, muxcable_info_dict, + create_json_dump_per_port_status(db, port_status_dict, muxcable_info_dict, muxcable_grpc_dict, muxcable_health_dict, muxcable_metrics_dict, asic_id, port) click.echo("{}".format(json.dumps(port_status_dict, indent=4))) @@ -599,20 +721,22 @@ def status(db, port, json_output): print_data = [] for namespace in namespaces: asic_id = multi_asic.get_asic_index_from_namespace(namespace) - for key in natsorted(port_table_keys[asic_id]): - port = key.split("|")[1] + for key in natsorted(appl_db_muxcable_tbl_keys[asic_id]): + port = key.split(":")[1] + muxcable_info_dict[asic_id] = per_npu_appl_db[asic_id].get_all( + per_npu_appl_db[asic_id].APPL_DB, 'MUX_CABLE_TABLE:{}'.format(port)) muxcable_health_dict[asic_id] = per_npu_statedb[asic_id].get_all( per_npu_statedb[asic_id].STATE_DB, 'MUX_LINKMGR_TABLE|{}'.format(port)) - muxcable_info_dict[asic_id] = per_npu_statedb[asic_id].get_all( + muxcable_grpc_dict[asic_id] = per_npu_statedb[asic_id].get_all( per_npu_statedb[asic_id].STATE_DB, 'MUX_CABLE_TABLE|{}'.format(port)) muxcable_metrics_dict[asic_id] = per_npu_statedb[asic_id].get_all( per_npu_statedb[asic_id].STATE_DB, 'MUX_METRICS_TABLE|{}'.format(port)) if not muxcable_metrics_dict[asic_id]: muxcable_metrics_dict[asic_id] = {} - create_table_dump_per_port_status(db, print_data, muxcable_info_dict, + create_table_dump_per_port_status(db, print_data, muxcable_info_dict, muxcable_grpc_dict, muxcable_health_dict, muxcable_metrics_dict, asic_id, port) - headers = ['PORT', 'STATUS', 'HEALTH', 'HWSTATUS','LAST_SWITCHOVER_TIME'] + headers = ['PORT', 'STATUS', 'SERVER_STATUS', 'HEALTH', 'HWSTATUS', 'LAST_SWITCHOVER_TIME'] click.echo(tabulate(print_data, headers=headers)) sys.exit(STATUS_SUCCESSFUL) @@ -688,8 +812,10 @@ def config(db, port, json_output): else: print_data = [] print_peer_tor = [] + is_dualtor_active_active = [False] + - create_table_dump_per_port_config(db, print_data, per_npu_configdb, asic_id, port) + create_table_dump_per_port_config(db, print_data, per_npu_configdb, asic_id, port, is_dualtor_active_active) headers = ['SWITCH_NAME', 'PEER_TOR'] peer_tor_data = [] @@ -697,7 +823,10 @@ def config(db, port, json_output): peer_tor_data.append(peer_switch_value) print_peer_tor.append(peer_tor_data) click.echo(tabulate(print_peer_tor, headers=headers)) - headers = ['port', 'state', 'ipv4', 'ipv6'] + if is_dualtor_active_active[0]: + headers = ['port', 'state', 'ipv4', 'ipv6', 'cable_type', 'soc_ipv4'] + else: + headers = ['port', 'state', 'ipv4', 'ipv6'] click.echo(tabulate(print_data, headers=headers)) sys.exit(CONFIG_SUCCESSFUL) @@ -733,10 +862,12 @@ def config(db, port, json_output): else: print_data = [] print_peer_tor = [] + is_dualtor_active_active = [False] + for namespace in namespaces: asic_id = multi_asic.get_asic_index_from_namespace(namespace) for port in natsorted(port_mux_tbl_keys[asic_id]): - create_table_dump_per_port_config(db, print_data, per_npu_configdb, asic_id, port) + create_table_dump_per_port_config(db, print_data, per_npu_configdb, asic_id, port, is_dualtor_active_active) headers = ['SWITCH_NAME', 'PEER_TOR'] peer_tor_data = [] @@ -744,7 +875,10 @@ def config(db, port, json_output): peer_tor_data.append(peer_switch_value) print_peer_tor.append(peer_tor_data) click.echo(tabulate(print_peer_tor, headers=headers)) - headers = ['port', 'state', 'ipv4', 'ipv6'] + if is_dualtor_active_active[0]: + headers = ['port', 'state', 'ipv4', 'ipv6', 'cable_type', 'soc_ipv4'] + else: + headers = ['port', 'state', 'ipv4', 'ipv6'] click.echo(tabulate(print_data, headers=headers)) sys.exit(CONFIG_SUCCESSFUL) @@ -1449,7 +1583,7 @@ def version(db, port, active): delete_all_keys_in_db_table("STATE_DB", "XCVRD_SHOW_FW_RSP") delete_all_keys_in_db_table("STATE_DB", "XCVRD_SHOW_FW_RES") - if port is not None: + if port is not None and port != "all": res_dict = {} mux_info_dict, mux_info_active_dict = {}, {} @@ -1482,6 +1616,65 @@ def version(db, port, active): click.echo("{}".format(json.dumps(mux_info_active_dict, indent=4))) else: click.echo("{}".format(json.dumps(mux_info_dict, indent=4))) + + elif port == "all" and port is not None: + + logical_port_list = platform_sfputil_helper.get_logical_list() + + rc_exit = True + + for port in logical_port_list: + + if platform_sfputil is not None: + physical_port_list = platform_sfputil_helper.logical_port_name_to_physical_port_list(port) + + if not isinstance(physical_port_list, list): + continue + if len(physical_port_list) != 1: + continue + + if not check_port_in_mux_cable_table(port): + continue + + physical_port = physical_port_list[0] + + logical_port_list_for_physical_port = platform_sfputil_helper.get_physical_to_logical() + + logical_port_list_per_port = logical_port_list_for_physical_port.get(physical_port, None) + + """ This check is required for checking whether or not this logical port is the one which is + actually mapped to physical port and by convention it is always the first port. + TODO: this should be removed with more logic to check which logical port maps to actual physical port + being used""" + + if port != logical_port_list_per_port[0]: + continue + + + port = platform_sfputil_helper.get_interface_alias(port, db) + + mux_info_dict = get_per_port_firmware(port) + if not isinstance(mux_info_dict, dict): + mux_info_dict = {} + rc_exit = False + + mux_info = {} + mux_info_active_dict = {} + if active is True: + for key in mux_info_dict: + if key.endswith("_active"): + mux_info_active_dict[key] = mux_info_dict[key] + mux_info[port] = mux_info_active_dict + click.echo("{}".format(json.dumps(mux_info, indent=4))) + else: + mux_info[port] = mux_info_dict + click.echo("{}".format(json.dumps(mux_info, indent=4))) + + if rc_exit == False: + sys.exit(EXIT_FAIL) + + sys.exit(CONFIG_SUCCESSFUL) + else: port_name = platform_sfputil_helper.get_interface_name(port, db) click.echo("Did not get a valid Port for mux firmware version".format(port_name)) @@ -1561,6 +1754,7 @@ def metrics(db, port, json_output): def event_log(db, port, json_output): """Show muxcable event log """ + click.confirm(('Muxcable at port {} will retreive cable logs from MCU, Caution: approx wait time could be ~2 minutes Continue?'.format(port)), abort=True) port = platform_sfputil_helper.get_interface_name(port, db) delete_all_keys_in_db_table("APPL_DB", "XCVRD_EVENT_LOG_CMD") delete_all_keys_in_db_table("STATE_DB", "XCVRD_EVENT_LOG_RSP") @@ -1656,7 +1850,7 @@ def packetloss(db, port, json_output): for namespace in namespaces: asic_id = multi_asic.get_asic_index_from_namespace(namespace) - per_npu_statedb[asic_id] = swsscommon.SonicV2Connector(use_unix_socket_path=True, namespace=namespace) + per_npu_statedb[asic_id] = swsscommon.SonicV2Connector(use_unix_socket_path=False, namespace=namespace) per_npu_statedb[asic_id].connect(per_npu_statedb[asic_id].STATE_DB) pckloss_table_keys[asic_id] = per_npu_statedb[asic_id].keys( @@ -1708,3 +1902,104 @@ def packetloss(db, port, json_output): click.echo(tabulate(print_count, headers=count_headers)) click.echo(tabulate(print_event, headers=event_headers)) + +@muxcable.command() +@click.argument('port', metavar='', required=False, default=None) +@click.option('--json', 'json_output', required=False, is_flag=True, type=click.BOOL, help="display the output in json format") +@clicommon.pass_db +def tunnel_route(db, port, json_output): + """show muxcable tunnel-route """ + + port = platform_sfputil_helper.get_interface_name(port, db) + + per_npu_appl_db = {} + per_npu_asic_db = {} + per_npu_configdb = {} + mux_tbl_keys = {} + + namespaces = multi_asic.get_front_end_namespaces() + for namespace in namespaces: + asic_id = multi_asic.get_asic_index_from_namespace(namespace) + + per_npu_appl_db[asic_id] = swsscommon.SonicV2Connector(use_unix_socket_path=False, namespace=namespace) + per_npu_appl_db[asic_id].connect(per_npu_appl_db[asic_id].APPL_DB) + + per_npu_asic_db[asic_id] = swsscommon.SonicV2Connector(use_unix_socket_path=False, namespace=namespace) + per_npu_asic_db[asic_id].connect(per_npu_asic_db[asic_id].ASIC_DB) + + per_npu_configdb[asic_id] = swsscommon.SonicV2Connector(use_unix_socket_path=False, namespace=namespace) + per_npu_configdb[asic_id].connect(per_npu_configdb[asic_id].CONFIG_DB) + + mux_tbl_keys[asic_id] = per_npu_configdb[asic_id].keys( + per_npu_configdb[asic_id].CONFIG_DB, "MUX_CABLE|*") + + if port is not None: + + logical_port_list = platform_sfputil_helper.get_logical_list() + + if port not in logical_port_list: + port_name = platform_sfputil_helper.get_interface_alias(port, db) + click.echo(("ERR: Not a valid logical port for dualtor firmware {}".format(port_name))) + sys.exit(CONFIG_FAIL) + + asic_index = None + if platform_sfputil is not None: + asic_index = platform_sfputil_helper.get_asic_id_for_logical_port(port) + if asic_index is None: + # TODO this import is only for unit test purposes, and should be removed once sonic_platform_base + # is fully mocked + import sonic_platform_base.sonic_sfp.sfputilhelper + asic_index = sonic_platform_base.sonic_sfp.sfputilhelper.SfpUtilHelper().get_asic_id_for_logical_port(port) + if asic_index is None: + port_name = platform_sfputil_helper.get_interface_alias(port, db) + click.echo("Got invalid asic index for port {}, cant retreive tunnel route info".format(port_name)) + sys.exit(STATUS_FAIL) + + if mux_tbl_keys[asic_index] is not None and "MUX_CABLE|{}".format(port) in mux_tbl_keys[asic_index]: + if json_output: + port_tunnel_route = {} + port_tunnel_route["TUNNEL_ROUTE"] = {} + + create_json_dump_per_port_tunnel_route(db, port_tunnel_route, per_npu_configdb, per_npu_appl_db, per_npu_asic_db, asic_index, port) + + click.echo("{}".format(json.dumps(port_tunnel_route, indent=4))) + + else: + print_data = [] + + create_table_dump_per_port_tunnel_route(db, print_data, per_npu_configdb, per_npu_appl_db, per_npu_asic_db, asic_index, port) + + headers = ['PORT', 'DEST_TYPE', 'DEST_ADDRESS', 'kernel', 'asic'] + + click.echo(tabulate(print_data, headers=headers)) + else: + click.echo("this is not a valid port present on dualToR".format(port)) + sys.exit(STATUS_FAIL) + + else: + if json_output: + port_tunnel_route = {} + port_tunnel_route["TUNNEL_ROUTE"] = {} + for namespace in namespaces: + asic_id = multi_asic.get_asic_index_from_namespace(namespace) + for key in natsorted(mux_tbl_keys[asic_id]): + port = key.split("|")[1] + + create_json_dump_per_port_tunnel_route(db, port_tunnel_route, per_npu_configdb, per_npu_appl_db, per_npu_asic_db, asic_id, port) + + click.echo("{}".format(json.dumps(port_tunnel_route, indent=4))) + else: + print_data = [] + + for namespace in namespaces: + asic_id = multi_asic.get_asic_index_from_namespace(namespace) + for key in natsorted(mux_tbl_keys[asic_id]): + port = key.split("|")[1] + + create_table_dump_per_port_tunnel_route(db, print_data, per_npu_configdb, per_npu_appl_db, per_npu_asic_db, asic_id, port) + + headers = ['PORT', 'DEST_TYPE', 'DEST_ADDRESS', 'kernel', 'asic'] + + click.echo(tabulate(print_data, headers=headers)) + + sys.exit(STATUS_SUCCESSFUL) diff --git a/show/plugins/auto_techsupport.py b/show/plugins/auto_techsupport.py index 9bcda1b04c..2afb0bf9c5 100644 --- a/show/plugins/auto_techsupport.py +++ b/show/plugins/auto_techsupport.py @@ -61,6 +61,8 @@ def AUTO_TECHSUPPORT_GLOBAL(db): "RATE LIMIT INTERVAL (sec)", "MAX TECHSUPPORT LIMIT (%)", "MAX CORE LIMIT (%)", + "AVAILABLE MEM THRESHOLD (%)", + "MIN AVAILABLE MEM (Kb)", "SINCE", ] @@ -84,6 +86,14 @@ def AUTO_TECHSUPPORT_GLOBAL(db): entry, {'name': 'max_core_limit', 'description': 'Max Limit in percentage for the cummulative size of core dumps. No cleanup is performed if the value isn\'t congiured or is 0.0', 'is-leaf-list': False, 'is-mandatory': False, 'group': ''} ), + format_attr_value( + entry, + {'name': 'available_mem_threshold', 'description': 'Memory threshold; 0 to disable techsupport invocation on memory usage threshold crossing.', 'is-leaf-list': False, 'is-mandatory': False, 'group': ''} + ), + format_attr_value( + entry, + {'name': 'min_available_mem', 'description': 'Minimum Free memory (in MB) that should be available for the techsupport execution to start', 'is-leaf-list': False, 'is-mandatory': False, 'group': ''} + ), format_attr_value( entry, {'name': 'since', 'description': "Only collect the logs & core-dumps generated since the time provided. A default value of '2 days ago' is used if this value is not set explicitly or a non-valid string is provided", 'is-leaf-list': False, 'is-mandatory': False, 'group': ''} @@ -98,14 +108,15 @@ def AUTO_TECHSUPPORT_GLOBAL(db): @clicommon.pass_db def AUTO_TECHSUPPORT_history(db): keys = db.db.keys("STATE_DB", "AUTO_TECHSUPPORT_DUMP_INFO|*") - header = ["TECHSUPPORT DUMP", "TRIGGERED BY", "CORE DUMP"] + header = ["TECHSUPPORT DUMP", "TRIGGERED BY", "EVENT TYPE", "CORE DUMP"] body = [] for key in keys: dump = key.split("|")[-1] fv_pairs = db.db.get_all("STATE_DB", key) core_dump = fv_pairs.get("core_dump", "") container = fv_pairs.get("container_name", "") - body.append([dump, container, core_dump]) + event_type = fv_pairs.get("event_type", "") + body.append([dump, container, event_type, core_dump]) click.echo(tabulate.tabulate(body, header, numalign="left")) @@ -120,6 +131,7 @@ def AUTO_TECHSUPPORT_FEATURE(db): "FEATURE NAME", "STATE", "RATE LIMIT INTERVAL (sec)", + "AVAILABLE MEM THRESHOLD (%)", ] body = [] @@ -139,6 +151,10 @@ def AUTO_TECHSUPPORT_FEATURE(db): entry, {'name': 'rate_limit_interval', 'description': 'Rate limit interval for the corresponding feature. Configure 0 to explicitly disable', 'is-leaf-list': False, 'is-mandatory': False, 'group': ''} ), + format_attr_value( + entry, + {'name': 'available_mem_threshold', 'description': 'Memory threshold; 0 to disable techsupport invocation on memory usage threshold crossing.', 'is-leaf-list': False, 'is-mandatory': False, 'group': ''} + ), ] body.append(row) click.echo(tabulate.tabulate(body, header, numalign="left")) diff --git a/show/plugins/cisco-8000.py b/show/plugins/cisco-8000.py index c3e5e0327b..2113336bdb 100644 --- a/show/plugins/cisco-8000.py +++ b/show/plugins/cisco-8000.py @@ -1,36 +1,25 @@ #!/usr/bin/env python ######################################################### -# Copyright 2021 Cisco Systems, Inc. +# Copyright 2021-2022 Cisco Systems, Inc. # All rights reserved. # # CLI Extensions for show command ######################################################### try: - import click - import yaml - from show import platform from sonic_py_common import device_info import utilities_common.cli as clicommon except ImportError as e: - raise ImportError("%s - required module not found" % str(e)) + raise ImportError("%s - required module not found".format(str(e))) -PLATFORM_PY = '/opt/cisco/bin/platform.py' - -@click.command() -def inventory(): - """Show Platform Inventory""" - args = [ PLATFORM_PY, 'inventoryshow' ] - clicommon.run_command(args) +try: + from sonic_platform.cli import PLATFORM_CLIS +except ImportError: + PLATFORM_CLIS = [] -@click.command() -def idprom(): - """Show Platform Idprom Inventory""" - args = [ PLATFORM_PY, 'idprom' ] - clicommon.run_command(args) def register(cli): - version_info = device_info.get_sonic_version_info() - if (version_info and version_info.get('asic_type') == 'cisco-8000'): - cli.commands['platform'].add_command(inventory) - cli.commands['platform'].add_command(idprom) + version_info = device_info.get_sonic_version_info() + if version_info and version_info.get("asic_type") == "cisco-8000": + for c in PLATFORM_CLIS: + cli.commands["platform"].add_command(c) diff --git a/show/plugins/pbh.py b/show/plugins/pbh.py index e50f6507a5..407c596163 100644 --- a/show/plugins/pbh.py +++ b/show/plugins/pbh.py @@ -14,14 +14,14 @@ import utilities_common.cli as clicommon from swsscommon.swsscommon import SonicV2Connector -PBH_COUNTERS_LOCATION = '/tmp/.pbh_counters.txt' - COUNTER_PACKETS_ATTR = "SAI_ACL_COUNTER_ATTR_PACKETS" COUNTER_BYTES_ATTR = "SAI_ACL_COUNTER_ATTR_BYTES" COUNTERS = "COUNTERS" ACL_COUNTER_RULE_MAP = "ACL_COUNTER_RULE_MAP" +PBH_COUNTERS_CACHE_FILENAME = "pbh-counters" + pbh_hash_field_tbl_name = 'PBH_HASH_FIELD' pbh_hash_tbl_name = 'PBH_HASH' pbh_table_tbl_name = 'PBH_TABLE' @@ -428,15 +428,18 @@ def deserialize_pbh_counters(): obj: counters dict. """ + cache = clicommon.UserCache('pbh') + counters_cache_file = os.path.join(cache.get_directory(), PBH_COUNTERS_CACHE_FILENAME) + def remap_keys(obj): res = {} for e in obj: res[e['key'][0], e['key'][1]] = e['value'] return res - if os.path.isfile(PBH_COUNTERS_LOCATION): + if os.path.isfile(counters_cache_file): try: - with open(PBH_COUNTERS_LOCATION, 'r') as f: + with open(counters_cache_file, 'r') as f: return remap_keys(json.load(f)) except Exception as err: pass diff --git a/show/plugins/sonic-passwh_yang.py b/show/plugins/sonic-passwh_yang.py new file mode 100644 index 0000000000..04f56877a0 --- /dev/null +++ b/show/plugins/sonic-passwh_yang.py @@ -0,0 +1,126 @@ +""" +Auto-generated show CLI plugin. + + +""" + +import click +import tabulate +import utilities_common.cli as clicommon + + + + + +def format_attr_value(entry, attr): + """ Helper that formats attribute to be presented in the table output. + + Args: + entry (Dict[str, str]): CONFIG DB entry configuration. + attr (Dict): Attribute metadata. + + Returns: + str: fomatted attribute value. + """ + + if attr["is-leaf-list"]: + return "\n".join(entry.get(attr["name"], [])) + return entry.get(attr["name"], "N/A") + + +@click.group(name="passw-hardening", + cls=clicommon.AliasedGroup) +def PASSW_HARDENING(): + """ PASSWORD HARDENING part of config_db.json """ + + pass + + + +@PASSW_HARDENING.command(name="policies") +@clicommon.pass_db +def PASSW_HARDENING_POLICIES(db): + """ """ + + header = [ + +"STATE", +"EXPIRATION", +"EXPIRATION WARNING", +"HISTORY CNT", +"LEN MIN", +"REJECT USER PASSW MATCH", +"LOWER CLASS", +"UPPER CLASS", +"DIGITS CLASS", +"SPECIAL CLASS", + +] + + body = [] + + table = db.cfgdb.get_table("PASSW_HARDENING") + entry = table.get("POLICIES", {}) + row = [ + format_attr_value( + entry, + {'name': 'state', 'description': 'state of the feature', 'is-leaf-list': False, 'is-mandatory': False, 'group': ''} + ), + format_attr_value( + entry, + {'name': 'expiration', 'description': 'expiration time (days unit)', 'is-leaf-list': False, 'is-mandatory': False, 'group': ''} + ), + format_attr_value( + entry, + {'name': 'expiration_warning', 'description': 'expiration warning time (days unit)', 'is-leaf-list': False, 'is-mandatory': False, 'group': ''} + ), + format_attr_value( + entry, + {'name': 'history_cnt', 'description': 'num of old password that the system will recorded', 'is-leaf-list': False, 'is-mandatory': False, 'group': ''} + ), + format_attr_value( + entry, + {'name': 'len_min', 'description': 'password min length', 'is-leaf-list': False, 'is-mandatory': False, 'group': ''} + ), + format_attr_value( + entry, + {'name': 'reject_user_passw_match', 'description': 'username password match', 'is-leaf-list': False, 'is-mandatory': False, 'group': ''} + ), + format_attr_value( + entry, + {'name': 'lower_class', 'description': 'password lower chars policy', 'is-leaf-list': False, 'is-mandatory': False, 'group': ''} + ), + format_attr_value( + entry, + {'name': 'upper_class', 'description': 'password upper chars policy', 'is-leaf-list': False, 'is-mandatory': False, 'group': ''} + ), + format_attr_value( + entry, + {'name': 'digits_class', 'description': 'password digits chars policy', 'is-leaf-list': False, 'is-mandatory': False, 'group': ''} + ), + format_attr_value( + entry, + {'name': 'special_class', 'description': 'password special chars policy', 'is-leaf-list': False, 'is-mandatory': False, 'group': ''} + ), +] + + body.append(row) + click.echo(tabulate.tabulate(body, header)) + + + + + +def register(cli): + """ Register new CLI nodes in root CLI. + + Args: + cli (click.core.Command): Root CLI node. + Raises: + Exception: when root CLI already has a command + we are trying to register. + """ + cli_node = PASSW_HARDENING + if cli_node.name in cli.commands: + raise Exception(f"{cli_node.name} already exists in CLI") + cli.add_command(PASSW_HARDENING) diff --git a/show/vnet.py b/show/vnet.py index 21d46af7fa..ba6f81ce8d 100644 --- a/show/vnet.py +++ b/show/vnet.py @@ -3,7 +3,7 @@ from natsort import natsorted from swsscommon.swsscommon import SonicV2Connector, ConfigDBConnector from tabulate import tabulate - +import ipaddress # # 'vnet' command ("show vnet") @@ -14,6 +14,56 @@ def vnet(): pass +@vnet.command() +@click.argument('args', metavar='[community:string]', required=False) +def advertised_routes(args): + """Show vnet advertised-routes [community string XXXX:XXXX]""" + state_db = SonicV2Connector() + state_db.connect(state_db.STATE_DB) + appl_db = SonicV2Connector() + appl_db.connect(appl_db.APPL_DB) + community_filter = '' + profile_filter = 'NO_PROFILE' + if args and len(args) > 0: + community_filter = args + + bgp_profile_keys = appl_db.keys(appl_db.APPL_DB, "BGP_PROFILE_TABLE:*") + bgp_profile_keys = natsorted(bgp_profile_keys) if bgp_profile_keys else [] + profiles = {} + for profilekey in bgp_profile_keys: + val = appl_db.get_all(appl_db.APPL_DB, profilekey) + if val: + community_id = val.get('community_id') + profiles[profilekey.split(':')[1]] = community_id + if community_filter and community_filter == community_id: + profile_filter = profilekey.split(':')[1] + break; + + adv_table_keys = state_db.keys(state_db.STATE_DB, "ADVERTISE_NETWORK_TABLE|*") + adv_table_keys = natsorted(adv_table_keys) if adv_table_keys else [] + header = ['Prefix', 'Profile', 'Community Id'] + table = [] + for k in adv_table_keys: + ip = k.split('|')[1] + val = state_db.get_all(appl_db.STATE_DB, k) + profile = val.get('profile') if val else 'NA' + if community_filter: + if profile == profile_filter: + r = [] + r.append(ip) + r.append(profile) + r.append(community_filter) + table.append(r) + else: + r = [] + r.append(ip) + r.append(profile) + if profile in profiles.keys(): + r.append(profiles[profile]) + table.append(r) + click.echo(tabulate(table, header)) + + @vnet.command() @click.argument('vnet_name', required=True) def name(vnet_name): @@ -195,6 +245,88 @@ def neighbors(): if not bool(vnet_intfs): click.echo(tabulate(table, header)) +@vnet.command() +@click.argument('args', metavar='[IPADDRESS]', nargs=1, required=False) +def endpoint(args): + """Show Vxlan tunnel endpoint status""" + """Specify IPv4 or IPv6 address for detail""" + + state_db = SonicV2Connector() + state_db.connect(state_db.STATE_DB) + appl_db = SonicV2Connector() + appl_db.connect(appl_db.APPL_DB) + filter_by_ip = '' + if args and len(args) > 0: + try: + filter_by_ip = ipaddress.ip_network(args) + except ValueError: + # Not ip address just ignore it + print ("wrong parameter",args) + return + # Fetching data from appl_db for VNET TUNNEL ROUTES + vnet_rt_keys = appl_db.keys(appl_db.APPL_DB, "VNET_ROUTE_TUNNEL_TABLE:*") + vnet_rt_keys = natsorted(vnet_rt_keys) if vnet_rt_keys else [] + bfd_keys = state_db.keys(state_db.STATE_DB, "BFD_SESSION_TABLE|*") + if not filter_by_ip: + header = ['Endpoint', 'Endpoint Monitor', 'prefix count', 'status'] + prefix_count = {} + monitor_dict = {} + table = [] + for k in vnet_rt_keys: + val = appl_db.get_all(appl_db.APPL_DB, k) + endpoints = val.get('endpoint').split(',') if 'endpoint' in val else [] + if 'endpoint_monitor' in val: + monitors = val.get('endpoint_monitor').split(',') + else: + continue + for idx, endpoint in enumerate(endpoints): + monitor_dict[endpoint] = monitors[idx] + if endpoint not in prefix_count: + prefix_count[endpoint] = 0 + prefix_count[endpoint] += 1 + for endpoint in prefix_count: + r = [] + r.append(endpoint) + r.append(monitor_dict[endpoint]) + r.append(prefix_count[endpoint]) + bfd_session_key = "BFD_SESSION_TABLE|default|default|" + monitor_dict[endpoint] + if bfd_session_key in bfd_keys: + val_state = state_db.get_all(state_db.STATE_DB, bfd_session_key) + r.append(val_state.get('state')) + else: + r.append('Unknown') + table.append(r) + else: + table = [] + header = ['Endpoint', 'Endpoint Monitor', 'prefix', 'status'] + state = 'Unknown' + prefix = [] + monitor_list = [] + have_status = False + for k in vnet_rt_keys: + val = appl_db.get_all(appl_db.APPL_DB, k) + endpoints = val.get('endpoint').split(',') + monitors = val.get('endpoint_monitor').split(',') + for idx, endpoint in enumerate(endpoints): + if args == endpoint: + prefix.append(k.split(":", 2)[2]) + if not have_status: + bfd_session_key = "BFD_SESSION_TABLE|default|default|" + monitors[idx] + if bfd_session_key in bfd_keys: + val_state = state_db.get_all(state_db.STATE_DB, bfd_session_key) + state = val_state.get('state') + have_status = True + monitor_list.append( monitors[idx]) + break + if prefix: + r = [] + r.append(args) + r.append(monitor_list) + r.append(prefix) + r.append(state) + table.append(r) + click.echo(tabulate(table, header)) + @vnet.group() def routes(): @@ -207,7 +339,8 @@ def all(): """Show all vnet routes""" appl_db = SonicV2Connector() appl_db.connect(appl_db.APPL_DB) - + state_db = SonicV2Connector() + state_db.connect(state_db.STATE_DB) header = ['vnet name', 'prefix', 'nexthop', 'interface'] # Fetching data from appl_db for VNET ROUTES @@ -227,7 +360,7 @@ def all(): click.echo() - header = ['vnet name', 'prefix', 'endpoint', 'mac address', 'vni'] + header = ['vnet name', 'prefix', 'endpoint', 'mac address', 'vni', 'status'] # Fetching data from appl_db for VNET TUNNEL ROUTES vnet_rt_keys = appl_db.keys(appl_db.APPL_DB, "VNET_ROUTE_TUNNEL_TABLE:*") @@ -237,10 +370,14 @@ def all(): for k in vnet_rt_keys: r = [] r.extend(k.split(":", 2)[1:]) + state_db_key = '|'.join(k.split(":",2)) val = appl_db.get_all(appl_db.APPL_DB, k) + val_state = state_db.get_all(state_db.STATE_DB, state_db_key) r.append(val.get('endpoint')) r.append(val.get('mac_address')) r.append(val.get('vni')) + if val_state: + r.append(val_state.get('state')) table.append(r) click.echo(tabulate(table, header)) diff --git a/show/vxlan.py b/show/vxlan.py index 0a00a28b03..3d04552904 100644 --- a/show/vxlan.py +++ b/show/vxlan.py @@ -32,10 +32,17 @@ def name(vxlan_name): vxlan_map_keys = config_db.keys(config_db.CONFIG_DB, 'VXLAN_TUNNEL_MAP{}{}{}*'.format(config_db.KEY_SEPARATOR, vxlan_name, config_db.KEY_SEPARATOR)) if vxlan_map_keys: - vxlan_map_mapping = config_db.get_all(config_db.CONFIG_DB, vxlan_map_keys[0]) - r.append(vxlan_map_keys[0].split(config_db.KEY_SEPARATOR, 2)[2]) - r.append("{} -> {}".format(vxlan_map_mapping.get('vni'), vxlan_map_mapping.get('vlan'))) - table.append(r) + for key in natsorted(vxlan_map_keys): + vxlan_map_mapping = config_db.get_all(config_db.CONFIG_DB, key) + r.append(key.split(config_db.KEY_SEPARATOR, 2)[2]) + r.append("{} -> {}".format(vxlan_map_mapping.get('vni'), vxlan_map_mapping.get('vlan'))) + table.append(r) + r = [] + r.append(' ') + r.append(' ') + r.append(' ') + else: + table.append(r) click.echo(tabulate(table, header)) @@ -59,10 +66,17 @@ def tunnel(): vxlan_map_keys = config_db.keys(config_db.CONFIG_DB, 'VXLAN_TUNNEL_MAP{}{}{}*'.format(config_db.KEY_SEPARATOR, k, config_db.KEY_SEPARATOR)) if vxlan_map_keys: - vxlan_map_mapping = config_db.get_all(config_db.CONFIG_DB, vxlan_map_keys[0]) - r.append(vxlan_map_keys[0].split(config_db.KEY_SEPARATOR, 2)[2]) - r.append("{} -> {}".format(vxlan_map_mapping.get('vni'), vxlan_map_mapping.get('vlan'))) - table.append(r) + for key in natsorted(vxlan_map_keys): + vxlan_map_mapping = config_db.get_all(config_db.CONFIG_DB, key) + r.append(key.split(config_db.KEY_SEPARATOR, 2)[2]) + r.append("{} -> {}".format(vxlan_map_mapping.get('vni'), vxlan_map_mapping.get('vlan'))) + table.append(r) + r = [] + r.append(' ') + r.append(' ') + r.append(' ') + else: + table.append(r) click.echo(tabulate(table, header)) @@ -84,14 +98,14 @@ def interface(): vtepname = key1.pop(); if 'src_ip' in vxlan_table[key]: vtep_sip = vxlan_table[key]['src_ip'] - if vtep_sip is not '0.0.0.0': + if vtep_sip != '0.0.0.0': output = '\tVTEP Name : ' + vtepname + ', SIP : ' + vxlan_table[key]['src_ip'] else: output = '\tVTEP Name : ' + vtepname click.echo(output) - if vtep_sip is not '0.0.0.0': + if vtep_sip != '0.0.0.0': vxlan_table = config_db.get_table('VXLAN_EVPN_NVO') vxlan_keys = vxlan_table.keys() if vxlan_keys is not None: @@ -293,8 +307,8 @@ def remotemac(remote_vtep_ip, count): vxlan_table = db.get_all(db.APPL_DB, key); if vxlan_table is None: continue - rmtip = vxlan_table['remote_vtep'] - if remote_vtep_ip != 'all' and rmtip != remote_vtep_ip: + rmtip = vxlan_table.get('remote_vtep') + if remote_vtep_ip != 'all' and rmtip != remote_vtep_ip or rmtip is None: continue if count is None: body.append([vlan, mac, rmtip, vxlan_table['vni'], vxlan_table['type']]) diff --git a/sonic-utilities-data/templates/service_mgmt.sh.j2 b/sonic-utilities-data/templates/service_mgmt.sh.j2 index e46ba47380..d206049015 100644 --- a/sonic-utilities-data/templates/service_mgmt.sh.j2 +++ b/sonic-utilities-data/templates/service_mgmt.sh.j2 @@ -28,7 +28,7 @@ if [[ -f /etc/sonic/${SERVICE}_dependent ]]; then fi if [[ -f /etc/sonic/${SERVICE}_multi_inst_dependent ]]; then - MULTI_INST_DEPENDENT="${MULTI_INST_DEPENDENT} cat /etc/sonic/${SERVICE}_multi_inst_dependent" + MULTI_INST_DEPENDENT="${MULTI_INST_DEPENDENT} $(cat /etc/sonic/${SERVICE}_multi_inst_dependent)" fi function debug() diff --git a/sonic-utilities-data/templates/timer.unit.j2 b/sonic-utilities-data/templates/timer.unit.j2 index a757b8deb8..09989f2c51 100644 --- a/sonic-utilities-data/templates/timer.unit.j2 +++ b/sonic-utilities-data/templates/timer.unit.j2 @@ -12,4 +12,8 @@ OnBootSec=3min 30 sec Unit={{ manifest.service.name }}{% if multi_instance %}@%i{% endif %}.service [Install] -WantedBy=timers.target sonic.target +WantedBy=timers.target sonic.target sonic-delayed.target +{%- for service in manifest.service["wanted-by"] %} +WantedBy={{ service }}{% if multi_instance and service in multi_instance_services %}@%i{% endif %}.service +{%- endfor %} + diff --git a/sonic_installer/bootloader/aboot.py b/sonic_installer/bootloader/aboot.py index ab4c0ff38c..8884ab5434 100644 --- a/sonic_installer/bootloader/aboot.py +++ b/sonic_installer/bootloader/aboot.py @@ -146,6 +146,11 @@ def _get_image_cmdline(self, image): with open(os.path.join(image_path, KERNEL_CMDLINE_NAME)) as f: return f.read() + def _set_image_cmdline(self, image, cmdline): + image_path = self.get_image_path(image) + with open(os.path.join(image_path, KERNEL_CMDLINE_NAME), 'w') as f: + return f.write(cmdline) + def supports_package_migration(self, image): if is_secureboot(): # NOTE: unsafe until migration can guarantee migration safety @@ -204,6 +209,17 @@ def verify_next_image(self): image_path = os.path.join(self.get_image_path(image), DEFAULT_SWI_IMAGE) return self._verify_secureboot_image(image_path) + def set_fips(self, image, enable): + fips = "1" if enable else "0" + cmdline = self._get_image_cmdline(image) + cmdline = re.sub(r' sonic_fips=[^\s]', '', cmdline) + " sonic_fips=" + fips + self._set_image_cmdline(image, cmdline) + click.echo('Done') + + def get_fips(self, image): + cmdline = self._get_image_cmdline(image) + return 'sonic_fips=1' in cmdline + def _verify_secureboot_image(self, image_path): if is_secureboot(): cert = self.getCert(image_path) diff --git a/sonic_installer/bootloader/bootloader.py b/sonic_installer/bootloader/bootloader.py index aaeddeba2f..d0919cdd50 100644 --- a/sonic_installer/bootloader/bootloader.py +++ b/sonic_installer/bootloader/bootloader.py @@ -57,6 +57,14 @@ def verify_secureboot_image(self, image_path): """verify that the image is secure running image""" raise NotImplementedError + def set_fips(self, image, enable): + """set fips""" + raise NotImplementedError + + def get_fips(self, image): + """returns true if fips set""" + raise NotImplementedError + def verify_next_image(self): """verify the next image for reboot""" image = self.get_next_image() diff --git a/sonic_installer/bootloader/grub.py b/sonic_installer/bootloader/grub.py index 11ee3de1f4..9a00800be5 100644 --- a/sonic_installer/bootloader/grub.py +++ b/sonic_installer/bootloader/grub.py @@ -85,6 +85,45 @@ def remove_image(self, image): run_command('grub-set-default --boot-directory=' + HOST_PATH + ' 0') click.echo('Image removed') + def get_linux_cmdline(self, image): + cmdline = None + config = open(HOST_PATH + '/grub/grub.cfg', 'r') + old_config = config.read() + menuentry = re.search("menuentry '" + image + "[^}]*}", old_config).group() + config.close() + for line in menuentry.split('\n'): + line = line.strip() + if line.startswith('linux '): + cmdline = line[6:].strip() + break + return cmdline + + def set_linux_cmdline(self, image, cmdline): + config = open(HOST_PATH + '/grub/grub.cfg', 'r') + old_config = config.read() + old_menuentry = re.search("menuentry '" + image + "[^}]*}", old_config).group() + config.close() + new_menuentry = old_menuentry + for line in old_menuentry.split('\n'): + line = line.strip() + if line.startswith('linux '): + new_menuentry = old_menuentry.replace(line, "linux " + cmdline) + break + config = open(HOST_PATH + '/grub/grub.cfg', 'w') + config.write(old_config.replace(old_menuentry, new_menuentry)) + config.close() + + def set_fips(self, image, enable): + fips = "1" if enable else "0" + cmdline = self.get_linux_cmdline(image) + cmdline = re.sub(r' sonic_fips=[^\s]', '', cmdline) + " sonic_fips=" + fips + self.set_linux_cmdline(image, cmdline) + click.echo('Done') + + def get_fips(self, image): + cmdline = self.get_linux_cmdline(image) + return 'sonic_fips=1' in cmdline + def platform_in_platforms_asic(self, platform, image_path): """ For those images that don't have devices list builtin, 'tar' will have non-zero returncode. diff --git a/sonic_installer/bootloader/uboot.py b/sonic_installer/bootloader/uboot.py index bc4b98daeb..3e3517dd1e 100644 --- a/sonic_installer/bootloader/uboot.py +++ b/sonic_installer/bootloader/uboot.py @@ -5,6 +5,7 @@ import platform import subprocess import os +import re import click @@ -39,7 +40,7 @@ def get_next_image(self): proc = subprocess.Popen("/usr/bin/fw_printenv -n boot_next", shell=True, text=True, stdout=subprocess.PIPE) (out, _) = proc.communicate() image = out.rstrip() - if "sonic_image_2" in image: + if "sonic_image_2" in image and len(images) == 2: next_image_index = 1 else: next_image_index = 0 @@ -81,6 +82,21 @@ def remove_image(self, image): def verify_image_platform(self, image_path): return os.path.isfile(image_path) + def set_fips(self, image, enable): + fips = "1" if enable else "0" + proc = subprocess.Popen("/usr/bin/fw_printenv linuxargs", shell=True, text=True, stdout=subprocess.PIPE) + (out, _) = proc.communicate() + cmdline = out.strip() + cmdline = re.sub('^linuxargs=', '', cmdline) + cmdline = re.sub(r' sonic_fips=[^\s]', '', cmdline) + " sonic_fips=" + fips + run_command('/usr/bin/fw_setenv linuxargs ' + cmdline) + click.echo('Done') + + def get_fips(self, image): + proc = subprocess.Popen("/usr/bin/fw_printenv linuxargs", shell=True, text=True, stdout=subprocess.PIPE) + (out, _) = proc.communicate() + return 'sonic_fips=1' in out + @classmethod def detect(cls): arch = platform.machine() diff --git a/sonic_installer/main.py b/sonic_installer/main.py index 1aaec8054e..44a4c08da6 100644 --- a/sonic_installer/main.py +++ b/sonic_installer/main.py @@ -306,16 +306,27 @@ def update_sonic_environment(bootloader, binary_image_version): umount(new_image_mount) +def get_docker_opts(): + """ Get options dockerd is started with """ + with open("/var/run/docker.pid") as pid_file: + pid = int(pid_file.read()) + + with open("/proc/{}/cmdline".format(pid)) as cmdline_file: + return cmdline_file.read().strip().split("\x00")[1:] + + def migrate_sonic_packages(bootloader, binary_image_version): """ Migrate SONiC packages to new SONiC image. """ + TMP_DIR = "tmp" SONIC_PACKAGE_MANAGER = "sonic-package-manager" PACKAGE_MANAGER_DIR = "/var/lib/sonic-package-manager/" DOCKER_CTL_SCRIPT = "/usr/lib/docker/docker.sh" DOCKERD_SOCK = "docker.sock" VAR_RUN_PATH = "/var/run/" + RESOLV_CONF_FILE = os.path.join("etc", "resolv.conf") + RESOLV_CONF_BACKUP_FILE = os.path.join("/", TMP_DIR, "resolv.conf.backup") - tmp_dir = "tmp" packages_file = "packages.json" packages_path = os.path.join(PACKAGE_MANAGER_DIR, packages_file) sonic_version = re.sub(IMAGE_PREFIX, '', binary_image_version) @@ -323,8 +334,10 @@ def migrate_sonic_packages(bootloader, binary_image_version): new_image_upper_dir = os.path.join(new_image_dir, UPPERDIR_NAME) new_image_work_dir = os.path.join(new_image_dir, WORKDIR_NAME) new_image_docker_dir = os.path.join(new_image_dir, DOCKERDIR_NAME) - new_image_mount = os.path.join("/", tmp_dir, "image-{0}-fs".format(sonic_version)) + new_image_mount = os.path.join("/", TMP_DIR, "image-{0}-fs".format(sonic_version)) new_image_docker_mount = os.path.join(new_image_mount, "var", "lib", "docker") + docker_default_config = os.path.join(new_image_mount, "etc", "default", "docker") + docker_default_config_backup = os.path.join(new_image_mount, TMP_DIR, "docker_config_backup") if not os.path.isdir(new_image_docker_dir): # NOTE: This codepath can be reached if the installation process did not @@ -349,21 +362,36 @@ def migrate_sonic_packages(bootloader, binary_image_version): if not os.path.exists(os.path.join(new_image_mount, os.path.relpath(DOCKER_CTL_SCRIPT, os.path.abspath(os.sep)))): echo_and_log("Warning: SONiC Application Extension is not supported in this image", LOG_WARN, fg="yellow") return + + # Start dockerd with same docker bridge, iptables configuration as on the host to not override docker configurations on the host. + # Dockerd has an option to start without creating a bridge, using --bridge=none option, however dockerd will remove the host docker0 in that case. + # Also, it is not possible to configure dockerd to start using a different bridge as it will also override the ip of the default docker0. + # Considering that, we start dockerd with same options the host dockerd is started. + run_command_or_raise(["cp", docker_default_config, docker_default_config_backup]) + run_command_or_raise(["sh", "-c", "echo 'DOCKER_OPTS=\"$DOCKER_OPTS {}\"' >> {}".format(" ".join(get_docker_opts()), docker_default_config)]) + run_command_or_raise(["chroot", new_image_mount, DOCKER_CTL_SCRIPT, "start"]) docker_started = True - run_command_or_raise(["cp", packages_path, os.path.join(new_image_mount, tmp_dir, packages_file)]) + run_command_or_raise(["cp", packages_path, os.path.join(new_image_mount, TMP_DIR, packages_file)]) run_command_or_raise(["touch", os.path.join(new_image_mount, "tmp", DOCKERD_SOCK)]) run_command_or_raise(["mount", "--bind", os.path.join(VAR_RUN_PATH, DOCKERD_SOCK), os.path.join(new_image_mount, "tmp", DOCKERD_SOCK)]) + + run_command_or_raise(["cp", os.path.join(new_image_mount, RESOLV_CONF_FILE), RESOLV_CONF_BACKUP_FILE]) + run_command_or_raise(["cp", os.path.join("/", RESOLV_CONF_FILE), os.path.join(new_image_mount, RESOLV_CONF_FILE)]) + run_command_or_raise(["chroot", new_image_mount, "sh", "-c", "command -v {}".format(SONIC_PACKAGE_MANAGER)]) run_command_or_raise(["chroot", new_image_mount, SONIC_PACKAGE_MANAGER, "migrate", - os.path.join("/", tmp_dir, packages_file), - "--dockerd-socket", os.path.join("/", tmp_dir, DOCKERD_SOCK), + os.path.join("/", TMP_DIR, packages_file), + "--dockerd-socket", os.path.join("/", TMP_DIR, DOCKERD_SOCK), "-y"]) finally: if docker_started: run_command_or_raise(["chroot", new_image_mount, DOCKER_CTL_SCRIPT, "stop"], raise_exception=False) + if os.path.exists(docker_default_config_backup): + run_command_or_raise(["mv", docker_default_config_backup, docker_default_config], raise_exception=False); + run_command_or_raise(["cp", RESOLV_CONF_BACKUP_FILE, os.path.join(new_image_mount, RESOLV_CONF_FILE)], raise_exception=False) umount(new_image_mount, recursive=True, read_only=False, remove_dir=False, raise_exception=False) umount(new_image_mount, raise_exception=False) @@ -616,6 +644,38 @@ def set_next_boot(image): sys.exit(1) bootloader.set_next_image(image) +# Set fips for image +@sonic_installer.command('set-fips') +@click.argument('image', required=False) +@click.option('--enable-fips/--disable-fips', is_flag=True, default=True, + help="Enable or disable FIPS, the default value is to enable FIPS") +def set_fips(image, enable_fips): + """ Set fips for the image """ + bootloader = get_bootloader() + if not image: + image = bootloader.get_next_image() + if image not in bootloader.get_installed_images(): + echo_and_log('Error: Image does not exist', LOG_ERR) + sys.exit(1) + bootloader.set_fips(image, enable=enable_fips) + click.echo('Set FIPS for the image successfully') + +# Get fips for image +@sonic_installer.command('get-fips') +@click.argument('image', required=False) +def get_fips(image): + """ Get the fips enabled or disabled status for the image """ + bootloader = get_bootloader() + if not image: + image = bootloader.get_next_image() + if image not in bootloader.get_installed_images(): + echo_and_log('Error: Image does not exist', LOG_ERR) + sys.exit(1) + enable = bootloader.get_fips(image) + if enable: + click.echo("FIPS is enabled") + else: + click.echo("FIPS is disabled") # Uninstall image @sonic_installer.command('remove') diff --git a/sonic_package_manager/service_creator/feature.py b/sonic_package_manager/service_creator/feature.py index 73e35566dd..7928274a6f 100644 --- a/sonic_package_manager/service_creator/feature.py +++ b/sonic_package_manager/service_creator/feature.py @@ -19,10 +19,10 @@ AUTO_TS_GLOBAL = "AUTO_TECHSUPPORT" AUTO_TS_FEATURE = "AUTO_TECHSUPPORT_FEATURE" CFG_STATE = "state" -# TODO: Enable available_mem_threshold once the mem_leak_auto_ts feature is available DEFAULT_AUTO_TS_FEATURE_CONFIG = { 'state': 'disabled', - 'rate_limit_interval': '600' + 'rate_limit_interval': '600', + 'available_mem_threshold': '10.0' } def is_enabled(cfg): diff --git a/tests/acl_input/incremental_1.json b/tests/acl_input/incremental_1.json new file mode 100644 index 0000000000..57ede08bf7 --- /dev/null +++ b/tests/acl_input/incremental_1.json @@ -0,0 +1,32 @@ +{ + "acl": { + "acl-sets": { + "acl-set": { + "ntp-acl": { + "acl-entries": { + "acl-entry": { + "1": { + "ip": { + "config": { + "source-ip-address": "20.0.0.12/32" + } + }, + "config": { + "sequence-id": 1 + }, + "actions": { + "config": { + "forwarding-action": "ACCEPT" + } + } + } + } + }, + "config": { + "name": "ntp-acl" + } + } + } + } + } +} \ No newline at end of file diff --git a/tests/acl_input/incremental_2.json b/tests/acl_input/incremental_2.json new file mode 100644 index 0000000000..b7de6edbac --- /dev/null +++ b/tests/acl_input/incremental_2.json @@ -0,0 +1,32 @@ +{ + "acl": { + "acl-sets": { + "acl-set": { + "ntp-acl": { + "acl-entries": { + "acl-entry": { + "1": { + "ip": { + "config": { + "source-ip-address": "20.0.0.12/32" + } + }, + "config": { + "sequence-id": 1 + }, + "actions": { + "config": { + "forwarding-action": "DROP" + } + } + } + } + }, + "config": { + "name": "ntp-acl" + } + } + } + } + } +} \ No newline at end of file diff --git a/tests/acl_loader_test.py b/tests/acl_loader_test.py index bae24de9a4..20b7283319 100644 --- a/tests/acl_loader_test.py +++ b/tests/acl_loader_test.py @@ -1,6 +1,7 @@ import sys import os import pytest +from unittest import mock test_path = os.path.dirname(os.path.abspath(__file__)) modules_path = os.path.dirname(test_path) @@ -200,3 +201,19 @@ def test_icmp_fields_with_non_tcp_protocol(self, acl_loader): acl_loader.rules_info = {} acl_loader.load_rules_from_file(os.path.join(test_path, 'acl_input/tcp_bad_protocol_number.json')) assert not acl_loader.rules_info.get("RULE_1") + + def test_incremental_update(self, acl_loader): + acl_loader.rules_info = {} + acl_loader.tables_db_info['NTP_ACL'] = { + "stage": "INGRESS", + "type": "CTRLPLANE" + } + acl_loader.load_rules_from_file(os.path.join(test_path, 'acl_input/incremental_1.json')) + acl_loader.rules_db_info = acl_loader.rules_info + assert acl_loader.rules_info[(('NTP_ACL', 'RULE_1'))]["PACKET_ACTION"] == "ACCEPT" + acl_loader.per_npu_configdb = None + acl_loader.configdb.mod_entry = mock.MagicMock(return_value=True) + acl_loader.configdb.set_entry = mock.MagicMock(return_value=True) + acl_loader.load_rules_from_file(os.path.join(test_path, 'acl_input/incremental_2.json')) + acl_loader.incremental_update() + assert acl_loader.rules_info[(('NTP_ACL', 'RULE_1'))]["PACKET_ACTION"] == "DROP" diff --git a/tests/aclshow_test.py b/tests/aclshow_test.py index d0a92174f4..90fe46f683 100644 --- a/tests/aclshow_test.py +++ b/tests/aclshow_test.py @@ -192,8 +192,8 @@ def nullify_counters(self): This method is used to empty dumped counters if exist in /tmp/.counters_acl.p (by default). """ - if os.path.isfile(aclshow.COUNTER_POSITION): - with open(aclshow.COUNTER_POSITION, 'w') as fp: + if os.path.isfile(aclshow.COUNTERS_CACHE): + with open(aclshow.COUNTERS_CACHE, 'w') as fp: json.dump([], fp) def runTest(self): diff --git a/tests/bgp_commands_test.py b/tests/bgp_commands_test.py index c862468781..67c05a2fd3 100644 --- a/tests/bgp_commands_test.py +++ b/tests/bgp_commands_test.py @@ -97,6 +97,14 @@ Error: bgp summary from bgp container not in json format """ +show_error_no_v6_neighbor = """\ +No IPv6 neighbor is configured +""" + +show_error_no_v4_neighbor = """\ +No IPv4 neighbor is configured +""" + show_bgp_summary_v4_chassis = """\ IPv4 Unicast Summary: @@ -319,3 +327,31 @@ def test_bgp_summary_v4_all_chassis( print("{}".format(result.output)) assert result.exit_code == 0 assert result.output == show_bgp_summary_v4_all_chassis + + @pytest.mark.parametrize('setup_single_bgp_instance', + ['show_bgp_summary_no_neigh'], indirect=['setup_single_bgp_instance']) + def test_bgp_summary_no_v4_neigh( + self, + setup_bgp_commands, + setup_single_bgp_instance): + show = setup_bgp_commands + runner = CliRunner() + result = runner.invoke( + show.cli.commands["ipv6"].commands["bgp"].commands["summary"], []) + print("{}".format(result.output)) + assert result.exit_code == 0 + assert result.output == show_error_no_v6_neighbor + + @pytest.mark.parametrize('setup_single_bgp_instance', + ['show_bgp_summary_no_neigh'], indirect=['setup_single_bgp_instance']) + def test_bgp_summary_no_v6_neigh( + self, + setup_bgp_commands, + setup_single_bgp_instance): + show = setup_bgp_commands + runner = CliRunner() + result = runner.invoke( + show.cli.commands["ip"].commands["bgp"].commands["summary"], []) + print("{}".format(result.output)) + assert result.exit_code == 0 + assert result.output == show_error_no_v4_neighbor diff --git a/tests/config_an_test.py b/tests/config_an_test.py index f16099e40c..0af19898c6 100644 --- a/tests/config_an_test.py +++ b/tests/config_an_test.py @@ -33,6 +33,9 @@ def test_config_autoneg(self, ctx): self.basic_check("autoneg", ["Ethernet0", "disabled"], ctx) self.basic_check("autoneg", ["Invalid", "enabled"], ctx, operator.ne) self.basic_check("autoneg", ["Ethernet0", "invalid"], ctx, operator.ne) + # Setting auto negotiation on a port channel is not supported + result = self.basic_check("autoneg", ["PortChannel0001", "enabled"], ctx, operator.ne) + assert 'Invalid port PortChannel0001' in result.output def test_config_speed(self, ctx): self.basic_check("speed", ["Ethernet0", "40000"], ctx) @@ -42,6 +45,9 @@ def test_config_speed(self, ctx): assert 'Invalid speed' in result.output assert 'Valid speeds:' in result.output self.basic_check("speed", ["Ethernet0", "invalid"], ctx, operator.ne) + # Setting speed on a port channel is not supported + result = self.basic_check("speed", ["PortChannel0001", "100000"], ctx, operator.ne) + assert 'Invalid port PortChannel0001' in result.output def test_config_adv_speeds(self, ctx): self.basic_check("advertised-speeds", ["Ethernet0", "40000,100000"], ctx) @@ -53,6 +59,9 @@ def test_config_adv_speeds(self, ctx): result = self.basic_check("advertised-speeds", ["Ethernet0", "50000,50000"], ctx, operator.ne) assert 'Invalid speed' in result.output assert 'duplicate' in result.output + # Setting advertised speeds on a port channel is not supported + result = self.basic_check("advertised-speeds", ["PortChannel0001", "40000,100000"], ctx, operator.ne) + assert 'Invalid port PortChannel0001' in result.output def test_config_type(self, ctx): self.basic_check("type", ["Ethernet0", "CR4"], ctx) @@ -64,6 +73,9 @@ def test_config_type(self, ctx): assert 'Valid interface types:' in result.output result = self.basic_check("type", ["Ethernet16", "Invalid"], ctx, operator.ne) assert "Setting RJ45 ports' type is not supported" in result.output + # Setting type on a port channel is not supported + result = self.basic_check("type", ["PortChannel0001", "CR4"], ctx, operator.ne) + assert 'Invalid port PortChannel0001' in result.output def test_config_adv_types(self, ctx): self.basic_check("advertised-types", ["Ethernet0", "CR4,KR4"], ctx) @@ -78,6 +90,33 @@ def test_config_adv_types(self, ctx): self.basic_check("advertised-types", ["Ethernet0", ""], ctx, operator.ne) result = self.basic_check("advertised-types", ["Ethernet16", "Invalid"], ctx, operator.ne) assert "Setting RJ45 ports' advertised types is not supported" in result.output + # Setting advertised types on a port channel is not supported + result = self.basic_check("advertised-types", ["PortChannel0001", "CR4,KR4"], ctx, operator.ne) + assert 'Invalid port PortChannel0001' in result.output + + def test_config_mtu(self, ctx): + self.basic_check("mtu", ["Ethernet0", "1514"], ctx) + result = self.basic_check("mtu", ["PortChannel0001", "1514"], ctx, operator.ne) + assert 'Invalid port PortChannel0001' in result.output + + def test_config_fec(self, ctx): + # Set a fec mode which is in supported_fec list but not default + # on an interface with supported_fec + self.basic_check("fec", ["Ethernet0", "test"], ctx) + # Set a fec mode which is one of default values on an interface without supported_fecs + self.basic_check("fec", ["Ethernet4", "rs"], ctx) + # Negative case: Set a fec mode which is default but not in port's supported_fecs + result = self.basic_check("fec", ["Ethernet0", "fc"], ctx, operator.ne) + assert "fec fc is not in ['rs', 'none', 'test']" in result.output + # Negative case: set a fec mode which is not default on an interface without supported_fecs + result = self.basic_check("fec", ["Ethernet4", "test"], ctx, operator.ne) + assert "fec test is not in ['rs', 'fc', 'none']" in result.output + # Negative case: set a fec mode on a port where setting fec is not supported + result = self.basic_check("fec", ["Ethernet112", "test"], ctx, operator.ne) + assert "Setting fec is not supported" in result.output + # Negative case: set a fec mode on a port channel is not supported + result = self.basic_check("fec", ["PortChannel0001", "none"], ctx, operator.ne) + assert 'Invalid port PortChannel0001' in result.output def basic_check(self, command_name, para_list, ctx, op=operator.eq, expect_result=0): runner = CliRunner() diff --git a/tests/config_int_ip_test.py b/tests/config_int_ip_test.py index 6968fcbe45..d1addd0f6d 100644 --- a/tests/config_int_ip_test.py +++ b/tests/config_int_ip_test.py @@ -105,6 +105,36 @@ def test_config_int_ip_rem_static( assert result.exit_code == 0 assert mock_run_command.call_count == 1 + @pytest.mark.parametrize('setup_single_bgp_instance', + ['ip_route_for_int_ip'], indirect=['setup_single_bgp_instance']) + def test_config_int_ip_rem_sub_intf( + self, + get_cmd_module, + setup_single_bgp_instance): + (config, _) = get_cmd_module + jsonfile_config = os.path.join(mock_db_path, "config_db") + from .mock_tables import dbconnector + dbconnector.dedicated_dbs['CONFIG_DB'] = jsonfile_config + + runner = CliRunner() + db = Db() + obj = {'config_db': db.cfgdb} + + # remove vlan IP`s + with mock.patch('utilities_common.cli.run_command') as mock_run_command: + print(db.cfgdb.get_table('INTERFACE')) + assert ('Ethernet16.16', '16.1.1.1/16') in db.cfgdb.get_table('VLAN_SUB_INTERFACE') + assert 'Ethernet16.16' in db.cfgdb.get_table('VLAN_SUB_INTERFACE') + result = runner.invoke(config.config.commands["interface"].commands["ip"].commands["remove"], + ["Ethernet16.16", "16.1.1.1/16"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code == 0 + assert mock_run_command.call_count == 1 + # removing IP should only remove the INTERFACE,IP key. The regular INTERFACE key should still exists for sub interface + assert ('Ethernet16.16', '16.1.1.1/16') not in db.cfgdb.get_table('VLAN_SUB_INTERFACE') + assert 'Ethernet16.16' in db.cfgdb.get_table('VLAN_SUB_INTERFACE') + + class TestIntIpMultiasic(object): @pytest.fixture(scope="class", autouse=True) def setup_class(cls): diff --git a/tests/config_lt_test.py b/tests/config_lt_test.py new file mode 100644 index 0000000000..8e8c1d6fb1 --- /dev/null +++ b/tests/config_lt_test.py @@ -0,0 +1,46 @@ +import click +import config.main as config +import operator +import os +import pytest +import sys + +from click.testing import CliRunner +from utilities_common.db import Db + +test_path = os.path.dirname(os.path.abspath(__file__)) +modules_path = os.path.dirname(test_path) +scripts_path = os.path.join(modules_path, "scripts") +sys.path.insert(0, modules_path) + + +@pytest.fixture(scope='module') +def ctx(scope='module'): + db = Db() + obj = {'config_db':db.cfgdb, 'namespace': ''} + yield obj + + +class TestConfigInterface(object): + @classmethod + def setup_class(cls): + print("SETUP") + os.environ["PATH"] += os.pathsep + scripts_path + os.environ["UTILITIES_UNIT_TESTING"] = "1" + + def test_config_link_training(self, ctx): + self.basic_check("link-training", ["Ethernet0", "on"], ctx) + self.basic_check("link-training", ["Ethernet0", "off"], ctx) + self.basic_check("link-training", ["Invalid", "on"], ctx, operator.ne) + self.basic_check("link-training", ["Invalid", "off"], ctx, operator.ne) + self.basic_check("link-training", ["Ethernet0", "invalid"], ctx, operator.ne) + # Setting link training on a port channel is not supported + result = self.basic_check("link-training", ["PortChannel0001", "on"], ctx, operator.ne) + assert 'Invalid port PortChannel0001' in result.output + + def basic_check(self, command_name, para_list, ctx, op=operator.eq, expect_result=0): + runner = CliRunner() + result = runner.invoke(config.config.commands["interface"].commands[command_name], para_list, obj = ctx) + print(result.output) + assert op(result.exit_code, expect_result) + return result diff --git a/tests/config_mirror_session_test.py b/tests/config_mirror_session_test.py index 986df2e711..de5e755a3f 100644 --- a/tests/config_mirror_session_test.py +++ b/tests/config_mirror_session_test.py @@ -80,6 +80,18 @@ def test_mirror_session_add(): mocked.assert_called_with("test_session", "100.1.1.1", "2.2.2.2", 8, 63, 0x1234, 100, None) + result = runner.invoke( + config.config.commands["mirror_session"].commands["add"], + ["test_session", "100.1.1.1", "2.2.2.2", "8", "63", "0", "0"]) + + mocked.assert_called_with("test_session", "100.1.1.1", "2.2.2.2", 8, 63, 0, 0, None) + + result = runner.invoke( + config.config.commands["mirror_session"].commands["add"], + ["test_session", "100.1.1.1", "2.2.2.2", "8", "63"]) + + mocked.assert_called_with("test_session", "100.1.1.1", "2.2.2.2", 8, 63, None, None, None) + def test_mirror_session_erspan_add(): runner = CliRunner() @@ -125,7 +137,7 @@ def test_mirror_session_erspan_add(): ["test_session", "1.1.1.1", "2.2.2.2", "6", "63", "65536", "100"]) assert result.exit_code != 0 assert ERR_MSG_GRE_TYPE_FAILURE in result.stdout - + result = runner.invoke( config.config.commands["mirror_session"].commands["erspan"].commands["add"], ["test_session", "1.1.1.1", "2.2.2.2", "6", "63", "abcd", "100"]) @@ -153,6 +165,12 @@ def test_mirror_session_erspan_add(): mocked.assert_called_with("test_session", "100.1.1.1", "2.2.2.2", 8, 63, 0x1234, 100, None, None, None) + result = runner.invoke( + config.config.commands["mirror_session"].commands["erspan"].commands["add"], + ["test_session", "100.1.1.1", "2.2.2.2", "8", "63", "0", "0"]) + + mocked.assert_called_with("test_session", "100.1.1.1", "2.2.2.2", 8, 63, 0, 0, None, None, None) + def test_mirror_session_span_add(): runner = CliRunner() @@ -246,9 +264,12 @@ def test_mirror_session_span_add(): result = runner.invoke( config.config.commands["mirror_session"].commands["span"].commands["add"], ["test_session", "Ethernet8", "Ethernet4", "tx", "100"]) + + mocked.assert_called_with("test_session", "Ethernet8", "Ethernet4", "tx", 100, None) + result = runner.invoke( config.config.commands["mirror_session"].commands["span"].commands["add"], - ["test_session", "Ethernet0", "Ethernet4", "rx", "100"]) + ["test_session", "Ethernet0", "Ethernet4", "rx", "0"]) - mocked.assert_called_with("test_session", "Ethernet0", "Ethernet4", "rx", 100, None) + mocked.assert_called_with("test_session", "Ethernet0", "Ethernet4", "rx", 0, None) diff --git a/tests/config_override_input/empty_table_removal.json b/tests/config_override_input/empty_table_removal.json new file mode 100644 index 0000000000..2230911ae6 --- /dev/null +++ b/tests/config_override_input/empty_table_removal.json @@ -0,0 +1,96 @@ +{ + "running_config": { + "ACL_TABLE": { + "DATAACL": { + "policy_desc": "DATAACL", + "ports": [ + "Ethernet4" + ], + "stage": "ingress", + "type": "L3" + }, + "NTP_ACL": { + "policy_desc": "NTP_ACL", + "services": [ + "NTP" + ], + "stage": "ingress", + "type": "CTRLPLANE" + } + }, + "AUTO_TECHSUPPORT_FEATURE": { + "bgp": { + "rate_limit_interval": "600", + "state": "enabled" + }, + "database": { + "rate_limit_interval": "600", + "state": "enabled" + } + }, + "PORT": { + "Ethernet4": { + "admin_status": "up", + "alias": "fortyGigE0/4", + "description": "Servers0:eth0", + "index": "1", + "lanes": "29,30,31,32", + "mtu": "9100", + "pfc_asym": "off", + "speed": "40000", + "tpid": "0x8100" + }, + "Ethernet8": { + "admin_status": "up", + "alias": "fortyGigE0/8", + "description": "Servers1:eth0", + "index": "2", + "lanes": "33,34,35,36", + "mtu": "9100", + "pfc_asym": "off", + "speed": "40000", + "tpid": "0x8100" + } + } + }, + "golden_config": { + "ACL_TABLE": { + } + }, + "expected_config": { + "AUTO_TECHSUPPORT_FEATURE": { + "bgp": { + "rate_limit_interval": "600", + "state": "enabled" + }, + "database": { + "rate_limit_interval": "600", + "state": "enabled" + } + }, + "PORT": { + "Ethernet4": { + "admin_status": "up", + "alias": "fortyGigE0/4", + "description": "Servers0:eth0", + "index": "1", + "lanes": "29,30,31,32", + "mtu": "9100", + "pfc_asym": "off", + "speed": "40000", + "tpid": "0x8100" + }, + "Ethernet8": { + "admin_status": "up", + "alias": "fortyGigE0/8", + "description": "Servers1:eth0", + "index": "2", + "lanes": "33,34,35,36", + "mtu": "9100", + "pfc_asym": "off", + "speed": "40000", + "tpid": "0x8100" + } + } + } +} diff --git a/tests/config_override_input/final_config_yang_failure.json b/tests/config_override_input/final_config_yang_failure.json new file mode 100644 index 0000000000..51e5e40098 --- /dev/null +++ b/tests/config_override_input/final_config_yang_failure.json @@ -0,0 +1,71 @@ +{ + "running_config": { + "ACL_TABLE": { + "DATAACL": { + "policy_desc": "DATAACL", + "ports": [ + "Ethernet4" + ], + "stage": "ingress", + "type": "L3" + }, + "NTP_ACL": { + "policy_desc": "NTP_ACL", + "services": [ + "NTP" + ], + "stage": "ingress", + "type": "CTRLPLANE" + } + }, + "AUTO_TECHSUPPORT_FEATURE": { + "bgp": { + "rate_limit_interval": "600", + "state": "enabled" + }, + "database": { + "rate_limit_interval": "600", + "state": "enabled" + } + }, + "PORT": { + "Ethernet4": { + "admin_status": "up", + "alias": "fortyGigE0/4", + "description": "Servers0:eth0", + "index": "1", + "lanes": "29,30,31,32", + "mtu": "9100", + "pfc_asym": "off", + "speed": "40000", + "tpid": "0x8100" + }, + "Ethernet8": { + "admin_status": "up", + "alias": "fortyGigE0/8", + "description": "Servers1:eth0", + "index": "2", + "lanes": "33,34,35,36", + "mtu": "9100", + "pfc_asym": "off", + "speed": "40000", + "tpid": "0x8100" + } + } + }, + "golden_config": { + "PORT": { + "Ethernet12": { + "admin_status": "up", + "alias": "fortyGigE0/12", + "description": "Servers2:eth0", + "index": "3", + "lanes": "37,38,39,40", + "mtu": "9100", + "pfc_asym": "off", + "speed": "40000", + "tpid": "0x8100" + } + } + } +} diff --git a/tests/config_override_input/golden_input_yang_failure.json b/tests/config_override_input/golden_input_yang_failure.json new file mode 100644 index 0000000000..4b533e1598 --- /dev/null +++ b/tests/config_override_input/golden_input_yang_failure.json @@ -0,0 +1,89 @@ +{ + "running_config": { + "ACL_TABLE": { + "DATAACL": { + "policy_desc": "DATAACL", + "ports": [ + "Ethernet4" + ], + "stage": "ingress", + "type": "L3" + }, + "NTP_ACL": { + "policy_desc": "NTP_ACL", + "services": [ + "NTP" + ], + "stage": "ingress", + "type": "CTRLPLANE" + } + }, + "AUTO_TECHSUPPORT_FEATURE": { + "bgp": { + "rate_limit_interval": "600", + "state": "enabled" + }, + "database": { + "rate_limit_interval": "600", + "state": "enabled" + } + }, + "PORT": { + "Ethernet4": { + "admin_status": "up", + "alias": "fortyGigE0/4", + "description": "Servers0:eth0", + "index": "1", + "lanes": "29,30,31,32", + "mtu": "9100", + "pfc_asym": "off", + "speed": "40000", + "tpid": "0x8100" + }, + "Ethernet8": { + "admin_status": "up", + "alias": "fortyGigE0/8", + "description": "Servers1:eth0", + "index": "2", + "lanes": "33,34,35,36", + "mtu": "9100", + "pfc_asym": "off", + "speed": "40000", + "tpid": "0x8100" + } + } + }, + "golden_config": { + "ACL_TABLE": { + "EVERFLOWV6": { + "policy_desc": "EVERFLOWV6", + "ports": [ + "Ethernet0" + ], + "stage": "ingress", + "type": "MIRRORV6" + } + }, + "AUTO_TECHSUPPORT_FEATURE": { + "bgp": { + "state": "disabled" + }, + "database": { + "state": "disabled" + } + }, + "PORT": { + "Ethernet12": { + "admin_status": "up", + "alias": "fortyGigE0/12", + "description": "Servers2:eth0", + "index": "3", + "lanes": "37,38,39,40", + "mtu": "9100", + "pfc_asym": "off", + "speed": "40000", + "tpid": "0x8100" + } + } + } +} diff --git a/tests/config_override_input/port_config_override.json b/tests/config_override_input/port_config_override.json new file mode 100644 index 0000000000..3c80a7344a --- /dev/null +++ b/tests/config_override_input/port_config_override.json @@ -0,0 +1,134 @@ +{ + "running_config": { + "ACL_TABLE": { + "DATAACL": { + "policy_desc": "DATAACL", + "ports": [ + "Ethernet4" + ], + "stage": "ingress", + "type": "L3" + }, + "NTP_ACL": { + "policy_desc": "NTP_ACL", + "services": [ + "NTP" + ], + "stage": "ingress", + "type": "CTRLPLANE" + } + }, + "AUTO_TECHSUPPORT_FEATURE": { + "bgp": { + "rate_limit_interval": "600", + "state": "enabled" + }, + "database": { + "rate_limit_interval": "600", + "state": "enabled" + } + }, + "PORT": { + "Ethernet4": { + "alias": "fortyGigE0/4", + "description": "Servers0:eth0", + "index": "1", + "lanes": "29,30,31,32", + "mtu": "9100", + "pfc_asym": "off", + "speed": "40000", + "tpid": "0x8100" + }, + "Ethernet8": { + "alias": "fortyGigE0/8", + "description": "Servers1:eth0", + "index": "2", + "lanes": "33,34,35,36", + "mtu": "9100", + "pfc_asym": "off", + "speed": "40000", + "tpid": "0x8100" + } + } + }, + "golden_config": { + "PORT": { + "Ethernet4": { + "admin_status": "up", + "alias": "fortyGigE0/4", + "description": "Servers0:eth0", + "index": "1", + "lanes": "29,30,31,32", + "mtu": "9100", + "pfc_asym": "off", + "speed": "40000", + "tpid": "0x8100" + }, + "Ethernet8": { + "admin_status": "down", + "alias": "fortyGigE0/8", + "description": "Servers1:eth0", + "index": "2", + "lanes": "33,34,35,36", + "mtu": "9100", + "pfc_asym": "off", + "speed": "40000", + "tpid": "0x8100" + } + } + }, + "expected_config": { + "ACL_TABLE": { + "DATAACL": { + "policy_desc": "DATAACL", + "ports": [ + "Ethernet4" + ], + "stage": "ingress", + "type": "L3" + }, + "NTP_ACL": { + "policy_desc": "NTP_ACL", + "services": [ + "NTP" + ], + "stage": "ingress", + "type": "CTRLPLANE" + } + }, + "AUTO_TECHSUPPORT_FEATURE": { + "bgp": { + "rate_limit_interval": "600", + "state": "enabled" + }, + "database": { + "rate_limit_interval": "600", + "state": "enabled" + } + }, + "PORT": { + "Ethernet4": { + "admin_status": "up", + "alias": "fortyGigE0/4", + "description": "Servers0:eth0", + "index": "1", + "lanes": "29,30,31,32", + "mtu": "9100", + "pfc_asym": "off", + "speed": "40000", + "tpid": "0x8100" + }, + "Ethernet8": { + "admin_status": "down", + "alias": "fortyGigE0/8", + "description": "Servers1:eth0", + "index": "2", + "lanes": "33,34,35,36", + "mtu": "9100", + "pfc_asym": "off", + "speed": "40000", + "tpid": "0x8100" + } + } + } +} diff --git a/tests/config_override_input/running_config_yang_failure.json b/tests/config_override_input/running_config_yang_failure.json new file mode 100644 index 0000000000..7060dd4d22 --- /dev/null +++ b/tests/config_override_input/running_config_yang_failure.json @@ -0,0 +1,89 @@ +{ + "running_config": { + "ACL_TABLE": { + "DATAACL": { + "policy_desc": "DATAACL", + "ports": [ + "Ethernet0" + ], + "stage": "ingress", + "type": "L3" + }, + "NTP_ACL": { + "policy_desc": "NTP_ACL", + "services": [ + "NTP" + ], + "stage": "ingress", + "type": "CTRLPLANE" + } + }, + "AUTO_TECHSUPPORT_FEATURE": { + "bgp": { + "rate_limit_interval": "600", + "state": "enabled" + }, + "database": { + "rate_limit_interval": "600", + "state": "enabled" + } + }, + "PORT": { + "Ethernet4": { + "admin_status": "up", + "alias": "fortyGigE0/4", + "description": "Servers0:eth0", + "index": "1", + "lanes": "29,30,31,32", + "mtu": "9100", + "pfc_asym": "off", + "speed": "40000", + "tpid": "0x8100" + }, + "Ethernet8": { + "admin_status": "up", + "alias": "fortyGigE0/8", + "description": "Servers1:eth0", + "index": "2", + "lanes": "33,34,35,36", + "mtu": "9100", + "pfc_asym": "off", + "speed": "40000", + "tpid": "0x8100" + } + } + }, + "golden_config": { + "ACL_TABLE": { + "EVERFLOWV6": { + "policy_desc": "EVERFLOWV6", + "ports": [ + "Ethernet12" + ], + "stage": "ingress", + "type": "MIRRORV6" + } + }, + "AUTO_TECHSUPPORT_FEATURE": { + "bgp": { + "state": "disabled" + }, + "database": { + "state": "disabled" + } + }, + "PORT": { + "Ethernet12": { + "admin_status": "up", + "alias": "fortyGigE0/12", + "description": "Servers2:eth0", + "index": "3", + "lanes": "37,38,39,40", + "mtu": "9100", + "pfc_asym": "off", + "speed": "40000", + "tpid": "0x8100" + } + } + } +} diff --git a/tests/config_override_test.py b/tests/config_override_test.py index bee2b44192..1b058ace13 100644 --- a/tests/config_override_test.py +++ b/tests/config_override_test.py @@ -15,10 +15,18 @@ PARTIAL_CONFIG_OVERRIDE = os.path.join(DATA_DIR, "partial_config_override.json") NEW_FEATURE_CONFIG = os.path.join(DATA_DIR, "new_feature_config.json") FULL_CONFIG_OVERRIDE = os.path.join(DATA_DIR, "full_config_override.json") +PORT_CONFIG_OVERRIDE = os.path.join(DATA_DIR, "port_config_override.json") +EMPTY_TABLE_REMOVAL = os.path.join(DATA_DIR, "empty_table_removal.json") +RUNNING_CONFIG_YANG_FAILURE = os.path.join(DATA_DIR, "running_config_yang_failure.json") +GOLDEN_INPUT_YANG_FAILURE = os.path.join(DATA_DIR, "golden_input_yang_failure.json") +FINAL_CONFIG_YANG_FAILURE = os.path.join(DATA_DIR, "final_config_yang_failure.json") # Load sonic-cfggen from source since /usr/local/bin/sonic-cfggen does not have .py extension. sonic_cfggen = load_module_from_source('sonic_cfggen', '/usr/local/bin/sonic-cfggen') +config_mgmt_py_path = os.path.join(os.path.dirname(__file__), '..', 'config', 'config_mgmt.py') +config_mgmt = load_module_from_source('config_mgmt', config_mgmt_py_path) + def write_init_config_db(cfgdb, config): tables = cfgdb.get_config() @@ -127,6 +135,24 @@ def test_golden_config_db_full(self): db, config, read_data['running_config'], read_data['golden_config'], read_data['expected_config']) + def test_golden_config_db_port_config(self): + """Golden Config makes change to PORT admin_status""" + db = Db() + with open(PORT_CONFIG_OVERRIDE, "r") as f: + read_data = json.load(f) + self.check_override_config_table( + db, config, read_data['running_config'], read_data['golden_config'], + read_data['expected_config']) + + def test_golden_config_db_empty_table_removal(self): + """Golden Config empty table does table removal""" + db = Db() + with open(EMPTY_TABLE_REMOVAL, "r") as f: + read_data = json.load(f) + self.check_override_config_table( + db, config, read_data['running_config'], read_data['golden_config'], + read_data['expected_config']) + def check_override_config_table(self, db, config, running_config, golden_config, expected_config): def read_json_file_side_effect(filename): @@ -143,6 +169,89 @@ def read_json_file_side_effect(filename): assert result.exit_code == 0 assert current_config == expected_config + def test_yang_verification_enabled(self): + def is_yang_config_validation_enabled_side_effect(filename): + return True + + def config_mgmt_side_effect(): + return config_mgmt.ConfigMgmt(source=CONFIG_DB_JSON_FILE) + + db = Db() + with open(FULL_CONFIG_OVERRIDE, "r") as f: + read_data = json.load(f) + + # ConfigMgmt will call ConfigDBConnector to load default config_db.json. + # Here I modify the ConfigMgmt initialization and make it initiated with + # a source file which share the same as what we write to cfgdb. + CONFIG_DB_JSON_FILE = "startConfigDb.json" + write_config_to_file(read_data['running_config'], CONFIG_DB_JSON_FILE) + with mock.patch('config.main.device_info.is_yang_config_validation_enabled', + mock.MagicMock(side_effect=is_yang_config_validation_enabled_side_effect)), \ + mock.patch('config.main.ConfigMgmt', + mock.MagicMock(side_effect=config_mgmt_side_effect)): + self.check_override_config_table( + db, config, read_data['running_config'], read_data['golden_config'], + read_data['expected_config']) + + + def test_running_config_yang_failure(self): + def is_yang_config_validation_enabled_side_effect(filename): + return True + db = Db() + with open(RUNNING_CONFIG_YANG_FAILURE, "r") as f: + read_data = json.load(f) + with mock.patch('config.main.device_info.is_yang_config_validation_enabled', + mock.MagicMock(side_effect=is_yang_config_validation_enabled_side_effect)): + self.check_yang_verification_failure( + db, config, read_data['running_config'], read_data['golden_config'], "running config") + + def test_golden_input_yang_failure(self): + def is_yang_config_validation_enabled_side_effect(filename): + return True + db = Db() + with open(GOLDEN_INPUT_YANG_FAILURE, "r") as f: + read_data = json.load(f) + with mock.patch('config.main.device_info.is_yang_config_validation_enabled', + mock.MagicMock(side_effect=is_yang_config_validation_enabled_side_effect)): + self.check_yang_verification_failure( + db, config, read_data['running_config'], read_data['golden_config'], "config_input") + + def test_final_config_yang_failure(self): + def is_yang_config_validation_enabled_side_effect(filename): + return True + db = Db() + with open(FINAL_CONFIG_YANG_FAILURE, "r") as f: + read_data = json.load(f) + with mock.patch('config.main.device_info.is_yang_config_validation_enabled', + mock.MagicMock(side_effect=is_yang_config_validation_enabled_side_effect)): + self.check_yang_verification_failure( + db, config, read_data['running_config'], read_data['golden_config'], "updated_config") + + def check_yang_verification_failure(self, db, config, running_config, + golden_config, jname): + def read_json_file_side_effect(filename): + return golden_config + + def config_mgmt_side_effect(): + return config_mgmt.ConfigMgmt(source=CONFIG_DB_JSON_FILE) + + # ConfigMgmt will call ConfigDBConnector to load default config_db.json. + # Here I modify the ConfigMgmt initialization and make it initiated with + # a source file which share the same as what we write to cfgdb. + CONFIG_DB_JSON_FILE = "startConfigDb.json" + write_config_to_file(running_config, CONFIG_DB_JSON_FILE) + with mock.patch('config.main.read_json_file', + mock.MagicMock(side_effect=read_json_file_side_effect)), \ + mock.patch('config.main.ConfigMgmt', + mock.MagicMock(side_effect=config_mgmt_side_effect)): + write_init_config_db(db.cfgdb, running_config) + + runner = CliRunner() + result = runner.invoke(config.config.commands["override-config-table"], + ['golden_config_db.json'], obj=db) + assert result.exit_code == 1 + assert "Failed to validate {}. Error:".format(jname) in result.output + @classmethod def teardown_class(cls): print("TEARDOWN") diff --git a/tests/config_test.py b/tests/config_test.py index 87865334a2..a19d16d6f9 100644 --- a/tests/config_test.py +++ b/tests/config_test.py @@ -6,6 +6,7 @@ import jsonpatch import sys import unittest +import ipaddress from unittest import mock import click @@ -35,16 +36,50 @@ load_minigraph_command_output="""\ Stopping SONiC target ... Running command: /usr/local/bin/sonic-cfggen -H -m --write-to-db -Running command: config qos reload --no-dynamic-buffer +Running command: config qos reload --no-dynamic-buffer --no-delay Running command: pfcwd start_default Restarting SONiC target ... Reloading Monit configuration ... Please note setting loaded from minigraph will be lost after system reboot. To preserve setting, run `config save`. """ +load_mgmt_config_command_ipv4_only_output="""\ +Running command: /usr/local/bin/sonic-cfggen -M device_desc.xml --write-to-db +parse dummy device_desc.xml +change hostname to dummy +Running command: ifconfig eth0 10.0.0.100 netmask 255.255.255.0 +Running command: ip route add default via 10.0.0.1 dev eth0 table default +Running command: ip rule add from 10.0.0.100 table default +Running command: [ -f /var/run/dhclient.eth0.pid ] && kill `cat /var/run/dhclient.eth0.pid` && rm -f /var/run/dhclient.eth0.pid +Please note loaded setting will be lost after system reboot. To preserve setting, run `config save`. +""" + +load_mgmt_config_command_ipv6_only_output="""\ +Running command: /usr/local/bin/sonic-cfggen -M device_desc.xml --write-to-db +parse dummy device_desc.xml +change hostname to dummy +Running command: ifconfig eth0 add fc00:1::32/64 +Running command: ip -6 route add default via fc00:1::1 dev eth0 table default +Running command: ip -6 rule add from fc00:1::32 table default +Running command: [ -f /var/run/dhclient.eth0.pid ] && kill `cat /var/run/dhclient.eth0.pid` && rm -f /var/run/dhclient.eth0.pid +Please note loaded setting will be lost after system reboot. To preserve setting, run `config save`. +""" + +load_mgmt_config_command_ipv4_ipv6_output="""\ +Running command: /usr/local/bin/sonic-cfggen -M device_desc.xml --write-to-db +parse dummy device_desc.xml +change hostname to dummy +Running command: ifconfig eth0 10.0.0.100 netmask 255.255.255.0 +Running command: ip route add default via 10.0.0.1 dev eth0 table default +Running command: ip rule add from 10.0.0.100 table default +Running command: ifconfig eth0 add fc00:1::32/64 +Running command: ip -6 route add default via fc00:1::1 dev eth0 table default +Running command: ip -6 rule add from fc00:1::32 table default +Running command: [ -f /var/run/dhclient.eth0.pid ] && kill `cat /var/run/dhclient.eth0.pid` && rm -f /var/run/dhclient.eth0.pid +Please note loaded setting will be lost after system reboot. To preserve setting, run `config save`. +""" RELOAD_CONFIG_DB_OUTPUT = """\ -Running command: rm -rf /tmp/dropstat-* Stopping SONiC target ... Running command: /usr/local/bin/sonic-cfggen -j /tmp/config.json --write-to-db Restarting SONiC target ... @@ -52,7 +87,6 @@ """ RELOAD_YANG_CFG_OUTPUT = """\ -Running command: rm -rf /tmp/dropstat-* Stopping SONiC target ... Running command: /usr/local/bin/sonic-cfggen -Y /tmp/config.json --write-to-db Restarting SONiC target ... @@ -60,7 +94,6 @@ """ RELOAD_MASIC_CONFIG_DB_OUTPUT = """\ -Running command: rm -rf /tmp/dropstat-* Stopping SONiC target ... Running command: /usr/local/bin/sonic-cfggen -j /tmp/config.json --write-to-db Running command: /usr/local/bin/sonic-cfggen -j /tmp/config.json -n asic0 --write-to-db @@ -70,9 +103,19 @@ """ reload_config_with_sys_info_command_output="""\ -Running command: rm -rf /tmp/dropstat-* Running command: /usr/local/bin/sonic-cfggen -H -k Seastone-DX010-25-50 --write-to-db""" +reload_config_with_disabled_service_output="""\ +Stopping SONiC target ... +Running command: /usr/local/bin/sonic-cfggen -j /tmp/config.json --write-to-db +Restarting SONiC target ... +Reloading Monit configuration ... +""" + +reload_config_with_untriggered_timer_output="""\ +Relevant services are not up. Retry later or use -f to avoid system checks +""" + def mock_run_command_side_effect(*args, **kwargs): command = args[0] @@ -81,20 +124,59 @@ def mock_run_command_side_effect(*args, **kwargs): if kwargs.get('return_cmd'): if command == "systemctl list-dependencies --plain sonic-delayed.target | sed '1d'": - return 'snmp.timer' + return 'snmp.timer' , 0 elif command == "systemctl list-dependencies --plain sonic.target | sed '1d'": - return 'swss' + return 'swss', 0 elif command == "systemctl is-enabled snmp.timer": - return 'enabled' + return 'enabled', 0 else: - return '' + return '', 0 +def mock_run_command_side_effect_disabled_timer(*args, **kwargs): + command = args[0] + + if kwargs.get('display_cmd'): + click.echo(click.style("Running command: ", fg='cyan') + click.style(command, fg='green')) + + if kwargs.get('return_cmd'): + if command == "systemctl list-dependencies --plain sonic-delayed.target | sed '1d'": + return 'snmp.timer', 0 + elif command == "systemctl list-dependencies --plain sonic.target | sed '1d'": + return 'swss', 0 + elif command == "systemctl is-enabled snmp.timer": + return 'masked', 0 + elif command == "systemctl show swss.service --property ActiveState --value": + return 'active', 0 + elif command == "systemctl show swss.service --property ActiveEnterTimestampMonotonic --value": + return '0', 0 + else: + return '', 0 + +def mock_run_command_side_effect_untriggered_timer(*args, **kwargs): + command = args[0] + + if kwargs.get('display_cmd'): + click.echo(click.style("Running command: ", fg='cyan') + click.style(command, fg='green')) + + if kwargs.get('return_cmd'): + if command == "systemctl list-dependencies --plain sonic-delayed.target | sed '1d'": + return 'snmp.timer', 0 + elif command == "systemctl list-dependencies --plain sonic.target | sed '1d'": + return 'swss', 0 + elif command == "systemctl is-enabled snmp.timer": + return 'enabled', 0 + elif command == "systemctl show snmp.timer --property=LastTriggerUSecMonotonic --value": + return '0', 0 + else: + return '', 0 # Load sonic-cfggen from source since /usr/local/bin/sonic-cfggen does not have .py extension. sonic_cfggen = load_module_from_source('sonic_cfggen', '/usr/local/bin/sonic-cfggen') class TestConfigReload(object): + dummy_cfg_file = os.path.join(os.sep, "tmp", "config.json") + @classmethod def setup_class(cls): os.environ['UTILITIES_UNIT_TESTING'] = "1" @@ -105,6 +187,7 @@ def setup_class(cls): import config.main importlib.reload(config.main) + open(cls.dummy_cfg_file, 'w').close() def test_config_reload(self, get_cmd_module, setup_single_broadcom_asic): with mock.patch("utilities_common.cli.run_command", mock.MagicMock(side_effect=mock_run_command_side_effect)) as mock_run_command: @@ -130,7 +213,33 @@ def test_config_reload(self, get_cmd_module, setup_single_broadcom_asic): assert result.exit_code == 0 - assert "\n".join([l.rstrip() for l in result.output.split('\n')][:2]) == reload_config_with_sys_info_command_output + assert "\n".join([l.rstrip() for l in result.output.split('\n')][:1]) == reload_config_with_sys_info_command_output + + def test_config_reload_untriggered_timer(self, get_cmd_module, setup_single_broadcom_asic): + with mock.patch("utilities_common.cli.run_command", mock.MagicMock(side_effect=mock_run_command_side_effect_untriggered_timer)) as mock_run_command: + (config, show) = get_cmd_module + + jsonfile_config = os.path.join(mock_db_path, "config_db.json") + jsonfile_init_cfg = os.path.join(mock_db_path, "init_cfg.json") + + # create object + config.INIT_CFG_FILE = jsonfile_init_cfg + config.DEFAULT_CONFIG_DB_FILE = jsonfile_config + + db = Db() + runner = CliRunner() + obj = {'config_db': db.cfgdb} + + # simulate 'config reload' to provoke load_sys_info option + result = runner.invoke(config.config.commands["reload"], ["-l", "-y"], obj=obj) + + print(result.exit_code) + print(result.output) + traceback.print_tb(result.exc_info[2]) + + assert result.exit_code == 1 + + assert "\n".join([l.rstrip() for l in result.output.split('\n')][:2]) == reload_config_with_untriggered_timer_output @classmethod def teardown_class(cls): @@ -162,9 +271,9 @@ def test_load_minigraph(self, get_cmd_module, setup_single_broadcom_asic): traceback.print_tb(result.exc_info[2]) assert result.exit_code == 0 assert "\n".join([l.rstrip() for l in result.output.split('\n')]) == load_minigraph_command_output - # Verify "systemctl reset-failed" is called for services under sonic.target + # Verify "systemctl reset-failed" is called for services under sonic.target mock_run_command.assert_any_call('systemctl reset-failed swss') - # Verify "systemctl reset-failed" is called for services under sonic-delayed.target + # Verify "systemctl reset-failed" is called for services under sonic-delayed.target mock_run_command.assert_any_call('systemctl reset-failed snmp') assert mock_run_command.call_count == 11 @@ -210,6 +319,49 @@ def test_load_minigraph_with_port_config(self, get_cmd_module, setup_single_broa port_config = [{"PORT": {"Ethernet0": {"admin_status": "up"}}}] self.check_port_config(db, config, port_config, "config interface startup Ethernet0") + def test_load_backend_acl(self, get_cmd_module, setup_single_broadcom_asic): + db = Db() + db.cfgdb.set_entry("DEVICE_METADATA", "localhost", {"storage_device": "true"}) + self.check_backend_acl(get_cmd_module, db, device_type='BackEndToRRouter', condition=True) + + def test_load_backend_acl_not_storage(self, get_cmd_module, setup_single_broadcom_asic): + db = Db() + self.check_backend_acl(get_cmd_module, db, device_type='BackEndToRRouter', condition=False) + + def test_load_backend_acl_storage_leaf(self, get_cmd_module, setup_single_broadcom_asic): + db = Db() + db.cfgdb.set_entry("DEVICE_METADATA", "localhost", {"storage_device": "true"}) + self.check_backend_acl(get_cmd_module, db, device_type='BackEndLeafRouter', condition=False) + + def test_load_backend_acl_storage_no_dataacl(self, get_cmd_module, setup_single_broadcom_asic): + db = Db() + db.cfgdb.set_entry("DEVICE_METADATA", "localhost", {"storage_device": "true"}) + db.cfgdb.set_entry("ACL_TABLE", "DATAACL", None) + self.check_backend_acl(get_cmd_module, db, device_type='BackEndToRRouter', condition=False) + + def check_backend_acl(self, get_cmd_module, db, device_type='BackEndToRRouter', condition=True): + def is_file_side_effect(filename): + return True if 'backend_acl' in filename else False + with mock.patch('os.path.isfile', mock.MagicMock(side_effect=is_file_side_effect)): + with mock.patch('config.main._get_device_type', mock.MagicMock(return_value=device_type)): + with mock.patch( + "utilities_common.cli.run_command", + mock.MagicMock(side_effect=mock_run_command_side_effect)) as mock_run_command: + (config, show) = get_cmd_module + runner = CliRunner() + result = runner.invoke(config.config.commands["load_minigraph"], ["-y"], obj=db) + print(result.exit_code) + expected_output = ['Running command: acl-loader update incremental /etc/sonic/backend_acl.json', + 'Running command: /usr/local/bin/sonic-cfggen -d -t /usr/share/sonic/templates/backend_acl.j2,/etc/sonic/backend_acl.json' + ] + print(result.output) + assert result.exit_code == 0 + output = result.output.split('\n') + if condition: + assert set(expected_output).issubset(set(output)) + else: + assert not(set(expected_output).issubset(set(output))) + def check_port_config(self, db, config, port_config, expected_output): def read_json_file_side_effect(filename): return port_config @@ -224,26 +376,66 @@ def is_file_side_effect(filename): assert result.exit_code == 0 assert expected_output in result.output - def test_load_minigraph_with_golden_config(self, get_cmd_module, setup_single_broadcom_asic): - with mock.patch( - "utilities_common.cli.run_command", - mock.MagicMock(side_effect=mock_run_command_side_effect)) as mock_run_command: + def test_load_minigraph_with_non_exist_golden_config_path(self, get_cmd_module): + def is_file_side_effect(filename): + return True if 'golden_config' in filename else False + with mock.patch("utilities_common.cli.run_command", mock.MagicMock(side_effect=mock_run_command_side_effect)) as mock_run_command, \ + mock.patch('os.path.isfile', mock.MagicMock(side_effect=is_file_side_effect)): (config, show) = get_cmd_module - db = Db() - golden_config = {} - self.check_golden_config(db, config, golden_config, - "config override-config-table /etc/sonic/golden_config_db.json") + runner = CliRunner() + result = runner.invoke(config.config.commands["load_minigraph"], ["--override_config", "--golden_config_path", "non_exist.json", "-y"]) + assert result.exit_code != 0 + assert "Cannot find 'non_exist.json'" in result.output - def check_golden_config(self, db, config, golden_config, expected_output): + def test_load_minigraph_with_specified_golden_config_path(self, get_cmd_module): def is_file_side_effect(filename): return True if 'golden_config' in filename else False - with mock.patch('os.path.isfile', mock.MagicMock(side_effect=is_file_side_effect)): + with mock.patch("utilities_common.cli.run_command", mock.MagicMock(side_effect=mock_run_command_side_effect)) as mock_run_command, \ + mock.patch('os.path.isfile', mock.MagicMock(side_effect=is_file_side_effect)): + (config, show) = get_cmd_module + runner = CliRunner() + result = runner.invoke(config.config.commands["load_minigraph"], ["--override_config", "--golden_config_path", "golden_config.json", "-y"]) + assert result.exit_code == 0 + assert "config override-config-table golden_config.json" in result.output + + def test_load_minigraph_with_default_golden_config_path(self, get_cmd_module): + def is_file_side_effect(filename): + return True if 'golden_config' in filename else False + with mock.patch("utilities_common.cli.run_command", mock.MagicMock(side_effect=mock_run_command_side_effect)) as mock_run_command, \ + mock.patch('os.path.isfile', mock.MagicMock(side_effect=is_file_side_effect)): + (config, show) = get_cmd_module runner = CliRunner() - result = runner.invoke(config.config.commands["load_minigraph"], ["-y"], obj=db) + result = runner.invoke(config.config.commands["load_minigraph"], ["--override_config", "-y"]) + assert result.exit_code == 0 + assert "config override-config-table /etc/sonic/golden_config_db.json" in result.output + + def test_load_minigraph_with_traffic_shift_away(self, get_cmd_module): + with mock.patch("utilities_common.cli.run_command", mock.MagicMock(side_effect=mock_run_command_side_effect)) as mock_run_command: + (config, show) = get_cmd_module + runner = CliRunner() + result = runner.invoke(config.config.commands["load_minigraph"], ["-ty"]) print(result.exit_code) print(result.output) + traceback.print_tb(result.exc_info[2]) assert result.exit_code == 0 - assert expected_output in result.output + assert "TSA" in result.output + + def test_load_minigraph_with_traffic_shift_away_with_golden_config(self, get_cmd_module): + with mock.patch("utilities_common.cli.run_command", mock.MagicMock(side_effect=mock_run_command_side_effect)) as mock_run_command: + def is_file_side_effect(filename): + return True if 'golden_config' in filename else False + with mock.patch('os.path.isfile', mock.MagicMock(side_effect=is_file_side_effect)): + (config, show) = get_cmd_module + db = Db() + golden_config = {} + runner = CliRunner() + result = runner.invoke(config.config.commands["load_minigraph"], ["-ty", "--override_config"]) + print(result.exit_code) + print(result.output) + traceback.print_tb(result.exc_info[2]) + assert result.exit_code == 0 + assert "TSA" in result.output + assert "[WARNING] Golden configuration may override Traffic-shift-away state" in result.output @classmethod def teardown_class(cls): @@ -280,6 +472,25 @@ def test_reload_config(self, get_cmd_module, setup_single_broadcom_asic): assert "\n".join([l.rstrip() for l in result.output.split('\n')]) \ == RELOAD_CONFIG_DB_OUTPUT + def test_config_reload_disabled_service(self, get_cmd_module, setup_single_broadcom_asic): + with mock.patch( + "utilities_common.cli.run_command", + mock.MagicMock(side_effect=mock_run_command_side_effect_disabled_timer) + ) as mock_run_command: + (config, show) = get_cmd_module + + runner = CliRunner() + result = runner.invoke(config.config.commands["reload"], [self.dummy_cfg_file, "-y"]) + + print(result.exit_code) + print(result.output) + print(reload_config_with_disabled_service_output) + traceback.print_tb(result.exc_info[2]) + + assert result.exit_code == 0 + + assert "\n".join([l.rstrip() for l in result.output.split('\n')]) == reload_config_with_disabled_service_output + def test_reload_config_masic(self, get_cmd_module, setup_multi_broadcom_masic): with mock.patch( "utilities_common.cli.run_command", @@ -289,7 +500,7 @@ def test_reload_config_masic(self, get_cmd_module, setup_multi_broadcom_masic): runner = CliRunner() # 3 config files: 1 for host and 2 for asic cfg_files = "{},{},{}".format( - self.dummy_cfg_file, + self.dummy_cfg_file, self.dummy_cfg_file, self.dummy_cfg_file) result = runner.invoke( @@ -313,7 +524,7 @@ def test_reload_yang_config(self, get_cmd_module, runner = CliRunner() result = runner.invoke(config.config.commands["reload"], - [self.dummy_cfg_file, '-y','-f' ,'-t', 'config_yang']) + [self.dummy_cfg_file, '-y', '-f', '-t', 'config_yang']) print(result.exit_code) print(result.output) @@ -328,7 +539,7 @@ def teardown_class(cls): os.remove(cls.dummy_cfg_file) print("TEARDOWN") - + class TestConfigCbf(object): @classmethod def setup_class(cls): @@ -436,6 +647,28 @@ def setup_class(cls): import config.main importlib.reload(config.main) + def _keys(args, kwargs): + if not TestConfigQos._keys_counter: + return [] + TestConfigQos._keys_counter-=1 + return ["BUFFER_POOL_TABLE:egress_lossy_pool"] + + def test_qos_wait_until_clear_empty(self): + from config.main import _wait_until_clear + + with mock.patch('swsscommon.swsscommon.SonicV2Connector.keys', side_effect=TestConfigQos._keys): + TestConfigQos._keys_counter = 1 + empty = _wait_until_clear("BUFFER_POOL_TABLE:*", 0.5,2) + assert empty + + def test_qos_wait_until_clear_not_empty(self): + from config.main import _wait_until_clear + + with mock.patch('swsscommon.swsscommon.SonicV2Connector.keys', side_effect=TestConfigQos._keys): + TestConfigQos._keys_counter = 10 + empty = _wait_until_clear("BUFFER_POOL_TABLE:*", 0.5,2) + assert not empty + def test_qos_reload_single( self, get_cmd_module, setup_qos_mock_apis, setup_single_broadcom_asic @@ -1226,3 +1459,97 @@ def validate_list_checkpoints_optional_parameter(self, param_args, expected_call self.assertTrue(expected_output in result.output) mock_generic_updater.list_checkpoints.assert_called_once() mock_generic_updater.list_checkpoints.assert_has_calls([expected_call]) + + +class TestConfigLoadMgmtConfig(object): + @classmethod + def setup_class(cls): + os.environ['UTILITIES_UNIT_TESTING'] = "1" + print("SETUP") + + from .mock_tables import mock_single_asic + importlib.reload(mock_single_asic) + + import config.main + importlib.reload(config.main) + + def test_config_load_mgmt_config_ipv4_only(self, get_cmd_module, setup_single_broadcom_asic): + device_desc_result = { + 'DEVICE_METADATA': { + 'localhost': { + 'hostname': 'dummy' + } + }, + 'MGMT_INTERFACE': { + ('eth0', '10.0.0.100/24') : { + 'gwaddr': ipaddress.ip_address(u'10.0.0.1') + } + } + } + self.check_output(get_cmd_module, device_desc_result, load_mgmt_config_command_ipv4_only_output, 5) + + def test_config_load_mgmt_config_ipv6_only(self, get_cmd_module, setup_single_broadcom_asic): + device_desc_result = { + 'DEVICE_METADATA': { + 'localhost': { + 'hostname': 'dummy' + } + }, + 'MGMT_INTERFACE': { + ('eth0', 'FC00:1::32/64') : { + 'gwaddr': ipaddress.ip_address(u'fc00:1::1') + } + } + } + self.check_output(get_cmd_module, device_desc_result, load_mgmt_config_command_ipv6_only_output, 5) + + def test_config_load_mgmt_config_ipv4_ipv6(self, get_cmd_module, setup_single_broadcom_asic): + device_desc_result = { + 'DEVICE_METADATA': { + 'localhost': { + 'hostname': 'dummy' + } + }, + 'MGMT_INTERFACE': { + ('eth0', '10.0.0.100/24') : { + 'gwaddr': ipaddress.ip_address(u'10.0.0.1') + }, + ('eth0', 'FC00:1::32/64') : { + 'gwaddr': ipaddress.ip_address(u'fc00:1::1') + } + } + } + self.check_output(get_cmd_module, device_desc_result, load_mgmt_config_command_ipv4_ipv6_output, 8) + + def check_output(self, get_cmd_module, parse_device_desc_xml_result, expected_output, expected_command_call_count): + def parse_device_desc_xml_side_effect(filename): + print("parse dummy device_desc.xml") + return parse_device_desc_xml_result + def change_hostname_side_effect(hostname): + print("change hostname to {}".format(hostname)) + with mock.patch("utilities_common.cli.run_command", mock.MagicMock(side_effect=mock_run_command_side_effect)) as mock_run_command: + with mock.patch('config.main.parse_device_desc_xml', mock.MagicMock(side_effect=parse_device_desc_xml_side_effect)): + with mock.patch('config.main._change_hostname', mock.MagicMock(side_effect=change_hostname_side_effect)): + (config, show) = get_cmd_module + runner = CliRunner() + with runner.isolated_filesystem(): + with open('device_desc.xml', 'w') as f: + f.write('dummy') + result = runner.invoke(config.config.commands["load_mgmt_config"], ["-y", "device_desc.xml"]) + print(result.exit_code) + print(result.output) + traceback.print_tb(result.exc_info[2]) + assert result.exit_code == 0 + assert "\n".join([l.rstrip() for l in result.output.split('\n')]) == expected_output + assert mock_run_command.call_count == expected_command_call_count + + @classmethod + def teardown_class(cls): + print("TEARDOWN") + os.environ['UTILITIES_UNIT_TESTING'] = "0" + + # change back to single asic config + from .mock_tables import dbconnector + from .mock_tables import mock_single_asic + importlib.reload(mock_single_asic) + dbconnector.load_namespace_config() diff --git a/tests/config_xcvr_test.py b/tests/config_xcvr_test.py new file mode 100644 index 0000000000..5043aa89d5 --- /dev/null +++ b/tests/config_xcvr_test.py @@ -0,0 +1,55 @@ +import click +import config.main as config +import operator +import os +import pytest +import sys + +from click.testing import CliRunner +from utilities_common.db import Db + +test_path = os.path.dirname(os.path.abspath(__file__)) +modules_path = os.path.dirname(test_path) +scripts_path = os.path.join(modules_path, "scripts") +sys.path.insert(0, modules_path) + + +@pytest.fixture(scope='module') +def ctx(scope='module'): + db = Db() + obj = {'config_db':db.cfgdb, 'namespace': ''} + yield obj + + +class TestConfigXcvr(object): + @classmethod + def setup_class(cls): + print("SETUP") + os.environ["PATH"] += os.pathsep + scripts_path + os.environ["UTILITIES_UNIT_TESTING"] = "1" + + def test_config_laser_frequency(self, ctx): + #self.basic_check("link-training", ["Ethernet0", "on"], ctx) + result = self.basic_check("frequency", ["Ethernet0", "191300"], ctx) + assert "Setting laser frequency" in result.output + result = self.basic_check("frequency", ["Ethernet0", "--", "-1"], ctx, op=operator.ne) + assert "Error: Frequency must be > 0" in result.output + # Setting laser frequency on a port channel is not supported + result = self.basic_check("frequency", ["PortChannel0001", "191300"], ctx, operator.ne) + assert 'Invalid port PortChannel0001' in result.output + + def test_config_tx_power(self, ctx): + result = self.basic_check("tx_power", ["Ethernet0", "11.3"], ctx) + assert "Setting target Tx output power" in result.output + result = self.basic_check("tx_power", ["Ethernet0", "11.34"], ctx, op=operator.ne) + assert "Error: tx power must be with single decimal place" in result.output + # Setting tx power on a port channel is not supported + result = self.basic_check("tx_power", ["PortChannel0001", "11.3"], ctx, operator.ne) + assert 'Invalid port PortChannel0001' in result.output + + def basic_check(self, command_name, para_list, ctx, op=operator.eq, expect_result=0): + runner = CliRunner() + result = runner.invoke(config.config.commands["interface"].commands["transceiver"].commands[command_name], para_list, obj = ctx) + print(result.output) + assert op(result.exit_code, expect_result) + return result diff --git a/tests/conftest.py b/tests/conftest.py index b48d0ef93f..96b80df3e1 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -145,9 +145,13 @@ def mock_show_bgp_summary( bgp_mocked_json = os.path.join( test_path, 'mock_tables', 'ipv6_bgp_summary_chassis.json') + _old_run_bgp_command = bgp_util.run_bgp_command bgp_util.run_bgp_command = mock.MagicMock( return_value=mock_show_bgp_summary("", "")) + yield + bgp_util.run_bgp_command = _old_run_bgp_command + @pytest.fixture def setup_t1_topo(): @@ -165,10 +169,23 @@ def setup_single_bgp_instance(request): elif request.param == 'v6': bgp_mocked_json = os.path.join( test_path, 'mock_tables', 'ipv6_bgp_summary.json') + elif request.param == 'ip_route': + bgp_mocked_json = 'ip_route.json' + elif request.param == 'ip_specific_route': + bgp_mocked_json = 'ip_specific_route.json' + elif request.param == 'ipv6_specific_route': + bgp_mocked_json = 'ipv6_specific_route.json' + elif request.param == 'ipv6_route': + bgp_mocked_json = 'ipv6_route.json' + elif request.param == 'ip_special_route': + bgp_mocked_json = 'ip_special_route.json' else: bgp_mocked_json = os.path.join( test_path, 'mock_tables', 'dummy.json') + def mock_show_bgp_summary_no_neigh(vtysh_cmd, bgp_namespace, vtysh_shell_cmd=constants.RVTYSH_COMMAND): + return "{}" + def mock_show_bgp_summary(vtysh_cmd, bgp_namespace, vtysh_shell_cmd=constants.RVTYSH_COMMAND): if os.path.isfile(bgp_mocked_json): with open(bgp_mocked_json) as json_data: @@ -187,23 +204,26 @@ def mock_run_bgp_command_for_static(vtysh_cmd, bgp_namespace="", vtysh_shell_cmd def mock_run_show_ip_route_commands(request): if request.param == 'ipv6_route_err': return show_ip_route_common.show_ipv6_route_err_expected_output - elif request.param == 'ip_route': - return show_ip_route_common.show_ip_route_expected_output - elif request.param == 'ip_specific_route': - return show_ip_route_common.show_specific_ip_route_expected_output - elif request.param == 'ip_special_route': - return show_ip_route_common.show_special_ip_route_expected_output - elif request.param == 'ipv6_route': - return show_ip_route_common.show_ipv6_route_expected_output - elif request.param == 'ipv6_specific_route': - return show_ip_route_common.show_ipv6_route_single_json_expected_output else: return "" + def mock_run_bgp_command(vtysh_cmd, bgp_namespace, vtysh_shell_cmd=constants.RVTYSH_COMMAND): + bgp_mocked_json_file = os.path.join( + test_path, 'mock_tables', bgp_mocked_json) + if os.path.isfile(bgp_mocked_json_file): + with open(bgp_mocked_json_file) as json_data: + mock_frr_data = json_data.read() + return mock_frr_data + else: + return "" - if any ([request.param == 'ipv6_route_err', request.param == 'ip_route',\ + _old_run_bgp_command = bgp_util.run_bgp_command + if any ([request.param == 'ip_route',\ request.param == 'ip_specific_route', request.param == 'ip_special_route',\ request.param == 'ipv6_route', request.param == 'ipv6_specific_route']): + bgp_util.run_bgp_command = mock.MagicMock( + return_value=mock_run_bgp_command("","")) + elif request.param.startswith('ipv6_route_err'): bgp_util.run_bgp_command = mock.MagicMock( return_value=mock_run_show_ip_route_commands(request)) elif request.param.startswith('bgp_v4_neighbor') or \ @@ -215,16 +235,17 @@ def mock_run_show_ip_route_commands(request): bgp_util.run_bgp_command = mock.MagicMock( return_value=mock_show_bgp_network_single_asic(request)) elif request.param == 'ip_route_for_int_ip': - _old_run_bgp_command = bgp_util.run_bgp_command bgp_util.run_bgp_command = mock_run_bgp_command_for_static + elif request.param == "show_bgp_summary_no_neigh": + bgp_util.run_bgp_command = mock.MagicMock( + return_value=mock_show_bgp_summary_no_neigh("", "")) else: bgp_util.run_bgp_command = mock.MagicMock( return_value=mock_show_bgp_summary("", "")) yield - if request.param == 'ip_route_for_int_ip': - bgp_util.run_bgp_command = _old_run_bgp_command + bgp_util.run_bgp_command = _old_run_bgp_command @pytest.fixture @@ -310,9 +331,9 @@ def setup_bgp_commands(): @pytest.fixture def setup_ip_route_commands(): import show.main as show - return show + @pytest.fixture def setup_fib_commands(): import show.main as show diff --git a/tests/coredump_gen_handler_test.py b/tests/coredump_gen_handler_test.py index bf4ae8dc78..49ed16e4ab 100644 --- a/tests/coredump_gen_handler_test.py +++ b/tests/coredump_gen_handler_test.py @@ -6,6 +6,7 @@ import signal from pyfakefs.fake_filesystem_unittest import Patcher from swsscommon import swsscommon +import utilities_common.auto_techsupport_helper as ts_helper from utilities_common.general import load_module_from_source from utilities_common.db import Db from utilities_common.auto_techsupport_helper import EXT_RETRY @@ -20,6 +21,8 @@ /tmp/saisdkdump """ +TS_DEFAULT_CMD = "show techsupport --silent --global-timeout 60 --since 2 days ago" + def signal_handler(signum, frame): raise Exception("Timed out!") @@ -91,7 +94,7 @@ def mock_cmd(cmd, env): else: return 1, "", "Command Not Found" return 0, AUTO_TS_STDOUT + ts_dump, "" - cdump_mod.subprocess_exec = mock_cmd + ts_helper.subprocess_exec = mock_cmd patcher.fs.create_file("/var/dump/sonic_dump_random1.tar.gz") patcher.fs.create_file("/var/dump/sonic_dump_random2.tar.gz") patcher.fs.create_file("/var/core/orchagent.12345.123.core.gz") @@ -123,7 +126,7 @@ def mock_cmd(cmd, env): else: return 1, "", "Command Not Found" return 0, AUTO_TS_STDOUT + ts_dump, "" - cdump_mod.subprocess_exec = mock_cmd + ts_helper.subprocess_exec = mock_cmd patcher.fs.create_file("/var/dump/sonic_dump_random1.tar.gz") patcher.fs.create_file("/var/dump/sonic_dump_random2.tar.gz") patcher.fs.create_file("/var/core/orchagent.12345.123.core.gz") @@ -157,7 +160,7 @@ def mock_cmd(cmd, env): else: return 1, "", "Command Not Found" return 0, AUTO_TS_STDOUT + ts_dump, "" - cdump_mod.subprocess_exec = mock_cmd + ts_helper.subprocess_exec = mock_cmd patcher.fs.create_file("/var/dump/sonic_dump_random1.tar.gz") patcher.fs.create_file("/var/core/orchagent.12345.123.core.gz") cls = cdump_mod.CriticalProcCoreDumpHandle("orchagent.12345.123.core.gz", "swss", redis_mock) @@ -187,7 +190,7 @@ def mock_cmd(cmd, env): else: return 1, "", "Command Not Found" return 0, AUTO_TS_STDOUT + ts_dump, "" - cdump_mod.subprocess_exec = mock_cmd + ts_helper.subprocess_exec = mock_cmd patcher.fs.create_file("/var/dump/sonic_dump_random1.tar.gz") patcher.fs.create_file("/var/dump/sonic_dump_random2.tar.gz") patcher.fs.create_file("/var/core/orchagent.12345.123.core.gz") @@ -218,7 +221,7 @@ def mock_cmd(cmd, env): else: return 1, "", "Command Not Found" return 0, AUTO_TS_STDOUT + ts_dump, "" - cdump_mod.subprocess_exec = mock_cmd + ts_helper.subprocess_exec = mock_cmd patcher.fs.create_file("/var/dump/sonic_dump_random1.tar.gz") patcher.fs.create_file("/var/core/snmpd.12345.123.core.gz") cls = cdump_mod.CriticalProcCoreDumpHandle("snmpd.12345.123.core.gz", "whatevver", redis_mock) @@ -247,7 +250,7 @@ def mock_cmd(cmd, env): else: return 1, "", "Command Not Found" return 0, AUTO_TS_STDOUT + ts_dump, "" - cdump_mod.subprocess_exec = mock_cmd + ts_helper.subprocess_exec = mock_cmd patcher.fs.create_file("/var/dump/sonic_dump_random1.tar.gz") patcher.fs.create_file("/var/core/python3.12345.123.core.gz") cls = cdump_mod.CriticalProcCoreDumpHandle("python3.12345.123.core.gz", "snmp", redis_mock) @@ -276,7 +279,7 @@ def mock_cmd(cmd, env): return 0, "", "" else: return 1, "", "Invalid Command" - cdump_mod.subprocess_exec = mock_cmd + ts_helper.subprocess_exec = mock_cmd patcher.fs.create_file("/var/dump/sonic_dump_random1.tar.gz") patcher.fs.create_file("/var/dump/sonic_dump_random2.tar.gz") patcher.fs.create_file("/var/core/orchagent.12345.123.core.gz") @@ -308,7 +311,7 @@ def mock_cmd(cmd, env): else: return 1, "", "Command Not Found" return 0, AUTO_TS_STDOUT + ts_dump, "" - cdump_mod.subprocess_exec = mock_cmd + ts_helper.subprocess_exec = mock_cmd patcher.fs.create_file("/var/dump/sonic_dump_random1.tar.gz") patcher.fs.create_file("/var/dump/sonic_dump_random2.tar.gz") patcher.fs.create_file("/var/core/orchagent.12345.123.core.gz") @@ -343,7 +346,7 @@ def mock_cmd(cmd, env): return 1, "", "Invalid Date Format" else: return 1, "", "" - cdump_mod.subprocess_exec = mock_cmd + ts_helper.subprocess_exec = mock_cmd patcher.fs.create_file("/var/dump/sonic_dump_random1.tar.gz") patcher.fs.create_file("/var/dump/sonic_dump_random2.tar.gz") patcher.fs.create_file("/var/core/orchagent.12345.123.core.gz") @@ -415,10 +418,10 @@ def test_max_retry_ts_failure(self): def mock_cmd(cmd, env): return EXT_RETRY, "", "" - cdump_mod.subprocess_exec = mock_cmd + ts_helper.subprocess_exec = mock_cmd patcher.fs.create_file("/var/core/orchagent.12345.123.core.gz") cls = cdump_mod.CriticalProcCoreDumpHandle("orchagent.12345.123.core.gz", "swss", redis_mock) - + signal.signal(signal.SIGALRM, signal_handler) signal.alarm(5) # 5 seconds try: @@ -427,4 +430,42 @@ def mock_cmd(cmd, env): assert False, "Method should not time out" finally: signal.alarm(0) + + def test_auto_ts_options(self): + """ + Scenario: Check if the techsupport is called as expected + """ + db_wrap = Db() + redis_mock = db_wrap.db + set_auto_ts_cfg(redis_mock, state="enabled", since_cfg="2 days ago") + set_feature_table_cfg(redis_mock, state="enabled") + with Patcher() as patcher: + def mock_cmd(cmd, env): + cmd_str = " ".join(cmd) + if "show techsupport" in cmd_str and cmd_str != TS_DEFAULT_CMD: + assert False, "Expected TS_CMD: {}, Recieved: {}".format(TS_DEFAULT_CMD, cmd_str) + return 0, AUTO_TS_STDOUT, "" + ts_helper.subprocess_exec = mock_cmd + patcher.fs.create_file("/var/core/orchagent.12345.123.core.gz") + cls = cdump_mod.CriticalProcCoreDumpHandle("orchagent.12345.123.core.gz", "swss", redis_mock) + cls.handle_core_dump_creation_event() + def test_auto_ts_empty_state_db(self): + """ + Scenario: Check if the techsupport is called as expected even when the history table in empty + and container cooloff is non-zero + """ + db_wrap = Db() + redis_mock = db_wrap.db + set_auto_ts_cfg(redis_mock, state="enabled", since_cfg="2 days ago") + set_feature_table_cfg(redis_mock, state="enabled", rate_limit_interval="300") + with Patcher() as patcher: + def mock_cmd(cmd, env): + cmd_str = " ".join(cmd) + if "show techsupport" in cmd_str and cmd_str != TS_DEFAULT_CMD: + assert False, "Expected TS_CMD: {}, Recieved: {}".format(TS_DEFAULT_CMD, cmd_str) + return 0, AUTO_TS_STDOUT, "" + ts_helper.subprocess_exec = mock_cmd + patcher.fs.create_file("/var/core/orchagent.12345.123.core.gz") + cls = cdump_mod.CriticalProcCoreDumpHandle("orchagent.12345.123.core.gz", "swss", redis_mock) + cls.handle_core_dump_creation_event() diff --git a/tests/counterpoll_test.py b/tests/counterpoll_test.py index 7a8171825a..4a4da07ee9 100644 --- a/tests/counterpoll_test.py +++ b/tests/counterpoll_test.py @@ -25,7 +25,8 @@ QUEUE_WATERMARK_STAT default (60000) enable PG_WATERMARK_STAT default (60000) enable PG_DROP_STAT 10000 enable -ACL 10000 enable +ACL 5000 enable +TUNNEL_STAT 3000 enable FLOW_CNT_TRAP_STAT 10000 enable FLOW_CNT_ROUTE_STAT 10000 enable """ diff --git a/tests/crm_test.py b/tests/crm_test.py index 24ced116ce..6b3f32ed9d 100644 --- a/tests/crm_test.py +++ b/tests/crm_test.py @@ -1033,6 +1033,8 @@ """ +crm_config_interval_too_big = "Error: Invalid value for \"INTERVAL\": 30000 is not in the valid range of 1 to 9999." + class TestCrm(object): @classmethod def setup_class(cls): @@ -1053,6 +1055,18 @@ def test_crm_show_summary(self): assert result.exit_code == 0 assert result.output == crm_new_show_summary + def test_crm_config_polling_interval(self): + runner = CliRunner() + db = Db() + result = runner.invoke(crm.cli, ['config', 'polling', 'interval', '10'], obj=db) + print(sys.stderr, result.output) + assert result.exit_code == 0 + result = runner.invoke(crm.cli, ['config', 'polling', 'interval', '30000'], obj=db) + print(sys.stderr, result.output) + assert result.exit_code == 2 + assert crm_config_interval_too_big in result.output + + def test_crm_show_thresholds_acl_group(self): runner = CliRunner() db = Db() diff --git a/tests/db_migrator_input/appl_db/acs-msn2700-t0-version_2_0_0.json b/tests/db_migrator_input/appl_db/acs-msn2700-t0-version_3_0_0.json similarity index 100% rename from tests/db_migrator_input/appl_db/acs-msn2700-t0-version_2_0_0.json rename to tests/db_migrator_input/appl_db/acs-msn2700-t0-version_3_0_0.json diff --git a/tests/db_migrator_input/appl_db/acs-msn2700-t0-version_2_0_3.json b/tests/db_migrator_input/appl_db/acs-msn2700-t0-version_3_0_3.json similarity index 100% rename from tests/db_migrator_input/appl_db/acs-msn2700-t0-version_2_0_3.json rename to tests/db_migrator_input/appl_db/acs-msn2700-t0-version_3_0_3.json diff --git a/tests/db_migrator_input/appl_db/acs-msn2700-t1-version_2_0_0.json b/tests/db_migrator_input/appl_db/acs-msn2700-t1-version_3_0_0.json similarity index 100% rename from tests/db_migrator_input/appl_db/acs-msn2700-t1-version_2_0_0.json rename to tests/db_migrator_input/appl_db/acs-msn2700-t1-version_3_0_0.json diff --git a/tests/db_migrator_input/appl_db/acs-msn2700-t1-version_2_0_3.json b/tests/db_migrator_input/appl_db/acs-msn2700-t1-version_3_0_3.json similarity index 100% rename from tests/db_migrator_input/appl_db/acs-msn2700-t1-version_2_0_3.json rename to tests/db_migrator_input/appl_db/acs-msn2700-t1-version_3_0_3.json diff --git a/tests/db_migrator_input/appl_db/acs-msn3700-t0-version_2_0_0.json b/tests/db_migrator_input/appl_db/acs-msn3700-t0-version_3_0_0.json similarity index 100% rename from tests/db_migrator_input/appl_db/acs-msn3700-t0-version_2_0_0.json rename to tests/db_migrator_input/appl_db/acs-msn3700-t0-version_3_0_0.json diff --git a/tests/db_migrator_input/appl_db/acs-msn3700-t0-version_2_0_3.json b/tests/db_migrator_input/appl_db/acs-msn3700-t0-version_3_0_3.json similarity index 100% rename from tests/db_migrator_input/appl_db/acs-msn3700-t0-version_2_0_3.json rename to tests/db_migrator_input/appl_db/acs-msn3700-t0-version_3_0_3.json diff --git a/tests/db_migrator_input/appl_db/acs-msn3700-t1-version_2_0_0.json b/tests/db_migrator_input/appl_db/acs-msn3700-t1-version_3_0_0.json similarity index 100% rename from tests/db_migrator_input/appl_db/acs-msn3700-t1-version_2_0_0.json rename to tests/db_migrator_input/appl_db/acs-msn3700-t1-version_3_0_0.json diff --git a/tests/db_migrator_input/appl_db/acs-msn3700-t1-version_2_0_3.json b/tests/db_migrator_input/appl_db/acs-msn3700-t1-version_3_0_3.json similarity index 100% rename from tests/db_migrator_input/appl_db/acs-msn3700-t1-version_2_0_3.json rename to tests/db_migrator_input/appl_db/acs-msn3700-t1-version_3_0_3.json diff --git a/tests/db_migrator_input/appl_db/acs-msn3800-t0-version_2_0_0.json b/tests/db_migrator_input/appl_db/acs-msn3800-t0-version_3_0_0.json similarity index 100% rename from tests/db_migrator_input/appl_db/acs-msn3800-t0-version_2_0_0.json rename to tests/db_migrator_input/appl_db/acs-msn3800-t0-version_3_0_0.json diff --git a/tests/db_migrator_input/appl_db/acs-msn3800-t0-version_2_0_3.json b/tests/db_migrator_input/appl_db/acs-msn3800-t0-version_3_0_3.json similarity index 100% rename from tests/db_migrator_input/appl_db/acs-msn3800-t0-version_2_0_3.json rename to tests/db_migrator_input/appl_db/acs-msn3800-t0-version_3_0_3.json diff --git a/tests/db_migrator_input/appl_db/acs-msn3800-t1-version_2_0_0.json b/tests/db_migrator_input/appl_db/acs-msn3800-t1-version_3_0_0.json similarity index 100% rename from tests/db_migrator_input/appl_db/acs-msn3800-t1-version_2_0_0.json rename to tests/db_migrator_input/appl_db/acs-msn3800-t1-version_3_0_0.json diff --git a/tests/db_migrator_input/appl_db/acs-msn3800-t1-version_2_0_3.json b/tests/db_migrator_input/appl_db/acs-msn3800-t1-version_3_0_3.json similarity index 100% rename from tests/db_migrator_input/appl_db/acs-msn3800-t1-version_2_0_3.json rename to tests/db_migrator_input/appl_db/acs-msn3800-t1-version_3_0_3.json diff --git a/tests/db_migrator_input/appl_db/acs-msn4700-t0-version_2_0_0.json b/tests/db_migrator_input/appl_db/acs-msn4700-t0-version_3_0_0.json similarity index 100% rename from tests/db_migrator_input/appl_db/acs-msn4700-t0-version_2_0_0.json rename to tests/db_migrator_input/appl_db/acs-msn4700-t0-version_3_0_0.json diff --git a/tests/db_migrator_input/appl_db/acs-msn4700-t0-version_2_0_3.json b/tests/db_migrator_input/appl_db/acs-msn4700-t0-version_3_0_3.json similarity index 100% rename from tests/db_migrator_input/appl_db/acs-msn4700-t0-version_2_0_3.json rename to tests/db_migrator_input/appl_db/acs-msn4700-t0-version_3_0_3.json diff --git a/tests/db_migrator_input/appl_db/acs-msn4700-t1-version_2_0_0.json b/tests/db_migrator_input/appl_db/acs-msn4700-t1-version_3_0_0.json similarity index 100% rename from tests/db_migrator_input/appl_db/acs-msn4700-t1-version_2_0_0.json rename to tests/db_migrator_input/appl_db/acs-msn4700-t1-version_3_0_0.json diff --git a/tests/db_migrator_input/appl_db/acs-msn4700-t1-version_2_0_3.json b/tests/db_migrator_input/appl_db/acs-msn4700-t1-version_3_0_3.json similarity index 100% rename from tests/db_migrator_input/appl_db/acs-msn4700-t1-version_2_0_3.json rename to tests/db_migrator_input/appl_db/acs-msn4700-t1-version_3_0_3.json diff --git a/tests/db_migrator_input/appl_db/loopback_interface_migrate_from_1_0_1_expected.json b/tests/db_migrator_input/appl_db/loopback_interface_migrate_from_1_0_1_expected.json new file mode 100644 index 0000000000..5d40ad319d --- /dev/null +++ b/tests/db_migrator_input/appl_db/loopback_interface_migrate_from_1_0_1_expected.json @@ -0,0 +1,8 @@ +{ + "INTF_TABLE:Loopback0" : {"NULL": "NULL"}, + "INTF_TABLE:Loopback0:10.1.0.32/32" : {"NULL": "NULL"}, + "INTF_TABLE:Loopback0:FC00:1::32/128" : {"NULL": "NULL"}, + "INTF_TABLE:Loopback1" : {"NULL": "NULL"}, + "INTF_TABLE:Loopback1:10.20.8.199/32" : {"NULL": "NULL"}, + "INTF_TABLE:Loopback1:2001:506:28:500::1/128" : {"NULL": "NULL"} +} diff --git a/tests/db_migrator_input/appl_db/loopback_interface_migrate_from_1_0_1_input.json b/tests/db_migrator_input/appl_db/loopback_interface_migrate_from_1_0_1_input.json new file mode 100644 index 0000000000..4326e37ec1 --- /dev/null +++ b/tests/db_migrator_input/appl_db/loopback_interface_migrate_from_1_0_1_input.json @@ -0,0 +1,18 @@ +{ + "INTF_TABLE:lo:10.1.0.32/32" : { + "scope": "global", + "family": "IPv4" + }, + "INTF_TABLE:lo:FC00:1::32/128" : { + "scope": "global", + "family": "IPv6" + }, + "INTF_TABLE:lo:10.20.8.199/32" : { + "scope": "global", + "family": "IPv4" + }, + "INTF_TABLE:lo:2001:506:28:500::1/128" : { + "scope": "global", + "family": "IPv6" + } +} \ No newline at end of file diff --git a/tests/db_migrator_input/appl_db/mellanox-sn2700-c28d8-single-pool-t0-version_2_0_0.json b/tests/db_migrator_input/appl_db/mellanox-sn2700-c28d8-single-pool-t0-version_3_0_0.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn2700-c28d8-single-pool-t0-version_2_0_0.json rename to tests/db_migrator_input/appl_db/mellanox-sn2700-c28d8-single-pool-t0-version_3_0_0.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn2700-c28d8-single-pool-t0-version_2_0_3.json b/tests/db_migrator_input/appl_db/mellanox-sn2700-c28d8-single-pool-t0-version_3_0_3.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn2700-c28d8-single-pool-t0-version_2_0_3.json rename to tests/db_migrator_input/appl_db/mellanox-sn2700-c28d8-single-pool-t0-version_3_0_3.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn2700-c28d8-single-pool-t1-version_2_0_0.json b/tests/db_migrator_input/appl_db/mellanox-sn2700-c28d8-single-pool-t1-version_3_0_0.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn2700-c28d8-single-pool-t1-version_2_0_0.json rename to tests/db_migrator_input/appl_db/mellanox-sn2700-c28d8-single-pool-t1-version_3_0_0.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn2700-c28d8-single-pool-t1-version_2_0_3.json b/tests/db_migrator_input/appl_db/mellanox-sn2700-c28d8-single-pool-t1-version_3_0_3.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn2700-c28d8-single-pool-t1-version_2_0_3.json rename to tests/db_migrator_input/appl_db/mellanox-sn2700-c28d8-single-pool-t1-version_3_0_3.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn2700-c28d8-t0-version_2_0_0.json b/tests/db_migrator_input/appl_db/mellanox-sn2700-c28d8-t0-version_3_0_0.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn2700-c28d8-t0-version_2_0_0.json rename to tests/db_migrator_input/appl_db/mellanox-sn2700-c28d8-t0-version_3_0_0.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn2700-c28d8-t0-version_2_0_3.json b/tests/db_migrator_input/appl_db/mellanox-sn2700-c28d8-t0-version_3_0_3.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn2700-c28d8-t0-version_2_0_3.json rename to tests/db_migrator_input/appl_db/mellanox-sn2700-c28d8-t0-version_3_0_3.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn2700-c28d8-t1-version_2_0_0.json b/tests/db_migrator_input/appl_db/mellanox-sn2700-c28d8-t1-version_3_0_0.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn2700-c28d8-t1-version_2_0_0.json rename to tests/db_migrator_input/appl_db/mellanox-sn2700-c28d8-t1-version_3_0_0.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn2700-c28d8-t1-version_2_0_3.json b/tests/db_migrator_input/appl_db/mellanox-sn2700-c28d8-t1-version_3_0_3.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn2700-c28d8-t1-version_2_0_3.json rename to tests/db_migrator_input/appl_db/mellanox-sn2700-c28d8-t1-version_3_0_3.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn2700-d40c8s8-t0-version_2_0_0.json b/tests/db_migrator_input/appl_db/mellanox-sn2700-d40c8s8-t0-version_3_0_0.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn2700-d40c8s8-t0-version_2_0_0.json rename to tests/db_migrator_input/appl_db/mellanox-sn2700-d40c8s8-t0-version_3_0_0.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn2700-d40c8s8-t0-version_2_0_3.json b/tests/db_migrator_input/appl_db/mellanox-sn2700-d40c8s8-t0-version_3_0_3.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn2700-d40c8s8-t0-version_2_0_3.json rename to tests/db_migrator_input/appl_db/mellanox-sn2700-d40c8s8-t0-version_3_0_3.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn2700-d40c8s8-t1-version_2_0_0.json b/tests/db_migrator_input/appl_db/mellanox-sn2700-d40c8s8-t1-version_3_0_0.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn2700-d40c8s8-t1-version_2_0_0.json rename to tests/db_migrator_input/appl_db/mellanox-sn2700-d40c8s8-t1-version_3_0_0.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn2700-d40c8s8-t1-version_2_0_3.json b/tests/db_migrator_input/appl_db/mellanox-sn2700-d40c8s8-t1-version_3_0_3.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn2700-d40c8s8-t1-version_2_0_3.json rename to tests/db_migrator_input/appl_db/mellanox-sn2700-d40c8s8-t1-version_3_0_3.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn2700-d48c8-single-pool-t0-version_2_0_0.json b/tests/db_migrator_input/appl_db/mellanox-sn2700-d48c8-single-pool-t0-version_3_0_0.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn2700-d48c8-single-pool-t0-version_2_0_0.json rename to tests/db_migrator_input/appl_db/mellanox-sn2700-d48c8-single-pool-t0-version_3_0_0.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn2700-d48c8-single-pool-t0-version_2_0_3.json b/tests/db_migrator_input/appl_db/mellanox-sn2700-d48c8-single-pool-t0-version_3_0_3.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn2700-d48c8-single-pool-t0-version_2_0_3.json rename to tests/db_migrator_input/appl_db/mellanox-sn2700-d48c8-single-pool-t0-version_3_0_3.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn2700-d48c8-single-pool-t1-version_2_0_0.json b/tests/db_migrator_input/appl_db/mellanox-sn2700-d48c8-single-pool-t1-version_3_0_0.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn2700-d48c8-single-pool-t1-version_2_0_0.json rename to tests/db_migrator_input/appl_db/mellanox-sn2700-d48c8-single-pool-t1-version_3_0_0.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn2700-d48c8-single-pool-t1-version_2_0_3.json b/tests/db_migrator_input/appl_db/mellanox-sn2700-d48c8-single-pool-t1-version_3_0_3.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn2700-d48c8-single-pool-t1-version_2_0_3.json rename to tests/db_migrator_input/appl_db/mellanox-sn2700-d48c8-single-pool-t1-version_3_0_3.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn2700-d48c8-t0-version_2_0_0.json b/tests/db_migrator_input/appl_db/mellanox-sn2700-d48c8-t0-version_3_0_0.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn2700-d48c8-t0-version_2_0_0.json rename to tests/db_migrator_input/appl_db/mellanox-sn2700-d48c8-t0-version_3_0_0.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn2700-d48c8-t0-version_2_0_3.json b/tests/db_migrator_input/appl_db/mellanox-sn2700-d48c8-t0-version_3_0_3.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn2700-d48c8-t0-version_2_0_3.json rename to tests/db_migrator_input/appl_db/mellanox-sn2700-d48c8-t0-version_3_0_3.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn2700-d48c8-t1-version_2_0_0.json b/tests/db_migrator_input/appl_db/mellanox-sn2700-d48c8-t1-version_3_0_0.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn2700-d48c8-t1-version_2_0_0.json rename to tests/db_migrator_input/appl_db/mellanox-sn2700-d48c8-t1-version_3_0_0.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn2700-d48c8-t1-version_2_0_3.json b/tests/db_migrator_input/appl_db/mellanox-sn2700-d48c8-t1-version_3_0_3.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn2700-d48c8-t1-version_2_0_3.json rename to tests/db_migrator_input/appl_db/mellanox-sn2700-d48c8-t1-version_3_0_3.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn2700-single-pool-t0-version_2_0_0.json b/tests/db_migrator_input/appl_db/mellanox-sn2700-single-pool-t0-version_3_0_0.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn2700-single-pool-t0-version_2_0_0.json rename to tests/db_migrator_input/appl_db/mellanox-sn2700-single-pool-t0-version_3_0_0.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn2700-single-pool-t0-version_2_0_3.json b/tests/db_migrator_input/appl_db/mellanox-sn2700-single-pool-t0-version_3_0_3.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn2700-single-pool-t0-version_2_0_3.json rename to tests/db_migrator_input/appl_db/mellanox-sn2700-single-pool-t0-version_3_0_3.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn2700-single-pool-t1-version_2_0_0.json b/tests/db_migrator_input/appl_db/mellanox-sn2700-single-pool-t1-version_3_0_0.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn2700-single-pool-t1-version_2_0_0.json rename to tests/db_migrator_input/appl_db/mellanox-sn2700-single-pool-t1-version_3_0_0.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn2700-single-pool-t1-version_2_0_3.json b/tests/db_migrator_input/appl_db/mellanox-sn2700-single-pool-t1-version_3_0_3.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn2700-single-pool-t1-version_2_0_3.json rename to tests/db_migrator_input/appl_db/mellanox-sn2700-single-pool-t1-version_3_0_3.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn2700-t0-version_2_0_0.json b/tests/db_migrator_input/appl_db/mellanox-sn2700-t0-version_3_0_0.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn2700-t0-version_2_0_0.json rename to tests/db_migrator_input/appl_db/mellanox-sn2700-t0-version_3_0_0.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn2700-t0-version_2_0_3.json b/tests/db_migrator_input/appl_db/mellanox-sn2700-t0-version_3_0_3.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn2700-t0-version_2_0_3.json rename to tests/db_migrator_input/appl_db/mellanox-sn2700-t0-version_3_0_3.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn2700-t1-version_2_0_0.json b/tests/db_migrator_input/appl_db/mellanox-sn2700-t1-version_3_0_0.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn2700-t1-version_2_0_0.json rename to tests/db_migrator_input/appl_db/mellanox-sn2700-t1-version_3_0_0.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn2700-t1-version_2_0_3.json b/tests/db_migrator_input/appl_db/mellanox-sn2700-t1-version_3_0_3.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn2700-t1-version_2_0_3.json rename to tests/db_migrator_input/appl_db/mellanox-sn2700-t1-version_3_0_3.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn3800-c64-t0-version_2_0_0.json b/tests/db_migrator_input/appl_db/mellanox-sn3800-c64-t0-version_3_0_0.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn3800-c64-t0-version_2_0_0.json rename to tests/db_migrator_input/appl_db/mellanox-sn3800-c64-t0-version_3_0_0.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn3800-c64-t0-version_2_0_3.json b/tests/db_migrator_input/appl_db/mellanox-sn3800-c64-t0-version_3_0_3.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn3800-c64-t0-version_2_0_3.json rename to tests/db_migrator_input/appl_db/mellanox-sn3800-c64-t0-version_3_0_3.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn3800-c64-t1-version_2_0_0.json b/tests/db_migrator_input/appl_db/mellanox-sn3800-c64-t1-version_3_0_0.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn3800-c64-t1-version_2_0_0.json rename to tests/db_migrator_input/appl_db/mellanox-sn3800-c64-t1-version_3_0_0.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn3800-c64-t1-version_2_0_3.json b/tests/db_migrator_input/appl_db/mellanox-sn3800-c64-t1-version_3_0_3.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn3800-c64-t1-version_2_0_3.json rename to tests/db_migrator_input/appl_db/mellanox-sn3800-c64-t1-version_3_0_3.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn3800-d112c8-t0-version_2_0_0.json b/tests/db_migrator_input/appl_db/mellanox-sn3800-d112c8-t0-version_3_0_0.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn3800-d112c8-t0-version_2_0_0.json rename to tests/db_migrator_input/appl_db/mellanox-sn3800-d112c8-t0-version_3_0_0.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn3800-d112c8-t0-version_2_0_3.json b/tests/db_migrator_input/appl_db/mellanox-sn3800-d112c8-t0-version_3_0_3.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn3800-d112c8-t0-version_2_0_3.json rename to tests/db_migrator_input/appl_db/mellanox-sn3800-d112c8-t0-version_3_0_3.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn3800-d112c8-t1-version_2_0_0.json b/tests/db_migrator_input/appl_db/mellanox-sn3800-d112c8-t1-version_3_0_0.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn3800-d112c8-t1-version_2_0_0.json rename to tests/db_migrator_input/appl_db/mellanox-sn3800-d112c8-t1-version_3_0_0.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn3800-d112c8-t1-version_2_0_3.json b/tests/db_migrator_input/appl_db/mellanox-sn3800-d112c8-t1-version_3_0_3.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn3800-d112c8-t1-version_2_0_3.json rename to tests/db_migrator_input/appl_db/mellanox-sn3800-d112c8-t1-version_3_0_3.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn3800-d24c52-t0-version_2_0_0.json b/tests/db_migrator_input/appl_db/mellanox-sn3800-d24c52-t0-version_3_0_0.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn3800-d24c52-t0-version_2_0_0.json rename to tests/db_migrator_input/appl_db/mellanox-sn3800-d24c52-t0-version_3_0_0.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn3800-d24c52-t0-version_2_0_3.json b/tests/db_migrator_input/appl_db/mellanox-sn3800-d24c52-t0-version_3_0_3.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn3800-d24c52-t0-version_2_0_3.json rename to tests/db_migrator_input/appl_db/mellanox-sn3800-d24c52-t0-version_3_0_3.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn3800-d24c52-t1-version_2_0_0.json b/tests/db_migrator_input/appl_db/mellanox-sn3800-d24c52-t1-version_3_0_0.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn3800-d24c52-t1-version_2_0_0.json rename to tests/db_migrator_input/appl_db/mellanox-sn3800-d24c52-t1-version_3_0_0.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn3800-d24c52-t1-version_2_0_3.json b/tests/db_migrator_input/appl_db/mellanox-sn3800-d24c52-t1-version_3_0_3.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn3800-d24c52-t1-version_2_0_3.json rename to tests/db_migrator_input/appl_db/mellanox-sn3800-d24c52-t1-version_3_0_3.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn3800-d28c50-t0-version_2_0_0.json b/tests/db_migrator_input/appl_db/mellanox-sn3800-d28c50-t0-version_3_0_0.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn3800-d28c50-t0-version_2_0_0.json rename to tests/db_migrator_input/appl_db/mellanox-sn3800-d28c50-t0-version_3_0_0.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn3800-d28c50-t0-version_2_0_3.json b/tests/db_migrator_input/appl_db/mellanox-sn3800-d28c50-t0-version_3_0_3.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn3800-d28c50-t0-version_2_0_3.json rename to tests/db_migrator_input/appl_db/mellanox-sn3800-d28c50-t0-version_3_0_3.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn3800-d28c50-t1-version_2_0_0.json b/tests/db_migrator_input/appl_db/mellanox-sn3800-d28c50-t1-version_3_0_0.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn3800-d28c50-t1-version_2_0_0.json rename to tests/db_migrator_input/appl_db/mellanox-sn3800-d28c50-t1-version_3_0_0.json diff --git a/tests/db_migrator_input/appl_db/mellanox-sn3800-d28c50-t1-version_2_0_3.json b/tests/db_migrator_input/appl_db/mellanox-sn3800-d28c50-t1-version_3_0_3.json similarity index 100% rename from tests/db_migrator_input/appl_db/mellanox-sn3800-d28c50-t1-version_2_0_3.json rename to tests/db_migrator_input/appl_db/mellanox-sn3800-d28c50-t1-version_3_0_3.json diff --git a/tests/db_migrator_input/appl_db/qos_tables_db_field_value_reference_format_2_0_1.json b/tests/db_migrator_input/appl_db/qos_tables_db_field_value_reference_format_3_0_1.json similarity index 100% rename from tests/db_migrator_input/appl_db/qos_tables_db_field_value_reference_format_2_0_1.json rename to tests/db_migrator_input/appl_db/qos_tables_db_field_value_reference_format_3_0_1.json diff --git a/tests/db_migrator_input/appl_db/qos_tables_db_field_value_reference_format_2_0_3.json b/tests/db_migrator_input/appl_db/qos_tables_db_field_value_reference_format_3_0_3.json similarity index 100% rename from tests/db_migrator_input/appl_db/qos_tables_db_field_value_reference_format_2_0_3.json rename to tests/db_migrator_input/appl_db/qos_tables_db_field_value_reference_format_3_0_3.json diff --git a/tests/db_migrator_input/config_db/acs-msn2700-t0-version_1_0_1.json b/tests/db_migrator_input/config_db/acs-msn2700-t0-version_1_0_1.json index 731bcea1fe..c9e5c04a5f 100644 --- a/tests/db_migrator_input/config_db/acs-msn2700-t0-version_1_0_1.json +++ b/tests/db_migrator_input/config_db/acs-msn2700-t0-version_1_0_1.json @@ -731,6 +731,7 @@ "hwsku": "ACS-MSN2700", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/acs-msn2700-t0-version_1_0_2.json b/tests/db_migrator_input/config_db/acs-msn2700-t0-version_1_0_2.json index 9c01e38daf..07966ad742 100644 --- a/tests/db_migrator_input/config_db/acs-msn2700-t0-version_1_0_2.json +++ b/tests/db_migrator_input/config_db/acs-msn2700-t0-version_1_0_2.json @@ -737,7 +737,8 @@ "default_pfcwd_status": "disable", "bgp_asn": "65100", "deployment_id": "1", - "type": "ToRRouter" + "type": "ToRRouter", + "synchronous_mode": "enable" }, "PORT|Ethernet0": { "lanes": "0,1,2,3", diff --git a/tests/db_migrator_input/config_db/acs-msn2700-t0-version_1_0_3.json b/tests/db_migrator_input/config_db/acs-msn2700-t0-version_1_0_3.json index 2ef38d24ec..66f6c58284 100644 --- a/tests/db_migrator_input/config_db/acs-msn2700-t0-version_1_0_3.json +++ b/tests/db_migrator_input/config_db/acs-msn2700-t0-version_1_0_3.json @@ -737,7 +737,8 @@ "default_pfcwd_status": "disable", "bgp_asn": "65100", "deployment_id": "1", - "type": "ToRRouter" + "type": "ToRRouter", + "synchronous_mode": "enable" }, "PORT|Ethernet0": { "lanes": "0,1,2,3", diff --git a/tests/db_migrator_input/config_db/acs-msn2700-t0-version_1_0_4.json b/tests/db_migrator_input/config_db/acs-msn2700-t0-version_1_0_4.json index d92a6336b0..6848917e04 100644 --- a/tests/db_migrator_input/config_db/acs-msn2700-t0-version_1_0_4.json +++ b/tests/db_migrator_input/config_db/acs-msn2700-t0-version_1_0_4.json @@ -737,7 +737,8 @@ "default_pfcwd_status": "disable", "bgp_asn": "65100", "deployment_id": "1", - "type": "ToRRouter" + "type": "ToRRouter", + "synchronous_mode": "enable" }, "PORT|Ethernet0": { "lanes": "0,1,2,3", diff --git a/tests/db_migrator_input/config_db/acs-msn2700-t0-version_1_0_5.json b/tests/db_migrator_input/config_db/acs-msn2700-t0-version_1_0_5.json index 84eccb4978..96fd7dd809 100644 --- a/tests/db_migrator_input/config_db/acs-msn2700-t0-version_1_0_5.json +++ b/tests/db_migrator_input/config_db/acs-msn2700-t0-version_1_0_5.json @@ -737,7 +737,8 @@ "default_pfcwd_status": "disable", "bgp_asn": "65100", "deployment_id": "1", - "type": "ToRRouter" + "type": "ToRRouter", + "synchronous_mode": "enable" }, "PORT|Ethernet0": { "lanes": "0,1,2,3", diff --git a/tests/db_migrator_input/config_db/acs-msn2700-t0-version_1_0_6.json b/tests/db_migrator_input/config_db/acs-msn2700-t0-version_1_0_6.json index 98130c4baa..f549368983 100644 --- a/tests/db_migrator_input/config_db/acs-msn2700-t0-version_1_0_6.json +++ b/tests/db_migrator_input/config_db/acs-msn2700-t0-version_1_0_6.json @@ -737,7 +737,8 @@ "default_pfcwd_status": "disable", "bgp_asn": "65100", "deployment_id": "1", - "type": "ToRRouter" + "type": "ToRRouter", + "synchronous_mode": "enable" }, "PORT|Ethernet0": { "lanes": "0,1,2,3", diff --git a/tests/db_migrator_input/config_db/acs-msn2700-t0-version_2_0_0.json b/tests/db_migrator_input/config_db/acs-msn2700-t0-version_3_0_0.json similarity index 99% rename from tests/db_migrator_input/config_db/acs-msn2700-t0-version_2_0_0.json rename to tests/db_migrator_input/config_db/acs-msn2700-t0-version_3_0_0.json index 76ed34269e..4cab434e29 100644 --- a/tests/db_migrator_input/config_db/acs-msn2700-t0-version_2_0_0.json +++ b/tests/db_migrator_input/config_db/acs-msn2700-t0-version_3_0_0.json @@ -689,7 +689,8 @@ "bgp_asn": "65100", "buffer_model": "dynamic", "deployment_id": "1", - "type": "ToRRouter" + "type": "ToRRouter", + "synchronous_mode": "enable" }, "LOSSLESS_TRAFFIC_PATTERN|AZURE": { "small_packet_percentage": "100", @@ -1014,6 +1015,6 @@ "speed": "50000" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_0" + "VERSION": "version_3_0_0" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/acs-msn2700-t0-version_2_0_3.json b/tests/db_migrator_input/config_db/acs-msn2700-t0-version_3_0_3.json similarity index 99% rename from tests/db_migrator_input/config_db/acs-msn2700-t0-version_2_0_3.json rename to tests/db_migrator_input/config_db/acs-msn2700-t0-version_3_0_3.json index 3f70cfa87e..89f46af5c6 100644 --- a/tests/db_migrator_input/config_db/acs-msn2700-t0-version_2_0_3.json +++ b/tests/db_migrator_input/config_db/acs-msn2700-t0-version_3_0_3.json @@ -689,7 +689,8 @@ "bgp_asn": "65100", "buffer_model": "dynamic", "deployment_id": "1", - "type": "ToRRouter" + "type": "ToRRouter", + "synchronous_mode": "enable" }, "LOSSLESS_TRAFFIC_PATTERN|AZURE": { "small_packet_percentage": "100", @@ -1014,6 +1015,6 @@ "speed": "50000" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } -} \ No newline at end of file +} diff --git a/tests/db_migrator_input/config_db/acs-msn2700-t1-version_1_0_1.json b/tests/db_migrator_input/config_db/acs-msn2700-t1-version_1_0_1.json index 62a74e7d50..c97f51d5a2 100644 --- a/tests/db_migrator_input/config_db/acs-msn2700-t1-version_1_0_1.json +++ b/tests/db_migrator_input/config_db/acs-msn2700-t1-version_1_0_1.json @@ -824,6 +824,7 @@ "hwsku": "ACS-MSN2700", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/acs-msn2700-t1-version_1_0_2.json b/tests/db_migrator_input/config_db/acs-msn2700-t1-version_1_0_2.json index 48c6e36a85..25d2701574 100644 --- a/tests/db_migrator_input/config_db/acs-msn2700-t1-version_1_0_2.json +++ b/tests/db_migrator_input/config_db/acs-msn2700-t1-version_1_0_2.json @@ -824,6 +824,7 @@ "hwsku": "ACS-MSN2700", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/acs-msn2700-t1-version_1_0_3.json b/tests/db_migrator_input/config_db/acs-msn2700-t1-version_1_0_3.json index 2f37a3e238..9a438f3b19 100644 --- a/tests/db_migrator_input/config_db/acs-msn2700-t1-version_1_0_3.json +++ b/tests/db_migrator_input/config_db/acs-msn2700-t1-version_1_0_3.json @@ -824,6 +824,7 @@ "hwsku": "ACS-MSN2700", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/acs-msn2700-t1-version_1_0_4.json b/tests/db_migrator_input/config_db/acs-msn2700-t1-version_1_0_4.json index 837abc8b5a..13758db256 100644 --- a/tests/db_migrator_input/config_db/acs-msn2700-t1-version_1_0_4.json +++ b/tests/db_migrator_input/config_db/acs-msn2700-t1-version_1_0_4.json @@ -824,6 +824,7 @@ "hwsku": "ACS-MSN2700", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/acs-msn2700-t1-version_1_0_5.json b/tests/db_migrator_input/config_db/acs-msn2700-t1-version_1_0_5.json index f24650a270..6557d7f90f 100644 --- a/tests/db_migrator_input/config_db/acs-msn2700-t1-version_1_0_5.json +++ b/tests/db_migrator_input/config_db/acs-msn2700-t1-version_1_0_5.json @@ -824,6 +824,7 @@ "hwsku": "ACS-MSN2700", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/acs-msn2700-t1-version_1_0_6.json b/tests/db_migrator_input/config_db/acs-msn2700-t1-version_1_0_6.json index b3b4b31275..205620de9f 100644 --- a/tests/db_migrator_input/config_db/acs-msn2700-t1-version_1_0_6.json +++ b/tests/db_migrator_input/config_db/acs-msn2700-t1-version_1_0_6.json @@ -824,6 +824,7 @@ "hwsku": "ACS-MSN2700", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/acs-msn2700-t1-version_2_0_0.json b/tests/db_migrator_input/config_db/acs-msn2700-t1-version_3_0_0.json similarity index 99% rename from tests/db_migrator_input/config_db/acs-msn2700-t1-version_2_0_0.json rename to tests/db_migrator_input/config_db/acs-msn2700-t1-version_3_0_0.json index be1f36d71c..d7698caccd 100644 --- a/tests/db_migrator_input/config_db/acs-msn2700-t1-version_2_0_0.json +++ b/tests/db_migrator_input/config_db/acs-msn2700-t1-version_3_0_0.json @@ -754,6 +754,7 @@ "hwsku": "ACS-MSN2700", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", @@ -1086,6 +1087,6 @@ "speed": "50000" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_0" + "VERSION": "version_3_0_0" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/acs-msn2700-t1-version_2_0_3.json b/tests/db_migrator_input/config_db/acs-msn2700-t1-version_3_0_3.json similarity index 99% rename from tests/db_migrator_input/config_db/acs-msn2700-t1-version_2_0_3.json rename to tests/db_migrator_input/config_db/acs-msn2700-t1-version_3_0_3.json index 44246edd6b..b9ad1706a8 100644 --- a/tests/db_migrator_input/config_db/acs-msn2700-t1-version_2_0_3.json +++ b/tests/db_migrator_input/config_db/acs-msn2700-t1-version_3_0_3.json @@ -761,7 +761,8 @@ "bgp_asn": "65100", "buffer_model": "dynamic", "deployment_id": "1", - "docker_routing_config_mode": "unified" + "docker_routing_config_mode": "unified", + "synchronous_mode": "enable" }, "LOSSLESS_TRAFFIC_PATTERN|AZURE": { "small_packet_percentage": "100", @@ -1086,6 +1087,6 @@ "speed": "50000" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } -} \ No newline at end of file +} diff --git a/tests/db_migrator_input/config_db/acs-msn3700-t0-version_1_0_2.json b/tests/db_migrator_input/config_db/acs-msn3700-t0-version_1_0_2.json index dad6528bd1..e3bb4f100d 100644 --- a/tests/db_migrator_input/config_db/acs-msn3700-t0-version_1_0_2.json +++ b/tests/db_migrator_input/config_db/acs-msn3700-t0-version_1_0_2.json @@ -738,6 +738,7 @@ "hwsku": "ACS-MSN3700", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "region": "None", "hostname": "sonic", "platform": "x86_64-mlnx_msn3700-r0", diff --git a/tests/db_migrator_input/config_db/acs-msn3700-t0-version_1_0_3.json b/tests/db_migrator_input/config_db/acs-msn3700-t0-version_1_0_3.json index ed90ec38f2..ee33adc896 100644 --- a/tests/db_migrator_input/config_db/acs-msn3700-t0-version_1_0_3.json +++ b/tests/db_migrator_input/config_db/acs-msn3700-t0-version_1_0_3.json @@ -864,6 +864,7 @@ "hwsku": "ACS-MSN3700", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "region": "None", "hostname": "sonic", "platform": "x86_64-mlnx_msn3700-r0", diff --git a/tests/db_migrator_input/config_db/acs-msn3700-t0-version_1_0_4.json b/tests/db_migrator_input/config_db/acs-msn3700-t0-version_1_0_4.json index 508dc5dc7f..45af1c2997 100644 --- a/tests/db_migrator_input/config_db/acs-msn3700-t0-version_1_0_4.json +++ b/tests/db_migrator_input/config_db/acs-msn3700-t0-version_1_0_4.json @@ -864,6 +864,7 @@ "hwsku": "ACS-MSN3700", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "region": "None", "hostname": "sonic", "platform": "x86_64-mlnx_msn3700-r0", diff --git a/tests/db_migrator_input/config_db/acs-msn3700-t0-version_1_0_5.json b/tests/db_migrator_input/config_db/acs-msn3700-t0-version_1_0_5.json index 4ed4668d8b..04448a2667 100644 --- a/tests/db_migrator_input/config_db/acs-msn3700-t0-version_1_0_5.json +++ b/tests/db_migrator_input/config_db/acs-msn3700-t0-version_1_0_5.json @@ -864,6 +864,7 @@ "hwsku": "ACS-MSN3700", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "region": "None", "hostname": "sonic", "platform": "x86_64-mlnx_msn3700-r0", diff --git a/tests/db_migrator_input/config_db/acs-msn3700-t0-version_1_0_6.json b/tests/db_migrator_input/config_db/acs-msn3700-t0-version_1_0_6.json index 48ba24ab3b..825d3c495d 100644 --- a/tests/db_migrator_input/config_db/acs-msn3700-t0-version_1_0_6.json +++ b/tests/db_migrator_input/config_db/acs-msn3700-t0-version_1_0_6.json @@ -864,6 +864,7 @@ "hwsku": "ACS-MSN3700", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "region": "None", "hostname": "sonic", "platform": "x86_64-mlnx_msn3700-r0", diff --git a/tests/db_migrator_input/config_db/acs-msn3700-t0-version_2_0_0.json b/tests/db_migrator_input/config_db/acs-msn3700-t0-version_3_0_0.json similarity index 99% rename from tests/db_migrator_input/config_db/acs-msn3700-t0-version_2_0_0.json rename to tests/db_migrator_input/config_db/acs-msn3700-t0-version_3_0_0.json index c79217b1c5..18876fb486 100644 --- a/tests/db_migrator_input/config_db/acs-msn3700-t0-version_2_0_0.json +++ b/tests/db_migrator_input/config_db/acs-msn3700-t0-version_3_0_0.json @@ -808,6 +808,7 @@ "hwsku": "ACS-MSN3700", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "region": "None", "hostname": "sonic", "platform": "x86_64-mlnx_msn3700-r0", @@ -1900,6 +1901,6 @@ "admin_status": "up" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_0" + "VERSION": "version_3_0_0" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/acs-msn3700-t0-version_2_0_3.json b/tests/db_migrator_input/config_db/acs-msn3700-t0-version_3_0_3.json similarity index 99% rename from tests/db_migrator_input/config_db/acs-msn3700-t0-version_2_0_3.json rename to tests/db_migrator_input/config_db/acs-msn3700-t0-version_3_0_3.json index 598b9b16c7..eb6138bdc6 100644 --- a/tests/db_migrator_input/config_db/acs-msn3700-t0-version_2_0_3.json +++ b/tests/db_migrator_input/config_db/acs-msn3700-t0-version_3_0_3.json @@ -817,7 +817,8 @@ "buffer_model": "dynamic", "deployment_id": "1", "docker_routing_config_mode": "separated", - "cloudtype": "None" + "cloudtype": "None", + "synchronous_mode": "enable" }, "LOSSLESS_TRAFFIC_PATTERN|AZURE": { "small_packet_percentage": "100", @@ -1900,6 +1901,6 @@ "admin_status": "up" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } -} \ No newline at end of file +} diff --git a/tests/db_migrator_input/config_db/acs-msn3700-t1-version_1_0_2.json b/tests/db_migrator_input/config_db/acs-msn3700-t1-version_1_0_2.json index d2a1290368..80d96b8bc5 100644 --- a/tests/db_migrator_input/config_db/acs-msn3700-t1-version_1_0_2.json +++ b/tests/db_migrator_input/config_db/acs-msn3700-t1-version_1_0_2.json @@ -838,6 +838,7 @@ "hwsku": "ACS-MSN3700", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "region": "None", "hostname": "sonic", "platform": "x86_64-mlnx_msn3700-r0", diff --git a/tests/db_migrator_input/config_db/acs-msn3700-t1-version_1_0_3.json b/tests/db_migrator_input/config_db/acs-msn3700-t1-version_1_0_3.json index 57b106555b..0743a08bf9 100644 --- a/tests/db_migrator_input/config_db/acs-msn3700-t1-version_1_0_3.json +++ b/tests/db_migrator_input/config_db/acs-msn3700-t1-version_1_0_3.json @@ -940,6 +940,7 @@ "hwsku": "ACS-MSN3700", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "region": "None", "hostname": "sonic", "platform": "x86_64-mlnx_msn3700-r0", diff --git a/tests/db_migrator_input/config_db/acs-msn3700-t1-version_1_0_4.json b/tests/db_migrator_input/config_db/acs-msn3700-t1-version_1_0_4.json index e97efaa06d..764e2639fd 100644 --- a/tests/db_migrator_input/config_db/acs-msn3700-t1-version_1_0_4.json +++ b/tests/db_migrator_input/config_db/acs-msn3700-t1-version_1_0_4.json @@ -940,6 +940,7 @@ "hwsku": "ACS-MSN3700", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "region": "None", "hostname": "sonic", "platform": "x86_64-mlnx_msn3700-r0", diff --git a/tests/db_migrator_input/config_db/acs-msn3700-t1-version_1_0_5.json b/tests/db_migrator_input/config_db/acs-msn3700-t1-version_1_0_5.json index 0e4d8035b6..431218c6c1 100644 --- a/tests/db_migrator_input/config_db/acs-msn3700-t1-version_1_0_5.json +++ b/tests/db_migrator_input/config_db/acs-msn3700-t1-version_1_0_5.json @@ -940,6 +940,7 @@ "hwsku": "ACS-MSN3700", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "region": "None", "hostname": "sonic", "platform": "x86_64-mlnx_msn3700-r0", diff --git a/tests/db_migrator_input/config_db/acs-msn3700-t1-version_1_0_6.json b/tests/db_migrator_input/config_db/acs-msn3700-t1-version_1_0_6.json index bb26b43b58..a815bf97d6 100644 --- a/tests/db_migrator_input/config_db/acs-msn3700-t1-version_1_0_6.json +++ b/tests/db_migrator_input/config_db/acs-msn3700-t1-version_1_0_6.json @@ -940,6 +940,7 @@ "hwsku": "ACS-MSN3700", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "region": "None", "hostname": "sonic", "platform": "x86_64-mlnx_msn3700-r0", diff --git a/tests/db_migrator_input/config_db/acs-msn3700-t1-version_2_0_0.json b/tests/db_migrator_input/config_db/acs-msn3700-t1-version_3_0_0.json similarity index 99% rename from tests/db_migrator_input/config_db/acs-msn3700-t1-version_2_0_0.json rename to tests/db_migrator_input/config_db/acs-msn3700-t1-version_3_0_0.json index a756fde63d..c3fb115b8e 100644 --- a/tests/db_migrator_input/config_db/acs-msn3700-t1-version_2_0_0.json +++ b/tests/db_migrator_input/config_db/acs-msn3700-t1-version_3_0_0.json @@ -856,6 +856,7 @@ "hwsku": "ACS-MSN3700", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "region": "None", "hostname": "sonic", "platform": "x86_64-mlnx_msn3700-r0", @@ -1948,6 +1949,6 @@ "admin_status": "up" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_0" + "VERSION": "version_3_0_0" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/acs-msn3700-t1-version_2_0_3.json b/tests/db_migrator_input/config_db/acs-msn3700-t1-version_3_0_3.json similarity index 99% rename from tests/db_migrator_input/config_db/acs-msn3700-t1-version_2_0_3.json rename to tests/db_migrator_input/config_db/acs-msn3700-t1-version_3_0_3.json index 684b52910e..fc34c0870e 100644 --- a/tests/db_migrator_input/config_db/acs-msn3700-t1-version_2_0_3.json +++ b/tests/db_migrator_input/config_db/acs-msn3700-t1-version_3_0_3.json @@ -865,7 +865,8 @@ "buffer_model": "dynamic", "deployment_id": "1", "docker_routing_config_mode": "separated", - "cloudtype": "None" + "cloudtype": "None", + "synchronous_mode": "enable" }, "LOSSLESS_TRAFFIC_PATTERN|AZURE": { "small_packet_percentage": "100", @@ -1948,6 +1949,6 @@ "admin_status": "up" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } -} \ No newline at end of file +} diff --git a/tests/db_migrator_input/config_db/acs-msn3800-t0-version_1_0_5.json b/tests/db_migrator_input/config_db/acs-msn3800-t0-version_1_0_5.json index b6fddf6215..df40c5049a 100644 --- a/tests/db_migrator_input/config_db/acs-msn3800-t0-version_1_0_5.json +++ b/tests/db_migrator_input/config_db/acs-msn3800-t0-version_1_0_5.json @@ -988,6 +988,7 @@ "bgp_asn": "65100", "cloudtype": "None", "type": "ToRRouter", + "synchronous_mode": "enable", "deployment_id": "1" }, "PORT|Ethernet0": { diff --git a/tests/db_migrator_input/config_db/acs-msn3800-t0-version_1_0_6.json b/tests/db_migrator_input/config_db/acs-msn3800-t0-version_1_0_6.json index c655ab4dee..aadef8ed0b 100644 --- a/tests/db_migrator_input/config_db/acs-msn3800-t0-version_1_0_6.json +++ b/tests/db_migrator_input/config_db/acs-msn3800-t0-version_1_0_6.json @@ -988,6 +988,7 @@ "bgp_asn": "65100", "cloudtype": "None", "type": "ToRRouter", + "synchronous_mode": "enable", "deployment_id": "1" }, "PORT|Ethernet0": { diff --git a/tests/db_migrator_input/config_db/acs-msn3800-t0-version_2_0_0.json b/tests/db_migrator_input/config_db/acs-msn3800-t0-version_3_0_0.json similarity index 99% rename from tests/db_migrator_input/config_db/acs-msn3800-t0-version_2_0_0.json rename to tests/db_migrator_input/config_db/acs-msn3800-t0-version_3_0_0.json index d367b5dca2..13723251c2 100644 --- a/tests/db_migrator_input/config_db/acs-msn3800-t0-version_2_0_0.json +++ b/tests/db_migrator_input/config_db/acs-msn3800-t0-version_3_0_0.json @@ -971,6 +971,7 @@ "buffer_model": "dynamic", "cloudtype": "None", "type": "ToRRouter", + "synchronous_mode": "enable", "deployment_id": "1" }, "LOSSLESS_TRAFFIC_PATTERN|AZURE": { @@ -2034,6 +2035,6 @@ "admin_status": "up" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_0" + "VERSION": "version_3_0_0" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/acs-msn3800-t0-version_2_0_3.json b/tests/db_migrator_input/config_db/acs-msn3800-t0-version_3_0_3.json similarity index 99% rename from tests/db_migrator_input/config_db/acs-msn3800-t0-version_2_0_3.json rename to tests/db_migrator_input/config_db/acs-msn3800-t0-version_3_0_3.json index add7cf0371..a1f6a8e1f1 100644 --- a/tests/db_migrator_input/config_db/acs-msn3800-t0-version_2_0_3.json +++ b/tests/db_migrator_input/config_db/acs-msn3800-t0-version_3_0_3.json @@ -971,7 +971,8 @@ "buffer_model": "dynamic", "cloudtype": "None", "type": "ToRRouter", - "deployment_id": "1" + "deployment_id": "1", + "synchronous_mode": "enable" }, "LOSSLESS_TRAFFIC_PATTERN|AZURE": { "small_packet_percentage": "100", @@ -2034,6 +2035,6 @@ "admin_status": "up" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } -} \ No newline at end of file +} diff --git a/tests/db_migrator_input/config_db/acs-msn3800-t1-version_1_0_5.json b/tests/db_migrator_input/config_db/acs-msn3800-t1-version_1_0_5.json index 9ea07af0f9..2916e541ca 100644 --- a/tests/db_migrator_input/config_db/acs-msn3800-t1-version_1_0_5.json +++ b/tests/db_migrator_input/config_db/acs-msn3800-t1-version_1_0_5.json @@ -1102,6 +1102,7 @@ "bgp_asn": "65100", "cloudtype": "None", "type": "LeafRouter", + "synchronous_mode": "enable", "deployment_id": "1" }, "PORT|Ethernet0": { diff --git a/tests/db_migrator_input/config_db/acs-msn3800-t1-version_1_0_6.json b/tests/db_migrator_input/config_db/acs-msn3800-t1-version_1_0_6.json index 049834652e..e80ca33864 100644 --- a/tests/db_migrator_input/config_db/acs-msn3800-t1-version_1_0_6.json +++ b/tests/db_migrator_input/config_db/acs-msn3800-t1-version_1_0_6.json @@ -1102,6 +1102,7 @@ "bgp_asn": "65100", "cloudtype": "None", "type": "LeafRouter", + "synchronous_mode": "enable", "deployment_id": "1" }, "PORT|Ethernet0": { diff --git a/tests/db_migrator_input/config_db/acs-msn3800-t1-version_2_0_0.json b/tests/db_migrator_input/config_db/acs-msn3800-t1-version_3_0_0.json similarity index 99% rename from tests/db_migrator_input/config_db/acs-msn3800-t1-version_2_0_0.json rename to tests/db_migrator_input/config_db/acs-msn3800-t1-version_3_0_0.json index 9a14f0659c..b399934c77 100644 --- a/tests/db_migrator_input/config_db/acs-msn3800-t1-version_2_0_0.json +++ b/tests/db_migrator_input/config_db/acs-msn3800-t1-version_3_0_0.json @@ -1019,6 +1019,7 @@ "buffer_model": "dynamic", "cloudtype": "None", "type": "LeafRouter", + "synchronous_mode": "enable", "deployment_id": "1" }, "LOSSLESS_TRAFFIC_PATTERN|AZURE": { @@ -2082,6 +2083,6 @@ "admin_status": "up" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_0" + "VERSION": "version_3_0_0" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/acs-msn3800-t1-version_2_0_3.json b/tests/db_migrator_input/config_db/acs-msn3800-t1-version_3_0_3.json similarity index 99% rename from tests/db_migrator_input/config_db/acs-msn3800-t1-version_2_0_3.json rename to tests/db_migrator_input/config_db/acs-msn3800-t1-version_3_0_3.json index b930cc4632..d97c95c537 100644 --- a/tests/db_migrator_input/config_db/acs-msn3800-t1-version_2_0_3.json +++ b/tests/db_migrator_input/config_db/acs-msn3800-t1-version_3_0_3.json @@ -1019,7 +1019,8 @@ "buffer_model": "dynamic", "cloudtype": "None", "type": "LeafRouter", - "deployment_id": "1" + "deployment_id": "1", + "synchronous_mode": "enable" }, "LOSSLESS_TRAFFIC_PATTERN|AZURE": { "small_packet_percentage": "100", @@ -2082,6 +2083,6 @@ "admin_status": "up" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } -} \ No newline at end of file +} diff --git a/tests/db_migrator_input/config_db/acs-msn4700-t0-version_1_0_4.json b/tests/db_migrator_input/config_db/acs-msn4700-t0-version_1_0_4.json index 34b697493e..1e71535a50 100644 --- a/tests/db_migrator_input/config_db/acs-msn4700-t0-version_1_0_4.json +++ b/tests/db_migrator_input/config_db/acs-msn4700-t0-version_1_0_4.json @@ -745,6 +745,7 @@ "hwsku": "ACS-MSN4700", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "region": "None", "hostname": "sonic", "platform": "x86_64-mlnx_msn4700-r0", diff --git a/tests/db_migrator_input/config_db/acs-msn4700-t0-version_1_0_5.json b/tests/db_migrator_input/config_db/acs-msn4700-t0-version_1_0_5.json index 313ca97934..c90b68bee5 100644 --- a/tests/db_migrator_input/config_db/acs-msn4700-t0-version_1_0_5.json +++ b/tests/db_migrator_input/config_db/acs-msn4700-t0-version_1_0_5.json @@ -949,6 +949,7 @@ "hwsku": "ACS-MSN4700", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "region": "None", "hostname": "sonic", "platform": "x86_64-mlnx_msn4700-r0", diff --git a/tests/db_migrator_input/config_db/acs-msn4700-t0-version_1_0_6.json b/tests/db_migrator_input/config_db/acs-msn4700-t0-version_1_0_6.json index 1eb7bc9ff0..553cd3fdce 100644 --- a/tests/db_migrator_input/config_db/acs-msn4700-t0-version_1_0_6.json +++ b/tests/db_migrator_input/config_db/acs-msn4700-t0-version_1_0_6.json @@ -949,6 +949,7 @@ "hwsku": "ACS-MSN4700", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "region": "None", "hostname": "sonic", "platform": "x86_64-mlnx_msn4700-r0", diff --git a/tests/db_migrator_input/config_db/acs-msn4700-t0-version_2_0_0.json b/tests/db_migrator_input/config_db/acs-msn4700-t0-version_3_0_0.json similarity index 99% rename from tests/db_migrator_input/config_db/acs-msn4700-t0-version_2_0_0.json rename to tests/db_migrator_input/config_db/acs-msn4700-t0-version_3_0_0.json index d0c5b06344..a421b638f1 100644 --- a/tests/db_migrator_input/config_db/acs-msn4700-t0-version_2_0_0.json +++ b/tests/db_migrator_input/config_db/acs-msn4700-t0-version_3_0_0.json @@ -886,6 +886,7 @@ "hwsku": "ACS-MSN4700", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "region": "None", "hostname": "sonic", "platform": "x86_64-mlnx_msn4700-r0", @@ -1978,6 +1979,6 @@ "admin_status": "up" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_0" + "VERSION": "version_3_0_0" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/acs-msn4700-t0-version_2_0_3.json b/tests/db_migrator_input/config_db/acs-msn4700-t0-version_3_0_3.json similarity index 99% rename from tests/db_migrator_input/config_db/acs-msn4700-t0-version_2_0_3.json rename to tests/db_migrator_input/config_db/acs-msn4700-t0-version_3_0_3.json index fdcd78b5bb..b00b45ac2f 100644 --- a/tests/db_migrator_input/config_db/acs-msn4700-t0-version_2_0_3.json +++ b/tests/db_migrator_input/config_db/acs-msn4700-t0-version_3_0_3.json @@ -886,6 +886,7 @@ "hwsku": "ACS-MSN4700", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "region": "None", "hostname": "sonic", "platform": "x86_64-mlnx_msn4700-r0", @@ -1978,6 +1979,6 @@ "admin_status": "up" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/acs-msn4700-t1-version_1_0_4.json b/tests/db_migrator_input/config_db/acs-msn4700-t1-version_1_0_4.json index 763342e143..5adef7f9e4 100644 --- a/tests/db_migrator_input/config_db/acs-msn4700-t1-version_1_0_4.json +++ b/tests/db_migrator_input/config_db/acs-msn4700-t1-version_1_0_4.json @@ -1050,6 +1050,7 @@ "hwsku": "ACS-MSN4700", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "region": "None", "hostname": "sonic", "platform": "x86_64-mlnx_msn4700-r0", diff --git a/tests/db_migrator_input/config_db/acs-msn4700-t1-version_1_0_5.json b/tests/db_migrator_input/config_db/acs-msn4700-t1-version_1_0_5.json index c043e37bf0..a71bc64979 100644 --- a/tests/db_migrator_input/config_db/acs-msn4700-t1-version_1_0_5.json +++ b/tests/db_migrator_input/config_db/acs-msn4700-t1-version_1_0_5.json @@ -1050,6 +1050,7 @@ "hwsku": "ACS-MSN4700", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "region": "None", "hostname": "sonic", "platform": "x86_64-mlnx_msn4700-r0", diff --git a/tests/db_migrator_input/config_db/acs-msn4700-t1-version_1_0_6.json b/tests/db_migrator_input/config_db/acs-msn4700-t1-version_1_0_6.json index 6716ec67b4..6bcb4affc8 100644 --- a/tests/db_migrator_input/config_db/acs-msn4700-t1-version_1_0_6.json +++ b/tests/db_migrator_input/config_db/acs-msn4700-t1-version_1_0_6.json @@ -1050,6 +1050,7 @@ "hwsku": "ACS-MSN4700", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "region": "None", "hostname": "sonic", "platform": "x86_64-mlnx_msn4700-r0", diff --git a/tests/db_migrator_input/config_db/acs-msn4700-t1-version_2_0_0.json b/tests/db_migrator_input/config_db/acs-msn4700-t1-version_3_0_0.json similarity index 99% rename from tests/db_migrator_input/config_db/acs-msn4700-t1-version_2_0_0.json rename to tests/db_migrator_input/config_db/acs-msn4700-t1-version_3_0_0.json index 05dc4f5558..5b6ff7d6a2 100644 --- a/tests/db_migrator_input/config_db/acs-msn4700-t1-version_2_0_0.json +++ b/tests/db_migrator_input/config_db/acs-msn4700-t1-version_3_0_0.json @@ -952,6 +952,7 @@ "hwsku": "ACS-MSN4700", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "region": "None", "hostname": "sonic", "platform": "x86_64-mlnx_msn4700-r0", @@ -2044,6 +2045,6 @@ "admin_status": "up" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_0" + "VERSION": "version_3_0_0" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/acs-msn4700-t1-version_2_0_3.json b/tests/db_migrator_input/config_db/acs-msn4700-t1-version_3_0_3.json similarity index 99% rename from tests/db_migrator_input/config_db/acs-msn4700-t1-version_2_0_3.json rename to tests/db_migrator_input/config_db/acs-msn4700-t1-version_3_0_3.json index 9338443212..3aedb14d17 100644 --- a/tests/db_migrator_input/config_db/acs-msn4700-t1-version_2_0_3.json +++ b/tests/db_migrator_input/config_db/acs-msn4700-t1-version_3_0_3.json @@ -952,6 +952,7 @@ "hwsku": "ACS-MSN4700", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "region": "None", "hostname": "sonic", "platform": "x86_64-mlnx_msn4700-r0", @@ -2044,6 +2045,6 @@ "admin_status": "up" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/cross_branch_upgrade_to_version_2_0_2_expected.json b/tests/db_migrator_input/config_db/cross_branch_upgrade_to_version_2_0_2_expected.json new file mode 100644 index 0000000000..c975229287 --- /dev/null +++ b/tests/db_migrator_input/config_db/cross_branch_upgrade_to_version_2_0_2_expected.json @@ -0,0 +1,26 @@ +{ + "RESTAPI|config": { + "client_auth": "true", + "log_level": "info", + "allow_insecure": "false" + }, + "RESTAPI|certs": { + "server_key": "/etc/sonic/credentials/restapiserver.key", + "ca_crt": "/etc/sonic/credentials/AME_ROOT_CERTIFICATE.pem", + "server_crt": "/etc/sonic/credentials/restapiserver.crt", + "client_crt_cname": "client.restapi.sonic.gbl" + }, + "TELEMETRY|gnmi": { + "client_auth": "true", + "log_level": "2", + "port": "50051" + }, + "TELEMETRY|certs": { + "server_key": "/etc/sonic/telemetry/streamingtelemetryserver.key", + "ca_crt": "/etc/sonic/telemetry/dsmsroot.cer", + "server_crt": "/etc/sonic/telemetry/streamingtelemetryserver.cer" + }, + "CONSOLE_SWITCH|console_mgmt": { + "enabled": "no" + } +} diff --git a/tests/db_migrator_input/config_db/cross_branch_upgrade_to_version_2_0_2_input.json b/tests/db_migrator_input/config_db/cross_branch_upgrade_to_version_2_0_2_input.json new file mode 100644 index 0000000000..bfd870e452 --- /dev/null +++ b/tests/db_migrator_input/config_db/cross_branch_upgrade_to_version_2_0_2_input.json @@ -0,0 +1,3 @@ +{ +} + diff --git a/tests/db_migrator_input/config_db/empty-config-expected.json b/tests/db_migrator_input/config_db/empty-config-expected.json index 8111516340..eebe7eafbd 100644 --- a/tests/db_migrator_input/config_db/empty-config-expected.json +++ b/tests/db_migrator_input/config_db/empty-config-expected.json @@ -1,5 +1,8 @@ { "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" + }, + "DEVICE_METADATA|localhost": { + "synchronous_mode": "enable" } } diff --git a/tests/db_migrator_input/config_db/loopback_interface_migrate_from_1_0_1_expected.json b/tests/db_migrator_input/config_db/loopback_interface_migrate_from_1_0_1_expected.json new file mode 100644 index 0000000000..0d98a49ffd --- /dev/null +++ b/tests/db_migrator_input/config_db/loopback_interface_migrate_from_1_0_1_expected.json @@ -0,0 +1,8 @@ +{ + "LOOPBACK_INTERFACE|Loopback0" : {"NULL": "NULL"}, + "LOOPBACK_INTERFACE|Loopback0|10.1.0.32/32" : {"NULL": "NULL"}, + "LOOPBACK_INTERFACE|Loopback0|FC00:1::32/128" : {"NULL": "NULL"}, + "LOOPBACK_INTERFACE|Loopback1" : {"NULL": "NULL"}, + "LOOPBACK_INTERFACE|Loopback1|10.20.8.199/32" : {"NULL": "NULL"}, + "LOOPBACK_INTERFACE|Loopback1|2001:506:28:500::1/128" : {"NULL": "NULL"} +} diff --git a/tests/db_migrator_input/config_db/loopback_interface_migrate_from_1_0_1_input.json b/tests/db_migrator_input/config_db/loopback_interface_migrate_from_1_0_1_input.json new file mode 100644 index 0000000000..58832dc511 --- /dev/null +++ b/tests/db_migrator_input/config_db/loopback_interface_migrate_from_1_0_1_input.json @@ -0,0 +1,7 @@ +{ + "LOOPBACK_INTERFACE|Loopback0|10.1.0.32/32" : {"NULL": "NULL"}, + "LOOPBACK_INTERFACE|Loopback0|FC00:1::32/128" : {"NULL": "NULL"}, + "LOOPBACK_INTERFACE|Loopback1|10.20.8.199/32" : {"NULL": "NULL"}, + "LOOPBACK_INTERFACE|Loopback1|2001:506:28:500::1/128" : {"NULL": "NULL"}, + "VERSIONS|DATABASE": {"VERSION": "version_1_0_1"} +} diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t0-version_1_0_4.json b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t0-version_1_0_4.json index 4509a55587..8add09883a 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t0-version_1_0_4.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t0-version_1_0_4.json @@ -726,6 +726,7 @@ "hwsku": "Mellanox-SN2700-C28D8", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t0-version_1_0_5.json b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t0-version_1_0_5.json index 44c05c9dfb..af2f6b4d5f 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t0-version_1_0_5.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t0-version_1_0_5.json @@ -727,6 +727,7 @@ "hwsku": "Mellanox-SN2700-C28D8", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t0-version_1_0_6.json b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t0-version_1_0_6.json index c5369e6344..9881ff7ba8 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t0-version_1_0_6.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t0-version_1_0_6.json @@ -727,6 +727,7 @@ "hwsku": "Mellanox-SN2700-C28D8", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t0-version_2_0_0.json b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t0-version_3_0_0.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t0-version_2_0_0.json rename to tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t0-version_3_0_0.json index af7b580c12..f9d6c6ce92 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t0-version_2_0_0.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t0-version_3_0_0.json @@ -727,6 +727,7 @@ "hwsku": "Mellanox-SN2700-C28D8", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", @@ -1055,6 +1056,6 @@ "speed": "50000" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_0" + "VERSION": "version_3_0_0" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t0-version_2_0_3.json b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t0-version_3_0_3.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t0-version_2_0_3.json rename to tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t0-version_3_0_3.json index 22850ddc1f..e6cf41110b 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t0-version_2_0_3.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t0-version_3_0_3.json @@ -734,7 +734,8 @@ "bgp_asn": "65100", "buffer_model": "traditional", "deployment_id": "1", - "docker_routing_config_mode": "unified" + "docker_routing_config_mode": "unified", + "synchronous_mode": "enable" }, "PORT|Ethernet0": { "lanes": "0,1,2,3", @@ -1055,6 +1056,6 @@ "speed": "50000" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } -} \ No newline at end of file +} diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t1-version_1_0_4.json b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t1-version_1_0_4.json index 0acf1b0fac..c89504ce61 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t1-version_1_0_4.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t1-version_1_0_4.json @@ -819,6 +819,7 @@ "hwsku": "Mellanox-SN2700-C28D8", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t1-version_1_0_5.json b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t1-version_1_0_5.json index 91e78b8b96..c8464391d0 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t1-version_1_0_5.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t1-version_1_0_5.json @@ -820,6 +820,7 @@ "hwsku": "Mellanox-SN2700-C28D8", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t1-version_1_0_6.json b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t1-version_1_0_6.json index c7d7070c74..16845fd95e 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t1-version_1_0_6.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t1-version_1_0_6.json @@ -820,6 +820,7 @@ "hwsku": "Mellanox-SN2700-C28D8", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t1-version_2_0_0.json b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t1-version_3_0_0.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t1-version_2_0_0.json rename to tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t1-version_3_0_0.json index 2b680a34e9..a77c75e9c1 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t1-version_2_0_0.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t1-version_3_0_0.json @@ -820,6 +820,7 @@ "hwsku": "Mellanox-SN2700-C28D8", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", @@ -1148,6 +1149,6 @@ "speed": "50000" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_0" + "VERSION": "version_3_0_0" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t1-version_2_0_3.json b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t1-version_3_0_3.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t1-version_2_0_3.json rename to tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t1-version_3_0_3.json index 077e8e847f..81f6b1f1ce 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t1-version_2_0_3.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-single-pool-t1-version_3_0_3.json @@ -827,7 +827,8 @@ "bgp_asn": "65100", "buffer_model": "traditional", "deployment_id": "1", - "docker_routing_config_mode": "unified" + "docker_routing_config_mode": "unified", + "synchronous_mode": "enable" }, "PORT|Ethernet0": { "lanes": "0,1,2,3", @@ -1148,6 +1149,6 @@ "speed": "50000" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } -} \ No newline at end of file +} diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_1_0_1.json b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_1_0_1.json index b85b85118c..e960998c4b 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_1_0_1.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_1_0_1.json @@ -731,6 +731,7 @@ "hwsku": "Mellanox-SN2700-C28D8", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_1_0_2.json b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_1_0_2.json index 6648cce024..f4c80a0136 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_1_0_2.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_1_0_2.json @@ -731,6 +731,7 @@ "hwsku": "Mellanox-SN2700-C28D8", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_1_0_3.json b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_1_0_3.json index c80dce5874..920f88d462 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_1_0_3.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_1_0_3.json @@ -731,6 +731,7 @@ "hwsku": "Mellanox-SN2700-C28D8", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_1_0_4.json b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_1_0_4.json index 2ba6c8253a..d150d1a306 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_1_0_4.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_1_0_4.json @@ -731,6 +731,7 @@ "hwsku": "Mellanox-SN2700-C28D8", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_1_0_5.json b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_1_0_5.json index 70e25898ce..e3ff2f75da 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_1_0_5.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_1_0_5.json @@ -732,6 +732,7 @@ "hwsku": "Mellanox-SN2700-C28D8", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_1_0_6.json b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_1_0_6.json index 8b978e50ac..2f79723493 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_1_0_6.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_1_0_6.json @@ -732,6 +732,7 @@ "hwsku": "Mellanox-SN2700-C28D8", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_2_0_0.json b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_3_0_0.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_2_0_0.json rename to tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_3_0_0.json index fd55102445..dac897f792 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_2_0_0.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_3_0_0.json @@ -732,6 +732,7 @@ "hwsku": "Mellanox-SN2700-C28D8", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", @@ -1060,6 +1061,6 @@ "speed": "50000" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_0" + "VERSION": "version_3_0_0" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_2_0_3.json b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_3_0_3.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_2_0_3.json rename to tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_3_0_3.json index 5144e7fbc6..76d095e995 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_2_0_3.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t0-version_3_0_3.json @@ -739,7 +739,8 @@ "bgp_asn": "65100", "buffer_model": "traditional", "deployment_id": "1", - "docker_routing_config_mode": "unified" + "docker_routing_config_mode": "unified", + "synchronous_mode": "enable" }, "PORT|Ethernet0": { "lanes": "0,1,2,3", @@ -1060,6 +1061,6 @@ "speed": "50000" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } -} \ No newline at end of file +} diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_1_0_1.json b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_1_0_1.json index 7ec20f8cec..b5e515a4af 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_1_0_1.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_1_0_1.json @@ -824,6 +824,7 @@ "hwsku": "Mellanox-SN2700-C28D8", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_1_0_2.json b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_1_0_2.json index 31a1179ad2..472550b670 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_1_0_2.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_1_0_2.json @@ -824,6 +824,7 @@ "hwsku": "Mellanox-SN2700-C28D8", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_1_0_3.json b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_1_0_3.json index 855b16afc3..6c562bc0c8 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_1_0_3.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_1_0_3.json @@ -824,6 +824,7 @@ "hwsku": "Mellanox-SN2700-C28D8", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_1_0_4.json b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_1_0_4.json index 2b0ad78528..13e241b808 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_1_0_4.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_1_0_4.json @@ -824,6 +824,7 @@ "hwsku": "Mellanox-SN2700-C28D8", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_1_0_5.json b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_1_0_5.json index 19aeca0bc9..2890da1306 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_1_0_5.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_1_0_5.json @@ -825,6 +825,7 @@ "hwsku": "Mellanox-SN2700-C28D8", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_1_0_6.json b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_1_0_6.json index 9c6b896de5..8098a3cf3b 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_1_0_6.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_1_0_6.json @@ -825,6 +825,7 @@ "hwsku": "Mellanox-SN2700-C28D8", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_2_0_0.json b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_3_0_0.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_2_0_0.json rename to tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_3_0_0.json index 38428be263..05ca9f95fb 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_2_0_0.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_3_0_0.json @@ -825,6 +825,7 @@ "hwsku": "Mellanox-SN2700-C28D8", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", @@ -1153,6 +1154,6 @@ "speed": "50000" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_0" + "VERSION": "version_3_0_0" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_2_0_3.json b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_3_0_3.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_2_0_3.json rename to tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_3_0_3.json index 32c0814a7a..abccee2062 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_2_0_3.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-c28d8-t1-version_3_0_3.json @@ -832,7 +832,8 @@ "bgp_asn": "65100", "buffer_model": "traditional", "deployment_id": "1", - "docker_routing_config_mode": "unified" + "docker_routing_config_mode": "unified", + "synchronous_mode": "enable" }, "PORT|Ethernet0": { "lanes": "0,1,2,3", @@ -1153,6 +1154,6 @@ "speed": "50000" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } -} \ No newline at end of file +} diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t0-version_1_0_5.json b/tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t0-version_1_0_5.json index 752f4001c1..f0ef79e917 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t0-version_1_0_5.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t0-version_1_0_5.json @@ -727,6 +727,7 @@ "hwsku": "Mellanox-SN2700-D40C8S8", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t0-version_1_0_6.json b/tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t0-version_1_0_6.json index 288e0e727f..97bfefde06 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t0-version_1_0_6.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t0-version_1_0_6.json @@ -727,6 +727,7 @@ "hwsku": "Mellanox-SN2700-D40C8S8", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t0-version_2_0_0.json b/tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t0-version_3_0_0.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t0-version_2_0_0.json rename to tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t0-version_3_0_0.json index 2513d40083..cae7a8de89 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t0-version_2_0_0.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t0-version_3_0_0.json @@ -727,6 +727,7 @@ "hwsku": "Mellanox-SN2700-D40C8S8", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", @@ -1055,6 +1056,6 @@ "speed": "50000" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_0" + "VERSION": "version_3_0_0" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t0-version_2_0_3.json b/tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t0-version_3_0_3.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t0-version_2_0_3.json rename to tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t0-version_3_0_3.json index 842f8622dd..9367e7d6df 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t0-version_2_0_3.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t0-version_3_0_3.json @@ -734,7 +734,8 @@ "bgp_asn": "65100", "buffer_model": "traditional", "deployment_id": "1", - "docker_routing_config_mode": "unified" + "docker_routing_config_mode": "unified", + "synchronous_mode": "enable" }, "PORT|Ethernet0": { "lanes": "0,1,2,3", @@ -1055,6 +1056,6 @@ "speed": "50000" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } -} \ No newline at end of file +} diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t1-version_1_0_5.json b/tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t1-version_1_0_5.json index 94ec238858..770a586427 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t1-version_1_0_5.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t1-version_1_0_5.json @@ -820,6 +820,7 @@ "hwsku": "Mellanox-SN2700-D40C8S8", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t1-version_1_0_6.json b/tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t1-version_1_0_6.json index b848c67791..998a3f39ed 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t1-version_1_0_6.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t1-version_1_0_6.json @@ -820,6 +820,7 @@ "hwsku": "Mellanox-SN2700-D40C8S8", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t1-version_2_0_0.json b/tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t1-version_3_0_0.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t1-version_2_0_0.json rename to tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t1-version_3_0_0.json index cf2d4ecdd8..51f0ab67af 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t1-version_2_0_0.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t1-version_3_0_0.json @@ -820,6 +820,7 @@ "hwsku": "Mellanox-SN2700-D40C8S8", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", @@ -1148,6 +1149,6 @@ "speed": "50000" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_0" + "VERSION": "version_3_0_0" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t1-version_2_0_3.json b/tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t1-version_3_0_3.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t1-version_2_0_3.json rename to tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t1-version_3_0_3.json index da9416a429..c2f12ef94c 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t1-version_2_0_3.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-d40c8s8-t1-version_3_0_3.json @@ -827,7 +827,8 @@ "bgp_asn": "65100", "buffer_model": "traditional", "deployment_id": "1", - "docker_routing_config_mode": "unified" + "docker_routing_config_mode": "unified", + "synchronous_mode": "enable" }, "PORT|Ethernet0": { "lanes": "0,1,2,3", @@ -1148,6 +1149,6 @@ "speed": "50000" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } -} \ No newline at end of file +} diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t0-version_1_0_4.json b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t0-version_1_0_4.json index 53921af16f..5854e6456e 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t0-version_1_0_4.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t0-version_1_0_4.json @@ -726,6 +726,7 @@ "hwsku": "Mellanox-SN2700-D48C8", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t0-version_1_0_5.json b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t0-version_1_0_5.json index 9e3c1387a3..ea741ecae1 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t0-version_1_0_5.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t0-version_1_0_5.json @@ -727,6 +727,7 @@ "hwsku": "Mellanox-SN2700-D48C8", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t0-version_1_0_6.json b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t0-version_1_0_6.json index 60e34b7012..4ca5faa56f 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t0-version_1_0_6.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t0-version_1_0_6.json @@ -727,6 +727,7 @@ "hwsku": "Mellanox-SN2700-D48C8", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t0-version_2_0_0.json b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t0-version_3_0_0.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t0-version_2_0_0.json rename to tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t0-version_3_0_0.json index 8fc4128142..9aeb0b2b31 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t0-version_2_0_0.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t0-version_3_0_0.json @@ -727,6 +727,7 @@ "hwsku": "Mellanox-SN2700-D48C8", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", @@ -1055,6 +1056,6 @@ "speed": "50000" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_0" + "VERSION": "version_3_0_0" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t0-version_2_0_3.json b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t0-version_3_0_3.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t0-version_2_0_3.json rename to tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t0-version_3_0_3.json index 62ad538df3..52b9c7f58c 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t0-version_2_0_3.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t0-version_3_0_3.json @@ -734,7 +734,8 @@ "bgp_asn": "65100", "buffer_model": "traditional", "deployment_id": "1", - "docker_routing_config_mode": "unified" + "docker_routing_config_mode": "unified", + "synchronous_mode": "enable" }, "PORT|Ethernet0": { "lanes": "0,1,2,3", @@ -1055,6 +1056,6 @@ "speed": "50000" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } -} \ No newline at end of file +} diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t1-version_1_0_4.json b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t1-version_1_0_4.json index 647a0eeff0..6486ebdb2c 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t1-version_1_0_4.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t1-version_1_0_4.json @@ -819,6 +819,7 @@ "hwsku": "Mellanox-SN2700-D48C8", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t1-version_1_0_5.json b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t1-version_1_0_5.json index ed3bf55e60..3ae16cd145 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t1-version_1_0_5.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t1-version_1_0_5.json @@ -820,6 +820,7 @@ "hwsku": "Mellanox-SN2700-D48C8", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t1-version_1_0_6.json b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t1-version_1_0_6.json index a57f2b6842..853bb5c17b 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t1-version_1_0_6.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t1-version_1_0_6.json @@ -820,6 +820,7 @@ "hwsku": "Mellanox-SN2700-D48C8", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t1-version_2_0_0.json b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t1-version_3_0_0.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t1-version_2_0_0.json rename to tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t1-version_3_0_0.json index 171cbe43d0..6add5489d1 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t1-version_2_0_0.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t1-version_3_0_0.json @@ -820,6 +820,7 @@ "hwsku": "Mellanox-SN2700-D48C8", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", @@ -1148,6 +1149,6 @@ "speed": "50000" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_0" + "VERSION": "version_3_0_0" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t1-version_2_0_3.json b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t1-version_3_0_3.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t1-version_2_0_3.json rename to tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t1-version_3_0_3.json index b6464b117f..082bd15765 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t1-version_2_0_3.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-single-pool-t1-version_3_0_3.json @@ -827,7 +827,8 @@ "bgp_asn": "65100", "buffer_model": "traditional", "deployment_id": "1", - "docker_routing_config_mode": "unified" + "docker_routing_config_mode": "unified", + "synchronous_mode": "enable" }, "PORT|Ethernet0": { "lanes": "0,1,2,3", @@ -1148,6 +1149,6 @@ "speed": "50000" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } -} \ No newline at end of file +} diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_1_0_1.json b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_1_0_1.json index 2e9f075fb0..379445f819 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_1_0_1.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_1_0_1.json @@ -731,6 +731,7 @@ "hwsku": "Mellanox-SN2700-D48C8", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_1_0_2.json b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_1_0_2.json index 1bb45cc2ce..3794807637 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_1_0_2.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_1_0_2.json @@ -731,6 +731,7 @@ "hwsku": "Mellanox-SN2700-D48C8", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_1_0_3.json b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_1_0_3.json index 6df051fab2..6677793096 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_1_0_3.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_1_0_3.json @@ -731,6 +731,7 @@ "hwsku": "Mellanox-SN2700-D48C8", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_1_0_4.json b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_1_0_4.json index 83edfa3b5d..819e670ce6 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_1_0_4.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_1_0_4.json @@ -731,6 +731,7 @@ "hwsku": "Mellanox-SN2700-D48C8", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_1_0_5.json b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_1_0_5.json index 87788b7bb8..6e351f2a76 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_1_0_5.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_1_0_5.json @@ -732,6 +732,7 @@ "hwsku": "Mellanox-SN2700-D48C8", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_1_0_6.json b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_1_0_6.json index e531918185..1e61a9e935 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_1_0_6.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_1_0_6.json @@ -732,6 +732,7 @@ "hwsku": "Mellanox-SN2700-D48C8", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_2_0_0.json b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_3_0_0.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_2_0_0.json rename to tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_3_0_0.json index 1119126485..adf0fb31ac 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_2_0_0.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_3_0_0.json @@ -732,6 +732,7 @@ "hwsku": "Mellanox-SN2700-D48C8", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", @@ -1060,6 +1061,6 @@ "speed": "50000" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_0" + "VERSION": "version_3_0_0" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_2_0_3.json b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_3_0_3.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_2_0_3.json rename to tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_3_0_3.json index 3de072f4b7..5282b3e73e 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_2_0_3.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t0-version_3_0_3.json @@ -739,7 +739,8 @@ "bgp_asn": "65100", "buffer_model": "traditional", "deployment_id": "1", - "docker_routing_config_mode": "unified" + "docker_routing_config_mode": "unified", + "synchronous_mode": "enable" }, "PORT|Ethernet0": { "lanes": "0,1,2,3", @@ -1060,6 +1061,6 @@ "speed": "50000" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } -} \ No newline at end of file +} diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_1_0_1.json b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_1_0_1.json index 93b622b860..eaedbbb102 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_1_0_1.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_1_0_1.json @@ -824,6 +824,7 @@ "hwsku": "Mellanox-SN2700-D48C8", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_1_0_2.json b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_1_0_2.json index 5fea4f31b5..52f3d5070c 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_1_0_2.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_1_0_2.json @@ -824,6 +824,7 @@ "hwsku": "Mellanox-SN2700-D48C8", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_1_0_3.json b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_1_0_3.json index 69331752c6..51fecae2da 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_1_0_3.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_1_0_3.json @@ -824,6 +824,7 @@ "hwsku": "Mellanox-SN2700-D48C8", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_1_0_4.json b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_1_0_4.json index 226ecf053d..b18cc6e41e 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_1_0_4.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_1_0_4.json @@ -824,6 +824,7 @@ "hwsku": "Mellanox-SN2700-D48C8", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_1_0_5.json b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_1_0_5.json index f1a2f4fc9b..7b22d88c95 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_1_0_5.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_1_0_5.json @@ -825,6 +825,7 @@ "hwsku": "Mellanox-SN2700-D48C8", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_1_0_6.json b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_1_0_6.json index e43f55ee8f..7ae6b09098 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_1_0_6.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_1_0_6.json @@ -825,6 +825,7 @@ "hwsku": "Mellanox-SN2700-D48C8", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_2_0_0.json b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_3_0_0.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_2_0_0.json rename to tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_3_0_0.json index 436e5a4803..09df55a46b 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_2_0_0.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_3_0_0.json @@ -825,6 +825,7 @@ "hwsku": "Mellanox-SN2700-D48C8", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", @@ -1153,6 +1154,6 @@ "speed": "50000" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_0" + "VERSION": "version_3_0_0" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_2_0_3.json b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_3_0_3.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_2_0_3.json rename to tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_3_0_3.json index 9571eb9c96..e20f0dce78 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_2_0_3.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-d48c8-t1-version_3_0_3.json @@ -832,7 +832,8 @@ "bgp_asn": "65100", "buffer_model": "traditional", "deployment_id": "1", - "docker_routing_config_mode": "unified" + "docker_routing_config_mode": "unified", + "synchronous_mode": "enable" }, "PORT|Ethernet0": { "lanes": "0,1,2,3", @@ -1153,6 +1154,6 @@ "speed": "50000" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } -} \ No newline at end of file +} diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t0-version_1_0_4.json b/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t0-version_1_0_4.json index fdc77e9a4b..478aa3dc70 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t0-version_1_0_4.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t0-version_1_0_4.json @@ -732,7 +732,8 @@ "default_pfcwd_status": "disable", "bgp_asn": "65100", "deployment_id": "1", - "type": "ToRRouter" + "type": "ToRRouter", + "synchronous_mode": "enable" }, "PORT|Ethernet0": { "lanes": "0,1,2,3", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t0-version_1_0_5.json b/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t0-version_1_0_5.json index 0e0d4e91b9..ead6486d17 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t0-version_1_0_5.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t0-version_1_0_5.json @@ -733,7 +733,8 @@ "default_pfcwd_status": "disable", "bgp_asn": "65100", "deployment_id": "1", - "type": "ToRRouter" + "type": "ToRRouter", + "synchronous_mode": "enable" }, "PORT|Ethernet0": { "lanes": "0,1,2,3", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t0-version_1_0_6.json b/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t0-version_1_0_6.json index 37a3cc2bf3..d20b0db1fa 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t0-version_1_0_6.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t0-version_1_0_6.json @@ -733,7 +733,8 @@ "default_pfcwd_status": "disable", "bgp_asn": "65100", "deployment_id": "1", - "type": "ToRRouter" + "type": "ToRRouter", + "synchronous_mode": "enable" }, "PORT|Ethernet0": { "lanes": "0,1,2,3", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t0-version_2_0_0.json b/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t0-version_3_0_0.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t0-version_2_0_0.json rename to tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t0-version_3_0_0.json index 093ea2c7db..e0f5d3fbb8 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t0-version_2_0_0.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t0-version_3_0_0.json @@ -734,7 +734,8 @@ "bgp_asn": "65100", "buffer_model": "traditional", "deployment_id": "1", - "type": "ToRRouter" + "type": "ToRRouter", + "synchronous_mode": "enable" }, "PORT|Ethernet0": { "lanes": "0,1,2,3", @@ -1055,6 +1056,6 @@ "speed": "50000" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_0" + "VERSION": "version_3_0_0" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t0-version_2_0_3.json b/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t0-version_3_0_3.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t0-version_2_0_3.json rename to tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t0-version_3_0_3.json index e9a3ce0336..39956f85ed 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t0-version_2_0_3.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t0-version_3_0_3.json @@ -734,7 +734,8 @@ "bgp_asn": "65100", "buffer_model": "traditional", "deployment_id": "1", - "type": "ToRRouter" + "type": "ToRRouter", + "synchronous_mode": "enable" }, "PORT|Ethernet0": { "lanes": "0,1,2,3", @@ -1055,6 +1056,6 @@ "speed": "50000" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } -} \ No newline at end of file +} diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t1-version_1_0_4.json b/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t1-version_1_0_4.json index c99bad1dc6..5c876d66ff 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t1-version_1_0_4.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t1-version_1_0_4.json @@ -819,6 +819,7 @@ "hwsku": "Mellanox-SN2700", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t1-version_1_0_5.json b/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t1-version_1_0_5.json index 4bf50c3456..bb5b2da3ba 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t1-version_1_0_5.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t1-version_1_0_5.json @@ -820,6 +820,7 @@ "hwsku": "Mellanox-SN2700", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t1-version_1_0_6.json b/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t1-version_1_0_6.json index 8c35bd19de..b290fd57e9 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t1-version_1_0_6.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t1-version_1_0_6.json @@ -820,6 +820,7 @@ "hwsku": "Mellanox-SN2700", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t1-version_2_0_0.json b/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t1-version_3_0_0.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t1-version_2_0_0.json rename to tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t1-version_3_0_0.json index 0e07eb8f5b..b72e1498c4 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t1-version_2_0_0.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t1-version_3_0_0.json @@ -820,6 +820,7 @@ "hwsku": "Mellanox-SN2700", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", @@ -1148,6 +1149,6 @@ "speed": "50000" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_0" + "VERSION": "version_3_0_0" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t1-version_2_0_3.json b/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t1-version_3_0_3.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t1-version_2_0_3.json rename to tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t1-version_3_0_3.json index d150a9667e..28b01ee3fb 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t1-version_2_0_3.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-single-pool-t1-version_3_0_3.json @@ -827,7 +827,8 @@ "bgp_asn": "65100", "buffer_model": "traditional", "deployment_id": "1", - "docker_routing_config_mode": "unified" + "docker_routing_config_mode": "unified", + "synchronous_mode": "enable" }, "PORT|Ethernet0": { "lanes": "0,1,2,3", @@ -1148,6 +1149,6 @@ "speed": "50000" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } -} \ No newline at end of file +} diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_1_0_1.json b/tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_1_0_1.json index 4a38a382f1..94ecade338 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_1_0_1.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_1_0_1.json @@ -731,6 +731,7 @@ "hwsku": "Mellanox-SN2700", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_1_0_2.json b/tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_1_0_2.json index da5d5ebef3..f97f5dd554 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_1_0_2.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_1_0_2.json @@ -731,6 +731,7 @@ "hwsku": "Mellanox-SN2700", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_1_0_3.json b/tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_1_0_3.json index c518a0a9ce..3843271a45 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_1_0_3.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_1_0_3.json @@ -731,6 +731,7 @@ "hwsku": "Mellanox-SN2700", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_1_0_4.json b/tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_1_0_4.json index de29236261..80a9ff5c08 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_1_0_4.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_1_0_4.json @@ -731,6 +731,7 @@ "hwsku": "Mellanox-SN2700", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_1_0_5.json b/tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_1_0_5.json index 967726dbb3..0f078f7071 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_1_0_5.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_1_0_5.json @@ -732,6 +732,7 @@ "hwsku": "Mellanox-SN2700", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_1_0_6.json b/tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_1_0_6.json index 088c63f519..9fdbcf7a20 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_1_0_6.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_1_0_6.json @@ -732,6 +732,7 @@ "hwsku": "Mellanox-SN2700", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_2_0_0.json b/tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_3_0_0.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_2_0_0.json rename to tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_3_0_0.json index 1061135496..3b614fe042 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_2_0_0.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_3_0_0.json @@ -732,6 +732,7 @@ "hwsku": "Mellanox-SN2700", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", @@ -1060,6 +1061,6 @@ "speed": "50000" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_0" + "VERSION": "version_3_0_0" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_2_0_3.json b/tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_3_0_3.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_2_0_3.json rename to tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_3_0_3.json index 8422c1e651..7bc0720ec9 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_2_0_3.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-t0-version_3_0_3.json @@ -739,7 +739,8 @@ "bgp_asn": "65100", "buffer_model": "traditional", "deployment_id": "1", - "docker_routing_config_mode": "unified" + "docker_routing_config_mode": "unified", + "synchronous_mode": "enable" }, "PORT|Ethernet0": { "lanes": "0,1,2,3", @@ -1060,6 +1061,6 @@ "speed": "50000" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } -} \ No newline at end of file +} diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_1_0_1.json b/tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_1_0_1.json index e0b75fa484..eaabe74697 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_1_0_1.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_1_0_1.json @@ -824,6 +824,7 @@ "hwsku": "Mellanox-SN2700", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_1_0_2.json b/tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_1_0_2.json index 5a78582246..d98d906e46 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_1_0_2.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_1_0_2.json @@ -824,6 +824,7 @@ "hwsku": "Mellanox-SN2700", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_1_0_3.json b/tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_1_0_3.json index a54358373c..15333f0052 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_1_0_3.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_1_0_3.json @@ -824,6 +824,7 @@ "hwsku": "Mellanox-SN2700", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_1_0_4.json b/tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_1_0_4.json index 5b1bceeabb..6bb8c338db 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_1_0_4.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_1_0_4.json @@ -824,6 +824,7 @@ "hwsku": "Mellanox-SN2700", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_1_0_5.json b/tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_1_0_5.json index 76ec1bb52c..feb158e4a7 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_1_0_5.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_1_0_5.json @@ -825,6 +825,7 @@ "hwsku": "Mellanox-SN2700", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_1_0_6.json b/tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_1_0_6.json index 81f7377f84..a5eaedbb85 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_1_0_6.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_1_0_6.json @@ -825,6 +825,7 @@ "hwsku": "Mellanox-SN2700", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_2_0_0.json b/tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_3_0_0.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_2_0_0.json rename to tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_3_0_0.json index 7d9192a523..a53b1bbda7 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_2_0_0.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_3_0_0.json @@ -825,6 +825,7 @@ "hwsku": "Mellanox-SN2700", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", @@ -1153,6 +1154,6 @@ "speed": "50000" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_0" + "VERSION": "version_3_0_0" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_2_0_3.json b/tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_3_0_3.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_2_0_3.json rename to tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_3_0_3.json index 3012654e7b..203ac2171f 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_2_0_3.json +++ b/tests/db_migrator_input/config_db/mellanox-sn2700-t1-version_3_0_3.json @@ -832,7 +832,8 @@ "bgp_asn": "65100", "buffer_model": "traditional", "deployment_id": "1", - "docker_routing_config_mode": "unified" + "docker_routing_config_mode": "unified", + "synchronous_mode": "enable" }, "PORT|Ethernet0": { "lanes": "0,1,2,3", @@ -1153,6 +1154,6 @@ "speed": "50000" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } -} \ No newline at end of file +} diff --git a/tests/db_migrator_input/config_db/mellanox-sn3800-c64-t0-version_1_0_5.json b/tests/db_migrator_input/config_db/mellanox-sn3800-c64-t0-version_1_0_5.json index 94d64196ab..79bd49a9a4 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn3800-c64-t0-version_1_0_5.json +++ b/tests/db_migrator_input/config_db/mellanox-sn3800-c64-t0-version_1_0_5.json @@ -704,6 +704,7 @@ "bgp_asn": "65100", "cloudtype": "None", "type": "ToRRouter", + "synchronous_mode": "enable", "deployment_id": "1" }, "PORT|Ethernet0": { diff --git a/tests/db_migrator_input/config_db/mellanox-sn3800-c64-t0-version_1_0_6.json b/tests/db_migrator_input/config_db/mellanox-sn3800-c64-t0-version_1_0_6.json index e0d47020e5..3b7815cc1a 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn3800-c64-t0-version_1_0_6.json +++ b/tests/db_migrator_input/config_db/mellanox-sn3800-c64-t0-version_1_0_6.json @@ -704,6 +704,7 @@ "bgp_asn": "65100", "cloudtype": "None", "type": "ToRRouter", + "synchronous_mode": "enable", "deployment_id": "1" }, "PORT|Ethernet0": { diff --git a/tests/db_migrator_input/config_db/mellanox-sn3800-c64-t0-version_2_0_0.json b/tests/db_migrator_input/config_db/mellanox-sn3800-c64-t0-version_3_0_0.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn3800-c64-t0-version_2_0_0.json rename to tests/db_migrator_input/config_db/mellanox-sn3800-c64-t0-version_3_0_0.json index b69b2cf019..6422d9ce10 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn3800-c64-t0-version_2_0_0.json +++ b/tests/db_migrator_input/config_db/mellanox-sn3800-c64-t0-version_3_0_0.json @@ -705,6 +705,7 @@ "buffer_model": "traditional", "cloudtype": "None", "type": "ToRRouter", + "synchronous_mode": "enable", "deployment_id": "1" }, "PORT|Ethernet0": { @@ -1764,6 +1765,6 @@ "admin_status": "up" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_0" + "VERSION": "version_3_0_0" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/mellanox-sn3800-c64-t0-version_2_0_3.json b/tests/db_migrator_input/config_db/mellanox-sn3800-c64-t0-version_3_0_3.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn3800-c64-t0-version_2_0_3.json rename to tests/db_migrator_input/config_db/mellanox-sn3800-c64-t0-version_3_0_3.json index a27361ef0f..027cc5325c 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn3800-c64-t0-version_2_0_3.json +++ b/tests/db_migrator_input/config_db/mellanox-sn3800-c64-t0-version_3_0_3.json @@ -705,7 +705,8 @@ "buffer_model": "traditional", "cloudtype": "None", "type": "ToRRouter", - "deployment_id": "1" + "deployment_id": "1", + "synchronous_mode": "enable" }, "PORT|Ethernet0": { "index": "0", @@ -1764,6 +1765,6 @@ "admin_status": "up" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } -} \ No newline at end of file +} diff --git a/tests/db_migrator_input/config_db/mellanox-sn3800-c64-t1-version_1_0_5.json b/tests/db_migrator_input/config_db/mellanox-sn3800-c64-t1-version_1_0_5.json index a299500e52..6256051591 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn3800-c64-t1-version_1_0_5.json +++ b/tests/db_migrator_input/config_db/mellanox-sn3800-c64-t1-version_1_0_5.json @@ -826,6 +826,7 @@ "bgp_asn": "65100", "cloudtype": "None", "type": "LeafRouter", + "synchronous_mode": "enable", "deployment_id": "1" }, "PORT|Ethernet0": { diff --git a/tests/db_migrator_input/config_db/mellanox-sn3800-c64-t1-version_1_0_6.json b/tests/db_migrator_input/config_db/mellanox-sn3800-c64-t1-version_1_0_6.json index e5f078c959..0961703d95 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn3800-c64-t1-version_1_0_6.json +++ b/tests/db_migrator_input/config_db/mellanox-sn3800-c64-t1-version_1_0_6.json @@ -826,6 +826,7 @@ "bgp_asn": "65100", "cloudtype": "None", "type": "LeafRouter", + "synchronous_mode": "enable", "deployment_id": "1" }, "PORT|Ethernet0": { diff --git a/tests/db_migrator_input/config_db/mellanox-sn3800-c64-t1-version_2_0_0.json b/tests/db_migrator_input/config_db/mellanox-sn3800-c64-t1-version_3_0_0.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn3800-c64-t1-version_2_0_0.json rename to tests/db_migrator_input/config_db/mellanox-sn3800-c64-t1-version_3_0_0.json index 318bed85ab..d172932f50 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn3800-c64-t1-version_2_0_0.json +++ b/tests/db_migrator_input/config_db/mellanox-sn3800-c64-t1-version_3_0_0.json @@ -827,6 +827,7 @@ "buffer_model": "traditional", "cloudtype": "None", "type": "LeafRouter", + "synchronous_mode": "enable", "deployment_id": "1" }, "PORT|Ethernet0": { @@ -1886,6 +1887,6 @@ "admin_status": "up" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_0" + "VERSION": "version_3_0_0" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/mellanox-sn3800-c64-t1-version_2_0_3.json b/tests/db_migrator_input/config_db/mellanox-sn3800-c64-t1-version_3_0_3.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn3800-c64-t1-version_2_0_3.json rename to tests/db_migrator_input/config_db/mellanox-sn3800-c64-t1-version_3_0_3.json index 901bc3fe61..c0ca921d94 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn3800-c64-t1-version_2_0_3.json +++ b/tests/db_migrator_input/config_db/mellanox-sn3800-c64-t1-version_3_0_3.json @@ -827,7 +827,8 @@ "buffer_model": "traditional", "cloudtype": "None", "type": "LeafRouter", - "deployment_id": "1" + "deployment_id": "1", + "synchronous_mode": "enable" }, "PORT|Ethernet0": { "index": "0", @@ -1886,6 +1887,6 @@ "admin_status": "up" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } -} \ No newline at end of file +} diff --git a/tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t0-version_1_0_5.json b/tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t0-version_1_0_5.json index 3d1650b1fc..85c078c8cb 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t0-version_1_0_5.json +++ b/tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t0-version_1_0_5.json @@ -984,6 +984,7 @@ "bgp_asn": "65100", "cloudtype": "None", "type": "ToRRouter", + "synchronous_mode": "enable", "deployment_id": "1" }, "PORT|Ethernet0": { diff --git a/tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t0-version_1_0_6.json b/tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t0-version_1_0_6.json index 85664d39ef..9db400fb93 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t0-version_1_0_6.json +++ b/tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t0-version_1_0_6.json @@ -984,6 +984,7 @@ "bgp_asn": "65100", "cloudtype": "None", "type": "ToRRouter", + "synchronous_mode": "enable", "deployment_id": "1" }, "PORT|Ethernet0": { diff --git a/tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t0-version_2_0_0.json b/tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t0-version_3_0_0.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t0-version_2_0_0.json rename to tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t0-version_3_0_0.json index fa15acac8d..85c2cfbabe 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t0-version_2_0_0.json +++ b/tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t0-version_3_0_0.json @@ -985,6 +985,7 @@ "buffer_model": "traditional", "cloudtype": "None", "type": "ToRRouter", + "synchronous_mode": "enable", "deployment_id": "1" }, "PORT|Ethernet0": { @@ -2044,6 +2045,6 @@ "admin_status": "up" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_0" + "VERSION": "version_3_0_0" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t0-version_2_0_3.json b/tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t0-version_3_0_3.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t0-version_2_0_3.json rename to tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t0-version_3_0_3.json index 9cddd16235..41b514410f 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t0-version_2_0_3.json +++ b/tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t0-version_3_0_3.json @@ -985,7 +985,8 @@ "buffer_model": "traditional", "cloudtype": "None", "type": "ToRRouter", - "deployment_id": "1" + "deployment_id": "1", + "synchronous_mode": "enable" }, "PORT|Ethernet0": { "index": "0", @@ -2044,6 +2045,6 @@ "admin_status": "up" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } -} \ No newline at end of file +} diff --git a/tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t1-version_1_0_5.json b/tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t1-version_1_0_5.json index f0576552a1..c7809b711d 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t1-version_1_0_5.json +++ b/tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t1-version_1_0_5.json @@ -1098,6 +1098,7 @@ "bgp_asn": "65100", "cloudtype": "None", "type": "LeafRouter", + "synchronous_mode": "enable", "deployment_id": "1" }, "PORT|Ethernet0": { diff --git a/tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t1-version_1_0_6.json b/tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t1-version_1_0_6.json index 9e08f652fe..2bf0ab7029 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t1-version_1_0_6.json +++ b/tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t1-version_1_0_6.json @@ -1098,6 +1098,7 @@ "bgp_asn": "65100", "cloudtype": "None", "type": "LeafRouter", + "synchronous_mode": "enable", "deployment_id": "1" }, "PORT|Ethernet0": { diff --git a/tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t1-version_2_0_0.json b/tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t1-version_3_0_0.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t1-version_2_0_0.json rename to tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t1-version_3_0_0.json index 9093aa176b..349bd02ff7 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t1-version_2_0_0.json +++ b/tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t1-version_3_0_0.json @@ -1099,6 +1099,7 @@ "buffer_model": "traditional", "cloudtype": "None", "type": "LeafRouter", + "synchronous_mode": "enable", "deployment_id": "1" }, "PORT|Ethernet0": { @@ -2158,6 +2159,6 @@ "admin_status": "up" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_0" + "VERSION": "version_3_0_0" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t1-version_2_0_3.json b/tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t1-version_3_0_3.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t1-version_2_0_3.json rename to tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t1-version_3_0_3.json index 6169646c08..a3c05d3bb2 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t1-version_2_0_3.json +++ b/tests/db_migrator_input/config_db/mellanox-sn3800-d112c8-t1-version_3_0_3.json @@ -1099,7 +1099,8 @@ "buffer_model": "traditional", "cloudtype": "None", "type": "LeafRouter", - "deployment_id": "1" + "deployment_id": "1", + "synchronous_mode": "enable" }, "PORT|Ethernet0": { "index": "0", @@ -2158,6 +2159,6 @@ "admin_status": "up" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } -} \ No newline at end of file +} diff --git a/tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t0-version_1_0_5.json b/tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t0-version_1_0_5.json index 9b331a15d5..7808bc4545 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t0-version_1_0_5.json +++ b/tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t0-version_1_0_5.json @@ -704,6 +704,7 @@ "bgp_asn": "65100", "cloudtype": "None", "type": "ToRRouter", + "synchronous_mode": "enable", "deployment_id": "1" }, "PORT|Ethernet0": { diff --git a/tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t0-version_1_0_6.json b/tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t0-version_1_0_6.json index edefc7e4bf..a765865644 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t0-version_1_0_6.json +++ b/tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t0-version_1_0_6.json @@ -704,6 +704,7 @@ "bgp_asn": "65100", "cloudtype": "None", "type": "ToRRouter", + "synchronous_mode": "enable", "deployment_id": "1" }, "PORT|Ethernet0": { diff --git a/tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t0-version_2_0_0.json b/tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t0-version_3_0_0.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t0-version_2_0_0.json rename to tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t0-version_3_0_0.json index a4477de9ad..9394215698 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t0-version_2_0_0.json +++ b/tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t0-version_3_0_0.json @@ -705,6 +705,7 @@ "buffer_model": "traditional", "cloudtype": "None", "type": "ToRRouter", + "synchronous_mode": "enable", "deployment_id": "1" }, "PORT|Ethernet0": { @@ -1764,6 +1765,6 @@ "admin_status": "up" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_0" + "VERSION": "version_3_0_0" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t0-version_2_0_3.json b/tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t0-version_3_0_3.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t0-version_2_0_3.json rename to tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t0-version_3_0_3.json index 9358cc568e..0d5131d574 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t0-version_2_0_3.json +++ b/tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t0-version_3_0_3.json @@ -705,7 +705,8 @@ "buffer_model": "traditional", "cloudtype": "None", "type": "ToRRouter", - "deployment_id": "1" + "deployment_id": "1", + "synchronous_mode": "enable" }, "PORT|Ethernet0": { "index": "0", @@ -1764,6 +1765,6 @@ "admin_status": "up" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } -} \ No newline at end of file +} diff --git a/tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t1-version_1_0_5.json b/tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t1-version_1_0_5.json index 5a0c41c854..875df36443 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t1-version_1_0_5.json +++ b/tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t1-version_1_0_5.json @@ -826,6 +826,7 @@ "bgp_asn": "65100", "cloudtype": "None", "type": "LeafRouter", + "synchronous_mode": "enable", "deployment_id": "1" }, "PORT|Ethernet0": { diff --git a/tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t1-version_1_0_6.json b/tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t1-version_1_0_6.json index 5a0c41c854..875df36443 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t1-version_1_0_6.json +++ b/tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t1-version_1_0_6.json @@ -826,6 +826,7 @@ "bgp_asn": "65100", "cloudtype": "None", "type": "LeafRouter", + "synchronous_mode": "enable", "deployment_id": "1" }, "PORT|Ethernet0": { diff --git a/tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t1-version_2_0_0.json b/tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t1-version_3_0_0.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t1-version_2_0_0.json rename to tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t1-version_3_0_0.json index 4772573a66..07790160c8 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t1-version_2_0_0.json +++ b/tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t1-version_3_0_0.json @@ -827,6 +827,7 @@ "buffer_model": "traditional", "cloudtype": "None", "type": "LeafRouter", + "synchronous_mode": "enable", "deployment_id": "1" }, "PORT|Ethernet0": { @@ -1886,6 +1887,6 @@ "admin_status": "up" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_0" + "VERSION": "version_3_0_0" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t1-version_2_0_3.json b/tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t1-version_3_0_3.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t1-version_2_0_3.json rename to tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t1-version_3_0_3.json index 0ae91b3c53..a6cd6671f0 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t1-version_2_0_3.json +++ b/tests/db_migrator_input/config_db/mellanox-sn3800-d24c52-t1-version_3_0_3.json @@ -827,7 +827,8 @@ "buffer_model": "traditional", "cloudtype": "None", "type": "LeafRouter", - "deployment_id": "1" + "deployment_id": "1", + "synchronous_mode": "enable" }, "PORT|Ethernet0": { "index": "0", @@ -1886,6 +1887,6 @@ "admin_status": "up" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } -} \ No newline at end of file +} diff --git a/tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t0-version_1_0_5.json b/tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t0-version_1_0_5.json index 340de9a2fe..0cf0683206 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t0-version_1_0_5.json +++ b/tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t0-version_1_0_5.json @@ -704,6 +704,7 @@ "bgp_asn": "65100", "cloudtype": "None", "type": "ToRRouter", + "synchronous_mode": "enable", "deployment_id": "1" }, "PORT|Ethernet0": { diff --git a/tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t0-version_1_0_6.json b/tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t0-version_1_0_6.json index 5d439de320..760dc26fa9 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t0-version_1_0_6.json +++ b/tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t0-version_1_0_6.json @@ -704,6 +704,7 @@ "bgp_asn": "65100", "cloudtype": "None", "type": "ToRRouter", + "synchronous_mode": "enable", "deployment_id": "1" }, "PORT|Ethernet0": { diff --git a/tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t0-version_2_0_0.json b/tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t0-version_3_0_0.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t0-version_2_0_0.json rename to tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t0-version_3_0_0.json index 941a6fdb75..3e2998210f 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t0-version_2_0_0.json +++ b/tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t0-version_3_0_0.json @@ -705,6 +705,7 @@ "buffer_model": "traditional", "cloudtype": "None", "type": "ToRRouter", + "synchronous_mode": "enable", "deployment_id": "1" }, "PORT|Ethernet0": { @@ -1764,6 +1765,6 @@ "admin_status": "up" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_0" + "VERSION": "version_3_0_0" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t0-version_2_0_3.json b/tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t0-version_3_0_3.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t0-version_2_0_3.json rename to tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t0-version_3_0_3.json index 362f763df1..67971e733c 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t0-version_2_0_3.json +++ b/tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t0-version_3_0_3.json @@ -705,7 +705,8 @@ "buffer_model": "traditional", "cloudtype": "None", "type": "ToRRouter", - "deployment_id": "1" + "deployment_id": "1", + "synchronous_mode": "enable" }, "PORT|Ethernet0": { "index": "0", @@ -1764,6 +1765,6 @@ "admin_status": "up" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } -} \ No newline at end of file +} diff --git a/tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t1-version_1_0_5.json b/tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t1-version_1_0_5.json index 97403e343d..5cd8f639a8 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t1-version_1_0_5.json +++ b/tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t1-version_1_0_5.json @@ -826,6 +826,7 @@ "bgp_asn": "65100", "cloudtype": "None", "type": "LeafRouter", + "synchronous_mode": "enable", "deployment_id": "1" }, "PORT|Ethernet0": { diff --git a/tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t1-version_1_0_6.json b/tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t1-version_1_0_6.json index 97403e343d..5cd8f639a8 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t1-version_1_0_6.json +++ b/tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t1-version_1_0_6.json @@ -826,6 +826,7 @@ "bgp_asn": "65100", "cloudtype": "None", "type": "LeafRouter", + "synchronous_mode": "enable", "deployment_id": "1" }, "PORT|Ethernet0": { diff --git a/tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t1-version_2_0_0.json b/tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t1-version_3_0_0.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t1-version_2_0_0.json rename to tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t1-version_3_0_0.json index 429324cb11..3448ef3a35 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t1-version_2_0_0.json +++ b/tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t1-version_3_0_0.json @@ -827,6 +827,7 @@ "buffer_model": "traditional", "cloudtype": "None", "type": "LeafRouter", + "synchronous_mode": "enable", "deployment_id": "1" }, "PORT|Ethernet0": { @@ -1886,6 +1887,6 @@ "admin_status": "up" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_0" + "VERSION": "version_3_0_0" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t1-version_2_0_3.json b/tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t1-version_3_0_3.json similarity index 99% rename from tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t1-version_2_0_3.json rename to tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t1-version_3_0_3.json index 0a97a493ec..cb94646dca 100644 --- a/tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t1-version_2_0_3.json +++ b/tests/db_migrator_input/config_db/mellanox-sn3800-d28c50-t1-version_3_0_3.json @@ -827,7 +827,8 @@ "buffer_model": "traditional", "cloudtype": "None", "type": "LeafRouter", - "deployment_id": "1" + "deployment_id": "1", + "synchronous_mode": "enable" }, "PORT|Ethernet0": { "index": "0", @@ -1886,6 +1887,6 @@ "admin_status": "up" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } -} \ No newline at end of file +} diff --git a/tests/db_migrator_input/config_db/non-default-config-expected.json b/tests/db_migrator_input/config_db/non-default-config-expected.json index dab1997e24..13ae7aa2f3 100644 --- a/tests/db_migrator_input/config_db/non-default-config-expected.json +++ b/tests/db_migrator_input/config_db/non-default-config-expected.json @@ -762,7 +762,8 @@ "bgp_asn": "65100", "buffer_model": "traditional", "deployment_id": "1", - "type": "ToRRouter" + "type": "ToRRouter", + "synchronous_mode": "enable" }, "PORT|Ethernet0": { "index": "1", @@ -1115,6 +1116,6 @@ "speed": "50000" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/non-default-config-input.json b/tests/db_migrator_input/config_db/non-default-config-input.json index b806793fc4..3cdd352729 100644 --- a/tests/db_migrator_input/config_db/non-default-config-input.json +++ b/tests/db_migrator_input/config_db/non-default-config-input.json @@ -737,7 +737,8 @@ "default_pfcwd_status": "disable", "bgp_asn": "65100", "deployment_id": "1", - "type": "ToRRouter" + "type": "ToRRouter", + "synchronous_mode": "enable" }, "PORT|Ethernet0": { "lanes": "0,1,2,3", diff --git a/tests/db_migrator_input/config_db/non-default-lossless-profile-in-pg-expected.json b/tests/db_migrator_input/config_db/non-default-lossless-profile-in-pg-expected.json index b0e6400785..fd7241724d 100644 --- a/tests/db_migrator_input/config_db/non-default-lossless-profile-in-pg-expected.json +++ b/tests/db_migrator_input/config_db/non-default-lossless-profile-in-pg-expected.json @@ -956,6 +956,7 @@ "hwsku": "ACS-MSN4700", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "region": "None", "hostname": "sonic", "platform": "x86_64-mlnx_msn4700-r0", @@ -2044,6 +2045,6 @@ "admin_status": "up" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/non-default-lossless-profile-in-pg-input.json b/tests/db_migrator_input/config_db/non-default-lossless-profile-in-pg-input.json index 94e3f8004d..a043137f28 100644 --- a/tests/db_migrator_input/config_db/non-default-lossless-profile-in-pg-input.json +++ b/tests/db_migrator_input/config_db/non-default-lossless-profile-in-pg-input.json @@ -956,6 +956,7 @@ "hwsku": "ACS-MSN4700", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "region": "None", "hostname": "sonic", "platform": "x86_64-mlnx_msn4700-r0", diff --git a/tests/db_migrator_input/config_db/non-default-lossy-profile-in-pg-expected.json b/tests/db_migrator_input/config_db/non-default-lossy-profile-in-pg-expected.json index f42708ea49..fd8550953e 100644 --- a/tests/db_migrator_input/config_db/non-default-lossy-profile-in-pg-expected.json +++ b/tests/db_migrator_input/config_db/non-default-lossy-profile-in-pg-expected.json @@ -954,6 +954,7 @@ "hwsku": "ACS-MSN4700", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "region": "None", "hostname": "sonic", "platform": "x86_64-mlnx_msn4700-r0", @@ -2042,6 +2043,6 @@ "admin_status": "up" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/non-default-lossy-profile-in-pg-input.json b/tests/db_migrator_input/config_db/non-default-lossy-profile-in-pg-input.json index 85d5da7ea8..e6c28d0c1d 100644 --- a/tests/db_migrator_input/config_db/non-default-lossy-profile-in-pg-input.json +++ b/tests/db_migrator_input/config_db/non-default-lossy-profile-in-pg-input.json @@ -954,6 +954,7 @@ "hwsku": "ACS-MSN4700", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "region": "None", "hostname": "sonic", "platform": "x86_64-mlnx_msn4700-r0", diff --git a/tests/db_migrator_input/config_db/non-default-pg-expected.json b/tests/db_migrator_input/config_db/non-default-pg-expected.json index efa881e34d..2a0aa78699 100644 --- a/tests/db_migrator_input/config_db/non-default-pg-expected.json +++ b/tests/db_migrator_input/config_db/non-default-pg-expected.json @@ -952,6 +952,7 @@ "hwsku": "ACS-MSN4700", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "region": "None", "hostname": "sonic", "platform": "x86_64-mlnx_msn4700-r0", @@ -2040,6 +2041,6 @@ "admin_status": "up" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/non-default-pg-input.json b/tests/db_migrator_input/config_db/non-default-pg-input.json index 87c8d59a0c..0592451717 100644 --- a/tests/db_migrator_input/config_db/non-default-pg-input.json +++ b/tests/db_migrator_input/config_db/non-default-pg-input.json @@ -952,6 +952,7 @@ "hwsku": "ACS-MSN4700", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "region": "None", "hostname": "sonic", "platform": "x86_64-mlnx_msn4700-r0", diff --git a/tests/db_migrator_input/config_db/non-default-xoff-expected.json b/tests/db_migrator_input/config_db/non-default-xoff-expected.json index 0d762a5baa..29075900f7 100644 --- a/tests/db_migrator_input/config_db/non-default-xoff-expected.json +++ b/tests/db_migrator_input/config_db/non-default-xoff-expected.json @@ -990,6 +990,7 @@ "buffer_model": "traditional", "cloudtype": "None", "type": "ToRRouter", + "synchronous_mode": "enable", "deployment_id": "1" }, "PORT|Ethernet0": { @@ -2049,6 +2050,6 @@ "admin_status": "up" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/non-default-xoff-input.json b/tests/db_migrator_input/config_db/non-default-xoff-input.json index aa9d8574ea..032e6112ac 100644 --- a/tests/db_migrator_input/config_db/non-default-xoff-input.json +++ b/tests/db_migrator_input/config_db/non-default-xoff-input.json @@ -989,6 +989,7 @@ "bgp_asn": "65100", "cloudtype": "None", "type": "ToRRouter", + "synchronous_mode": "enable", "deployment_id": "1" }, "PORT|Ethernet0": { diff --git a/tests/db_migrator_input/config_db/port-an-expected.json b/tests/db_migrator_input/config_db/port-an-expected.json index 1f3a461206..1ef2cf4916 100644 --- a/tests/db_migrator_input/config_db/port-an-expected.json +++ b/tests/db_migrator_input/config_db/port-an-expected.json @@ -35,6 +35,6 @@ "fec": "none" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_1" + "VERSION": "version_3_0_1" } } diff --git a/tests/db_migrator_input/config_db/port-an-input.json b/tests/db_migrator_input/config_db/port-an-input.json index 373c9ae989..6cda388135 100644 --- a/tests/db_migrator_input/config_db/port-an-input.json +++ b/tests/db_migrator_input/config_db/port-an-input.json @@ -34,6 +34,6 @@ "fec": "none" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_0" + "VERSION": "version_3_0_0" } } \ No newline at end of file diff --git a/tests/db_migrator_input/config_db/portchannel-expected.json b/tests/db_migrator_input/config_db/portchannel-expected.json index acc61d1316..2644e5f4e9 100644 --- a/tests/db_migrator_input/config_db/portchannel-expected.json +++ b/tests/db_migrator_input/config_db/portchannel-expected.json @@ -33,7 +33,7 @@ "lacp_key": "auto" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_2" + "VERSION": "version_3_0_2" } } diff --git a/tests/db_migrator_input/config_db/portchannel-input.json b/tests/db_migrator_input/config_db/portchannel-input.json index 5a890755a0..753a88601d 100644 --- a/tests/db_migrator_input/config_db/portchannel-input.json +++ b/tests/db_migrator_input/config_db/portchannel-input.json @@ -28,6 +28,6 @@ "mtu": "9100" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_1" + "VERSION": "version_3_0_1" } } diff --git a/tests/db_migrator_input/config_db/qos_map_table_expected.json b/tests/db_migrator_input/config_db/qos_map_table_expected.json index 946f7f02d9..47381ec550 100644 --- a/tests/db_migrator_input/config_db/qos_map_table_expected.json +++ b/tests/db_migrator_input/config_db/qos_map_table_expected.json @@ -1,36 +1,34 @@ { "VERSIONS|DATABASE": { - "VERSION": "version_2_0_5" + "VERSION": "version_3_0_5" }, - "PORT_QOS_MAP": { - "Ethernet0": { - "dscp_to_tc_map": "[DSCP_TO_TC_MAP|AZURE]", - "pfc_enable": "3,4", - "pfcwd_sw_enable": "3,4", - "pfc_to_queue_map": "[MAP_PFC_PRIORITY_TO_QUEUE|AZURE]", - "tc_to_pg_map": "[TC_TO_PRIORITY_GROUP_MAP|AZURE]", - "tc_to_queue_map": "[TC_TO_QUEUE_MAP|AZURE]" - }, - "Ethernet100": { - "dscp_to_tc_map": "[DSCP_TO_TC_MAP|AZURE]", - "pfc_enable": "3,4", - "pfcwd_sw_enable": "3,4", - "pfc_to_queue_map": "[MAP_PFC_PRIORITY_TO_QUEUE|AZURE]", - "tc_to_pg_map": "[TC_TO_PRIORITY_GROUP_MAP|AZURE]", - "tc_to_queue_map": "[TC_TO_QUEUE_MAP|AZURE]" - }, - "Ethernet92": { - "dscp_to_tc_map": "[DSCP_TO_TC_MAP|AZURE]", - "pfc_to_queue_map": "[MAP_PFC_PRIORITY_TO_QUEUE|AZURE]", - "tc_to_pg_map": "[TC_TO_PRIORITY_GROUP_MAP|AZURE]", - "tc_to_queue_map": "[TC_TO_QUEUE_MAP|AZURE]" - }, - "Ethernet96": { - "dscp_to_tc_map": "[DSCP_TO_TC_MAP|AZURE]", - "pfc_to_queue_map": "[MAP_PFC_PRIORITY_TO_QUEUE|AZURE]", - "tc_to_pg_map": "[TC_TO_PRIORITY_GROUP_MAP|AZURE]", - "tc_to_queue_map": "[TC_TO_QUEUE_MAP|AZURE]" - } + "PORT_QOS_MAP|Ethernet0": { + "dscp_to_tc_map": "AZURE", + "pfc_enable": "3,4", + "pfcwd_sw_enable": "3,4", + "pfc_to_queue_map": "AZURE", + "tc_to_pg_map": "AZURE", + "tc_to_queue_map": "AZURE" + }, + "PORT_QOS_MAP|Ethernet100": { + "dscp_to_tc_map": "AZURE", + "pfc_enable": "3,4", + "pfcwd_sw_enable": "3,4", + "pfc_to_queue_map": "AZURE", + "tc_to_pg_map": "AZURE", + "tc_to_queue_map": "AZURE" + }, + "PORT_QOS_MAP|Ethernet92": { + "dscp_to_tc_map": "AZURE", + "pfc_to_queue_map": "AZURE", + "tc_to_pg_map": "AZURE", + "tc_to_queue_map": "AZURE" + }, + "PORT_QOS_MAP|Ethernet96": { + "dscp_to_tc_map": "AZURE", + "pfc_to_queue_map": "AZURE", + "tc_to_pg_map": "AZURE", + "tc_to_queue_map": "AZURE" } } diff --git a/tests/db_migrator_input/config_db/qos_map_table_global_expected.json b/tests/db_migrator_input/config_db/qos_map_table_global_expected.json new file mode 100644 index 0000000000..db2096144f --- /dev/null +++ b/tests/db_migrator_input/config_db/qos_map_table_global_expected.json @@ -0,0 +1,12 @@ +{ + "VERSIONS|DATABASE": { + "VERSION": "version_2_0_1" + }, + "DSCP_TO_TC_MAP|AZURE": { + "0": "0", + "1": "1" + }, + "PORT_QOS_MAP|global": { + "dscp_to_tc_map": "AZURE" + } +} diff --git a/tests/db_migrator_input/config_db/qos_map_table_global_input.json b/tests/db_migrator_input/config_db/qos_map_table_global_input.json new file mode 100644 index 0000000000..dd4b78bb0e --- /dev/null +++ b/tests/db_migrator_input/config_db/qos_map_table_global_input.json @@ -0,0 +1,10 @@ +{ + "VERSIONS|DATABASE": { + "VERSION": "version_2_0_0" + }, + "DSCP_TO_TC_MAP|AZURE": { + "0": "0", + "1": "1" + } +} + diff --git a/tests/db_migrator_input/config_db/qos_map_table_input.json b/tests/db_migrator_input/config_db/qos_map_table_input.json index c7dbce9658..c62e293daf 100644 --- a/tests/db_migrator_input/config_db/qos_map_table_input.json +++ b/tests/db_migrator_input/config_db/qos_map_table_input.json @@ -1,34 +1,31 @@ { "VERSIONS|DATABASE": { - "VERSION": "version_2_0_4" + "VERSION": "version_3_0_4" }, - "PORT_QOS_MAP": { - "Ethernet0": { - "dscp_to_tc_map": "[DSCP_TO_TC_MAP|AZURE]", - "pfc_enable": "3,4", - "pfc_to_queue_map": "[MAP_PFC_PRIORITY_TO_QUEUE|AZURE]", - "tc_to_pg_map": "[TC_TO_PRIORITY_GROUP_MAP|AZURE]", - "tc_to_queue_map": "[TC_TO_QUEUE_MAP|AZURE]" - }, - "Ethernet100": { - "dscp_to_tc_map": "[DSCP_TO_TC_MAP|AZURE]", - "pfc_enable": "3,4", - "pfc_to_queue_map": "[MAP_PFC_PRIORITY_TO_QUEUE|AZURE]", - "tc_to_pg_map": "[TC_TO_PRIORITY_GROUP_MAP|AZURE]", - "tc_to_queue_map": "[TC_TO_QUEUE_MAP|AZURE]" - }, - "Ethernet92": { - "dscp_to_tc_map": "[DSCP_TO_TC_MAP|AZURE]", - "pfc_to_queue_map": "[MAP_PFC_PRIORITY_TO_QUEUE|AZURE]", - "tc_to_pg_map": "[TC_TO_PRIORITY_GROUP_MAP|AZURE]", - "tc_to_queue_map": "[TC_TO_QUEUE_MAP|AZURE]" - }, - "Ethernet96": { - "dscp_to_tc_map": "[DSCP_TO_TC_MAP|AZURE]", - "pfc_to_queue_map": "[MAP_PFC_PRIORITY_TO_QUEUE|AZURE]", - "tc_to_pg_map": "[TC_TO_PRIORITY_GROUP_MAP|AZURE]", - "tc_to_queue_map": "[TC_TO_QUEUE_MAP|AZURE]" - } + "PORT_QOS_MAP|Ethernet0": { + "dscp_to_tc_map": "AZURE", + "pfc_enable": "3,4", + "pfc_to_queue_map": "AZURE", + "tc_to_pg_map": "AZURE", + "tc_to_queue_map": "AZURE" + }, + "PORT_QOS_MAP|Ethernet100": { + "dscp_to_tc_map": "AZURE", + "pfc_enable": "3,4", + "pfc_to_queue_map": "AZURE", + "tc_to_pg_map": "AZURE", + "tc_to_queue_map": "AZURE" + }, + "PORT_QOS_MAP|Ethernet92": { + "dscp_to_tc_map": "AZURE", + "pfc_to_queue_map": "AZURE", + "tc_to_pg_map": "AZURE", + "tc_to_queue_map": "AZURE" + }, + "PORT_QOS_MAP|Ethernet96": { + "dscp_to_tc_map": "AZURE", + "pfc_to_queue_map": "AZURE", + "tc_to_pg_map": "AZURE", + "tc_to_queue_map": "AZURE" } } - diff --git a/tests/db_migrator_input/config_db/qos_tables_db_field_value_reference_format_2_0_1.json b/tests/db_migrator_input/config_db/qos_tables_db_field_value_reference_format_3_0_1.json similarity index 99% rename from tests/db_migrator_input/config_db/qos_tables_db_field_value_reference_format_2_0_1.json rename to tests/db_migrator_input/config_db/qos_tables_db_field_value_reference_format_3_0_1.json index 4b14ad7568..b252cba1dd 100644 --- a/tests/db_migrator_input/config_db/qos_tables_db_field_value_reference_format_2_0_1.json +++ b/tests/db_migrator_input/config_db/qos_tables_db_field_value_reference_format_3_0_1.json @@ -1050,7 +1050,8 @@ "hwsku": "DellEMC-Z9264f-C64", "mac": "50:9a:4c:d3:86:70", "platform": "x86_64-dellemc_z9264f_c3538-r0", - "type": "LeafRouter" + "type": "LeafRouter", + "synchronous_mode": "enable" } }, "DSCP_TO_TC_MAP": { @@ -3682,7 +3683,7 @@ } }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_1" + "VERSION": "version_3_0_1" }, "WRED_PROFILE": { "AZURE_LOSSLESS": { diff --git a/tests/db_migrator_input/config_db/qos_tables_db_field_value_reference_format_2_0_3.json b/tests/db_migrator_input/config_db/qos_tables_db_field_value_reference_format_3_0_3.json similarity index 99% rename from tests/db_migrator_input/config_db/qos_tables_db_field_value_reference_format_2_0_3.json rename to tests/db_migrator_input/config_db/qos_tables_db_field_value_reference_format_3_0_3.json index 9d22794dc2..1f4390a9c4 100644 --- a/tests/db_migrator_input/config_db/qos_tables_db_field_value_reference_format_2_0_3.json +++ b/tests/db_migrator_input/config_db/qos_tables_db_field_value_reference_format_3_0_3.json @@ -1050,7 +1050,8 @@ "hwsku": "DellEMC-Z9264f-C64", "mac": "50:9a:4c:d3:86:70", "platform": "x86_64-dellemc_z9264f_c3538-r0", - "type": "LeafRouter" + "type": "LeafRouter", + "synchronous_mode": "enable" } }, "DSCP_TO_TC_MAP": { @@ -3692,7 +3693,7 @@ } }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" }, "WRED_PROFILE": { "AZURE_LOSSLESS": { diff --git a/tests/db_migrator_input/config_db/reclaiming-buffer-dynamic-double-pools-expected.json b/tests/db_migrator_input/config_db/reclaiming-buffer-dynamic-double-pools-expected.json index 03b21b7d4c..a5126017bf 100644 --- a/tests/db_migrator_input/config_db/reclaiming-buffer-dynamic-double-pools-expected.json +++ b/tests/db_migrator_input/config_db/reclaiming-buffer-dynamic-double-pools-expected.json @@ -199,6 +199,7 @@ "hwsku": "Mellanox-SN2700", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", @@ -284,6 +285,6 @@ "description": "Servers6:eth0" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } } diff --git a/tests/db_migrator_input/config_db/reclaiming-buffer-dynamic-double-pools-input.json b/tests/db_migrator_input/config_db/reclaiming-buffer-dynamic-double-pools-input.json index 7d059812f5..df58b4e54b 100644 --- a/tests/db_migrator_input/config_db/reclaiming-buffer-dynamic-double-pools-input.json +++ b/tests/db_migrator_input/config_db/reclaiming-buffer-dynamic-double-pools-input.json @@ -115,6 +115,7 @@ "hwsku": "Mellanox-SN2700", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", @@ -200,6 +201,6 @@ "description": "Servers6:eth0" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_2" + "VERSION": "version_3_0_2" } } diff --git a/tests/db_migrator_input/config_db/reclaiming-buffer-dynamic-single-pool-expected.json b/tests/db_migrator_input/config_db/reclaiming-buffer-dynamic-single-pool-expected.json index 52aeb07c93..7bd0dd25a0 100644 --- a/tests/db_migrator_input/config_db/reclaiming-buffer-dynamic-single-pool-expected.json +++ b/tests/db_migrator_input/config_db/reclaiming-buffer-dynamic-single-pool-expected.json @@ -195,6 +195,7 @@ "hwsku": "Mellanox-SN2700", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", @@ -280,6 +281,6 @@ "description": "Servers6:eth0" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } } diff --git a/tests/db_migrator_input/config_db/reclaiming-buffer-dynamic-single-pool-input.json b/tests/db_migrator_input/config_db/reclaiming-buffer-dynamic-single-pool-input.json index 3ec46e9c63..b2ea5f52c3 100644 --- a/tests/db_migrator_input/config_db/reclaiming-buffer-dynamic-single-pool-input.json +++ b/tests/db_migrator_input/config_db/reclaiming-buffer-dynamic-single-pool-input.json @@ -111,6 +111,7 @@ "hwsku": "Mellanox-SN2700", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", @@ -196,6 +197,6 @@ "description": "Servers6:eth0" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_2" + "VERSION": "version_3_0_2" } } diff --git a/tests/db_migrator_input/config_db/reclaiming-buffer-traditional-double-pools-expected.json b/tests/db_migrator_input/config_db/reclaiming-buffer-traditional-double-pools-expected.json index 7b2b0d658d..d1537d3d3d 100644 --- a/tests/db_migrator_input/config_db/reclaiming-buffer-traditional-double-pools-expected.json +++ b/tests/db_migrator_input/config_db/reclaiming-buffer-traditional-double-pools-expected.json @@ -258,6 +258,7 @@ "hwsku": "Mellanox-SN2700", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", @@ -343,6 +344,6 @@ "description": "Servers6:eth0" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } } diff --git a/tests/db_migrator_input/config_db/reclaiming-buffer-traditional-double-pools-input.json b/tests/db_migrator_input/config_db/reclaiming-buffer-traditional-double-pools-input.json index a7832fe14d..35fc6a6a92 100644 --- a/tests/db_migrator_input/config_db/reclaiming-buffer-traditional-double-pools-input.json +++ b/tests/db_migrator_input/config_db/reclaiming-buffer-traditional-double-pools-input.json @@ -150,6 +150,7 @@ "hwsku": "Mellanox-SN2700", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", @@ -235,6 +236,6 @@ "description": "Servers6:eth0" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_2" + "VERSION": "version_3_0_2" } } diff --git a/tests/db_migrator_input/config_db/reclaiming-buffer-traditional-single-pool-expected.json b/tests/db_migrator_input/config_db/reclaiming-buffer-traditional-single-pool-expected.json index 557072bd86..4c1518c43a 100644 --- a/tests/db_migrator_input/config_db/reclaiming-buffer-traditional-single-pool-expected.json +++ b/tests/db_migrator_input/config_db/reclaiming-buffer-traditional-single-pool-expected.json @@ -253,6 +253,7 @@ "hwsku": "Mellanox-SN2700", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", @@ -338,6 +339,6 @@ "description": "Servers6:eth0" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_3" + "VERSION": "version_3_0_3" } } diff --git a/tests/db_migrator_input/config_db/reclaiming-buffer-traditional-single-pool-input.json b/tests/db_migrator_input/config_db/reclaiming-buffer-traditional-single-pool-input.json index 85f50fe3a3..408afb409e 100644 --- a/tests/db_migrator_input/config_db/reclaiming-buffer-traditional-single-pool-input.json +++ b/tests/db_migrator_input/config_db/reclaiming-buffer-traditional-single-pool-input.json @@ -150,6 +150,7 @@ "hwsku": "Mellanox-SN2700", "default_bgp_status": "up", "type": "ToRRouter", + "synchronous_mode": "enable", "hostname": "sonic", "platform": "x86_64-mlnx_msn2700-r0", "mac": "00:01:02:03:04:00", @@ -235,6 +236,6 @@ "description": "Servers6:eth0" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_2" + "VERSION": "version_3_0_2" } } diff --git a/tests/db_migrator_input/config_db/reclaiming-buffer-warmreboot-expected.json b/tests/db_migrator_input/config_db/reclaiming-buffer-warmreboot-expected.json index 09d6fc8c77..ea1291e815 100644 --- a/tests/db_migrator_input/config_db/reclaiming-buffer-warmreboot-expected.json +++ b/tests/db_migrator_input/config_db/reclaiming-buffer-warmreboot-expected.json @@ -952,6 +952,7 @@ "hwsku": "ACS-MSN4700", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "region": "None", "hostname": "sonic", "platform": "x86_64-mlnx_msn4700-r0", @@ -2043,6 +2044,6 @@ "admin_status": "up" }, "VERSIONS|DATABASE": { - "VERSION": "version_2_0_4" + "VERSION": "version_3_0_5" } } diff --git a/tests/db_migrator_input/config_db/reclaiming-buffer-warmreboot-input.json b/tests/db_migrator_input/config_db/reclaiming-buffer-warmreboot-input.json index e8a44eb4ed..254af10b37 100644 --- a/tests/db_migrator_input/config_db/reclaiming-buffer-warmreboot-input.json +++ b/tests/db_migrator_input/config_db/reclaiming-buffer-warmreboot-input.json @@ -1047,6 +1047,7 @@ "hwsku": "ACS-MSN4700", "default_bgp_status": "up", "type": "LeafRouter", + "synchronous_mode": "enable", "region": "None", "hostname": "sonic", "platform": "x86_64-mlnx_msn4700-r0", diff --git a/tests/db_migrator_test.py b/tests/db_migrator_test.py index 96e139b934..efb7aef298 100644 --- a/tests/db_migrator_test.py +++ b/tests/db_migrator_test.py @@ -43,9 +43,9 @@ def setup_class(cls): cls.config_db_tables_to_verify = ['BUFFER_POOL', 'BUFFER_PROFILE', 'BUFFER_PG', 'DEFAULT_LOSSLESS_BUFFER_PARAMETER', 'LOSSLESS_TRAFFIC_PATTERN', 'VERSIONS', 'DEVICE_METADATA'] cls.appl_db_tables_to_verify = ['BUFFER_POOL_TABLE:*', 'BUFFER_PROFILE_TABLE:*', 'BUFFER_PG_TABLE:*', 'BUFFER_QUEUE:*', 'BUFFER_PORT_INGRESS_PROFILE_LIST:*', 'BUFFER_PORT_EGRESS_PROFILE_LIST:*'] cls.warm_reboot_from_version = 'version_1_0_6' - cls.warm_reboot_to_version = 'version_2_0_3' + cls.warm_reboot_to_version = 'version_3_0_3' - cls.version_list = ['version_1_0_1', 'version_1_0_2', 'version_1_0_3', 'version_1_0_4', 'version_1_0_5', 'version_1_0_6', 'version_2_0_0', 'version_2_0_3'] + cls.version_list = ['version_1_0_1', 'version_1_0_2', 'version_1_0_3', 'version_1_0_4', 'version_1_0_5', 'version_1_0_6', 'version_3_0_0', 'version_3_0_3'] os.environ['UTILITIES_UNIT_TESTING'] = "2" @classmethod @@ -211,7 +211,7 @@ def test_mellanox_buffer_reclaiming(self, buffer_model, ingress_pools): dbmgtr = db_migrator.DBMigrator(None) dbmgtr.migrate() expected_db = self.mock_dedicated_config_db(db_after_migrate) - advance_version_for_expected_database(dbmgtr.configDB, expected_db.cfgdb, 'version_2_0_3') + advance_version_for_expected_database(dbmgtr.configDB, expected_db.cfgdb, 'version_3_0_3') tables_to_verify = self.config_db_tables_to_verify tables_to_verify.extend(['BUFFER_QUEUE', 'BUFFER_PORT_INGRESS_PROFILE_LIST', 'BUFFER_PORT_EGRESS_PROFILE_LIST']) self.check_config_db(dbmgtr.configDB, expected_db.cfgdb, tables_to_verify) @@ -241,7 +241,7 @@ def test_port_autoneg_migrator(self): dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'config_db', 'port-an-expected') expected_db = Db() - advance_version_for_expected_database(dbmgtr.configDB, expected_db.cfgdb, 'version_2_0_1') + advance_version_for_expected_database(dbmgtr.configDB, expected_db.cfgdb, 'version_3_0_1') assert dbmgtr.configDB.get_table('PORT') == expected_db.cfgdb.get_table('PORT') assert dbmgtr.configDB.get_table('VERSIONS') == expected_db.cfgdb.get_table('VERSIONS') @@ -289,7 +289,7 @@ def test_lacp_key_migrator(self): dbmgtr.migrate() dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'config_db', 'portchannel-expected') expected_db = Db() - advance_version_for_expected_database(dbmgtr.configDB, expected_db.cfgdb, 'version_2_0_2') + advance_version_for_expected_database(dbmgtr.configDB, expected_db.cfgdb, 'version_3_0_2') assert dbmgtr.configDB.get_table('PORTCHANNEL') == expected_db.cfgdb.get_table('PORTCHANNEL') assert dbmgtr.configDB.get_table('VERSIONS') == expected_db.cfgdb.get_table('VERSIONS') @@ -335,8 +335,8 @@ def check_appl_db(self, result, expected): assert expected.get_all(expected.APPL_DB, key) == result.get_all(result.APPL_DB, key) def test_qos_buffer_migrator_for_cold_reboot(self): - db_before_migrate = 'qos_tables_db_field_value_reference_format_2_0_1' - db_after_migrate = 'qos_tables_db_field_value_reference_format_2_0_3' + db_before_migrate = 'qos_tables_db_field_value_reference_format_3_0_1' + db_after_migrate = 'qos_tables_db_field_value_reference_format_3_0_3' db = self.mock_dedicated_config_db(db_before_migrate) _ = self.mock_dedicated_appl_db(db_before_migrate) import db_migrator @@ -344,7 +344,8 @@ def test_qos_buffer_migrator_for_cold_reboot(self): dbmgtr.migrate() expected_db = self.mock_dedicated_config_db(db_after_migrate) expected_appl_db = self.mock_dedicated_appl_db(db_after_migrate) - advance_version_for_expected_database(dbmgtr.configDB, expected_db.cfgdb, 'version_2_0_3') + advance_version_for_expected_database(dbmgtr.configDB, expected_db.cfgdb, 'version_3_0_3') + self.check_config_db(dbmgtr.configDB, expected_db.cfgdb) self.check_appl_db(dbmgtr.appDB, expected_appl_db) self.clear_dedicated_mock_dbs() @@ -373,3 +374,107 @@ def test_pfc_enable_migrator(self): diff = DeepDiff(resulting_table, expected_table, ignore_order=True) assert not diff + +class TestGlobalDscpToTcMapMigrator(object): + @classmethod + def setup_class(cls): + os.environ['UTILITIES_UNIT_TESTING'] = "2" + + @classmethod + def teardown_class(cls): + os.environ['UTILITIES_UNIT_TESTING'] = "0" + dbconnector.dedicated_dbs['CONFIG_DB'] = None + + def test_global_dscp_to_tc_map_migrator(self): + dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'config_db', 'qos_map_table_global_input') + import db_migrator + dbmgtr = db_migrator.DBMigrator(None) + dbmgtr.asic_type = "broadcom" + dbmgtr.hwsku = "vs" + dbmgtr.migrate() + dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'config_db', 'qos_map_table_global_expected') + expected_db = Db() + + resulting_table = dbmgtr.configDB.get_table('PORT_QOS_MAP') + expected_table = expected_db.cfgdb.get_table('PORT_QOS_MAP') + + diff = DeepDiff(resulting_table, expected_table, ignore_order=True) + assert not diff + + # Check port_qos_map|global is not generated on mellanox asic + dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'config_db', 'qos_map_table_global_input') + dbmgtr_mlnx = db_migrator.DBMigrator(None) + dbmgtr_mlnx.asic_type = "mellanox" + dbmgtr_mlnx.hwsku = "vs" + dbmgtr_mlnx.migrate() + resulting_table = dbmgtr_mlnx.configDB.get_table('PORT_QOS_MAP') + assert resulting_table == {} + + +class TestWarmUpgrade_to_2_0_2(object): + @classmethod + def setup_class(cls): + os.environ['UTILITIES_UNIT_TESTING'] = "2" + + @classmethod + def teardown_class(cls): + os.environ['UTILITIES_UNIT_TESTING'] = "0" + dbconnector.dedicated_dbs['CONFIG_DB'] = None + + def test_warm_upgrade_to_2_0_2(self): + dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'config_db', 'cross_branch_upgrade_to_version_2_0_2_input') + import db_migrator + dbmgtr = db_migrator.DBMigrator(None) + dbmgtr.migrate() + dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'config_db', 'cross_branch_upgrade_to_version_2_0_2_expected') + expected_db = Db() + + expected_db + new_tables = ["RESTAPI", "TELEMETRY", "CONSOLE_SWITCH"] + for table in new_tables: + resulting_table = dbmgtr.configDB.get_table(table) + expected_table = expected_db.cfgdb.get_table(table) + diff = DeepDiff(resulting_table, expected_table, ignore_order=True) + assert not diff + +class Test_Migrate_Loopback(object): + @classmethod + def setup_class(cls): + os.environ['UTILITIES_UNIT_TESTING'] = "2" + + @classmethod + def teardown_class(cls): + os.environ['UTILITIES_UNIT_TESTING'] = "0" + dbconnector.dedicated_dbs['CONFIG_DB'] = None + dbconnector.dedicated_dbs['APPL_DB'] = None + + def test_migrate_loopback_int(self): + dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'config_db', 'loopback_interface_migrate_from_1_0_1_input') + dbconnector.dedicated_dbs['APPL_DB'] = os.path.join(mock_db_path, 'appl_db', 'loopback_interface_migrate_from_1_0_1_input') + + import db_migrator + dbmgtr = db_migrator.DBMigrator(None) + dbmgtr.migrate() + dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'config_db', 'loopback_interface_migrate_from_1_0_1_expected') + dbconnector.dedicated_dbs['APPL_DB'] = os.path.join(mock_db_path, 'appl_db', 'loopback_interface_migrate_from_1_0_1_expected') + expected_db = Db() + + # verify migrated configDB + resulting_table = dbmgtr.configDB.get_table("LOOPBACK_INTERFACE") + expected_table = expected_db.cfgdb.get_table("LOOPBACK_INTERFACE") + diff = DeepDiff(resulting_table, expected_table, ignore_order=True) + assert not diff + + # verify migrated appDB + expected_appl_db = SonicV2Connector(host='127.0.0.1') + expected_appl_db.connect(expected_appl_db.APPL_DB) + expected_keys = expected_appl_db.keys(expected_appl_db.APPL_DB, "INTF_TABLE:*") + expected_keys.sort() + resulting_keys = dbmgtr.appDB.keys(dbmgtr.appDB.APPL_DB, "INTF_TABLE:*") + resulting_keys.sort() + assert expected_keys == resulting_keys + for key in expected_keys: + resulting_keys = dbmgtr.appDB.get_all(dbmgtr.appDB.APPL_DB, key) + expected_keys = expected_appl_db.get_all(expected_appl_db.APPL_DB, key) + diff = DeepDiff(resulting_keys, expected_keys, ignore_order=True) + assert not diff diff --git a/tests/decode_syseeprom_test.py b/tests/decode_syseeprom_test.py index ae3801d369..50c7667453 100644 --- a/tests/decode_syseeprom_test.py +++ b/tests/decode_syseeprom_test.py @@ -192,3 +192,12 @@ def test_print_model(self, capsys): decode_syseeprom.print_model(True) captured = capsys.readouterr() assert captured.out == 'S6100-ON\n' + + @mock.patch('os.geteuid', lambda: 0) + @mock.patch('sonic_py_common.device_info.get_platform', lambda: 'arista') + @mock.patch('decode-syseeprom.read_and_print_eeprom') + @mock.patch('decode-syseeprom.read_eeprom_from_db') + def test_support_platforms_not_db_based(self, mockDbBased, mockNotDbBased): + decode_syseeprom.main() + assert mockNotDbBased.called + assert not mockDbBased.called diff --git a/tests/dump_tests/dump_state_test.py b/tests/dump_tests/dump_state_test.py index 8e3cda0c0e..06b1b9e423 100644 --- a/tests/dump_tests/dump_state_test.py +++ b/tests/dump_tests/dump_state_test.py @@ -25,21 +25,23 @@ def compare_json_output(exp_json, rec, exclude_paths=None): table_display_output = '''\ -+-------------+-----------+----------------------------------------------------------------------------+ -| port_name | DB_NAME | DUMP | -+=============+===========+============================================================================+ -| Ethernet0 | STATE_DB | +----------------------+-------------------------------------------------+ | -| | | | Keys | field-value pairs | | -| | | +======================+=================================================+ | -| | | | PORT_TABLE|Ethernet0 | +------------------+--------------------------+ | | -| | | | | | field | value | | | -| | | | | |------------------+--------------------------| | | -| | | | | | rmt_adv_speeds | 10,100,1000 | | | -| | | | | | speed | 100000 | | | -| | | | | | supported_speeds | 10000,25000,40000,100000 | | | -| | | | | +------------------+--------------------------+ | | -| | | +----------------------+-------------------------------------------------+ | -+-------------+-----------+----------------------------------------------------------------------------+ ++-------------+-----------+--------------------------------------------------------------------------------+ +| port_name | DB_NAME | DUMP | ++=============+===========+================================================================================+ +| Ethernet0 | STATE_DB | +----------------------+-----------------------------------------------------+ | +| | | | Keys | field-value pairs | | +| | | +======================+=====================================================+ | +| | | | PORT_TABLE|Ethernet0 | +----------------------+--------------------------+ | | +| | | | | | field | value | | | +| | | | | |----------------------+--------------------------| | | +| | | | | | rmt_adv_speeds | 10,100,1000 | | | +| | | | | | speed | 100000 | | | +| | | | | | supported_speeds | 10000,25000,40000,100000 | | | +| | | | | | supported_fecs | rs,none,test | | | +| | | | | | link_training_status | not_trained | | | +| | | | | +----------------------+--------------------------+ | | +| | | +----------------------+-----------------------------------------------------+ | ++-------------+-----------+--------------------------------------------------------------------------------+ ''' @@ -121,7 +123,7 @@ def test_identifier_single(self): expected = {'Ethernet0': {'CONFIG_DB': {'keys': [{'PORT|Ethernet0': {'alias': 'etp1', 'description': 'etp1', 'index': '0', 'lanes': '25,26,27,28', 'mtu': '9100', 'pfc_asym': 'off', 'speed': '40000'}}], 'tables_not_found': []}, 'APPL_DB': {'keys': [{'PORT_TABLE:Ethernet0': {'index': '0', 'lanes': '0', 'alias': 'Ethernet0', 'description': 'ARISTA01T2:Ethernet1', 'speed': '25000', 'oper_status': 'down', 'pfc_asym': 'off', 'mtu': '9100', 'fec': 'rs', 'admin_status': 'up'}}], 'tables_not_found': []}, 'ASIC_DB': {'keys': [{'ASIC_STATE:SAI_OBJECT_TYPE_HOSTIF:oid:0xd00000000056d': {'SAI_HOSTIF_ATTR_NAME': 'Ethernet0', 'SAI_HOSTIF_ATTR_OBJ_ID': 'oid:0x10000000004a4', 'SAI_HOSTIF_ATTR_OPER_STATUS': 'true', 'SAI_HOSTIF_ATTR_TYPE': 'SAI_HOSTIF_TYPE_NETDEV', 'SAI_HOSTIF_ATTR_VLAN_TAG': 'SAI_HOSTIF_VLAN_TAG_STRIP'}}, {'ASIC_STATE:SAI_OBJECT_TYPE_PORT:oid:0x10000000004a4': {'NULL': 'NULL', 'SAI_PORT_ATTR_ADMIN_STATE': 'true', 'SAI_PORT_ATTR_MTU': '9122', 'SAI_PORT_ATTR_SPEED': '100000'}}], 'tables_not_found': [], 'vidtorid': {'oid:0xd00000000056d': 'oid:0xd', 'oid:0x10000000004a4': 'oid:0x1690000000001'}}, - 'STATE_DB': {'keys': [{'PORT_TABLE|Ethernet0': {'rmt_adv_speeds': '10,100,1000', 'speed': '100000', 'supported_speeds': '10000,25000,40000,100000'}}], 'tables_not_found': []}}} + 'STATE_DB': {'keys': [{'PORT_TABLE|Ethernet0': {'rmt_adv_speeds': '10,100,1000', 'speed': '100000', 'supported_speeds': '10000,25000,40000,100000', 'supported_fecs': 'rs,none,test', 'link_training_status': 'not_trained'}}], 'tables_not_found': []}}} assert result.exit_code == 0, "exit code: {}, Exception: {}, Traceback: {}".format(result.exit_code, result.exception, result.exc_info) # Cause other tests depend and change these paths in the mock_db, this test would fail everytime when a field or a value in changed in this path, creating noise @@ -138,7 +140,7 @@ def test_identifier_multiple(self): {"CONFIG_DB": {"keys": [{"PORT|Ethernet0": {"alias": "etp1", "description": "etp1", "index": "0", "lanes": "25,26,27,28", "mtu": "9100", "pfc_asym": "off", "speed": "40000"}}], "tables_not_found": []}, "APPL_DB": {"keys": [{"PORT_TABLE:Ethernet0": {"index": "0", "lanes": "0", "alias": "Ethernet0", "description": "ARISTA01T2:Ethernet1", "speed": "25000", "oper_status": "down", "pfc_asym": "off", "mtu": "9100", "fec": "rs", "admin_status": "up"}}], "tables_not_found": []}, "ASIC_DB": {"keys": [{"ASIC_STATE:SAI_OBJECT_TYPE_HOSTIF:oid:0xd00000000056d": {"SAI_HOSTIF_ATTR_NAME": "Ethernet0", "SAI_HOSTIF_ATTR_OBJ_ID": "oid:0x10000000004a4", "SAI_HOSTIF_ATTR_OPER_STATUS": "true", "SAI_HOSTIF_ATTR_TYPE": "SAI_HOSTIF_TYPE_NETDEV", "SAI_HOSTIF_ATTR_VLAN_TAG": "SAI_HOSTIF_VLAN_TAG_STRIP"}}, {"ASIC_STATE:SAI_OBJECT_TYPE_PORT:oid:0x10000000004a4": {"NULL": "NULL", "SAI_PORT_ATTR_ADMIN_STATE": "true", "SAI_PORT_ATTR_MTU": "9122", "SAI_PORT_ATTR_SPEED": "100000"}}], "tables_not_found": [], "vidtorid": {"oid:0xd00000000056d": "oid:0xd", "oid:0x10000000004a4": "oid:0x1690000000001"}}, - "STATE_DB": {"keys": [{"PORT_TABLE|Ethernet0": {"rmt_adv_speeds": "10,100,1000", "speed": "100000", "supported_speeds": "10000,25000,40000,100000"}}], "tables_not_found": []}}, + "STATE_DB": {"keys": [{"PORT_TABLE|Ethernet0": {"rmt_adv_speeds": "10,100,1000", "speed": "100000", "supported_speeds": "10000,25000,40000,100000", "supported_fecs": "rs,none,test", "link_training_status": "not_trained"}}], "tables_not_found": []}}, "Ethernet4": {"CONFIG_DB": {"keys": [{"PORT|Ethernet4": {"admin_status": "up", "alias": "etp2", "description": "Servers0:eth0", "index": "1", "lanes": "29,30,31,32", "mtu": "9100", "pfc_asym": "off", "speed": "40000"}}], "tables_not_found": []}, "APPL_DB": {"keys": [], "tables_not_found": ["PORT_TABLE"]}, @@ -167,7 +169,7 @@ def test_option_db_filtering(self): result = runner.invoke(dump.state, ["port", "Ethernet0", "--db", "ASIC_DB", "--db", "STATE_DB"]) print(result.output) expected = {"Ethernet0": {"ASIC_DB": {"keys": [{"ASIC_STATE:SAI_OBJECT_TYPE_HOSTIF:oid:0xd00000000056d": {"SAI_HOSTIF_ATTR_NAME": "Ethernet0", "SAI_HOSTIF_ATTR_OBJ_ID": "oid:0x10000000004a4", "SAI_HOSTIF_ATTR_OPER_STATUS": "true", "SAI_HOSTIF_ATTR_TYPE": "SAI_HOSTIF_TYPE_NETDEV", "SAI_HOSTIF_ATTR_VLAN_TAG": "SAI_HOSTIF_VLAN_TAG_STRIP"}}, {"ASIC_STATE:SAI_OBJECT_TYPE_PORT:oid:0x10000000004a4": {"NULL": "NULL", "SAI_PORT_ATTR_ADMIN_STATE": "true", "SAI_PORT_ATTR_MTU": "9122", "SAI_PORT_ATTR_SPEED": "100000"}}], "tables_not_found": [], "vidtorid": {"oid:0xd00000000056d": "oid:0xd", "oid:0x10000000004a4": "oid:0x1690000000001"}}, - "STATE_DB": {"keys": [{"PORT_TABLE|Ethernet0": {"rmt_adv_speeds": "10,100,1000", "speed": "100000", "supported_speeds": "10000,25000,40000,100000"}}], "tables_not_found": []}}} + "STATE_DB": {"keys": [{"PORT_TABLE|Ethernet0": {"rmt_adv_speeds": "10,100,1000", "speed": "100000", "supported_speeds": "10000,25000,40000,100000", "supported_fecs": "rs,none,test", "link_training_status": "not_trained"}}], "tables_not_found": []}}} assert result.exit_code == 0, "exit code: {}, Exception: {}, Traceback: {}".format(result.exit_code, result.exception, result.exc_info) ddiff = compare_json_output(expected, result.output) assert not ddiff, ddiff diff --git a/tests/fabricstat_test.py b/tests/fabricstat_test.py new file mode 100644 index 0000000000..23bb37d2ed --- /dev/null +++ b/tests/fabricstat_test.py @@ -0,0 +1,142 @@ +import os +import shutil + +from click.testing import CliRunner + +import clear.main as clear +import show.main as show +from .utils import get_result_and_return_code + +root_path = os.path.dirname(os.path.abspath(__file__)) +modules_path = os.path.dirname(root_path) +scripts_path = os.path.join(modules_path, "scripts") + +multi_asic_fabric_counters = """\ + ASIC PORT STATE IN_CELL IN_OCTET OUT_CELL OUT_OCTET CRC FEC_CORRECTABLE FEC_UNCORRECTABLE SYMBOL_ERR +------ ------ ------- --------- ---------- ---------- ----------- ----- ----------------- ------------------- ------------ + 0 0 up 6 1113 0 0 0 5 1759692040 5 + 0 1 down 0 0 0 0 0 0 58977677898 0 + 0 2 up 2 371 0 0 0 0 1769448760 0 + 0 3 down 0 0 0 0 0 0 58976477608 0 + 0 4 up 10 1855 0 0 0 73 1763293100 73 + 0 5 down 0 0 0 0 0 44196 58975150569 0 + 0 6 up 4 742 0 0 0 10 1763174090 0 + 0 7 up 10 1855 0 0 0 187 1768439529 1331 + + ASIC PORT STATE IN_CELL IN_OCTET OUT_CELL OUT_OCTET CRC FEC_CORRECTABLE FEC_UNCORRECTABLE SYMBOL_ERR +------ ------ ------- --------- ---------- ---------- ----------- ----- ----------------- ------------------- ------------ + 1 0 up 16 2968 0 0 0 0 1763890500 0 + 1 1 down 0 0 0 0 0 0 105269481425 0 + 1 2 down 0 0 0 0 0 0 105268895944 0 + 1 3 down 0 0 0 0 0 0 105268290607 0 + 1 4 up 14 2597 0 0 0 0 1762188940 0 + 1 5 down 0 0 0 0 0 968 105267020477 0 + 1 6 down 0 0 0 0 0 53192703023 1422986 41913682074 + 1 7 down 0 0 0 0 0 0 105264567398 0 + +""" +multi_asic_fabric_counters_asic0 = """\ + ASIC PORT STATE IN_CELL IN_OCTET OUT_CELL OUT_OCTET CRC FEC_CORRECTABLE FEC_UNCORRECTABLE SYMBOL_ERR +------ ------ ------- --------- ---------- ---------- ----------- ----- ----------------- ------------------- ------------ + 0 0 up 6 1113 0 0 0 5 1759692040 5 + 0 1 down 0 0 0 0 0 0 58977677898 0 + 0 2 up 2 371 0 0 0 0 1769448760 0 + 0 3 down 0 0 0 0 0 0 58976477608 0 + 0 4 up 10 1855 0 0 0 73 1763293100 73 + 0 5 down 0 0 0 0 0 44196 58975150569 0 + 0 6 up 4 742 0 0 0 10 1763174090 0 + 0 7 up 10 1855 0 0 0 187 1768439529 1331 + +""" + +fabric_invalid_asic_error = """ValueError: Unknown Namespace asic99""" + +multi_asic_fabric_counters_queue = """\ + ASIC PORT STATE QUEUE_ID CURRENT_BYTE CURRENT_LEVEL WATERMARK_LEVEL +------ ------ ------- ---------- -------------- --------------- ----------------- + 0 0 up 0 763 12 20 + 0 1 down 0 0 0 0 + 0 2 up 0 104 8 8 + 0 3 down 0 0 0 0 + 0 4 up 0 1147 14 22 + 0 5 down 0 0 0 0 + 0 6 up 0 527 8 10 + 0 7 up 0 1147 14 17 + + ASIC PORT STATE QUEUE_ID CURRENT_BYTE CURRENT_LEVEL WATERMARK_LEVEL +------ ------ ------- ---------- -------------- --------------- ----------------- + 1 0 up 0 1942 18 24 + 1 1 down 0 0 0 0 + 1 2 down 0 0 0 0 + 1 3 down 0 0 0 0 + 1 4 up 0 1362 15 24 + 1 5 down 0 0 0 0 + 1 6 down 0 0 0 0 + 1 7 down 0 0 0 0 + +""" + +multi_asic_fabric_counters_queue_asic0 = """\ + ASIC PORT STATE QUEUE_ID CURRENT_BYTE CURRENT_LEVEL WATERMARK_LEVEL +------ ------ ------- ---------- -------------- --------------- ----------------- + 0 0 up 0 763 12 20 + 0 1 down 0 0 0 0 + 0 2 up 0 104 8 8 + 0 3 down 0 0 0 0 + 0 4 up 0 1147 14 22 + 0 5 down 0 0 0 0 + 0 6 up 0 527 8 10 + 0 7 up 0 1147 14 17 + +""" + +class TestMultiAsicFabricStat(object): + @classmethod + def setup_class(cls): + print("SETUP") + os.environ["PATH"] += os.pathsep + scripts_path + os.environ["UTILITIES_UNIT_TESTING"] = "2" + os.environ["UTILITIES_UNIT_TESTING_TOPOLOGY"] = "multi_asic" + + def test_multi_show_fabric_counters(self): + return_code, result = get_result_and_return_code('fabricstat') + print("return_code: {}".format(return_code)) + print("result = {}".format(result)) + assert return_code == 0 + assert result == multi_asic_fabric_counters + + def test_multi_show_fabric_counters_asic(self): + return_code, result = get_result_and_return_code('fabricstat -n asic0') + print("return_code: {}".format(return_code)) + print("result = {}".format(result)) + assert return_code == 0 + assert result == multi_asic_fabric_counters_asic0 + + def test_multi_asic_invalid_asic(self): + return_code, result = get_result_and_return_code('fabricstat -n asic99') + print("return_code: {}".format(return_code)) + print("result = {}".format(result)) + assert return_code == 1 + assert result == fabric_invalid_asic_error + + def test_multi_show_fabric_counters_queue(self): + return_code, result = get_result_and_return_code('fabricstat -q') + print("return_code: {}".format(return_code)) + print("result = {}".format(result)) + assert return_code == 0 + assert result == multi_asic_fabric_counters_queue + + def test_multi_show_fabric_counters_queue_asic(self): + return_code, result = get_result_and_return_code('fabricstat -q -n asic0') + print("return_code: {}".format(return_code)) + print("result = {}".format(result)) + assert return_code == 0 + assert result == multi_asic_fabric_counters_queue_asic0 + + @classmethod + def teardown_class(cls): + print("TEARDOWN") + os.environ["PATH"] = os.pathsep.join( + os.environ["PATH"].split(os.pathsep)[:-1]) + os.environ["UTILITIES_UNIT_TESTING"] = "0" + os.environ["UTILITIES_UNIT_TESTING_TOPOLOGY"] = "" diff --git a/tests/feature_test.py b/tests/feature_test.py index 8891d07a12..2f3c6e60bf 100644 --- a/tests/feature_test.py +++ b/tests/feature_test.py @@ -127,6 +127,32 @@ telemetry enabled """ +show_feature_autorestart_missing_output="""\ +Feature AutoRestart +---------- -------------- +bar unknown +bgp enabled +database always_enabled +dhcp_relay enabled +lldp enabled +nat enabled +pmon enabled +radv enabled +restapi enabled +sflow enabled +snmp enabled +swss enabled +syncd enabled +teamd enabled +telemetry enabled +""" + +show_feature_autorestart_bar_missing_output="""\ +Feature AutoRestart +--------- ------------- +bar unknown +""" + show_feature_bgp_autorestart_output="""\ Feature AutoRestart --------- ------------- @@ -274,6 +300,25 @@ def test_show_unknown_autorestart_status(self, get_cmd_module): print(result.output) assert result.exit_code == 1 + def test_show_feature_autorestart_missing(self, get_cmd_module): + (config, show) = get_cmd_module + db = Db() + dbconn = db.db + db.cfgdb.set_entry("FEATURE", "bar", { "state": "enabled" }) + runner = CliRunner() + + result = runner.invoke(show.cli.commands["feature"].commands["autorestart"], obj=db) + print(result.exit_code) + print(result.output) + assert result.exit_code == 0 + assert result.output == show_feature_autorestart_missing_output + + result = runner.invoke(show.cli.commands["feature"].commands["autorestart"], ["bar"], obj=db) + print(result.exit_code) + print(result.output) + assert result.exit_code == 0 + assert result.output == show_feature_autorestart_bar_missing_output + def test_config_bgp_feature_state(self, get_cmd_module): (config, show) = get_cmd_module db = Db() diff --git a/tests/generic_config_updater/change_applier_test.py b/tests/generic_config_updater/change_applier_test.py index 63944b2571..afe166b008 100644 --- a/tests/generic_config_updater/change_applier_test.py +++ b/tests/generic_config_updater/change_applier_test.py @@ -281,6 +281,7 @@ def test_apply__calls_apply_change_to_config_db(self): # Act applier.apply(change) + applier.remove_backend_tables_from_config(change) # Assert applier.config_wrapper.apply_change_to_config_db.assert_has_calls([call(change)]) diff --git a/tests/generic_config_updater/files/config_db_with_port_critical.json b/tests/generic_config_updater/files/config_db_with_port_critical.json index 5853bfe5ea..2b2007d068 100644 --- a/tests/generic_config_updater/files/config_db_with_port_critical.json +++ b/tests/generic_config_updater/files/config_db_with_port_critical.json @@ -36,6 +36,23 @@ "lanes": "41,42,43,44", "pfc_asym": "off", "speed": "40000" + }, + "Ethernet28": { + "alias": "fortyGigE0/28", + "description": "Servers5:eth0", + "index": "6", + "lanes": "53,54,55,56", + "pfc_asym": "off", + "speed": "40000" + }, + "Ethernet32": { + "alias": "fortyGigE0/32", + "description": "Servers6:eth0", + "index": "7", + "lanes": "57,58,59,60", + "mtu": "9100", + "pfc_asym": "off", + "speed": "40000" } }, "BUFFER_PG": { @@ -44,6 +61,9 @@ }, "Ethernet12|0": { "profile": "ingress_lossy_profile" + }, + "Ethernet28|0": { + "profile": "ingress_lossy_profile" } } } diff --git a/tests/generic_config_updater/files/config_db_with_profile_list.json b/tests/generic_config_updater/files/config_db_with_profile_list.json new file mode 100644 index 0000000000..00195433b6 --- /dev/null +++ b/tests/generic_config_updater/files/config_db_with_profile_list.json @@ -0,0 +1,42 @@ +{ + "BUFFER_POOL": { + "egress_lossless_pool": { + "mode": "static", + "size": "33004032", + "xoff": "196608", + "type": "egress" + }, + "egress_lossy_pool": { + "size": "12766208", + "type": "egress", + "mode": "dynamic" + } + }, + "BUFFER_PROFILE": { + "egress_lossless_profile": { + "pool":"egress_lossless_pool", + "size":"1518", + "dynamic_th":"3" + }, + "egress_lossy_profile": { + "pool":"egress_lossy_pool", + "size":"1518", + "dynamic_th":"3" + } + }, + "BUFFER_PORT_EGRESS_PROFILE_LIST": { + "Ethernet9": { + "profile_list": "egress_lossless_profile,egress_lossy_profile" + } + }, + "PORT": { + "Ethernet9": { + "alias": "Eth3/2", + "lanes": "74", + "description": "", + "speed": "11100", + "tpid": "0x8100", + "admin_status": "up" + } + } +} \ No newline at end of file diff --git a/tests/generic_config_updater/files/config_db_with_type1_tables.json b/tests/generic_config_updater/files/config_db_with_type1_tables.json new file mode 100644 index 0000000000..c1f2d3e389 --- /dev/null +++ b/tests/generic_config_updater/files/config_db_with_type1_tables.json @@ -0,0 +1,22 @@ +{ + "DOT1P_TO_TC_MAP": { + "Dot1p_to_tc_map1": { + "1": "1", + "2": "2" + }, + "Dot1p_to_tc_map2": { + "3": "3", + "4": "4" + } + }, + "EXP_TO_FC_MAP": { + "Exp_to_fc_map1": { + "1": "1", + "2": "2" + }, + "Exp_to_fc_map2": { + "3": "3", + "4": "4" + } + } +} \ No newline at end of file diff --git a/tests/generic_config_updater/files/patch_sorter_test_success.json b/tests/generic_config_updater/files/patch_sorter_test_success.json index 74cb4ed728..217737e412 100644 --- a/tests/generic_config_updater/files/patch_sorter_test_success.json +++ b/tests/generic_config_updater/files/patch_sorter_test_success.json @@ -574,38 +574,6 @@ } ], "expected_changes": [ - [ - { - "op": "remove", - "path": "/LOOPBACK_INTERFACE/Loopback0|10.1.0.32~132" - } - ], - [ - { - "op": "remove", - "path": "/LOOPBACK_INTERFACE/Loopback0|1100:1::32~1128" - } - ], - [ - { - "op": "add", - "path": "/LOOPBACK_INTERFACE/Loopback0|10.1.0.32~132", - "value": {} - } - ], - [ - { - "op": "remove", - "path": "/LOOPBACK_INTERFACE/Loopback1|20.2.0.32~132" - } - ], - [ - { - "op": "add", - "path": "/LOOPBACK_INTERFACE/Loopback0|1100:1::32~1128", - "value": {} - } - ], [ { "op": "remove", @@ -646,13 +614,6 @@ "path": "/LOOPBACK_INTERFACE/Loopback0|1100:1::32~1128", "value": {} } - ], - [ - { - "op": "add", - "path": "/LOOPBACK_INTERFACE/Loopback1|20.2.0.32~132", - "value": {} - } ] ] }, @@ -809,51 +770,12 @@ "path": "/ACL_TABLE/NO-NSW-PACL-V4/ports" } ], - [ - { - "op": "remove", - "path": "/ACL_TABLE" - } - ], - [ - { - "op": "add", - "path": "/ACL_TABLE", - "value": { - "NO-NSW-PACL-V4": { - "type": "L3" - } - } - } - ], - [ - { - "op": "add", - "path": "/ACL_TABLE/NO-NSW-PACL-V4/ports", - "value": [ - "Ethernet0" - ] - } - ], [ { "op": "remove", "path": "/VLAN_MEMBER" } ], - [ - { - "op": "add", - "path": "/ACL_TABLE/NO-NSW-PACL-V4/policy_desc", - "value": "NO-NSW-PACL-V4" - } - ], - [ - { - "op": "remove", - "path": "/ACL_TABLE/NO-NSW-PACL-V4/ports" - } - ], [ { "op": "remove", @@ -1124,6 +1046,12 @@ "path": "/VLAN_MEMBER/Vlan100|Ethernet3" } ], + [ + { + "op": "remove", + "path": "/ACL_TABLE/NO-NSW-PACL-V4/ports/0" + } + ], [ { "op": "replace", @@ -1184,7 +1112,7 @@ [ { "op": "remove", - "path": "/ACL_TABLE/NO-NSW-PACL-V4/ports/1" + "path": "/ACL_TABLE/NO-NSW-PACL-V4/ports/0" } ], [ @@ -1196,7 +1124,7 @@ [ { "op": "remove", - "path": "/ACL_TABLE/NO-NSW-PACL-V4/ports/1" + "path": "/ACL_TABLE/NO-NSW-PACL-V4/ports/0" } ], [ @@ -1207,72 +1135,27 @@ ], [ { - "op": "remove", - "path": "/ACL_TABLE/NO-NSW-PACL-V4/ports/1" - } - ], - [ - { - "op": "remove", - "path": "/PORT/Ethernet3" + "op": "add", + "path": "/ACL_TABLE/NO-NSW-PACL-V4/ports/0", + "value": "Ethernet0" } ], [ { "op": "remove", - "path": "/ACL_TABLE/NO-NSW-PACL-V4/ports" + "path": "/ACL_TABLE/NO-NSW-PACL-V4/ports/1" } ], [ { "op": "remove", - "path": "/VLAN_MEMBER" - } - ], - [ - { - "op": "add", - "path": "/ACL_TABLE/NO-NSW-PACL-V4/ports", - "value": [ - "Ethernet0" - ] + "path": "/PORT/Ethernet3" } ], [ { "op": "remove", - "path": "/ACL_TABLE" - } - ], - [ - { - "op": "add", - "path": "/VLAN_MEMBER", - "value": { - "Vlan100|Ethernet0": { - "tagging_mode": "untagged" - } - } - } - ], - [ - { - "op": "add", - "path": "/ACL_TABLE", - "value": { - "NO-NSW-PACL-V4": { - "type": "L3" - } - } - } - ], - [ - { - "op": "add", - "path": "/ACL_TABLE/NO-NSW-PACL-V4/ports", - "value": [ - "Ethernet0" - ] + "path": "/ACL_TABLE/NO-NSW-PACL-V4/ports" } ], [ @@ -1281,12 +1164,6 @@ "path": "/VLAN_MEMBER" } ], - [ - { - "op": "remove", - "path": "/ACL_TABLE/NO-NSW-PACL-V4/ports" - } - ], [ { "op": "remove", @@ -1318,13 +1195,6 @@ } } ], - [ - { - "op": "add", - "path": "/ACL_TABLE/NO-NSW-PACL-V4/policy_desc", - "value": "NO-NSW-PACL-V4" - } - ], [ { "op": "add", @@ -2323,38 +2193,6 @@ } ], "expected_changes": [ - [ - { - "op": "remove", - "path": "/LOOPBACK_INTERFACE/Loopback1|20.2.0.32~132" - } - ], - [ - { - "op": "remove", - "path": "/LOOPBACK_INTERFACE/Loopback1|2200:2::32~1128" - } - ], - [ - { - "op": "add", - "path": "/LOOPBACK_INTERFACE/Loopback1|20.2.0.32~132", - "value": {} - } - ], - [ - { - "op": "remove", - "path": "/LOOPBACK_INTERFACE/Loopback0|10.1.0.32~132" - } - ], - [ - { - "op": "add", - "path": "/LOOPBACK_INTERFACE/Loopback1|2200:2::32~1128", - "value": {} - } - ], [ { "op": "remove", @@ -2373,13 +2211,6 @@ "path": "/LOOPBACK_INTERFACE/Loopback1" } ], - [ - { - "op": "add", - "path": "/LOOPBACK_INTERFACE/Loopback0|10.1.0.32~132", - "value": {} - } - ], [ { "op": "add", @@ -2565,64 +2396,6 @@ "path": "/VLAN_MEMBER" } ], - [ - { - "op": "add", - "path": "/ACL_TABLE/NO-NSW-PACL-V4/ports", - "value": [ - "Ethernet0" - ] - } - ], - [ - { - "op": "remove", - "path": "/ACL_TABLE" - } - ], - [ - { - "op": "add", - "path": "/VLAN_MEMBER", - "value": { - "Vlan100|Ethernet0": { - "tagging_mode": "untagged" - } - } - } - ], - [ - { - "op": "add", - "path": "/ACL_TABLE", - "value": { - "NO-NSW-PACL-V4": { - "type": "L3" - } - } - } - ], - [ - { - "op": "add", - "path": "/ACL_TABLE/NO-NSW-PACL-V4/ports", - "value": [ - "Ethernet0" - ] - } - ], - [ - { - "op": "remove", - "path": "/VLAN_MEMBER" - } - ], - [ - { - "op": "remove", - "path": "/ACL_TABLE/NO-NSW-PACL-V4/ports" - } - ], [ { "op": "remove", @@ -2654,13 +2427,6 @@ } } ], - [ - { - "op": "add", - "path": "/ACL_TABLE/NO-NSW-PACL-V4/policy_desc", - "value": "NO-NSW-PACL-V4" - } - ], [ { "op": "add", @@ -2673,8 +2439,10 @@ ] }, "ADDING_LOOPBACK0_VRF_NAME__DELETES_LOOPBACK0_AND_IPS_DOES_NOT_AFFECT_OTHER_TABLES": { - "desc": ["Adding loopback vrf name, deletes loopback0 and the associated ips. ", - "It does not affect other tables."], + "desc": [ + "Adding loopback vrf name, deletes loopback0 and the associated ips. ", + "It does not affect other tables." + ], "current_config": { "CABLE_LENGTH": { "AZURE": { @@ -2733,7 +2501,7 @@ "op": "add", "path": "/LOOPBACK_INTERFACE", "value": { - "Loopback0":{ + "Loopback0": { "vrf_name": "Vrf_01" } } @@ -3538,6 +3306,15 @@ "profile": "egress_lossy_profile" } }, + "CABLE_LENGTH": { + "AZURE": { + "Ethernet52": "40m", + "Ethernet56": "40m", + "Ethernet60": "40m", + "Ethernet68": "40m", + "Ethernet72": "40m" + } + }, "DEVICE_NEIGHBOR": { "Ethernet52": { "name": "ARISTA13T2", @@ -3819,6 +3596,11 @@ "path": "/ACL_TABLE/EVERFLOW/ports/0", "value": "Ethernet64" }, + { + "op": "add", + "path": "/CABLE_LENGTH/AZURE/Ethernet64", + "value": "40m" + }, { "op": "add", "path": "/INTERFACE/Ethernet64", @@ -4584,6 +4366,13 @@ "value": "up" } ], + [ + { + "op": "add", + "path": "/CABLE_LENGTH/AZURE/Ethernet64", + "value": "40m" + } + ], [ { "op": "replace", @@ -5233,6 +5022,16 @@ "profile": "egress_lossy_profile" } }, + "CABLE_LENGTH": { + "AZURE": { + "Ethernet52": "40m", + "Ethernet56": "40m", + "Ethernet60": "40m", + "Ethernet64": "40m", + "Ethernet68": "40m", + "Ethernet72": "40m" + } + }, "DEVICE_NEIGHBOR": { "Ethernet52": { "name": "ARISTA13T2", @@ -5680,6 +5479,10 @@ "op": "remove", "path": "/BGP_NEIGHBOR/fc00::7e/admin_status" }, + { + "op": "remove", + "path": "/CABLE_LENGTH/AZURE/Ethernet64" + }, { "op": "remove", "path": "/INTERFACE/Ethernet64" @@ -6063,6 +5866,12 @@ "path": "/BGP_NEIGHBOR/fc00::a/admin_status" } ], + [ + { + "op": "remove", + "path": "/CABLE_LENGTH/AZURE/Ethernet64" + } + ], [ { "op": "replace", diff --git a/tests/generic_config_updater/gu_common_test.py b/tests/generic_config_updater/gu_common_test.py index e3a8a3bde0..a767e641a5 100644 --- a/tests/generic_config_updater/gu_common_test.py +++ b/tests/generic_config_updater/gu_common_test.py @@ -3,12 +3,24 @@ import jsonpatch import sonic_yang import unittest -from unittest.mock import MagicMock, Mock +from unittest.mock import MagicMock, Mock, patch from .gutest_helpers import create_side_effect_dict, Files import generic_config_updater.gu_common as gu_common class TestDryRunConfigWrapper(unittest.TestCase): + @patch('generic_config_updater.gu_common.subprocess.Popen') + def test_get_config_db_as_json(self, mock_popen): + config_wrapper = gu_common.DryRunConfigWrapper() + mock_proc = MagicMock() + mock_proc.communicate = MagicMock( + return_value=('{"PORT": {}, "bgpraw": ""}', None)) + mock_proc.returncode = 0 + mock_popen.return_value = mock_proc + actual = config_wrapper.get_config_db_as_json() + expected = {"PORT": {}} + self.assertDictEqual(actual, expected) + def test_get_config_db_as_json__returns_imitated_config_db(self): # Arrange config_wrapper = gu_common.DryRunConfigWrapper(Files.CONFIG_DB_AS_JSON) @@ -186,6 +198,158 @@ def test_validate_config_db_config__invalid_config__returns_false(self): self.assertEqual(expected, actual) self.assertIsNotNone(error) + def test_validate_bgp_peer_group__valid_non_intersecting_ip_ranges__returns_true(self): + # Arrange + config_wrapper = gu_common.ConfigWrapper() + config = { + "BGP_PEER_RANGE": + { + "BGPSLBPassive": { + "ip_range": ["1.1.1.1/31", "10.10.10.10/16", "100.100.100.100/24"] + }, + "BgpVac": { + "ip_range": ["2.2.2.2/31", "20.20.20.20/16", "200.200.200.200/24"] + } + } + } + + # Act + actual, error = config_wrapper.validate_bgp_peer_group(config) + + # Assert + self.assertTrue(actual) + self.assertIsNone(error) + + def test_validate_bgp_peer_group__same_ip_prefix__return_false(self): + # duplicate v4 within same ip_range + self.check_validate_bgp_peer_group( + ["1.1.1.1/16", "1.1.1.1/16"], + duplicated_ip="1.1.1.1/16") + # duplicate v4 within different ip_ranges + self.check_validate_bgp_peer_group( + ["1.1.1.1/16"], + ["1.1.1.1/16"], + duplicated_ip="1.1.1.1/16") + # duplicate v4 within different ip_ranges, but many ips + self.check_validate_bgp_peer_group( + ["1.1.1.1/16", "1.1.1.1/31", "10.10.10.10/16", "100.100.100.100/24"], + ["2.2.2.2/31", "20.20.20.20/16", "200.200.200.200/24", "1.1.1.1/16"], + duplicated_ip="1.1.1.1/16") + # duplicate v6 within same ip_range + self.check_validate_bgp_peer_group( + ["fc00:1::32/16", "fc00:1::32/16"], + duplicated_ip="fc00:1::32/16") + # duplicate v6 within different ip_ranges + self.check_validate_bgp_peer_group( + ["fc00:1::32/16"], + ["fc00:1::32/16"], + duplicated_ip="fc00:1::32/16") + # duplicate v6 within different ip_ranges, but many ips + self.check_validate_bgp_peer_group( + ["fc00:1::32/16", "fc00:1::32/31", "10:1::1/16", "100:1::1/24"], + ["2:1::1/31", "20:1::1/16", "200:1::1/24", "fc00:1::32/16"], + duplicated_ip="fc00:1::32/16") + + def check_validate_bgp_peer_group(self, ip_range, other_ip_range=[], duplicated_ip=None): + # Arrange + config_wrapper = gu_common.ConfigWrapper() + config = { + "BGP_PEER_RANGE": + { + "BGPSLBPassive": { + "ip_range": ip_range + }, + "BgpVac": { + "ip_range": other_ip_range + }, + } + } + + # Act + actual, error = config_wrapper.validate_bgp_peer_group(config) + + # Assert + self.assertFalse(actual) + self.assertTrue(duplicated_ip in error) + + def test_validate_lanes__no_port_table__success(self): + config = {"ACL_TABLE": {}} + self.validate_lanes(config) + + def test_validate_lanes__empty_port_table__success(self): + config = {"PORT": {}} + self.validate_lanes(config) + + def test_validate_lanes__empty_lane__failure(self): + config = {"PORT": {"Ethernet0": {"lanes": "", "speed":"10000"}}} + self.validate_lanes(config, 'has an empty lane') + + def test_validate_lanes__whitespace_lane__failure(self): + config = {"PORT": {"Ethernet0": {"lanes": " ", "speed":"10000"}}} + self.validate_lanes(config, 'has an empty lane') + + def test_validate_lanes__non_digits_lane__failure(self): + config = {"PORT": {"Ethernet0": {"lanes": "10g", "speed":"10000"}}} + self.validate_lanes(config, "has an invalid lane '10g'") + + def test_validate_lanes__space_between_digits_lane__failure(self): + config = {"PORT": {"Ethernet0": {"lanes": " 1 0 ", "speed":"10000"}}} + self.validate_lanes(config, "has an invalid lane '1 0'") + + def test_validate_lanes__single_valid_lane__success(self): + config = {"PORT": {"Ethernet0": {"lanes": "66", "speed":"10000"}}} + self.validate_lanes(config) + + def test_validate_lanes__different_valid_lanes_single_port__success(self): + config = {"PORT": {"Ethernet0": {"lanes": "66, 67, 68", "speed":"10000"}}} + self.validate_lanes(config) + + def test_validate_lanes__different_valid_and_invalid_empty_lanes_single_port__failure(self): + config = {"PORT": {"Ethernet0": {"lanes": "66, , 68", "speed":"10000"}}} + self.validate_lanes(config, 'has an empty lane') + + def test_validate_lanes__different_valid_and_invalid_non_digit_lanes_single_port__failure(self): + config = {"PORT": {"Ethernet0": {"lanes": "66, 67, 10g", "speed":"10000"}}} + self.validate_lanes(config, "has an invalid lane '10g'") + + def test_validate_lanes__different_valid_lanes_multi_ports__success(self): + config = {"PORT": { + "Ethernet0": {"lanes": " 64 , 65 \t", "speed":"10000"}, + "Ethernet1": {"lanes": " 66 , 67 \r\t\n, 68 ", "speed":"10000"}, + }} + self.validate_lanes(config) + + def test_validate_lanes__same_valid_lanes_single_port__failure(self): + config = {"PORT": {"Ethernet0": {"lanes": "65 \r\t\n, 65", "speed":"10000"}}} + self.validate_lanes(config, '65') + + def test_validate_lanes__same_valid_lanes_multi_ports__failure(self): + config = {"PORT": { + "Ethernet0": {"lanes": "64, 65, 67", "speed":"10000"}, + "Ethernet1": {"lanes": "66, 67, 68", "speed":"10000"}, + }} + self.validate_lanes(config, '67') + + def test_validate_lanes__same_valid_lanes_multi_ports_no_spaces__failure(self): + config = {"PORT": { + "Ethernet0": {"lanes": "64,65,67", "speed":"10000"}, + "Ethernet1": {"lanes": "66,67,68", "speed":"10000"}, + }} + self.validate_lanes(config, '67') + + def validate_lanes(self, config_db, expected_error=None): + # Arrange + config_wrapper = gu_common.ConfigWrapper() + expected = expected_error is None # if expected_error is None, then the input is valid + + # Act + actual, error = config_wrapper.validate_lanes(config_db) + + # Assert + self.assertEqual(expected, actual) + if expected_error: + self.assertTrue(expected_error in error) + def test_crop_tables_without_yang__returns_cropped_config_db_as_json(self): # Arrange config_wrapper = gu_common.ConfigWrapper() @@ -705,6 +869,19 @@ def test_find_ref_paths__does_not_remove_tables_without_yang(self): # Assert self.assertEqual(expected_config, config) + def test_find_ref_paths__ref_path_is_leaflist_in_yang_but_string_in_config_db__path_to_string_returned(self): + # Arrange + path = "/BUFFER_PROFILE/egress_lossless_profile" + expected = [ + "/BUFFER_PORT_EGRESS_PROFILE_LIST/Ethernet9/profile_list", + ] + + # Act + actual = self.path_addressing.find_ref_paths(path, Files.CONFIG_DB_WITH_PROFILE_LIST) + + # Assert + self.assertEqual(expected, actual) + def test_convert_path_to_xpath(self): def check(path, xpath, config=None): if not config: @@ -765,6 +942,18 @@ def check(path, xpath, config=None): check(path="/LLDP/GLOBAL/mode", xpath="/sonic-lldp:sonic-lldp/LLDP/GLOBAL/mode", config=Files.CONFIG_DB_WITH_LLDP) + check(path="/BUFFER_PORT_EGRESS_PROFILE_LIST/Ethernet9/profile_list", + xpath="/sonic-buffer-port-egress-profile-list:sonic-buffer-port-egress-profile-list/BUFFER_PORT_EGRESS_PROFILE_LIST/BUFFER_PORT_EGRESS_PROFILE_LIST_LIST[port='Ethernet9']/profile_list", + config=Files.CONFIG_DB_WITH_PROFILE_LIST) + check(path="/DOT1P_TO_TC_MAP/Dot1p_to_tc_map1", + xpath="/sonic-dot1p-tc-map:sonic-dot1p-tc-map/DOT1P_TO_TC_MAP/DOT1P_TO_TC_MAP_LIST[name='Dot1p_to_tc_map1']", + config=Files.CONFIG_DB_WITH_TYPE1_TABLES) + check(path="/DOT1P_TO_TC_MAP/Dot1p_to_tc_map1/2", + xpath="/sonic-dot1p-tc-map:sonic-dot1p-tc-map/DOT1P_TO_TC_MAP/DOT1P_TO_TC_MAP_LIST[name='Dot1p_to_tc_map1']/DOT1P_TO_TC_MAP[dot1p='2']", + config=Files.CONFIG_DB_WITH_TYPE1_TABLES) + check(path="/EXP_TO_FC_MAP/Exp_to_fc_map2/4", + xpath="/sonic-exp-fc-map:sonic-exp-fc-map/EXP_TO_FC_MAP/EXP_TO_FC_MAP_LIST[name='Exp_to_fc_map2']/EXP_TO_FC_MAP[exp='4']", + config=Files.CONFIG_DB_WITH_TYPE1_TABLES) def test_convert_xpath_to_path(self): def check(xpath, path, config=None): @@ -840,6 +1029,30 @@ def check(xpath, path, config=None): check(xpath="/sonic-lldp:sonic-lldp/LLDP/GLOBAL/mode", path="/LLDP/GLOBAL/mode", config=Files.CONFIG_DB_WITH_LLDP) + check(xpath="/sonic-buffer-port-egress-profile-list:sonic-buffer-port-egress-profile-list/BUFFER_PORT_EGRESS_PROFILE_LIST/BUFFER_PORT_EGRESS_PROFILE_LIST_LIST[port='Ethernet9']/profile_list", + path="/BUFFER_PORT_EGRESS_PROFILE_LIST/Ethernet9/profile_list", + config=Files.CONFIG_DB_WITH_PROFILE_LIST) + check(xpath="/sonic-buffer-port-egress-profile-list:sonic-buffer-port-egress-profile-list/BUFFER_PORT_EGRESS_PROFILE_LIST/BUFFER_PORT_EGRESS_PROFILE_LIST_LIST[port='Ethernet9']/profile_list[.='egress_lossy_profile']", + path="/BUFFER_PORT_EGRESS_PROFILE_LIST/Ethernet9/profile_list", + config=Files.CONFIG_DB_WITH_PROFILE_LIST) + check(xpath="/sonic-dot1p-tc-map:sonic-dot1p-tc-map/DOT1P_TO_TC_MAP/DOT1P_TO_TC_MAP_LIST[name='Dot1p_to_tc_map1']", + path="/DOT1P_TO_TC_MAP/Dot1p_to_tc_map1", + config=Files.CONFIG_DB_WITH_TYPE1_TABLES) + check(xpath="/sonic-dot1p-tc-map:sonic-dot1p-tc-map/DOT1P_TO_TC_MAP/DOT1P_TO_TC_MAP_LIST[name='Dot1p_to_tc_map1']/DOT1P_TO_TC_MAP", + path="/DOT1P_TO_TC_MAP/Dot1p_to_tc_map1", + config=Files.CONFIG_DB_WITH_TYPE1_TABLES) + check(xpath="/sonic-dot1p-tc-map:sonic-dot1p-tc-map/DOT1P_TO_TC_MAP/DOT1P_TO_TC_MAP_LIST[name='Dot1p_to_tc_map1']/DOT1P_TO_TC_MAP[dot1p='2']", + path="/DOT1P_TO_TC_MAP/Dot1p_to_tc_map1/2", + config=Files.CONFIG_DB_WITH_TYPE1_TABLES) + check(xpath="/sonic-dot1p-tc-map:sonic-dot1p-tc-map/DOT1P_TO_TC_MAP/DOT1P_TO_TC_MAP_LIST[name='Dot1p_to_tc_map1']/DOT1P_TO_TC_MAP[dot1p='2']/dot1p", + path="/DOT1P_TO_TC_MAP/Dot1p_to_tc_map1/2", + config=Files.CONFIG_DB_WITH_TYPE1_TABLES) + check(xpath="/sonic-dot1p-tc-map:sonic-dot1p-tc-map/DOT1P_TO_TC_MAP/DOT1P_TO_TC_MAP_LIST[name='Dot1p_to_tc_map1']/DOT1P_TO_TC_MAP[dot1p='2']/tc", + path="/DOT1P_TO_TC_MAP/Dot1p_to_tc_map1/2", + config=Files.CONFIG_DB_WITH_TYPE1_TABLES) + check(xpath="/sonic-exp-fc-map:sonic-exp-fc-map/EXP_TO_FC_MAP/EXP_TO_FC_MAP_LIST[name='Exp_to_fc_map2']/EXP_TO_FC_MAP[exp='4']", + path="/EXP_TO_FC_MAP/Exp_to_fc_map2/4", + config=Files.CONFIG_DB_WITH_TYPE1_TABLES) def test_has_path(self): def check(config, path, expected): diff --git a/tests/generic_config_updater/patch_sorter_test.py b/tests/generic_config_updater/patch_sorter_test.py index 4cb8fa7019..900538dd6e 100644 --- a/tests/generic_config_updater/patch_sorter_test.py +++ b/tests/generic_config_updater/patch_sorter_test.py @@ -753,6 +753,41 @@ def test_simulate__applies_move(self): # Assert self.assertIs(self.any_diff, actual) +class TestJsonPointerFilter(unittest.TestCase): + def test_get_paths__common_prefix__exact_match_returned(self): + config = { + "BUFFER_PG": { + "Ethernet1|0": {}, + "Ethernet12|0": {}, + "Ethernet120|0": {}, # 'Ethernet12' is a common prefix with the previous line + }, + } + + filter = ps.JsonPointerFilter([["BUFFER_PG", "Ethernet12|*"]], PathAddressing()) + + expected_paths = ["/BUFFER_PG/Ethernet12|0"] + + actual_paths = list(filter.get_paths(config)) + + self.assertCountEqual(expected_paths, actual_paths) + + def test_get_paths__common_suffix__exact_match_returned(self): + config = { + "QUEUE": { + "Ethernet1|0": {}, + "Ethernet1|10": {}, + "Ethernet1|110": {}, # 10 is a common suffix with the previous line + }, + } + + filter = ps.JsonPointerFilter([["QUEUE", "*|10"]], PathAddressing()) + + expected_paths = ["/QUEUE/Ethernet1|10"] + + actual_paths = list(filter.get_paths(config)) + + self.assertCountEqual(expected_paths, actual_paths) + class TestRequiredValueIdentifier(unittest.TestCase): def test_hard_coded_required_value_data(self): identifier = ps.RequiredValueIdentifier(PathAddressing()) @@ -868,49 +903,6 @@ def verify(self, operation_type, path, expected): # Assert self.assertEqual(expected, actual) -class TestUniqueLanesMoveValidator(unittest.TestCase): - def setUp(self): - self.validator = ps.UniqueLanesMoveValidator() - - def test_validate__no_port_table__success(self): - config = {"ACL_TABLE": {}} - self.validate_target_config(config) - - def test_validate__empty_port_table__success(self): - config = {"PORT": {}} - self.validate_target_config(config) - - def test_validate__single_lane__success(self): - config = {"PORT": {"Ethernet0": {"lanes": "66", "speed":"10000"}}} - self.validate_target_config(config) - - def test_validate__different_lanes_single_port___success(self): - config = {"PORT": {"Ethernet0": {"lanes": "66, 67, 68", "speed":"10000"}}} - self.validate_target_config(config) - - def test_validate__different_lanes_multi_ports___success(self): - config = {"PORT": { - "Ethernet0": {"lanes": "64, 65", "speed":"10000"}, - "Ethernet1": {"lanes": "66, 67, 68", "speed":"10000"}, - }} - self.validate_target_config(config) - - def test_validate__same_lanes_single_port___success(self): - config = {"PORT": {"Ethernet0": {"lanes": "65, 65", "speed":"10000"}}} - self.validate_target_config(config, False) - - def validate_target_config(self, target_config, expected=True): - # Arrange - current_config = {} - diff = ps.Diff(current_config, target_config) - move = ps.JsonMove(diff, OperationType.REPLACE, [], []) - - # Act - actual = self.validator.validate(move, diff) - - # Assert - self.assertEqual(expected, actual) - class TestFullConfigMoveValidator(unittest.TestCase): def setUp(self): self.any_current_config = Mock() @@ -1892,6 +1884,22 @@ def _get_critical_port_change_test_cases(self): } }) }, + # Additional cases where the full port is getting deleted + # If port is getting deleted, there is no point in checking if there are critical changes depending on it + "NOT_PORT_UP__STATUS_CHANGING__UNDER_PORT__PORT_EXIST__PORT_DELETION": { + "expected": True, + "config": Files.CONFIG_DB_WITH_PORT_CRITICAL, + "move": ps.JsonMove.from_operation({ "op": "remove", "path": "/PORT/Ethernet32" }) + }, + "NOT_PORT_UP__STATUS_CHANGING__NOT_UNDER_PORT__PORT_EXIST__PORT_DELETION": { + "expected": True, + "config": Files.CONFIG_DB_WITH_PORT_CRITICAL, + "target_config": self._apply_operations(Files.CONFIG_DB_WITH_PORT_CRITICAL, [ + { "op": "remove", "path": "/PORT/Ethernet28" }, + { "op": "remove", "path": "/BUFFER_PG/Ethernet28|0" }, + ]), + "move": ps.JsonMove.from_operation({ "op": "remove", "path": "/PORT/Ethernet28" }) + }, } def test_validate__no_critical_port_changes(self): @@ -1945,6 +1953,106 @@ def _get_no_critical_port_change_test_cases(self): def _apply_operations(self, config, operations): return jsonpatch.JsonPatch(operations).apply(config) +class RemoveCreateOnlyDependencyMoveValidator(unittest.TestCase): + def setUp(self): + path_addressing = PathAddressing(ConfigWrapper()) + self.validator = ps.RemoveCreateOnlyDependencyMoveValidator(path_addressing) + + def test_validate__lane_replacement_change(self): + test_cases = self._get_lane_replacement_change_test_cases() + for test_case_name in test_cases: + with self.subTest(name=test_case_name): + self._run_single_test(test_cases[test_case_name]) + + def _run_single_test(self, test_case): + # Arrange + expected = test_case['expected'] + current_config = test_case['config'] + move = test_case['move'] + target_config = test_case.get('target_config', move.apply(current_config)) + diff = ps.Diff(current_config, target_config) + + # Act and Assert + self.assertEqual(expected, self.validator.validate(move, diff)) + + def _apply_operations(self, config, operations): + return jsonpatch.JsonPatch(operations).apply(config) + + def _get_lane_replacement_change_test_cases(self): + return { + "PORT_NOT_IN_CURRENT_CONFIG": { + "expected": True, + "config": {}, + "move": Mock(), + "target_config": Files.DPB_1_SPLIT_FULL_CONFIG + }, + "PORT_NOT_IN_TARGET_CONFIG": { + "expected": True, + "config": Files.DPB_1_SPLIT_FULL_CONFIG, + "move": Mock(), + "target_config": {} + }, + "PORT_EMPTY_IN_CURRENT_CONFIG": { + "expected": True, + "config": {"PORT": {}}, + "move": Mock(), + "target_config": Files.DPB_1_SPLIT_FULL_CONFIG + }, + "PORT_EMPTY_IN_TARGET_CONFIG": { + "expected": True, + "config": Files.DPB_1_SPLIT_FULL_CONFIG, + "move": Mock(), + "target_config": {"PORT": {}} + }, + "SAME_LANE_IN_BOTH_CONFIG": { + "expected": True, + "config": Files.DPB_1_SPLIT_FULL_CONFIG, + "move": ps.JsonMove.from_operation({ + "op": "remove", + "path": "/ACL_TABLE" + }) + }, + "LANE_DIFF__CURRENT_DOWN__SIMULATED_UP": { + "expected": False, + "config": Files.DPB_1_SPLIT_FULL_CONFIG, + "move": ps.JsonMove.from_operation({ + "op": "add", + "path": "/PORT/Ethernet0/admin_status", + "value": "up" + }), + "target_config":Files.DPB_4_SPLITS_FULL_CONFIG, + }, + "LANE_DIFF__STATUS_SAME__SIMULATED_EXTRA_DEPDENDENCY": { + "expected": False, + "config": self._apply_operations(Files.DPB_1_SPLIT_FULL_CONFIG, [ + {"op": "remove", "path": "/ACL_TABLE"}, + ]), + "move": ps.JsonMove.from_operation({ + "op": "add", + "path": "/ACL_TABLE", + "value": { + "NO-NSW-PACL-V4": { + "type": "L3", + "policy_desc": "NO-NSW-PACL-V4", + "ports": [ + "Ethernet0" + ] + } + } + }), + "target_config": Files.DPB_4_SPLITS_FULL_CONFIG + }, + "LANE_DIFF__STATUS_SAME__SIMULATED_LESS_DEPDENDENCY": { + "expected": True, + "config": Files.DPB_1_SPLIT_FULL_CONFIG, + "move": ps.JsonMove.from_operation({ + "op": "remove", + "path": "/ACL_TABLE" + }), + "target_config": Files.DPB_4_SPLITS_FULL_CONFIG + } + } + class TestTableLevelMoveGenerator(unittest.TestCase): def setUp(self): self.generator = ps.TableLevelMoveGenerator() @@ -2321,6 +2429,85 @@ def get_diff(self, target_config_ops = None, current_config_ops = None): return ps.Diff(current_config, target_config) +class RemoveCreateOnlyDependencyMoveGenerator(unittest.TestCase): + def setUp(self): + config_wrapper = ConfigWrapper() + path_addressing = PathAddressing(config_wrapper) + self.generator = ps.RemoveCreateOnlyDependencyMoveGenerator(path_addressing) + + def test_generate__no_port_table__no_moves(self): + current_config = {} + target_config = {"PORT": {"Ethernet0": {}}} + + # No PORT table in current_config + diff = ps.Diff(current_config, target_config) + moves = list(self.generator.generate(diff)) + self.verify_moves([], moves) + + # No PORT table in target_config + diff = ps.Diff(target_config, current_config) + moves = list(self.generator.generate(diff)) + self.verify_moves([], moves) + + def test_generate__empty_port_content__no_moves(self): + current_config = {"PORT": {}} + target_config = {"PORT": {"Ethernet0": {}}} + + # Empty PORT content in current_config + diff = ps.Diff(current_config, target_config) + moves = list(self.generator.generate(diff)) + self.verify_moves([], moves) + + # Empty PORT content in target_config + diff = ps.Diff(target_config, current_config) + moves = list(self.generator.generate(diff)) + self.verify_moves([], moves) + + def test_generate__same_lanes__no_moves(self): + current_config = Files.CROPPED_CONFIG_DB_AS_JSON + patch = jsonpatch.JsonPatch([ + {'op': 'remove', 'path': '/VLAN_MEMBER'} + ]) + target_config = patch.apply(Files.CROPPED_CONFIG_DB_AS_JSON) + + # Remove VLAN_MEMBER in target_config, lanes are same + diff = ps.Diff(current_config, target_config) + moves = list(self.generator.generate(diff)) + self.verify_moves([], moves) + + # Add VLAN_MEMBER in current_config, lanes are same + diff = ps.Diff(target_config, current_config) + moves = list(self.generator.generate(diff)) + self.verify_moves([], moves) + + def test_generate__dpb_4_to_1_example(self): + # Arrange + diff = ps.Diff(Files.DPB_4_SPLITs_FULL_CONFIG, Files.DPB_1_SPLIT_FULL_CONFIG) + + # Act + moves = list(self.generator.generate(diff)) + + # Assert + self.verify_moves([{'op': 'remove', 'path': '/ACL_TABLE/NO-NSW-PACL-V4/ports/0'}, + {'op': 'remove', 'path': '/VLAN_MEMBER/Vlan100|Ethernet0'}], + moves) + + def test_generate__dpb_1_to_4_example(self): + # Arrange + diff = ps.Diff(Files.DPB_1_SPLIT_FULL_CONFIG, Files.DPB_4_SPLITS_FULL_CONFIG) + + # Act + moves = list(self.generator.generate(diff)) + + # Assert + self.verify_moves([{'op': 'remove', 'path': '/ACL_TABLE/NO-NSW-PACL-V4/ports/0'}, + {'op': 'remove', 'path': '/VLAN_MEMBER/Vlan100|Ethernet0'}], + moves) + + def verify_moves(self, ops, moves): + moves_ops = [list(move.patch)[0] for move in moves] + self.assertCountEqual(ops, moves_ops) + class TestRequiredValueMoveExtender(unittest.TestCase): def setUp(self): path_addressing = PathAddressing() @@ -2551,6 +2738,26 @@ def test_extend__multiple_changes__multiple_extend_moves(self): # Assert self._verify_moves(expected, actual) + def test_extend__port_deletion__no_extension(self): + # Arrange + move = ps.JsonMove.from_operation({ + "op":"remove", + "path":"/PORT/Ethernet28" + }) + current_config = Files.CONFIG_DB_WITH_PORT_CRITICAL + target_config = self._apply_operations(Files.CONFIG_DB_WITH_PORT_CRITICAL, [ + { "op": "remove", "path": "/PORT/Ethernet28" }, + { "op": "remove", "path": "/BUFFER_PG/Ethernet28|0" } + ]) + diff = ps.Diff(current_config, target_config) + expected = [] + + # Act + actual = self.extender.extend(move, diff) + + # Assert + self._verify_moves(expected, actual) + def _verify_moves(self, ex_ops, moves): moves_ops = [list(move.patch)[0] for move in moves] self.assertCountEqual(ex_ops, moves_ops) @@ -3029,7 +3236,8 @@ def verify(self, algo, algo_class): # Arrange config_wrapper = ConfigWrapper() factory = ps.SortAlgorithmFactory(OperationWrapper(), config_wrapper, PathAddressing(config_wrapper)) - expected_generators = [ps.LowLevelMoveGenerator] + expected_generators = [ps.RemoveCreateOnlyDependencyMoveGenerator, + ps.LowLevelMoveGenerator] expected_non_extendable_generators = [ps.KeyLevelMoveGenerator] expected_extenders = [ps.RequiredValueMoveExtender, ps.UpperLevelMoveExtender, @@ -3038,9 +3246,9 @@ def verify(self, algo, algo_class): expected_validator = [ps.DeleteWholeConfigMoveValidator, ps.FullConfigMoveValidator, ps.NoDependencyMoveValidator, - ps.UniqueLanesMoveValidator, ps.CreateOnlyMoveValidator, ps.RequiredValueMoveValidator, + ps.RemoveCreateOnlyDependencyMoveValidator, ps.NoEmptyTableMoveValidator] # Act @@ -3078,7 +3286,6 @@ def test_patch_sorter_success(self): data = Files.PATCH_SORTER_TEST_SUCCESS skip_exact_change_list_match = False for test_case_name in data: - # TODO: Add CABLE_LENGTH to ADD_RACK and REMOVE_RACK tests https://github.com/Azure/sonic-utilities/issues/2034 with self.subTest(name=test_case_name): self.run_single_success_case(data[test_case_name], skip_exact_change_list_match) diff --git a/tests/installer_bootloader_aboot_test.py b/tests/installer_bootloader_aboot_test.py new file mode 100644 index 0000000000..15d2dc1121 --- /dev/null +++ b/tests/installer_bootloader_aboot_test.py @@ -0,0 +1,32 @@ +from unittest.mock import Mock, patch + +# Import test module +import sonic_installer.bootloader.aboot as aboot +import tempfile +import shutil + +# Constants +image_dir = f'{aboot.IMAGE_DIR_PREFIX}expeliarmus-{aboot.IMAGE_DIR_PREFIX}abcde' +exp_image = f'{aboot.IMAGE_PREFIX}expeliarmus-{aboot.IMAGE_DIR_PREFIX}abcde' +image_dirs = [image_dir] + +def test_set_fips_aboot(): + image = 'test-image' + dirpath = tempfile.mkdtemp() + bootloader = aboot.AbootBootloader() + bootloader.get_image_path = Mock(return_value=dirpath) + + # The the default setting + bootloader._set_image_cmdline(image, 'test=1') + assert not bootloader.get_fips(image) + + # Test fips enabled + bootloader.set_fips(image, True) + assert bootloader.get_fips(image) + + # Test fips disabled + bootloader.set_fips(image, False) + assert not bootloader.get_fips(image) + + # Cleanup + shutil.rmtree(dirpath) diff --git a/tests/installer_bootloader_grub_test.py b/tests/installer_bootloader_grub_test.py new file mode 100644 index 0000000000..9450aa1d47 --- /dev/null +++ b/tests/installer_bootloader_grub_test.py @@ -0,0 +1,34 @@ +import os +import shutil +from unittest.mock import Mock, patch + +# Import test module +import sonic_installer.bootloader.grub as grub + +@patch("sonic_installer.bootloader.grub.HOST_PATH", os.path.join(os.path.dirname(os.path.abspath(__file__)), 'installer_bootloader_input/_tmp_host')) +def test_set_fips_grub(): + # Prepare the grub.cfg in the _tmp_host folder + current_path = os.path.dirname(os.path.abspath(__file__)) + grub_config = os.path.join(current_path, 'installer_bootloader_input/host/grub/grub.cfg') + tmp_host_path = os.path.join(current_path, 'installer_bootloader_input/_tmp_host') + tmp_grub_path = os.path.join(tmp_host_path, 'grub') + tmp_grub_config = os.path.join(tmp_grub_path, 'grub.cfg') + os.makedirs(tmp_grub_path, exist_ok=True) + shutil.copy(grub_config, tmp_grub_path) + + image = 'SONiC-OS-internal-202205.57377412-84a9a7f11b' + bootloader = grub.GrubBootloader() + + # The the default setting + assert not bootloader.get_fips(image) + + # Test fips enabled + bootloader.set_fips(image, True) + assert bootloader.get_fips(image) + + # Test fips disabled + bootloader.set_fips(image, False) + assert not bootloader.get_fips(image) + + # Cleanup the _tmp_host folder + shutil.rmtree(tmp_host_path) diff --git a/tests/installer_bootloader_input/host/grub/grub.cfg b/tests/installer_bootloader_input/host/grub/grub.cfg new file mode 100644 index 0000000000..5b44bae12b --- /dev/null +++ b/tests/installer_bootloader_input/host/grub/grub.cfg @@ -0,0 +1,51 @@ +serial --port=0x3f8 --speed=9600 --word=8 --parity=no --stop=1 +terminal_input console serial +terminal_output console serial + +set timeout=5 + +if [ -s $prefix/grubenv ]; then + load_env +fi +if [ "${saved_entry}" ]; then + set default="${saved_entry}" +fi +if [ "${next_entry}" ]; then + set default="${next_entry}" + unset next_entry + save_env next_entry +fi +if [ "${onie_entry}" ]; then + set next_entry="${default}" + set default="${onie_entry}" + unset onie_entry + save_env onie_entry next_entry +fi + +menuentry 'SONiC-OS-internal-202205.57377412-84a9a7f11b' { + search --no-floppy --label --set=root SONiC-OS + echo 'Loading SONiC-OS OS kernel ...' + insmod gzio + if [ x = xxen ]; then insmod xzio; insmod lzopio; fi + insmod part_msdos + insmod ext2 + linux /image-internal-202205.57377412-84a9a7f11b/boot/vmlinuz-5.10.0-12-2-amd64 root=UUID=df89970c-bf6d-40cf-80fc-a977c89054dd rw console=tty0 console=ttyS0,9600n8 quiet intel_idle.max_cstate=0 net.ifnames=0 biosdevname=0 loop=image-internal-202205.57377412-84a9a7f11b/fs.squashfs loopfstype=squashfs systemd.unified_cgroup_hierarchy=0 apparmor=1 security=apparmor varlog_size=4096 usbcore.autosuspend=-1 acpi_enforce_resources=lax acpi=noirq + echo 'Loading SONiC-OS OS initial ramdisk ...' + initrd /image-internal-202205.57377412-84a9a7f11b/boot/initrd.img-5.10.0-12-2-amd64 +} +menuentry 'SONiC-OS-master-11298.116581-1a4f95389' { + search --no-floppy --label --set=root SONiC-OS + echo 'Loading SONiC-OS OS kernel ...' + insmod gzio + if [ x = xxen ]; then insmod xzio; insmod lzopio; fi + insmod part_msdos + insmod ext2 + linux /image-master-11298.116581-1a4f95389/boot/vmlinuz-5.10.0-12-2-amd64 root=UUID=df89970c-bf6d-40cf-80fc-a977c89054dd rw console=tty0 console=ttyS0,9600n8 quiet intel_idle.max_cstate=0 sonic_fips=1 net.ifnames=0 biosdevname=0 loop=image-master-11298.116581-1a4f95389/fs.squashfs loopfstype=squashfs systemd.unified_cgroup_hierarchy=0 apparmor=1 security=apparmor varlog_size=4096 usbcore.autosuspend=-1 acpi_enforce_resources=lax acpi=noirq + echo 'Loading SONiC-OS OS initial ramdisk ...' + initrd /image-master-11298.116581-1a4f95389/boot/initrd.img-5.10.0-12-2-amd64 +} +menuentry ONIE { + search --no-floppy --label --set=root ONIE-BOOT + echo 'Loading ONIE ...' + chainloader +1 +} diff --git a/tests/installer_bootloader_uboot_test.py b/tests/installer_bootloader_uboot_test.py new file mode 100644 index 0000000000..848f4f7ba4 --- /dev/null +++ b/tests/installer_bootloader_uboot_test.py @@ -0,0 +1,73 @@ +import os +from unittest.mock import Mock, patch + +# Import test module +import sonic_installer.bootloader.uboot as uboot + +class MockProc(): + commandline = "linuxargs=" + def communicate(): + return commandline, None + +def mock_run_command(cmd): + MockProc.commandline = cmd + +@patch("sonic_installer.bootloader.uboot.subprocess.Popen") +@patch("sonic_installer.bootloader.uboot.run_command") +def test_get_next_image(run_command_patch, popen_patch): + class MockProc(): + commandline = "boot_next" + def communicate(self): + return MockProc.commandline, None + + def mock_run_command(cmd): + # Remove leading string "/usr/bin/fw_setenv boot_next " -- the 29 characters + MockProc.commandline = cmd[29:] + + # Constants + intstalled_images = [ + f'{uboot.IMAGE_PREFIX}expeliarmus-{uboot.IMAGE_PREFIX}abcde', + f'{uboot.IMAGE_PREFIX}expeliarmus-abcde', + ] + + run_command_patch.side_effect = mock_run_command + popen_patch.return_value = MockProc() + + bootloader = uboot.UbootBootloader() + bootloader.get_installed_images = Mock(return_value=intstalled_images) + + bootloader.set_default_image(intstalled_images[1]) + + # Verify get_next_image was executed with image path + next_image=bootloader.get_next_image() + + assert next_image == intstalled_images[1] + +@patch("sonic_installer.bootloader.uboot.subprocess.Popen") +@patch("sonic_installer.bootloader.uboot.run_command") +def test_set_fips_uboot(run_command_patch, popen_patch): + class MockProc(): + commandline = "linuxargs" + def communicate(self): + return MockProc.commandline, None + + def mock_run_command(cmd): + # Remove leading string "/usr/bin/fw_setenv linuxargs " -- the 29 characters + MockProc.commandline = 'linuxargs=' + cmd[29:] + + run_command_patch.side_effect = mock_run_command + popen_patch.return_value = MockProc() + + image = 'test-image' + bootloader = uboot.UbootBootloader() + + # The the default setting + assert not bootloader.get_fips(image) + + # Test fips enabled + bootloader.set_fips(image, True) + assert bootloader.get_fips(image) + + # Test fips disabled + bootloader.set_fips(image, False) + assert not bootloader.get_fips(image) diff --git a/tests/int_ip_input/config_db.json b/tests/int_ip_input/config_db.json index 3f2d6e5beb..344217aecd 100644 --- a/tests/int_ip_input/config_db.json +++ b/tests/int_ip_input/config_db.json @@ -37,5 +37,11 @@ }, "VLAN_INTERFACE|Vlan2|192.168.1.1/21": { "NULL": "NULL" + }, + "VLAN_SUB_INTERFACE|Ethernet16.16": { + "admin_status": "up" + }, + "VLAN_SUB_INTERFACE|Ethernet16.16|16.1.1.1/16": { + "NULL": "NULL" } } \ No newline at end of file diff --git a/tests/intfutil_test.py b/tests/intfutil_test.py index 2023b5939e..2a13075919 100644 --- a/tests/intfutil_test.py +++ b/tests/intfutil_test.py @@ -97,7 +97,20 @@ Ethernet32 disabled 40G all N/A N/A all up up """ - +show_interface_link_training_status_output = """\ + Interface LT Oper LT Admin Oper Admin +----------- ----------- ---------- ------ ------- + Ethernet0 not trained on down up + Ethernet16 off - up up + Ethernet24 off - up up + Ethernet28 off - up up + Ethernet32 trained on up up + Ethernet36 off - up up +Ethernet112 off off up up +Ethernet116 off - up up +Ethernet120 off - up up +Ethernet124 off - up up +""" class TestIntfutil(TestCase): @classmethod @@ -196,8 +209,9 @@ def test_subintf_status(self): expected_output = ( "Sub port interface Speed MTU Vlan Admin Type\n" "-------------------- ------- ----- ------ ------- --------------------\n" - " Eth32.10 40G 9100 100 up 802.1q-encapsulation\n" - " Ethernet0.10 25G 9100 10 up 802.1q-encapsulation" + " Eth36.10 10M 9100 100 up 802.1q-encapsulation\n" + " Ethernet0.10 25G 9100 10 up 802.1q-encapsulation\n" + " Po0001.10 40G 9100 100 up 802.1q-encapsulation" ) self.assertEqual(result.output.strip(), expected_output) @@ -234,10 +248,20 @@ def test_single_subintf_status(self): expected_output = ( "Sub port interface Speed MTU Vlan Admin Type\n" "-------------------- ------- ----- ------ ------- --------------------\n" - " Eth32.10 40G 9100 100 up 802.1q-encapsulation" + " Eth36.10 10M 9100 100 up 802.1q-encapsulation" ) - # Test 'intfutil status Eth32.10' - output = subprocess.check_output('intfutil -c status -i Eth32.10', stderr=subprocess.STDOUT, shell=True, text=True) + # Test 'intfutil status Eth36.10' + output = subprocess.check_output('intfutil -c status -i Eth36.10', stderr=subprocess.STDOUT, shell=True, text=True) + print(output, file=sys.stderr) + self.assertEqual(output.strip(), expected_output) + + expected_output = ( + "Sub port interface Speed MTU Vlan Admin Type\n" + "-------------------- ------- ----- ------ ------- --------------------\n" + " Po0001.10 40G 9100 100 up 802.1q-encapsulation" + ) + # Test 'intfutil status Po0001.10' + output = subprocess.check_output('intfutil -c status -i Po0001.10', stderr=subprocess.STDOUT, shell=True, text=True) print(output, file=sys.stderr) self.assertEqual(output.strip(), expected_output) @@ -248,9 +272,14 @@ def test_single_subintf_status_verbose(self): expected_output = "Command: intfutil -c status -i Ethernet0.10" self.assertEqual(result.output.split('\n')[0], expected_output) - result = self.runner.invoke(show.cli.commands["subinterfaces"].commands["status"], ["Eth32.10", "--verbose"]) + result = self.runner.invoke(show.cli.commands["subinterfaces"].commands["status"], ["Eth36.10", "--verbose"]) + print(result.output, file=sys.stderr) + expected_output = "Command: intfutil -c status -i Eth36.10" + self.assertEqual(result.output.split('\n')[0], expected_output) + + result = self.runner.invoke(show.cli.commands["subinterfaces"].commands["status"], ["Po0001.10", "--verbose"]) print(result.output, file=sys.stderr) - expected_output = "Command: intfutil -c status -i Eth32.10" + expected_output = "Command: intfutil -c status -i Po0001.10" self.assertEqual(result.output.split('\n')[0], expected_output) # Test status of single sub interface in alias naming mode @@ -302,6 +331,13 @@ def test_show_interfaces_autoneg_status_etp9_in_alias_mode(self): assert result.exit_code == 0 assert result.output == show_interface_auto_neg_status_eth9_output + def test_show_interfaces_link_training_status(self): + result = self.runner.invoke(show.cli.commands["interfaces"].commands["link-training"].commands["status"], []) + print(result.exit_code) + print(result.output) + assert result.exit_code == 0 + assert result.output == show_interface_link_training_status_output + @classmethod def teardown_class(cls): print("TEARDOWN") diff --git a/tests/ip_config_input/patch_ipv6.test b/tests/ip_config_input/patch_ipv6.test new file mode 100644 index 0000000000..00b43fda4c --- /dev/null +++ b/tests/ip_config_input/patch_ipv6.test @@ -0,0 +1,6 @@ +[ + { + "path": "/INTERFACE/Ethernet12|FC00::1~1126", + "op": "remove" + } +] diff --git a/tests/ip_config_test.py b/tests/ip_config_test.py index 47f82fb959..2bc3525aeb 100644 --- a/tests/ip_config_test.py +++ b/tests/ip_config_test.py @@ -1,3 +1,5 @@ +import json +import jsonpatch import os import traceback from unittest import mock @@ -7,17 +9,42 @@ import config.main as config import show.main as show from utilities_common.db import Db +import utilities_common.bgp_util as bgp_util + +test_path = os.path.dirname(os.path.abspath(__file__)) +ip_config_input_path = os.path.join(test_path, "ip_config_input") ERROR_MSG = "Error: IP address is not valid" +INVALID_VRF_MSG ="""\ +Usage: bind [OPTIONS] +Try "bind --help" for help. + +Error: VRF Vrf2 does not exist! +""" + +INVALID_MGMT_VRF_MSG ="""\ +Usage: bind [OPTIONS] +Try "bind --help" for help. + +Error: VRF mgmt does not exist! +""" + class TestConfigIP(object): + _old_run_bgp_command = None @classmethod def setup_class(cls): os.environ['UTILITIES_UNIT_TESTING'] = "1" + cls._old_run_bgp_command = bgp_util.run_bgp_command + bgp_util.run_bgp_command = mock.MagicMock( + return_value=cls.mock_run_bgp_command()) print("SETUP") ''' Tests for IPv4 ''' + def mock_run_bgp_command(): + return "" + def test_add_del_interface_valid_ipv4(self): db = Db() runner = CliRunner() @@ -29,12 +56,36 @@ def test_add_del_interface_valid_ipv4(self): assert result.exit_code == 0 assert ('Ethernet64', '10.10.10.1/24') in db.cfgdb.get_table('INTERFACE') + # config int ip add Ethernet0.10 10.11.10.1/24 + result = runner.invoke(config.config.commands["interface"].commands["ip"].commands["add"], ["Ethernet0.10", "10.11.10.1/24"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code == 0 + assert ('Ethernet0.10', '10.11.10.1/24') in db.cfgdb.get_table('VLAN_SUB_INTERFACE') + + # config int ip add Eth36.10 32.11.10.1/24 + result = runner.invoke(config.config.commands["interface"].commands["ip"].commands["add"], ["Eth36.10", "32.11.10.1/24"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code == 0 + assert ('Eth36.10', '32.11.10.1/24') in db.cfgdb.get_table('VLAN_SUB_INTERFACE') + # config int ip remove Ethernet64 10.10.10.1/24 result = runner.invoke(config.config.commands["interface"].commands["ip"].commands["remove"], ["Ethernet64", "10.10.10.1/24"], obj=obj) print(result.exit_code, result.output) assert result.exit_code != 0 assert ('Ethernet64', '10.10.10.1/24') not in db.cfgdb.get_table('INTERFACE') + # config int ip remove Ethernet0.10 10.11.10.1/24 + result = runner.invoke(config.config.commands["interface"].commands["ip"].commands["remove"], ["Ethernet0.10", "10.11.10.1/24"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code != 0 + assert ('Ethernet0.10', '10.11.10.1/24') not in db.cfgdb.get_table('VLAN_SUB_INTERFACE') + + # config int ip remove Eth36.10 32.11.10.1/24 + result = runner.invoke(config.config.commands["interface"].commands["ip"].commands["remove"], ["Eth36.10", "32.11.10.1/24"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code != 0 + assert ('Eth36.10', '32.11.10.1/24') not in db.cfgdb.get_table('VLAN_SUB_INTERFACE') + def test_add_interface_invalid_ipv4(self): db = Db() runner = CliRunner() @@ -68,6 +119,18 @@ def test_add_interface_ipv4_with_leading_zeros(self): assert result.exit_code != 0 assert ERROR_MSG in result.output + def test_ip_add_on_interface_which_is_member_of_portchannel(self): + runner = CliRunner() + db = Db() + obj = {'config_db':db.cfgdb} + + # config int ip add Ethernet32 100.10.10.1/24 + result = runner.invoke(config.config.commands["interface"].commands["ip"].commands["add"], ["Ethernet32", "100.10.10.1/24"], obj=obj) + assert result.exit_code != 0 + print(result.output) + print(result.exit_code) + assert 'Error: Ethernet32 is configured as a member of portchannel.' in result.output + ''' Tests for IPv6 ''' def test_add_del_interface_valid_ipv6(self): @@ -81,12 +144,32 @@ def test_add_del_interface_valid_ipv6(self): assert result.exit_code == 0 assert ('Ethernet72', '2001:1db8:11a3:19d7:1f34:8a2e:17a0:765d/34') in db.cfgdb.get_table('INTERFACE') + result = runner.invoke(config.config.commands["interface"].commands["ip"].commands["add"], ["Ethernet0.10", "1010:1db8:11a3:19d7:1f34:8a2e:17a0:765d/34"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code == 0 + assert ('Ethernet0.10', '1010:1db8:11a3:19d7:1f34:8a2e:17a0:765d/34') in db.cfgdb.get_table('VLAN_SUB_INTERFACE') + + result = runner.invoke(config.config.commands["interface"].commands["ip"].commands["add"], ["Eth36.10", "3210:1db8:11a3:19d7:1f34:8a2e:17a0:765d/34"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code == 0 + assert ('Eth36.10', '3210:1db8:11a3:19d7:1f34:8a2e:17a0:765d/34') in db.cfgdb.get_table('VLAN_SUB_INTERFACE') + # config int ip remove Ethernet72 2001:1db8:11a3:19d7:1f34:8a2e:17a0:765d/34 result = runner.invoke(config.config.commands["interface"].commands["ip"].commands["remove"], ["Ethernet72", "2001:1db8:11a3:19d7:1f34:8a2e:17a0:765d/34"], obj=obj) print(result.exit_code, result.output) assert result.exit_code != 0 assert ('Ethernet72', '2001:1db8:11a3:19d7:1f34:8a2e:17a0:765d/34') not in db.cfgdb.get_table('INTERFACE') + result = runner.invoke(config.config.commands["interface"].commands["ip"].commands["remove"], ["Ethernet0.10", "1010:1db8:11a3:19d7:1f34:8a2e:17a0:765d/34"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code != 0 + assert ('Ethernet0.10', '1010:1db8:11a3:19d7:1f34:8a2e:17a0:765d/34') not in db.cfgdb.get_table('VLAN_SUB_INTERFACE') + + result = runner.invoke(config.config.commands["interface"].commands["ip"].commands["remove"], ["Eth36.10", "3210:1db8:11a3:19d7:1f34:8a2e:17a0:765d/34"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code != 0 + assert ('Eth36.10', '3210:1db8:11a3:19d7:1f34:8a2e:17a0:765d/34') not in db.cfgdb.get_table('VLAN_SUB_INTERFACE') + def test_del_interface_case_sensitive_ipv6(self): db = Db() runner = CliRunner() @@ -157,7 +240,57 @@ def test_add_del_interface_shortened_ipv6_with_leading_zeros(self): assert result.exit_code != 0 assert ('Ethernet68', '3000::1/64') not in db.cfgdb.get_table('INTERFACE') + def test_remove_interface_case_sensitive_mock_ipv6_w_apply_patch(self): + runner = CliRunner() + any_patch_as_json = [{"op": "remove", "path": "/INTERFACE/Ethernet12|FC00::1~1126"}] + any_patch = jsonpatch.JsonPatch(any_patch_as_json) + any_patch_as_text = json.dumps(any_patch_as_json) + ipv6_patch_file = os.path.join(ip_config_input_path, 'patch_ipv6.test') + + # config apply-patch patch + mock_generic_updater = mock.Mock() + with mock.patch('config.main.GenericUpdater', return_value=mock_generic_updater): + with mock.patch('builtins.open', mock.mock_open(read_data=any_patch_as_text)): + result = runner.invoke(config.config.commands["apply-patch"], [ipv6_patch_file], catch_exceptions=False) + print(result.exit_code, result.output) + assert "converted ipv6 address to lowercase fc00::1~1126 with prefix /INTERFACE/Ethernet12| in value: /INTERFACE/Ethernet12|FC00::1~1126" in result.output + + def test_intf_vrf_bind_unbind(self): + runner = CliRunner() + db = Db() + obj = {'config_db':db.cfgdb, 'namespace':db.db.namespace} + + result = runner.invoke(config.config.commands["interface"].commands["vrf"].commands["bind"], ["Ethernet64", "Vrf1"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code == 0 + + result = runner.invoke(config.config.commands["interface"].commands["vrf"].commands["unbind"], ["Ethernet64"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code == 0 + + def test_intf_unknown_vrf_bind(self): + runner = CliRunner() + db = Db() + obj = {'config_db':db.cfgdb, 'namespace':db.db.namespace} + + result = runner.invoke(config.config.commands["interface"].commands["vrf"].commands["bind"], ["Ethernet64", "Vrf2"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code != 0 + assert result.output == INVALID_VRF_MSG + + result = runner.invoke(config.config.commands["interface"].commands["vrf"].commands["bind"], ["Ethernet64", "mgmt"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code != 0 + assert result.output == INVALID_MGMT_VRF_MSG + + result = runner.invoke(config.config.commands["vrf"].commands["add"], ["mgmt"], obj=obj) + print(result.exit_code, result.output) + result = runner.invoke(config.config.commands["interface"].commands["vrf"].commands["bind"], ["Ethernet64", "mgmt"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code == 0 + @classmethod def teardown_class(cls): os.environ['UTILITIES_UNIT_TESTING'] = "0" + bgp_util.run_bgp_command = cls._old_run_bgp_command print("TEARDOWN") diff --git a/tests/ip_show_routes_multi_asic_test.py b/tests/ip_show_routes_multi_asic_test.py index 271467dae5..bfce5e539d 100644 --- a/tests/ip_show_routes_multi_asic_test.py +++ b/tests/ip_show_routes_multi_asic_test.py @@ -164,6 +164,22 @@ def test_show_multi_asic_ipv6_route_all_namespace( assert result.exit_code == 0 assert result.output == show_ip_route_common.show_ipv6_route_multi_asic_all_namesapce_output + @pytest.mark.parametrize('setup_multi_asic_bgp_instance', + ['ipv6_route'], indirect=['setup_multi_asic_bgp_instance']) + def test_show_multi_asic_ipv6_route_all_namespace_alias( + self, + setup_ip_route_commands, + setup_multi_asic_bgp_instance): + show = setup_ip_route_commands + runner = CliRunner() + os.environ['SONIC_CLI_IFACE_MODE'] = "alias" + result = runner.invoke( + show.cli.commands["ipv6"].commands["route"], ["-dfrontend"]) + os.environ['SONIC_CLI_IFACE_MODE'] = "default" + print("{}".format(result.output)) + assert result.exit_code == 0 + assert result.output == show_ip_route_common.show_ipv6_route_multi_asic_all_namesapce_alias_output + @pytest.mark.parametrize('setup_multi_asic_bgp_instance', ['ipv6_route'], indirect=['setup_multi_asic_bgp_instance']) def test_show_multi_asic_ipv6_route_single_namespace( diff --git a/tests/ip_show_routes_test.py b/tests/ip_show_routes_test.py index 820827d550..f39ccc52d5 100644 --- a/tests/ip_show_routes_test.py +++ b/tests/ip_show_routes_test.py @@ -3,11 +3,15 @@ from . import show_ip_route_common from click.testing import CliRunner +import mock +import sys test_path = os.path.dirname(os.path.abspath(__file__)) modules_path = os.path.dirname(test_path) scripts_path = os.path.join(modules_path, "scripts") +sys.path.insert(0, test_path) + class TestShowIpRouteCommands(object): @classmethod @@ -18,6 +22,25 @@ def setup_class(cls): os.environ["UTILITIES_UNIT_TESTING"] = "0" os.environ["UTILITIES_UNIT_TESTING_TOPOLOGY"] = "" import mock_tables.dbconnector + + def test_show_ip_route_err( + self, + setup_ip_route_commands): + show = setup_ip_route_commands + + def mock_run_bgp_command(*args, **kwargs): + command = args[0] + return "% Unknown command: show ip route unknown", 1 + + with mock.patch('utilities_common.cli.run_command', mock.MagicMock(side_effect=mock_run_bgp_command)) as mock_run_command: + runner = CliRunner() + result = runner.invoke( + show.cli.commands["ip"].commands["route"], ["unknown"]) + print("{}".format(result.output)) + print(result.exit_code) + assert result.exit_code == 1 + assert result.output == "% Unknown command: show ip route unknown" + "\n" + @pytest.mark.parametrize('setup_single_bgp_instance', ['ip_route'], indirect=['setup_single_bgp_instance']) def test_show_ip_route( @@ -30,7 +53,7 @@ def test_show_ip_route( show.cli.commands["ip"].commands["route"], []) print("{}".format(result.output)) assert result.exit_code == 0 - assert result.output == show_ip_route_common.show_ip_route_expected_output + "\n" + assert result.output == show_ip_route_common.show_ip_route_expected_output @pytest.mark.parametrize('setup_single_bgp_instance', ['ip_specific_route'], indirect=['setup_single_bgp_instance']) @@ -44,7 +67,7 @@ def test_show_specific_ip_route( show.cli.commands["ip"].commands["route"], ["192.168.0.1"]) print("{}".format(result.output)) assert result.exit_code == 0 - assert result.output == show_ip_route_common.show_specific_ip_route_expected_output + "\n" + assert result.output == show_ip_route_common.show_specific_ip_route_expected_output @pytest.mark.parametrize('setup_single_bgp_instance', ['ip_special_route'], indirect=['setup_single_bgp_instance']) @@ -58,7 +81,7 @@ def test_show_special_ip_route( show.cli.commands["ip"].commands["route"], []) print("{}".format(result.output)) assert result.exit_code == 0 - assert result.output == show_ip_route_common.show_special_ip_route_expected_output + "\n" + assert result.output == show_ip_route_common.show_special_ip_route_expected_output @pytest.mark.parametrize('setup_single_bgp_instance', ['ipv6_specific_route'], indirect=['setup_single_bgp_instance']) @@ -72,7 +95,7 @@ def test_show_specific_ipv6_route_json( show.cli.commands["ip"].commands["route"], ["20c0:a8c7:0:81::", "json"]) print("{}".format(result.output)) assert result.exit_code == 0 - assert result.output == show_ip_route_common.show_ipv6_route_single_json_expected_output + "\n" + assert result.output == show_ip_route_common.show_ipv6_route_single_json_expected_output @pytest.mark.parametrize('setup_single_bgp_instance', ['ipv6_route'], indirect=['setup_single_bgp_instance']) @@ -86,7 +109,23 @@ def test_show_ipv6_route( show.cli.commands["ipv6"].commands["route"], []) print("{}".format(result.output)) assert result.exit_code == 0 - assert result.output == show_ip_route_common.show_ipv6_route_expected_output + "\n" + assert result.output == show_ip_route_common.show_ipv6_route_expected_output + + @pytest.mark.parametrize('setup_single_bgp_instance', + ['ipv6_route'], indirect=['setup_single_bgp_instance']) + def test_show_ipv6_route_alias( + self, + setup_ip_route_commands, + setup_single_bgp_instance): + show = setup_ip_route_commands + runner = CliRunner() + os.environ['SONIC_CLI_IFACE_MODE'] = "alias" + result = runner.invoke( + show.cli.commands["ipv6"].commands["route"], []) + os.environ['SONIC_CLI_IFACE_MODE'] = "default" + print("{}".format(result.output)) + assert result.exit_code == 0 + assert result.output == show_ip_route_common.show_ipv6_route_alias_expected_output @pytest.mark.parametrize('setup_single_bgp_instance', ['ipv6_route_err'], indirect=['setup_single_bgp_instance']) @@ -101,3 +140,4 @@ def test_show_ipv6_route_err( print("{}".format(result.output)) assert result.exit_code == 0 assert result.output == show_ip_route_common.show_ipv6_route_err_expected_output + "\n" + diff --git a/tests/ipv6_link_local_test.py b/tests/ipv6_link_local_test.py index a01bfa726d..50b691be6b 100644 --- a/tests/ipv6_link_local_test.py +++ b/tests/ipv6_link_local_test.py @@ -30,7 +30,7 @@ +------------------+----------+ | Ethernet36 | Disabled | +------------------+----------+ -| Ethernet40 | Disabled | +| Ethernet40 | Enabled | +------------------+----------+ | Ethernet44 | Disabled | +------------------+----------+ @@ -224,6 +224,16 @@ def test_config_enable_disable_ipv6_link_local_on_all_valid_interfaces(self): assert result.exit_code == 0 assert result.output == '' + def test_vlan_member_add_on_link_local_interface(self): + runner = CliRunner() + db = Db() + obj = {'config_db':db.cfgdb, 'namespace':db.db.namespace} + + result = runner.invoke(config.config.commands["vlan"].commands["member"].commands["add"], ["4000", "Ethernet40"], obj=obj) + print(result.output) + assert result.exit_code != 0 + assert 'Error: Ethernet40 is a router interface!' in result.output + @classmethod def teardown_class(cls): os.environ['UTILITIES_UNIT_TESTING'] = "0" diff --git a/tests/kube_test.py b/tests/kube_test.py index 90a4f6e292..e49a2a55f8 100644 --- a/tests/kube_test.py +++ b/tests/kube_test.py @@ -34,6 +34,18 @@ 10.3.157.24 7777 True False """ +show_server_output_5="""\ +ip port insecure disable +----------- ------ ---------- --------- +10.10.10.11 6443 True False +""" + +show_server_output_6="""\ +ip port insecure disable +----------- ------ ---------- --------- +10.3.157.24 6443 True False +""" + empty_server_status="""\ Kubernetes server has no status info """ @@ -96,6 +108,20 @@ def test_no_kube_server(self, get_cmd_module): result = runner.invoke(config.config.commands["kubernetes"].commands["server"], ["ip", "10.10.10.11"], obj=db) self.__check_res(result, "set server IP when none", "") + result = runner.invoke(show.cli.commands["kubernetes"].commands["server"].commands["config"], [], obj=db) + self.__check_res(result, "config command default value", show_server_output_5) + + + def test_only_kube_server(self, get_cmd_module): + (config, show) = get_cmd_module + runner = CliRunner() + db = Db() + + db.cfgdb.delete_table("KUBERNETES_MASTER") + db.cfgdb.set_entry("KUBERNETES_MASTER", "SERVER", {"ip": "10.3.157.24"}) + + result = runner.invoke(show.cli.commands["kubernetes"].commands["server"].commands["config"], [], obj=db) + self.__check_res(result, "show command default value", show_server_output_6) def test_kube_server_status(self, get_cmd_module): diff --git a/tests/loopback_action_test.py b/tests/loopback_action_test.py new file mode 100644 index 0000000000..b88d36973d --- /dev/null +++ b/tests/loopback_action_test.py @@ -0,0 +1,139 @@ +import os +from click.testing import CliRunner +import config.main as config +import show.main as show +from utilities_common.db import Db + +show_ip_interfaces_loopback_action_output="""\ +Interface Action +--------------- -------- +Eth36.10 drop +Ethernet0 forward +PortChannel0001 drop +Vlan3000 forward +""" + +class TestLoopbackAction(object): + @classmethod + def setup_class(cls): + print("\nSETUP") + os.environ['UTILITIES_UNIT_TESTING'] = "1" + + def test_config_loopback_action_on_physical_interface(self): + runner = CliRunner() + db = Db() + obj = {'config_db':db.cfgdb} + action = 'drop' + iface = 'Ethernet0' + + result = runner.invoke(config.config.commands['interface'].commands["ip"].commands['loopback-action'], [iface, action], obj=obj) + + table = db.cfgdb.get_table('INTERFACE') + assert(table[iface]['loopback_action'] == action) + + print(result.exit_code, result.output) + assert result.exit_code == 0 + + def test_config_loopback_action_on_physical_interface_alias(self): + runner = CliRunner() + db = Db() + obj = {'config_db':db.cfgdb} + action = 'forward' + iface = 'Ethernet0' + iface_alias = 'etp1' + + os.environ['SONIC_CLI_IFACE_MODE'] = "alias" + result = runner.invoke(config.config.commands['interface'].commands["ip"].commands['loopback-action'], [iface_alias, action], obj=obj) + os.environ['SONIC_CLI_IFACE_MODE'] = "default" + + table = db.cfgdb.get_table('INTERFACE') + assert(table[iface]['loopback_action'] == action) + + print(result.exit_code, result.output) + assert result.exit_code == 0 + + def test_config_loopback_action_on_port_channel_interface(self): + runner = CliRunner() + db = Db() + obj = {'config_db':db.cfgdb} + action = 'forward' + iface = 'PortChannel0002' + + result = runner.invoke(config.config.commands['interface'].commands["ip"].commands['loopback-action'], [iface, action], obj=obj) + + table = db.cfgdb.get_table('PORTCHANNEL_INTERFACE') + assert(table[iface]['loopback_action'] == action) + + print(result.exit_code, result.output) + assert result.exit_code == 0 + + def test_config_loopback_action_on_vlan_interface(self): + runner = CliRunner() + db = Db() + obj = {'config_db':db.cfgdb} + action = 'drop' + iface = 'Vlan1000' + + result = runner.invoke(config.config.commands['interface'].commands["ip"].commands['loopback-action'], [iface, action], obj=obj) + + table = db.cfgdb.get_table('VLAN_INTERFACE') + assert(table[iface]['loopback_action'] == action) + + print(result.exit_code, result.output) + assert result.exit_code == 0 + + def test_config_loopback_action_on_subinterface(self): + runner = CliRunner() + db = Db() + obj = {'config_db':db.cfgdb} + action = 'forward' + iface = 'Ethernet0.10' + + result = runner.invoke(config.config.commands['interface'].commands["ip"].commands['loopback-action'], [iface, action], obj=obj) + + table = db.cfgdb.get_table('VLAN_SUB_INTERFACE') + assert(table[iface]['loopback_action'] == action) + + print(result.exit_code, result.output) + assert result.exit_code == 0 + + def test_show_ip_interfaces_loopback_action(self): + runner = CliRunner() + result = runner.invoke(show.cli.commands["ip"].commands["interfaces"].commands["loopback-action"], []) + + print(result.exit_code, result.output) + assert result.exit_code == 0 + assert result.output == show_ip_interfaces_loopback_action_output + + def test_config_loopback_action_on_non_ip_interface(self): + runner = CliRunner() + db = Db() + obj = {'config_db':db.cfgdb} + action = 'forward' + iface = 'Ethernet0.11' + ERROR_MSG = "Error: Interface {} is not an IP interface".format(iface) + + result = runner.invoke(config.config.commands['interface'].commands["ip"].commands['loopback-action'], [iface, action], obj=obj) + + print(result.exit_code, result.output) + assert result.exit_code != 0 + assert ERROR_MSG in result.output + + def test_config_loopback_action_invalid_action(self): + runner = CliRunner() + db = Db() + obj = {'config_db':db.cfgdb} + action = 'xforwardx' + iface = 'Ethernet0' + ERROR_MSG = "Error: Invalid action" + + result = runner.invoke(config.config.commands['interface'].commands["ip"].commands['loopback-action'], [iface, action], obj=obj) + + print(result.exit_code, result.output) + assert result.exit_code != 0 + assert ERROR_MSG in result.output + + @classmethod + def teardown_class(cls): + print("\nTEARDOWN") + os.environ['UTILITIES_UNIT_TESTING'] = "0" diff --git a/tests/memory_check_handler_test.py b/tests/memory_check_handler_test.py new file mode 100644 index 0000000000..12cbbe8f28 --- /dev/null +++ b/tests/memory_check_handler_test.py @@ -0,0 +1,28 @@ +""" These tests check the memory_threshold_check_handler script monit description string handling while the rest of auto thechsupport is unit tested by coredump_gen_handler_test.py """ + +import sys +from unittest.mock import patch, ANY +from utilities_common.auto_techsupport_helper import EVENT_TYPE_MEMORY +from utilities_common.db import Db + +sys.path.append("scripts") +import memory_threshold_check_handler + + +@patch("os.environ.get", lambda var: "status code 2 -- swss") +def test_memory_threshold_check_handler_host(): + with patch('memory_threshold_check_handler.invoke_ts_command_rate_limited') as invoke_ts: + memory_threshold_check_handler.main() + invoke_ts.assert_called_once_with(ANY, EVENT_TYPE_MEMORY, 'swss') + +@patch("os.environ.get", lambda var: "status code 2 -- no output") +def test_memory_threshold_check_handler_host(): + with patch('memory_threshold_check_handler.invoke_ts_command_rate_limited') as invoke_ts: + memory_threshold_check_handler.main() + invoke_ts.assert_called_once_with(ANY, EVENT_TYPE_MEMORY, None) + +@patch("os.environ.get", lambda var: "foo bar") +def test_memory_threshold_check_handler_host(): + with patch('memory_threshold_check_handler.invoke_ts_command_rate_limited') as invoke_ts: + memory_threshold_check_handler.main() + invoke_ts.assert_not_called() diff --git a/tests/memory_threshold_check/config_db.json b/tests/memory_threshold_check/config_db.json new file mode 100644 index 0000000000..a270db5bc1 --- /dev/null +++ b/tests/memory_threshold_check/config_db.json @@ -0,0 +1,12 @@ +{ + "AUTO_TECHSUPPORT|GLOBAL": { + "available_mem_threshold": "10.0", + "min_available_mem": "200" + }, + "AUTO_TECHSUPPORT_FEATURE|swss": { + "available_mem_threshold": "50.0" + }, + "AUTO_TECHSUPPORT_FEATURE|telemetry": { + "available_mem_threshold": "50.0" + } +} diff --git a/tests/memory_threshold_check/state_db.json b/tests/memory_threshold_check/state_db.json new file mode 100644 index 0000000000..0cd8c34e13 --- /dev/null +++ b/tests/memory_threshold_check/state_db.json @@ -0,0 +1,10 @@ +{ + "DOCKER_STATS|b77647f643a2": { + "MEM%": "10", + "NAME": "swss1" + }, + "DOCKER_STATS|b77647f643a3": { + "MEM%": "10", + "NAME": "telemetry" + } +} diff --git a/tests/memory_threshold_check/state_db_2.json b/tests/memory_threshold_check/state_db_2.json new file mode 100644 index 0000000000..67f18ac89f --- /dev/null +++ b/tests/memory_threshold_check/state_db_2.json @@ -0,0 +1,14 @@ +{ + "DOCKER_STATS|b77647f643a1": { + "MEM%": "10.5", + "NAME": "swss1" + }, + "DOCKER_STATS|b77647f643a2": { + "MEM%": "10.1", + "NAME": "swss2" + }, + "DOCKER_STATS|b77647f643a3": { + "MEM%": "80.6", + "NAME": "telemetry" + } +} diff --git a/tests/memory_threshold_check/state_db_3.json b/tests/memory_threshold_check/state_db_3.json new file mode 100644 index 0000000000..0ded64771a --- /dev/null +++ b/tests/memory_threshold_check/state_db_3.json @@ -0,0 +1,14 @@ +{ + "DOCKER_STATS|b77647f643a1": { + "MEM%": "80.1", + "NAME": "swss1" + }, + "DOCKER_STATS|b77647f643a2": { + "MEM%": "10.1", + "NAME": "swss2" + }, + "DOCKER_STATS|b77647f643a3": { + "MEM%": "10.2", + "NAME": "telemetry" + } +} diff --git a/tests/memory_threshold_check_test.py b/tests/memory_threshold_check_test.py new file mode 100644 index 0000000000..b6b4b2fee8 --- /dev/null +++ b/tests/memory_threshold_check_test.py @@ -0,0 +1,71 @@ +import os +import sys +import pytest +from unittest import mock +from .mock_tables import dbconnector +from utilities_common.general import load_module_from_source + +test_path = os.path.dirname(os.path.abspath(__file__)) +modules_path = os.path.dirname(test_path) +scripts_path = os.path.join(modules_path, 'scripts') +sys.path.insert(0, scripts_path) + +memory_threshold_check_path = os.path.join(scripts_path, 'memory_threshold_check.py') +memory_threshold_check = load_module_from_source('memory_threshold_check.py', memory_threshold_check_path) + +@pytest.fixture() +def setup_dbs_regular_mem_usage(): + cfg_db = dbconnector.dedicated_dbs.get('CONFIG_DB') + state_db = dbconnector.dedicated_dbs.get('STATE_DB') + dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(test_path, 'memory_threshold_check', 'config_db') + dbconnector.dedicated_dbs['STATE_DB'] = os.path.join(test_path, 'memory_threshold_check', 'state_db') + yield + dbconnector.dedicated_dbs['CONFIG_DB'] = cfg_db + dbconnector.dedicated_dbs['STATE_DB'] = state_db + + +@pytest.fixture() +def setup_dbs_telemetry_high_mem_usage(): + memory_threshold_check.MemoryStats.get_sys_memory_stats = mock.Mock(return_value={'MemAvailable': 10000000, 'MemTotal': 20000000}) + cfg_db = dbconnector.dedicated_dbs.get('CONFIG_DB') + state_db = dbconnector.dedicated_dbs.get('STATE_DB') + dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(test_path, 'memory_threshold_check', 'config_db') + dbconnector.dedicated_dbs['STATE_DB'] = os.path.join(test_path, 'memory_threshold_check', 'state_db_2') + yield + dbconnector.dedicated_dbs['CONFIG_DB'] = cfg_db + dbconnector.dedicated_dbs['STATE_DB'] = state_db + + +@pytest.fixture() +def setup_dbs_swss_high_mem_usage(): + memory_threshold_check.MemoryStats.get_sys_memory_stats = mock.Mock(return_value={'MemAvailable': 10000000, 'MemTotal': 20000000}) + cfg_db = dbconnector.dedicated_dbs.get('CONFIG_DB') + state_db = dbconnector.dedicated_dbs.get('STATE_DB') + dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(test_path, 'memory_threshold_check', 'config_db') + dbconnector.dedicated_dbs['STATE_DB'] = os.path.join(test_path, 'memory_threshold_check', 'state_db_3') + yield + dbconnector.dedicated_dbs['CONFIG_DB'] = cfg_db + dbconnector.dedicated_dbs['STATE_DB'] = state_db + + +def test_memory_check_host_not_crossed(setup_dbs_regular_mem_usage): + memory_threshold_check.MemoryStats.get_sys_memory_stats = mock.Mock(return_value={'MemAvailable': 1000000, 'MemTotal': 2000000}) + assert memory_threshold_check.main() == (memory_threshold_check.EXIT_SUCCESS, '') + + +def test_memory_check_host_less_then_min_required(setup_dbs_regular_mem_usage): + memory_threshold_check.MemoryStats.get_sys_memory_stats = mock.Mock(return_value={'MemAvailable': 1000, 'MemTotal': 2000000}) + assert memory_threshold_check.main() == (memory_threshold_check.EXIT_THRESHOLD_CROSSED, '') + + +def test_memory_check_host_threshold_crossed(setup_dbs_regular_mem_usage): + memory_threshold_check.MemoryStats.get_sys_memory_stats = mock.Mock(return_value={'MemAvailable': 2000000, 'MemTotal': 20000000}) + assert memory_threshold_check.main() == (memory_threshold_check.EXIT_THRESHOLD_CROSSED, '') + + +def test_memory_check_telemetry_threshold_crossed(setup_dbs_telemetry_high_mem_usage): + assert memory_threshold_check.main() == (memory_threshold_check.EXIT_THRESHOLD_CROSSED, 'telemetry') + + +def test_memory_check_swss_threshold_crossed(setup_dbs_swss_high_mem_usage): + assert memory_threshold_check.main() == (memory_threshold_check.EXIT_THRESHOLD_CROSSED, 'swss') diff --git a/tests/mock_platform_sfputil/mock_platform_sfputil.py b/tests/mock_platform_sfputil/mock_platform_sfputil.py new file mode 100644 index 0000000000..5c3ea2e248 --- /dev/null +++ b/tests/mock_platform_sfputil/mock_platform_sfputil.py @@ -0,0 +1,41 @@ +import json +import os +from sonic_platform_base.platform_base import PlatformBase +from sonic_platform_base.chassis_base import ChassisBase +from sonic_platform_base.sfp_base import SfpBase +import utilities_common.platform_sfputil_helper as platform_sfputil_helper + +portMap = None +RJ45Ports = None + +class mock_Chassis(ChassisBase): + def __init__(self): + ChassisBase.__init__(self) + + def get_port_or_cage_type(self, index): + if index in RJ45Ports: + return SfpBase.SFP_PORT_TYPE_BIT_RJ45 + else: + raise NotImplementedError + +def mock_logical_port_name_to_physical_port_list(port_name): + index = portMap.get(port_name) + if not index: + index = 0 + return [index] + +def mock_platform_sfputil_read_porttab_mappings(): + global portMap + global RJ45Ports + + with open(os.path.join(os.path.dirname(__file__), 'portmap.json')) as pm: + jsonobj = json.load(pm) + portMap = jsonobj['portMap'] + RJ45Ports = jsonobj['RJ45Ports'] + +def mock_platform_sfputil_helper(): + platform_sfputil_helper.platform_chassis = mock_Chassis() + platform_sfputil_helper.platform_sfputil = True + platform_sfputil_helper.platform_porttab_mapping_read = False + platform_sfputil_helper.platform_sfputil_read_porttab_mappings = mock_platform_sfputil_read_porttab_mappings + platform_sfputil_helper.logical_port_name_to_physical_port_list = mock_logical_port_name_to_physical_port_list diff --git a/tests/mock_platform_sfputil/portmap.json b/tests/mock_platform_sfputil/portmap.json new file mode 100644 index 0000000000..eec9a9f40d --- /dev/null +++ b/tests/mock_platform_sfputil/portmap.json @@ -0,0 +1,8 @@ +{ + "portMap": { + "Ethernet29": 1 + }, + "RJ45Ports": [ + 1 + ] +} diff --git a/tests/mock_tables/appl_db.json b/tests/mock_tables/appl_db.json index 81fa7c7297..8554a07eaf 100644 --- a/tests/mock_tables/appl_db.json +++ b/tests/mock_tables/appl_db.json @@ -39,7 +39,8 @@ "adv_speeds": "50000,10000", "interface_type": "CR4", "adv_interface_types": "CR4,CR2", - "autoneg": "on" + "autoneg": "on", + "link_training": "on" }, "PORT_TABLE:Ethernet16": { "index": "4", @@ -101,7 +102,8 @@ "admin_status": "up", "autoneg": "off", "adv_speeds": "all", - "adv_interface_types": "all" + "adv_interface_types": "all", + "link_training": "on" }, "PORT_TABLE:Ethernet112": { "index": "28", @@ -114,7 +116,8 @@ "mtu": "9100", "tpid": "0x8100", "fec": "rs", - "admin_status": "up" + "admin_status": "up", + "link_training": "off" }, "PORT_TABLE:Ethernet116": { "index": "29", @@ -185,10 +188,36 @@ "admin_status": "up", "vlan": "10" }, - "INTF_TABLE:Eth32.10": { + "INTF_TABLE:Eth36.10": { "admin_status": "up", + "vrf_name": "Vrf1", "vlan": "100" }, + "INTF_TABLE:Po0001.10": { + "admin_status": "up", + "vrf_name": "Vrf1", + "vlan": "100" + }, + "INTF_TABLE:Ethernet0.10|10.11.12.13/24": { + "family": "IPv4", + "scope": "global" + }, + "INTF_TABLE:Eth36.10|32.10.11.12/24": { + "family": "IPv4", + "scope": "global" + }, + "INTF_TABLE:Po0001.10|10.10.11.12/24": { + "family": "IPv4", + "scope": "global" + }, + "INTF_TABLE:Eth36.10|3210::12/126": { + "family": "IPv6", + "scope": "global" + }, + "INTF_TABLE:Po0001.10|1010::12/126": { + "family": "IPv6", + "scope": "global" + }, "_GEARBOX_TABLE:phy:1": { "name": "sesto-1", "phy_id": "1", @@ -260,5 +289,58 @@ }, "VXLAN_REMOTE_VNI_TABLE:Vlan200:25.25.25.27": { "vni": "200" + }, + "VXLAN_FDB_TABLE:Vlan200:00:02:00:00:47:e2": { + "remote_vtep": "2.2.2.2", + "type": "dynamic", + "vni": "200" + }, + "VXLAN_FDB_TABLE:Vlan200:00:02:00:00:47:e3": { + "remote_vtep": "2.2.2.3", + "type": "dynamic", + "vni": "200" + }, + "MUX_CABLE_TABLE:Ethernet32": { + "state": "active" + }, + "MUX_CABLE_TABLE:Ethernet0": { + "state": "active" + }, + "MUX_CABLE_TABLE:Ethernet4": { + "state": "standby" + }, + "MUX_CABLE_TABLE:Ethernet8": { + "state": "standby" + }, + "MUX_CABLE_TABLE:Ethernet16": { + "state": "standby" + }, + "MUX_CABLE_TABLE:Ethernet12": { + "state": "active" + }, + "TUNNEL_ROUTE_TABLE:10.2.1.1": { + "alias": "Vlan1000" + }, + "TUNNEL_ROUTE_TABLE:10.3.1.1": { + "alias": "Vlan1000" + }, + "VNET_ROUTE_TUNNEL_TABLE:test_v4_in_v4-0:160.163.191.1/32": { + "endpoint":"100.251.7.1", + "endpoint_monitor":"100.251.7.1" + }, + "VNET_ROUTE_TUNNEL_TABLE:Vnet_v6_in_v6-0:fddd:a156:a251::a6:1/128": { + "endpoint": "fddd:a100:a251::a10:1,fddd:a101:a251::a10:1", + "endpoint_monitor":"fddd:a100:a251::a10:1,fddd:a101:a251::a10:1" + }, + "VNET_ROUTE_TUNNEL_TABLE:test_v4_in_v4-0:160.162.191.1/32": { + "endpoint":"100.251.7.1", + "endpoint_monitor":"100.251.7.1" + }, + "VNET_ROUTE_TUNNEL_TABLE:test_v4_in_v4-0:160.164.191.1/32": { + "endpoint":"100.251.7.1", + "endpoint_monitor":"100.251.7.1" + }, + "BGP_PROFILE_TABLE:FROM_SDN_SLB_ROUTES": { + "community_id" : "1234:1235" } } diff --git a/tests/mock_tables/asic0/config_db.json b/tests/mock_tables/asic0/config_db.json index 77874eb59c..66b51f4ccb 100644 --- a/tests/mock_tables/asic0/config_db.json +++ b/tests/mock_tables/asic0/config_db.json @@ -38,6 +38,17 @@ "speed": "40000", "asic_port_name": "Eth1-ASIC0" }, + "PORT|Ethernet16": { + "lanes": "17,18,19,20", + "description": "ARISTA01T2:Ethernet3/3/1", + "pfc_asym": "off", + "mtu": "9100", + "alias": "Ethernet1/5", + "admin_status": "up", + "role": "Ext", + "speed": "40000", + "asic_port_name": "Eth1-ASIC0" + }, "PORT|Ethernet-BP0" : { "lanes": "93,94,95,96", "description": "ASIC1:Eth0-ASIC1", diff --git a/tests/mock_tables/asic0/counters_db.json b/tests/mock_tables/asic0/counters_db.json index 5c144393f2..53e3b558a2 100644 --- a/tests/mock_tables/asic0/counters_db.json +++ b/tests/mock_tables/asic0/counters_db.json @@ -77,7 +77,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "499", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "2", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "7886", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "13" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "13", + "SAI_QUEUE_STAT_BYTES": "30", + "SAI_QUEUE_STAT_DROPPED_BYTES": "74", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "56", + "SAI_QUEUE_STAT_PACKETS": "68", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "61" }, "COUNTERS:oid:0x1000000001001": { @@ -98,7 +103,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "226", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "5", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "8318", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "92" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "92", + "SAI_QUEUE_STAT_BYTES": "31", + "SAI_QUEUE_STAT_DROPPED_BYTES": "73", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "55", + "SAI_QUEUE_STAT_PACKETS": "69", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "62" }, "COUNTERS:oid:0x1000000001002": { @@ -119,7 +129,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "999", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "0", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "9885", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "99" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "99", + "SAI_QUEUE_STAT_BYTES": "32", + "SAI_QUEUE_STAT_DROPPED_BYTES": "72", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "54", + "SAI_QUEUE_STAT_PACKETS": "70", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "63" }, "COUNTERS:oid:0x1000000001003": { @@ -140,7 +155,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "470", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "5", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "9734", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "35" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "35", + "SAI_QUEUE_STAT_BYTES": "33", + "SAI_QUEUE_STAT_DROPPED_BYTES": "71", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "53", + "SAI_QUEUE_STAT_PACKETS": "71", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "64" }, "COUNTERS:oid:0x1000000001004": { @@ -161,7 +181,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "880", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "1", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "8957", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "10" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "10", + "SAI_QUEUE_STAT_BYTES": "34", + "SAI_QUEUE_STAT_DROPPED_BYTES": "70", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "52", + "SAI_QUEUE_STAT_PACKETS": "72", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "65" }, "COUNTERS:oid:0x1000000001005": { @@ -182,7 +207,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "633", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "8", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "9538", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "54" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "54", + "SAI_QUEUE_STAT_BYTES": "35", + "SAI_QUEUE_STAT_DROPPED_BYTES": "69", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "51", + "SAI_QUEUE_STAT_PACKETS": "73", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "66" }, "COUNTERS:oid:0x1000000001006": { @@ -203,7 +233,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "934", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "6", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "1060", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "53" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "53", + "SAI_QUEUE_STAT_BYTES": "36", + "SAI_QUEUE_STAT_DROPPED_BYTES": "68", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "50", + "SAI_QUEUE_STAT_PACKETS": "74", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "67" }, "COUNTERS:oid:0x1000000001007": { @@ -224,7 +259,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "216", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "7", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "4283", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "0" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "0", + "SAI_QUEUE_STAT_BYTES": "37", + "SAI_QUEUE_STAT_DROPPED_BYTES": "67", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "49", + "SAI_QUEUE_STAT_PACKETS": "75", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "68" }, "COUNTERS:oid:0x1000000001008": { @@ -245,7 +285,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "235", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "6", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "3256", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "22" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "22", + "SAI_QUEUE_STAT_BYTES": "38", + "SAI_QUEUE_STAT_DROPPED_BYTES": "66", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "48", + "SAI_QUEUE_STAT_PACKETS": "76", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "67" }, "COUNTERS:oid:0x1000000001009": { @@ -266,7 +311,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "172", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "9", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "8458", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "35" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "35", + "SAI_QUEUE_STAT_BYTES": "39", + "SAI_QUEUE_STAT_DROPPED_BYTES": "65", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "47", + "SAI_QUEUE_STAT_PACKETS": "77", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "68" }, "COUNTERS:oid:0x1000000001010": { @@ -287,7 +337,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "360", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "1", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "1394", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "13" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "13", + "SAI_QUEUE_STAT_BYTES": "40", + "SAI_QUEUE_STAT_DROPPED_BYTES": "64", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "46", + "SAI_QUEUE_STAT_PACKETS": "78", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "69" }, "COUNTERS:oid:0x1000000001011": { @@ -308,7 +363,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "777", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "4", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "8694", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "34" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "34", + "SAI_QUEUE_STAT_BYTES": "41", + "SAI_QUEUE_STAT_DROPPED_BYTES": "63", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "45", + "SAI_QUEUE_STAT_PACKETS": "79", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "70" }, "COUNTERS:oid:0x1000000001012": { @@ -329,7 +389,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "444", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "4", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "6390", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "11" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "11", + "SAI_QUEUE_STAT_BYTES": "42", + "SAI_QUEUE_STAT_DROPPED_BYTES": "62", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "44", + "SAI_QUEUE_STAT_PACKETS": "80", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "71" }, "COUNTERS:oid:0x1000000001013": { @@ -350,7 +415,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "496", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "5", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "3181", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "96" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "96", + "SAI_QUEUE_STAT_BYTES": "43", + "SAI_QUEUE_STAT_DROPPED_BYTES": "61", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "43", + "SAI_QUEUE_STAT_PACKETS": "81", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "72" }, "COUNTERS:oid:0x1000000001014": { @@ -371,7 +441,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "126", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "1", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "487", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "69" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "69", + "SAI_QUEUE_STAT_BYTES": "44", + "SAI_QUEUE_STAT_DROPPED_BYTES": "60", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "42", + "SAI_QUEUE_STAT_PACKETS": "82", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "73" }, "COUNTERS:oid:0x1000000001015": { @@ -392,7 +467,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "347", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "6", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "2844", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "88" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "88", + "SAI_QUEUE_STAT_BYTES": "45", + "SAI_QUEUE_STAT_DROPPED_BYTES": "59", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "41", + "SAI_QUEUE_STAT_PACKETS": "83", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "74" }, "COUNTERS:oid:0x1000000002000": { @@ -413,7 +493,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "997", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "3", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "4406", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "93" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "93", + "SAI_QUEUE_STAT_BYTES": "46", + "SAI_QUEUE_STAT_DROPPED_BYTES": "58", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "40", + "SAI_QUEUE_STAT_PACKETS": "84", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "75" }, "COUNTERS:oid:0x1000000002001": { @@ -434,7 +519,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "560", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "7", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "4320", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "95" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "95", + "SAI_QUEUE_STAT_BYTES": "47", + "SAI_QUEUE_STAT_DROPPED_BYTES": "57", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "39", + "SAI_QUEUE_STAT_PACKETS": "85", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "76" }, "COUNTERS:oid:0x1000000002002": { @@ -455,7 +545,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "196", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "2", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "150", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "56" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "56", + "SAI_QUEUE_STAT_BYTES": "48", + "SAI_QUEUE_STAT_DROPPED_BYTES": "56", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "38", + "SAI_QUEUE_STAT_PACKETS": "86", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "77" }, "COUNTERS:oid:0x1000000002003": { @@ -476,7 +571,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "515", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "3", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "5525", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "57" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "57", + "SAI_QUEUE_STAT_BYTES": "49", + "SAI_QUEUE_STAT_DROPPED_BYTES": "55", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "37", + "SAI_QUEUE_STAT_PACKETS": "87", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "78" }, "COUNTERS:oid:0x1000000002004": { @@ -497,7 +597,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "995", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "6", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "9133", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "46" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "46", + "SAI_QUEUE_STAT_BYTES": "50", + "SAI_QUEUE_STAT_DROPPED_BYTES": "54", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "36", + "SAI_QUEUE_STAT_PACKETS": "88", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "79" }, "COUNTERS:oid:0x1000000002005": { @@ -518,7 +623,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "30", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "8", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "1972", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "4" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "4", + "SAI_QUEUE_STAT_BYTES": "51", + "SAI_QUEUE_STAT_DROPPED_BYTES": "53", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "35", + "SAI_QUEUE_STAT_PACKETS": "89", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "80" }, "COUNTERS:oid:0x1000000002006": { @@ -539,7 +649,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "908", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "3", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "6804", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "10" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "10", + "SAI_QUEUE_STAT_BYTES": "52", + "SAI_QUEUE_STAT_DROPPED_BYTES": "52", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "34", + "SAI_QUEUE_STAT_PACKETS": "90", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "81" }, "COUNTERS:oid:0x1000000002007": { @@ -560,7 +675,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "875", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "0", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "2979", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "48" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "48", + "SAI_QUEUE_STAT_BYTES": "53", + "SAI_QUEUE_STAT_DROPPED_BYTES": "51", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "33", + "SAI_QUEUE_STAT_PACKETS": "91", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "82" }, "COUNTERS:oid:0x1000000002008": { @@ -581,7 +701,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "67", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "2", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "4005", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "8" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "8", + "SAI_QUEUE_STAT_BYTES": "54", + "SAI_QUEUE_STAT_DROPPED_BYTES": "50", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "32", + "SAI_QUEUE_STAT_PACKETS": "92", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "83" }, "COUNTERS:oid:0x1000000002009": { @@ -602,7 +727,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "226", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "8", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "1732", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "86" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "86", + "SAI_QUEUE_STAT_BYTES": "55", + "SAI_QUEUE_STAT_DROPPED_BYTES": "49", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "31", + "SAI_QUEUE_STAT_PACKETS": "93", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "84" }, "COUNTERS:oid:0x1000000002010": { @@ -623,7 +753,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "567", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "5", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "9822", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "32" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "32", + "SAI_QUEUE_STAT_BYTES": "56", + "SAI_QUEUE_STAT_DROPPED_BYTES": "48", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "30", + "SAI_QUEUE_STAT_PACKETS": "94", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "85" }, "COUNTERS:oid:0x1000000002011": { @@ -644,7 +779,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "527", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "7", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "2772", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "1" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "1", + "SAI_QUEUE_STAT_BYTES": "57", + "SAI_QUEUE_STAT_DROPPED_BYTES": "47", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "29", + "SAI_QUEUE_STAT_PACKETS": "95", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "86" }, "COUNTERS:oid:0x1000000002012": { @@ -665,7 +805,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "537", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "4", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "4423", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "30" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "30", + "SAI_QUEUE_STAT_BYTES": "58", + "SAI_QUEUE_STAT_DROPPED_BYTES": "46", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "28", + "SAI_QUEUE_STAT_PACKETS": "96", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "87" }, "COUNTERS:oid:0x1000000002013": { @@ -686,7 +831,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "364", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "3", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "6280", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "94" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "94", + "SAI_QUEUE_STAT_BYTES": "59", + "SAI_QUEUE_STAT_DROPPED_BYTES": "45", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "27", + "SAI_QUEUE_STAT_PACKETS": "97", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "88" }, "COUNTERS:oid:0x1000000002014": { @@ -707,7 +857,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "69", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "8", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "5812", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "39" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "39", + "SAI_QUEUE_STAT_BYTES": "60", + "SAI_QUEUE_STAT_DROPPED_BYTES": "44", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "26", + "SAI_QUEUE_STAT_PACKETS": "98", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "89" }, "COUNTERS:oid:0x1000000002015": { @@ -728,7 +883,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "115", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "8", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "7589", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "9" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "9", + "SAI_QUEUE_STAT_BYTES": "61", + "SAI_QUEUE_STAT_DROPPED_BYTES": "43", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "25", + "SAI_QUEUE_STAT_PACKETS": "99", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "90" }, "COUNTERS:oid:0x1000000003000": { @@ -749,7 +909,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "719", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "9", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "7806", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "73" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "73", + "SAI_QUEUE_STAT_BYTES": "62", + "SAI_QUEUE_STAT_DROPPED_BYTES": "42", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "24", + "SAI_QUEUE_STAT_PACKETS": "100", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "91" }, "COUNTERS:oid:0x1000000003001": { @@ -770,7 +935,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "737", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "4", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "6904", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "71" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "71", + "SAI_QUEUE_STAT_BYTES": "63", + "SAI_QUEUE_STAT_DROPPED_BYTES": "41", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "23", + "SAI_QUEUE_STAT_PACKETS": "101", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "92" }, "COUNTERS:oid:0x1000000003002": { @@ -791,7 +961,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "946", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "9", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "7498", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "13" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "13", + "SAI_QUEUE_STAT_BYTES": "64", + "SAI_QUEUE_STAT_DROPPED_BYTES": "40", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "22", + "SAI_QUEUE_STAT_PACKETS": "102", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "93" }, "COUNTERS:oid:0x1000000003003": { @@ -812,7 +987,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "5", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "0", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "1876", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "43" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "43", + "SAI_QUEUE_STAT_BYTES": "65", + "SAI_QUEUE_STAT_DROPPED_BYTES": "39", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "21", + "SAI_QUEUE_STAT_PACKETS": "103", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "94" }, "COUNTERS:oid:0x1000000003004": { @@ -833,7 +1013,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "648", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "8", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "1599", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "78" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "78", + "SAI_QUEUE_STAT_BYTES": "66", + "SAI_QUEUE_STAT_DROPPED_BYTES": "38", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "20", + "SAI_QUEUE_STAT_PACKETS": "104", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "95" }, "COUNTERS:oid:0x1000000003005": { @@ -854,7 +1039,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "127", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "8", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "2939", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "48" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "48", + "SAI_QUEUE_STAT_BYTES": "67", + "SAI_QUEUE_STAT_DROPPED_BYTES": "37", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "19", + "SAI_QUEUE_STAT_PACKETS": "105", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "96" }, "COUNTERS:oid:0x1000000003006": { @@ -875,7 +1065,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "940", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "0", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "3828", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "20" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "20", + "SAI_QUEUE_STAT_BYTES": "68", + "SAI_QUEUE_STAT_DROPPED_BYTES": "36", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "18", + "SAI_QUEUE_STAT_PACKETS": "106", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "97" }, "COUNTERS:oid:0x1000000003007": { @@ -896,7 +1091,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "685", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "9", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "9058", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "54" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "54", + "SAI_QUEUE_STAT_BYTES": "69", + "SAI_QUEUE_STAT_DROPPED_BYTES": "35", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "17", + "SAI_QUEUE_STAT_PACKETS": "107", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "98" }, "COUNTERS:oid:0x1000000003008": { @@ -917,7 +1117,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "181", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "4", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "4963", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "85" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "85", + "SAI_QUEUE_STAT_BYTES": "70", + "SAI_QUEUE_STAT_DROPPED_BYTES": "34", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "16", + "SAI_QUEUE_STAT_PACKETS": "108", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "99" }, "COUNTERS:oid:0x1000000003009": { @@ -938,7 +1143,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "359", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "8", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "5498", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "36" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "36", + "SAI_QUEUE_STAT_BYTES": "71", + "SAI_QUEUE_STAT_DROPPED_BYTES": "33", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "15", + "SAI_QUEUE_STAT_PACKETS": "109", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "100" }, "COUNTERS:oid:0x1000000003010": { @@ -959,7 +1169,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "902", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "0", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "8748", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "26" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "26", + "SAI_QUEUE_STAT_BYTES": "72", + "SAI_QUEUE_STAT_DROPPED_BYTES": "32", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "14", + "SAI_QUEUE_STAT_PACKETS": "110", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "101" }, "COUNTERS:oid:0x1000000003011": { @@ -980,7 +1195,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "116", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "4", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "8272", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "94" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "94", + "SAI_QUEUE_STAT_BYTES": "73", + "SAI_QUEUE_STAT_DROPPED_BYTES": "31", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "13", + "SAI_QUEUE_STAT_PACKETS": "111", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "102" }, "COUNTERS:oid:0x1000000003012": { @@ -1001,7 +1221,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "74", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "8", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "5817", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "0" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "0", + "SAI_QUEUE_STAT_BYTES": "74", + "SAI_QUEUE_STAT_DROPPED_BYTES": "30", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "12", + "SAI_QUEUE_STAT_PACKETS": "112", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "103" }, "COUNTERS:oid:0x1000000003013": { @@ -1022,7 +1247,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "253", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "4", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "4833", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "65" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "65", + "SAI_QUEUE_STAT_BYTES": "75", + "SAI_QUEUE_STAT_DROPPED_BYTES": "29", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "11", + "SAI_QUEUE_STAT_PACKETS": "113", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "104" }, "COUNTERS:oid:0x1000000003014": { @@ -1043,7 +1273,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "573", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "5", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "2860", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "48" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "48", + "SAI_QUEUE_STAT_BYTES": "76", + "SAI_QUEUE_STAT_DROPPED_BYTES": "28", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "10", + "SAI_QUEUE_STAT_PACKETS": "114", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "105" }, "COUNTERS:oid:0x1000000003015": { @@ -1064,7 +1299,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "230", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "4", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "6469", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "50" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "50", + "SAI_QUEUE_STAT_BYTES": "77", + "SAI_QUEUE_STAT_DROPPED_BYTES": "27", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "9", + "SAI_QUEUE_STAT_PACKETS": "115", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "106" }, "COUNTERS:oid:0x1000000004000": { @@ -1085,7 +1325,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "962", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "2", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "3473", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "45" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "45", + "SAI_QUEUE_STAT_BYTES": "78", + "SAI_QUEUE_STAT_DROPPED_BYTES": "26", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "8", + "SAI_QUEUE_STAT_PACKETS": "116", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "107" }, "COUNTERS:oid:0x1000000004001": { @@ -1106,7 +1351,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "788", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "8", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "8089", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "15" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "15", + "SAI_QUEUE_STAT_BYTES": "79", + "SAI_QUEUE_STAT_DROPPED_BYTES": "25", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "7", + "SAI_QUEUE_STAT_PACKETS": "117", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "108" }, "COUNTERS:oid:0x1000000004002": { @@ -1127,7 +1377,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "413", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "3", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "9569", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "8" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "8", + "SAI_QUEUE_STAT_BYTES": "80", + "SAI_QUEUE_STAT_DROPPED_BYTES": "24", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "6", + "SAI_QUEUE_STAT_PACKETS": "118", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "109" }, "COUNTERS:oid:0x1000000004003": { @@ -1148,7 +1403,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "701", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "7", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "8669", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "96" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "96", + "SAI_QUEUE_STAT_BYTES": "81", + "SAI_QUEUE_STAT_DROPPED_BYTES": "23", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "5", + "SAI_QUEUE_STAT_PACKETS": "119", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "110" }, "COUNTERS:oid:0x1000000004004": { @@ -1169,7 +1429,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "860", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "4", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "3633", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "92" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "92", + "SAI_QUEUE_STAT_BYTES": "82", + "SAI_QUEUE_STAT_DROPPED_BYTES": "22", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "4", + "SAI_QUEUE_STAT_PACKETS": "120", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "111" }, "COUNTERS:oid:0x1000000004005": { @@ -1190,7 +1455,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "45", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "8", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "5074", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "10" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "10", + "SAI_QUEUE_STAT_BYTES": "83", + "SAI_QUEUE_STAT_DROPPED_BYTES": "21", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "3", + "SAI_QUEUE_STAT_PACKETS": "121", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "112" }, "COUNTERS:oid:0x1000000004006": { @@ -1211,7 +1481,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "6", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "7", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "3372", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "93" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "93", + "SAI_QUEUE_STAT_BYTES": "84", + "SAI_QUEUE_STAT_DROPPED_BYTES": "20", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "2", + "SAI_QUEUE_STAT_PACKETS": "122", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "113" }, "COUNTERS:oid:0x1000000004007": { @@ -1232,7 +1507,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "440", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "1", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "1084", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "7" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "7", + "SAI_QUEUE_STAT_BYTES": "85", + "SAI_QUEUE_STAT_DROPPED_BYTES": "19", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "1", + "SAI_QUEUE_STAT_PACKETS": "123", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "114" }, "COUNTERS:oid:0x1000000004008": { @@ -1253,7 +1533,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "281", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "1", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "5858", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "45" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "45", + "SAI_QUEUE_STAT_BYTES": "86", + "SAI_QUEUE_STAT_DROPPED_BYTES": "18", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "0", + "SAI_QUEUE_STAT_PACKETS": "124", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "115" }, "COUNTERS:oid:0x1000000004009": { @@ -1274,7 +1559,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "636", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "8", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "1734", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "63" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "63", + "SAI_QUEUE_STAT_BYTES": "87", + "SAI_QUEUE_STAT_DROPPED_BYTES": "17", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "1", + "SAI_QUEUE_STAT_PACKETS": "125", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "116" }, "COUNTERS:oid:0x1000000004010": { @@ -1295,7 +1585,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "625", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "7", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "3991", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "1" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "1", + "SAI_QUEUE_STAT_BYTES": "88", + "SAI_QUEUE_STAT_DROPPED_BYTES": "16", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "2", + "SAI_QUEUE_STAT_PACKETS": "126", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "117" }, "COUNTERS:oid:0x1000000004011": { @@ -1316,7 +1611,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "778", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "0", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "133", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "29" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "29", + "SAI_QUEUE_STAT_BYTES": "89", + "SAI_QUEUE_STAT_DROPPED_BYTES": "15", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "3", + "SAI_QUEUE_STAT_PACKETS": "127", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "118" }, "COUNTERS:oid:0x1000000004012": { @@ -1337,7 +1637,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "573", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "7", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "6631", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "57" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "57", + "SAI_QUEUE_STAT_BYTES": "90", + "SAI_QUEUE_STAT_DROPPED_BYTES": "14", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "4", + "SAI_QUEUE_STAT_PACKETS": "128", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "119" }, "COUNTERS:oid:0x1000000004013": { @@ -1358,7 +1663,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "768", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "1", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "9010", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "41" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "41", + "SAI_QUEUE_STAT_BYTES": "91", + "SAI_QUEUE_STAT_DROPPED_BYTES": "13", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "5", + "SAI_QUEUE_STAT_PACKETS": "129", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "120" }, "COUNTERS:oid:0x1000000004014": { @@ -1379,7 +1689,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "288", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "1", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "4343", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "60" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "60", + "SAI_QUEUE_STAT_BYTES": "92", + "SAI_QUEUE_STAT_DROPPED_BYTES": "12", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "6", + "SAI_QUEUE_STAT_PACKETS": "130", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "121" }, "COUNTERS:oid:0x1000000004015": { @@ -1400,7 +1715,12 @@ "PFC_WD_QUEUE_STATS_TX_PACKETS_LAST": "758", "PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST": "7", "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "7599", - "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "8" + "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "8", + "SAI_QUEUE_STAT_BYTES": "93", + "SAI_QUEUE_STAT_DROPPED_BYTES": "11", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "7", + "SAI_QUEUE_STAT_PACKETS": "131", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "122" }, "COUNTERS_RIF_NAME_MAP": { @@ -1693,6 +2013,344 @@ "Ethernet-BP4:14": "oid:0x1000000004014", "Ethernet-BP4:15": "oid:0x1000000004015" }, + "COUNTERS_QUEUE_PORT_MAP": { + "oid:0x1000000001000": "oid:0x1000000000002", + "oid:0x1000000001001": "oid:0x1000000000002", + "oid:0x1000000001002": "oid:0x1000000000002", + "oid:0x1000000001003": "oid:0x1000000000002", + "oid:0x1000000001004": "oid:0x1000000000002", + "oid:0x1000000001005": "oid:0x1000000000002", + "oid:0x1000000001006": "oid:0x1000000000002", + "oid:0x1000000001007": "oid:0x1000000000002", + "oid:0x1000000001008": "oid:0x1000000000002", + "oid:0x1000000001009": "oid:0x1000000000002", + "oid:0x1000000001010": "oid:0x1000000000002", + "oid:0x1000000001011": "oid:0x1000000000002", + "oid:0x1000000001012": "oid:0x1000000000002", + "oid:0x1000000001013": "oid:0x1000000000002", + "oid:0x1000000001014": "oid:0x1000000000002", + "oid:0x1000000001015": "oid:0x1000000000002", + "oid:0x1000000002000": "oid:0x1000000000004", + "oid:0x1000000002001": "oid:0x1000000000004", + "oid:0x1000000002002": "oid:0x1000000000004", + "oid:0x1000000002003": "oid:0x1000000000004", + "oid:0x1000000002004": "oid:0x1000000000004", + "oid:0x1000000002005": "oid:0x1000000000004", + "oid:0x1000000002006": "oid:0x1000000000004", + "oid:0x1000000002007": "oid:0x1000000000004", + "oid:0x1000000002008": "oid:0x1000000000004", + "oid:0x1000000002009": "oid:0x1000000000004", + "oid:0x1000000002010": "oid:0x1000000000004", + "oid:0x1000000002011": "oid:0x1000000000004", + "oid:0x1000000002012": "oid:0x1000000000004", + "oid:0x1000000002013": "oid:0x1000000000004", + "oid:0x1000000002014": "oid:0x1000000000004", + "oid:0x1000000002015": "oid:0x1000000000004", + "oid:0x1000000003000": "oid:0x1000000000006", + "oid:0x1000000003001": "oid:0x1000000000006", + "oid:0x1000000003002": "oid:0x1000000000006", + "oid:0x1000000003003": "oid:0x1000000000006", + "oid:0x1000000003004": "oid:0x1000000000006", + "oid:0x1000000003005": "oid:0x1000000000006", + "oid:0x1000000003006": "oid:0x1000000000006", + "oid:0x1000000003007": "oid:0x1000000000006", + "oid:0x1000000003008": "oid:0x1000000000006", + "oid:0x1000000003009": "oid:0x1000000000006", + "oid:0x1000000003010": "oid:0x1000000000006", + "oid:0x1000000003011": "oid:0x1000000000006", + "oid:0x1000000003012": "oid:0x1000000000006", + "oid:0x1000000003013": "oid:0x1000000000006", + "oid:0x1000000003014": "oid:0x1000000000006", + "oid:0x1000000003015": "oid:0x1000000000006", + "oid:0x1000000004000": "oid:0x1000000000008", + "oid:0x1000000004001": "oid:0x1000000000008", + "oid:0x1000000004002": "oid:0x1000000000008", + "oid:0x1000000004003": "oid:0x1000000000008", + "oid:0x1000000004004": "oid:0x1000000000008", + "oid:0x1000000004005": "oid:0x1000000000008", + "oid:0x1000000004006": "oid:0x1000000000008", + "oid:0x1000000004007": "oid:0x1000000000008", + "oid:0x1000000004008": "oid:0x1000000000008", + "oid:0x1000000004009": "oid:0x1000000000008", + "oid:0x1000000004010": "oid:0x1000000000008", + "oid:0x1000000004011": "oid:0x1000000000008", + "oid:0x1000000004012": "oid:0x1000000000008", + "oid:0x1000000004013": "oid:0x1000000000008", + "oid:0x1000000004014": "oid:0x1000000000008", + "oid:0x1000000004015": "oid:0x1000000000008" + }, + "COUNTERS_QUEUE_INDEX_MAP": { + "oid:0x1000000001000": "0", + "oid:0x1000000001001": "1", + "oid:0x1000000001002": "2", + "oid:0x1000000001003": "3", + "oid:0x1000000001004": "4", + "oid:0x1000000001005": "5", + "oid:0x1000000001006": "6", + "oid:0x1000000001007": "7", + "oid:0x1000000001008": "8", + "oid:0x1000000001009": "9", + "oid:0x1000000001010": "10", + "oid:0x1000000001011": "11", + "oid:0x1000000001012": "12", + "oid:0x1000000001013": "13", + "oid:0x1000000001014": "14", + "oid:0x1000000001015": "15", + "oid:0x1000000002000": "0", + "oid:0x1000000002001": "1", + "oid:0x1000000002002": "2", + "oid:0x1000000002003": "3", + "oid:0x1000000002004": "4", + "oid:0x1000000002005": "5", + "oid:0x1000000002006": "6", + "oid:0x1000000002007": "7", + "oid:0x1000000002008": "8", + "oid:0x1000000002009": "9", + "oid:0x1000000002010": "10", + "oid:0x1000000002011": "11", + "oid:0x1000000002012": "12", + "oid:0x1000000002013": "13", + "oid:0x1000000002014": "14", + "oid:0x1000000002015": "15", + "oid:0x1000000003000": "0", + "oid:0x1000000003001": "1", + "oid:0x1000000003002": "2", + "oid:0x1000000003003": "3", + "oid:0x1000000003004": "4", + "oid:0x1000000003005": "5", + "oid:0x1000000003006": "6", + "oid:0x1000000003007": "7", + "oid:0x1000000003008": "8", + "oid:0x1000000003009": "9", + "oid:0x1000000003010": "10", + "oid:0x1000000003011": "11", + "oid:0x1000000003012": "12", + "oid:0x1000000003013": "13", + "oid:0x1000000003014": "14", + "oid:0x1000000003015": "15", + "oid:0x1000000004000": "0", + "oid:0x1000000004001": "1", + "oid:0x1000000004002": "2", + "oid:0x1000000004003": "3", + "oid:0x1000000004004": "4", + "oid:0x1000000004005": "5", + "oid:0x1000000004006": "6", + "oid:0x1000000004007": "7", + "oid:0x1000000004008": "8", + "oid:0x1000000004009": "9", + "oid:0x1000000004010": "10", + "oid:0x1000000004011": "11", + "oid:0x1000000004012": "12", + "oid:0x1000000004013": "13", + "oid:0x1000000004014": "14", + "oid:0x1000000004015": "15" + }, + "COUNTERS_QUEUE_TYPE_MAP": { + "oid:0x1000000001000": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1000000001001": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1000000001002": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1000000001003": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1000000001004": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1000000001005": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1000000001006": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1000000001007": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1000000001008": "SAI_QUEUE_TYPE_MULTICAST", + "oid:0x1000000001009": "SAI_QUEUE_TYPE_MULTICAST", + "oid:0x1000000001010": "SAI_QUEUE_TYPE_MULTICAST", + "oid:0x1000000001011": "SAI_QUEUE_TYPE_MULTICAST", + "oid:0x1000000001012": "SAI_QUEUE_TYPE_MULTICAST", + "oid:0x1000000001013": "SAI_QUEUE_TYPE_MULTICAST", + "oid:0x1000000001014": "SAI_QUEUE_TYPE_MULTICAST", + "oid:0x1000000001015": "SAI_QUEUE_TYPE_MULTICAST", + "oid:0x1000000002000": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1000000002001": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1000000002002": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1000000002003": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1000000002004": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1000000002005": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1000000002006": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1000000002007": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1000000002008": "SAI_QUEUE_TYPE_MULTICAST", + "oid:0x1000000002009": "SAI_QUEUE_TYPE_MULTICAST", + "oid:0x1000000002010": "SAI_QUEUE_TYPE_MULTICAST", + "oid:0x1000000002011": "SAI_QUEUE_TYPE_MULTICAST", + "oid:0x1000000002012": "SAI_QUEUE_TYPE_MULTICAST", + "oid:0x1000000002013": "SAI_QUEUE_TYPE_MULTICAST", + "oid:0x1000000002014": "SAI_QUEUE_TYPE_MULTICAST", + "oid:0x1000000002015": "SAI_QUEUE_TYPE_MULTICAST", + "oid:0x1000000003000": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1000000003001": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1000000003002": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1000000003003": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1000000003004": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1000000003005": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1000000003006": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1000000003007": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1000000003008": "SAI_QUEUE_TYPE_MULTICAST", + "oid:0x1000000003009": "SAI_QUEUE_TYPE_MULTICAST", + "oid:0x1000000003010": "SAI_QUEUE_TYPE_MULTICAST", + "oid:0x1000000003011": "SAI_QUEUE_TYPE_MULTICAST", + "oid:0x1000000003012": "SAI_QUEUE_TYPE_MULTICAST", + "oid:0x1000000003013": "SAI_QUEUE_TYPE_MULTICAST", + "oid:0x1000000003014": "SAI_QUEUE_TYPE_MULTICAST", + "oid:0x1000000003015": "SAI_QUEUE_TYPE_MULTICAST", + "oid:0x1000000004000": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1000000004001": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1000000004002": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1000000004003": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1000000004004": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1000000004005": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1000000004006": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1000000004007": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1000000004008": "SAI_QUEUE_TYPE_MULTICAST", + "oid:0x1000000004009": "SAI_QUEUE_TYPE_MULTICAST", + "oid:0x1000000004010": "SAI_QUEUE_TYPE_MULTICAST", + "oid:0x1000000004011": "SAI_QUEUE_TYPE_MULTICAST", + "oid:0x1000000004012": "SAI_QUEUE_TYPE_MULTICAST", + "oid:0x1000000004013": "SAI_QUEUE_TYPE_MULTICAST", + "oid:0x1000000004014": "SAI_QUEUE_TYPE_MULTICAST", + "oid:0x1000000004015": "SAI_QUEUE_TYPE_MULTICAST" + }, + "COUNTERS_FABRIC_PORT_NAME_MAP" : { + "PORT0": "oid:0x1000000000143", + "PORT1": "oid:0x1000000000144", + "PORT2": "oid:0x1000000000145", + "PORT3": "oid:0x1000000000146", + "PORT4": "oid:0x1000000000147", + "PORT5": "oid:0x1000000000148", + "PORT6": "oid:0x1000000000149", + "PORT7": "oid:0x100000000014a" + }, + "COUNTERS:oid:0x1000000000143": { + "SAI_PORT_STAT_IF_OUT_FABRIC_DATA_UNITS": "0", + "SAI_PORT_STAT_IF_OUT_OCTETS": "0", + "SAI_PORT_STAT_IF_IN_OCTETS": "1113", + "SAI_PORT_STAT_IF_IN_ERRORS": "0", + "SAI_PORT_STAT_IF_IN_FABRIC_DATA_UNITS": "6", + "SAI_PORT_STAT_IF_IN_FEC_CORRECTABLE_FRAMES": "5", + "SAI_PORT_STAT_IF_IN_FEC_NOT_CORRECTABLE_FRAMES": "1759692040", + "SAI_PORT_STAT_IF_IN_FEC_SYMBOL_ERRORS": "5" + }, + "COUNTERS:oid:0x1000000000144": { + "SAI_PORT_STAT_IF_OUT_FABRIC_DATA_UNITS": "0", + "SAI_PORT_STAT_IF_OUT_OCTETS": "0", + "SAI_PORT_STAT_IF_IN_OCTETS": "0", + "SAI_PORT_STAT_IF_IN_ERRORS": "0", + "SAI_PORT_STAT_IF_IN_FABRIC_DATA_UNITS": "0", + "SAI_PORT_STAT_IF_IN_FEC_CORRECTABLE_FRAMES": "0", + "SAI_PORT_STAT_IF_IN_FEC_NOT_CORRECTABLE_FRAMES": "58977677898", + "SAI_PORT_STAT_IF_IN_FEC_SYMBOL_ERRORS": "0" + }, + "COUNTERS:oid:0x1000000000145": { + "SAI_PORT_STAT_IF_OUT_FABRIC_DATA_UNITS": "0", + "SAI_PORT_STAT_IF_OUT_OCTETS": "0", + "SAI_PORT_STAT_IF_IN_OCTETS": "371", + "SAI_PORT_STAT_IF_IN_ERRORS": "0", + "SAI_PORT_STAT_IF_IN_FABRIC_DATA_UNITS": "2", + "SAI_PORT_STAT_IF_IN_FEC_CORRECTABLE_FRAMES": "0", + "SAI_PORT_STAT_IF_IN_FEC_NOT_CORRECTABLE_FRAMES": "1769448760", + "SAI_PORT_STAT_IF_IN_FEC_SYMBOL_ERRORS": "0" + }, + "COUNTERS:oid:0x1000000000146": { + "SAI_PORT_STAT_IF_OUT_FABRIC_DATA_UNITS": "0", + "SAI_PORT_STAT_IF_OUT_OCTETS": "0", + "SAI_PORT_STAT_IF_IN_OCTETS": "0", + "SAI_PORT_STAT_IF_IN_ERRORS": "0", + "SAI_PORT_STAT_IF_IN_FABRIC_DATA_UNITS": "0", + "SAI_PORT_STAT_IF_IN_FEC_CORRECTABLE_FRAMES": "0", + "SAI_PORT_STAT_IF_IN_FEC_NOT_CORRECTABLE_FRAMES": "58976477608", + "SAI_PORT_STAT_IF_IN_FEC_SYMBOL_ERRORS": "0" + }, + "COUNTERS:oid:0x1000000000147": { + "SAI_PORT_STAT_IF_OUT_FABRIC_DATA_UNITS": "0", + "SAI_PORT_STAT_IF_OUT_OCTETS": "0", + "SAI_PORT_STAT_IF_IN_OCTETS": "1855", + "SAI_PORT_STAT_IF_IN_ERRORS": "0", + "SAI_PORT_STAT_IF_IN_FABRIC_DATA_UNITS": "10", + "SAI_PORT_STAT_IF_IN_FEC_CORRECTABLE_FRAMES": "73", + "SAI_PORT_STAT_IF_IN_FEC_NOT_CORRECTABLE_FRAMES": "1763293100", + "SAI_PORT_STAT_IF_IN_FEC_SYMBOL_ERRORS": "73" + }, + "COUNTERS:oid:0x1000000000148": { + "SAI_PORT_STAT_IF_OUT_FABRIC_DATA_UNITS": "0", + "SAI_PORT_STAT_IF_OUT_OCTETS": "0", + "SAI_PORT_STAT_IF_IN_OCTETS": "0", + "SAI_PORT_STAT_IF_IN_ERRORS": "0", + "SAI_PORT_STAT_IF_IN_FABRIC_DATA_UNITS": "0", + "SAI_PORT_STAT_IF_IN_FEC_CORRECTABLE_FRAMES": "44196", + "SAI_PORT_STAT_IF_IN_FEC_NOT_CORRECTABLE_FRAMES": "58975150569", + "SAI_PORT_STAT_IF_IN_FEC_SYMBOL_ERRORS": "0" + }, + "COUNTERS:oid:0x1000000000149": { + "SAI_PORT_STAT_IF_OUT_FABRIC_DATA_UNITS": "0", + "SAI_PORT_STAT_IF_OUT_OCTETS": "0", + "SAI_PORT_STAT_IF_IN_OCTETS": "742", + "SAI_PORT_STAT_IF_IN_ERRORS": "0", + "SAI_PORT_STAT_IF_IN_FABRIC_DATA_UNITS": "4", + "SAI_PORT_STAT_IF_IN_FEC_CORRECTABLE_FRAMES": "10", + "SAI_PORT_STAT_IF_IN_FEC_NOT_CORRECTABLE_FRAMES": "1763174090", + "SAI_PORT_STAT_IF_IN_FEC_SYMBOL_ERRORS": "0" + }, + "COUNTERS:oid:0x100000000014a": { + "SAI_PORT_STAT_IF_OUT_FABRIC_DATA_UNITS": "0", + "SAI_PORT_STAT_IF_OUT_OCTETS": "0", + "SAI_PORT_STAT_IF_IN_OCTETS": "1855", + "SAI_PORT_STAT_IF_IN_ERRORS": "0", + "SAI_PORT_STAT_IF_IN_FABRIC_DATA_UNITS": "10", + "SAI_PORT_STAT_IF_IN_FEC_CORRECTABLE_FRAMES": "187", + "SAI_PORT_STAT_IF_IN_FEC_NOT_CORRECTABLE_FRAMES": "1768439529", + "SAI_PORT_STAT_IF_IN_FEC_SYMBOL_ERRORS": "1331" + }, + "COUNTERS_FABRIC_QUEUE_NAME_MAP" : { + "PORT0:0": "oid:0x15000000000186", + "PORT1:0": "oid:0x15000000000187", + "PORT2:0": "oid:0x15000000000188", + "PORT3:0": "oid:0x15000000000189", + "PORT4:0": "oid:0x1500000000018a", + "PORT5:0": "oid:0x1500000000018b", + "PORT6:0": "oid:0x1500000000018c", + "PORT7:0": "oid:0x1500000000018d" + }, + "COUNTERS:oid:0x15000000000186": { + "SAI_QUEUE_STAT_WATERMARK_LEVEL": "20", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES": "763", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_LEVEL": "12" + }, + "COUNTERS:oid:0x15000000000187": { + "SAI_QUEUE_STAT_WATERMARK_LEVEL": "0", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES": "0", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_LEVEL": "0" + }, + "COUNTERS:oid:0x15000000000188": { + "SAI_QUEUE_STAT_WATERMARK_LEVEL": "8", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES": "104", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_LEVEL": "8" + }, + "COUNTERS:oid:0x15000000000189": { + "SAI_QUEUE_STAT_WATERMARK_LEVEL": "0", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES": "0", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_LEVEL": "0" + }, + "COUNTERS:oid:0x1500000000018a": { + "SAI_QUEUE_STAT_WATERMARK_LEVEL": "22", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES": "1147", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_LEVEL": "14" + }, + "COUNTERS:oid:0x1500000000018b": { + "SAI_QUEUE_STAT_WATERMARK_LEVEL": "0", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES": "0", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_LEVEL": "0" + }, + "COUNTERS:oid:0x1500000000018c": { + "SAI_QUEUE_STAT_WATERMARK_LEVEL": "10", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES": "527", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_LEVEL": "8" + }, + "COUNTERS:oid:0x1500000000018d": { + "SAI_QUEUE_STAT_WATERMARK_LEVEL": "17", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES": "1147", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_LEVEL": "14" + }, "COUNTERS_DEBUG_NAME_PORT_STAT_MAP": { "DEBUG_0": "SAI_PORT_STAT_IN_DROP_REASON_RANGE_BASE", "DEBUG_2": "SAI_PORT_STAT_OUT_CONFIGURED_DROP_REASONS_1_DROPPED_PKTS" diff --git a/tests/mock_tables/asic0/state_db.json b/tests/mock_tables/asic0/state_db.json index 97fbb3d33c..21b4fa0eab 100644 --- a/tests/mock_tables/asic0/state_db.json +++ b/tests/mock_tables/asic0/state_db.json @@ -31,7 +31,9 @@ "tx1power": "N/A", "tx2power": "N/A", "tx3power": "N/A", - "tx4power": "N/A", + "tx4power": "N/A" + }, + "TRANSCEIVER_DOM_THRESHOLD|Ethernet0": { "rxpowerhighalarm": "3.4001", "rxpowerhighwarning": "2.4000", "rxpowerlowalarm": "-13.5067", @@ -213,5 +215,39 @@ }, "MUX_CABLE_TABLE|Ethernet0": { "state": "active" + }, + "FABRIC_PORT_TABLE|PORT0" : { + "STATUS": "up", + "REMOTE_MOD": "0", + "REMOTE_PORT": "79" + }, + "FABRIC_PORT_TABLE|PORT1" : { + "STATUS": "down" + }, + "FABRIC_PORT_TABLE|PORT2" : { + "STATUS": "up", + "REMOTE_MOD": "0", + "REMOTE_PORT": "94" + }, + "FABRIC_PORT_TABLE|PORT3" : { + "STATUS": "down" + }, + "FABRIC_PORT_TABLE|PORT4" : { + "STATUS": "up", + "REMOTE_MOD": "0", + "REMOTE_PORT": "85" + }, + "FABRIC_PORT_TABLE|PORT5" : { + "STATUS": "down" + }, + "FABRIC_PORT_TABLE|PORT6" : { + "STATUS": "up", + "REMOTE_MOD": "0", + "REMOTE_PORT": "84" + }, + "FABRIC_PORT_TABLE|PORT7" : { + "STATUS": "up", + "REMOTE_MOD": "0", + "REMOTE_PORT": "93" } } diff --git a/tests/mock_tables/asic1/counters_db.json b/tests/mock_tables/asic1/counters_db.json index aed3b22b58..c364d8599e 100644 --- a/tests/mock_tables/asic1/counters_db.json +++ b/tests/mock_tables/asic1/counters_db.json @@ -888,6 +888,146 @@ "PFC_WD_QUEUE_STATS_RX_PACKETS_LAST": "8343", "PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST": "72" }, + "COUNTERS_FABRIC_PORT_NAME_MAP" : { + "PORT0": "oid:0x1000000000143", + "PORT1": "oid:0x1000000000144", + "PORT2": "oid:0x1000000000145", + "PORT3": "oid:0x1000000000146", + "PORT4": "oid:0x1000000000147", + "PORT5": "oid:0x1000000000148", + "PORT6": "oid:0x1000000000149", + "PORT7": "oid:0x100000000014a" + }, + "COUNTERS:oid:0x1000000000143": { + "SAI_PORT_STAT_IF_OUT_FABRIC_DATA_UNITS": "0", + "SAI_PORT_STAT_IF_OUT_OCTETS": "0", + "SAI_PORT_STAT_IF_IN_OCTETS": "2968", + "SAI_PORT_STAT_IF_IN_ERRORS": "0", + "SAI_PORT_STAT_IF_IN_FABRIC_DATA_UNITS": "16", + "SAI_PORT_STAT_IF_IN_FEC_CORRECTABLE_FRAMES": "0", + "SAI_PORT_STAT_IF_IN_FEC_NOT_CORRECTABLE_FRAMES": "1763890500", + "SAI_PORT_STAT_IF_IN_FEC_SYMBOL_ERRORS": "0" + }, + "COUNTERS:oid:0x1000000000144": { + "SAI_PORT_STAT_IF_OUT_FABRIC_DATA_UNITS": "0", + "SAI_PORT_STAT_IF_OUT_OCTETS": "0", + "SAI_PORT_STAT_IF_IN_OCTETS": "0", + "SAI_PORT_STAT_IF_IN_ERRORS": "0", + "SAI_PORT_STAT_IF_IN_FABRIC_DATA_UNITS": "0", + "SAI_PORT_STAT_IF_IN_FEC_CORRECTABLE_FRAMES": "0", + "SAI_PORT_STAT_IF_IN_FEC_NOT_CORRECTABLE_FRAMES": "105269481425", + "SAI_PORT_STAT_IF_IN_FEC_SYMBOL_ERRORS": "0" + }, + "COUNTERS:oid:0x1000000000145": { + "SAI_PORT_STAT_IF_OUT_FABRIC_DATA_UNITS": "0", + "SAI_PORT_STAT_IF_OUT_OCTETS": "0", + "SAI_PORT_STAT_IF_IN_OCTETS": "0", + "SAI_PORT_STAT_IF_IN_ERRORS": "0", + "SAI_PORT_STAT_IF_IN_FABRIC_DATA_UNITS": "0", + "SAI_PORT_STAT_IF_IN_FEC_CORRECTABLE_FRAMES": "0", + "SAI_PORT_STAT_IF_IN_FEC_NOT_CORRECTABLE_FRAMES": "105268895944", + "SAI_PORT_STAT_IF_IN_FEC_SYMBOL_ERRORS": "0" + }, + "COUNTERS:oid:0x1000000000146": { + "SAI_PORT_STAT_IF_OUT_FABRIC_DATA_UNITS": "0", + "SAI_PORT_STAT_IF_OUT_OCTETS": "0", + "SAI_PORT_STAT_IF_IN_OCTETS": "0", + "SAI_PORT_STAT_IF_IN_ERRORS": "0", + "SAI_PORT_STAT_IF_IN_FABRIC_DATA_UNITS": "0", + "SAI_PORT_STAT_IF_IN_FEC_CORRECTABLE_FRAMES": "0", + "SAI_PORT_STAT_IF_IN_FEC_NOT_CORRECTABLE_FRAMES": "105268290607", + "SAI_PORT_STAT_IF_IN_FEC_SYMBOL_ERRORS": "0" + }, + "COUNTERS:oid:0x1000000000147": { + "SAI_PORT_STAT_IF_OUT_FABRIC_DATA_UNITS": "0", + "SAI_PORT_STAT_IF_OUT_OCTETS": "0", + "SAI_PORT_STAT_IF_IN_OCTETS": "2597", + "SAI_PORT_STAT_IF_IN_ERRORS": "0", + "SAI_PORT_STAT_IF_IN_FABRIC_DATA_UNITS": "14", + "SAI_PORT_STAT_IF_IN_FEC_CORRECTABLE_FRAMES": "0", + "SAI_PORT_STAT_IF_IN_FEC_NOT_CORRECTABLE_FRAMES": "1762188940", + "SAI_PORT_STAT_IF_IN_FEC_SYMBOL_ERRORS": "0" + }, + "COUNTERS:oid:0x1000000000148": { + "SAI_PORT_STAT_IF_OUT_FABRIC_DATA_UNITS": "0", + "SAI_PORT_STAT_IF_OUT_OCTETS": "0", + "SAI_PORT_STAT_IF_IN_OCTETS": "0", + "SAI_PORT_STAT_IF_IN_ERRORS": "0", + "SAI_PORT_STAT_IF_IN_FABRIC_DATA_UNITS": "0", + "SAI_PORT_STAT_IF_IN_FEC_CORRECTABLE_FRAMES": "968", + "SAI_PORT_STAT_IF_IN_FEC_NOT_CORRECTABLE_FRAMES": "105267020477", + "SAI_PORT_STAT_IF_IN_FEC_SYMBOL_ERRORS": "0" + }, + "COUNTERS:oid:0x1000000000149": { + "SAI_PORT_STAT_IF_OUT_FABRIC_DATA_UNITS": "0", + "SAI_PORT_STAT_IF_OUT_OCTETS": "0", + "SAI_PORT_STAT_IF_IN_OCTETS": "0", + "SAI_PORT_STAT_IF_IN_ERRORS": "0", + "SAI_PORT_STAT_IF_IN_FABRIC_DATA_UNITS": "0", + "SAI_PORT_STAT_IF_IN_FEC_CORRECTABLE_FRAMES": "53192703023", + "SAI_PORT_STAT_IF_IN_FEC_NOT_CORRECTABLE_FRAMES": "1422986", + "SAI_PORT_STAT_IF_IN_FEC_SYMBOL_ERRORS": "41913682074" + }, + "COUNTERS:oid:0x100000000014a": { + "SAI_PORT_STAT_IF_OUT_FABRIC_DATA_UNITS": "0", + "SAI_PORT_STAT_IF_OUT_OCTETS": "0", + "SAI_PORT_STAT_IF_IN_OCTETS": "0", + "SAI_PORT_STAT_IF_IN_ERRORS": "0", + "SAI_PORT_STAT_IF_IN_FABRIC_DATA_UNITS": "0", + "SAI_PORT_STAT_IF_IN_FEC_CORRECTABLE_FRAMES": "0", + "SAI_PORT_STAT_IF_IN_FEC_NOT_CORRECTABLE_FRAMES": "105264567398", + "SAI_PORT_STAT_IF_IN_FEC_SYMBOL_ERRORS": "0" + }, + "COUNTERS_FABRIC_QUEUE_NAME_MAP" : { + "PORT0:0": "oid:0x15000000000186", + "PORT1:0": "oid:0x15000000000187", + "PORT2:0": "oid:0x15000000000188", + "PORT3:0": "oid:0x15000000000189", + "PORT4:0": "oid:0x1500000000018a", + "PORT5:0": "oid:0x1500000000018b", + "PORT6:0": "oid:0x1500000000018c", + "PORT7:0": "oid:0x1500000000018d" + }, + "COUNTERS:oid:0x15000000000186": { + "SAI_QUEUE_STAT_WATERMARK_LEVEL": "24", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES": "1942", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_LEVEL": "18" + }, + "COUNTERS:oid:0x15000000000187": { + "SAI_QUEUE_STAT_WATERMARK_LEVEL": "0", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES": "0", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_LEVEL": "0" + }, + "COUNTERS:oid:0x15000000000188": { + "SAI_QUEUE_STAT_WATERMARK_LEVEL": "0", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES": "0", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_LEVEL": "0" + }, + "COUNTERS:oid:0x15000000000189": { + "SAI_QUEUE_STAT_WATERMARK_LEVEL": "0", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES": "0", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_LEVEL": "0" + }, + "COUNTERS:oid:0x1500000000018a": { + "SAI_QUEUE_STAT_WATERMARK_LEVEL": "24", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES": "1362", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_LEVEL": "15" + }, + "COUNTERS:oid:0x1500000000018b": { + "SAI_QUEUE_STAT_WATERMARK_LEVEL": "0", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES": "0", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_LEVEL": "0" + }, + "COUNTERS:oid:0x1500000000018c": { + "SAI_QUEUE_STAT_WATERMARK_LEVEL": "0", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES": "0", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_LEVEL": "0" + }, + "COUNTERS:oid:0x1500000000018d": { + "SAI_QUEUE_STAT_WATERMARK_LEVEL": "0", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES": "0", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_LEVEL": "0" + }, "COUNTERS_DEBUG_NAME_PORT_STAT_MAP": { "DEBUG_0": "SAI_PORT_STAT_IN_DROP_REASON_RANGE_BASE", "DEBUG_2": "SAI_PORT_STAT_OUT_CONFIGURED_DROP_REASONS_1_DROPPED_PKTS" diff --git a/tests/mock_tables/asic1/state_db.json b/tests/mock_tables/asic1/state_db.json index 354f66f708..dd775b9b50 100644 --- a/tests/mock_tables/asic1/state_db.json +++ b/tests/mock_tables/asic1/state_db.json @@ -31,7 +31,9 @@ "tx1power": "N/A", "tx2power": "N/A", "tx3power": "N/A", - "tx4power": "N/A", + "tx4power": "N/A" + }, + "TRANSCEIVER_DOM_THRESHOLD|Ethernet64": { "rxpowerhighalarm": "3.4001", "rxpowerhighwarning": "2.4000", "rxpowerlowalarm": "-13.5067", @@ -213,5 +215,33 @@ }, "MUX_CABLE_TABLE|Ethernet0": { "state": "active" + }, + "FABRIC_PORT_TABLE|PORT0" : { + "STATUS": "up", + "REMOTE_MOD": "0", + "REMOTE_PORT": "69" + }, + "FABRIC_PORT_TABLE|PORT1" : { + "STATUS": "down" + }, + "FABRIC_PORT_TABLE|PORT2" : { + "STATUS": "down" + }, + "FABRIC_PORT_TABLE|PORT3" : { + "STATUS": "down" + }, + "FABRIC_PORT_TABLE|PORT4" : { + "STATUS": "up", + "REMOTE_MOD": "0", + "REMOTE_PORT": "75" + }, + "FABRIC_PORT_TABLE|PORT5" : { + "STATUS": "down" + }, + "FABRIC_PORT_TABLE|PORT6" : { + "STATUS": "down" + }, + "FABRIC_PORT_TABLE|PORT7" : { + "STATUS": "down" } } diff --git a/tests/mock_tables/asic_db.json b/tests/mock_tables/asic_db.json index 333899f273..e16fc315af 100644 --- a/tests/mock_tables/asic_db.json +++ b/tests/mock_tables/asic_db.json @@ -19,5 +19,9 @@ "VIDTORID":{ "oid:0xd00000000056d": "oid:0xd", "oid:0x10000000004a4": "oid:0x1690000000001" - } + }, + "ASIC_STATE:SAI_OBJECT_TYPE_ROUTE_ENTRY:{\"dest\":\"10.2.1.1\",\"switch_id\":\"oid:0x21000000000000\",\"vr\":\"oid:0x300000000007c\"}": { + "SAI_ROUTE_ENTRY_ATTR_PACKET_ACTION": "SAI_PACKET_ACTION_FORWARD", + "SAI_ROUTE_ENTRY_ATTR_NEXT_HOP_ID": "oid:0x40000000015d8" + } } diff --git a/tests/mock_tables/config_db.json b/tests/mock_tables/config_db.json index 9a037bb587..bb96260d3f 100644 --- a/tests/mock_tables/config_db.json +++ b/tests/mock_tables/config_db.json @@ -373,10 +373,32 @@ "VLAN_SUB_INTERFACE|Ethernet0.10": { "admin_status": "up" }, - "VLAN_SUB_INTERFACE|Eth32.10": { + "VLAN_SUB_INTERFACE|Ethernet0.10|10.11.12.13/24": { + "NULL" : "NULL" + }, + "VLAN_SUB_INTERFACE|Eth36.10": { "admin_status": "up", + "loopback_action": "drop", + "vrf_name": "Vrf1", "vlan": "100" }, + "VLAN_SUB_INTERFACE|Eth36.10|32.10.11.12/24": { + "NULL" : "NULL" + }, + "VLAN_SUB_INTERFACE|Eth36.10|3210::12/126": { + "NULL" : "NULL" + }, + "VLAN_SUB_INTERFACE|Po0001.10": { + "admin_status": "up", + "vrf_name": "Vrf1", + "vlan": "100" + }, + "VLAN_SUB_INTERFACE|Po0001.10|10.10.11.12/24": { + "NULL" : "NULL" + }, + "VLAN_SUB_INTERFACE|Po0001.10|1010::12/126": { + "NULL" : "NULL" + }, "ACL_RULE|NULL_ROUTE_V4|DEFAULT_RULE": { "PACKET_ACTION": "DROP", "PRIORITY": "1" @@ -552,6 +574,9 @@ "VLAN_INTERFACE|Vlan2000": { "proxy_arp": "enabled" }, + "VLAN_INTERFACE|Vlan3000": { + "loopback_action": "forward" + }, "VLAN_INTERFACE|Vlan1000|192.168.0.1/21": { "NULL": "NULL" }, @@ -636,7 +661,8 @@ "NULL": "NULL" }, "PORTCHANNEL_INTERFACE|PortChannel0001": { - "ipv6_use_link_local_only": "disable" + "ipv6_use_link_local_only": "disable", + "loopback_action": "drop" }, "PORTCHANNEL_INTERFACE|PortChannel0002": { "NULL": "NULL" @@ -672,11 +698,15 @@ "NULL": "NULL" }, "INTERFACE|Ethernet0": { - "ipv6_use_link_local_only": "disable" + "ipv6_use_link_local_only": "disable", + "loopback_action": "forward" }, "INTERFACE|Ethernet0|14.14.0.1/24": { "NULL": "NULL" }, + "INTERFACE|Ethernet40": { + "ipv6_use_link_local_only": "enable" + }, "DEBUG_COUNTER|DEBUG_0": { "type": "PORT_INGRESS_DROPS" }, @@ -1614,7 +1644,11 @@ "FLEX_COUNTER_STATUS": "enable" }, "FLEX_COUNTER_TABLE|ACL": { - "POLL_INTERVAL": "10000", + "POLL_INTERVAL": "5000", + "FLEX_COUNTER_STATUS": "enable" + }, + "FLEX_COUNTER_TABLE|TUNNEL": { + "POLL_INTERVAL": "3000", "FLEX_COUNTER_STATUS": "enable" }, "FLEX_COUNTER_TABLE|FLOW_CNT_TRAP": { @@ -1712,11 +1746,14 @@ "MUX_CABLE|Ethernet32": { "state": "auto", "server_ipv4": "10.1.1.1", + "cable_type": "active-active", + "soc_ipv4": "10.1.1.2", "server_ipv6": "fc00::75" }, "MUX_CABLE|Ethernet16": { "state": "standby", "server_ipv4": "10.1.1.1", + "cable_type": "active-standby", "server_ipv6": "fc00::75" }, "MUX_CABLE|Ethernet28": { diff --git a/tests/mock_tables/counters_db.json b/tests/mock_tables/counters_db.json index b79c839288..e12e3347fd 100644 --- a/tests/mock_tables/counters_db.json +++ b/tests/mock_tables/counters_db.json @@ -398,6 +398,150 @@ "SAI_QUEUE_STAT_PACKETS": "20", "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "81" }, + "COUNTERS:oid:0x15000000000657": { + "SAI_QUEUE_STAT_BYTES": "30", + "SAI_QUEUE_STAT_DROPPED_BYTES": "74", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "56", + "SAI_QUEUE_STAT_PACKETS": "68" + }, + "COUNTERS:oid:0x15000000000658": { + "SAI_QUEUE_STAT_BYTES": "43", + "SAI_QUEUE_STAT_DROPPED_BYTES": "1", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "39", + "SAI_QUEUE_STAT_PACKETS": "60" + }, + "COUNTERS:oid:0x15000000000659": { + "SAI_QUEUE_STAT_BYTES": "7", + "SAI_QUEUE_STAT_DROPPED_BYTES": "21", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "39", + "SAI_QUEUE_STAT_PACKETS": "82" + }, + "COUNTERS:oid:0x1500000000065a": { + "SAI_QUEUE_STAT_BYTES": "59", + "SAI_QUEUE_STAT_DROPPED_BYTES": "94", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "12", + "SAI_QUEUE_STAT_PACKETS": "11" + }, + "COUNTERS:oid:0x1500000000065b": { + "SAI_QUEUE_STAT_BYTES": "62", + "SAI_QUEUE_STAT_DROPPED_BYTES": "40", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "35", + "SAI_QUEUE_STAT_PACKETS": "36" + }, + "COUNTERS:oid:0x1500000000065c": { + "SAI_QUEUE_STAT_BYTES": "91", + "SAI_QUEUE_STAT_DROPPED_BYTES": "88", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "2", + "SAI_QUEUE_STAT_PACKETS": "49" + }, + "COUNTERS:oid:0x1500000000065d": { + "SAI_QUEUE_STAT_BYTES": "17", + "SAI_QUEUE_STAT_DROPPED_BYTES": "74", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "94", + "SAI_QUEUE_STAT_PACKETS": "33" + }, + "COUNTERS:oid:0x1500000000065e": { + "SAI_QUEUE_STAT_BYTES": "71", + "SAI_QUEUE_STAT_DROPPED_BYTES": "33", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "95", + "SAI_QUEUE_STAT_PACKETS": "40" + }, + "COUNTERS:oid:0x15000000000667": { + "SAI_QUEUE_STAT_BYTES": "8", + "SAI_QUEUE_STAT_DROPPED_BYTES": "78", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "93", + "SAI_QUEUE_STAT_PACKETS": "54" + }, + "COUNTERS:oid:0x15000000000668": { + "SAI_QUEUE_STAT_BYTES": "96", + "SAI_QUEUE_STAT_DROPPED_BYTES": "9", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "74", + "SAI_QUEUE_STAT_PACKETS": "83" + }, + "COUNTERS:oid:0x15000000000669": { + "SAI_QUEUE_STAT_BYTES": "60", + "SAI_QUEUE_STAT_DROPPED_BYTES": "31", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "61", + "SAI_QUEUE_STAT_PACKETS": "15" + }, + "COUNTERS:oid:0x1500000000066a": { + "SAI_QUEUE_STAT_BYTES": "52", + "SAI_QUEUE_STAT_DROPPED_BYTES": "94", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "82", + "SAI_QUEUE_STAT_PACKETS": "45" + }, + "COUNTERS:oid:0x1500000000066b": { + "SAI_QUEUE_STAT_BYTES": "88", + "SAI_QUEUE_STAT_DROPPED_BYTES": "52", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "89", + "SAI_QUEUE_STAT_PACKETS": "55" + }, + "COUNTERS:oid:0x1500000000066c": { + "SAI_QUEUE_STAT_BYTES": "70", + "SAI_QUEUE_STAT_DROPPED_BYTES": "79", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "95", + "SAI_QUEUE_STAT_PACKETS": "14" + }, + "COUNTERS:oid:0x1500000000066d": { + "SAI_QUEUE_STAT_BYTES": "60", + "SAI_QUEUE_STAT_DROPPED_BYTES": "81", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "66", + "SAI_QUEUE_STAT_PACKETS": "68" + }, + "COUNTERS:oid:0x1500000000066e": { + "SAI_QUEUE_STAT_BYTES": "4", + "SAI_QUEUE_STAT_DROPPED_BYTES": "76", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "48", + "SAI_QUEUE_STAT_PACKETS": "63" + }, + "COUNTERS:oid:0x15000000000677": { + "SAI_QUEUE_STAT_BYTES": "73", + "SAI_QUEUE_STAT_DROPPED_BYTES": "74", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "77", + "SAI_QUEUE_STAT_PACKETS": "41" + }, + "COUNTERS:oid:0x15000000000678": { + "SAI_QUEUE_STAT_BYTES": "21", + "SAI_QUEUE_STAT_DROPPED_BYTES": "54", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "56", + "SAI_QUEUE_STAT_PACKETS": "60" + }, + "COUNTERS:oid:0x15000000000679": { + "SAI_QUEUE_STAT_BYTES": "31", + "SAI_QUEUE_STAT_DROPPED_BYTES": "39", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "12", + "SAI_QUEUE_STAT_PACKETS": "57" + }, + "COUNTERS:oid:0x1500000000067a": { + "SAI_QUEUE_STAT_BYTES": "96", + "SAI_QUEUE_STAT_DROPPED_BYTES": "98", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "70", + "SAI_QUEUE_STAT_PACKETS": "41" + }, + "COUNTERS:oid:0x1500000000067b": { + "SAI_QUEUE_STAT_BYTES": "49", + "SAI_QUEUE_STAT_DROPPED_BYTES": "36", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "63", + "SAI_QUEUE_STAT_PACKETS": "18" + }, + "COUNTERS:oid:0x1500000000067c": { + "SAI_QUEUE_STAT_BYTES": "90", + "SAI_QUEUE_STAT_DROPPED_BYTES": "15", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "3", + "SAI_QUEUE_STAT_PACKETS": "99" + }, + "COUNTERS:oid:0x1500000000067d": { + "SAI_QUEUE_STAT_BYTES": "84", + "SAI_QUEUE_STAT_DROPPED_BYTES": "94", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "82", + "SAI_QUEUE_STAT_PACKETS": "8" + }, + "COUNTERS:oid:0x1500000000067e": { + "SAI_QUEUE_STAT_BYTES": "15", + "SAI_QUEUE_STAT_DROPPED_BYTES": "92", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "75", + "SAI_QUEUE_STAT_PACKETS": "83" + }, "COUNTERS:oid:0x60000000005a3": { "SAI_ROUTER_INTERFACE_STAT_IN_ERROR_OCTETS": "0", "SAI_ROUTER_INTERFACE_STAT_IN_ERROR_PACKETS": "0", @@ -904,7 +1048,40 @@ "COUNTERS:oid:0x1a0000000003a6" : { "SAI_INGRESS_PRIORITY_GROUP_STAT_DROPPED_PACKETS" : "107" }, + + "COUNTERS_SYSTEM_PORT_NAME_MAP": { + "Ethernet0": "oid:0x1000000000042", + "Ethernet4": "oid:0x1000000000043", + "Ethernet8": "oid:0x1000000000044" + }, + "COUNTERS_VOQ_NAME_MAP": { + "Ethernet0:0": "oid:0x15000000000657", + "Ethernet0:1": "oid:0x15000000000658", + "Ethernet0:2": "oid:0x15000000000659", + "Ethernet0:3": "oid:0x1500000000065a", + "Ethernet0:4": "oid:0x1500000000065b", + "Ethernet0:5": "oid:0x1500000000065c", + "Ethernet0:6": "oid:0x1500000000065d", + "Ethernet0:7": "oid:0x1500000000065e", + "Ethernet4:0": "oid:0x15000000000667", + "Ethernet4:1": "oid:0x15000000000668", + "Ethernet4:2": "oid:0x15000000000669", + "Ethernet4:3": "oid:0x1500000000066a", + "Ethernet4:4": "oid:0x1500000000066b", + "Ethernet4:5": "oid:0x1500000000066c", + "Ethernet4:6": "oid:0x1500000000066d", + "Ethernet4:7": "oid:0x1500000000066e", + "Ethernet8:0": "oid:0x15000000000677", + "Ethernet8:1": "oid:0x15000000000678", + "Ethernet8:2": "oid:0x15000000000679", + "Ethernet8:3": "oid:0x1500000000067a", + "Ethernet8:4": "oid:0x1500000000067b", + "Ethernet8:5": "oid:0x1500000000067c", + "Ethernet8:6": "oid:0x1500000000067d", + "Ethernet8:7": "oid:0x1500000000067e" + }, + "COUNTERS_PORT_NAME_MAP": { "Ethernet0": "oid:0x1000000000012", "Ethernet4": "oid:0x1000000000013", @@ -1155,8 +1332,33 @@ "oid:0x150000000003c3": "oid:0x1000000000014", "oid:0x150000000003c4": "oid:0x1000000000014", "oid:0x150000000003c5": "oid:0x1000000000014", - "oid:0x150000000003c6": "oid:0x1000000000014" + "oid:0x150000000003c6": "oid:0x1000000000014", + "oid:0x15000000000657": "oid:0x1000000000042", + "oid:0x15000000000658": "oid:0x1000000000042", + "oid:0x15000000000659": "oid:0x1000000000042", + "oid:0x1500000000065a": "oid:0x1000000000042", + "oid:0x1500000000065b": "oid:0x1000000000042", + "oid:0x1500000000065c": "oid:0x1000000000042", + "oid:0x1500000000065d": "oid:0x1000000000042", + "oid:0x1500000000065e": "oid:0x1000000000042", + "oid:0x15000000000667": "oid:0x1000000000043", + "oid:0x15000000000668": "oid:0x1000000000043", + "oid:0x15000000000669": "oid:0x1000000000043", + "oid:0x1500000000066a": "oid:0x1000000000043", + "oid:0x1500000000066b": "oid:0x1000000000043", + "oid:0x1500000000066c": "oid:0x1000000000043", + "oid:0x1500000000066d": "oid:0x1000000000043", + "oid:0x1500000000066e": "oid:0x1000000000043", + "oid:0x15000000000677": "oid:0x1000000000044", + "oid:0x15000000000678": "oid:0x1000000000044", + "oid:0x15000000000679": "oid:0x1000000000044", + "oid:0x1500000000067a": "oid:0x1000000000044", + "oid:0x1500000000067b": "oid:0x1000000000044", + "oid:0x1500000000067c": "oid:0x1000000000044", + "oid:0x1500000000067d": "oid:0x1000000000044", + "oid:0x1500000000067e": "oid:0x1000000000044" }, + "COUNTERS_PG_INDEX_MAP": { "oid:0x1a00000000034f": "0", "oid:0x1a000000000350": "1", @@ -1273,7 +1475,31 @@ "oid:0x150000000003c3": "26", "oid:0x150000000003c4": "27", "oid:0x150000000003c5": "28", - "oid:0x150000000003c6": "29" + "oid:0x150000000003c6": "29", + "oid:0x15000000000657": "0", + "oid:0x15000000000658": "1", + "oid:0x15000000000659": "2", + "oid:0x1500000000065a": "3", + "oid:0x1500000000065b": "4", + "oid:0x1500000000065c": "5", + "oid:0x1500000000065d": "6", + "oid:0x1500000000065e": "7", + "oid:0x15000000000667": "0", + "oid:0x15000000000668": "1", + "oid:0x15000000000669": "2", + "oid:0x1500000000066a": "3", + "oid:0x1500000000066b": "4", + "oid:0x1500000000066c": "5", + "oid:0x1500000000066d": "6", + "oid:0x1500000000066e": "7", + "oid:0x15000000000677": "0", + "oid:0x15000000000678": "1", + "oid:0x15000000000679": "2", + "oid:0x1500000000067a": "3", + "oid:0x1500000000067b": "4", + "oid:0x1500000000067c": "5", + "oid:0x1500000000067d": "6", + "oid:0x1500000000067e": "7" }, "COUNTERS_QUEUE_TYPE_MAP": { "oid:0x15000000000357": "SAI_QUEUE_TYPE_UNICAST", @@ -1365,7 +1591,31 @@ "oid:0x150000000003c3": "SAI_QUEUE_TYPE_ALL", "oid:0x150000000003c4": "SAI_QUEUE_TYPE_ALL", "oid:0x150000000003c5": "SAI_QUEUE_TYPE_ALL", - "oid:0x150000000003c6": "SAI_QUEUE_TYPE_ALL" + "oid:0x150000000003c6": "SAI_QUEUE_TYPE_ALL", + "oid:0x15000000000657": "SAI_QUEUE_TYPE_UNICAST_VOQ", + "oid:0x15000000000658": "SAI_QUEUE_TYPE_UNICAST_VOQ", + "oid:0x15000000000659": "SAI_QUEUE_TYPE_UNICAST_VOQ", + "oid:0x1500000000065a": "SAI_QUEUE_TYPE_UNICAST_VOQ", + "oid:0x1500000000065b": "SAI_QUEUE_TYPE_UNICAST_VOQ", + "oid:0x1500000000065c": "SAI_QUEUE_TYPE_UNICAST_VOQ", + "oid:0x1500000000065d": "SAI_QUEUE_TYPE_UNICAST_VOQ", + "oid:0x1500000000065e": "SAI_QUEUE_TYPE_UNICAST_VOQ", + "oid:0x15000000000667": "SAI_QUEUE_TYPE_UNICAST_VOQ", + "oid:0x15000000000668": "SAI_QUEUE_TYPE_UNICAST_VOQ", + "oid:0x15000000000669": "SAI_QUEUE_TYPE_UNICAST_VOQ", + "oid:0x1500000000066a": "SAI_QUEUE_TYPE_UNICAST_VOQ", + "oid:0x1500000000066b": "SAI_QUEUE_TYPE_UNICAST_VOQ", + "oid:0x1500000000066c": "SAI_QUEUE_TYPE_UNICAST_VOQ", + "oid:0x1500000000066d": "SAI_QUEUE_TYPE_UNICAST_VOQ", + "oid:0x1500000000066e": "SAI_QUEUE_TYPE_UNICAST_VOQ", + "oid:0x15000000000677": "SAI_QUEUE_TYPE_UNICAST_VOQ", + "oid:0x15000000000678": "SAI_QUEUE_TYPE_UNICAST_VOQ", + "oid:0x15000000000679": "SAI_QUEUE_TYPE_UNICAST_VOQ", + "oid:0x1500000000067a": "SAI_QUEUE_TYPE_UNICAST_VOQ", + "oid:0x1500000000067b": "SAI_QUEUE_TYPE_UNICAST_VOQ", + "oid:0x1500000000067c": "SAI_QUEUE_TYPE_UNICAST_VOQ", + "oid:0x1500000000067d": "SAI_QUEUE_TYPE_UNICAST_VOQ", + "oid:0x1500000000067e": "SAI_QUEUE_TYPE_UNICAST_VOQ" }, "COUNTERS_DEBUG_NAME_PORT_STAT_MAP": { "DEBUG_0": "SAI_PORT_STAT_IN_DROP_REASON_RANGE_BASE", diff --git a/tests/mock_tables/dbconnector.py b/tests/mock_tables/dbconnector.py index 80d74cafd7..924849abd7 100644 --- a/tests/mock_tables/dbconnector.py +++ b/tests/mock_tables/dbconnector.py @@ -60,6 +60,8 @@ def connect_SonicV2Connector(self, db_name, retry_on=True): def _subscribe_keyspace_notification(self, db_name, client): pass +def mock_close(self, db_name): + pass def config_set(self, *args): pass @@ -183,6 +185,7 @@ def keys(self, pattern='*'): swsssdk.interface.DBInterface._subscribe_keyspace_notification = _subscribe_keyspace_notification +swsssdk.interface.DBInterface.close = mock_close mockredis.MockRedis.config_set = config_set redis.StrictRedis = SwssSyncClient SonicV2Connector.connect = connect_SonicV2Connector diff --git a/tests/mock_tables/state_db.json b/tests/mock_tables/state_db.json index 720c14d164..0a3ba0dca5 100644 --- a/tests/mock_tables/state_db.json +++ b/tests/mock_tables/state_db.json @@ -49,7 +49,9 @@ "tx1power": "N/A", "tx2power": "N/A", "tx3power": "N/A", - "tx4power": "N/A", + "tx4power": "N/A" + }, + "TRANSCEIVER_DOM_THRESHOLD|Ethernet0": { "rxpowerhighalarm": "3.4001", "rxpowerhighwarning": "2.4000", "rxpowerlowalarm": "-13.5067", @@ -74,7 +76,7 @@ "manufacturer": "INNOLIGHT", "model": "C-DQ8FNM010-N00", "vendor_oui": "44-7c-7f", - "vendor_date": "2020-05-22 ", + "vendor_date": "2020-05-22", "connector": "No separable connector", "encoding": "Not supported for CMIS cables", "ext_identifier": "Power Class 1(10.0W Max)", @@ -83,7 +85,7 @@ "cable_length": "10", "specification_compliance": "Not supported for CMIS cables", "nominal_bit_rate": "Not supported for CMIS cables", - "application_advertisement": "400GAUI-8 C2M (Annex 120E) - Active Cable assembly with BER < 2.6x10^-4\n\t\t\t\t IB EDR (Arch.Spec.Vol.2) - Active Cable assembly with BER < 5x10^-5\n\t\t\t\t IB QDR (Arch.Spec.Vol.2) - Active Cable assembly with BER < 10^-12\n\t\t\t\t " + "application_advertisement": "400GAUI-8 C2M (Annex 120E) - Active Cable assembly with BER < 2.6x10^-4\n\t\t\t\t IB EDR (Arch.Spec.Vol.2) - Active Cable assembly with BER < 5x10^-5\n\t\t\t\t IB QDR (Arch.Spec.Vol.2) - Active Cable assembly with BER < 10^-12" }, "TRANSCEIVER_DOM_SENSOR|Ethernet8": { "temperature": "44.9883", @@ -111,7 +113,9 @@ "tx5power": "1.175", "tx6power": "1.175", "tx7power": "1.175", - "tx8power": "1.175", + "tx8power": "1.175" + }, + "TRANSCEIVER_DOM_THRESHOLD|Ethernet8": { "rxpowerhighalarm": "6.9999", "rxpowerhighwarning": "4.9999", "rxpowerlowalarm": "-11.9044", @@ -205,6 +209,24 @@ "nominal_bit_rate": "N/A", "application_advertisement": "N/A" }, + "TRANSCEIVER_INFO|Ethernet40": { + "type": "QSFP-DD Double Density 8X Pluggable Transceiver", + "vendor_rev": "2A", + "serial": "INKAO2900002A", + "manufacturer": "INNOLIGHT", + "model": "C-DQ8FNM010-N00", + "vendor_oui": "44-7c-7f", + "vendor_date": "2020-05-22", + "connector": "No separable connector", + "encoding": "Not supported for CMIS cables", + "ext_identifier": "Power Class 1(10.0W Max)", + "ext_rateselect_compliance": "Not supported for CMIS cables", + "cable_type": "Length Cable Assembly(m)", + "cable_length": "10", + "specification_compliance": "Not supported for CMIS cables", + "nominal_bit_rate": "Not supported for CMIS cables", + "application_advertisement": "{1: {'host_electrical_interface_id': '400G CR8', 'module_media_interface_id': 'Copper cable', 'media_lane_count': 8, 'host_lane_count': 8, 'host_lane_assignment_options': 1, 'media_lane_assignment_options': 2}, 2: {'host_electrical_interface_id': '200GBASE-CR4 (Clause 136)'}}" + }, "TRANSCEIVER_STATUS|Ethernet0": { "status": "67", "error": "Blocking Error|High temperature" @@ -221,6 +243,22 @@ "status": "255", "error": "N/A" }, + "TRANSCEIVER_STATUS|Ethernet16": { + "status": "0", + "error": "N/A" + }, + "TRANSCEIVER_STATUS|Ethernet28": { + "status": "0", + "error": "N/A" + }, + "TRANSCEIVER_STATUS|Ethernet36": { + "status": "255", + "error": "Unknown" + }, + "TRANSCEIVER_STATUS|Ethernet40": { + "status": "0", + "error": "N/A" + }, "CHASSIS_INFO|chassis 1": { "psu_num": "2" }, @@ -353,6 +391,30 @@ "Name": "CRC-32", "Value": "0xAC518FB3" }, + "MUX_CABLE_INFO|Ethernet0": { + "version_peer_next": "0.2MS", + "version_peer_active": "0.2MS", + "version_peer_inactive": "0.2MS", + "version_nic_next": "0.2MS", + "version_nic_active": "0.2MS", + "version_nic_inactive": "0.2MS", + "version_self_next": "0.2MS", + "version_self_active": "0.2MS", + "version_self_inactive": "0.2MS", + "Value": "AABB" + }, + "MUX_CABLE_INFO|Ethernet12": { + "version_peer_next": "0.1MS", + "version_peer_active": "0.1MS", + "version_peer_inactive": "0.1MS", + "version_nic_next": "0.1MS", + "version_nic_active": "0.1MS", + "version_nic_inactive": "0.1MS", + "version_self_next": "0.1MS", + "version_self_active": "0.1MS", + "version_self_inactive": "0.1MS", + "Value": "AABB" + }, "SWITCH_CAPABILITY|switch": { "MIRROR": "true", "MIRRORV6": "true", @@ -685,10 +747,17 @@ "PORT_TABLE|Ethernet0": { "rmt_adv_speeds" : "10,100,1000", "speed" : "100000", - "supported_speeds": "10000,25000,40000,100000" + "supported_speeds": "10000,25000,40000,100000", + "supported_fecs": "rs,none,test", + "link_training_status": "not_trained" + }, + "PORT_TABLE|Ethernet32": { + "link_training_status": "trained" }, "PORT_TABLE|Ethernet112": { - "speed": "40000" + "speed": "40000", + "supported_fecs": "N/A", + "link_training_status": "off" }, "PCIE_DEVICE|00:01.0": { "correctable|BadDLLP": "0", @@ -823,5 +892,59 @@ "admin_status": "up", "mtu": "9100", "speed": "1000" + }, + "LINK_TRAINING|Ethernet0": { + "status": "not_trained" + }, + "LINK_TRAINING|Ethernet32": { + "status": "trained" + }, + "LINK_TRAINING|Ethernet112": { + "status": "off" + }, + "BFD_SESSION_TABLE|default|default|100.251.7.1": { + "state":"Up", + "type": "async_active", + "local_addr" : "10.0.0.1", + "tx_interval" :"300", + "rx_interval" : "500", + "multiplier" : "3", + "multihop": "true" + }, + "BFD_SESSION_TABLE|default|default|fddd:a101:a251::a10:1": { + "state":"Down", + "type": "async_active", + "local_addr" : "fddd:c101:a251::a10:2", + "tx_interval" :"300", + "rx_interval" : "500", + "multiplier" : "3", + "multihop": "true" + }, + "VNET_ROUTE_TUNNEL_TABLE|test_v4_in_v4-0|160.162.191.1/32": { + "active_endpoints":"100.251.7.1", + "state":"active" + }, + "VNET_ROUTE_TUNNEL_TABLE|test_v4_in_v4-0|160.163.191.1/32": { + "active_endpoints":"100.251.7.1", + "state":"active" + }, + "VNET_ROUTE_TUNNEL_TABLE|Vnet_v6_in_v6-0|fddd:a156:a251::a6:1/128": { + "active_endpoints":"fddd:a100:a251::a10:1,fddd:a101:a251::a10:1", + "state":"active" + }, + "ADVERTISE_NETWORK_TABLE|160.63.191.1/32": { + "profile": "FROM_SDN_SLB_ROUTES" + }, + "ADVERTISE_NETWORK_TABLE|160.62.191.1/32": { + "profile": "FROM_SDN_SLB_ROUTES" + }, + "ADVERTISE_NETWORK_TABLE|160.64.191.1/32": { + "profile": "FROM_SDN_SLB_ROUTES" + }, + "ADVERTISE_NETWORK_TABLE|fddd:a150:a251::a6:1/128": { + "profile": "FROM_SDN_SLB_ROUTES" + }, + "ADVERTISE_NETWORK_TABLE|fccc:a250:a251::a6:1/128": { + "profile": "" } } diff --git a/tests/multi_asic_queue_counter_test.py b/tests/multi_asic_queue_counter_test.py new file mode 100644 index 0000000000..c501c68609 --- /dev/null +++ b/tests/multi_asic_queue_counter_test.py @@ -0,0 +1,151 @@ +import imp +import json +import os +import sys + +from click.testing import CliRunner +from unittest import TestCase +from swsscommon.swsscommon import ConfigDBConnector + +from .mock_tables import dbconnector + +import show.main as show +from utilities_common.cli import json_dump +from utilities_common.db import Db +from .utils import get_result_and_return_code + +test_path = os.path.dirname(os.path.abspath(__file__)) +modules_path = os.path.dirname(test_path) +scripts_path = os.path.join(modules_path, "scripts") +sys.path.insert(0, test_path) +sys.path.insert(0, modules_path) + + +show_queue_counters = """\ + Port TxQ Counter/pkts Counter/bytes Drop/pkts Drop/bytes +--------- ----- -------------- --------------- ----------- ------------ +Ethernet0 UC0 68 30 56 74 +Ethernet0 UC1 69 31 55 73 +Ethernet0 UC2 70 32 54 72 +Ethernet0 UC3 71 33 53 71 +Ethernet0 UC4 72 34 52 70 +Ethernet0 UC5 73 35 51 69 +Ethernet0 UC6 74 36 50 68 +Ethernet0 UC7 75 37 49 67 +Ethernet0 MC8 76 38 48 66 +Ethernet0 MC9 77 39 47 65 +Ethernet0 MC10 78 40 46 64 +Ethernet0 MC11 79 41 45 63 +Ethernet0 MC12 80 42 44 62 +Ethernet0 MC13 81 43 43 61 +Ethernet0 MC14 82 44 42 60 +Ethernet0 MC15 83 45 41 59 + + Port TxQ Counter/pkts Counter/bytes Drop/pkts Drop/bytes +--------- ----- -------------- --------------- ----------- ------------ +Ethernet4 UC0 84 46 40 58 +Ethernet4 UC1 85 47 39 57 +Ethernet4 UC2 86 48 38 56 +Ethernet4 UC3 87 49 37 55 +Ethernet4 UC4 88 50 36 54 +Ethernet4 UC5 89 51 35 53 +Ethernet4 UC6 90 52 34 52 +Ethernet4 UC7 91 53 33 51 +Ethernet4 MC8 92 54 32 50 +Ethernet4 MC9 93 55 31 49 +Ethernet4 MC10 94 56 30 48 +Ethernet4 MC11 95 57 29 47 +Ethernet4 MC12 96 58 28 46 +Ethernet4 MC13 97 59 27 45 +Ethernet4 MC14 98 60 26 44 +Ethernet4 MC15 99 61 25 43 + + Port TxQ Counter/pkts Counter/bytes Drop/pkts Drop/bytes +------------ ----- -------------- --------------- ----------- ------------ +Ethernet-BP0 UC0 100 62 24 42 +Ethernet-BP0 UC1 101 63 23 41 +Ethernet-BP0 UC2 102 64 22 40 +Ethernet-BP0 UC3 103 65 21 39 +Ethernet-BP0 UC4 104 66 20 38 +Ethernet-BP0 UC5 105 67 19 37 +Ethernet-BP0 UC6 106 68 18 36 +Ethernet-BP0 UC7 107 69 17 35 +Ethernet-BP0 MC8 108 70 16 34 +Ethernet-BP0 MC9 109 71 15 33 +Ethernet-BP0 MC10 110 72 14 32 +Ethernet-BP0 MC11 111 73 13 31 +Ethernet-BP0 MC12 112 74 12 30 +Ethernet-BP0 MC13 113 75 11 29 +Ethernet-BP0 MC14 114 76 10 28 +Ethernet-BP0 MC15 115 77 9 27 + + Port TxQ Counter/pkts Counter/bytes Drop/pkts Drop/bytes +------------ ----- -------------- --------------- ----------- ------------ +Ethernet-BP4 UC0 116 78 8 26 +Ethernet-BP4 UC1 117 79 7 25 +Ethernet-BP4 UC2 118 80 6 24 +Ethernet-BP4 UC3 119 81 5 23 +Ethernet-BP4 UC4 120 82 4 22 +Ethernet-BP4 UC5 121 83 3 21 +Ethernet-BP4 UC6 122 84 2 20 +Ethernet-BP4 UC7 123 85 1 19 +Ethernet-BP4 MC8 124 86 0 18 +Ethernet-BP4 MC9 125 87 1 17 +Ethernet-BP4 MC10 126 88 2 16 +Ethernet-BP4 MC11 127 89 3 15 +Ethernet-BP4 MC12 128 90 4 14 +Ethernet-BP4 MC13 129 91 5 13 +Ethernet-BP4 MC14 130 92 6 12 +Ethernet-BP4 MC15 131 93 7 11 + +""" + + +show_queue_counters_port = """\ + Port TxQ Counter/pkts Counter/bytes Drop/pkts Drop/bytes +------------ ----- -------------- --------------- ----------- ------------ +Ethernet-BP4 UC0 116 78 8 26 +Ethernet-BP4 UC1 117 79 7 25 +Ethernet-BP4 UC2 118 80 6 24 +Ethernet-BP4 UC3 119 81 5 23 +Ethernet-BP4 UC4 120 82 4 22 +Ethernet-BP4 UC5 121 83 3 21 +Ethernet-BP4 UC6 122 84 2 20 +Ethernet-BP4 UC7 123 85 1 19 +Ethernet-BP4 MC8 124 86 0 18 +Ethernet-BP4 MC9 125 87 1 17 +Ethernet-BP4 MC10 126 88 2 16 +Ethernet-BP4 MC11 127 89 3 15 +Ethernet-BP4 MC12 128 90 4 14 +Ethernet-BP4 MC13 129 91 5 13 +Ethernet-BP4 MC14 130 92 6 12 +Ethernet-BP4 MC15 131 93 7 11 + +""" + +class TestQueueMultiAsic(object): + @classmethod + def setup_class(cls): + os.environ["PATH"] += os.pathsep + scripts_path + os.environ['UTILITIES_UNIT_TESTING'] = "2" + os.environ["UTILITIES_UNIT_TESTING_TOPOLOGY"] = "multi_asic" + print("SETUP") + + def test_queue_counters(self): + return_code, result = get_result_and_return_code('queuestat -n asic0') + assert return_code == 0 + print(result) + assert result == show_queue_counters + + def test_queue_counters_port(self): + return_code, result = get_result_and_return_code('queuestat -p Ethernet-BP4 -n asic0') + assert return_code == 0 + print(result) + assert result == show_queue_counters_port + + @classmethod + def teardown_class(cls): + os.environ["PATH"] = os.pathsep.join(os.environ["PATH"].split(os.pathsep)[:-1]) + os.environ['UTILITIES_UNIT_TESTING'] = "0" + os.environ["UTILITIES_UNIT_TESTING_TOPOLOGY"] = "" + print("TEARDOWN") diff --git a/tests/muxcable_test.py b/tests/muxcable_test.py index 30798e3915..b8eb3dce62 100644 --- a/tests/muxcable_test.py +++ b/tests/muxcable_test.py @@ -25,25 +25,25 @@ tabular_data_status_output_expected = """\ -PORT STATUS HEALTH HWSTATUS LAST_SWITCHOVER_TIME ----------- -------- --------- ------------ --------------------------- -Ethernet0 active healthy inconsistent 2021-May-13 10:01:15.696728 -Ethernet4 standby healthy consistent -Ethernet8 standby unhealthy consistent -Ethernet12 unknown unhealthy inconsistent -Ethernet16 standby healthy consistent -Ethernet32 active healthy inconsistent +PORT STATUS SERVER_STATUS HEALTH HWSTATUS LAST_SWITCHOVER_TIME +---------- -------- --------------- --------- ------------ --------------------------- +Ethernet0 active active healthy inconsistent 2021-May-13 10:01:15.696728 +Ethernet4 standby standby healthy consistent +Ethernet8 standby standby unhealthy consistent +Ethernet12 active unknown unhealthy inconsistent +Ethernet16 standby standby healthy consistent +Ethernet32 active active healthy inconsistent """ tabular_data_status_output_expected_alias = """\ -PORT STATUS HEALTH HWSTATUS LAST_SWITCHOVER_TIME ------- -------- --------- ------------ --------------------------- -etp1 active healthy inconsistent 2021-May-13 10:01:15.696728 -etp2 standby healthy consistent -etp3 standby unhealthy consistent -etp4 unknown unhealthy inconsistent -etp5 standby healthy consistent -etp9 active healthy inconsistent +PORT STATUS SERVER_STATUS HEALTH HWSTATUS LAST_SWITCHOVER_TIME +------ -------- --------------- --------- ------------ --------------------------- +etp1 active active healthy inconsistent 2021-May-13 10:01:15.696728 +etp2 standby standby healthy consistent +etp3 standby standby unhealthy consistent +etp4 active unknown unhealthy inconsistent +etp5 standby standby healthy consistent +etp9 active active healthy inconsistent """ @@ -52,36 +52,42 @@ "MUX_CABLE": { "Ethernet0": { "STATUS": "active", + "SERVER_STATUS": "active", "HEALTH": "healthy", "HWSTATUS": "inconsistent", "LAST_SWITCHOVER_TIME": "2021-May-13 10:01:15.696728" }, "Ethernet4": { "STATUS": "standby", + "SERVER_STATUS": "standby", "HEALTH": "healthy", "HWSTATUS": "consistent", "LAST_SWITCHOVER_TIME": "" }, "Ethernet8": { "STATUS": "standby", + "SERVER_STATUS": "standby", "HEALTH": "unhealthy", "HWSTATUS": "consistent", "LAST_SWITCHOVER_TIME": "" }, "Ethernet12": { - "STATUS": "unknown", + "STATUS": "active", + "SERVER_STATUS": "unknown", "HEALTH": "unhealthy", "HWSTATUS": "inconsistent", "LAST_SWITCHOVER_TIME": "" }, "Ethernet16": { "STATUS": "standby", + "SERVER_STATUS": "standby", "HEALTH": "healthy", "HWSTATUS": "consistent", "LAST_SWITCHOVER_TIME": "" }, "Ethernet32": { "STATUS": "active", + "SERVER_STATUS": "active", "HEALTH": "healthy", "HWSTATUS": "inconsistent", "LAST_SWITCHOVER_TIME": "" @@ -95,36 +101,42 @@ "MUX_CABLE": { "etp1": { "STATUS": "active", + "SERVER_STATUS": "active", "HEALTH": "healthy", "HWSTATUS": "inconsistent", "LAST_SWITCHOVER_TIME": "2021-May-13 10:01:15.696728" }, "etp2": { "STATUS": "standby", + "SERVER_STATUS": "standby", "HEALTH": "healthy", "HWSTATUS": "consistent", "LAST_SWITCHOVER_TIME": "" }, "etp3": { "STATUS": "standby", + "SERVER_STATUS": "standby", "HEALTH": "unhealthy", "HWSTATUS": "consistent", "LAST_SWITCHOVER_TIME": "" }, "etp4": { - "STATUS": "unknown", + "STATUS": "active", + "SERVER_STATUS": "unknown", "HEALTH": "unhealthy", "HWSTATUS": "inconsistent", "LAST_SWITCHOVER_TIME": "" }, "etp5": { "STATUS": "standby", + "SERVER_STATUS": "standby", "HEALTH": "healthy", "HWSTATUS": "consistent", "LAST_SWITCHOVER_TIME": "" }, "etp9": { "STATUS": "active", + "SERVER_STATUS": "active", "HEALTH": "healthy", "HWSTATUS": "inconsistent", "LAST_SWITCHOVER_TIME": "" @@ -138,30 +150,30 @@ SWITCH_NAME PEER_TOR ------------- ---------- sonic-switch 10.2.2.2 -port state ipv4 ipv6 ----------- ------- -------- -------- +port state ipv4 ipv6 cable_type soc_ipv4 +---------- ------- -------- -------- -------------- ---------- Ethernet0 active 10.2.1.1 e800::46 Ethernet4 auto 10.3.1.1 e801::46 Ethernet8 active 10.4.1.1 e802::46 Ethernet12 active 10.4.1.1 e802::46 -Ethernet16 standby 10.1.1.1 fc00::75 +Ethernet16 standby 10.1.1.1 fc00::75 active-standby Ethernet28 manual 10.1.1.1 fc00::75 -Ethernet32 auto 10.1.1.1 fc00::75 +Ethernet32 auto 10.1.1.1 fc00::75 active-active 10.1.1.2 """ tabular_data_config_output_expected_alias = """\ SWITCH_NAME PEER_TOR ------------- ---------- sonic-switch 10.2.2.2 -port state ipv4 ipv6 ------- ------- -------- -------- +port state ipv4 ipv6 cable_type soc_ipv4 +------ ------- -------- -------- -------------- ---------- etp1 active 10.2.1.1 e800::46 etp2 auto 10.3.1.1 e801::46 etp3 active 10.4.1.1 e802::46 etp4 active 10.4.1.1 e802::46 -etp5 standby 10.1.1.1 fc00::75 +etp5 standby 10.1.1.1 fc00::75 active-standby etp8 manual 10.1.1.1 fc00::75 -etp9 auto 10.1.1.1 fc00::75 +etp9 auto 10.1.1.1 fc00::75 active-active 10.1.1.2 """ json_data_status_config_output_expected = """\ @@ -201,7 +213,8 @@ "STATE": "standby", "SERVER": { "IPv4": "10.1.1.1", - "IPv6": "fc00::75" + "IPv6": "fc00::75", + "cable_type": "active-standby" } }, "Ethernet28": { @@ -215,7 +228,9 @@ "STATE": "auto", "SERVER": { "IPv4": "10.1.1.1", - "IPv6": "fc00::75" + "IPv6": "fc00::75", + "cable_type": "active-active", + "soc_ipv4": "10.1.1.2" } } } @@ -260,7 +275,8 @@ "STATE": "standby", "SERVER": { "IPv4": "10.1.1.1", - "IPv6": "fc00::75" + "IPv6": "fc00::75", + "cable_type": "active-standby" } }, "etp8": { @@ -274,7 +290,9 @@ "STATE": "auto", "SERVER": { "IPv4": "10.1.1.1", - "IPv6": "fc00::75" + "IPv6": "fc00::75", + "cable_type": "active-active", + "soc_ipv4": "10.1.1.2" } } } @@ -366,6 +384,11 @@ Credo CACL1X321P2PA1M """ +expected_muxcable_cableinfo_invalid_port_output = """\ +Invalid port 'abc' +ERR: Unable to get a port on muxcable port +""" + show_muxcable_hwmode_muxdirection_active_expected_output = """\ Port Direction Presence ---------- ----------- ---------- @@ -404,6 +427,34 @@ } """ +show_muxcable_firmware_version_all_expected_output = """\ +{ + "Ethernet12": { + "version_nic_active": "0.1MS", + "version_nic_inactive": "0.1MS", + "version_nic_next": "0.1MS", + "version_peer_active": "0.1MS", + "version_peer_inactive": "0.1MS", + "version_peer_next": "0.1MS", + "version_self_active": "0.1MS", + "version_self_inactive": "0.1MS", + "version_self_next": "0.1MS" + } +} +""" + +show_muxcable_firmware_version_all_active_expected_output = """\ +{ + "Ethernet12": { + "version_nic_active": "0.1MS", + "version_peer_active": "0.1MS", + "version_self_active": "0.1MS" + } +} +""" + + + show_muxcable_firmware_version_active_expected_output = """\ { "version_self_active": "0.6MS", @@ -459,6 +510,54 @@ } """ +show_muxcable_tunnel_route_expected_output_json="""\ +{ + "TUNNEL_ROUTE": { + "Ethernet0": { + "server_ipv4": { + "DEST": "10.2.1.1", + "kernel": 1, + "asic": 1 + } + }, + "Ethernet4": { + "server_ipv4": { + "DEST": "10.3.1.1", + "kernel": 1, + "asic": false + } + } + } +} +""" + +show_muxcable_tunnel_route_expected_output="""\ +PORT DEST_TYPE DEST_ADDRESS kernel asic +--------- ----------- -------------- -------- ------ +Ethernet0 server_ipv4 10.2.1.1 added added +Ethernet4 server_ipv4 10.3.1.1 added - +""" + +show_muxcable_tunnel_route_expected_output_port_json="""\ +{ + "TUNNEL_ROUTE": { + "Ethernet0": { + "server_ipv4": { + "DEST": "10.2.1.1", + "kernel": 1, + "asic": 1 + } + } + } +} +""" + +show_muxcable_tunnel_route_expected_port_output="""\ +PORT DEST_TYPE DEST_ADDRESS kernel asic +--------- ----------- -------------- -------- ------ +Ethernet0 server_ipv4 10.2.1.1 added added +""" + class TestMuxcable(object): @classmethod def setup_class(cls): @@ -860,6 +959,15 @@ def test_config_muxcable_packetloss_reset_Ethernet0(self): assert result.exit_code == 0 + def test_config_muxcable_kill_radv_enable(self): + runner = CliRunner() + db = Db() + + result = runner.invoke(config.config.commands["muxcable"].commands["kill-radv"], ["enable"], obj=db) + + assert result.exit_code == 0 + assert result.output == "" + @mock.patch('show.muxcable.delete_all_keys_in_db_table', mock.MagicMock(return_value=0)) @mock.patch('show.muxcable.update_and_get_response_for_xcvr_cmd', mock.MagicMock(return_value={0: 0, 1: "active"})) @@ -920,6 +1028,7 @@ def test_show_mux_fecstatistics(self): assert result.exit_code == 0 + @mock.patch('click.confirm', mock.MagicMock(return_value=("y"))) @mock.patch('show.muxcable.delete_all_keys_in_db_table', mock.MagicMock(return_value=0)) @mock.patch('show.muxcable.update_and_get_response_for_xcvr_cmd', mock.MagicMock(return_value={0: 0, 1: "True"})) @@ -1080,6 +1189,21 @@ def test_show_muxcable_cableinfo_incorrect_logical_port_return_value(self): ["Ethernet0"], obj=db) assert result.exit_code == 1 + @mock.patch('sonic_y_cable.y_cable.get_part_number', mock.MagicMock(return_value=(False))) + @mock.patch('sonic_y_cable.y_cable.get_vendor', mock.MagicMock(return_value=(False))) + @mock.patch('show.muxcable.platform_sfputil', mock.MagicMock(return_value=1)) + def test_show_muxcable_cableinfo_invalid_port(self): + runner = CliRunner() + db = Db() + + result = runner.invoke(show.cli.commands["muxcable"].commands["cableinfo"], + ["Ethernet0"], obj=db) + assert result.exit_code == 1 + + result = runner.invoke(show.cli.commands["muxcable"].commands["cableinfo"], + ["abc"], obj=db) + assert result.exit_code == 1 + assert result.output == expected_muxcable_cableinfo_invalid_port_output @mock.patch('show.muxcable.delete_all_keys_in_db_table', mock.MagicMock(return_value=0)) @mock.patch('show.muxcable.update_and_get_response_for_xcvr_cmd', mock.MagicMock(return_value={0: 0, @@ -1368,6 +1492,66 @@ def test_show_muxcable_firmware_version(self): assert result.exit_code == 0 assert result.output == show_muxcable_firmware_version_expected_output + + @mock.patch('show.muxcable.delete_all_keys_in_db_table', mock.MagicMock(return_value=0)) + @mock.patch('show.muxcable.update_and_get_response_for_xcvr_cmd', mock.MagicMock(return_value={0: 0, + 1: "True"})) + @mock.patch('utilities_common.platform_sfputil_helper.get_logical_list', mock.MagicMock(return_value=["Ethernet0", "Ethernet12"])) + @mock.patch('utilities_common.platform_sfputil_helper.get_asic_id_for_logical_port', mock.MagicMock(return_value=0)) + @mock.patch('show.muxcable.platform_sfputil', mock.MagicMock(return_value={0: ["Ethernet12", "Ethernet0"]})) + @mock.patch('utilities_common.platform_sfputil_helper.get_logical_list', mock.MagicMock(return_value=["Ethernet0", "Ethernet12"])) + @mock.patch('utilities_common.platform_sfputil_helper.get_physical_to_logical', mock.MagicMock(return_value={0: ["Ethernet12", "Ethernet0"]})) + @mock.patch('utilities_common.platform_sfputil_helper.logical_port_name_to_physical_port_list', mock.MagicMock(return_value=[0])) + def test_show_muxcable_firmware_version_all(self): + runner = CliRunner() + db = Db() + + result = runner.invoke(show.cli.commands["muxcable"].commands["firmware"].commands["version"], [ + "all"], obj=db) + assert result.exit_code == 0 + f = open("newfile", "w") + f.write(result.output) + assert result.output == show_muxcable_firmware_version_all_expected_output + + + @mock.patch('show.muxcable.delete_all_keys_in_db_table', mock.MagicMock(return_value=0)) + @mock.patch('show.muxcable.update_and_get_response_for_xcvr_cmd', mock.MagicMock(return_value={0: 0, + 1: "True"})) + @mock.patch('utilities_common.platform_sfputil_helper.get_logical_list', mock.MagicMock(return_value=["Ethernet0", "Ethernet12"])) + @mock.patch('utilities_common.platform_sfputil_helper.get_asic_id_for_logical_port', mock.MagicMock(return_value=0)) + @mock.patch('show.muxcable.platform_sfputil', mock.MagicMock(return_value={0: ["Ethernet12", "Ethernet0"]})) + @mock.patch('utilities_common.platform_sfputil_helper.get_logical_list', mock.MagicMock(return_value=["Ethernet0", "Ethernet12"])) + @mock.patch('utilities_common.platform_sfputil_helper.get_physical_to_logical', mock.MagicMock(return_value={0: ["Ethernet12", "Ethernet0"]})) + @mock.patch('utilities_common.platform_sfputil_helper.logical_port_name_to_physical_port_list', mock.MagicMock(return_value=[0])) + def test_show_muxcable_firmware_version_all_active(self): + runner = CliRunner() + db = Db() + + result = runner.invoke(show.cli.commands["muxcable"].commands["firmware"].commands["version"], [ + "all", "--active"], obj=db) + assert result.exit_code == 0 + f = open("newfile", "w") + f.write(result.output) + assert result.output == show_muxcable_firmware_version_all_active_expected_output + + @mock.patch('show.muxcable.delete_all_keys_in_db_table', mock.MagicMock(return_value=0)) + @mock.patch('show.muxcable.update_and_get_response_for_xcvr_cmd', mock.MagicMock(return_value={0: 0, + 1: "True"})) + @mock.patch('utilities_common.platform_sfputil_helper.get_logical_list', mock.MagicMock(return_value=["Ethernet0", "Ethernet12"])) + @mock.patch('utilities_common.platform_sfputil_helper.get_asic_id_for_logical_port', mock.MagicMock(return_value=1)) + @mock.patch('show.muxcable.platform_sfputil', mock.MagicMock(return_value={0: ["Ethernet12", "Ethernet0"]})) + @mock.patch('utilities_common.platform_sfputil_helper.get_logical_list', mock.MagicMock(return_value=["Ethernet0", "Ethernet12"])) + @mock.patch('utilities_common.platform_sfputil_helper.get_physical_to_logical', mock.MagicMock(return_value={0: ["Ethernet12", "Ethernet0"]})) + @mock.patch('utilities_common.platform_sfputil_helper.logical_port_name_to_physical_port_list', mock.MagicMock(return_value=[0])) + def test_show_muxcable_firmware_version_all_bad_asic_index(self): + runner = CliRunner() + db = Db() + + result = runner.invoke(show.cli.commands["muxcable"].commands["firmware"].commands["version"], [ + "all"], obj=db) + assert result.exit_code == 1 + + @mock.patch('config.muxcable.delete_all_keys_in_db_table', mock.MagicMock(return_value=0)) @mock.patch('config.muxcable.update_and_get_response_for_xcvr_cmd', mock.MagicMock(return_value={0: 0, 1: "sucess"})) @@ -2095,6 +2279,94 @@ def test_show_muxcable_packetloss_port_json(self): assert result.exit_code == 0 assert result.output == show_muxcable_packetloss_expected_output_json + @mock.patch('utilities_common.platform_sfputil_helper.get_logical_list', mock.MagicMock(return_value=["Ethernet0", "Ethernet12"])) + @mock.patch('utilities_common.platform_sfputil_helper.get_asic_id_for_logical_port', mock.MagicMock(return_value=0)) + @mock.patch('show.muxcable.platform_sfputil', mock.MagicMock(return_value={0: ["Ethernet12", "Ethernet0"]})) + @mock.patch('utilities_common.platform_sfputil_helper.logical_port_name_to_physical_port_list', mock.MagicMock(return_value=[0])) + def test_show_muxcable_tunnel_route(self): + runner = CliRunner() + db = Db() + + result = runner.invoke(show.cli.commands["muxcable"].commands["tunnel-route"], obj=db) + + assert result.exit_code == 0 + assert result.output == show_muxcable_tunnel_route_expected_output + + @mock.patch('utilities_common.platform_sfputil_helper.get_logical_list', mock.MagicMock(return_value=["Ethernet0", "Ethernet12"])) + @mock.patch('utilities_common.platform_sfputil_helper.get_asic_id_for_logical_port', mock.MagicMock(return_value=0)) + @mock.patch('show.muxcable.platform_sfputil', mock.MagicMock(return_value={0: ["Ethernet12", "Ethernet0"]})) + @mock.patch('utilities_common.platform_sfputil_helper.logical_port_name_to_physical_port_list', mock.MagicMock(return_value=[0])) + def test_show_muxcable_tunnel_route_json(self): + runner = CliRunner() + db = Db() + + result = runner.invoke(show.cli.commands["muxcable"].commands["tunnel-route"], + ["--json"], obj=db) + + assert result.exit_code == 0 + assert result.output == show_muxcable_tunnel_route_expected_output_json + + @mock.patch('utilities_common.platform_sfputil_helper.get_logical_list', mock.MagicMock(return_value=["Ethernet0", "Ethernet12"])) + @mock.patch('utilities_common.platform_sfputil_helper.get_asic_id_for_logical_port', mock.MagicMock(return_value=0)) + @mock.patch('show.muxcable.platform_sfputil', mock.MagicMock(return_value={0: ["Ethernet12", "Ethernet0"]})) + @mock.patch('utilities_common.platform_sfputil_helper.logical_port_name_to_physical_port_list', mock.MagicMock(return_value=[0])) + def test_show_muxcable_tunnel_route_port(self): + runner = CliRunner() + db = Db() + + result = runner.invoke(show.cli.commands["muxcable"].commands["tunnel-route"], + ["Ethernet0"], obj=db) + + assert result.exit_code == 0 + assert result.output == show_muxcable_tunnel_route_expected_port_output + + @mock.patch('utilities_common.platform_sfputil_helper.get_logical_list', mock.MagicMock(return_value=["Ethernet0", "Ethernet12"])) + @mock.patch('utilities_common.platform_sfputil_helper.get_asic_id_for_logical_port', mock.MagicMock(return_value=0)) + @mock.patch('show.muxcable.platform_sfputil', mock.MagicMock(return_value={0: ["Ethernet12", "Ethernet0"]})) + @mock.patch('utilities_common.platform_sfputil_helper.logical_port_name_to_physical_port_list', mock.MagicMock(return_value=[0])) + def test_show_muxcable_tunnel_route_json_port(self): + runner = CliRunner() + db = Db() + + result = runner.invoke(show.cli.commands["muxcable"].commands["tunnel-route"], + ["Ethernet0", "--json"], obj=db) + assert result.exit_code == 0 + assert result.output == show_muxcable_tunnel_route_expected_output_port_json + + @mock.patch('config.muxcable.swsscommon.DBConnector', mock.MagicMock(return_value=0)) + @mock.patch('config.muxcable.swsscommon.Table', mock.MagicMock(return_value=0)) + @mock.patch('config.muxcable.swsscommon.Select', mock.MagicMock(return_value=0)) + def test_config_muxcable_telemetry_enable_without_patch(self): + runner = CliRunner() + db = Db() + + result = runner.invoke(config.config.commands["muxcable"].commands["telemetry"], [ + "enable"], obj=db) + assert result.exit_code == 1 + + @mock.patch('config.muxcable.swsscommon.DBConnector', mock.MagicMock(return_value=0)) + @mock.patch('config.muxcable.swsscommon.Table', mock.MagicMock(return_value=0)) + @mock.patch('config.muxcable.swsscommon.Select', mock.MagicMock(return_value=0)) + def test_config_muxcable_telemetry_disable_without_patch(self): + runner = CliRunner() + db = Db() + + result = runner.invoke(config.config.commands["muxcable"].commands["telemetry"], [ + "disable"], obj=db) + assert result.exit_code == 1 + + @mock.patch('config.muxcable.swsscommon.DBConnector', mock.MagicMock(return_value=0)) + @mock.patch('config.muxcable.swsscommon.Table', mock.MagicMock(return_value=0)) + @mock.patch('config.muxcable.swsscommon.Select', mock.MagicMock(return_value=0)) + @mock.patch('config.muxcable.update_configdb_ycable_telemetry_data', mock.MagicMock(return_value=0)) + def test_config_muxcable_telemetry_enable(self): + runner = CliRunner() + db = Db() + + result = runner.invoke(config.config.commands["muxcable"].commands["telemetry"], [ + "enable"], obj=db) + assert result.exit_code == 0 + @classmethod def teardown_class(cls): os.environ['UTILITIES_UNIT_TESTING'] = "0" diff --git a/tests/passw_hardening_input/assert_show_output.py b/tests/passw_hardening_input/assert_show_output.py new file mode 100644 index 0000000000..9500c98be4 --- /dev/null +++ b/tests/passw_hardening_input/assert_show_output.py @@ -0,0 +1,40 @@ +""" +Module holding the correct values for show CLI command outputs for the passw_hardening_test.py +""" + +show_passw_hardening_policies_default="""\ +STATE EXPIRATION EXPIRATION WARNING HISTORY CNT LEN MIN REJECT USER PASSW MATCH LOWER CLASS UPPER CLASS DIGITS CLASS SPECIAL CLASS +-------- ------------ -------------------- ------------- --------- ------------------------- ------------- ------------- -------------- --------------- +disabled 180 15 10 8 true true true true true +""" + +show_passw_hardening_policies_classes_disabled="""\ +STATE EXPIRATION EXPIRATION WARNING HISTORY CNT LEN MIN REJECT USER PASSW MATCH LOWER CLASS UPPER CLASS DIGITS CLASS SPECIAL CLASS +-------- ------------ -------------------- ------------- --------- ------------------------- ------------- ------------- -------------- --------------- +disabled 180 15 10 8 false false false false false +""" + +show_passw_hardening_policies_enabled="""\ +STATE EXPIRATION EXPIRATION WARNING HISTORY CNT LEN MIN REJECT USER PASSW MATCH LOWER CLASS UPPER CLASS DIGITS CLASS SPECIAL CLASS +------- ------------ -------------------- ------------- --------- ------------------------- ------------- ------------- -------------- --------------- +enabled 180 15 10 8 true true true true true +""" + + +show_passw_hardening_policies_expiration="""\ +STATE EXPIRATION EXPIRATION WARNING HISTORY CNT LEN MIN REJECT USER PASSW MATCH LOWER CLASS UPPER CLASS DIGITS CLASS SPECIAL CLASS +------- ------------ -------------------- ------------- --------- ------------------------- ------------- ------------- -------------- --------------- +enabled 100 15 10 8 true true true true true +""" + +show_passw_hardening_policies_history_cnt="""\ +STATE EXPIRATION EXPIRATION WARNING HISTORY CNT LEN MIN REJECT USER PASSW MATCH LOWER CLASS UPPER CLASS DIGITS CLASS SPECIAL CLASS +-------- ------------ -------------------- ------------- --------- ------------------------- ------------- ------------- -------------- --------------- +disabled 180 15 40 8 true true true true true +""" + +show_passw_hardening_policies_len_min="""\ +STATE EXPIRATION EXPIRATION WARNING HISTORY CNT LEN MIN REJECT USER PASSW MATCH LOWER CLASS UPPER CLASS DIGITS CLASS SPECIAL CLASS +-------- ------------ -------------------- ------------- --------- ------------------------- ------------- ------------- -------------- --------------- +disabled 180 15 10 30 true true true true true +""" \ No newline at end of file diff --git a/tests/passw_hardening_input/default_config_db.json b/tests/passw_hardening_input/default_config_db.json new file mode 100644 index 0000000000..0eb363eb41 --- /dev/null +++ b/tests/passw_hardening_input/default_config_db.json @@ -0,0 +1,14 @@ +{ + "PASSW_HARDENING|POLICIES": { + "state": "disabled", + "expiration": "180", + "expiration_warning": "15", + "history_cnt": "10", + "len_min": "8", + "reject_user_passw_match": "true", + "digits_class": "true", + "lower_class": "true", + "special_class": "true", + "upper_class": "true" + } +} diff --git a/tests/passw_hardening_test.py b/tests/passw_hardening_test.py new file mode 100644 index 0000000000..e57fdfd0c8 --- /dev/null +++ b/tests/passw_hardening_test.py @@ -0,0 +1,222 @@ +#!/usr/bin/env python + +import os +import logging +import show.main as show +import config.main as config + +from .passw_hardening_input import assert_show_output +from utilities_common.db import Db +from click.testing import CliRunner +from .mock_tables import dbconnector + +logger = logging.getLogger(__name__) +test_path = os.path.dirname(os.path.abspath(__file__)) +mock_db_path = os.path.join(test_path, "passw_hardening_input") + +SUCCESS = 0 +ERROR = 1 +INVALID_VALUE = 'INVALID' +EXP_GOOD_FLOW = 1 +EXP_BAD_FLOW = 0 + +class TestPasswHardening: + @classmethod + def setup_class(cls): + logger.info("SETUP") + os.environ['UTILITIES_UNIT_TESTING'] = "2" + + + @classmethod + def teardown_class(cls): + logger.info("TEARDOWN") + os.environ['UTILITIES_UNIT_TESTING'] = "0" + os.environ["UTILITIES_UNIT_TESTING_TOPOLOGY"] = "" + dbconnector.dedicated_dbs['CONFIG_DB'] = None + + def verify_passw_policies_output(self, db, runner, output, expected=EXP_GOOD_FLOW): + result = runner.invoke(show.cli.commands["passw-hardening"].commands["policies"], [], obj=db) + logger.debug("\n" + result.output) + logger.debug(result.exit_code) + + if expected: # good flow expected (default) + assert result.exit_code == SUCCESS + assert result.output == output + else: # bad flow expected + assert result.exit_code == ERROR + + def passw_hardening_set_policy(self, runner, db, attr, value, expected=EXP_GOOD_FLOW): + result = runner.invoke( + config.config.commands["passw-hardening"].commands["policies"].commands[attr], + [value], obj=db + ) + + if expected: # good flow expected (default) + logger.debug("\n" + result.output) + logger.debug(result.exit_code) + assert result.exit_code == SUCCESS + else: # bad flow expected + assert result.exit_code == ERROR + + + ######### PASSW-HARDENING ######### + + def test_passw_hardening_default(self): + dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'default_config_db') + db = Db() + runner = CliRunner() + + self.verify_passw_policies_output(db, runner, assert_show_output.show_passw_hardening_policies_default) + + def test_passw_hardening_feature_enabled(self): + dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'default_config_db') + db = Db() + runner = CliRunner() + + self.passw_hardening_set_policy(runner, db, "state", "enabled") + + self.verify_passw_policies_output(db, runner, assert_show_output.show_passw_hardening_policies_enabled) + + def test_passw_hardening_feature_disabled(self): + dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'default_config_db') + db = Db() + runner = CliRunner() + + self.passw_hardening_set_policy(runner, db, "state", "enabled") + self.passw_hardening_set_policy(runner, db, "state", "disabled") + + self.verify_passw_policies_output(db, runner, assert_show_output.show_passw_hardening_policies_default) + + def test_passw_hardening_policies_classes_disabled(self): + """Disable passw hardening classes & reject user passw match policies""" + + dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'default_config_db') + db = Db() + runner = CliRunner() + + passw_classes = { "reject-user-passw-match": "false", + "digits-class": "false", + "lower-class": "false", + "special-class": "false", + "upper-class": "false" + } + + for k, v in passw_classes.items(): + self.passw_hardening_set_policy(runner, db, k, v) + + self.verify_passw_policies_output(db, runner, assert_show_output.show_passw_hardening_policies_classes_disabled) + + def test_passw_hardening_policies_exp_time(self): + dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'default_config_db') + db = Db() + runner = CliRunner() + + self.passw_hardening_set_policy(runner, db, "state", "enabled") + self.passw_hardening_set_policy(runner, db, "expiration", "100") + self.passw_hardening_set_policy(runner, db, "expiration-warning", "15") + + self.verify_passw_policies_output(db, runner, assert_show_output.show_passw_hardening_policies_expiration) + + def test_passw_hardening_policies_history(self): + dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'default_config_db') + db = Db() + runner = CliRunner() + + self.passw_hardening_set_policy(runner, db, "history-cnt", "40") + + self.verify_passw_policies_output(db, runner, assert_show_output.show_passw_hardening_policies_history_cnt) + + def test_passw_hardening_policies_len_min(self): + dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'default_config_db') + db = Db() + runner = CliRunner() + + self.passw_hardening_set_policy(runner, db, "len-min", "30") + + self.verify_passw_policies_output(db, runner, assert_show_output.show_passw_hardening_policies_len_min) + + def test_passw_hardening_bad_flow_len_min(self): + dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'default_config_db') + db = Db() + runner = CliRunner() + + self.passw_hardening_set_policy(runner, db, "state", "enabled") + self.passw_hardening_set_policy(runner, db, "len-min", "10000", EXP_BAD_FLOW) + + def test_passw_hardening_bad_flow_history_cnt(self): + dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'default_config_db') + db = Db() + runner = CliRunner() + + self.passw_hardening_set_policy(runner, db, "state", "enabled") + self.passw_hardening_set_policy(runner, db, "history-cnt", "100000", EXP_BAD_FLOW) + + def test_passw_hardening_bad_flow_state(self): + dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'default_config_db') + db = Db() + runner = CliRunner() + + self.passw_hardening_set_policy(runner, db, "state", "0", EXP_BAD_FLOW) + + def test_passw_hardening_bad_flow_expiration(self): + dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'default_config_db') + db = Db() + runner = CliRunner() + + self.passw_hardening_set_policy(runner, db, "expiration", "####", EXP_BAD_FLOW) + + def test_passw_hardening_bad_flow_expiration_warning(self): + dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'default_config_db') + db = Db() + runner = CliRunner() + + self.passw_hardening_set_policy(runner, db, "expiration-warning", "4000", EXP_BAD_FLOW) + + def test_passw_hardening_bad_flow_upper_class(self): + dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'default_config_db') + db = Db() + runner = CliRunner() + + self.passw_hardening_set_policy(runner, db, "upper-class", "1", EXP_BAD_FLOW) + + def test_passw_hardening_bad_flow_lower_class(self): + dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'default_config_db') + db = Db() + runner = CliRunner() + + self.passw_hardening_set_policy(runner, db, "lower-class", "1", EXP_BAD_FLOW) + + def test_passw_hardening_bad_flow_special_class(self): + dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'default_config_db') + db = Db() + runner = CliRunner() + + self.passw_hardening_set_policy(runner, db, "special-class", "1", EXP_BAD_FLOW) + + def test_passw_hardening_bad_flow_digits_class(self): + dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'default_config_db') + db = Db() + runner = CliRunner() + + self.passw_hardening_set_policy(runner, db, "digits-class", "1", EXP_BAD_FLOW) + + def test_passw_hardening_bad_flow_reject_user_passw_match(self): + dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'default_config_db') + db = Db() + runner = CliRunner() + + self.passw_hardening_set_policy(runner, db, "reject-user-passw-match", "1", EXP_BAD_FLOW) + + def test_passw_hardening_bad_flow_policy(self): + dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'default_config_db') + db = Db() + runner = CliRunner() + try: + self.passw_hardening_set_policy(runner, db, "no-exist-command", "1", EXP_BAD_FLOW) + except Exception as e: + # import pdb;pdb.set_trace() + if 'no-exist-command' in str(e): + pass + else: + raise e + diff --git a/tests/pbh_test.py b/tests/pbh_test.py index 1972747782..7dddfea9ca 100644 --- a/tests/pbh_test.py +++ b/tests/pbh_test.py @@ -10,6 +10,7 @@ from .pbh_input import assert_show_output from utilities_common.db import Db +from utilities_common.cli import UserCache from click.testing import CliRunner from .mock_tables import dbconnector from .mock_tables import mock_single_asic @@ -876,10 +877,7 @@ def test_show_pbh_rule(self): def remove_pbh_counters_file(self): - SAVED_PBH_COUNTERS_FILE = '/tmp/.pbh_counters.txt' - if os.path.isfile(SAVED_PBH_COUNTERS_FILE): - os.remove(SAVED_PBH_COUNTERS_FILE) - + UserCache('pbh').remove_all() def test_show_pbh_statistics_on_empty_config(self): dbconnector.dedicated_dbs['CONFIG_DB'] = None diff --git a/tests/pfcstat_test.py b/tests/pfcstat_test.py index 955db3c23b..75f7ea6f59 100644 --- a/tests/pfcstat_test.py +++ b/tests/pfcstat_test.py @@ -8,6 +8,7 @@ import show.main as show from .utils import get_result_and_return_code +from utilities_common.cli import UserCache test_path = os.path.dirname(os.path.abspath(__file__)) modules_path = os.path.dirname(test_path) @@ -130,9 +131,8 @@ def del_cached_stats(): - uid = str(os.getuid()) - cnstat_dir = os.path.join(os.sep, "tmp", "pfcstat-{}".format(uid)) - shutil.rmtree(cnstat_dir, ignore_errors=True, onerror=None) + cache = UserCache("pfcstat") + cache.remove_all() def pfc_clear(expected_output): @@ -143,17 +143,6 @@ def pfc_clear(expected_output): 'pfcstat -c' ) - # verify that files are created with stats - uid = str(os.getuid()) - cnstat_dir = os.path.join(os.sep, "tmp", "pfcstat-{}".format(uid)) - cnstat_fqn_file_rx = "{}rx".format(uid) - cnstat_fqn_file_tx = "{}tx".format(uid) - file_list = [cnstat_fqn_file_tx, cnstat_fqn_file_rx] - file_list.sort() - files = os.listdir(cnstat_dir) - files.sort() - assert files == file_list - return_code, result = get_result_and_return_code( 'pfcstat -s all' ) diff --git a/tests/pgdrop_input/counters_db.json b/tests/pgdrop_input/counters_db.json new file mode 100644 index 0000000000..448f7a124f --- /dev/null +++ b/tests/pgdrop_input/counters_db.json @@ -0,0 +1,83 @@ +{ + "COUNTERS_PORT_NAME_MAP": { + }, + "COUNTERS_PG_NAME_MAP": { + "Ethernet0:0": "oid:0x1a00000000034f", + "Ethernet0:1": "oid:0x1a000000000350", + "Ethernet0:2": "oid:0x1a000000000351", + "Ethernet0:3": "oid:0x1a000000000352", + "Ethernet0:4": "oid:0x1a000000000353", + "Ethernet0:5": "oid:0x1a000000000354", + "Ethernet0:6": "oid:0x1a000000000355", + "Ethernet0:7": "oid:0x1a000000000356", + "Ethernet4:0": "oid:0x1a000000000377", + "Ethernet4:1": "oid:0x1a000000000378", + "Ethernet4:2": "oid:0x1a000000000379", + "Ethernet4:3": "oid:0x1a00000000037a", + "Ethernet4:4": "oid:0x1a00000000037b", + "Ethernet4:5": "oid:0x1a00000000037c", + "Ethernet4:6": "oid:0x1a00000000037d", + "Ethernet4:7": "oid:0x1a00000000037e", + "Ethernet8:0": "oid:0x1a00000000039f", + "Ethernet8:1": "oid:0x1a0000000003a0", + "Ethernet8:2": "oid:0x1a0000000003a1", + "Ethernet8:3": "oid:0x1a0000000003a2", + "Ethernet8:4": "oid:0x1a0000000003a3", + "Ethernet8:5": "oid:0x1a0000000003a4", + "Ethernet8:6": "oid:0x1a0000000003a5", + "Ethernet8:7": "oid:0x1a0000000003a6" + }, + "COUNTERS_PG_PORT_MAP": { + "oid:0x1a00000000034f": "oid:0x1000000000012", + "oid:0x1a000000000350": "oid:0x1000000000012", + "oid:0x1a000000000351": "oid:0x1000000000012", + "oid:0x1a000000000352": "oid:0x1000000000012", + "oid:0x1a000000000353": "oid:0x1000000000012", + "oid:0x1a000000000354": "oid:0x1000000000012", + "oid:0x1a000000000355": "oid:0x1000000000012", + "oid:0x1a000000000356": "oid:0x1000000000012", + "oid:0x1a000000000377": "oid:0x1000000000013", + "oid:0x1a000000000378": "oid:0x1000000000013", + "oid:0x1a000000000379": "oid:0x1000000000013", + "oid:0x1a00000000037a": "oid:0x1000000000013", + "oid:0x1a00000000037b": "oid:0x1000000000013", + "oid:0x1a00000000037c": "oid:0x1000000000013", + "oid:0x1a00000000037d": "oid:0x1000000000013", + "oid:0x1a00000000037e": "oid:0x1000000000013", + "oid:0x1a00000000039f": "oid:0x1000000000014", + "oid:0x1a0000000003a0": "oid:0x1000000000014", + "oid:0x1a0000000003a1": "oid:0x1000000000014", + "oid:0x1a0000000003a2": "oid:0x1000000000014", + "oid:0x1a0000000003a3": "oid:0x1000000000014", + "oid:0x1a0000000003a4": "oid:0x1000000000014", + "oid:0x1a0000000003a5": "oid:0x1000000000014", + "oid:0x1a0000000003a6": "oid:0x1000000000014" + }, + + "COUNTERS_PG_INDEX_MAP": { + "oid:0x1a00000000034f": "0", + "oid:0x1a000000000350": "1", + "oid:0x1a000000000351": "2", + "oid:0x1a000000000352": "3", + "oid:0x1a000000000353": "4", + "oid:0x1a000000000354": "5", + "oid:0x1a000000000355": "6", + "oid:0x1a000000000356": "7", + "oid:0x1a000000000377": "0", + "oid:0x1a000000000378": "1", + "oid:0x1a000000000379": "2", + "oid:0x1a00000000037a": "3", + "oid:0x1a00000000037b": "4", + "oid:0x1a00000000037c": "5", + "oid:0x1a00000000037d": "6", + "oid:0x1a00000000037e": "7", + "oid:0x1a00000000039f": "0", + "oid:0x1a0000000003a0": "1", + "oid:0x1a0000000003a1": "2", + "oid:0x1a0000000003a2": "3", + "oid:0x1a0000000003a3": "4", + "oid:0x1a0000000003a4": "5", + "oid:0x1a0000000003a5": "6", + "oid:0x1a0000000003a6": "7" + } +} diff --git a/tests/pgdrop_input/counters_db2.json b/tests/pgdrop_input/counters_db2.json new file mode 100644 index 0000000000..3c5d84df1f --- /dev/null +++ b/tests/pgdrop_input/counters_db2.json @@ -0,0 +1,63 @@ +{ + "COUNTERS_PORT_NAME_MAP": { + "Ethernet0": "oid:0x1000000000012", + "Ethernet4": "oid:0x1000000000013", + "Ethernet8": "oid:0x1000000000014" + + }, + "COUNTERS_PG_NAME_MAP": { + }, + "COUNTERS_PG_PORT_MAP": { + "oid:0x1a00000000034f": "oid:0x1000000000012", + "oid:0x1a000000000350": "oid:0x1000000000012", + "oid:0x1a000000000351": "oid:0x1000000000012", + "oid:0x1a000000000352": "oid:0x1000000000012", + "oid:0x1a000000000353": "oid:0x1000000000012", + "oid:0x1a000000000354": "oid:0x1000000000012", + "oid:0x1a000000000355": "oid:0x1000000000012", + "oid:0x1a000000000356": "oid:0x1000000000012", + "oid:0x1a000000000377": "oid:0x1000000000013", + "oid:0x1a000000000378": "oid:0x1000000000013", + "oid:0x1a000000000379": "oid:0x1000000000013", + "oid:0x1a00000000037a": "oid:0x1000000000013", + "oid:0x1a00000000037b": "oid:0x1000000000013", + "oid:0x1a00000000037c": "oid:0x1000000000013", + "oid:0x1a00000000037d": "oid:0x1000000000013", + "oid:0x1a00000000037e": "oid:0x1000000000013", + "oid:0x1a00000000039f": "oid:0x1000000000014", + "oid:0x1a0000000003a0": "oid:0x1000000000014", + "oid:0x1a0000000003a1": "oid:0x1000000000014", + "oid:0x1a0000000003a2": "oid:0x1000000000014", + "oid:0x1a0000000003a3": "oid:0x1000000000014", + "oid:0x1a0000000003a4": "oid:0x1000000000014", + "oid:0x1a0000000003a5": "oid:0x1000000000014", + "oid:0x1a0000000003a6": "oid:0x1000000000014" + }, + + "COUNTERS_PG_INDEX_MAP": { + "oid:0x1a00000000034f": "0", + "oid:0x1a000000000350": "1", + "oid:0x1a000000000351": "2", + "oid:0x1a000000000352": "3", + "oid:0x1a000000000353": "4", + "oid:0x1a000000000354": "5", + "oid:0x1a000000000355": "6", + "oid:0x1a000000000356": "7", + "oid:0x1a000000000377": "0", + "oid:0x1a000000000378": "1", + "oid:0x1a000000000379": "2", + "oid:0x1a00000000037a": "3", + "oid:0x1a00000000037b": "4", + "oid:0x1a00000000037c": "5", + "oid:0x1a00000000037d": "6", + "oid:0x1a00000000037e": "7", + "oid:0x1a00000000039f": "0", + "oid:0x1a0000000003a0": "1", + "oid:0x1a0000000003a1": "2", + "oid:0x1a0000000003a2": "3", + "oid:0x1a0000000003a3": "4", + "oid:0x1a0000000003a4": "5", + "oid:0x1a0000000003a5": "6", + "oid:0x1a0000000003a6": "7" + } +} diff --git a/tests/pgdrop_input/counters_db3.json b/tests/pgdrop_input/counters_db3.json new file mode 100644 index 0000000000..00ae077d03 --- /dev/null +++ b/tests/pgdrop_input/counters_db3.json @@ -0,0 +1,62 @@ +{ + "COUNTERS_PORT_NAME_MAP": { + "Ethernet0": "oid:0x1000000000012", + "Ethernet4": "oid:0x1000000000013", + "Ethernet8": "oid:0x1000000000014" + }, + "COUNTERS_PG_NAME_MAP": { + "Ethernet0:0": "oid:0x1a00000000034f", + "Ethernet0:1": "oid:0x1a000000000350", + "Ethernet0:2": "oid:0x1a000000000351", + "Ethernet0:3": "oid:0x1a000000000352", + "Ethernet0:4": "oid:0x1a000000000353", + "Ethernet0:5": "oid:0x1a000000000354", + "Ethernet0:6": "oid:0x1a000000000355", + "Ethernet0:7": "oid:0x1a000000000356", + "Ethernet4:0": "oid:0x1a000000000377", + "Ethernet4:1": "oid:0x1a000000000378", + "Ethernet4:2": "oid:0x1a000000000379", + "Ethernet4:3": "oid:0x1a00000000037a", + "Ethernet4:4": "oid:0x1a00000000037b", + "Ethernet4:5": "oid:0x1a00000000037c", + "Ethernet4:6": "oid:0x1a00000000037d", + "Ethernet4:7": "oid:0x1a00000000037e", + "Ethernet8:0": "oid:0x1a00000000039f", + "Ethernet8:1": "oid:0x1a0000000003a0", + "Ethernet8:2": "oid:0x1a0000000003a1", + "Ethernet8:3": "oid:0x1a0000000003a2", + "Ethernet8:4": "oid:0x1a0000000003a3", + "Ethernet8:5": "oid:0x1a0000000003a4", + "Ethernet8:6": "oid:0x1a0000000003a5", + "Ethernet8:7": "oid:0x1a0000000003a6" + }, + "COUNTERS_PG_PORT_MAP": { + }, + + "COUNTERS_PG_INDEX_MAP": { + "oid:0x1a00000000034f": "0", + "oid:0x1a000000000350": "1", + "oid:0x1a000000000351": "2", + "oid:0x1a000000000352": "3", + "oid:0x1a000000000353": "4", + "oid:0x1a000000000354": "5", + "oid:0x1a000000000355": "6", + "oid:0x1a000000000356": "7", + "oid:0x1a000000000377": "0", + "oid:0x1a000000000378": "1", + "oid:0x1a000000000379": "2", + "oid:0x1a00000000037a": "3", + "oid:0x1a00000000037b": "4", + "oid:0x1a00000000037c": "5", + "oid:0x1a00000000037d": "6", + "oid:0x1a00000000037e": "7", + "oid:0x1a00000000039f": "0", + "oid:0x1a0000000003a0": "1", + "oid:0x1a0000000003a1": "2", + "oid:0x1a0000000003a2": "3", + "oid:0x1a0000000003a3": "4", + "oid:0x1a0000000003a4": "5", + "oid:0x1a0000000003a5": "6", + "oid:0x1a0000000003a6": "7" + } +} diff --git a/tests/pgdrop_input/counters_db4.json b/tests/pgdrop_input/counters_db4.json new file mode 100644 index 0000000000..366652a5ef --- /dev/null +++ b/tests/pgdrop_input/counters_db4.json @@ -0,0 +1,62 @@ +{ + "COUNTERS_PORT_NAME_MAP": { + "Ethernet0": "oid:0x1000000000012", + "Ethernet4": "oid:0x1000000000013", + "Ethernet8": "oid:0x1000000000014" + }, + "COUNTERS_PG_NAME_MAP": { + "Ethernet0:0": "oid:0x1a00000000034f", + "Ethernet0:1": "oid:0x1a000000000350", + "Ethernet0:2": "oid:0x1a000000000351", + "Ethernet0:3": "oid:0x1a000000000352", + "Ethernet0:4": "oid:0x1a000000000353", + "Ethernet0:5": "oid:0x1a000000000354", + "Ethernet0:6": "oid:0x1a000000000355", + "Ethernet0:7": "oid:0x1a000000000356", + "Ethernet4:0": "oid:0x1a000000000377", + "Ethernet4:1": "oid:0x1a000000000378", + "Ethernet4:2": "oid:0x1a000000000379", + "Ethernet4:3": "oid:0x1a00000000037a", + "Ethernet4:4": "oid:0x1a00000000037b", + "Ethernet4:5": "oid:0x1a00000000037c", + "Ethernet4:6": "oid:0x1a00000000037d", + "Ethernet4:7": "oid:0x1a00000000037e", + "Ethernet8:0": "oid:0x1a00000000039f", + "Ethernet8:1": "oid:0x1a0000000003a0", + "Ethernet8:2": "oid:0x1a0000000003a1", + "Ethernet8:3": "oid:0x1a0000000003a2", + "Ethernet8:4": "oid:0x1a0000000003a3", + "Ethernet8:5": "oid:0x1a0000000003a4", + "Ethernet8:6": "oid:0x1a0000000003a5", + "Ethernet8:7": "oid:0x1a0000000003a6" + }, + "COUNTERS_PG_PORT_MAP": { + "oid:0x1a00000000034f": "oid:0x1000000000012", + "oid:0x1a000000000350": "oid:0x1000000000012", + "oid:0x1a000000000351": "oid:0x1000000000012", + "oid:0x1a000000000352": "oid:0x1000000000012", + "oid:0x1a000000000353": "oid:0x1000000000012", + "oid:0x1a000000000354": "oid:0x1000000000012", + "oid:0x1a000000000355": "oid:0x1000000000012", + "oid:0x1a000000000356": "oid:0x1000000000012", + "oid:0x1a000000000377": "oid:0x1000000000013", + "oid:0x1a000000000378": "oid:0x1000000000013", + "oid:0x1a000000000379": "oid:0x1000000000013", + "oid:0x1a00000000037a": "oid:0x1000000000013", + "oid:0x1a00000000037b": "oid:0x1000000000013", + "oid:0x1a00000000037c": "oid:0x1000000000013", + "oid:0x1a00000000037d": "oid:0x1000000000013", + "oid:0x1a00000000037e": "oid:0x1000000000013", + "oid:0x1a00000000039f": "oid:0x1000000000014", + "oid:0x1a0000000003a0": "oid:0x1000000000014", + "oid:0x1a0000000003a1": "oid:0x1000000000014", + "oid:0x1a0000000003a2": "oid:0x1000000000014", + "oid:0x1a0000000003a3": "oid:0x1000000000014", + "oid:0x1a0000000003a4": "oid:0x1000000000014", + "oid:0x1a0000000003a5": "oid:0x1000000000014", + "oid:0x1a0000000003a6": "oid:0x1000000000014" + }, + + "COUNTERS_PG_INDEX_MAP": { + } +} diff --git a/tests/pgdropstat_test.py b/tests/pgdropstat_test.py index 3aea0f2959..6b58b8f6e2 100644 --- a/tests/pgdropstat_test.py +++ b/tests/pgdropstat_test.py @@ -9,6 +9,8 @@ from click.testing import CliRunner from shutil import copyfile +from utilities_common.cli import UserCache + test_path = os.path.dirname(os.path.abspath(__file__)) modules_path = os.path.dirname(test_path) scripts_path = os.path.join(modules_path, "scripts") @@ -41,18 +43,95 @@ def setup_class(cls): os.environ['UTILITIES_UNIT_TESTING'] = "2" print("SETUP") + def replace_file(self, file_name_src, file_name_dst): + sample_config_db_file = os.path.join(test_path, file_name_src) + mock_config_db_file = os.path.join(test_path, "mock_tables", file_name_dst) + + #Backup origin config_db and replace it with config_db file with disabled PG_DROP counters + copyfile(mock_config_db_file, "/tmp/" + file_name_dst) + copyfile(sample_config_db_file, mock_config_db_file) + + return mock_config_db_file + + @pytest.fixture(scope='function') + def replace_counter_db_file(self): + mock_file = self.replace_file("pgdrop_input/counters_db.json", "counters_db.json") + + yield + + copyfile("/tmp/counters_db.json", mock_file) + @pytest.fixture(scope='function') def replace_config_db_file(self): - sample_config_db_file = os.path.join(test_path, "pgdrop_input", "config_db.json") - mock_config_db_file = os.path.join(test_path, "mock_tables", "config_db.json") + mock_file = self.replace_file("pgdrop_input/config_db.json", "config_db.json") - #Backup origin config_db and replace it with config_db file with disabled PG_DROP counters - copyfile(mock_config_db_file, "/tmp/config_db.json") - copyfile(sample_config_db_file, mock_config_db_file) + yield + + copyfile("/tmp/config_db.json", mock_file) + + @pytest.fixture(scope='function') + def replace_counter_db2_file(self): + mock_file = self.replace_file("pgdrop_input/counters_db2.json", "counters_db.json") yield - copyfile("/tmp/config_db.json", mock_config_db_file) + copyfile("/tmp/counters_db.json", mock_file) + + @pytest.fixture(scope='function') + def replace_counter_db3_file(self): + mock_file = self.replace_file("pgdrop_input/counters_db3.json", "counters_db.json") + + yield + + copyfile("/tmp/counters_db.json", mock_file) + + @pytest.fixture(scope='function') + def replace_counter_db4_file(self): + mock_file = self.replace_file("pgdrop_input/counters_db4.json", "counters_db.json") + + yield + + copyfile("/tmp/counters_db.json", mock_file) + + def test_show_pg_drop_pg_port_map(self, replace_counter_db3_file): + runner = CliRunner() + + result = runner.invoke(show.cli.commands["priority-group"].commands["drop"].commands["counters"]) + assert result.exit_code == 1 + print(result.exit_code) + + assert "Port is not available for oid" in result.output + print(result.exit_code) + + def test_show_pg_drop_pg_index_map(self, replace_counter_db4_file): + runner = CliRunner() + + result = runner.invoke(show.cli.commands["priority-group"].commands["drop"].commands["counters"]) + assert result.exit_code == 1 + print(result.exit_code) + + assert "Priority group index is not available for oid" in result.output + print(result.output) + + def test_show_pg_drop_port_name_map(self, replace_counter_db_file): + runner = CliRunner() + + result = runner.invoke(show.cli.commands["priority-group"].commands["drop"].commands["counters"]) + assert result.exit_code == 1 + print(result.exit_code) + + assert result.output == "COUNTERS_PORT_NAME_MAP is empty!\n" + print(result.output) + + def test_show_pg_drop_pg_name_map(self, replace_counter_db2_file): + runner = CliRunner() + + result = runner.invoke(show.cli.commands["priority-group"].commands["drop"].commands["counters"]) + assert result.exit_code == 1 + print(result.exit_code) + + assert result.output == "COUNTERS_PG_NAME_MAP is empty!\n" + print(result.output) def test_show_pg_drop_disabled(self, replace_config_db_file): runner = CliRunner() @@ -88,25 +167,9 @@ def executor(self, clear_before_show): assert result.exit_code == 0 assert result.output == show_output - def test_show_pg_drop_config_reload(self): - runner = CliRunner() - self.test_show_pg_drop_clear() - - # simulate 'config reload' to provoke counters recalculation (remove backup from /tmp folder) - result = runner.invoke(config.config.commands["reload"], [ "--no_service_restart", "-y"]) - - print(result.exit_code) - print(result.output) - - assert result.exit_code == 0 - - self.test_show_pg_drop_show() - @classmethod def teardown_class(cls): os.environ["PATH"] = os.pathsep.join(os.environ["PATH"].split(os.pathsep)[:-1]) os.environ['UTILITIES_UNIT_TESTING'] = "0" - dropstat_dir_prefix = '/tmp/dropstat' - dir_path = "{}-{}/".format(dropstat_dir_prefix, os.getuid()) - os.system("rm -rf {}".format(dir_path)) + UserCache('pg-drop').remove_all() print("TEARDOWN") diff --git a/tests/portchannel_test.py b/tests/portchannel_test.py index ebf77e86b5..705d22890c 100644 --- a/tests/portchannel_test.py +++ b/tests/portchannel_test.py @@ -121,6 +121,19 @@ def test_add_portchannel_member_which_has_ipaddress(self): assert result.exit_code != 0 assert "Error: Ethernet0 has ip address configured" in result.output + def test_add_portchannel_member_which_has_subintf(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + # add a portchannel member with port which has ip-address + result = runner.invoke(config.config.commands["portchannel"].commands["member"].commands["add"], ["PortChannel1001", "Ethernet36"], obj=obj) + print(result.exit_code) + print(result.output) + assert result.exit_code != 0 + print(result.output) + assert "Error: Ethernet36 has subinterfaces configured" in result.output + def test_add_portchannel_member_which_is_member_of_vlan(self): runner = CliRunner() db = Db() @@ -157,6 +170,18 @@ def test_delete_portchannel_member_which_is_member_of_another_po(self): assert result.exit_code != 0 assert "Error: Ethernet116 is not a member of portchannel PortChannel1001" in result.output + def test_delete_portchannel_which_is_member_of_a_vlan(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + # try to delete the portchannel when its member of a vlan + result = runner.invoke(config.config.commands["portchannel"].commands["del"], ["PortChannel1001"], obj=obj) + print(result.exit_code) + print(result.output) + assert result.exit_code != 0 + assert "PortChannel1001 has vlan Vlan4000 configured, remove vlan membership to proceed" in result.output + @classmethod def teardown_class(cls): os.environ['UTILITIES_UNIT_TESTING'] = "0" diff --git a/tests/portstat_test.py b/tests/portstat_test.py index b8dd055733..f431747c62 100644 --- a/tests/portstat_test.py +++ b/tests/portstat_test.py @@ -6,6 +6,7 @@ import clear.main as clear import show.main as show from .utils import get_result_and_return_code +from utilities_common.cli import UserCache root_path = os.path.dirname(os.path.abspath(__file__)) modules_path = os.path.dirname(root_path) @@ -57,6 +58,9 @@ --------- ------- ------- -------- --------- -------- -------- -------- ------- -------- --------- -------- -------- -------- Ethernet0 U 8 0.00 B/s 0.00% 10 100 N/A 10 0.00 B/s 0.00% N/A N/A N/A Ethernet4 U 4 0.00 B/s 0.00% 0 1,000 N/A 40 0.00 B/s 0.00% N/A N/A N/A + +Reminder: Please execute 'show interface counters -d all' to include internal links + """ multi_asic_all_intf_counters = """\ @@ -68,6 +72,9 @@ Ethernet-BP4 U 8 0.00 B/s 0.00% 0 1,000 N/A 80 0.00 B/s 0.00% N/A N/A N/A Ethernet-BP256 U 8 0.00 B/s 0.00% 10 100 N/A 10 0.00 B/s 0.00% N/A N/A N/A Ethernet-BP260 U 4 0.00 B/s 0.00% 0 1,000 N/A 40 0.00 B/s 0.00% N/A N/A N/A + +Reminder: Please execute 'show interface counters -d all' to include internal links + """ multi_asic_intf_counters_asic0 = """\ IFACE STATE RX_OK RX_BPS RX_UTIL RX_ERR RX_DRP RX_OVR TX_OK TX_BPS TX_UTIL TX_ERR TX_DRP TX_OVR @@ -76,6 +83,9 @@ Ethernet4 U 4 0.00 B/s 0.00% 0 1,000 N/A 40 0.00 B/s 0.00% N/A N/A N/A Ethernet-BP0 U 6 0.00 B/s 0.00% 0 1,000 N/A 60 0.00 B/s 0.00% N/A N/A N/A Ethernet-BP4 U 8 0.00 B/s 0.00% 0 1,000 N/A 80 0.00 B/s 0.00% N/A N/A N/A + +Reminder: Please execute 'show interface counters -d all' to include internal links + """ multi_asic_external_intf_counters_printall = """\ @@ -83,6 +93,9 @@ --------- ------- ------- -------- -------- --------- -------- -------- -------- ------- -------- -------- --------- -------- -------- -------- Ethernet0 U 8 0.00 B/s 0.00/s 0.00% 10 100 N/A 10 0.00 B/s 0.00/s 0.00% N/A N/A N/A Ethernet4 U 4 0.00 B/s 0.00/s 0.00% 0 1,000 N/A 40 0.00 B/s 0.00/s 0.00% N/A N/A N/A + +Reminder: Please execute 'show interface counters -d all' to include internal links + """ multi_asic_intf_counters_printall = """\ @@ -94,6 +107,9 @@ Ethernet-BP4 U 8 0.00 B/s 0.00/s 0.00% 0 1,000 N/A 80 0.00 B/s 0.00/s 0.00% N/A N/A N/A Ethernet-BP256 U 8 0.00 B/s 0.00/s 0.00% 10 100 N/A 10 0.00 B/s 0.00/s 0.00% N/A N/A N/A Ethernet-BP260 U 4 0.00 B/s 0.00/s 0.00% 0 1,000 N/A 40 0.00 B/s 0.00/s 0.00% N/A N/A N/A + +Reminder: Please execute 'show interface counters -d all' to include internal links + """ multi_asic_intf_counters_asic0_printall = """\ @@ -103,6 +119,9 @@ Ethernet4 U 4 0.00 B/s 0.00/s 0.00% 0 1,000 N/A 40 0.00 B/s 0.00/s 0.00% N/A N/A N/A Ethernet-BP0 U 6 0.00 B/s 0.00/s 0.00% 0 1,000 N/A 60 0.00 B/s 0.00/s 0.00% N/A N/A N/A Ethernet-BP4 U 8 0.00 B/s 0.00/s 0.00% 0 1,000 N/A 80 0.00 B/s 0.00/s 0.00% N/A N/A N/A + +Reminder: Please execute 'show interface counters -d all' to include internal links + """ multi_asic_intf_counters_period = """\ The rates are calculated within 3 seconds period @@ -110,6 +129,9 @@ --------- ------- ------- -------- --------- -------- -------- -------- ------- -------- --------- -------- -------- -------- Ethernet0 U 0 0.00 B/s 0.00% 0 0 N/A 0 0.00 B/s 0.00% N/A N/A N/A Ethernet4 U 0 0.00 B/s 0.00% 0 0 N/A 0 0.00 B/s 0.00% N/A N/A N/A + +Reminder: Please execute 'show interface counters -d all' to include internal links + """ multi_asic_intf_counters_period_all = """\ @@ -122,6 +144,9 @@ Ethernet-BP4 U 0 0.00 B/s 0.00% 0 0 N/A 0 0.00 B/s 0.00% N/A N/A N/A Ethernet-BP256 U 0 0.00 B/s 0.00% 0 0 N/A 0 0.00 B/s 0.00% N/A N/A N/A Ethernet-BP260 U 0 0.00 B/s 0.00% 0 0 N/A 0 0.00 B/s 0.00% N/A N/A N/A + +Reminder: Please execute 'show interface counters -d all' to include internal links + """ multi_asic_intf_counter_period_asic_all = """\ @@ -132,6 +157,9 @@ Ethernet4 U 0 0.00 B/s 0.00% 0 0 N/A 0 0.00 B/s 0.00% N/A N/A N/A Ethernet-BP0 U 0 0.00 B/s 0.00% 0 0 N/A 0 0.00 B/s 0.00% N/A N/A N/A Ethernet-BP4 U 0 0.00 B/s 0.00% 0 0 N/A 0 0.00 B/s 0.00% N/A N/A N/A + +Reminder: Please execute 'show interface counters -d all' to include internal links + """ mutli_asic_intf_counters_after_clear = """\ @@ -142,7 +170,11 @@ Ethernet-BP0 U 0 0.00 B/s 0.00% 0 0 N/A 0 0.00 B/s 0.00% N/A N/A N/A Ethernet-BP4 U 0 0.00 B/s 0.00% 0 0 N/A 0 0.00 B/s 0.00% N/A N/A N/A Ethernet-BP256 U 0 0.00 B/s 0.00% 0 0 N/A 0 0.00 B/s 0.00% N/A N/A N/A -Ethernet-BP260 U 0 0.00 B/s 0.00% 0 0 N/A 0 0.00 B/s 0.00% N/A N/A N/A""" +Ethernet-BP260 U 0 0.00 B/s 0.00% 0 0 N/A 0 0.00 B/s 0.00% N/A N/A N/A + +Reminder: Please execute 'show interface counters -d all' to include internal links +""" + intf_invalid_asic_error = """ValueError: Unknown Namespace asic99""" @@ -191,9 +223,8 @@ def remove_tmp_cnstat_file(): # remove the tmp portstat - uid = str(os.getuid()) - cnstat_dir = os.path.join(os.sep, "tmp", "portstat-{}".format(uid)) - shutil.rmtree(cnstat_dir, ignore_errors=True, onerror=None) + cache = UserCache("portstat") + cache.remove_all() def verify_after_clear(output, expected_out): diff --git a/tests/queue_counter_test.py b/tests/queue_counter_test.py index 66dfc828ed..b7b3637126 100644 --- a/tests/queue_counter_test.py +++ b/tests/queue_counter_test.py @@ -895,6 +895,263 @@ } }""" +show_queue_voq_counters = """\ + Port Voq Counter/pkts Counter/bytes Drop/pkts Drop/bytes +--------- ----- -------------- --------------- ----------- ------------ +Ethernet0 VOQ0 68 30 56 74 +Ethernet0 VOQ1 60 43 39 1 +Ethernet0 VOQ2 82 7 39 21 +Ethernet0 VOQ3 11 59 12 94 +Ethernet0 VOQ4 36 62 35 40 +Ethernet0 VOQ5 49 91 2 88 +Ethernet0 VOQ6 33 17 94 74 +Ethernet0 VOQ7 40 71 95 33 + + Port Voq Counter/pkts Counter/bytes Drop/pkts Drop/bytes +--------- ----- -------------- --------------- ----------- ------------ +Ethernet4 VOQ0 54 8 93 78 +Ethernet4 VOQ1 83 96 74 9 +Ethernet4 VOQ2 15 60 61 31 +Ethernet4 VOQ3 45 52 82 94 +Ethernet4 VOQ4 55 88 89 52 +Ethernet4 VOQ5 14 70 95 79 +Ethernet4 VOQ6 68 60 66 81 +Ethernet4 VOQ7 63 4 48 76 + + Port Voq Counter/pkts Counter/bytes Drop/pkts Drop/bytes +--------- ----- -------------- --------------- ----------- ------------ +Ethernet8 VOQ0 41 73 77 74 +Ethernet8 VOQ1 60 21 56 54 +Ethernet8 VOQ2 57 31 12 39 +Ethernet8 VOQ3 41 96 70 98 +Ethernet8 VOQ4 18 49 63 36 +Ethernet8 VOQ5 99 90 3 15 +Ethernet8 VOQ6 8 84 82 94 +Ethernet8 VOQ7 83 15 75 92 + +""" + +show_queue_port_voq_counters = """\ + Port Voq Counter/pkts Counter/bytes Drop/pkts Drop/bytes +--------- ----- -------------- --------------- ----------- ------------ +Ethernet0 VOQ0 68 30 56 74 +Ethernet0 VOQ1 60 43 39 1 +Ethernet0 VOQ2 82 7 39 21 +Ethernet0 VOQ3 11 59 12 94 +Ethernet0 VOQ4 36 62 35 40 +Ethernet0 VOQ5 49 91 2 88 +Ethernet0 VOQ6 33 17 94 74 +Ethernet0 VOQ7 40 71 95 33 + +""" + +show_queue_voq_counters_json = """\ +{ + "Ethernet0": { + "VOQ0": { + "dropbytes": "74", + "droppacket": "56", + "totalbytes": "30", + "totalpacket": "68" + }, + "VOQ1": { + "dropbytes": "1", + "droppacket": "39", + "totalbytes": "43", + "totalpacket": "60" + }, + "VOQ2": { + "dropbytes": "21", + "droppacket": "39", + "totalbytes": "7", + "totalpacket": "82" + }, + "VOQ3": { + "dropbytes": "94", + "droppacket": "12", + "totalbytes": "59", + "totalpacket": "11" + }, + "VOQ4": { + "dropbytes": "40", + "droppacket": "35", + "totalbytes": "62", + "totalpacket": "36" + }, + "VOQ5": { + "dropbytes": "88", + "droppacket": "2", + "totalbytes": "91", + "totalpacket": "49" + }, + "VOQ6": { + "dropbytes": "74", + "droppacket": "94", + "totalbytes": "17", + "totalpacket": "33" + }, + "VOQ7": { + "dropbytes": "33", + "droppacket": "95", + "totalbytes": "71", + "totalpacket": "40" + } + }, + "Ethernet4": { + "VOQ0": { + "dropbytes": "78", + "droppacket": "93", + "totalbytes": "8", + "totalpacket": "54" + }, + "VOQ1": { + "dropbytes": "9", + "droppacket": "74", + "totalbytes": "96", + "totalpacket": "83" + }, + "VOQ2": { + "dropbytes": "31", + "droppacket": "61", + "totalbytes": "60", + "totalpacket": "15" + }, + "VOQ3": { + "dropbytes": "94", + "droppacket": "82", + "totalbytes": "52", + "totalpacket": "45" + }, + "VOQ4": { + "dropbytes": "52", + "droppacket": "89", + "totalbytes": "88", + "totalpacket": "55" + }, + "VOQ5": { + "dropbytes": "79", + "droppacket": "95", + "totalbytes": "70", + "totalpacket": "14" + }, + "VOQ6": { + "dropbytes": "81", + "droppacket": "66", + "totalbytes": "60", + "totalpacket": "68" + }, + "VOQ7": { + "dropbytes": "76", + "droppacket": "48", + "totalbytes": "4", + "totalpacket": "63" + } + }, + "Ethernet8": { + "VOQ0": { + "dropbytes": "74", + "droppacket": "77", + "totalbytes": "73", + "totalpacket": "41" + }, + "VOQ1": { + "dropbytes": "54", + "droppacket": "56", + "totalbytes": "21", + "totalpacket": "60" + }, + "VOQ2": { + "dropbytes": "39", + "droppacket": "12", + "totalbytes": "31", + "totalpacket": "57" + }, + "VOQ3": { + "dropbytes": "98", + "droppacket": "70", + "totalbytes": "96", + "totalpacket": "41" + }, + "VOQ4": { + "dropbytes": "36", + "droppacket": "63", + "totalbytes": "49", + "totalpacket": "18" + }, + "VOQ5": { + "dropbytes": "15", + "droppacket": "3", + "totalbytes": "90", + "totalpacket": "99" + }, + "VOQ6": { + "dropbytes": "94", + "droppacket": "82", + "totalbytes": "84", + "totalpacket": "8" + }, + "VOQ7": { + "dropbytes": "92", + "droppacket": "75", + "totalbytes": "15", + "totalpacket": "83" + } + } +}""" + +show_queue_port_voq_counters_json = """\ +{ + "Ethernet0": { + "VOQ0": { + "dropbytes": "74", + "droppacket": "56", + "totalbytes": "30", + "totalpacket": "68" + }, + "VOQ1": { + "dropbytes": "1", + "droppacket": "39", + "totalbytes": "43", + "totalpacket": "60" + }, + "VOQ2": { + "dropbytes": "21", + "droppacket": "39", + "totalbytes": "7", + "totalpacket": "82" + }, + "VOQ3": { + "dropbytes": "94", + "droppacket": "12", + "totalbytes": "59", + "totalpacket": "11" + }, + "VOQ4": { + "dropbytes": "40", + "droppacket": "35", + "totalbytes": "62", + "totalpacket": "36" + }, + "VOQ5": { + "dropbytes": "88", + "droppacket": "2", + "totalbytes": "91", + "totalpacket": "49" + }, + "VOQ6": { + "dropbytes": "74", + "droppacket": "94", + "totalbytes": "17", + "totalpacket": "33" + }, + "VOQ7": { + "dropbytes": "33", + "droppacket": "95", + "totalbytes": "71", + "totalpacket": "40" + } + } +}""" class TestQueue(object): @classmethod @@ -953,6 +1210,58 @@ def test_queue_counters_port_json(self): del v["time"] assert json_dump(json_output) == show_queue_counters_port_json + def test_queue_voq_counters(self): + runner = CliRunner() + result = runner.invoke( + show.cli.commands["queue"].commands["counters"], + ["--voq"] + ) + print(result.output) + assert result.exit_code == 0 + assert result.output == show_queue_voq_counters + + def test_queue_port_voq_counters(self): + runner = CliRunner() + result = runner.invoke( + show.cli.commands["queue"].commands["counters"], + ["Ethernet0 --voq"] + ) + print(result.output) + assert result.exit_code == 0 + assert result.output == show_queue_port_voq_counters + + def test_queue_voq_counters_json(self): + runner = CliRunner() + result = runner.invoke( + show.cli.commands["queue"].commands["counters"], + ["--voq", "--json"] + ) + assert result.exit_code == 0 + print(result.output) + json_output = json.loads(result.output) + + # remove "time" from the output + for _, v in json_output.items(): + del v["time"] + print(json_dump(json_output)) + print(show_queue_voq_counters_json) + assert json_dump(json_output) == show_queue_voq_counters_json + + def test_queue_voq_counters_port_json(self): + runner = CliRunner() + result = runner.invoke( + show.cli.commands["queue"].commands["counters"], + ["Ethernet0", "--voq", "--json"] + ) + assert result.exit_code == 0 + print(result.output) + json_output = json.loads(result.output) + + # remove "time" from the output + for _, v in json_output.items(): + del v["time"] + assert json_dump(json_output) == show_queue_port_voq_counters_json + @classmethod def teardown_class(cls): os.environ["PATH"] = os.pathsep.join(os.environ["PATH"].split(os.pathsep)[:-1]) diff --git a/tests/route_check_test.py b/tests/route_check_test.py index b4fd3ce17d..85e6a64a95 100644 --- a/tests/route_check_test.py +++ b/tests/route_check_test.py @@ -1,331 +1,39 @@ import copy import json import os +import logging import sys import syslog import time from sonic_py_common import device_info from unittest.mock import MagicMock, patch +from tests.route_check_test_data import APPL_DB, ARGS, ASIC_DB, CONFIG_DB, DEFAULT_CONFIG_DB, DESCR, OP_DEL, OP_SET, PRE, RESULT, RET, TEST_DATA, UPD import pytest +logger = logging.getLogger(__name__) + sys.path.append("scripts") import route_check -DESCR = "Description" -ARGS = "args" -RET = "return" -APPL_DB = 0 -ASIC_DB = 1 -PRE = "pre-value" -UPD = "update" -RESULT = "res" - -OP_SET = "SET" -OP_DEL = "DEL" - -ROUTE_TABLE = 'ROUTE_TABLE' -VNET_ROUTE_TABLE = 'VNET_ROUTE_TABLE' -INTF_TABLE = 'INTF_TABLE' -RT_ENTRY_TABLE = 'ASIC_STATE' -SEPARATOR = ":" - -RT_ENTRY_KEY_PREFIX = 'SAI_OBJECT_TYPE_ROUTE_ENTRY:{\"dest":\"' -RT_ENTRY_KEY_SUFFIX = '\",\"switch_id\":\"oid:0x21000000000000\",\"vr\":\"oid:0x3000000000023\"}' - -current_test_name = None -current_test_no = None current_test_data = None tables_returned = {} - selector_returned = None subscribers_returned = {} -test_data = { - "0": { - DESCR: "basic good one", - ARGS: "route_check -m INFO -i 1000", - PRE: { - APPL_DB: { - ROUTE_TABLE: { - "0.0.0.0/0" : { "ifname": "portchannel0" }, - "10.10.196.12/31" : { "ifname": "portchannel0" }, - "10.10.196.20/31" : { "ifname": "portchannel0" }, - "10.10.196.30/31" : { "ifname": "lo" } - }, - INTF_TABLE: { - "PortChannel1013:10.10.196.24/31": {}, - "PortChannel1023:2603:10b0:503:df4::5d/126": {}, - "PortChannel1024": {} - } - }, - ASIC_DB: { - RT_ENTRY_TABLE: { - RT_ENTRY_KEY_PREFIX + "10.10.196.12/31" + RT_ENTRY_KEY_SUFFIX: {}, - RT_ENTRY_KEY_PREFIX + "10.10.196.20/31" + RT_ENTRY_KEY_SUFFIX: {}, - RT_ENTRY_KEY_PREFIX + "10.10.196.24/32" + RT_ENTRY_KEY_SUFFIX: {}, - RT_ENTRY_KEY_PREFIX + "2603:10b0:503:df4::5d/128" + RT_ENTRY_KEY_SUFFIX: {}, - RT_ENTRY_KEY_PREFIX + "0.0.0.0/0" + RT_ENTRY_KEY_SUFFIX: {} - } - } - } - }, - "1": { - DESCR: "With updates", - ARGS: "route_check -m DEBUG -i 1", - PRE: { - APPL_DB: { - ROUTE_TABLE: { - "0.0.0.0/0" : { "ifname": "portchannel0" }, - "10.10.196.12/31" : { "ifname": "portchannel0" }, - "10.10.196.20/31" : { "ifname": "portchannel0" }, - "10.10.196.30/31" : { "ifname": "lo" } - }, - INTF_TABLE: { - "PortChannel1013:10.10.196.24/31": {}, - "PortChannel1023:2603:10b0:503:df4::5d/126": {} - } - }, - ASIC_DB: { - RT_ENTRY_TABLE: { - RT_ENTRY_KEY_PREFIX + "10.10.196.20/31" + RT_ENTRY_KEY_SUFFIX: {}, - RT_ENTRY_KEY_PREFIX + "10.10.196.24/32" + RT_ENTRY_KEY_SUFFIX: {}, - RT_ENTRY_KEY_PREFIX + "2603:10b0:503:df4::5d/128" + RT_ENTRY_KEY_SUFFIX: {}, - RT_ENTRY_KEY_PREFIX + "0.0.0.0/0" + RT_ENTRY_KEY_SUFFIX: {}, - RT_ENTRY_KEY_PREFIX + "10.10.10.10/32" + RT_ENTRY_KEY_SUFFIX: {} - } - } - }, - UPD: { - ASIC_DB: { - RT_ENTRY_TABLE: { - OP_SET: { - RT_ENTRY_KEY_PREFIX + "10.10.196.12/31" + RT_ENTRY_KEY_SUFFIX: {}, - }, - OP_DEL: { - RT_ENTRY_KEY_PREFIX + "10.10.10.10/32" + RT_ENTRY_KEY_SUFFIX: {} - } - } - } - } - }, - "2": { - DESCR: "basic failure one", - ARGS: "route_check -i 15", - RET: -1, - PRE: { - APPL_DB: { - ROUTE_TABLE: { - "0.0.0.0/0" : { "ifname": "portchannel0" }, - "10.10.196.12/31" : { "ifname": "portchannel0" }, - "10.10.196.20/31" : { "ifname": "portchannel0" }, - "10.10.196.30/31" : { "ifname": "lo" } - }, - INTF_TABLE: { - "PortChannel1013:90.10.196.24/31": {}, - "PortChannel1023:9603:10b0:503:df4::5d/126": {}, - "PortChannel1024": {} - } - }, - ASIC_DB: { - RT_ENTRY_TABLE: { - RT_ENTRY_KEY_PREFIX + "20.10.196.12/31" + RT_ENTRY_KEY_SUFFIX: {}, - RT_ENTRY_KEY_PREFIX + "20.10.196.20/31" + RT_ENTRY_KEY_SUFFIX: {}, - RT_ENTRY_KEY_PREFIX + "20.10.196.24/32" + RT_ENTRY_KEY_SUFFIX: {}, - RT_ENTRY_KEY_PREFIX + "3603:10b0:503:df4::5d/128" + RT_ENTRY_KEY_SUFFIX: {}, - RT_ENTRY_KEY_PREFIX + "0.0.0.0/0" + RT_ENTRY_KEY_SUFFIX: {} - } - } - }, - RESULT: { - "missed_ROUTE_TABLE_routes": [ - "10.10.196.12/31", - "10.10.196.20/31" - ], - "missed_INTF_TABLE_entries": [ - "90.10.196.24/32", - "9603:10b0:503:df4::5d/128" - ], - "Unaccounted_ROUTE_ENTRY_TABLE_entries": [ - "20.10.196.12/31", - "20.10.196.20/31", - "20.10.196.24/32", - "3603:10b0:503:df4::5d/128" - ] - } - }, - "3": { - DESCR: "basic good one with no args", - ARGS: "route_check", - PRE: { - APPL_DB: { - ROUTE_TABLE: { - "0.0.0.0/0" : { "ifname": "portchannel0" }, - "10.10.196.12/31" : { "ifname": "portchannel0" }, - "10.10.196.20/31" : { "ifname": "portchannel0" }, - "10.10.196.30/31" : { "ifname": "lo" } - }, - INTF_TABLE: { - "PortChannel1013:10.10.196.24/31": {}, - "PortChannel1023:2603:10b0:503:df4::5d/126": {}, - "PortChannel1024": {} - } - }, - ASIC_DB: { - RT_ENTRY_TABLE: { - RT_ENTRY_KEY_PREFIX + "10.10.196.12/31" + RT_ENTRY_KEY_SUFFIX: {}, - RT_ENTRY_KEY_PREFIX + "10.10.196.20/31" + RT_ENTRY_KEY_SUFFIX: {}, - RT_ENTRY_KEY_PREFIX + "10.10.196.24/32" + RT_ENTRY_KEY_SUFFIX: {}, - RT_ENTRY_KEY_PREFIX + "2603:10b0:503:df4::5d/128" + RT_ENTRY_KEY_SUFFIX: {}, - RT_ENTRY_KEY_PREFIX + "0.0.0.0/0" + RT_ENTRY_KEY_SUFFIX: {} - } - } - } - }, - "4": { - DESCR: "Good one with routes on voq inband interface", - ARGS: "route_check", - PRE: { - APPL_DB: { - ROUTE_TABLE: { - "0.0.0.0/0" : { "ifname": "portchannel0" }, - "10.10.196.12/31" : { "ifname": "portchannel0" }, - "10.10.196.20/31" : { "ifname": "portchannel0" }, - "10.10.196.30/31" : { "ifname": "lo" }, - "10.10.197.1" : { "ifname": "Ethernet-IB0", "nexthop": "0.0.0.0"}, - "2603:10b0:503:df5::1" : { "ifname": "Ethernet-IB0", "nexthop": "::"}, - "100.0.0.2/32" : { "ifname": "Ethernet-IB0", "nexthop": "0.0.0.0" }, - "2064:100::2/128" : { "ifname": "Ethernet-IB0", "nexthop": "::" }, - "101.0.0.0/24" : { "ifname": "Ethernet-IB0", "nexthop": "100.0.0.2"} - }, - INTF_TABLE: { - "PortChannel1013:10.10.196.24/31": {}, - "PortChannel1023:2603:10b0:503:df4::5d/126": {}, - "PortChannel1024": {}, - "Ethernet-IB0:10.10.197.1/24": {}, - "Ethernet-IB0:2603:10b0:503:df5::1/64": {} - } - }, - ASIC_DB: { - RT_ENTRY_TABLE: { - RT_ENTRY_KEY_PREFIX + "10.10.196.12/31" + RT_ENTRY_KEY_SUFFIX: {}, - RT_ENTRY_KEY_PREFIX + "10.10.196.20/31" + RT_ENTRY_KEY_SUFFIX: {}, - RT_ENTRY_KEY_PREFIX + "10.10.196.24/32" + RT_ENTRY_KEY_SUFFIX: {}, - RT_ENTRY_KEY_PREFIX + "2603:10b0:503:df4::5d/128" + RT_ENTRY_KEY_SUFFIX: {}, - RT_ENTRY_KEY_PREFIX + "0.0.0.0/0" + RT_ENTRY_KEY_SUFFIX: {}, - RT_ENTRY_KEY_PREFIX + "10.10.197.1/32" + RT_ENTRY_KEY_SUFFIX: {}, - RT_ENTRY_KEY_PREFIX + "2603:10b0:503:df5::1/128" + RT_ENTRY_KEY_SUFFIX: {}, - RT_ENTRY_KEY_PREFIX + "101.0.0.0/24" + RT_ENTRY_KEY_SUFFIX: {} - } - } - } - }, - "5": { - DESCR: "local route with nexthop - fail", - ARGS: "route_check -m INFO -i 1000", - RET: -1, - PRE: { - APPL_DB: { - ROUTE_TABLE: { - "0.0.0.0/0" : { "ifname": "portchannel0" }, - "10.10.196.12/31" : { "ifname": "portchannel0" }, - "10.10.196.20/31" : { "ifname": "portchannel0" }, - "10.10.196.30/31" : { "ifname": "lo", "nexthop": "100.0.0.2" } - }, - INTF_TABLE: { - "PortChannel1013:10.10.196.24/31": {}, - "PortChannel1023:2603:10b0:503:df4::5d/126": {}, - "PortChannel1024": {} - } - }, - ASIC_DB: { - RT_ENTRY_TABLE: { - RT_ENTRY_KEY_PREFIX + "10.10.196.12/31" + RT_ENTRY_KEY_SUFFIX: {}, - RT_ENTRY_KEY_PREFIX + "10.10.196.20/31" + RT_ENTRY_KEY_SUFFIX: {}, - RT_ENTRY_KEY_PREFIX + "10.10.196.24/32" + RT_ENTRY_KEY_SUFFIX: {}, - RT_ENTRY_KEY_PREFIX + "2603:10b0:503:df4::5d/128" + RT_ENTRY_KEY_SUFFIX: {}, - RT_ENTRY_KEY_PREFIX + "0.0.0.0/0" + RT_ENTRY_KEY_SUFFIX: {} - } - } - }, - RESULT: { - "missed_ROUTE_TABLE_routes": [ - "10.10.196.30/31" - ] - } - }, - "6": { - DESCR: "Good one with VNET routes", - ARGS: "route_check", - PRE: { - APPL_DB: { - ROUTE_TABLE: { - "0.0.0.0/0" : { "ifname": "portchannel0" }, - "10.10.196.12/31" : { "ifname": "portchannel0" }, - "10.10.196.20/31" : { "ifname": "portchannel0" }, - "10.10.196.30/31" : { "ifname": "lo" } - }, - VNET_ROUTE_TABLE: { - "Vnet1:30.1.10.0/24": { "ifname": "Vlan3001" }, - "Vnet1:50.1.1.0/24": { "ifname": "Vlan3001" }, - "Vnet1:50.2.2.0/24": { "ifname": "Vlan3001" } - }, - INTF_TABLE: { - "PortChannel1013:10.10.196.24/31": {}, - "PortChannel1023:2603:10b0:503:df4::5d/126": {}, - "PortChannel1024": {}, - "Vlan3001": { "vnet_name": "Vnet1" }, - "Vlan3001:30.1.10.1/24": {} - } - }, - ASIC_DB: { - RT_ENTRY_TABLE: { - RT_ENTRY_KEY_PREFIX + "10.10.196.12/31" + RT_ENTRY_KEY_SUFFIX: {}, - RT_ENTRY_KEY_PREFIX + "10.10.196.20/31" + RT_ENTRY_KEY_SUFFIX: {}, - RT_ENTRY_KEY_PREFIX + "10.10.196.24/32" + RT_ENTRY_KEY_SUFFIX: {}, - RT_ENTRY_KEY_PREFIX + "2603:10b0:503:df4::5d/128" + RT_ENTRY_KEY_SUFFIX: {}, - RT_ENTRY_KEY_PREFIX + "0.0.0.0/0" + RT_ENTRY_KEY_SUFFIX: {}, - RT_ENTRY_KEY_PREFIX + "30.1.10.1/32" + RT_ENTRY_KEY_SUFFIX: {}, - RT_ENTRY_KEY_PREFIX + "30.1.10.0/24" + RT_ENTRY_KEY_SUFFIX: {}, - RT_ENTRY_KEY_PREFIX + "50.1.1.0/24" + RT_ENTRY_KEY_SUFFIX: {}, - RT_ENTRY_KEY_PREFIX + "50.2.2.0/24" + RT_ENTRY_KEY_SUFFIX: {} - } - } - } - } -} - -def do_start_test(tname, tno, ctdata): - global current_test_name, current_test_no, current_test_data - global tables_returned, selector_returned, subscribers_returned - - current_test_name = tname - current_test_no = tno +def set_test_case_data(ctdata): + """ + Setup global variables for each test case + """ + global current_test_data, tables_returned, selector_returned, subscribers_returned + current_test_data = ctdata tables_returned = {} selector_returned = None subscribers_returned = {} - print("Starting test case {} number={}".format(tname, tno)) - - -def check_subset(d_sub, d_all): - if type(d_sub) != type(d_all): - return -1 - if not type(d_sub) is dict: - ret = 0 if d_sub == d_all else -2 - return ret - - for (k, v) in d_sub.items(): - if not k in d_all: - return -3 - ret = check_subset(v, d_all[k]) - if ret != 0: - return ret - return 0 - def recursive_update(d, t): assert (type(t) is dict) @@ -376,6 +84,11 @@ def get(self, key): return (True, ret) + def hget(self, key, field): + ret = copy.deepcopy(self.data.get(key, {}).get(field, {})) + return True, ret + + db_conns = {"APPL_DB": APPL_DB, "ASIC_DB": ASIC_DB} def conn_side_effect(arg, _): return db_conns[arg] @@ -503,12 +216,22 @@ def table_side_effect(db, tbl): return tables_returned[db][tbl] -def set_mock(mock_table, mock_conn, mock_sel, mock_subs): +def config_db_side_effect(table): + if CONFIG_DB not in current_test_data[PRE]: + return DEFAULT_CONFIG_DB[table] + if not CONFIG_DB in tables_returned: + tables_returned[CONFIG_DB] = {} + if not table in tables_returned[CONFIG_DB]: + tables_returned[CONFIG_DB][table] = current_test_data[PRE][CONFIG_DB].get(table, {}) + return tables_returned[CONFIG_DB][table] + + +def set_mock(mock_table, mock_conn, mock_sel, mock_subs, mock_config_db): mock_conn.side_effect = conn_side_effect mock_table.side_effect = table_side_effect mock_sel.side_effect = select_side_effect mock_subs.side_effect = subscriber_side_effect - + mock_config_db.get_table = MagicMock(side_effect=config_db_side_effect) class TestRouteCheck(object): def setup(self): @@ -517,39 +240,58 @@ def setup(self): def init(self): route_check.UNIT_TESTING = 1 + @pytest.fixture + def force_hang(self): + old_timeout = route_check.TIMEOUT_SECONDS + route_check.TIMEOUT_SECONDS = 5 + mock_selector.EMULATE_HANG = True - @patch("route_check.swsscommon.DBConnector") - @patch("route_check.swsscommon.Table") - @patch("route_check.swsscommon.Select") - @patch("route_check.swsscommon.SubscriberStateTable") - def test_server(self, mock_subs, mock_sel, mock_table, mock_conn): + yield + + route_check.TIMEOUT_SECONDS = old_timeout + mock_selector.EMULATE_HANG = False + + @pytest.fixture + def mock_dbs(self): + mock_config_db = MagicMock() + with patch("route_check.swsscommon.DBConnector") as mock_conn, \ + patch("route_check.swsscommon.Table") as mock_table, \ + patch("route_check.swsscommon.Select") as mock_sel, \ + patch("route_check.swsscommon.SubscriberStateTable") as mock_subs, \ + patch("route_check.swsscommon.ConfigDBConnector", return_value=mock_config_db): + device_info.get_platform = MagicMock(return_value='unittest') + set_mock(mock_table, mock_conn, mock_sel, mock_subs, mock_config_db) + yield + + @pytest.mark.parametrize("test_num", TEST_DATA.keys()) + def test_route_check(self, mock_dbs, test_num): self.init() ret = 0 - device_info.get_platform = MagicMock(return_value='unittest') - set_mock(mock_table, mock_conn, mock_sel, mock_subs) - for (i, ct_data) in test_data.items(): - do_start_test("route_test", i, ct_data) - - with patch('sys.argv', ct_data[ARGS].split()): - ret, res = route_check.main() - expect_ret = ct_data[RET] if RET in ct_data else 0 - expect_res = ct_data[RESULT] if RESULT in ct_data else None - if res: - print("res={}".format(json.dumps(res, indent=4))) - if expect_res: - print("expect_res={}".format(json.dumps(expect_res, indent=4))) - assert ret == expect_ret - assert res == expect_res - + ct_data = TEST_DATA[test_num] + set_test_case_data(ct_data) + logger.info("Running test case {}: {}".format(test_num, ct_data[DESCR])) + with patch('sys.argv', ct_data[ARGS].split()): + ret, res = route_check.main() + expect_ret = ct_data[RET] if RET in ct_data else 0 + expect_res = ct_data[RESULT] if RESULT in ct_data else None + if res: + print("res={}".format(json.dumps(res, indent=4))) + if expect_res: + print("expect_res={}".format(json.dumps(expect_res, indent=4))) + assert ret == expect_ret + assert res == expect_res + + def test_timeout(self, mock_dbs, force_hang): # Test timeout - route_check.TIMEOUT_SECONDS = 5 - mock_selector.EMULATE_HANG = True ex_raised = False + # Use an expected failing test case to trigger the select + set_test_case_data(TEST_DATA['2']) try: - ret, res = route_check.main() + with patch('sys.argv', [route_check.__file__.split('/')[-1]]): + ret, res = route_check.main() except Exception as err: ex_raised = True expect = "timeout occurred" @@ -557,6 +299,7 @@ def test_server(self, mock_subs, mock_sel, mock_table, mock_conn): assert ex_str == expect, "{} != {}".format(ex_str, expect) assert ex_raised, "Exception expected" + def test_logging(self): # Test print_msg route_check.PRINT_MSG_LEN_MAX = 5 msg = route_check.print_message(syslog.LOG_ERR, "abcdefghi") @@ -567,10 +310,3 @@ def test_server(self, mock_subs, mock_sel, mock_table, mock_conn): assert len(msg) == 5 msg = route_check.print_message(syslog.LOG_ERR, "a", "b", "c", "d", "e", "f") assert len(msg) == 5 - - - - - - - diff --git a/tests/route_check_test_data.py b/tests/route_check_test_data.py new file mode 100644 index 0000000000..036a0a9b57 --- /dev/null +++ b/tests/route_check_test_data.py @@ -0,0 +1,336 @@ +DESCR = "Description" +ARGS = "args" +RET = "return" +APPL_DB = 0 +ASIC_DB = 1 +CONFIG_DB = 4 +PRE = "pre-value" +UPD = "update" +RESULT = "res" + +OP_SET = "SET" +OP_DEL = "DEL" + +NEIGH_TABLE = 'NEIGH_TABLE' +ROUTE_TABLE = 'ROUTE_TABLE' +VNET_ROUTE_TABLE = 'VNET_ROUTE_TABLE' +INTF_TABLE = 'INTF_TABLE' +RT_ENTRY_TABLE = 'ASIC_STATE' +SEPARATOR = ":" +DEVICE_METADATA = "DEVICE_METADATA" +MUX_CABLE = "MUX_CABLE" + +LOCALHOST = "localhost" + +RT_ENTRY_KEY_PREFIX = 'SAI_OBJECT_TYPE_ROUTE_ENTRY:{\"dest":\"' +RT_ENTRY_KEY_SUFFIX = '\",\"switch_id\":\"oid:0x21000000000000\",\"vr\":\"oid:0x3000000000023\"}' + +DEFAULT_CONFIG_DB = {DEVICE_METADATA: {LOCALHOST: {}}} + +TEST_DATA = { + "0": { + DESCR: "basic good one", + ARGS: "route_check -m INFO -i 1000", + PRE: { + APPL_DB: { + ROUTE_TABLE: { + "0.0.0.0/0" : { "ifname": "portchannel0" }, + "10.10.196.12/31" : { "ifname": "portchannel0" }, + "10.10.196.20/31" : { "ifname": "portchannel0" }, + "10.10.196.30/31" : { "ifname": "lo" } + }, + INTF_TABLE: { + "PortChannel1013:10.10.196.24/31": {}, + "PortChannel1023:2603:10b0:503:df4::5d/126": {}, + "PortChannel1024": {} + } + }, + ASIC_DB: { + RT_ENTRY_TABLE: { + RT_ENTRY_KEY_PREFIX + "10.10.196.12/31" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "10.10.196.20/31" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "10.10.196.24/32" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "2603:10b0:503:df4::5d/128" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "0.0.0.0/0" + RT_ENTRY_KEY_SUFFIX: {} + } + } + } + }, + "1": { + DESCR: "With updates", + ARGS: "route_check -m DEBUG -i 1", + PRE: { + APPL_DB: { + ROUTE_TABLE: { + "0.0.0.0/0" : { "ifname": "portchannel0" }, + "10.10.196.12/31" : { "ifname": "portchannel0" }, + "10.10.196.20/31" : { "ifname": "portchannel0" }, + "10.10.196.30/31" : { "ifname": "lo" } + }, + INTF_TABLE: { + "PortChannel1013:10.10.196.24/31": {}, + "PortChannel1023:2603:10b0:503:df4::5d/126": {} + } + }, + ASIC_DB: { + RT_ENTRY_TABLE: { + RT_ENTRY_KEY_PREFIX + "10.10.196.20/31" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "10.10.196.24/32" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "2603:10b0:503:df4::5d/128" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "0.0.0.0/0" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "10.10.10.10/32" + RT_ENTRY_KEY_SUFFIX: {} + } + } + }, + UPD: { + ASIC_DB: { + RT_ENTRY_TABLE: { + OP_SET: { + RT_ENTRY_KEY_PREFIX + "10.10.196.12/31" + RT_ENTRY_KEY_SUFFIX: {}, + }, + OP_DEL: { + RT_ENTRY_KEY_PREFIX + "10.10.10.10/32" + RT_ENTRY_KEY_SUFFIX: {} + } + } + } + } + }, + "2": { + DESCR: "basic failure one", + ARGS: "route_check -i 15", + RET: -1, + PRE: { + APPL_DB: { + ROUTE_TABLE: { + "0.0.0.0/0" : { "ifname": "portchannel0" }, + "10.10.196.12/31" : { "ifname": "portchannel0" }, + "10.10.196.20/31" : { "ifname": "portchannel0" }, + "10.10.196.30/31" : { "ifname": "lo" } + }, + INTF_TABLE: { + "PortChannel1013:90.10.196.24/31": {}, + "PortChannel1023:9603:10b0:503:df4::5d/126": {}, + "PortChannel1024": {} + } + }, + ASIC_DB: { + RT_ENTRY_TABLE: { + RT_ENTRY_KEY_PREFIX + "20.10.196.12/31" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "20.10.196.20/31" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "20.10.196.24/32" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "3603:10b0:503:df4::5d/128" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "0.0.0.0/0" + RT_ENTRY_KEY_SUFFIX: {} + } + } + }, + RESULT: { + "missed_ROUTE_TABLE_routes": [ + "10.10.196.12/31", + "10.10.196.20/31" + ], + "missed_INTF_TABLE_entries": [ + "90.10.196.24/32", + "9603:10b0:503:df4::5d/128" + ], + "Unaccounted_ROUTE_ENTRY_TABLE_entries": [ + "20.10.196.12/31", + "20.10.196.20/31", + "20.10.196.24/32", + "3603:10b0:503:df4::5d/128" + ] + } + }, + "3": { + DESCR: "basic good one with no args", + ARGS: "route_check", + PRE: { + APPL_DB: { + ROUTE_TABLE: { + "0.0.0.0/0" : { "ifname": "portchannel0" }, + "10.10.196.12/31" : { "ifname": "portchannel0" }, + "10.10.196.20/31" : { "ifname": "portchannel0" }, + "10.10.196.30/31" : { "ifname": "lo" } + }, + INTF_TABLE: { + "PortChannel1013:10.10.196.24/31": {}, + "PortChannel1023:2603:10b0:503:df4::5d/126": {}, + "PortChannel1024": {} + } + }, + ASIC_DB: { + RT_ENTRY_TABLE: { + RT_ENTRY_KEY_PREFIX + "10.10.196.12/31" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "10.10.196.20/31" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "10.10.196.24/32" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "2603:10b0:503:df4::5d/128" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "0.0.0.0/0" + RT_ENTRY_KEY_SUFFIX: {} + } + } + } + }, + "4": { + DESCR: "Good one with routes on voq inband interface", + ARGS: "route_check", + PRE: { + APPL_DB: { + ROUTE_TABLE: { + "0.0.0.0/0" : { "ifname": "portchannel0" }, + "10.10.196.12/31" : { "ifname": "portchannel0" }, + "10.10.196.20/31" : { "ifname": "portchannel0" }, + "10.10.196.30/31" : { "ifname": "lo" }, + "10.10.197.1" : { "ifname": "Ethernet-IB0", "nexthop": "0.0.0.0"}, + "2603:10b0:503:df5::1" : { "ifname": "Ethernet-IB0", "nexthop": "::"}, + "100.0.0.2/32" : { "ifname": "Ethernet-IB0", "nexthop": "0.0.0.0" }, + "2064:100::2/128" : { "ifname": "Ethernet-IB0", "nexthop": "::" }, + "101.0.0.0/24" : { "ifname": "Ethernet-IB0", "nexthop": "100.0.0.2"} + }, + INTF_TABLE: { + "PortChannel1013:10.10.196.24/31": {}, + "PortChannel1023:2603:10b0:503:df4::5d/126": {}, + "PortChannel1024": {}, + "Ethernet-IB0:10.10.197.1/24": {}, + "Ethernet-IB0:2603:10b0:503:df5::1/64": {} + } + }, + ASIC_DB: { + RT_ENTRY_TABLE: { + RT_ENTRY_KEY_PREFIX + "10.10.196.12/31" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "10.10.196.20/31" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "10.10.196.24/32" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "2603:10b0:503:df4::5d/128" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "0.0.0.0/0" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "10.10.197.1/32" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "2603:10b0:503:df5::1/128" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "101.0.0.0/24" + RT_ENTRY_KEY_SUFFIX: {} + } + } + } + }, + "5": { + DESCR: "local route with nexthop - fail", + ARGS: "route_check -m INFO -i 1000", + RET: -1, + PRE: { + APPL_DB: { + ROUTE_TABLE: { + "0.0.0.0/0" : { "ifname": "portchannel0" }, + "10.10.196.12/31" : { "ifname": "portchannel0" }, + "10.10.196.20/31" : { "ifname": "portchannel0" }, + "10.10.196.30/31" : { "ifname": "lo", "nexthop": "100.0.0.2" } + }, + INTF_TABLE: { + "PortChannel1013:10.10.196.24/31": {}, + "PortChannel1023:2603:10b0:503:df4::5d/126": {}, + "PortChannel1024": {} + } + }, + ASIC_DB: { + RT_ENTRY_TABLE: { + RT_ENTRY_KEY_PREFIX + "10.10.196.12/31" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "10.10.196.20/31" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "10.10.196.24/32" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "2603:10b0:503:df4::5d/128" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "0.0.0.0/0" + RT_ENTRY_KEY_SUFFIX: {} + } + } + }, + RESULT: { + "missed_ROUTE_TABLE_routes": [ + "10.10.196.30/31" + ] + } + }, + "6": { + DESCR: "Good one with VNET routes", + ARGS: "route_check", + PRE: { + APPL_DB: { + ROUTE_TABLE: { + "0.0.0.0/0" : { "ifname": "portchannel0" }, + "10.10.196.12/31" : { "ifname": "portchannel0" }, + "10.10.196.20/31" : { "ifname": "portchannel0" }, + "10.10.196.30/31" : { "ifname": "lo" } + }, + VNET_ROUTE_TABLE: { + "Vnet1:30.1.10.0/24": { "ifname": "Vlan3001" }, + "Vnet1:50.1.1.0/24": { "ifname": "Vlan3001" }, + "Vnet1:50.2.2.0/24": { "ifname": "Vlan3001" } + }, + INTF_TABLE: { + "PortChannel1013:10.10.196.24/31": {}, + "PortChannel1023:2603:10b0:503:df4::5d/126": {}, + "PortChannel1024": {}, + "Vlan3001": { "vnet_name": "Vnet1" }, + "Vlan3001:30.1.10.1/24": {} + } + }, + ASIC_DB: { + RT_ENTRY_TABLE: { + RT_ENTRY_KEY_PREFIX + "10.10.196.12/31" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "10.10.196.20/31" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "10.10.196.24/32" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "2603:10b0:503:df4::5d/128" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "0.0.0.0/0" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "30.1.10.1/32" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "30.1.10.0/24" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "50.1.1.0/24" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "50.2.2.0/24" + RT_ENTRY_KEY_SUFFIX: {} + } + } + } + }, + "7": { + DESCR: "dualtor standalone tunnel route case", + ARGS: "route_check", + PRE: { + CONFIG_DB: { + DEVICE_METADATA: { + LOCALHOST: {"subtype": "DualToR"} + } + }, + APPL_DB: { + NEIGH_TABLE: { + "Vlan1000:fc02:1000::99": { "neigh": "00:00:00:00:00:00", "family": "IPv6"} + } + }, + ASIC_DB: { + RT_ENTRY_TABLE: { + RT_ENTRY_KEY_PREFIX + "fc02:1000::99/128" + RT_ENTRY_KEY_SUFFIX: {}, + } + } + } + }, + "8": { + DESCR: "SOC IPs on Libra ToRs should be ignored", + ARGS: "route_check", + PRE: { + CONFIG_DB: { + DEVICE_METADATA: { + LOCALHOST: {"subtype": "DualToR"} + }, + MUX_CABLE: { + "Ethernet4": { + "cable_type": "active-active", + "server_ipv4": "192.168.0.2/32", + "server_ipv6": "fc02:1000::2/128", + "soc_ipv4": "192.168.0.3/32", + "state": "auto" + }, + } + }, + APPL_DB: { + ROUTE_TABLE: { + "192.168.0.2/32": {"ifname": "tun0"}, + "fc02:1000::2/128": {"ifname": "tun0"} + } + }, + ASIC_DB: { + RT_ENTRY_TABLE: { + RT_ENTRY_KEY_PREFIX + "192.168.0.2/32" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "fc02:1000::2/128" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "192.168.0.3/32" + RT_ENTRY_KEY_SUFFIX: {} + } + } + } + } +} diff --git a/tests/sfp_test.py b/tests/sfp_test.py index 3cbd9ecda8..6d5d9fa7af 100644 --- a/tests/sfp_test.py +++ b/tests/sfp_test.py @@ -66,7 +66,6 @@ Application Advertisement: 400GAUI-8 C2M (Annex 120E) - Active Cable assembly with BER < 2.6x10^-4 IB EDR (Arch.Spec.Vol.2) - Active Cable assembly with BER < 5x10^-5 IB QDR (Arch.Spec.Vol.2) - Active Cable assembly with BER < 10^-12 - Connector: No separable connector Encoding: Not supported for CMIS cables Extended Identifier: Power Class 1(10.0W Max) @@ -75,13 +74,13 @@ Length Cable Assembly(m): 10 Nominal Bit Rate(100Mbs): Not supported for CMIS cables Specification compliance: Not supported for CMIS cables - Vendor Date Code(YYYY-MM-DD Lot): 2020-05-22 + Vendor Date Code(YYYY-MM-DD Lot): 2020-05-22 Vendor Name: INNOLIGHT Vendor OUI: 44-7c-7f Vendor PN: C-DQ8FNM010-N00 Vendor Rev: 2A Vendor SN: INKAO2900002A - ChannelMonitorValues: + ChannelMonitorValues: RX1Power: -3.8595dBm RX2Power: 8.1478dBm RX3Power: -22.9243dBm @@ -98,15 +97,15 @@ TX3Power: 1.175dBm TX4Bias: 0.0000mA TX4Power: 1.175dBm - TX5Bias: 0.0000mAmA + TX5Bias: 0.0000mA TX5Power: 1.175dBm - TX6Bias: 8.2240mAmA + TX6Bias: 8.2240mA TX6Power: 1.175dBm - TX7Bias: 8.2240mAmA + TX7Bias: 8.2240mA TX7Power: 1.175dBm - TX8Bias: 8.2240mAmA + TX8Bias: 8.2240mA TX8Power: 1.175dBm - ChannelThresholdValues: + ChannelThresholdValues: RxPowerHighAlarm : 6.9999dBm RxPowerHighWarning: 4.9999dBm RxPowerLowAlarm : -11.9044dBm @@ -119,10 +118,10 @@ TxPowerHighWarning: 4.9999dBm TxPowerLowAlarm : -10.5012dBm TxPowerLowWarning : -7.5007dBm - ModuleMonitorValues: + ModuleMonitorValues: Temperature: 44.9883C Vcc: 3.2999Volts - ModuleThresholdValues: + ModuleThresholdValues: TempHighAlarm : 80.0000C TempHighWarning: 75.0000C TempLowAlarm : -10.0000C @@ -158,7 +157,6 @@ Application Advertisement: 400GAUI-8 C2M (Annex 120E) - Active Cable assembly with BER < 2.6x10^-4 IB EDR (Arch.Spec.Vol.2) - Active Cable assembly with BER < 5x10^-5 IB QDR (Arch.Spec.Vol.2) - Active Cable assembly with BER < 10^-12 - Connector: No separable connector Encoding: Not supported for CMIS cables Extended Identifier: Power Class 1(10.0W Max) @@ -167,7 +165,27 @@ Length Cable Assembly(m): 10 Nominal Bit Rate(100Mbs): Not supported for CMIS cables Specification compliance: Not supported for CMIS cables - Vendor Date Code(YYYY-MM-DD Lot): 2020-05-22 + Vendor Date Code(YYYY-MM-DD Lot): 2020-05-22 + Vendor Name: INNOLIGHT + Vendor OUI: 44-7c-7f + Vendor PN: C-DQ8FNM010-N00 + Vendor Rev: 2A + Vendor SN: INKAO2900002A +""" + +test_qsfp_dd_eeprom_adv_app_output = """\ +Ethernet40: SFP EEPROM detected + Application Advertisement: 400G CR8 - Host Assign (0x1) - Copper cable - Media Assign (0x2) + 200GBASE-CR4 (Clause 136) - Host Assign (Unknown) - Unknown - Media Assign (Unknown) + Connector: No separable connector + Encoding: Not supported for CMIS cables + Extended Identifier: Power Class 1(10.0W Max) + Extended RateSelect Compliance: Not supported for CMIS cables + Identifier: QSFP-DD Double Density 8X Pluggable Transceiver + Length Cable Assembly(m): 10 + Nominal Bit Rate(100Mbs): Not supported for CMIS cables + Specification compliance: Not supported for CMIS cables + Vendor Date Code(YYYY-MM-DD Lot): 2020-05-22 Vendor Name: INNOLIGHT Vendor OUI: 44-7c-7f Vendor PN: C-DQ8FNM010-N00 @@ -344,6 +362,38 @@ def test_sfp_presence(self): expected = """Port Presence ----------- ----------- Ethernet200 Not present +""" + assert result.exit_code == 0 + assert result.output == expected + + result = runner.invoke(show.cli.commands["interfaces"].commands["transceiver"].commands["presence"], ["Ethernet16"]) + expected = """Port Presence +---------- ---------- +Ethernet16 Present +""" + assert result.exit_code == 0 + assert result.output == expected + + result = runner.invoke(show.cli.commands["interfaces"].commands["transceiver"].commands["presence"], ["Ethernet28"]) + expected = """Port Presence +---------- ---------- +Ethernet28 Present +""" + assert result.exit_code == 0 + assert result.output == expected + + result = runner.invoke(show.cli.commands["interfaces"].commands["transceiver"].commands["presence"], ["Ethernet29"]) + expected = """Port Presence +---------- ----------- +Ethernet29 Not present +""" + assert result.exit_code == 0 + assert result.output == expected + + result = runner.invoke(show.cli.commands["interfaces"].commands["transceiver"].commands["presence"], ["Ethernet36"]) + expected = """Port Presence +---------- ---------- +Ethernet36 Present """ assert result.exit_code == 0 assert result.output == expected @@ -358,7 +408,7 @@ def test_qsfp_dd_eeprom_with_dom(self): runner = CliRunner() result = runner.invoke(show.cli.commands["interfaces"].commands["transceiver"].commands["eeprom"], ["Ethernet8 -d"]) assert result.exit_code == 0 - assert "result.output == test_qsfp_dd_eeprom_with_dom_output" + assert result.output == test_qsfp_dd_eeprom_with_dom_output def test_sfp_eeprom(self): runner = CliRunner() @@ -375,7 +425,21 @@ def test_qsfp_dd_eeprom(self): runner = CliRunner() result = runner.invoke(show.cli.commands["interfaces"].commands["transceiver"].commands["eeprom"], ["Ethernet8"]) assert result.exit_code == 0 - assert "result.output == test_qsfp_dd_eeprom_output" + assert result.output == test_qsfp_dd_eeprom_output + + def test_qsfp_dd_eeprom_adv_app(self): + runner = CliRunner() + result = runner.invoke(show.cli.commands["interfaces"].commands["transceiver"].commands["eeprom"], ["Ethernet40"]) + assert result.exit_code == 0 + print(result.output) + assert result.output == test_qsfp_dd_eeprom_adv_app_output + + def test_rj45_eeprom(self): + runner = CliRunner() + result = runner.invoke(show.cli.commands["interfaces"].commands["transceiver"].commands["eeprom"], ["Ethernet36"]) + result_lines = result.output.strip('\n') + expected = "Ethernet36: SFP EEPROM is not applicable for RJ45 port" + assert result_lines == expected @classmethod def teardown_class(cls): @@ -456,6 +520,13 @@ def test_sfp_eeprom_dom_all(self): assert result.exit_code == 0 assert "\n".join([ l.rstrip() for l in result.output.split('\n')]) == test_sfp_eeprom_dom_all_output + def test_is_rj45_port(self): + import utilities_common.platform_sfputil_helper as platform_sfputil_helper + platform_sfputil_helper.platform_chassis = None + if 'sonic_platform' in sys.modules: + sys.modules.pop('sonic_platform') + assert platform_sfputil_helper.is_rj45_port("Ethernet0") == False + @classmethod def teardown_class(cls): print("TEARDOWN") diff --git a/tests/sfputil_test.py b/tests/sfputil_test.py index 83d2f8c4cc..89faa55a7c 100644 --- a/tests/sfputil_test.py +++ b/tests/sfputil_test.py @@ -16,6 +16,9 @@ sys.modules['sonic_platform'] = mock.MagicMock() import sfputil.main as sfputil +EXIT_FAIL = -1 +ERROR_NOT_IMPLEMENTED = 5 +ERROR_INVALID_PORT = 6 class TestSfputil(object): def test_format_dict_value_to_string(self): @@ -77,6 +80,7 @@ def test_format_dict_value_to_string(self): sfputil.QSFP_DOM_CHANNEL_MONITOR_MAP, sfputil.DOM_VALUE_UNIT_MAP) assert output == expected_output + @pytest.mark.parametrize("sfp_info_dict, expected_output",[ # Non-CMIS module ( @@ -137,7 +141,13 @@ def test_format_dict_value_to_string(self): 'ext_rateselect_compliance': 'N/A', 'cable_type': 'Length Cable Assembly(m)', 'cable_length': '0', - 'application_advertisement': 'N/A', + 'application_advertisement': "{1: {'host_electrical_interface_id': '400G CR8', \ + 'module_media_interface_id': 'Copper cable', \ + 'media_lane_count': 8, \ + 'host_lane_count': 8, \ + 'host_lane_assignment_options': 1, \ + 'media_lane_assignment_options': 2}, \ + 2: {'host_electrical_interface_id': '200GBASE-CR4 (Clause 136)'}}", 'specification_compliance': "sm_media_interface", 'dom_capability': "{'Tx_power_support': 'no', 'Rx_power_support': 'no', 'Voltage_support': 'no', 'Temp_support': 'no'}", 'nominal_bit_rate': '0', @@ -175,6 +185,8 @@ def test_format_dict_value_to_string(self): " Active App Selection Host Lane 7: 1\n" " Active App Selection Host Lane 8: 1\n" " Active Firmware Version: 0.1\n" + " Application Advertisement: 400G CR8 - Host Assign (0x1) - Copper cable - Media Assign (0x2)\n" + " 200GBASE-CR4 (Clause 136) - Host Assign (Unknown) - Unknown - Media Assign (Unknown)\n" " CMIS Revision: 5.0\n" " Connector: LC\n" " Encoding: N/A\n" @@ -266,12 +278,17 @@ def test_version(self): result = runner.invoke(sfputil.cli.commands['version'], []) assert result.output.rstrip() == 'sfputil version {}'.format(sfputil.VERSION) + @patch('sfputil.main.is_port_type_rj45', MagicMock(return_value=False)) def test_error_status_from_db(self): db = Db() expected_output = [['Ethernet0', 'Blocking Error|High temperature'], ['Ethernet4', 'OK'], ['Ethernet8', 'Unplugged'], - ['Ethernet12', 'Unknown state: 255']] + ['Ethernet12', 'Unknown state: 255'], + ['Ethernet16', 'Unplugged'], + ['Ethernet28', 'Unplugged'], + ['Ethernet36', 'Unknown'], + ['Ethernet40', 'Unplugged']] output = sfputil.fetch_error_status_from_state_db(None, db.db) assert output == expected_output @@ -279,6 +296,40 @@ def test_error_status_from_db(self): output = sfputil.fetch_error_status_from_state_db('Ethernet0', db.db) assert output == expected_output_ethernet0 + @patch('sfputil.main.is_port_type_rj45', MagicMock(return_value=True)) + def test_error_status_from_db_RJ45(self): + db = Db() + expected_output = [['Ethernet0', 'N/A'], + ['Ethernet4', 'N/A'], + ['Ethernet8', 'N/A'], + ['Ethernet12', 'N/A'], + ['Ethernet16', 'N/A'], + ['Ethernet28', 'N/A'], + ['Ethernet36', 'N/A'], + ['Ethernet40', 'N/A']] + output = sfputil.fetch_error_status_from_state_db(None, db.db) + assert output == expected_output + + expected_output_ethernet0 = expected_output[:1] + output = sfputil.fetch_error_status_from_state_db('Ethernet0', db.db) + assert output == expected_output_ethernet0 + + @patch('sfputil.main.logical_port_name_to_physical_port_list', MagicMock(return_value=[1])) + @patch('sfputil.main.logical_port_to_physical_port_index', MagicMock(return_value=1)) + @patch('sfputil.main.is_port_type_rj45', MagicMock(return_value=False)) + @patch('subprocess.check_output', MagicMock(return_value="['0:OK']")) + def test_fetch_error_status_from_platform_api(self): + output = sfputil.fetch_error_status_from_platform_api('Ethernet0') + assert output == [['Ethernet0', None]] + + @patch('sfputil.main.logical_port_name_to_physical_port_list', MagicMock(return_value=[1])) + @patch('sfputil.main.logical_port_to_physical_port_index', MagicMock(return_value=1)) + @patch('subprocess.check_output', MagicMock(return_value="['0:OK']")) + @patch('sfputil.main.is_port_type_rj45', MagicMock(return_value=True)) + def test_fetch_error_status_from_platform_api_RJ45(self): + output = sfputil.fetch_error_status_from_platform_api('Ethernet0') + assert output == [['Ethernet0', 'N/A']] + @patch('sfputil.main.platform_chassis') @patch('sfputil.main.logical_port_to_physical_port_index', MagicMock(return_value=1)) def test_show_firmware_version(self, mock_chassis): @@ -292,6 +343,330 @@ def test_show_firmware_version(self, mock_chassis): result = runner.invoke(sfputil.cli.commands['show'].commands['fwversion'], ["Ethernet0"]) assert result.exit_code == 0 + @patch('sfputil.main.platform_chassis') + @patch('sfputil.main.logical_port_to_physical_port_index', MagicMock(return_value=1)) + @patch('sfputil.main.logical_port_name_to_physical_port_list', MagicMock(return_value=[1])) + @patch('sfputil.main.platform_sfputil', MagicMock(is_logical_port=MagicMock(return_value=1))) + def test_show_presence(self, mock_chassis): + mock_sfp = MagicMock() + mock_api = MagicMock() + mock_sfp.get_xcvr_api = MagicMock(return_value=mock_api) + mock_sfp.get_presence.return_value = True + runner = CliRunner() + result = runner.invoke(sfputil.cli.commands['show'].commands['presence'], ["-p", "Ethernet16"]) + assert result.exit_code == 0 + expected_output = """Port Presence +---------- ---------- +Ethernet16 Present +""" + assert result.output == expected_output + + result = runner.invoke(sfputil.cli.commands['show'].commands['presence'], ["-p", "Ethernet28"]) + assert result.exit_code == 0 + expected_output = """Port Presence +---------- ---------- +Ethernet28 Present +""" + assert result.output == expected_output + + result = runner.invoke(sfputil.cli.commands['show'].commands['presence'], ["-p", "Ethernet36"]) + assert result.exit_code == 0 + expected_output = """Port Presence +---------- ---------- +Ethernet36 Present +""" + assert result.output == expected_output + + @patch('sfputil.main.is_port_type_rj45', MagicMock(return_value=False)) + @patch('sfputil.main.platform_sfputil', MagicMock(is_logical_port=MagicMock(return_value=1))) + def test_show_error_status(self): + runner = CliRunner() + result = runner.invoke(sfputil.cli.commands['show'].commands['error-status'], []) + assert result.exit_code == 0 + expected_output = """Port Error Status +---------- ------------------------------- +Ethernet0 Blocking Error|High temperature +Ethernet4 OK +Ethernet8 Unplugged +Ethernet12 Unknown state: 255 +Ethernet16 Unplugged +Ethernet28 Unplugged +Ethernet36 Unknown +Ethernet40 Unplugged +""" + assert result.output == expected_output + + @patch('sfputil.main.SonicV2Connector', MagicMock(return_value=None)) + def test_show_error_status_error_case(self): + runner = CliRunner() + result = runner.invoke(sfputil.cli.commands['show'].commands['error-status'], []) + assert result.exit_code == 0 + expected_output = """Failed to connect to STATE_DB\n""" + assert result.output == expected_output + + + @patch('sfputil.main.platform_chassis') + @patch('sfputil.main.logical_port_name_to_physical_port_list', MagicMock(return_value=[1])) + @patch('sfputil.main.platform_sfputil', MagicMock(is_logical_port=MagicMock(return_value=1))) + def test_show_lpmode(self, mock_chassis): + mock_sfp = MagicMock() + mock_api = MagicMock() + mock_sfp.get_xcvr_api = MagicMock(return_value=mock_api) + mock_sfp.get_lpmode.return_value = True + mock_chassis.get_sfp = MagicMock(return_value=mock_sfp) + runner = CliRunner() + result = runner.invoke(sfputil.cli.commands['show'].commands['lpmode'], ["-p", "Ethernet0"]) + assert result.exit_code == 0 + expected_output = """Port Low-power Mode +--------- ---------------- +Ethernet0 On +""" + assert result.output == expected_output + + mock_sfp.get_lpmode.return_value = False + result = runner.invoke(sfputil.cli.commands['show'].commands['lpmode'], ["-p", "Ethernet0"]) + assert result.exit_code == 0 + expected_output = """Port Low-power Mode +--------- ---------------- +Ethernet0 Off +""" + assert result.output == expected_output + + mock_sfp.get_lpmode.return_value = False + mock_sfp.get_transceiver_info = MagicMock(return_value={'type': sfputil.RJ45_PORT_TYPE}) + mock_chassis.get_port_or_cage_type = MagicMock(return_value=sfputil.SfpBase.SFP_PORT_TYPE_BIT_RJ45) + result = runner.invoke(sfputil.cli.commands['show'].commands['lpmode'], ["-p", "Ethernet0"]) + assert result.exit_code == 0 + expected_output = """Port Low-power Mode +--------- ---------------- +Ethernet0 N/A +""" + assert result.output == expected_output + + @patch('sfputil.main.platform_chassis') + @patch('sfputil.main.logical_port_to_physical_port_index', MagicMock(return_value=1)) + @patch('sfputil.main.logical_port_name_to_physical_port_list', MagicMock(return_value=[1])) + @patch('sfputil.main.platform_sfputil', MagicMock(is_logical_port=MagicMock(return_value=1))) + @patch('sfputil.main.is_port_type_rj45', MagicMock(return_value=True)) + def test_show_eeprom_RJ45(self, mock_chassis): + mock_sfp = MagicMock() + mock_api = MagicMock() + mock_sfp.get_xcvr_api = MagicMock(return_value=mock_api) + runner = CliRunner() + result = runner.invoke(sfputil.cli.commands['show'].commands['eeprom'], ["-p", "Ethernet16", "-d"]) + assert result.exit_code == 0 + expected_output = "Ethernet16: SFP EEPROM is not applicable for RJ45 port\n\n\n" + assert result.output == expected_output + + @patch('sfputil.main.platform_chassis') + @patch('sfputil.main.platform_sfputil', MagicMock(is_logical_port=MagicMock(return_value=0))) + def test_show_eeprom_hexdump_invalid_port(self, mock_chassis): + runner = CliRunner() + result = runner.invoke(sfputil.cli.commands['show'].commands['eeprom-hexdump'], ["-p", "Ethernet"]) + assert result.exit_code == ERROR_INVALID_PORT + + @patch('sfputil.main.platform_chassis') + @patch('sfputil.main.platform_sfputil', MagicMock(is_logical_port=MagicMock(return_value=1))) + def test_show_eeprom_hexdump_invalid_page(self, mock_chassis): + runner = CliRunner() + result = runner.invoke(sfputil.cli.commands['show'].commands['eeprom-hexdump'], ["-p", "Ethernet1", "-n", "INVALID"]) + assert result.exit_code == ERROR_NOT_IMPLEMENTED + + @patch('sfputil.main.platform_chassis') + @patch('sfputil.main.logical_port_to_physical_port_index', MagicMock(return_value=1)) + @patch('sfputil.main.platform_sfputil', MagicMock(is_logical_port=MagicMock(return_value=1))) + @patch('sfputil.main.is_port_type_rj45', MagicMock(return_value=True)) + def test_show_eeprom_hexdump_RJ45(self, mock_chassis): + runner = CliRunner() + result = runner.invoke(sfputil.cli.commands['show'].commands['eeprom-hexdump'], ["-p", "Ethernet16"]) + assert result.exit_code == ERROR_INVALID_PORT + expected_output = "Ethernet16: SFP EEPROM Hexdump is not applicable for RJ45 port\n" + assert result.output == expected_output + + @patch('sfputil.main.platform_chassis') + @patch('sfputil.main.logical_port_to_physical_port_index', MagicMock(return_value=1)) + @patch('sfputil.main.platform_sfputil', MagicMock(is_logical_port=MagicMock(return_value=1))) + @patch('sfputil.main.is_port_type_rj45', MagicMock(return_value=False)) + def test_show_eeprom_hexdump_xcvr_presence_not_implemented(self, mock_chassis): + mock_sfp = MagicMock() + mock_chassis.get_sfp = MagicMock(return_value=mock_sfp) + mock_sfp.get_presence = MagicMock(side_effect=NotImplementedError) + runner = CliRunner() + result = runner.invoke(sfputil.cli.commands['show'].commands['eeprom-hexdump'], ["-p", "Ethernet16"]) + assert result.exit_code == ERROR_NOT_IMPLEMENTED + expected_output = "Sfp.get_presence() is currently not implemented for this platform\n" + assert result.output == expected_output + + @patch('sfputil.main.platform_chassis') + @patch('sfputil.main.logical_port_to_physical_port_index', MagicMock(return_value=1)) + @patch('sfputil.main.platform_sfputil', MagicMock(is_logical_port=MagicMock(return_value=1))) + @patch('sfputil.main.is_port_type_rj45', MagicMock(return_value=False)) + def test_show_eeprom_hexdump_xcvr_not_present(self, mock_chassis): + mock_sfp = MagicMock() + mock_chassis.get_sfp = MagicMock(return_value=mock_sfp) + mock_sfp.get_presence.return_value = False + runner = CliRunner() + result = runner.invoke(sfputil.cli.commands['show'].commands['eeprom-hexdump'], ["-p", "Ethernet16"]) + assert result.exit_code == ERROR_NOT_IMPLEMENTED + expected_output = "SFP EEPROM not detected\n" + assert result.output == expected_output + + @patch('sfputil.main.platform_chassis') + @patch('sfputil.main.logical_port_to_physical_port_index', MagicMock(return_value=1)) + @patch('sfputil.main.platform_sfputil', MagicMock(is_logical_port=MagicMock(return_value=1))) + @patch('sfputil.main.is_port_type_rj45', MagicMock(return_value=False)) + def test_show_eeprom_hexdump_read_eeprom_failure(self, mock_chassis): + mock_sfp = MagicMock() + mock_chassis.get_sfp = MagicMock(return_value=mock_sfp) + mock_sfp.get_presence.return_value = True + mock_sfp.read_eeprom = MagicMock(return_value=None) + runner = CliRunner() + result = runner.invoke(sfputil.cli.commands['show'].commands['eeprom-hexdump'], ["-p", "Ethernet16"]) + assert result.exit_code == ERROR_NOT_IMPLEMENTED + expected_output = "Error: Failed to read EEPROM for offset 0!\n" + assert result.output == expected_output + + @patch('sfputil.main.platform_chassis') + @patch('sfputil.main.logical_port_to_physical_port_index', MagicMock(return_value=1)) + @patch('sfputil.main.platform_sfputil', MagicMock(is_logical_port=MagicMock(return_value=1))) + @patch('sfputil.main.is_port_type_rj45', MagicMock(return_value=False)) + def test_show_eeprom_hexdump_read_eeprom_not_implemented(self, mock_chassis): + mock_sfp = MagicMock() + mock_chassis.get_sfp = MagicMock(return_value=mock_sfp) + mock_sfp.get_presence.return_value = True + mock_sfp.read_eeprom = MagicMock(side_effect=NotImplementedError) + runner = CliRunner() + result = runner.invoke(sfputil.cli.commands['show'].commands['eeprom-hexdump'], ["-p", "Ethernet16"]) + assert result.exit_code == ERROR_NOT_IMPLEMENTED + expected_output = "Sfp.read_eeprom() is currently not implemented for this platform\n" + assert result.output == expected_output + + @patch('sfputil.main.platform_chassis') + @patch('sfputil.main.logical_port_to_physical_port_index', MagicMock(return_value=1)) + @patch('sfputil.main.platform_sfputil', MagicMock(is_logical_port=MagicMock(return_value=1))) + @patch('sfputil.main.is_port_type_rj45', MagicMock(return_value=False)) + def test_show_eeprom_hexdump_sff8636_page(self, mock_chassis): + lower_page_bytearray = bytearray([13, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 129, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) + upper_page0_bytearray = bytearray([13, 0, 35, 8, 0, 0, 0, 65, 128, 128, 245, 0, 0, 0, 0, 0, 0, 0, 1, 160, 77, 111, 108, 101, 120, 32, 73, 110, 99, 46, 32, 32, 32, 32, 32, 32, 7, 0, 9, 58, 49, 49, 49, 48, 52, 48, 49, 48, 53, 52, 32, 32, 32, 32, 32, 32, 32, 32, 3, 4, 0, 0, 70, 196, 0, 0, 0, 0, 54, 49, 49, 48, 51, 48, 57, 50, 57, 32, 32, 32, 32, 32, 32, 32, 49, 54, 48, 52, 49, 57, 32, 32, 0, 0, 0, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) + expected_output = '''EEPROM hexdump for port Ethernet0 page 0h + Lower page 0h + 00000000 0d 00 06 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| + 00000010 00 00 00 00 00 00 01 81 00 00 00 00 00 00 00 00 |................| + 00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| + 00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| + 00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| + 00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| + 00000060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| + 00000070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| + + Upper page 0h + 00000080 0d 00 23 08 00 00 00 41 80 80 f5 00 00 00 00 00 |..#....A........| + 00000090 00 00 01 a0 4d 6f 6c 65 78 20 49 6e 63 2e 20 20 |....Molex Inc. | + 000000a0 20 20 20 20 07 00 09 3a 31 31 31 30 34 30 31 30 | ...:11104010| + 000000b0 35 34 20 20 20 20 20 20 20 20 03 04 00 00 46 c4 |54 ....F.| + 000000c0 00 00 00 00 36 31 31 30 33 30 39 32 39 20 20 20 |....611030929 | + 000000d0 20 20 20 20 31 36 30 34 31 39 20 20 00 00 00 24 | 160419 ...$| + 000000e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| + 000000f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| + +''' + def side_effect(offset, num_bytes): + if offset == 0: + return lower_page_bytearray + else: + return upper_page0_bytearray + mock_sfp = MagicMock() + mock_sfp.get_presence.return_value = True + mock_chassis.get_sfp = MagicMock(return_value=mock_sfp) + mock_sfp.read_eeprom = MagicMock(side_effect=side_effect) + runner = CliRunner() + result = runner.invoke(sfputil.cli.commands['show'].commands['eeprom-hexdump'], ["-p", "Ethernet0", "-n", "0"]) + assert result.exit_code == 0 + assert result.output == expected_output + + @patch('sfputil.main.platform_chassis') + @patch('sfputil.main.logical_port_to_physical_port_index', MagicMock(return_value=1)) + @patch('sfputil.main.platform_sfputil', MagicMock(is_logical_port=MagicMock(return_value=1))) + @patch('sfputil.main.is_port_type_rj45', MagicMock(return_value=False)) + def test_show_eeprom_hexdump_sff8472_page(self, mock_chassis): + a0h_bytearray = bytearray([3, 4, 7, 16, 0, 0, 0, 0, 0, 0, 0, 6, 103, 0, 0, 0, 8, 3, 0, 30, 70, 73, 78, 73, 83, 65, 82, 32, 67, 79, 82, 80, 46, 32, 32, 32, 0, 0, 144, 101, 70, 84, 76, 88, 56, 53, 55, 49, 68, 51, 66, 67, 76, 32, 32, 32, 65, 32, 32, 32, 3, 82, 0, 72, 0, 26, 0, 0, 65, 85, 74, 48, 82, 67, 74, 32, 32, 32, 32, 32, 32, 32, 32, 32, 49, 53, 49, 48, 50, 57, 32, 32, 104, 240, 3, 246, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) + a2h_lower_bytearray = bytearray([78, 0, 243, 0, 73, 0, 248, 0, 144, 136, 113, 72, 140, 160, 117, 48, 25, 200, 7, 208, 24, 156, 9, 196, 39, 16, 9, 208, 31, 7, 12, 90, 39, 16, 0, 100, 31, 7, 0, 158, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 63, 128, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 27, 20, 2, 129, 177, 13, 90, 23, 165, 21, 135, 0, 0, 0, 0, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 1]) + a2h_upper_bytearray = bytearray([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) + expected_output = '''EEPROM hexdump for port Ethernet256 page 0h + A0h dump + 00000000 03 04 07 10 00 00 00 00 00 00 00 06 67 00 00 00 |............g...| + 00000010 08 03 00 1e 46 49 4e 49 53 41 52 20 43 4f 52 50 |....FINISAR CORP| + 00000020 2e 20 20 20 00 00 90 65 46 54 4c 58 38 35 37 31 |. ...eFTLX8571| + 00000030 44 33 42 43 4c 20 20 20 41 20 20 20 03 52 00 48 |D3BCL A .R.H| + 00000040 00 1a 00 00 41 55 4a 30 52 43 4a 20 20 20 20 20 |....AUJ0RCJ | + 00000050 20 20 20 20 31 35 31 30 32 39 20 20 68 f0 03 f6 | 151029 h...| + 00000060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| + 00000070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| + 00000080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| + 00000090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| + 000000a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| + 000000b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| + 000000c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| + 000000d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| + 000000e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| + 000000f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| + + A2h dump (lower 128 bytes) + 00000000 4e 00 f3 00 49 00 f8 00 90 88 71 48 8c a0 75 30 |N...I.....qH..u0| + 00000010 19 c8 07 d0 18 9c 09 c4 27 10 09 d0 1f 07 0c 5a |........'......Z| + 00000020 27 10 00 64 1f 07 00 9e 00 00 00 00 00 00 00 00 |'..d............| + 00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| + 00000040 00 00 00 00 3f 80 00 00 00 00 00 00 01 00 00 00 |....?...........| + 00000050 01 00 00 00 01 00 00 00 01 00 00 00 00 00 00 1b |................| + 00000060 14 02 81 b1 0d 5a 17 a5 15 87 00 00 00 00 30 00 |.....Z........0.| + 00000070 00 00 00 00 00 00 00 00 ff ff ff ff ff ff ff 01 |................| + + A2h dump (upper 128 bytes) page 0h + 00000080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| + 00000090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| + 000000a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| + 000000b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| + 000000c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| + 000000d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| + 000000e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| + 000000f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| + +''' + SFF8472_A0_SIZE = 256 + def side_effect(offset, num_bytes): + if offset == 0: + return a0h_bytearray + elif (offset == SFF8472_A0_SIZE): + return a2h_lower_bytearray + else: + return a2h_upper_bytearray + mock_sfp = MagicMock() + mock_chassis.get_sfp = MagicMock(return_value=mock_sfp) + mock_sfp.get_presence.return_value = True + mock_sfp.read_eeprom = MagicMock(side_effect=side_effect) + runner = CliRunner() + result = runner.invoke(sfputil.cli.commands['show'].commands['eeprom-hexdump'], ["-p", "Ethernet256", "-n", "0"]) + assert result.exit_code == 0 + assert result.output == expected_output + + @patch('sfputil.main.logical_port_name_to_physical_port_list', MagicMock(return_value=1)) + @patch('sfputil.main.is_port_type_rj45', MagicMock(return_value=True)) + @patch('sfputil.main.platform_sfputil', MagicMock(is_logical_port=MagicMock(return_value=1))) + def test_lpmode_set(self): + runner = CliRunner() + result = runner.invoke(sfputil.cli.commands['lpmode'].commands['on'], ["Ethernet0"]) + assert result.output == 'Enabling low-power mode is not applicable for RJ45 port Ethernet0.\n' + assert result.exit_code == EXIT_FAIL + + @patch('sfputil.main.logical_port_name_to_physical_port_list', MagicMock(return_value=1)) + @patch('sfputil.main.is_port_type_rj45', MagicMock(return_value=True)) + @patch('sfputil.main.platform_sfputil', MagicMock(is_logical_port=MagicMock(return_value=1))) + def test_reset_RJ45(self): + runner = CliRunner() + result = runner.invoke(sfputil.cli.commands['reset'], ["Ethernet0"]) + assert result.output == 'Reset is not applicable for RJ45 port Ethernet0.\n' + assert result.exit_code == EXIT_FAIL + @patch('sfputil.main.platform_chassis') @patch('sfputil.main.logical_port_to_physical_port_index', MagicMock(return_value=1)) def test_unlock_firmware(self, mock_chassis): @@ -305,6 +680,19 @@ def test_unlock_firmware(self, mock_chassis): result = runner.invoke(sfputil.cli.commands['firmware'].commands['unlock'], ["Ethernet0"]) assert result.exit_code == 0 + @patch('sfputil.main.platform_chassis') + @patch('sfputil.main.logical_port_to_physical_port_index', MagicMock(return_value=1)) + @patch('sfputil.main.is_port_type_rj45', MagicMock(return_value=True)) + def test_show_fwversion_Rj45(self, mock_chassis): + mock_sfp = MagicMock() + mock_api = MagicMock() + mock_sfp.get_xcvr_api = MagicMock(return_value=mock_api) + mock_sfp.get_presence.return_value = True + mock_chassis.get_sfp = MagicMock(return_value=mock_sfp) + runner = CliRunner() + result = runner.invoke(sfputil.cli.commands['show'].commands['fwversion'], ["Ethernet0"]) + assert result.output == 'Show firmware version is not applicable for RJ45 port Ethernet0.\n' + assert result.exit_code == EXIT_FAIL @patch('sfputil.main.platform_chassis') @patch('sfputil.main.logical_port_to_physical_port_index', MagicMock(return_value=1)) @@ -329,3 +717,37 @@ def test_commit_firmwre(self, mock_chassis): mock_api.cdb_commit_firmware.return_value = 1 status = sfputil.commit_firmware("Ethernet0") assert status == 1 + + @patch('sfputil.main.is_sfp_present', MagicMock(return_value=True)) + @patch('sfputil.main.is_port_type_rj45', MagicMock(return_value=True)) + def test_firmware_run_RJ45(self): + runner = CliRunner() + result = runner.invoke(sfputil.cli.commands['firmware'].commands['run'], ["--mode", "0", "Ethernet0"]) + assert result.output == 'This functionality is not applicable for RJ45 port Ethernet0.\n' + assert result.exit_code == EXIT_FAIL + + @patch('sfputil.main.is_sfp_present', MagicMock(return_value=True)) + @patch('sfputil.main.is_port_type_rj45', MagicMock(return_value=True)) + def test_firmware_commit_RJ45(self): + runner = CliRunner() + result = runner.invoke(sfputil.cli.commands['firmware'].commands['commit'], ["Ethernet0"]) + assert result.output == 'This functionality is not applicable for RJ45 port Ethernet0.\n' + assert result.exit_code == EXIT_FAIL + + @patch('sfputil.main.logical_port_to_physical_port_index', MagicMock(return_value=1)) + @patch('sfputil.main.is_port_type_rj45', MagicMock(return_value=True)) + @patch('sfputil.main.is_sfp_present', MagicMock(return_value=1)) + def test_firmware_upgrade_RJ45(self): + runner = CliRunner() + result = runner.invoke(sfputil.cli.commands['firmware'].commands['upgrade'], ["Ethernet0", "a.b"]) + assert result.output == 'This functionality is not applicable for RJ45 port Ethernet0.\n' + assert result.exit_code == EXIT_FAIL + + @patch('sfputil.main.logical_port_to_physical_port_index', MagicMock(return_value=1)) + @patch('sfputil.main.is_port_type_rj45', MagicMock(return_value=True)) + @patch('sfputil.main.is_sfp_present', MagicMock(return_value=1)) + def test_firmware_download_RJ45(self): + runner = CliRunner() + result = runner.invoke(sfputil.cli.commands['firmware'].commands['download'], ["Ethernet0", "a.b"]) + assert result.output == 'This functionality is not applicable for RJ45 port Ethernet0.\n' + assert result.exit_code == EXIT_FAIL diff --git a/tests/show_bfd_test.py b/tests/show_bfd_test.py index fdf4fbe5e2..c92fb7690b 100644 --- a/tests/show_bfd_test.py +++ b/tests/show_bfd_test.py @@ -29,7 +29,7 @@ def test_bfd_show(self): "tx_interval" :"300", "rx_interval" : "500", "multiplier" : "3", "multihop": "true"}) self.set_db_values(dbconnector, "BFD_SESSION_TABLE|default|Ethernet12|10.0.2.1", {"state": "UP", "type": "async_active", "local_addr" : "10.0.0.1", - "tx_interval" :"200", "rx_interval" : "600", "multiplier" : "3", "multihop": "false"}) + "tx_interval" :"200", "rx_interval" : "600", "multiplier" : "3", "multihop": "false", "local_discriminator": "88"}) self.set_db_values(dbconnector, "BFD_SESSION_TABLE|default|default|2000::10:1", {"state": "UP", "type": "async_active", "local_addr" : "2000::1", "tx_interval" :"100", "rx_interval" : "700", "multiplier" : "3", "multihop": "false"}) @@ -38,13 +38,15 @@ def test_bfd_show(self): "tx_interval" :"400", "rx_interval" : "500", "multiplier" : "5", "multihop": "false"}) expected_output = """\ -Total number of BFD sessions: 4 -Peer Addr Interface Vrf State Type Local Addr TX Interval RX Interval Multiplier Multihop ------------ ----------- ------- ------- ------------ ------------ ------------- ------------- ------------ ---------- -10.0.1.1 default default DOWN async_active 10.0.0.1 300 500 3 true -10.0.2.1 Ethernet12 default UP async_active 10.0.0.1 200 600 3 false -2000::10:1 default default UP async_active 2000::1 100 700 3 false -10.0.1.1 default VrfRed UP async_active 10.0.0.1 400 500 5 false +Total number of BFD sessions: 6 +Peer Addr Interface Vrf State Type Local Addr TX Interval RX Interval Multiplier Multihop Local Discriminator +--------------------- ----------- ------- ------- ------------ --------------------- ------------- ------------- ------------ ---------- --------------------- +100.251.7.1 default default Up async_active 10.0.0.1 300 500 3 true NA +fddd:a101:a251::a10:1 default default Down async_active fddd:c101:a251::a10:2 300 500 3 true NA +10.0.1.1 default default DOWN async_active 10.0.0.1 300 500 3 true NA +10.0.2.1 Ethernet12 default UP async_active 10.0.0.1 200 600 3 false 88 +2000::10:1 default default UP async_active 2000::1 100 700 3 false NA +10.0.1.1 default VrfRed UP async_active 10.0.0.1 400 500 5 false NA """ result = runner.invoke(show.cli.commands['bfd'].commands['summary'], [], obj=db) @@ -53,10 +55,10 @@ def test_bfd_show(self): expected_output = """\ Total number of BFD sessions for peer IP 10.0.1.1: 2 -Peer Addr Interface Vrf State Type Local Addr TX Interval RX Interval Multiplier Multihop ------------ ----------- ------- ------- ------------ ------------ ------------- ------------- ------------ ---------- -10.0.1.1 default default DOWN async_active 10.0.0.1 300 500 3 true -10.0.1.1 default VrfRed UP async_active 10.0.0.1 400 500 5 false +Peer Addr Interface Vrf State Type Local Addr TX Interval RX Interval Multiplier Multihop Local Discriminator +----------- ----------- ------- ------- ------------ ------------ ------------- ------------- ------------ ---------- --------------------- +10.0.1.1 default default DOWN async_active 10.0.0.1 300 500 3 true NA +10.0.1.1 default VrfRed UP async_active 10.0.0.1 400 500 5 false NA """ result = runner.invoke(show.cli.commands['bfd'].commands['peer'], ['10.0.1.1'], obj=db) @@ -65,9 +67,9 @@ def test_bfd_show(self): expected_output = """\ Total number of BFD sessions for peer IP 10.0.2.1: 1 -Peer Addr Interface Vrf State Type Local Addr TX Interval RX Interval Multiplier Multihop ------------ ----------- ------- ------- ------------ ------------ ------------- ------------- ------------ ---------- -10.0.2.1 Ethernet12 default UP async_active 10.0.0.1 200 600 3 false +Peer Addr Interface Vrf State Type Local Addr TX Interval RX Interval Multiplier Multihop Local Discriminator +----------- ----------- ------- ------- ------------ ------------ ------------- ------------- ------------ ---------- --------------------- +10.0.2.1 Ethernet12 default UP async_active 10.0.0.1 200 600 3 false 88 """ result = runner.invoke(show.cli.commands['bfd'].commands['peer'], ['10.0.2.1'], obj=db) @@ -88,9 +90,11 @@ def test_bfd_show_no_session(self): db = Db() expected_output = """\ -Total number of BFD sessions: 0 -Peer Addr Interface Vrf State Type Local Addr TX Interval RX Interval Multiplier Multihop ------------ ----------- ----- ------- ------ ------------ ------------- ------------- ------------ ---------- +Total number of BFD sessions: 2 +Peer Addr Interface Vrf State Type Local Addr TX Interval RX Interval Multiplier Multihop Local Discriminator +--------------------- ----------- ------- ------- ------------ --------------------- ------------- ------------- ------------ ---------- --------------------- +100.251.7.1 default default Up async_active 10.0.0.1 300 500 3 true NA +fddd:a101:a251::a10:1 default default Down async_active fddd:c101:a251::a10:2 300 500 3 true NA """ result = runner.invoke(show.cli.commands['bfd'].commands['summary'], [], obj=db) diff --git a/tests/show_ip_int_test.py b/tests/show_ip_int_test.py index 31350d3ea5..d2abdbbf5d 100644 --- a/tests/show_ip_int_test.py +++ b/tests/show_ip_int_test.py @@ -19,7 +19,7 @@ Vlan100 40.1.1.1/24 error/down N/A N/A""" show_ipv6_intf_with_multiple_ips = """\ -Interface Master IPv4 address/mask Admin/Oper BGP Neighbor Neighbor IP +Interface Master IPv6 address/mask Admin/Oper BGP Neighbor Neighbor IP --------------- -------- -------------------------------------------- ------------ -------------- ------------- Ethernet0 2100::1/64 error/down N/A N/A aa00::1/64 N/A N/A @@ -36,7 +36,7 @@ PortChannel0001 20.1.1.1/24 error/down T2-Peer 20.1.1.5""" show_multi_asic_ipv6_intf = """\ -Interface Master IPv4 address/mask Admin/Oper BGP Neighbor Neighbor IP +Interface Master IPv6 address/mask Admin/Oper BGP Neighbor Neighbor IP --------------- -------- -------------------------------------- ------------ -------------- ------------- Loopback0 fe80::60a5:9dff:fef4:1696%Loopback0/64 error/down N/A N/A PortChannel0001 aa00::1/64 error/down N/A N/A @@ -54,7 +54,7 @@ veth@eth2 193.1.1.1/24 error/down N/A N/A""" show_multi_asic_ipv6_intf_all = """\ -Interface Master IPv4 address/mask Admin/Oper BGP Neighbor Neighbor IP +Interface Master IPv6 address/mask Admin/Oper BGP Neighbor Neighbor IP --------------- -------- -------------------------------------- ------------ -------------- ------------- Loopback0 fe80::60a5:9dff:fef4:1696%Loopback0/64 error/down N/A N/A PortChannel0001 aa00::1/64 error/down N/A N/A diff --git a/tests/show_ip_route_common.py b/tests/show_ip_route_common.py index 386d32e55e..101b23309c 100644 --- a/tests/show_ip_route_common.py +++ b/tests/show_ip_route_common.py @@ -323,6 +323,162 @@ C>*fe80::/64 is directly connected, eth0, 1d11h34m """ +show_ipv6_route_alias_expected_output = """\ +Codes: K - kernel route, C - connected, S - static, R - RIP, + O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, + T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, + F - PBR, f - OpenFabric, + > - selected route, * - FIB route, q - queued route, r - rejected route + +B>*::/0 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +K *::/0 [210/0] via fd00::1, eth0, 1d11h34m +B>*2064:100::1/128 [20/0] via fc00::2, PortChannel0002, 1d11h34m +B>*2064:100::3/128 [20/0] via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a800::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a800:0:1::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a800:0:10::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a800:0:11::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a800:0:20::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a800:0:21::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a800:0:30::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a800:0:31::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a800:0:40::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a800:0:41::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a800:0:50::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a800:0:51::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a800:0:60::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a800:0:61::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a800:0:70::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a800:0:71::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a800:0:80::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a800:0:81::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a800:0:90::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a800:0:91::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a800:0:a0::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a800:0:a1::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a800:0:b0::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a800:0:b1::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a800:0:c0::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a800:0:c1::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a800:0:d0::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a800:0:d1::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a800:0:e0::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a800:0:e1::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a800:0:f0::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a800:0:f1::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a801::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a801:0:1::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a801:0:10::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a801:0:11::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a801:0:20::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a801:0:21::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a801:0:30::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a801:0:31::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a801:0:40::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a801:0:41::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a801:0:50::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a801:0:51::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a801:0:60::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a801:0:61::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a801:0:70::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a801:0:71::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a801:0:80::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a801:0:81::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a801:0:90::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a801:0:91::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a801:0:a0::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a801:0:a1::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a801:0:b0::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a801:0:b1::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a801:0:c0::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a801:0:c1::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a801:0:d0::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a801:0:d1::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a801:0:e0::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a801:0:e1::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a801:0:f0::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +B>*20c0:a801:0:f1::/64 [20/0] via fc00::2, PortChannel0002, 1d11h34m + * via fc00::6, PortChannel0005, 1d11h34m +C>*2603:10e2:400::/128 is directly connected, Loopback4096, 1d11h34m +C>*fc00::/126 is directly connected, PortChannel0002, 1d11h34m +C>*fc00::4/126 is directly connected, PortChannel0005, 1d11h34m +C>*fc00:1::32/128 is directly connected, Loopback0, 1d11h34m +C>*fd00::/80 is directly connected, eth0, 1d11h34m +C *fe80::/64 is directly connected, PortChannel0002, 1d11h34m +C *fe80::/64 is directly connected, PortChannel0005, 1d11h34m +C *fe80::/64 is directly connected, etp6, 1d11h34m +C *fe80::/64 is directly connected, etp5, 1d11h34m +C *fe80::/64 is directly connected, etp2, 1d11h34m +C *fe80::/64 is directly connected, etp1, 1d11h34m +C *fe80::/64 is directly connected, Loopback4096, 1d11h34m +C *fe80::/64 is directly connected, Loopback0, 1d11h34m +C>*fe80::/64 is directly connected, eth0, 1d11h34m +""" + # # MULTI ASIC TEST SECTION # @@ -555,6 +711,52 @@ C *fe80::/64 is directly connected, Ethernet24, 2d22h02m """ +show_ipv6_route_multi_asic_all_namesapce_alias_output = """\ +Codes: K - kernel route, C - connected, S - static, R - RIP, + O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, + T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, + F - PBR, f - OpenFabric, + > - selected route, * - FIB route, q - queued route, r - rejected route + +K *::/0 [210/0] via fd00::1, eth0, 2d22h00m +B>*::/0 [20/0] via fc00::6, PortChannel0005, 2d22h00m + * via fc00::2, PortChannel0002, 2d22h00m + * via fc00::2, PortChannel1015, 2d22h00m + * via fc00::6, PortChannel1016, 2d22h00m +B>*2064:100::1/128 [20/0] via fc00::2, PortChannel0002, 2d22h00m + * via fc00::2, PortChannel1015, 2d22h00m +B>*2064:100::3/128 [20/0] via fc00::6, PortChannel0005, 2d22h00m + * via fc00::6, PortChannel1016, 2d22h00m +B>*20c0:a800:0:1::/64 [20/0] via fc00::6, PortChannel0005, 2d22h00m + * via fc00::2, PortChannel0002, 2d22h00m + * via fc00::2, PortChannel1015, 2d22h00m + * via fc00::6, PortChannel1016, 2d22h00m +B>*20c0:a800:0:10::/64 [20/0] via fc00::6, PortChannel0005, 2d22h00m + * via fc00::2, PortChannel0002, 2d22h00m + * via fc00::2, PortChannel1015, 2d22h00m + * via fc00::6, PortChannel1016, 2d22h00m +B>*20c0:a800:0:11::/64 [20/0] via fc00::6, PortChannel0002, 2d22h00m + * via fc00::6, PortChannel1015, 2d22h00m +B>*20c0:a800:0:20::/64 [20/0] via fc00::2, PortChannel0002, 2d22h00m + * via fc00::2, PortChannel1015, 2d22h00m +B>*20c0:a800:0:21::/64 [20/0] via fc00::2, PortChannel0002, 2d22h00m + * via fc00::2, PortChannel1015, 2d22h00m +C>*2603:10e2:400::/128 is directly connected, Loopback4096, 2d22h00m +C>*2603:10e2:400::2/128 is directly connected, Loopback4096, 2d22h02m +C>*fc00::4/126 is directly connected, PortChannel0005, 2d22h00m +C>*fc00::4/126 is directly connected, PortChannel1016, 2d22h02m +C>*fc00:1::32/128 is directly connected, Loopback0, 2d22h00m +C>*fd00::/80 is directly connected, eth0, 2d22h00m +C>*fe80::/64 is directly connected, eth0, 2d22h00m +C *fe80::/64 is directly connected, Loopback0, 2d22h00m +C *fe80::/64 is directly connected, Loopback4096, 2d22h00m +C *fe80::/64 is directly connected, Ethernet1/5, 2d22h00m +C *fe80::/64 is directly connected, Ethernet1/6, 2d22h00m +C *fe80::/64 is directly connected, PortChannel0005, 2d22h00m +C *fe80::/64 is directly connected, PortChannel1016, 2d22h02m +C *fe80::/64 is directly connected, Ethernet1/7, 2d22h02m +""" + show_ipv6_route_multi_asic_single_namesapce_output = """\ Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, diff --git a/tests/show_test.py b/tests/show_test.py new file mode 100644 index 0000000000..114dbc3c6c --- /dev/null +++ b/tests/show_test.py @@ -0,0 +1,118 @@ +import os +import sys +import pytest +import show.main as show +from click.testing import CliRunner +from unittest import mock +from unittest.mock import call, MagicMock, patch + +EXPECTED_BASE_COMMAND = 'sudo ' + +test_path = os.path.dirname(os.path.abspath(__file__)) +modules_path = os.path.dirname(test_path) +sys.path.insert(0, test_path) +sys.path.insert(0, modules_path) + + +class TestShowRunAllCommands(object): + @classmethod + def setup_class(cls): + print("SETUP") + os.environ["UTILITIES_UNIT_TESTING"] = "1" + + def test_show_runningconfiguration_all_json_loads_failure(self): + def get_cmd_output_side_effect(*args, **kwargs): + return "", 0 + with mock.patch('show.main.get_cmd_output', + mock.MagicMock(side_effect=get_cmd_output_side_effect)) as mock_get_cmd_output: + result = CliRunner().invoke(show.cli.commands['runningconfiguration'].commands['all'], []) + assert result.exit_code != 0 + + def test_show_runningconfiguration_all_get_cmd_ouput_failure(self): + def get_cmd_output_side_effect(*args, **kwargs): + return "{}", 2 + with mock.patch('show.main.get_cmd_output', + mock.MagicMock(side_effect=get_cmd_output_side_effect)) as mock_get_cmd_output: + result = CliRunner().invoke(show.cli.commands['runningconfiguration'].commands['all'], []) + assert result.exit_code != 0 + + def test_show_runningconfiguration_all(self): + def get_cmd_output_side_effect(*args, **kwargs): + return "{}", 0 + with mock.patch('show.main.get_cmd_output', + mock.MagicMock(side_effect=get_cmd_output_side_effect)) as mock_get_cmd_output: + result = CliRunner().invoke(show.cli.commands['runningconfiguration'].commands['all'], []) + assert mock_get_cmd_output.call_count == 2 + assert mock_get_cmd_output.call_args_list == [ + call(['sonic-cfggen', '-d', '--print-data']), + call(['rvtysh', '-c', 'show running-config'])] + + @classmethod + def teardown_class(cls): + print("TEARDOWN") + os.environ["PATH"] = os.pathsep.join(os.environ["PATH"].split(os.pathsep)[:-1]) + os.environ["UTILITIES_UNIT_TESTING"] = "0" + +@patch('show.main.run_command') +@pytest.mark.parametrize( + "cli_arguments,expected", + [ + ([], 'cat /var/log/syslog'), + (['xcvrd'], "cat /var/log/syslog | grep 'xcvrd'"), + (['-l', '10'], 'cat /var/log/syslog | tail -10'), + (['-f'], 'tail -F /var/log/syslog'), + ] +) +def test_show_logging_default(run_command, cli_arguments, expected): + runner = CliRunner() + result = runner.invoke(show.cli.commands["logging"], cli_arguments) + run_command.assert_called_with(EXPECTED_BASE_COMMAND + expected, display_cmd=False) + +@patch('show.main.run_command') +@patch('os.path.isfile', MagicMock(return_value=True)) +@pytest.mark.parametrize( + "cli_arguments,expected", + [ + ([], 'cat /var/log/syslog.1 /var/log/syslog'), + (['xcvrd'], "cat /var/log/syslog.1 /var/log/syslog | grep 'xcvrd'"), + (['-l', '10'], 'cat /var/log/syslog.1 /var/log/syslog | tail -10'), + (['-f'], 'tail -F /var/log/syslog'), + ] +) +def test_show_logging_syslog_1(run_command, cli_arguments, expected): + runner = CliRunner() + result = runner.invoke(show.cli.commands["logging"], cli_arguments) + run_command.assert_called_with(EXPECTED_BASE_COMMAND + expected, display_cmd=False) + +@patch('show.main.run_command') +@patch('os.path.exists', MagicMock(return_value=True)) +@pytest.mark.parametrize( + "cli_arguments,expected", + [ + ([], 'cat /var/log.tmpfs/syslog'), + (['xcvrd'], "cat /var/log.tmpfs/syslog | grep 'xcvrd'"), + (['-l', '10'], 'cat /var/log.tmpfs/syslog | tail -10'), + (['-f'], 'tail -F /var/log.tmpfs/syslog'), + ] +) +def test_show_logging_tmpfs(run_command, cli_arguments, expected): + runner = CliRunner() + result = runner.invoke(show.cli.commands["logging"], cli_arguments) + run_command.assert_called_with(EXPECTED_BASE_COMMAND + expected, display_cmd=False) + +@patch('show.main.run_command') +@patch('os.path.isfile', MagicMock(return_value=True)) +@patch('os.path.exists', MagicMock(return_value=True)) +@pytest.mark.parametrize( + "cli_arguments,expected", + [ + ([], 'cat /var/log.tmpfs/syslog.1 /var/log.tmpfs/syslog'), + (['xcvrd'], "cat /var/log.tmpfs/syslog.1 /var/log.tmpfs/syslog | grep 'xcvrd'"), + (['-l', '10'], 'cat /var/log.tmpfs/syslog.1 /var/log.tmpfs/syslog | tail -10'), + (['-f'], 'tail -F /var/log.tmpfs/syslog'), + ] +) +def test_show_logging_tmpfs_syslog_1(run_command, cli_arguments, expected): + runner = CliRunner() + result = runner.invoke(show.cli.commands["logging"], cli_arguments) + run_command.assert_called_with(EXPECTED_BASE_COMMAND + expected, display_cmd=False) diff --git a/tests/show_vnet_test.py b/tests/show_vnet_test.py new file mode 100644 index 0000000000..5317b9b3ff --- /dev/null +++ b/tests/show_vnet_test.py @@ -0,0 +1,77 @@ +import os +from click.testing import CliRunner +from utilities_common.db import Db +import show.main as show + +class TestShowVnetRoutesAll(object): + @classmethod + def setup_class(cls): + print("SETUP") + os.environ["UTILITIES_UNIT_TESTING"] = "1" + + def test_show_vnet_routes_all_basic(self): + runner = CliRunner() + db = Db() + + result = runner.invoke(show.cli.commands['vnet'].commands['routes'].commands['all'], [], obj=db) + assert result.exit_code == 0 + expected_output = """\ +vnet name prefix nexthop interface +----------- -------- --------- ----------- + +vnet name prefix endpoint mac address vni status +--------------- ------------------------ ------------------------------------------- ------------- ----- -------- +Vnet_v6_in_v6-0 fddd:a156:a251::a6:1/128 fddd:a100:a251::a10:1,fddd:a101:a251::a10:1 active +test_v4_in_v4-0 160.162.191.1/32 100.251.7.1 active +test_v4_in_v4-0 160.163.191.1/32 100.251.7.1 active +test_v4_in_v4-0 160.164.191.1/32 100.251.7.1 +""" + assert result.output == expected_output + +class TestShowVnetAdvertisedRoutesIPX(object): + @classmethod + def setup_class(cls): + print("SETUP") + os.environ["UTILITIES_UNIT_TESTING"] = "1" + + def test_show_vnet_adv_routes_ip_basic(self): + runner = CliRunner() + db = Db() + result = runner.invoke(show.cli.commands['vnet'].commands['advertised-routes'], [], obj=db) + assert result.exit_code == 0 + expected_output = """\ +Prefix Profile Community Id +------------------------ ------------------- -------------- +160.62.191.1/32 FROM_SDN_SLB_ROUTES 1234:1235 +160.63.191.1/32 FROM_SDN_SLB_ROUTES 1234:1235 +160.64.191.1/32 FROM_SDN_SLB_ROUTES 1234:1235 +fccc:a250:a251::a6:1/128 +fddd:a150:a251::a6:1/128 FROM_SDN_SLB_ROUTES 1234:1235 +""" + assert result.output == expected_output + + def test_show_vnet_adv_routes_ip_string(self): + runner = CliRunner() + db = Db() + result = runner.invoke(show.cli.commands['vnet'].commands['advertised-routes'], ['1234:1235'], obj=db) + assert result.exit_code == 0 + expected_output = """\ +Prefix Profile Community Id +------------------------ ------------------- -------------- +160.62.191.1/32 FROM_SDN_SLB_ROUTES 1234:1235 +160.63.191.1/32 FROM_SDN_SLB_ROUTES 1234:1235 +160.64.191.1/32 FROM_SDN_SLB_ROUTES 1234:1235 +fddd:a150:a251::a6:1/128 FROM_SDN_SLB_ROUTES 1234:1235 +""" + assert result.output == expected_output + + def test_show_vnet_adv_routes_ipv6_Error(self): + runner = CliRunner() + db = Db() + result = runner.invoke(show.cli.commands['vnet'].commands['advertised-routes'], ['1230:1235'], obj=db) + assert result.exit_code == 0 + expected_output = """\ +Prefix Profile Community Id +-------- --------- -------------- +""" + assert result.output == expected_output diff --git a/tests/show_vnet_vxlan_cli_test.py b/tests/show_vnet_vxlan_cli_test.py new file mode 100644 index 0000000000..f0cee3b257 --- /dev/null +++ b/tests/show_vnet_vxlan_cli_test.py @@ -0,0 +1,74 @@ +import os +import sys +import traceback +import mock_tables.dbconnector +from click.testing import CliRunner +from unittest import mock +from utilities_common.db import Db +import show.main as show + +#test_path = os.path.dirname(os.path.abspath(__file__)) + + + +class TestShowVnet(object): + @classmethod + def setup_class(cls): + print("SETUP") + os.environ["UTILITIES_UNIT_TESTING"] = "1" + + def test_show_vnet_routes_all_basic(self): + runner = CliRunner() + db = Db() + result = runner.invoke(show.cli.commands['vnet'].commands['routes'].commands['all'], [], obj=db) + assert result.exit_code == 0 + expected_output = """\ +vnet name prefix nexthop interface +----------- -------- --------- ----------- + +vnet name prefix endpoint mac address vni status +--------------- ------------------------ ------------------------------------------- ------------- ----- -------- +Vnet_v6_in_v6-0 fddd:a156:a251::a6:1/128 fddd:a100:a251::a10:1,fddd:a101:a251::a10:1 active +test_v4_in_v4-0 160.162.191.1/32 100.251.7.1 active +test_v4_in_v4-0 160.163.191.1/32 100.251.7.1 active +test_v4_in_v4-0 160.164.191.1/32 100.251.7.1 +""" + assert result.output == expected_output + + def test_show_vnet_endpoint(self): + runner = CliRunner() + db = Db() + result = runner.invoke(show.cli.commands['vnet'].commands['endpoint'], [], obj=db) + assert result.exit_code == 0 + expected_output = """\ +Endpoint Endpoint Monitor prefix count status +--------------------- --------------------- -------------- -------- +fddd:a100:a251::a10:1 fddd:a100:a251::a10:1 1 Unknown +fddd:a101:a251::a10:1 fddd:a101:a251::a10:1 1 Down +100.251.7.1 100.251.7.1 3 Up +""" + assert result.output == expected_output + + def test_show_vnet_endpoint_ipv4(self): + runner = CliRunner() + db = Db() + result = runner.invoke(show.cli.commands['vnet'].commands['endpoint'], ['100.251.7.1'], obj=db) + assert result.exit_code == 0 + expected_output = """\ +Endpoint Endpoint Monitor prefix status +----------- ------------------ ------------------------------------------------------------ -------- +100.251.7.1 ['100.251.7.1'] ['160.162.191.1/32', '160.163.191.1/32', '160.164.191.1/32'] Up +""" + assert result.output == expected_output + + def test_show_vnet_endpoint_ipv6(self): + runner = CliRunner() + db = Db() + result = runner.invoke(show.cli.commands['vnet'].commands['endpoint'], ['fddd:a101:a251::a10:1'], obj=db) + assert result.exit_code == 0 + expected_output = """\ +Endpoint Endpoint Monitor prefix status +--------------------- ------------------------- ---------------------------- -------- +fddd:a101:a251::a10:1 ['fddd:a101:a251::a10:1'] ['fddd:a156:a251::a6:1/128'] Down +""" + assert result.output == expected_output diff --git a/tests/show_vrf_test.py b/tests/show_vrf_test.py deleted file mode 100644 index 3c6d1c5b36..0000000000 --- a/tests/show_vrf_test.py +++ /dev/null @@ -1,39 +0,0 @@ -import os -import sys -from click.testing import CliRunner -from swsscommon.swsscommon import SonicV2Connector -from utilities_common.db import Db - -import show.main as show - -test_path = os.path.dirname(os.path.abspath(__file__)) -mock_db_path = os.path.join(test_path, "vrf_input") - -class TestShowVrf(object): - @classmethod - def setup_class(cls): - print("SETUP") - os.environ["UTILITIES_UNIT_TESTING"] = "1" - - def test_vrf_show(self): - from .mock_tables import dbconnector - jsonfile_config = os.path.join(mock_db_path, "config_db") - dbconnector.dedicated_dbs['CONFIG_DB'] = jsonfile_config - runner = CliRunner() - db = Db() - expected_output = """\ -VRF Interfaces ------- --------------- -Vrf1 -Vrf101 Ethernet0.10 -Vrf102 PortChannel0002 - Vlan40 - Eth32.10 -Vrf103 Ethernet4 - Loopback0 -""" - - result = runner.invoke(show.cli.commands['vrf'], [], obj=db) - dbconnector.dedicated_dbs = {} - assert result.exit_code == 0 - assert result.output == expected_output diff --git a/tests/sonic_package_manager/test_service_creator.py b/tests/sonic_package_manager/test_service_creator.py index c943289362..7ca2e4f783 100644 --- a/tests/sonic_package_manager/test_service_creator.py +++ b/tests/sonic_package_manager/test_service_creator.py @@ -308,7 +308,7 @@ def get_entry(cls, table, key): @classmethod def get_entry_running_cfg(cls, table, key): if table == "AUTO_TECHSUPPORT_FEATURE" and key == "test": - return {"state" : "disabled", "rate_limit_interval" : "1000"} + return {"state" : "disabled", "rate_limit_interval" : "1000", "available_mem_threshold": "20.0"} else: return {} @@ -323,7 +323,8 @@ def test_auto_ts_global_disabled(mock_sonic_db, manifest): feature_registry.register(manifest) mock_init_cfg.set_entry.assert_any_call("AUTO_TECHSUPPORT_FEATURE", "test", { "state" : "disabled", - "rate_limit_interval" : "600" + "rate_limit_interval" : "600", + "available_mem_threshold": "10.0" } ) @@ -338,7 +339,8 @@ def test_auto_ts_global_enabled(mock_sonic_db, manifest): feature_registry.register(manifest) mock_init_cfg.set_entry.assert_any_call("AUTO_TECHSUPPORT_FEATURE", "test", { "state" : "enabled", - "rate_limit_interval" : "600" + "rate_limit_interval" : "600", + "available_mem_threshold": "10.0" } ) @@ -377,7 +379,8 @@ def test_auto_ts_feature_update_flow(mock_sonic_db, manifest): call("AUTO_TECHSUPPORT_FEATURE", "test", None), call("AUTO_TECHSUPPORT_FEATURE", "test_new", { "state" : "enabled", - "rate_limit_interval" : "600" + "rate_limit_interval" : "600", + "available_mem_threshold": "10.0" }) ], any_order = True @@ -388,7 +391,8 @@ def test_auto_ts_feature_update_flow(mock_sonic_db, manifest): call("AUTO_TECHSUPPORT_FEATURE", "test", None), call("AUTO_TECHSUPPORT_FEATURE", "test_new", { "state" : "disabled", - "rate_limit_interval" : "1000" + "rate_limit_interval" : "1000", + "available_mem_threshold": "20.0" }) ], any_order = True diff --git a/tests/static_routes_test.py b/tests/static_routes_test.py index 5704844aef..da8a4ea97b 100644 --- a/tests/static_routes_test.py +++ b/tests/static_routes_test.py @@ -45,8 +45,8 @@ def test_simple_static_route(self): result = runner.invoke(config.config.commands["route"].commands["add"], \ ["prefix", "1.2.3.4/32", "nexthop", "30.0.0.5"], obj=obj) print(result.exit_code, result.output) - assert ('1.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') - assert db.cfgdb.get_entry('STATIC_ROUTE', '1.2.3.4/32') == {'nexthop': '30.0.0.5', 'blackhole': 'false', 'distance': '0', 'ifname': '', 'nexthop-vrf': ''} + assert ('default', '1.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') + assert db.cfgdb.get_entry('STATIC_ROUTE', 'default|1.2.3.4/32') == {'nexthop': '30.0.0.5', 'blackhole': 'false', 'distance': '0', 'ifname': '', 'nexthop-vrf': ''} # config route del prefix 1.2.3.4/32 nexthop 30.0.0.5 result = runner.invoke(config.config.commands["route"].commands["del"], \ @@ -93,6 +93,8 @@ def test_vrf_static_route(self): obj = {'config_db':db.cfgdb} # config route add prefix vrf Vrf-BLUE 2.2.3.4/32 nexthop 30.0.0.6 + result = runner.invoke(config.config.commands["vrf"].commands["add"], ["Vrf-BLUE"], obj=obj) + print(result.exit_code, result.output) result = runner.invoke(config.config.commands["route"].commands["add"], \ ["prefix", "vrf", "Vrf-BLUE", "2.2.3.4/32", "nexthop", "30.0.0.6"], obj=obj) print(result.exit_code, result.output) @@ -111,11 +113,14 @@ def test_dest_vrf_static_route(self): obj = {'config_db':db.cfgdb} # config route add prefix 3.2.3.4/32 nexthop vrf Vrf-RED 30.0.0.6 + result = runner.invoke(config.config.commands["vrf"].commands["add"], ["Vrf-RED"], obj=obj) + print(result.exit_code, result.output) result = runner.invoke(config.config.commands["route"].commands["add"], \ ["prefix", "3.2.3.4/32", "nexthop", "vrf", "Vrf-RED", "30.0.0.6"], obj=obj) print(result.exit_code, result.output) - assert ('3.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') - assert db.cfgdb.get_entry('STATIC_ROUTE', '3.2.3.4/32') == {'nexthop': '30.0.0.6', 'nexthop-vrf': 'Vrf-RED', 'blackhole': 'false', 'distance': '0', 'ifname': ''} + print(db.cfgdb.get_table('STATIC_ROUTE')) + assert ('default', '3.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') + assert db.cfgdb.get_entry('STATIC_ROUTE', 'default|3.2.3.4/32') == {'nexthop': '30.0.0.6', 'nexthop-vrf': 'Vrf-RED', 'blackhole': 'false', 'distance': '0', 'ifname': ''} # config route del prefix 3.2.3.4/32 nexthop vrf Vrf-RED 30.0.0.6 result = runner.invoke(config.config.commands["route"].commands["del"], \ @@ -129,26 +134,28 @@ def test_multiple_nexthops_with_vrf_static_route(self): obj = {'config_db':db.cfgdb} ''' Add ''' + result = runner.invoke(config.config.commands["vrf"].commands["add"], ["Vrf-RED"], obj=obj) + print(result.exit_code, result.output) # config route add prefix 6.2.3.4/32 nexthop vrf Vrf-RED "30.0.0.6,30.0.0.7" result = runner.invoke(config.config.commands["route"].commands["add"], \ ["prefix", "6.2.3.4/32", "nexthop", "vrf", "Vrf-RED", "30.0.0.6,30.0.0.7"], obj=obj) print(result.exit_code, result.output) - assert ('6.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') - assert db.cfgdb.get_entry('STATIC_ROUTE', '6.2.3.4/32') == {'nexthop': '30.0.0.6,30.0.0.7', 'blackhole': 'false,false', 'distance': '0,0', 'ifname': ',', 'nexthop-vrf': 'Vrf-RED,Vrf-RED'} + assert ('default', '6.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') + assert db.cfgdb.get_entry('STATIC_ROUTE', 'default|6.2.3.4/32') == {'nexthop': '30.0.0.6,30.0.0.7', 'blackhole': 'false,false', 'distance': '0,0', 'ifname': ',', 'nexthop-vrf': 'Vrf-RED,Vrf-RED'} ''' Del ''' # config route del prefix 6.2.3.4/32 nexthop vrf Vrf-RED 30.0.0.7 result = runner.invoke(config.config.commands["route"].commands["del"], \ ["prefix", "6.2.3.4/32", "nexthop", "vrf", "Vrf-RED", "30.0.0.7"], obj=obj) print(result.exit_code, result.output) - assert ('6.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') - assert db.cfgdb.get_entry('STATIC_ROUTE', '6.2.3.4/32') == {'nexthop': '30.0.0.6', 'blackhole': 'false', 'distance': '0', 'ifname': '', 'nexthop-vrf': 'Vrf-RED'} + assert ('default', '6.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') + assert db.cfgdb.get_entry('STATIC_ROUTE', 'default|6.2.3.4/32') == {'nexthop': '30.0.0.6', 'blackhole': 'false', 'distance': '0', 'ifname': '', 'nexthop-vrf': 'Vrf-RED'} # config route del prefix 6.2.3.4/32 nexthop vrf Vrf-RED 30.0.0.6 result = runner.invoke(config.config.commands["route"].commands["del"], \ ["prefix", "6.2.3.4/32", "nexthop", "vrf", "Vrf-RED", "30.0.0.6"], obj=obj) print(result.exit_code, result.output) - assert not ('6.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') + assert not ('default', '6.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') def test_multiple_nexthops_static_route(self): db = Db() @@ -160,30 +167,30 @@ def test_multiple_nexthops_static_route(self): result = runner.invoke(config.config.commands["route"].commands["add"], \ ["prefix", "6.2.3.4/32", "nexthop", "30.0.0.6,30.0.0.7"], obj=obj) print(result.exit_code, result.output) - assert ('6.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') - assert db.cfgdb.get_entry('STATIC_ROUTE', '6.2.3.4/32') == {'nexthop': '30.0.0.6,30.0.0.7', 'blackhole': 'false,false', 'distance': '0,0', 'ifname': ',', 'nexthop-vrf': ','} + assert ('default', '6.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') + assert db.cfgdb.get_entry('STATIC_ROUTE', 'default|6.2.3.4/32') == {'nexthop': '30.0.0.6,30.0.0.7', 'blackhole': 'false,false', 'distance': '0,0', 'ifname': ',', 'nexthop-vrf': ','} # config route add prefix 6.2.3.4/32 nexthop 30.0.0.8 result = runner.invoke(config.config.commands["route"].commands["add"], \ ["prefix", "6.2.3.4/32", "nexthop", "30.0.0.8"], obj=obj) print(result.exit_code, result.output) - assert ('6.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') - assert db.cfgdb.get_entry('STATIC_ROUTE', '6.2.3.4/32') == {'nexthop': '30.0.0.6,30.0.0.7,30.0.0.8', 'blackhole': 'false,false,false', 'distance': '0,0,0', 'ifname': ',,', 'nexthop-vrf': ',,'} + assert ('default', '6.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') + assert db.cfgdb.get_entry('STATIC_ROUTE', 'default|6.2.3.4/32') == {'nexthop': '30.0.0.6,30.0.0.7,30.0.0.8', 'blackhole': 'false,false,false', 'distance': '0,0,0', 'ifname': ',,', 'nexthop-vrf': ',,'} ''' Del ''' # config route del prefix 6.2.3.4/32 nexthop 30.0.0.8 result = runner.invoke(config.config.commands["route"].commands["del"], \ ["prefix", "6.2.3.4/32", "nexthop", "30.0.0.8"], obj=obj) print(result.exit_code, result.output) - assert ('6.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') - assert db.cfgdb.get_entry('STATIC_ROUTE', '6.2.3.4/32') == {"nexthop": '30.0.0.6,30.0.0.7', 'blackhole': 'false,false', 'distance': '0,0', 'ifname': ',', 'nexthop-vrf': ','} + assert ('default', '6.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') + assert db.cfgdb.get_entry('STATIC_ROUTE', 'default|6.2.3.4/32') == {"nexthop": '30.0.0.6,30.0.0.7', 'blackhole': 'false,false', 'distance': '0,0', 'ifname': ',', 'nexthop-vrf': ','} # config route del prefix 6.2.3.4/32 nexthop 30.0.0.7 result = runner.invoke(config.config.commands["route"].commands["del"], \ ["prefix", "6.2.3.4/32", "nexthop", "30.0.0.7"], obj=obj) print(result.exit_code, result.output) - assert ('6.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') - assert db.cfgdb.get_entry('STATIC_ROUTE', '6.2.3.4/32') == {'nexthop': '30.0.0.6', 'blackhole': 'false', 'distance': '0', 'ifname': '', 'nexthop-vrf': ''} + assert ('default', '6.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') + assert db.cfgdb.get_entry('STATIC_ROUTE', 'default|6.2.3.4/32') == {'nexthop': '30.0.0.6', 'blackhole': 'false', 'distance': '0', 'ifname': '', 'nexthop-vrf': ''} # config route del prefix 6.2.3.4/32 nexthop 30.0.0.6 result = runner.invoke(config.config.commands["route"].commands["del"], \ @@ -221,23 +228,23 @@ def test_static_route_ECMP_nexthop(self): result = runner.invoke(config.config.commands["route"].commands["add"], \ ["prefix", "10.2.3.4/32", "nexthop", "30.0.0.5"], obj=obj) print(result.exit_code, result.output) - assert ('10.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') - assert db.cfgdb.get_entry('STATIC_ROUTE', '10.2.3.4/32') == {'nexthop': '30.0.0.5', 'blackhole': 'false', 'distance': '0', 'ifname': '', 'nexthop-vrf': ''} + assert ('default', '10.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') + assert db.cfgdb.get_entry('STATIC_ROUTE', 'default|10.2.3.4/32') == {'nexthop': '30.0.0.5', 'blackhole': 'false', 'distance': '0', 'ifname': '', 'nexthop-vrf': ''} # config route add prefix 10.2.3.4/32 nexthop 30.0.0.6 result = runner.invoke(config.config.commands["route"].commands["add"], \ ["prefix", "10.2.3.4/32", "nexthop", "30.0.0.6"], obj=obj) print(result.exit_code, result.output) - assert ('10.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') - assert db.cfgdb.get_entry('STATIC_ROUTE', '10.2.3.4/32') == {'nexthop': '30.0.0.5,30.0.0.6', 'blackhole': 'false,false', 'distance': '0,0', 'ifname': ',', 'nexthop-vrf': ','} + assert ('default', '10.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') + assert db.cfgdb.get_entry('STATIC_ROUTE', 'default|10.2.3.4/32') == {'nexthop': '30.0.0.5,30.0.0.6', 'blackhole': 'false,false', 'distance': '0,0', 'ifname': ',', 'nexthop-vrf': ','} ''' Del ''' # config route del prefix 10.2.3.4/32 nexthop 30.0.0.5 result = runner.invoke(config.config.commands["route"].commands["del"], \ ["prefix", "10.2.3.4/32", "nexthop", "30.0.0.5"], obj=obj) print(result.exit_code, result.output) - assert ('10.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') - assert db.cfgdb.get_entry('STATIC_ROUTE', '10.2.3.4/32') == {'nexthop': '30.0.0.6', 'blackhole': 'false', 'distance': '0', 'ifname': '', 'nexthop-vrf': ''} + assert ('default', '10.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') + assert db.cfgdb.get_entry('STATIC_ROUTE', 'default|10.2.3.4/32') == {'nexthop': '30.0.0.6', 'blackhole': 'false', 'distance': '0', 'ifname': '', 'nexthop-vrf': ''} # config route del prefix 1.2.3.4/32 nexthop 30.0.0.6 result = runner.invoke(config.config.commands["route"].commands["del"], \ @@ -251,33 +258,37 @@ def test_static_route_ECMP_nexthop_with_vrf(self): obj = {'config_db':db.cfgdb} ''' Add ''' + result = runner.invoke(config.config.commands["vrf"].commands["add"], ["Vrf-RED"], obj=obj) + print(result.exit_code, result.output) # config route add prefix 11.2.3.4/32 nexthop vrf Vrf-RED 30.0.0.5 result = runner.invoke(config.config.commands["route"].commands["add"], \ ["prefix", "11.2.3.4/32", "nexthop", "vrf", "Vrf-RED", "30.0.0.5"], obj=obj) print(result.exit_code, result.output) - assert ('11.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') - assert db.cfgdb.get_entry('STATIC_ROUTE', '11.2.3.4/32') == {'nexthop': '30.0.0.5', 'nexthop-vrf': 'Vrf-RED', 'blackhole': 'false', 'distance': '0', 'ifname': ''} + assert ('default', '11.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') + assert db.cfgdb.get_entry('STATIC_ROUTE', 'default|11.2.3.4/32') == {'nexthop': '30.0.0.5', 'nexthop-vrf': 'Vrf-RED', 'blackhole': 'false', 'distance': '0', 'ifname': ''} + result = runner.invoke(config.config.commands["vrf"].commands["add"], ["Vrf-BLUE"], obj=obj) + print(result.exit_code, result.output) # config route add prefix 11.2.3.4/32 nexthop vrf Vrf-BLUE 30.0.0.6 result = runner.invoke(config.config.commands["route"].commands["add"], \ ["prefix", "11.2.3.4/32", "nexthop", "vrf", "Vrf-BLUE", "30.0.0.6"], obj=obj) print(result.exit_code, result.output) - assert ('11.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') - assert db.cfgdb.get_entry('STATIC_ROUTE', '11.2.3.4/32') == {"nexthop": "30.0.0.5,30.0.0.6", "nexthop-vrf": "Vrf-RED,Vrf-BLUE", 'blackhole': 'false,false', 'distance': '0,0', 'ifname': ','} + assert ('default', '11.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') + assert db.cfgdb.get_entry('STATIC_ROUTE', 'default|11.2.3.4/32') == {"nexthop": "30.0.0.5,30.0.0.6", "nexthop-vrf": "Vrf-RED,Vrf-BLUE", 'blackhole': 'false,false', 'distance': '0,0', 'ifname': ','} ''' Del ''' # config route del prefix 11.2.3.4/32 nexthop vrf Vrf-RED 30.0.0.5 result = runner.invoke(config.config.commands["route"].commands["del"], \ ["prefix", "11.2.3.4/32", "nexthop", "vrf", "Vrf-RED", "30.0.0.5"], obj=obj) print(result.exit_code, result.output) - assert ('11.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') - assert db.cfgdb.get_entry('STATIC_ROUTE', '11.2.3.4/32') == {"nexthop": "30.0.0.6", "nexthop-vrf": "Vrf-BLUE", 'blackhole': 'false', 'distance': '0', 'ifname': ''} + assert ('default', '11.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') + assert db.cfgdb.get_entry('STATIC_ROUTE', 'default|11.2.3.4/32') == {"nexthop": "30.0.0.6", "nexthop-vrf": "Vrf-BLUE", 'blackhole': 'false', 'distance': '0', 'ifname': ''} # config route del prefix 11.2.3.4/32 nexthop vrf Vrf-BLUE 30.0.0.6 result = runner.invoke(config.config.commands["route"].commands["del"], \ ["prefix", "11.2.3.4/32", "nexthop", "vrf", "Vrf-BLUE", "30.0.0.6"], obj=obj) print(result.exit_code, result.output) - assert not ('11.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') + assert not ('default', '11.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') def test_static_route_ECMP_mixed_nextfop(self): db = Db() @@ -289,29 +300,31 @@ def test_static_route_ECMP_mixed_nextfop(self): result = runner.invoke(config.config.commands["route"].commands["add"], \ ["prefix", "12.2.3.4/32", "nexthop", "30.0.0.6"], obj=obj) print(result.exit_code, result.output) - assert ('12.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') - assert db.cfgdb.get_entry('STATIC_ROUTE', '12.2.3.4/32') == {'nexthop': '30.0.0.6', 'blackhole': 'false', 'distance': '0', 'ifname': '', 'nexthop-vrf': ''} + assert ('default', '12.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') + assert db.cfgdb.get_entry('STATIC_ROUTE', 'default|12.2.3.4/32') == {'nexthop': '30.0.0.6', 'blackhole': 'false', 'distance': '0', 'ifname': '', 'nexthop-vrf': ''} + result = runner.invoke(config.config.commands["vrf"].commands["add"], ["Vrf-RED"], obj=obj) + print(result.exit_code, result.output) # config route add prefix 12.2.3.4/32 nexthop vrf Vrf-RED 30.0.0.7 result = runner.invoke(config.config.commands["route"].commands["add"], \ ["prefix", "12.2.3.4/32", "nexthop", "vrf", "Vrf-RED", "30.0.0.7"], obj=obj) print(result.exit_code, result.output) - assert ('12.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') - assert db.cfgdb.get_entry('STATIC_ROUTE', '12.2.3.4/32') == {'nexthop': '30.0.0.6,30.0.0.7', 'nexthop-vrf': ',Vrf-RED', 'blackhole': 'false,false', 'distance': '0,0', 'ifname': ','} + assert ('default', '12.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') + assert db.cfgdb.get_entry('STATIC_ROUTE', 'default|12.2.3.4/32') == {'nexthop': '30.0.0.6,30.0.0.7', 'nexthop-vrf': ',Vrf-RED', 'blackhole': 'false,false', 'distance': '0,0', 'ifname': ','} ''' Del ''' # config route del prefix 12.2.3.4/32 nexthop vrf Vrf-Red 30.0.0.7 result = runner.invoke(config.config.commands["route"].commands["del"], \ ["prefix", "12.2.3.4/32", "nexthop", "vrf", "Vrf-RED", "30.0.0.7"], obj=obj) print(result.exit_code, result.output) - assert ('12.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') - assert db.cfgdb.get_entry('STATIC_ROUTE', '12.2.3.4/32') == {'nexthop': '30.0.0.6', 'nexthop-vrf': '', 'ifname': '', 'blackhole': 'false', 'distance': '0'} + assert ('default', '12.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') + assert db.cfgdb.get_entry('STATIC_ROUTE', 'default|12.2.3.4/32') == {'nexthop': '30.0.0.6', 'nexthop-vrf': '', 'ifname': '', 'blackhole': 'false', 'distance': '0'} # config route del prefix 12.2.3.4/32 nexthop 30.0.0.6 result = runner.invoke(config.config.commands["route"].commands["del"], \ ["prefix", "12.2.3.4/32", "nexthop", "30.0.0.6"], obj=obj) print(result.exit_code, result.output) - assert not ('12.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') + assert not ('default', '12.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') def test_del_nonexist_key_static_route(self): db = Db() @@ -322,7 +335,7 @@ def test_del_nonexist_key_static_route(self): result = runner.invoke(config.config.commands["route"].commands["del"], \ ["prefix", "17.2.3.4/32", "nexthop", "30.0.0.6"], obj=obj) print(result.exit_code, result.output) - assert ERROR_DEL_NONEXIST_KEY_STR.format("17.2.3.4/32") in result.output + assert ERROR_DEL_NONEXIST_KEY_STR.format("default|17.2.3.4/32") in result.output def test_del_nonexist_entry_static_route(self): db = Db() @@ -333,20 +346,20 @@ def test_del_nonexist_entry_static_route(self): result = runner.invoke(config.config.commands["route"].commands["add"], \ ["prefix", "13.2.3.4/32", "nexthop", "30.0.0.5"], obj=obj) print(result.exit_code, result.output) - assert ('13.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') - assert db.cfgdb.get_entry('STATIC_ROUTE', '13.2.3.4/32') == {'nexthop': '30.0.0.5', 'blackhole': 'false', 'distance': '0', 'ifname': '', 'nexthop-vrf': ''} + assert ('default', '13.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') + assert db.cfgdb.get_entry('STATIC_ROUTE', 'default|13.2.3.4/32') == {'nexthop': '30.0.0.5', 'blackhole': 'false', 'distance': '0', 'ifname': '', 'nexthop-vrf': ''} # config route del prefix 13.2.3.4/32 nexthop 30.0.0.6 <- nh ip that doesnt exist result = runner.invoke(config.config.commands["route"].commands["del"], \ ["prefix", "13.2.3.4/32", "nexthop", "30.0.0.6"], obj=obj) print(result.exit_code, result.output) - assert ERROR_DEL_NONEXIST_ENTRY_STR.format(('30.0.0.6', '', ''), "13.2.3.4/32") in result.output + assert ERROR_DEL_NONEXIST_ENTRY_STR.format(('30.0.0.6', '', ''), "default|13.2.3.4/32") in result.output # config route del prefix 13.2.3.4/32 nexthop 30.0.0.5 result = runner.invoke(config.config.commands["route"].commands["del"], \ ["prefix", "13.2.3.4/32", "nexthop", "30.0.0.5"], obj=obj) print(result.exit_code, result.output) - assert not '13.2.3.4/32' in db.cfgdb.get_table('STATIC_ROUTE') + assert not ('default', '13.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') def test_del_entire_ECMP_static_route(self): db = Db() @@ -357,20 +370,51 @@ def test_del_entire_ECMP_static_route(self): result = runner.invoke(config.config.commands["route"].commands["add"], \ ["prefix", "14.2.3.4/32", "nexthop", "30.0.0.5"], obj=obj) print(result.exit_code, result.output) - assert ('14.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') - assert db.cfgdb.get_entry('STATIC_ROUTE', '14.2.3.4/32') == {'nexthop': '30.0.0.5', 'blackhole': 'false', 'distance': '0', 'ifname': '', 'nexthop-vrf': ''} + assert ('default', '14.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') + assert db.cfgdb.get_entry('STATIC_ROUTE', 'default|14.2.3.4/32') == {'nexthop': '30.0.0.5', 'blackhole': 'false', 'distance': '0', 'ifname': '', 'nexthop-vrf': ''} # config route add prefix 14.2.3.4/32 nexthop 30.0.0.6 result = runner.invoke(config.config.commands["route"].commands["add"], \ ["prefix", "14.2.3.4/32", "nexthop", "30.0.0.6"], obj=obj) print(result.exit_code, result.output) - assert ('14.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') - assert db.cfgdb.get_entry('STATIC_ROUTE', '14.2.3.4/32') == {'nexthop': '30.0.0.5,30.0.0.6', 'nexthop-vrf': ',', 'ifname': ',', 'blackhole': 'false,false', 'distance': '0,0'} + assert ('default', '14.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') + assert db.cfgdb.get_entry('STATIC_ROUTE', 'default|14.2.3.4/32') == {'nexthop': '30.0.0.5,30.0.0.6', 'nexthop-vrf': ',', 'ifname': ',', 'blackhole': 'false,false', 'distance': '0,0'} # config route del prefix 14.2.3.4/32 result = runner.invoke(config.config.commands["route"].commands["del"], ["prefix", "14.2.3.4/32"], obj=obj) print(result.exit_code, result.output) - assert not '14.2.3.4/32' in db.cfgdb.get_table('STATIC_ROUTE') + assert not ('default', '14.2.3.4/32') in db.cfgdb.get_table('STATIC_ROUTE') + + def test_static_route_nexthop_subinterface(self): + db = Db() + runner = CliRunner() + obj = {'config_db':db.cfgdb} + + # config route add prefix 2.2.3.5/32 nexthop dev Ethernet0.10 + result = runner.invoke(config.config.commands["route"].commands["add"], \ + ["prefix", "2.2.3.5/32", "nexthop", "dev", "Ethernet0.10"], obj=obj) + print(result.exit_code, result.output) + assert ('default', '2.2.3.5/32') in db.cfgdb.get_table('STATIC_ROUTE') + assert db.cfgdb.get_entry('STATIC_ROUTE', 'default|2.2.3.5/32') == {'nexthop': '', 'blackhole': 'false', 'distance': '0', 'ifname': 'Ethernet0.10', 'nexthop-vrf': ''} + + # config route del prefix 2.2.3.5/32 nexthop dev Ethernet0.10 + result = runner.invoke(config.config.commands["route"].commands["del"], \ + ["prefix", "2.2.3.5/32", "nexthop", "dev", "Ethernet0.10"], obj=obj) + print(result.exit_code, result.output) + assert not ('default', '2.2.3.5/32') in db.cfgdb.get_table('STATIC_ROUTE') + + # config route add prefix 2.2.3.5/32 nexthop dev Eth36.10 + result = runner.invoke(config.config.commands["route"].commands["add"], \ + ["prefix", "2.2.3.5/32", "nexthop", "dev", "Eth36.10"], obj=obj) + print(result.exit_code, result.output) + assert ('default', '2.2.3.5/32') in db.cfgdb.get_table('STATIC_ROUTE') + assert db.cfgdb.get_entry('STATIC_ROUTE', 'default|2.2.3.5/32') == {'nexthop': '', 'blackhole': 'false', 'distance': '0', 'ifname': 'Eth36.10', 'nexthop-vrf': ''} + + # config route del prefix 2.2.3.5/32 nexthop dev Eth36.10 + result = runner.invoke(config.config.commands["route"].commands["del"], \ + ["prefix", "2.2.3.5/32", "nexthop", "dev", "Eth36.10"], obj=obj) + print(result.exit_code, result.output) + assert not ('default', '2.2.3.5/32') in db.cfgdb.get_table('STATIC_ROUTE') @classmethod def teardown_class(cls): diff --git a/tests/subintf_test.py b/tests/subintf_test.py new file mode 100644 index 0000000000..c69d87572e --- /dev/null +++ b/tests/subintf_test.py @@ -0,0 +1,231 @@ +import os +import traceback + +from click.testing import CliRunner + +import config.main as config +import show.main as show +from utilities_common.db import Db + +SUB_INTF_ON_LAG_MEMBER_ERR="""\ +Usage: add [OPTIONS] +Try "add --help" for help. + +Error: Ethernet32 is configured as a member of portchannel. Cannot configure subinterface +""" + +class TestSubinterface(object): + @classmethod + def setup_class(cls): + os.environ['UTILITIES_UNIT_TESTING'] = "1" + print("SETUP") + + def test_add_del_subintf_short_name(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + result = runner.invoke(config.config.commands["subinterface"].commands["add"], ["Eth0.102", "1002"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code == 0 + assert ('Eth0.102') in db.cfgdb.get_table('VLAN_SUB_INTERFACE') + assert db.cfgdb.get_table('VLAN_SUB_INTERFACE')['Eth0.102']['vlan'] == '1002' + assert db.cfgdb.get_table('VLAN_SUB_INTERFACE')['Eth0.102']['admin_status'] == 'up' + + result = runner.invoke(config.config.commands["subinterface"].commands["add"], ["Po0004.104", "1004"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code == 0 + assert ('Po0004.104') in db.cfgdb.get_table('VLAN_SUB_INTERFACE') + assert db.cfgdb.get_table('VLAN_SUB_INTERFACE')['Po0004.104']['vlan'] == '1004' + assert db.cfgdb.get_table('VLAN_SUB_INTERFACE')['Po0004.104']['admin_status'] == 'up' + + result = runner.invoke(config.config.commands["subinterface"].commands["del"], ["Eth0.102"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code == 0 + assert ('Eth0.102') not in db.cfgdb.get_table('VLAN_SUB_INTERFACE') + + result = runner.invoke(config.config.commands["subinterface"].commands["del"], ["Po0004.104"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code == 0 + assert ('Po0004.104') not in db.cfgdb.get_table('VLAN_SUB_INTERFACE') + + def test_add_del_subintf_with_long_name(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + result = runner.invoke(config.config.commands["subinterface"].commands["add"], ["Ethernet0.102"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code == 0 + assert ('Ethernet0.102') in db.cfgdb.get_table('VLAN_SUB_INTERFACE') + assert db.cfgdb.get_table('VLAN_SUB_INTERFACE')['Ethernet0.102']['admin_status'] == 'up' + + result = runner.invoke(config.config.commands["subinterface"].commands["add"], ["PortChannel0004.104"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code == 0 + assert ('PortChannel0004.104') in db.cfgdb.get_table('VLAN_SUB_INTERFACE') + assert db.cfgdb.get_table('VLAN_SUB_INTERFACE')['PortChannel0004.104']['admin_status'] == 'up' + + result = runner.invoke(config.config.commands["subinterface"].commands["del"], ["Ethernet0.102"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code == 0 + assert ('Ethernet0.102') not in db.cfgdb.get_table('VLAN_SUB_INTERFACE') + + result = runner.invoke(config.config.commands["subinterface"].commands["del"], ["PortChannel0004.104"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code == 0 + assert ('PortChannel0004.104') not in db.cfgdb.get_table('VLAN_SUB_INTERFACE') + + + def test_add_existing_subintf_again(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + result = runner.invoke(config.config.commands["subinterface"].commands["add"], ["Ethernet0.102"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code == 0 + assert ('Ethernet0.102') in db.cfgdb.get_table('VLAN_SUB_INTERFACE') + assert db.cfgdb.get_table('VLAN_SUB_INTERFACE')['Ethernet0.102']['admin_status'] == 'up' + + #Check if same long format subintf creation is rejected + result = runner.invoke(config.config.commands["subinterface"].commands["add"], ["Ethernet0.102"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code != 0 + + #Check if same short format subintf creation with same encap vlan is rejected + result = runner.invoke(config.config.commands["subinterface"].commands["add"], ["Eth0.1002", "102"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code != 0 + assert ('Eth0.1002') not in db.cfgdb.get_table('VLAN_SUB_INTERFACE') + + + def test_delete_non_existing_subintf(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + result = runner.invoke(config.config.commands["subinterface"].commands["del"], ["Ethernet0.102"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code != 0 + + result = runner.invoke(config.config.commands["subinterface"].commands["del"], ["Eth0.102"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code != 0 + + result = runner.invoke(config.config.commands["subinterface"].commands["del"], ["PortChannel0004.104"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code != 0 + + result = runner.invoke(config.config.commands["subinterface"].commands["del"], ["Po0004.104"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code != 0 + + def test_invalid_subintf_creation(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + result = runner.invoke(config.config.commands["subinterface"].commands["add"], ["Ethernet1000.102"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code != 0 + + result = runner.invoke(config.config.commands["subinterface"].commands["add"], ["PortChannel0008.102"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code != 0 + + result = runner.invoke(config.config.commands["subinterface"].commands["add"], ["Ethe0.102"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code != 0 + + #Short format subintf without encap vlan should be rejected + result = runner.invoke(config.config.commands["subinterface"].commands["add"], ["Eth0.102"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code != 0 + + result = runner.invoke(config.config.commands["subinterface"].commands["add"], ["Po0004.102"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code != 0 + + def test_subintf_creation_on_lag_member(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + result = runner.invoke(config.config.commands["subinterface"].commands["add"], ["Ethernet32.10"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code != 0 + assert(result.output == SUB_INTF_ON_LAG_MEMBER_ERR) + + result = runner.invoke(config.config.commands["subinterface"].commands["add"], ["Eth32.20"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code != 0 + assert(result.output == SUB_INTF_ON_LAG_MEMBER_ERR) + + def test_subintf_vrf_bind_unbind(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + result = runner.invoke(config.config.commands["subinterface"].commands["add"], ["Ethernet0.102"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code == 0 + assert ('Ethernet0.102') in db.cfgdb.get_table('VLAN_SUB_INTERFACE') + assert db.cfgdb.get_table('VLAN_SUB_INTERFACE')['Ethernet0.102']['admin_status'] == 'up' + + vrf_obj = {'config_db':db.cfgdb, 'namespace':db.db.namespace} + result = runner.invoke(config.config.commands["interface"].commands["vrf"].commands["bind"], ["Ethernet0.102", "Vrf1"], obj=vrf_obj) + assert result.exit_code == 0 + assert ('Vrf1') in db.cfgdb.get_table('VLAN_SUB_INTERFACE')['Ethernet0.102']['vrf_name'] + + result = runner.invoke(config.config.commands["interface"].commands["vrf"].commands["unbind"], ["Ethernet0.102"], obj=vrf_obj) + assert result.exit_code == 0 + assert ('vrf_name') not in db.cfgdb.get_table('VLAN_SUB_INTERFACE')['Ethernet0.102'] + + result = runner.invoke(config.config.commands["subinterface"].commands["del"], ["Ethernet0.102"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code == 0 + assert ('Ethernet0.102') not in db.cfgdb.get_table('VLAN_SUB_INTERFACE') + + #shut name subintf vrf bind unbind check + result = runner.invoke(config.config.commands["subinterface"].commands["add"], ["Eth0.1002", "2002"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code == 0 + assert ('Eth0.1002') in db.cfgdb.get_table('VLAN_SUB_INTERFACE') + + result = runner.invoke(config.config.commands["interface"].commands["vrf"].commands["bind"], ["Eth0.1002", "Vrf1"], obj=vrf_obj) + assert result.exit_code == 0 + assert ('Vrf1') in db.cfgdb.get_table('VLAN_SUB_INTERFACE')['Eth0.1002']['vrf_name'] + + result = runner.invoke(config.config.commands["interface"].commands["vrf"].commands["unbind"], ["Eth0.1002"], obj=vrf_obj) + assert result.exit_code == 0 + assert ('vrf_name') not in db.cfgdb.get_table('VLAN_SUB_INTERFACE')['Eth0.1002'] + + result = runner.invoke(config.config.commands["subinterface"].commands["del"], ["Eth0.1002"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code == 0 + assert ('Eth0.1002') not in db.cfgdb.get_table('VLAN_SUB_INTERFACE') + + #Po subintf vrf bind unbind check + result = runner.invoke(config.config.commands["subinterface"].commands["add"], ["Po0004.1004", "2004"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code == 0 + assert ('Po0004.1004') in db.cfgdb.get_table('VLAN_SUB_INTERFACE') + + result = runner.invoke(config.config.commands["interface"].commands["vrf"].commands["bind"], ["Po0004.1004", "Vrf1"], obj=vrf_obj) + assert result.exit_code == 0 + assert ('Vrf1') in db.cfgdb.get_table('VLAN_SUB_INTERFACE')['Po0004.1004']['vrf_name'] + + result = runner.invoke(config.config.commands["interface"].commands["vrf"].commands["unbind"], ["Po0004.1004"], obj=vrf_obj) + assert result.exit_code == 0 + assert ('vrf_name') not in db.cfgdb.get_table('VLAN_SUB_INTERFACE')['Po0004.1004'] + + result = runner.invoke(config.config.commands["subinterface"].commands["del"], ["Po0004.1004"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code == 0 + assert ('Po0004.1004') not in db.cfgdb.get_table('VLAN_SUB_INTERFACE') + + @classmethod + def teardown_class(cls): + os.environ['UTILITIES_UNIT_TESTING'] = "0" + print("TEARDOWN") diff --git a/tests/techsupport_test.py b/tests/techsupport_test.py index 64bc133627..8effa89887 100644 --- a/tests/techsupport_test.py +++ b/tests/techsupport_test.py @@ -3,18 +3,18 @@ from unittest.mock import patch, Mock from click.testing import CliRunner -EXPECTED_BASE_COMMAND = 'sudo timeout --kill-after=300s -s SIGTERM --foreground ' +EXPECTED_BASE_COMMAND = 'sudo ' @patch("show.main.run_command") @pytest.mark.parametrize( "cli_arguments,expected", [ - ([], '30m generate_dump -v -t 5'), - (['--since', '2 days ago'], "30m generate_dump -v -s '2 days ago' -t 5"), - (['-g', '50'], '50m generate_dump -v -t 5'), - (['--allow-process-stop'], '30m -a generate_dump -v -t 5'), - (['--silent'], '30m generate_dump -t 5'), - (['--debug-dump', '--redirect-stderr'], '30m generate_dump -v -d -t 5 -r'), + ([], 'generate_dump -v -t 5'), + (['--since', '2 days ago'], "generate_dump -v -s '2 days ago' -t 5"), + (['-g', '50'], 'timeout --kill-after=300s -s SIGTERM --foreground 50m generate_dump -v -t 5'), + (['--allow-process-stop'], '-a generate_dump -v -t 5'), + (['--silent'], 'generate_dump -t 5'), + (['--debug-dump', '--redirect-stderr'], 'generate_dump -v -d -t 5 -r'), ] ) def test_techsupport(run_command, cli_arguments, expected): diff --git a/tests/test_sonic_installer.py b/tests/test_sonic_installer.py new file mode 100644 index 0000000000..c445dfb6e3 --- /dev/null +++ b/tests/test_sonic_installer.py @@ -0,0 +1,116 @@ +import os +from contextlib import contextmanager +from sonic_installer.main import sonic_installer +from click.testing import CliRunner +from unittest.mock import patch, Mock, call + +@patch("sonic_installer.main.SWAPAllocator") +@patch("sonic_installer.main.get_bootloader") +@patch("sonic_installer.main.run_command_or_raise") +@patch("sonic_installer.main.run_command") +def test_install(run_command, run_command_or_raise, get_bootloader, swap, fs): + """ This test covers the execution of "sonic-installer install" command. """ + + sonic_image_filename = "sonic.bin" + current_image_version = "image_1" + new_image_version = "image_2" + new_image_folder = f"/images/{new_image_version}" + image_docker_folder = os.path.join(new_image_folder, "docker") + mounted_image_folder = f"/tmp/image-{new_image_version}-fs" + dockerd_opts = ["--iptables=false", "--bip=1.1.1.1/24"] + + # Setup mock files needed for our test scenario + fs.create_file(sonic_image_filename) + fs.create_dir(image_docker_folder) + fs.create_dir(os.path.join(mounted_image_folder, "usr/lib/docker/docker.sh")) + fs.create_file("/var/run/docker.pid", contents="15") + fs.create_file("/proc/15/cmdline", contents="\x00".join(["dockerd"] + dockerd_opts)) + + # Setup bootloader mock + mock_bootloader = Mock() + mock_bootloader.get_binary_image_version = Mock(return_value=new_image_version) + mock_bootloader.get_installed_images = Mock(return_value=[current_image_version]) + mock_bootloader.get_image_path = Mock(return_value=new_image_folder) + + @contextmanager + def rootfs_path_mock(path): + yield mounted_image_folder + + mock_bootloader.get_rootfs_path = rootfs_path_mock + get_bootloader.return_value=mock_bootloader + + # Invoke CLI command + runner = CliRunner() + result = runner.invoke(sonic_installer.commands["install"], [sonic_image_filename, "-y"]) + print(result.output) + + assert result.exit_code == 0 + + # Assert bootloader install API was called + mock_bootloader.install_image.assert_called_with(f"./{sonic_image_filename}") + # Assert all below commands were called, so we ensure that + # 1. update SONiC environment works + # 2. package migration works + expected_call_list = [ + call(["mkdir", "-p", mounted_image_folder]), + call(["mount", "-t", "squashfs", mounted_image_folder, mounted_image_folder]), + call(["sonic-cfggen", "-d", "-y", f"{mounted_image_folder}/etc/sonic/sonic_version.yml", "-t", f"{mounted_image_folder}/usr/share/sonic/templates/sonic-environment.j2"]), + call(["umount", "-r", "-f", mounted_image_folder], raise_exception=True), + call(["rm", "-rf", mounted_image_folder], raise_exception=True), + call(["mkdir", "-p", mounted_image_folder]), + call(["mount", "-t", "squashfs", mounted_image_folder, mounted_image_folder]), + call(["mkdir", "-p", f"{new_image_folder}/rw"]), + call(["mkdir", "-p", f"{new_image_folder}/work"]), + call(["mkdir", "-p", mounted_image_folder]), + call(["mount", "overlay", "-t", "overlay", "-o", f"rw,relatime,lowerdir={mounted_image_folder},upperdir={new_image_folder}/rw,workdir={new_image_folder}/work", mounted_image_folder]), + call(["mkdir", "-p", f"{mounted_image_folder}/var/lib/docker"]), + call(["mount", "--bind", f"{new_image_folder}/docker", f"{mounted_image_folder}/var/lib/docker"]), + call(["chroot", mounted_image_folder, "mount", "proc", "/proc", "-t", "proc"]), + call(["chroot", mounted_image_folder, "mount", "sysfs", "/sys", "-t", "sysfs"]), + call(["cp", f"{mounted_image_folder}/etc/default/docker", f"{mounted_image_folder}/tmp/docker_config_backup"]), + call(["sh", "-c", f"echo 'DOCKER_OPTS=\"$DOCKER_OPTS {' '.join(dockerd_opts)}\"' >> {mounted_image_folder}/etc/default/docker"]), # dockerd started with added options as host dockerd + call(["chroot", mounted_image_folder, "/usr/lib/docker/docker.sh", "start"]), + call(["cp", "/var/lib/sonic-package-manager/packages.json", f"{mounted_image_folder}/tmp/packages.json"]), + call(["touch", f"{mounted_image_folder}/tmp/docker.sock"]), + call(["mount", "--bind", "/var/run/docker.sock", f"{mounted_image_folder}/tmp/docker.sock"]), + call(["cp", f"{mounted_image_folder}/etc/resolv.conf", "/tmp/resolv.conf.backup"]), + call(["cp", "/etc/resolv.conf", f"{mounted_image_folder}/etc/resolv.conf"]), + call(["chroot", mounted_image_folder, "sh", "-c", "command -v sonic-package-manager"]), + call(["chroot", mounted_image_folder, "sonic-package-manager", "migrate", "/tmp/packages.json", "--dockerd-socket", "/tmp/docker.sock", "-y"]), + call(["chroot", mounted_image_folder, "/usr/lib/docker/docker.sh", "stop"], raise_exception=False), + call(["cp", "/tmp/resolv.conf.backup", f"{mounted_image_folder}/etc/resolv.conf"], raise_exception=False), + call(["umount", "-f", "-R", mounted_image_folder], raise_exception=False), + call(["umount", "-r", "-f", mounted_image_folder], raise_exception=False), + call(["rm", "-rf", mounted_image_folder], raise_exception=False), + ] + assert run_command_or_raise.call_args_list == expected_call_list + +@patch("sonic_installer.main.get_bootloader") +def test_set_fips(get_bootloader): + """ This test covers the execution of "sonic-installer set-fips/get-fips" command. """ + + image = "image_1" + next_image = "image_2" + + # Setup bootloader mock + mock_bootloader = Mock() + mock_bootloader.get_next_image = Mock(return_value=next_image) + mock_bootloader.get_installed_images = Mock(return_value=[image, next_image]) + mock_bootloader.set_fips = Mock() + mock_bootloader.get_fips = Mock(return_value=False) + get_bootloader.return_value=mock_bootloader + + runner = CliRunner() + + # Test set-fips command options: --enable-fips/--disable-fips + result = runner.invoke(sonic_installer.commands["set-fips"], [next_image, '--enable-fips']) + assert 'Set FIPS' in result.output + result = runner.invoke(sonic_installer.commands["set-fips"], ['--disable-fips']) + assert 'Set FIPS' in result.output + + # Test command get-fips options + result = runner.invoke(sonic_installer.commands["get-fips"]) + assert "FIPS is disabled" in result.output + mock_bootloader.get_fips = Mock(return_value=True) + result = runner.invoke(sonic_installer.commands["get-fips"], [next_image]) + assert "FIPS is enabled" in result.output diff --git a/tests/vlan_test.py b/tests/vlan_test.py index a7f533a824..66ec3606cf 100644 --- a/tests/vlan_test.py +++ b/tests/vlan_test.py @@ -8,6 +8,7 @@ import show.main as show from utilities_common.db import Db from importlib import reload +import utilities_common.bgp_util as bgp_util show_vlan_brief_output="""\ +-----------+-----------------+-----------------+----------------+-------------+ @@ -143,16 +144,23 @@ +-----------+-----------------+-----------------+----------------+-------------+ """ class TestVlan(object): + _old_run_bgp_command = None @classmethod def setup_class(cls): os.environ['UTILITIES_UNIT_TESTING'] = "1" # ensure that we are working with single asic config + cls._old_run_bgp_command = bgp_util.run_bgp_command + bgp_util.run_bgp_command = mock.MagicMock( + return_value=cls.mock_run_bgp_command()) from .mock_tables import dbconnector from .mock_tables import mock_single_asic reload(mock_single_asic) dbconnector.load_namespace_config() print("SETUP") + def mock_run_bgp_command(): + return "" + def test_show_vlan(self): runner = CliRunner() result = runner.invoke(show.cli.commands["vlan"], []) @@ -311,6 +319,30 @@ def test_config_vlan_add_rif_portchannel_member(self): assert result.exit_code != 0 assert "Error: PortChannel0001 is a router interface!" in result.output + def test_config_vlan_with_vxlanmap_del_vlan(self): + runner = CliRunner() + db = Db() + obj = {'config_db': db.cfgdb} + + # create vlan + result = runner.invoke(config.config.commands["vlan"].commands["add"], ["1027"], obj=db) + print(result.exit_code) + print(result.output) + assert result.exit_code == 0 + + # create vxlan map + result = runner.invoke(config.config.commands["vxlan"].commands["map"].commands["add"], ["vtep1", "1027", "11027"], obj=db) + print(result.exit_code) + print(result.output) + assert result.exit_code == 0 + + # attempt to del vlan with vxlan map, should fail + result = runner.invoke(config.config.commands["vlan"].commands["del"], ["1027"], obj=db) + print(result.exit_code) + print(result.output) + assert result.exit_code != 0 + assert "Error: vlan: 1027 can not be removed. First remove vxlan mapping" in result.output + def test_config_vlan_del_vlan(self): runner = CliRunner() db = Db() @@ -555,4 +587,5 @@ def test_config_vlan_add_member_of_portchannel(self): @classmethod def teardown_class(cls): os.environ['UTILITIES_UNIT_TESTING'] = "0" + bgp_util.run_bgp_command = cls._old_run_bgp_command print("TEARDOWN") diff --git a/tests/vnet_input/config_db.json b/tests/vnet_input/config_db.json new file mode 100644 index 0000000000..51a75b39c9 --- /dev/null +++ b/tests/vnet_input/config_db.json @@ -0,0 +1,10 @@ +{ + "VNET|Vnet_2000": { + "peer_list": "", + "vni": "2000", + "vxlan_tunnel": "tunnel1" + }, + "VXLAN_TUNNEL|tunnel1": { + "src_ip": "10.10.10.10" + } +} diff --git a/tests/vnet_route_check_test.py b/tests/vnet_route_check_test.py index 09f35761a4..092a89e2f9 100644 --- a/tests/vnet_route_check_test.py +++ b/tests/vnet_route_check_test.py @@ -27,7 +27,7 @@ VNET_ROUTE_TABLE = "VNET_ROUTE_TABLE" INTF_TABLE = "INTF_TABLE" ASIC_STATE = "ASIC_STATE" - +VNET_ROUTE_TUNNEL_TABLE = "VNET_ROUTE_TUNNEL_TABLE" RT_ENTRY_KEY_PREFIX = 'SAI_OBJECT_TYPE_ROUTE_ENTRY:{\"dest":\"' RT_ENTRY_KEY_SUFFIX = '\",\"switch_id\":\"oid:0x21000000000000\",\"vr\":\"oid:0x3000000000d4b\"}' @@ -72,9 +72,6 @@ CNTR_DB: { "COUNTERS_RIF_NAME_MAP": { "Vlan3001": "oid:0x6000000000d76" } } - }, - RESULT: { - "results": {} } }, "1": { @@ -223,6 +220,91 @@ } } } + }, + "4": { + DESCR: "All tunnel routes are configured in both APP and ASIC DB", + ARGS: "vnet_route_check", + PRE: { + APPL_DB: { + VXLAN_TUNNEL_TABLE: { + "tunnel_v4": { "src_ip": "10.1.0.32" }, + "tunnel_v6": { "src_ip": "3001:2000::1" } + }, + VNET_TABLE: { + "Vnet_v4_in_v4-0": [("vxlan_tunnel", "tunnel_v4"), ("scope", "default"), ("vni", "10000"), ("peer_list", "")], + "Vnet_v6_in_v6-0": [("vxlan_tunnel", "tunnel_v6"), ("scope", "default"), ("vni", "10002"), ("peer_list", "")] + + }, + VNET_ROUTE_TUNNEL_TABLE: { + "Vnet_v4_in_v4-0:150.62.191.1/32" : { "endpoint" : "100.251.7.1,100.251.7.2" }, + "Vnet_v6_in_v6-0:fd01:fc00::1/128" : { "endpoint" : "fc02:1000::1,fc02:1000::2" } + + } + }, + ASIC_DB: { + "ASIC_STATE:SAI_OBJECT_TYPE_VIRTUAL_ROUTER": { + "oid:0x3000000000d4b" : { "":"" } + }, + ASIC_STATE: { + RT_ENTRY_KEY_PREFIX + "150.62.191.1/32" + RT_ENTRY_KEY_SUFFIX: {}, + RT_ENTRY_KEY_PREFIX + "fd01:fc00::1/128" + RT_ENTRY_KEY_SUFFIX: {} + } + } + } + }, + "5": { + DESCR: "Tunnel route present in APP DB but mssing in ASIC DB", + ARGS: "vnet_route_check", + RET: -1, + PRE: { + APPL_DB: { + VXLAN_TUNNEL_TABLE: { + "tunnel_v4": { "src_ip": "10.1.0.32" } + }, + VNET_TABLE: { + "Vnet_v4_in_v4-0": [("vxlan_tunnel", "tunnel_v4"), ("scope", "default"), ("vni", "10000"), ("peer_list", "")] + }, + VNET_ROUTE_TUNNEL_TABLE: { + "Vnet_v4_in_v4-0:150.62.191.1/32" : { "endpoint" : "100.251.7.1,100.251.7.2" } + } + }, + ASIC_DB: { + "ASIC_STATE:SAI_OBJECT_TYPE_VIRTUAL_ROUTER": { + "oid:0x3000000000d4b" : { "":"" } + }, + ASIC_STATE: { + } + } + }, + RESULT: { + "results": { + "missed_in_asic_db_routes": { + "Vnet_v4_in_v4-0": { + "routes": [ + "150.62.191.1/32" + ] + } + } + } + } + }, + "6": { + DESCR: "Only Vxlan tunnel configured, No routes.", + ARGS: "vnet_route_check", + PRE: { + APPL_DB: { + VXLAN_TUNNEL_TABLE: { + "tunnel_v4": { "src_ip": "10.1.0.32" } + }, + VNET_TABLE: { + "Vnet1": { "vxlan_tunnel": "tunnel_v4", "vni": "10001" } + }, + INTF_TABLE: { + "Vlan3001": { "vnet_name": "Vnet1" }, + "Vlan3001:30.1.10.1/24": {} + }, + }, + } } } @@ -254,7 +336,7 @@ def getKeys(self): return list(self.data.keys()) def get(self, key): - ret = copy.deepcopy(self.data.get(key, {})) + ret = copy.deepcopy(self.data.get(key, self.data)) return (True, ret) @@ -314,9 +396,15 @@ def test_vnet_route_check(self, mock_table, mock_conn): do_start_test("route_test", i, ct_data) with patch('sys.argv', ct_data[ARGS].split()): - ret, res = vnet_route_check.main() expect_ret = ct_data[RET] if RET in ct_data else 0 expect_res = ct_data[RESULT] if RESULT in ct_data else None + res = None + if expect_ret == 0: + ret = vnet_route_check.main() + if ret != 0: + ret, res = vnet_route_check.main() + else: + ret, res = vnet_route_check.main() if res: print("res={}".format(json.dumps(res, indent=4))) if expect_res: diff --git a/tests/vrf_input/config_db.json b/tests/vrf_input/config_db.json index 6d646f2f2b..1746c14c4f 100644 --- a/tests/vrf_input/config_db.json +++ b/tests/vrf_input/config_db.json @@ -3,11 +3,16 @@ "vrf_name": "Vrf101", "admin_status": "up" }, - "VLAN_SUB_INTERFACE|Eth32.10": { + "VLAN_SUB_INTERFACE|Eth36.10": { "vrf_name": "Vrf102", "admin_status": "up", "vlan": "100" }, + "VLAN_SUB_INTERFACE|Po0002.101": { + "vrf_name": "Vrf103", + "admin_status": "up", + "vlan": "1001" + }, "VLAN_INTERFACE|Vlan40": { "vrf_name": "Vrf102" }, diff --git a/tests/vrf_test.py b/tests/vrf_test.py new file mode 100644 index 0000000000..d2443b3c3d --- /dev/null +++ b/tests/vrf_test.py @@ -0,0 +1,159 @@ +import os +import sys +from click.testing import CliRunner +from swsscommon.swsscommon import SonicV2Connector +from utilities_common.db import Db + +import config.main as config +import show.main as show +import threading + +DEFAULT_NAMESPACE = '' +test_path = os.path.dirname(os.path.abspath(__file__)) +mock_db_path = os.path.join(test_path, "vrf_input") + +class TestShowVrf(object): + @classmethod + def setup_class(cls): + print("SETUP") + os.environ["UTILITIES_UNIT_TESTING"] = "1" + + def update_statedb(self, db, db_name, key): + import time + time.sleep(0.5) + db.delete(db_name, key) + + def test_vrf_show(self): + from .mock_tables import dbconnector + jsonfile_config = os.path.join(mock_db_path, "config_db") + dbconnector.dedicated_dbs['CONFIG_DB'] = jsonfile_config + runner = CliRunner() + db = Db() + expected_output = """\ +VRF Interfaces +------ --------------- +Vrf1 +Vrf101 Ethernet0.10 +Vrf102 PortChannel0002 + Vlan40 + Eth36.10 +Vrf103 Ethernet4 + Loopback0 + Po0002.101 +""" + + result = runner.invoke(show.cli.commands['vrf'], [], obj=db) + dbconnector.dedicated_dbs = {} + assert result.exit_code == 0 + assert result.output == expected_output + + def test_vrf_bind_unbind(self): + from .mock_tables import dbconnector + jsonfile_config = os.path.join(mock_db_path, "config_db") + dbconnector.dedicated_dbs['CONFIG_DB'] = jsonfile_config + runner = CliRunner() + db = Db() + expected_output = """\ +VRF Interfaces +------ --------------- +Vrf1 +Vrf101 Ethernet0.10 +Vrf102 PortChannel0002 + Vlan40 + Eth36.10 +Vrf103 Ethernet4 + Loopback0 + Po0002.101 +""" + + result = runner.invoke(show.cli.commands['vrf'], [], obj=db) + dbconnector.dedicated_dbs = {} + assert result.exit_code == 0 + assert result.output == expected_output + + + vrf_obj = {'config_db':db.cfgdb, 'namespace':db.db.namespace} + + result = runner.invoke(config.config.commands["interface"].commands["vrf"].commands["unbind"], ["Ethernet4"], obj=vrf_obj) + + print(result.exit_code, result.output) + assert result.exit_code == 0 + assert 'Ethernet4' not in db.cfgdb.get_table('INTERFACE') + + result = runner.invoke(config.config.commands["interface"].commands["vrf"].commands["unbind"], ["Loopback0"], obj=vrf_obj) + + print(result.exit_code, result.output) + assert result.exit_code == 0 + assert 'Loopback0' not in db.cfgdb.get_table('LOOPBACK_INTERFACE') + + + result = runner.invoke(config.config.commands["interface"].commands["vrf"].commands["unbind"], ["Vlan40"], obj=vrf_obj) + + print(result.exit_code, result.output) + assert result.exit_code == 0 + assert 'Vlan40' not in db.cfgdb.get_table('VLAN_INTERFACE') + + result = runner.invoke(config.config.commands["interface"].commands["vrf"].commands["unbind"], ["PortChannel0002"], obj=vrf_obj) + + print(result.exit_code, result.output) + assert result.exit_code == 0 + assert 'PortChannel002' not in db.cfgdb.get_table('PORTCHANNEL_INTERFACE') + + vrf_obj = {'config_db':db.cfgdb, 'namespace':DEFAULT_NAMESPACE} + state_db = SonicV2Connector(use_unix_socket_path=True, namespace='') + state_db.connect(state_db.STATE_DB, False) + _hash = "INTERFACE_TABLE|Eth36.10" + state_db.set(db.db.STATE_DB, _hash, "state", "ok") + vrf_obj['state_db'] = state_db + + T1 = threading.Thread( target = self.update_statedb, args = (state_db, db.db.STATE_DB, _hash)) + T1.start() + result = runner.invoke(config.config.commands["interface"].commands["vrf"].commands["unbind"], ["Eth36.10"], obj=vrf_obj) + T1.join() + print(result.exit_code, result.output) + assert result.exit_code == 0 + assert ('vrf_name', 'Vrf102') not in db.cfgdb.get_table('VLAN_SUB_INTERFACE')['Eth36.10'] + + vrf_obj = {'config_db':db.cfgdb, 'namespace':DEFAULT_NAMESPACE} + + + result = runner.invoke(config.config.commands["interface"].commands["vrf"].commands["unbind"], ["Ethernet0.10"], obj=vrf_obj) + + print(result.exit_code, result.output) + assert result.exit_code == 0 + assert ('vrf_name', 'Vrf101') not in db.cfgdb.get_table('VLAN_SUB_INTERFACE')['Ethernet0.10'] + + + result = runner.invoke(config.config.commands["interface"].commands["vrf"].commands["unbind"], ["Po0002.101"], obj=vrf_obj) + + print(result.exit_code, result.output) + assert result.exit_code == 0 + assert ('vrf_name', 'Vrf103') not in db.cfgdb.get_table('VLAN_SUB_INTERFACE')['Po0002.101'] + + result = runner.invoke(config.config.commands["interface"].commands["vrf"].commands["bind"], ["Ethernet0", "Vrf1"], obj=vrf_obj) + assert result.exit_code == 0 + assert ('Vrf1') in db.cfgdb.get_table('INTERFACE')['Ethernet0']['vrf_name'] + + + #Bind click CLI cannot be tested as it tries to connecte to statedb + #for verification of all IP address delete before applying new vrf configuration + jsonfile_config = os.path.join(mock_db_path, "config_db") + dbconnector.dedicated_dbs['CONFIG_DB'] = jsonfile_config + + expected_output = """\ +VRF Interfaces +------ --------------- +Vrf1 +Vrf101 Ethernet0.10 +Vrf102 PortChannel0002 + Vlan40 + Eth36.10 +Vrf103 Ethernet4 + Loopback0 + Po0002.101 +""" + + result = runner.invoke(show.cli.commands['vrf'], [], obj=db) + dbconnector.dedicated_dbs = {} + assert result.exit_code == 0 + assert result.output == expected_output diff --git a/tests/vxlan_test.py b/tests/vxlan_test.py index 5541a6e84a..61c78dc429 100644 --- a/tests/vxlan_test.py +++ b/tests/vxlan_test.py @@ -7,6 +7,10 @@ import config.main as config import show.main as show from utilities_common.db import Db +from .mock_tables import dbconnector + +test_path = os.path.dirname(os.path.abspath(__file__)) +mock_db_path = os.path.join(test_path, "vnet_input") show_vxlan_interface_output="""\ VTEP Information: @@ -56,6 +60,15 @@ """ +show_vxlan_name_output="""\ +vxlan tunnel name source ip destination ip tunnel map name tunnel map mapping(vni -> vlan) +------------------- ----------- ---------------- ----------------- --------------------------------- +vtep1 1.1.1.1 map_100_Vlan100 100 -> Vlan100 + map_101_Vlan101 101 -> Vlan101 + map_102_Vlan102 102 -> Vlan102 + map_200_Vlan200 200 -> Vlan200 +""" + show_vxlan_remotevni_output="""\ +---------+--------------+-------+ | VLAN | RemoteVTEP | VNI | @@ -99,6 +112,38 @@ """ +show_vxlan_remotemac_all_output="""\ ++---------+-------------------+--------------+-------+---------+ +| VLAN | MAC | RemoteVTEP | VNI | Type | ++=========+===================+==============+=======+=========+ +| Vlan200 | 00:02:00:00:47:e2 | 2.2.2.2 | 200 | dynamic | ++---------+-------------------+--------------+-------+---------+ +| Vlan200 | 00:02:00:00:47:e3 | 2.2.2.3 | 200 | dynamic | ++---------+-------------------+--------------+-------+---------+ +Total count : 2 + +""" + +show_vxlan_remotemac_specific_output="""\ ++---------+-------------------+--------------+-------+---------+ +| VLAN | MAC | RemoteVTEP | VNI | Type | ++=========+===================+==============+=======+=========+ +| Vlan200 | 00:02:00:00:47:e2 | 2.2.2.2 | 200 | dynamic | ++---------+-------------------+--------------+-------+---------+ +Total count : 1 + +""" + +show_vxlan_remotemac_cnt_output="""\ +Total count : 2 + +""" + +show_vxlan_remotemac_specific_cnt_output="""\ +Total count : 1 + +""" + class TestVxlan(object): @classmethod def setup_class(cls): @@ -137,6 +182,22 @@ def test_show_vxlan_tunnel(self): assert result.exit_code == 0 assert result.output == show_vxlan_tunnel_output + def test_show_vxlan_tunnel_output(self): + runner = CliRunner() + result = runner.invoke(show.cli.commands["vxlan"].commands["tunnel"], []) + print(result.exit_code) + print(result.output) + assert result.exit_code == 0 + assert result.output == show_vxlan_name_output + + def test_show_vxlan_name_vtep(self): + runner = CliRunner() + result = runner.invoke(show.cli.commands["vxlan"].commands["name"],["vtep1"]) + print(result.exit_code) + print(result.output) + assert result.exit_code == 0 + assert result.output == show_vxlan_name_output + def test_show_vxlan_remotevni(self): runner = CliRunner() result = runner.invoke(show.cli.commands["vxlan"].commands["remotevni"], ["all"]) @@ -186,6 +247,38 @@ def test_show_vxlan_remotevni_specific_cnt(self): assert result.exit_code == 0 assert result.output == show_vxlan_remotevni_specific_cnt_output + def test_show_vxlan_remotemac(self): + runner = CliRunner() + result = runner.invoke(show.cli.commands["vxlan"].commands["remotemac"], ["all"]) + print(result.exit_code) + print(result.output) + assert result.exit_code == 0 + assert result.output == show_vxlan_remotemac_all_output + + def test_show_vxlan_remotemac_specific(self): + runner = CliRunner() + result = runner.invoke(show.cli.commands["vxlan"].commands["remotemac"], ["2.2.2.2"]) + print(result.exit_code) + print(result.output) + assert result.exit_code == 0 + assert result.output == show_vxlan_remotemac_specific_output + + def test_show_vxlan_remotemac_cnt(self): + runner = CliRunner() + result = runner.invoke(show.cli.commands["vxlan"].commands["remotemac"], ["all", "count"]) + print(result.exit_code) + print(result.output) + assert result.exit_code == 0 + assert result.output == show_vxlan_remotemac_cnt_output + + def test_show_vxlan_remotemac_specific_cnt(self): + runner = CliRunner() + result = runner.invoke(show.cli.commands["vxlan"].commands["remotemac"], ["2.2.2.2", "count"]) + print(result.exit_code) + print(result.output) + assert result.exit_code == 0 + assert result.output == show_vxlan_remotemac_specific_cnt_output + def test_config_vxlan_add(self): runner = CliRunner() db = Db() @@ -247,6 +340,24 @@ def test_config_vxlan_add(self): assert result.exit_code == 0 assert result.output == show_vxlan_vlanvnimap_output + def test_config_vxlan_del(self): + dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'config_db') + db = Db() + runner = CliRunner() + + result = runner.invoke(config.config.commands["vxlan"].commands["del"], ["tunnel_invalid"], obj=db) + print(result.exit_code) + print(result.output) + assert result.exit_code != 0 + assert "Error: Vxlan tunnel tunnel_invalid does not exist" in result.output + + result = runner.invoke(config.config.commands["vxlan"].commands["del"], ["tunnel1"], obj=db) + dbconnector.dedicated_dbs = {} + print(result.exit_code) + print(result.output) + assert result.exit_code != 0 + assert "Please delete all VNET configuration referencing the tunnel" in result.output + @classmethod def teardown_class(cls): os.environ['UTILITIES_UNIT_TESTING'] = "0" diff --git a/tests/watermarkstat_test.py b/tests/watermarkstat_test.py index cd4eae00a3..dc419ae3b9 100644 --- a/tests/watermarkstat_test.py +++ b/tests/watermarkstat_test.py @@ -1,5 +1,6 @@ import os import sys +import pytest import show.main as show from click.testing import CliRunner @@ -13,6 +14,15 @@ sys.path.insert(0, modules_path) +@pytest.fixture(scope="function") +def q_multicast_wm_neg(): + print("Setup watermarkstat sample data: no queue multicast watermark counters") + os.environ['WATERMARKSTAT_UNIT_TESTING'] = "1" + yield + del os.environ['WATERMARKSTAT_UNIT_TESTING'] + print("Teardown watermarkstat sample data: no queue multicast watermark counters") + + class TestWatermarkstat(object): @classmethod def setup_class(cls): @@ -32,6 +42,9 @@ def test_show_queue_unicast_wm(self): def test_show_queue_multicast_wm(self): self.executor(testData['show_q_wm_multicast']) + def test_show_queue_multicast_wm_neg(self, q_multicast_wm_neg): + self.executor(testData['show_q_wm_multicast_neg']) + def test_show_queue_all_wm(self): self.executor(testData['show_q_wm_all']) diff --git a/tests/wm_input/mock_db/counters_db.json b/tests/wm_input/mock_db/counters_db.json new file mode 100644 index 0000000000..443b84bf7c --- /dev/null +++ b/tests/wm_input/mock_db/counters_db.json @@ -0,0 +1,1246 @@ +{ + "COUNTERS:oid:0x1000000000012": { + "SAI_PORT_STAT_IF_IN_UCAST_PKTS": "8", + "SAI_PORT_STAT_IF_IN_NON_UCAST_PKTS": "0", + "SAI_PORT_STAT_IF_IN_OCTETS" : "800", + "SAI_PORT_STAT_IF_OUT_UCAST_PKTS": "10", + "SAI_PORT_STAT_IF_OUT_NON_UCAST_PKTS" : "0", + "SAI_PORT_STAT_IF_OUT_OCTETS" : "1000", + "SAI_PORT_STAT_IF_IN_ERRORS": "10", + "SAI_PORT_STAT_IF_IN_DISCARDS": "100", + "SAI_PORT_STAT_IN_DROP_REASON_RANGE_BASE": "80", + "SAI_PORT_STAT_OUT_CONFIGURED_DROP_REASONS_1_DROPPED_PKTS": "20", + "SAI_PORT_STAT_PFC_0_RX_PKTS": "1200", + "SAI_PORT_STAT_PFC_1_RX_PKTS": "201", + "SAI_PORT_STAT_PFC_2_RX_PKTS": "202", + "SAI_PORT_STAT_PFC_3_RX_PKTS": "203", + "SAI_PORT_STAT_PFC_4_RX_PKTS": "204", + "SAI_PORT_STAT_PFC_5_RX_PKTS": "205", + "SAI_PORT_STAT_PFC_6_RX_PKTS": "206", + "SAI_PORT_STAT_PFC_7_RX_PKTS": "207", + "SAI_PORT_STAT_PFC_0_TX_PKTS": "1210", + "SAI_PORT_STAT_PFC_1_TX_PKTS": "211", + "SAI_PORT_STAT_PFC_2_TX_PKTS": "212", + "SAI_PORT_STAT_PFC_3_TX_PKTS": "213", + "SAI_PORT_STAT_PFC_4_TX_PKTS": "214", + "SAI_PORT_STAT_PFC_5_TX_PKTS": "215", + "SAI_PORT_STAT_PFC_6_TX_PKTS": "216", + "SAI_PORT_STAT_PFC_7_TX_PKTS": "217", + "SAI_PORT_STAT_IF_IN_BROADCAST_PKTS": "0", + "SAI_PORT_STAT_IF_IN_MULTICAST_PKTS": "0", + "SAI_PORT_STAT_IP_IN_UCAST_PKTS": "0", + "SAI_PORT_STAT_IP_IN_RECEIVES": "0", + "SAI_PORT_STAT_IF_OUT_MULTICAST_PKTS": "0", + "SAI_PORT_STAT_IF_OUT_BROADCAST_PKTS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_64_OCTETS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_65_TO_127_OCTETS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_128_TO_255_OCTETS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_256_TO_511_OCTETS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_512_TO_1023_OCTETS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_1024_TO_1518_OCTETS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_1519_TO_2047_OCTETS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_2048_TO_4095_OCTETS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_4096_TO_9216_OCTETS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_9217_TO_16383_OCTETS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_64_OCTETS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_65_TO_127_OCTETS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_128_TO_255_OCTETS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_256_TO_511_OCTETS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_512_TO_1023_OCTETS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_1024_TO_1518_OCTETS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_1519_TO_2047_OCTETS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_2048_TO_4095_OCTETS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_4096_TO_9216_OCTETS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_9217_TO_16383_OCTETS": "0", + "SAI_PORT_STAT_ETHER_STATS_FRAGMENTS": "0", + "SAI_PORT_STAT_ETHER_STATS_UNDERSIZE_PKTS": "0", + "SAI_PORT_STAT_ETHER_STATS_JABBERS": "0" + }, + "COUNTERS:oid:0x1000000000013": { + "SAI_PORT_STAT_IF_IN_UCAST_PKTS": "4", + "SAI_PORT_STAT_IF_IN_NON_UCAST_PKTS": "0", + "SAI_PORT_STAT_IF_IN_OCTETS" : "400", + "SAI_PORT_STAT_IF_OUT_UCAST_PKTS": "40", + "SAI_PORT_STAT_IF_OUT_NON_UCAST_PKTS" : "0", + "SAI_PORT_STAT_IF_OUT_OCTETS" : "4000", + "SAI_PORT_STAT_IF_IN_ERRORS": "0", + "SAI_PORT_STAT_IF_IN_DISCARDS": "1000", + "SAI_PORT_STAT_IN_DROP_REASON_RANGE_BASE": "800", + "SAI_PORT_STAT_OUT_CONFIGURED_DROP_REASONS_1_DROPPED_PKTS": "100", + "SAI_PORT_STAT_PFC_0_RX_PKTS": "1400", + "SAI_PORT_STAT_PFC_1_RX_PKTS": "401", + "SAI_PORT_STAT_PFC_2_RX_PKTS": "402", + "SAI_PORT_STAT_PFC_3_RX_PKTS": "403", + "SAI_PORT_STAT_PFC_4_RX_PKTS": "404", + "SAI_PORT_STAT_PFC_5_RX_PKTS": "405", + "SAI_PORT_STAT_PFC_6_RX_PKTS": "406", + "SAI_PORT_STAT_PFC_7_RX_PKTS": "407", + "SAI_PORT_STAT_PFC_0_TX_PKTS": "1410", + "SAI_PORT_STAT_PFC_1_TX_PKTS": "411", + "SAI_PORT_STAT_PFC_2_TX_PKTS": "412", + "SAI_PORT_STAT_PFC_3_TX_PKTS": "413", + "SAI_PORT_STAT_PFC_4_TX_PKTS": "414", + "SAI_PORT_STAT_PFC_5_TX_PKTS": "415", + "SAI_PORT_STAT_PFC_6_TX_PKTS": "416", + "SAI_PORT_STAT_PFC_7_TX_PKTS": "417", + "SAI_PORT_STAT_IF_IN_BROADCAST_PKTS": "0", + "SAI_PORT_STAT_IF_IN_MULTICAST_PKTS": "0", + "SAI_PORT_STAT_IP_IN_UCAST_PKTS": "0", + "SAI_PORT_STAT_IP_IN_RECEIVES": "0", + "SAI_PORT_STAT_IF_OUT_MULTICAST_PKTS": "0", + "SAI_PORT_STAT_IF_OUT_BROADCAST_PKTS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_64_OCTETS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_65_TO_127_OCTETS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_128_TO_255_OCTETS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_256_TO_511_OCTETS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_512_TO_1023_OCTETS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_1024_TO_1518_OCTETS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_1519_TO_2047_OCTETS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_2048_TO_4095_OCTETS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_4096_TO_9216_OCTETS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_9217_TO_16383_OCTETS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_64_OCTETS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_65_TO_127_OCTETS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_128_TO_255_OCTETS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_256_TO_511_OCTETS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_512_TO_1023_OCTETS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_1024_TO_1518_OCTETS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_1519_TO_2047_OCTETS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_2048_TO_4095_OCTETS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_4096_TO_9216_OCTETS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_9217_TO_16383_OCTETS": "0", + "SAI_PORT_STAT_ETHER_STATS_FRAGMENTS": "0", + "SAI_PORT_STAT_ETHER_STATS_UNDERSIZE_PKTS": "0", + "SAI_PORT_STAT_ETHER_STATS_JABBERS": "0" + }, + "COUNTERS:oid:0x1000000000014": { + "SAI_PORT_STAT_IF_IN_UCAST_PKTS": "6", + "SAI_PORT_STAT_IF_IN_NON_UCAST_PKTS": "0", + "SAI_PORT_STAT_IF_IN_OCTETS" : "600", + "SAI_PORT_STAT_IF_OUT_UCAST_PKTS": "60", + "SAI_PORT_STAT_IF_OUT_NON_UCAST_PKTS" : "0", + "SAI_PORT_STAT_IF_OUT_OCTETS" : "6000", + "SAI_PORT_STAT_IF_IN_ERRORS": "100", + "SAI_PORT_STAT_IF_IN_DISCARDS": "10", + "SAI_PORT_STAT_IN_DROP_REASON_RANGE_BASE": "10", + "SAI_PORT_STAT_OUT_CONFIGURED_DROP_REASONS_1_DROPPED_PKTS": "0", + "SAI_PORT_STAT_PFC_0_RX_PKTS": "1800", + "SAI_PORT_STAT_PFC_1_RX_PKTS": "801", + "SAI_PORT_STAT_PFC_2_RX_PKTS": "802", + "SAI_PORT_STAT_PFC_3_RX_PKTS": "803", + "SAI_PORT_STAT_PFC_4_RX_PKTS": "804", + "SAI_PORT_STAT_PFC_5_RX_PKTS": "805", + "SAI_PORT_STAT_PFC_6_RX_PKTS": "806", + "SAI_PORT_STAT_PFC_7_RX_PKTS": "807", + "SAI_PORT_STAT_PFC_0_TX_PKTS": "1810", + "SAI_PORT_STAT_PFC_1_TX_PKTS": "811", + "SAI_PORT_STAT_PFC_2_TX_PKTS": "812", + "SAI_PORT_STAT_PFC_3_TX_PKTS": "813", + "SAI_PORT_STAT_PFC_4_TX_PKTS": "814", + "SAI_PORT_STAT_PFC_5_TX_PKTS": "815", + "SAI_PORT_STAT_PFC_6_TX_PKTS": "816", + "SAI_PORT_STAT_PFC_7_TX_PKTS": "817", + "SAI_PORT_STAT_IF_IN_BROADCAST_PKTS": "0", + "SAI_PORT_STAT_IF_IN_MULTICAST_PKTS": "0", + "SAI_PORT_STAT_IP_IN_UCAST_PKTS": "0", + "SAI_PORT_STAT_IP_IN_RECEIVES": "0", + "SAI_PORT_STAT_IF_OUT_MULTICAST_PKTS": "0", + "SAI_PORT_STAT_IF_OUT_BROADCAST_PKTS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_64_OCTETS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_65_TO_127_OCTETS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_128_TO_255_OCTETS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_256_TO_511_OCTETS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_512_TO_1023_OCTETS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_1024_TO_1518_OCTETS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_1519_TO_2047_OCTETS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_2048_TO_4095_OCTETS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_4096_TO_9216_OCTETS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_9217_TO_16383_OCTETS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_64_OCTETS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_65_TO_127_OCTETS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_128_TO_255_OCTETS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_256_TO_511_OCTETS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_512_TO_1023_OCTETS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_1024_TO_1518_OCTETS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_1519_TO_2047_OCTETS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_2048_TO_4095_OCTETS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_4096_TO_9216_OCTETS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_9217_TO_16383_OCTETS": "0", + "SAI_PORT_STAT_ETHER_STATS_FRAGMENTS": "0", + "SAI_PORT_STAT_ETHER_STATS_UNDERSIZE_PKTS": "0", + "SAI_PORT_STAT_ETHER_STATS_JABBERS": "0" + }, + "COUNTERS:oid:0x15000000000357": { + "SAI_QUEUE_STAT_BYTES": "30", + "SAI_QUEUE_STAT_DROPPED_BYTES": "74", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "56", + "SAI_QUEUE_STAT_PACKETS": "68", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "61" + }, + "COUNTERS:oid:0x15000000000358": { + "SAI_QUEUE_STAT_BYTES": "43", + "SAI_QUEUE_STAT_DROPPED_BYTES": "1", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "39", + "SAI_QUEUE_STAT_PACKETS": "60", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "88" + }, + "COUNTERS:oid:0x15000000000359": { + "SAI_QUEUE_STAT_BYTES": "7", + "SAI_QUEUE_STAT_DROPPED_BYTES": "21", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "39", + "SAI_QUEUE_STAT_PACKETS": "82", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "4" + }, + "COUNTERS:oid:0x1500000000035b": { + "SAI_QUEUE_STAT_BYTES": "59", + "SAI_QUEUE_STAT_DROPPED_BYTES": "94", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "12", + "SAI_QUEUE_STAT_PACKETS": "11", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "15" + }, + "COUNTERS:oid:0x1500000000035c": { + "SAI_QUEUE_STAT_BYTES": "62", + "SAI_QUEUE_STAT_DROPPED_BYTES": "40", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "35", + "SAI_QUEUE_STAT_PACKETS": "36", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "18" + }, + "COUNTERS:oid:0x1500000000035d": { + "SAI_QUEUE_STAT_BYTES": "91", + "SAI_QUEUE_STAT_DROPPED_BYTES": "88", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "2", + "SAI_QUEUE_STAT_PACKETS": "49", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "73" + }, + "COUNTERS:oid:0x1500000000035e": { + "SAI_QUEUE_STAT_BYTES": "17", + "SAI_QUEUE_STAT_DROPPED_BYTES": "74", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "94", + "SAI_QUEUE_STAT_PACKETS": "33", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "98" + }, + "COUNTERS:oid:0x1500000000035f": { + "SAI_QUEUE_STAT_BYTES": "71", + "SAI_QUEUE_STAT_DROPPED_BYTES": "33", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "95", + "SAI_QUEUE_STAT_PACKETS": "40", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "81" + }, + "COUNTERS:oid:0x15000000000360": { + "SAI_QUEUE_STAT_BYTES": "8", + "SAI_QUEUE_STAT_DROPPED_BYTES": "78", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "93", + "SAI_QUEUE_STAT_PACKETS": "54", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "59" + }, + "COUNTERS:oid:0x1500000000037f": { + "SAI_QUEUE_STAT_BYTES": "96", + "SAI_QUEUE_STAT_DROPPED_BYTES": "98", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "70", + "SAI_QUEUE_STAT_PACKETS": "41", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "46" + }, + "COUNTERS:oid:0x15000000000380": { + "SAI_QUEUE_STAT_BYTES": "49", + "SAI_QUEUE_STAT_DROPPED_BYTES": "36", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "63", + "SAI_QUEUE_STAT_PACKETS": "18", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "18" + }, + "COUNTERS:oid:0x15000000000381": { + "SAI_QUEUE_STAT_BYTES": "90", + "SAI_QUEUE_STAT_DROPPED_BYTES": "15", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "3", + "SAI_QUEUE_STAT_PACKETS": "99", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "15" + }, + "COUNTERS:oid:0x15000000000383": { + "SAI_QUEUE_STAT_BYTES": "84", + "SAI_QUEUE_STAT_DROPPED_BYTES": "94", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "82", + "SAI_QUEUE_STAT_PACKETS": "8", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "17" + }, + "COUNTERS:oid:0x15000000000384": { + "SAI_QUEUE_STAT_BYTES": "15", + "SAI_QUEUE_STAT_DROPPED_BYTES": "92", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "75", + "SAI_QUEUE_STAT_PACKETS": "83", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "42" + }, + "COUNTERS:oid:0x15000000000385": { + "SAI_QUEUE_STAT_BYTES": "26", + "SAI_QUEUE_STAT_DROPPED_BYTES": "71", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "50", + "SAI_QUEUE_STAT_PACKETS": "84", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "31" + }, + "COUNTERS:oid:0x15000000000386": { + "SAI_QUEUE_STAT_BYTES": "19", + "SAI_QUEUE_STAT_DROPPED_BYTES": "80", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "49", + "SAI_QUEUE_STAT_PACKETS": "27", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "4" + }, + "COUNTERS:oid:0x15000000000387": { + "SAI_QUEUE_STAT_BYTES": "89", + "SAI_QUEUE_STAT_DROPPED_BYTES": "33", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "13", + "SAI_QUEUE_STAT_PACKETS": "13", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "45" + }, + "COUNTERS:oid:0x15000000000388": { + "SAI_QUEUE_STAT_BYTES": "48", + "SAI_QUEUE_STAT_DROPPED_BYTES": "31", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "86", + "SAI_QUEUE_STAT_PACKETS": "43", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "6" + }, + "COUNTERS:oid:0x150000000003a7": { + "SAI_QUEUE_STAT_BYTES": "5", + "SAI_QUEUE_STAT_DROPPED_BYTES": "56", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "36", + "SAI_QUEUE_STAT_PACKETS": "19", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "65" + }, + "COUNTERS:oid:0x150000000003a8": { + "SAI_QUEUE_STAT_BYTES": "17", + "SAI_QUEUE_STAT_DROPPED_BYTES": "91", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "68", + "SAI_QUEUE_STAT_PACKETS": "38", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "94" + }, + "COUNTERS:oid:0x150000000003a9": { + "SAI_QUEUE_STAT_BYTES": "65", + "SAI_QUEUE_STAT_DROPPED_BYTES": "51", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "79", + "SAI_QUEUE_STAT_PACKETS": "16", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "71" + }, + "COUNTERS:oid:0x150000000003aa": { + "SAI_QUEUE_STAT_BYTES": "97", + "SAI_QUEUE_STAT_DROPPED_BYTES": "72", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "63", + "SAI_QUEUE_STAT_PACKETS": "11", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "51" + }, + "COUNTERS:oid:0x150000000003ac": { + "SAI_QUEUE_STAT_BYTES": "84", + "SAI_QUEUE_STAT_DROPPED_BYTES": "59", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "30", + "SAI_QUEUE_STAT_PACKETS": "13", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "47" + }, + "COUNTERS:oid:0x150000000003ad": { + "SAI_QUEUE_STAT_BYTES": "67", + "SAI_QUEUE_STAT_DROPPED_BYTES": "85", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "99", + "SAI_QUEUE_STAT_PACKETS": "49", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "86" + }, + "COUNTERS:oid:0x150000000003ae": { + "SAI_QUEUE_STAT_BYTES": "63", + "SAI_QUEUE_STAT_DROPPED_BYTES": "88", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "38", + "SAI_QUEUE_STAT_PACKETS": "2", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "98" + }, + "COUNTERS:oid:0x150000000003af": { + "SAI_QUEUE_STAT_BYTES": "82", + "SAI_QUEUE_STAT_DROPPED_BYTES": "43", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "93", + "SAI_QUEUE_STAT_PACKETS": "0", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "50" + }, + "COUNTERS:oid:0x150000000003b0": { + "SAI_QUEUE_STAT_BYTES": "17", + "SAI_QUEUE_STAT_DROPPED_BYTES": "61", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "91", + "SAI_QUEUE_STAT_PACKETS": "80", + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "91" + }, + "COUNTERS:oid:0x1a00000000034f": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_DROPPED_PACKETS" : "800" + }, + "COUNTERS:oid:0x1a000000000350" : { + "SAI_INGRESS_PRIORITY_GROUP_STAT_DROPPED_PACKETS" : "801" + }, + "COUNTERS:oid:0x1a000000000351" : { + "SAI_INGRESS_PRIORITY_GROUP_STAT_DROPPED_PACKETS" : "802" + }, + "COUNTERS:oid:0x1a000000000352" : { + "SAI_INGRESS_PRIORITY_GROUP_STAT_DROPPED_PACKETS" : "803" + }, + "COUNTERS:oid:0x1a000000000353" : { + "SAI_INGRESS_PRIORITY_GROUP_STAT_DROPPED_PACKETS" : "804" + }, + "COUNTERS:oid:0x1a000000000354" : { + "SAI_INGRESS_PRIORITY_GROUP_STAT_DROPPED_PACKETS" : "805" + }, + "COUNTERS:oid:0x1a000000000355" : { + "SAI_INGRESS_PRIORITY_GROUP_STAT_DROPPED_PACKETS" : "806" + }, + "COUNTERS:oid:0x1a000000000356" : { + "SAI_INGRESS_PRIORITY_GROUP_STAT_DROPPED_PACKETS" : "807" + }, + "COUNTERS:oid:0x1a000000000377" : { + "SAI_INGRESS_PRIORITY_GROUP_STAT_DROPPED_PACKETS" : "400" + }, + "COUNTERS:oid:0x1a000000000378" : { + "SAI_INGRESS_PRIORITY_GROUP_STAT_DROPPED_PACKETS" : "401" + }, + "COUNTERS:oid:0x1a000000000379" : { + "SAI_INGRESS_PRIORITY_GROUP_STAT_DROPPED_PACKETS" : "402" + }, + "COUNTERS:oid:0x1a00000000037a" : { + "SAI_INGRESS_PRIORITY_GROUP_STAT_DROPPED_PACKETS" : "403" + }, + "COUNTERS:oid:0x1a00000000037b" : { + "SAI_INGRESS_PRIORITY_GROUP_STAT_DROPPED_PACKETS" : "404" + }, + "COUNTERS:oid:0x1a00000000037c" : { + "SAI_INGRESS_PRIORITY_GROUP_STAT_DROPPED_PACKETS" : "405" + }, + "COUNTERS:oid:0x1a00000000037d" : { + "SAI_INGRESS_PRIORITY_GROUP_STAT_DROPPED_PACKETS" : "406" + }, + "COUNTERS:oid:0x1a00000000037e" : { + "SAI_INGRESS_PRIORITY_GROUP_STAT_DROPPED_PACKETS" : "407" + }, + "COUNTERS:oid:0x1a00000000039f" : { + "SAI_INGRESS_PRIORITY_GROUP_STAT_DROPPED_PACKETS" : "100" + }, + "COUNTERS:oid:0x1a0000000003a0" : { + "SAI_INGRESS_PRIORITY_GROUP_STAT_DROPPED_PACKETS" : "101" + }, + "COUNTERS:oid:0x1a0000000003a1" : { + "SAI_INGRESS_PRIORITY_GROUP_STAT_DROPPED_PACKETS" : "102" + }, + "COUNTERS:oid:0x1a0000000003a2" : { + "SAI_INGRESS_PRIORITY_GROUP_STAT_DROPPED_PACKETS" : "103" + }, + "COUNTERS:oid:0x1a0000000003a3" : { + "SAI_INGRESS_PRIORITY_GROUP_STAT_DROPPED_PACKETS" : "104" + }, + "COUNTERS:oid:0x1a0000000003a4" : { + "SAI_INGRESS_PRIORITY_GROUP_STAT_DROPPED_PACKETS" : "105" + }, + "COUNTERS:oid:0x1a0000000003a5" : { + "SAI_INGRESS_PRIORITY_GROUP_STAT_DROPPED_PACKETS" : "106" + }, + "COUNTERS:oid:0x1a0000000003a6" : { + "SAI_INGRESS_PRIORITY_GROUP_STAT_DROPPED_PACKETS" : "107" + }, + "COUNTERS_PORT_NAME_MAP": { + "Ethernet0": "oid:0x1000000000012", + "Ethernet4": "oid:0x1000000000013", + "Ethernet8": "oid:0x1000000000014" + }, + "COUNTERS_BUFFER_POOL_NAME_MAP": { + "egress_lossless_pool": "oid:0x18000000000b64", + "egress_lossy_pool": "oid:0x18000000000b65", + "ingress_lossless_pool": "oid:0x18000000000b66" + }, + "COUNTERS_PG_NAME_MAP": { + "Ethernet0:0": "oid:0x1a00000000034f", + "Ethernet0:1": "oid:0x1a000000000350", + "Ethernet0:2": "oid:0x1a000000000351", + "Ethernet0:3": "oid:0x1a000000000352", + "Ethernet0:4": "oid:0x1a000000000353", + "Ethernet0:5": "oid:0x1a000000000354", + "Ethernet0:6": "oid:0x1a000000000355", + "Ethernet0:7": "oid:0x1a000000000356", + "Ethernet4:0": "oid:0x1a000000000377", + "Ethernet4:1": "oid:0x1a000000000378", + "Ethernet4:2": "oid:0x1a000000000379", + "Ethernet4:3": "oid:0x1a00000000037a", + "Ethernet4:4": "oid:0x1a00000000037b", + "Ethernet4:5": "oid:0x1a00000000037c", + "Ethernet4:6": "oid:0x1a00000000037d", + "Ethernet4:7": "oid:0x1a00000000037e", + "Ethernet8:0": "oid:0x1a00000000039f", + "Ethernet8:1": "oid:0x1a0000000003a0", + "Ethernet8:2": "oid:0x1a0000000003a1", + "Ethernet8:3": "oid:0x1a0000000003a2", + "Ethernet8:4": "oid:0x1a0000000003a3", + "Ethernet8:5": "oid:0x1a0000000003a4", + "Ethernet8:6": "oid:0x1a0000000003a5", + "Ethernet8:7": "oid:0x1a0000000003a6" + }, + "COUNTERS_PG_PORT_MAP": { + "oid:0x1a00000000034f": "oid:0x1000000000012", + "oid:0x1a000000000350": "oid:0x1000000000012", + "oid:0x1a000000000351": "oid:0x1000000000012", + "oid:0x1a000000000352": "oid:0x1000000000012", + "oid:0x1a000000000353": "oid:0x1000000000012", + "oid:0x1a000000000354": "oid:0x1000000000012", + "oid:0x1a000000000355": "oid:0x1000000000012", + "oid:0x1a000000000356": "oid:0x1000000000012", + "oid:0x1a000000000377": "oid:0x1000000000013", + "oid:0x1a000000000378": "oid:0x1000000000013", + "oid:0x1a000000000379": "oid:0x1000000000013", + "oid:0x1a00000000037a": "oid:0x1000000000013", + "oid:0x1a00000000037b": "oid:0x1000000000013", + "oid:0x1a00000000037c": "oid:0x1000000000013", + "oid:0x1a00000000037d": "oid:0x1000000000013", + "oid:0x1a00000000037e": "oid:0x1000000000013", + "oid:0x1a00000000039f": "oid:0x1000000000014", + "oid:0x1a0000000003a0": "oid:0x1000000000014", + "oid:0x1a0000000003a1": "oid:0x1000000000014", + "oid:0x1a0000000003a2": "oid:0x1000000000014", + "oid:0x1a0000000003a3": "oid:0x1000000000014", + "oid:0x1a0000000003a4": "oid:0x1000000000014", + "oid:0x1a0000000003a5": "oid:0x1000000000014", + "oid:0x1a0000000003a6": "oid:0x1000000000014" + }, + "COUNTERS_QUEUE_NAME_MAP": { + "Ethernet0:0": "oid:0x15000000000357", + "Ethernet0:1": "oid:0x15000000000358", + "Ethernet0:2": "oid:0x15000000000359", + "Ethernet0:3": "oid:0x1500000000035a", + "Ethernet0:4": "oid:0x1500000000035b", + "Ethernet0:5": "oid:0x1500000000035c", + "Ethernet0:6": "oid:0x1500000000035d", + "Ethernet0:7": "oid:0x1500000000035e", + "Ethernet0:8": "oid:0x1500000000035f", + "Ethernet0:9": "oid:0x15000000000360", + "Ethernet0:20": "oid:0x1500000000036d", + "Ethernet0:21": "oid:0x1500000000036e", + "Ethernet0:22": "oid:0x1500000000036f", + "Ethernet0:23": "oid:0x15000000000370", + "Ethernet0:24": "oid:0x15000000000371", + "Ethernet0:25": "oid:0x15000000000372", + "Ethernet0:26": "oid:0x15000000000373", + "Ethernet0:27": "oid:0x15000000000374", + "Ethernet0:28": "oid:0x15000000000375", + "Ethernet0:29": "oid:0x15000000000376", + "Ethernet4:0": "oid:0x1500000000037f", + "Ethernet4:1": "oid:0x15000000000380", + "Ethernet4:2": "oid:0x15000000000381", + "Ethernet4:3": "oid:0x15000000000382", + "Ethernet4:4": "oid:0x15000000000383", + "Ethernet4:5": "oid:0x15000000000384", + "Ethernet4:6": "oid:0x15000000000385", + "Ethernet4:7": "oid:0x15000000000386", + "Ethernet4:8": "oid:0x15000000000387", + "Ethernet4:9": "oid:0x15000000000388", + "Ethernet4:20": "oid:0x15000000000395", + "Ethernet4:21": "oid:0x15000000000396", + "Ethernet4:22": "oid:0x15000000000397", + "Ethernet4:23": "oid:0x15000000000398", + "Ethernet4:24": "oid:0x15000000000399", + "Ethernet4:25": "oid:0x1500000000039a", + "Ethernet4:26": "oid:0x1500000000039b", + "Ethernet4:27": "oid:0x1500000000039c", + "Ethernet4:28": "oid:0x1500000000039d", + "Ethernet4:29": "oid:0x1500000000039e", + "Ethernet8:0": "oid:0x150000000003a7", + "Ethernet8:1": "oid:0x150000000003a8", + "Ethernet8:2": "oid:0x150000000003a9", + "Ethernet8:3": "oid:0x150000000003aa", + "Ethernet8:4": "oid:0x150000000003ab", + "Ethernet8:5": "oid:0x150000000003ac", + "Ethernet8:6": "oid:0x150000000003ad", + "Ethernet8:7": "oid:0x150000000003ae", + "Ethernet8:8": "oid:0x150000000003af", + "Ethernet8:9": "oid:0x150000000003b0", + "Ethernet8:20": "oid:0x150000000003bd", + "Ethernet8:21": "oid:0x150000000003be", + "Ethernet8:22": "oid:0x150000000003bf", + "Ethernet8:23": "oid:0x150000000003c0", + "Ethernet8:24": "oid:0x150000000003c1", + "Ethernet8:25": "oid:0x150000000003c2", + "Ethernet8:26": "oid:0x150000000003c3", + "Ethernet8:27": "oid:0x150000000003c4", + "Ethernet8:28": "oid:0x150000000003c5", + "Ethernet8:29": "oid:0x150000000003c6" + }, + "COUNTERS_QUEUE_PORT_MAP": { + "oid:0x15000000000357": "oid:0x1000000000012", + "oid:0x15000000000358": "oid:0x1000000000012", + "oid:0x15000000000359": "oid:0x1000000000012", + "oid:0x1500000000035a": "oid:0x1000000000012", + "oid:0x1500000000035b": "oid:0x1000000000012", + "oid:0x1500000000035c": "oid:0x1000000000012", + "oid:0x1500000000035d": "oid:0x1000000000012", + "oid:0x1500000000035e": "oid:0x1000000000012", + "oid:0x1500000000035f": "oid:0x1000000000012", + "oid:0x15000000000360": "oid:0x1000000000012", + "oid:0x1500000000036d": "oid:0x1000000000012", + "oid:0x1500000000036e": "oid:0x1000000000012", + "oid:0x1500000000036f": "oid:0x1000000000012", + "oid:0x15000000000370": "oid:0x1000000000012", + "oid:0x15000000000371": "oid:0x1000000000012", + "oid:0x15000000000372": "oid:0x1000000000012", + "oid:0x15000000000373": "oid:0x1000000000012", + "oid:0x15000000000374": "oid:0x1000000000012", + "oid:0x15000000000375": "oid:0x1000000000012", + "oid:0x15000000000376": "oid:0x1000000000012", + "oid:0x1500000000037f": "oid:0x1000000000013", + "oid:0x15000000000380": "oid:0x1000000000013", + "oid:0x15000000000381": "oid:0x1000000000013", + "oid:0x15000000000382": "oid:0x1000000000013", + "oid:0x15000000000383": "oid:0x1000000000013", + "oid:0x15000000000384": "oid:0x1000000000013", + "oid:0x15000000000385": "oid:0x1000000000013", + "oid:0x15000000000386": "oid:0x1000000000013", + "oid:0x15000000000387": "oid:0x1000000000013", + "oid:0x15000000000388": "oid:0x1000000000013", + "oid:0x15000000000395": "oid:0x1000000000013", + "oid:0x15000000000396": "oid:0x1000000000013", + "oid:0x15000000000397": "oid:0x1000000000013", + "oid:0x15000000000398": "oid:0x1000000000013", + "oid:0x15000000000399": "oid:0x1000000000013", + "oid:0x1500000000039a": "oid:0x1000000000013", + "oid:0x1500000000039b": "oid:0x1000000000013", + "oid:0x1500000000039c": "oid:0x1000000000013", + "oid:0x1500000000039d": "oid:0x1000000000013", + "oid:0x1500000000039e": "oid:0x1000000000013", + "oid:0x150000000003a7": "oid:0x1000000000014", + "oid:0x150000000003a8": "oid:0x1000000000014", + "oid:0x150000000003a9": "oid:0x1000000000014", + "oid:0x150000000003aa": "oid:0x1000000000014", + "oid:0x150000000003ab": "oid:0x1000000000014", + "oid:0x150000000003ac": "oid:0x1000000000014", + "oid:0x150000000003ad": "oid:0x1000000000014", + "oid:0x150000000003ae": "oid:0x1000000000014", + "oid:0x150000000003af": "oid:0x1000000000014", + "oid:0x150000000003b0": "oid:0x1000000000014", + "oid:0x150000000003bd": "oid:0x1000000000014", + "oid:0x150000000003be": "oid:0x1000000000014", + "oid:0x150000000003bf": "oid:0x1000000000014", + "oid:0x150000000003c0": "oid:0x1000000000014", + "oid:0x150000000003c1": "oid:0x1000000000014", + "oid:0x150000000003c2": "oid:0x1000000000014", + "oid:0x150000000003c3": "oid:0x1000000000014", + "oid:0x150000000003c4": "oid:0x1000000000014", + "oid:0x150000000003c5": "oid:0x1000000000014", + "oid:0x150000000003c6": "oid:0x1000000000014" + }, + "COUNTERS_QUEUE_INDEX_MAP": { + "oid:0x15000000000357": "0", + "oid:0x15000000000358": "1", + "oid:0x15000000000359": "2", + "oid:0x1500000000035a": "3", + "oid:0x1500000000035b": "4", + "oid:0x1500000000035c": "5", + "oid:0x1500000000035d": "6", + "oid:0x1500000000035e": "7", + "oid:0x1500000000035f": "8", + "oid:0x15000000000360": "9", + "oid:0x1500000000036d": "20", + "oid:0x1500000000036e": "21", + "oid:0x1500000000036f": "22", + "oid:0x15000000000370": "23", + "oid:0x15000000000371": "24", + "oid:0x15000000000372": "25", + "oid:0x15000000000373": "26", + "oid:0x15000000000374": "27", + "oid:0x15000000000375": "28", + "oid:0x15000000000376": "29", + "oid:0x1500000000037f": "0", + "oid:0x15000000000380": "1", + "oid:0x15000000000381": "2", + "oid:0x15000000000382": "3", + "oid:0x15000000000383": "4", + "oid:0x15000000000384": "5", + "oid:0x15000000000385": "6", + "oid:0x15000000000386": "7", + "oid:0x15000000000387": "8", + "oid:0x15000000000388": "9", + "oid:0x15000000000395": "20", + "oid:0x15000000000396": "21", + "oid:0x15000000000397": "22", + "oid:0x15000000000398": "23", + "oid:0x15000000000399": "24", + "oid:0x1500000000039a": "25", + "oid:0x1500000000039b": "26", + "oid:0x1500000000039c": "27", + "oid:0x1500000000039d": "28", + "oid:0x1500000000039e": "29", + "oid:0x150000000003a7": "0", + "oid:0x150000000003a8": "1", + "oid:0x150000000003a9": "2", + "oid:0x150000000003aa": "3", + "oid:0x150000000003ab": "4", + "oid:0x150000000003ac": "5", + "oid:0x150000000003ad": "6", + "oid:0x150000000003ae": "7", + "oid:0x150000000003af": "8", + "oid:0x150000000003b0": "9", + "oid:0x150000000003bd": "20", + "oid:0x150000000003be": "21", + "oid:0x150000000003bf": "22", + "oid:0x150000000003c0": "23", + "oid:0x150000000003c1": "24", + "oid:0x150000000003c2": "25", + "oid:0x150000000003c3": "26", + "oid:0x150000000003c4": "27", + "oid:0x150000000003c5": "28", + "oid:0x150000000003c6": "29" + }, + "COUNTERS_QUEUE_TYPE_MAP": { + "oid:0x15000000000357": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x15000000000358": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x15000000000359": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1500000000035a": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1500000000035b": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1500000000035c": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1500000000035d": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1500000000035e": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1500000000035f": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x15000000000360": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1500000000036d": "SAI_QUEUE_TYPE_ALL", + "oid:0x1500000000036e": "SAI_QUEUE_TYPE_ALL", + "oid:0x1500000000036f": "SAI_QUEUE_TYPE_ALL", + "oid:0x15000000000370": "SAI_QUEUE_TYPE_ALL", + "oid:0x15000000000371": "SAI_QUEUE_TYPE_ALL", + "oid:0x15000000000372": "SAI_QUEUE_TYPE_ALL", + "oid:0x15000000000373": "SAI_QUEUE_TYPE_ALL", + "oid:0x15000000000374": "SAI_QUEUE_TYPE_ALL", + "oid:0x15000000000375": "SAI_QUEUE_TYPE_ALL", + "oid:0x15000000000376": "SAI_QUEUE_TYPE_ALL", + "oid:0x1500000000037f": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x15000000000380": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x15000000000381": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x15000000000382": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x15000000000383": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x15000000000384": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x15000000000385": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x15000000000386": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x15000000000387": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x15000000000388": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x15000000000395": "SAI_QUEUE_TYPE_ALL", + "oid:0x15000000000396": "SAI_QUEUE_TYPE_ALL", + "oid:0x15000000000397": "SAI_QUEUE_TYPE_ALL", + "oid:0x15000000000398": "SAI_QUEUE_TYPE_ALL", + "oid:0x15000000000399": "SAI_QUEUE_TYPE_ALL", + "oid:0x1500000000039a": "SAI_QUEUE_TYPE_ALL", + "oid:0x1500000000039b": "SAI_QUEUE_TYPE_ALL", + "oid:0x1500000000039c": "SAI_QUEUE_TYPE_ALL", + "oid:0x1500000000039d": "SAI_QUEUE_TYPE_ALL", + "oid:0x1500000000039e": "SAI_QUEUE_TYPE_ALL", + "oid:0x150000000003a7": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x150000000003a8": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x150000000003a9": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x150000000003aa": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x150000000003ab": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x150000000003ac": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x150000000003ad": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x150000000003ae": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x150000000003af": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x150000000003b0": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x150000000003bd": "SAI_QUEUE_TYPE_ALL", + "oid:0x150000000003be": "SAI_QUEUE_TYPE_ALL", + "oid:0x150000000003bf": "SAI_QUEUE_TYPE_ALL", + "oid:0x150000000003c0": "SAI_QUEUE_TYPE_ALL", + "oid:0x150000000003c1": "SAI_QUEUE_TYPE_ALL", + "oid:0x150000000003c2": "SAI_QUEUE_TYPE_ALL", + "oid:0x150000000003c3": "SAI_QUEUE_TYPE_ALL", + "oid:0x150000000003c4": "SAI_QUEUE_TYPE_ALL", + "oid:0x150000000003c5": "SAI_QUEUE_TYPE_ALL", + "oid:0x150000000003c6": "SAI_QUEUE_TYPE_ALL" + }, + "USER_WATERMARKS:oid:0x1a00000000034f": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "100", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "100" + }, + "USER_WATERMARKS:oid:0x1a000000000350": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "101", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "101" + }, + "USER_WATERMARKS:oid:0x1a000000000351": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "102", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "102" + }, + "USER_WATERMARKS:oid:0x1a000000000352": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "103", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "103" + }, + "USER_WATERMARKS:oid:0x1a000000000353": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "104", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "104" + }, + "USER_WATERMARKS:oid:0x1a000000000354": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "105", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "105" + }, + "USER_WATERMARKS:oid:0x1a000000000355": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "106", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "106" + }, + "USER_WATERMARKS:oid:0x1a000000000356": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "107", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "107" + }, + "USER_WATERMARKS:oid:0x1a000000000377": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "400", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "400" + }, + "USER_WATERMARKS:oid:0x1a000000000378": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "401", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "401" + }, + "USER_WATERMARKS:oid:0x1a000000000379": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "402", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "402" + }, + "USER_WATERMARKS:oid:0x1a00000000037a": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "403", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "403" + }, + "USER_WATERMARKS:oid:0x1a00000000037b": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "404", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "404" + }, + "USER_WATERMARKS:oid:0x1a00000000037c": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "405", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "405" + }, + "USER_WATERMARKS:oid:0x1a00000000037d": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "406", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "406" + }, + "USER_WATERMARKS:oid:0x1a00000000037e": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "407", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "407" + }, + "USER_WATERMARKS:oid:0x1a00000000039f": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "800", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "800" + }, + "USER_WATERMARKS:oid:0x1a0000000003a0": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "801", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "801" + }, + "USER_WATERMARKS:oid:0x1a0000000003a1": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "802", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "802" + }, + "USER_WATERMARKS:oid:0x1a0000000003a2": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "803", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "803" + }, + "USER_WATERMARKS:oid:0x1a0000000003a3": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "804", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "804" + }, + "USER_WATERMARKS:oid:0x1a0000000003a4": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "805", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "805" + }, + "USER_WATERMARKS:oid:0x1a0000000003a5": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "806", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "806" + }, + "USER_WATERMARKS:oid:0x1a0000000003a6": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "807", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "807" + }, + "PERSISTENT_WATERMARKS:oid:0x1a00000000034f": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "200", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "200" + }, + "PERSISTENT_WATERMARKS:oid:0x1a000000000350": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "201", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "201" + }, + "PERSISTENT_WATERMARKS:oid:0x1a000000000351": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "202", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "202" + }, + "PERSISTENT_WATERMARKS:oid:0x1a000000000352": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "203", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "203" + }, + "PERSISTENT_WATERMARKS:oid:0x1a000000000353": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "204", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "204" + }, + "PERSISTENT_WATERMARKS:oid:0x1a000000000354": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "205", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "205" + }, + "PERSISTENT_WATERMARKS:oid:0x1a000000000355": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "206", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "206" + }, + "PERSISTENT_WATERMARKS:oid:0x1a000000000356": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "207", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "207" + }, + "PERSISTENT_WATERMARKS:oid:0x1a000000000377": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "500", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "500" + }, + "PERSISTENT_WATERMARKS:oid:0x1a000000000378": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "501", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "501" + }, + "PERSISTENT_WATERMARKS:oid:0x1a000000000379": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "502", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "502" + }, + "PERSISTENT_WATERMARKS:oid:0x1a00000000037a": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "503", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "503" + }, + "PERSISTENT_WATERMARKS:oid:0x1a00000000037b": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "504", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "504" + }, + "PERSISTENT_WATERMARKS:oid:0x1a00000000037c": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "505", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "505" + }, + "PERSISTENT_WATERMARKS:oid:0x1a00000000037d": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "506", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "506" + }, + "PERSISTENT_WATERMARKS:oid:0x1a00000000037e": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "507", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "507" + }, + "PERSISTENT_WATERMARKS:oid:0x1a00000000039f": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "900", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "900" + }, + "PERSISTENT_WATERMARKS:oid:0x1a0000000003a0": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "901", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "901" + }, + "PERSISTENT_WATERMARKS:oid:0x1a0000000003a1": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "902", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "902" + }, + "PERSISTENT_WATERMARKS:oid:0x1a0000000003a2": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "903", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "903" + }, + "PERSISTENT_WATERMARKS:oid:0x1a0000000003a3": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "904", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "904" + }, + "PERSISTENT_WATERMARKS:oid:0x1a0000000003a4": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "905", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "905" + }, + "PERSISTENT_WATERMARKS:oid:0x1a0000000003a5": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "906", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "906" + }, + "PERSISTENT_WATERMARKS:oid:0x1a0000000003a6": { + "SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES": "907", + "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES": "907" + }, + "USER_WATERMARKS:oid:0x15000000000357": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "2057328" + }, + "USER_WATERMARKS:oid:0x15000000000358": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "2056704" + }, + "USER_WATERMARKS:oid:0x15000000000359": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "USER_WATERMARKS:oid:0x1500000000035a": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "USER_WATERMARKS:oid:0x1500000000035b": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "USER_WATERMARKS:oid:0x1500000000035c": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "USER_WATERMARKS:oid:0x1500000000035d": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "USER_WATERMARKS:oid:0x1500000000035e": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "2704" + }, + "USER_WATERMARKS:oid:0x1500000000035f": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "416" + }, + "USER_WATERMARKS:oid:0x15000000000360": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "20" + }, + "USER_WATERMARKS:oid:0x1500000000036d": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "1234567" + }, + "USER_WATERMARKS:oid:0x1500000000036e": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "7654321" + }, + "USER_WATERMARKS:oid:0x1500000000036f": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "USER_WATERMARKS:oid:0x15000000000370": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "USER_WATERMARKS:oid:0x15000000000371": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "USER_WATERMARKS:oid:0x15000000000372": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "20" + }, + "USER_WATERMARKS:oid:0x15000000000373": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "500" + }, + "USER_WATERMARKS:oid:0x15000000000374": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "200" + }, + "USER_WATERMARKS:oid:0x15000000000375": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "USER_WATERMARKS:oid:0x15000000000376": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "10" + }, + "USER_WATERMARKS:oid:0x1500000000037f": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "USER_WATERMARKS:oid:0x15000000000380": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "USER_WATERMARKS:oid:0x15000000000381": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "USER_WATERMARKS:oid:0x15000000000382": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "1986" + }, + "USER_WATERMARKS:oid:0x15000000000383": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "2567" + }, + "USER_WATERMARKS:oid:0x15000000000384": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "USER_WATERMARKS:oid:0x15000000000385": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "USER_WATERMARKS:oid:0x15000000000386": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "USER_WATERMARKS:oid:0x15000000000387": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "USER_WATERMARKS:oid:0x15000000000388": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "USER_WATERMARKS:oid:0x15000000000395": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "USER_WATERMARKS:oid:0x15000000000396": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "USER_WATERMARKS:oid:0x15000000000397": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "USER_WATERMARKS:oid:0x15000000000398": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "1986" + }, + "USER_WATERMARKS:oid:0x15000000000399": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "2567" + }, + "USER_WATERMARKS:oid:0x1500000000039a": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "USER_WATERMARKS:oid:0x1500000000039b": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "USER_WATERMARKS:oid:0x1500000000039c": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "USER_WATERMARKS:oid:0x1500000000039d": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "USER_WATERMARKS:oid:0x1500000000039e": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "USER_WATERMARKS:oid:0x150000000003a7": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "USER_WATERMARKS:oid:0x150000000003a8": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "USER_WATERMARKS:oid:0x150000000003a9": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "1040" + }, + "USER_WATERMARKS:oid:0x150000000003aa": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "USER_WATERMARKS:oid:0x150000000003ab": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "USER_WATERMARKS:oid:0x150000000003ac": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "USER_WATERMARKS:oid:0x150000000003ad": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "USER_WATERMARKS:oid:0x150000000003ae": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "USER_WATERMARKS:oid:0x150000000003af": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "8528" + }, + "USER_WATERMARKS:oid:0x150000000003b0": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "7696" + }, + "USER_WATERMARKS:oid:0x150000000003bd": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "20" + }, + "USER_WATERMARKS:oid:0x150000000003be": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "5" + }, + "USER_WATERMARKS:oid:0x150000000003bf": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "1998" + }, + "USER_WATERMARKS:oid:0x150000000003c0": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "USER_WATERMARKS:oid:0x150000000003c1": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "USER_WATERMARKS:oid:0x150000000003c2": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "USER_WATERMARKS:oid:0x150000000003c3": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "USER_WATERMARKS:oid:0x150000000003c4": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "USER_WATERMARKS:oid:0x150000000003c5": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "8528" + }, + "USER_WATERMARKS:oid:0x150000000003c6": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "7696" + }, + "PERSISTENT_WATERMARKS:oid:0x15000000000357": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "3057328" + }, + "PERSISTENT_WATERMARKS:oid:0x15000000000358": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "3056704" + }, + "PERSISTENT_WATERMARKS:oid:0x15000000000359": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "PERSISTENT_WATERMARKS:oid:0x1500000000035a": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "PERSISTENT_WATERMARKS:oid:0x1500000000035b": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "PERSISTENT_WATERMARKS:oid:0x1500000000035c": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "PERSISTENT_WATERMARKS:oid:0x1500000000035d": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "PERSISTENT_WATERMARKS:oid:0x1500000000035e": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "3704" + }, + "PERSISTENT_WATERMARKS:oid:0x1500000000035f": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "516" + }, + "PERSISTENT_WATERMARKS:oid:0x15000000000360": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "30" + }, + "PERSISTENT_WATERMARKS:oid:0x1500000000037f": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "PERSISTENT_WATERMARKS:oid:0x15000000000380": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "PERSISTENT_WATERMARKS:oid:0x15000000000381": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "PERSISTENT_WATERMARKS:oid:0x15000000000382": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "2986" + }, + "PERSISTENT_WATERMARKS:oid:0x15000000000383": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "3567" + }, + "PERSISTENT_WATERMARKS:oid:0x15000000000384": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "PERSISTENT_WATERMARKS:oid:0x15000000000385": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "PERSISTENT_WATERMARKS:oid:0x15000000000386": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "PERSISTENT_WATERMARKS:oid:0x15000000000387": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "PERSISTENT_WATERMARKS:oid:0x15000000000388": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "PERSISTENT_WATERMARKS:oid:0x150000000003a7": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "PERSISTENT_WATERMARKS:oid:0x150000000003a8": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "PERSISTENT_WATERMARKS:oid:0x150000000003a9": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "2040" + }, + "PERSISTENT_WATERMARKS:oid:0x150000000003aa": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "PERSISTENT_WATERMARKS:oid:0x150000000003ab": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "PERSISTENT_WATERMARKS:oid:0x150000000003ac": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "PERSISTENT_WATERMARKS:oid:0x150000000003ad": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "PERSISTENT_WATERMARKS:oid:0x150000000003ae": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0" + }, + "PERSISTENT_WATERMARKS:oid:0x150000000003af": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "9528" + }, + "PERSISTENT_WATERMARKS:oid:0x150000000003b0": { + "SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "8696" + }, + "USER_WATERMARKS:oid:0x18000000000b64": { + "SAI_BUFFER_POOL_STAT_WATERMARK_BYTES": "1000" + }, + "USER_WATERMARKS:oid:0x18000000000b65": { + "SAI_BUFFER_POOL_STAT_WATERMARK_BYTES": "2000" + }, + "USER_WATERMARKS:oid:0x18000000000b66": { + "SAI_BUFFER_POOL_STAT_WATERMARK_BYTES": "3000", + "SAI_BUFFER_POOL_STAT_XOFF_ROOM_WATERMARK_BYTES": "432640" + }, + "PERSISTENT_WATERMARKS:oid:0x18000000000b64": { + "SAI_BUFFER_POOL_STAT_WATERMARK_BYTES": "2000" + }, + "PERSISTENT_WATERMARKS:oid:0x18000000000b65": { + "SAI_BUFFER_POOL_STAT_WATERMARK_BYTES": "3000" + }, + "PERSISTENT_WATERMARKS:oid:0x18000000000b66": { + "SAI_BUFFER_POOL_STAT_WATERMARK_BYTES": "4000", + "SAI_BUFFER_POOL_STAT_XOFF_ROOM_WATERMARK_BYTES": "863616" + }, + "COUNTERS:oid:0x1500000000034e":{ + "SAI_COUNTER_STAT_PACKETS": 100, + "SAI_COUNTER_STAT_BYTES": 2000 + }, + "COUNTERS:oid:0x1600000000034e":{ + "SAI_COUNTER_STAT_PACKETS": 100, + "SAI_COUNTER_STAT_BYTES": 2000 + }, + "COUNTERS:oid:0x1600000000034f":{ + "SAI_COUNTER_STAT_PACKETS": 1000, + "SAI_COUNTER_STAT_BYTES": 2000 + }, + "COUNTERS:oid:0x1600000000035e":{ + "SAI_COUNTER_STAT_PACKETS": 50, + "SAI_COUNTER_STAT_BYTES": 1000 + }, + "COUNTERS:oid:0x1600000000035f":{ + "SAI_COUNTER_STAT_PACKETS": 1000, + "SAI_COUNTER_STAT_BYTES": 25000 + } +} diff --git a/tests/wm_input/wm_test_vectors.py b/tests/wm_input/wm_test_vectors.py index 336afdc42a..93d9faa4cb 100644 --- a/tests/wm_input/wm_test_vectors.py +++ b/tests/wm_input/wm_test_vectors.py @@ -61,6 +61,10 @@ Ethernet8 N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A """ +show_queue_wm_multicast_neg_output="""\ +Object map from the COUNTERS_DB is empty because the multicast queues are not configured in the CONFIG_DB! +""" + show_queue_wm_all_output="""\ Egress shared pool occupancy per all queues: Port ALL20 ALL21 ALL22 ALL23 ALL24 ALL25 ALL26 ALL27 ALL28 ALL29 @@ -140,6 +144,10 @@ 'rc_output': show_queue_wm_multicast_output } ], + 'show_q_wm_multicast_neg' : [ { 'cmd' : ['queue', 'watermark', 'multicast'], + 'rc_output': show_queue_wm_multicast_neg_output + } + ], 'show_q_pwm_multicast' : [ {'cmd' : ['queue', 'persistent-watermark', 'multicast'], 'rc_output': show_queue_wm_multicast_output } diff --git a/utilities_common/auto_techsupport_helper.py b/utilities_common/auto_techsupport_helper.py index 4eaae933b0..f9382bf2af 100644 --- a/utilities_common/auto_techsupport_helper.py +++ b/utilities_common/auto_techsupport_helper.py @@ -1,4 +1,5 @@ import os +import re import glob import time import subprocess @@ -13,7 +14,8 @@ "CFG_CORE_USAGE", "CFG_SINCE", "FEATURE", "STATE_DB", "TS_MAP", "CORE_DUMP", "TIMESTAMP", "CONTAINER", "TIME_BUF", "SINCE_DEFAULT", "TS_PTRN_GLOB", "EXT_LOCKFAIL", "EXT_RETRY", - "EXT_SUCCESS", "MAX_RETRY_LIMIT" + "EXT_SUCCESS", "MAX_RETRY_LIMIT", "TS_GLOBAL_TIMEOUT", + "EVENT_TYPE", "EVENT_TYPE_CORE", "EVENT_TYPE_MEMORY" ] + [ # Methods "verify_recent_file_creation", "get_ts_dumps", @@ -22,7 +24,8 @@ "pretty_size", "cleanup_process", "subprocess_exec", - "trim_masic_suffix" + "trim_masic_suffix", + "invoke_ts_command_rate_limited", ] @@ -35,8 +38,9 @@ TS_PTRN = "sonic_dump_.*tar.*" # Regex Exp TS_PTRN_GLOB = "sonic_dump_*tar*" # Glob Exp -# CONFIG DB Attributes +# DBs identifiers CFG_DB = "CONFIG_DB" +STATE_DB = "STATE_DB" # AUTO_TECHSUPPORT|GLOBAL table attributes AUTO_TS = "AUTO_TECHSUPPORT|GLOBAL" @@ -57,9 +61,19 @@ CORE_DUMP = "core_dump" TIMESTAMP = "timestamp" CONTAINER = "container_name" +EVENT_TYPE = "event_type" + +EVENT_TYPE_CORE = "core" +EVENT_TYPE_MEMORY = "memory" TIME_BUF = 20 SINCE_DEFAULT = "2 days ago" +TS_GLOBAL_TIMEOUT = "60" + +# Explicity Pass this to the subprocess invoking techsupport +ENV_VAR = os.environ +PATH_PREV = ENV_VAR["PATH"] if "PATH" in ENV_VAR else "" +ENV_VAR["PATH"] = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:" + PATH_PREV # Techsupport Exit Codes EXT_LOCKFAIL = 2 @@ -192,3 +206,130 @@ def trim_masic_suffix(container_name): break index = index - 1 return "".join(arr) + +def get_since_arg(db): + """Get since configuration from AUTO_TECHSUPPORT table or default value""" + since_cfg = db.get(CFG_DB, AUTO_TS, CFG_SINCE) + if not since_cfg: + return SINCE_DEFAULT + rc, _, stderr = subprocess_exec(["date", "--date={}".format(since_cfg)], env=ENV_VAR) + if rc == 0: + return since_cfg + return SINCE_DEFAULT + + +def parse_ts_dump_name(ts_stdout): + """ Figure out the ts_dump name from the techsupport stdout """ + matches = re.findall(TS_PTRN, ts_stdout) + if matches: + return matches[-1] + syslog.syslog(syslog.LOG_ERR, "stdout of the 'show techsupport' cmd doesn't have the dump name") + return "" + + +def invoke_ts_cmd(db, num_retry=0): + """Invoke techsupport generation command""" + since_cfg = get_since_arg(db) + cmd_opts = ["show", "techsupport", "--silent", "--global-timeout", TS_GLOBAL_TIMEOUT, "--since", since_cfg] + cmd = " ".join(cmd_opts) + rc, stdout, stderr = subprocess_exec(cmd_opts, env=ENV_VAR) + new_dump = "" + if rc == EXT_LOCKFAIL: + syslog.syslog(syslog.LOG_NOTICE, "Another instance of techsupport running, aborting this. stderr: {}".format(stderr)) + elif rc == EXT_RETRY: + if num_retry <= MAX_RETRY_LIMIT: + return invoke_ts_cmd(db, num_retry+1) + else: + syslog.syslog(syslog.LOG_ERR, "MAX_RETRY_LIMIT for show techsupport invocation exceeded, stderr: {}".format(stderr)) + elif rc != EXT_SUCCESS: + syslog.syslog(syslog.LOG_ERR, "show techsupport failed with exit code {}, stderr: {}".format(rc, stderr)) + else: # EXT_SUCCESS + new_dump = parse_ts_dump_name(stdout) # Parse the dump name + if not new_dump: + syslog.syslog(syslog.LOG_ERR, "{} was run, but no techsupport dump is found".format(cmd)) + else: + syslog.syslog(syslog.LOG_INFO, "{} is successful, {} is created".format(cmd, new_dump)) + return new_dump + + +def get_ts_map(db): + """Create ts_dump & creation_time map""" + ts_map = {} + ts_keys = db.keys(STATE_DB, TS_MAP+"*") + if not ts_keys: + return ts_map + for ts_key in ts_keys: + data = db.get_all(STATE_DB, ts_key) + if not data: + continue + container_name = data.get(CONTAINER, "") + creation_time = data.get(TIMESTAMP, "") + try: + creation_time = int(creation_time) + except Exception: + continue # if the creation time is invalid, skip the entry + ts_dump = ts_key.split("|")[-1] + if container_name not in ts_map: + ts_map[container_name] = [] + ts_map[container_name].append((int(creation_time), ts_dump)) + for container_name in ts_map: + ts_map[container_name].sort() + return ts_map + + +def verify_rate_limit_intervals(db, global_cooloff, container_cooloff, container): + """Verify both the global and per-proc rate_limit_intervals have passed""" + curr_ts_list = get_ts_dumps(True) + if global_cooloff and curr_ts_list: + last_ts_dump_creation = os.path.getmtime(curr_ts_list[-1]) + if time.time() - last_ts_dump_creation < global_cooloff: + msg = "Global rate_limit_interval period has not passed. Techsupport Invocation is skipped" + syslog.syslog(msg) + return False + + ts_map = get_ts_map(db) + if container_cooloff and container in ts_map: + last_creation_time = ts_map[container][0][0] + if time.time() - last_creation_time < container_cooloff: + msg = "Per Container rate_limit_interval for {} has not passed. Techsupport Invocation is skipped" + syslog.syslog(msg.format(container)) + return False + return True + + +def write_to_state_db(db, timestamp, ts_dump, event_type, event_data, container=None): + name = strip_ts_ext(ts_dump) + key = TS_MAP + "|" + name + db.set(STATE_DB, key, TIMESTAMP, str(timestamp)) + db.set(STATE_DB, key, EVENT_TYPE, event_type) + for event_data_key, event_data_value in event_data.items(): + db.set(STATE_DB, key, event_data_key, event_data_value) + if container: + db.set(STATE_DB, key, CONTAINER, container) + + +def invoke_ts_command_rate_limited(db, event_type, event_data, container=None): + """Invoke techsupport generation command accounting the rate limit""" + global_cooloff = db.get(CFG_DB, AUTO_TS, COOLOFF) + if container: + container_cooloff = db.get( + CFG_DB, FEATURE.format(container), COOLOFF + ) + else: + container_cooloff = 0.0 + + try: + global_cooloff = float(global_cooloff) + except ValueError: + global_cooloff = 0.0 + + try: + container_cooloff = float(container_cooloff) + except ValueError: + container_cooloff = 0.0 + + cooloff_passed = verify_rate_limit_intervals(db, global_cooloff, container_cooloff, container) + if cooloff_passed: + new_file = invoke_ts_cmd(db) + if new_file: + write_to_state_db(db, int(time.time()), new_file, event_type, event_data, container) diff --git a/utilities_common/bgp_util.py b/utilities_common/bgp_util.py index 3b2ef99a11..3897d4a103 100644 --- a/utilities_common/bgp_util.py +++ b/utilities_common/bgp_util.py @@ -1,6 +1,7 @@ import ipaddress import json import re +import sys import click import utilities_common.cli as clicommon @@ -185,7 +186,10 @@ def run_bgp_command(vtysh_cmd, bgp_namespace=multi_asic.DEFAULT_NAMESPACE, vtysh cmd = 'sudo {} {} -c "{}"'.format( vtysh_shell_cmd, bgp_instance_id, vtysh_cmd) try: - output = clicommon.run_command(cmd, return_cmd=True) + output, ret = clicommon.run_command(cmd, return_cmd=True) + if ret != 0: + click.echo(output.rstrip('\n')) + sys.exit(ret) except Exception: ctx = click.get_current_context() ctx.fail("Unable to get summary from bgp {}".format(bgp_instance_id)) @@ -193,7 +197,24 @@ def run_bgp_command(vtysh_cmd, bgp_namespace=multi_asic.DEFAULT_NAMESPACE, vtysh return output def run_bgp_show_command(vtysh_cmd, bgp_namespace=multi_asic.DEFAULT_NAMESPACE): - return run_bgp_command(vtysh_cmd, bgp_namespace, constants.RVTYSH_COMMAND) + output = run_bgp_command(vtysh_cmd, bgp_namespace, constants.RVTYSH_COMMAND) + # handle the the alias mode in the following code + if output is not None: + if clicommon.get_interface_naming_mode() == "alias" and re.search("show ip|ipv6 route", vtysh_cmd): + iface_alias_converter = clicommon.InterfaceAliasConverter() + route_info =json.loads(output) + for route, info in route_info.items(): + for i in range(0, len(info)): + if 'nexthops' in info[i]: + for j in range(0, len(info[i]['nexthops'])): + intf_name = "" + if 'interfaceName' in info[i]['nexthops'][j]: + intf_name = info[i]['nexthops'][j]['interfaceName'] + alias = iface_alias_converter.name_to_alias(intf_name) + if alias is not None: + info[i]['nexthops'][j]['interfaceName'] = alias + output= json.dumps(route_info) + return output def get_bgp_summary_from_all_bgp_instances(af, namespace, display): @@ -215,8 +236,10 @@ def get_bgp_summary_from_all_bgp_instances(af, namespace, display): except ValueError: ctx.fail("bgp summary from bgp container not in json format") + # exit cli command without printing the error message if key not in cmd_output_json: - ctx.fail("bgp summary from bgp container in invalid format") + click.echo("No IP{} neighbor is configured".format(af)) + exit() device.current_namespace = ns diff --git a/utilities_common/cli.py b/utilities_common/cli.py index c05069adcf..ca9e061078 100644 --- a/utilities_common/cli.py +++ b/utilities_common/cli.py @@ -4,9 +4,11 @@ import re import subprocess import sys +import shutil import click import json +import lazy_object_proxy import netaddr from natsort import natsorted @@ -183,8 +185,8 @@ def alias_to_name(self, interface_alias): # interface_alias not in port_dict. Just return interface_alias return interface_alias if sub_intf_sep_idx == -1 else interface_alias + VLAN_SUB_INTERFACE_SEPARATOR + vlan_id -# Global class instance for SONiC interface name to alias conversion -iface_alias_converter = InterfaceAliasConverter() +# Lazy global class instance for SONiC interface name to alias conversion +iface_alias_converter = lazy_object_proxy.Proxy(lambda: InterfaceAliasConverter()) def get_interface_naming_mode(): mode = os.getenv('SONIC_CLI_IFACE_MODE') @@ -292,7 +294,7 @@ def is_port_router_interface(config_db, port): interface_table = config_db.get_table('INTERFACE') for intf in interface_table: - if port == intf[0]: + if port == intf: return True return False @@ -302,7 +304,7 @@ def is_pc_router_interface(config_db, pc): pc_interface_table = config_db.get_table('PORTCHANNEL_INTERFACE') for intf in pc_interface_table: - if pc == intf[0]: + if pc == intf: return True return False @@ -527,7 +529,9 @@ def run_command(command, display_cmd=False, ignore_error=False, return_cmd=False # No conversion needed for intfutil commands as it already displays # both SONiC interface name and alias name for all interfaces. - if get_interface_naming_mode() == "alias" and not command.startswith("intfutil"): + # IP route table cannot be handled in function run_command_in_alias_mode since it is in JSON format + # with a list for next hops + if get_interface_naming_mode() == "alias" and not command.startswith("intfutil") and not re.search("show ip|ipv6 route", command): run_command_in_alias_mode(command) sys.exit(0) @@ -535,7 +539,7 @@ def run_command(command, display_cmd=False, ignore_error=False, return_cmd=False if return_cmd: output = proc.communicate()[0] - return output + return output, proc.returncode if not interactive_mode: (out, err) = proc.communicate() @@ -593,6 +597,7 @@ def is_interface_in_config_db(config_db, interface_name): if (not interface_name in config_db.get_keys('VLAN_INTERFACE') and not interface_name in config_db.get_keys('INTERFACE') and not interface_name in config_db.get_keys('PORTCHANNEL_INTERFACE') and + not interface_name in config_db.get_keys('VLAN_SUB_INTERFACE') and not interface_name == 'null'): return False @@ -661,3 +666,41 @@ def query_yes_no(question, default="yes"): else: sys.stdout.write("Please respond with 'yes' or 'no' " "(or 'y' or 'n').\n") + + +class UserCache: + """ General purpose cache directory created per user """ + + CACHE_DIR = "/tmp/cache/" + + def __init__(self, app_name=None, tag=None): + """ Initialize UserCache and create a cache directory if it does not exist. + + Args: + tag (str): Tag the user cache. Different tags correspond to different cache directories even for the same user. + """ + self.uid = os.getuid() + self.app_name = os.path.basename(sys.argv[0]) if app_name is None else app_name + self.cache_directory_suffix = str(self.uid) if tag is None else f"{self.uid}-{tag}" + self.cache_directory_app = os.path.join(self.CACHE_DIR, self.app_name) + + prev_umask = os.umask(0) + try: + os.makedirs(self.cache_directory_app, exist_ok=True) + finally: + os.umask(prev_umask) + + self.cache_directory = os.path.join(self.cache_directory_app, self.cache_directory_suffix) + os.makedirs(self.cache_directory, exist_ok=True) + + def get_directory(self): + """ Return the cache directory path """ + return self.cache_directory + + def remove(self): + """ Remove the content of the cache directory """ + shutil.rmtree(self.cache_directory) + + def remove_all(self): + """ Remove the content of the cache for all users """ + shutil.rmtree(self.cache_directory_app) diff --git a/utilities_common/general.py b/utilities_common/general.py index a2f9eaf2a9..6ed70a46a1 100644 --- a/utilities_common/general.py +++ b/utilities_common/general.py @@ -30,4 +30,15 @@ def load_db_config(): swsscommon.SonicDBConfig.load_sonic_global_db_config() else: if not swsscommon.SonicDBConfig.isInit(): - swsscommon.SonicDBConfig.load_sonic_db_config() \ No newline at end of file + swsscommon.SonicDBConfig.load_sonic_db_config() + +def get_optional_value_for_key_in_config_tbl(config_db, port, key, table): + info_dict = {} + info_dict = config_db.get_entry(table, port) + if info_dict is None: + return None + + value = info_dict.get(key, None) + + return value + diff --git a/utilities_common/multi_asic.py b/utilities_common/multi_asic.py index 7e704befe7..9e213f67f1 100644 --- a/utilities_common/multi_asic.py +++ b/utilities_common/multi_asic.py @@ -96,19 +96,21 @@ def multi_asic_display_default_option(): return constants.DISPLAY_EXTERNAL +_multi_asic_click_option_display = click.option('--display', + '-d', 'display', + default=multi_asic_display_default_option(), + show_default=True, + type=click.Choice(multi_asic_display_choices()), + help='Show internal interfaces') +_multi_asic_click_option_namespace = click.option('--namespace', + '-n', 'namespace', + default=None, + type=click.Choice(multi_asic_ns_choices()), + show_default=True, + help='Namespace name or all') _multi_asic_click_options = [ - click.option('--display', - '-d', 'display', - default=multi_asic_display_default_option(), - show_default=True, - type=click.Choice(multi_asic_display_choices()), - help='Show internal interfaces'), - click.option('--namespace', - '-n', 'namespace', - default=None, - type=click.Choice(multi_asic_ns_choices()), - show_default=True, - help='Namespace name or all'), + _multi_asic_click_option_display, + _multi_asic_click_option_namespace, ] def multi_asic_namespace_validation_callback(ctx, param, value): @@ -122,6 +124,9 @@ def multi_asic_click_options(func): func = option(func) return func +def multi_asic_click_option_namespace(func): + func = _multi_asic_click_option_namespace(func) + return func def run_on_multi_asic(func): ''' diff --git a/utilities_common/platform_sfputil_helper.py b/utilities_common/platform_sfputil_helper.py index a7f4477660..0de83f05b0 100644 --- a/utilities_common/platform_sfputil_helper.py +++ b/utilities_common/platform_sfputil_helper.py @@ -6,7 +6,11 @@ from sonic_py_common import multi_asic, device_info platform_sfputil = None +platform_chassis = None +platform_sfp_base = None +platform_porttab_mapping_read = False +RJ45_PORT_TYPE = 'RJ45' def load_platform_sfputil(): @@ -22,6 +26,10 @@ def load_platform_sfputil(): def platform_sfputil_read_porttab_mappings(): + global platform_porttab_mapping_read + + if platform_porttab_mapping_read: + return 0 try: @@ -35,6 +43,8 @@ def platform_sfputil_read_porttab_mappings(): # For single ASIC platforms we pass port_config_file_path and the asic_inst as 0 port_config_file_path = device_info.get_path_to_port_config_file() platform_sfputil.read_porttab_mappings(port_config_file_path, 0) + + platform_porttab_mapping_read = True except Exception as e: click.echo("Error reading port info (%s)" % str(e)) sys.exit(1) @@ -43,14 +53,17 @@ def platform_sfputil_read_porttab_mappings(): def logical_port_name_to_physical_port_list(port_name): - if port_name.startswith("Ethernet"): - if platform_sfputil.is_logical_port(port_name): - return platform_sfputil.get_logical_to_physical(port_name) + try: + if port_name.startswith("Ethernet"): + if platform_sfputil.is_logical_port(port_name): + return platform_sfputil.get_logical_to_physical(port_name) else: - click.echo("Invalid port '{}'".format(port_name)) - return None - else: - return [int(port_name)] + return [int(port_name)] + except ValueError: + pass + + click.echo("Invalid port '{}'".format(port_name)) + return None def get_logical_list(): @@ -70,7 +83,7 @@ def get_physical_to_logical(): def get_interface_name(port, db): - if port is not "all" and port is not None: + if port != "all" and port is not None: alias = port iface_alias_converter = clicommon.InterfaceAliasConverter(db) if clicommon.get_interface_naming_mode() == "alias": @@ -83,7 +96,7 @@ def get_interface_name(port, db): def get_interface_alias(port, db): - if port is not "all" and port is not None: + if port != "all" and port is not None: alias = port iface_alias_converter = clicommon.InterfaceAliasConverter(db) if clicommon.get_interface_naming_mode() == "alias": @@ -93,3 +106,42 @@ def get_interface_alias(port, db): sys.exit(1) return port + + +def is_rj45_port(port_name): + global platform_sfputil + global platform_chassis + global platform_sfp_base + global platform_sfputil_loaded + + try: + if not platform_chassis: + import sonic_platform + platform_chassis = sonic_platform.platform.Platform().get_chassis() + if not platform_sfp_base: + import sonic_platform_base + platform_sfp_base = sonic_platform_base.sfp_base.SfpBase + except ModuleNotFoundError as e: + # This method is referenced by intfutil which is called on vs image + # However, there is no platform API supported on vs image + # So False is returned in such case + return False + + if platform_chassis and platform_sfp_base: + if not platform_sfputil: + load_platform_sfputil() + + if not platform_porttab_mapping_read: + platform_sfputil_read_porttab_mappings() + + port_type = None + try: + physical_port = platform_sfputil.get_logical_to_physical(port_name) + if physical_port: + port_type = platform_chassis.get_port_or_cage_type(physical_port[0]) + except Exception as e: + pass + + return port_type == platform_sfp_base.SFP_PORT_TYPE_BIT_RJ45 + + return False diff --git a/utilities_common/sfp_helper.py b/utilities_common/sfp_helper.py new file mode 100644 index 0000000000..6ae9b85a1c --- /dev/null +++ b/utilities_common/sfp_helper.py @@ -0,0 +1,53 @@ +import ast + +QSFP_DATA_MAP = { + 'model': 'Vendor PN', + 'vendor_oui': 'Vendor OUI', + 'vendor_date': 'Vendor Date Code(YYYY-MM-DD Lot)', + 'manufacturer': 'Vendor Name', + 'vendor_rev': 'Vendor Rev', + 'serial': 'Vendor SN', + 'type': 'Identifier', + 'ext_identifier': 'Extended Identifier', + 'ext_rateselect_compliance': 'Extended RateSelect Compliance', + 'cable_length': 'cable_length', + 'cable_type': 'Length', + 'nominal_bit_rate': 'Nominal Bit Rate(100Mbs)', + 'specification_compliance': 'Specification compliance', + 'encoding': 'Encoding', + 'connector': 'Connector', + 'application_advertisement': 'Application Advertisement' +} + + +def covert_application_advertisement_to_output_string(indent, sfp_info_dict): + key = 'application_advertisement' + field_name = '{}{}: '.format(indent, QSFP_DATA_MAP[key]) + output = field_name + try: + app_adv_str = sfp_info_dict[key] + app_adv_dict = ast.literal_eval(app_adv_str) + if not app_adv_dict: + output += 'N/A\n' + else: + lines = [] + for item in app_adv_dict.values(): + host_interface_id = item.get('host_electrical_interface_id') + if not host_interface_id: + continue + elements = [] + elements.append(host_interface_id) + host_assign_options = item.get('host_lane_assignment_options') + host_assign_options = hex(host_assign_options) if host_assign_options else 'Unknown' + elements.append(f'Host Assign ({host_assign_options})') + elements.append(item.get('module_media_interface_id', 'Unknown')) + media_assign_options = item.get('media_lane_assignment_options') + media_assign_options = hex(media_assign_options) if media_assign_options else 'Unknown' + elements.append(f'Media Assign ({media_assign_options})') + lines.append(' - '.join(elements)) + sep = '\n' + ' ' * len(field_name) + output += sep.join(lines) + output += '\n' + except Exception: + output += '{}\n'.format(app_adv_str) + return output