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

Add support for vlanconfd and intfconfd #1063

Merged
merged 5 commits into from
Nov 6, 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
4 changes: 4 additions & 0 deletions dockers/docker-orchagent/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ supervisorctl start neighsyncd

supervisorctl start swssconfig

supervisorctl start vlanmgrd

supervisorctl start intfmgrd

# Start arp_update when VLAN exists
VLAN=`sonic-cfggen -d -v 'VLAN.keys() | join(" ") if VLAN'`
if [ "$VLAN" != "" ]; then
Expand Down
16 changes: 16 additions & 0 deletions dockers/docker-orchagent/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,19 @@ autostart=false
autorestart=true
stdout_logfile=syslog
stderr_logfile=syslog

[program:vlanmgrd]
command=/usr/bin/vlanmgrd
priority=9
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog

[program:intfmgrd]
command=/usr/bin/intfmgrd
priority=10
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog
27 changes: 0 additions & 27 deletions files/image_config/interfaces/interfaces.j2
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,6 @@ iface {{ name }} {{ 'inet' if prefix | ipv4 else 'inet6' }} static
netmask {{ prefix | netmask if prefix | ipv4 else prefix | prefixlen }}
#
{% endfor %}
{% if VLAN %}
# "|| true" is added to suppress the error when interface is already a member of VLAN
{% for vlan in VLAN.keys()|sort %}
{% for member in VLAN[vlan]['members'] %}
allow-hotplug {{ member }}
iface {{ member }} inet manual
pre-up ifconfig {{ member }} up mtu 9100
post-up brctl addif {{ vlan }} {{ member }} || true
post-down ifconfig {{ member }} down
#
{% endfor %}
{% endfor %}
{% endif %}
{% if PORTCHANNEL %}
# "|| true" is added to suppress the error when interface is already a member of LAG
# "ip link show | grep -q master" is added to ensure interface is enslaved
Expand All @@ -83,20 +70,6 @@ iface {{ member }} inet manual
{% endfor %}
{% endif %}
{% endblock front_panel_interfaces %}
{% block vlan_interfaces %}
{% if VLAN_INTERFACE %}
# Vlan interfaces
{% for (name, prefix) in VLAN_INTERFACE.keys() | sort %}
auto {{ name }}
iface {{ name }} {{ 'inet' if prefix | ipv4 else 'inet6' }} static
bridge_ports none
hwaddress ether {{ hwaddr }}
address {{ prefix | ip }}
netmask {{ prefix | netmask if prefix | ipv4 else prefix | prefixlen }}
{% endfor %}
#
{% endif %}
{% endblock vlan_interfaces %}
{% block pc_interfaces %}
{% if PORTCHANNEL_INTERFACE %}
# Portchannel interfaces
Expand Down
18 changes: 12 additions & 6 deletions src/sonic-config-engine/minigraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
ns1 = "http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"
ns2 = "Microsoft.Search.Autopilot.NetMux"
ns3 = "http://www.w3.org/2001/XMLSchema-instance"

KEY_SEPARATOR = '|'

class minigraph_encoder(json.JSONEncoder):
def default(self, obj):
Expand Down Expand Up @@ -86,7 +86,7 @@ def parse_png(png, hname):
if child.tag == str(QName(ns, "Devices")):
for device in child.findall(str(QName(ns, "Device"))):
(lo_prefix, mgmt_prefix, name, hwsku, d_type) = parse_device(device)
device_data = {'lo_addr': lo_prefix, 'type': d_type, 'mgmt_addr': mgmt_prefix, 'hwsku': hwsku }
device_data = {'lo_addr': lo_prefix, 'type': d_type, 'mgmt_addr': mgmt_prefix, 'hwsku': hwsku }
devices[name] = device_data

