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.engine.resources import Resource
from novaclient.exceptions import NotFound
logger = logging.getLogger('heat.engine.volume')
@ -99,18 +100,24 @@ class VolumeAttachment(Resource):
(server_id, volume_id))
volapi = self.nova().volumes
volapi.delete_server_volume(server_id,
volume_id)
try:
volapi.delete_server_volume(server_id,
volume_id)
vol = self.nova('volume').volumes.get(volume_id)
logger.info('un-attaching %s, status %s' % (volume_id, vol.status))
while vol.status == 'in-use':
logger.info('trying to un-attach %s, but still %s' %
(volume_id, vol.status))
eventlet.sleep(1)
try:
volapi.delete_server_volume(server_id,
volume_id)
except Exception:
pass
vol.get()
vol = self.nova('volume').volumes.get(volume_id)
logger.info('un-attaching %s, status %s' % (volume_id, vol.status))
while vol.status == 'in-use':
logger.info('trying to un-attach %s, but still %s' %
(volume_id, vol.status))
eventlet.sleep(1)
try:
volapi.delete_server_volume(server_id,
volume_id)
except Exception:
pass
vol.get()
except NotFound as e:
logger.warning('Deleting VolumeAttachment %s %s - not found' %
(server_id, volume_id))
return