You are on page 1of 6

ABOUT PRICING COMMUNITY TEAMS Start Free Trial Log in

gowroju asked on 5/19/2011

Mapping of modules to servers in jython scripting , Here is the Script which I am


running ...it is running fyn but the thing is mapping of modules to servers is not
talking place properly ...mapping i
# Purpose --- To deploy EAR file on Server
# Date   ----  2/11/2011
#version   --- 1.0
import sys
from time import sleep

def DeployOnServer(earlocation, appName, nodeName, serverName, virtualHost, webNode1, webSrv1):


   #--------------------------------------------------------------
   # do some sanity checking
   #     -- do we have a node by this name?
   #--------------------------------------------------------------
   cellName = AdminControl.getCell()
   print cellName
   node = AdminConfig.getid("/Node:" + nodeName + "/")
   print " checking for existence of node " + nodeName
   if len(node) == 0:
      print " Error -- node not found for name " + nodeName
      return
   else:
      print " "+nodeName+" does exists so deployment process will start "
   #---------------------------------------------------------------------------------------
   # Here we specify ear file location and server where we wish to deploy the ear file
   #----------------------------------------------------------------------------------------
   defapp = earlocation
   servOpt1 = "WebSphere:cell=" + cellName + ",node=" + nodeName + ",server=" + serverName
   servOpt2 = "+WebSphere:cell=" + cellName + ",node=" + webNode1 + ",server=" + webSrv1
   servOpt = servOpt1+servOpt2
   serv = ["-target", servOpt]
#---------------------------------------------------------
#  print "-------------------------------------------------------------"
#  print "These are the options we are passing to deploy the EAR file."
#  print " -------------------------------------------------------------"

   nameOpt = ["-appname", appName]


   nodeOpt = ["-node", nodeName]
   serverOpt1 = ["-server", serverName]

   mapVhOptValus = [[".*",".*", virtualHost]]


   mapVhOpt = ["-MapWebModToVH", mapVhOptValus]
   appOptions = []
   appOptions.extend(nameOpt)
   appOptions.extend(nodeOpt)
   appOptions.extend(serverOpt1)
   appOptions.extend(mapVhOpt)
   print appOptions
   AdminApp.install(defapp, appOptions)

   #---------------------------------------------------------
   # Save all the changes
   #---------------------------------------------------------
   print "Deploy: saving the configuration"
   AdminConfig.save()
   sleep(20)
#----------------------------------------------------------------------
# check if the application is ready to start. If ready then start it
#------------------------------------------------------------------------
def startAppOnServer():
   appready = AdminApp.isAppReady(appName)
   print appready
   if appready == 'false':
                sleep(40)
                appready = AdminApp.isAppReady(appName)
                print appready
   else:
                print "starting the application "+appName+" on "+serverName+" "
                appManager = AdminControl.queryNames("type=ApplicationManager,process="+ serverName +",*")
                if appManager == "":
                        print "Please make sure whether Application Server is up and running before starting the applicaiton "
                        print " Or There could be something wrong with installated EAR file "
                AdminControl.invoke(appManager, 'startApplication', appName)
                appstate = AdminControl.completeObjectName("type=Application,name="+appName+",*")
                if appstate != "":
                        print ""+ appName +" started "

# ----------------------------------------------------------------------------------------------------------------------------
# This function verifies whether Application is already deployed or not. If already deployed it will be uninstalled first
# -----------------------------------------------------------------------------------------------------------------------------
def appexist():
   print " checking for the "+appName+" applicaiton whether it is already exists or not"

   apps = AdminApp.list().split(lineSeparator)
   for applist in apps:
    if applist == appName:
        print "Application is already installed so It will be uninstalled first "
        AdminApp.uninstall(appName)
        AdminConfig.save()
    else:
        print " ------------------------------------------------"
        print " "+appName+" doesn't exists now so it will be deployed "

#----------------------------------------------------------------------------------------
#Main codes start here....
# ----------------------------------------------------------------------------------------
if (len(sys.argv) !=7):
        print " Please enter correct arguments "
        print " ex: DeployEAROnServer.py /usr/IBM/AppServer/installableApps/sample.ear sample mynode server1 virtualHost webserverNode
webserver"
else:
        earlocation = sys.argv[0]
        appName = sys.argv[1]
        nodeName = sys.argv[2]
        serverName = sys.argv[3]
        virtualHost = sys.argv[4]
        webNode1 = sys.argv[5]
        webSrv1 = sys.argv[6]
        print "EARfilelocation :" +earlocation
        print "Application Name : " +appName
        print "Node Name : " +nodeName
        print "Server Name : " +serverName
        print "Virtual Host :" +virtualHost
        print "WebServerNode :" +webNode1
        print "WebServer : " +webSrv1
        appexist()
        DeployOnServer(earlocation, appName, nodeName, serverName, virtualHost, webNode1, webSrv1)
        execfile('/usr/IBM/WebSphere/wasadm/scripts/jython/syncNode.py')
startAppOnServer()

Python

Last Comment
19 1 HonorGod 8/22/2022

5/19/2011
gowroju ASKER

mapping of modules to server in the sense its getting mapped to appserver node but not webserver node probably what might be the reason and if
anything i needs to add there let me know....

ASKER CERTIFIED SOLUTION

HonorGod

5/19/2011

THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.

Start a free trial to see this answer


Start a 7-day free trial and enjoy unlimited access to the platform.

Membership Options Sign up - free for 7 days

GET A PERSONALIZED SOLUTION


Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.

5/19/2011
gowroju ASKER

