Work on avoiding lingering sessions on the HMC.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
41decccc82
commit
bdfa535b75
14
build.gradle
14
build.gradle
|
@ -17,15 +17,15 @@ group = projectGroup
|
||||||
version = projectVersion
|
version = projectVersion
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
annotationProcessor 'info.picocli:picocli-codegen:4.7.3'
|
annotationProcessor 'info.picocli:picocli-codegen:4.7.4'
|
||||||
implementation 'info.picocli:picocli:4.7.3'
|
implementation 'info.picocli:picocli:4.7.4'
|
||||||
implementation 'org.slf4j:slf4j-api:2.0.7'
|
implementation 'org.slf4j:slf4j-api:2.0.7'
|
||||||
implementation 'org.slf4j:slf4j-simple:2.0.7'
|
implementation 'org.slf4j:slf4j-simple:2.0.7'
|
||||||
implementation 'com.squareup.okhttp3:okhttp:4.10.0' // Also used by InfluxDB Client
|
implementation 'com.squareup.okhttp3:okhttp:4.11.0' // Also used by InfluxDB Client
|
||||||
implementation 'com.influxdb:influxdb-client-java:6.8.0'
|
implementation 'com.influxdb:influxdb-client-java:6.10.0'
|
||||||
implementation 'com.fasterxml.jackson.core:jackson-databind:2.14.3'
|
implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.2'
|
||||||
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.14.3'
|
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.15.2'
|
||||||
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-toml:2.14.3'
|
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-toml:2.15.2'
|
||||||
|
|
||||||
testImplementation 'junit:junit:4.13.2'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
testImplementation 'org.spockframework:spock-core:2.3-groovy-4.0'
|
testImplementation 'org.spockframework:spock-core:2.3-groovy-4.0'
|
||||||
|
|
|
@ -11,9 +11,9 @@ Ensure you have **correct date/time** and NTPd running to keep it accurate!
|
||||||
- Navigate to *Users and Security*
|
- Navigate to *Users and Security*
|
||||||
- Create a new read-only/viewer **hmci** user, which will be used to connect to the HMC.
|
- Create a new read-only/viewer **hmci** user, which will be used to connect to the HMC.
|
||||||
- Click *Manage User Profiles and Access*, edit the newly created *hmci* user and click *User Properties*:
|
- Click *Manage User Profiles and Access*, edit the newly created *hmci* user and click *User Properties*:
|
||||||
- Set *Session timeout minutes* to **60**
|
- Set *Session timeout minutes* to **120** (or at least 61 minutes)
|
||||||
- Set *Verify timeout minutes* to **15**
|
- Set *Verify timeout minutes* to **15**
|
||||||
- Set *Idle timeout minutes* to **90**
|
- Set *Idle timeout minutes* to **15**
|
||||||
- Set *Minimum time in days between password changes* to **0**
|
- Set *Minimum time in days between password changes* to **0**
|
||||||
- **Enable** *Allow remote access via the web*
|
- **Enable** *Allow remote access via the web*
|
||||||
- Navigate to *HMC Management* and *Console Settings*
|
- Navigate to *HMC Management* and *Console Settings*
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
projectId = hmci
|
projectId = hmci
|
||||||
projectGroup = biz.nellemann.hmci
|
projectGroup = biz.nellemann.hmci
|
||||||
projectVersion = 1.4.4
|
projectVersion = 1.4.5
|
||||||
|
|
|
@ -83,10 +83,10 @@ public final class InfluxClient {
|
||||||
Runtime.getRuntime().addShutdownHook(new Thread(influxDBClient::close));
|
Runtime.getRuntime().addShutdownHook(new Thread(influxDBClient::close));
|
||||||
|
|
||||||
// Todo: Handle events - https://github.com/influxdata/influxdb-client-java/tree/master/client#handle-the-events
|
// Todo: Handle events - https://github.com/influxdata/influxdb-client-java/tree/master/client#handle-the-events
|
||||||
//writeApi = influxDBClient.makeWriteApi();
|
|
||||||
writeApi = influxDBClient.makeWriteApi(
|
writeApi = influxDBClient.makeWriteApi(
|
||||||
WriteOptions.builder()
|
WriteOptions.builder()
|
||||||
.bufferLimit(20_000)
|
.batchSize(15_000)
|
||||||
|
.bufferLimit(500_000)
|
||||||
.flushInterval(5_000)
|
.flushInterval(5_000)
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,8 @@ import java.security.KeyManagementException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@ -38,6 +40,9 @@ public class RestClient {
|
||||||
protected final String username;
|
protected final String username;
|
||||||
protected final String password;
|
protected final String password;
|
||||||
|
|
||||||
|
private final static int MAX_MINUTES_BETWEEN_AUTHENTICATION = 60; // TODO: Make configurable and match HMC timeout settings
|
||||||
|
private Instant lastAuthenticationTimestamp;
|
||||||
|
|
||||||
|
|
||||||
public RestClient(String baseUrl, String username, String password, Boolean trustAll) {
|
public RestClient(String baseUrl, String username, String password, Boolean trustAll) {
|
||||||
this.baseUrl = baseUrl;
|
this.baseUrl = baseUrl;
|
||||||
|
@ -63,6 +68,8 @@ public class RestClient {
|
||||||
log.error("ManagementConsole() - trace error: " + e.getMessage());
|
log.error("ManagementConsole() - trace error: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
Thread shutdownHook = new Thread(this::logoff);
|
||||||
|
Runtime.getRuntime().addShutdownHook(shutdownHook);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,6 +77,9 @@ public class RestClient {
|
||||||
* Logon to the HMC and get an authentication token for further requests.
|
* Logon to the HMC and get an authentication token for further requests.
|
||||||
*/
|
*/
|
||||||
public synchronized void login() {
|
public synchronized void login() {
|
||||||
|
if(authToken != null) {
|
||||||
|
logoff();
|
||||||
|
}
|
||||||
|
|
||||||
log.info("Connecting to HMC - {} @ {}", username, baseUrl);
|
log.info("Connecting to HMC - {} @ {}", username, baseUrl);
|
||||||
StringBuilder payload = new StringBuilder();
|
StringBuilder payload = new StringBuilder();
|
||||||
|
@ -102,10 +112,12 @@ public class RestClient {
|
||||||
LogonResponse logonResponse = xmlMapper.readValue(responseBody, LogonResponse.class);
|
LogonResponse logonResponse = xmlMapper.readValue(responseBody, LogonResponse.class);
|
||||||
|
|
||||||
authToken = logonResponse.getToken();
|
authToken = logonResponse.getToken();
|
||||||
|
lastAuthenticationTimestamp = Instant.now();
|
||||||
log.debug("logon() - auth token: {}", authToken);
|
log.debug("logon() - auth token: {}", authToken);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("logon() - error: {}", e.getMessage());
|
log.warn("logon() - error: {}", e.getMessage());
|
||||||
|
lastAuthenticationTimestamp = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -136,6 +148,7 @@ public class RestClient {
|
||||||
log.warn("logoff() error: {}", e.getMessage());
|
log.warn("logoff() error: {}", e.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
authToken = null;
|
authToken = null;
|
||||||
|
lastAuthenticationTimestamp = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
|
@ -164,6 +177,9 @@ public class RestClient {
|
||||||
public synchronized String getRequest(URL url) throws IOException {
|
public synchronized String getRequest(URL url) throws IOException {
|
||||||
|
|
||||||
log.debug("getRequest() - URL: {}", url.toString());
|
log.debug("getRequest() - URL: {}", url.toString());
|
||||||
|
if (lastAuthenticationTimestamp == null || lastAuthenticationTimestamp.plus(MAX_MINUTES_BETWEEN_AUTHENTICATION, ChronoUnit.MINUTES).isBefore(Instant.now())) {
|
||||||
|
login();
|
||||||
|
}
|
||||||
|
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
.url(url)
|
.url(url)
|
||||||
|
@ -222,6 +238,10 @@ public class RestClient {
|
||||||
public synchronized String postRequest(URL url, String payload) throws IOException {
|
public synchronized String postRequest(URL url, String payload) throws IOException {
|
||||||
|
|
||||||
log.debug("sendPostRequest() - URL: {}", url.toString());
|
log.debug("sendPostRequest() - URL: {}", url.toString());
|
||||||
|
if (lastAuthenticationTimestamp == null || lastAuthenticationTimestamp.plus(MAX_MINUTES_BETWEEN_AUTHENTICATION, ChronoUnit.MINUTES).isBefore(Instant.now())) {
|
||||||
|
login();
|
||||||
|
}
|
||||||
|
|
||||||
RequestBody requestBody;
|
RequestBody requestBody;
|
||||||
if(payload != null) {
|
if(payload != null) {
|
||||||
requestBody = RequestBody.create(payload, MEDIA_TYPE_IBM_XML_POST);
|
requestBody = RequestBody.create(payload, MEDIA_TYPE_IBM_XML_POST);
|
||||||
|
|
|
@ -5,6 +5,6 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public final class PowerUtil {
|
public final class PowerUtil {
|
||||||
|
|
||||||
public Number powerReading = 0.0;
|
public float powerReading = 0.0F;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,7 @@ class LogicalPartitionTest extends Specification {
|
||||||
}
|
}
|
||||||
|
|
||||||
def cleanupSpec() {
|
def cleanupSpec() {
|
||||||
|
serviceClient.logoff()
|
||||||
mockServer.stop()
|
mockServer.stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ class ManagedSystemTest extends Specification {
|
||||||
}
|
}
|
||||||
|
|
||||||
def cleanupSpec() {
|
def cleanupSpec() {
|
||||||
|
serviceClient.logoff()
|
||||||
mockServer.stop()
|
mockServer.stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue