Skip to content

Commit

Permalink
[multi-asic][minigraph]: Modify minigraph templates for multi-asic pl…
Browse files Browse the repository at this point in the history
…atform (#3025)

What is the motivation for this PR?
Minigraph template changes to support minigraph generation for multi-asic platform.

How did you do it?
Pre-requisite: #3024
Add changes to minigraph templates to use the new data structure asic_topo_config and include asic topology.

How did you verify/test it?
With the changes in PR#3024:
Bring up four-asic VS testbed using the changes in: #2858
testbed-cli.sh -t vtestbed.csv -m veos_vtb -k ceos add-topo vms-kvm-four-asic-t1-lag password.txt
Deploy minigraph using:
./testbed-cli.sh -t vtestbed.csv -m veos_vtb deploy-mg vms-kvm-four-asic-t1-lag lab password.txt
With this, minigraph should be generated and deployed on the multi-asic VS DUT.
Check all interfaces status and BGP status.
  • Loading branch information
SuvarnaMeenakshi authored Mar 10, 2021
1 parent 17dc195 commit 986592b
Show file tree
Hide file tree
Showing 5 changed files with 357 additions and 0 deletions.
79 changes: 79 additions & 0 deletions ansible/templates/minigraph_cpg.j2
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@
<HoldTime>10</HoldTime>
<KeepAliveTime>3</KeepAliveTime>
</BGPSession>
{% if vm_asic_ifnames is defined %}
<BGPSession>
<MacSec>false</MacSec>
<StartRouter>{{ vm_asic_ifnames[vm][0].split('-')[1] }}</StartRouter>
<StartPeer>{{ vm_topo_config['vm'][vm]['bgp_ipv4'][dut_index|int] }}</StartPeer>
<EndRouter>{{ vm }}</EndRouter>
<EndPeer>{{ vm_topo_config['vm'][vm]['peer_ipv4'][dut_index|int] }}</EndPeer>
<Multihop>1</Multihop>
<HoldTime>10</HoldTime>
<KeepAliveTime>3</KeepAliveTime>
</BGPSession>
{% endif %}
{% endif %}
{% if vm_topo_config['vm'][vm]['peer_ipv6'][dut_index|int] %}
<BGPSession>
Expand All @@ -25,7 +37,45 @@
<HoldTime>10</HoldTime>
<KeepAliveTime>3</KeepAliveTime>
</BGPSession>
{% if vm_asic_ifnames is defined %}
<BGPSession>
<StartRouter>{{ vm_asic_ifnames[vm][0].split('-')[1] }}</StartRouter>
<StartPeer>{{ vm_topo_config['vm'][vm]['bgp_ipv6'][dut_index|int] }}</StartPeer>
<EndRouter>{{ vm }}</EndRouter>
<EndPeer>{{ vm_topo_config['vm'][vm]['peer_ipv6'][dut_index|int] }}</EndPeer>
<Multihop>1</Multihop>
<HoldTime>10</HoldTime>
<KeepAliveTime>3</KeepAliveTime>
</BGPSession>
{% endif %}
{% endif %}
{% endfor %}
{% for asic in asic_topo_config %}
{% for neigh_asic in asic_topo_config[asic]['neigh_asic'] %}
{% if asic_topo_config[asic]['neigh_asic'][neigh_asic]['peer_ipv4'][0] %}
<BGPSession>
<MacSec>false</MacSec>
<StartRouter>{{ asic }}</StartRouter>
<StartPeer>{{ asic_topo_config[asic]['neigh_asic'][neigh_asic]['bgp_ipv4'][0] }}</StartPeer>
<EndRouter>{{ neigh_asic }}</EndRouter>
<EndPeer>{{ asic_topo_config[asic]['neigh_asic'][neigh_asic]['peer_ipv4'][0] }}</EndPeer>
<Multihop>1</Multihop>
<HoldTime>0</HoldTime>
<KeepAliveTime>0</KeepAliveTime>
</BGPSession>
{% endif %}
{% if asic_topo_config[asic]['neigh_asic'][neigh_asic]['peer_ipv6'][0] %}
<BGPSession>
<StartRouter>{{ asic }}</StartRouter>
<StartPeer>{{ asic_topo_config[asic]['neigh_asic'][neigh_asic]['bgp_ipv6'][0] }}</StartPeer>
<EndRouter>{{ neigh_asic }}</EndRouter>
<EndPeer>{{ asic_topo_config[asic]['neigh_asic'][neigh_asic]['peer_ipv6'][0] }}</EndPeer>
<Multihop>1</Multihop>
<HoldTime>0</HoldTime>
<KeepAliveTime>0</KeepAliveTime>
</BGPSession>
{% endif %}
{% endfor %}
{% endfor %}
</PeeringSessions>
<Routers xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
Expand Down Expand Up @@ -77,6 +127,35 @@
{% endif %}
{% endfor %}
{% endif %}
{% for asic in asic_topo_config %}
<a:BGPRouterDeclaration>
<a:ASN>{{ vm_topo_config['dut_asn'] }}</a:ASN>
<a:Hostname>{{ asic }}</a:Hostname>
<a:Peers>
{% for index in range( vms_number) %}
{% if vm_asic_ifnames[vms[index]][0].split('-')[1] == asic %}
<BGPPeer>
<Address>{{ vm_topo_config['vm'][vms[index]]['peer_ipv4'][dut_index|int] }}</Address>
<RouteMapIn i:nil="true"/>
<RouteMapOut i:nil="true"/>
<Vrf i:nil="true"/>
</BGPPeer>
{% endif %}
{% endfor %}
{% for neigh_asic in asic_topo_config %}
{% if neigh_asic in asic_topo_config[asic]['neigh_asic'] and asic_topo_config[asic]['neigh_asic'][neigh_asic]['peer_ipv4'][0] %}
<BGPPeer>
<Address>{{ asic_topo_config[asic]['neigh_asic'][neigh_asic]['peer_ipv4'][0] }}</Address>
<RouteMapIn i:nil="true"/>
<RouteMapOut i:nil="true"/>
<Vrf i:nil="true"/>
</BGPPeer>
{% endif %}
{% endfor %}
</a:Peers>
<a:RouteMaps/>
</a:BGPRouterDeclaration>
{% endfor %}
</Routers>
</CpgDec>

1 change: 1 addition & 0 deletions ansible/templates/minigraph_dpg.j2
Original file line number Diff line number Diff line change
Expand Up @@ -210,5 +210,6 @@
<DownstreamSummaries/>
<DownstreamSummarySet xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
</DeviceDataPlaneInfo>
{% include 'minigraph_dpg_asic.j2' %}
</DpgDec>

208 changes: 208 additions & 0 deletions ansible/templates/minigraph_dpg_asic.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
{% macro port_channel_id(asic_idx, neigh_asic_idx) -%}
{{ ((4000 + asic_idx + (10*neigh_asic_idx))|string) }}
{%- endmacro -%}
{% for asic in asic_topo_config %}
{% set asic_index = asic.split('ASIC')[1]|int %}
<DeviceDataPlaneInfo>
<IPSecTunnels/>
<LoopbackIPInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
<a:LoopbackIPInterface>
<Name>HostIP</Name>
<AttachTo>Loopback0</AttachTo>
<a:Prefix xmlns:b="Microsoft.Search.Autopilot.Evolution">
<b:IPPrefix>{{ lp_ipv4 }}</b:IPPrefix>
</a:Prefix>
<a:PrefixStr>{{ lp_ipv4 }}</a:PrefixStr>
</a:LoopbackIPInterface>
<a:LoopbackIPInterface>
<Name>HostIP1</Name>
<AttachTo>Loopback0</AttachTo>
<a:Prefix xmlns:b="Microsoft.Search.Autopilot.Evolution">
<b:IPPrefix>{{ lp_ipv6 }}</b:IPPrefix>
</a:Prefix>
<a:PrefixStr>{{ lp_ipv6 }}</a:PrefixStr>
</a:LoopbackIPInterface>
{% for lo4096 in asic_topo_config[asic]['Loopback4096'] %}
<a:LoopbackIPInterface>
<Name>HostIP1</Name>
<AttachTo>Loopback4096</AttachTo>
<a:Prefix xmlns:b="Microsoft.Search.Autopilot.Evolution">
<b:IPPrefix>{{ lo4096 }}</b:IPPrefix>
</a:Prefix>
<a:PrefixStr>{{ lo4096 }}</a:PrefixStr>
</a:LoopbackIPInterface>
{% endfor %}
</LoopbackIPInterfaces>
<ManagementIPInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
<a:ManagementIPInterface>
<Name>HostIP</Name>
<AttachTo>eth0</AttachTo>
<a:Prefix xmlns:b="Microsoft.Search.Autopilot.Evolution">
<b:IPPrefix>{{ ansible_host }}/{{ mgmt_subnet_mask_length }}</b:IPPrefix>
</a:Prefix>
<a:PrefixStr>{{ ansible_host }}/{{ mgmt_subnet_mask_length }}</a:PrefixStr>
</a:ManagementIPInterface>
<a:ManagementIPInterface>
<Name>V6HostIP</Name>
<AttachTo>eth0</AttachTo>
<a:Prefix xmlns:b="Microsoft.Search.Autopilot.Evolution">
<b:IPPrefix>{{ ansible_hostv6 if ansible_hostv6 is defined else 'FC00:2::32' }}/64</b:IPPrefix>
</a:Prefix>
<a:PrefixStr>{{ ansible_hostv6 if ansible_hostv6 is defined else 'FC00:2::32' }}/64</a:PrefixStr>
</a:ManagementIPInterface>
</ManagementIPInterfaces>
<ManagementVIPInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
<MplsInterfaces/>
<MplsTeInterfaces/>
<RsvpInterfaces/>
<Hostname>{{ asic }}</Hostname>
<PortChannelInterfaces>
{% for index in range(vms_number) %}
{% if vm_asic_ifnames[vms[index]][0].split('-')[1] == asic %}
{% if 'port-channel' in vm_topo_config['vm'][vms[index]]['ip_intf'][dut_index|int]|lower %}
{% set port_channel_intf=';'.join(vm_asic_ifnames[vms[index]]) %}
<PortChannel>
<Name>PortChannel{{ ((index+1)|string).zfill(4) }}</Name>
<AttachTo>{{ port_channel_intf }}</AttachTo>
<SubInterface/>
</PortChannel>
{% endif %}
{% endif %}
{% endfor %}
{% for neigh_asic in asic_topo_config %}
{%- set pc_intfs = [] -%}
{%- if neigh_asic in asic_topo_config[asic]['neigh_asic'] and 'port-channel' in asic_topo_config[asic]['neigh_asic'][neigh_asic]['ip_intf'][0]|lower -%}
{%- for intf in asic_topo_config[asic]['neigh_asic'][neigh_asic]['asic_intfs'][0] %}
{{- pc_intfs.append(intf) }}
{%- endfor -%}
{%- set port_channel_intf=pc_intfs|join(';') -%}
{% set neigh_asic_index = neigh_asic.split('ASIC')[1]|int %}
<PortChannel>
<Name>PortChannel{{ port_channel_id(asic_index, neigh_asic_index).zfill(4) }}</Name>
<AttachTo>{{ port_channel_intf }}</AttachTo>
<SubInterface/>
</PortChannel>
{% endif %}
{% endfor %}
</PortChannelInterfaces>
<SubInterfaces/>
<VlanInterfaces/>
<IPInterfaces>
{% for index in range(vms_number) %}
{% if vm_asic_ifnames[vms[index]][0].split('-')[1] == asic %}
{% if vm_topo_config['vm'][vms[index]]['ip_intf'][dut_index|int] is not none %}
<IPInterface>
<Name i:nil="true"/>
{% if 'port-channel' in vm_topo_config['vm'][vms[index]]['ip_intf'][dut_index|int]|lower %}
<AttachTo>PortChannel{{ ((index+1) |string).zfill(4) }}</AttachTo>
{% else %}
<AttachTo>{{ front_panel_asic_ifnames[vm_topo_config['vm'][vms[index]]['interface_indexes'][dut_index|int][0]] }}</AttachTo>
{% endif %}
<Prefix>{{ vm_topo_config['vm'][vms[index]]['bgp_ipv4'][dut_index|int] }}/{{ vm_topo_config['vm'][vms[index]]['ipv4mask'][dut_index|int] }}</Prefix>
</IPInterface>
<IPInterface>
<Name i:Name="true"/>
{% if 'port-channel' in vm_topo_config['vm'][vms[index]]['ip_intf'][dut_index|int]|lower %}
<AttachTo>PortChannel{{ ((index+1) |string).zfill(4) }}</AttachTo>
{% else %}
<AttachTo>{{ front_panel_asic_ifnames[vm_topo_config['vm'][vms[index]]['interface_indexes'][dut_index|int][0]] }}</AttachTo>
{% endif %}
<Prefix>{{ vm_topo_config['vm'][vms[index]]['bgp_ipv6'][dut_index|int] }}/{{ vm_topo_config['vm'][vms[index]]['ipv6mask'][dut_index|int] }}</Prefix>
</IPInterface>
{% endif %}
{% endif %}
{% endfor %}
{% for neigh_asic in asic_topo_config[asic]['neigh_asic'] %}
<IPInterface>
<Name i:nil="true"/>
{%- if 'port-channel' in asic_topo_config[asic]['neigh_asic'][neigh_asic]['ip_intf'][0]|lower %}
{%- set neigh_asic_index = neigh_asic.split('ASIC')[1]|int %}
<AttachTo>PortChannel{{ port_channel_id(asic_index, neigh_asic_index).zfill(4) }}</AttachTo>
{% else %}
<AttachTo>{{ asic_topo_config[asic]['neigh_asic'][neigh_asic]['asic_intfs'][0][0] }}</AttachTo>
{% endif %}
<Prefix>{{ asic_topo_config[asic]['neigh_asic'][neigh_asic]['bgp_ipv4'][0] }}/{{ asic_topo_config[asic]['neigh_asic'][neigh_asic]['ipv4mask'][0] }}</Prefix>
</IPInterface>
<IPInterface>
<Name i:nil="true"/>
{%- if 'port-channel' in asic_topo_config[asic]['neigh_asic'][neigh_asic]['ip_intf'][0]|lower %}
{%- set neigh_asic_index = neigh_asic.split('ASIC')[1]|int %}
<AttachTo>PortChannel{{ port_channel_id(asic_index, neigh_asic_index).zfill(4) }}</AttachTo>
{% else %}
<AttachTo>{{ asic_topo_config[asic]['neigh_asic'][neigh_asic]['asic_intfs'][0][0] }}</AttachTo>
{% endif %}
<Prefix>{{ asic_topo_config[asic]['neigh_asic'][neigh_asic]['bgp_ipv6'][0] }}/{{ asic_topo_config[asic]['neigh_asic'][neigh_asic]['ipv6mask'][0] }}</Prefix>
</IPInterface>
{% endfor %}
</IPInterfaces>
<DataAcls/>
<AclInterfaces>
<AclInterface>
<InAcl>SNMP_ACL</InAcl>
<AttachTo>SNMP</AttachTo>
<Type>SNMP</Type>
</AclInterface>
<AclInterface>
<AttachTo>ERSPAN</AttachTo>
<InAcl>Everflow</InAcl>
<Type>Everflow</Type>
</AclInterface>
<AclInterface>
<AttachTo>ERSPANV6</AttachTo>
<InAcl>EverflowV6</InAcl>
<Type>EverflowV6</Type>
</AclInterface>
<AclInterface>
<AttachTo>VTY_LINE</AttachTo>
<InAcl>ssh-only</InAcl>
<Type>SSH</Type>
</AclInterface>
<AclInterface>
<AttachTo>
{%- set acl_intfs = [] -%}
{%- for index in range(vms_number) %}
{% if vm_asic_ifnames[vms[index]][0].split('-')[1] == asic %}
{% if 'port-channel' in vm_topo_config['vm'][vms[index]]['ip_intf'][0]|lower %}
{% set a_intf = 'PortChannel' + ((index+1) |string).zfill(4) %}
{{- acl_intfs.append(a_intf) -}}
{% endif %}
{% endif %}
{% endfor %}
{% for neigh_asic in asic_topo_config %}
{% set neigh_asic_index = neigh_asic.split('ASIC')[1]|int %}
{%- if neigh_asic in asic_topo_config[asic]['neigh_asic'] and 'port-channel' in asic_topo_config[asic]['neigh_asic'][neigh_asic]['ip_intf'][0]|lower -%}
{% set a_intf = 'PortChannel' + port_channel_id(asic_index, neigh_asic_index).zfill(4) %}
{{- acl_intfs.append(a_intf) -}}
{% endif %}
{% endfor %}

{%- for index in range(vms_number) -%}
{% if vm_asic_ifnames[vms[index]][0].split('-')[1] == asic %}
{% if 'port-channel' not in vm_topo_config['vm'][vms[index]]['ip_intf'][0]|lower %}
{% if vm_topo_config['vm'][vms[index]]['intfs'][dut_index|int]|length %}
{% set a_intf = front_panel_asic_ifnames[vm_topo_config['vm'][vms[index]]['interface_indexes'][dut_index|int][0]] %}
{{- acl_intfs.append(a_intf) -}}
{% endif %}
{% endif %}
{% endif %}
{% endfor -%}
{%- for neigh_asic in asic_topo_config -%}
{%- if neigh_asic in asic_topo_config[asic]['neigh_asic'] and 'port-channel' not in asic_topo_config[asic]['neigh_asic'][neigh_asic]['ip_intf'][0]|lower -%}
{% if asic_topo_config[asic]['neigh_asic'][neigh_asic]['intfs'][0]|length %}
{% set a_intf = asic_topo_config[asic]['neigh_asic'][neigh_asic]['asic_intfs'][0][0] %}
{{- acl_intfs.append(a_intf) -}}
{% endif %}
{% endif %}
{% endfor %}

{{- acl_intfs|join(';') -}}
</AttachTo>
<InAcl>DataAcl</InAcl>
<Type>DataPlane</Type>
</AclInterface>
</AclInterfaces>
<DownstreamSummaries/>
<DownstreamSummarySet xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
</DeviceDataPlaneInfo>
{% endfor %}

12 changes: 12 additions & 0 deletions ansible/templates/minigraph_meta.j2
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@
{% endif %}
</a:Properties>
</a:DeviceMetadata>
{% for asic in asic_topo_config %}
<a:DeviceMetadata>
<a:Name>{{ asic }}</a:Name>
<a:Properties>
<a:DeviceProperty>
<a:Name>SubRole</a:Name>
<a:Reference i:nil="true"/>
<a:Value>{{ asic_topo_config[asic]['asic_type'] }}</a:Value>
</a:DeviceProperty>
</a:Properties>
</a:DeviceMetadata>
{% endfor %}
</Devices>
<Properties xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
</MetadataDeclaration>
Expand Down
Loading

0 comments on commit 986592b

Please sign in to comment.