Example #1
0
    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
Example #2
0
 def GET(self):
     return {'images': data.dump_images()}