12 Replies Latest reply on Apr 13, 2015 12:16 PM by Prasad Bonasu

    Need help writing an NSH script to delete Instances in a component template

    Prasad Bonasu

      Hi

       

         I have a component template which has lot of "Instances" in its local properties. Is there a way to delete them via NSH script. I'm able to rename them manually in console but not able to delete them(after deleting if I try to save the template - complaining instance already in use). I don't want to delete the whole component template - just the Instances under it

       

      Thank you

        • 3. Re: Need help writing an NSH script to delete Instances in a component template
          Prasad Bonasu

          Bill,

           

          I'm getting the below error. Instance names seem to resolve properly

           

          Command execution failed. com.bladelogic.om.infra.mfw.util.BlException: Unexpected exception while handling request.com.bladelogic.om.infra.model.template.TemplateService_deleteAssociatedSubclassPrototypeInstance(com.bladelogic.om.infra.model.template.Template, java.lang.String, boolean): java.lang.NullPointerException

          • 4. Re: Need help writing an NSH script to delete Instances in a component template
            Prasad Bonasu

            script used

             

            #!/bin/nsh

             

            blcli_connect

             

            blcli_execute Template getDBKeyByGroupAndName "/Middleware/WAS" "WAS 7.0"

            blcli_storeenv TemplateKey

            blcli_execute Template findByDBKey ${templateKey}

            blcli_execute Template getAssociatedSubclassPrototypeInstances

            blcli_execute Utility setTargetObject

            blcli_execute PropertySetInstance getName

            blcli_execute Utility setTargetObject

            blcli_execute Utility listPrint

            blcli_storeenv PSIs

            for psi in "${PSIs}"

            do

            blcli_execute Template deleteLocalParameterInstance "WAS 7.0" "/Middleware/WAS" "${psi}" false

            done

            • 5. Re: Need help writing an NSH script to delete Instances in a component template
              Bill Robinson

              change it to:

               

              blcli_execute Template getDBKeyByGroupAndName "/Middleware/WAS" "WAS 7.0"

              blcli_storeenv TemplateKey

              blcli_execute Template findByDBKey ${templateKey}

              blcli_execute Template getAssociatedSubclassPrototypeInstances

              blcli_execute Utility setTargetObject

              blcli_execute PropertySetInstance getName

              blcli_execute Utility setTargetObject

              blcli_execute Utility listPrint

              blcli_storeenv PSIs

              for psi in "${PSIs}"

              do

              echo ***"

              echo "${psi}"

              echo "***"

              done

               

              what does that show ?

              • 6. Re: Need help writing an NSH script to delete Instances in a component template
                Prasad Bonasu

                1 error

                 

                //@/opt/bmc/bladelogic/NSH/tmp/application_server/scripts/job__67257e92-56c4-4691-8390-4c8fe76e9e6a/script_DBKey-SJobKeyImpl-2020640-2__015a2933-6b2e-4e15-8f7c-00b3c964deca.2004060.1_Delete_WAS_components.nsh:36: unmatched "

                 

                PSI's :

                 

                ][ppselector, psage01, qinteractivevoice01, qdpmsgenrollment01.NotInUse, qmembermvr01, tdpmsgeregistration01, tdstprtl01, thealthincentives01, thipaa27x01, thipaainfosvc, thipaatablemaint01, thlinct01, tihub01, ptransrouting03, tmembermvr01, tproviderfaxrptsvc01, tprovidermvr01, tpselector01, trbf01, tsage01, ttman01, ttman02, ttransrouting01, selectRestore, pitimtds01, t5010hb01, taccumretrieval01, tbhfd01, tbluesquared01, Testing01, ibluesquared01, ibluesquared03, ipega05xxx, wasUpdater7.0, qpega05, qpega06, was7.0Installer, UpdateInstaller.7.0.3, pmembermvr01.1032014, ppega05, ibluesquared02, qproviderfaxrptsvc01, qprovidermvr01, qpselector, qsage01, qsecurityaccess01, tpega0xxxx, tdisttest01, temma01, titimtds01, qimagecontent01, qdpmsgeregistration01, iclmviewer01, icontractsvc01, psecurityaccess01, pstarauto01.retired, ptman01, ptman02, ptransrouting01, idpmsgenrollment01, ihipaatablemaint01, iimagecontent01, iimageservice01, iinteractivevoice01, imbrconversion01, imembermvr01, ipega06xxx, iproviderfaxrptsvc01, iprovidermvr01, irbf01, timageservice01, i5010hb01, qstarauto01, qtman01, qtman02, qtransrouting01, ibhfd01, ibirt01, tclmviewer01, tcontlib01, tcrp02, tdpmifp01, tdpmins01, tpegaxxx, tdpmsgenrollment01, qbhfd01, qbluesquared01, qccsmid01, qclmviewer01, qcontractsvc01, pcrp02, pdpmifp01, phealthincentives01, phipaa27x01, phipaainfosvc, pihub01, pimagecontent01, pimageservice01, pdpmsgenrollment01, pdpmsgeregistration01, pdstprtl01, pemma01, qcrp02, qdpmifp01, ibma70.NotInUse, iihub01, timagecontent01, tinteractivevoice01, tjon01, tjython01, tleapcodeexpl01, tmbrconversion01, tmbrsvcs02, ipselector, istarauto01, itman01, itman02, itransrouting01, UpdateInstaller, phipaatablemaint01, q5010hb01, qaccumretrieval01, qajh01, qdstprtl01, qemma01, qhealthincentives01, qhipaa27x01, qhipaainfosvc, qhipaatablemaint01, qihub01, qmbrconversion01, qtransrouting03, tcontractsvc01, MAINT, WAS7.0, emed01, p5010hb01, paccumretrieval01, pajh01, pbhfd01, pbluesquared01, pccsmid01, pclmviewer01, pcontractsvc01, iccsmid01, icontlib01, tstarauto01, tstardash01, tstime01, icrp02, idpmifp01, idpmsgeregistration01, idstprtl01, ihealthincentives01, ihipaa27x01, ihipaainfosvc, tbma70, tccsmid01, iaccumretrieval01, qdpmsgenrollment01, qimageservice01, pinteractivevoice01, pmbrconversion01, pmembermvr01, pproviderfaxrptsvc01, pprovidermvr01][ppselector, psage01, qinteractivevoice01, qdpmsgenrollment01.NotInUse, qmembermvr01, tdpmsgeregistration01, tdstprtl01, thealthincentives01, thipaa27x01, thipaainfosvc, thipaatablemaint01, thlinct01, tihub01, ptransrouting03, tmembermvr01, tproviderfaxrptsvc01, tprovidermvr01, tpselector01, trbf01, tsage01, ttman01, ttman02, ttransrouting01, selectRestore, pitimtds01, t5010hb01, taccumretrieval01, tbhfd01, tbluesquared01, Testing01, ibluesquared01, ibluesquared03, ipega05xxx, wasUpdater7.0, qpega05, qpega06, was7.0Installer, UpdateInstaller.7.0.3, pmembermvr01.1032014, ppega05, ibluesquared02, qproviderfaxrptsvc01, qprovidermvr01, qpselector, qsage01, qsecurityaccess01, tpega0xxxx, tdisttest01, temma01, titimtds01, qimagecontent01, qdpmsgeregistration01, iclmviewer01, icontractsvc01, psecurityaccess01, pstarauto01.retired, ptman01, ptman02, ptransrouting01, idpmsgenrollment01, ihipaatablemaint01, iimagecontent01, iimageservice01, iinteractivevoice01, imbrconversion01, imembermvr01, ipega06xxx, iproviderfaxrptsvc01, iprovidermvr01, irbf01, timageservice01, i5010hb01, qstarauto01, qtman01, qtman02, qtransrouting01, ibhfd01, ibirt01, tclmviewer01, tcontlib01, tcrp02, tdpmifp01, tdpmins01, tpegaxxx, tdpmsgenrollment01, qbhfd01, qbluesquared01, qccsmid01, qclmviewer01, qcontractsvc01, pcrp02, pdpmifp01, phealthincentives01, phipaa27x01, phipaainfosvc, pihub01, pimagecontent01, pimageservice01, pdpmsgenrollment01, pdpmsgeregistration01, pdstprtl01, pemma01, qcrp02, qdpmifp01, ibma70.NotInUse, iihub01, timagecontent01, tinteractivevoice01, tjon01, tjython01, tleapcodeexpl01, tmbrconversion01, tmbrsvcs02, ipselector, istarauto01, itman01, itman02, itransrouting01, UpdateInstaller, phipaatablemaint01, q5010hb01, qaccumretrieval01, qajh01, qdstprtl01, qemma01, qhealthincentives01, qhipaa27x01, qhipaainfosvc, qhipaatablemaint01, qihub01, qmbrconversion01, qtransrouting03, tcontractsvc01, MAINT, WAS7.0, emed01, p5010hb01, paccumretrieval01, pajh01, pbhfd01, pbluesquared01, pccsmid01, pclmviewer01, pcontractsvc01, iccsmid01, icontlib01, tstarauto01, tstardash01, tstime01, icrp02, idpmifp01, idpmsgeregistration01, idstprtl01, ihealthincentives01, ihipaa27x01, ihipaainfosvc, tbma70, tccsmid01, iaccumretrieval01, qdpmsgenrollment01, qimageservice01, pinteractivevoice01, pmbrconversion01, pmembermvr01, pproviderfaxrptsvc01, pprovidermvr01]ppselector

                • 7. Re: Need help writing an NSH script to delete Instances in a component template
                  Prasad Bonasu

                  please ignore the above comment. Missed a "

                   

                  Works fine without any errors.

                   

                  Wonder why deleteLocalParameterInstance is giving an error

                  • 8. Re: Need help writing an NSH script to delete Instances in a component template
                    Prasad Bonasu

                    Bill,

                     

                    blcli_execute Template deleteLocalParameterInstance "/Middleware/WAS" "WAS 7.0" "${psi}" false is working fine but the instances are being used to discover components. so setting the value true will deprecate the instance. Setting false doesn't seem to do anything(I can still see the instances)

                     

                    Is there a way to delete that discovery component first and then delete instance without deprecating ?

                    • 9. Re: Need help writing an NSH script to delete Instances in a component template
                      Bill Robinson

                      there should be a blcli.log in the $HOME of the user running this.  can you clear that out, run the script w/ the delete again and attach the log ?

                      • 10. Re: Need help writing an NSH script to delete Instances in a component template
                        Prasad Bonasu

                        blcli_execute Template deleteLocalParameterInstance "WAS 7.0" "/Middleware/WAS" "${psi}" false

                         

                         

                        13 Apr 2015 12:05:49,470 ERROR [MESSAGE] Command execution failed.  [/MESSAGE]

                        com.bladelogic.om.infra.mfw.util.BlException: Unexpected exception while handling request.com.bladelogic.om.infra.model.template.TemplateService_deleteAssociatedSubclassPrototypeInstance(com.bladelogic.om.infra.model.template.Template, java.lang.String, boolean)

                                at com.bladelogic.om.infra.app.api.manage.APIMethodInvocationProvider.executeRequest(APIMethodInvocationProvider.java:64)

                                at com.bladelogic.om.infra.app.api.manage.APIMethodInvocationProvider.invoke(APIMethodInvocationProvider.java:39)

                                at com.bladelogic.om.infra.app.service.routing.RoutingServiceImpl.invokeMethodLocally(RoutingServiceImpl.java:317)

                                at com.bladelogic.om.infra.app.service.routing.RoutingServiceImpl.invoke(RoutingServiceImpl.java:244)

                                at com.bladelogic.om.infra.app.api.manage.APIRequestManager.executeRequest(APIRequestManager.java:30)

                                at com.bladelogic.om.infra.message.app.frame.APIMessageFrame.service(APIMessageFrame.java:113)

                                at com.bladelogic.om.infra.mfw.net.ClientWorkerThread.processRequest(ClientWorkerThread.java:385)

                                at com.bladelogic.om.infra.mfw.net.ClientWorkerThread.processClientRequest(ClientWorkerThread.java:282)

                                at com.bladelogic.om.infra.mfw.net.ClientWorkerThread.handleClientRequest(ClientWorkerThread.java:182)

                                at com.bladelogic.om.infra.mfw.net.ClientWorkerThread.execute(ClientWorkerThread.java:101)

                                at com.bladelogic.om.infra.mfw.net.ClientWorkerThread.execute(ClientWorkerThread.java:27)

                                at com.bladelogic.om.infra.app.service.thread.BlBlockingThread.run(BlBlockingThread.java:95)

                        Caused by: java.lang.NullPointerException

                                at com.bladelogic.om.infra.model.property.PropertySetInstanceServiceImpl.findNumberOfPropertyConditionsUsingInstance(PropertySetInstanceServiceImpl.java:402)

                                at com.bladelogic.om.infra.model.property.PropertySetInstanceServiceImpl.findNumberOfUsesOfInstance(PropertySetInstanceServiceImpl.java:497)

                                at com.bladelogic.om.infra.model.template.TemplateServiceImpl.deleteAssociatedSubclassPrototypeInstance(TemplateServiceImpl.java:597)

                                at com.bladelogic.om.infra.model.template.TemplateServiceRequestHandlerImpl.deleteAssociatedSubclassPrototypeInstance_3(TemplateServiceRequestHandlerImpl.java:638)

                                at com.bladelogic.om.infra.model.template.TemplateServiceRequestHandlerImpl.execute(TemplateServiceRequestHandlerImpl.java:341)

                                at com.bladelogic.om.infra.app.api.manage.APIMethodInvocationProvider.executeRequest(APIMethodInvocationProvider.java:54)

                                ... 11 more

                         

                         

                         

                        blcli_execute Template deleteLocalParameterInstance  "/Middleware/WAS" "WAS 7.0" "${psi}" false

                         

                        13 Apr 2015 12:04:07,815 ERROR [MESSAGE] Command execution failed.  [/MESSAGE]

                        com.bladelogic.om.infra.mfw.util.BlException: Invalid qualified group name : WAS 7.0

                                at com.bladelogic.om.infra.model.group.GroupFactory.getGroupByQualifiedName(GroupFactory.java:371)

                                at com.bladelogic.om.infra.app.api.factory.GroupServiceImpl.getGroupByQualifiedName(GroupServiceImpl.java:182)

                                at com.bladelogic.om.infra.app.api.GroupServiceRequestHandlerImpl.getGroupByQualifiedName_8(GroupServiceRequestHandlerImpl.java:432)

                                at com.bladelogic.om.infra.app.api.GroupServiceRequestHandlerImpl.execute(GroupServiceRequestHandlerImpl.java:176)

                                at com.bladelogic.om.infra.app.api.manage.APIMethodInvocationProvider.executeRequest(APIMethodInvocationProvider.java:54)

                                at com.bladelogic.om.infra.app.api.manage.APIMethodInvocationProvider.invoke(APIMethodInvocationProvider.java:39)

                                at com.bladelogic.om.infra.app.service.routing.RoutingServiceImpl.invokeMethodLocally(RoutingServiceImpl.java:317)

                                at com.bladelogic.om.infra.app.service.routing.RoutingServiceImpl.invoke(RoutingServiceImpl.java:244)

                                at com.bladelogic.om.infra.app.api.manage.APIRequestManager.executeRequest(APIRequestManager.java:30)

                                at com.bladelogic.om.infra.message.app.frame.APIMessageFrame.service(APIMessageFrame.java:113)

                                at com.bladelogic.om.infra.mfw.net.ClientWorkerThread.processRequest(ClientWorkerThread.java:385)

                                at com.bladelogic.om.infra.mfw.net.ClientWorkerThread.processClientRequest(ClientWorkerThread.java:282)

                                at com.bladelogic.om.infra.mfw.net.ClientWorkerThread.handleClientRequest(ClientWorkerThread.java:182)

                                at com.bladelogic.om.infra.mfw.net.ClientWorkerThread.execute(ClientWorkerThread.java:101)

                                at com.bladelogic.om.infra.mfw.net.ClientWorkerThread.execute(ClientWorkerThread.java:27)

                                at com.bladelogic.om.infra.app.service.thread.BlBlockingThread.run(BlBlockingThread.java:95)

                        13 Apr 2015 12:05:48,398 INFO [MESSAGE] DBKey:STemplateModelKeyImpl:2000161-379-2038981 [/MESSAGE]

                        13 Apr 2015 12:05:48,411 ERROR [MESSAGE] Command execution failed.  [/MESSAGE]

                        com.bladelogic.om.infra.cli.factory.CommandNotFoundException: Could not find any instance of command "Template,findByDBKey" with expected number of arguments: 0

                                at com.bladelogic.om.infra.cli.factory.CommandTemplateInventory.getCommandTemplate(CommandTemplateInventory.java:202)

                                at com.bladelogic.om.infra.cli.factory.CommandFactory.getCommand(CommandFactory.java:69)

                                at com.bladelogic.om.infra.cli.CLIEngine.executeCommand(CLIEngine.java:109)

                                at com.bladelogic.om.infra.cli.CLIMain.executeCommand(CLIMain.java:954)

                                at com.bladelogic.om.infra.cli.CLIMain.executeCommand(CLIMain.java:937)

                                at com.bladelogic.om.infra.cli.CLIMain.executeEmbeddedShellCommand(CLIMain.java:746)

                        • 11. Re: Need help writing an NSH script to delete Instances in a component template
                          Bill Robinson

                          It looks like it’s having a problem w/ the dependency solving for the delete.  i’d open a support ticket for that w/ the command and the blcli trace there.