IBM WebSphere: How to map an application to multiple clusters using wsadmin scripting?

Question:

I am trying to automate the deployments of an application which is mapped to two clusters in a cell using wsadmin scripting. But no matter how much I try, the application is getting mapped to only one cluster. As a result the application is not at all starting.

I am getting the following error message:

Application helloteam_07062019_1956 is not deployed on the cluster SPPAbcd
Exception: exceptions.AttributeError WASL6048E: The helloteam_07062019_1956 application is not deployed on the SPPAbcd target.  
WASX7017E: Exception received while running file "/app/was_scripts/main_scripts/deploy_mutlitest.py"; exception information: com.ibm.bsf.BSFException: exception from Jython:
Traceback (innermost last):
  File "<string>", line 175, in ?
  File "/app/service/IBM/WebSphere/AppServer/scriptLibraries/application/V70/AdminApplication.py", line 4665, in startApplicationOnCluster
ScriptLibraryException: : 'exceptions.AttributeError WASL6048E: The helloteam_07062019_1956 application is not deployed on the SPPAbcd target. '

It is clear from the error message that app is only mapped to SRVApp cluster, but it is not mapped to SPPAbcd cluster. As a result, it is unable to start the app.

Here is the script:

targetServerOne = "WebSphere:cell=DIGIAPP1Cell02,cluster=SPPAbcd"
targetServerTwo = "WebSphere:cell=DIGIAPP1Cell02,cluster=SRVApp"

AdminApp.install(location, ['-appname',"hellotest",'-defaultbinding.virtual.host',virtualHost,'-usedefaultbindings','-contextroot',ctxRoot,'-MapModulesToServers',[["EchoApp",URI,targetServerOne],["EchoApp",URI,targetServerTwo]]])
AdminConfig.save()

cell=AdminConfig.list('Cell')
cellName=AdminConfig.showAttribute(cell, 'name')
clusters=AdminConfig.list('ServerCluster').split('n')
print("The clusters in "+cellName+" are...")
print(clusters)

for name in startClusters:
    startapp = AdminApplication.startApplicationOnCluster(newWar, name)
    print(startapp)

As aforementioned, no matter what I try, the app is only getting mapped to SRVApp cluster (after checking app’s Manage module section in DMGR console). It is not getting mapped to SPPAbcd cluster.

How to achieve proper module mapping to multi clusters? The module mapping part is mentioned in adminapp.install command. Is that the correct way to map modules?

Asked By: CK5

||

Answers:

To solve this issue, I have leveraged EnvInject plugin of Jenkins to inject properties at build time.

Instead of having two targetServers (targetServerOne and targetServerTwo), i have just used only target server, and invoked it from properties file.

This is my properties file:

moduleMapping=WebSphere:cell=cell1,cluster=cluster1+WebSphere:cell=cell1,cluster=cluster2

My script has been modified like below:

from os import getenv as env

targetServer = env(‘moduleMapping’)

AdminApp.install(filename, [ ‘-MapModulesToServers, [[‘moduleName’, ‘uri’, targetServer]]])

This has mapped my app to two clusters within a cell.

Answered By: CK5