Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inventory-provider
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
geant-swd
dashboardv3
inventory-provider
Commits
622beba6
Commit
622beba6
authored
3 years ago
by
Erik Reid
Browse files
Options
Downloads
Patches
Plain Diff
de-camelcased some var names
parent
87d24110
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
inventory_provider/snmp.py
+15
-15
15 additions, 15 deletions
inventory_provider/snmp.py
with
15 additions
and
15 deletions
inventory_provider/snmp.py
+
15
−
15
View file @
622beba6
...
@@ -72,13 +72,13 @@ def walk(agent_hostname, community, base_oid): # pragma: no cover
...
@@ -72,13 +72,13 @@ def walk(agent_hostname, community, base_oid): # pragma: no cover
:return:
:return:
"""
"""
mib
B
uilder
=
builder
.
MibBuilder
()
mib
_b
uilder
=
builder
.
MibBuilder
()
# mibViewController = view.MibViewController(mibBuilder)
# mibViewController = view.MibViewController(mibBuilder)
compiler
.
addMibCompiler
(
compiler
.
addMibCompiler
(
mib
B
uilder
,
mib
_b
uilder
,
sources
=
[
'
http://mibs.snmplabs.com/asn1/@mib@
'
])
sources
=
[
'
http://mibs.snmplabs.com/asn1/@mib@
'
])
# Pre-load MIB modules we expect to work with
# Pre-load MIB modules we expect to work with
mib
B
uilder
.
loadModules
(
mib
_b
uilder
.
loadModules
(
'
SNMPv2-MIB
'
,
'
SNMPv2-MIB
'
,
'
SNMP-COMMUNITY-MIB
'
,
'
SNMP-COMMUNITY-MIB
'
,
'
RFC1213-MIB
'
)
'
RFC1213-MIB
'
)
...
@@ -86,10 +86,10 @@ def walk(agent_hostname, community, base_oid): # pragma: no cover
...
@@ -86,10 +86,10 @@ def walk(agent_hostname, community, base_oid): # pragma: no cover
logger
.
debug
(
"
walking %s: %s
"
%
(
agent_hostname
,
base_oid
))
logger
.
debug
(
"
walking %s: %s
"
%
(
agent_hostname
,
base_oid
))
try
:
try
:
for
(
engine
E
rror
I
ndication
,
for
(
engine
_e
rror
_i
ndication
,
pdu
E
rror
I
ndication
,
pdu
_e
rror
_i
ndication
,
error
I
ndex
,
error
_i
ndex
,
var
B
inds
)
in
nextCmd
(
var
_b
inds
)
in
nextCmd
(
SnmpEngine
(),
SnmpEngine
(),
CommunityData
(
community
),
CommunityData
(
community
),
UdpTransportTarget
((
agent_hostname
,
161
)),
UdpTransportTarget
((
agent_hostname
,
161
)),
...
@@ -101,17 +101,17 @@ def walk(agent_hostname, community, base_oid): # pragma: no cover
...
@@ -101,17 +101,17 @@ def walk(agent_hostname, community, base_oid): # pragma: no cover
# cf. http://snmplabs.com/
# cf. http://snmplabs.com/
# pysnmp/examples/hlapi/asyncore/sync/contents.html
# pysnmp/examples/hlapi/asyncore/sync/contents.html
if
engine
E
rror
I
ndication
:
if
engine
_e
rror
_i
ndication
:
raise
SNMPWalkError
(
raise
SNMPWalkError
(
f
'
snmp response engine error indication:
'
f
'
snmp response engine error indication:
'
f
'
{
str
(
engine
E
rror
I
ndication
)
}
-
{
agent_hostname
}
'
)
f
'
{
str
(
engine
_e
rror
_i
ndication
)
}
-
{
agent_hostname
}
'
)
if
pdu
E
rror
I
ndication
:
if
pdu
_e
rror
_i
ndication
:
raise
SNMPWalkError
(
raise
SNMPWalkError
(
'
snmp response pdu error %r at %r
'
%
(
'
snmp response pdu error %r at %r
'
%
(
pdu
E
rror
I
ndication
,
pdu
_e
rror
_i
ndication
,
error
I
ndex
error
_i
ndex
and
var
B
inds
[
int
(
error
I
ndex
)
-
1
][
0
]
or
'
?
'
))
and
var
_b
inds
[
int
(
error
_i
ndex
)
-
1
][
0
]
or
'
?
'
))
if
error
I
ndex
!=
0
:
if
error
_i
ndex
!=
0
:
raise
SNMPWalkError
(
raise
SNMPWalkError
(
'
sanity failure: errorIndex != 0,
'
'
sanity failure: errorIndex != 0,
'
'
but no error indication
'
)
'
but no error indication
'
)
...
@@ -120,7 +120,7 @@ def walk(agent_hostname, community, base_oid): # pragma: no cover
...
@@ -120,7 +120,7 @@ def walk(agent_hostname, community, base_oid): # pragma: no cover
# rfc1902.ObjectType(rfc1902.ObjectIdentity(x[0]),x[1])
# rfc1902.ObjectType(rfc1902.ObjectIdentity(x[0]),x[1])
# .resolveWithMib(mibViewController)
# .resolveWithMib(mibViewController)
# for x in varBinds]
# for x in varBinds]
for
oid
,
val
in
var
B
inds
:
for
oid
,
val
in
var
_b
inds
:
result
=
{
result
=
{
"
oid
"
:
_canonify_oid
(
oid
),
"
oid
"
:
_canonify_oid
(
oid
),
"
value
"
:
_cast_snmp_value
(
val
)
"
value
"
:
_cast_snmp_value
(
val
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment