From 564c8ff2403da87b96562076865f42426a4f8eac Mon Sep 17 00:00:00 2001 From: Richard Theis Date: Fri, 26 Feb 2016 11:33:45 -0600 Subject: Refactor security group show to use SDK Refactored the 'os security group show' command to use the SDK when neutron is enabled, but continue to use the nova client when nova network is enabled. Added a release note for the change in security group rules output due to Network v2. The column names remain unchanged to maintain backwards compatibility. Change-Id: I25233ddb8115d18b8b88affb3de13346084a339d Partial-Bug: #1519511 Implements: blueprint neutron-client --- openstackclient/compute/v2/security_group.py | 54 ---------------------------- 1 file changed, 54 deletions(-) (limited to 'openstackclient/compute') diff --git a/openstackclient/compute/v2/security_group.py b/openstackclient/compute/v2/security_group.py index f378af14..042e5caf 100644 --- a/openstackclient/compute/v2/security_group.py +++ b/openstackclient/compute/v2/security_group.py @@ -56,23 +56,6 @@ def _xform_security_group_rule(sgroup): return info -def _xform_and_trim_security_group_rule(sgroup): - info = _xform_security_group_rule(sgroup) - # Trim parent security group ID since caller has this information. - info.pop('parent_group_id', None) - # Trim keys with empty string values. - keys_to_trim = [ - 'ip_protocol', - 'ip_range', - 'port_range', - 'remote_security_group', - ] - for key in keys_to_trim: - if key in info and not info[key]: - info.pop(key) - return info - - class CreateSecurityGroup(command.ShowOne): """Create a new security group""" @@ -215,40 +198,3 @@ class ListSecurityGroupRule(command.Lister): (utils.get_item_properties( s, columns, ) for s in rules)) - - -class ShowSecurityGroup(command.ShowOne): - """Display security group details""" - - def get_parser(self, prog_name): - parser = super(ShowSecurityGroup, self).get_parser(prog_name) - parser.add_argument( - 'group', - metavar='', - help='Security group to display (name or ID)', - ) - return parser - - def take_action(self, parsed_args): - - compute_client = self.app.client_manager.compute - info = {} - info.update(utils.find_resource( - compute_client.security_groups, - parsed_args.group, - )._info) - rules = [] - for r in info['rules']: - formatted_rule = _xform_and_trim_security_group_rule(r) - rules.append(utils.format_dict(formatted_rule)) - - # Format rules into a list of strings - info.update( - {'rules': utils.format_list(rules, separator='\n')} - ) - # Map 'tenant_id' column to 'project_id' - info.update( - {'project_id': info.pop('tenant_id')} - ) - - return zip(*sorted(six.iteritems(info))) -- cgit v1.2.1