-
Notifications
You must be signed in to change notification settings - Fork 0
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
Vlan snmp #1
Vlan snmp #1
Conversation
tests/test_mibs.py
Outdated
<<<<<<< HEAD | ||
oid_lag_name_map, \ | ||
lag_sai_map = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_lag_tables, db_conn) | ||
======= | ||
oid_lag_name_map, _ = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_lag_tables, db_conn) | ||
>>>>>>> 4e063e4ade89943f2413a767f24564aecfa2cd1c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove git conflict markers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed that. Taking the HEAD branch as in https://github.com/Azure/sonic-snmpagent/pull/169/files.
@@ -30,3 +35,4 @@ def test_init_sync_d_lag_tables(self): | |||
|
|||
self.assertTrue("PortChannel_Temp" in lag_name_if_name_map) | |||
self.assertTrue(lag_name_if_name_map["PortChannel_Temp"] == []) | |||
self.assertTrue(lag_sai_map["PortChannel01"] == "2000000000006") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is "2000000000006"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was added in sonic-net#169.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved
self.update_if_counters() | ||
self.update_rif_counters() | ||
self.aggregate_counters() | ||
|
||
self.lag_name_if_name_map, \ | ||
self.if_name_lag_name_map, \ | ||
self.oid_lag_name_map, \ | ||
self.lag_sai_map = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_lag_tables, self.db_conn) | ||
|
||
self.if_range = sorted(list(self.oid_name_map.keys()) + | ||
list(self.oid_lag_name_map.keys()) + | ||
list(self.mgmt_oid_name_map.keys()) + | ||
list(self.vlan_oid_name_map.keys())) | ||
self.if_range = [(i,) for i in self.if_range] | ||
|
||
def update_if_counters(self): | ||
for sai_id_key in self.if_id_map: | ||
namespace, sai_id = mibs.split_sai_id_key(sai_id_key) | ||
if_idx = mibs.get_index_from_str(self.if_id_map[sai_id_key]) | ||
counters_db_data = self.namespace_db_map[namespace].get_all(mibs.COUNTERS_DB, | ||
mibs.counter_table(sai_id), | ||
blocking=True) | ||
self.if_counters[if_idx] = { | ||
counter: int(value) for counter, value in counters_db_data.items() | ||
} | ||
|
||
def update_rif_counters(self): | ||
rif_sai_ids = list(self.rif_port_map) + list(self.vlan_name_map) | ||
for sai_id in rif_sai_ids: | ||
counters_db_data = Namespace.dbs_get_all(self.db_conn, mibs.COUNTERS_DB, | ||
mibs.counter_table(mibs.split_sai_id_key(sai_id)[1]), | ||
blocking=False) | ||
self.rif_counters[sai_id] = { | ||
counter: int(value) for counter, value in counters_db_data.items() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be duplicated code from rfc1213. Can we write this logic once and reuse in both mibs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can try, but to do that I need to understand the code better in order to write it in an understandable way. In update_data(), the following code was deleted in the original commit (PR 169) from rfc1213, but retained in rfc2863. Do you know why, and what the code does?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basim and Stepan agreed that counters are not needed in rfc2863, therefore I have deleted update_if_counters(), update_rif_counters(), aggregate_counters(), and the calls to them.
@@ -153,6 +236,31 @@ def interface_alias(self, sub_id): | |||
|
|||
return entry.get("description", "") | |||
|
|||
def aggregate_counters(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment regarding code duplication
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above.
) | ||
|
||
response = get_pdu.make_response(self.lut) | ||
print(response) | ||
|
||
value0 = response.values[0] | ||
self.assertEqual(value0.type_, ValueType.COUNTER_32) | ||
self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 10, 1001)))) | ||
self.assertEqual(value0.data, 100) | ||
|
||
def test_in_ucast_portchannel(self): | ||
""" | ||
For a l3 portchannel interface value is accumulated on members plus added Rif counters | ||
""" | ||
oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 11, 1001)) | ||
get_pdu = GetPDU( | ||
header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), | ||
oids=[oid] | ||
) | ||
|
||
response = get_pdu.make_response(self.lut) | ||
print(response) | ||
|
||
value0 = response.values[0] | ||
self.assertEqual(value0.type_, ValueType.COUNTER_32) | ||
self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 11, 1001)))) | ||
self.assertEqual(value0.data, 100) | ||
|
||
def test_in_errors_portchannel(self): | ||
""" | ||
For a l3 portchannel interface value is accumulated on members plus added Rif counters | ||
""" | ||
oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 14, 1001)) | ||
get_pdu = GetPDU( | ||
header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), | ||
oids=[oid] | ||
) | ||
|
||
response = get_pdu.make_response(self.lut) | ||
print(response) | ||
|
||
value0 = response.values[0] | ||
self.assertEqual(value0.type_, ValueType.COUNTER_32) | ||
self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 14, 1001)))) | ||
self.assertEqual(value0.data, 106) | ||
|
||
def test_out_octets_portchannel(self): | ||
""" | ||
For a l3 portchannel interface value is accumulated on members plus added Rif counters | ||
""" | ||
oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 16, 1001)) | ||
get_pdu = GetPDU( | ||
header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), | ||
oids=[oid] | ||
) | ||
|
||
response = get_pdu.make_response(self.lut) | ||
print(response) | ||
|
||
value0 = response.values[0] | ||
self.assertEqual(value0.type_, ValueType.COUNTER_32) | ||
self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 16, 1001)))) | ||
self.assertEqual(value0.data, 100) | ||
|
||
def test_out_ucast_portchannel(self): | ||
""" | ||
For a l3 portchannel interface value is accumulated on members plus added Rif counters | ||
""" | ||
oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 17, 1001)) | ||
get_pdu = GetPDU( | ||
header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), | ||
oids=[oid] | ||
) | ||
|
||
response = get_pdu.make_response(self.lut) | ||
print(response) | ||
|
||
value0 = response.values[0] | ||
self.assertEqual(value0.type_, ValueType.COUNTER_32) | ||
self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 17, 1001)))) | ||
self.assertEqual(value0.data, 100) | ||
|
||
def test_out_errors_portchannel(self): | ||
""" | ||
For a l3 portchannel interface value is accumulated on members plus added Rif counters | ||
""" | ||
oid = ObjectIdentifier(11, 0, 0, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 20, 1001)) | ||
get_pdu = GetPDU( | ||
header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), | ||
oids=[oid] | ||
) | ||
|
||
response = get_pdu.make_response(self.lut) | ||
print(response) | ||
|
||
value0 = response.values[0] | ||
self.assertEqual(value0.type_, ValueType.COUNTER_32) | ||
self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 20, 1001)))) | ||
self.assertEqual(value0.data, 106) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add similar tests for rfc2863?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, after speaking with Basim, RFC2863 counters are not required, so I looked for vlan references in the file. The only reference is in test_in_ucast_vlan_subinterface(), which is a counter, so I don't see what additional tests I should write.
@raphaelt-nvidia have you upstream this already? i could not find an open PR so it is either not upstream or merged. if merged, lets close this one, if not, lets please have it done. |
**- What I did** Extend RFC3433 implementation with: 1. FAN tachometers 2. PSU current sensor 3. PSU voltage sensor 4. PSU power sensor 5. PSU temp sensor 6. Chassis temp sensor MIB HLD update PR to reflect this change please refer to: sonic-net/SONiC#766 A fix for the LGTM checker **- How I did it** 1. Refactor sensor data parsing class by adding a base class BaseSensorData; inherit TransceiverSensorData, PSUSensorData, FANSensorData, and ThermalSensorData from it to reduce redundant code. 2. Adding more sensor MIB entry class: PSUTempSensor, PSUVoltageSensor, PSUCurrentSensor, PSUPowerSensor, FANSpeedSensor, and ThermalSensor. 3. Separate MIB update to different functions according to different sensors types: update_xcvr_dom_data, update_psu_sensor_data, update_fan_sensor_data, and update_thermal_sensor_data. 4. Add unit test cases to cover the new added MIB entries. 5. Add lgtm.yaml to fix the LGTM checker. **- How to verify it** Manual test and run updated community SNMP test case(sonic-net/sonic-mgmt#3357).
…egate rif counters (sonic-net#169)" (sonic-net#191)" This reverts commit dfde06e.
Signed-off-by: Raphael Tryster <[email protected]>
Signed-off-by: Raphael Tryster <[email protected]>
Signed-off-by: Raphael Tryster <[email protected]>
…import paths Signed-off-by: Raphael Tryster <[email protected]>
8842851
to
cc61819
Compare
- What I did
Restored snmp vlan support per RFC1213, which had been reverted due to inconsistency with RFC2863, and added the missing support for RFC2863. Added unit tests for RFC2863.
- How I did it
Reverted sonic-net#191, which was itself a revert of sonic-net#169. Then added code to support vlan in rfc2863.py and unit tests.
Since a long time has elapsed since the original commit and other code has been pushed in the meantime, great care is needed in merging. Note in particular that mibs.init_sync_d_lag_tables now returns five parameters, the last two of which were added: lag_sai_map and sai_lap_map. This PR needs one of those maps, and a concurrent commit supporting RFC4363 needs the other, so all the callers were updated and use the one they need.
- How to verify it
Unit tests are run via make target/python-wheels/asyncsnmp-2.1.0-py3-none-any.whl.
See also sonic-net#169.
- Description for the changelog
Restored support for aggregated router interface counters and L3 VLAN counters to RFC1213 MIB, and extended to RFC2863.