-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feature] driver/netio: use netio via json-api #1234
base: master
Are you sure you want to change the base?
[feature] driver/netio: use netio via json-api #1234
Conversation
Following the contribution-guidelines an additional functionality using the netio-json-api was added to simplify netio handling. To get all actions working powerprotocol.py:NetworkPowerDriver probably needs a refactor. Signed-off-by: Raffael Krakau <[email protected]>
Apply suggestions from code review add 'netio_json' section to configuration.rst Signed-off-by: Raffael Krakau <[email protected]> Co-authored-by: Christian Happ <[email protected]>
labgrid already supports these netio APIs:
See: https://labgrid.readthedocs.io/en/latest/configuration.html#networkpowerport Why do you need to implement an additional API? |
We had issues using kshell with the 8-port version of netio. (even changed devices) When we contacted netio they told us, that we must use e.g. the json-api to control the 8-port-netios. Which we did and implemented this netio-json-driver for labgrid. Considering the manufacturer telling us to use json-api, this is a mandatory feature for people who want to use 8-port netios. Even if the current netio-docs say, that kshell should be possible with the netio PowerPDU 8QS, we use the json-api to control the netios. |
[bugfix] add global-var PORT Bug was missed due to old version Signed-off-by: Raffael Krakau <[email protected]>
78b1d7b
to
c63336b
Compare
PORT = 80 | ||
|
||
|
||
class __NetioControl: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the double underscore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initially dunderscore was added to keep NetioControl private and to prevent it from showing up in the doc.(imo a user/dev does only need this info if he already takes a look in the source-code)
With dunderscore the class will be mangled and show up as power__NetioControl
giving a better idea what this exactly is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be resolved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would a single underscore still be prefered?
""" | ||
Netio-Class to switch sockets via HTTP-JSON-API | ||
""" | ||
__host: str |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__host
and the variables below are defined as class variables, however they are not used anywhere? Every place uses the instance variables instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__host
is a private copy of host
(added to prevent side-effects)
At line 105 this copy will be used.
__host
will be mangled and show up as NetioControl__host
which prevents any other operation from accidentally modifying it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be resolved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any further suggestion on how to handle this preferably?
- 3: Short ON delay, | ||
- 4: Toggle (invert the state) | ||
""" | ||
netio = __NetioControl(host, port) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the class indirection necessary? How are username
and password
set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The class indirection isn't strictly necessary, sure it would also be possible to implement this classless.
The json-api supports/expects username and password, even if they're empty.
afaik NetworkPowerDriver doesn't support to set username and password because NetworkPowerPort doesn't support it.
We/I couldn't find a way to set username
and password
at exporter-config.yaml
.
Because of this another PR is on it's way (hopefully PR-ready within 2 weeks).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Username and password are prefabricated.
If you want this to be removed I will remove username and password.
If it's ok for you I would keep it for possible "future-use".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the class is not necessary, we can adjust that. Just as note, we use the NetioControl class in other projects as well, we just added the Labgrid API functions power_set
and power_get
to reuse that code and get it working with Labgrid.
How should we continue on that ?
Are the netio devices supported by pdudaemon? In that case it may be easier to use PDUDaemon. |
I don't see the benefits from using If you or someone else sees the benefit from using |
labgrid/driver/power/netio_json.py
Outdated
|
||
for outputState in responseDict['Outputs']: | ||
if outputState['ID'] == socketID: | ||
state = outputState |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be
state = outputState['State']
Otherwise it always shows as on
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you
set state to ...'State' as mentioned in labgrid-project#1234 (comment) Signed-off-by: Raffael Krakau <[email protected]>
Why do you want distribute the credentials via the coordinator in the clear to all clients? PDUDaemon current has no authentication either, but it's a HTTP API, so it should be relatively easy to switch to authenticated HTTPS using a reverse proxy. At that point, every user could have personal credentials (would need small changes to the
With PDUDaemon, we can:
|
Since I will be no longer collaborating with JUMO and therefore have no setup to test changes, I close this PR. |
Reopened as requested by @JUMO-GmbH-Co-KG. |
Description
Following the contribution-guidelines an additional functionality using the netio-json-api was added to simplify netio handling. To get all actions working powerprotocol.py:NetworkPowerDriver probably needs a refactor.
Tested manually with a Netio-4-Device and in productive-env used with netio-8.
Signed-off-by: Raffael Krakau [email protected]
Checklist