7 Replies Latest reply on Jul 9, 2013 7:35 PM by Bill Robinson

    Maintaining SmartGroup Conditions

      Hi All,


      I'm working on a script that processes a bunch of Server Smart Groups to ensure that a specific condition is set.  I don't always know what the existing conditions are, so I can't just use "SmartServerGroup resetConditions" and simply calling "SmartServerGroup addCondition" will always add another instance of my condition, so I don't want to do that on a regular basis!


      I've been trying to find some method of querying the existing conditions to see if my required condition is already set, but this seems to be much harder than I expected!


      Can anyone suggest how this could be handled, please, either in straight NSH or in Jython?


      Many thanks,


        • 1. Re: Maintaining SmartGroup Conditions
          Bill Robinson

          there should be a way to load the group, get the conditions and then loop through each condition and dump the condition values and operators.

          • 2. Re: Maintaining SmartGroup Conditions

            My thoughts exactly!


            I can get a reference to conditions, but it's of a type that doesn't seem to work with any of the commands in the Conditions namespace.  In my head, this all seems really easy, but in practise, I just can't get it to work!


            There's always the option that I'm blind and have overlooked a really obvious command, but so far it's a no go.




            • 3. Re: Maintaining SmartGroup Conditions
              Jim Wilson

              Hi John,


              Did this get resolved?

              If so, please can you update the discussion thread with details so that is can be marked as answered.


              Thanks & Regards,

              Jim (Forum Manager/Facilitator)

              • 4. Re: Maintaining SmartGroup Conditions

                I would love to see this as a feature in a future release.


                SMARTGROUPS, based on a Server Property.


                We place 'customer names' as a custom property on every server.  So I need to create a SMARTGROUP with the filter on the specific customer name, and it will group the servers in that name. 


                Why cant I say 'SmartGroup' IS bsed on PROPERTY CUSTOMER. and it would create the group names based on the that specific property!


                I this this would fix the issue above as well.  we use a script to set the custom property, and then the smart group would automatically group them.


                At present, I'll get on of my engineers to dump all the customer propery values to a list and create the smart groups on a regular basis!



                • 5. Re: Maintaining SmartGroup Conditions

                  Hi Jim,


                  No - sadly I didn't get an answer to this so we're having to stick with workarounds, as with pretty much ALL of our Jython scripts!



                  • 6. Re: Maintaining SmartGroup Conditions
                    Jim Wilson

                    Hi Dean & John,


                    If you have not done so already, please consider:


                    - logging your ideas under the ideas tab in Communities:





                    - contacting support and getting Request For Enhancement (RFE) into the system.


                    Thanks & Regards,


                    • 7. Re: Maintaining SmartGroup Conditions
                      Bill Robinson


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

                      blcli_setoption serviceProfileName defaultProfile

                      blcli_setoption roleName BLAdmins




                      smartGroup="/Workspace/All Available Servers by OS/Linux - Red Hat/Red Hat ES 5.x"


                      blcli_execute SmartServerGroup groupNameToId "${smartGroup}"

                      blcli_storeenv smartGroupId

                      blcli_execute Group findById ${smartGroupId}

                      blcli_execute SmartGroup getSmartGroupCondition

                      blcli_execute Utility setTargetObject

                      blcli_execute NAryCondition getSubConditions

                      blcli_execute Utility setTargetObject

                      blcli_execute Utility storeTargetObject NAryConditions

                      blcli_execute Utility listLength

                      blcli_storeenv listLength


                      for i in {0..$((${listLength}-1))}


                              blcli_execute Utility setTargetObject NAryConditions

                              blcli_execute Utility listItemSelect ${i}

                              blcli_execute Utility setTargetObject

                              blcli_execute PropertyCondition getBlValue

                              blcli_storeenv blValue

                              blcli_execute PropertyCondition getOperator

                              blcli_storeenv operator

                              blcli_execute PropertyCondition getPropertyReference

                              blcli_storeenv propertyReference

                              blcli_execute PropertyCondition getInitialClass

                              blcli_execute Utility setTargetObject

                              blcli_execute PropertySetClass getFullyQualifiedPath

                              blcli_storeenv propertySetClass

                              echo "${propertySetClass} -- ${propertyReference} -- ${operator} -- ${blValue}"