Power Global

 View Only
Expand all | Collapse all

HMC Rest API's

  • 1.  HMC Rest API's

    Posted Wed August 23, 2023 11:13 AM

    Hi,

    I am writing a number of Nagios checks for the HMC using the REST API's supplied by IBM, I am finding the documentation a little sparse and while I have opened a case asking IBM for help it is not really helping much.

    Does anyone have in depth knowledge of the REST API's available? When running the API's specifically for the Managed Systems and Partitions the data returned can be pretty extensive (about 12K for each request) so doing this on a regular time period will be pretty over bearing on the network where there are a lot of managed systems and partitions being handled by the HMC. I do notice that the returns for the /quick checks are pretty minimal, however the quick checks appear to need the UUID for the Managed system and Partition, this requires the non quick checks and then a search through the xml for the UUID. I also noticed that the managed system returns the links to the partitions as links (using the UUID) but the links do not show the partition names?

    I can use a single check to get the UUID's at configuration time, but no indication from IBM when those may change? Also they are not exposed via the HMC GUI.

    IBM did provide me with one REST url that was not shown in the documentation for service events, so I am sure there are more that are not shown in the documentation.

    Just interested in knowing if anyone else has gone down this path and found out more information that provided in the docs?

    Chris...



    ------------------------------
    Christopher Hird
    ------------------------------


  • 2.  RE: HMC Rest API's

    Posted Thu August 24, 2023 02:25 AM

    Hi Chris,

    Here is the documentation that would give some insight on all available HMC Rest API's.

    https://www.ibm.com/docs/en/power10/7063-CR2?topic=hmc-rest-apis

    To retrieve the minimal information on ManagedSystem/LogicalPartition, you can use the below API, which does not need any UUID input. The response will be in the Json format.

    For ManagedSystem:  https://<hmc_IP/hostname>/rest/api/uom/ManagedSystem/quick/All

    For LogicalPartition: https://<hmc_IP/hostname>/rest/api/uom/LogicalPartition/quick/All

    (This API will retrieve all the partitions across systems connected to HMC)

    Please let me know if you need any further information on any specific API.

    Thanks

    Sridevi Joshi



    ------------------------------
    Sridevi Joshi
    ------------------------------



  • 3.  RE: HMC Rest API's

    Posted Thu August 24, 2023 10:38 AM

    Hi Sridevi,

    Thanks for the information, but those url's do not work on my HMC?

    https://<hmc_IP/hostname>/rest/api/uom/ManagedSystem/quick/All

    Returns :

    <!doctype html public "-//IETF//DTD HTML 2.0//EN"> <html><head><title>Console Internal Error</title> <link href="/skin/HMCskin.css" rel="stylesheet" type="text/css"/></head> <body><h1>Console Internal Error</h1> <br><hr size="1" noshade><h2>Details:</h2><p><br> HTTP status code: 406<p><br>http.406<hr size="1" noshade></body></html>
     If I add the UUID for the managed system in ie :
    https://hmc:12443/rest/api/uom/ManagedSystem/98d8de0f-6108-37dc-8ca7-b6b873c65631/quick/all
    I get the following:
    <Message kb="ROO" kxe="false">REST0003 Type ManagedSystem does not support Quick Property all.</Message>
    I have not tried against the partition (the docs do not show the ALL quick property for the partition either), but everything I read about the quick requests requires that the UUID for the entity be entered as part of the request? Maybe I am missing something?
    I need to reduce the content returned as this check may be run many times an hour, when I use the /quick entries with the UUID correctly I do see minimal data being returned, but there are very few defines for the / quick entries in the documentation and the SRC code (Something I want to pull back efficiently) is not one for any entity.
    Chris...


    ------------------------------
    Christopher Hird
    ------------------------------



  • 4.  RE: HMC Rest API's

    Posted Thu August 24, 2023 11:40 AM

    That URL works for me.  Maybe HMC version?  I have also found that sometimes (especially on older HMC) I have to use port 12443 instead of 443 default.  https://hmc:12443

    You may also find the search functions helpful if you want data for a specific LPAR without all the hassle of UUIDs:

    https://$hmc/rest/api/uom/LogicalPartition/search/(PartitionName==LPARNAME)

    That is supposed to be a regular expression, but I've only been able to get it to work with full names, and it rejects most of the regex syntax (like "LPAR.", "LPAR.*"), but accepts others like "LPAR[0-9]"

    The output will include links from which you can get most of the UUIDs

    https://$hmc/rest/api/uom/LogicalPartition/search/  will give you a list of what parameters you can use to search

    You can substitute ManagedSystem for LogicalPartition if you want that instead -- likewise for many of the other supported types.

    In my experience, UUIDs don't change except through delete/recreate of the underlying objects, so capturing a list during setup and reusing is a good strategy when you are looking for speed in data collection.



    ------------------------------
    Vincent Greene
    IT Consultant
    Technology Expert labs
    IBM
    Vincent.Greene@ibm.com


    The postings on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
    ------------------------------



  • 5.  RE: HMC Rest API's

    Posted Thu August 24, 2023 11:51 AM
    Edited by MANJUNATH SHANBHAG Thu August 24, 2023 11:52 AM

    Hi Chris,

    I am not sure what you have used "Accept" header for the https://<hmc_IP/hostname>/rest/api/uom/ManagedSystem/quick/All URI call. Response code 406 tell you have not used "application/json". The response for this URI comes in Json format. Please try with the "Accept" header as "application/json"

    Also https://<hmc_IP/hostname>/rest/api/uom/ManagedSystem/quick/All is applicable to list all the Managed System's quick attribute information. While if you want to get a specific system's info, you can use the URI as https://<hmc_IP/hostname>/rest/api/uom/ManagedSystem/<UUID>/quick 

    Couple of more quick APIs that might help you

    https://<hmc_IP/hostname>/rest/api/uom/ManagedSystem/{UUID}/LogicalPartition/quick/All ----> To get all Logical Partitions quick attributes of specific system
    https://<hmc_IP/hostname>/rest/api/uom/ManagedSystem/{UUID}/LogicalPartition/{UUID} ----> To get Specific Logical Partition's quick attributes of a system
    https://<hmc_IP/hostname>/rest/api/uom/ManagedSystem/{UUID}/VirtualIOServer/quick/All ----> To get all VIOSs quick attributes of specific system
    https://<hmc_IP/hostname>/rest/api/uom/ManagedSystem/{UUID}/VirtualIOServer/{UUID} ----> To get Specific VIOS's quick attributes of a system
    If you want to get the specific quick attribute info of the resource, you can specify that attribute in the URI. For example, to get the "SystemName" attribute value of a system, you can use URI https://hmc_ip/rest/api/uom/ManagedSystem/{UUID}/quick/SystemName. Hope this helps. Thanks!

    -Manju



    ------------------------------
    MANJUNATH SHANBHAG
    ------------------------------



  • 6.  RE: HMC Rest API's

    Posted Thu August 24, 2023 11:57 AM

    Agreed, I am need to get the UUID to run those requests, to get the UUID I have to pull a lot of data back which is what I am trying to get away from.



    ------------------------------
    Christopher Hird
    ------------------------------



  • 7.  RE: HMC Rest API's

    Posted Thu August 24, 2023 12:06 PM

    Sorry another note, I did try the json request and it failed as described previously. I found the json issue after following the documentation and raised a case with IBM who gave me the json header requirement.



    ------------------------------
    Christopher Hird
    ------------------------------



  • 8.  RE: HMC Rest API's

    Posted Thu August 24, 2023 11:52 AM

    > Also they are not exposed via the HMC GUI.

    They are if you look at the URLs when hovering over a system name.



    ------------------------------
    Michael Quaranta
    ------------------------------



  • 9.  RE: HMC Rest API's

    Posted Thu August 24, 2023 11:57 AM

    UUID of the System and Logical Partition/VIOS is available in CLI too. For example, you can use the command :
    "lssyscfg -r sys -Fname,state,uuid" will list the info of system name, state and UUID info. Similarly for partition you can use 

    "lssyscfg -r lpar -m <System Name> -Fname,state,uuid".

    UUID of the system or partition does not change. Even if the partition is migrated to the other system, its UUID will be retained. Thanks!

    -Manju



    ------------------------------
    MANJUNATH SHANBHAG
    ------------------------------



  • 10.  RE: HMC Rest API's

    Posted Thu August 24, 2023 11:59 AM

    Agreed, but this is being run from a remote system program, so would have to code up an ssh session then run the CLI and return the information. REST API's seemed to be the better option in terms of simplicity.

    Chris...



    ------------------------------
    Christopher Hird
    ------------------------------



  • 11.  RE: HMC Rest API's

    Posted Thu August 24, 2023 12:06 PM

    Actually no.

    You can use CLIRunner from REST:

    https://hmc/rest/api/uom/ManagementConsole/UUID/do/CLIRunner

    VERY handy to avoid the whole SSH key thing. 



    ------------------------------
    Vincent Greene
    IT Consultant
    Technology Expert labs
    IBM
    Vincent.Greene@ibm.com


    The postings on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
    ------------------------------



  • 12.  RE: HMC Rest API's

    Posted Thu August 24, 2023 02:16 PM

    Vincent,

    Thanks for that information, I did send a couple of replies but they do not appear to have worked? Do you have any information on how to call the API? I have tried with a PUT and passing in an xml file that is formatted with the correct content but that does not work?

    I get an error stating that there is no active session, it shows in the HMC GUI and even running it again and creating another session does not return anything from the request.

    Here is the request I am running:

    curl -k -c cookies.txt -X PUT -H "X-Audit-Memento: hmc_test" -d @clirq.xml https://myhmc:12443/rest/api/uom/ManagementConsole/62b2f905-d4cb-3ddd-b006-06f7f7c07b2c/do/CLIRunner

    the content of the xml file is as per the docs with the following 

    <JobParameter schemaVersion="V1_0">
                <Metadata>
                    <Atom/>
                </Metadata>
                <ParameterName kxe="false" kb="ROR">cmd</ParameterName>
                <ParameterValue kxe="false" kb="CUR">lssvcevents -t hardware -d 0</ParameterValue>
            </JobParameter>
    Thanks.

    Again not a lot of information about how to use the API's correctly so just trying to get a better fell for things.

    Chris



    ------------------------------
    Christopher Hird
    ------------------------------



  • 13.  RE: HMC Rest API's

    Posted Thu August 24, 2023 02:31 PM

    OK I got it working, I see the response is in the returned data so just need to figure it out a bit more.

    Here is the request that appears to work (just in case someone else is going down this route. The input XML is as per the docs

    curl -k -c cookies.txt -b cookies.txt  -H "Content-Type: application/vnd.ibm.powervm.web+xml; type=JobRequest" -H "Accept: application/atom+xml; charset=UTF-8" -H "X-Audit-Memento: clicmd" -X PUT -H "Expect:" -d @clirq.xml https://myhmc:1244
    3/rest/api/uom/ManagementConsole/62b2f905-d4cb-3ddd-b006-06f7f7c07b2c/do/CLIRunner

    Chris..



    ------------------------------
    Christopher Hird
    ------------------------------



  • 14.  RE: HMC Rest API's

    Posted Thu August 24, 2023 02:53 PM

    Vincent, 

    The request now runs and returns a 200 status code but I cannot find where the data is returned? All looks good other than I have nothing to review.

    Chris...



    ------------------------------
    Christopher Hird
    ------------------------------



  • 15.  RE: HMC Rest API's

    Posted Thu August 24, 2023 12:03 PM

    Yes I saw that, but asking an user to hover over a link and capture the UUID presented would not end well :-). I was hoping to have it displayed in the sysplan or something, I think the users could easily use that to get the UUID but not sure many create the sysplans anyhow?.. I think I will pull all of the data back and parse it to get the information I need and store in a DB, then map that so when the request comes through so I can use the data and build quick property request.

    Chris... 



    ------------------------------
    Christopher Hird
    ------------------------------