Skip to content
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

driver: digitalloggers_restapi: enable REST API #1512

Merged
merged 1 commit into from
Dec 2, 2024

Conversation

moto-timo
Copy link
Contributor

@moto-timo moto-timo commented Sep 30, 2024

The legacy HTTP API does not work on newer units without manually changing the configuration in Setup.

This driver is based on https://www.digital-loggers.com/restapi.pdf

Curl examples that were used for development are included as comments so that users can test their access outside of labgrid.

The REST API seems to only allow authenticated users, so the host: parameter is parsed to pass user and password to HTTPDigestAuth. CSRF is also required, so a valid (simple) header is provided. Non-authenticated URLs are supported, but most likely will not work.

HTTPS is recommended, but the units ship with self-signed certificates so SSL certificate verification warnings are intentionally ignored.

Example usage in lg-env.yaml (default as-shipped settings):

NetworkPowerPort:
model: 'digitalloggers_restapi'
host: 'http://admin:1234@192.168.0.100'
index: 0

Description

Checklist

  • Documentation for the feature
  • Tests for the feature
  • The arguments and description in doc/configuration.rst have been updated
  • Add a section on how to use the feature to doc/usage.rst
  • Add a section on how to use the feature to doc/development.rst
  • PR has been tested
  • Man pages have been regenerated

@moto-timo moto-timo force-pushed the digitalloggers_restapi branch from 3b6145d to b7e9452 Compare September 30, 2024 22:52
@moto-timo
Copy link
Contributor Author

Added to test_powerdriver.py in second push.

Emantor
Emantor previously approved these changes Oct 1, 2024
@Bastian-Krause
Copy link
Member

Have you considered contributing this to pdudaemon? Please see our merge policy for network PDUs: #1031

@moto-timo
Copy link
Contributor Author

Have you considered contributing this to pdudaemon? Please see our merge policy for network PDUs: #1031

There is no support for digitalloggers in pdudaemon but there was support in labgrid... I'm not currently using pdudaemon and the code will be significantly different so no sure when i will have time for that.

I remember conversations about pdudaemon in the past, not opposed to the policy... I almost feel like we should drop network power support in labgrid though to avoid confusion.

@Emantor Emantor force-pushed the digitalloggers_restapi branch from b7e9452 to c1252d4 Compare October 21, 2024 05:52
@Emantor
Copy link
Member

Emantor commented Oct 21, 2024

Rebased this on current master.

Copy link

codecov bot commented Oct 21, 2024

Codecov Report

Attention: Patch coverage is 16.66667% with 35 lines in your changes missing coverage. Please review.

Project coverage is 56.3%. Comparing base (d4d8370) to head (71e3604).
Report is 2 commits behind head on master.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
labgrid/driver/power/digitalloggers_restapi.py 16.6% 35 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master   #1512     +/-   ##
========================================
- Coverage    56.5%   56.3%   -0.2%     
========================================
  Files         168     169      +1     
  Lines       13136   13178     +42     
========================================
+ Hits         7425    7432      +7     
- Misses       5711    5746     +35     
Flag Coverage Δ
3.10 56.3% <16.6%> (-0.2%) ⬇️
3.11 56.3% <16.6%> (-0.2%) ⬇️
3.12 56.3% <16.6%> (-0.2%) ⬇️
3.13 56.3% <16.6%> (-0.2%) ⬇️
3.9 56.4% <16.6%> (-0.2%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Emantor Emantor force-pushed the digitalloggers_restapi branch from 01f82ae to 6579cf6 Compare October 21, 2024 10:10
@Emantor Emantor requested a review from jluebbe October 21, 2024 10:28
The legacy HTTP API does not work on newer units without manually
changing the configuration in Setup.

This driver is based on https://www.digital-loggers.com/restapi.pdf

Curl examples that were used for development are included as comments
so that users can test their access outside of labgrid.

The REST API seems to only allow authenticated users, so the host:
parameter is parsed to pass user and password to HTTPDigestAuth.
CSRF is also required, so a valid (simple) header is provided.
Non-authenticated URLs are supported, but most likely will not
work.

HTTPS is recommended, but the units ship with self-signed certificates
so SSL certificate verification warnings are intentionally ignored.

Add to test_powerdriver.py import test.

Example usage in lg-env.yaml (default as-shipped settings):

NetworkPowerPort:
    model: 'digitalloggers_restapi'
    host: 'http://admin:1234@192.168.0.100'
    index: 0

Signed-off-by: Tim Orling <tim.orling@konsulko.com>
[r.czerwinski@pengutronix.de: removed unused and sorted imports]
Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
@Emantor Emantor force-pushed the digitalloggers_restapi branch from 6579cf6 to 71e3604 Compare December 2, 2024 13:12
@Emantor Emantor merged commit b67bfc1 into labgrid-project:master Dec 2, 2024
9 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants