Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tango
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
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
LOFAR2.0
tango
Commits
9183204a
Commit
9183204a
authored
3 years ago
by
Taya Snijder
Browse files
Options
Downloads
Patches
Plain Diff
updated write with new code
parent
669baa76
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!243
Resolve L2SS-464 "Replace snmp python library with pysnmp"
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tangostationcontrol/tangostationcontrol/examples/snmp/snmp_client.py
+14
-17
14 additions, 17 deletions
...ncontrol/tangostationcontrol/examples/snmp/snmp_client.py
with
14 additions
and
17 deletions
tangostationcontrol/tangostationcontrol/examples/snmp/snmp_client.py
+
14
−
17
View file @
9183204a
...
@@ -158,15 +158,18 @@ class SNMP_client(CommClient):
...
@@ -158,15 +158,18 @@ class SNMP_client(CommClient):
# get all the necessary data to set up the read/write functions from the attribute_wrapper
# get all the necessary data to set up the read/write functions from the attribute_wrapper
dim_x
,
dim_y
,
numpy_type
=
self
.
setup_value_conversion
(
attribute
)
dim_x
,
dim_y
,
numpy_type
=
self
.
setup_value_conversion
(
attribute
)
if
uses_oids
:
if
uses_oids
:
# get a list of str of the oids
# get a list of str of the oids
oids
=
self
.
get_oids
(
dim_x
,
dim_y
,
output
)
oids
=
self
.
get_oids
(
dim_x
,
dim_y
,
output
)
# turn the list of oids in to a tuple of pysnmp objects
# turn the list of oids in to a tuple of pysnmp objects
obj
=
(
pysnmp
.
ObjectType
(
pysnmp
.
ObjectIdentity
(
oids
))
for
i
in
range
(
len
(
oids
)))
objID
=
(
pysnmp
.
ObjectIdentity
(
oids
)
for
i
in
range
(
len
(
oids
)))
obj
=
(
pysnmp
.
ObjectType
(
i
)
for
i
in
objID
)
else
:
else
:
# if a single one
# if its an mib and name thingy
obj
=
(
pysnmp
.
ObjectType
(
pysnmp
.
ObjectIdentity
(
output
[
0
],
output
[
1
],
0
)),)
objID
=
pysnmp
.
ObjectIdentity
(
output
[
0
],
output
[
1
],
0
)
obj
=
(
pysnmp
.
ObjectType
(
objID
),)
def
_read_function
():
def
_read_function
():
# get the thingy to get the values
# get the thingy to get the values
...
@@ -191,24 +194,18 @@ class SNMP_client(CommClient):
...
@@ -191,24 +194,18 @@ class SNMP_client(CommClient):
# return the list of values
# return the list of values
return
val_lst
return
val_lst
if
dtype
is
not
None
:
def
_write_function
(
value
):
set_cmd
=
pysnmp
.
setCmd
(
self
.
engine
,
self
.
community
,
self
.
trasport
,
self
.
ctx_data
,
*
obj
)
errorIndication
,
errorStatus
,
errorIndex
,
varBinds
=
next
(
set_cmd
)
def
_write_function
(
value
):
is_scalar
=
(
self
.
dim_x
+
self
.
dim_y
)
==
1
if
len
(
oids
)
==
1
and
type
(
value
)
!=
list
:
if
is_scalar
:
value
=
[
value
]
write_obj
=
(
pysnmp
.
ObjectType
(
objID
[
0
],
value
),)
for
i
in
range
(
len
(
oids
)):
self
.
manager
.
set
(
self
.
host
,
oids
[
i
],
snmp_types
[
dtype
](
value
[
i
]))
else
:
else
:
def
_write_function
(
value
):
write_obj
=
tuple
(
pysnmp
.
ObjectType
(
objID
[
i
],
value
[
i
])
for
i
in
range
(
len
(
objID
)))
if
len
(
oids
)
==
1
and
type
(
value
)
!=
list
:
value
=
[
value
]
for
i
in
range
(
len
(
oids
)):
set_cmd
=
pysnmp
.
setCmd
(
self
.
engine
,
self
.
community
,
self
.
trasport
,
self
.
ctx_data
,
*
write_obj
)
self
.
manager
.
set
(
self
.
host
,
oids
[
i
],
value
[
i
]
)
errorIndication
,
errorStatus
,
errorIndex
,
varBinds
=
next
(
set_cmd
)
# return the read/write functions
# return the read/write functions
...
...
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