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

added relative dir to SNMP device

parent f273495a
No related branches found
No related tags found
1 merge request!288Resolve L2SS-446 "Extend snmp client to support mib files"
...@@ -12,13 +12,15 @@ ...@@ -12,13 +12,15 @@
""" """
# PyTango imports # PyTango imports
from tango.server import run from tangostationcontrol.common.entrypoint import entry
from tangostationcontrol.clients.attribute_wrapper import attribute_wrapper
from tangostationcontrol.devices.lofar_device import lofar_device
from tango.server import device_property from tango.server import device_property
import os
# Additional import # Additional import
from tangostationcontrol.clients.snmp_client import SNMP_client, mib_loader from tangostationcontrol.clients.snmp_client import SNMP_client, mib_loader
from tangostationcontrol.clients.attribute_wrapper import attribute_wrapper
from tangostationcontrol.devices.lofar_device import lofar_device
import numpy import numpy
...@@ -40,6 +42,8 @@ class SNMP(lofar_device): ...@@ -40,6 +42,8 @@ class SNMP(lofar_device):
- Type:'DevULong' - Type:'DevULong'
SNMP_community SNMP_community
- Type:'DevString' - Type:'DevString'
SNMP_rel_mib_dir
- Type:'DevString'
SNMP_timeout SNMP_timeout
- Type:'DevDouble' - Type:'DevDouble'
""" """
...@@ -58,7 +62,7 @@ class SNMP(lofar_device): ...@@ -58,7 +62,7 @@ class SNMP(lofar_device):
mandatory=True mandatory=True
) )
SNMP_mib_dir = device_property( SNMP_rel_mib_dir = device_property(
dtype='DevString', dtype='DevString',
mandatory=False mandatory=False
) )
...@@ -108,8 +112,14 @@ class SNMP(lofar_device): ...@@ -108,8 +112,14 @@ class SNMP(lofar_device):
# create the mib_loader # create the mib_loader
loader = mib_loader() loader = mib_loader()
# get the full mib directory adding the given relative path to the absolute path of this
if self.SNMP_rel_mib_dir[0] == "/":
mib_path = os.path.dirname(__file__) + self.SNMP_rel_mib_dir
else:
mib_path = os.path.dirname(__file__) + "/" + self.SNMP_rel_mib_dir
# set the directory with the compiled mib files. # set the directory with the compiled mib files.
loader.set_pymib_dir(self.SNMP_mib_dir) loader.set_pymib_dir(mib_path)
for i in self.attr_list(): for i in self.attr_list():
try: try:
...@@ -130,9 +140,5 @@ class SNMP(lofar_device): ...@@ -130,9 +140,5 @@ class SNMP(lofar_device):
# ---------- # ----------
def main(args=None, **kwargs): def main(args=None, **kwargs):
"""Main function of the module.""" """Main function of the module."""
return entry((SNMP,), args=args, **kwargs)
from tangostationcontrol.common.lofar_logging import configure_logger
configure_logger()
return run((SNMP,), args=args, **kwargs)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment