5 Replies Latest reply on Jan 25, 2016 7:27 AM by Santhosh Kurimilla

    NSH-Check if Server Group is empty

    James Donohue



      Is there a blcli command that checks a Static Server Group (or any Group) to determine if it contains any Objects in it? I have a Static Server Group that will get populated with Servers everyday and I'm running another job against them and then removing the Servers from the Group. There may some days that the group will not get populated. I get an ERROR when I run the code below and am trying to figure out a way to check if the Group is empty first, and if it, just Exit the script gracefully.



      blcli_execute ServerGroup groupNameToId "/WorkAreas/Eng_WinSvr_Infra/Users/jimmyd/Testing/G_Servers-ACL_Push"

      blcli_storeenv groupId

      blcli_execute Server findAllHeadersByServerGroup ${groupId} false

      blcli_execute SDeviceHeader getDBKey

      blcli_execute Utility setTargetObject

      blcli_execute Utility objectToList

      blcli_execute Utility setTargetObject

      blcli_execute Utility storeTargetObject serverKeys

      blcli_execute Group findByTypeAndId 5003 ${groupId}

      blcli_execute Group getSBLGroupKey

      blcli_storeenv groupKey

      blcli_execute ServerGroup bulkRemoveServersFromGroup ${groupKey} NAMED_OBJECT=serverKeys > /dev/null