Clean up snapshot metadata
- Removed image_state from compute api snapshot (only needed by ec2/s3) - Only set backup_type when image_type is 'backup' - Add testing to verify snapshots/backups get the correct metadata Change-Id: Ib5461f9aa790d7ed5629c591bbe1510443dbc2aa
This commit is contained in:
parent
8a8dd22aea
commit
c3b7cce810
@ -1131,11 +1131,15 @@ class API(base.Base):
|
||||
if task_state == task_states.IMAGE_SNAPSHOT:
|
||||
raise exception.InstanceSnapshotting(instance_uuid=instance_uuid)
|
||||
|
||||
properties = {'instance_uuid': instance_uuid,
|
||||
'user_id': str(context.user_id),
|
||||
'image_state': 'creating',
|
||||
'image_type': image_type,
|
||||
'backup_type': backup_type}
|
||||
properties = {
|
||||
'instance_uuid': instance_uuid,
|
||||
'user_id': str(context.user_id),
|
||||
'image_type': image_type,
|
||||
}
|
||||
|
||||
if image_type == 'backup':
|
||||
properties['backup_type'] = backup_type
|
||||
|
||||
properties.update(extra_properties or {})
|
||||
sent_meta = {'name': name, 'is_public': False,
|
||||
'status': 'creating', 'properties': properties}
|
||||
|
@ -1504,13 +1504,32 @@ class ComputeAPITestCase(BaseTestCase):
|
||||
def test_snapshot(self):
|
||||
"""Can't backup an instance which is already being backed up."""
|
||||
instance = self._create_fake_instance()
|
||||
self.compute_api.snapshot(self.context, instance, None, None)
|
||||
image = self.compute_api.snapshot(self.context, instance, 'snap1',
|
||||
{'extra_param': 'value1'})
|
||||
|
||||
self.assertEqual(image['name'], 'snap1')
|
||||
properties = image['properties']
|
||||
self.assertTrue('backup_type' not in properties)
|
||||
self.assertEqual(properties['image_type'], 'snapshot')
|
||||
self.assertEqual(properties['instance_uuid'], instance['uuid'])
|
||||
self.assertEqual(properties['extra_param'], 'value1')
|
||||
|
||||
db.instance_destroy(self.context, instance['id'])
|
||||
|
||||
def test_backup(self):
|
||||
"""Can't backup an instance which is already being backed up."""
|
||||
instance = self._create_fake_instance()
|
||||
self.compute_api.backup(self.context, instance, None, None, None)
|
||||
image = self.compute_api.backup(self.context, instance,
|
||||
'backup1', 'DAILY', None,
|
||||
{'extra_param': 'value1'})
|
||||
|
||||
self.assertEqual(image['name'], 'backup1')
|
||||
properties = image['properties']
|
||||
self.assertEqual(properties['backup_type'], 'DAILY')
|
||||
self.assertEqual(properties['image_type'], 'backup')
|
||||
self.assertEqual(properties['instance_uuid'], instance['uuid'])
|
||||
self.assertEqual(properties['extra_param'], 'value1')
|
||||
|
||||
db.instance_destroy(self.context, instance['id'])
|
||||
|
||||
def test_backup_conflict(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user