Initial code commit

This commit is contained in:
Mark Nellemann 2020-08-07 08:13:48 +02:00
commit 9083e85d76
18 changed files with 9528 additions and 0 deletions

6
.gitattributes vendored Normal file
View File

@ -0,0 +1,6 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# These are explicitly windows files and should use crlf
*.bat text eol=crlf

8
.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
# Ignore Gradle project-specific cache directory
.gradle
# Ignore Gradle build output directory
build
# Ignore IntelliJ Idea directory
.idea

45
build.gradle Normal file
View File

@ -0,0 +1,45 @@
/*
* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Groovy project to get you started.
* For more details take a look at the Groovy Quickstart chapter in the Gradle
* User Manual available at https://docs.gradle.org/6.5.1/userguide/tutorial_groovy_projects.html
*/
plugins {
// Apply the groovy plugin to add support for Groovy
id 'groovy'
// Apply the application plugin to add support for building a CLI application.
id 'application'
}
repositories {
// Use jcenter for resolving dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
}
dependencies {
// Use the latest Groovy version for building this library
implementation 'org.codehaus.groovy:groovy-all:3.0.5'
implementation 'com.squareup.okhttp3:okhttp:4.8.0'
implementation 'org.slf4j:slf4j-api:1.7.+'
runtimeOnly 'ch.qos.logback:logback-classic:1.+'
// Use the awesome Spock testing and specification framework
//testImplementation 'org.spockframework:spock-core:1.3-groovy-2.5'
testImplementation('org.spockframework:spock-core:2.0-M3-groovy-3.0')
testImplementation("org.slf4j:slf4j-simple:1.7.+")
testImplementation('com.squareup.okhttp3:mockwebserver:4.8.0')
}
application {
// Define the main class for the application.
mainClassName = 'biz.nellemann.hmci.App'
}
test {
useJUnitPlatform()
}

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View File

@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

185
gradlew vendored Executable file
View File

@ -0,0 +1,185 @@
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
exec "$JAVACMD" "$@"

104
gradlew.bat vendored Normal file
View File

@ -0,0 +1,104 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

10
settings.gradle Normal file
View File

@ -0,0 +1,10 @@
/*
* This file was generated by the Gradle 'init' task.
*
* The settings file is used to specify which projects to include in your build.
*
* Detailed information about configuring a multi-project build in Gradle can be found
* in the user manual at https://docs.gradle.org/6.5.1/userguide/multi_project_builds.html
*/
rootProject.name = 'hmci'

View File

@ -0,0 +1,49 @@
package biz.nellemann.hmci
import groovy.cli.picocli.CliBuilder
import groovy.cli.picocli.OptionAccessor
import groovy.util.logging.Slf4j
@Slf4j
class App {
static void main(String... args) {
def cli = new CliBuilder()
cli.h(longOpt: 'help', 'display usage')
cli.v(longOpt: 'version', 'display version')
cli.c(longOpt: 'config', args: 1, required: true, defaultValue: '~/.config/hmci.properties', 'configuration file')
OptionAccessor options = cli.parse(args)
if (options.h) cli.usage()
if(options.c) {
//println("TODO: Use configuration file: " + options.config)
}
Hmc hmc
try {
hmc = new Hmc("https://10.32.64.39:12443", "hmci", "hmcihmci")
hmc.login()
hmc.getManagedSystems()
hmc.getLogicalPartitions()
//hmc.getManagedSystemProcessedMetrics()
//hmc.getLogicalPartitionProcessedMetrics()
hmc.logoff()
} catch(Exception e) {
log.error(e.message)
}
hmc?.managedSystems?.each {
println("Found system: " + it.name)
}
System.exit(0);
}
}

View File

