Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
changes to support fabric asic in gen-mg and chassis TestbedProcessing
1. Support chassis, multi-duts scenarios in TestbedProcessing. When testbed.yaml file contains cardtype=Linecard or cardtype=supervisor, TestbedProcessing will add that to lab, veos inventory files. When dut is multi-dut, TestbedProcessing will convert the dut type list to string. 2. Support fabric_info generation in fabric_info.py when the num_asic > 0 and cardtype is supervisor. 3. Use the fabric_info in minigraph templates to generated the fabric asic info 4. Use variable name cardtype instead of type in ansible, dut_utils.py and minigraph templates to be more explicit 5. allow t2 as a topo in testbed.py
- Loading branch information
1 parent
1141ee7
commit 006f5ae
Showing
15 changed files
with
225 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#!/usr/bin/env python | ||
|
||
import os | ||
|
||
try: | ||
from sonic_py_common import multi_asic | ||
except ImportError: | ||
print("Failed to import multi_asic") | ||
|
||
DOCUMENTATION = ''' | ||
module: fabric_info.py | ||
Ansible_version_added: 2.0.0.2 | ||
short_description: Find SONiC Fabric ASIC inforamtion if applicable for the DUT | ||
Description: | ||
When the testbed has Fabric ASICs, this module helps to collect that information | ||
which helps in generating the minigraph | ||
Input: | ||
hwsku num_asic | ||
Return Ansible_facts: | ||
fabric_info: SONiC Fabric ASIC information | ||
''' | ||
|
||
EXAMPLES = ''' | ||
- name: get Fabric ASIC info | ||
fabric_info: hwsku='ACS-MSN2700' num_asic=1 | ||
''' | ||
|
||
RETURN = ''' | ||
ansible_facts{ | ||
fabric_info: [{'asicname': 'ASIC0', 'ip_prefix': '10.1.0.33/32', 'ip6_prefix': 'FC00:1::33/128'}, | ||
{'asicname': 'ASIC1', 'ip_prefix': '10.1.0.34/32', 'ip6_prefix': 'FC00:1::34/128'}] | ||
} | ||
''' | ||
|
||
def main(): | ||
module = AnsibleModule( | ||
argument_spec=dict( | ||
hwsku=dict(required=True, type='str'), | ||
num_asic=dict(type='str', required=False), | ||
asics_host_pfx=dict(type='str', required=False), | ||
asics_host_pfx6=dict(type='str', required=False) | ||
), | ||
supports_check_mode=True | ||
) | ||
m_args = module.params | ||
try: | ||
fabric_info = [] | ||
# num_asic may not be present for fixed systems which have no Fabric ASIC. | ||
# Then return empty fabric_info | ||
if 'num_asic' not in m_args or int(m_args['num_asic']) <= 1: | ||
module.exit_json(ansible_facts={'fabric_info': fabric_info}) | ||
return | ||
num_asic = int( m_args[ 'num_asic' ] ) | ||
asics_host_pfx = str( m_args[ 'asics_host_pfx' ] ) | ||
asics_host_pfx6 = str( m_args[ 'asics_host_pfx6' ] ) | ||
for asic_id in range(num_asic): | ||
key = "ASIC%d" % asic_id | ||
data = { 'asicname': key, | ||
'ip_prefix': asics_host_pfx % asic_id, | ||
'ip6_prefix': asics_host_pfx6 % asic_id } | ||
fabric_info.append( data ) | ||
module.exit_json(ansible_facts={'fabric_info': fabric_info}) | ||
except (IOError, OSError), e: | ||
fail_msg = "IO error" + str(e) | ||
module.fail_json(msg=fail_msg) | ||
except Exception, e: | ||
fail_msg = "failed to find the correct fabric asic info for "+m_args['hwsku'] + str(e) | ||
module.fail_json(msg=fail_msg) | ||
|
||
from ansible.module_utils.basic import * | ||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.