Skip to content

Commit

Permalink
[snmp] Remove Ansible test cases for LLDP code modification. (#1319)
Browse files Browse the repository at this point in the history
  • Loading branch information
shihhsien-wang authored and qiluo-msft committed Jan 7, 2020
1 parent 6de2b53 commit d584331
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 53 deletions.
42 changes: 0 additions & 42 deletions ansible/library/snmp_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,23 +167,17 @@ def __init__(self,dotprefix=False):
self.lldpLocSysDesc = dp + "1.0.8802.1.1.2.1.3.4"

# From LLDP-MIB: lldpLocPortTable
self.lldpLocPortNum = dp + "1.0.8802.1.1.2.1.3.7.1.1" # + .ifindex
self.lldpLocPortIdSubtype = dp + "1.0.8802.1.1.2.1.3.7.1.2" # + .ifindex
self.lldpLocPortId = dp + "1.0.8802.1.1.2.1.3.7.1.3" # + .ifindex
self.lldpLocPortDesc = dp + "1.0.8802.1.1.2.1.3.7.1.4" # + .ifindex

# From LLDP-MIB: lldpLocManAddrTables
self.lldpLocManAddrSubtype = dp + "1.0.8802.1.1.2.1.3.8.1.1" # + .subtype + .man addr
self.lldpLocManAddr = dp + "1.0.8802.1.1.2.1.3.8.1.2" # + .subtype + .man addr
self.lldpLocManAddrLen = dp + "1.0.8802.1.1.2.1.3.8.1.3" # + .subtype + .man addr
self.lldpLocManAddrIfSubtype = dp + "1.0.8802.1.1.2.1.3.8.1.4" # + .subtype + .man addr
self.lldpLocManAddrIfId = dp + "1.0.8802.1.1.2.1.3.8.1.5" # + .subtype + .man addr
self.lldpLocManAddrOID = dp + "1.0.8802.1.1.2.1.3.8.1.6" # + .subtype + .man addr

# From LLDP-MIB: lldpRemTable
self.lldpRemTimeMark = dp + "1.0.8802.1.1.2.1.4.1.1.1" # + .time mark + .ifindex + .rem index
self.lldpRemLocalPortNum = dp + "1.0.8802.1.1.2.1.4.1.1.2" # + .time mark + .ifindex + .rem index
self.lldpRemIndex = dp + "1.0.8802.1.1.2.1.4.1.1.3" # + .time mark + .ifindex + .rem index
self.lldpRemChassisIdSubtype = dp + "1.0.8802.1.1.2.1.4.1.1.4" # + .time mark + .ifindex + .rem index
self.lldpRemChassisId = dp + "1.0.8802.1.1.2.1.4.1.1.5" # + .time mark + .ifindex + .rem index
self.lldpRemPortIdSubtype = dp + "1.0.8802.1.1.2.1.4.1.1.6" # + .time mark + .ifindex + .rem index
Expand All @@ -195,8 +189,6 @@ def __init__(self,dotprefix=False):
self.lldpRemSysCapEnabled = dp + "1.0.8802.1.1.2.1.4.1.1.12" # + .time mark + .ifindex + .rem index

# From LLDP-MIB: lldpRemManAddrTable
self.lldpRemManAddrSubtype = dp + "1.0.8802.1.1.2.1.4.2.1.1" # + .time mark + .ifindex + .rem index + .addr_subtype + .man addr
self.lldpRemManAddr = dp + "1.0.8802.1.1.2.1.4.2.1.2" # + .time mark + .ifindex + .rem index + .addr_subtype + .man addr
self.lldpRemManAddrIfSubtype = dp + "1.0.8802.1.1.2.1.4.2.1.3" # + .time mark + .ifindex + .rem index + .addr_subtype + .man addr
self.lldpRemManAddrIfId = dp + "1.0.8802.1.1.2.1.4.2.1.4" # + .time mark + .ifindex + .rem index + .addr_subtype + .man addr
self.lldpRemManAddrOID = dp + "1.0.8802.1.1.2.1.4.2.1.5" # + .time mark + .ifindex + .rem index + .addr_subtype + .man addr
Expand Down Expand Up @@ -647,7 +639,6 @@ def main():
errorIndication, errorStatus, errorIndex, varTable = cmdGen.nextCmd(
snmp_auth,
cmdgen.UdpTransportTarget((m_args['host'], 161)),
cmdgen.MibVariable(p.lldpLocPortNum,),
cmdgen.MibVariable(p.lldpLocPortIdSubtype,),
cmdgen.MibVariable(p.lldpLocPortId,),
cmdgen.MibVariable(p.lldpLocPortDesc,),
Expand All @@ -660,9 +651,6 @@ def main():
for oid, val in varBinds:
current_oid = oid.prettyPrint()
current_val = val.prettyPrint()
if v.lldpLocPortNum in current_oid:
ifIndex = int(current_oid.rsplit('.', 1)[-1])
results['snmp_interfaces'][ifIndex]['lldpLocPortNum'] = current_val
if v.lldpLocPortIdSubtype in current_oid:
ifIndex = int(current_oid.rsplit('.', 1)[-1])
results['snmp_interfaces'][ifIndex]['lldpLocPortIdSubtype'] = current_val
Expand All @@ -676,8 +664,6 @@ def main():
errorIndication, errorStatus, errorIndex, varTable = cmdGen.nextCmd(
snmp_auth,
cmdgen.UdpTransportTarget((m_args['host'], 161)),
cmdgen.MibVariable(p.lldpLocManAddrSubtype,),
cmdgen.MibVariable(p.lldpLocManAddr,),
cmdgen.MibVariable(p.lldpLocManAddrLen,),
cmdgen.MibVariable(p.lldpLocManAddrIfSubtype,),
cmdgen.MibVariable(p.lldpLocManAddrIfId,),
Expand All @@ -691,12 +677,6 @@ def main():
for oid, val in varBinds:
current_oid = oid.prettyPrint()
current_val = val.prettyPrint()
if v.lldpLocManAddrSubtype in current_oid:
address = '.'.join(current_oid.split('.')[13:])
results['snmp_lldp']['lldpLocManAddrSubtype'] = current_val
if v.lldpLocManAddr in current_oid:
address = '.'.join(current_oid.split('.')[13:])
results['snmp_lldp']['lldpLocManAddr'] = current_val
if v.lldpLocManAddrLen in current_oid:
address = '.'.join(current_oid.split('.')[13:])
results['snmp_lldp']['lldpLocManAddrLen'] = current_val
Expand All @@ -713,9 +693,6 @@ def main():
errorIndication, errorStatus, errorIndex, varTable = cmdGen.nextCmd(
snmp_auth,
cmdgen.UdpTransportTarget((m_args['host'], 161)),
cmdgen.MibVariable(p.lldpRemTimeMark,),
cmdgen.MibVariable(p.lldpRemLocalPortNum,),
cmdgen.MibVariable(p.lldpRemIndex,),
cmdgen.MibVariable(p.lldpRemChassisIdSubtype,),
cmdgen.MibVariable(p.lldpRemChassisId,),
cmdgen.MibVariable(p.lldpRemPortIdSubtype,),
Expand All @@ -734,15 +711,6 @@ def main():
for oid, val in varBinds:
current_oid = oid.prettyPrint()
current_val = val.prettyPrint()
if v.lldpRemTimeMark in current_oid:
ifIndex = int(current_oid.split('.')[12])
results['snmp_interfaces'][ifIndex]['lldpRemTimeMark'] = current_val
if v.lldpRemLocalPortNum in current_oid:
ifIndex = int(current_oid.split('.')[12])
results['snmp_interfaces'][ifIndex]['lldpRemLocalPortNum'] = current_val
if v.lldpRemIndex in current_oid:
ifIndex = int(current_oid.split('.')[12])
results['snmp_interfaces'][ifIndex]['lldpRemIndex'] = current_val
if v.lldpRemChassisIdSubtype in current_oid:
ifIndex = int(current_oid.split('.')[12])
results['snmp_interfaces'][ifIndex]['lldpRemChassisIdSubtype'] = current_val
Expand Down Expand Up @@ -774,8 +742,6 @@ def main():
errorIndication, errorStatus, errorIndex, varTable = cmdGen.nextCmd(
snmp_auth,
cmdgen.UdpTransportTarget((m_args['host'], 161)),
cmdgen.MibVariable(p.lldpRemManAddrSubtype,),
cmdgen.MibVariable(p.lldpRemManAddr,),
cmdgen.MibVariable(p.lldpRemManAddrIfSubtype,),
cmdgen.MibVariable(p.lldpRemManAddrIfId,),
cmdgen.MibVariable(p.lldpRemManAddrOID,),
Expand All @@ -788,14 +754,6 @@ def main():
for oid, val in varBinds:
current_oid = oid.prettyPrint()
current_val = val.prettyPrint()
if v.lldpRemManAddrSubtype in current_oid:
ifIndex = int(current_oid.split('.')[12])
address = '.'.join(current_oid.split('.')[16:])
results['snmp_interfaces'][ifIndex]['lldpRemManAddrSubtype'] = current_val
if v.lldpRemManAddr in current_oid:
ifIndex = int(current_oid.split('.')[12])
address = '.'.join(current_oid.split('.')[16:])
results['snmp_interfaces'][ifIndex]['lldpRemManAddr'] = current_val
if v.lldpRemManAddrIfSubtype in current_oid:
ifIndex = int(current_oid.split('.')[12])
address = '.'.join(current_oid.split('.')[16:])
Expand Down
15 changes: 4 additions & 11 deletions tests/snmp/test_snmp_lldp.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,12 @@ def test_snmp_interfaces(ansible_adhoc, testbed, creds):
# Check if lldpLocPortTable is present for all ports
for k, v in snmp_facts['snmp_interfaces'].items():
if "Ethernet" in v['name'] or "eth" in v['name']:
for oid in ['lldpLocPortNum', 'lldpLocPortIdSubtype', 'lldpLocPortId', 'lldpLocPortDesc']:
for oid in ['lldpLocPortIdSubtype', 'lldpLocPortId', 'lldpLocPortDesc']:
assert v.has_key(oid)
assert "No Such Object currently exists" not in v[oid]

# Check if lldpLocManAddrTable is present
for k in ['lldpLocManAddrSubtype', \
'lldpLocManAddr', \
'lldpLocManAddrLen', \
for k in ['lldpLocManAddrLen', \
'lldpLocManAddrIfSubtype', \
'lldpLocManAddrIfId', \
'lldpLocManAddrOID']:
Expand All @@ -54,10 +52,7 @@ def test_snmp_interfaces(ansible_adhoc, testbed, creds):
# Check if lldpRemTable is present
active_intf = []
for k, v in snmp_facts['snmp_interfaces'].items():
if v.has_key("lldpRemTimeMark") and \
v.has_key("lldpRemLocalPortNum") and \
v.has_key("lldpRemIndex") and \
v.has_key("lldpRemChassisIdSubtype") and \
if v.has_key("lldpRemChassisIdSubtype") and \
v.has_key("lldpRemChassisId") and \
v.has_key("lldpRemPortIdSubtype") and \
v.has_key("lldpRemPortId") and \
Expand All @@ -74,9 +69,7 @@ def test_snmp_interfaces(ansible_adhoc, testbed, creds):
# Check if lldpRemManAddrTable is present
active_intf = []
for k, v in snmp_facts['snmp_interfaces'].items():
if v.has_key("lldpRemManAddrSubtype") and \
v.has_key("lldpRemManAddr") and \
v.has_key("lldpRemManAddrIfSubtype") and \
if v.has_key("lldpRemManAddrIfSubtype") and \
v.has_key("lldpRemManAddrIfId") and \
v.has_key("lldpRemManAddrOID"):
active_intf.append(k)
Expand Down

0 comments on commit d584331

Please sign in to comment.