Hi Marvin,
Good day,
To use the REST API to perform HMC shutdown or restart. Giving a sample from a 1060 HMC version
- Perform login using with the user who has got the authorisation
i.e PUT operation to get the X-API-Session using the URI:- https://{IP_OR_DOMAIN}/rest/api/web/Logon
Curl Sample:-
curl --insecure --request PUT '${URI}' \
--header 'Content-Type: application/vnd.ibm.powervm.web+xml; type=LogonRequest' \
--data '<LogonRequest
schemaVersion="V1_0"
xmlns="http://www.ibm.com/xmlns/systems/power/firmware/web/mc/2012_10/"
xmlns:mc="http://www.ibm.com/xmlns/systems/power/firmware/web/mc/2012_10/">
<UserID>hscroot</UserID>
<Password>{password}</Password>
</LogonRequest>'
2. Perform a GET call to get the ManagementConsole UUID
e.g:- URI = https://{IP_OR_DOMAIN}/rest/api/uom/ManagementConsole
Curl Sample:-
curl --insecure --request GET --url ${URI} --header 'X-API-Session: ${API_SESSSION}'
3. Next we need to perform a PUT call to perform shutdown or restart operation of HMC.
URI:- https://{IP_OR_DOMAIN}/rest/api/uom/ManagementConsole/{UUID}/do/ShutdownHMC .
UUID is the value obtained from step2. Ensure you set the header params.
i.e :-
3.1) Content-Type =. application/vnd.ibm.powervm.web+xml; type=JobRequest
3.2) X-API-Session. Value obtained from step1.
3.A) The XML body sample for restart of HMC:-
<JobRequest:JobRequest
xmlns:JobRequest="http://www.ibm.com/xmlns/systems/power/firmware/web/mc/2012_10/"
xmlns="http://www.ibm.com/xmlns/systems/power/firmware/web/mc/2012_10/"
xmlns:ns2="http://www.w3.org/XML/1998/namespace/k2" schemaVersion="V1_1_0">
<Metadata>
<Atom/>
</Metadata>
<RequestedOperation kb="CUR" kxe="false" schemaVersion="V1_1_0">
<Metadata>
<Atom/>
</Metadata>
<OperationName kb="ROR" kxe="false">ShutdownHMC</OperationName>
<GroupName kb="ROR" kxe="false">ManagementConsole</GroupName>
</RequestedOperation>
<JobParameters kb="CUR" kxe="false" schemaVersion="V1_1_0">
<Metadata>
<Atom/>
</Metadata>
<JobParameter schemaVersion="V1_0"><Metadata><Atom/></Metadata>
<ParameterName kb="ROR" kxe="false">Operation</ParameterName>
<ParameterValue kb="CUR" kxe="false">Restart</ParameterValue>
</JobParameter>
</JobParameters>
</JobRequest:JobRequest>
3.B) The XML body sample for shutdown of HMC:-
<JobRequest:JobRequest
xmlns:JobRequest="http://www.ibm.com/xmlns/systems/power/firmware/web/mc/2012_10/"
xmlns="http://www.ibm.com/xmlns/systems/power/firmware/web/mc/2012_10/"
xmlns:ns2="http://www.w3.org/XML/1998/namespace/k2" schemaVersion="V1_1_0">
<Metadata>
<Atom/>
</Metadata>
<RequestedOperation kb="CUR" kxe="false" schemaVersion="V1_1_0">
<Metadata>
<Atom/>
</Metadata>
<OperationName kb="ROR" kxe="false">ShutdownHMC</OperationName>
<GroupName kb="ROR" kxe="false">ManagementConsole</GroupName>
</RequestedOperation>
<JobParameters kb="CUR" kxe="false" schemaVersion="V1_1_0">
<Metadata>
<Atom/>
</Metadata>
<JobParameter schemaVersion="V1_0"><Metadata><Atom/></Metadata>
<ParameterName kb="ROR" kxe="false">Operation</ParameterName>
<ParameterValue kb="CUR" kxe="false">Shutdown</ParameterValue>
</JobParameter>
</JobParameters>
</JobRequest:JobRequest>
Curl Sample for restart:-
curl --insecure --request PUT \
--url ${URI} \
--header 'Content-Type: application/vnd.ibm.powervm.web+xml; type=JobRequest' \
--header 'X-API-Session: $'{API_SESSION} \
--data '<JobRequest:JobRequest
xmlns:JobRequest="http://www.ibm.com/xmlns/systems/power/firmware/web/mc/2012_10/"
xmlns="http://www.ibm.com/xmlns/systems/power/firmware/web/mc/2012_10/"
xmlns:ns2="http://www.w3.org/XML/1998/namespace/k2" schemaVersion="V1_1_0">
<Metadata>
<Atom/>
</Metadata>
<RequestedOperation kb="CUR" kxe="false" schemaVersion="V1_1_0">
<Metadata>
<Atom/>
</Metadata>
<OperationName kb="ROR" kxe="false">ShutdownHMC</OperationName>
<GroupName kb="ROR" kxe="false">ManagementConsole</GroupName>
</RequestedOperation>
<JobParameters kb="CUR" kxe="false" schemaVersion="V1_1_0">
<Metadata>
<Atom/>
</Metadata>
<JobParameter schemaVersion="V1_0"><Metadata><Atom/></Metadata>
<ParameterName kb="ROR" kxe="false">Operation</ParameterName>
<ParameterValue kb="CUR" kxe="false">Restart</ParameterValue>
</JobParameter>
</JobParameters>
</JobRequest:JobRequest>'
------------------------------
Vardhaman Narasagoudar
------------------------------