From e799dcd197278eee4444b0737a84b7ad1f5dafa8 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 25 Jun 2018 15:14:35 -0400 Subject: [PATCH] GPIO configuration section --- config.json | 4 ++++ libremanage.py | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/config.json b/config.json index b126863..ea700ae 100644 --- a/config.json +++ b/config.json @@ -5,6 +5,10 @@ "tty": { "file": "/dev/ttyUSB0", "baud": 115200 + }, + "power": { + "pin": 1, + "invert": true } } }, diff --git a/libremanage.py b/libremanage.py index 87cb488..e0f23a0 100644 --- a/libremanage.py +++ b/libremanage.py @@ -61,6 +61,13 @@ def get_server_handle(name): def set_server_power(state, server): print("Setting to power state " + str(state)) + conf = server["power"] + + # Set invert to write LOW for power on and HIGH for off + if conf["invert"]: + state = 1 - state + + print(conf["pin"]) open_ssh(server, "echo " + str(state) + " > /dev/shm/power") COMMANDS = { -- 2.25.1