'Retrieve a router for the given tenant id.
If a public router has been configured, it will be returned.
If a public router has not been configured, but a public
network has, a tenant router will be created and returned that
routes traffic to the public network.'

def _get_router(self, client=None, tenant_id=None):

    if (not client):
        client = self.routers_client
    if (not tenant_id):
        tenant_id = client.tenant_id
    router_id = CONF.network.public_router_id
    network_id = CONF.network.public_network_id
    if router_id:
        body = client.show_router(router_id)
        return body['router']
    elif network_id:
        router = self._create_router(client, tenant_id)
        kwargs = {'external_gateway_info': dict(network_id=network_id)}
        router = client.update_router(router['id'], **kwargs)['router']
        return router
    else:
        raise Exception("Neither    of    'public_router_id'    or    'public_network_id'    has    been    defined.")
