Exemplo n.º 1
0
 def check_groups(remote_group_set):
     """
     Function to remove the groups that are on the local node and not in the remote node
     """
     local_groups = {x['name'] for x in get_all_groups(limit=None)['items']}
     for removed_group in local_groups - remote_group_set:
         try:
             remove_group(removed_group)
             logging.info("Group {0} removed successfully".format(removed_group))
         except Exception as e:
             logging.error("Error deleting group {0}: {1}".format(removed_group, str(e)))
Exemplo n.º 2
0
def remove_group(group_id, quiet=False):
    ans = 'n'
    if not quiet:
         ans = get_stdin("Do you want to remove the '{0}' group? [y/N]: ".format(group_id))
    else:
        ans = 'y'

    if ans.lower() == 'y':
        data = group.remove_group(group_id)
        msg = data['msg']
        if not data['affected_agents']:
            msg += "\nNo affected agents."
        else:
            msg += "\nAffected agents: {0}.".format(', '.join(data['affected_agents']))
    else:
        msg = "Cancelled."

    print(msg)