def put(self, item_id, item): for fieldname in "configuration", "name": if fieldname in self.request_json["data"]: setattr(item, fieldname, self.request_json["data"][fieldname]) item.initiator_id = self.initiator_id try: item.save() except base_exceptions.CannotUpdateDeletedModel as exc: LOG.warning( "Cannot update playbook configuration %s (deleted at %s, " "version %s)", item_id, item.time_deleted, item.version) raise http_exceptions.CannotUpdateDeletedModel() from exc except base_exceptions.UniqueConstraintViolationError as exc: LOG.warning( "Cannot update playbook configuration %s " "(unique constraint violation)", self.request_json["data"]["name"]) raise http_exceptions.CannotUpdateModelWithSuchParameters() \ from exc LOG.info("Playbook configuration %s was updated by %s", item_id, self.initiator_id) return item
def put(self, item_id, item): try: for key, value in self.request_json["data"].items(): setattr(item, key, value) item.initiator_id = self.initiator_id item.save() except base_exceptions.CannotUpdateDeletedModel as exc: LOG.warning( "Cannot update deleted role %s (deleted at %s, " "version %s)", item_id, item.time_deleted, item.version ) raise http_exceptions.CannotUpdateDeletedModel() from exc except base_exceptions.UniqueConstraintViolationError as exc: LOG.warning("Cannot update role %s (unique constraint " "violation)", self.request_json["data"]["name"]) raise http_exceptions.CannotUpdateModelWithSuchParameters() \ from exc except ValueError as exc: LOG.warning("Incorrect permissions for role %s: %s", item_id, exc) raise http_exceptions.BadRequest from exc LOG.info("Role %s was updated by %s", item_id, self.initiator_id) return item
def put(self, item_id, item): item.name = self.request_json["data"]["name"] item.initiator_id = self.initiator_id try: item.save() except base_exceptions.CannotUpdateDeletedModel as exc: LOG.warning( "Cannot update deleted model %s (deleted at %s, " "version %s)", item.model_id, item.time_deleted, item.version) raise http_exceptions.CannotUpdateDeletedModel() from exc except base_exceptions.UniqueConstraintViolationError as exc: LOG.warning( "Cannot update server %s (unique constraint " "violation)", self.request_json["data"]["name"]) raise http_exceptions.CannotUpdateModelWithSuchParameters() \ from exc else: if item.cluster_id: item.cluster.update_servers([item]) item.cluster.save() LOG.info("Server model %s was update to version %s by %s", item.model_id, item.version, self.initiator_id) return item
def put(self, item_id, item): for key, value in self.request_json["data"].items(): setattr(item, key, value) item.initiator_id = self.initiator_id try: item.save() except base_exceptions.CannotUpdateDeletedModel as exc: LOG.warning( "Cannot update deleted model %s (deleted at %s, " "version %s)", item.model_id, item.time_deleted, item.version) raise http_exceptions.CannotUpdateDeletedModel() from exc except base_exceptions.UniqueConstraintViolationError as exc: LOG.warning( "Cannot update user %s (unique constraint " "violation)", self.request_json["data"]["login"]) raise http_exceptions.CannotUpdateModelWithSuchParameters() \ from exc LOG.info("User model %s was updated to version %s by %s", item.model_id, item.version, self.initiator_id) return item