Search code examples
openstackopenstack-nova

How can I choose a specific subnet when creating new server in OpenStack?


I trying create new server with Openstack API. But api respons is; Additional properties are not allowed ('subnet-id' was unexpected). i cant choose specific subnet. I checked api documentation but i couldn't see subnet-id parameters And then i looked source code and I couldn't find subnet-id parameters. . I guess openstack nova api doesn't support subnet-id parameter. Do you have any idea or solution. Because I have a network and 2 subnet under the this network. I want to use my second subnet. Actually I want to network segmantation in one network. for example; database-subnet, application-subnet, public-subnet etc.

This is my request json;

    "server" : {
        "name" : "new-server-test-01",
        "imageRef" : "ae5f************",
        "flavorRef" : "29*******************************",
        "networks": [
                        {"uuid":"0**********************",
                         "subnet-id": "2****************"
                        }
        ],
        "availability_zone": "nova",
        "OS-DCF:diskConfig": "AUTO",
        "security_groups": [
            {
                "name": "default"
            }
        ]     
    }
} 

By the way, I read this documantation and I saw that;

What is missing is applying existing neutron functionality to horizon and nova codebases. This blueprint is for Nova.


Solution

  • Since there is no subnet option to use in the create request to the API, I think what you can do is either create the port previously as suggested on the comments, or assign a fixed ip within the desired range.

    None of these are the perfect solution, but I hope it can solve your issue.