Hi Joao,
I have created a pyhthon script, which tries to clean up as many apps as possible (only use in staging or testing environments).
It does work pretty well, but still does not get all the toolkits. You are welcome to help me on this ;)
CODE...........................
import re
import sys
import time
oSysOut = sys.stdout
timestr = time.strftime("%Y%m%d-%H%M%S")
filename = "CleanupAllAppsLog_" + timestr + ".txt"
print "Switching to file output: " + filename
f = open(filename, 'w')
sys.stdout = f
apps = re.split(r'\n\s*\n',AdminTask.BPMListProcessApplications())
apps.remove("")
countDeact = 0
countDel = 0
try:
for app in [a[a.index('Acronym:')+9:a.index('Description:')].rstrip() for a in apps if a.find('Toolkit: false') > 0 if a.find('SYS') < 0]:
snapshots = re.split(r'\n\s*\n',AdminTask.BPMShowProcessApplication('[-containerAcronym '+app+']').split('List of Snapshots:',1)[1])
for snap in [s[s.index('Acronym: ')+9:s.index('Created On:')].rstrip() for s in snapshots if s.find('instances: 0') > 0 if s.find('State: State[Inactive]') > 0]:
print "Processing Snapshot "+ snap +" of ProcessApp [" + app + "]:"
try:
print AdminTask.BPMDeactivate('[-containerAcronym '+app+' -containerSnapshotAcronym '+snap+']')
countDeact = countDeact + 1
print AdminTask.BPMDeleteSnapshot('[-containerAcronym '+app+' -containerSnapshotAcronyms '+snap+']')
countDel = countDel + 1
except java.lang.Exception,e:
print str(e)
continue
#endTry
except:
pass
print "Finished cleanup for all apps, "+ countDeact + " snapshots were deactivated, " + countDel + " snapshots were deleted."
f.close()
sys.stdout = oSysOut
print "Finished processing"
CODEEND..........................................
------------------------------
Nils Schiwek
------------------------------
Original Message:
Sent: Tue August 25, 2020 04:21 AM
From: Joao Alexandre
Subject: Housekeeping
I am trying to clean the house eliminating snapshots, but I receive a lot of error messages about dependencies:
"Deactivate snapshot COECA_6 da PApp COECA
Error:
com.ibm.ws.scripting.ScriptingException: java.lang.Exception: java.lang.Exception: Snapshot cannot be deleted at this time due to dependents on the current snapshot. Please use BPMShowSnapshot command to get detail information."
I found the algorithm to implement this:
"Toolkits that the process application depended on remain. There might be other toolkits and process applications depending on those remaining toolkits. The toolkits cannot be deleted while those dependencies exist. To delete toolkits, complete the following steps:
- Deactivate the toolkit snapshot of the dependency with the BPMDeactivate command.
- Stop the toolkit snapshot with the BPMStop command.
- Get a list of toolkits and process applications that have dependencies on the toolkit snapshot with the following command: BPMShowSnapshot -showDependents snapshot_name.
- Starting with the root of the list of reported dependencies, remove each dependency. For each dependency that you want to remove, delete the snapshot of the toolkit or process application.
- After you resolve all of the dependencies, delete the snapshot with the BPMDeleteSnapshot command."
Do anyone have already implemented in python this?
------------------------------
Joao Alexandre
Lisboa
------------------------------