From 622f10e87fda5dc439d43543216d953920079282 Mon Sep 17 00:00:00 2001 From: Ken'ichi Ohmichi Date: Tue, 17 Sep 2013 13:29:51 +0900 Subject: [PATCH] Allow display_name for v2 snapshot-update According to the comment in the source code, the snapshot-update of v2 would be able to allow either "name" or "display_name" parameter. And if both paramters are specified, "name" parameter is effective over "display_name" like "description" parameter. However "display_name" parameter is ignored now, because cinder writes over empty dict(update_dict['display_name']). This patch fixes the problem. Fixes bug #1226398 Change-Id: Icd48556a26b9346f73b7c1b82ffbcdd469c4d28d --- cinder/api/v2/snapshots.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cinder/api/v2/snapshots.py b/cinder/api/v2/snapshots.py index 5e415392b..f6ac6da76 100644 --- a/cinder/api/v2/snapshots.py +++ b/cinder/api/v2/snapshots.py @@ -232,9 +232,15 @@ class SnapshotsController(wsgi.Controller): valid_update_keys = ( 'name', 'description', + 'display_name', 'display_description', ) + # NOTE(thingee): v2 API allows name instead of display_name + if 'name' in snapshot: + snapshot['display_name'] = snapshot['name'] + del snapshot['name'] + # NOTE(thingee): v2 API allows description instead of # display_description if 'description' in snapshot: @@ -245,11 +251,6 @@ class SnapshotsController(wsgi.Controller): if key in snapshot: update_dict[key] = snapshot[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'] - try: snapshot = self.volume_api.get_snapshot(context, id) self.volume_api.update_snapshot(context, snapshot, update_dict) -- 2.45.2