Wednesday, May 12, 2010

How to install an application?

Use wsadminlib's method installApplication().

Here is the method signature. The parameter names are straightforward, and the pydoc is pretty good. The list of servers is meant to specify individual non-clustered servers. If a server is part of a cluster, just specify the cluster name.

def installApplication( filename, servers, clusternames, options )

Clusters

First let's install an app on a cluster of servers. Define the name of the ear file, and the name of the cluster. Then install the app, specifying an empty list for individual servers, and no options.

filename = '/tmp/pxyapps.ear'
clusternames = [ 'cluster1' ]
installApplication( filename, [], clusternames, None )


After saving the config, we can browse to the admin console, look at the app's mappings, and see it worked:

Individual servers

Next let's install an app on an individual non-clustered server. Define the server in a list of dictionaries containing the node name and server name. This time we specify an empty list for the clusternames.



filename = '/tmp/pxyapps.ear'
servers = [ { 'nodename': 'node1', 'servername': 'sippbx1' } ]
installApplication( filename, servers, [], None )


After saving the config, we again browse to the admin console, and see the app's mappings"

But wait, there's more. If you browse through wsadminlib.py, in the section titled 'application-related methods', you'll find a bevy of methods to list applications, delete them, start and stop, etc. Poke around and see what you can find.

Just for the archives, here is the full transcript of installing on the cluster...

root@ding1:/tmp# /opt/WAS70/bin/wsadmin.sh -lang jython -host ding6 -port 8879
WASX7209I: Connected to process "dmgr" on node dmgr using SOAP connector; The type of process is: DeploymentManager
WASX7031I: For help, enter: "print Help.help()"
wsadmin>
wsadmin>
wsadmin>execfile('/tmp/wsadminlib.py')
$Id: wsadminlib.py 104 2010-02-15 19:06:18Z ding $
wsadmin>
wsadmin>
wsadmin>enableDebugMessages()
[2010-0512-1007-1600] enableDebugMessages Verbose trace messages are now enabled; future debug messages will now be printed.
wsadmin>
wsadmin>
wsadmin>filename = '/tmp/pxyapps.ear'
wsadmin>clusternames = [ 'cluster1' ]
wsadmin>
wsadmin>
wsadmin>installApplication( filename, [], clusternames, None )
[2010-0512-1020-4200] installApplication: filename=/tmp/pxyapps.ear, servers=[], clusternames=['cluster1'], options=None
[2010-0512-1020-4200] installApplication: Calling AdminApp.install of /tmp/pxyapps.ear with arglist = ['-target', 'WebSphere:cell=ndcell,cluster=cluster1']
ADMA0073W: Custom permissions are found in the [(com.ibm.websphere.security.WebSphereRuntimePermission AdminPermission)] policy file. Custom permissions can compromise the integrity of Java 2 Security.
WASX7327I: Contents of was.policy file:
/*
* WARNING: IF YOU EDIT THIS FILE WITH THE policytool, THESE
* COMMENTS MIGHT BE LOST
*/

grant codeBase "file:${application}" {

/* Pxyapps needs this - it tries to get the cell name */
permission com.ibm.websphere.security.WebSphereRuntimePermission "AdminPermission";

permission java.io.FilePermission "${was.install.root}${/}properties${/}version${/}CEA.product", "read";
permission java.lang.RuntimePermission "accessClassInPackage.sun.misc";

permission java.security.AllPermission;
};

ADMA5016I: Installation of pxyapps started.
ADMA5058I: Application and module versions are validated with versions of deployment targets.
ADMA5005I: The application pxyapps is configured in the WebSphere Application Server repository.
ADMA5053I: The library references for the installed optional package are created.
ADMA5005I: The application pxyapps is configured in the WebSphere Application Server repository.
ADMA5001I: The application binaries are saved in /opt/WAS70/profiles/dmgr/wstemp/Script1288cd6bd3d/workspace/cells/ndcell/applications/pxyapps.ear/pxyapps.ear
ADMA5005I: The application pxyapps is configured in the WebSphere Application Server repository.
SECJ0400I: Successfully updated the application pxyapps with the appContextIDForSecurity information.
ADMA5005I: The application pxyapps is configured in the WebSphere Application Server repository.
ADMA5113I: Activation plan created successfully.
ADMA5011I: The cleanup of the temp directory for application pxyapps is complete.
ADMA5013I: Application pxyapps installed successfully.
wsadmin>
wsadmin>
wsadmin>save()
[2010-0512-1020-4700] save: AdminConfig.queryChanges()
[2010-0512-1020-4700] save: WASX7146I: The following configuration files contain unsaved changes:
[2010-0512-1020-4700] save: cells/ndcell/nodes/node1/serverindex.xml
[2010-0512-1020-4700] save: cells/ndcell/applications/pxyapps.ear/deltas/pxyapps/delta-1273674004465
[2010-0512-1020-4700] save: cells/ndcell/applications/pxyapps.ear/pxyapps.ear
[2010-0512-1020-4700] save: cells/ndcell/applications/pxyapps.ear/deployments/pxyapps/META-INF/ibm-application-bnd.xmi
[2010-0512-1020-4700] save: cells/ndcell/applications/pxyapps.ear/deployments/pxyapps/META-INF/MANIFEST.MF
[2010-0512-1020-4700] save: cells/ndcell/applications/pxyapps.ear/deployments/pxyapps/pxyapps.war/WEB-INF/ibm-web-bnd.xmi
[2010-0512-1020-4700] save: cells/ndcell/applications/pxyapps.ear/deployments/pxyapps/META-INF/application.xml
[2010-0512-1020-4700] save: cells/ndcell/applications/pxyapps.ear/deployments/pxyapps/pxyapps.war/WEB-INF/web.xml
[2010-0512-1020-4700] save: cells/ndcell/applications/pxyapps.ear/deployments/pxyapps/pxyapps.war/META-INF/MANIFEST.MF
[2010-0512-1020-4700] save: cells/ndcell/applications/pxyapps.ear/deployments/pxyapps/pxyapps.war/WEB-INF/ibm-web-ext.xmi
[2010-0512-1020-4700] save: cells/ndcell/applications/pxyapps.ear/deployments/pxyapps/META-INF/was.policy
[2010-0512-1020-4700] save: cells/ndcell/applications/pxyapps.ear/deployments/pxyapps/META-INF/ibm-application-runtime.props
[2010-0512-1020-4700] save: cells/ndcell/applications/pxyapps.ear/deployments/pxyapps/deployment.xml
[2010-0512-1020-4700] save: cells/ndcell/blas/pxyapps/bver/BASE/bla.xml
[2010-0512-1020-4700] save: cells/ndcell/cus/pxyapps/cver/BASE/cu-ref.xml
[2010-0512-1020-4700] save: cells/ndcell/cus/pxyapps/cver/BASE/controlOpDefs.xml
[2010-0512-1020-4700] save: cells/ndcell/cus/pxyapps/cver/BASE/cu.xml
[2010-0512-1020-4700] save: AdminConfig.getSaveMode()
[2010-0512-1020-4700] save: rollbackOnConflict
[2010-0512-1020-4700] save: AdminConfig.save()
[2010-0512-1020-4800] save: Save complete!
[2010-0512-1020-4800] wsadminlib.syncall Start
[2010-0512-1020-4900] wsadminlib.syncall Sync config to node node1
[2010-0512-1020-4900] wsadminlib.syncall Done
0
wsadmin>
wsadmin>