Question

I want to do post-deploy script using standalone wsadmin. It should delete all caches on profile (/profile/temp /profile/myCacheFolder). My question is, is it possible to do this with wsadmin? If so how? Can I somehow use AdminConfig.deleteDocument or something like this?

thank you

Was it helpful?

Solution

With AntAgent MBean you can upload ant script and then invoke it on remote node:

http://pic.dhe.ibm.com/infocenter/wasinfo/v7r0/topic/com.ibm.websphere.javadoc.doc/web/mbeanDocs/AntAgent.html

from java.lang import String
import jarray

fileContent = '<project name="cleanup" default="cleanup"><target name="cleanup"><delete dir="${user.install.root}/temp" /><delete dir="${user.install.root}/wstemp" /></target></project>'
antAgent = AdminControl.makeObjectName(AdminControl.queryNames('WebSphere:*,type=AntAgent,process=dmgr'))

str = String(fileContent)
bytes = str.getBytes()

AdminControl.invoke_jmx(antAgent, 'putScript', [String('cleanup.xml'),bytes], jarray.array(['java.lang.String', '[B'], String))

AdminControl.invoke_jmx(antAgent, 'invokeAnt', [jarray.array([], String), String('cleanup.xml'), String('cleanup')], jarray.array(['[Ljava.lang.String;', 'java.lang.String', 'java.lang.String'], String))

fileContent variable is you Ant script, you may have to tweak it a bit more, especially on Windows in order to deal with blocked files/directories.

OTHER TIPS

wsadmin.sh can be launched with Jython which is Python with Java.

So you can use Python default classes: import os os.rmdir('/a/b/c')

Also if you are on Unix: import os os.sys('rm -r /a/b/c') or os.system('rm -r /a/b/c')

The above commands will remove directory 'c' in /a/b. Use os.remove('filename') to remove a file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top