Skip to content

Commit 48facca

Browse files
author
Taras Keryk
committed
Merge branch 'master' into tk_tof3_prof_nam_bf
2 parents 9895ee8 + c2d746d commit 48facca

File tree

4 files changed

+82
-6
lines changed

4 files changed

+82
-6
lines changed

scripts/db_migrator.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,12 @@ def common_migration_ops(self):
884884
new_cfg = {**init_cfg, **curr_cfg}
885885
self.configDB.set_entry(init_cfg_table, key, new_cfg)
886886

887-
self.migrate_copp_table()
887+
# Avoiding copp table migration is platform specific at the moment as I understood this might cause issues for some
888+
# vendors, probably Broadcom. This change can be checked with any specific vendor and if this works fine the platform
889+
# condition can be modified and extend. If no vendor has an issue with not clearing copp tables the condition can be
890+
# removed together with calling to migrate_copp_table function.
891+
if self.asic_type != "mellanox":
892+
self.migrate_copp_table()
888893
if self.asic_type == "broadcom" and 'Force10-S6100' in self.hwsku:
889894
self.migrate_mgmt_ports_on_s6100()
890895
else:

scripts/fast-reboot

+1-3
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ case "$REBOOT_TYPE" in
532532
check_warm_restart_in_progress
533533
BOOT_TYPE_ARG=$REBOOT_TYPE
534534
trap clear_boot EXIT HUP INT QUIT TERM KILL ABRT ALRM
535-
sonic-db-cli STATE_DB SET "FAST_REBOOT|system" "1" "EX" "180" &>/dev/null
535+
sonic-db-cli STATE_DB SET "FAST_REBOOT|system" "1" "EX" "210" &>/dev/null
536536
config warm_restart enable system
537537
;;
538538
"warm-reboot")
@@ -727,8 +727,6 @@ for service in ${SERVICES_TO_STOP}; do
727727
sonic-db-cli FLEX_COUNTER_DB FLUSHDB > /dev/null
728728
fi
729729
730-
# TODO: backup_database preserves FDB_TABLE
731-
# need to cleanup as well for fastfast boot case
732730
backup_database
733731
734732
fi

show/main.py

+24-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from datetime import datetime
2020
import utilities_common.constants as constants
2121
from utilities_common.general import load_db_config
22+
from json.decoder import JSONDecodeError
2223

2324
# mock the redis for unit test purposes #
2425
try:
@@ -129,6 +130,10 @@ def run_command(command, display_cmd=False, return_cmd=False):
129130
if rc != 0:
130131
sys.exit(rc)
131132

133+
def get_cmd_output(cmd):
134+
proc = subprocess.Popen(cmd, text=True, stdout=subprocess.PIPE)
135+
return proc.communicate()[0], proc.returncode
136+
132137
# Lazy global class instance for SONiC interface name to alias conversion
133138
iface_alias_converter = lazy_object_proxy.Proxy(lambda: clicommon.InterfaceAliasConverter())
134139

@@ -1383,8 +1388,25 @@ def runningconfiguration():
13831388
@click.option('--verbose', is_flag=True, help="Enable verbose output")
13841389
def all(verbose):
13851390
"""Show full running configuration"""
1386-
cmd = "sonic-cfggen -d --print-data"
1387-
run_command(cmd, display_cmd=verbose)
1391+
cmd = ['sonic-cfggen', '-d', '--print-data']
1392+
stdout, rc = get_cmd_output(cmd)
1393+
if rc:
1394+
click.echo("Failed to get cmd output '{}':rc {}".format(cmd, rc))
1395+
raise click.Abort()
1396+
1397+
try:
1398+
output = json.loads(stdout)
1399+
except JSONDecodeError as e:
1400+
click.echo("Failed to load output '{}':{}".format(cmd, e))
1401+
raise click.Abort()
1402+
1403+
if not multi_asic.is_multi_asic():
1404+
bgpraw_cmd = [constants.RVTYSH_COMMAND, '-c', 'show running-config']
1405+
bgpraw, rc = get_cmd_output(bgpraw_cmd)
1406+
if rc:
1407+
bgpraw = ""
1408+
output['bgpraw'] = bgpraw
1409+
click.echo(json.dumps(output, indent=4))
13881410

13891411

13901412
# 'acl' subcommand ("show runningconfiguration acl")

tests/show_test.py

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import os
2+
import sys
3+
import show.main as show
4+
from click.testing import CliRunner
5+
from unittest import mock
6+
from unittest.mock import call, MagicMock
7+
8+
test_path = os.path.dirname(os.path.abspath(__file__))
9+
modules_path = os.path.dirname(test_path)
10+
sys.path.insert(0, test_path)
11+
sys.path.insert(0, modules_path)
12+
13+
14+
class TestShowRunAllCommands(object):
15+
@classmethod
16+
def setup_class(cls):
17+
print("SETUP")
18+
os.environ["UTILITIES_UNIT_TESTING"] = "1"
19+
20+
def test_show_runningconfiguration_all_json_loads_failure(self):
21+
def get_cmd_output_side_effect(*args, **kwargs):
22+
return "", 0
23+
with mock.patch('show.main.get_cmd_output',
24+
mock.MagicMock(side_effect=get_cmd_output_side_effect)) as mock_get_cmd_output:
25+
result = CliRunner().invoke(show.cli.commands['runningconfiguration'].commands['all'], [])
26+
assert result.exit_code != 0
27+
28+
def test_show_runningconfiguration_all_get_cmd_ouput_failure(self):
29+
def get_cmd_output_side_effect(*args, **kwargs):
30+
return "{}", 2
31+
with mock.patch('show.main.get_cmd_output',
32+
mock.MagicMock(side_effect=get_cmd_output_side_effect)) as mock_get_cmd_output:
33+
result = CliRunner().invoke(show.cli.commands['runningconfiguration'].commands['all'], [])
34+
assert result.exit_code != 0
35+
36+
def test_show_runningconfiguration_all(self):
37+
def get_cmd_output_side_effect(*args, **kwargs):
38+
return "{}", 0
39+
with mock.patch('show.main.get_cmd_output',
40+
mock.MagicMock(side_effect=get_cmd_output_side_effect)) as mock_get_cmd_output:
41+
result = CliRunner().invoke(show.cli.commands['runningconfiguration'].commands['all'], [])
42+
assert mock_get_cmd_output.call_count == 2
43+
assert mock_get_cmd_output.call_args_list == [
44+
call(['sonic-cfggen', '-d', '--print-data']),
45+
call(['rvtysh', '-c', 'show running-config'])]
46+
47+
@classmethod
48+
def teardown_class(cls):
49+
print("TEARDOWN")
50+
os.environ["PATH"] = os.pathsep.join(os.environ["PATH"].split(os.pathsep)[:-1])
51+
os.environ["UTILITIES_UNIT_TESTING"] = "0"

0 commit comments

Comments
 (0)