简体   繁体   中英

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

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 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM