如何序列化 openstack.compute.v2.server.ServerDetail ?
我使用openstacksdk开发自己的 openstack 应用程序。
但是当我得到我的连接生成器时:
user_conn = UserOpenstackConn()
openstack_servers_gen = user_conn.conn.compute.servers()
我可以使用 list() 将 openstack_servers_gen 转换为列表:
: [openstack.compute.v2.server.ServerDetail(OS-EXT-AZ:availability_zone=, key_name=None, hostId=, os-extended-volumes:volumes_attached=[], OS-SRV-USG:launched_at=None, OS -EXT-STS:vm_state=error, flavor={'id': '5c5dca53-9f96-4851-afd4-60de75faf896', 'links': [{'href': ' http://controller:8774/233cf23186bf4c52afc464ee008cdf7f/flavors /5c5dca53-9f96-4851-afd4-60de75faf896 ', 'rel': '书签'}]}, 更新=2017-11-27T10:29:50Z, accessIPv4=, image={'id': '60f4005e-5daf- 4aef-a018-4c6b2ff06b40','链接':[{'href':' http://controller:8774/233cf23186bf4c52afc464ee008cdf7f/images/60f4005e-5daf-4aef-a018-4c6b2ff06b40 ','rel':'书签'} },创建=2017-11-27T10:29:49Z,元数据={},链接=[{'':'http://controller:8774/v2.1/233cf23186bf4c52afc464ee008cdf7f/servers/3db46b7b-a641-49ce-97ef-f17c9a11f58a ', 'rel': 'self'}, {'href': ' http://controller:8774/ 233cf23186bf4c52afc464ee008cdf7f/servers/3db46b7b-a641-49ce-97ef-f17c9a11f58a', 'rel': '书签'}], OS-DCF:diskConfig=MANUAL, id=3db46b7b-a641-49ce-97ef-f17c9a11f58a, user_id=41bb48ee30e449d5868f7af9e6251156, OS-SRV-USG:terminated_at=None, name=123456, config_drive=, accessIPv6=, OS-EXT-STS:power_state=0, 地址={}, OS-EXT-STS:task_state=None, status=ERROR, tenant_id=233cf23186bf4c52afc464ee008cdf7f), openstack.compute.v2.server.ServerDetail( OS-EXT-AZ:availability_zone=, key_name=None, hostId=, os-extended-volumes:volumes_attached=[], OS-SRV-USG:launched_at=None, OS-EXT-STS:vm_state=error, flavor={ 'id': '5c5dca53-9f96-4851-afd4-60de75faf896', '链接': [{'href': ' http://controller:8774/233cf23186bf4c52afc464ee008cdf7f/flavors/5c5dca53-9f96-4851-afd4-60de75', 'rel': '书签'}]}, 更新=2017-11-27T10:27:42Z, accessIPv4=, image={'id': '60f4005e-5daf-4aef-a018-4c6b2ff06b40', '链接' : [{'href': ' http://controller:8774/233cf23186bf4c52afc464ee008cdf7f/images/60f4005e-5daf-4aef-a018-4c6b2ff06b40 ', 'rel': '书签'}]}, created=2017-11-27T10: 27:41Z,元数据={},链接=[{'href':' http://controller:8774/v2.1/233cf23186bf4c52afc464ee008cdf7f/servers/721467ac-440f-4784-b825-f6155c65abee ','rel':' self'}, {'href':' http://controller:8774/233cf23186bf4c52afc464ee008 ......
但是我怎样才能让它在我的项目中可序列化呢?
比如如果我写序列化器来映射它我不知道如何处理下面的键:
os-extended-volumes:volumes_attached
EDIT-1 x
我打开另一个帖子,可能与此帖子相关: