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-engine] minigraph.py refactoring #448

Merged
merged 8 commits into from
Mar 30, 2017
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion dockers/docker-dhcp-relay/isc-dhcp-relay.j2
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SERVERS="{{ dhcp_servers | join(' ') }}"

INTERFACES="{{ minigraph_vlan_interfaces[0]['name'] }}"
INTERFACES="{{ minigraph_vlan_interfaces[0]['attachto'] }}"

# '-a' option provides option 82 circuit id information
OPTIONS="-a"
Expand Down
2 changes: 1 addition & 1 deletion dockers/docker-dhcp-relay/start.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

VLAN_IFACE_NAME=`sonic-cfggen -m /etc/sonic/minigraph.xml -v "minigraph_vlan_interfaces[0]['name']"`
VLAN_IFACE_NAME=`sonic-cfggen -m /etc/sonic/minigraph.xml -v "minigraph_vlan_interfaces[0]['attachto']"`

# Wait for the VLAN to come up (i.e., 'ip link show' returns 0)
until ip link show $VLAN_IFACE_NAME > /dev/null 2>&1; do
Expand Down
7 changes: 6 additions & 1 deletion dockers/docker-fpm-gobgp/zebra.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ enable password zebra
{% block interfaces %}
! Enable link-detect (default disabled)
{% for interface in minigraph_interfaces %}
interface {{ interface['alias'] }}
interface {{ interface['attachto'] }}
link-detect
!
{% endfor %}
{% for interface in minigraph_portchannels.keys() %}
interface {{ interface }}
link-detect
!
{% endfor %}
Expand Down
6 changes: 3 additions & 3 deletions dockers/docker-fpm/zebra.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ enable password zebra
{% block interfaces %}
! Enable link-detect (default disabled)
{% for interface in minigraph_interfaces %}
interface {{ interface['alias'] }}
interface {{ interface['attachto'] }}
link-detect
!
{% endfor %}
{% for interface in minigraph_portchannel_interfaces %}
interface {{ interface['name'] }}
{% for interface in minigraph_portchannels.keys() %}
interface {{ interface }}
link-detect
!
{% endfor %}
Expand Down
4 changes: 2 additions & 2 deletions dockers/docker-lldp-sv2/lldpd.conf.j2
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{% for member in alias_map %}
configure ports {{member['sonic']}} lldp portidsubtype local {{member['origin']}}
{% for member in minigraph_ports.keys() %}
configure ports {{member}} lldp portidsubtype local {{minigraph_ports[member]['alias']}}
{% endfor %}
5 changes: 5 additions & 0 deletions dockers/docker-snmp-sv2/alias_map.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
{% for member in minigraph_ports.keys() %}
"{{member}}": "{{minigraph_ports[member]['alias']}}"
{% endfor %}
}
2 changes: 1 addition & 1 deletion dockers/docker-snmp-sv2/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ mkdir -p /etc/snmp

sonic-cfggen -m /etc/sonic/minigraph.xml -y /etc/sonic/snmp.yml -t /usr/share/sonic/templates/snmpd.conf.j2 >/etc/snmp/snmpd.conf

sonic-cfggen -m /etc/sonic/minigraph.xml -s >/etc/snmp/alias_map.json
sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/alias_map.j2 >/etc/snmp/alias_map.json

