Merge "Add is_shared to security_groups"
This commit is contained in:
@@ -90,10 +90,7 @@ def _get_columns(item):
|
|||||||
column_map = {
|
column_map = {
|
||||||
'security_group_rules': 'rules',
|
'security_group_rules': 'rules',
|
||||||
}
|
}
|
||||||
# FIXME(lajoskatona): Stop hiding is_shared when
|
hidden_columns = ['location', 'tenant_id']
|
||||||
# https://review.opendev.org/c/openstack/openstacksdk/+/950305
|
|
||||||
# is released and SDK version is bumped
|
|
||||||
hidden_columns = ['location', 'tenant_id', 'is_shared']
|
|
||||||
return utils.get_osc_show_columns_for_sdk_resource(
|
return utils.get_osc_show_columns_for_sdk_resource(
|
||||||
item, column_map, hidden_columns
|
item, column_map, hidden_columns
|
||||||
)
|
)
|
||||||
@@ -225,7 +222,14 @@ class DeleteSecurityGroup(common.NetworkAndComputeDelete):
|
|||||||
# the OSC minimum requirements include SDK 1.0.
|
# the OSC minimum requirements include SDK 1.0.
|
||||||
class ListSecurityGroup(common.NetworkAndComputeLister):
|
class ListSecurityGroup(common.NetworkAndComputeLister):
|
||||||
_description = _("List security groups")
|
_description = _("List security groups")
|
||||||
FIELDS_TO_RETRIEVE = ['id', 'name', 'description', 'project_id', 'tags']
|
FIELDS_TO_RETRIEVE = [
|
||||||
|
'id',
|
||||||
|
'name',
|
||||||
|
'description',
|
||||||
|
'project_id',
|
||||||
|
'tags',
|
||||||
|
'shared',
|
||||||
|
]
|
||||||
|
|
||||||
def update_parser_network(self, parser):
|
def update_parser_network(self, parser):
|
||||||
if not self.is_docs_build:
|
if not self.is_docs_build:
|
||||||
@@ -248,6 +252,23 @@ class ListSecurityGroup(common.NetworkAndComputeLister):
|
|||||||
identity_common.add_project_domain_option_to_parser(
|
identity_common.add_project_domain_option_to_parser(
|
||||||
parser, enhance_help=self.enhance_help_neutron
|
parser, enhance_help=self.enhance_help_neutron
|
||||||
)
|
)
|
||||||
|
|
||||||
|
shared_group = parser.add_mutually_exclusive_group()
|
||||||
|
shared_group.add_argument(
|
||||||
|
'--share',
|
||||||
|
action='store_true',
|
||||||
|
dest='shared',
|
||||||
|
default=None,
|
||||||
|
help=_("List security groups shared between projects"),
|
||||||
|
)
|
||||||
|
shared_group.add_argument(
|
||||||
|
'--no-share',
|
||||||
|
action='store_false',
|
||||||
|
dest='shared',
|
||||||
|
default=None,
|
||||||
|
help=_("List security groups not shared between projects"),
|
||||||
|
)
|
||||||
|
|
||||||
_tag.add_tag_filtering_option_to_parser(
|
_tag.add_tag_filtering_option_to_parser(
|
||||||
parser, _('security group'), enhance_help=self.enhance_help_neutron
|
parser, _('security group'), enhance_help=self.enhance_help_neutron
|
||||||
)
|
)
|
||||||
@@ -275,13 +296,30 @@ class ListSecurityGroup(common.NetworkAndComputeLister):
|
|||||||
).id
|
).id
|
||||||
filters['project_id'] = project_id
|
filters['project_id'] = project_id
|
||||||
|
|
||||||
|
if parsed_args.shared is not None:
|
||||||
|
filters['shared'] = parsed_args.shared
|
||||||
|
|
||||||
_tag.get_tag_filtering_args(parsed_args, filters)
|
_tag.get_tag_filtering_args(parsed_args, filters)
|
||||||
data = client.security_groups(
|
data = client.security_groups(
|
||||||
fields=self.FIELDS_TO_RETRIEVE, **filters
|
fields=self.FIELDS_TO_RETRIEVE, **filters
|
||||||
)
|
)
|
||||||
|
|
||||||
columns = ("id", "name", "description", "project_id", "tags")
|
columns = (
|
||||||
column_headers = ("ID", "Name", "Description", "Project", "Tags")
|
"id",
|
||||||
|
"name",
|
||||||
|
"description",
|
||||||
|
"project_id",
|
||||||
|
"tags",
|
||||||
|
"is_shared",
|
||||||
|
)
|
||||||
|
column_headers = (
|
||||||
|
"ID",
|
||||||
|
"Name",
|
||||||
|
"Description",
|
||||||
|
"Project",
|
||||||
|
"Tags",
|
||||||
|
"Shared",
|
||||||
|
)
|
||||||
return (
|
return (
|
||||||
column_headers,
|
column_headers,
|
||||||
(
|
(
|
||||||
|
@@ -1412,6 +1412,7 @@ def create_one_security_group(attrs=None):
|
|||||||
'security_group_rules': [],
|
'security_group_rules': [],
|
||||||
'tags': [],
|
'tags': [],
|
||||||
'location': 'MUNCHMUNCHMUNCH',
|
'location': 'MUNCHMUNCHMUNCH',
|
||||||
|
'is_shared': False,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Overwrite default attributes.
|
# Overwrite default attributes.
|
||||||
|
@@ -42,6 +42,7 @@ class TestCreateSecurityGroupNetwork(TestSecurityGroupNetwork):
|
|||||||
'created_at',
|
'created_at',
|
||||||
'description',
|
'description',
|
||||||
'id',
|
'id',
|
||||||
|
'is_shared',
|
||||||
'name',
|
'name',
|
||||||
'project_id',
|
'project_id',
|
||||||
'revision_number',
|
'revision_number',
|
||||||
@@ -55,6 +56,7 @@ class TestCreateSecurityGroupNetwork(TestSecurityGroupNetwork):
|
|||||||
_security_group.created_at,
|
_security_group.created_at,
|
||||||
_security_group.description,
|
_security_group.description,
|
||||||
_security_group.id,
|
_security_group.id,
|
||||||
|
_security_group.is_shared,
|
||||||
_security_group.name,
|
_security_group.name,
|
||||||
_security_group.project_id,
|
_security_group.project_id,
|
||||||
_security_group.revision_number,
|
_security_group.revision_number,
|
||||||
@@ -274,6 +276,7 @@ class TestListSecurityGroupNetwork(TestSecurityGroupNetwork):
|
|||||||
'Description',
|
'Description',
|
||||||
'Project',
|
'Project',
|
||||||
'Tags',
|
'Tags',
|
||||||
|
'Shared',
|
||||||
)
|
)
|
||||||
|
|
||||||
data = []
|
data = []
|
||||||
@@ -285,6 +288,7 @@ class TestListSecurityGroupNetwork(TestSecurityGroupNetwork):
|
|||||||
grp.description,
|
grp.description,
|
||||||
grp.project_id,
|
grp.project_id,
|
||||||
grp.tags,
|
grp.tags,
|
||||||
|
grp.is_shared,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -524,6 +528,7 @@ class TestShowSecurityGroupNetwork(TestSecurityGroupNetwork):
|
|||||||
'created_at',
|
'created_at',
|
||||||
'description',
|
'description',
|
||||||
'id',
|
'id',
|
||||||
|
'is_shared',
|
||||||
'name',
|
'name',
|
||||||
'project_id',
|
'project_id',
|
||||||
'revision_number',
|
'revision_number',
|
||||||
@@ -537,6 +542,7 @@ class TestShowSecurityGroupNetwork(TestSecurityGroupNetwork):
|
|||||||
_security_group.created_at,
|
_security_group.created_at,
|
||||||
_security_group.description,
|
_security_group.description,
|
||||||
_security_group.id,
|
_security_group.id,
|
||||||
|
_security_group.is_shared,
|
||||||
_security_group.name,
|
_security_group.name,
|
||||||
_security_group.project_id,
|
_security_group.project_id,
|
||||||
_security_group.revision_number,
|
_security_group.revision_number,
|
||||||
|
@@ -7,7 +7,7 @@ pbr!=2.1.0,>=2.0.0 # Apache-2.0
|
|||||||
cryptography>=2.7 # BSD/Apache-2.0
|
cryptography>=2.7 # BSD/Apache-2.0
|
||||||
cliff>=4.8.0 # Apache-2.0
|
cliff>=4.8.0 # Apache-2.0
|
||||||
iso8601>=0.1.11 # MIT
|
iso8601>=0.1.11 # MIT
|
||||||
openstacksdk>=4.5.0 # Apache-2.0
|
openstacksdk>=4.6.0 # Apache-2.0
|
||||||
osc-lib>=2.3.0 # Apache-2.0
|
osc-lib>=2.3.0 # Apache-2.0
|
||||||
oslo.i18n>=3.15.3 # Apache-2.0
|
oslo.i18n>=3.15.3 # Apache-2.0
|
||||||
python-keystoneclient>=3.22.0 # Apache-2.0
|
python-keystoneclient>=3.22.0 # Apache-2.0
|
||||||
|
Reference in New Issue
Block a user