From: Steven Dake Date: Wed, 9 May 2012 20:35:22 +0000 (-0700) Subject: Validate invalid mountpoint.device entries X-Git-Tag: 2014.1~1858 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=899e952ed697d7b44b5d3b9438c95dd157f3a14a;p=openstack-build%2Fheat-build.git Validate invalid mountpoint.device entries Since KVM only allows /dev/vd[a-z], we validate that implementation-specific sd[a-z] is rejected by heat validation. See: http://docs.openstack.org/trunk/openstack-compute/admin/content/managing-volumes.html Search device name Resolves issue #71 Signed-off-by: Steven Dake --- diff --git a/heat/engine/volume.py b/heat/engine/volume.py index 92cec886..d3cd6db0 100644 --- a/heat/engine/volume.py +++ b/heat/engine/volume.py @@ -16,6 +16,7 @@ import eventlet import logging import os +import re from heat.common import exception from heat.engine.resources import Resource @@ -101,6 +102,16 @@ class VolumeAttachment(Resource): else: self.state_set(self.CREATE_FAILED) + def validate(self): + ''' + Validate the mountpoint device + ''' + device_re = re.compile('/dev/vd[b-z]') + if re.match(device_re, self.t['Properties']['Device']): + return None + else: + return 'MountPoint.Device must be in format /dev/vd[b-z]' + def delete(self): if self.state == self.DELETE_IN_PROGRESS or \ self.state == self.DELETE_COMPLETE: