summaryrefslogtreecommitdiff
path: root/examples/smi
diff options
context:
space:
mode:
authorelie <elie>2015-06-21 13:24:35 +0000
committerelie <elie>2015-06-21 13:24:35 +0000
commitbc0647778478f3f3e481f00cccf4bfa0e8faea6a (patch)
tree4c3c12ce31a5c456bd09b16807176b63ad4e31b5 /examples/smi
parent5439bc3305efd547d02ea6b33b0a2e3dde14be56 (diff)
downloadpysnmp-git-bc0647778478f3f3e481f00cccf4bfa0e8faea6a.tar.gz
ObjectIdentity class additionally supports just a MIB module name
initializer in which case if resolves into either first or last symbol in given MIB. Another new option is just a MIB symbol initializer without specifying MIB module.
Diffstat (limited to 'examples/smi')
-rw-r--r--examples/smi/manager/var-binds-mib-resolution.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/examples/smi/manager/var-binds-mib-resolution.py b/examples/smi/manager/var-binds-mib-resolution.py
index 1c83afa0..a2088977 100644
--- a/examples/smi/manager/var-binds-mib-resolution.py
+++ b/examples/smi/manager/var-binds-mib-resolution.py
@@ -32,6 +32,36 @@ mibVar = rfc1902.ObjectIdentity(str(mibVar)).resolveWithMib(mibView)
print(mibVar.prettyPrint(), tuple(mibVar), str(mibVar))
+# Obtain MIB object information by a mix of OID/label parts
+mibVar = rfc1902.ObjectIdentity((1,3,6,1,2,'mib-2',1,'sysDescr')).resolveWithMib(mibView)
+
+print(mibVar.prettyPrint(), tuple(mibVar), str(mibVar))
+
+# Obtain MIB object information by a label
+mibVar = rfc1902.ObjectIdentity('iso.org.dod.internet.mgmt.mib-2.system.sysDescr').resolveWithMib(mibView)
+
+print(mibVar.prettyPrint(), tuple(mibVar), str(mibVar))
+
+# Obtain the first MIB object in given MIB module
+mibVar = rfc1902.ObjectIdentity('SNMPv2-MIB').resolveWithMib(mibView)
+
+print(mibVar.prettyPrint(), tuple(mibVar), str(mibVar))
+
+# Obtain the last MIB object in given MIB module
+mibVar = rfc1902.ObjectIdentity('SNMPv2-MIB', last=True).resolveWithMib(mibView)
+
+print(mibVar.prettyPrint(), tuple(mibVar), str(mibVar))
+
+# Another way to obtain the first (or last) symbol in MIB module
+mibVar = rfc1902.ObjectIdentity('SNMPv2-MIB', '').resolveWithMib(mibView)
+
+print(mibVar.prettyPrint(), tuple(mibVar), str(mibVar))
+
+# Obtain MIB symbol from whatever MIB it is defined at (MIB should be loaded)
+mibVar = rfc1902.ObjectIdentity('', 'sysDescr', 0).resolveWithMib(mibView)
+
+print(mibVar.prettyPrint(), tuple(mibVar), str(mibVar))
+
# Create an OID-value pair (called variable-binding in SNMP)
varBind = rfc1902.ObjectType(
rfc1902.ObjectIdentity('SNMPv2-MIB', 'sysObjectID', 0), '1.3.6.1'