6 Replies Latest reply on Jun 22, 2020 3:43 PM by David Dell

    Remove target server from execution task

    David Dell
      Share This:

      Hi,

       

      Is there a simple way to remove a single target server from an execution task using another job?  Basically, the task hasn't been created yet, and I won't be online to remove the target using the console.  The job name will be [/BladeLogic/Jobs/Windows/Tasks/Job_06_29_2020] and the server to remove from the list is DEV02.

        • 1. Re: Remove target server from execution task
          Bill Robinson

          i don't see any blcli that looks like it will do it... if the task hasn't been created, why would it get created w/ the target ?

          • 2. Re: Remove target server from execution task
            David Dell

            I honestly didn't want to get into the main script that creates these tasks.  It creates many tasks based on an input file, and I have no control over that file.  It would be really bad to break that script.

             

            This wouldn't help all the time, but sometimes it only has one target server.  Is there a way to check if it's the only target and if so delete the whole task?

            • 3. Re: Remove target server from execution task
              Bill Robinson

              ExecutionTask.listExecutionTaskTargets looks like it will list the targets out.

              • 4. Re: Remove target server from execution task
                Matthew Ragland

                This can be used to remove a single target from an execution task using blcli:

                # ESTABLISH VARIABLES
                ETGROUP='/PATH/TO/EXECUTION/TASK'
                ETNAME='ET NAME'
                REMOVESERVER='server1.domain'
                
                # OBTAIN EXECUTION TASK KEY
                blcli_execute ExecutionTask getDBKeyByGroupAndName "${ETGROUP}" "${ETNAME}"
                blcli_storelocal ETKEY
                
                # LIST EXECUTION TASK TARGETS
                blcli_execute ExecutionTask listExecutionTaskTargets "${ETKEY}"
                
                # INDEX LIST TO DETERMINE WHICH DEVICE # TO REMOVE FROM INDEX
                blcli_execute Utility indexList
                blcli_storelocal DEVICELIST
                
                # GREP OUT REMOVESERVER AND PARSE THE REMAINING INDEXES INTO A COMMA DELIMITED LIST
                INDEXES=$(echo "${DEVICELIST}" | grep -vE "^$|${REMOVESERVER}" | cut -d ')' -f 1 | tr '\n' , | sed 's/,$//')
                
                # STORE EXECUTION TASK AS OBJECT
                blcli_execute ExecutionTask findByGroupAndName "${ETGROUP}" "${ETNAME}"
                blcli_execute Utility storeTargetObject ET
                
                # GET EXECUTIONTASK DEVICE LIST
                blcli_execute ExecutionTask getSExecutionTaskDeviceList
                blcli_execute Utility setTargetObject
                
                # INDEX LIST
                blcli_execute Utility indexList
                
                # SELECT ALL DEVICES EXCEPT FOR REMOVESERVER (USING INDEXES VARIABLE FROM EARLIER)
                blcli_execute Utility listSelect "${INDEXES}"
                blcli_execute Utility setTargetObject
                blcli_execute Utility storeTargetObject UPDATEDLIST
                
                # SET TARGET OBJECT AS EXECUTION TASK
                blcli_execute Utility setTargetObject ET
                
                # UPDATE THE DEVICE LIST WITH THE UPDATEDLIST
                blcli_execute ExecutionTask setSExecutionTaskDeviceList NAMED_OBJECT=UPDATEDLIST
                
                # UPDATE/SAVE CHANGES TO EXECUTION TASK
                blcli_execute ExecutionTask update
                
                1 of 1 people found this helpful
                • 5. Re: Remove target server from execution task
                  Bill Robinson

                  I think you could also do the list, take out the target you don't want, then use ExcutionTask clearTargetServers, then addTargetServers

                  1 of 1 people found this helpful
                  • 6. Re: Remove target server from execution task
                    David Dell

                    Awesome, thanks Bill and Matthew for your help!