Merge "Ignore NotFound error in prepare_for_replace" into stable/pike
This commit is contained in:
commit
75bf7a3f17
@ -579,6 +579,8 @@ class Port(neutron.NeutronResource):
|
||||
if self.resource_id is None:
|
||||
return
|
||||
# store port fixed_ips for restoring after failed update
|
||||
# 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 []
|
||||
|
@ -681,6 +681,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)
|
||||
|
Loading…
Reference in New Issue
Block a user