Ask Your Question
0

list ports associated with specific security group

asked 2019-02-21 04:47:59 -0500

major_slackr gravatar image

I want to be able to list all ports associated with a specific security group. I can see the port object has the security_group_ids field but I cant see how to search using this. I ideally want a command like:

 $  openstack show all ports where security_group_id = <sec_group_id>

Open to any methods to do this - new to openstack so apologies if overlooked a simple solution...

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-02-21 06:21:47 -0500

I am afraid it will be something like this:

SECGROUP=<your security group id>
for p in $(openstack port list -f value -c ID)
do 
    if openstack port show $p | grep -q security_group_ids.*$SECGROUP
    then echo $p; fi
done
edit flag offensive delete link more

Comments

Works a treat, many thanks!

major_slackr gravatar imagemajor_slackr ( 2019-02-21 09:08:50 -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

1 follower

Stats

Asked: 2019-02-21 04:47:59 -0500

Seen: 28 times

Last updated: Feb 21