def create_fixtures(self): fixtures = [ {'id': UUID1, 'status': 'queued'}, {'id': UUID2, 'status': 'queued'}, ] for fixture in fixtures: db_api.image_create(self.adm_context, fixture)
def create_fixtures(self): fixtures = [ { 'id': UUID1, 'status': 'queued' }, { 'id': UUID2, 'status': 'queued' }, ] for fixture in fixtures: db_api.image_create(self.adm_context, fixture)
def create(self, req, body): """ Registers a new image with the registry. :param req: wsgi Request object :param body: Dictionary of information about the image :retval Returns the newly-created image information as a mapping, which will include the newly-created image's internal id in the 'id' field """ if req.context.read_only: raise exc.HTTPForbidden() image_data = body['image'] # Ensure the image has a status set image_data.setdefault('status', 'active') # Set up the image owner if not req.context.is_admin or 'owner' not in image_data: image_data['owner'] = req.context.owner try: image_data = db_api.image_create(req.context, image_data) return dict(image=make_image_dict(image_data)) except exception.Duplicate: msg = (_("Image with identifier %s already exists!") % id) logger.error(msg) return exc.HTTPConflict(msg) except exception.Invalid, e: msg = (_("Failed to add image metadata. " "Got error: %(e)s") % locals()) logger.error(msg) return exc.HTTPBadRequest(msg)
def create(self, req): """ Registers a new image with the registry. :param req: Request body. A JSON-ified dict of information about the image. :retval Returns the newly-created image information as a mapping, which will include the newly-created image's internal id in the 'id' field """ image_data = json.loads(req.body)['image'] # Ensure the image has a status set image_data.setdefault('status', 'active') context = None try: image_data = db_api.image_create(context, image_data) return dict(image=make_image_dict(image_data)) except exception.Duplicate: msg = ("Image with identifier %s already exists!" % id) logger.error(msg) return exc.HTTPConflict(msg) except exception.Invalid, e: msg = ("Failed to add image metadata. Got error: %(e)s" % locals()) logger.error(msg) return exc.HTTPBadRequest(msg)
def create_fixtures(self): self.fixtures = self.build_fixtures() for fixture in self.fixtures: db_api.image_create(self.adm_context, fixture)
def create_fixtures(self): for fixture in FIXTURES: db_api.image_create(self.adm_context, fixture)