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

removed blank lines and old class

parent edc4b195
No related branches found
No related tags found
1 merge request!288Resolve L2SS-446 "Extend snmp client to support mib files"
...@@ -111,34 +111,7 @@ class SNMP_client(CommClient): ...@@ -111,34 +111,7 @@ class SNMP_client(CommClient):
def load_mib(mib_name): def load_mib(mib_name):
mibBuilder = builder.MibBuilder() mibBuilder = builder.MibBuilder()
mibBuilder.loadModule(mib_name) mibBuilder.loadModule(mib_name)
class annotation_wrapper:
def __init__(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.
"""
# values start as None
self.mib = None
self.name = None
self.idx = None
# check if the 'mib' and 'name' keys are present
if 'mib' in annotation and 'name' in annotation:
self.mib = annotation["mib"]
self.name = annotation["name"]
# SNMP has tables that require an index number to access them. regular non-table variable have an index of 0
self.idx = annotation.get('index', 0)
else:
raise ValueError(f"SNMP attribute annotation requires a dict argument with both a 'name' and 'mib' key. Instead got: {annotation}")
class snmp_attribute: class snmp_attribute:
......
...@@ -157,3 +157,4 @@ def main(args=None, **kwargs): ...@@ -157,3 +157,4 @@ def main(args=None, **kwargs):
configure_logger() configure_logger()
return run((SNMP,), args=args, **kwargs) return run((SNMP,), args=args, **kwargs)
...@@ -5,7 +5,7 @@ from unittest import mock ...@@ -5,7 +5,7 @@ from unittest import mock
from tangostationcontrol.test import base from tangostationcontrol.test import base
from tangostationcontrol.clients.snmp_client import SNMP_client, snmp_attribute, annotation_wrapper from tangostationcontrol.clients.snmp_client import SNMP_client, snmp_attribute
class server_imitator: class server_imitator:
...@@ -165,6 +165,3 @@ class TestSNMP(base.TestCase): ...@@ -165,6 +165,3 @@ class TestSNMP(base.TestCase):
checkval = server.val_check(i, server.dim_list[j]) checkval = server.val_check(i, server.dim_list[j])
self.assertEqual(checkval, res_lst, f"Expected: {checkval}, got: {res_lst}") self.assertEqual(checkval, res_lst, f"Expected: {checkval}, got: {res_lst}")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment