1 Reply Latest reply on Jul 28, 2017 3:51 PM by Stephane Forand

    can we use blcli SmartServerGroup addCondition to add grouping condition (parenthesis)

      Share This:

      Hi there,

       

      Is there a way to create SmartServer group, via blcli that would allow us to use rule grouping, such as parenthesis ? this is possible inside the UI, but how to with blcli ?

      I Would need to create servers smart group like this one below with blcli .

       

      Thanks

      ServerSmartGroup.jpg

       

      Base on documentation of blcli, there is no such example for that. not even a word. So maybe I feel lucky, by asking here. who knows !

      Thanks again

        • 1. Re: can we use blcli SmartServerGroup addCondition to add grouping condition (parenthesis)

          HI there again.

          We have manage an workaround. So instead of creating the serverSmartGroup from scratch, we have created an ServerSmartGroupTemplate, somewhere inside the structure, and we then used blcli to Export that serversmartgroup & modify the mapping.xml & blexport.xml, to reflect new folder destination and new Serversmartgroup Name...  Then we used a blcli to import it again into the new location with new name.  find below some little peace of the code example.

           

           

          ####  Function EXAMPLE

          #########################

          create_servers_groups() {

          CUSTOMER=$1
          ServerGroups="$2"
          CURRENT=""

          # Loop through file, for each action
          cat $ServerGroups | while read -r ACTION PARENT GROUPNAME CONTENT;do

          GROUPNAME=`eval echo "$GROUPNAME"`
          PARENT=`eval echo "$PARENT"`
           
          case "$ACTION" in
              ImportSmartServerGroup_from_Export)
                  echo "INFO: Creating Server Smart Group from(copying) Parent ServersmartGroup"
                  echo "Exporting_Parent ServerSmartGroup. . ."
                  TMP_FILE="/tmp/export_smg.$$"
            
                  Dest_Name=`eval echo "$CONTENT"`
            
                  blcli_execute SmartServerGroup groupNameToDBKey $PARENT
                  blcli_storeenv smg_key
                  blcli_execute ImportExport exportObject 5007 $smg_key $TMP_FILE
            
                  smartgroupname=$(basename $PARENT)
                  cat $TMP_FILE/mapping.xml | sed 's/'$smartgroupname'/'$Dest_Name'/g' > $TMP_FILE/mapping-new.xml
                  cat $TMP_FILE/blexport.xml | sed 's/'$smartgroupname'/'$Dest_Name'/g' > $TMP_FILE/blexport-new.xml
            
                  mv $TMP_FILE/blexport-new.xml $TMP_FILE/blexport.xml
                  cat $TMP_FILE/mapping-new.xml | sed 's#/Published/Customers/xxxxxx agent status#/'$GROUPNAME'#g' > $TMP_FILE/mapping.xml
             
                  echo "Importing ServerSmartGroup. . ."

                  blcli_execute ImportExport importObject "$TMP_FILE" "$TMP_FILE/mapping.xml"
              ;;
            esac
          done
          }

           

          Good luck !