简体   繁体   English

novaclient身份验证期间出现urlsplit错误

[英]urlsplit error during novaclient authentication

So I've got some OpenStack gear and I'm sick of fighting with the dashboard, so I'd like to write my own bit of automation in python. 所以我有了一些OpenStack的工具,我讨厌与仪表板打架,所以我想用python编写自己的自动化工具。 However, I've barely even gotten my feet wet and I'm running into problems. 但是,我什至没有弄湿我的脚,并且遇到了麻烦。

Code: 码:

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

Error: 错误:

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'

All of the connection info has come from the environment variables on the controller, so I know that that should be correct, and I've tried swapping the tenant name with the project ID but still no joy. 所有的连接信息都来自控制器上的环境变量,因此我知道这应该是正确的,并且我尝试将租户名称与项目ID交换,但仍然不满意。 I have no idea why it's throwing this error all the way down in urlparse, or why it appears to be using the 1.1 client even though I've specified v2. 我不知道为什么它会在urlparse中彻底抛出该错误,或​​者即使我指定了v2,为什么它似乎仍在使用1.1客户端。

Also, I get the same error whether or not I use keystone auth, I figured it was my best bet since OS_AUTH_STRATEGY=keystone in the controller's rc file. 另外,无论是否使用梯形失真验证,都会出现相同的错误,我认为这是我最好的选择,因为控制器的rc文件中的OS_AUTH_STRATEGY=keystone

Lastly, in case it's helpful, during the imports I also get the following deprecation warnings: 最后,如果有帮助,在导入期间,我还会收到以下弃用警告:

/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

You have some errors in your code. 您的代码中有一些错误。 Take a closer look at the api documentation . 请仔细阅读api文档 If you call: 如果您致电:

nova = Client(2, sess)

Then sess isn't getting passes to the session keyword parameter. sess不会传递给session关键字参数。 You want: 你要:

nova = Client(2, session=sess)

And you don't need to call nova.authenticate() . 而且您不需要调用nova.authenticate()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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