def profile_remove(profile_name, nocheck): """ Remove a profile as long as it does not contain any endpoints. Allow user to explicitly remove the profile if desired. :param profile_name: The name of the profile to remove. :param nocheck: Flag saying to remove profile regardless of endpoints. :return: None. """ # Check if the profile exists. if client.profile_exists(profile_name): rm_profile = False # Check that the nocheck flag was used if nocheck: rm_profile = True else: # Check if the the profile has endpoints associated with it members = client.get_profile_members(profile_name) if not members: rm_profile = True # Remove the profile if criteria was met if rm_profile: client.remove_profile(profile_name) print "Deleted profile %s" % profile_name else: # Members must exist if this branch is reached print "Cannot remove profile - profile in use by endpoint(s).\n" + \ "Use the '--no-check' flag to remove the profile anyway." else: print "Profile %s not found." % profile_name
def profile_remove(profile_name, nocheck): """ Remove a profile as long as it does not contain any endpoints. Allow user to explicitly remove the profile if desired. :param profile_name: The name of the profile to remove. :param nocheck: Flag saying to remove profile regardless of endpoints. :return: None. """ # Check if the profile exists. if client.profile_exists(profile_name): rm_profile = False # Check that the nocheck flag was used if nocheck: rm_profile = True else: # Check if the the profile has endpoints associated with it members = client.get_profile_members(profile_name) if not members: rm_profile = True # Remove the profile if criteria was met if rm_profile: client.remove_profile(profile_name) print "Deleted profile %s" % profile_name else: # Members must exist if this branch is reached print "Cannot remove profile - profile in use by endpoint(s).\n" + \ "Use the '--no-check' flag to remove the profile anyway." else: print "Profile %s not found." % profile_name