예제 #1
0
파일: handlers.py 프로젝트: armenzg/mozpool
    def POST(self, device_name):
        args, body = templeton.handlers.get_request_parms()
        try:
            assignee = body['assignee']
            duration = int(body['duration'])
            image_name = body['image']
            environment = body.get('environment', 'any')
        except (KeyError, ValueError):
            raise web.badrequest()

        images = data.dump_images(image_name)
        if not images:
            raise web.badrequest()

        boot_config = {}
        for k in images[0]['boot_config_keys']:
            try:
                boot_config[k] = body[k]
            except KeyError:
                raise web.badrequest()

        request_id = data.create_request(device_name, environment, assignee,
                                         duration, images[0]['id'], boot_config)
        mozpool.mozpool.driver.handle_event(request_id, 'find_device', None)
        response_data = {'request': data.request_config(request_id)}
        if data.request_status(request_id)['state'] == 'closed':
            raise ConflictJSON(response_data)
        return response_data
예제 #2
0
 def POST(self, device_name):
     args, body = templeton.handlers.get_request_parms()
     boot_config = body.get('boot_config', {})
     try:
         assignee = body['assignee']
         duration = int(body['duration'])
     except (KeyError, ValueError):
         raise web.badrequest()
     request_id = data.create_request(device_name, assignee, duration,
                                      boot_config)
     mozpool.mozpool.driver.handle_event(request_id, 'find_device', None)
     response_data = {'request': data.request_config(request_id)}
     if data.request_status(request_id)['state'] == 'closed':
         raise ConflictJSON(response_data)
     return response_data
예제 #3
0
 def POST(self, device_name):
     args, body = templeton.handlers.get_request_parms()
     boot_config = body.get('boot_config', {})
     try:
         assignee = body['assignee']
         duration = int(body['duration'])
     except (KeyError, ValueError):
         raise web.badrequest()
     request_id = data.create_request(device_name, assignee, duration,
                                      boot_config)
     mozpool.mozpool.driver.handle_event(request_id, 'find_device', None)
     response_data = {'request': data.request_config(request_id)}
     if data.request_status(request_id)['state'] == 'closed':
         raise ConflictJSON(response_data)
     return response_data
예제 #4
0
파일: handlers.py 프로젝트: armenzg/mozpool
 def GET(self, request_id):
     try:
         return data.request_status(request_id)
     except IndexError:
         raise web.notfound()
예제 #5
0
 def GET(self, request_id):
     try:
         return data.request_status(request_id)
     except IndexError:
         raise web.notfound()