-
Notifications
You must be signed in to change notification settings - Fork 669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support to reload mgmt conf file and minigraph #93
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
import json | ||
import subprocess | ||
from swsssdk import ConfigDBConnector | ||
from minigraph import parse_device_desc_xml | ||
|
||
SONIC_CFGGEN_PATH = "sonic-cfggen" | ||
MINIGRAPH_PATH = "/etc/sonic/minigraph.xml" | ||
|
@@ -112,6 +113,40 @@ def load(filename): | |
command = "{} -j {} --write-to-db".format(SONIC_CFGGEN_PATH, filename) | ||
run_command(command, display_cmd=True) | ||
|
||
@cli.command() | ||
@click.option('-y', '--yes', is_flag=True, callback=_abort_if_false, | ||
expose_value=False, prompt='Reload mgmt config?') | ||
@click.argument('filename', default='/etc/sonic/device_desc.xml', type=click.Path(exists=True)) | ||
def load_mgmt_config(filename): | ||
"""Reconfigure mgmt interface based on device description file.""" | ||
command = "{} -M {} --write-to-db".format(SONIC_CFGGEN_PATH, filename) | ||
run_command(command, display_cmd=True) | ||
#FIXME: After config DB daemon for mgmt interface is implemented, we'll no longer need to manually config mgmt interface here | ||
mgmt_conf = parse_device_desc_xml(filename)['minigraph_mgmt_interface'] | ||
command = "ifconfig eth0 {} netmask {}".format(str(mgmt_conf['addr']), str(mgmt_conf['mask'])) | ||
run_command(command, display_cmd=True) | ||
command = "[ -f /var/run/dhclient.eth0.pid ] && kill `cat /var/run/dhclient.eth0.pid` && rm -f /var/run/dhclient.eth0.pid" | ||
run_command(command, display_cmd=True) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we do interfaces-config restart here? #WontFix There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No. Because interfaces-config service will read data from minigraph but not device description file. #Closed |
||
|
||
@cli.command() | ||
@click.option('-y', '--yes', is_flag=True, callback=_abort_if_false, | ||
expose_value=False, prompt='Reload config from minigraph?') | ||
def load_minigraph(): | ||
"""Reconfigure based on minigraph.""" | ||
command = "{} -m --write-to-db".format(SONIC_CFGGEN_PATH) | ||
run_command(command, display_cmd=True) | ||
#FIXME: After config DB daemon is implemented, we'll no longer need to restart every service. | ||
run_command("service interfaces-config restart", display_cmd=True) | ||
run_command("service ntp-config restart", display_cmd=True) | ||
run_command("service rsyslog-config restart", display_cmd=True) | ||
run_command("service swss restart", display_cmd=True) | ||
run_command("service bgp restart", display_cmd=True) | ||
run_command("service teamd restart", display_cmd=True) | ||
run_command("service pmon restart", display_cmd=True) | ||
run_command("service lldp restart", display_cmd=True) | ||
run_command("service snmp restart", display_cmd=True) | ||
run_command("service dhcp_relay restart", display_cmd=True) | ||
|
||
# | ||
# 'bgp' group | ||
# | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we do interfaces-config restart here like below? #WontFix