Reviewed: https://review.opendev.org/663464 Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=af773557323580c7b07bd41dd1f524e81530c939 Submitter: Zuul Branch: master
commit af773557323580c7b07bd41dd1f524e81530c939 Author: Harald Jensås <[email protected]> Date: Thu Jun 6 03:06:17 2019 +0200 Turn CIDR in query filter into proper subnet Use netaddr.IPNetwork to convert CIDRs in a query into proper subnets. When creating subnets the CIDR is converted into a proper subnet. i.e a subnet can be created with cidr=10.0.0.11/24 in the create request. On create the cidr is turned into a proper subnet resulting in a subnet with cidr=10.0.0.0/24. This change does the same to CIDRs when used as query filters during a list subnet request, so that the same value that was used to create the subnet can be used to find the subnet. Closes-Bug: #1831811 Change-Id: I8ae478a03ceedc6c3b1ae1d40081b5e5158813e6 ** Changed in: neutron Status: In Progress => Fix Released -- You received this bug notification because you are a member of Yahoo! Engineering Team, which is subscribed to neutron. https://bugs.launchpad.net/bugs/1831811 Title: Unable to filter using same cidr value as used for subnet create Status in neutron: Fix Released Bug description: When subnets are created using a cidr the value provided is normalized/converted to a proper subnet https://opendev.org/openstack/neutron/src/branch/master/neutron/db/db_base_plugin_v2.py#L818-L820 818 # turn the CIDR into a proper subnet 819 net = netaddr.IPNetwork(s['cidr']) 820 subnet['subnet']['cidr'] = '%s/%s' % (net.network, net.prefixlen) I.e if the user create using `192.168.100.1/24` as the cidr the subnet create is successfull. The cidr is turned into the proper subnet `192.168.100.0/24` internally in the pre-commit. When listing subnets and filtering using the same value for the cidr the return is an empty list. Example: $ curl -s -H "X-Auth-Token: $(openstack token issue -c id -f value)" -H "Content-Type: application/json" http://192.168.122.103:9696/v2.0/subnets?cidr=192.168.100.1/24 | json_reformat { "subnets": [ ] } A user should be able to find the subnet by filtering using the same `192.168.100.1/24` value used when creating the subnet. To manage notifications about this bug go to: https://bugs.launchpad.net/neutron/+bug/1831811/+subscriptions -- Mailing list: https://launchpad.net/~yahoo-eng-team Post to : [email protected] Unsubscribe : https://launchpad.net/~yahoo-eng-team More help : https://help.launchpad.net/ListHelp

