From 1a8c18a7cec428d644c439667fec04ece490c462 Mon Sep 17 00:00:00 2001 From: http Date: Tue, 24 Jan 2017 21:15:00 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B5=D0=B5=D1=85=D0=B0?= =?UTF-8?q?=D0=BB=20=D0=BD=D0=B0=20=D0=BD=D0=BE=D0=B2=D1=83=D1=8E=20=D0=BB?= =?UTF-8?q?=D0=B8=D0=B1=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- devapp/base_intr.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/devapp/base_intr.py b/devapp/base_intr.py index 067c50b..e3f72f0 100644 --- a/devapp/base_intr.py +++ b/devapp/base_intr.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- from abc import ABCMeta, abstractmethod -from netsnmp import Session, VarList, Varbind +from easysnmp import Session class DevBase(object, metaclass=ABCMeta): @@ -50,20 +50,14 @@ class SNMPBaseWorker(object, metaclass=ABCMeta): ses = None def __init__(self, ip, community='public', ver=2): - self.ses = Session(DestHost=ip, Version=ver, Community=community) + self.ses = Session(hostname=ip, community=community, version=ver) def set_int_value(self, oid, value): - vs = VarList(Varbind( - tag=oid, - val=int(value), - type='INTEGER' - )) - return self.ses.set(vs) + return self.ses.set(oid, value) def get_list(self, oid): - vs = VarList(Varbind(oid)) - return self.ses.walk(vs) + l = self.ses.walk(oid) + return [e.value for e in l] def get_item(self, oid): - var = VarList(Varbind(oid)) - return self.ses.get(var)[0] + return self.ses.get(oid).value