JACL Script - Update Application in WebSphere and Keep Existing Bindings

Hi all,

I have a jacl script that updates an Enterprise Application in WebSphere 7.0 base install.  The script works as is as far as updating the application, but I have an issue where it resets the virtual host back to default_host.  I need to be able to update the application and have it keep existing bindings.  The virtual host is not the only reason I need to do this.

I tried to modify the script to do this, based on what I found searching the IBM documentation, but it does not work.  In the JACL script below I have the line commented out that I thought should work (update.ignore.new), according to this:

http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/index.jsp?topic=/com.ibm.websphere.express.doc/info/exp/ae/rxml_taskoptions.html

Can anyone suggest what needs to be done for the application update to keep the existing bindings?

On more note.. I'm not opposed to a simple jython script to accomplish this, but I'm trying to reuse what I currently have working in other environments due to a time crunch and my lack of knowledge on this subject.



PORTION OF THE SHELL SCRIPT THAT CALL THE JACL SCRIPT - all variables are previously defined in the script
#===================================================================
updateApplicationBase()  # Update Enterprise Application Routine BASE
#===================================================================
{
echo "# Updating Enterprise Application ${CLUSTERPREFIX}${APP}"
echo ""
echo "${WASBIN}/wsadmin.sh -host $WASSERVER -port ${SOAPPORT} -f ${JACL_SCRIPTS}/updateApplicationBase.jacl $EARPATH ${CLUSTERPREFIX}${APP}EAR ${NODE}"

${WASBIN}/wsadmin.sh -host $WASSERVER -port ${SOAPPORT} -f ${JACL_SCRIPTS}/updateApplicationBase.jacl $EARPATH ${CLUSTERPREFIX}${APP}EAR ${NODE}
}


JACL SCRIPT - updateApplicationBase.jacl
#============================
#   Main
#============================
if { !($argc == 3) } {
    puts "Missing parameter."
    puts "- The name and location of the ear."
    puts "- The name of the application."
    puts "- The name of the node."
} else {

    set earName       [lindex $argv 0]
    set appName       [lindex $argv 1]
    set nodeName      [lindex $argv 2]

    puts "Application Deploy - Installing $earName in $appName"

    set appOptions [list -update -appname $appName]
    #set appOptions [list -update.ignore.new -appname $appName]


    $AdminApp install $earName $appOptions

    puts "Application was updated successfully"

    $AdminConfig save

    puts "Application Update Complete"
}
lphillipsAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

HonorGodSoftware EngineerCommented:
The link that you provide is to version 6.0 of the Application Server product.
The link for version 7.0 is:

http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=/com.ibm.websphere.express.doc/info/exp/ae/rxml_taskoptions.html

Is there a particular reason that you are using Jacl as your scripting language?

I can understand if any/all of following are true:
- You have an existing collection of administrative scripts written in Jacl
- You already have knowledge of Jacl (Tcl), and are comfortable reading/writing in this language

The reason that I ask this question is that Jacl was announced as a deprecated scripting language in the version 6.1 document.  Subsequently, the version 7.0 statement was revised as documented here:

http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=/com.ibm.websphere.base.doc/info/aes/ae/cxml_jacl.html

So, you might want to consider using Jython as your WSAS scripting language.

A book is available from IBM Press that describes / explains how to do this:

http://www.ibmpressbooks.com/bookstore/product.asp?isbn=9780137009527

An article about writing Jython scripts from scratch was recently published on the IBM developerWorks site:

http://www.ibm.com/developerworks/websphere/library/techarticles/1004_gibson/1004_gibson.html

Let me look into the deployment parameters to see if I can provide a more complete answer to your question.
0
HonorGodSoftware EngineerCommented:
It looks like you are going to need to use/specify the virtualHost field of the MapWebModToVH option.

http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=/com.ibm.websphere.base.doc/info/aes/ae/rxml_adminapp.html
0
lphillipsAuthor Commented:
Hi HonorGod,

Let me answer your questions below.

** Is there a particular reason that you are using Jacl as your scripting language?
The only reason is because we have existing scripts from way back when and they still work. I realize that Jacl is being deprecated, but am in a time crunch and just need something that works.

** You already have knowledge of Jacl (Tcl), and are comfortable reading/writing in this language
Well, it would be more accurate to say that I know enough to get around, mostly by looking at simple examples in IBM infocenter many years ago.  Most of our newer scripts were done in jython by an experienced developer, which is no longer here.  I would attempt to use those, but they are written against ND installs and work through the deployment manager, vs. a base install.

I certainly am not opposed to using jython if you can provide a script that I can call from my shell script.

I can pass the virtual host if needed it, as I already have it set as a variable in the shell script.

Thanks so much for responding.

Lisa

0
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

