Skip to content

Commit 3a43d49

Browse files
committed
Adapt to new minigraph_parser schema (#103)
1 parent b82ea42 commit 3a43d49

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

config/main.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import click
66
import json
77
import subprocess
8+
import netaddr
89
from swsssdk import ConfigDBConnector
910
from minigraph import parse_device_desc_xml
1011

@@ -127,10 +128,10 @@ def load_mgmt_config(filename):
127128
run_command(command, display_cmd=True)
128129
#FIXME: After config DB daemon for hostname and mgmt interface is implemented, we'll no longer need to do manual configuration here
129130
config_data = parse_device_desc_xml(filename)
130-
hostname = config_data['minigraph_hostname']
131+
hostname = config_data['DEVICE_METADATA']['localhost']['hostname']
131132
_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))
134135
run_command(command, display_cmd=True)
135136
command = "[ -f /var/run/dhclient.eth0.pid ] && kill `cat /var/run/dhclient.eth0.pid` && rm -f /var/run/dhclient.eth0.pid"
136137
run_command(command, display_cmd=True)
@@ -142,7 +143,7 @@ def load_minigraph():
142143
"""Reconfigure based on minigraph."""
143144
command = "{} -m --write-to-db".format(SONIC_CFGGEN_PATH)
144145
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)
146147
p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
147148
p.wait()
148149
hostname = p.communicate()[0].strip()

scripts/teamshow

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class Teamshow(object):
4949
minigraph_path = '/etc/sonic/minigraph.xml'
5050
machine_info = get_machine_info()
5151
platform_info = get_platform_info(machine_info)
52-
self.teams = parse_xml(minigraph_path, platform = platform_info)['minigraph_portchannels'].keys();
52+
self.teams = parse_xml(minigraph_path, platform = platform_info)['PORTCHANNEL'].keys();
5353

5454
def get_portchannel_status(self, port_channel_name):
5555
"""

sfputil/main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
PLATFORM_ROOT_PATH = '/usr/share/sonic/device'
2929
SONIC_CFGGEN_PATH = '/usr/local/bin/sonic-cfggen'
3030
MINIGRAPH_PATH = '/etc/sonic/minigraph.xml'
31-
HWSKU_KEY = 'minigraph_hwsku'
31+
HWSKU_KEY = "DEVICE_METADATA['localhost']['hwsku']"
3232
PLATFORM_KEY = 'platform'
3333

3434
# Global platform-specific sfputil class instance

show/main.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -275,15 +275,15 @@ def summary():
275275

276276
PLATFORM_TEMPLATE_FILE = "/tmp/cli_platform_{0}.j2".format(username)
277277
PLATFORM_TEMPLATE_CONTENTS = "Platform: {{ platform }}\n" \
278-
"HwSKU: {{ minigraph_hwsku }}\n" \
278+
"HwSKU: {{ DEVICE_METADATA['localhost']['hwsku'] }}\n" \
279279
"ASIC: {{ asic_type }}"
280280

281281
# Create a temporary Jinja2 template file to use with sonic-cfggen
282282
f = open(PLATFORM_TEMPLATE_FILE, 'w')
283283
f.write(PLATFORM_TEMPLATE_CONTENTS)
284284
f.close()
285285

286-
command = "sonic-cfggen -m /etc/sonic/minigraph.xml -y /etc/sonic/sonic_version.yml -t {0}".format(PLATFORM_TEMPLATE_FILE)
286+
command = "sonic-cfggen -d -y /etc/sonic/sonic_version.yml -t {0}".format(PLATFORM_TEMPLATE_FILE)
287287
p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
288288
click.echo(p.stdout.read())
289289

0 commit comments

Comments
 (0)