本文整理匯總了Java中com.veraxsystems.vxipmi.coding.commands.chassis.PowerCommand類的典型用法代碼示例。如果您正苦於以下問題:Java PowerCommand類的具體用法?Java PowerCommand怎麽用?Java PowerCommand使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
PowerCommand類屬於com.veraxsystems.vxipmi.coding.commands.chassis包,在下文中一共展示了PowerCommand類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import com.veraxsystems.vxipmi.coding.commands.chassis.PowerCommand; //導入依賴的package包/類
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
IpmiConnector connector;
// Create the connector, specify port that will be used to communicate
// with the remote host. The UDP layer starts listening at this port, so
// no 2 connectors can work at the same time on the same port.
connector = new IpmiConnector(6000);
System.out.println("Connector created");
// Create the connection and get the handle, specify IP address of the
// remote host. The connection is being registered in ConnectionManager,
// the handle will be needed to identify it among other connections
// (target IP address isn't enough, since we can handle multiple
// connections to the same host)
ConnectionHandle handle = connector.createConnection(InetAddress.getByName("192.168.1.1"));
System.out.println("Connection created");
// Get available cipher suites list via getAvailableCipherSuites and
// pick one of them that will be used further in the session.
//CipherSuite cs = connector.getAvailableCipherSuites(handle).get(3);
//System.out.println("Cipher suite picked");
// Provide chosen cipher suite and privilege level to the remote host.
// From now on, your connection handle will contain these information.
//connector.getChannelAuthenticationCapabilities(handle, cs, PrivilegeLevel.Administrator);
//System.out.println("Channel authentication capabilities receivied");
// new action to getCipherSuite
CipherSuite cs = new CipherSuite((byte) 0, (byte) 1, (byte) 1,(byte) 1);
Connection connection = connector.getAsyncConnector().getConnectionManager().getConnection(handle.getHandle());
connection.getStateMachine().setCurrent(new Ciphers());
connector.getChannelAuthenticationCapabilities(handle, cs, PrivilegeLevel.User);
System.out.println("Channel authentication capabilities receivied");
// Start the session, provide username and password, and optionally the
// BMC key (only if the remote host has two-key authentication enabled,
// otherwise this parameter should be null)
connector.openSession(handle, "user", "pass", null);
System.out.println("Session open");
// Send some message and read the response
GetChassisStatusResponseData rd = (GetChassisStatusResponseData) connector.sendMessage(handle,
new GetChassisStatus(IpmiVersion.V20, cs, AuthenticationType.RMCPPlus));
System.out.println("Received answer");
System.out.println("System power state is " + (rd.isPowerOn() ? "up" : "down"));
// Set session privilege level to administrator, as ChassisControl command requires this level
connector.sendMessage(handle, new SetSessionPrivilegeLevel(IpmiVersion.V20, cs, AuthenticationType.RMCPPlus,
PrivilegeLevel.Administrator));
ChassisControl chassisControl = null;
//Power on or off
if (!rd.isPowerOn()) {
chassisControl = new ChassisControl(IpmiVersion.V20, cs, AuthenticationType.RMCPPlus, PowerCommand.PowerUp);
} else {
chassisControl = new ChassisControl(IpmiVersion.V20, cs, AuthenticationType.RMCPPlus,
PowerCommand.PowerDown);
}
ChassisControlResponseData data = (ChassisControlResponseData) connector.sendMessage(handle, chassisControl);
// Close the session
connector.closeSession(handle);
System.out.println("Session closed");
// Close connection manager and release the listener port.
connector.tearDown();
System.out.println("Connection manager closed");
}
示例2: main
import com.veraxsystems.vxipmi.coding.commands.chassis.PowerCommand; //導入依賴的package包/類
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
IpmiConnector connector;
// Create the connector, specify port that will be used to communicate
// with the remote host. The UDP layer starts listening at this port, so
// no 2 connectors can work at the same time on the same port.
connector = new IpmiConnector(6000);
System.out.println("Connector created");
// Create the connection and get the handle, specify IP address of the
// remote host. The connection is being registered in ConnectionManager,
// the handle will be needed to identify it among other connections
// (target IP address isn't enough, since we can handle multiple
// connections to the same host)
ConnectionHandle handle = connector.createConnection(InetAddress.getByName("192.168.1.1"));
System.out.println("Connection created");
// Get available cipher suites list via getAvailableCipherSuites and
// pick one of them that will be used further in the session.
CipherSuite cs = connector.getAvailableCipherSuites(handle).get(3);
System.out.println("Cipher suite picked");
// Provide chosen cipher suite and privilege level to the remote host.
// From now on, your connection handle will contain these information.
connector.getChannelAuthenticationCapabilities(handle, cs, PrivilegeLevel.Administrator);
System.out.println("Channel authentication capabilities receivied");
// Start the session, provide username and password, and optionally the
// BMC key (only if the remote host has two-key authentication enabled,
// otherwise this parameter should be null)
connector.openSession(handle, "user", "pass", null);
System.out.println("Session open");
// Send some message and read the response
GetChassisStatusResponseData rd = (GetChassisStatusResponseData) connector.sendMessage(handle,
new GetChassisStatus(IpmiVersion.V20, cs, AuthenticationType.RMCPPlus));
System.out.println("Received answer");
System.out.println("System power state is " + (rd.isPowerOn() ? "up" : "down"));
// Set session privilege level to administrator, as ChassisControl command requires this level
connector.sendMessage(handle, new SetSessionPrivilegeLevel(IpmiVersion.V20, cs, AuthenticationType.RMCPPlus,
PrivilegeLevel.Administrator));
ChassisControl chassisControl = null;
//Power on or off
if (!rd.isPowerOn()) {
chassisControl = new ChassisControl(IpmiVersion.V20, cs, AuthenticationType.RMCPPlus, PowerCommand.PowerUp);
} else {
chassisControl = new ChassisControl(IpmiVersion.V20, cs, AuthenticationType.RMCPPlus,
PowerCommand.PowerDown);
}
ChassisControlResponseData data = (ChassisControlResponseData) connector.sendMessage(handle, chassisControl);
// Close the session
connector.closeSession(handle);
System.out.println("Session closed");
// Close connection manager and release the listener port.
connector.tearDown();
System.out.println("Connection manager closed");
}