summaryrefslogtreecommitdiff
path: root/pysnmp/entity/rfc3413/oneliner/ctx.py
blob: 528a2b0cfe7785e3872b20a49ac80930243005f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from pyasn1.compat.octets import null

class ContextData:
    """Creates UDP/IPv6 configuration entry and initialize socket API if needed.

    This object can be used by 
    :py:class:`~pysnmp.entity.rfc3413.oneliner.cmdgen.AsyncCommandGenerator` or
    :py:class:`~pysnmp.entity.rfc3413.oneliner.ntforg.AsyncNotificationOriginator`
    and their derevatives for forming SNMP PDU and also adding new entries to
    Local Configuration Datastore (LCD) in order to support SNMPv1/v2c with
    SNMPv3 interoperability.

    See :RFC:`3411#section-4.1` for SNMP Context details.

    Parameters
    ----------
    contextEngineId : str
        Uniquely identifies an SNMP entity that may realize an instance of 
        a MIB with a particular contextName (:RFC:`3411#section-3.3.2`).
        More frequently than not, ContextEngineID is the same as 
        authoritative SnmpEngineID, however if SNMP Engine serves multiple
        SNMP Entities, their ContextEngineIDs would be distinct.
        Default is authoritative SNMP Engine ID.
    contextName : str
        Used to name an instance of MIB (:RFC:`3411#section-3.3.3`).
        Default is empty string.

    Examples
    --------
    >>> from pysnmp.entity.rfc3413.oneliner.ctx import ContextData
    >>> ContextData()
    ContextData(contextEngineId=None, contextName='')
    >>> ContextData(OctetString(hexValue='01020ABBA0'))
    ContextData(contextEngineId=OctetString(hexValue='01020abba0'), contextName='')
    >>> ContextData(contextName='mycontext')
    ContextData(contextEngineId=None, contextName='mycontext')

    """        
    def __init__(self, contextEngineId=None, contextName=null):
        self.contextEngineId = contextEngineId
        self.contextName = contextName

    def __repr__(self):
        return '%s(contextEngineId=%r, contextName=%r)' % (
            self.__class__.__name__, self.contextEngineId, self.contextName
        )