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

more processing reviews

parent 7fafe584
No related branches found
No related tags found
1 merge request!288Resolve L2SS-446 "Extend snmp client to support mib files"
...@@ -51,7 +51,6 @@ class SNMP_client(CommClient): ...@@ -51,7 +51,6 @@ class SNMP_client(CommClient):
# only sets up the engine, doesn't connect # only sets up the engine, doesn't connect
self.connected = True self.connected = True
def _process_annotation(self, annotation): def _process_annotation(self, annotation):
try: try:
...@@ -129,12 +128,10 @@ class snmp_attribute: ...@@ -129,12 +128,10 @@ class snmp_attribute:
def create_objID(self): def create_objID(self):
# only scalars can be used at the present time. if self.is_scalar:
if not self.is_scalar:
objID = tuple(hlapi.ObjectIdentity(self.mib, self.name, self.idx + i) for i in range(self.len))
else:
objID = hlapi.ObjectIdentity(self.mib, self.name, self.idx) objID = hlapi.ObjectIdentity(self.mib, self.name, self.idx)
else:
objID = tuple(hlapi.ObjectIdentity(self.mib, self.name, self.idx + i) for i in range(self.len))
return objID return objID
...@@ -183,6 +180,7 @@ class snmp_attribute: ...@@ -183,6 +180,7 @@ class snmp_attribute:
""" """
vals = [] vals = []
if not self.is_scalar: if not self.is_scalar:
#just the first element of this single element list #just the first element of this single element list
varBinds = varBinds[0] varBinds = varBinds[0]
...@@ -241,7 +239,6 @@ class mib_loader: ...@@ -241,7 +239,6 @@ class mib_loader:
mib_source = builder.DirMibSource(dir_path) mib_source = builder.DirMibSource(dir_path)
self.mibBuilder.addMibSources(mib_source) self.mibBuilder.addMibSources(mib_source)
def load_pymib(self, mib_name): def load_pymib(self, mib_name):
self.mibBuilder.loadModule(mib_name) self.mibBuilder.loadModule(mib_name)
......
...@@ -79,11 +79,11 @@ class SNMP(lofar_device): ...@@ -79,11 +79,11 @@ class SNMP(lofar_device):
# example attributes. mib and name mandatory and index optional. # example attributes. mib and name mandatory and index optional.
# Reads from a table and returns an array of table entries 1 to 10 (note, tables require an index key and start at 1) # Reads from a table and returns an array of table entries 1 to 10 (note, tables require an index key and start at 1)
test_attr1_R = attribute_wrapper(comms_annotation={"mib": "TEST-MIB", "name": "test_attr1", "index": 1}, dims=(10,), datatype=numpy.str) # test_attr1_R = attribute_wrapper(comms_annotation={"mib": "TEST-MIB", "name": "test_attr1", "index": 1}, dims=(10,), datatype=numpy.str)
# indices can also be IP addresses sometimes. Gets a single scalar value # indices can also be IP addresses sometimes. Gets a single scalar value
test_attr2_R = attribute_wrapper(comms_annotation={"mib": "TEST-MIB", "name": "test_attr2", "index": (127,0,0,1)}, datatype=numpy.int64) # test_attr2_R = attribute_wrapper(comms_annotation={"mib": "TEST-MIB", "name": "test_attr2", "index": (127,0,0,1)}, datatype=numpy.int64)
# if the attribute doesn't get the value from a table, then no index is needed, or the default of 0 can be supplied. # if the attribute doesn't get the value from a table, then no index is needed, or the default of 0 can be supplied.
test_attr3_R = attribute_wrapper(comms_annotation={"mib": "TEST-MIB", "name": "test_attr3"}, datatype=numpy.int64) # test_attr3_R = attribute_wrapper(comms_annotation={"mib": "TEST-MIB", "name": "test_attr3"}, datatype=numpy.int64)
# -------- # --------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment