Ask Your Question
1

how to give security group in REST json request to create server

asked 2013-06-14 11:44:22 -0500

Anshul Gangwar gravatar image

updated 2013-06-16 23:45:50 -0500

I am trying to create instance from REST client. I want to give security group in json request so that the instance gets created in some specified security group. I didn't find any document regarding this. I have tried giving security_group paramater as

http://10.102.153.51:8774/v2/f24b19b2b81c433ab9598bdb184ff12d/servers?security_group=pehlasg "server": {"name": "teesra", "imageRef": "082aa3ea-26dc-44bd-89db-c540e202bfce", "flavorRef": "42", "key_name": "firstkeypair" } I have tried some other ways also

http://10.102.153.51:8774/v2/f24b19b2b81c433ab9598bdb184ff12d/servers

"server": {"name": "teesra", "imageRef": "082aa3ea-26dc-44bd-89db-c540e202bfce", "flavorRef": "42", "key_name": "firstkeypair", "security_groups": [{"name": "default" } ] }

and

"server": {"name": "teesra", "imageRef": "082aa3ea-26dc-44bd-89db-c540e202bfce", "flavorRef": "42", "key_name": "firstkeypair", "security_group": "default" }

but all this is resulting in some error.

What is the correct way to give security groups(multiple ) in json request?

[edit] : It seems like other parameter, which specifies the network(quantum) is missing. How can I give that? I am not able to deploy instance without giving network if quantum is enabled.

edit retag flag offensive close merge delete

Comments

Normally you'd find the answer in the API documentation , but I can't see an example there for the security_groups parameter. I've submitted a bug for that.

kspear gravatar imagekspear ( 2013-06-16 22:41:49 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2013-06-16 22:36:24 -0500

kspear gravatar image

updated 2013-06-19 09:15:46 -0500

If you run novaclient with --debug, it'll show you the API requests that it's making behind the scenes:

nova --debug boot --image <image_id> --flavor m1.tiny --security-groups sg1,sg2 test

The relevant bits are:

curl -i http://localhost:8774/v1.1/b32b3fad7bfe4b82a353a4374809476e/servers -X POST -H "X-Auth-Project-Id: demo" -H "User-Agent: python-novaclient" -H "Content-Type: application/json" -H "Accept: application/json" -H "X-Auth-Token: ********" -d '{"server": {"name": "test", "imageRef": "1123f214-94ef-4f4c-813c-ffd5e1209aa1", "flavorRef": "1", "max_count": 1, "min_count": 1, "security_groups": [{"name": "sg1"}, {"name": "sg2"}]}}'

Which looks like your second example.

An example with a network:

curl -i http://localhost:8774/v1.1/b32b3fad7bfe4b82a353a4374809476e/servers -X POST -H "X-Auth-Project-Id: demo" -H "User-Agent: python-novaclient" -H "Content-Type: application/json" -H "Accept: application/json" -H "X-Auth-Token: ********" -d '{"server": {"name": "test", "imageRef": "1123f214-94ef-4f4c-813c-ffd5e1209aa1", "flavorRef": "1", "max_count": 1, "min_count": 1, "security_groups": [{"name": "sg1"}, {"name": "sg2"}], "networks": [{"uuid": "07de3a763a3c452c85ffc1008dbe10b8"}] }}'
edit flag offensive delete link more

Comments

wow, documentation is rather weak to explain how things are set :/ Thanks a lot.

akostadinov gravatar imageakostadinov ( 2018-08-06 14:04:49 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

Stats

Asked: 2013-06-14 11:44:22 -0500

Seen: 806 times

Last updated: Jun 19 '13