On the protocol level, a Managed Object Instance is represented by a pair of Name and Value items collectively called a Variable-Binding. In PySNMP oneliner API, a Managed Object Instance is represented by a two-component sequence of two objects -- one represents Managed Object Name or Managed Object Instance Name, and the other - Managed Object Instance Value. The types of these objects may vary, details follow.
Managed Object or Managed Object Instance Name is an instance of ObjectName class which is derived from PyASN1 ObjectIdentifier. In most cases, PySNMP oneliner API will automatically create an instance of ObjectName class from its initialization value which can be:
In order to make use of additional information related to Managed Objects, such as their human-friendly representation, associated value type, description of intended use and other details contained in MIBs, the MibVariable class instances may be used interchangeably instead of ObjectName objects.
Create an object representing a varying amount of Managed Object Name information. At the bare minimum MibVariable object will only hold an OBJECT IDENTIFIER that identifies particular Managed Object. However more information on Managed Object may be gathered by PySNMP during the course of SNMP request processing. All the extra information comes through a lookup at a MIB where particular Managed Object is specified.
The mandatory varName argument must hold a valid initializer for ObjectIdentifier kind of objects.
Create an object potentially representing all MIB information on particular Managed Object. By the moment of instantiation no additional information is acquired, but during the later stages of SNMP request processing, PySNMP will attempt to lookup additional information at the MIB named mibName for the object registered there under name symName.
If requested MIB or symbol can not be found, the PySnmpError exception will be thrown.
The mandatory mibName and symName arguments refer to the names under which particular Managed Object is specified in the MIB (e.g. 'IF-MIB' and 'ifTable' respectively). Both parameters are Python strings.
The optional indices sequence semantics depend on the type of MIB Object refered by mibName and symName parameters.
Methods of the MibVariable objects are as follows:
Return a sequence of mibName, symName and indices identifying arbitrary Managed Object.
Return Managed Object Name in form of ObjectIdentifier object.
Return MIB information in form of a Managed Object identified by this particular name.
Return True if MIB lookup for initial initializers was successful and complete MIB information is available.
PySNMP implementation of SNMPv3 architecture always exposes, SMIv2 definitions for Managed Objects are always used regardless of the underlying SNMP protocol version being talked with a peer. For instance, an SNMPv3 Manager will always report SMIv2 types even when working to SNMPv1 Agent (which is SMIv1-compliant).
The list of Managed Object Instance Value classes follows.
Create a SMIv2 Integer object. The value parameter should be an integer value. Instances of this class mimic basic properties of a Python integer. SMIv2 Integer class is derived from PyASN1 Integer.
Create a SMIv2 Integer32 object. This object is similar to Integer class instance.
Create a SMIv2 OctetIdentifier object. The value parameter could be a tuple of integer sub-IDs or a human-friendly string form like ".126.96.36.199.3.1". SMIv2 OctetString class is derived from PyASN1 OctetIdentifier.
Create a SMIv2 OctetString object. The value parameter should be a string value. Instances of this class mimic basic properties of a Python string. SMIv2 OctetString class is derived from PyASN1 OctetString.
Create a SMIv2 IpAddress object. The value parameter should be an IP address expressed in quad-dotted notation (e.g. "127.0.0.1"). SMIv2 IpAddress class is derived from PyASN1 OctetString.
Create a SMIv2 Counter32 object. Besides different value constraints, this object is similar to Integer class instance.
Create a SMIv2 Gauge32 object. Besides different value constraints, this object is similar to Integer class instance.
Create a SMIv2 Unsigned32 object. Besides different value constraints, this object is similar to Integer class instance.
Create a SMIv2 TimeTicks object. Besides different value constraints, this object is similar to Integer class instance.
Create a SMIv2 Opaque object. This object is similar to OctetString class instance.
Create a SMIv2 Counter64 object. Besides different value constraints, this object is similar to Integer class instance.
Create a SMIv2 Bits object. The value parameter should be sequence of names of bits raised to one. Unmentioned bits default to zero. The Bits class is derived from PyASN1 OctetString.
All the above types are directly used by SNMP protocol and can be exchanged between user application and PySNMP in the course of SNMP engine operations through PySNMP APIs. However, by SNMP design, some additional information on specific Managed Objects Instances value ranges and human-friendly representation can be carried by MIBs in form of TEXTUAL-CONVENTION SMI constructs. PySNMP implements this feature in form of TextualConvention class which is actually a derivative of one of the above Managed Objects Instance Value classes so objects of these classes can be used interchangeably in all PySNMP APIs.
For more information on SNMP Managed Value objects properties, refer to their base classes in PyASN1 documentation.