Clarity

Expand all | Collapse all

Running ODUM Utility within a GEL Script?

navzjoshi00

navzjoshi00Jan 08, 2015 11:16 AM

  • 1.  Running ODUM Utility within a GEL Script?

    Posted Oct 18, 2013 05:52 AM
    Has anyone ever tried running the ODUM Utility from within a GEL script? I would imagine that you'd be able to do something like this:

    <core:invokeStatic className="java.lang.Runtime" method="getRuntime" var="javaRuntime"/>

    <core:set value="${vOdum} -propertyfile ${vProperties}" var="myArgs"/>

    <core:invoke method="exec" on="${javaRuntime}" var="execBAT">

    <core:arg type="java.lang.String" value="${myArgs}"/>
    </core:invoke>

    <core:invoke method="waitFor" on="${execBAT}" var="waitBAT"/>

    However, I can't seem to get this to work. I'm wondering if CA has made it so that I can't run executables from their sftp folder that they allow us to access from Clarity. Any ideas?


  • 2.  RE: Running ODUM Utility within a GEL Script?

     
    Posted Oct 22, 2013 06:38 PM
    Hi All,

    Any ideas here for this one?

    Thanks!
    Chris


    J1mzz wrote:

    Has anyone ever tried running the ODUM Utility from within a GEL script? I would imagine that you'd be able to do something like this:

    <core:invokeStatic className="java.lang.Runtime" method="getRuntime" var="javaRuntime"/>

    <core:set value="${vOdum} -propertyfile ${vProperties}" var="myArgs"/>

    <core:invoke method="exec" on="${javaRuntime}" var="execBAT">

    <core:arg type="java.lang.String" value="${myArgs}"/>
    </core:invoke>

    <core:invoke method="waitFor" on="${execBAT}" var="waitBAT"/>

    However, I can't seem to get this to work. I'm wondering if CA has made it so that I can't run executables from their sftp folder that they allow us to access from Clarity. Any ideas?


  • 3.  Re: Running ODUM Utility within a GEL Script?

    Posted Jan 07, 2015 03:57 PM

    We are also looking forward to access ODUM from Clarity GEL, please suggest



  • 4.  Re: Running ODUM Utility within a GEL Script?

    Posted Jan 08, 2015 11:13 AM

    Team,

    The ODUM wsdl requires basic authentication to be completed first which we ended up doing in a small shell script by using wget and hitting the url:

     

    So step #1 is to hit the url with username and password in order to open the session by replacing user:pass in the following url, they need to be separated by a colon:

    pass@ondemand.ca.com/tunnel-web/secure/axis/Portlet_Odp_OdpUserService?wsdl" rel="nofollow" target="_blank">https://user:pass@ondemand.ca.com/tunnel-web/secure/axis/Portlet_Odp_OdpUserService?wsdlpass@ondemand.ca.com/tunnel-web/secure/axis/Portlet_Odp_OdpUserService?wsdl

     

    #2 is once a session is obtained the xml can be sent, a sample for new user looks like the one below, replace all tokens that start and end with # with actual values/additional tags can be taken from the url in step #1:

    <urn:addModifyUserRequest xmlns:urn="urn:http.service.odp.ondemand.ca.com" xmlns:odum="http://odum.service.odp.ondemand.ca.com">

      <odum:odumOptions>

      <odum:defaultTenantName>#tenant name#</odum:defaultTenantName>

      <odum:defaultPassword>#defaultpassword#</odum:defaultPassword>

      <odum:sendWelcomeEmail>#true or false#</odum:sendWelcomeEmail>

      <odum:additiveAppInstList>true</odum:additiveAppInstList>

      <odum:forcePasswordReset>#true or false#</odum:forcePasswordReset>

      </odum:odumOptions>

     

     

      <odum:user>

      <odum:firstName>#first name#</odum:firstName>

      <odum:lastName>#last name#</odum:lastName>

      <odum:jobTitle>#job title#</odum:jobTitle>

      <odum:emailAddress>#email address#</odum:emailAddress>

      <odum:active>#true or false#</odum:active>

      <odum:languageId>en_US</odum:languageId>

      <odum:lockout>#true or false#</odum:lockout>

      <odum:timezone>#3 letter code for timezone#</odum:timezone>

      <odum:tenantName>#odum tenant name#</odum:tenantName>

     

     

      <odum:appInstances>

      <urn:item>#environment tag, one line per each environment access#</urn:item>

      </odum:appInstances>

     

     

      <odum:clarityAppDetails>

      <urn:item>

      <odum:applicationName>#environment application name as listed by OD#</odum:applicationName>

      <odum:emailAddress>#email#</odum:emailAddress>

      <odum:resourceId>#resource id as in clarity#</odum:resourceId>

      <odum:userLanguage>English</odum:userLanguage>

      <odum:userLocale>en_US</odum:userLocale>

      <odum:userTimezone>#Timezone code, same as the one's xog uses#</odum:userTimezone>

      </urn:item>

      </odum:clarityAppDetails>

      </odum:user>

    </urn:addModifyUserRequest>



  • 5.  Re: Running ODUM Utility within a GEL Script?

    Posted Jan 08, 2015 11:16 AM

    Thanks for sharing this useful info, Luis

     

    NJ



  • 6.  Re: Running ODUM Utility within a GEL Script?

    Posted Jan 08, 2015 12:31 PM

    Thanks for sharing, do you have a sample of how this is to be used in Clarity GEL?

    Want to know how to get a session and use the same for create / update a user



  • 7.  Re: Running ODUM Utility within a GEL Script?

    Posted Jan 08, 2015 12:40 PM

    Sanjay,

    Exactly my point, authentication is basic based, no session id or soap call to get it.

    You must first hit the url and then send the webservice call



  • 8.  Re: Running ODUM Utility within a GEL Script?

    Posted Jan 08, 2015 05:58 PM

    I tried to write in GEL as follows but no success...any suggestion. I was logged into Clarity as Tenat Admin

     

    <gel:script
      xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:core="jelly:core"
      xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary"
      xmlns:soap="jelly:com.niku.union.gel.SOAPTagLibrary"
      xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:sql="jelly:sql"
      xmlns:xog="http://www.niku.com/xog"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

      <soapenv:Envelope
        xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
        xmlns:urn="urn:http.service.odp.ondemand.ca.com"
        xmlns:odum="http://odum.service.odp.ondemand.ca.com">

        <soapenv:Header/>
        <soapenv:Body>
          <urn:addOdpUserRequest
            xmlns:urn="urn:http.service.odp.ondemand.ca.com"
            xmlns:odum="http://odum.service.odp.ondemand.ca.com">

            <odum:odumOptions>
              <odum:defaultTenantName>#tenantName#</odum:defaultTenantName>
              <odum:defaultPassword>clarityod</odum:defaultPassword>
              <odum:sendWelcomeEmail>false</odum:sendWelcomeEmail>
              <odum:additiveAppInstList>true</odum:additiveAppInstList>
              <odum:forcePasswordReset>false</odum:forcePasswordReset>
            </odum:odumOptions>
         
            <odum:user>
              <odum:firstName>SKFirstName</odum:firstName>
              <odum:lastName>SKLastName</odum:lastName>
              <odum:jobTitle>TestingResource</odum:jobTitle>
              <odum:emailAddress>FirstLast@discover.com</odum:emailAddress>
              <odum:active>true</odum:active>
              <odum:languageId>en_US</odum:languageId>
              <odum:lockout>false</odum:lockout>
              <odum:timezone>CST</odum:timezone>
              <odum:tenantName>#tenantName#</odum:tenantName>
            </odum:user>
          </urn:addOdpUserRequest>
        </soapenv:Body>
      </soapenv:Envelope>
      <gel:log level="INFO">End ODUM Add Script</gel:log>
    </gel:script>



  • 9.  Re: Running ODUM Utility within a GEL Script?

    Posted Jan 08, 2015 07:02 PM

    Sanjay,

    This cant be done by just sending the wsdl call. First you need to hit the url with username:password as mentioned in step one to get a valid session from the server.

    In my case I did a shell script to do a wget, and then you can start doing webservice calls.

    This is due to the OD portal requiring basic web authentication



  • 10.  Re: Running ODUM Utility within a GEL Script?

    Posted Jan 09, 2015 09:35 AM

    So even I am logged into the Portal as Tenat Admin, it cannot be done through GEL, correct?

    Due to basic authentication requirement, the session need to be available locally?

    I will try to write something on our Lynux server as script.



  • 11.  Re: Running ODUM Utility within a GEL Script?

    Posted Jan 09, 2015 09:40 AM

    Exactly, that is why we ended up doing it via a shell, first it did a wget to hit the url



  • 12.  Re: Running ODUM Utility within a GEL Script?

    Posted Jan 09, 2015 09:46 AM

    Can you share your sample Shell Script please, and the way you used wget? I never did this before so need some sample.



  • 13.  Re: Running ODUM Utility within a GEL Script?

    Posted Jan 10, 2015 08:03 PM

    Sanjay,

    What we did was something like

     

    Wget password@ondemand.ca.com/tunnel-web/secure/axis/wsdl" rel="nofollow" target="_blank">https://user:password@ondemand.ca.com/tunnel-web/secure/axis/wsdlpassword@ondemand.ca.com/tunnel-web/secure/axis/wsdl

     

    Replace user and password accordingly, that will cause the OD portal to grant a session by using basic authentication



  • 14.  Re: Running ODUM Utility within a GEL Script?

    Posted Feb 17, 2015 12:47 PM

    One more question, do you need a Unix/Lynux box or it works with Windows as well?



  • 15.  Re: Running ODUM Utility within a GEL Script?

    Posted May 22, 2015 10:24 AM

    ODUM can be run by gel with the java Runtime. The odum.zip only has an odum.bat in the bin which is for window only. In order to run it from the ondemand SFTP folder, a shell script need to be create.

    odum.sh

     

    #! /bin/sh

    date > /fs0/clarity1/share/odum/odum.log

    java -Dlog4j.configuration=/fs0/clarity1/share/odum/lib/log4j.properties -cp "/fs0/clarity1/share/odum/lib/odum.jar:/fs0/clarity1/share/odum/lib/axis.jar:/fs0/clarity1/share/odum/lib/commons-beanutils.jar:/fs0/clarity1/share/odum/lib/odum-parser.jar:/fs0/clarity1/share/odum/lib/commons-discovery.jar:/fs0/clarity1/share/odum/lib/commons-logging.jar:/fs0/clarity1/share/odum/lib/jaxrpc.jar:/fs0/clarity1/share/odum/lib/log4j.jar:/fs0/clarity1/share/odum/lib/odp-client.jar:/fs0/clarity1/share/odum/lib/saaj-api.jar:/fs0/clarity1/share/odum/lib/wsdl4j.jar:/fs0/clarity1/share/odum/lib/jaxb-api.jar:/fs0/clarity1/share/odum/lib/jaxb-impl.jar:/fs0/clarity1/share/odum/lib/jaxb-xjc.jar:/fs0/clarity1/share/odum/lib/activation.jar:/fs0/clarity1/share/odum/lib/jsr173_api.jar:/fs0/clarity1/share/odum/lib/ws-util.jar:":. com.ca.odp.odum.Odum $@ >> /fs0/clarity1/share/odum/odum.log



  • 16.  Re: Running ODUM Utility within a GEL Script?

    Posted Jun 05, 2015 07:18 PM

    Wuj1 - Did you actually upload that shell script to the SFTP folder and have success running it from GEL?  If so, I'd be interested in seeing your GEL script as well.



  • 17.  Re: Running ODUM Utility within a GEL Script?

    Posted Jun 05, 2015 10:48 PM

    J1mzz, Yes, I have ran it from the SFTP folder. I have set the shell script permission to allow any users to execute. (rwxr x r x).

    The script I have is no different than your.

     

    <gel:script xmlns:core="jelly:core"

                      xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary"

                      xmlns:util="jelly:util">

     

             <core:invokeStatic className="java.lang.Runtime" method="getRuntime" var="javaRuntime"/>

     

             <core:set value="/fs0/clarity1/share/odum/bin/odum.sh -propertyfile /fs0/clarity1/share/odum/sample.properties" var="command"/>

     

             <core:invoke method="exec" on="${javaRuntime}" var="execCommand">

                 <core:arg type="java.lang.String" value="${command}"/>

             </core:invoke>

     

    </gel:script>



  • 18.  Re: Running ODUM Utility within a GEL Script?

    Posted Jun 06, 2015 11:33 PM

    I uploaded the odum directory with your odum.sh shell script in the bin directory.  I update the permissions for that shell script to allow any user to execute it, and then I used the same GEL script you had with the only difference being that I updated it to use my properties file instead.  I ended up getting the following error:

     

    org.apache.commons.jelly.JellyTagException: null:7:71: <core:invoke> method exec threw exception: Cannot run program "/fs0/clarity1/share/odum/bin/odum.sh": error=2, No such file or directory

    at org.apache.commons.jelly.tags.core.InvokeTag.doTag(InvokeTag.java:109)

    at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:247)...

     

    Any ideas?  Did you have to do anything else special to get it to work. 



  • 19.  Re: Running ODUM Utility within a GEL Script?

    Posted Jun 07, 2015 10:40 PM

    Your error either is the odum and bin folder permissions or the shell script has some hidden special character in it.

    If not the permission, try recreate the shell script in notepad and make sure it is 3 lines only.

    select text mode transfer when sftp. I use winscp with text.

    If you do have your own linux server, upload the script and run odum.sh without any parameters and it should give you the usage message.



  • 20.  Re: Running ODUM Utility within a GEL Script?
    Best Answer

    Posted Jun 09, 2015 01:11 AM

    Finally got this thing to work after playing around with it on a linux machine for a little bit.  I just ended up having to add "sh " to the beginning of the arguments that I passed in to the exec command.  Thanks so much!

     

    <gel:script xmlns:core="jelly:core"

                      xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary"

                      xmlns:util="jelly:util">

     

             <core:invokeStatic className="java.lang.Runtime" method="getRuntime" var="javaRuntime"/>

     

             <core:set value="sh /fs0/clarity1/share/odum/bin/odum.sh -propertyfile /fs0/clarity1/share/odum/sample.properties" var="command"/>

     

             <core:invoke method="exec" on="${javaRuntime}" var="execCommand">

                 <core:arg type="java.lang.String" value="${command}"/>

             </core:invoke>

     

    </gel:script>