Merge "SDK Refactor: Prepare security group rule commands"
This commit is contained in:
commit
12442371a8
@ -29,6 +29,7 @@ import six
|
|||||||
from openstackclient.i18n import _
|
from openstackclient.i18n import _
|
||||||
from openstackclient.identity import common as identity_common
|
from openstackclient.identity import common as identity_common
|
||||||
from openstackclient.network import common
|
from openstackclient.network import common
|
||||||
|
from openstackclient.network import sdk_utils
|
||||||
from openstackclient.network import utils as network_utils
|
from openstackclient.network import utils as network_utils
|
||||||
|
|
||||||
|
|
||||||
@ -67,11 +68,10 @@ def _format_network_port_range(rule):
|
|||||||
|
|
||||||
|
|
||||||
def _get_columns(item):
|
def _get_columns(item):
|
||||||
columns = list(item.keys())
|
column_map = {
|
||||||
if 'tenant_id' in columns:
|
'tenant_id': 'project_id',
|
||||||
columns.remove('tenant_id')
|
}
|
||||||
columns.append('project_id')
|
return sdk_utils.get_osc_show_columns_for_sdk_resource(item, column_map)
|
||||||
return tuple(sorted(columns))
|
|
||||||
|
|
||||||
|
|
||||||
def _convert_to_lowercase(string):
|
def _convert_to_lowercase(string):
|
||||||
@ -89,6 +89,8 @@ def _is_icmp_protocol(protocol):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
# TODO(abhiraut): Use the SDK resource mapped attribute names once the
|
||||||
|
# OSC minimum requirements include SDK 1.0.
|
||||||
class CreateSecurityGroupRule(common.NetworkAndComputeShowOne):
|
class CreateSecurityGroupRule(common.NetworkAndComputeShowOne):
|
||||||
_description = _("Create a new security group rule")
|
_description = _("Create a new security group rule")
|
||||||
|
|
||||||
@ -341,9 +343,9 @@ class CreateSecurityGroupRule(common.NetworkAndComputeShowOne):
|
|||||||
|
|
||||||
# Create and show the security group rule.
|
# Create and show the security group rule.
|
||||||
obj = client.create_security_group_rule(**attrs)
|
obj = client.create_security_group_rule(**attrs)
|
||||||
columns = _get_columns(obj)
|
display_columns, columns = _get_columns(obj)
|
||||||
data = utils.get_item_properties(obj, columns)
|
data = utils.get_item_properties(obj, columns)
|
||||||
return (columns, data)
|
return (display_columns, data)
|
||||||
|
|
||||||
def take_action_compute(self, client, parsed_args):
|
def take_action_compute(self, client, parsed_args):
|
||||||
group = utils.find_resource(
|
group = utils.find_resource(
|
||||||
@ -597,9 +599,9 @@ class ShowSecurityGroupRule(common.NetworkAndComputeShowOne):
|
|||||||
def take_action_network(self, client, parsed_args):
|
def take_action_network(self, client, parsed_args):
|
||||||
obj = client.find_security_group_rule(parsed_args.rule,
|
obj = client.find_security_group_rule(parsed_args.rule,
|
||||||
ignore_missing=False)
|
ignore_missing=False)
|
||||||
columns = _get_columns(obj)
|
display_columns, columns = _get_columns(obj)
|
||||||
data = utils.get_item_properties(obj, columns)
|
data = utils.get_item_properties(obj, columns)
|
||||||
return (columns, data)
|
return (display_columns, data)
|
||||||
|
|
||||||
def take_action_compute(self, client, parsed_args):
|
def take_action_compute(self, client, parsed_args):
|
||||||
# NOTE(rtheis): Unfortunately, compute does not have an API
|
# NOTE(rtheis): Unfortunately, compute does not have an API
|
||||||
|
Loading…
Reference in New Issue
Block a user