mkdir -p /var/sonic
echo "# Config files managed by sonic-config-engine" >/var/sonic/config_status
Expand Down
56 changes: 28 additions & 28 deletions files/image_config/interfaces/interfaces.j2
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ iface eth0 inet static
{% for prefix in forced_mgmt_routes %}
down ip route delete {{ prefix }} via {{ minigraph_mgmt_interface['gwaddr'] }} dev eth0
{% endfor %}
{# TODO: COPP policy type rules #}
{# TODO: COPP policy type rules #}
{% else %}
iface eth0 inet dhcp
{% endif %}
Expand All @@ -46,53 +46,53 @@ iface eth0 inet dhcp
{% block front_panel_interfaces %}
# The switch front panel interfaces
{% for interface in minigraph_interfaces %}
auto {{ interface['alias'] }}
allow-hotplug {{ interface['alias'] }}
iface {{ interface['alias'] }} {{ 'inet' if interface['addr'] | ipv4 else 'inet6' }} static
auto {{ interface['attachto'] }}
allow-hotplug {{ interface['attachto'] }}
iface {{ interface['attachto'] }} {{ 'inet' if interface['addr'] | ipv4 else 'inet6' }} static
address {{ interface['addr'] }}
netmask {{ interface['mask'] }}
#
{% endfor %}
{% for vlan_interface in minigraph_vlan_interfaces|unique_name %}
Copy link
Contributor

@stcheng stcheng Mar 28, 2017

Choose a reason for hiding this comment

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

could you also remove the unique_name filter in sonic-cfggen? #WontFix

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I feel it's OK to keep it?


In reply to: 108321887 [](ancestors = 108321887)

{% for interface in vlan_interface['members'] %}
auto {{ interface }}
allow-hotplug {{ interface }}
iface {{ interface }} inet manual
pre-up ifconfig {{ interface }} up
post-up brctl addif {{ vlan_interface['name'] }} {{ interface }}
post-down ifconfig {{ interface }} down
{% for vlan in minigraph_vlans.keys()|sort %}
{% for member in minigraph_vlans[vlan]['members'] %}
auto {{ member }}
allow-hotplug {{ member }}
iface {{ member }} inet manual
pre-up ifconfig {{ member }} up
post-up brctl addif {{ vlan }} {{ member }}
post-down ifconfig {{ member }} down
#
{% endfor %}
{% endfor %}
# Add || true to suppress the error when docker-teamd starts after docker-swss
{% for pc_interface in minigraph_portchannel_interfaces|unique_name %}
{% for interface in pc_interface['members'] %}
{% if pc_interface['name'] not in pc_set %}
auto {{ interface }}
allow-hotplug {{ interface }}
iface {{ interface }} inet manual
pre-up teamdctl {{ pc_interface['name'] }} port add {{ interface }} || true
post-down ifconfig {{ interface }} down
# "|| true" is added to suppress the error when docker-teamd starts after docker-swss
{% for pc in minigraph_portchannels.keys()|sort %}
{% for member in minigraph_portchannels[pc]['members'] %}
auto {{ member }}
allow-hotplug {{ member }}
iface {{ member }} inet manual
pre-up teamdctl {{ pc }} port add {{ member }} || true
post-down ifconfig {{ member }} down
#
{% endif %}
{% endfor %}
{% endfor %}
{% endblock front_panel_interfaces %}
{% block vlan_interfaces %}
# Vlan interfaces
{% for vlan_interface in minigraph_vlan_interfaces %}
auto {{ vlan_interface['name'] }}
iface {{ vlan_interface['name'] }} {{ 'inet' if vlan_interface['addr'] | ipv4 else 'inet6' }} static
auto {{ vlan_interface['attachto'] }}
iface {{ vlan_interface['attachto'] }} {{ 'inet' if vlan_interface['addr'] | ipv4 else 'inet6' }} static
bridge_ports none
address {{ vlan_interface['addr'] }}
netmask {{ vlan_interface['mask'] }}
#
{% endfor %}
#
{% endblock vlan_interfaces %}
{% block pc_interfaces %}
# Portchannel interfaces
{% for pc_interface in minigraph_portchannel_interfaces %}
auto {{ pc_interface['name'] }}
allow-hotplug {{ pc_interface['name'] }}
iface {{ pc_interface['name'] }} {{ 'inet' if pc_interface['addr'] | ipv4 else 'inet6' }} static
auto {{ pc_interface['attachto'] }}
allow-hotplug {{ pc_interface['attachto'] }}
iface {{ pc_interface['attachto'] }} {{ 'inet' if pc_interface['addr'] | ipv4 else 'inet6' }} static
address {{ pc_interface['addr'] }}
netmask {{ pc_interface['mask'] }}
#
Expand Down
4 changes: 2 additions & 2 deletions slave.mk
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,13 @@ $(SONIC_INSTALL_TARGETS) : $(DEBS_PATH)/%-install : .platform $$(addsuffix -inst
# $(SOME_NEW_WHL)_SRC_PATH = $(SRC_PATH)/project_name
# $(SOME_NEW_WHL)_PYTHON_VERSION = 2 (or 3)
# $(SOME_NEW_WHL)_DEPENDS = $(SOME_OTHER_WHL1) $(SOME_OTHER_WHL2) ...
# SONIC_PYTHON_WHEELS += $(SOME_NEW_DEB)
# SONIC_PYTHON_WHEELS += $(SOME_NEW_WHL)
$(addprefix $(PYTHON_WHEELS_PATH)/, $(SONIC_PYTHON_WHEELS)) : $(PYTHON_WHEELS_PATH)/% : .platform $$(addsuffix -install,$$(addprefix $(PYTHON_WHEELS_PATH)/,$$($$*_DEPENDS)))
$(HEADER)
pushd $($*_SRC_PATH) $(LOG)
# apply series of patches if exist
if [ -f ../$(notdir $($*_SRC_PATH)).patch/series ]; then QUILT_PATCHES=../$(notdir $($*_SRC_PATH)).patch quilt push -a; fi
python$($*_PYTHON_VERSION) setup.py bdist_wheel $(LOG)
python$($*_PYTHON_VERSION) setup.py bdist_wheel test $(LOG)
# clean up
if [ -f ../$(notdir $($*_SRC_PATH)).patch/series ]; then quilt pop -a -f; fi
popd $(LOG)
Expand Down
Loading