Post

3 followers Follow
0
Avatar

Extending XL Deploy Websphere Plugin

Hi All,

I am trying to extend/customize the websphere plugin for XL Deploy to have the ability to pause/resume J2C Activation Specifications. Currently this feature isn't available via XL Deploy Websphere plugin. I have created the required python script to run the target host and also synthetic.xml as well xl-rules.xml files. Here I am facing challenges whenever I tried to call my jython script via xl-rules or synthetic xml files. I have tried using <jython> and <wsadmin> steps in xl-rules.xml files, but I am getting different errors for those.

Has anyone tried this? If so, could you please let me know how to call this jython script from XL rules file or from synthetic.xml file? I can provide both the files if needed. Thanks in advance and I really appreciate your help.

Srinivas Bonthu

Please sign in to leave a comment.

11 comments

0
Avatar

Hi Srivinas,

For extending WAS plugin through you should make use of wsadmin step. Have you followed the wsadmin step doc, there you will find a really nice example. 

 

Cheers,

Elton

Elton Qevani 0 votes
0
Avatar

Hi Elton,

Thanks for your reply. I have tried that option and after making the changes as specified in that document, I tried to deploy the changes in XL Deploy, but  the deployment failed with the below error.


2017-05-05 14:15:49.710 [main] {} ERROR c.x.d.booter.local.LocalBooter - Quitting, could not boot plugins:


java.lang.NullPointerException: Could not find a type definition associated with type [was.deployable]

Below is the Syntetic.xml file I have used,

 

<?xml version='1.0' encoding='UTF-8'?>
<synthetic xmlns="http://www.xebialabs.com/deployit/synthetic" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.xebialabs.com/deployit/synthetic synthetic.xsd">

     <type type="was.J2CActivationSpecControlDeployed" extends="was.ExtensibleDeployedResource" deployable-type="was.J2CActivationSpecControl" container-type="was.DeploymentManager" description="Artifact that can be used to control JMS Activation Specification">
        <generate-deployable type="was.J2CActivationSpecControl" extends="was.deployable" description="Deployable to control J2CActivation Specifications"/>
        <property name="runOrder" kind="integer" description="pause=20 and resume=60 (default value=20)" default="20" />
        <property name="Action"  kind="enum" description="Action to perform on JMS Activation Specification" required="true" >
           <enum-values>
                <value>pause</value>
                <value>resume</value>
            </enum-values>
        </property>
    </type>

</synthetic.xml>

Below is the xl-rules.xml file,

<rules xmlns="http://www.xebialabs.com/xl-deploy/xl-rules">

        <rule name="was.J2CActivationSpecControlDeployed.CREATE_MODIFY" scope="deployed">
                <conditions>
                        <type>was.J2CActivationSpecControlDeployed</type>
                        <operation>CREATE</operation>
                        <operation>MODIFY</operation>
                </conditions>
                <steps>
                               <wsadmin>
                                   <description>Python script to pause/resume jmsActivationSpecifications</description>
                                    <order expression="true">deployed.runOrder</order>
                                    <script>ebz/pause-resume.py</script>
                                </wsadmin>
                </steps>
        </rule>

</rules>

 

Srinivas Bonthu 0 votes
0
Avatar

Hi Srivinas,

The cause of that error is the type your Deployable is inheriting from. You are using was.deployable when you should use was.Deployable . The synthetic XML is case sensitive .

 

Cheers,

Elton

Elton Qevani 0 votes
0
Avatar

Thank you Elton for pointing that out. I will try and will let you know. I really appreciate it and now I know my silly mistake :).

 

Srinivas Bonthu 0 votes
0
Avatar

Hi Elton,

Thanks for your help. After correcting the typo I was able to run my python script as a daemon on target host. But, I am now running into issues while referencing the properties in my python script. I have a couple of properties on my deployable that I want to refer them in my script but I am getting below error when I tried to do that,

Error getting task preview for deployment [deployment-4192c8b4-d6b4-48d5-aa1a-65df66692ebb]
Error while evaluating rule [was.J2CActivationSpecControlDeployed.CREATE_MODIFY]: Error while executing script [jython-expression]: AttributeError: 'com.xebialabs.deployit.plugin.was.deployed.Extensi' object has no attribute 'fileUri' in <script> at line number 1

 

