Manage composition units with scripting
Use the commands in the BLAManagement command group to manage composition units. Use the examples in this topic to add, remove, edit, export, and view composition units.
There are two ways to complete the examples in this task. Use the
BLAManagement to manage composition units. Alternatively, we can use the scripts in the AdminBLA script library to administer the composition unit configurations.
Composition units can represent deployed assets, other business-level applications, or external artifacts that are deployed on non-WAS runtime environments without associated assets. Business-level applications contain zero or more composition units. We cannot add the same composition unit to more than one business-level application, but we can use one asset to create more than one composition unit.
- Add composition units.
- Launch the wsadmin scripting tool using the Jython scripting language.
- Add composition units. Use the addCompUnit command to add composition units to business-level applications. Use the following command example to add the asset1 asset as a composition unit in the myBLA business-level application, and map the deployment to the server1 server:
AdminTask.addCompUnit('-blaID myBLA -cuSourceID asset1 -CUOptions [[.* .* compositionUnit1 "composition unit that is backed by asset1" 0]] -MapTargets [[.* server1]] -ActivationPlanOptions [.* specname=actplan0+specname=actplan1]')Use the following command to add the asset2 asset as a composition unit in the myBLA business-level application, and map the deployment to the server1 and testServer servers:
AdminTask.addCompUnit('-blaID myBLA -cuSourceID asset2 -CUOptions [[.* .* compositionUnit2 "composition unit that is backed by asset2" 0]] -MapTargets [[.* server1+testServer]] -ActivationPlanOptions [.* specname=actplan0+specname=actplan1]')Use the following command to add the J2EEAsset asset as a composition unit in the myBLA business-level application, and map the deployment to the server1 and testServer servers:
AdminTask.addCompUnit('[-blaID myBLA -cuSourceID J2EEAsset -defaultBindingOptions defaultbinding.ejbjndi.prefix=ejb# defaultbinding.virtual.host=default_host# defaultbinding.force=yes -AppDeploymentOptions [-appname defaultapp -installed.ear.destination application_root/myCell/defaultapp.ear] -MapModulesToServers [[defaultapp.war .* WebSphere:cell=cellName,node=nodeName,server=server1][Increment.jar .* Websphere:cell=cellName,node=nodeName,server=testServer]] -CtxRootForWebMod [[defaultapp.war .* myctx/]]]')The command returns the configuration IDs of the composition unit and the new composition unit created for the asset in the asset relationship, as the following example displays:
WebSphere:cuname=compositionUnit1 WebSphere:cuname=compositionUnit2WebSphere:cuname=J2EEAsset
- Save the configuration changes...
AdminConfig.save()- Display composition units and settings.
Use the listCompUnits and viewCompUnits commands to display the configuration
IDs of each composition unit that matches a specific search scope. You can use the listCompUnits command to display each composition unit in the configuration or within a specific business-level application.
The following example displays each composition unit in the myBLA business-level application:
AdminTask.listCompUnits('-blaID blaname=myBLA')The command returns the configuration IDs and type of backing asset for each composition unit that matches the search scope, as the following sample displays:
Websphere:cuname=cu1 asset
Websphere:cuname=cu4 bla WebSphere:cuname=defaultapp__j2eeUse the viewCompUnits command to display additional configuration information about a specific composition unit of a business-level application. For example, the following example displays additional information about the cu1 composition unit for the myBLA business-level application:
AdminTask.viewCompUnit('-blaID myBLA -cuID cu1')The command returns detailed configuration information for the composition unit, as the following sample displays:
Specify Composition Unit options (CUOptions) Specify name, description options forUse the editCompUnit command to modify the composition unit configuration options.Composition Unit. Parent BLA (parentBLA): [WebSphere:blaname=myBLA] Backing Id (backingId): [WebSphere:assetname=asset1.zip]
Name (name): [cu1] Description (description): [my description of cu1 composition unit] Starting Weight (startingWeight): [0]
Specify servers (MapTargets) Specify targets such as appservers or clusters of appservers where you want to deploy the composition unit contained in the application. Deployable Unit (deplUnit): [default] *Servers (server): [WebSphere:node=myNode,server=server1] Specify Composition Unit activation plan options (ActivationPlanOptions) Specify composition unit activation plan optionsDeployableUnit Name (deplUnit): [default] Activation Plan (activationPlan): [WebSphere:specname=actplan0+WebSphere:specname=actplan1]
- Edit composition units.
- Launch the wsadmin scripting tool using the Jython scripting language.
- Modify the composition unit.
Use the editCompUnit command to modify composition unit options. Use this command to modify the starting weight of the composition unit, deployment targets, activation plan options, and relationship settings. See the documentation for the BLAManagement to view descriptions of each option that we can modify.
The following example edits a composition unit, which is associated with an asset, and replaces the deployment target:
AdminTask.editCompUnit('-blaID myBLA –cuID cu1 –CUOptions [[.* .* cu1cudesc 1]] -MapTargets [[.* server2]] -ActivationPlanOptions [.* #specname=actplan0+specname=actplan2]')The command returns the configuration ID of the composition unit that the system edits, as the following sample displays:
WebSphere:cuname=cu1- Save the configuration changes...
AdminConfig.save()- Remove composition units.
- Launch the wsadmin scripting tool using the Jython scripting language.
- Remove composition units. Use the deleteCompUnit command to remove a composition unit. Both parameters for the following command accept incomplete configuration IDs, as long as the system can match the string to a unique ID:
AdminTask.deleteCompUnit('-blaID myBLA –cuID cu1')The command returns the configuration ID of the composition unit that the system deletes, as the following sample demonstrates:
WebSphere:cuname=cu1- Save the configuration changes...
AdminConfig.save()
Related tasks
Set up business-level applications using scripting
Edit a composition unit using programming
Deploy business-level applications
Related
Business-level application configuration scripts
BLAManagement