Browse Source

refactor _get to call _getmany...

ssh-lenovo
John-Mark Gurney 5 years ago
parent
commit
fea82bea15
1 changed files with 3 additions and 17 deletions
  1. +3
    -17
      vlanmang.py

+ 3
- 17
vlanmang.py View File

@@ -188,24 +188,10 @@ class SNMPSwitch(object):
return varBinds

def _get(self, oid):
oid = ObjectIdentity(*oid)
oid.resolveWithMib(_mvc)

errorInd, errorStatus, errorIndex, varBinds = \
next(getCmd(self._eng, self._cd, self._targ, ContextData(), ObjectType(oid)))

if errorInd: # pragma: no cover
raise ValueError(errorIndication)
elif errorStatus:
raise ValueError('%s at %s' %
(errorStatus.prettyPrint(), errorIndex and
varBinds[int(errorIndex)-1][0] or '?'))
else:
if len(varBinds) != 1: # pragma: no cover
raise ValueError('too many return values')
varBinds = self._getmany(oid)

varBind = varBinds[0]
return varBind[1]
varBind = varBinds[0]
return varBind[1]

def _set(self, oid, value):
oid = ObjectIdentity(*oid)


Loading…
Cancel
Save