python 2.7 - Openstack output in json format -


i using novaclient details openstack. able retrieve information, want convert json format. using "to_dic()" it;s throwing "attribute" error on "server_details = server_id_name.to_dict()", not sure why.

attributeerror: "'tuple' object has no attribute 'to_dict'" 

code given below,

from novaclient import client 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() server in nova.servers.list():     print server.id, server.name     server_id_name = server.id, server.name     server_details = server_id_name.to_dict()     network in server.networks.items():         print network 

it's error in python code. should use

server_details[server.id] = server.name 

to replace code

server_id_name = server.id, server.name server_details = server_id_name.to_dict() 

btw, should learn more python. if want change tuple dict, should see python-tuple-to-dict


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -