Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
Signed-off-by: Mai Bui <maibui@microsoft.com>
  • Loading branch information
maipbui committed May 26, 2023
1 parent f6c49a9 commit 63a7c16
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1656,18 +1656,17 @@ def load_mgmt_config(filename):
clicommon.run_command(command, display_cmd=True, ignore_error=True)
if len(config_data['MGMT_INTERFACE'].keys()) > 0:
filepath = '/var/run/dhclient.eth0.pid'
if os.path.isfile(filepath):
out0, rc0 = clicommon.run_command(['cat', filepath], display_cmd=True, return_cmd=True)
if rc0 == 0:
out1, rc1 = clicommon.run_command(['kill', out0], return_cmd=True)
if rc1 == 0:
clicommon.run_command(['rm', '-f', filepath], display_cmd=True, return_cmd=True)
else:
sys.exit('Exit: {}. Command: kill {} failed.'.format(rc1, out0))
else:
sys.exit('Exit: {}. Command: cat {} failed.'.format(rc0, filepath))
else:
if not os.path.isfile(filepath):
sys.exit('File {} does not exist'.format(filepath))

out0, rc0 = clicommon.run_command(['cat', filepath], display_cmd=True, return_cmd=True)
if rc0 != 0:
sys.exit('Exit: {}. Command: cat {} failed.'.format(rc0, filepath))

out1, rc1 = clicommon.run_command(['kill', str(out0).strip('\n')], return_cmd=True)
if rc1 != 0:
sys.exit('Exit: {}. Command: kill {} failed.'.format(rc1, out0))
clicommon.run_command(['rm', '-f', filepath], display_cmd=True, return_cmd=True)
click.echo("Please note loaded setting will be lost after system reboot. To preserve setting, run `config save`.")

@config.command("load_minigraph")
Expand Down

0 comments on commit 63a7c16

Please sign in to comment.