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

Fix index nodes in LLDP tables whose access right is not-accessible. #112

Merged
merged 2 commits into from
Jan 7, 2020
Merged
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
25 changes: 0 additions & 25 deletions src/sonic_ax_impl/mibs/ieee802_1ab.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,8 +668,6 @@ class LLDPLocPortTable(metaclass=MIBMeta, prefix='.1.0.8802.1.1.2.1.3.7'):

# lldpLocPortEntry = '1'

lldpLocPortNum = SubtreeMIBEntry('1.1', port_updater, ValueType.INTEGER, port_updater.local_port_num)

# We're using locally assigned name, so according to textual convention, the subtype is 7
lldpLocPortIdSubtype = SubtreeMIBEntry('1.2', port_updater, ValueType.INTEGER, port_updater.port_id_subtype)

Expand All @@ -691,12 +689,6 @@ class LLDPLocManAddrTable(metaclass=MIBMeta, prefix='.1.0.8802.1.1.2.1.3.8'):
"""
updater = LLDPLocManAddrUpdater()

lldpLocManAddrSubtype = SubtreeMIBEntry('1.1', updater, ValueType.INTEGER,
updater.lookup, updater.man_addr_subtype)

lldpLocManAddr = SubtreeMIBEntry('1.2', updater, ValueType.OCTET_STRING,
updater.lookup, updater.man_addr)

lldpLocManAddrLen = SubtreeMIBEntry('1.3', updater, ValueType.INTEGER,
updater.lookup, updater.man_addr_len)

Expand Down Expand Up @@ -800,17 +792,6 @@ class LLDPRemTable(metaclass=MIBMeta, prefix='.1.0.8802.1.1.2.1.4.1'):
"""
lldp_updater = LLDPRemTableUpdater()

lldpRemTimeMark = \
SubtreeMIBEntry('1.1', lldp_updater, ValueType.TIME_TICKS, lldp_updater.lldp_table_lookup_integer,
LLDPRemoteTables(1))

lldpRemLocalPortNum = \
SubtreeMIBEntry('1.2', lldp_updater, ValueType.INTEGER, lldp_updater.local_port_num)

lldpRemIndex = \
SubtreeMIBEntry('1.3', lldp_updater, ValueType.INTEGER, lldp_updater.lldp_table_lookup_integer,
LLDPRemoteTables(3))

lldpRemChassisIdSubtype = \
SubtreeMIBEntry('1.4', lldp_updater, ValueType.INTEGER, lldp_updater.lldp_table_lookup_integer,
LLDPRemoteTables(4))
Expand Down Expand Up @@ -862,12 +843,6 @@ class LLDPRemManAddrTable(metaclass=MIBMeta, prefix='.1.0.8802.1.1.2.1.4.2'):
"""
updater = LLDPRemManAddrUpdater()

lldpRemManAddrSubtype = SubtreeMIBEntry('1.1', updater, ValueType.INTEGER,
updater.lookup, updater.man_addr_subtype)

lldpRemManAddr = SubtreeMIBEntry('1.2', updater, ValueType.OCTET_STRING,
updater.lookup, updater.man_addr)

lldpRemManAddrIfSubtype = SubtreeMIBEntry('1.3', updater, ValueType.INTEGER,
updater.lookup, updater.man_addr_if_subtype)

Expand Down
47 changes: 4 additions & 43 deletions tests/test_lldp.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ def test_getnextpdu_eth2(self):
self.assertEqual(str(value0.data), "Ethernet2")

def test_subtype_lldp_rem_table(self):
for entry in range(2, 13):
for entry in range(4, 13):
mib_entry = self.lut[(1, 0, 8802, 1, 1, 2, 1, 4, 1, 1, entry)]
ret = mib_entry(sub_id=(1, 1))
self.assertIsNotNone(ret)
print(ret)

def test_subtype_lldp_loc_port_table(self):
for entry in range(1, 5):
for entry in range(2, 5):
mib_entry = self.lut[(1, 0, 8802, 1, 1, 2, 1, 3, 7, 1, entry)]
ret = mib_entry(sub_id=(1,))
self.assertIsNotNone(ret)
Expand All @@ -89,64 +89,25 @@ def test_subtype_lldp_loc_sys_data(self):
print(ret)

def test_subtype_lldp_loc_man_addr_table(self):
for entry in range(1, 7):
for entry in range(3, 7):
mib_entry = self.lut[(1, 0, 8802, 1, 1, 2, 1, 3, 8, 1, entry)]
ret = mib_entry(sub_id=(1,))
self.assertIsNotNone(ret)
print(ret)

def test_subtype_lldp_rem_man_addr_table(self):
for entry in range(1, 6):
for entry in range(3, 6):
mib_entry = self.lut[(1, 0, 8802, 1, 1, 2, 1, 4, 2, 1, entry)]
ret = mib_entry(sub_id=(1, 1))
self.assertIsNotNone(ret)
print(ret)

def test_ipv4_rem_man_addr(self):
# ethernet0 has IPv4 remote management address
interface_number = 1
mib_entry = self.lut[(1, 0, 8802, 1, 1, 2, 1, 4, 2, 1, 2)]
ret = mib_entry(sub_id=(1, interface_number,))
self.assertEquals(ret, "0A E0 19 64")
print(ret)
# test remManAddrSubtype
mib_entry = self.lut[(1, 0, 8802, 1, 1, 2, 1, 4, 2, 1, 1)]
ret = mib_entry(sub_id=(1, interface_number,))
# subtype 1 means IPv4
self.assertEquals(ret, 1)
print(ret)

def test_ipv6_rem_man_addr(self):
# ethernet4 has IPv6 remote management address
interface_number = 5
mib_entry = self.lut[(1, 0, 8802, 1, 1, 2, 1, 4, 2, 1, 2)]
ret = mib_entry(sub_id=(1, interface_number,))
self.assertEquals(ret, "fe80 0 268a 7ff fe3f 834c")
print(ret)
# test remManAddrSubtype
mib_entry = self.lut[(1, 0, 8802, 1, 1, 2, 1, 4, 2, 1, 1)]
ret = mib_entry(sub_id=(1, interface_number,))
# subtype 2 means IPv6
self.assertEquals(ret, 2)
print(ret)

def test_local_port_identification(self):
mib_entry = self.lut[(1, 0, 8802, 1, 1, 2, 1, 3, 7, 1, 3)]
ret = mib_entry(sub_id=(1,))
self.assertEquals(ret, b'etp1')
print(ret)

def test_local_port_num(self):
mib_entry = self.lut[(1, 0, 8802, 1, 1, 2, 1, 4, 1, 1, 2)]
for num in range(1, 126, 4):
ret = mib_entry(sub_id=(1, num,))
self.assertEqual(ret, num)

def test_mgmt_local_port_num(self):
mib_entry = self.lut[(1, 0, 8802, 1, 1, 2, 1, 4, 1, 1, 2)]
ret = mib_entry(sub_id=(1, 10001,))
self.assertEqual(ret, 10001)

def test_mgmt_local_port_identification(self):
mib_entry = self.lut[(1, 0, 8802, 1, 1, 2, 1, 3, 7, 1, 3)]
ret = mib_entry(sub_id=(10001,))
Expand Down