-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move PySNMP imports to a dedicated module (#5990)
* Move imported PySNMP types to a dedicated module * Fix test_parse_metrics by injecting an explicit spy object * Lint * Fix regression in snmp value decoding * Rename types.py to models.py * Please Python 2
- Loading branch information
1 parent
d57710e
commit 27ca9e5
Showing
8 changed files
with
251 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# (C) Datadog, Inc. 2020-present | ||
# All rights reserved | ||
# Licensed under Simplified BSD License (see LICENSE) | ||
""" | ||
Re-export PySNMP exceptions that we use, so that we can access them from a single module. | ||
""" | ||
|
||
from pysnmp.error import PySnmpError | ||
from pysnmp.smi.error import SmiError | ||
|
||
__all__ = ['PySnmpError', 'SmiError'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# (C) Datadog, Inc. 2020-present | ||
# All rights reserved | ||
# Licensed under Simplified BSD License (see LICENSE) | ||
""" | ||
Re-export PyASN1/PySNMP types and classes that we use, so that we can access them from a single module. | ||
""" | ||
|
||
from pyasn1.type.base import Asn1Type | ||
from pyasn1.type.univ import OctetString | ||
from pysnmp import hlapi | ||
from pysnmp.hlapi import ( | ||
CommunityData, | ||
ContextData, | ||
ObjectIdentity, | ||
ObjectType, | ||
SnmpEngine, | ||
UdpTransportTarget, | ||
UsmUserData, | ||
usmDESPrivProtocol, | ||
usmHMACMD5AuthProtocol, | ||
) | ||
from pysnmp.hlapi.asyncore.cmdgen import lcd | ||
from pysnmp.hlapi.transport import AbstractTransportTarget | ||
from pysnmp.proto.rfc1902 import Counter32, Counter64, Gauge32, Integer, Integer32, ObjectName, Unsigned32 | ||
from pysnmp.smi.builder import DirMibSource, MibBuilder | ||
from pysnmp.smi.exval import endOfMibView, noSuchInstance, noSuchObject | ||
from pysnmp.smi.view import MibViewController | ||
|
||
# Additional types that are not part of the SNMP protocol (see RFC 2856). | ||
CounterBasedGauge64, ZeroBasedCounter64 = MibBuilder().importSymbols( | ||
'HCNUM-TC', 'CounterBasedGauge64', 'ZeroBasedCounter64' | ||
) | ||
|
||
# Cleanup. | ||
del MibBuilder | ||
|
||
__all__ = [ | ||
'AbstractTransportTarget', | ||
'Asn1Type', | ||
'DirMibSource', | ||
'CommunityData', | ||
'ContextData', | ||
'CounterBasedGauge64', | ||
'endOfMibView', | ||
'hlapi', | ||
'lcd', | ||
'MibViewController', | ||
'noSuchInstance', | ||
'noSuchObject', | ||
'ObjectIdentity', | ||
'ObjectName', | ||
'ObjectType', | ||
'OctetString', | ||
'SnmpEngine', | ||
'UdpTransportTarget', | ||
'usmDESPrivProtocol', | ||
'usmHMACMD5AuthProtocol', | ||
'UsmUserData', | ||
'ZeroBasedCounter64', | ||
'Counter32', | ||
'Counter64', | ||
'Gauge32', | ||
'Unsigned32', | ||
'Integer', | ||
'Integer32', | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.