Class Device
Client session.
It can retrieve its description, its number of logins, its variable and command lists.
A Device object can be retrieved from a Client instance,
and cannot be constructed directly.
- Author:
- Emilien Kia
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidThis function does little by itself.voidThis function does little by itself.Return the client to which the device is connected.String[]Return the list of clients which have done LOGIN for this UPS.getCommand(String name) Return a command from its name.Command[]Return the list of device commands from the NUT server.Retrieve the device description from UPSD and store it in a cache.getName()Return the device name.intReturn the number of clients which have done LOGIN for this UPS.Variable[]Return the list of device RW variables from the NUT server.getVariable(String name) Return a variable from its name.Variable[]Return the list of device variables from the NUT server.voidlogin()Log in to the UPS to assume a special role which matters to orchestration of the server lifecycle and its other clients.voidmaster()Deprecated.voidSet the "forced shutdown" flag.
-
Constructor Details
-
Device
-
-
Method Details
-
getClient
Return the client to which the device is connected.- Returns:
- Attached client.
-
getName
-
getDescription
Retrieve the device description from UPSD and store it in a cache.- Returns:
- Device description
- Throws:
IOExceptionNutException
-
login
Log in to the UPS to assume a special role which matters to orchestration of the server lifecycle and its other clients. NOTE: CallClient.authenticate()first.Use this to log the fact that a system is drawing power from this UPS. The upsmon primary system will wait until the count of attached systems reaches 1 - itself. This allows the secondaries to shut down first.
NOTE: You probably shouldn't send this command unless you are upsmon, or an upsmon replacement.
- Throws:
IOExceptionNutException- See Also:
-
becomePrimary
This function does little by itself. It is used by upsmon to make sure that master-level functions like FSD are available if necessary.NOTE: API changed since NUT 2.8.0 to replace MASTER with PRIMARY (and backwards-compatible alias handling)
- Throws:
IOExceptionNutException- See Also:
-
master
Deprecated.UsebecomePrimary()instead- Throws:
IOExceptionNutException- See Also:
-
becomeSecondary
This function does little by itself. It is used by upsmon to make sure that slave instances are known and waited for by the master instance to disconnect from the data server in case of FSD and mass shutdown.NOTE: API changed since NUT 2.8.0 to replace SLAVE with SECONDARY (and backwards-compatible alias handling)
- Throws:
IOExceptionNutException- See Also:
-
setForcedShutdown
Set the "forced shutdown" flag.upsmon in
PRIMARYmode is the main user of this function. On the data server side, it sets the "forced shutdown" flag on any UPS when it plans to power it off. This is done so thatSECONDARYsystems will know about it, and would shut down before the power disappears.Setting this flag makes "FSD" appear in a STATUS request for this UPS. Finding "FSD" in a status request should be treated just like an "OB LB".
It should be noted that FSD is currently a latch - once set, there is no way to clear it short of restarting upsd or dropping then re-adding it in the ups.conf. This may cause issues when upsd is running on a system that is not shut down due to the UPS event.
- Throws:
IOExceptionNutException
-
getNumLogin
Return the number of clients which have done LOGIN for this UPS. Force to retrieve it from UPSD and store it in a cache.- Returns:
- Number of clients, -1 if error.
- Throws:
IOExceptionNutException
-
getClients
Return the list of clients which have done LOGIN for this UPS.- Returns:
- List of client hostnames.
- Throws:
IOExceptionNutException
-
getVariableList
Return the list of device variables from the NUT server.- Returns:
- List of variables, empty if nothing, null if not connected or failed.
- Throws:
IOExceptionNutException
-
getRWVariableList
Return the list of device RW variables from the NUT server.- Returns:
- List of variables, empty if nothing, null if not connected or failed.
- Throws:
IOExceptionNutException
-
getVariable
Return a variable from its name.- Parameters:
name- Name of the queried variable.- Returns:
- The corresponding variable object if exists.
- Throws:
IOExceptionNutException
-
getCommandList
Return the list of device commands from the NUT server.- Returns:
- List of commands, empty if nothing, null if not connected or failed.
- Throws:
IOExceptionNutException
-
getCommand
Return a command from its name.- Parameters:
name- Name of the queried command.- Returns:
- The corresponding command object if exists.
- Throws:
IOExceptionNutException
-
becomePrimary()instead