@ -0,0 +1,258 @@
package biz.nellemann.hmci
import biz.nellemann.hmci.pojo.LogicalPartition
import biz.nellemann.hmci.pojo.ManagedSystem
import groovy.util.logging.Slf4j
import groovy.xml.XmlSlurper
import okhttp3.MediaType
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.RequestBody
import okhttp3.Response
import javax.net.ssl.HostnameVerifier
import javax.net.ssl.SSLContext
import javax.net.ssl.SSLSession
import javax.net.ssl.SSLSocketFactory
import javax.net.ssl.TrustManager
import javax.net.ssl.X509TrustManager
import java.security.SecureRandom
import java.security.cert.CertificateException
import java.security.cert.X509Certificate;
@Slf4j
class Hmc {
private static final MediaType MEDIA_TYPE_PLAIN = MediaType.parse("text/plain; charset=utf-8");
private static final MediaType MEDIA_TYPE_XML = MediaType.parse("application/xml; charset=utf-8");
private static final MediaType MEDIA_TYPE_IBM_XML_LOGIN = MediaType.parse("application/vnd.ibm.powervm.web+xml; type=LogonRequest");
private final String baseUrl
private final String username
private final String password
protected Map<String,ManagedSystem> managedSystems = new HashMap<String, ManagedSystem>()
protected String authToken
private final OkHttpClient client
Hmc(String baseUrl, String username, String password) {
this.baseUrl = baseUrl
this.username = username
this.password = password
//this.client = new OkHttpClient()
this.client = getUnsafeOkHttpClient()
}
void login() throws IOException {
String payload = """\
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<LogonRequest xmlns="http://www.ibm.com/xmlns/systems/power/firmware/web/mc/2012_10/" schemaVersion="V1_0">
<UserID>${username}</UserID>
<Password>${password}</Password>
</LogonRequest>"""
URL url = new URL(String.format("%s/rest/api/web/Logon", baseUrl))
Request request = new Request.Builder()
.url(url)
//.addHeader("Content-Type", "application/vnd.ibm.powervm.web+xml; type=LogonRequest")
.addHeader("Accept", "application/vnd.ibm.powervm.web+xml; type=LogonResponse")
.addHeader("X-Audit-Memento", "hmci")
.put(RequestBody.create(payload, MEDIA_TYPE_IBM_XML_LOGIN))
.build();
Response response = client.newCall(request).execute();
if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);
// Get response body and parse
String responseBody = response.body.string()
def xml = new XmlSlurper().parseText(responseBody)
authToken = xml.toString()
log.debug("Auth Token: " + authToken)
}
void logoff() {
URL absUrl = new URL(String.format("%s/rest/api/web/Logon", baseUrl))
Request request = new Request.Builder()
.url(absUrl)
.addHeader("Content-Type", "application/vnd.ibm.powervm.web+xml; type=LogonRequest")
.addHeader("X-API-Session", authToken)
.delete()
.build();
Response response = client.newCall(request).execute();
if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);
this.authToken = null
}
void getManagedSystems() {
URL url = new URL(String.format("%s/rest/api/uom/ManagedSystem", baseUrl))
Response response = getResponse(url)
String responseBody = response.body.string()
def feed = new XmlSlurper().parseText(responseBody)
feed?.entry?.each { entry ->
//log.debug("Entry")
entry.content.each { content ->
//log.debug("Content")
content.ManagedSystem.each { system ->
ManagedSystem managedSystem = new ManagedSystem(entry.id as String)
managedSystem.name = system.SystemName
managedSystem.model = system.MachineTypeModelAndSerialNumber.Model
managedSystem.type = system.MachineTypeModelAndSerialNumber.MachineType
managedSystem.serialNumber = system.MachineTypeModelAndSerialNumber.SerialNumber
managedSystems.put(managedSystem.id, managedSystem)
log.debug("getManagedSystems() " + managedSystem.toString())
}
}
}
}
void getLogicalPartitions(ManagedSystem system) {
managedSystems.each {
getLogicalPartitionsForManagedSystem(it)
}
}
void getLogicalPartitionsForManagedSystem(ManagedSystem system) {
URL url = new URL(String.format("%s/rest/api/uom/ManagedSystem/%s/LogicalPartition", baseUrl, system.id))
Response response = getResponse(url)
String responseBody = response.body.string()
//log.debug(responseBody)
def feed = new XmlSlurper().parseText(responseBody)
feed?.entry?.each { entry ->
//log.debug("Entry")
entry.content.each { content ->
//log.debug("Content")
content.LogicalPartition.each { partition ->
LogicalPartition logicalPartition = new LogicalPartition(partition.PartitionUUID as String)
logicalPartition.name = partition.PartitionName
logicalPartition.type = partition.PartitionType
system.partitions.put(logicalPartition.id, logicalPartition)
log.debug("getLogicalPartitionsForManagedSystem() " + logicalPartition.toString())
}
}
}
}
void getManagedSystemProcessedMetrics() {
managedSystems.each {
getManagedSystemProcessedMetricsForManagedSystem(it)
}
}
void getManagedSystemProcessedMetricsForManagedSystem(ManagedSystem system) {
URL url = new URL(String.format("%s/rest/api/pcm/ManagedSystem/%s/ProcessedMetrics", baseUrl, system.id))
Response response = getResponse(url)
String responseBody = response.body.string()
log.debug(responseBody)
}
void getLogicalPartitionProcessedMetrics() {
managedSystems.each {
it.partitions.each {
getLogicalPartitionProcessedMetricsForLogicalPartition(it)
}
}
}
void getLogicalPartitionProcessedMetricsForLogicalPartition(LogicalPartition partition) {
URL url = new URL(String.format("%s/rest/api/pcm/LogicalPartition/%s/ProcessedMetrics", baseUrl, partition.id))
log.debug("getLogicalPartitionProcessedMetricsForLogicalPartition() " + url.toString())
Response response = getResponse(url)
String responseBody = response.body.string()
log.debug(responseBody)
/*
def feed = new XmlSlurper().parseText(responseBody)
feed?.entry?.each { entry ->
if(entry.category["@term"] != category) return
String link = entry.link["@href"]
linksList.add(link)
log.debug(link)
}*/
}
private Response getResponse(URL url) {
Request request = new Request.Builder()
.url(url)
.addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8")
.addHeader("X-API-Session", authToken)
.get()
.build();
Response response = client.newCall(request).execute();
if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);
// TODO: Better error detection
return response
}
private static OkHttpClient getUnsafeOkHttpClient() {
try {
// Create a trust manager that does not validate certificate chains
final TrustManager[] trustAllCerts = new TrustManager[] {
new X509TrustManager() {
@Override
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}
@Override
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}
@Override
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[]{};
}
}
};
// Install the all-trusting trust manager
final SSLContext sslContext = SSLContext.getInstance("SSL");
sslContext.init(null, trustAllCerts, new SecureRandom());
// Create an ssl socket factory with our all-trusting manager
final SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
OkHttpClient.Builder builder = new OkHttpClient.Builder();
builder.sslSocketFactory(sslSocketFactory, (X509TrustManager)trustAllCerts[0]);
builder.hostnameVerifier(new HostnameVerifier() {
@Override
public boolean verify(String hostname, SSLSession session) {
return true;
}
});
OkHttpClient okHttpClient = builder.build();
return okHttpClient;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}

