Skip to content

Commit

Permalink
Implement volume tags as metadata
Browse files Browse the repository at this point in the history
I have created the wordpress with ebs and confirmed that
cinder show <id> displays the metadata correctly.

Change-Id: I84f394bbd3748884deca64630cdfee7ac1bb9786
Closes-bug: #1224339
  • Loading branch information
asalkeld committed Oct 30, 2013
1 parent d9ca0c9 commit bca4b68
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
16 changes: 14 additions & 2 deletions heat/engine/resources/volume.py
Expand Up @@ -30,6 +30,10 @@


class Volume(resource.Resource):
tags_schema = {'Key': {'Type': 'String',
'Required': True},
'Value': {'Type': 'String',
'Required': True}}

properties_schema = {
'AvailabilityZone': {
Expand All @@ -45,8 +49,9 @@ class Volume(resource.Resource):
'to create the volume.')},
'Tags': {
'Type': 'List',
'Description': _('The list of tags to associate with the volume '
' (ignored).')}
'Description': _('The list of tags to associate '
'with the volume.')},
'Schema': {'Type': 'Map', 'Schema': tags_schema},
}

_restore_property = 'SnapshotId'
Expand All @@ -60,9 +65,16 @@ def _display_description(self):
return self.physical_resource_name()

def _create_arguments(self):
if self.properties['Tags']:
tags = dict((tm['Key'], tm['Value'])
for tm in self.properties['Tags'])
else:
tags = None

return {
'size': self.properties['Size'],
'availability_zone': self.properties['AvailabilityZone'] or None,
'metadata': tags
}

def handle_create(self):
Expand Down
6 changes: 4 additions & 2 deletions heat/tests/test_volume.py
Expand Up @@ -114,7 +114,8 @@ def _mock_create_volume(self, fv, stack_name):
self.cinder_fc.volumes.create(
size=1, availability_zone='nova',
display_description=vol_name,
display_name=vol_name).AndReturn(fv)
display_name=vol_name,
metadata={u'Usage': u'Wiki Data Volume'}).AndReturn(fv)

def _stubout_delete_volume(self, fv):
self.m.StubOutWithMock(fv, 'delete')
Expand Down Expand Up @@ -185,7 +186,8 @@ def test_volume_default_az(self):
self.cinder_fc.volumes.create(
size=1, availability_zone=None,
display_description=vol_name,
display_name=vol_name).AndReturn(fv)
display_name=vol_name,
metadata={u'Usage': u'Wiki Data Volume'}).AndReturn(fv)
vol.VolumeAttachment.handle_create().AndReturn(None)
vol.VolumeAttachment.check_create_complete(None).AndReturn(True)

Expand Down

0 comments on commit bca4b68

Please sign in to comment.