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

Adapt to new minigraph_parser schema #103

Merged
merged 1 commit into from
Sep 19, 2017
Merged
Show file tree
Hide file tree
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
9 changes: 5 additions & 4 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import click
import json
import subprocess
import netaddr
from swsssdk import ConfigDBConnector
from minigraph import parse_device_desc_xml

Expand Down Expand Up @@ -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)
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion scripts/teamshow
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
2 changes: 1 addition & 1 deletion sfputil/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions show/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,15 +275,15 @@ 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
f = open(PLATFORM_TEMPLATE_FILE, 'w')
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())

Expand Down