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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

moto-timo
Copy link

@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:[email protected]'
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
Copy link
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
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
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.5%. Comparing base (71bfcd2) to head (6579cf6).

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.6%   56.5%   -0.2%     
========================================
  Files         168     169      +1     
  Lines       13033   13075     +42     
========================================
+ Hits         7385    7392      +7     
- Misses       5648    5683     +35     
Flag Coverage Δ
3.10 56.5% <16.6%> (-0.2%) ⬇️
3.11 56.5% <16.6%> (-0.2%) ⬇️
3.12 56.5% <16.6%> (-0.2%) ⬇️
3.13 56.4% <16.6%> (-0.2%) ⬇️
3.9 56.5% <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.

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:[email protected]'
    index: 0

Signed-off-by: Tim Orling <[email protected]>
[[email protected]: removed unused and sorted imports]
Signed-off-by: Rouven Czerwinski <[email protected]>
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