def managedb_get(dbid):
    try:
        if managedbapi_status == 'enabled':
            sess, err, code = api_utils.create_adminsession(
                clusterurl, adminuser, adminpwd)
            if err != None:
                return make_response(jsonify(err), code)
            else:
                mresponse, mcode = managedbapi.process_get(request, sess, dbid)
                api_utils.close_cluster_session(sess, clusterurl)
                if mresponse and mcode is not None:
                    return make_response(jsonify(mresponse), int(mcode))
                if mresponse and mcode is None:
                    return mresponse
        else:
            return make_response(jsonify({'error': 'API Disabled '}), 503)
    except Exception as e:
        return make_response(
            jsonify({'error': 'API Processing Error (' + str(e) + ')'}), 500)
def perfagent_post():
    try:
        if perfagentapi_status == 'enabled':
            sess, err, code = api_utils.create_adminsession(
                clusterurl, adminuser, adminpwd)
            if err != None:
                return make_response(jsonify(err), code)
            else:
                if api_utils.create_db(sess, clusterurl, 'apiperfagentqueue',
                                       adminuser):
                    mresponse, mcode = perfagentapi.process_post(request, sess)
                    api_utils.close_cluster_session(sess, clusterurl)
                    if mresponse and mcode is not None:
                        return make_response(jsonify(mresponse), mcode)
                    if mresponse and mcode is None:
                        return mresponse
        else:
            return make_response(jsonify({'error': 'API Disabled '}), 503)
    except Exception as e:
        return make_response(
            jsonify({'error': 'API Processing Error (' + str(e) + ')'}), 500)
Exemple #3
0
        requests.packages.urllib3.disable_warnings()
    except:
        logging.warn("{perfagent worker} Unable to disable urllib3 warnings")
        pass

if __name__ == '__main__':
    try:
        logging.warn("{perfagent worker} Startup")
        clusterurl, creds, migrateapi_status, managedbapi_status, perfagentapi_status = api_utils.process_config(
            '/opt/cloudant-specialapi/csapi.conf')
        credparts = str(base64.urlsafe_b64decode(str(creds))).split(':')
        if len(credparts) == 2:
            adminuser = credparts[0]
            adminpwd = credparts[1]
            while True:
                sess, serr, scode = api_utils.create_adminsession(
                    clusterurl, adminuser, adminpwd)
                if serr != None:
                    logging.warn(str(serr) + '/' + str(scode))
                else:
                    qdata, qcode = process_queue(sess, clusterurl,
                                                 'apiperfagentqueue')
                    if qdata is not None:
                        if not 'error' in qdata:
                            for qitem in qdata:
                                logging.warn(
                                    '{perfagent worker} Executing Performance Agent Processing for Entry ['
                                    + qitem['_id'] + ']')
                                update_queue_entry(sess, clusterurl, qitem,
                                                   'apiperfagentqueue',
                                                   "processing", None, None)
                                if 'opts' in qitem: