def update(self, req, id, body): """Update a volume.""" context = req.environ['cinder.context'] if not body: raise exc.HTTPUnprocessableEntity() if not 'volume' in body: raise exc.HTTPUnprocessableEntity() volume = body['volume'] update_dict = {} valid_update_keys = ( 'display_name', 'display_description', ) for key in valid_update_keys: if key in volume: update_dict[key] = volume[key] try: volume = self.volume_api.get(context, id) self.volume_api.update(context, volume, update_dict) except exception.NotFound: raise exc.HTTPNotFound() volume.update(update_dict) return {'volume': _translate_volume_detail_view(context, volume)}
def update(self, req, id, body): """Update a volume.""" context = req.environ['cinder.context'] if not body: raise exc.HTTPUnprocessableEntity() if not 'volume' in body: raise exc.HTTPUnprocessableEntity() volume = body['volume'] update_dict = {} valid_update_keys = ( 'display_name', 'display_description', 'metadata', ) for key in valid_update_keys: if key in volume: update_dict[key] = volume[key] try: volume = self.volume_api.get(context, id) self.volume_api.update(context, volume, update_dict) except exception.NotFound: raise exc.HTTPNotFound() volume.update(update_dict) return {'volume': _translate_volume_detail_view(context, volume)}
def update(self, req, id, body): """Update a volume.""" context = req.environ['cinder.context'] if not body: msg = _("Missing request body") raise exc.HTTPBadRequest(explanation=msg) if 'volume' not in body: msg = _("Missing required element '%s' in request body") % 'volume' raise exc.HTTPBadRequest(explanation=msg) volume = body['volume'] update_dict = {} valid_update_keys = ( 'name', 'description', 'metadata', ) for key in valid_update_keys: if key in volume: update_dict[key] = volume[key] # NOTE(thingee): v2 API allows name instead of display_name if 'name' in update_dict: update_dict['display_name'] = update_dict['name'] del update_dict['name'] # NOTE(thingee): v2 API allows name instead of display_name if 'description' in update_dict: update_dict['display_description'] = update_dict['description'] del update_dict['description'] try: volume = self.volume_api.get(context, id) self.volume_api.update(context, volume, update_dict) except exception.NotFound: msg = _("Volume could not be found") raise exc.HTTPNotFound(explanation=msg) volume.update(update_dict) self._add_visible_admin_metadata(context, volume) return self._view_builder.detail(req, volume)
def update(self, req, id, body): """Update a volume.""" context = req.environ['cinder.context'] if not body: raise exc.HTTPBadRequest() if 'volume' not in body: raise exc.HTTPBadRequest() volume = body['volume'] update_dict = {} valid_update_keys = ( 'name', 'description', 'metadata', ) for key in valid_update_keys: if key in volume: update_dict[key] = volume[key] # NOTE(thingee): v2 API allows name instead of display_name if 'name' in update_dict: update_dict['display_name'] = update_dict['name'] del update_dict['name'] # NOTE(thingee): v2 API allows name instead of display_name if 'description' in update_dict: update_dict['display_description'] = update_dict['description'] del update_dict['description'] try: volume = self.volume_api.get(context, id) self.volume_api.update(context, volume, update_dict) except exception.NotFound: raise exc.HTTPNotFound() volume.update(update_dict) return self._view_builder.detail(req, volume)
def update(self, req, id, body): """Update a volume.""" context = req.environ["cinder.context"] if not body: msg = _("Missing request body") raise exc.HTTPBadRequest(explanation=msg) if "volume" not in body: msg = _("Missing required element '%s' in request body") % "volume" raise exc.HTTPBadRequest(explanation=msg) volume = body["volume"] update_dict = {} valid_update_keys = ("name", "description", "metadata") for key in valid_update_keys: if key in volume: update_dict[key] = volume[key] # NOTE(thingee): v2 API allows name instead of display_name if "name" in update_dict: update_dict["display_name"] = update_dict["name"] del update_dict["name"] # NOTE(thingee): v2 API allows name instead of display_name if "description" in update_dict: update_dict["display_description"] = update_dict["description"] del update_dict["description"] try: volume = self.volume_api.get(context, id) self.volume_api.update(context, volume, update_dict) except exception.NotFound: msg = _("Volume could not be found") raise exc.HTTPNotFound(explanation=msg) volume.update(update_dict) return self._view_builder.detail(req, volume)