if child.tag == str(QName(ns, "DeviceInterfaceLinks")):
Expand Down Expand Up @@ -153,14 +153,18 @@ def parse_dpg(dpg, hname):
vlanintfs = child.find(str(QName(ns, "VlanInterfaces")))
vlan_intfs = []
vlans = {}
vlan_members = {}
for vintf in vlanintfs.findall(str(QName(ns, "VlanInterface"))):
vintfname = vintf.find(str(QName(ns, "Name"))).text
vlanid = vintf.find(str(QName(ns, "VlanID"))).text
vintfmbr = vintf.find(str(QName(ns, "AttachTo"))).text
vmbr_list = vintfmbr.split(';')
for i, member in enumerate(vmbr_list):
vmbr_list[i] = port_alias_map.get(member, member)
vlan_attributes = {'members': vmbr_list, 'vlanid': vlanid}
sonic_vlan_member_name = "Vlan%s%s%s" % (vlanid, KEY_SEPARATOR, vmbr_list[i])
vlan_members[sonic_vlan_member_name] = {'tagging_mode': 'untagged'}

vlan_attributes = {'vlanid': vlanid}

# If this VLAN requires a DHCP relay agent, it will contain a <DhcpRelays> element
# containing a list of DHCP server IPs
Expand Down Expand Up @@ -194,8 +198,8 @@ def parse_dpg(dpg, hname):
break;
if acl_intfs:
acls[aclname] = { 'policy_desc': aclname, 'ports': acl_intfs, 'type': 'MIRROR' if is_mirror else 'L3'}
return intfs, lo_intfs, mgmt_intf, vlans, pcs, acls
return None, None, None, None, None, None
return intfs, lo_intfs, mgmt_intf, vlans, vlan_members, pcs, acls
return None, None, None, None, None, None, None


def parse_cpg(cpg, hname):
Expand Down Expand Up @@ -318,6 +322,7 @@ def parse_xml(filename, platform=None, port_config_file=None):
vlan_intfs = None
pc_intfs = None
vlans = None
vlan_members = None
pcs = None
mgmt_intf = None
lo_intf = None
Expand Down Expand Up @@ -345,7 +350,7 @@ def parse_xml(filename, platform=None, port_config_file=None):
port_alias_map.update(alias_map)
for child in root:
if child.tag == str(QName(ns, "DpgDec")):
(intfs, lo_intfs, mgmt_intf, vlans, pcs, acls) = parse_dpg(child, hostname)
(intfs, lo_intfs, mgmt_intf, vlans, vlan_members, pcs, acls) = parse_dpg(child, hostname)
elif child.tag == str(QName(ns, "CpgDec")):
(bgp_sessions, bgp_asn, bgp_peers_with_range) = parse_cpg(child, hostname)
elif child.tag == str(QName(ns, "PngDec")):
Expand Down Expand Up @@ -393,6 +398,7 @@ def parse_xml(filename, platform=None, port_config_file=None):
results['PORT'] = ports
results['PORTCHANNEL'] = pcs
results['VLAN'] = vlans
results['VLAN_MEMBER'] = vlan_members

