OpenStack Python API脚本收到SSL错误

时间:2018-11-25 22:03:05

标签: python openstack python-novaclient

我已经基于Queens版本构建了一个新的openstack,现在尝试学习python SDK api脚本并被卡在这里,不确定什么地方出错了。

我的脚本

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()

遇到错误

[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是我的F5负载平衡器,并且我确实配置了8774正确地路由到nova api服务器。

我的horizo​​n GUI正常运行,所有openstack命令也正常运行而没有错误。

2 个答案:

答案 0 :(得分:1)

verify=False帮助:

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

答案 1 :(得分:0)

您需要包括SSL证书。

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

也许有一个禁用SSL的选项。