4 Replies Latest reply on Oct 12, 2018 10:21 AM by Justan Suss

    BLCLI: Moving a task using ExecutionTask name space and setgroupid command

    Justan Suss

      Hi,

       

      I'm trying to script up something that moves an execution task from current folder, to a new folder.

      Using a snippet from here

      Re: Creating an execution task in a folder via BLCLI

       

      My current Execution task location: [/BladeLogic/Jobs/Live/Patching/Compute/Windows]

      Execution task Name: Compute_ET_BAUwinPatchCat1_Grp12_DEV

      Target folder: [/BladeLogic/Jobs/Live/Patching/NOC/Generic_BAU/Patch_Grp12/DEV]

       

      =========================

       

      Here's what I have for my test script

       

      blcli_connect

      blcli_execute ExecutionTask getDBKeyByGroupAndName /Live/Patching/Compute/Windows Compute_ET_BAUwinPatchCat1_Grp12_DEV

      blcli_execute Utility storeTargetObject et

      blcli_execute ExecutionTask setGroupId /Live/Patching/CommandCentre/Generic_BAU/Patch_Grp12/DEV

      blcli_execute ExecutionTask update NAMED_OBJECT=et

       

      I'm getting error re: 4th line - setGroupID

      "Command execution failed. com.bladelogic.om.infra.cli.factory.CommandNotFoundException: Found command 'ExecutionTask.setGroupId' but with mismatching arguments."

      And the ET is still in the same location.

       

      Unfortunately looking up BLCLI ref / Execution Tasks, seems there's nothing for setgroupid.

      Can anyone spot my error?

       

      The NSH script / script job is type 2 and no targets (in case it matters)

       

      Message was edited by: Justan Suss

       

      Message was edited by: Justan Suss added details re: my requirements

        • 1. Re: BLCLI: Moving a task using ExecutionTask name space and setgroupid command
          Bill Robinson

          /Live/Patching/CommandCentre/Generic_BAU/Patch_Grp12/DEV

           

          is not a group id.  you need to get the group id w/ something like:

          JobGroup groupNameToId "/Live/Patching/CommandCentre/Generic_BAU/Patch_Grp12/DEV"

           

          • 2. Re: BLCLI: Moving a task using ExecutionTask name space and setgroupid command
            Justan Suss

            thanks, So, I'm now struggling with understanding the rest of what I've picked up from Re: Creating an execution task in a folder via BLCLI .

             

            So, Now that I have the groupNametoID for the target folder I want to move the task into.. I'm stuck at trying to use the groupID.

             

            I'm able to get the GroupID of the target folder and echo it successfully with this:

             

            blcli_execute JobGroup groupNameToId "/Live/Patching/CommandCentre/Generic_BAU/Patch_Grp12/DEV"

            blcli_storeenv target

            echo ${target}

             

            But when I try to use the ${target} with ExecutionTask.setGroupId command it fails.

             

            I've tried passing it the $target variable like this.

            blcli_execute ExecutionTask setGroupId ${target}

            ERROR:

            Error 11-Oct-2018 11:29:36 AM Command execution failed. java.lang.IllegalArgumentException: argument type mismatch

             

            and even hardcoding the GroupId like this

            blcli_execute ExecutionTask setGroupId 20102792010279

            OR

            blcli_execute ExecutionTask setGroupId '20102792010279'

             

             

            ERROR:

            Error 11-Oct-2018 11:32:35 AM Command execution failed. com.bladelogic.om.infra.cli.factory.CommandNotFoundException: Found command 'ExecutionTask.setGroupId' but with mismatching arguments.

             

            So, I guess the real problem now is this: with the BMC docs having no info for the setGroupId command in ExecutionTask namespace, what arguments does it accept?

             

            NOTE: In case it matters, while the snippet from the post in 2014 used UTILITY namespace and storeTargetObject I can't find any documentation on that so I'm using blcli_storeenv.

            • 3. Re: BLCLI: Moving a task using ExecutionTask name space and setgroupid command
              Bill Robinson

              the [set|store]TargetObject are one of the Unreleased blcli commands and documentation .  so is the setGroupId.

               

               

               

              # blcli_execute JobGroup groupNameToId "/Workspace"

              2000301

              # blcli_storeenv groupId

              # blcli_execute ExecutionTask getDBKeyByGroupAndName "/Workspace/NSH Script Jobs" "TestET"

              DBKey:SExecutionTaskModelKeyImpl:2000100-2157100

              # blcli_execute ExecutionTask setGroupId ${groupId}

              void

              # blcli_execute ExecutionTask update

              com.bladelogic.om.infra.model.executiontask.ExecutionTaskImpl@1336325f

              -> it's moved.

               

              or like this:

              # blcli_execute JobGroup groupNameToId "/Workspace/NSH Script Jobs"

              2002400

              # blcli_storeenv groupId

              # blcli_execute ExecutionTask getDBKeyByGroupAndName "/Workspace" "TestET"

              DBKey:SExecutionTaskModelKeyImpl:2000100-2157100

              # blcli_storeenv dbKey       

              # blcli_execute ExecutionTask findByDBKey ${dbKey}

              com.bladelogic.om.infra.model.executiontask.ExecutionTaskImpl@1336325f

              # blcli_execute Utility storeTargetObject et

              com.bladelogic.om.infra.model.executiontask.ExecutionTaskImpl@1336325f

              # blcli_execute ExecutionTask setGroupId ${groupId}

              void

              # blcli_execute ExecutionTask update NAMED_OBJECT=et

              com.bladelogic.om.infra.model.executiontask.ExecutionTaskImpl@1336325f

              • 4. Re: BLCLI: Moving a task using ExecutionTask name space and setgroupid command
                Justan Suss

                Thanks Bill,

                 

                To get it to work for me I had to do a mash-up your two examples. It seems to the 'update' command for Execution Tasks namespace needs you to first 'load' the task object and then store it in utility' namespace. Based on what works here, that's what I think is happening. Anyway, even if I'm completely out to lunch, it works.

                 

                In case anyone is interested, here's what i got to work for me. No parameterization applied yet.

                 

                blcli_connect

                # Get 'groupId' of the folder the task will be moved TO and store as variable 'groupId'

                blcli_execute JobGroup groupNameToId "/Live/Patching/CommandCentre/Generic_BAU/Patch_Grp12/DEV"

                blcli_storeenv groupId

                 

                # Get the Tasks DBKey and store as variable 'etkey'

                blcli_execute ExecutionTask getDBKeyByGroupAndName "/Live/Patching/Compute/Windows" "Compute_ET_BAUwinPatchCat1_Grp12_DEV"

                blcli_storeenv etkey

                 

                #Use 'etkey'  to load the task as a stored object in utility namespace called 'et'

                blcli_execute ExecutionTask findByDBKey ${etkey}

                blcli_execute Utility storeTargetObject et

                 

                # define use 'groupId' command to define target folder the task should be moved to.

                blcli_execute ExecutionTask setGroupId ${groupId}

                 

                # commit the change to the Execution task

                blcli_execute ExecutionTask update NAMED_OBJECT=et