diff options
| author | John Griffith <john.griffith@solidfire.com> | 2012-07-28 10:02:42 -0600 |
|---|---|---|
| committer | John Griffith <john.griffith@solidfire.com> | 2012-09-17 15:17:36 -0600 |
| commit | 9733b4eb9f3aeadd29f8dd8b00a37ce3d454edb8 (patch) | |
| tree | 582939a20b73c3d4a87c939bb7da2b6f425fecf3 /nova | |
| parent | 76ca8c184bed7aa706ac6ef1010c3f4ebf08f7f0 (diff) | |
| download | nova-9733b4eb9f3aeadd29f8dd8b00a37ce3d454edb8.tar.gz nova-9733b4eb9f3aeadd29f8dd8b00a37ce3d454edb8.tar.xz nova-9733b4eb9f3aeadd29f8dd8b00a37ce3d454edb8.zip | |
Include volume_metadata with object on vol create
Fix for Bug 1029762
The symptom of this bug is that the response data of an
OSAPI create call always shows and empty dict for volume_metadata
regardless of what was passed in to created and actually used.
Upon the db create_volume call a reference to the volume
object is all that was being returned. Since metadata is
specified and set, it should also be returned with the
create reference object.
This will result in the the osapi create call returning
a body with correct metdata info rather than always showing
and empty dict as it was previously.
Change-Id: I469e06941f446526bae39168f3b1ebfea851e0ef
Diffstat (limited to 'nova')
| -rw-r--r-- | nova/db/sqlalchemy/api.py | 2 | ||||
| -rw-r--r-- | nova/tests/test_volume.py | 20 |
2 files changed, 20 insertions, 2 deletions
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index ea8d7cbec..533298bee 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -2931,7 +2931,7 @@ def volume_create(context, values): with session.begin(): volume_ref.save(session=session) - return volume_ref + return volume_get(context, values['id'], session=session) @require_admin_context diff --git a/nova/tests/test_volume.py b/nova/tests/test_volume.py index 5bd510406..3de5404f6 100644 --- a/nova/tests/test_volume.py +++ b/nova/tests/test_volume.py @@ -74,7 +74,7 @@ class VolumeTestCase(test.TestCase): return 1 @staticmethod - def _create_volume(size=0, snapshot_id=None): + def _create_volume(size=0, snapshot_id=None, metadata=None): """Create a volume object.""" vol = {} vol['size'] = size @@ -84,6 +84,8 @@ class VolumeTestCase(test.TestCase): vol['availability_zone'] = FLAGS.storage_availability_zone vol['status'] = "creating" vol['attach_status'] = "detached" + if metadata is not None: + vol['metadata'] = metadata return db.volume_create(context.get_admin_context(), vol) def test_ec2_uuid_mapping(self): @@ -132,6 +134,22 @@ class VolumeTestCase(test.TestCase): self.context, volume_id) + def test_create_delete_volume_with_metadata(self): + """Test volume can be created and deleted.""" + test_meta = {'fake_key': 'fake_value'} + volume = self._create_volume('0', None, test_meta) + volume_id = volume['id'] + self.volume.create_volume(self.context, volume_id) + result_meta = { + volume.volume_metadata[0].key: volume.volume_metadata[0].value} + self.assertEqual(result_meta, test_meta) + + self.volume.delete_volume(self.context, volume_id) + self.assertRaises(exception.NotFound, + db.volume_get, + self.context, + volume_id) + def _do_test_create_over_quota(self, resource, expected): """Test volume creation over quota.""" |
