11 Replies Latest reply on Jan 17, 2011 10:11 AM by R V

    CLI to print Smartgroup Conditions

    Jim Campbell

      Seems an extremely simple task but I can't figure out the arguments to use to print out the Condition(s) for a smartgroup, and in particular a Patch Catalog Smart group for windows patching. I've tried:

       

      blcli_execute Group getGroupByQualifiedName 5017 "/Path/PatchCatalogSmartGroup"

      blcli_execute SmartGroup getSmartGroupCondition

       

      The cli function that seems like it should work is Condition getConditionString but it requires an input of:

       

      Variable NameVariable TypeDescription
      locale java.util.Locale no description
      prettyMode Boolean no description

       

      It seems like its storing the Smartgroup in memory rather than the condition, but even still I can't find the right syntax for the locale.

        • 1. Re: CLI to print Smartgroup Conditions
          Bill Robinson

          There’s a smartgroup getsmartgroupcondition but I can’t figure out how create a locale object.

          • 2. Re: CLI to print Smartgroup Conditions
            Jim Campbell

            Yah thats the one i was trying to use after getting the smartgroup with Group getGroupByQualifiedName.  I'm not sure how using the 'undocumented' blcli functions in succession works.  It seemed like when I used Group getGroupByQualifiedName and then SmartGroup getSmartGroupCondition that it was working (echoed a value that looked like a Condition), if i did something like Condition getDBKey it looked like it was returning the DBKey of the group, not the Condition e.g.

             

            blcli_execute Group getGroupByQualifiedName 5017 "/Path/PatchCatalogSmartGroup"

            blcli_execute SmartGroup getSmartGroupCondition

            blcli_execute Condition getDBKey

             

            is echoing:

             

            DBKey:SBLGroupModelKeyImpl:2002175-4295348

            • 3. Re: CLI to print Smartgroup Conditions
              Bill Robinson

              You want something like getConditionString I think (or a similarly named command) – when you do a ‘get’ that loads the object into memory.  Commands that don’t take input act on the object in memory – some that do take input also act on what’s in memory.

              • 4. Re: CLI to print Smartgroup Conditions
                R V

                To get some Locale-object try the following (assumption: you have a SystemPackageType named "SLES 10" - which is available as default, at least in BL8.0)

                 

                blcli_execute SystemPackage getLocaleIdByName "SLES 10" "de_DE"

                blcli_storeenv localeId

                blcli_execute SystemPackage findLocaleById $localeId

                blcli_execute Utility setTargetObject

                blcli_execute Locale getDisplayName

                • 5. Re: CLI to print Smartgroup Conditions
                  Jim Campbell

                  I'll try that, looks promising.

                   

                  Is Utility setTargetObject the way to change the 'default' target when using the 'undocumented' commands in succession?

                  • 6. Re: CLI to print Smartgroup Conditions
                    Bill Robinson

                    try something like:

                    blcli_execute SystemPackage getLocaleIdByName "SLES 10" "de_DE"

                    blcli_storeenv localeId

                    blcli_execute SystemPackage findLocaleById $localeId

                    blcli_execute Utility storeTargetObject myLocale

                    blcli_execute Group getGroupByQualifiedName 5017 "/Path/PatchCatalogSmartGroup"

                    blcli_execute SmartGroup getSmartGroupCondition NAMED_OBJECT=myLocale true

                    • 7. Re: CLI to print Smartgroup Conditions
                      R V

                      Sometimes "Utility.setTargetObject" (or "Utility.storeTargetObject" - thanks Bill, never saw this one before, presumably because I was so happy using SETtargetobject ) is needed but not always. Unfortunately I haven't figured out WHEN exactly it has to be used. But it probably has something to do with a "context".

                      • 8. Re: CLI to print Smartgroup Conditions
                        Bill Robinson

                        Store is good to save the object (not a dbkey) for when you need to reference the object in a later command like this case.  There are other cases I have used this and if you dig through the unreleased docs/commands the storeTargetObject is the same as saving a result in a command I think.

                        • 9. Re: CLI to print Smartgroup Conditions
                          Jim Campbell

                          Still getting mismatching arguments with all of this (from the getConditionString part, not the previous commands).  I was thinking this looked most likely:

                           

                          blcli_execute SystemPackage getLocaleIdByName "SLES 10" "de_DE"

                          blcli_storeenv localeId

                          blcli_execute SystemPackage findLocaleById $localeId

                          blcli_execute Utility storeTargetObject myLocale

                          blcli_execute Group getGroupByQualifiedName 5017 "/Path/PatchCatalogSmartGroup"

                          blcli_execute SmartGroup getSmartGroupCondition

                          blcli_execute Utility setTargetObject

                          blcli_execute Condition getConditionString NAMED_OBJECT=myLocale true

                           

                          I tried it the way you had it as well and still mismatches.  I'm not sure how the 'NAMED_OBJECT=' bit works either.

                          • 10. Re: CLI to print Smartgroup Conditions
                            Jim Campbell

                            So if i do the above (up to the point of the Condition getConditionString command) its definitely getting the right object.  For instance if i do:

                             

                            blcli_execute SystemPackage getLocaleIdByName "SLES 10" "de_DE"

                            blcli_storeenv localeId

                            blcli_execute SystemPackage findLocaleById $localeId

                            blcli_execute Locale getDisplayName

                            blcli_storeenv myLocaleString

                            blcli_execute Utility storeTargetObject myLocale

                            blcli_execute Group getGroupByQualifiedName 5017 "/Path/PatchCatalogSmartGroup"

                            blcli_execute SmartGroup getSmartGroupCondition

                            blcli_execute Utility setTargetObject

                            blcli_execute Condition getType

                             

                            It returns 5313 which is the object type for PROPERTY_CONDITION

                             

                            I've tried to use Condition getConditionString with:

                             

                            Condition getConditionString myLocaleString true

                            Condition getConditionString NAMED_OBJECT=myLocaleString true

                            Condition getConditionString myLocale true

                            Condition getConditionString NAMED_OBJECT=myLocale true

                             

                            So far everything gives:

                             

                            Command execution failed. com.bladelogic.cli.factory.CommandNotFoundException: Found command 'PropertyCondition.getConditionString' but with mismatching arguments.

                             

                            The localestring comes up as German (Germany) so that part is apparently working as well - its just a matter of trying to figure out how to pass the object required for the locale into the function.

                            1 of 1 people found this helpful
                            • 11. Re: CLI to print Smartgroup Conditions
                              R V

                              It tunrs out that "java.util.Locale" (which you need) is very different from "com.bladelogic.model.provision.systempackage.Locale" (which you get with my "SystemPackage-hint"; sorry for misleading you...).

                               

                              The only blcli-method returning a "java.util.Locale" is "JobSchedule.getLocale". Maybe you have better luck using this one. But then again you presumably have to have some JobSchedule.object.

                               

                              Another way to get some "java.util.Locale"-object may be using Jython. But using Jython I have no experience at all.