summaryrefslogtreecommitdiff
path: root/openstackclient/compute
diff options
context:
space:
mode:
authorRichard Theis <rtheis@us.ibm.com>2016-02-09 07:21:01 -0600
committerRichard Theis <rtheis@us.ibm.com>2016-02-29 14:46:57 -0600
commit842882f3cbfca6df9a42bc49b0deefdb84509a8e (patch)
tree72edcbb413c01582ec4899b925e37306a88cfc5d /openstackclient/compute
parent5310cfb8b750b3a17b99d235318e736023cfd234 (diff)
downloadpython-openstackclient-842882f3cbfca6df9a42bc49b0deefdb84509a8e.tar.gz
Refactor security group list to use SDK
Refactored the 'os security group list' command to use the SDK when neutron is enabled, but continue to use the nova client when nova network is enabled. This refactor also removes the logic for displaying project names instead of project IDs when the --all-projects option is specified. This logic was removed because it is inconsistent with the other network commands. Since neutron will always display security groups across all projects for an admin, the --all-projects option is now hidden when neutron is enabled and the Project column is always displayed. Change-Id: I934a1f5084ef3c5f929d0ffd38ebf5064d799941 Partial-Bug: #1519511 Related-to: blueprint neutron-client
Diffstat (limited to 'openstackclient/compute')
-rw-r--r--openstackclient/compute/v2/security_group.py54
1 files changed, 0 insertions, 54 deletions
diff --git a/openstackclient/compute/v2/security_group.py b/openstackclient/compute/v2/security_group.py
index 2a7b40f4..907175f7 100644
--- a/openstackclient/compute/v2/security_group.py
+++ b/openstackclient/compute/v2/security_group.py
@@ -18,8 +18,6 @@
import six
-from keystoneauth1 import exceptions as ks_exc
-
try:
from novaclient.v2 import security_group_rules
except ImportError:
@@ -169,58 +167,6 @@ class CreateSecurityGroupRule(command.ShowOne):
return zip(*sorted(six.iteritems(info)))
-class ListSecurityGroup(command.Lister):
- """List security groups"""
-
- def get_parser(self, prog_name):
- parser = super(ListSecurityGroup, self).get_parser(prog_name)
- parser.add_argument(
- '--all-projects',
- action='store_true',
- default=False,
- help='Display information from all projects (admin only)',
- )
- return parser
-
- def take_action(self, parsed_args):
-
- def _get_project(project_id):
- try:
- return getattr(project_hash[project_id], 'name', project_id)
- except KeyError:
- return project_id
-
- compute_client = self.app.client_manager.compute
- columns = (
- "ID",
- "Name",
- "Description",
- )
- column_headers = columns
- if parsed_args.all_projects:
- # TODO(dtroyer): Translate Project_ID to Project (name)
- columns = columns + ('Tenant ID',)
- column_headers = column_headers + ('Project',)
- search = {'all_tenants': parsed_args.all_projects}
- data = compute_client.security_groups.list(search_opts=search)
-
- project_hash = {}
- try:
- projects = self.app.client_manager.identity.projects.list()
- except ks_exc.ClientException:
- # This fails when the user is not an admin, just move along
- pass
- else:
- for project in projects:
- project_hash[project.id] = project
-
- return (column_headers,
- (utils.get_item_properties(
- s, columns,
- formatters={'Tenant ID': _get_project},
- ) for s in data))
-
-
class ListSecurityGroupRule(command.Lister):
"""List security group rules"""