Search code examples
restapiopenstack

Openstack Create server request don't work via api


I'm trying to do a post request for creating a server inthe openstack using REST API. i tried this code (followed in the Openstack documentation) but it won't work. Can you help please?

{
"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"

}}

the URI is :

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

Solution

  • try this code, it works for me:

    {
      "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"
          }
        ]
      }
    }