Openstack python客户端
我正在尝试这个玩具代码来初始化python客户端库Openstack python客户端,python,openstack,Python,Openstack,我正在尝试这个玩具代码来初始化python客户端库 #!/usr/bin/python from novaclient.client import Client nova = Client(2, "####", "####", "####" , "####:8774/v2.0") _test = nova.images.list() print _test 但我总是犯这样的错误: 有人知道这会是什么样的问题吗 您将python novaclient用作一个库,而它从
#!/usr/bin/python
from novaclient.client import Client
nova = Client(2, "####", "####", "####" , "####:8774/v2.0")
_test = nova.images.list()
print _test
但我总是犯这样的错误:
有人知道这会是什么样的问题吗 您将python novaclient用作一个库,而它从来没有被设计成这样使用。不幸的是,这是一个被人们用作库的CLI 尝试一下官方的Python OpenStack SDK
pip install openstacksdk
用于列出图像的代码
import sys
from openstack import connection
from openstack import profile
from openstack import utils
utils.enable_logging(True, stream=sys.stdout)
prof = profile.Profile()
prof.set_region(prof.ALL, "RegionOne")
conn = connection.Connection(
auth_url='https://my.identity.endpoint/v2.0/',
profile=prof,
username="my_username",
password="my_password")
for image in conn.compute.images():
print(image)
更多可能有用的信息:
- 您只需要一个好的例子,请参考:
特别是,如果您的用户名是admin,密码是password,项目名称是admin,keystone端点是,那么它应该是
>>> nova = client.Client(2, 'admin', 'password', 'admin', 'http://127.0.0.1:5000')
请注意,验证url是keystone endpoint,而不是nova endpoint。如果尝试CLI,是否会获得映像?使用CLI工具,您可以使用:
nova image list
执行此操作,我收到以下消息:找不到记录器“keystoneclient.auth.identity.generic.base”错误的处理程序(InvalidResponse):我应该补充一点,在使用CLI工具之前,您需要正确地获取环境变量的源代码,以便能够首先根据keystone进行身份验证。创建和获取OpenStack RC文件的源代码时,请遵循此链接中“创建和获取OpenStack RC文件”下的步骤
>>> nova = client.Client(2, 'admin', 'password', 'admin', 'http://127.0.0.1:5000')