d['id'] = snapshot['id']
d['created_at'] = snapshot['created_at']
- d['display_name'] = snapshot['display_name']
- d['display_description'] = snapshot['display_description']
+ d['name'] = snapshot['display_name']
+ d['description'] = snapshot['display_description']
d['volume_id'] = snapshot['volume_id']
d['status'] = snapshot['status']
d['size'] = snapshot['volume_size']
elem.set('status')
elem.set('size')
elem.set('created_at')
- elem.set('display_name')
- elem.set('display_description')
+ elem.set('name')
+ elem.set('description')
elem.set('volume_id')
search_opts = {}
search_opts.update(req.GET)
- allowed_search_options = ('status', 'volume_id', 'display_name')
+ allowed_search_options = ('status', 'volume_id', 'name')
volumes.remove_invalid_options(context, search_opts,
allowed_search_options)
+ # NOTE(thingee): v2 API allows name instead of display_name
+ if 'name' in search_opts:
+ search_opts['display_name'] = search_opts['name']
+ del search_opts['name']
+
snapshots = self.volume_api.get_all_snapshots(context,
search_opts=search_opts)
limited_list = common.limited(snapshots, req)
msg = _("Create snapshot from volume %s")
LOG.audit(msg, volume_id, context=context)
+ # NOTE(thingee): v2 API allows name instead of display_name
+ if 'name' in snapshot:
+ snapshot['display_name'] = snapshot.get('name')
+ del snapshot['name']
+
if not utils.is_valid_boolstr(force):
msg = _("Invalid value '%s' for force. ") % force
raise exception.InvalidParameterValue(err=msg)
context,
volume,
snapshot.get('display_name'),
- snapshot.get('display_description'))
+ snapshot.get('description'))
else:
new_snapshot = self.volume_api.create_snapshot(
context,
volume,
snapshot.get('display_name'),
- snapshot.get('display_description'))
+ snapshot.get('description'))
retval = _translate_snapshot_detail_view(context, new_snapshot)
update_dict = {}
valid_update_keys = (
- 'display_name',
+ 'name',
+ 'description',
'display_description',
)
+ # NOTE(thingee): v2 API allows description instead of
+ # display_description
+ if 'description' in snapshot:
+ snapshot['display_description'] = snapshot['description']
+ del snapshot['description']
+
for key in valid_update_keys:
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)
def test_snapshot_create(self):
self.stubs.Set(volume.api.API, "create_snapshot", stub_snapshot_create)
self.stubs.Set(volume.api.API, 'get', stubs.stub_volume_get)
+ snapshot_name = 'Snapshot Test Name'
+ snapshot_description = 'Snapshot Test Desc'
snapshot = {
"volume_id": '12',
"force": False,
- "display_name": "Snapshot Test Name",
- "display_description": "Snapshot Test Desc"
+ "name": snapshot_name,
+ "description": snapshot_description
}
+
body = dict(snapshot=snapshot)
req = fakes.HTTPRequest.blank('/v2/snapshots')
resp_dict = self.controller.create(req, body)
self.assertTrue('snapshot' in resp_dict)
- self.assertEqual(resp_dict['snapshot']['display_name'],
- snapshot['display_name'])
- self.assertEqual(resp_dict['snapshot']['display_description'],
- snapshot['display_description'])
+ self.assertEqual(resp_dict['snapshot']['name'],
+ snapshot_name)
+ self.assertEqual(resp_dict['snapshot']['description'],
+ snapshot_description)
def test_snapshot_create_force(self):
self.stubs.Set(volume.api.API, "create_snapshot_force",
stub_snapshot_create)
self.stubs.Set(volume.api.API, 'get', stubs.stub_volume_get)
+ snapshot_name = 'Snapshot Test Name'
+ snapshot_description = 'Snapshot Test Desc'
snapshot = {
"volume_id": '12',
"force": True,
- "display_name": "Snapshot Test Name",
- "display_description": "Snapshot Test Desc"
+ "name": snapshot_name,
+ "description": snapshot_description
}
body = dict(snapshot=snapshot)
req = fakes.HTTPRequest.blank('/v2/snapshots')
resp_dict = self.controller.create(req, body)
self.assertTrue('snapshot' in resp_dict)
- self.assertEqual(resp_dict['snapshot']['display_name'],
- snapshot['display_name'])
- self.assertEqual(resp_dict['snapshot']['display_description'],
- snapshot['display_description'])
+ self.assertEqual(resp_dict['snapshot']['name'],
+ snapshot_name)
+ self.assertEqual(resp_dict['snapshot']['description'],
+ snapshot_description)
snapshot = {
"volume_id": "12",
"force": "**&&^^%%$$##@@",
- "display_name": "Snapshot Test Name",
- "display_description": "Snapshot Test Desc"
+ "name": "Snapshot Test Name",
+ "description": "Snapshot Test Desc"
}
body = dict(snapshot=snapshot)
req = fakes.HTTPRequest.blank('/v2/snapshots')
self.stubs.Set(volume.api.API, "update_snapshot",
stubs.stub_snapshot_update)
updates = {
- "display_name": "Updated Test Name",
+ "name": "Updated Test Name",
}
body = {"snapshot": updates}
req = fakes.HTTPRequest.blank('/v2/snapshots/%s' % UUID)
'status': 'available',
'size': 100,
'created_at': None,
- 'display_name': 'Updated Test Name',
- 'display_description': 'Default description',
+ 'name': 'Updated Test Name',
+ 'description': 'Default description',
}
}
self.assertEquals(expected, res_dict)
self.controller.update, req, UUID, body)
def test_snapshot_update_invalid_body(self):
- body = {'display_name': 'missing top level snapshot key'}
+ body = {'name': 'missing top level snapshot key'}
req = fakes.HTTPRequest.blank('/v2/snapshots/%s' % UUID)
self.assertRaises(webob.exc.HTTPUnprocessableEntity,
self.controller.update, req, UUID, body)
def test_snapshot_update_not_found(self):
self.stubs.Set(volume.api.API, "get_snapshot", stub_snapshot_get)
updates = {
- "display_name": "Updated Test Name",
+ "name": "Updated Test Name",
}
body = {"snapshot": updates}
req = fakes.HTTPRequest.blank('/v2/snapshots/not-the-uuid')
self.stubs.Set(db, 'snapshot_get_all_by_project',
stub_snapshot_get_all_by_project)
- # no display_name filter
+ # no name filter
req = fakes.HTTPRequest.blank('/v2/snapshots')
resp = self.controller.index(req)
self.assertEqual(len(resp['snapshots']), 3)
# filter by one name
- req = fakes.HTTPRequest.blank('/v2/snapshots?display_name=backup2')
+ req = fakes.HTTPRequest.blank('/v2/snapshots?name=backup2')
resp = self.controller.index(req)
self.assertEqual(len(resp['snapshots']), 1)
- self.assertEquals(resp['snapshots'][0]['display_name'], 'backup2')
+ self.assertEquals(resp['snapshots'][0]['name'], 'backup2')
# filter no match
- req = fakes.HTTPRequest.blank('/v2/snapshots?display_name=backup4')
+ req = fakes.HTTPRequest.blank('/v2/snapshots?name=backup4')
resp = self.controller.index(req)
self.assertEqual(len(resp['snapshots']), 0)
self.assertEqual(tree.tag, 'snapshot')
for attr in ('id', 'status', 'size', 'created_at',
- 'display_name', 'display_description', 'volume_id'):
+ 'name', 'description', 'volume_id'):
self.assertEqual(str(snap[attr]), tree.get(attr))
def test_snapshot_show_create_serializer(self):
status='snap_status',
size=1024,
created_at=datetime.datetime.now(),
- display_name='snap_name',
+ name='snap_name',
+ description='snap_desc',
display_description='snap_desc',
volume_id='vol_id',
)
status='snap1_status',
size=1024,
created_at=datetime.datetime.now(),
- display_name='snap1_name',
- display_description='snap1_desc',
+ name='snap1_name',
+ description='snap1_desc',
volume_id='vol1_id',
),
dict(
status='snap2_status',
size=1024,
created_at=datetime.datetime.now(),
- display_name='snap2_name',
- display_description='snap2_desc',
+ name='snap2_name',
+ description='snap2_desc',
volume_id='vol2_id',
)
]