NSX-T+P: Delete subnet in case of dhcp error

If backend errors out during dhcp config, delete neutron subnet that
was already created.

Change-Id: I526b25c84fc55eed23f9d7f3fa9ac160ed1627df
This commit is contained in:
Anna Khmelnitsky 2019-01-04 14:39:08 -08:00 committed by Adit Sarfaty
parent da9414f192
commit 17759dba87
1 changed files with 8 additions and 2 deletions

View File

@ -1409,8 +1409,14 @@ class NsxPluginV3Base(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
subnet['subnet']['network_id']).dhcp_relay_service
if not dhcp_relay:
if self.nsxlib:
self._enable_native_dhcp(context, network,
created_subnet)
try:
self._enable_native_dhcp(context, network,
created_subnet)
except nsx_lib_exc.ManagerError:
with excutils.save_and_reraise_exception():
super(NsxPluginV3Base,
self).delete_subnet(
context, created_subnet['id'])
else:
msg = (_("Native DHCP is not supported since "
"passthough API is disabled"))