Example #1
0
def abdicate_marathon_leader(params="", marathon_name='marathon'):
    """
    Abdicates current leader. Waits until the HTTP service is stopped.

    params arg should include a "?" prefix.
    """
    leader_endpoint = get_marathon_endpoint('/v2/leader', marathon_name)
    result = http.delete(leader_endpoint + params)
    wait_until_fail(leader_endpoint)
    return result
Example #2
0
def remove_user(uid):
    """ Removes a user from the DCOS Enterprise.

        :param uid: user id
        :type uid: str
    """
    try:
        acl_url = urljoin(_acl_url(), 'users/{}'.format(uid))
        r = http.delete(acl_url)
        assert r.status_code == 204
    except DCOSHTTPException as e:
        # doesn't exist
        if e.response.status_code != 400:
            raise
Example #3
0
def remove_user_from_group(uid, gid):
    """ Removes a user from a group within DCOS Enterprise.

        :param uid: user id
        :type uid: str
        :param gid: group id
        :type gid: str
    """
    acl_url = urljoin(_acl_url(), 'groups/{}/users/{}'.format(gid, uid))
    try:
        r = http.delete(acl_url)
        assert r.status_code == 204
    except dcos.errors.DCOSBadRequest:
        pass
Example #4
0
def remove_group(id):
    """ Removes a group from the DCOS Enterprise.  The group is
        removed regardless of associated users.

        :param id: group id
        :type id: str
    """
    acl_url = urljoin(_acl_url(), 'groups/{}'.format(id))
    try:
        r = http.delete(acl_url)
        print(r.status_code)
    except DCOSHTTPException as e:
        if e.response.status_code != 400:
            raise
Example #5
0
def remove_user_permission(rid, uid, action='full'):
    """ Removes user permission on a given resource.

        :param uid: user id
        :type uid: str
        :param rid: resource ID
        :type rid: str
        :param action: read, write, update, delete or full
        :type action: str
    """
    rid = rid.replace('/', '%252F')

    try:
        acl_url = urljoin(_acl_url(),
                          'acls/{}/users/{}/{}'.format(rid, uid, action))
        r = http.delete(acl_url)
        assert r.status_code == 204
    except DCOSHTTPException as e:
        if e.response.status_code != 400:
            raise
Example #6
0
def delete_marathon_path(name, marathon_name='marathon'):
    """ Invokes HTTP DELETE for marathon url with name
        ex.  name='v2/leader'  http GET {dcos_url}/service/marathon/v2/leader
    """
    url = get_marathon_endpoint(name, marathon_name)
    return http.delete(url)
Example #7
0
def delete_marathon_path(name, marathon_name='marathon'):
    """ Invokes HTTP DELETE for marathon url with name
        ex.  name='v2/leader'  http GET {dcos_url}/service/marathon/v2/leader
    """
    url = get_marathon_endpoint(name, marathon_name)
    return http.delete(url)