diff options
| author | Zuul <zuul@review.opendev.org> | 2019-06-22 21:39:31 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2019-06-22 21:39:31 +0000 |
| commit | 3258b9e5e3c2c6e7752806f505d1fefbbe135eef (patch) | |
| tree | b32b5d16773952d9c3dad0ec81afc64874d7a713 /openstackclient | |
| parent | 1a21f02bc7507120f3a4fe2af12ba7a27b002b44 (diff) | |
| parent | 33a255612c661f174d2cb5d4ca93f8d7096e9290 (diff) | |
| download | python-openstackclient-3258b9e5e3c2c6e7752806f505d1fefbbe135eef.tar.gz | |
Merge "Change default security group protocol to 'any'"
Diffstat (limited to 'openstackclient')
3 files changed, 11 insertions, 7 deletions
diff --git a/openstackclient/network/v2/security_group_rule.py b/openstackclient/network/v2/security_group_rule.py index df19af20..637fba1d 100644 --- a/openstackclient/network/v2/security_group_rule.py +++ b/openstackclient/network/v2/security_group_rule.py @@ -155,7 +155,7 @@ class CreateSecurityGroupRule(common.NetworkAndComputeShowOne): "ipv6-encap, ipv6-frag, ipv6-icmp, ipv6-nonxt, " "ipv6-opts, ipv6-route, ospf, pgm, rsvp, sctp, tcp, " "udp, udplite, vrrp and integer representations [0-255] " - "or any; default: tcp)") + "or any; default: any (all protocols))") ) protocol_group.add_argument( '--proto', @@ -220,8 +220,8 @@ class CreateSecurityGroupRule(common.NetworkAndComputeShowOne): ) return parser - def _get_protocol(self, parsed_args): - protocol = 'tcp' + def _get_protocol(self, parsed_args, default_protocol='any'): + protocol = default_protocol if parsed_args.protocol is not None: protocol = parsed_args.protocol if parsed_args.proto is not None: @@ -324,7 +324,7 @@ class CreateSecurityGroupRule(common.NetworkAndComputeShowOne): def take_action_compute(self, client, parsed_args): group = client.api.security_group_find(parsed_args.group) - protocol = self._get_protocol(parsed_args) + protocol = self._get_protocol(parsed_args, default_protocol='tcp') if protocol == 'icmp': from_port, to_port = -1, -1 else: @@ -415,8 +415,8 @@ class ListSecurityGroupRule(common.NetworkAndComputeLister): "ah, dhcp, egp, esp, gre, icmp, igmp, " "ipv6-encap, ipv6-frag, ipv6-icmp, ipv6-nonxt, " "ipv6-opts, ipv6-route, ospf, pgm, rsvp, sctp, tcp, " - "udp, udplite, vrrp and integer representations [0-255])." - ) + "udp, udplite, vrrp and integer representations [0-255] " + "or any; default: any (all protocols))") ) direction_group = parser.add_mutually_exclusive_group() direction_group.add_argument( diff --git a/openstackclient/tests/unit/network/v2/fakes.py b/openstackclient/tests/unit/network/v2/fakes.py index 100ea2b1..e41621a4 100644 --- a/openstackclient/tests/unit/network/v2/fakes.py +++ b/openstackclient/tests/unit/network/v2/fakes.py @@ -1305,7 +1305,7 @@ class FakeSecurityGroupRule(object): 'id': 'security-group-rule-id-' + uuid.uuid4().hex, 'port_range_max': None, 'port_range_min': None, - 'protocol': 'tcp', + 'protocol': None, 'remote_group_id': None, 'remote_ip_prefix': '0.0.0.0/0', 'security_group_id': 'security-group-id-' + uuid.uuid4().hex, diff --git a/openstackclient/tests/unit/network/v2/test_security_group_rule_network.py b/openstackclient/tests/unit/network/v2/test_security_group_rule_network.py index 2b0de0d2..eb0cf310 100644 --- a/openstackclient/tests/unit/network/v2/test_security_group_rule_network.py +++ b/openstackclient/tests/unit/network/v2/test_security_group_rule_network.py @@ -168,10 +168,12 @@ class TestCreateSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork): def test_create_default_rule(self): self._setup_security_group_rule({ + 'protocol': 'tcp', 'port_range_max': 443, 'port_range_min': 443, }) arglist = [ + '--protocol', 'tcp', '--dst-port', str(self._security_group_rule.port_range_min), self._security_group.id, ] @@ -258,10 +260,12 @@ class TestCreateSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork): def test_create_remote_group(self): self._setup_security_group_rule({ + 'protocol': 'tcp', 'port_range_max': 22, 'port_range_min': 22, }) arglist = [ + '--protocol', 'tcp', '--dst-port', str(self._security_group_rule.port_range_min), '--ingress', '--remote-group', self._security_group.name, |
