Skip to content

Commit

Permalink
Fix del vlan command (#2982)
Browse files Browse the repository at this point in the history
Resolves sonic-net/sonic-buildimage#16542
#### What I did
Update str -> list[str] commands which were missed in #2718
#### How I did it
#### How to verify it
Pass UT. Manual test, issue resolved, tested in internal.79435802-3bbd91c86e version
Signed-off-by: Mai Bui <maibui@microsoft.com>
  • Loading branch information
maipbui committed Sep 15, 2023
1 parent ff6f8f3 commit 5729028
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions config/vlan.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,21 +176,21 @@ def del_vlan(db, vid, multiple, no_restart_dhcp_relay):

vlans = db.cfgdb.get_keys('VLAN')
if not vlans:
docker_exec_cmd = "docker exec -i swss {}"
_, rc = clicommon.run_command(docker_exec_cmd.format("supervisorctl status ndppd"), ignore_error=True, return_cmd=True)
docker_exec_cmd = ['docker', 'exec', '-i', 'swss']
_, rc = clicommon.run_command(docker_exec_cmd + ['supervisorctl', 'status', 'ndppd'], ignore_error=True, return_cmd=True)
if rc == 0:
click.echo("No VLANs remaining, stopping ndppd service")
clicommon.run_command(docker_exec_cmd.format("supervisorctl stop ndppd"), ignore_error=True, return_cmd=True)
clicommon.run_command(docker_exec_cmd.format("rm -f /etc/supervisor/conf.d/ndppd.conf"), ignore_error=True, return_cmd=True)
clicommon.run_command(docker_exec_cmd.format("supervisorctl update"), return_cmd=True)
clicommon.run_command(docker_exec_cmd + ['supervisorctl', 'stop', 'ndppd'], ignore_error=True, return_cmd=True)
clicommon.run_command(docker_exec_cmd + ['rm', '-f', '/etc/supervisor/conf.d/ndppd.conf'], ignore_error=True, return_cmd=True)
clicommon.run_command(docker_exec_cmd + ['supervisorctl', 'update'], return_cmd=True)


def restart_ndppd():
verify_swss_running_cmd = ['docker', 'container', 'inspect', '-f', '{{.State.Status}}', 'swss']
docker_exec_cmd = ['docker', 'exec', '-i', 'swss']
ndppd_config_gen_cmd = ['sonic-cfggen', '-d', '-t', '/usr/share/sonic/templates/ndppd.conf.j2,/etc/ndppd.conf']
ndppd_restart_cmd =['supervisorctl', 'restart', 'ndppd']
ndppd_status_cmd= ["supervisorctl", "status", "ndppd"]
ndppd_restart_cmd = ['supervisorctl', 'restart', 'ndppd']
ndppd_status_cmd = ["supervisorctl", "status", "ndppd"]
ndppd_conf_copy_cmd = ['cp', '/usr/share/sonic/templates/ndppd.conf', '/etc/supervisor/conf.d/']
supervisor_update_cmd = ['supervisorctl', 'update']

Expand Down
8 changes: 4 additions & 4 deletions tests/vlan_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,10 +630,10 @@ def test_config_vlan_del_last_vlan(self):
print(result.exit_code)
print(result.output)
mock_run_command.assert_has_calls([
mock.call("docker exec -i swss supervisorctl status ndppd", ignore_error=True, return_cmd=True),
mock.call("docker exec -i swss supervisorctl stop ndppd", ignore_error=True, return_cmd=True),
mock.call("docker exec -i swss rm -f /etc/supervisor/conf.d/ndppd.conf", ignore_error=True, return_cmd=True),
mock.call("docker exec -i swss supervisorctl update", return_cmd=True)
mock.call(['docker', 'exec', '-i', 'swss', 'supervisorctl', 'status', 'ndppd'], ignore_error=True, return_cmd=True),
mock.call(['docker', 'exec', '-i', 'swss', 'supervisorctl', 'stop', 'ndppd'], ignore_error=True, return_cmd=True),
mock.call(['docker', 'exec', '-i', 'swss', 'rm', '-f', '/etc/supervisor/conf.d/ndppd.conf'], ignore_error=True, return_cmd=True),
mock.call(['docker', 'exec', '-i', 'swss', 'supervisorctl', 'update'], return_cmd=True)
])
assert result.exit_code == 0

Expand Down

0 comments on commit 5729028

Please sign in to comment.