labgrid icon indicating copy to clipboard operation
labgrid copied to clipboard

driver: digitalloggers_restapi: enable REST API

Open moto-timo opened this issue 1 year ago • 5 comments

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

  • [x] Documentation for the feature
  • [x] Tests for the feature
  • [x] 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
  • [x] PR has been tested
  • [ ] Man pages have been regenerated

moto-timo avatar Sep 30 '24 22:09 moto-timo

Added to test_powerdriver.py in second push.

moto-timo avatar Sep 30 '24 22:09 moto-timo

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

Bastian-Krause avatar Oct 01 '24 09:10 Bastian-Krause

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.

moto-timo avatar Oct 01 '24 22:10 moto-timo

Rebased this on current master.

Emantor avatar Oct 21 '24 05:10 Emantor

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 81 commits behind head on master.

:white_check_mark: All tests successful. No failed tests found.

Files with missing lines Patch % Lines
labgrid/driver/power/digitalloggers_restapi.py 16.6% 35 Missing :warning:
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%) :arrow_down:
3.11 56.3% <16.6%> (-0.2%) :arrow_down:
3.12 56.3% <16.6%> (-0.2%) :arrow_down:
3.13 56.3% <16.6%> (-0.2%) :arrow_down:
3.9 56.4% <16.6%> (-0.2%) :arrow_down:

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

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Oct 21 '24 10:10 codecov[bot]