简体   繁体   中英

openstack python api script getting SSL error

I have build new openstack based on Queens release and now trying to learn python SDK api script and stuck here not sure what is wrong.

my script

from keystoneclient.auth.identity import v3
from keystoneclient import session
from keystoneclient.v3 import client
auth_url = 'http://172.28.0.9:5000/v3'
username = 'dev'
user_domain_name = 'Default'
project_name = 'dev'
project_domain_name = 'Default'
password = 'Password123'
auth = v3.Password(auth_url=auth_url,
                   username=username,
                   password=password,
                   project_id='344506541fd94f068d25990af3eff4b8',
                   user_domain_name=user_domain_name)
sess = session.Session(auth=auth)
keystone = client.Client(session=sess)
#keystone.projects.list()

from novaclient import client
nova = client.Client(2, session=keystone.session)
nova.flavors.list()

Getting error

[dev@openstack ~]$ python /tmp/myscript.py
/usr/lib/python2.7/site-packages/keystoneauth1/adapter.py:200: UserWarning: Using keystoneclient sessions has been deprecated. Please update your software to use keystoneauth1.
  warnings.warn('Using keystoneclient sessions has been deprecated. '
Traceback (most recent call last):
  File "/tmp/o.py", line 22, in <module>
    nova.flavors.list()
  File "/usr/lib/python2.7/site-packages/novaclient/v2/flavors.py", line 145, in list
    return self._list("/flavors%s" % detail, "flavors", filters=qparams)
  File "/usr/lib/python2.7/site-packages/novaclient/base.py", line 257, in _list
    resp, body = self.api.client.get(url)
  File "/usr/lib/python2.7/site-packages/keystoneauth1/adapter.py", line 328, in get
    return self.request(url, 'GET', **kwargs)
  File "/usr/lib/python2.7/site-packages/novaclient/client.py", line 77, in request
    **kwargs)
  File "/usr/lib/python2.7/site-packages/keystoneauth1/adapter.py", line 487, in request
    resp = super(LegacyJsonAdapter, self).request(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/keystoneauth1/adapter.py", line 213, in request
    return self.session.request(url, method, **kwargs)
  File "/usr/lib/python2.7/site-packages/keystoneclient/session.py", line 428, in request
    resp = send(**kwargs)
  File "/usr/lib/python2.7/site-packages/keystoneclient/session.py", line 466, in _send_request
    raise exceptions.SSLError(msg)
keystoneauth1.exceptions.connection.SSLError: SSL exception connecting to https://10.30.2.9:8774/v2.1/flavors/detail: HTTPSConnectionPool(host='10.30.2.9', port=8774): Max retries exceeded with url: /v2.1/flavors/detail (Caused by SSLError(SSLError("bad handshake: SysCallError(104, 'ECONNRESET')",),))

10.30.2.9 is my F5 load-balancer and i did configured 8774 correctly route to nova api server.

my horizon GUI working fine and also all openstack commands working fine without error.

verify=False帮助:

keystone = client.Client(session=sess, verify=False)

You need to include the certificate for SSL.

sess = session.Session(auth=auth, verify=path_to_certificate)
        keystone = keystoneclient.Client(session=sess)

Perhaps there is an option to disable SSL.

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