diff options
author | elie <elie> | 2015-09-14 05:20:24 +0000 |
---|---|---|
committer | elie <elie> | 2015-09-14 05:20:24 +0000 |
commit | ddc989155d58641cf32e6a1ef8a400f22f5d167c (patch) | |
tree | 9df696918f07781d60cca7a8cc3ff8a6378b638f /examples/hlapi/asyncore/sync/manager/cmdgen/usm-sha-aes128.py | |
parent | 6596cb464810233b3b16973665f2a4fe27ddd1db (diff) | |
download | pysnmp-git-ddc989155d58641cf32e6a1ef8a400f22f5d167c.tar.gz |
* synchronous oneliner apps redesigned to offer Python generator-based
API along with a more comprehensive set of accepted parameters.
* massively documented (in Sphinx, NumPy style)
Diffstat (limited to 'examples/hlapi/asyncore/sync/manager/cmdgen/usm-sha-aes128.py')
-rw-r--r-- | examples/hlapi/asyncore/sync/manager/cmdgen/usm-sha-aes128.py | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/examples/hlapi/asyncore/sync/manager/cmdgen/usm-sha-aes128.py b/examples/hlapi/asyncore/sync/manager/cmdgen/usm-sha-aes128.py new file mode 100644 index 00000000..85a0399e --- /dev/null +++ b/examples/hlapi/asyncore/sync/manager/cmdgen/usm-sha-aes128.py @@ -0,0 +1,57 @@ +""" +SNMPv3: auth SHA, privacy AES128 +++++++++++++++++++++++++++++++++ + +Send SNMP GET request using the following options: + +* with SNMPv3, user 'usr-sha-aes', SHA authentication, AES128 encryption +* over IPv4/UDP +* to an Agent at demo.snmplabs.com:161 +* for SNMPv2-MIB::sysDescr.0 MIB object + +Available authentication protocols: + +#. usmHMACMD5AuthProtocol +#. usmHMACSHAAuthProtocol +#. usmNoAuthProtocol + +Available privacy protocols: + +#. usmDESPrivProtocol +#. usm3DESEDEPrivProtocol +#. usmAesCfb128Protocol +#. usmAesCfb192Protocol +#. usmAesCfb256Protocol +#. usmNoPrivProtocol + +Functionally similar to: + +| $ snmpget -v3 -l authPriv -u usr-sha-aes -A authkey1 -X privkey1 \ +| -a SHA -x AES \ +| demo.snmplabs.com \ +| SNMPv2-MIB::sysDescr.0 + +"""# +from pysnmp.entity.rfc3413.oneliner.cmdgen import * + +errorIndication, errorStatus, errorIndex, varBinds = next( + getCmd(SnmpEngine(), + UsmUserData('usr-sha-aes', 'authkey1', 'privkey1', + authProtocol=usmHMACSHAAuthProtocol, + privProtocol=usmAesCfb128Protocol), + UdpTransportTarget(('demo.snmplabs.com', 161)), + ContextData(), + ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0))) +) + +if errorIndication: + print(errorIndication) +elif errorStatus: + print('%s at %s' % ( + errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex)-1][0] or '?' + ) + ) +else: + for varBind in varBinds: + print(' = '.join([ x.prettyPrint() for x in varBind ])) |