|
23 | 23 | from collections import defaultdict |
24 | 24 | from datetime import datetime |
25 | 25 | from argparse import ArgumentParser |
| 26 | +from itertools import chain |
26 | 27 | import functools |
27 | 28 | import shutil |
28 | 29 | import warnings |
@@ -1735,36 +1736,60 @@ def switch_bootflash_usage_check(tversion, **kwargs): |
1735 | 1736 | def l3out_mtu_check(**kwargs): |
1736 | 1737 | result = MANUAL |
1737 | 1738 | msg = "" |
1738 | | - headers = ["Tenant", "L3Out", "Node Profile", "Logical Interface Profile", |
1739 | | - "Pod", "Node", "Interface", "Type", "IP Address", "MTU"] |
| 1739 | + headers = ["Tenant", "L3Out", "Node Profile", "Interface Profile", |
| 1740 | + "Pod", "Node", "Interface", "Type", "VLAN", "IP Address", "MTU"] |
1740 | 1741 | data = [] |
1741 | 1742 | unformatted_headers = ['L3 DN', "Type", "IP Address", "MTU"] |
1742 | 1743 | unformatted_data = [] |
1743 | 1744 | recommended_action = 'Verify that these MTUs match with connected devices' |
1744 | 1745 | doc_url = "https://datacenter.github.io/ACI-Pre-Upgrade-Validation-Script/validations/#l3out-mtu" |
1745 | 1746 |
|
1746 | | - dn_regex = r'tn-(?P<tenant>[^/]+)/out-(?P<l3out>[^/]+)/lnodep-(?P<lnodep>[^/]+)/lifp-(?P<lifp>[^/]+)/rspathL3OutAtt-\[topology/pod-(?P<pod>[^/]+)/.*paths-(?P<nodes>\d{3,4}|\d{3,4}-\d{3,4})/pathep-\[(?P<int>.+)\]\]' |
1747 | | - response_json = icurl('class', 'l3extRsPathL3OutAtt.json') |
1748 | | - if response_json: |
1749 | | - l2Pols = icurl('mo', 'uni/fabric/l2pol-default.json') |
1750 | | - fabricMtu = l2Pols[0]['l2InstPol']['attributes']['fabricMtu'] |
1751 | | - for l3extRsPathL3OutAtt in response_json: |
1752 | | - mtu = l3extRsPathL3OutAtt['l3extRsPathL3OutAtt']['attributes']['mtu'] |
1753 | | - iftype = l3extRsPathL3OutAtt['l3extRsPathL3OutAtt']['attributes']['ifInstT'] |
1754 | | - addr = l3extRsPathL3OutAtt['l3extRsPathL3OutAtt']['attributes']['addr'] |
1755 | | - |
1756 | | - if mtu == 'inherit': |
1757 | | - mtu += " (%s)" % fabricMtu |
1758 | | - |
1759 | | - dn = re.search(dn_regex, l3extRsPathL3OutAtt['l3extRsPathL3OutAtt']['attributes']['dn']) |
1760 | | - |
1761 | | - if dn: |
1762 | | - data.append([dn.group("tenant"), dn.group("l3out"), dn.group("lnodep"), |
1763 | | - dn.group("lifp"), dn.group("pod"), dn.group("nodes"), |
1764 | | - dn.group("int"), iftype, addr, mtu]) |
1765 | | - else: |
1766 | | - unformatted_data.append( |
1767 | | - [l3extRsPathL3OutAtt['l3extRsPathL3OutAtt']['attributes']['dn'], iftype, addr, mtu]) |
| 1747 | + fabricMtu = None |
| 1748 | + regex_prefix = r'tn-(?P<tenant>[^/]+)/out-(?P<l3out>[^/]+)/lnodep-(?P<lnodep>[^/]+)/lifp-(?P<lifp>[^/]+)' |
| 1749 | + path_dn_regex = regex_prefix + r'/rspathL3OutAtt-\[topology/pod-(?P<pod>[^/]+)/.*paths-(?P<node>\d{3,4}|\d{3,4}-\d{3,4})/pathep-\[(?P<int>.+)\]\]' |
| 1750 | + vlif_dn_regex = regex_prefix + r'/vlifp-\[topology/pod-(?P<pod>[^/]+)/node-(?P<node>\d{3,4})\]-\[vlan-(\d{1,4})\]' |
| 1751 | + l3extPaths = icurl('class', 'l3extRsPathL3OutAtt.json') # Regular L3Out |
| 1752 | + try: |
| 1753 | + l3extVLIfPs = icurl('class', 'l3extVirtualLIfP.json') # Floating L3Out |
| 1754 | + except OldVerClassNotFound: |
| 1755 | + l3extVLIfPs = [] # Pre 4.2 did not have this class |
| 1756 | + for mo in chain(l3extPaths, l3extVLIfPs): |
| 1757 | + if fabricMtu is None: |
| 1758 | + l2Pols = icurl('mo', 'uni/fabric/l2pol-default.json') |
| 1759 | + fabricMtu = l2Pols[0]['l2InstPol']['attributes']['fabricMtu'] |
| 1760 | + |
| 1761 | + is_floating = True if mo.get('l3extVirtualLIfP') else False |
| 1762 | + |
| 1763 | + mo_class = 'l3extVirtualLIfP' if is_floating else 'l3extRsPathL3OutAtt' |
| 1764 | + mtu = mo[mo_class]['attributes']['mtu'] |
| 1765 | + addr = mo[mo_class]['attributes']['addr'] |
| 1766 | + vlan = mo[mo_class]['attributes']['encap'] |
| 1767 | + iftype = mo[mo_class]['attributes']['ifInstT'] |
| 1768 | + # Differentiate between regular and floating SVI. Both use ext-svi in the object. |
| 1769 | + if is_floating: |
| 1770 | + iftype = "floating svi" |
| 1771 | + |
| 1772 | + if mtu == 'inherit': |
| 1773 | + mtu += " (%s)" % fabricMtu |
| 1774 | + |
| 1775 | + dn_regex = vlif_dn_regex if is_floating else path_dn_regex |
| 1776 | + dn = re.search(dn_regex, mo[mo_class]['attributes']['dn']) |
| 1777 | + if dn: |
| 1778 | + data.append([ |
| 1779 | + dn.group("tenant"), |
| 1780 | + dn.group("l3out"), |
| 1781 | + dn.group("lnodep"), |
| 1782 | + dn.group("lifp"), |
| 1783 | + dn.group("pod"), |
| 1784 | + dn.group("node"), |
| 1785 | + dn.group("int") if not is_floating else '---', |
| 1786 | + iftype, |
| 1787 | + vlan, |
| 1788 | + addr, |
| 1789 | + mtu, |
| 1790 | + ]) |
| 1791 | + else: |
| 1792 | + unformatted_data.append([mo[mo_class]['attributes']['dn'], iftype, addr, mtu]) |
1768 | 1793 |
|
1769 | 1794 | if not data and not unformatted_data: |
1770 | 1795 | result = NA |
|
0 commit comments