Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.metricshub.ipmi.client;

import org.metricshub.ipmi.core.common.Constants;

/*-
* ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
* IPMI Java Client
Expand Down Expand Up @@ -34,6 +36,7 @@ public class IpmiClientConfiguration {
private char[] password;
private byte[] bmcKey;
private boolean skipAuth;
private int port = Constants.IPMI_PORT;
private long timeout;
private long pingPeriod = -1;

Expand All @@ -57,6 +60,23 @@ public IpmiClientConfiguration(String hostname, String username, char[] password
this.timeout = timeout;
}

/**
* Instantiates a new {@link IpmiClientConfiguration} in order to query the IPMI host.
*
* @param hostname IP Address or host name of the remote IPMI host.
* @param port UDP port number of the remote IPMI host.
* @param username Name used to establish the connection with the host via the IPMI protocol.
* @param password Password used to establish the connection with the host via the IPMI protocol.
* @param bmcKey The key that should be provided if the two-key authentication is enabled, null otherwise.
* @param skipAuth Whether the client should skip authentication
* @param timeout Timeout used for each IPMI request.
*/
public IpmiClientConfiguration(String hostname, int port, String username, char[] password,
byte[] bmcKey, boolean skipAuth, long timeout) {
this(hostname, username, password, bmcKey, skipAuth, timeout);
this.port = port;
}

/**
* Instantiates a new {@link IpmiClientConfiguration} in order to query the IPMI host.
*
Expand Down Expand Up @@ -93,6 +113,24 @@ public void setHostname(String hostname) {
this.hostname = hostname;
}

/**
* Returns the UDP port number of the remote IPMI host.
*
* @return UDP port number of the remote IPMI host.
*/
public int getPort() {
return port;
}

/**
* Sets the UDP port number of the remote IPMI host.
*
* @param port UDP port number of the remote IPMI host.
*/
public void setPort(int port) {
this.port = port;
}

/**
* Returns the name used to establish the connection with the host via the IPMI
* protocol.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ protected void startSession() throws Exception {
authenticate();
} else {
handle = connector.createConnection(InetAddress.getByName(ipmiConfiguration.getHostname()),
Connection.getDefaultCipherSuite(), PrivilegeLevel.User);
ipmiConfiguration.getPort(), Connection.getDefaultCipherSuite(), PrivilegeLevel.User);
}

// Start the session, provide user name and password, and optionally the
Expand All @@ -122,7 +122,8 @@ public void authenticate() throws Exception {
// 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)
handle = connector.createConnection(InetAddress.getByName(ipmiConfiguration.getHostname()));
handle = connector.createConnection(InetAddress.getByName(ipmiConfiguration.getHostname()),
ipmiConfiguration.getPort());

// Get available cipher suites list via getAvailableCipherSuites and
// pick one of them that will be used further in the session.
Expand Down
Loading