Openstack创建服务器请求不能通过api工作

时间:2017-05-16 10:31:31

标签: rest api openstack

我正在尝试使用REST API在openstack中创建服务器的发布请求。我尝试了这个代码(在Openstack文档中),但它不起作用。 你能帮忙吗?

{
"server": {    "name":"auto-allocate-network",
    "imageRef":"d84ddc27-7e79-4f5f-a4fb-f5fccda375c3",
    "flavorRef":"583c710b-684b-4d05-a65c-eb69927212bd",
    "availability_zone": "nova",
    "network":"9f2989d3-c859-4ff5-ae0b-163e4562ea38"

}}

URI是:

http://192.1.1.184:8774/v2.1/servers

2 个答案:

答案 0 :(得分:2)

试试这段代码,它对我有用:

{
  "server": {
    "name": "test-vm1",
    "imageRef": "876d6dd5-06c7-43ea-8917-3f93ca074885",
    "flavorRef": "1",
    "max_count": 1,
    "min_count": 1,
    "networks": [
      {
        "uuid": "3b7f6755-46b1-4437-a164-5757bf0baedc"
      }
    ],
    "security_groups": [
      {
        "name": "default"
      }
    ]
  }
}

答案 1 :(得分:0)

这个solution from @node对我不起作用, 这是我的结果:

{
"choices": [
    {
        "status": "SUPPORTED",
        "media-types": [
            {
                "base": "application/json",
                "type": "application/vnd.openstack.compute+json;version=2"
            }
        ],
        "id": "v2.0",
        "links": [
            {
                "href": "http://rocky-controller.jcamp.net:8774/v2/v2.0/c0b89f614b5a457cb5acef8fe8c2b320/servers",
                "rel": "self"
            }
        ]
    },
    {
        "status": "CURRENT",
        "media-types": [
            {
                "base": "application/json",
                "type": "application/vnd.openstack.compute+json;version=2.1"
            }
        ],
        "id": "v2.1",
        "links": [
            {
                "href": "http://rocky-controller.jcamp.net:8774/v2.1/v2.0/c0b89f614b5a457cb5acef8fe8c2b320/servers",
                "rel": "self"
            }
        ]
    }
]

}