diff options
author | Manjeet Singh Bhatia <manjeet.s.bhatia@intel.com> | 2015-10-15 04:31:08 +0000 |
---|---|---|
committer | Manjeet Singh Bhatia <manjeet.s.bhatia@intel.com> | 2015-10-22 20:37:48 +0000 |
commit | 8e741981b11a41dfa6f53f96ff1bbe37e30e4151 (patch) | |
tree | 0b86a0f8a119c0717593a4dbe8071ee99bc0c9aa /neutronclient/neutron/v2_0/securitygroup.py | |
parent | 7eeba7e90d9d5430fd93e1b4377a41a86f5126e8 (diff) | |
download | python-neutronclient-8e741981b11a41dfa6f53f96ff1bbe37e30e4151.tar.gz |
Adding a generate_default_ethertype_function
Neutron Client is always setting ethertype value to IPv4 which should
not be done if protocol is icmpv6. This patch will add a function that
will generate appropriate default value of ethertype according to
protocol.
Change-Id: Ia1a5342a1d568cb1a015e1b7acecf38b8d1f46e1
Related-Bug: #1505832
Diffstat (limited to 'neutronclient/neutron/v2_0/securitygroup.py')
-rw-r--r-- | neutronclient/neutron/v2_0/securitygroup.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/neutronclient/neutron/v2_0/securitygroup.py b/neutronclient/neutron/v2_0/securitygroup.py index 962b3f8..2fb0bb9 100644 --- a/neutronclient/neutron/v2_0/securitygroup.py +++ b/neutronclient/neutron/v2_0/securitygroup.py @@ -91,6 +91,12 @@ def _format_sg_rules(secgroup): return '' +def generate_default_ethertype(protocol): + if protocol == 'icmpv6': + return 'IPv6' + return 'IPv4' + + class ListSecurityGroup(neutronV20.ListCommand): """List security groups that belong to a given tenant.""" @@ -303,7 +309,6 @@ class CreateSecurityGroupRule(neutronV20.CreateCommand): help=_('Direction of traffic: ingress/egress.')) parser.add_argument( '--ethertype', - default='IPv4', help=_('IPv4/IPv6')) parser.add_argument( '--protocol', @@ -338,7 +343,8 @@ class CreateSecurityGroupRule(neutronV20.CreateCommand): self.get_client(), 'security_group', parsed_args.security_group_id) body = {'security_group_id': _security_group_id, 'direction': parsed_args.direction, - 'ethertype': parsed_args.ethertype} + 'ethertype': parsed_args.ethertype or + generate_default_ethertype(parsed_args.protocol)} neutronV20.update_dict(parsed_args, body, ['protocol', 'port_range_min', 'port_range_max', 'remote_ip_prefix', 'tenant_id']) |