1

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

albciff
  • 18,112
  • 4
  • 64
  • 89
kikas
  • 127
  • 1
  • 3
  • 9

1 Answers1

7

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 
Tom
  • 15,798
  • 4
  • 37
  • 48
  • Thank you for your answer. What i'm trying to do is a python script to create a VM on openstack and that's why i'm using nova client. – kikas Oct 14 '16 at 07:56