Below is what my rule in xl-rules.xml file,

        <rule name="was.J2CActivationSpecControlDeployed.CREATE_MODIFY" scope="deployed">
                <conditions>
                        <type>was.J2CActivationSpecControlDeployed</type>
                        <operation>CREATE</operation>
                        <operation>MODIFY</operation>
                </conditions>
                <steps>
                               <wsadmin>
                                   <description>Python script to pause/resume jmsActivationSpecifications</description>
                                    <order expression="true">deployed.runOrder</order>
                                    <python-context>
                                       <fileUri expression="true">deployed.fileUri</fileUri> 
                                       <Action expression="true">deployed.Action</Action>
                                    </python-context>
                                    <script>ebz/pause-resume.py</script>
                                </wsadmin>
                </steps>
        </rule>

I really appreciate your help.

 

Srinivas Bonthu 0 votes
0
Avatar

HI Srinivas,

The latest error refers to the python-context <fileUri expression="true">deployed.fileUri</fileUri> 

Error while executing script [jython-expression]: AttributeError: 'com.xebialabs.deployit.plugin.was.deployed.Extensi' object has no attribute 'fileUri' in <script> at line number 1

This is, indeed true.  Neither the type was.J2CActivationSpecControlDeployed nor was.ExtensibleDeployedResource from which it extends has the property fileUri.  I'm not sure why that has been added to the rule. 

Regards, 

Dan

Daniel Robichau 0 votes
0
Avatar

Hi Dan,

Thanks for your post. But, I am trying to refer the path of the file in my python script so that it can process that file. I have added the screenshots of what I am talking about. In the below screenshot you can see the fileUri property. I want to refer this in my python script.
Is it supposed to be deployable.file.path instead of deployed.file.path?. I really appreciate your help.

Srinivas Bonthu 0 votes
0
Avatar

Hi Srinivas, 

Ok that clarifies things I guess you changed the deployable type. Yes to reference a deployed artifcact you want to  use deployed.file.path.   The fileUri property has meaning in the deployable context it is the location of the file to be uploaded.  In the deployed you want to reference the uploaded file by deployed.file.path.

Regards, 

Dan 

Daniel Robichau 0 votes
0
Avatar

Thanks for the response Dan. Yes, I have changed the deployable type from was.Deployable to udm.BaseDeployableArchiveArtifact. I have tried referring "deployed.file.path" in my python script, but it threw the similar error saying that the dictionary object doesn't have the attribute file. Below is the snippet of my reference in my python script,

FILEPATH=deployed.fileUri
ACTION=deployed.Action

Could you please suggest any other alternative.

Srinivas Bonthu 0 votes
0
Avatar

Hi Srinivas, 

Looking at the synthetic that you sent offline, there is still a problem with the deployed type you are using.  The deployed type was.ExtensibleDeployedResource does not have either a deploye.file or deployed.fileUri.  It isn't an artifact type. 

You want to use artifcat types for both the deployed and the deployable. 

If you start with the definition:

 

     <type type="was.J2CActivationSpecControlDeployed" extends="was.ExtensibleDeployedArtifact" deployable-type="was.J2CActivationSpecControl" container-type="was.DeploymentManager" description="Artifact that can be used to control JMS Activation Specification">

        <generate-deployable type="was.J2CActivationSpecControl" extends="udm.BaseDeployableArchiveArtifact" description="Deployable file to control J2CActivation Specifications"/>

        <property name="runOrder" kind="integer" description="pause=20 and resume=60 (default value=20)" default="20" />

        <property name="Action" kind="enum" description="Action to perform on JMS Activation Specification" required="true" >

          <enum-values>

                <value>pause</value>

                <value>resume</value>

            </enum-values>

        </property>

    </type>

 

And you acess deployed.file (sorry my last reply was in error) then you should get the full path.  You don't want to use fileUri. 

I tested with a simple script:

import sys

import os

import fileinput

 

print deployed.Action

print deployed.file

 

And this works. 

 

Dan 

Daniel Robichau 0 votes
0
Avatar

Hi Dan,

It did worked and I would like to thank you for your valuable suggestions. I really appreciate it.

Srinivas Bonthu 0 votes