HMC

 View Only
  • 1.  HMC API to shutdown

    Posted Mon February 12, 2024 10:55 AM

    Hello,

       Can someone or is there some sort of example to use this API call to reboot a HMC?

    python, Go  or any language will work

    ShutdownHMC_ManagementConsole Job

    Ibm remove preview
    ShutdownHMC_ManagementConsole Job
    The ShutdownHMC job performs shutdown and reboot operations on the HMC.
    View this on Ibm >

    P



    ------------------------------
    Marvin Jones
    ------------------------------


  • 2.  RE: HMC API to shutdown

    Posted Tue February 13, 2024 07:37 AM

    Hello Marvin,

    I think I have a solution for you. 

    But is in with Curl. 

    Shouldn't be a problem with Go or Python either. watsonx can do the job =) #advertising

    # create login file

    # Example
    #>cat login.xml
    <?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>hscroot</UserID>
    <Password>XXX</Password>
    </LogonRequest>




    # login with login.xml -> token(cookies.txt)

    curl -k -c cookies.txt -i -X PUT -H "Content-Type: application/vnd.ibm.powervm.web+xml; type=LogonRequest" -H "Accept: application/vnd.ibm.powervm.web+xml; type=LogonResponse" -H "X-Audit-Memento: hmc_test" -d @login.xml https://${HMC}:12443/rest/api/web/Logon


    #Example:
    # $ cat cookies.txt
    # Netscape HTTP Cookie File
    # This file was generated by libcurl! Edit at your own risk.

    #HttpOnly_hmc5.labda.sva.de FALSE / TRUE 0 CCFWSESSION 546BB7ACDD2A64817D86A718A403E48E
    #HttpOnly_hmc5.labda.sva.de FALSE /rest TRUE 0 JSESSIONID 57FA02F0C10FBB552EB353EB1CB367D7



    # curl to HMC to get HMC-UUID
    HMC-UUID=$(curl -s -k -c cookies.txt -b cookies.txt -H "Accept: application/atom+xml; charset=UTF-8" https://${HMC}:12443/rest/api/uom/ManagementConsole | grep "<id>" | tail -1 | tr -d '</id>' | tr '<id>' ' ' | cut -f 1)



    #Not tested but must do.
    #!!!!Attention!!!!
    #!!!!!HMC Reboot !!!!!
    ##
    curl -k -c cookies.txt -b cookies.txt -H "Accept: application/atom+xml; charset=UTF-8" https://${HMC}:12443/rest/api/uom/ManagementConsole/${HMC-UUID}/do/ShutdownHMC



    ------------------------------
    Andre Lutz
    ------------------------------



  • 3.  RE: HMC API to shutdown

    Posted Tue February 13, 2024 11:10 AM

    @Andre... oh man thank you!!!!! i will try and convert this into go .. will let you know what i find. 



    ------------------------------
    Marvin Jones
    ------------------------------



  • 4.  RE: HMC API to shutdown

    Posted Wed February 14, 2024 01:47 AM

    We need to provide the input parameter "Operation" with value "Restart" for reboot.  Without this HMC will go for shutdown.



    ------------------------------
    Vijay Kumar Bana
    ------------------------------



  • 5.  RE: HMC API to shutdown

    Posted Wed February 14, 2024 03:12 AM

    Must work like this. But unfortunately I can't test it. 

    curl -d "Operation=Restart" -k -c cookies.txt -b cookies.txt \
    -H "Accept: application/atom+xml; charset=UTF-8" -X POST \
    https://${HMC}:12443/rest/api/uom/ManagementConsole/${HMC-UUID}/do/ShutdownHM


    ------------------------------
    Andre Lutz
    ------------------------------



  • 6.  RE: HMC API to shutdown

    0