lphillipsAuthor Commented:
HonorGod - sorry for the late response last time, did not have my email configured to go to both addresses.  I corrected this and can respond quicker in the future.
0
HonorGodSoftware EngineerCommented:
Not a problem.

Here is another developerWorks link to some existing, and updated Administrative scripts for WebSphere.  Some are in Jacl, some are in Jython.

Take a look, your answer may be immediately available here:

http://www.ibm.com/developerworks/websphere/library/samples/SampleScripts.html
0
lphillipsAuthor Commented:
Yes, I actually downloaded the deployment scripts from here a while back and was going through them this morning.  The scripts are pages long and I never found where I could do the update while keeping existing bindings.
0
HonorGodSoftware EngineerCommented:
ah.  ok, let me see what I can find out...
0
lphillipsAuthor Commented:
HonorGod,

I have the following two simple Jython scripts (forget Jacl at this point) working.  All they do is update/install the app.  If you can get either one of them to keep existing bindings then that would be wonderful.  I have tried several attempts at stuff I find out on the net, but no luck so far.

Thanks,

Lisa


**********************************************
AdminApp.update Jython Script
**********************************************
# app info
appName = "CL01ASRCacheEAR"
contentType = "app"

#
# options
#
installOpts = "update"
updatedContentLoc = "/tmp/ASRCache_vsb4-6-6.ear"
options = ["-operation", installOpts, "-contents", updatedContentLoc]

AdminApp.update(appName, contentType, options)
AdminConfig.save()

**********************************************
AdminApp.install Jython Script
**********************************************
# EAR file name
earFileName = "/tmp/ASRCache_vsb4-6-6.ear"

#
# Installation target options
#
node = "ASRShipPRD01"
server = "CL01ASRShipCachePRD"

AdminApp.install(earFileName, ["-node", node, "-server", server])
AdminConfig.save()
0
HonorGodSoftware EngineerCommented:
Since you want to "keep existing bindings", it would seem that you are most interested in the update scenario.

So, to do this, I would use the AdminApp.list() method, and pass:

- The name of the application
- and the option to request the current Virtual Host mappings.

For example:

bindings = AdminApp.view( appName, '-MapWebModToVH' );

Unfortunately, this results in a multiple line string, something along the lines of:

--------------------------------------------------


MapWebModToVH: Selecting virtual hosts for Web modules

Specify the virtual host where you want to install the Web modules that are contained in your application. You can install Web m
odules on the same virtual host or disperse them among several hosts.

Web module:  Default Web Application
URI:  DefaultWebApplication.war,WEB-INF/web.xml
Virtual host:  default_host


--------------------------------------------------

  Yes, there are lots of blank lines.

  So, it would appear that the best way to determine the existing Virtual host definition from this text would be to use a regular expression (RegExp, or re),
to locate, and extract this information from the call.

  Does that make sense?

  So, we could use something like:


wsadmin>import re

wsadmin>print AdminApp.list()
DefaultApplication
PlantsByWebSphere
SamplesGallery

wsadmin>appName = AdminApp.list().splitlines()[ 0 ]

wsadmin>result = AdminApp.view( appName, '-MapWebModToVH' );
wsadmin>print result


MapWebModToVH: Selecting virtual hosts for Web modules

Specify the virtual host where you want to install the Web modules that are contained in your application. You can install Web m
odules on the same virtual host or disperse them among several hosts.

Web module:  Default Web Application
URI:  DefaultWebApplication.war,WEB-INF/web.xml
Virtual host:  default_host


wsadmin>vhost = re.compile( '^Virtual host: (.*)$', re.MULTILINE ).search( result )

wsadmin>hostname = vhost.group( 1 ).strip()
wsadmin>print hostname
default_host

Open in new window

0
lphillipsAuthor Commented:
Hi HonorGod,

You are over estimating my ability to grasp everything you did above.  8^)
I need to keep this as simple as possible so I understand what's going on.  Just so you know for each application we have there is a properties file that has all the info needed and is used by the scripts.  The shell script reads all those variables in and then we pass them to the jython/jacl scripts.  In the script examples below I have things hard coded for now, but will be substituting the variables once I have things working.  If you could just help me get the update working with the MapWebModToVH with the update script below then we'll be done.  I believe it's just a syntax error, me not putting the right brackets, etc.


This script is working - it installs the application and sets the virtual host as desired.  You are correct, we don't want to install everytime, we do need to update.
#===================================================================
# START installEntApp
#===================================================================
# EAR file name
earFileName = "/tmp/ASRCache_vsb4-6-6.ear"

#
# Installation target options
#
node = "ASRShipPRD01"
server = "CL01ASRShipCachePRD"

#
# "MapWebModToVH" task options
#
webModule = "ASRCacheServer"
uri = "ASRCacheServer.war,WEB-INF/web.xml"
virtualHost = "VHASRShip"
mapWebOptions = [[webModule, uri, virtualHost]]

