Skip to content
Snippets Groups Projects
Commit 5743e076 authored by Taya Snijder's avatar Taya Snijder
Browse files

began processing review

parent 6eeda113
No related branches found
No related tags found
1 merge request!288Resolve L2SS-446 "Extend snmp client to support mib files"
......@@ -52,13 +52,7 @@ class SNMP_client(CommClient):
self.connected = True
def _setup_annotation(self, annotation):
"""
The SNMP client uses a dict and takes the following keys:
mib: the mib name
name: name of the value to read
index (optional) the index if the value thats being read from is a table.
"""
def _process_annotation(self, annotation):
# check if the 'mib' and 'name' keys are present
if 'mib' in annotation and 'name' in annotation:
......@@ -94,7 +88,7 @@ class SNMP_client(CommClient):
"""
# process the annotation
mib, name, idx = self._setup_annotation(annotation)
mib, name, idx = self._process_annotation(annotation)
# get all the necessary data to set up the read/write functions from the attribute_wrapper
dim_x, dim_y, dtype = self.setup_value_conversion(attribute)
......@@ -236,10 +230,9 @@ class snmp_attribute:
class mib_loader:
def __init__(self):
def __init__(self, mib_dir :str):
self.mibBuilder = builder.MibBuilder()
def set_pymib_dir(self, mib_dir : str):
abs_path = str(Path().absolute()).replace("\\", "/")
if mib_dir[0] != "/":
......@@ -250,6 +243,7 @@ class mib_loader:
mib_source = builder.DirMibSource(dir_path)
self.mibBuilder.addMibSources(mib_source)
def load_pymib(self, mib_name):
self.mibBuilder.loadModule(mib_name)
......
......@@ -109,8 +109,7 @@ class SNMP(lofar_device):
def init_device(self):
super().init_device()
# create the mib_loader
loader = mib_loader()
# if the string doesn't start with '/' it is a relative directory and we need to prepend the full path + '/'
if self.SNMP_rel_mib_dir[0] != "/":
......@@ -119,8 +118,8 @@ class SNMP(lofar_device):
# if the string does start with
mib_path = self.SNMP_rel_mib_dir
# set the directory with the compiled mib files.
loader.set_pymib_dir(mib_path)
# create the mib_loader and set the mib path
loader = mib_loader(mib_path)
for i in self.attr_list():
try:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment