]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
a minor fix to volume.py
authorLiang Chen <cbjchen@cn.ibm.com>
Fri, 31 May 2013 09:41:30 +0000 (17:41 +0800)
committerLiang Chen <cbjchen@cn.ibm.com>
Sun, 2 Jun 2013 15:26:11 +0000 (23:26 +0800)
There seems a typo with the exception name and the comment.

Change-Id: I5c0abe48c81a69e4b879b080236899031bb40e97

heat/engine/resources/volume.py
heat/tests/test_volume.py

index fea76fcebb2933ca15911ec677dcfaaf69a42ffa..66a78deb4e76e1aa25fe5e0ee4eb6a677c7682ec 100644 (file)
@@ -166,7 +166,7 @@ class VolumeAttachTask(object):
 
 
 class VolumeDetachTask(object):
-    """A task for attaching a volume to a Nova server."""
+    """A task for detaching a volume from a Nova server."""
 
     def __init__(self, stack, server_id, volume_id):
         """
@@ -194,7 +194,7 @@ class VolumeDetachTask(object):
 
         try:
             vol = self.clients.cinder().volumes.get(self.volume_id)
-        except clients.cinder_exceptions.NotFound:
+        except clients.cinderclient.exceptions.NotFound:
             logger.warning('%s - volume not found' % str(self))
             return
 
index 9a490bb29e85bf08b471d585e8aad26d8548de04..61f0761c404367040c7c16e1a33555986e195128 100644 (file)
@@ -318,6 +318,45 @@ class VolumeTest(HeatTestCase):
 
         self.m.VerifyAll()
 
+    def test_volume_detach_non_exist(self):
+        fv = FakeVolume('creating', 'available')
+        fva = FakeVolume('in-use', 'available')
+        stack_name = 'test_volume_detach_stack'
+
+        # volume create
+        clients.OpenStackClients.cinder().MultipleTimes().AndReturn(
+            self.cinder_fc)
+        self.cinder_fc.volumes.create(
+            size=u'1', availability_zone='nova',
+            display_description='%s.DataVolume' % stack_name,
+            display_name='%s.DataVolume' % stack_name).AndReturn(fv)
+
+        # create script
+        clients.OpenStackClients.nova().MultipleTimes().AndReturn(self.fc)
+        self.fc.volumes.create_server_volume(
+            device=u'/dev/vdc',
+            server_id=u'WikiDatabase',
+            volume_id=u'vol-123').AndReturn(fva)
+
+        self.cinder_fc.volumes.get('vol-123').AndReturn(fva)
+
+        # delete script
+        self.cinder_fc.volumes.get('vol-123').AndRaise(
+            clients.cinderclient.exceptions.NotFound('Not found'))
+
+        self.m.ReplayAll()
+
+        t = template_format.parse(volume_template)
+        t['Resources']['DataVolume']['Properties']['AvailabilityZone'] = 'nova'
+        stack = parse_stack(t, stack_name=stack_name)
+
+        scheduler.TaskRunner(stack['DataVolume'].create)()
+        rsrc = self.create_attachment(t, stack, 'MountPoint')
+
+        self.assertEqual(rsrc.delete(), None)
+
+        self.m.VerifyAll()
+
     @skipIf(volume_backups is None, 'unable to import volume_backups')
     def test_snapshot(self):
         stack_name = 'test_volume_stack'