所以我有一些OpenStack设备,我厌倦了与仪表板的斗争,所以我想用python编写自己的自动化。然而,我连脚都没湿,我遇到了问题。
代码:
from keystoneclient.auth.identity import v2
from keystoneclient import session
from novaclient.client import Client
auth = v2.Password(auth_url='http://10.0.0.1:5000/v2.0/', username='foo.bla-admin',
password='hunter2', tenant_name='foo.bla')
sess = session.Session(auth=auth)
nova = Client(2, sess)
print nova.authenticate()
错误:
Traceback (most recent call last):
File "test.py", line 13, in <module>
print nova.authenticate()
File "/usr/lib/python2.6/site-packages/novaclient/client.py", line 169, in wrapper
return f(self, *args, **kwargs)
File "/usr/lib/python2.6/site-packages/novaclient/v1_1/client.py", line 239, in authenticate
self.client.authenticate()
File "/usr/lib/python2.6/site-packages/novaclient/client.py", line 561, in authenticate
magic_tuple = netutils.urlsplit(self.auth_url)
File "/usr/lib/python2.6/site-packages/oslo_utils/netutils.py", line 228, in urlsplit
url, scheme, allow_fragments)
File "/usr/lib64/python2.6/urlparse.py", line 171, in urlsplit
i = url.find(':')
AttributeError: 'NoneType' object has no attribute 'find'
所有的连接信息都来自控制器上的环境变量,所以我知道这应该是正确的,我已经尝试将租户名称与项目ID交换,但仍然没有任何乐趣。我不知道为什么它会在urlparse中一直抛出这个错误,也不知道为什么即使我指定了v2,它仍然使用1.1客户端。
此外,无论我是否使用keystone身份验证,我都会遇到同样的错误,我认为这是我自
OS_AUTH_STRATEGY=keystone
在控制器的rc文件中。
最后,如果有帮助,在导入过程中,我还会收到以下弃用警告:
/usr/lib/python2.6/site-packages/keystoneclient/access.py:20: DeprecationWarning: The oslo namespace package is deprecated. Please use oslo_utils instead.
from oslo.utils import timeutils
/usr/lib/python2.6/site-packages/keystoneclient/i18n.py:21: DeprecationWarning: The oslo namespace package is deprecated. Please use oslo_i18n instead.
from oslo import i18n
/usr/lib/python2.6/site-packages/keystoneclient/session.py:20: DeprecationWarning: The oslo namespace package is deprecated. Please use oslo_config instead.
from oslo.config import cfg
/usr/lib/python2.6/site-packages/keystoneclient/session.py:21: DeprecationWarning: The oslo namespace package is deprecated. Please use oslo_serialization instead.
from oslo.serialization import jsonutils