Skip to content

Commit

Permalink
Revert "[chassis] Support for gen-mg for multi-asic linecards in VoQ …
Browse files Browse the repository at this point in the history
…chassis (sonic-net#3746)" (sonic-net#4351)

Reverts sonic-net#3746
Reverting due to issue seen: sonic-net#4343
  • Loading branch information
SuvarnaMeenakshi committed Sep 25, 2021
1 parent 526d9e3 commit aa9c059
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 444 deletions.
87 changes: 36 additions & 51 deletions ansible/TestbedProcessing.py
Expand Up @@ -492,63 +492,48 @@ def makeLab(data, devices, testbed, outfile):
except AttributeError:
print("\t\t" + host + " asics_host_ipv6 not found")

try: #get voq_inband_ip
voq_inband_ip = dev.get("voq_inband_ip")
if voq_inband_ip is not None:
entry += "\tvoq_inband_ip=" + str( voq_inband_ip )
except AttributeError:
print("\t\t" + host + " voq_inband_ip not found")

try: #get voq_inband_ipv6
voq_inband_ipv6 = dev.get("voq_inband_ipv6")
if voq_inband_ipv6 is not None:
entry += "\tvoq_inband_ipv6=" + str( voq_inband_ipv6 )
except AttributeError:
print("\t\t" + host + " voq_inband_ipv6 not found")

try: #get voq_inband_intf
voq_inband_intf = dev.get("voq_inband_intf")
if voq_inband_intf is not None:
entry += "\tvoq_inband_intf=" + str( voq_inband_intf )
except AttributeError:
print("\t\t" + host + " voq_inband_intf not found")

try: #get voq_inband_type
voq_inband_type = dev.get("voq_inband_type")
if voq_inband_type is not None:
entry += "\tvoq_inband_type=" + str( voq_inband_type )
except AttributeError:
print("\t\t" + host + " voq_inband_type not found")

try: #get switch_type
switch_type = dev.get("switch_type")
if switch_type is not None:
entry += "\tswitch_type=" + str( switch_type )
if switch_type == 'voq' and card_type != 'supervisor':
if num_asics is None:
num_asics = 1

# All fields are a list. For single asic the list is of size 1.
switchids = dev.get("switchids") # switchids, single asic example "[4]", 3 asic example "[4,6,8]"
voq_inband_ip = dev.get("voq_inband_ip") # voq_inband_ip
voq_inband_ipv6 = dev.get("voq_inband_ipv6") # voq_inband_ipv6
voq_inband_intf = dev.get("voq_inband_intf") # voq_inband_intf
voq_inband_type = dev.get("voq_inband_type") # voq_inband_type
max_cores = dev.get("max_cores") # max cores
lo4096_ip = dev.get("loopback4096_ip") # loopback4096_ip
lo4096_ipv6 = dev.get("loopback4096_ipv6") # loopback4096_ipv6
num_cores_per_asic = dev.get("num_cores_per_asic", 1) # number of cores per asic - to be used in calculating the switchids, assuming to be the same for all linecards

# Add fields
if switchids is None:
switchids = [start_switchid + (asic_id * num_cores_per_asic) for asic_id in range(num_asics)]
entry += "\tswitchids=" + str(switchids)

if voq_inband_ip is None:
voq_inband_ip = ["1.1.1.{}/32".format(start_switchid + asic_id) for asic_id in range(num_asics)]
entry += "\tvoq_inband_ip=" + str(voq_inband_ip)

if voq_inband_ipv6 is None:
voq_inband_ip = ["1111::1:{}/128".format(start_switchid + asic_id) for asic_id in range(num_asics)]
entry += "\tvoq_inband_ipv6=" + str(voq_inband_ip)

if voq_inband_intf is None:
voq_inband_intf = ["Ethernet-IB{}".format(asic_id) for asic_id in range(num_asics)]
entry += "\tvoq_inband_intf=" + str(voq_inband_intf)

if voq_inband_type is None:
voq_inband_type = "port"
entry += "\tvoq_inband_type=" + voq_inband_type

if max_cores is None:
max_cores = 48
entry += "\tmax_cores=" + str(max_cores)

if lo4096_ip is None:
lo4096_ip = ["8.0.0.{}/32".format(start_switchid + asic_id) for asic_id in range(num_asics)]
entry += "\tloopback4096_ip=" + lo4096_ip

if lo4096_ipv6 is None:
lo4096_ipv6 = ["2603:10e2:400::{}/128".format(start_switchid + asic_id) for asic_id in range(num_asics)]
entry += "\tloopback4096_ipv6=" + lo4096_ipv6

start_switchid += (num_asics * num_cores_per_asic)

entry += "\tswitch_type=" + str( switch_type )
except AttributeError:
print("\t\t" + host + " switch_type not found")

try: #get max_cores
max_cores = dev.get("max_cores")
if max_cores is not None:
entry += "\tmax_cores=" + str( max_cores )
except AttributeError:
print("\t\t" + host + " max_cores not found")

try: #get os
os = dev.get("os")
if os is not None:
Expand Down
7 changes: 4 additions & 3 deletions ansible/config_sonic_basedon_testbed.yml
Expand Up @@ -84,7 +84,7 @@
hwsku: "{{ hwsku }}"
card_type: "{{ card_type | default('fixed') }}"
hostname: "{{ inventory_hostname | default('') }}"
switchids: "{{ switchids | default([0]) }}"
start_switchid: "{{ start_switchid | default(0) }}"
when: deploy is defined and deploy|bool == true

- name: find interface name mapping and individual interface speed if defined with local data
Expand All @@ -93,7 +93,7 @@
num_asic: "{{ num_asics }}"
card_type: "{{ card_type | default('fixed') }}"
hostname: "{{ inventory_hostname | default('') }}"
switchids: "{{ switchids | default([0]) }}"
start_switchid: "{{ start_switchid | default(0) }}"
delegate_to: localhost
when: deploy is not defined or deploy|bool == false

Expand All @@ -111,7 +111,8 @@

- name: set all VoQ information for iBGP
set_fact:
all_inbands: "{{ all_inbands | default( {} ) | combine( { item : hostvars[item]['voq_inband_ip']}) }}"
all_inbands: "{{ all_inbands | default( [] ) + [ hostvars[item]['voq_inband_ip'] ] }}"
all_hostnames: "{{ all_hostnames | default( [] ) + [ item ] }}"
when: hostvars[item]['voq_inband_ip'] is defined
loop: "{{ ansible_play_batch }}"

Expand Down
5 changes: 2 additions & 3 deletions ansible/library/fabric_info.py
Expand Up @@ -23,8 +23,8 @@

RETURN = '''
ansible_facts{
fabric_info: [{'asicname': 'ASIC0', 'asic_id': 0, 'ip_prefix': '10.1.0.1/32', 'ip6_prefix': 'FC00:1::1/128'},
{'asicname': 'ASIC1', 'asic_id': 1, 'ip_prefix': '10.1.0.2/32', 'ip6_prefix': 'FC00:1::2/128'}]
fabric_info: [{'asicname': 'ASIC0', 'ip_prefix': '10.1.0.1/32', 'ip6_prefix': 'FC00:1::1/128'},
{'asicname': 'ASIC1', 'ip_prefix': '10.1.0.2/32', 'ip6_prefix': 'FC00:1::2/128'}]
}
'''

Expand Down Expand Up @@ -55,7 +55,6 @@ def main():
next_v4addr = str( ipaddress.IPv4Address(v4base + asic_id) )
next_v6addr = str( ipaddress.IPv6Address(v6base + asic_id) )
data = { 'asicname': key,
'asic_id' : asic_id,
'ip_prefix': next_v4addr + "/" + v4pfx[-1],
'ip6_prefix': next_v6addr + "/" + v6pfx[-1] }
fabric_info.append( data )
Expand Down
18 changes: 9 additions & 9 deletions ansible/library/port_alias.py
Expand Up @@ -104,8 +104,8 @@ def get_portmap(self, asic_id=None, include_internal=False,
port_coreid_index = -1
port_core_portid_index = -1
num_voq_index = -1
# default to Asic0 as minigraph.py parsing code has that assumption.
asic_name = "Asic0" if asic_id is None else "asic" + str(asic_id)
# default to ASIC0 as minigraph.py parsing code has that assumption.
asic_name = "ASIC0" if asic_id is None else "ASIC" + str(asic_id)

filename = self.get_portconfig_path(asic_id)
if filename is None:
Expand Down Expand Up @@ -209,7 +209,7 @@ def main():
include_internal=dict(required=False, type='bool', default=False),
card_type=dict(type='str', required=False),
hostname=dict(type='str', required=False),
switchids=dict(type='list', required=False)
start_switchid=dict(type='int', required=False)
),
supports_check_mode=True
)
Expand All @@ -235,10 +235,10 @@ def main():
'sysports': sysports})
return
allmap = SonicPortAliasMap(m_args['hwsku'])
switchids = None
if 'switchids' in m_args and m_args['switchids'] != None:
switchids = m_args['switchids']
# When this script is invoked on sonic-mgmt docker, num_asic
start_switchid = 0
if 'start_switchid' in m_args and m_args['start_switchid'] != None:
start_switchid = int(m_args['start_switchid'])
# When this script is invoked on sonic-mgmt docker, num_asic
# parameter is passed.
if m_args['num_asic'] is not None:
num_asic = m_args['num_asic']
Expand All @@ -264,8 +264,8 @@ def main():
if 'hostname' in m_args:
hostname = m_args['hostname']
for asic_id in range(num_asic):
if switchids and asic_id is not None:
switchid = switchids[asic_id]
if asic_id is not None:
switchid = start_switchid + asic_id
if num_asic == 1:
asic_id = None
(aliases_asic, portmap_asic, aliasmap_asic, portspeed_asic, front_panel_asic, asicifnames_asic,
Expand Down
99 changes: 23 additions & 76 deletions ansible/templates/minigraph_cpg.j2
Expand Up @@ -80,40 +80,20 @@
{% endfor %}
{% endif %}
{% if switch_type is defined and switch_type == 'voq' %}
{% set voq_peers = dict() %}
{% for asic_id in range(num_asics) %}
{% if num_asics == 1 %}
{% set start_rtr = inventory_hostname %}
{% else %}
{% set start_rtr = "ASIC" + asic_id|string %}
{% endif %}
{% for a_linecard in all_inbands %}
{% for idx in range(all_inbands[a_linecard]|length) %}
{% if voq_inband_ip[asic_id] != all_inbands[a_linecard][idx] %}
{% for all_idx in range(all_inbands|length) %}
{% if voq_inband_ip != all_inbands[all_idx] %}
<BGPSession>
<StartRouter>{{ start_rtr }}</StartRouter>
<StartPeer>{{ voq_inband_ip[asic_id].split('/')[0] }}</StartPeer>
{% if all_inbands[a_linecard]|length == 1 %}
{% set end_rtr = a_linecard %}
{% else %}
{% if a_linecard == inventory_hostname %}
{% set end_rtr = "ASIC" + idx|string %}
{% else %}
{% set end_rtr = a_linecard + "-ASIC" + idx|string %}
{% endif %}
{% endif %}
{% set _ = voq_peers.update({ all_inbands[a_linecard][idx].split('/')[0] : end_rtr }) %}
<EndRouter>{{ end_rtr }}</EndRouter>
<EndPeer>{{ all_inbands[a_linecard][idx].split('/')[0] }}</EndPeer>
<StartRouter>{{ inventory_hostname }}</StartRouter>
<StartPeer>{{ voq_inband_ip.split('/')[0] }}</StartPeer>
<EndRouter>{{ all_hostnames[all_idx] }}</EndRouter>
<EndPeer>{{ all_inbands[all_idx].split('/')[0] }}</EndPeer>
<Multihop>1</Multihop>
<HoldTime>0</HoldTime>
<KeepAliveTime>0</KeepAliveTime>
<VoQChassisInternal>true</VoQChassisInternal>
</BGPSession>
{% endif %}
{% endfor %}
{% endfor %}
{% endfor %}
{% endif %}
</PeeringSessions>
<Routers xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
Expand All @@ -132,14 +112,16 @@
</BGPPeer>
{% endif %}
{% endfor %}
{% if num_asics == 1 and switch_type is defined and switch_type == 'voq' %}
{% for a_voq_peer in voq_peers %}
{% if switch_type is defined and switch_type == 'voq' %}
{% for all_idx in range(all_inbands|length) %}
{% if voq_inband_ip != all_inbands[all_idx] %}
<BGPPeer>
<Address>{{ a_voq_peer }}</Address>
<Address>{{ all_inbands[all_idx].split('/')[0] }}</Address>
<RouteMapIn i:nil="true"/>
<RouteMapOut i:nil="true"/>
<Vrf i:nil="true"/>
</BGPPeer>
{% endif %}
{% endfor %}
{% endif %}
{% if 'tor' in vm_topo_config['dut_type'] | lower %}
Expand All @@ -165,6 +147,17 @@
</a:Peers>
<a:RouteMaps/>
</a:BGPRouterDeclaration>
{% if switch_type is defined and switch_type == 'voq' %}
{% for all_idx in range(all_inbands|length) %}
{% if voq_inband_ip != all_inbands[all_idx] %}
<a:BGPRouterDeclaration>
<a:ASN>{{ vm_topo_config['dut_asn'] }}</a:ASN>
<a:Hostname>{{ all_hostnames[all_idx] }}</a:Hostname>
<a:RouteMaps/>
</a:BGPRouterDeclaration>
{% endif %}
{% endfor %}
{% endif %}
{% for index in range( vms_number) %}
{% if vm_topo_config['vm'][vms[index]]['intfs'][dut_index|int]|length > 0 %}
<a:BGPRouterDeclaration>
Expand All @@ -181,7 +174,7 @@
<a:Hostname>{{ asic }}</a:Hostname>
<a:Peers>
{% for index in range( vms_number) %}
{% if vms[index] in vm_asic_ifnames and vm_asic_ifnames[vms[index]][0].split('-')[1] == asic %}
{% 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"/>
Expand All @@ -204,52 +197,6 @@
<a:RouteMaps/>
</a:BGPRouterDeclaration>
{% endfor %}
{% if switch_type is defined and switch_type == 'voq' %}
{% for a_linecard in all_inbands %}
{% if a_linecard != inventory_hostname %}
{% for idx in range(all_inbands[a_linecard]|length) %}
<a:BGPRouterDeclaration>
<a:ASN>{{ vm_topo_config['dut_asn'] }}</a:ASN>
<a:Hostname>{{ voq_peers[all_inbands[a_linecard][idx].split('/')[0]] }}</a:Hostname>
<a:RouteMaps/>
</a:BGPRouterDeclaration>
{% endfor %}
{% endif %}
{% endfor %}
{% if num_asics > 1 %}
{% for asic_id in range(num_asics) %}
{% set asic_name = "ASIC" + asic_id|string %}
<a:BGPRouterDeclaration>
<a:ASN>{{ vm_topo_config['dut_asn'] }}</a:ASN>
<a:Hostname>{{ asic_name }}</a:Hostname>
<a:Peers>
{% for index in range( vms_number) %}
{% if vms[index] in vm_asic_ifnames and vm_asic_ifnames[vms[index]][0].split('-')[1] == asic_name %}
<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 a_linecard in all_inbands %}
{% for idx in range(all_inbands[a_linecard]|length) %}
{% if voq_inband_ip[asic_id] != all_inbands[a_linecard][idx] %}
<BGPPeer>
<Address>{{ all_inbands[a_linecard][idx] }}</Address>
<RouteMapIn i:nil="true"/>
<RouteMapOut i:nil="true"/>
<Vrf i:nil="true"/>
</BGPPeer>
{% endif %}
{% endfor %}
{% endfor %}
</a:Peers>
</a:BGPRouterDeclaration>
{% endfor %}
{% endif %}
{% endif %}
</Routers>
</CpgDec>

0 comments on commit aa9c059

Please sign in to comment.