Don't display duplicated security groups

As reported by users, we end up displaying duplicate security groups
on multi nic vms using neutron. Let's not do that.

Also add security group listing to the v3 client to make it
consistent.

Change-Id: I0a983aac08aaeacf3c2aef5aae49f64265fe78c5
Closes-Bug: #1331307
This commit is contained in:
Sean Dague 2014-09-11 20:44:44 -04:00
parent 3fa05957da
commit 3d68063809
2 changed files with 12 additions and 2 deletions

View File

@ -1610,8 +1610,11 @@ def _print_server(cs, args, server=None):
flavor_id)
if 'security_groups' in info:
info['security_groups'] = \
', '.join(group['name'] for group in info['security_groups'])
# when we have multiple nics the info will include the
# security groups N times where N == number of nics. Be nice
# and only display it once.
info['security_groups'] = ', '.join(
sorted(set(group['name'] for group in info['security_groups'])))
image = info.get('image', {})
if image:

View File

@ -1334,6 +1334,13 @@ def _print_server(cs, args, server=None):
info['flavor'] = '%s (%s)' % (_find_flavor(cs, flavor_id).name,
flavor_id)
if 'security_groups' in info:
# when we have multiple nics the info will include the
# security groups N times where N == number of nics. Be nice
# and only display it once.
info['security_groups'] = ', '.join(
sorted(set(group['name'] for group in info['security_groups'])))
image = info.get('image', {})
if image:
image_id = image.get('id', '')