Exemple #1
0
def wall_time_parsed(args):

    if not args.list and not (args.resource and
                              args.appkernel and
                              args.nodes and
                              args.walltime):
        parser.error(
            'Please provide a resource, app, node count and wall time.')
        exit(1)

    listing = args.list
    resource = args.resource
    app = args.appkernel
    nodes = args.nodes
    walltime = args.walltime
    comments = args.comments
    node_list = [node.strip() for node in nodes.split(',')] if ',' in nodes else list(nodes)

    for nodes in node_list:
        data = {
            'resource_params': "{'nnodes':%d}" % (int(nodes),) if nodes else "{}",
            'app_param':'{}',
            'walltime': walltime,
            'comments':comments
        }
        try:
            result = akrrrestclient.post(
                '/walltime/%s/%s'%(resource,app),
                data=data) if not listing else \
                akrrrestclient.get(
                    '/walltime/%s/%s'%(resource,app),
                    data=data)
            if result.status_code == 200:
                if not listing:
                    log.info('Successfully updated wall time (resource %s: application kernel: %s nodes: %d).'%(resource,app,nodes))
                else:
                    log.info(
                        'Successfully queried walltime records. \n{0}',
                        result.text)
            else:
                log.error('something went wrong. {0}:{1}',
                          result.status_code,
                          result.text)
        except StandardError, e:
            import traceback
            log.error('''
            An error occured while communicating
            with the REST API.
            {0}: {1}
            '''.strip(),
                      e.args[0] if len(e.args) > 0 else '',
                      e.args[1] if len(e.args) > 1 else '')
            print traceback.print_exc()
Exemple #2
0
def retrieve_tasks(resource, application):
    """
    Retrieve the list of currently scheduled tasks ( resource / application pairings ) from
    mod_akrr.

    :type resource str
    :type application str

    :param resource: filter the results by the provided resource
    :param application: filter the results by the provided application
    :return: a dict representation of the mod_akrr.SCHEDULEDTASKS table
    """
    data = {
        'application': application,
        'resource': resource
    }

    try:
        akrrrestclient.get_token()
    except StandardError:
        log.error('''
                An error occured while attempting to retrieve a token
                from the REST API.
                ''')
    try:
        result = akrrrestclient.get(
            '/scheduled_tasks',
            data=data)
        if result.status_code == 200:
            log.info('Successfully Completed Task Retrieval.\n{0}', result.text)

        else:
            log.error(
                'something went wrong. {0}:{1}',
                result.status_code,
                result.text)
        return result
    except StandardError, e:
        log.error('''
                An error occured while communicating
                with the REST API.
                {0}: {1}
                ''',
                  e.args[0] if len(e.args) > 0 else '',
                  e.args[1] if len(e.args) > 1 else '')
Exemple #3
0
def process_request(request):
    method = request[0]
    url = request[1]
    if method not in RESTCompleter.keywords:
        raise AssertionError("Invalid method. Please provide a valid method to continue.")
    if len(url) < 1:
        raise AssertionError("Must supply a url.")

    akrrrestclient.get_token()

    if method == "GET":
        return akrrrestclient.get(url)
    elif method == "PUT":
        return akrrrestclient.put(url)
    elif method == "POST":
        return akrrrestclient.post(url)
    elif method == "DELETE":
        return akrrrestclient.delete(url)
Exemple #4
0
def process_request(request):
    method = request[0]
    url = request[1]
    if method not in RESTCompleter.keywords:
        raise AssertionError(
            "Invalid method. Please provide a valid method to continue.")
    if len(url) < 1:
        raise AssertionError("Must supply a url.")

    akrrrestclient.get_token()

    if method == 'GET':
        return akrrrestclient.get(url)
    elif method == 'PUT':
        return akrrrestclient.put(url)
    elif method == 'POST':
        return akrrrestclient.post(url)
    elif method == 'DELETE':
        return akrrrestclient.delete(url)
     logerr("App.signature calculator is not working\n"+
            "See full error report below",out)
     exit()
 #close connection we don't need it any more
 rsh.close(force=True)
 del rsh    
 ###############################################################################################
 #send test job to queue
 
 log("#"*80)
 log("Will send test job to queue, wait till it executed and will analyze the output")
 
 print "Will use AKRR REST API at",akrrrestclient.restapi_host
 #get check connection 
 try:
     r = akrrrestclient.get('/scheduled_tasks')
     if r.status_code!=200:
         logerr("Can not get token for AKRR REST API ( """+akrrrestclient.restapi_host+" )\n"+
            "See server response below",json.dumps(r.json(),indent=4))
         exit()
 except Exception,e:
     logerr("Can not connect to AKRR REST API ( """+akrrrestclient.restapi_host+" )\n"+
            "Is it running?\n"+
            "See full error report below",traceback.format_exc())
     exit()
 
 #check if the test job is already submitted
 task_id=None
 test_job_lock_filename=os.path.join(akrr.data_dir,resource_name+"_test_task.dat")
 if os.path.isfile(test_job_lock_filename):
     fin=open(test_job_lock_filename,"r")