def update_capsule(self, context, capsule_id, values):
if 'uuid' in values:
msg = _("Cannot overwrite UUID for an existing Capsule.")
raise exception.InvalidParameterValue(err=msg)
try:
target_uuid = self.get_capsule_by_uuid(
context, capsule_id).uuid
target = self.client.read('/capsules/' + target_uuid)
target_value = json.loads(target.value)
target_value.update(values)
target.value = json.dump_as_bytes(target_value)
self.client.update(target)
except etcd.EtcdKeyNotFound:
raise exception.CapsuleNotFound(capsule=capsule_id)
except Exception as e:
LOG.error('Error occurred while updating capsule: %s',
six.text_type(e))
raise
return translate_etcd_result(target, 'capsule')
评论列表
文章目录