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

Initial Changes for generation of LC graph for Packet based chassis #4419

Closed
wants to merge 13 commits into from
Closed
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
87 changes: 51 additions & 36 deletions ansible/TestbedProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,47 +492,62 @@ 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 )
except AttributeError:
print("\t\t" + host + " switch_type not found")
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)

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")
print("\t\t" + host + " switch_type not found")

try: #get os
os = dev.get("os")
Expand Down
25 changes: 19 additions & 6 deletions ansible/config_sonic_basedon_testbed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
hwsku: "{{ hwsku }}"
card_type: "{{ card_type | default('fixed') }}"
hostname: "{{ inventory_hostname | default('') }}"
start_switchid: "{{ start_switchid | default(0) }}"
switchids: "{{ switchids | 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 @@ -92,7 +92,8 @@
num_asic: "{{ num_asics }}"
card_type: "{{ card_type | default('fixed') }}"
hostname: "{{ inventory_hostname | default('') }}"
start_switchid: "{{ start_switchid | default(0) }}"
switchids: "{{ switchids | default(None) }}"
slotid: "{{ slot_num | default(None) }}"
delegate_to: localhost
when: deploy is not defined or deploy|bool == false

Expand All @@ -101,18 +102,30 @@
num_fabric_asic: "{{ num_fabric_asics | default(0) }}"
asics_host_basepfx: "{{ asics_host_ip | default(None) }}"
asics_host_basepfx6: "{{ asics_host_ipv6 | default(None) }}"
delegate_to: localhost

- name: set all VoQ system ports information
set_fact:
all_sysports: "{{ all_sysports | default( [] ) + hostvars[item]['sysports'] }}"
when: hostvars[item]['sysports'] is defined
loop: "{{ ansible_play_batch }}"

- name: set all VoQ information for iBGP
- name: set all Loopback4096 information for iBGP chassis
set_fact:
all_loopback4096: "{{ all_loopback4096 | default( {} ) | combine( { item : hostvars[item]['loopback4096_ip']}) }}"
when: hostvars[item]['loopback4096_ip'] is defined
loop: "{{ ansible_play_batch }}"

- name: set all Loopback4096 ipv6 information for iBGP chassis
set_fact:
all_loopback4096_ipv6: "{{ all_loopback4096_ipv6 | default( {} ) | combine( { item : hostvars[item]['loopback4096_ipv6']}) }}"
when: hostvars[item]['loopback4096_ipv6'] is defined
loop: "{{ ansible_play_batch }}"

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

- name: find all enabled host_interfaces
Expand Down
53 changes: 53 additions & 0 deletions ansible/lab
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ all:
sonic_a7260:
sonic_multi_asic:
sonic_multi_asic_2:
sonic_sup:
sonic_lc_100G:
fanout:
hosts:
str-7260-10:
Expand Down Expand Up @@ -148,3 +150,54 @@ sonic_multi_asic_2:
vlab-08:
ansible_host: 10.250.0.112
ansible_hostv6: fec0::ffff:afa:c

sonic_sup:
vars:
HwSku: 8800-RP-O
sonic_hwsku: 8800-RP-O
sonic_hw_platform: x86_64-8800_rp_o-r0
slot_num: slot0
card_type: supervisor
hosts:
lab-8800-sup-1:
ansible_host: 10.3.147.95
hwsku: 8800-RP-O
num_asics: 2


