def delete_router(self, context, id): with context.session.begin(subtransactions=True): router = self._get_router(context, id) # Ensure that the router is not used fips = self.get_floatingips_count(context.elevated(), filters={'router_id': [id]}) if fips: raise l3.RouterInUse(router_id=id) device_filter = { 'device_id': [id], 'device_owner': [DEVICE_OWNER_ROUTER_INTF] } ports = self.get_ports_count(context.elevated(), filters=device_filter) if ports: raise l3.RouterInUse(router_id=id) # delete any gw port device_filter = { 'device_id': [id], 'device_owner': [DEVICE_OWNER_ROUTER_GW] } ports = self.get_ports(context.elevated(), filters=device_filter) if ports: self._delete_port(context.elevated(), ports[0]['id']) context.session.delete(router) l3_rpc_agent_api.L3AgentNotify.router_deleted(context, id)
def delete_router(self, context, id): with context.session.begin(subtransactions=True): router = self._get_router(context, id) device_filter = { 'device_id': [id], 'device_owner': [DEVICE_OWNER_ROUTER_INTF] } ports = self.get_ports(context, filters=device_filter) if ports: raise l3.RouterInUse(router_id=id) # NOTE(salvatore-orlando): gw port will be automatically deleted # thanks to cascading on the ORM relationship context.session.delete(router)
def delete_router(self, context, id): with context.session.begin(subtransactions=True): router = self._get_router(context, id) device_filter = { 'device_id': [id], 'device_owner': [DEVICE_OWNER_ROUTER_INTF] } ports = self.get_ports(context, filters=device_filter) if ports: raise l3.RouterInUse(router_id=id) # delete any gw port device_filter = { 'device_id': [id], 'device_owner': [DEVICE_OWNER_ROUTER_GW] } ports = self.get_ports(context.elevated(), filters=device_filter) if ports: self._delete_port(context.elevated(), ports[0]['id']) context.session.delete(router)