0
我使用novaclient從Openstack獲取詳細信息。我能夠檢索信息,但是我想將其轉換爲json格式。我使用「to_dic()」,但它在「server_details = server_id_name.to_dict()」上拋出「Attribute」錯誤,不知道爲什麼。json格式的Openstack輸出
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
謝謝並同意,我是新來的蟒蛇! – tgcloud