Skip to content
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

[config load_mgmt_config] add default route #123

Merged
merged 1 commit into from
Oct 6, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,13 @@ def load_mgmt_config(filename):
hostname = config_data['DEVICE_METADATA']['localhost']['hostname']
_change_hostname(hostname)
mgmt_conf = netaddr.IPNetwork(config_data['MGMT_INTERFACE'].keys()[0][1])
gw_addr = config_data['MGMT_INTERFACE'].values()[0]['gwaddr']
command = "ifconfig eth0 {} netmask {}".format(str(mgmt_conf.ip), str(mgmt_conf.netmask))
run_command(command, display_cmd=True)
command = "ip route add default via {} dev eth0 table default".format(gw_addr)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this management address ipv4? In our template, we support ipv6 mgmt port.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current device_desc file parser enforces that mgmt address is ipv4.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok.

run_command(command, display_cmd=True)
command = "ip rule add from {} table default".format(str(mgmt_conf.ip))
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)
print "Please note loaded setting will be lost after system reboot. To preserve setting, run `config save`."
Expand Down