Skip to content

Commit

Permalink
Handle fex interfaces using l1physif DNs
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Smith committed Jan 27, 2017
1 parent 3ce5b08 commit 15da122
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
17 changes: 10 additions & 7 deletions acitoolkit/aciphysobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -3007,13 +3007,16 @@ def get(cls, session, pod_parent=None, node=None, module=None, port=None):
attributes['name'] = str(interface['l1PhysIf']['attributes']['name'])
attributes['descr'] = str(interface['l1PhysIf']['attributes']['descr'])
attributes['usage'] = str(interface['l1PhysIf']['attributes']['usage'])
(interface_type, pod, node,
module, port) = Interface.parse_dn(dist_name)
attributes['operSt'] = eth_data_dict[dist_name + '/phys']['operSt']
attributes['operSpeed'] = eth_data_dict[dist_name + '/phys']['operSpeed']
interface_obj = Interface(interface_type, pod, node, module, port,
parent=None, session=session,
attributes=attributes)
try:
attributes['operSt'] = eth_data_dict[dist_name + '/phys']['operSt']
attributes['operSpeed'] = eth_data_dict[dist_name + '/phys']['operSpeed']
except KeyError:
attributes['operSt'] = 'unknown'
attributes['operSpeed'] = 'unknown'

interface_obj = ACI._interface_from_dn(dist_name)
for attribute in attributes:
interface_obj.attributes[attribute] = attributes[attribute]
interface_obj.porttype = porttype
interface_obj.adminstatus = adminstatus
interface_obj.speed = speed
Expand Down
23 changes: 23 additions & 0 deletions acitoolkit/acitoolkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -4664,6 +4664,26 @@ def __init__(self, if_type, pod, node, fex, module, port):
self.if_name = self.interface_type + ' ' + self.pod + '/'
self.if_name += self.node + '/' + self.fex + '/'
self.if_name += self.module + '/' + self.port
self.attributes = {'if_name': self.if_name}

@classmethod
def parse_dn(cls, dn):
if '/phys-' in dn:
pod = dn.split('/pod-')[1].split('/')[0]
node = dn.split('/node-')[1].split('/')[0]
if_name = dn.split('/phys-[')[1]
if_type = if_name[:3]
if_name = if_name.split(']')[0]
fex, module, port = if_name[3:].split('/')
return if_type, pod, node, fex, module, port

@classmethod
def is_dn_a_fex_interface(cls, dn):
#topology/pod-1/node-101/sys/phys-[eth101/1/1]
if '/phys-[' in dn:
if len(dn.split('/phys-[')[1].split(']')[0].split('/')) == 3:
return True
return False


def _interface_from_dn(dn):
Expand All @@ -4689,6 +4709,9 @@ def _interface_from_dn(dn):
'''
match = re.match(interface_pattern, dn)
if not match:
# Look for Fex interfaces encoded as topology/pod-1/node-101/sys/phys-[eth101/1/1]
if FexInterface.is_dn_a_fex_interface(dn):
return FexInterface(*FexInterface.parse_dn(dn))
return Interface(*Interface.parse_dn(dn))
elif match.group('fex') is not None:
args = match.group('if_type', 'pod', 'node', 'fex', 'module', 'port')
Expand Down

0 comments on commit 15da122

Please sign in to comment.