summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-08-08 17:34:07 +0000
committerGerrit Code Review <review@openstack.org>2018-08-08 17:34:07 +0000
commit21a4740a885184a95b37758d2b816443633db953 (patch)
tree503d3d734c7309d474e37006e1bba1eca0f10470
parentec32eb4c733e96e0e1bc219c6819058b947a0d70 (diff)
parent41fd13174549ab62be55906a1b2c0b5aff05335b (diff)
downloadheat-ocata-em.tar.gz
Merge "Ignore NotFound error in prepare_for_replace" into stable/ocataocata-em8.0.7
-rw-r--r--heat/engine/resources/openstack/neutron/port.py12
-rw-r--r--heat/tests/openstack/neutron/test_neutron_port.py19
2 files changed, 26 insertions, 5 deletions
diff --git a/heat/engine/resources/openstack/neutron/port.py b/heat/engine/resources/openstack/neutron/port.py
index 4ca10292c..6e12a1a8f 100644
--- a/heat/engine/resources/openstack/neutron/port.py
+++ b/heat/engine/resources/openstack/neutron/port.py
@@ -529,11 +529,13 @@ class Port(neutron.NeutronResource):
if self.resource_id is None:
return
# store port fixed_ips for restoring after failed update
- fixed_ips = self._show_resource().get('fixed_ips', [])
- self.data_set('port_fip', jsonutils.dumps(fixed_ips))
- # reset fixed_ips for this port by setting fixed_ips to []
- props = {'fixed_ips': []}
- self.client().update_port(self.resource_id, {'port': props})
+ # Ignore if the port does not exist in neutron (deleted)
+ with self.client_plugin().ignore_not_found:
+ fixed_ips = self._show_resource().get('fixed_ips', [])
+ self.data_set('port_fip', jsonutils.dumps(fixed_ips))
+ # reset fixed_ips for this port by setting fixed_ips to []
+ props = {'fixed_ips': []}
+ self.client().update_port(self.resource_id, {'port': props})
def restore_prev_rsrc(self, convergence=False):
# In case of convergence, during rollback, the previous rsrc is
diff --git a/heat/tests/openstack/neutron/test_neutron_port.py b/heat/tests/openstack/neutron/test_neutron_port.py
index d0b3a1fea..1410ecfba 100644
--- a/heat/tests/openstack/neutron/test_neutron_port.py
+++ b/heat/tests/openstack/neutron/test_neutron_port.py
@@ -605,6 +605,25 @@ class NeutronPortTest(common.HeatTestCase):
self.assertFalse(port.data_set.called)
self.assertFalse(n_client.update_port.called)
+ def test_prepare_for_replace_port_not_found(self):
+ t = template_format.parse(neutron_port_template)
+ stack = utils.parse_stack(t)
+ port = stack['port']
+ port.resource_id = 'test_res_id'
+ port._show_resource = mock.Mock(side_effect=qe.NotFound)
+ port.data_set = mock.Mock()
+ n_client = mock.Mock()
+ port.client = mock.Mock(return_value=n_client)
+
+ # execute prepare_for_replace
+ port.prepare_for_replace()
+
+ # check, if the port is not found, do nothing in
+ # prepare_for_replace()
+ self.assertTrue(port._show_resource.called)
+ self.assertFalse(port.data_set.called)
+ self.assertFalse(n_client.update_port.called)
+
def test_prepare_for_replace_port(self):
t = template_format.parse(neutron_port_template)
stack = utils.parse_stack(t)