Merge "NSX|V3: Fix update network rollback"
This commit is contained in:
commit
d3546ea6db
@ -1486,6 +1486,10 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
|
|||||||
LOG.exception("Unable to update NSX backend, rolling "
|
LOG.exception("Unable to update NSX backend, rolling "
|
||||||
"back changes on neutron")
|
"back changes on neutron")
|
||||||
with excutils.save_and_reraise_exception():
|
with excutils.save_and_reraise_exception():
|
||||||
|
# remove the AZ from the network before rollback because
|
||||||
|
# it is read only, and breaks the rollback
|
||||||
|
if 'availability_zone_hints' in original_net:
|
||||||
|
del original_net['availability_zone_hints']
|
||||||
super(NsxV3Plugin, self).update_network(
|
super(NsxV3Plugin, self).update_network(
|
||||||
context, id, {'network': original_net})
|
context, id, {'network': original_net})
|
||||||
|
|
||||||
|
@ -695,6 +695,21 @@ class TestNetworksV2(test_plugin.TestNetworksV2, NsxV3PluginTestCaseMixin):
|
|||||||
|
|
||||||
self.assertEqual(ctx_manager.exception.code, 503)
|
self.assertEqual(ctx_manager.exception.code, 503)
|
||||||
|
|
||||||
|
def test_update_network_rollback(self):
|
||||||
|
with self.network() as net:
|
||||||
|
# Fail the backend update
|
||||||
|
with mock.patch("vmware_nsxlib.v3.core_resources."
|
||||||
|
"NsxLibLogicalSwitch.update",
|
||||||
|
side_effect=nsxlib_exc.ManagerError):
|
||||||
|
args = {'network': {'description': 'test rollback'}}
|
||||||
|
req = self.new_update_request('networks', args,
|
||||||
|
net['network']['id'], fmt='json')
|
||||||
|
res = self.deserialize('json', req.get_response(self.api))
|
||||||
|
# should fail with the nsxlib error (meaning that the rollback
|
||||||
|
# did not fail)
|
||||||
|
self.assertEqual('ManagerError',
|
||||||
|
res['NeutronError']['type'])
|
||||||
|
|
||||||
|
|
||||||
class TestSubnetsV2(test_plugin.TestSubnetsV2, NsxV3PluginTestCaseMixin):
|
class TestSubnetsV2(test_plugin.TestSubnetsV2, NsxV3PluginTestCaseMixin):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user