Howto create VM though API with custom IP and MAC addresses?

asked 2015-01-22 10:10:02 -0600

rawsik gravatar image


howto create VM through API with custom IP and MAC addresses?

I have juno release.

The first problem is I can't create VM though curl, I tryied

curl -i http://localhost:8774/v2/%7Btenant_id%7D/servers (http://localhost:8774/v2/{tenant_id}/...) -X POST -H "X-Auth-Project-Id: admin" -H "Accept: application/json" -H "X-Auth-Token: {token_id}" -d '{"server": {"name": "instance1", "imageRef": "{image_id}", "key_name": "test1", "flavorRef": "2", "max_count": 1, "min_count": 1}}' HTTP/1.1 400 Bad Request Content-Length: 68 Content-Type: application/json; charset=UTF-8 X-Compute-Request-Id: req-e73f4f56-9bf9-4b6a-998e-21a09cde5ae1 Date: Thu, 22 Jan 2015 16:04:10 GMT

{"badRequest": {"message": "Unsupported Content-Type", "code": 400}}

curl -i 'http://localhost:8774/v2/{tenant_id}/servers' -X POST \

-H "Accept: application/json" -H "Content-Type: application/json" -H "X-Auth-Token: {token_id}"\ -d '{"server": {"name": "test", "imageRef": "{image_id}", "availability_zone": "nova", "flavorRef": "3", \ "max_count": 1, "min_count": 1, "networks": [{"fixed_ip": "{custom_ip}", "uuid": "{network_id}"}],\ "security_groups": [{"name": "default"}]}}' HTTP/1.1 400 Bad Request Content-Length: 66 Content-Type: application/json; charset=UTF-8 X-Compute-Request-Id: req-00a17355-06cd-4133-ac26-f890f2a2fc29 Date: Thu, 22 Jan 2015 16:04:24 GMT

{"badRequest": {"message": "Malformed request body", "code": 400}}

What I do wrong? How to create VM throught API with custom API and MAC addresses?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2015-01-23 00:26:32 -0600

If you dont want to use the cli clients, which makes thing much easier, then you should run the cli clients using --debug and it will spit out the curl command it uses to make the rest call.


nova --debug boot --image someimage --flavor someflavor testvm

This will spit out the curl command the cli clients use to make it happen.

To use a custom IP and custom mac, again, use the neutron cli client to see the exact syntax of the curl command.

neutron --debug port-create yournetwork_name -- name my_custom_port --fixed-ip --mac-address 00:00:00:00:00:00

Once you create the port in your nova boot command you can pass in --nic net-id=your_network_uuid,port-id=my_custom_port_uuid

edit flag offensive delete link more

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2015-01-22 10:10:02 -0600

Seen: 2,177 times

Last updated: Jan 23 '15