Merge "Convert [Cinder]VolumeAttachment to new Schema format"

This commit is contained in:
Jenkins
2013-12-19 01:58:55 +00:00
committed by Gerrit Code Review

View File

@@ -20,6 +20,7 @@ from heat.openstack.common.importutils import try_import
from heat.common import exception
from heat.engine import clients
from heat.engine import constraints
from heat.engine import properties
from heat.engine import resource
from heat.engine.resources import nova_utils
@@ -301,32 +302,39 @@ class VolumeDetachTask(object):
class VolumeAttachment(resource.Resource):
PROPERTIES = (
INSTANCE_ID, VOLUME_ID, DEVICE,
) = (
'InstanceId', 'VolumeId', 'Device',
)
properties_schema = {
'InstanceId': {
'Type': 'String', 'Required': True,
'Description': _('The ID of the instance to which the '
'volume attaches.')},
'VolumeId': {
'Type': 'String', 'Required': True,
'Description': _('The ID of the volume to be attached.')},
'Device': {
'Type': 'String', 'Required': True,
'AllowedPattern': '/dev/vd[b-z]',
'Description': _('The device where the volume is exposed on '
'the instance. This assignment may not be '
'honored and it is advised that the path '
'/dev/disk/by-id/virtio-<VolumeId> be used '
'instead.')}
INSTANCE_ID: properties.Schema(
properties.Schema.STRING,
_('The ID of the instance to which the volume attaches.'),
required=True
),
VOLUME_ID: properties.Schema(
properties.Schema.STRING,
_('The ID of the volume to be attached.'),
required=True
),
DEVICE: properties.Schema(
properties.Schema.STRING,
_('The device where the volume is exposed on the instance. This '
'assignment may not be honored and it is advised that the path '
'/dev/disk/by-id/virtio-<VolumeId> be used instead.'),
required=True,
constraints=[
constraints.AllowedPattern('/dev/vd[b-z]'),
]
),
}
_instance_property = 'InstanceId'
_volume_property = 'VolumeId'
_device_property = 'Device'
def handle_create(self):
server_id = self.properties[self._instance_property]
volume_id = self.properties[self._volume_property]
dev = self.properties[self._device_property]
server_id = self.properties[self.INSTANCE_ID]
volume_id = self.properties[self.VOLUME_ID]
dev = self.properties[self.DEVICE]
attach_task = VolumeAttachTask(self.stack, server_id, volume_id, dev)
attach_runner = scheduler.TaskRunner(attach_task)
@@ -341,8 +349,8 @@ class VolumeAttachment(resource.Resource):
return attach_runner.step()
def handle_delete(self):
server_id = self.properties[self._instance_property]
volume_id = self.properties[self._volume_property]
server_id = self.properties[self.INSTANCE_ID]
volume_id = self.properties[self.VOLUME_ID]
detach_task = VolumeDetachTask(self.stack, server_id, volume_id)
scheduler.TaskRunner(detach_task)()
@@ -462,26 +470,31 @@ class CinderVolume(Volume):
class CinderVolumeAttachment(VolumeAttachment):
properties_schema = {
'instance_uuid': {
'Type': 'String', 'Required': True,
'Description': _('The ID of the server to which the '
'volume attaches.')},
'volume_id': {
'Type': 'String', 'Required': True,
'Description': _('The ID of the volume to be attached.')},
'mountpoint': {
'Type': 'String', 'Required': True,
'Description': _('The location where the volume is exposed on '
'the instance. This assignment may not be '
'honored and it is advised that the path '
'/dev/disk/by-id/virtio-<VolumeId> be used '
'instead.')}
}
PROPERTIES = (
INSTANCE_ID, VOLUME_ID, DEVICE,
) = (
'instance_uuid', 'volume_id', 'mountpoint',
)
_instance_property = 'instance_uuid'
_volume_property = 'volume_id'
_device_property = 'mountpoint'
properties_schema = {
INSTANCE_ID: properties.Schema(
properties.Schema.STRING,
_('The ID of the server to which the volume attaches.'),
required=True
),
VOLUME_ID: properties.Schema(
properties.Schema.STRING,
_('The ID of the volume to be attached.'),
required=True
),
DEVICE: properties.Schema(
properties.Schema.STRING,
_('The location where the volume is exposed on the instance. This '
'assignment may not be honored and it is advised that the path '
'/dev/disk/by-id/virtio-<VolumeId> be used instead.'),
required=True
),
}
def resource_mapping():