Synaccess Agent
The Synaccess Agent interfaces with the power strip over ethernet to control different outlets as well as get their status.
usage: python3 agent.py [-h] [--ip-address IP_ADDRESS] [--username USERNAME]
[--password PASSWORD]
[--outlet-names OUTLET_NAMES [OUTLET_NAMES ...]]
[--num-outlets NUM_OUTLETS]
Agent Options
- --ip-address
IP address for the device.
- --username
Username credential to login to device.
- --password
Password credential to login to device.
- --outlet-names
List of outlet names.
- --num-outlets
Number of outlets for the device.
Default: 5
Configuration File Examples
Below are configuration examples for the ocs config file and for running the Agent in a docker container.
OCS Site Config
To configure the Synaccess Agent we need to add a Synaccess Agent block to our ocs configuration file. Here is an example configuration block using all of the available arguments:
{'agent-class': 'SynaccessAgent',
'instance-id': 'synacc',
'arguments':[
['--ip-address', '10.10.10.8'],
['--username', 'admin'],
['--password', 'admin'],
['--outlet-names', ['outlet1', 'outlet2', 'outlet3', 'outlet4', 'outlet5']]
]}
Docker Compose
The Synaccess Agent should be configured to run in a Docker container. An example docker-compose service configuration is shown here:
ocs-synacc:
image: simonsobs/socs:latest
hostname: ocs-docker
network_mode: "host"
environment:
- INSTANCE_ID=synacc
volumes:
- ${OCS_CONFIG_DIR}:/config:ro
Since the agent within the container needs to communicate with hardware on the
host network you must use network_mode: "host"
in your compose file.
Agent API
- class socs.agents.synacc.agent.SynaccessAgent(agent, ip_address, username, password, outlet_names=None, num_outlets=5)[source]
Agent to control and monitor Synaccess Networks PDUs.
- Parameters:
ip_address (str) – IP address for the device.
username (str) – Username credential to login to device.
password (str) – Password credential to login to device.
outlet_names (list of str) – List of outlet names.
num_outlets (int) – Number of outlets for device.
- reboot(outlet)[source]
Task - Reboot a given outlet.
- Parameters:
outlet (int) – The outlet that we are changing the state of.
- set_outlet(outlet, on)[source]
Task - Set a particular outlet on/off.
- Parameters:
outlet (int) – The outlet that we are changing the state of.
on (bool) – The new state. True for on, False for off.
- set_all(on)[source]
Task - Set all outlets on/off.
- Parameters:
on (bool) – The new state. True for on, False for off.
- acq()[source]
Process - Start data acquisition.
Notes
The most recent data collected is stored in session.data in the structure:
>>> response.session['data'] {"fields": {"0": {"status": 0 or 1, (0: OFF, 1:ON) "name": "outlet1"}, "1": {"status": 0 or 1, (0: OFF, 1:ON) "name": "outlet2"}, "2": {"status": 0 or 1, (0: OFF, 1:ON) "name": "outlet3"}, "3": {"status": 0 or 1, (0: OFF, 1:ON) "name": "outlet4"}, "4": {"status": 0 or 1, (0: OFF, 1:ON) "name": "outlet5"}, } }
Example Clients
Below is an example client to control outlets:
from ocs import ocs_client
synaccess = ocs_client.OCSClient('synacc', args=[])
#Get status of the strip
synaccess.get_status.start()
status, msg, session = synaccess.get_status.wait()
session['messages']
#Reboot outlet
synaccess.reboot.start(outlet=1)
synaccess.reboot.wait()
#Turn on/off outlet
synaccess.set_outlet.start(outlet=1, on=True)
synaccess.set_outlet.wait()
#Turn on/off all outlets
synaccess.set_all.start(on=True)
synaccess.set_all.wait()