7 Replies Latest reply on Aug 10, 2016 9:56 AM by Sorin Gancea

    How to reset condition for a Patch Smart Group

    Sorin Gancea

      I'm trying to find a way to reset condition for a Patch Smart Group, in BSA 8.8.

      I saw that a released command for a SmartDepotGroup exists (SmartDepotGroup resetConditions), also a unreleased command for SmartGroup - resetConditions exists as well.

      I can't get the first parameter of this unreleased command -

       

      Variable TypeDescription
      sGroup com.bladelogic.om.infra.model.group.smartgroup.SmartGroup no description

      into a proper form.

      I tried to get it via command - blcli_execute SmartGroup findSmartGroupByDBKey <SmartGroup-DBKey>.

       

      If I'm using the returned string from previous command and than I'm executing resetConditions I'm getting an error:

       

      Command execution failed. com.bladelogic.om.infra.cli.factory.CommandNotFoundException: Found command 'SmartGroup.resetConditions' but with mismatching arguments. : java.lang.IllegalArgumentException: Input 'com.bladelogic.om.infra.model.group.smartgroup.SmartGroupImpl@1e288b3' cannot be converted to expected type : interface com.bladelogic.om.infra.model.group.smartgroup.SmartGroup

       

      The output of SmartGroup findSmartGroupByDBKey command says that -> "Return type : com.bladelogic.om.infra.model.group.smartgroup.SmartGroup".

       

      Do you have a hint here?

       

      Thanks,

      Sorin

        • 1. Re: How to reset condition for a Patch Smart Group
          Jim Wilson

          Have you tried the syntax per this page?

          https://docs.bmc.com/docs/display/public/bsacli88/SmartDepotGroup+-+resetConditions

           

          Please show us the code and results

          • 2. Re: How to reset condition for a Patch Smart Group
            Sorin Gancea

            I tried it:

            blcli_execute SmartDepotGroup resetConditions /Patching/Catalogs/SUSE12SP1/Q3-2015  "Class://SystemObject/Depot Object/RPM" "RPM_BUILD_DATE*" "before" "02/23/2009 00:00:00"

            and it ended with an error:

            Command execution failed. com.bladelogic.om.infra.mfw.util.NotFoundException: no child of name RPM found

            Regards,

            Sorin

            • 3. Re: How to reset condition for a Patch Smart Group
              Jim Wilson

              My bad - sorry.  There is no released blcli for Patch Catalog Smart Groups

               

              It may be possible to use unreleased blcli  to achieve your goal - perhaps you can check that out.

               

              I found some original work by user Yanick Girouard that may be of use as a starting point:

               

              Example for a Windows patch catalog smartgroup (change IDs where apprppriate for other types of catalogs and smartgroups):

               

              #AIX_CATALOG_GROUP = 7037

              #OTHER_LINUX_CATALOG_GROUP = 7035

              #RED_HAT_CATALOG_GROUP = 5020

              #SMART_AIX_PATCH_CATALOG_GROUP = 5046

              #SMART_OTHER_LINUX_PATCH_CATALOG_GROUP = 5024

              #SMART_REDHAT_PATCH_CATALOG_GROUP = 5018

              #SMART_SOLARIS_PATCH_CATALOG_GROUP = 5019

              #SMART_WINDOWS_PATCH_CATALOG_GROUP = 5017

              #SOLARIS_CATALOG_GROUP = 5021

              #WINDOWS_CATALOG_GROUP = 5022

               

              CATALOG=/path/to/patch/catalog/name

              GROUP_NAME=name_of_smartgroup

               

              blcli_execute Group getGroupByQualifiedName 5022 "$CATALOG" > /dev/null

              if [ $? -ne 0 ]; then

                  echo "[FAILED]\n"

                  exit 1

              fi

              blcli_execute Utility storeTargetObject pgObject > /dev/null

              if [ $? -ne 0 ]; then

                  echo "[FAILED]\n"

                  exit 1

              fi

              blcli_execute Condition createPropertyCondition <YOUR CONDITION HERE - SEE BLCLI DOC FOR SYNTAX> > /dev/null

              if [ $? -ne 0 ]; then

                  echo "[FAILED]\n"

                  exit 1

              fi

              blcli_execute Utility storeTargetObject conditionObject > /dev/null

              if [ $? -ne 0 ]; then

                  echo "[FAILED]\n"

                  exit 1

              fi

              blcli_execute SmartGroup createSmartGroupWithTypeId 5017 "$GROUP_NAME" "" NAMED_OBJECT=pgObject NAMED_OBJECT=conditionObject > /dev/null

              if [ $? -ne 0 ]; then

                  echo "[FAILED]\n"

                  exit 1

              fi

              blcli_execute Utility storeTargetObject groupObject > /dev/null

              if [ $? -ne 0 ]; then

                  echo "[FAILED]\n"

                  exit 1

              fi

              blcli_execute SmartGroup save NAMED_OBJECT=groupObject > /dev/null

              if [ $? -ne 0 ]; then

                  echo "[FAILED]\n"

                  exit 1

              else

                  echo "[SUCCESS]\n"

              fi

              • 4. Re: How to reset condition for a Patch Smart Group
                Sorin Gancea

                Hello Jim,

                I checked in communities before I posted my discussion. I also explained what I did and what went wrong.

                 

                I'm working with unreleased commands and my customer wants to reset/change the condition for existing patch smart groups, not to create them again, as it's done in that previous code you've posted.

                 

                A patch smart group condition change can be done/simulate with a deletion of the existing one and recreation of it from scratch, with the same name and an amended condition. I couldn't find a way to delete a patch smart group via cli.

                 

                Maybe this option can be followed, as well, but I do not know how.

                 

                Regards,

                Sorin

                • 5. Re: How to reset condition for a Patch Smart Group
                  Yanick Girouard

                  Try this:

                   

                  blcli_setjvmoption -Dcom.bladelogic.cli.execute.quietmode.enabled=true

                   

                  #AIX_CATALOG_GROUP = 7037

                  #OTHER_LINUX_CATALOG_GROUP = 7035

                  #RED_HAT_CATALOG_GROUP = 5020

                  #SMART_AIX_PATCH_CATALOG_GROUP = 5046

                  #SMART_OTHER_LINUX_PATCH_CATALOG_GROUP = 5024

                  #SMART_REDHAT_PATCH_CATALOG_GROUP = 5018

                  #SMART_SOLARIS_PATCH_CATALOG_GROUP = 5019

                  #SMART_WINDOWS_PATCH_CATALOG_GROUP = 5017

                  #SOLARIS_CATALOG_GROUP = 5021

                  #WINDOWS_CATALOG_GROUP = 5022

                  CATALOG=/path/to/patch/catalog/name

                  GROUP_NAME=name_of_smartgroup

                   

                  blcli_execute Group getGroupByQualifiedName 5022 "$CATALOG"

                  echo

                  blcli_execute Utility storeTargetObject sgObject

                  echo

                  blcli_execute Condition createPropertyCondition "<CONDITION TO RESET TO HERE - SEE BLCLI DOC FOR SYNTAX>"

                  echo

                  blcli_execute Utility storeTargetObject conditionObject

                  echo

                  blcli_execute SmartGroup resetConditions NAMED_OBJECT=sgObject NAMED_OBJECT=conditionObject

                  echo

                  blcli_execute SmartGroup save NAMED_OBJECT=sgObject

                  echo

                  1 of 1 people found this helpful
                  • 6. Re: How to reset condition for a Patch Smart Group
                    Jim Wilson

                    Thanks Yanick - that works for me

                     

                    For Sorin

                     

                    blcli_execute Group getGroupByQualifiedName 5024 "/Patching/Catalogs/SUSE12SP1/Q3-2015"

                    echo

                    blcli_execute Utility storeTargetObject sgObject

                    echo

                    blcli_execute Condition createPropertyCondition "Class://SystemObject/Depot Object/Software/RPM" "RPM_BUILD_DATE*" "before" "2009/02/23 00:00:00"

                    echo

                    blcli_execute Utility storeTargetObject conditionObject

                    echo

                    blcli_execute SmartGroup resetConditions NAMED_OBJECT=sgObject NAMED_OBJECT=conditionObject

                    echo

                    blcli_execute SmartGroup save NAMED_OBJECT=sgObject

                    echo

                    • 7. Re: How to reset condition for a Patch Smart Group
                      Sorin Gancea

                      Thank you guys,

                      all is green now

                      Sorin