summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-10-12 09:32:54 +0000
committerGerrit Code Review <review@openstack.org>2013-10-12 09:32:54 +0000
commitfa85221f9e470410aa6c4b5fff8cef6c5b186afd (patch)
treefaf2962f6bdb86e8cceb1815e05ed310416ebcce
parent55b969e617cbaf8f7f36a9dbdd5ab4edde5fc299 (diff)
parent2aa4186dde97e580694b88ad22dad4db657cc5ad (diff)
downloadheat-2013.2.tar.gz
Merge "Fix heat deletion failed if floating ip is not found" into milestone-proposed2013.2.rc22013.2
-rw-r--r--heat/engine/resources/eip.py5
-rw-r--r--heat/tests/test_eip.py20
2 files changed, 24 insertions, 1 deletions
diff --git a/heat/engine/resources/eip.py b/heat/engine/resources/eip.py
index 23e8aa463..c18afc279 100644
--- a/heat/engine/resources/eip.py
+++ b/heat/engine/resources/eip.py
@@ -118,7 +118,10 @@ class ElasticIp(resource.Resource):
if e.status_code != 404:
raise e
else:
- self.nova().floating_ips.delete(self.resource_id)
+ try:
+ self.nova().floating_ips.delete(self.resource_id)
+ except clients.novaclient.exceptions.NotFound:
+ pass
def FnGetRefId(self):
return unicode(self._ipaddress())
diff --git a/heat/tests/test_eip.py b/heat/tests/test_eip.py
index 8ded59ccd..63f432b7f 100644
--- a/heat/tests/test_eip.py
+++ b/heat/tests/test_eip.py
@@ -12,6 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+import mox
+
from testtools import skipIf
from heat.common import exception
@@ -223,6 +225,24 @@ class EIPTest(HeatTestCase):
rsrc.handle_create)
self.m.VerifyAll()
+ def test_delete_eip_with_exception(self):
+ self.m.StubOutWithMock(self.fc.floating_ips, 'delete')
+ eip.ElasticIp.nova().MultipleTimes().AndReturn(self.fc)
+ self.fc.floating_ips.delete(mox.IsA(object)).AndRaise(
+ clients.novaclient.exceptions.NotFound('fake_falure'))
+ self.fc.servers.get(mox.IsA(object)).AndReturn(False)
+ self.m.ReplayAll()
+
+ t = template_format.parse(eip_template)
+ stack = utils.parse_stack(t)
+ resource_name = 'IPAddress'
+ rsrc = eip.ElasticIp(resource_name,
+ t['Resources'][resource_name],
+ stack)
+ rsrc.resource_id = 'fake_id'
+ rsrc.handle_delete()
+ self.m.VerifyAll()
+
class AllocTest(HeatTestCase):