Skip to content

Commit d6ff68e

Browse files
driver/power/aviosys9850: Add Aviosys driver
This driver implements a power port for Aviosys Power Switch 9850. Aviosys HTTP web-interface is here https://www.aviosys.com/products/lib/httpapi.html The command format is at http://ip:port/set.cmd?user=account+pass=password+cmd=command Signed-off-by: Guilherme M. Ferreira <guilherme.maciel.ferreira@gmail.com>
1 parent 6d8febb commit d6ff68e

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

doc/configuration.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ Currently available are:
155155
``apc``
156156
Controls *APU PDUs* via SNMP.
157157

158+
``aviosys9850``
159+
Controls the *AvioSys* IP Power 9850.
160+
158161
``digipower``
159162
Controls *DigiPower PDUs* via a simple HTTP API.
160163

labgrid/driver/power/aviosys9850.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import requests
2+
import re
3+
4+
from labgrid.driver.exception import ExecutionError
5+
6+
7+
# This driver implements a power port for Aviosys Power Switches.
8+
# Aviosys HTTP web-interface is described here https://www.aviosys.com/products/lib/httpapi.html
9+
# The command format is http://ip:port/set.cmd?user=account+pass=password+cmd=command
10+
11+
# The powerdriver.py uses the 'PORT' variable => backend_port = getattr(self.backend, 'PORT', None)
12+
PORT = 80
13+
USER = "admin"
14+
PASS = 12345678
15+
NUMBER_OF_OUTLETS = 4
16+
17+
def power_set(host, port, index, value):
18+
# <!--CGI-DATABEG-->
19+
# <p>
20+
# p61=1</p>
21+
# <!--CGI-DATAEND-->
22+
index = int(index)
23+
assert 1 <= index <= NUMBER_OF_OUTLETS
24+
value = 1 if value else 0
25+
26+
r = requests.get(
27+
f"http://{host}:{port}/set.cmd?user={USER}+pass={PASS}+cmd=setpower+p6{index}={value}"
28+
)
29+
r.raise_for_status()
30+
31+
def power_get(host, port, index):
32+
# <!--CGI-DATABEG-->
33+
# <p>
34+
# p61=1,p62=0,p63=0,p64=0
35+
# </p>
36+
# <!--CGI-DATAEND-->
37+
index = int(index)
38+
assert 1 <= index <= NUMBER_OF_OUTLETS
39+
40+
r = requests.get(
41+
f"http://{host}:{port}/set.cmd?user={USER}+pass={PASS}+cmd=getpower+p6{index}=0"
42+
)
43+
r.raise_for_status()
44+
45+
data = r.text
46+
matches = re.findall(r'p6(\d)=(\d)', data)
47+
values = {f"p6{index}": int(value) for index, value in matches}
48+
49+
state = values[f"p6{index}"]
50+
return bool(int(state))

0 commit comments

Comments
 (0)