From 5443453fbbaab761a42023c556ee7ed4c55d60ba Mon Sep 17 00:00:00 2001 From: Sergey Kraynev Date: Thu, 15 Sep 2016 04:08:20 -0400 Subject: [PATCH] Allow update inplace for allowed_address_pairs This patch allows to do update inplace for allowed_address_pairs properties. Scenario mentioned in bug works correct now. Also add couple fixes to related test: - Add explicit translation name to string, otherwise it returns objects, that raise error during resolving Property name, which should be a string. - Add check, that update of any of mentioned properties does not cause replace. Change-Id: I913fd36012179f2fdd602f2cca06a89e3fa896f3 Closes-Bug: #1623821 (cherry picked from commit 353e7319dbbff7f10e7cdf664f017a01e15b5168) --- heat/engine/resources/openstack/neutron/port.py | 3 ++- heat/tests/openstack/neutron/test_neutron_port.py | 11 ++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/heat/engine/resources/openstack/neutron/port.py b/heat/engine/resources/openstack/neutron/port.py index 687554b1b..2728a14d8 100644 --- a/heat/engine/resources/openstack/neutron/port.py +++ b/heat/engine/resources/openstack/neutron/port.py @@ -250,7 +250,8 @@ class Port(neutron.NeutronResource): ] ), }, - ) + ), + update_allowed=True, ), VNIC_TYPE: properties.Schema( properties.Schema.STRING, diff --git a/heat/tests/openstack/neutron/test_neutron_port.py b/heat/tests/openstack/neutron/test_neutron_port.py index 348f96bcc..cb2013eb2 100644 --- a/heat/tests/openstack/neutron/test_neutron_port.py +++ b/heat/tests/openstack/neutron/test_neutron_port.py @@ -933,7 +933,7 @@ class UpdatePortTest(common.HeatTestCase): return_value=fake_groups_list) props = {'network_id': u'net1234', - 'name': utils.PhysName(stack.name, 'port'), + 'name': str(utils.PhysName(stack.name, 'port')), 'admin_state_up': True, 'device_owner': u'network:dhcp'} @@ -970,6 +970,15 @@ class UpdatePortTest(common.HeatTestCase): update_props)()) update_port.assset_called_once_with(update_dict) + + # check, that update does not cause of Update Replace + create_snippet = rsrc_defn.ResourceDefinition(port.name, port.type(), + props) + after_props, before_props = port._prepare_update_props(update_snippet, + create_snippet) + self.assertIsNotNone( + port.update_template_diff_properties(after_props, before_props)) + # update with empty prop_diff scheduler.TaskRunner(port.handle_update, update_snippet, {}, {})() self.assertEqual(1, update_port.call_count)