defapp = earlocation
O 1 "W bS h ll " llN " d " d N " " N
   servOpt1 = "WebSphere:cell=" + cellName + ",node=" + nodeName + ",server=" + serverName
   servOpt2 = "+WebSphere:cell=" + cellName + ",node=" + webNode1 + ",server=" + webSrv1
   servOpt = servOpt1+servOpt2

   serv = ["-target", servOpt]

this is the statement which we are passing to map the modules to the appserver node and webserver  node...

5/19/2011
gowroju ASKER

acutally we are giving some arguements while running this script script is sucessfully getting deployed but the thing  is in manage modules we are missing
the webserver parameter....do i need to change anything or else..what i need to do....or else i need to add any statement in the script

I started with Experts Exchange in 2004 and it's been a


mainstay of my professional computing life since. It
helped me launch a career as a programmer / Oracle data
analyst

William Peck

5/19/2011
HonorGod

It is very hard to get a good understanding of your code by looking at these snippets.

The "WebSphere:" shouldn't be needed

Unless you are using WebSphere XD, which supports multiple cells, then the cell=<cellName> shouldn't be needed either.

I would use the Admin Console to deploy your application, then use an interactive wsadmin environment to display the MapModulesToServers section of
the deployed application to see the syntax that is expected and being used.  Then, you would be much more likely to satisfy the deployment expectations
with your script.

Does that make sense?

5/19/2011
gowroju ASKER

yeah we can do like that but , this script is running fyn for some applications and it is creating a proble with few application .. i am not sure whether it is
with script issue or else console issue.....

5/19/2011
HonorGod

Is the script running successfully, and failing on the same machine?

Is it working, and failing for the same "version"?


- e.g., you might have a Deployment Manager with different Application Server versions federated, and to which you are trying to deploy an application
using the same script.

I'm just trying to understand.

Thanks!

⚡ FREE TRIAL OFFER


Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.

5/19/2011
gowroju ASKER

the scripting is running successfully with out any errors on various versions...but the thing is that mapping of modules to server...is the issue...usually while
deploying we will select some manage modules right , while selecting manage modules ( one AppNode and webNode we will be selecting ) when we are
doing it from console ...but while in script we are mapping those two but webnode is failing in the sense i am unable to see in the console , the map of
webserver to the module.....where as appNode is mapped properly to server.

5/19/2011
HonorGod

And the value you are specifying for the mapping of modules to server in the Jython code matches what you see in Jython when you use code like this?
1: print AdminApp.view( appName, '-MapModulesToServers' )

Select all Open in new window

5/20/2011
gowroju ASKER

if i insert that statement in the script and i have seen this

MapModulesToServers: Selecting servers

Specify targets such as application servers or clusters of application servers where you want to install the modules that are contained in your application.
Modules can be installed on the same application server or dispersed among several application servers.
Also, specify the Web servers as targets that serve as routers for requests to this application.
The plug-in configuration file (plugin-cfg.xml) for each Web server is generated, based on the applications that are routed through.

Module:  provWebApp
URI:  provWebApp.war,WEB-INF/web.xml
Server:  WebSphere:cell=JFSDEVDMGRCell,node=JFSDEVNode02,server=ccidsportal_dev_srv2

Module:  IMS Connector for Java


URI:  imsico91015b.rar,META-INF/ra.xml
Server:  WebSphere:cell=JFSDEVDMGRCell,node=JFSDEVNode02,server=ccidsportal_dev_srv2

Deploy: saving the configuration


 Start Synchronizing the Nodes

Here is the thing which i am seeing in running script could you suggest do i need to add anything in the servOpt...

Your help has saved me hundreds of hours of internet


surfing.

fblack61

5/20/2011
gowroju ASKER

Thanks a lot guys working on my issue finally the issue got resolved

5/20/2011
HonorGod

Cool.  What did they do, and how did they do it?

5/20/2011
gowroju ASKER

actually i have obsorbed  the script very clearly four -five times

 appOptions = []
   appOptions.extend(nameOpt)
   appOptions.extend(nodeOpt)
   appOptions.extend(serverOpt1)
   appOptions.extend(mapVhOpt)
   print appOptions

by observing to this and searching in the google i found out the error we have to give  like this
appOptions.extend(server) in place of appOptions.extend(serverOpt1). then it worked out fine ...Actually our  target is not mapping to server, it is
mapping to serverOpt1..thats why it is mapping to only appserver node...

⚡ FREE TRIAL OFFER


Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.

5/20/2011
HonorGod

Ah ha!  That would have been very difficult for me to identify.  Thanks for sharing the details.
6/6/2011
HonorGod

Thanks for the grade & points.

Good luck & have a great day.

12/3/2013
ques4web

Hi Gowroju,

I don't the server variable that you have defined in your script. But I do see serverOpt1 and serverOpt2. How it is working when you passed server as
parameter?

Experts Exchange has (a) saved my job multiple times, (b)


saved me hours, days, and even weeks of work, and often
(c) makes me look like a superhero! This place is MAGIC!

Walt Forbes

12/3/2013
ques4web

sorry, I meant, I don't see* the server

5/16/2018
Minh Nguyen Van

Hi guys,

Could you please let me know how to map modules to:


1. Cell + Node+Server
2. Cell + Cluster

Now like I done as shown in the screenshot ( attached file)but it was done by manually. How Could we script for that archiving?
ModuleMappingPNG.PNG

5/16/2018
HonorGod

Minh Nguyen Van - If you want someone to respond, ask a new question.

⚡ FREE TRIAL OFFER


Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.

Plans and Pricing Teams

Resources Certified Expert Program

Product Credly Partnership

Podcasts Udemy Partnership

Careers Privacy Policy

Contact Us Terms of Use

© 1996-2023 Experts Exchange, LLC. All rights reserved. Covered by US Patent

You might also like