AdminApp.install(earFileName, ["-node", node, "-server", server, "-MapWebModToVH", mapWebOptions])
AdminConfig.save()
#===================================================================
# STOP installEntApp
#===================================================================


The problem with the update I'm having right now is I can't get the syntax right to MapWebModToVH.  The following script works for the update, and I commented out the line I was trying to get to work with the MapWebModToVH.
#===================================================================
# START updateEntApp
#===================================================================
#
# app info
#
appName = "CL01ASRCacheEAR"
contentType = "app"
installOpts = "update"
updatedContentLoc = "/tmp/ASRCache_vsb4-6-6.ear"
options = ["-operation", installOpts, "-contents", updatedContentLoc]

#
# "MapWebModToVH" task options
#
webModule = "ASRCacheServer"
uri = "ASRCacheServer.war,WEB-INF/web.xml"
virtualHost = "VHASRShip"
mapWebOptions = [[webModule, uri, virtualHost]]

AdminApp.update(appName, contentType, options)
#AdminApp.update(appName, contentType, options "-MapWebModToVH", mapWebOptions)
AdminConfig.save()
#===================================================================
# STOP updateEntApp
#===================================================================
0
lphillipsAuthor Commented:
hi Honor God,

I've still been trying to get this but no luck.  Do you have any insight?  In the updateEntApp.py script above it works if I don't MapWebModToVH.  I'm pretty sure my only issue is I can't get the syntax correct when adding that option.  Any ideas when looking at the above?

If you could just show me an example that you get working using your own app and using the script above, modifiying it get it to work I'm sure I can take it from there.  Please let me know.

Thanks,

Lisa
0
HonorGodSoftware EngineerCommented:
So, all you need is the MapWebModToVH parameter?
0
lphillipsAuthor Commented:
I would like it in the format that would work within the script above.  I know the parameters to pass, but it complains.  If you could suggest the format to use with the above and it works I'll be happy.  Thanks for your help.
0
HonorGodSoftware EngineerCommented:
What parameters would you like to pass?
0
lphillipsAuthor Commented:
well that option requires the three parms defined below:

webModule = "ASRCacheServer"
uri = "ASRCacheServer.war,WEB-INF/web.xml"
virtualHost = "VHASRShip"

I thought the AdminApp.update statement commented out below should have worked, but it did not.

#===================================================================
# START updateEntApp
#===================================================================
#
# app info
#
appName = "CL01ASRCacheEAR"
contentType = "app"
installOpts = "update"
updatedContentLoc = "/tmp/ASRCache_vsb4-6-6.ear"
options = ["-operation", installOpts, "-contents", updatedContentLoc]

#
# "MapWebModToVH" task options
#
webModule = "ASRCacheServer"
uri = "ASRCacheServer.war,WEB-INF/web.xml"
virtualHost = "VHASRShip"
mapWebOptions = [[webModule, uri, virtualHost]]

AdminApp.update(appName, contentType, options)
#AdminApp.update(appName, contentType, options "-MapWebModToVH", mapWebOptions)
AdminConfig.save()
#===================================================================
# STOP updateEntApp
#===================================================================
0
lphillipsAuthor Commented:
I'm going to close this thread.  I was found out how to Keep Existing Bindings, which in turn kept the Virtual Host.  The problem I'm having now is being able to pass arguments from the shell script to the .py script.  I get it to work if I hard code the values in the .py script.  I will open a new question for that and give the details there.

Here is the .py script that worked with updating the existing application and keeping existing bindings:

updateEntApp.py
#===================================================================
# START updateEntApp
#===================================================================
APPNAME = "CL01ASRShipEAR"
EARPATH = "/apps/WebSphere/AppServer/local/v70/migration/ASR/current/ASRInternal_sb_5-0-0.ear"

### VARIABLES ###
contentType = "app"
installOpts = "update"
cmdOptions = ["-operation", installOpts, "-contents", EARPATH, "-update.ignore.new"]
logFile = open(LOGFILE,"a")
### VARIABLES ###

## all three of the below statements work when executing
## updateEntApp.py from the command line:
## ./wsadmin.sh -f /apps/WebSphere/AppServer/local/v70/admin/scripts/migration/jython/updateEntApp.py

## STATEMENT 1
#AdminApp.update("CL01ASRShipEAR", "app", ["-operation", "update", "-contents", "/apps/WebSphere/AppServer/local/v70/migration/ASR/current/ASRInternal_sb_5-0-0.ear", "-update.ignore.new"])

## STATEMENT 2
#AdminApp.update(APPNAME, "app", ["-operation", "update", "-contents", EARPATH, "-update.ignore.new"])

## STATEMENT 3
AdminApp.update(APPNAME, contentType, cmdOptions)

AdminConfig.save()
#===================================================================
# STOP updateEntApp
#===================================================================
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java App Servers

From novice to tech pro — start learning today.