6 Replies Latest reply on Dec 27, 2010 9:19 AM by Greg Shively

    Boolean logic in blcli Condition createPropertyConditionCLI

      I have 2 separate conditions using this command working that I would like to combine to get a intersection of the 2 sets. But I can't figure out how to add the boolean logic to combine these 2 condtions.

        • 1. Re: Boolean logic in blcli Condition createPropertyConditionCLI
          Bill Robinson

          Is this in the context of a compliance rule or a smart group?

          • 2. Re: Boolean logic in blcli Condition createPropertyConditionCLI

            In the context of neither a compliance rule or a smart group, but

            instead of in the use of a one-time nsh process. I had a bunch of server

            objects that I needed to set a property that wasn't set during import -

            and the setting was for a bunch of servers that had the name that

            started with a prefix in their name. I got it to work by using one

            condition and looping over that set of machines, retrieving the other

            property and checking using shell syntax if the property needed to be

            set or not - but with the number of machine we had - it took quite a bit

            of time. I'm just trying to be a bit proactive and figure out the syntax

            prior to needing it again. A snippet of what I have is:

            • 3. Re: Boolean logic in blcli Condition createPropertyConditionCLI
              Bill Robinson

              I think your example got cut off.

              • 4. Re: Boolean logic in blcli Condition createPropertyConditionCLI

                Yeah it did. Here is the snippet


                blcli_execute           Condition createPropertyConditionCLI    \
                                        "Class://SystemObject/Server"           \
                                        NAME "starts with" "$prefix"
                blcli_storeenv          CONDITION

                blcli_execute           GenericObject getResultCountByPropertyCondition         \
                                        "$CONDITION"
                blcli_storeenv          COUNT

                blcli_execute           GenericObject getBlObjectsByPropertyCondition           \
                                        "$CONDITION" 0 $COUNT "Class://SystemObject/Server"     \
                                        "NAME" true
                blcli_storeenv          SERVER_LIST


                echo "$SERVER_LIST" | awk -F: '{print $2}' | while read server; do
                        if [ -n "$server" ]; then
                                blcli_execute Server printPropertyValue $server $property
                                blcli_storeenv PROP
                                if [ -z "$PROP" ];
                                    blcli_execute Server setPropertyValueByName \
                                                $server $property $value
                                fi
                        fi
                done

                Is there a better way to do this?  Greg Shively

                • 5. Re: Boolean logic in blcli Condition createPropertyConditionCLI
                  Bill Robinson

                  I'm confused - you are creating a condition object to generate a list of servers, then using that list setting a property on the servers?

                   

                  i would not do this w/ the condition object - those are meant to be used by a compliance rule or another object type, not just free-floating.  so while it works, i don't think it's the intended use of that object (on the fly evaluation).

                   

                  i'd do something like

                  Server listAllServers

                  parse the server list w/ your conditions and sed/awk/grep

                  run the property set.

                  • 6. Boolean logic in blcli Condition createPropertyConditionCLI

                    That is what I had actually did at the time - but it did take over 8 hours(I left after 8 hours) with the number of servers that we had in the environment. I was hoping to figure out to make it run more efficiently if I need to do something in the future. And since if I remember the "Condition createPropertConditionCLI" command documentation stated that there is the capability to have boolean expressions - but I couldn't figure out how to add more arguments to the command to add the boolean operators.