简体   繁体   中英

how to get nova client (v1.1) to use ssh tunnel when retrieving server list

the openstack nova client is giving me fits. i can't figure out how to get it to use a local ssh tunnel url i specify instead of the one it retrieves. so:

from novaclient.v1_1 import client as nova_client
from pprint import pprint

self.__nova_client = nova_client.Client(
    'myusername',
    'mypassword',
    'mytenantname',
    'https://localhost:5443/v2.0',
    service_type='compute',
    insecure=True
)
for server in self.__nova_client.servers.list():
    pprint(server)

yields...

requests.exceptions.ConnectionError: HTTPConnectionPool(host='os-compute.vip.mysubdomain.mydomain.com', port=8774): Max retries exceeded with url: /v2/aa0dffecaef543aca072a26fdff5c92b/servers/detail (Caused by <class 'socket.error'>: [Errno 111] Connection refused)

because the "os-compute.vip.mysubdomain.mydomain.com:8774" address is unreachable from where the script is running.

the self.__nova_client = nova_client.Client() bit connects fine because it uses ' https://localhost:5443/v2.0 ' - the established tunnel i provide. i just need a way to override the "os-compute.vip.mysubdomain.mydomain.com:8774" that it's trying to connect to with a "localhost:8774" tunnel that i set up. but i can't figure out whether/how that's possible.

any guidance will be greatly appreciated.

Your nova client is pulling the service catalogue from keystone through the tunnel setup on your localhost. You will need to explicitly override the endpoint specified in the service catalogue. One way is to explicitly specify the endpoint, while some of the clients allow you to directly specify the endpoint on construction novaclient doesn't, take a look at nova_client.management_url after you've constructed the object and replace it with your localhost address.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM