Disable application loading in deployed targets using wsadmin.sh
Use the AdminConfig object and scripting to disable application loading in deployed targets.
The following example uses the AdminConfig object to disable application loading in deployed targets:
Tasks
- Start the wsadmin scripting tool.
- Obtain the Deployment object for the application and assign it to the deployments variable, for example:
- Jacl:
set deployments [$AdminConfig getid /Deployment:myApp/]- Jython:
deployments = AdminConfig.getid("/Deployment:myApp/")
Element Description set Jacl command deployments Variable name $ Jacl operator for substituting a variable name with its value AdminConfig Object representing the WebSphere Application Server configuration getid AdminConfig command Deployment Attribute myApp Value of the application name If we are using the Jython scripting language, make sure that you read the notes concerning a space character within application names.
Example output:
myApp(cells/mycell/applications/myApp.ear/deployments/myApp|deployment.xml#Deployment_1)- Obtain the target mappings in the application and assign them to the targetMappings variable, for example:
- Jacl:
set deploymentObj1 [$AdminConfig showAttribute $deployments deployedObject] set targetMap1 [lindex [$AdminConfig showAttribute $deploymentObj1 targetMappings] 0]Example output:
(cells/mycell/applications/ivtApp.ear/deployments/ivtApp|deployment.xml#DeploymentTargetMapping_1)- Jython:
deploymentObj1 = AdminConfig.showAttribute(deployments, 'deployedObject') targetMap1 = AdminConfig.showAttribute(deploymentObj1, 'targetMappings') targetMap1 = targetMap1[1:len(targetMap1)-1].split(" ") print targetMap1When we attempt to obtain the target mappings in the application through scripting and then assigning those values to the targetMappings variable, be aware when the application has a space in the name or blank. In these cases, we must compensate for the occurrence of a blank or space character as the Jython example demonstrates. Errors can occur if we do not make this adjustment. Consider the following scenarios:
- If only one single DeploymentTargetMapping value exists within the deployment.xml file, we can either split the targetMappings value with a space or a line.separator entry. The line.separator entry syntax works when the application name contains a space, such as "IVT Application". For example:
targetMap1 = targetMap1[1:len(targetMap1)-1].split(" ")ortargetMap1 = targetMap1[1:len(targetMap1)-1].split(java.lang.System.getProperty("line.separator"))- If multiple DeploymentTargetMapping values exist within the deployment.xml file, split the targetMappings values with a space. However, we must also use "\" and " ", as appropriate, when the application name or deployment target string contains a space character. For example:
targetMap1 = targetMap1[1:len(targetMap1)-1].split(" ")
Example output:
['(cells/mycell/applications/ivtApp.ear/deployments/ivtApp|deployment.xml#DeploymentTargetMapping_1)']
Element Description set Jacl command deploymentObj1 variable name $ Jacl operator for substituting a variable name with its value AdminConfig object that represents the WAS configuration showAttribute n AdminConfig command deployments Evaluate the ID of the Deployment object specified in step number 1 deployedObject targetMap1 variable name targetMappings lindex Jacl command Jython command - Disable the loading of the application on each deployed target, for example:
- Jacl:
foreach tm $targetMap1 {$AdminConfig modify $tm {{enable false}}}- Jython:
for targetMapping in targetMap1: AdminConfig.modify(targetMapping, [["enable", "false"]])
- Save the configuration changes.
AdminConfig.save()- In a network deployment environment only, synchronize the node.
Use the syncActiveNode or syncNode scripts in the AdminNodeManagement script library to propagate the configuration changes to node or nodes.
- Use the syncActiveNodes script to propagate the changes to each node in the cell:
AdminNodeManagement.syncActiveNodes()- Use the syncNode script to propagate the changes to a specific node:
AdminNodeManagement.syncNode("myNode")
wsadmin AdminConfig Commands for the AdminConfig object