def _delete_lrouter(self, context, id):
        if not self._is_advanced_service_router(context, id):
            super(NvpAdvancedPlugin, self)._delete_lrouter(context, id)
            if id in self._router_type:
                del self._router_type[id]
            return

        binding = vcns_db.get_vcns_router_binding(context.session, id)
        if binding:
            vcns_db.update_vcns_router_binding(
                context.session, id, status=service_constants.PENDING_DELETE)

            lswitch_id = binding['lswitch_id']
            edge_id = binding['edge_id']

            # delete lswitch
            try:
                self.vcns_driver.delete_lswitch(lswitch_id)
            except exceptions.ResourceNotFound:
                LOG.warning(_("Did not found lswitch %s in NVP"), lswitch_id)

            # delete edge
            jobdata = {
                'context': context
            }
            self.vcns_driver.delete_edge(id, edge_id, jobdata=jobdata)

        # delete LR
        nvplib.delete_lrouter(self.cluster, id)
        if id in self._router_type:
            del self._router_type[id]
    def _create_lrouter(self, context, router, nexthop):
        lrouter = super(NvpAdvancedPlugin, self)._create_lrouter(
            context, router, vcns_const.INTEGRATION_EDGE_IPADDRESS)

        router_type = self._find_router_type(router)
        self._set_router_type(lrouter['uuid'], router_type)
        if router_type == ROUTER_TYPE_BASIC:
            return lrouter

        tenant_id = self._get_tenant_id_for_create(context, router)
        name = router['name']
        try:
            lsname = name[:36] + '-ls'
            lswitch = self._create_integration_lswitch(
                tenant_id, lsname)
        except Exception:
            msg = _("Unable to create integration logic switch "
                    "for router %s") % name
            LOG.exception(msg)
            nvplib.delete_lrouter(self.cluster, lrouter['uuid'])
            raise q_exc.NeutronException(message=msg)

        try:
            self._add_router_integration_interface(tenant_id, name,
                                                   lrouter, lswitch)
        except Exception:
            msg = _("Unable to add router interface to integration lswitch "
                    "for router %s") % name
            LOG.exception(msg)
            nvplib.delete_lrouter(self.cluster, lrouter['uuid'])
            raise q_exc.NeutronException(message=msg)

        try:
            self._create_advanced_service_router(
                context, name, lrouter, lswitch)
        except Exception:
            msg = (_("Unable to create advance service router for %s") % name)
            LOG.exception(msg)
            self.vcns_driver.delete_lswitch(lswitch('uuid'))
            nvplib.delete_lrouter(self.cluster, lrouter['uuid'])
            raise q_exc.NeutronException(message=msg)

        lrouter['status'] = service_constants.PENDING_CREATE
        return lrouter