Post

4 followers Follow
0
Avatar

Using XL Rules to execute a an unchanged deployable

Hi There,

 

I was looking for a little direction on using XL Rules.  I have read the manual and tutorial.  We have a use case where we have created a new type that does a wsdl refresh of services once they are deployed.   This deployable is included in the application along wiht a service (wls.war) and some property files.   I would like to create rule that makes sure the wsdl refresh deployable is in the deployment plan i.e. is executed whenever the service in the parent application is deployed.   Does this seem possible?   

Thanks!

Bernie

Bernie Bonn

Please sign in to leave a comment.

10 comments

0
Avatar

(posting my e-mail response here :)

Can you post your synthetic.xml entry that you created for the wsdl_refresh deployable?

Thank you!

T.j. Randall 0 votes
0
Avatar

Hi Bernie -

Here's an example of how we can get that refresh happens each deployment:

<type type="foo.DeployedserviceRefresh" deployable-type="foo.serviceRefresh" extends="generic.ExecutedScript"
description="Refresh for foo" container-type="overthere.Host">

<generate-deployable type="foo.serviceRefresh" extends="generic.Resource" description="Refresh for foo"/>

<!-- hidden -->

<property name="createScript" default="foo/serviceRefresher" hidden="true"/>

<property name="createOrder" kind="integer" default="100" hidden="true"/>

<property name="modifyScript" default="foo/serviceRefresher" hidden="true"/>

<property name="modifyOrder" kind="integer" default="100" hidden="true"/>

<property name="noopScript" default="foo/serviceRefresher" hidden="true"/>

<property name="noopOrder" kind="integer" default="100" hidden="true"/>

<property name="alwaysRun" kind="boolean" default="true" hidden="true"/>

<!-- public -->

<property name="someValue" required="true" description="the refresh value"/>

<property name="differentValue" required="true" description="the other value"/>

<property name="classpathResources" kind="set\_of\_string" hidden="true" default=
"foo/utils/your.dxe,
foo/utils/mint.esp" />

</type>

XebiaLabs Support 0 votes
0
Avatar

Hi Guys,

Let me clarify with some background.  Our 'flagship application' deploy has a bunch of services (over 30)    The wsdl_refresh deployable is part of each service's udm.DeploymentPackage.   Each wsdl_refresh references a specific url where it's wsdl is stored.  

So what we are really looking for  is for the wsdl_refesh deployable to be added to the plan every time it's 'parent' service is deployed i.e. is a new version.  That is the only time this refresh should happen.

So not really every deployment, just every time it's associated service is deployed.    Make sense?  Feel free to hit me up with more questions.

Thanks!

 

Bernie Bonn 0 votes
0
Avatar

Hi Bernie,

The rules-equivalent to the synthetic.xml snippet above is to add the NOOP operations to the set of conditions for a rule (see http://docs.xebialabs.com/releases/4.5/xl-deploy/rulesmanual.html#rule-scope). If that does not work, you can create a script-rule for more complicated "trigger logic" (see http://docs.xebialabs.com/releases/4.5/xl-deploy/rulesmanual.html#script-rules), e.g. when another deployed from the same package is CREATEd.

Can you paste a snippet of your synthetic.xml?

Regards, Vincent.

 

 

Vincent Partington 0 votes
0
Avatar

Hi Vincent,

 

I had to take down the synthetic.xml because of security issues.  TJ Randall has a copy which he can forward.   I'll have another look at the more complicated triggers.  I was struggling adding something to the plan once the deltas were calculated.  So once I figure out the service in the same package has changed i.e. CREATED, how would I add another deployable to the plan, how do I gain access to the other deployables?  I am probably just confused, but if you could give me a shove in the right direction that would be great.

Thanks!

Bernie Bonn 0 votes
0
Avatar

Hi Bernie,

I was wondering if you really need a "wsdl-refresh" deployable. Could you not achieve the desired result with a type modification that adds the wsdl url. Then add a rule to call an os script to trigger the url call. Say the service you mentioned has the following representation:

<type type="foo.ServiceModule" extends="udm.BaseDeployedArtifact" deployable-type="foo.Service" container-type="overthere.Host"><property name="wsdlUrl"/></type>

We could add the following rule to the xl-rules.xml:

<rule name="WsdlRefresh" scope="deployed">

    <conditions>

        <type>foo.ServiceModule</type>

        <operation>CREATE</operation>

        <operation>MODIFY</operation>

     </conditions> 

     <steps>

         <os-script>

             <description expression="true">"Refresh wsdl for service %s" % (deployed.name)</description>

             <script>myservice/refresh_wsdl</script>

             <order>80</order>

          </os-script>

    </steps>

</rule>

The content of myservice/refresh_wsdl.sh.ftl _could be something like "_curl ${deployed.wsdlUrl}"

I hope this example helps.

Regards, Ravan

Ravan Naidoo 0 votes
0
Avatar

Thanks so much for your response Ravan.   I think initially we were trying to be a little more selective about which services (wls.WarModule) we wanted to run the refresh on.  We have about 30 as part of this large application.   Which is why we thought a deployable and rules would be the way to go.  I think what you are proposing will have the rule apply to every wls.war that is deployed, which I think is OK, not much risk in a wsdl refresh.   

I'll give this a shot and see if it it works for us.    Thanks a lot!

Bernie Bonn 0 votes
0
Avatar

Hi Bernie,

Actual if you need the above rule to be executed selectively, then you can add an additional expression to the condition.  Say that if the war module does not have a wsdlUrl property filled in, then the rule should not fire.  The following will do that:

<rule name="WsdlRefresh" scope="deployed">

    <conditions>

        <type>foo.ServiceModule</type>

        <operation>CREATE</operation>

        <operation>MODIFY</operation>

         <expression>deploy.wsdlUrl not none or len(deployed.wsdlUrl.strip()) > 0</expression>

     </conditions>

       ...

</rule>

 

Regards, Ravan

Ravan Naidoo 0 votes
0
Avatar

Hi Ravan,

Thanks this is making more sense and it will work for us.   I ran into an interesting problem, and was wondering if anyone here may have insight.  When we execute this rule we are not going to use an os script, i.e. we don't want to execute the script on a remote box, we would like to execute it locally(on XLD server).   That being the case I started writing a python script to emulate this curl call.  

curl.exe --user ${deployed.username}:${deployed.password} -k -X GET ${deployed.URI}

When I try to run it in Jython, I get an error back stating Jython handles ssl differently, will not blindly accept certificates, which I think is what the -k in the curl command over rides.  I have found a few solutions online, but they are a bit complicated.   Just wondering if you guys have run up against this and if there is a better way to solve the problem.

Thanks for any help as always!

Bernie 

 

Here is the error:

urllib2.URLError: <urlopen error (-1, 'SSL handshake exception: Differences betw
een the SSL socket behaviour of cpython vs. jython are explained on the wiki: h
ttp://wiki.python.org/jython/NewSocketModule#SSL\_Support')>

 

Bernie Bonn 0 votes
0
Avatar

Hi All,

Just FYI.  I found a piece of code online that seems to solve this problem.    I need to test, but it allowed my to skip the validation of certificates.  Here it is if you are interested.

http://49c386d0057a547c.paste.se/

Thanks for your help,

BB

Bernie Bonn 0 votes