Don't fail to delete if VolumeAttachment not found

Change-Id: If12b7ebbee2d71e39e49152d971c11f55badca18
Signed-off-by: Zane Bitter <zbitter@redhat.com>
This commit is contained in:
Zane Bitter 2012-09-20 11:14:53 +02:00
parent a974326cd7
commit 2652832ef3

View File

@ -18,6 +18,7 @@ from heat.openstack.common import log as logging
from heat.common import exception from heat.common import exception
from heat.engine.resources import Resource from heat.engine.resources import Resource
from novaclient.exceptions import NotFound
logger = logging.getLogger('heat.engine.volume') logger = logging.getLogger('heat.engine.volume')
@ -99,10 +100,12 @@ class VolumeAttachment(Resource):
(server_id, volume_id)) (server_id, volume_id))
volapi = self.nova().volumes volapi = self.nova().volumes
try:
volapi.delete_server_volume(server_id, volapi.delete_server_volume(server_id,
volume_id) volume_id)
vol = self.nova('volume').volumes.get(volume_id) vol = self.nova('volume').volumes.get(volume_id)
logger.info('un-attaching %s, status %s' % (volume_id, vol.status)) logger.info('un-attaching %s, status %s' % (volume_id, vol.status))
while vol.status == 'in-use': while vol.status == 'in-use':
logger.info('trying to un-attach %s, but still %s' % logger.info('trying to un-attach %s, but still %s' %
@ -114,3 +117,7 @@ class VolumeAttachment(Resource):
except Exception: except Exception:
pass pass
vol.get() vol.get()
except NotFound as e:
logger.warning('Deleting VolumeAttachment %s %s - not found' %
(server_id, volume_id))
return