diff --git a/config/main.py b/config/main.py index 8ffc38e5b6a9..6208cc7ddaca 100644 --- a/config/main.py +++ b/config/main.py @@ -5,6 +5,7 @@ import click import json import subprocess +import netaddr from swsssdk import ConfigDBConnector from minigraph import parse_device_desc_xml @@ -127,10 +128,10 @@ def load_mgmt_config(filename): run_command(command, display_cmd=True) #FIXME: After config DB daemon for hostname and mgmt interface is implemented, we'll no longer need to do manual configuration here config_data = parse_device_desc_xml(filename) - hostname = config_data['minigraph_hostname'] + hostname = config_data['DEVICE_METADATA']['localhost']['hostname'] _change_hostname(hostname) - mgmt_conf = config_data['minigraph_mgmt_interface'] - command = "ifconfig eth0 {} netmask {}".format(str(mgmt_conf['addr']), str(mgmt_conf['mask'])) + mgmt_conf = netaddr.IPNetwork(config_data['MGMT_INTERFACE'].keys()[0][1]) + command = "ifconfig eth0 {} netmask {}".format(str(mgmt_conf.ip), str(mgmt_conf.netmask)) 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) @@ -142,7 +143,7 @@ def load_minigraph(): """Reconfigure based on minigraph.""" command = "{} -m --write-to-db".format(SONIC_CFGGEN_PATH) run_command(command, display_cmd=True) - command = "{} -m -v minigraph_hostname".format(SONIC_CFGGEN_PATH) + command = "{} -m -v \"DEVICE_METADATA['localhost']['hostname']\"".format(SONIC_CFGGEN_PATH) p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE) p.wait() hostname = p.communicate()[0].strip() diff --git a/scripts/teamshow b/scripts/teamshow index 6c988a7c3ba2..e31913aafe0a 100755 --- a/scripts/teamshow +++ b/scripts/teamshow @@ -49,7 +49,7 @@ class Teamshow(object): minigraph_path = '/etc/sonic/minigraph.xml' machine_info = get_machine_info() platform_info = get_platform_info(machine_info) - self.teams = parse_xml(minigraph_path, platform = platform_info)['minigraph_portchannels'].keys(); + self.teams = parse_xml(minigraph_path, platform = platform_info)['PORTCHANNEL'].keys(); def get_portchannel_status(self, port_channel_name): """ diff --git a/sfputil/main.py b/sfputil/main.py index 74b24c558770..d7ad92d0bfd7 100644 --- a/sfputil/main.py +++ b/sfputil/main.py @@ -28,7 +28,7 @@ PLATFORM_ROOT_PATH = '/usr/share/sonic/device' SONIC_CFGGEN_PATH = '/usr/local/bin/sonic-cfggen' MINIGRAPH_PATH = '/etc/sonic/minigraph.xml' -HWSKU_KEY = 'minigraph_hwsku' +HWSKU_KEY = "DEVICE_METADATA['localhost']['hwsku']" PLATFORM_KEY = 'platform' # Global platform-specific sfputil class instance diff --git a/show/main.py b/show/main.py index 62d029c9dd9f..4191ecc6de70 100644 --- a/show/main.py +++ b/show/main.py @@ -275,7 +275,7 @@ def summary(): PLATFORM_TEMPLATE_FILE = "/tmp/cli_platform_{0}.j2".format(username) PLATFORM_TEMPLATE_CONTENTS = "Platform: {{ platform }}\n" \ - "HwSKU: {{ minigraph_hwsku }}\n" \ + "HwSKU: {{ DEVICE_METADATA['localhost']['hwsku'] }}\n" \ "ASIC: {{ asic_type }}" # Create a temporary Jinja2 template file to use with sonic-cfggen @@ -283,7 +283,7 @@ def summary(): f.write(PLATFORM_TEMPLATE_CONTENTS) f.close() - command = "sonic-cfggen -m /etc/sonic/minigraph.xml -y /etc/sonic/sonic_version.yml -t {0}".format(PLATFORM_TEMPLATE_FILE) + command = "sonic-cfggen -d -y /etc/sonic/sonic_version.yml -t {0}".format(PLATFORM_TEMPLATE_FILE) p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE) click.echo(p.stdout.read())