From b153756fb49f1c3704cffaada9b7528bbf5ff47d Mon Sep 17 00:00:00 2001 From: thijs snijder <snijder@astron.nl> Date: Thu, 21 Apr 2022 13:33:30 +0200 Subject: [PATCH] more processing reviews --- .../tangostationcontrol/clients/snmp_client.py | 11 ++++------- .../tangostationcontrol/devices/snmp_device.py | 6 +++--- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/tangostationcontrol/tangostationcontrol/clients/snmp_client.py b/tangostationcontrol/tangostationcontrol/clients/snmp_client.py index f3318827a..8d2297128 100644 --- a/tangostationcontrol/tangostationcontrol/clients/snmp_client.py +++ b/tangostationcontrol/tangostationcontrol/clients/snmp_client.py @@ -51,7 +51,6 @@ class SNMP_client(CommClient): # only sets up the engine, doesn't connect self.connected = True - def _process_annotation(self, annotation): try: @@ -129,12 +128,10 @@ class snmp_attribute: def create_objID(self): - # only scalars can be used at the present time. - if not self.is_scalar: - objID = tuple(hlapi.ObjectIdentity(self.mib, self.name, self.idx + i) for i in range(self.len)) - - else: + if self.is_scalar: 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 @@ -183,6 +180,7 @@ class snmp_attribute: """ vals = [] + if not self.is_scalar: #just the first element of this single element list varBinds = varBinds[0] @@ -241,7 +239,6 @@ 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) diff --git a/tangostationcontrol/tangostationcontrol/devices/snmp_device.py b/tangostationcontrol/tangostationcontrol/devices/snmp_device.py index b8d16945a..e32d9ddff 100644 --- a/tangostationcontrol/tangostationcontrol/devices/snmp_device.py +++ b/tangostationcontrol/tangostationcontrol/devices/snmp_device.py @@ -79,11 +79,11 @@ class SNMP(lofar_device): # 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) - 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 - 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. - 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) # -------- -- GitLab