1# 2# This file is part of pysnmp software. 3# 4# Copyright (c) 2005-2019, Ilya Etingof <etingof@gmail.com> 5# License: http://snmplabs.com/pysnmp/license.html 6# 7from pyasn1.compat.octets import null 8 9__all__ = ['ContextData'] 10 11 12class ContextData(object): 13 """Creates UDP/IPv6 configuration entry and initialize socket API if needed. 14 15 This object can be used by 16 :py:class:`~pysnmp.hlapi.asyncore.AsyncCommandGenerator` or 17 :py:class:`~pysnmp.hlapi.asyncore.AsyncNotificationOriginator` 18 and their derevatives for forming SNMP PDU and also adding new entries to 19 Local Configuration Datastore (LCD) in order to support SNMPv1/v2c with 20 SNMPv3 interoperability. 21 22 See :RFC:`3411#section-4.1` for SNMP Context details. 23 24 Parameters 25 ---------- 26 contextEngineId : str 27 Uniquely identifies an SNMP entity that may realize an instance of 28 a MIB with a particular contextName (:RFC:`3411#section-3.3.2`). 29 More frequently than not, ContextEngineID is the same as 30 authoritative SnmpEngineID, however if SNMP Engine serves multiple 31 SNMP Entities, their ContextEngineIDs would be distinct. 32 Default is authoritative SNMP Engine ID. 33 contextName : str 34 Used to name an instance of MIB (:RFC:`3411#section-3.3.3`). 35 Default is empty string. 36 37 Examples 38 -------- 39 >>> from pysnmp.hlapi import ContextData 40 >>> ContextData() 41 ContextData(contextEngineId=None, contextName='') 42 >>> ContextData(OctetString(hexValue='01020ABBA0')) 43 ContextData(contextEngineId=OctetString(hexValue='01020abba0'), contextName='') 44 >>> ContextData(contextName='mycontext') 45 ContextData(contextEngineId=None, contextName='mycontext') 46 47 """ 48 49 def __init__(self, contextEngineId=None, contextName=null): 50 self.contextEngineId = contextEngineId 51 self.contextName = contextName 52 53 def __repr__(self): 54 return '%s(contextEngineId=%r, contextName=%r)' % ( 55 self.__class__.__name__, self.contextEngineId, self.contextName 56 ) 57