'Uplink tenant subnet(s) to external network.'

def _provision_external_connectivity(self, context, default_external_network, subnets, tenant_id):

    router_args = {'name': 'auto_allocated_router', l3.EXTERNAL_GW_INFO: {'network_id': default_external_network}, 'tenant_id': tenant_id, 'admin_state_up': True}
    router = None
    attached_subnets = []
    try:
        router = self.l3_plugin.create_router(context, {'router': router_args})
        for subnet in subnets:
            self.l3_plugin.add_router_interface(context, router['id'], {'subnet_id': subnet['id']})
            attached_subnets.append(subnet)
        return router
    except n_exc.BadRequest as e:
        LOG.error(_LE('Unable    to    auto    allocate    topology    for    tenant    %(tenant_id)s    because    of    router    errors.    Reason:    %(reason)s'), {'tenant_id': tenant_id, 'reason': e})
        router_id = (router['id'] if router else None)
        self._cleanup(context, network_id=subnets[0]['network_id'], router_id=router_id, subnets=attached_subnets)
        raise exceptions.AutoAllocationFailure(reason=_('Unable    to    provide    external    connectivity'))
    except Exception as e:
        router_id = (router['id'] if router else None)
        raise exceptions.UnknownProvisioningError(e, network_id=subnets[0]['network_id'], router_id=router_id, subnets=subnets)