results['DEVICE_NEIGHBOR'] = neighbors
results['DEVICE_NEIGHBOR_METADATA'] = { key:devices[key] for key in devices if key != hostname }
Expand Down
153 changes: 0 additions & 153 deletions src/sonic-config-engine/tests/sample_output/interfaces
Original file line number Diff line number Diff line change
Expand Up @@ -39,151 +39,6 @@ iface eth0 inet6 static
down ip -6 rule delete from 2603:10e2:0:2902::8/128 table default
#
# The switch front panel interfaces
# "|| true" is added to suppress the error when interface is already a member of VLAN
allow-hotplug fortyGigE0/4
iface fortyGigE0/4 inet manual
pre-up ifconfig fortyGigE0/4 up mtu 9100
post-up brctl addif Vlan1000 fortyGigE0/4 || true
post-down ifconfig fortyGigE0/4 down
#
allow-hotplug fortyGigE0/8
iface fortyGigE0/8 inet manual
pre-up ifconfig fortyGigE0/8 up mtu 9100
post-up brctl addif Vlan1000 fortyGigE0/8 || true
post-down ifconfig fortyGigE0/8 down
#
allow-hotplug fortyGigE0/12
iface fortyGigE0/12 inet manual
pre-up ifconfig fortyGigE0/12 up mtu 9100
post-up brctl addif Vlan1000 fortyGigE0/12 || true
post-down ifconfig fortyGigE0/12 down
#
allow-hotplug fortyGigE0/16
iface fortyGigE0/16 inet manual
pre-up ifconfig fortyGigE0/16 up mtu 9100
post-up brctl addif Vlan1000 fortyGigE0/16 || true
post-down ifconfig fortyGigE0/16 down
#
allow-hotplug fortyGigE0/20
iface fortyGigE0/20 inet manual
pre-up ifconfig fortyGigE0/20 up mtu 9100
post-up brctl addif Vlan1000 fortyGigE0/20 || true
post-down ifconfig fortyGigE0/20 down
#
allow-hotplug fortyGigE0/24
iface fortyGigE0/24 inet manual
pre-up ifconfig fortyGigE0/24 up mtu 9100
post-up brctl addif Vlan1000 fortyGigE0/24 || true
post-down ifconfig fortyGigE0/24 down
#
allow-hotplug fortyGigE0/28
iface fortyGigE0/28 inet manual
pre-up ifconfig fortyGigE0/28 up mtu 9100
post-up brctl addif Vlan1000 fortyGigE0/28 || true
post-down ifconfig fortyGigE0/28 down
#
allow-hotplug fortyGigE0/32
iface fortyGigE0/32 inet manual
pre-up ifconfig fortyGigE0/32 up mtu 9100
post-up brctl addif Vlan1000 fortyGigE0/32 || true
post-down ifconfig fortyGigE0/32 down
#
allow-hotplug fortyGigE0/36
iface fortyGigE0/36 inet manual
pre-up ifconfig fortyGigE0/36 up mtu 9100
post-up brctl addif Vlan1000 fortyGigE0/36 || true
post-down ifconfig fortyGigE0/36 down
#
allow-hotplug fortyGigE0/40
iface fortyGigE0/40 inet manual
pre-up ifconfig fortyGigE0/40 up mtu 9100
post-up brctl addif Vlan1000 fortyGigE0/40 || true
post-down ifconfig fortyGigE0/40 down
#
allow-hotplug fortyGigE0/44
iface fortyGigE0/44 inet manual
pre-up ifconfig fortyGigE0/44 up mtu 9100
post-up brctl addif Vlan1000 fortyGigE0/44 || true
post-down ifconfig fortyGigE0/44 down
#
allow-hotplug fortyGigE0/48
iface fortyGigE0/48 inet manual
pre-up ifconfig fortyGigE0/48 up mtu 9100
post-up brctl addif Vlan1000 fortyGigE0/48 || true
post-down ifconfig fortyGigE0/48 down
#
allow-hotplug fortyGigE0/52
iface fortyGigE0/52 inet manual
pre-up ifconfig fortyGigE0/52 up mtu 9100
post-up brctl addif Vlan1000 fortyGigE0/52 || true
post-down ifconfig fortyGigE0/52 down
#
allow-hotplug fortyGigE0/56
iface fortyGigE0/56 inet manual
pre-up ifconfig fortyGigE0/56 up mtu 9100
post-up brctl addif Vlan1000 fortyGigE0/56 || true
post-down ifconfig fortyGigE0/56 down
#
allow-hotplug fortyGigE0/60
iface fortyGigE0/60 inet manual
pre-up ifconfig fortyGigE0/60 up mtu 9100
post-up brctl addif Vlan1000 fortyGigE0/60 || true
post-down ifconfig fortyGigE0/60 down
#
allow-hotplug fortyGigE0/64
iface fortyGigE0/64 inet manual
pre-up ifconfig fortyGigE0/64 up mtu 9100
post-up brctl addif Vlan1000 fortyGigE0/64 || true
post-down ifconfig fortyGigE0/64 down
#
allow-hotplug fortyGigE0/68
iface fortyGigE0/68 inet manual
pre-up ifconfig fortyGigE0/68 up mtu 9100
post-up brctl addif Vlan1000 fortyGigE0/68 || true
post-down ifconfig fortyGigE0/68 down
#
allow-hotplug fortyGigE0/72
iface fortyGigE0/72 inet manual
pre-up ifconfig fortyGigE0/72 up mtu 9100
post-up brctl addif Vlan1000 fortyGigE0/72 || true
post-down ifconfig fortyGigE0/72 down
#
allow-hotplug fortyGigE0/76
iface fortyGigE0/76 inet manual
pre-up ifconfig fortyGigE0/76 up mtu 9100
post-up brctl addif Vlan1000 fortyGigE0/76 || true
post-down ifconfig fortyGigE0/76 down
#
allow-hotplug fortyGigE0/80
iface fortyGigE0/80 inet manual
pre-up ifconfig fortyGigE0/80 up mtu 9100
post-up brctl addif Vlan1000 fortyGigE0/80 || true
post-down ifconfig fortyGigE0/80 down
#
allow-hotplug fortyGigE0/84
iface fortyGigE0/84 inet manual
pre-up ifconfig fortyGigE0/84 up mtu 9100
post-up brctl addif Vlan1000 fortyGigE0/84 || true
post-down ifconfig fortyGigE0/84 down
#
allow-hotplug fortyGigE0/88
iface fortyGigE0/88 inet manual
pre-up ifconfig fortyGigE0/88 up mtu 9100
post-up brctl addif Vlan1000 fortyGigE0/88 || true
post-down ifconfig fortyGigE0/88 down
#
allow-hotplug fortyGigE0/92
iface fortyGigE0/92 inet manual
pre-up ifconfig fortyGigE0/92 up mtu 9100
post-up brctl addif Vlan1000 fortyGigE0/92 || true
post-down ifconfig fortyGigE0/92 down
#
allow-hotplug fortyGigE0/96
iface fortyGigE0/96 inet manual
pre-up ifconfig fortyGigE0/96 up mtu 9100
post-up brctl addif Vlan1000 fortyGigE0/96 || true
post-down ifconfig fortyGigE0/96 down
#
# "|| true" is added to suppress the error when interface is already a member of LAG
# "ip link show | grep -q master" is added to ensure interface is enslaved
allow-hotplug fortyGigE0/112
Expand All @@ -210,14 +65,6 @@ iface fortyGigE0/124 inet manual
post-up ip link show fortyGigE0/124 | grep -q master && ifconfig fortyGigE0/124 up
post-down ifconfig fortyGigE0/124 down
#
# Vlan interfaces
auto Vlan1000
iface Vlan1000 inet static
bridge_ports none
hwaddress ether e4:1d:2d:a5:f3:ad
address 192.168.0.1
netmask 255.255.255.224
#
# Portchannel interfaces
allow-hotplug PortChannel01
iface PortChannel01 inet static
Expand Down
7 changes: 6 additions & 1 deletion src/sonic-config-engine/tests/test_cfggen.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@ def test_minigraph_interfaces(self):
def test_minigraph_vlans(self):
argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" -v VLAN'
output = self.run_script(argument)
self.assertEqual(output.strip(), "{'Vlan1000': {'dhcp_servers': ['192.0.0.1', '192.0.0.2'], 'members': ['Ethernet8'], 'vlanid': '1000'}}")
self.assertEqual(output.strip(), "{'Vlan1000': {'dhcp_servers': ['192.0.0.1', '192.0.0.2'], 'vlanid': '1000'}}")

def test_minigraph_vlan_members(self):
argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" -v VLAN_MEMBER'
output = self.run_script(argument)
self.assertEqual(output.strip(), "{'Vlan1000|Ethernet8': {'tagging_mode': 'untagged'}}")

def test_minigraph_vlan_interfaces(self):
argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" -v "VLAN_INTERFACE.keys()"'
Expand Down
2 changes: 1 addition & 1 deletion src/sonic-swss
2 changes: 1 addition & 1 deletion src/sonic-swss-common