sonic_lc_100G:
vars:
switch_type: chassis-packet
num_asics: 2
frontend_asics: [0,1]
hosts:
lab-8808-lc0-1:
hwsku: 8800-LC-48H-O
sonic_hwsku: 8800-LC-48H-O
sonic_hw_platform: x86_64-8800_lc_48h_o-r0
slot_num: slot1
loopback4096_ip: [3.3.3.3/32,3.3.3.4/32]
loopback4096_ipv6: [2603:10e2:400::3/128,2603:10e2:400::4/128]
serial: SSN20220006
base_mac: fc:bd:67:67:e4:1C
ansible_host: 10.3.147.96
lab-8808-lc1-1:
hwsku: 8800-LC-48H-O
sonic_hwsku: 8800-LC-48H-O
sonic_hw_platform: x86_64-8800_lc_48h_o-r0
slot_num: slot2
loopback4096_ip: [3.3.3.5/32,3.3.3.6/32]
loopback4096_ipv6: [2603:10e2:400::5/128,2603:10e2:400::6/128]
serial: SSN20220006
base_mac: fc:bd:67:67:d9:30
ansible_host: 10.3.147.97
lab-8808-lc2-1:
hwsku: 8800-LC-48H-O
sonic_hwsku: 8800-LC-48H-O
sonic_hw_platform: x86_64-8800_lc_48h_o-r0
slot_num: slot3
loopback4096_ip: [3.3.3.7/32,3.3.3.8/32]
loopback4096_ipv6: [2603:10e2:400::7/128,2603:10e2:400::8/128]
serial: SSN20220011
base_mac: fc:bd:67:67:de:5b
ansible_host: 10.3.147.98
5 changes: 3 additions & 2 deletions ansible/library/fabric_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

RETURN = '''
ansible_facts{
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'}]
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'}]
}
'''

Expand Down Expand Up @@ -55,6 +55,7 @@ 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
35 changes: 21 additions & 14 deletions ansible/library/port_alias.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,22 @@ def get_platform_type(self):
return value
return None

def get_portconfig_path(self, asic_id=None):
def get_portconfig_path(self, slotid=None, asic_id=None):
platform = self.get_platform_type()
if platform is None:
return None
if asic_id is None:
portconfig = os.path.join(FILE_PATH, platform, self.hwsku, PORTMAP_FILE)
else:
elif slotid is None:
portconfig = os.path.join(FILE_PATH, platform, self.hwsku, str(asic_id), PORTMAP_FILE)
else:
portconfig = os.path.join(FILE_PATH, platform, self.hwsku, str(slotid), str(asic_id), PORTMAP_FILE)
if os.path.exists(portconfig):
return portconfig
return None

def get_portmap(self, asic_id=None, include_internal=False,
hostname=None, switchid=None):
hostname=None, switchid=None, slotid=None):
aliases = []
portmap = {}
aliasmap = {}
Expand All @@ -104,10 +106,10 @@ 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)
filename = self.get_portconfig_path(slotid, asic_id)
if filename is None:
raise Exception("Something wrong when trying to find the portmap file, either the hwsku is not available or file location is not correct")
with open(filename) as f:
Expand Down Expand Up @@ -209,7 +211,8 @@ def main():
include_internal=dict(required=False, type='bool', default=False),
card_type=dict(type='str', required=False),
hostname=dict(type='str', required=False),
start_switchid=dict(type='int', required=False)
switchids=dict(type='list', required=False),
slotid=dict(type='str', required=False)
),
supports_check_mode=True
)
Expand All @@ -235,10 +238,14 @@ def main():
'sysports': sysports})
return
allmap = SonicPortAliasMap(m_args['hwsku'])
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
switchids = None
slotid = None
if 'switchids' in m_args and m_args['switchids']:
switchids = m_args['switchids']

if 'slotid' in m_args and m_args['slotid'] != None:
slotid = m_args['slotid']
# 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,12 +271,12 @@ def main():
if 'hostname' in m_args:
hostname = m_args['hostname']
for asic_id in range(num_asic):
if asic_id is not None:
switchid = start_switchid + asic_id
if asic_id is not None and asic_id < len(switchids) and switchids[asic_id]:
switchid = switchids[asic_id]
if num_asic == 1:
asic_id = None
(aliases_asic, portmap_asic, aliasmap_asic, portspeed_asic, front_panel_asic, asicifnames_asic,
sysport_asic) = allmap.get_portmap(asic_id, include_internal, hostname, switchid)
sysport_asic) = allmap.get_portmap(asic_id, include_internal, hostname, switchid, slotid)
if aliases_asic is not None:
aliases.extend(aliases_asic)
if portmap_asic is not None:
Expand Down
Loading