-
Notifications
You must be signed in to change notification settings - Fork 116
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
support for some bridge-mib and q-bridge-mib objects #227
Open
suresh-rupanagudi
wants to merge
3
commits into
sonic-net:master
Choose a base branch
from
suresh-rupanagudi:snmp_bridge_q_bridge_mib
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
'mockredispy>=2.9.3', | ||
'pytest', | ||
'pytest-cov', | ||
'bitstring>=3.1.6', | ||
] | ||
|
||
high_performance_deps = [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
#import json | ||
#import ipaddress | ||
#from enum import unique, Enum | ||
|
||
#from swsssdk import port_util | ||
from sonic_ax_impl import mibs | ||
from sonic_ax_impl.mibs import Namespace | ||
from ax_interface import MIBMeta, ValueType, MIBUpdater, SubtreeMIBEntry, MIBEntry | ||
#from ax_interface.encodings import OctetString | ||
#from ax_interface.util import mac_decimals, ip2tuple_v4 | ||
from bisect import bisect_right | ||
#import re | ||
|
||
|
||
class Dot1dBaseTypeConst: | ||
unknown = 1 | ||
transparent = 2 | ||
source_route = 3 | ||
srt = 4 | ||
|
||
class Dot1dBaseUpdater(MIBUpdater): | ||
def __init__(self): | ||
super().__init__() | ||
self.db_conn = Namespace.init_namespace_dbs() | ||
self.dot1dbase_port_map = {} | ||
self.dot1dbase_port_list = [] | ||
self.dot1dbase_bridge_addr = None | ||
self.dot1d_aging_time = 600 | ||
|
||
def reinit_data(self): | ||
""" | ||
Subclass update interface information | ||
""" | ||
Namespace.connect_all_dbs(self.db_conn, mibs.CONFIG_DB) | ||
self.dot1dbase_bridge_addr = self.db_conn[0].get(mibs.CONFIG_DB, "DEVICE_METADATA|localhost", 'mac') | ||
|
||
def update_data(self): | ||
""" | ||
Update redis (caches config) | ||
Pulls the table references for each vlan member. | ||
""" | ||
self.dot1dbase_port_map = {} | ||
self.dot1dbase_port_list = [] | ||
|
||
fdb_aging_time = self.db_conn[0].get(mibs.CONFIG_DB, "SWITCH|switch", 'fdb_aging_time') | ||
if fdb_aging_time: | ||
self.dot1d_aging_time = int(fdb_aging_time) | ||
else: | ||
self.dot1d_aging_time = 600 | ||
|
||
vlanmem_entries = Namespace.dbs_keys(self.db_conn, mibs.CONFIG_DB, "VLAN_MEMBER|*") | ||
if not vlanmem_entries: | ||
return | ||
|
||
for vmem_entry in vlanmem_entries: | ||
ifname = vmem_entry.split('|')[2] | ||
if_index = mibs.get_index_from_str(ifname) | ||
if if_index is None: | ||
continue | ||
self.dot1dbase_port_map[if_index-1] = if_index | ||
|
||
self.dot1dbase_port_list = sorted(self.dot1dbase_port_map.keys()) | ||
self.dot1dbase_port_list = [(i,) for i in self.dot1dbase_port_list] | ||
mibs.logger.debug('Port map entries : {}' .format(self.dot1dbase_port_map)) | ||
mibs.logger.debug('Port list : {}' .format(self.dot1dbase_port_list)) | ||
|
||
def get_dot1dbase_bridge_addr(self): | ||
return self.dot1dbase_bridge_addr | ||
|
||
def get_dot1d_base_num_ports(self): | ||
return len(self.dot1dbase_port_map) | ||
|
||
def get_dot1d_base_type(self): | ||
return Dot1dBaseTypeConst.transparent | ||
|
||
def get_dot1d_aging_time(self): | ||
return self.dot1d_aging_time | ||
|
||
def get_dot1dbase_port(self, sub_id): | ||
if sub_id: | ||
if sub_id in self.dot1dbase_port_list: | ||
return sub_id[0] | ||
return | ||
|
||
def get_dot1dbase_port_ifindex(self, sub_id): | ||
if sub_id: | ||
return self.dot1dbase_port_map.get(sub_id[0], None) | ||
|
||
def get_dot1dbase_port_delay_discard(self, sub_id): | ||
if sub_id: | ||
return 0 | ||
|
||
def get_dot1dbase_port_mtu_discard(self, sub_id): | ||
if sub_id: | ||
return 0 | ||
|
||
def get_next(self, sub_id): | ||
right = bisect_right(self.dot1dbase_port_list, sub_id) | ||
if right == len(self.dot1dbase_port_list): | ||
return None | ||
|
||
return self.dot1dbase_port_list[right] | ||
|
||
class Dot1dBaseMIB(metaclass=MIBMeta, prefix='.1.3.6.1.2.1.17'): | ||
""" | ||
' dot1dBase MIB' https://tools.ietf.org/html/rfc4188 | ||
""" | ||
|
||
dot1dbase_updater = Dot1dBaseUpdater() | ||
|
||
# (subtree, value_type, callable_, *args, handler=None) | ||
dot1dBaseBridgeAddress = MIBEntry('1.1.0', ValueType.OCTET_STRING, dot1dbase_updater.get_dot1dbase_bridge_addr) | ||
dot1dBaseNumPorts = MIBEntry('1.2.0', ValueType.INTEGER, dot1dbase_updater.get_dot1d_base_num_ports) | ||
dot1dBaseType = MIBEntry('1.3.0', ValueType.INTEGER, dot1dbase_updater.get_dot1d_base_type) | ||
|
||
dot1dBasePort = \ | ||
SubtreeMIBEntry('1.4.1.1', dot1dbase_updater, ValueType.INTEGER, dot1dbase_updater.get_dot1dbase_port) | ||
dot1dBasePortIfIndex = \ | ||
SubtreeMIBEntry('1.4.1.2', dot1dbase_updater, ValueType.INTEGER, dot1dbase_updater.get_dot1dbase_port_ifindex) | ||
dot1dBasePortDelayExceededDiscards = \ | ||
SubtreeMIBEntry('1.4.1.4', dot1dbase_updater, ValueType.COUNTER_32, dot1dbase_updater.get_dot1dbase_port_delay_discard) | ||
dot1dBasePortMtuExceededDiscards = \ | ||
SubtreeMIBEntry('1.4.1.5', dot1dbase_updater, ValueType.COUNTER_32, dot1dbase_updater.get_dot1dbase_port_mtu_discard) | ||
|
||
dot1dTpAgingTime = MIBEntry('4.2.0', ValueType.INTEGER, dot1dbase_updater.get_dot1d_aging_time) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
why is " if_index-1" used as the OID index?
In interface MIB, if index is directly used as OID.
Example: https://github.com/Azure/sonic-snmpagent/blob/master/src/sonic_ax_impl/mibs/ietf/rfc1213.py#L298
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.
As per if-mib ifIndex should be (1..2147483647) . if_index is 1 based not zero based.