Merge "Fix cleanup upon metadata failure"
This commit is contained in:
commit
d186c36403
@ -111,6 +111,7 @@ class NsxVPluginV2(agents_db.AgentDbMixin,
|
||||
|
||||
def __init__(self):
|
||||
super(NsxVPluginV2, self).__init__()
|
||||
self.metadata_proxy_handler = None
|
||||
config.validate_nsxv_config_options()
|
||||
neutron_extensions.append_api_extensions_path([vmware.NSX_EXT_PATH])
|
||||
|
||||
@ -141,9 +142,9 @@ class NsxVPluginV2(agents_db.AgentDbMixin,
|
||||
and cfg.CONF.nsxv.mgt_net_moid
|
||||
and cfg.CONF.nsxv.mgt_net_proxy_ips
|
||||
and cfg.CONF.nsxv.mgt_net_proxy_netmask)
|
||||
self.metadata_proxy_handler = (
|
||||
nsx_v_md_proxy.NsxVMetadataProxyHandler(self)
|
||||
if has_metadata_cfg else None)
|
||||
if has_metadata_cfg:
|
||||
self.metadata_proxy_handler = (
|
||||
nsx_v_md_proxy.NsxVMetadataProxyHandler(self))
|
||||
|
||||
def _create_security_group_container(self):
|
||||
name = "OpenStack Security Group container"
|
||||
|
@ -23,7 +23,6 @@ from neutron.common import constants
|
||||
from neutron import context as neutron_context
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import excutils
|
||||
|
||||
from neutron.i18n import _LE
|
||||
from vmware_nsx.neutron.plugins.vmware.common import exceptions as nsxv_exc
|
||||
@ -151,18 +150,18 @@ class NsxVMetadataProxyHandler:
|
||||
internal_net, internal_subnet = (
|
||||
self._create_metadata_internal_network(INTERNAL_SUBNET))
|
||||
except Exception as e:
|
||||
with excutils.save_and_reraise_exception():
|
||||
nsxv_db.delete_nsxv_internal_network(
|
||||
self.context.session,
|
||||
vcns_const.InternalEdgePurposes.INTER_EDGE_PURPOSE)
|
||||
nsxv_db.delete_nsxv_internal_network(
|
||||
self.context.session,
|
||||
vcns_const.InternalEdgePurposes.INTER_EDGE_PURPOSE)
|
||||
|
||||
# if network is created, clean up
|
||||
if internal_net:
|
||||
self.nsxv_plugin.delete_network(self.context,
|
||||
internal_net)
|
||||
# if network is created, clean up
|
||||
if internal_net:
|
||||
self.nsxv_plugin.delete_network(self.context,
|
||||
internal_net)
|
||||
|
||||
LOG.exception(_LE("Exception %s while creating internal "
|
||||
"network for metadata service"), e)
|
||||
LOG.exception(_LE("Exception %s while creating internal "
|
||||
"network for metadata service"), e)
|
||||
return
|
||||
|
||||
# Update the new network_id in DB
|
||||
nsxv_db.create_nsxv_internal_network(
|
||||
@ -382,16 +381,23 @@ class NsxVMetadataProxyHandler:
|
||||
return edge_ip
|
||||
|
||||
except Exception as e:
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.exception(_LE("Exception %s while creating internal edge "
|
||||
"for metadata service"), e)
|
||||
LOG.exception(_LE("Exception %s while creating internal edge "
|
||||
"for metadata service"), e)
|
||||
|
||||
nsxv_db.delete_nsxv_internal_edge(
|
||||
self.context.session,
|
||||
rtr_ext_ip)
|
||||
ports = self.nsxv_plugin.get_ports(
|
||||
self.context, filters={'device_id': [rtr_id]})
|
||||
|
||||
if rtr_id:
|
||||
self.nsxv_plugin.delete_router(self.context, rtr_id)
|
||||
for port in ports:
|
||||
self.nsxv_plugin.delete_port(self.context, port['id'],
|
||||
l3_port_check=True,
|
||||
nw_gw_port_check=True)
|
||||
|
||||
nsxv_db.delete_nsxv_internal_edge(
|
||||
self.context.session,
|
||||
rtr_ext_ip)
|
||||
|
||||
if rtr_id:
|
||||
self.nsxv_plugin.delete_router(self.context, rtr_id)
|
||||
|
||||
def _get_address_groups(self, context, network_id, device_id, is_proxy):
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user