From e8415b2594fa0c9d9cb4b69c63bce22adcce2ee6 Mon Sep 17 00:00:00 2001 From: songbaisen Date: Wed, 7 Mar 2018 20:02:52 +0800 Subject: [PATCH] use the better way to handle the not found exception 1. What is the problem? When local neutron get the in deleting resource, we should return 404 not found. in before i used the _delete tag to handle it. but do not look like a good way. 2. What is the solution to the problem? Try hanlde it in the local and raise the network not found exception. 3. What the features to be implemented in the Tricircle to realize the solution? No new features. Change-Id: Iceacaa83e9b31d05a2435586e8bbb3b433d90a4b Signed-off-by: song baisen --- tricircle/network/central_plugin.py | 10 ++-------- tricircle/network/local_plugin.py | 5 +++-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/tricircle/network/central_plugin.py b/tricircle/network/central_plugin.py index 9febd349..cdcc478f 100644 --- a/tricircle/network/central_plugin.py +++ b/tricircle/network/central_plugin.py @@ -559,10 +559,6 @@ class TricirclePlugin(db_base_plugin_v2.NeutronDbPluginV2, return policy['id'] if policy else None def get_network(self, context, network_id, fields=None): - delete = False - if network_id.endswith('_delete'): - delete = True - network_id = network_id[0: network_id.find('_delete')] dict_para = {'resource_id': network_id, 'resource_type': 'network'} try: @@ -570,10 +566,8 @@ class TricirclePlugin(db_base_plugin_v2.NeutronDbPluginV2, except t_exceptions.ResourceIsInDeleting(): return network_id except t_exceptions.ResourceNotFound: - if delete: - pass - else: - raise exceptions.NotFound() + raise exceptions.NotFound() + net = super(TricirclePlugin, self).get_network(context, network_id, fields) diff --git a/tricircle/network/local_plugin.py b/tricircle/network/local_plugin.py index b30b406e..c72a1f1e 100644 --- a/tricircle/network/local_plugin.py +++ b/tricircle/network/local_plugin.py @@ -182,9 +182,10 @@ class TricirclePlugin(plugin.Ml2Plugin): t_ctx = t_context.get_context_from_neutron_context(context) if self._skip_non_api_query(t_ctx): return [] - para = network['id'] + '_delete' t_network = self.neutron_handle.handle_get( - t_ctx, 'network', para) + t_ctx, 'network', network['id']) + if not t_network: + return [] return self._ensure_subnet(context, t_network) if not subnet_ids: return []