BPM, Workflow, and Case

 View Only
  • 1.  Housekeeping

    Posted Tue August 25, 2020 04:21 AM
    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:
    1. Deactivate the toolkit snapshot of the dependency with the BPMDeactivate command.
    2. Stop the toolkit snapshot with the BPMStop command.
    3. Get a list of toolkits and process applications that have dependencies on the toolkit snapshot with the following command: BPMShowSnapshot -showDependents snapshot_name.
    4. 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.
    5. 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
    ------------------------------


  • 2.  RE: Housekeeping

    Posted Wed August 26, 2020 04:05 AM
    Edited by Nils Schiwek Wed August 26, 2020 07:40 AM
    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
    ------------------------------



  • 3.  RE: Housekeeping

    Posted Wed August 26, 2020 07:35 AM
    Thanks for your contribution. The script you post there is not formated in good conditions, but I will try to look into it.

    ------------------------------
    Joao Alexandre
    Lisboa
    ------------------------------



  • 4.  RE: Housekeeping

    Posted Wed August 26, 2020 07:42 AM
    Sorry about the format, I did insert as code and it looked good in the editor but not when I submitted. I have edited my above answer to text only.

    ------------------------------
    Nils Schiwek
    ------------------------------



  • 5.  RE: Housekeeping
    Best Answer

    Posted Wed August 26, 2020 10:21 AM
    Hi Joao,
     
    I developed a script that takes a list of snapshots and deletes them. The dependencys are listed for those that can't be deleted.
     
    The following link has the project:
     
    Following is a trace deleting 3 snapshots:
    Archivo de trace: /root/SnapshotCleanup/Trace_20200608185958.log
     Inicio Application: SU-0.00.07 1 de 3
      1. Borrando instancias
          => The BPMProcessInstancesPurge command passed.
          => The BPMProcessInstancesPurge command passed.
          => The BPMProcessInstancesPurge command passed.
      2. Desactivando aplicación
          => BPMDeactivate passed.
      3. Deteniendo aplicación
          => ERROR BPMStop: com.ibm.ws.scripting.ScriptingException: java.lang.Exception: java.lang.Exception: There are still '2' process instances running so the snapshot cannot be stopped. Please complete or terminate the instances before running the BPMStop command.
          => Error desconocido. Tomar acción manual.
     Fin Application: SU-0.00.07
    === Inicio Application: SU-0.00.08 2 de 3
      1. Borrando instancias
          => The BPMProcessInstancesPurge command passed.
          => The BPMProcessInstancesPurge command passed.
          => The BPMProcessInstancesPurge command passed.
      2. Desactivando aplicación
          => BPMDeactivate passed.
      3. Deteniendo aplicación
          => BPMStop passed.
      4. Eliminando despliegue
          => No tiene BLA
      5. Borrando aplicación
          => BPMDeleteSnapshot passed.
     Fin Application: SU-0.00.08
    === Inicio Application: TKA-0.00.02 3 de 3
      1. Borrando instancias
          => The BPMProcessInstancesPurge command passed.
          => The BPMProcessInstancesPurge command passed.
          => The BPMProcessInstancesPurge command passed.
      2. Desactivando aplicación
          => BPMDeactivate passed.
      3. Deteniendo aplicación
          => BPMStop passed.
      4. Eliminando despliegue
          => No tiene BLA
      5. Borrando aplicación
          => ERROR BPMDeleteSnapshot: 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.
         Detalles de Snapshot
          => Dependencias:
              Toolkit   : TKB-0.00.03
              ProcessApp: SU-0.00.07
     Fin Application: TKA-0.00.02
    ===
     
     
     
     
     
    Saludos / Regards,
     
    Sergio Andres Gutierrez Giraldo
    IT Specialist
    IBM Cloud Expert Labs
    IBM Colombia 
     
    Phone: 57-1-628-2311 | Mobile: 57-318-221-1140 | E-mail: sgutierr@co.ibm.com