5
5
import click
6
6
import json
7
7
import subprocess
8
+ import netaddr
8
9
from swsssdk import ConfigDBConnector
9
10
from minigraph import parse_device_desc_xml
10
11
@@ -127,10 +128,10 @@ def load_mgmt_config(filename):
127
128
run_command (command , display_cmd = True )
128
129
#FIXME: After config DB daemon for hostname and mgmt interface is implemented, we'll no longer need to do manual configuration here
129
130
config_data = parse_device_desc_xml (filename )
130
- hostname = config_data ['minigraph_hostname ' ]
131
+ hostname = config_data ['DEVICE_METADATA' ][ 'localhost' ][ 'hostname ' ]
131
132
_change_hostname (hostname )
132
- mgmt_conf = config_data ['minigraph_mgmt_interface' ]
133
- command = "ifconfig eth0 {} netmask {}" .format (str (mgmt_conf [ 'addr' ] ), str (mgmt_conf [ 'mask' ] ))
133
+ mgmt_conf = netaddr . IPNetwork ( config_data ['MGMT_INTERFACE' ]. keys ()[ 0 ][ 1 ])
134
+ command = "ifconfig eth0 {} netmask {}" .format (str (mgmt_conf . ip ), str (mgmt_conf . netmask ))
134
135
run_command (command , display_cmd = True )
135
136
command = "[ -f /var/run/dhclient.eth0.pid ] && kill `cat /var/run/dhclient.eth0.pid` && rm -f /var/run/dhclient.eth0.pid"
136
137
run_command (command , display_cmd = True )
@@ -142,7 +143,7 @@ def load_minigraph():
142
143
"""Reconfigure based on minigraph."""
143
144
command = "{} -m --write-to-db" .format (SONIC_CFGGEN_PATH )
144
145
run_command (command , display_cmd = True )
145
- command = "{} -m -v minigraph_hostname " .format (SONIC_CFGGEN_PATH )
146
+ command = "{} -m -v \" DEVICE_METADATA['localhost']['hostname'] \" " .format (SONIC_CFGGEN_PATH )
146
147
p = subprocess .Popen (command , shell = True , stdout = subprocess .PIPE )
147
148
p .wait ()
148
149
hostname = p .communicate ()[0 ].strip ()
0 commit comments