我正在使用 novaclient 从 Openstack 获取详细信息。我能够检索信息,但是我想将其转换为 json 格式。我正在使用“to_dic()”,但它在“server_details = server_id_name.to_dict()”上抛出“属性”错误,不知道为什么。
AttributeError: "'tuple' object has no attribute 'to_dict'"
代码如下,
from novaclient import client as novaclient
import json
nova = novaclient.Client(version='2.0',username='xxxx',api_key='xxxx',project_id='xxxx',auth_url='http://192.168.12.3:5000/v2.0/',insecure='True')
server_details = dict()
server = nova.servers.list()
for server in nova.servers.list():
print server.id, server.name
server_id_name = server.id, server.name
server_details = server_id_name.to_dict()
for network in server.networks.items():
print network