Merge "Add 'description' option"
This commit is contained in:
commit
8b2f256828
@ -22,6 +22,7 @@ Create a new security group rule
|
|||||||
[--ingress | --egress]
|
[--ingress | --egress]
|
||||||
[--ethertype <ethertype>]
|
[--ethertype <ethertype>]
|
||||||
[--project <project> [--project-domain <project-domain>]]
|
[--project <project> [--project-domain <project-domain>]]
|
||||||
|
[--description <description>]
|
||||||
<group>
|
<group>
|
||||||
|
|
||||||
.. option:: --src-ip <ip-address>
|
.. option:: --src-ip <ip-address>
|
||||||
@ -97,6 +98,12 @@ Create a new security group rule
|
|||||||
|
|
||||||
*Network version 2 only*
|
*Network version 2 only*
|
||||||
|
|
||||||
|
.. option:: --description <description>
|
||||||
|
|
||||||
|
Set security group rule description
|
||||||
|
|
||||||
|
*Network version 2 only*
|
||||||
|
|
||||||
.. describe:: <group>
|
.. describe:: <group>
|
||||||
|
|
||||||
Create rule in this security group (name or ID)
|
Create rule in this security group (name or ID)
|
||||||
|
@ -109,6 +109,11 @@ class CreateSecurityGroupRule(common.NetworkAndComputeShowOne):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def update_parser_network(self, parser):
|
def update_parser_network(self, parser):
|
||||||
|
parser.add_argument(
|
||||||
|
'--description',
|
||||||
|
metavar='<description>',
|
||||||
|
help=_("Set security group rule description")
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--dst-port',
|
'--dst-port',
|
||||||
metavar='<port-range>',
|
metavar='<port-range>',
|
||||||
@ -235,6 +240,9 @@ class CreateSecurityGroupRule(common.NetworkAndComputeShowOne):
|
|||||||
attrs = {}
|
attrs = {}
|
||||||
attrs['protocol'] = self._get_protocol(parsed_args)
|
attrs['protocol'] = self._get_protocol(parsed_args)
|
||||||
|
|
||||||
|
if parsed_args.description is not None:
|
||||||
|
attrs['description'] = parsed_args.description
|
||||||
|
|
||||||
# NOTE(rtheis): A direction must be specified and ingress
|
# NOTE(rtheis): A direction must be specified and ingress
|
||||||
# is the default.
|
# is the default.
|
||||||
if parsed_args.ingress or not parsed_args.egress:
|
if parsed_args.ingress or not parsed_args.egress:
|
||||||
|
@ -952,6 +952,8 @@ class FakeSecurityGroupRule(object):
|
|||||||
|
|
||||||
# Set default attributes.
|
# Set default attributes.
|
||||||
security_group_rule_attrs = {
|
security_group_rule_attrs = {
|
||||||
|
'description': 'security-group-rule-description-' +
|
||||||
|
uuid.uuid4().hex,
|
||||||
'direction': 'ingress',
|
'direction': 'ingress',
|
||||||
'ethertype': 'IPv4',
|
'ethertype': 'IPv4',
|
||||||
'id': 'security-group-rule-id-' + uuid.uuid4().hex,
|
'id': 'security-group-rule-id-' + uuid.uuid4().hex,
|
||||||
|
@ -60,6 +60,7 @@ class TestCreateSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
|
|||||||
network_fakes.FakeSecurityGroup.create_one_security_group()
|
network_fakes.FakeSecurityGroup.create_one_security_group()
|
||||||
|
|
||||||
expected_columns = (
|
expected_columns = (
|
||||||
|
'description',
|
||||||
'direction',
|
'direction',
|
||||||
'ethertype',
|
'ethertype',
|
||||||
'id',
|
'id',
|
||||||
@ -81,6 +82,7 @@ class TestCreateSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
|
|||||||
self.network.create_security_group_rule = mock.Mock(
|
self.network.create_security_group_rule = mock.Mock(
|
||||||
return_value=self._security_group_rule)
|
return_value=self._security_group_rule)
|
||||||
self.expected_data = (
|
self.expected_data = (
|
||||||
|
self._security_group_rule.description,
|
||||||
self._security_group_rule.direction,
|
self._security_group_rule.direction,
|
||||||
self._security_group_rule.ethertype,
|
self._security_group_rule.ethertype,
|
||||||
self._security_group_rule.id,
|
self._security_group_rule.id,
|
||||||
@ -452,6 +454,33 @@ class TestCreateSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
|
|||||||
self.assertEqual(self.expected_columns, columns)
|
self.assertEqual(self.expected_columns, columns)
|
||||||
self.assertEqual(self.expected_data, data)
|
self.assertEqual(self.expected_data, data)
|
||||||
|
|
||||||
|
def test_create_with_description(self):
|
||||||
|
self._setup_security_group_rule({
|
||||||
|
'description': 'Setting SGR',
|
||||||
|
})
|
||||||
|
arglist = [
|
||||||
|
'--description', self._security_group_rule.description,
|
||||||
|
self._security_group.id,
|
||||||
|
]
|
||||||
|
verifylist = [
|
||||||
|
('description', self._security_group_rule.description),
|
||||||
|
('group', self._security_group.id),
|
||||||
|
]
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
|
columns, data = (self.cmd.take_action(parsed_args))
|
||||||
|
|
||||||
|
self.network.create_security_group_rule.assert_called_once_with(**{
|
||||||
|
'description': self._security_group_rule.description,
|
||||||
|
'direction': self._security_group_rule.direction,
|
||||||
|
'ethertype': self._security_group_rule.ethertype,
|
||||||
|
'protocol': self._security_group_rule.protocol,
|
||||||
|
'remote_ip_prefix': self._security_group_rule.remote_ip_prefix,
|
||||||
|
'security_group_id': self._security_group.id,
|
||||||
|
})
|
||||||
|
self.assertEqual(self.expected_columns, columns)
|
||||||
|
self.assertEqual(self.expected_data, data)
|
||||||
|
|
||||||
|
|
||||||
class TestCreateSecurityGroupRuleCompute(TestSecurityGroupRuleCompute):
|
class TestCreateSecurityGroupRuleCompute(TestSecurityGroupRuleCompute):
|
||||||
|
|
||||||
@ -1075,6 +1104,7 @@ class TestShowSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
|
|||||||
network_fakes.FakeSecurityGroupRule.create_one_security_group_rule()
|
network_fakes.FakeSecurityGroupRule.create_one_security_group_rule()
|
||||||
|
|
||||||
columns = (
|
columns = (
|
||||||
|
'description',
|
||||||
'direction',
|
'direction',
|
||||||
'ethertype',
|
'ethertype',
|
||||||
'id',
|
'id',
|
||||||
@ -1088,6 +1118,7 @@ class TestShowSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
|
|||||||
)
|
)
|
||||||
|
|
||||||
data = (
|
data = (
|
||||||
|
_security_group_rule.description,
|
||||||
_security_group_rule.direction,
|
_security_group_rule.direction,
|
||||||
_security_group_rule.ethertype,
|
_security_group_rule.ethertype,
|
||||||
_security_group_rule.id,
|
_security_group_rule.id,
|
||||||
|
@ -7,3 +7,6 @@ features:
|
|||||||
Add ``--description`` option to ``router set`` and
|
Add ``--description`` option to ``router set`` and
|
||||||
``router create`` commands.
|
``router create`` commands.
|
||||||
[Blueprint :oscbp:`network-commands-options`]
|
[Blueprint :oscbp:`network-commands-options`]
|
||||||
|
|
|
||||||
|
Adds ``--description`` option to ``security group rule create``.
|
||||||
|
[Blueprint :oscbp:`network-commands-options`]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user