Example #1
0
def enqueue(userId, name, inobj, qcount=0, forcefirst=False):
    global localconfig, headers
    if localconfig == None:
        localconfig = anchore_engine.configuration.localconfig.get_config()

    ret = False

    if type(userId) == tuple:
        userId, pw = userId
    else:
        pw = ""
    auth = (userId, pw)

    payload = inobj

    url_postfix = [
        name, "?qcount=" + str(qcount) + "&forcefirst=" + str(forcefirst)
    ]
    base_urls = anchore_engine.clients.common.get_service_endpoints(
        auth, 'simplequeue', api_post='queues')
    verify = localconfig['internal_ssl_verify']

    ret = http.anchy_aa(http.anchy_post,
                        base_urls,
                        url_postfix,
                        data=json.dumps(payload),
                        auth=auth,
                        headers=headers,
                        verify=verify)

    return (ret)
Example #2
0
def qlen(userId, name):
    global localconfig, headers
    if localconfig == None:
        localconfig = anchore_engine.configuration.localconfig.get_config()

    ret = 0

    if type(userId) == tuple:
        userId, pw = userId
    else:
        pw = ""
    auth = (userId, pw)

    url_postfix = [name, "qlen"]
    base_urls = anchore_engine.clients.common.get_service_endpoints(
        auth, 'simplequeue', api_post='queues')
    verify = localconfig['internal_ssl_verify']

    ret = http.anchy_aa(http.anchy_get,
                        base_urls,
                        url_postfix,
                        auth=auth,
                        headers=headers,
                        verify=verify)
    ret = int(ret)

    return (ret)
Example #3
0
def update_message_visibility_timeout(userId, name, receipt_handle,
                                      visibility_timeout):
    global localconfig, headers
    if localconfig == None:
        localconfig = anchore_engine.configuration.localconfig.get_config()

    ret = False

    if type(userId) == tuple:
        userId, pw = userId
    else:
        pw = ""
    auth = (userId, pw)

    payload = ''

    url_postfix = [
        name, "?receipt_handle={}&visibility_timeout={}".format(
            receipt_handle, visibility_timeout)
    ]
    base_urls = anchore_engine.clients.common.get_service_endpoints(
        auth, 'simplequeue', api_post='queues')
    verify = localconfig['internal_ssl_verify']

    ret = http.anchy_aa(http.anchy_put,
                        base_urls,
                        url_postfix,
                        data=json.dumps(payload),
                        auth=auth,
                        headers=headers,
                        verify=verify)

    return (ret)
Example #4
0
def refresh_lease(userId, lease_id, client_id, epoch, ttl):
    global localconfig, headers
    if localconfig == None:
        localconfig = anchore_engine.configuration.localconfig.get_config()

    ret = []

    if type(userId) == tuple:
        userId, pw = userId
    else:
        pw = ""
    auth = (userId, pw)

    url_postfix = [
        lease_id, 'ttl',
        '?client_id={}&ttl={}&epoch={}'.format(client_id, ttl, epoch)
    ]
    base_urls = anchore_engine.clients.common.get_service_endpoints(
        auth, 'simplequeue', api_post='leases')
    verify = localconfig['internal_ssl_verify']

    ret = http.anchy_aa(http.anchy_put,
                        base_urls,
                        url_postfix,
                        auth=auth,
                        headers=headers,
                        verify=verify)

    return (ret)
Example #5
0
def dequeue(userId, name, visibility_timeout=0, max_wait_seconds=0):
    global localconfig, headers
    if localconfig == None:
        localconfig = anchore_engine.configuration.localconfig.get_config()

    ret = {}

    if type(userId) == tuple:
        userId, pw = userId
    else:
        pw = ""
    auth = (userId, pw)

    url_postfix = [
        name, "?wait_max_seconds={}&visibility_timeout={}".format(
            max_wait_seconds, visibility_timeout)
    ]
    base_urls = anchore_engine.clients.common.get_service_endpoints(
        auth, 'simplequeue', api_post='queues')
    verify = localconfig['internal_ssl_verify']

    ret = http.anchy_aa(http.anchy_get,
                        base_urls,
                        url_postfix,
                        auth=auth,
                        headers=headers,
                        verify=verify)

    return (ret)