View File

@ -0,0 +1,19 @@
package biz.nellemann.hmci.pojo
class LogicalPartition {
public String id
public String name
public String type
protected List<String> pcmLinks
LogicalPartition(String id) {
this.id = id
}
String toString() {
return "[${id}] ${name} (${type})"
}
}

View File

@ -0,0 +1,22 @@
package biz.nellemann.hmci.pojo
class ManagedSystem {
public String id
public String name
public String type
public String model
public String serialNumber
protected List<String> pcmLinks = new ArrayList<>()
public Map<String, LogicalPartition> partitions = new HashMap<String, LogicalPartition>()
ManagedSystem(String id) {
this.id = id
}
String toString() {
return "[${id}] ${name} (${type}-${model} ${serialNumber})"
}
}

View File

@ -0,0 +1,10 @@
/*
* This Spock specification was generated by the Gradle 'init' task.
*/
package biz.nellemann.hmci
import spock.lang.Specification
class AppTest extends Specification {
}

View File

@ -0,0 +1,92 @@
package biz.nellemann.hmci
import biz.nellemann.hmci.pojo.ManagedSystem
import okhttp3.mockwebserver.MockResponse
import okhttp3.mockwebserver.MockWebServer
import spock.lang.Specification
class HmcTest extends Specification {
Hmc hmc
MockWebServer mockServer = new MockWebServer();
def setup() {
mockServer.start();
hmc = new Hmc(mockServer.url("/").toString(), "testUser", "testPassword")
hmc.authToken = "blaBla"
}
def cleanup() {
mockServer.shutdown()
}
void "test getManagedSystems"() {
setup:
def testFile = new File(getClass().getResource('/managed-systems.xml').toURI())
def testXml = testFile.getText('UTF-8')
mockServer.enqueue(new MockResponse().setBody(testXml));
when:
hmc.getManagedSystems()
then:
hmc.managedSystems.size() == 2
hmc.managedSystems[0].id == "e09834d1-c930-3883-bdad-405d8e26e166"
hmc.managedSystems[0].name == "S822L-8247-213C1BA"
}
void "test getLogicalPartitionsForManagedSystem"() {
setup:
def testFile = new File(getClass().getResource('/logical-partitions.xml').toURI())
def testXml = testFile.getText('UTF-8')
mockServer.enqueue(new MockResponse().setBody(testXml));
when:
ManagedSystem system = new ManagedSystem("e09834d1-c930-3883-bdad-405d8e26e166")
hmc.managedSystems.add(system)
hmc.getLogicalPartitionsForManagedSystem(system)
then:
hmc.managedSystems[0].partitions.size() == 12
hmc.managedSystems[0].partitions[0].id == "3380A831-9D22-4F03-A1DF-18B249F0FF8E"
hmc.managedSystems[0].partitions[0].name == "AIX_Test1-e0f725f0-00000005"
hmc.managedSystems[0].partitions[0].type == "AIX/Linux"
}
/*
void "test getSystemPCMLinks"() {
setup:
def testFile = new File(getClass().getResource('/managed-system-pcm.xml').toURI())
def testXml = testFile.getText('UTF-8')
mockServer.enqueue(new MockResponse().setBody(testXml));
ManagedSystem managedSystem = new ManagedSystem("e09834d1-c930-3883-bdad-405d8e26e166")
when:
List<String> links = hmc.getManagedSystemProcessedMetrics(managedSystem)
then:
links.size() == 1
//links[0] == "https://10.32.64.39:12443/rest/api/pcm/ProcessedMetrics/ManagedSystem_b597e4da-2aab-3f52-8616-341d62153559_20200806T183800+0200_20200806T184000+0200_30.json"
}
void "test getPartitionPCMLinks"() {
setup:
def testFile = new File(getClass().getResource('/managed-system-pcm.xml').toURI())
def testXml = testFile.getText('UTF-8')
mockServer.enqueue(new MockResponse().setBody(testXml));
ManagedSystem system = new ManagedSystem()
when:
List<String> links = hmc.getPartitionPCMLinks("e09834d1-c930-3883-bdad-405d8e26e166")
then:
links.size() == 12
links[0] == "https://10.32.64.39:12443/rest/api/pcm/ManagedSystem/b597e4da-2aab-3f52-8616-341d62153559/LogicalPartition/44A89632-E9E6-4E12-91AF-1A33DEE060CF/ProcessedMetrics?NoOfSamples=5"
}
*/
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,151 @@
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:ns2="http://a9.com/-/spec/opensearch/1.1/" xmlns:ns3="http://www.w3.org/1999/xhtml">
<id>b597e4da-2aab-3f52-8616-341d62153559</id>
<updated>2020-08-06T18:40:00.000+02:00</updated>
<title type="text">ProcessedMetrics</title>
<subtitle type="text">ManagedSystem b597e4da-2aab-3f52-8616-341d62153559</subtitle>
<link rel="self" href="https://10.32.64.39:12443/rest/api/pcm/ManagedSystem/b597e4da-2aab-3f52-8616-341d62153559/ProcessedMetrics?NoOfSamples=5"/>
<generator uri="IBM Power Systems Management Console" version="1"/>
<entry>
<id>9b10b25b-2242-48f7-b46a-e25c300ae3f8</id>
<updated>2020-08-06T18:40:00.000+02:00</updated>
<title type="text">ManagedSystem_b597e4da-2aab-3f52-8616-341d62153559_20200806T183800+0200_20200806T184000+0200_30.json</title>
<published>2020-08-06T18:38:00.000+02:00</published>
<link type="application/json" href="https://10.32.64.39:12443/rest/api/pcm/ProcessedMetrics/ManagedSystem_b597e4da-2aab-3f52-8616-341d62153559_20200806T183800+0200_20200806T184000+0200_30.json"/>
<author>
<name>IBM Power Systems Management Console</name>
</author>
<category term="ManagedSystem" frequency="30"/>
</entry>
<entry>
<id>7c2828f5-d643-4274-b60e-d6b6ba8269da</id>
<updated>2020-08-06T18:40:34.417+02:00</updated>
<title type="text">LogicalPartition_44A89632-E9E6-4E12-91AF-1A33DEE060CF</title>
<published>2020-08-06T18:40:34.417+02:00</published>
<link type="application/atom+xml" href="https://10.32.64.39:12443/rest/api/pcm/ManagedSystem/b597e4da-2aab-3f52-8616-341d62153559/LogicalPartition/44A89632-E9E6-4E12-91AF-1A33DEE060CF/ProcessedMetrics?NoOfSamples=5"/>
<author>
<name>IBM Power Systems Management Console</name>
</author>
<category term="LogicalPartition"/>
</entry>
<entry>
<id>595fba0e-d15d-47f3-8403-302197a555ff</id>
<updated>2020-08-06T18:40:34.417+02:00</updated>
<title type="text">LogicalPartition_6B7D14D3-BBD2-475B-8284-70FADBFC37FB</title>
<published>2020-08-06T18:40:34.417+02:00</published>
<link type="application/atom+xml" href="https://10.32.64.39:12443/rest/api/pcm/ManagedSystem/b597e4da-2aab-3f52-8616-341d62153559/LogicalPartition/6B7D14D3-BBD2-475B-8284-70FADBFC37FB/ProcessedMetrics?NoOfSamples=5"/>
<author>
<name>IBM Power Systems Management Console</name>
</author>
<category term="LogicalPartition"/>
</entry>
<entry>
<id>64affb83-513d-4bbe-bc4d-fc82a2c4a802</id>
<updated>2020-08-06T18:40:34.417+02:00</updated>
<title type="text">LogicalPartition_2A379B8A-C6E0-415E-9601-9832251F616F</title>
<published>2020-08-06T18:40:34.417+02:00</published>
<link type="application/atom+xml" href="https://10.32.64.39:12443/rest/api/pcm/ManagedSystem/b597e4da-2aab-3f52-8616-341d62153559/LogicalPartition/2A379B8A-C6E0-415E-9601-9832251F616F/ProcessedMetrics?NoOfSamples=5"/>
<author>
<name>IBM Power Systems Management Console</name>
</author>
<category term="LogicalPartition"/>
</entry>
<entry>
<id>2cbdde76-5a0d-497d-842d-3eff5f21b260</id>
<updated>2020-08-06T18:40:34.417+02:00</updated>
<title type="text">LogicalPartition_1700D42D-C9FA-4131-B024-588FDDC70649</title>
<published>2020-08-06T18:40:34.417+02:00</published>
<link type="application/atom+xml" href="https://10.32.64.39:12443/rest/api/pcm/ManagedSystem/b597e4da-2aab-3f52-8616-341d62153559/LogicalPartition/1700D42D-C9FA-4131-B024-588FDDC70649/ProcessedMetrics?NoOfSamples=5"/>
<author>
<name>IBM Power Systems Management Console</name>
</author>
<category term="LogicalPartition"/>
</entry>
<entry>
<id>4227b8b3-3ac9-4f4b-a915-89b5b8263a84</id>
<updated>2020-08-06T18:40:34.417+02:00</updated>
<title type="text">LogicalPartition_42108956-78CB-4040-A291-DF872B49268F</title>
<published>2020-08-06T18:40:34.417+02:00</published>
<link type="application/atom+xml" href="https://10.32.64.39:12443/rest/api/pcm/ManagedSystem/b597e4da-2aab-3f52-8616-341d62153559/LogicalPartition/42108956-78CB-4040-A291-DF872B49268F/ProcessedMetrics?NoOfSamples=5"/>
<author>
<name>IBM Power Systems Management Console</name>
</author>
<category term="LogicalPartition"/>
</entry>
<entry>
<id>e590c92d-076c-4598-bc21-208758b30d24</id>
<updated>2020-08-06T18:40:34.417+02:00</updated>
<title type="text">LogicalPartition_243A3A4C-85BF-4384-80E9-00954962B8CB</title>
<published>2020-08-06T18:40:34.417+02:00</published>
<link type="application/atom+xml" href="https://10.32.64.39:12443/rest/api/pcm/ManagedSystem/b597e4da-2aab-3f52-8616-341d62153559/LogicalPartition/243A3A4C-85BF-4384-80E9-00954962B8CB/ProcessedMetrics?NoOfSamples=5"/>
<author>
<name>IBM Power Systems Management Console</name>
</author>
<category term="LogicalPartition"/>
</entry>
<entry>
<id>7170c4d9-1437-4571-ba86-7136165f0d82</id>
<updated>2020-08-06T18:40:34.417+02:00</updated>
<title type="text">LogicalPartition_72A9CD86-312A-4A61-B9A3-2D5A11B373E5</title>
<published>2020-08-06T18:40:34.417+02:00</published>
<link type="application/atom+xml" href="https://10.32.64.39:12443/rest/api/pcm/ManagedSystem/b597e4da-2aab-3f52-8616-341d62153559/LogicalPartition/72A9CD86-312A-4A61-B9A3-2D5A11B373E5/ProcessedMetrics?NoOfSamples=5"/>
<author>
<name>IBM Power Systems Management Console</name>
</author>
<category term="LogicalPartition"/>
</entry>
<entry>
<id>012e2505-b6e8-491f-bd1c-7638a5a5b72b</id>
<updated>2020-08-06T18:40:34.417+02:00</updated>
<title type="text">LogicalPartition_58215ABF-1C91-4932-96EA-88041D560EED</title>
<published>2020-08-06T18:40:34.417+02:00</published>
<link type="application/atom+xml" href="https://10.32.64.39:12443/rest/api/pcm/ManagedSystem/b597e4da-2aab-3f52-8616-341d62153559/LogicalPartition/58215ABF-1C91-4932-96EA-88041D560EED/ProcessedMetrics?NoOfSamples=5"/>
<author>
<name>IBM Power Systems Management Console</name>
</author>
<category term="LogicalPartition"/>
</entry>
<entry>
<id>f50167b3-4b05-47f8-b833-356ce10c48c5</id>
<updated>2020-08-06T18:40:34.417+02:00</updated>
<title type="text">LogicalPartition_6D775DB5-010B-4B7C-B585-BB7C9128D259</title>
<published>2020-08-06T18:40:34.417+02:00</published>
<link type="application/atom+xml" href="https://10.32.64.39:12443/rest/api/pcm/ManagedSystem/b597e4da-2aab-3f52-8616-341d62153559/LogicalPartition/6D775DB5-010B-4B7C-B585-BB7C9128D259/ProcessedMetrics?NoOfSamples=5"/>
<author>
<name>IBM Power Systems Management Console</name>
</author>
<category term="LogicalPartition"/>
</entry>
<entry>
<id>1d1117ee-2d1c-4a6e-b0c2-b599c75fe869</id>
<updated>2020-08-06T18:40:34.417+02:00</updated>
<title type="text">LogicalPartition_75E900B0-06E2-4C67-A158-0198B4264304</title>
<published>2020-08-06T18:40:34.417+02:00</published>
<link type="application/atom+xml" href="https://10.32.64.39:12443/rest/api/pcm/ManagedSystem/b597e4da-2aab-3f52-8616-341d62153559/LogicalPartition/75E900B0-06E2-4C67-A158-0198B4264304/ProcessedMetrics?NoOfSamples=5"/>
<author>
<name>IBM Power Systems Management Console</name>
</author>
<category term="LogicalPartition"/>
</entry>
<entry>
<id>037ea153-8368-46ff-9633-e152a7847099</id>
<updated>2020-08-06T18:40:34.417+02:00</updated>
<title type="text">LogicalPartition_3380A831-9D22-4F03-A1DF-18B249F0FF8E</title>
<published>2020-08-06T18:40:34.417+02:00</published>
<link type="application/atom+xml" href="https://10.32.64.39:12443/rest/api/pcm/ManagedSystem/b597e4da-2aab-3f52-8616-341d62153559/LogicalPartition/3380A831-9D22-4F03-A1DF-18B249F0FF8E/ProcessedMetrics?NoOfSamples=5"/>
<author>
<name>IBM Power Systems Management Console</name>
</author>
<category term="LogicalPartition"/>
</entry>
<entry>
<id>3219619b-9803-4807-a6e4-25eca82fa84c</id>
<updated>2020-08-06T18:40:34.417+02:00</updated>
<title type="text">LogicalPartition_2DE05DB6-8AD5-448F-8327-0F488D287E82</title>
<published>2020-08-06T18:40:34.417+02:00</published>
<link type="application/atom+xml" href="https://10.32.64.39:12443/rest/api/pcm/ManagedSystem/b597e4da-2aab-3f52-8616-341d62153559/LogicalPartition/2DE05DB6-8AD5-448F-8327-0F488D287E82/ProcessedMetrics?NoOfSamples=5"/>
<author>
<name>IBM Power Systems Management Console</name>
</author>
<category term="LogicalPartition"/>
</entry>
</feed>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,151 @@
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:ns2="http://a9.com/-/spec/opensearch/1.1/" xmlns:ns3="http://www.w3.org/1999/xhtml">
<id>b597e4da-2aab-3f52-8616-341d62153559</id>
<updated>2020-08-06T22:28:00.000+02:00</updated>
<title type="text">ProcessedMetrics</title>
<subtitle type="text">ManagedSystem b597e4da-2aab-3f52-8616-341d62153559</subtitle>
<link rel="self" href="https://10.32.64.39:12443/rest/api/pcm/ManagedSystem/b597e4da-2aab-3f52-8616-341d62153559/ProcessedMetrics"/>
<generator uri="IBM Power Systems Management Console" version="1"/>
<entry>
<id>c6490306-f076-4ef4-92ce-5259a309db61</id>
<updated>2020-08-06T22:28:00.000+02:00</updated>
<title type="text">ManagedSystem_b597e4da-2aab-3f52-8616-341d62153559_20200806T202900+0200_20200806T222800+0200_30.json</title>
<published>2020-08-06T20:29:00.000+02:00</published>
<link type="application/json" href="https://10.32.64.39:12443/rest/api/pcm/ProcessedMetrics/ManagedSystem_b597e4da-2aab-3f52-8616-341d62153559_20200806T202900+0200_20200806T222800+0200_30.json"/>
<author>
<name>IBM Power Systems Management Console</name>
</author>
<category term="ManagedSystem" frequency="30"/>
</entry>
<entry>
<id>3f3f9a87-2afc-4848-aac1-3119cb294109</id>
<updated>2020-08-06T22:28:57.020+02:00</updated>
<title type="text">LogicalPartition_44A89632-E9E6-4E12-91AF-1A33DEE060CF</title>
<published>2020-08-06T22:28:57.020+02:00</published>
<link type="application/atom+xml" href="https://10.32.64.39:12443/rest/api/pcm/ManagedSystem/b597e4da-2aab-3f52-8616-341d62153559/LogicalPartition/44A89632-E9E6-4E12-91AF-1A33DEE060CF/ProcessedMetrics"/>
<author>
<name>IBM Power Systems Management Console</name>
</author>
<category term="LogicalPartition"/>
</entry>
<entry>
<id>8ea7e83f-643c-4b59-a2af-fddde7727082</id>
<updated>2020-08-06T22:28:57.020+02:00</updated>
<title type="text">LogicalPartition_6B7D14D3-BBD2-475B-8284-70FADBFC37FB</title>
<published>2020-08-06T22:28:57.020+02:00</published>
<link type="application/atom+xml" href="https://10.32.64.39:12443/rest/api/pcm/ManagedSystem/b597e4da-2aab-3f52-8616-341d62153559/LogicalPartition/6B7D14D3-BBD2-475B-8284-70FADBFC37FB/ProcessedMetrics"/>
<author>
<name>IBM Power Systems Management Console</name>
</author>
<category term="LogicalPartition"/>
</entry>
<entry>
<id>a1045796-6070-429f-bb0d-a73199c6d04f</id>
<updated>2020-08-06T22:28:57.020+02:00</updated>
<title type="text">LogicalPartition_2A379B8A-C6E0-415E-9601-9832251F616F</title>
<published>2020-08-06T22:28:57.020+02:00</published>
<link type="application/atom+xml" href="https://10.32.64.39:12443/rest/api/pcm/ManagedSystem/b597e4da-2aab-3f52-8616-341d62153559/LogicalPartition/2A379B8A-C6E0-415E-9601-9832251F616F/ProcessedMetrics"/>
<author>
<name>IBM Power Systems Management Console</name>
</author>
<category term="LogicalPartition"/>
</entry>
<entry>
<id>b0f0e742-b7f3-4f2a-bf71-a34fd12ba48b</id>
<updated>2020-08-06T22:28:57.020+02:00</updated>
<title type="text">LogicalPartition_1700D42D-C9FA-4131-B024-588FDDC70649</title>
<published>2020-08-06T22:28:57.020+02:00</published>
<link type="application/atom+xml" href="https://10.32.64.39:12443/rest/api/pcm/ManagedSystem/b597e4da-2aab-3f52-8616-341d62153559/LogicalPartition/1700D42D-C9FA-4131-B024-588FDDC70649/ProcessedMetrics"/>
<author>
<name>IBM Power Systems Management Console</name>
</author>
<category term="LogicalPartition"/>
</entry>
<entry>
<id>244f78d1-bc27-4748-86cd-a9d7cdff6c4f</id>
<updated>2020-08-06T22:28:57.020+02:00</updated>
<title type="text">LogicalPartition_42108956-78CB-4040-A291-DF872B49268F</title>
<published>2020-08-06T22:28:57.020+02:00</published>
<link type="application/atom+xml" href="https://10.32.64.39:12443/rest/api/pcm/ManagedSystem/b597e4da-2aab-3f52-8616-341d62153559/LogicalPartition/42108956-78CB-4040-A291-DF872B49268F/ProcessedMetrics"/>
<author>
<name>IBM Power Systems Management Console</name>
</author>
<category term="LogicalPartition"/>
</entry>
<entry>
<id>d6b2b153-4de9-4546-b6e7-6e4fc4c97d56</id>
<updated>2020-08-06T22:28:57.020+02:00</updated>
<title type="text">LogicalPartition_243A3A4C-85BF-4384-80E9-00954962B8CB</title>
<published>2020-08-06T22:28:57.020+02:00</published>
<link type="application/atom+xml" href="https://10.32.64.39:12443/rest/api/pcm/ManagedSystem/b597e4da-2aab-3f52-8616-341d62153559/LogicalPartition/243A3A4C-85BF-4384-80E9-00954962B8CB/ProcessedMetrics"/>
<author>
<name>IBM Power Systems Management Console</name>
</author>
<category term="LogicalPartition"/>
</entry>
<entry>
<id>3512e881-82c1-4ffa-b975-689f79e82f90</id>
<updated>2020-08-06T22:28:57.020+02:00</updated>
<title type="text">LogicalPartition_72A9CD86-312A-4A61-B9A3-2D5A11B373E5</title>
<published>2020-08-06T22:28:57.020+02:00</published>
<link type="application/atom+xml" href="https://10.32.64.39:12443/rest/api/pcm/ManagedSystem/b597e4da-2aab-3f52-8616-341d62153559/LogicalPartition/72A9CD86-312A-4A61-B9A3-2D5A11B373E5/ProcessedMetrics"/>
<author>
<name>IBM Power Systems Management Console</name>
</author>
<category term="LogicalPartition"/>
</entry>
<entry>
<id>e903468f-94a9-4ac8-a892-064414fd40b5</id>
<updated>2020-08-06T22:28:57.020+02:00</updated>
<title type="text">LogicalPartition_58215ABF-1C91-4932-96EA-88041D560EED</title>
<published>2020-08-06T22:28:57.020+02:00</published>
<link type="application/atom+xml" href="https://10.32.64.39:12443/rest/api/pcm/ManagedSystem/b597e4da-2aab-3f52-8616-341d62153559/LogicalPartition/58215ABF-1C91-4932-96EA-88041D560EED/ProcessedMetrics"/>
<author>
<name>IBM Power Systems Management Console</name>
</author>
<category term="LogicalPartition"/>
</entry>
<entry>
<id>1eae063b-cc7f-4fc1-b245-bc03bcc3d53f</id>
<updated>2020-08-06T22:28:57.020+02:00</updated>
<title type="text">LogicalPartition_6D775DB5-010B-4B7C-B585-BB7C9128D259</title>
<published>2020-08-06T22:28:57.020+02:00</published>
<link type="application/atom+xml" href="https://10.32.64.39:12443/rest/api/pcm/ManagedSystem/b597e4da-2aab-3f52-8616-341d62153559/LogicalPartition/6D775DB5-010B-4B7C-B585-BB7C9128D259/ProcessedMetrics"/>
<author>
<name>IBM Power Systems Management Console</name>
</author>
<category term="LogicalPartition"/>
</entry>
<entry>
<id>17ce9f71-5f05-4c2b-8b42-28237b11eb87</id>
<updated>2020-08-06T22:28:57.020+02:00</updated>
<title type="text">LogicalPartition_75E900B0-06E2-4C67-A158-0198B4264304</title>
<published>2020-08-06T22:28:57.020+02:00</published>
<link type="application/atom+xml" href="https://10.32.64.39:12443/rest/api/pcm/ManagedSystem/b597e4da-2aab-3f52-8616-341d62153559/LogicalPartition/75E900B0-06E2-4C67-A158-0198B4264304/ProcessedMetrics"/>
<author>
<name>IBM Power Systems Management Console</name>
</author>
<category term="LogicalPartition"/>
</entry>
<entry>
<id>41e6f6b4-47d0-4a60-8273-dfc75d62107c</id>
<updated>2020-08-06T22:28:57.020+02:00</updated>
<title type="text">LogicalPartition_3380A831-9D22-4F03-A1DF-18B249F0FF8E</title>
<published>2020-08-06T22:28:57.020+02:00</published>
<link type="application/atom+xml" href="https://10.32.64.39:12443/rest/api/pcm/ManagedSystem/b597e4da-2aab-3f52-8616-341d62153559/LogicalPartition/3380A831-9D22-4F03-A1DF-18B249F0FF8E/ProcessedMetrics"/>
<author>
<name>IBM Power Systems Management Console</name>
</author>
<category term="LogicalPartition"/>
</entry>
<entry>
<id>503ae682-db8b-4eea-8ac9-47baf25fd93d</id>
<updated>2020-08-06T22:28:57.020+02:00</updated>
<title type="text">LogicalPartition_2DE05DB6-8AD5-448F-8327-0F488D287E82</title>
<published>2020-08-06T22:28:57.020+02:00</published>
<link type="application/atom+xml" href="https://10.32.64.39:12443/rest/api/pcm/ManagedSystem/b597e4da-2aab-3f52-8616-341d62153559/LogicalPartition/2DE05DB6-8AD5-448F-8327-0F488D287E82/ProcessedMetrics"/>
<author>
<name>IBM Power Systems Management Console</name>
</author>
<category term="LogicalPartition"/>
</entry>
</feed>