OpentestOtherSrvApc

From AragoWiki

Revision as of 19:08, 12 April 2012 by Chernandez (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Back to Opentest's home

Contents

Apc Power Controller Service (APCS)

The Apc Power Controller Service (APCS), is a STAF service developed in java that synchronizes simultaneous access of one or more Apc power controllers that are being accessed by several TEEs or users. The Apcs allow remote control of their power ports via telnet, however, the telnet server provided with the Apcs is only a single client server so the Apc power controller service provides a queuing mechanism that synchronizes the requests directed to a given Apc. Multiple Apcs can be managed by a single instance of the Apc power controller service, but two instances of the Apc power controller service should not be configured to manage the same Apc. The source code for APCS is included as part of the source code of the STAF services developed for Opentest, which can be found at Opentest STAF services

Starting the Service

APCS is a STAF service, in order to run APCS STAF should be running on the machine hosting the service. APCS can be started at STAF boot-up time via the STAF.cfg file, or through the STAF command line.

Starting APCS via STAF.cfg file

To start APCS at STAF boot-up time edit the STAF.cfg located inside the bin folder of your STAF installation directory and add the following line.

SERVICE <APCS service name> LIBRARY JSTAF EXECUTE <path to APCS jar file>

For example if the APCS service was to be name APCS and the jar file was located at /home/myhome/Apc.jar the STAF.cfg entry would be SERVICE APCS LIBRARY JSTAF EXECUTE /home/myhome/Apc.jar

Starting APCS from the command line

To start APCS from the command line open a shell and issue the following command.

staf local SERVICE ADD SERVICE <APCS service name> LIBRARY JSTAF EXECUTE <path to APCS jar file>

For example if the APCS service was to be name APCS and the jar file was located at /home/myhome/Apc.jar the STAF.cfg command would be staf local SERVICE ADD SERVICE APCS LIBRARY JSTAF EXECUTE /home/myhome/Apc.jar

APCS Commands

Since APCS is a STAF service all APCS commands listed below should be prefixed with staf <APCS machine ip address or network name> <APCS service name> when being used. APCS supports the following commands:

ADD

This command is used to register an Apc with APCS. The command syntax is

ADD <apc's IP address> USERNAME <user name> PASSWORD <password> ID <apc id>

where <apc's IP address> is the ip address of the Apc being registered, <user name> is the telnet login of the Apc being registered, <password> is the telnet password associated with <user name>, and id an is an id that can be used to reference the Apc being registered when issuing other commands. For example, if a machine is hosting an APCS service named "ApcServer" has IP address "1.2.3.4"; the Apc being registered uses ip address 11.22.33.44; requires "apc" as the user name that has "apc" as the password; and will be referenced as "apc1" in the future then the command would be "staf 1.2.3.4 ApcServer ADD 11.22.33.44 USERNAME apc PASSWORD apc ID apc1".

Note: More than one Apc can be registered with the same id as long as they are registered from different machines, if the same id is used to registered two different Apcs from the same machine, then the second registration command will overwrite the first entry.

SWITCH

This command is used to toggle the state of a given power port. The command syntax is

SWITCH <id|ip> PORT <port #> <ON|OFF>

where <id|ip> is either the ip address of the Apc or the id used when it was registered with the APCS service; <port #> is the number of the power port whose state will be changed; and <ON|OFF> is the state the port will be toggled to. For example, if a machine is hosting an APCS service named "ApcServer" has Ip address "1.2.3.4"; the Apc was registered with id "apc1"; the port being toggled is 4 and is going to be turned "on" the command would be "staf 1.2.3.4 ApcServer switch apc1 port 4 on".

RESET

This command is used to transition a given power port OFF then ON. The command syntax is

RESET <id|ip> PORT <port #> [DELAY <millisec>]

where <id|ip> is either the ip address of the Apc or the id used when it was registered with the APCS service; <port #> is the number of the power port being reset; <millisec> is an optional parameter that specifies a delay in milliseconds that will be taken before toggling the port to the ON state. For example, if a machine is hosting an APCS service named "ApcServer" has Ip address "1.2.3.4"; the Apc was registered with id "apc1"; the port being reset is 4; and 5 sec should pass between the OFF and ON states of the port the command would be "staf 1.2.3.4 ApcServer reset apc1 port 4 delay 5000".

GET

This command is used to obtain the state of a given power. The command syntax is

GET <id|ip> PORT <port #> STATUS

where <id|ip> is either the ip address of the Apc or the id used when it was registered with the APCS service; <port #> is the number of the power port whose state is being queried. For example, if a machine is hosting an APCS service named "ApcServer" has Ip address "1.2.3.4"; the Apc was registered with id "apc1"; the port being queried is 4 the command would be "staf 1.2.3.4 ApcServer get apc1 port 4 status".

DELETE

This command is used to remove the given Apc from the APCS service configuration. The command syntax is

DELETE <id>

where id is the id used when the Apc was registered with the APCS service. For example, if a machine is hosting an APCS service named "ApcServer" has Ip address "1.2.3.4"; and the Apc was registered with id "apc1" the command would be "staf 1.2.3.4 ApcServer delete apc1".

ADMIN DELETE

This command is used to remove alls Apcs that have been registered with the same id from the APCS service configuration. The command syntax is

ADMIN DELETE <id>

where id is the id used when the Apcs were registered with the APCS service. For example, if a machine is hosting an APCS service named "ApcServer" has Ip address "1.2.3.4"; and one or more Apcs have been registred with id "apc1" the command would be "staf 1.2.3.4 ApcServer admin delete apc1".

LIST

This command is used to print out a list of the Apcs that have been registered with the service. The command syntax is

LIST

For example, if a machine is hosting an APCS service named "ApcServer" and has Ip address "1.2.3.4"; the command would be "staf 1.2.3.4 ApcServer list".

Personal tools