7 Replies Latest reply on Mar 7, 2012 1:10 PM by Lou Troise

    Get Template Part Excludes

      Hello,

       

      I'm trying to get the list of exclusions for each part in a template, via blcli.  I'm looping through each part, and using TemplatePart getExcludes.

       

      But the data returned looks like a list of lists...?  Two brackets?

      [[com.bladelogic.model.template.ExcludeImpl@1eb8cd, com.bladelogic.model.template.ExcludeImpl@1eb8cd]]

       

      And even it that's OK and expected, I can't seem to pass the right thing to Exclude getNames.  If I listPrint the above, or chop it up into elements in a for loop, I get "Object is not an instance of declaring class".

      If I try to pass it as a stored variable argument to the command (again be it a list or an element of the list), I get "mismatched arguments".

       

      It's not clear to me from the API what the argument type or number of arguments should be for Exclude getNames.  Can anyone help me here?

       

       

      Thanks as always.

       

       

       

       

        • 1. Get Template Part Excludes

          can you paste the exact sequence of commands you are calling ?

          It can be very easy using Jython, handling list of java objects and calling  the methods on each.

          • 2. Get Template Part Excludes

            Hello,

             

            Firstly, I can't use BLJython for this procedure at the current time, at client's request.  I have to use the blcli performance commands.

             

            Here's the sequence of calls (I've run the following on Templates with one or more parts and can verify that the list of parts is accurate....just can't get those excludes):

             

            *********Method 1************

            blcli_execute Template getDBKeyByGroupAndName "/GROUP" "NAME"

            blcli_execute Template getParts

            blcli_execute Utility setTargetObject

            blcli_storeenv TEMPPARTS

            for TEMPPART in $TEMPPARTS
            do

            blcli_execute TemplatePart getExcludes

            blcli_execute Utility setTargetObject

            blcli_execute Utility listPrint

            blcli_storeenv EXCLUDELIST

            blcli_execute Exclude getName "${EXCLUDELIST}"  <------This gives me a "mismatched arguments" error

            done

            *********************************


            ************Method 2************
            blcli_execute Template getDBKeyByGroupAndName "/GROUP" "NAME"

            blcli_execute Template getParts

            blcli_execute Utility setTargetObject

            blcli_storeenv TEMPPARTS

            for TEMPPART in $TEMPPARTS
            do

            blcli_execute TemplatePart getExcludes

            blcli_execute Utility setTargetObject

            blcli_execute Utility listPrint

            blcli_execute Utility setTargetObject

            blcli_execute Exclude getName  <------This give "object not instance of class" error

            done
            *****************************

             

             

             

             

             

            I have also tried another method where I store the listPrint, then pass each element to the Exclude getName command using a FOR loop.  That gives me "mismatched arguments" error.

             

            • 3. Get Template Part Excludes

              The getExcludes is returning a list of list of excludes which is making it difficult to use Utility setTargetObject and call the Exlcude getName thing.

               

              I dont think the for loops are also not working because of the list of list return value, its only going ahead beacuse of setTargetObject call.

               

              Usually I would do somethng like

              blcli_execute Template getDBKeyByGroupAndName  "/bla" "bla"

              blcli_execute Template getParts

              blcli_execute Utility setTargetObject

              blcli_execute TemplatePart getExcludes

               

              -> Here I will again to a Utility setTargetObject

              and then call blcli_execute Exclude getName

              This should call getName on every object in the list returned by previous call

              But this doesnt seem to working with the list of list object .

              We have some limitations when it comes to use of lists in the blcli .

              Really cant see a way to do this ,

              I will try to test this and getback to you

              • 4. Get Template Part Excludes

                Hi,

                 

                Yeah I've tried the order of commands you list and also get an error. 

                 

                Ignoring the Exclude getName method for the moment, any other suggestion on how I could get a dump of a Template's parts, includes, & excludes via blcli?  We've got a pretty good need for this functionality. 

                 

                 

                Thanks.

                • 5. Get Template Part Excludes
                  Bill Robinson

                  blcli_execute Template getDBKeyByGroupAndName "/Workspace" "test"
                  blcli_execute Template getParts
                  blcli_execute Utility setTargetObject
                  blcli_execute Utility storeTargetObject templateParts
                  blcli_execute Utility listLength
                  blcli_storeenv listLength
                  count=0
                  while [ ${count} -lt ${listLength} ]
                  do
                          blcli_execute Utility setTargetObject templateParts
                          blcli_execute Utility listItemSelect ${count}
                          blcli_execute Utility setTargetObject
                          blcli_execute Utility storeTargetObject templatePart
                          blcli_execute TemplatePart getEscapedPath
                          blcli_storeenv partName
                          echo "Template Part: ${partName}" >> $$.out

                          for type in Include Exclude
                                  do
                                  blcli_execute Utility setTargetObject templatePart
                                  blcli_execute TemplatePart get${type}s
                                  blcli_execute Utility setTargetObject
                                  blcli_execute Utility storeTargetObject partIncs
                                  blcli_execute Utility listLength
                                  blcli_storeenv incLength
                                  count1=0
                                  while [ ${count1} -lt ${incLength} ]
                                          do
                                          blcli_execute Utility setTargetObject partIncs
                                          blcli_execute Utility listItemSelect ${count1}
                                          blcli_execute Utility setTargetObject
                                          blcli_execute ${type} getName
                                          blcli_storeenv partInc
                                          echo "${type}: ${partInc}" >> $$.out
                                          count1=$((${count1}+1))
                                  done
                          done
                          count=$((${count}+1))
                  done

                  • 6. Get Template Part Excludes

                    Wow Bill!!!

                     

                    Will test and let you know.  Thank you for your info.

                    • 7. Get Template Part Excludes

                      Thank you, Bill.  Your code works exactly as needed.