Merge "Add 'description' option"
This commit is contained in:
commit
8b2f256828
@ -22,6 +22,7 @@ Create a new security group rule
|
||||
[--ingress | --egress]
|
||||
[--ethertype <ethertype>]
|
||||
[--project <project> [--project-domain <project-domain>]]
|
||||
[--description <description>]
|
||||
<group>
|
||||
|
||||
.. option:: --src-ip <ip-address>
|
||||
@ -97,6 +98,12 @@ Create a new security group rule
|
||||
|
||||
*Network version 2 only*
|
||||
|
||||
.. option:: --description <description>
|
||||
|
||||
Set security group rule description
|
||||
|
||||
*Network version 2 only*
|
||||
|
||||
.. describe:: <group>
|
||||
|
||||
Create rule in this security group (name or ID)
|
||||
|
@ -109,6 +109,11 @@ class CreateSecurityGroupRule(common.NetworkAndComputeShowOne):
|
||||
return parser
|
||||
|
||||
def update_parser_network(self, parser):
|
||||
parser.add_argument(
|
||||
'--description',
|
||||
metavar='<description>',
|
||||
help=_("Set security group rule description")
|
||||
)
|
||||
parser.add_argument(
|
||||
'--dst-port',
|
||||
metavar='<port-range>',
|
||||
@ -235,6 +240,9 @@ class CreateSecurityGroupRule(common.NetworkAndComputeShowOne):
|
||||
attrs = {}
|
||||
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
|
||||
# is the default.
|
||||
if parsed_args.ingress or not parsed_args.egress:
|
||||
|
@ -952,6 +952,8 @@ class FakeSecurityGroupRule(object):
|
||||
|
||||
# Set default attributes.
|
||||
security_group_rule_attrs = {
|
||||
'description': 'security-group-rule-description-' +
|
||||
uuid.uuid4().hex,
|
||||
'direction': 'ingress',
|
||||
'ethertype': 'IPv4',
|
||||
'id': 'security-group-rule-id-' + uuid.uuid4().hex,
|
||||
|
@ -60,6 +60,7 @@ class TestCreateSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
|
||||
network_fakes.FakeSecurityGroup.create_one_security_group()
|
||||
|
||||
expected_columns = (
|
||||
'description',
|
||||
'direction',
|
||||
'ethertype',
|
||||
'id',
|
||||
@ -81,6 +82,7 @@ class TestCreateSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
|
||||
self.network.create_security_group_rule = mock.Mock(
|
||||
return_value=self._security_group_rule)
|
||||
self.expected_data = (
|
||||
self._security_group_rule.description,
|
||||
self._security_group_rule.direction,
|
||||
self._security_group_rule.ethertype,
|
||||
self._security_group_rule.id,
|
||||
@ -452,6 +454,33 @@ class TestCreateSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
|
||||
self.assertEqual(self.expected_columns, columns)
|
||||
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):
|
||||
|
||||
@ -1075,6 +1104,7 @@ class TestShowSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
|
||||
network_fakes.FakeSecurityGroupRule.create_one_security_group_rule()
|
||||
|
||||
columns = (
|
||||
'description',
|
||||
'direction',
|
||||
'ethertype',
|
||||
'id',
|
||||
@ -1088,6 +1118,7 @@ class TestShowSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
|
||||
)
|
||||
|
||||
data = (
|
||||
_security_group_rule.description,
|
||||
_security_group_rule.direction,
|
||||
_security_group_rule.ethertype,
|
||||
_security_group_rule.id,
|
||||
|
@ -7,3 +7,6 @@ features:
|
||||
Add ``--description`` option to ``router set`` and
|
||||
``router create`` commands.
|
||||
[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