]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Validate invalid mountpoint.device entries
authorSteven Dake <sdake@redhat.com>
Wed, 9 May 2012 20:35:22 +0000 (13:35 -0700)
committerSteven Dake <sdake@redhat.com>
Wed, 9 May 2012 20:35:22 +0000 (13:35 -0700)
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 <sdake@redhat.com>
heat/engine/volume.py

index 92cec88684e5f593cde792e05fe8b5a9661d02e7..d3cd6db058b3f3425315040022047b20f695be80 100644 (file)
@@ -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: