kikas
kikas

Reputation: 137

How to add a security group to a VM via the nova-client

I'm trying to use the OpenStack Nova client and create a script in order to launch an instance. I was able to create a VM with a specific key but the problem is that i can't add an existing security group to that instance.

I know how to create a security group and add some rules to it using the nova client.

Thank you in advance

Upvotes: 1

Views: 3945

Answers (1)

Tom
Tom

Reputation: 16198

After launching an instance you can add a security group to it using the CLI

nova add-secgroup my-special-server sec-group-3

See the help for more info

nova help add-secgroup 
usage: nova add-secgroup <server> <secgroup>

Add a Security Group to a server.

Positional arguments:
  <server>    Name or ID of server.
  <secgroup>  Name or ID of Security Group.

Personally I would add the security group during the boot of an instance using the --security-groups like below

nova boot --image cirros-0.3.1-x86_64-uec --flavor m1.tiny --security-groups my-sec-group 

Upvotes: 7

Related Questions