PowerVM

Power Virtualization

Learn about the virtualization technologies designed specifically for IBM Power including #PowerVM, #PowerVC, #VM Recovery Manager#HCM/CMC, and more.


#Power
#TechXchange Conference Lab


#Servers
 View Only
  • 1.  Invoking REST API from IBMi RPG

    Posted 07/06/16 12:10 PM

    Originally posted by: sashok


    http://www.midrangenews.com/view?id=2376&p=9

     

    This package allows GET, PUT, POST from within RPG.


    #HMCandCMC
    #Power-Hardware-Management-Console-Programmers


  • 2.  Re: Invoking REST API from IBMi RPG

    Posted 07/08/16 10:28 AM

    Originally posted by: dxd


    if the HMC is using its self-signed certificate you'll likely need to first export the HMC cert  from a browser then import to the IBM i default java keystore. 
     keytool -import -v -trustcacerts -alias icr9 -file /icr9.rchland.ibm.com -key
     store /QOpenSys/QIBM/ProdData/JavaVM/jdk70/32bit/jre/lib/security/cacerts    

    default pwd:  changeit

     

    Here's an example of the login and a simple query:

    SELECT varchar(responseMsg,2048), varchar(responseHttpHeader,1024)
     from table(  systools.HTTPPUTCLOBVERBOSE('https://icr9.rchland.ibm.com:12443/rest/api/web/Logon',
    CAST ('<httpHeader>
           <header name="Content-Type" value="application/vnd.ibm.powervm.web+xml; type=LogonRequest"/>
           <header name="Accept" value="application/vnd.ibm.powervm.web+xml; type=LogonResponse"/>
           </httpHeader>' AS CLOB(1K)),
    CAST('<?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>abc123</Password>                                                                             
    </LogonRequest>'
    AS CLOB(10K))  
    )) as HMC;

     

    Pass the X-API-Session value from the login reply to the next query.

     

    SELECT varchar(responseMsg,4096), varchar(responseHttpHeader,1024)
     from table(  systools.HTTPGETCLOBVERBOSE('https://icr9.rchland.ibm.com:12443/rest/api/uom/ManagementConsole',
    '<httpHeader>
         <header name="Accept" value="application/atom+xml; charset=UTF-8"/>
           <header name="X-API-Session" value="wZ2BHTWSv8FuPu3Lp-mcxMNrFInDZF4lYLRlMAbFGtiGH39pHgPEtbYts6yMSPS4cONApow8w-CNwpl7lAzCI8A9tR4_d-oex53k65JQLbQ_HlVF4zFhZVhFYznetNDvZGsq-0G7aQS0Nzvvhm-kXHvlg_k7TVO1xwy-kciOFJ6tLIXJnjaAphaUeIUIA-DrBeYCJAJnJTmRP2s_oeOtYEhH6xNloJSEv6SVaBHPRTg="  />
           </httpHeader>'
    )) as HMC;


    #HMCandCMC
    #Power-Hardware-Management-Console-Programmers