server 的json解释

示例:

server信息就是虚拟机信息。
下面是一个租户的所有VM的展示:

{
    "servers":[
        {
            "OS-EXT-STS:task_state":null,
            "addresses":{
                "private":[
                    {
                        "OS-EXT-IPS-MAC:mac_addr":"fa:16:3e:64:31:6c",
                        "version":4,
                        "addr":"192.168.1.4",
                        "OS-EXT-IPS:type":"fixed"
                    },
                    {
                        "OS-EXT-IPS-MAC:mac_addr":"fa:16:3e:64:31:6c",
                        "version":4,
                        "addr":"103.35.202.3",
                        "OS-EXT-IPS:type":"floating"
                    }
                ]
            },
            "links":[
                {
                    "href":"http://controller:8774/v2.1/99a50773b170406b8902227118bb72bf/servers/70950ab5-8f83-4114-a024-f40e923cbc08",
                    "rel":"self"
                },
                {
                    "href":"http://controller:8774/99a50773b170406b8902227118bb72bf/servers/70950ab5-8f83-4114-a024-f40e923cbc08",
                    "rel":"bookmark"
                }
            ],
            "image":{
                "id":"ecbd1ef0-7dcf-41ff-8618-4501aa4e3945",
                "links":[
                    {
                        "href":"http://controller:8774/99a50773b170406b8902227118bb72bf/images/ecbd1ef0-7dcf-41ff-8618-4501aa4e3945",
                        "rel":"bookmark"
                    }
                ]
            },
            "OS-EXT-STS:vm_state":"active",
            "OS-EXT-SRV-ATTR:instance_name":"instance-00000001",
            "OS-SRV-USG:launched_at":"2017-08-31T06:22:11.000000",
            "flavor":{
                "id":"1",
                "links":[
                    {
                        "href":"http://controller:8774/99a50773b170406b8902227118bb72bf/flavors/1",
                        "rel":"bookmark"
                    }
                ]
            },
            "id":"70950ab5-8f83-4114-a024-f40e923cbc08",
            "security_groups":[
                {
                    "name":"allow ping & ssh"
                }
            ],
            "user_id":"fb52853bde3d4d3e8e831749781f8671",
            "OS-DCF:diskConfig":"AUTO",
            "accessIPv4":"",
            "accessIPv6":"",
            "progress":0,
            "OS-EXT-STS:power_state":1,
            "OS-EXT-AZ:availability_zone":"nova",
            "metadata":{

            },
            "status":"ACTIVE",
            "updated":"2017-09-07T06:49:34Z",
            "hostId":"76f61a58cf6d411a30e3e34da4dd252a03aa0093d9dd19c653b234b3",
            "OS-EXT-SRV-ATTR:host":"controller",
            "OS-SRV-USG:terminated_at":null,
            "key_name":null,
            "OS-EXT-SRV-ATTR:hypervisor_hostname":"controller",
            "name":"VM1",
            "created":"2017-08-31T06:21:55Z",
            "tenant_id":"99a50773b170406b8902227118bb72bf",
            "os-extended-volumes:volumes_attached":[

            ],
            "config_drive":""
        }
    ]
}

可以使用下面的方式取得server,(to_dict()方法):

  for server in op_conn.conn.compute.servers():
        print(server.to_dict())

你可能感兴趣的:(server 的json解释)