2014-07-26 119 views
0

我需要在Java中爲OpenSTack對ReST API的響應生成引用/反射/模式類。如何獲取Openstack json模式以獲取其ReST API返回的響應?

比如我使用API​​來獲取服務器的列表:v2/{tenant_id}/servers/detail 這裏是我的迴應: -

{ 
    "servers": [ 
     { 
      "status": "ACTIVE", 
      "updated": "2014-07-11T11:29:58Z", 
      "hostId": "872e9b93ccd50b93612d49f4c371f49fe6365f02bcb51994868eb88f", 
      "OS-EXT-SRV-ATTR:host": "controller", 
      "addresses": { 
       "officenet": [ 
        { 
         "OS-EXT-IPS-MAC:mac_addr": "fa:16:3e:c8:52:41", 
         "version": 4, 
         "addr": "10.43.1.182", 
         "OS-EXT-IPS:type": "fixed" 
        } 
       ] 
      }, 
      "links": [ 
       { 
        "href": "http://10.43.1.197:8774/v2/1333f00f05564a02b3c4f608b9622fc9/servers/bbadfe78-c6eb-48ce-a51b-c26617a812ba", 
        "rel": "self" 
       }, 
       { 
        "href": "http://10.43.1.197:8774/1333f00f05564a02b3c4f608b9622fc9/servers/bbadfe78-c6eb-48ce-a51b-c26617a812ba", 
        "rel": "bookmark" 
       } 
      ], 
      "key_name": null, 
      "image": { 
       "id": "b724ae53-9113-4e33-987a-f58fd9a4ec81", 
       "links": [ 
        { 
         "href": "http://10.43.1.197:8774/1333f00f05564a02b3c4f608b9622fc9/images/b724ae53-9113-4e33-987a-f58fd9a4ec81", 
         "rel": "bookmark" 
        } 
       ] 
      }, 
      "OS-EXT-STS:task_state": null, 
      "OS-EXT-STS:vm_state": "active", 
      "OS-EXT-SRV-ATTR:instance_name": "instance-00000016", 
      "OS-SRV-USG:launched_at": "2014-07-11T11:29:58.000000", 
      "OS-EXT-SRV-ATTR:hypervisor_hostname": "controller", 
      "flavor": { 
       "id": "1", 
       "links": [ 
        { 
         "href": "http://10.43.1.197:8774/1333f00f05564a02b3c4f608b9622fc9/flavors/1", 
         "rel": "bookmark" 
        } 
       ] 
      }, 
      "id": "bbadfe78-c6eb-48ce-a51b-c26617a812ba", 
      "security_groups": [ 
       { 
        "name": "default" 
       } 
      ], 
      "OS-SRV-USG:terminated_at": null, 
      "OS-EXT-AZ:availability_zone": "nova", 
      "user_id": "a859477b42794e8fa6dbf339361bb268", 
      "name": "AKshay-DebianInstance 1", 
      "created": "2014-07-11T11:29:53Z", 
      "tenant_id": "1333f00f05564a02b3c4f608b9622fc9", 
      "OS-DCF:diskConfig": "MANUAL", 
      "os-extended-volumes:volumes_attached": [], 
      "accessIPv4": "", 
      "accessIPv6": "", 
      "progress": 0, 
      "OS-EXT-STS:power_state": 1, 
      "config_drive": "", 
      "metadata": {} 
     } 
    ] 
} 

我如何獲得這個JSON和相應的API類似JSONs的通用架構。 我在Openstack文檔上進行了搜索,但僅查找了可用的Image Service JSON模式。 另外,谷歌搜索了它,但徒勞無功。

[編輯]:我可以得到http://docs.openstack.org/api/openstack-image-service/2.0/content/get-images-schema.html,那個API是v2/schemas/images。 如何獲得計算和網絡相關架構?

回答

1

它們不是JSON模式,但是您可以處理OpenStack WADLs而不是您需要執行的操作。

+0

這很有幫助,但我發現很難獲得計算v2 API的JSON模式。 –

+1

我不知道有任何努力爲Nova v2做JSON模式。 [本藍圖](https://blueprints.launchpad.net/nova/+spec/v3-api-schema)中有一個針對v3的工作正在進行中(v2.1有*不*當前v2) 。 –

+0

感謝您的有見地的評論! –