Reviewed:  https://review.openstack.org/550588
Committed: 
https://git.openstack.org/cgit/openstack/neutron-lib/commit/?id=ce10b9df28ece6daee1f199740b672aae707630b
Submitter: Zuul
Branch:    master

commit ce10b9df28ece6daee1f199740b672aae707630b
Author: Brian Haley <bha...@redhat.com>
Date:   Wed Mar 7 15:08:42 2018 -0500

    Add prefixlen to subnet api-ref for create actions
    
    Prefixlen is used in subnet creation when allocating a subnet
    from a subnet pool.
    
    Change-Id: I251944ca15434ed9b17deb829cca985cd94a0bd1
    Closes-bug: #1754062


** 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/1754062

Title:
  openstack client does not pass prefixlen when creating subnet

Status in neutron:
  Fix Released
Status in OpenStack SDK:
  New

Bug description:
  Version: Pike
  OpenStack Client: 3.12.0

  When testing Subnet Pool functionality, I found that the behavior
  between the openstack and neutron clients is different.

  Subnet pool:

  root@controller01:~# openstack subnet pool show MySubnetPool
  +-------------------+--------------------------------------+
  | Field             | Value                                |
  +-------------------+--------------------------------------+
  | address_scope_id  | None                                 |
  | created_at        | 2018-03-07T13:18:22Z                 |
  | default_prefixlen | 8                                    |
  | default_quota     | None                                 |
  | description       |                                      |
  | id                | e49703d8-27f4-4a16-9bf4-91a6cf00fff3 |
  | ip_version        | 4                                    |
  | is_default        | False                                |
  | max_prefixlen     | 32                                   |
  | min_prefixlen     | 8                                    |
  | name              | MySubnetPool                         |
  | prefixes          | 172.31.0.0/16                        |
  | project_id        | 9233b6b4f6a54386af63c0a7b8f043c2     |
  | revision_number   | 0                                    |
  | shared            | False                                |
  | tags              |                                      |
  | updated_at        | 2018-03-07T13:18:22Z                 |
  +-------------------+--------------------------------------+

  When attempting to create a /28 subnet from that pool with the
  openstack client, the following error is observed:

  root@controller01:~# openstack subnet create \
  > --subnet-pool MySubnetPool \
  > --prefix-length 28 \
  > --network MyVLANNetwork2 \
  > MyFlatSubnetFromPool
  HttpException: Internal Server Error (HTTP 500) (Request-ID: 
req-61b3f00a-9764-4bcb-899d-e85d66f54e5a), Failed to allocate subnet: 
Insufficient prefix space to allocate subnet size /8.

  However, the same request is successful with the neutron client:

  root@controller01:~# neutron subnet-create --subnetpool MySubnetPool 
--prefixlen 28 --name MySubnetFromPool MyVLANNetwork2
  neutron CLI is deprecated and will be removed in the future. Use openstack 
CLI instead.
  Created a new subnet:
  +-------------------+-----------------------------------------------+
  | Field             | Value                                         |
  +-------------------+-----------------------------------------------+
  | allocation_pools  | {"start": "172.31.0.2", "end": "172.31.0.14"} |
  | cidr              | 172.31.0.0/28                                 |
  | created_at        | 2018-03-07T13:35:35Z                          |
  | description       |                                               |
  | dns_nameservers   |                                               |
  | enable_dhcp       | True                                          |
  | gateway_ip        | 172.31.0.1                                    |
  | host_routes       |                                               |
  | id                | 43cb9dda-1b7e-436d-9dc1-5312866a1b63          |
  | ip_version        | 4                                             |
  | ipv6_address_mode |                                               |
  | ipv6_ra_mode      |                                               |
  | name              | MySubnetFromPool                              |
  | network_id        | e01ca743-607c-4a94-9176-b572a46fba84          |
  | project_id        | 9233b6b4f6a54386af63c0a7b8f043c2              |
  | revision_number   | 0                                             |
  | service_types     |                                               |
  | subnetpool_id     | e49703d8-27f4-4a16-9bf4-91a6cf00fff3          |
  | tags              |                                               |
  | tenant_id         | 9233b6b4f6a54386af63c0a7b8f043c2              |
  | updated_at        | 2018-03-07T13:35:35Z                          |
  +-------------------+-----------------------------------------------+

  The payload is different between these clients - the openstack client
  fails to send the prefixlen key.

  openstack client:

  REQ: curl -g -i -X POST http://controller01:9696/v2.0/subnets -H "User-Agent: 
openstacksdk/0.9.17 keystoneauth1/3.1.0 python-requests/2.18.1 CPython/2.7.12" 
-H "Content-Type: application/json" -H "X-Auth-Token: 
{SHA1}ec04a71699eee2c70dc4abb35037de272523fef0" -d '{"subnet": {"network_id": 
"e01ca743-607c-4a94-9176-b572a46fba84", "ip_version": 4, "name": 
"MyFlatSubnetFromPool", "subnetpool_id": 
"e49703d8-27f4-4a16-9bf4-91a6cf00fff3"}}'
  http://controller01:9696 "POST /v2.0/subnets HTTP/1.1" 500 160

  neutron client:

  REQ: curl -g -i -X POST http://controller01:9696/v2.0/subnets -H
  "User-Agent: python-neutronclient" -H "Content-Type: application/json"
  -H "Accept: application/json" -H "X-Auth-Token:
  {SHA1}b3b6f0fa14c2b28c5c9784f857ee753455c1d375" -d '{"subnet":
  {"network_id": "e01ca743-607c-4a94-9176-b572a46fba84", "prefixlen":
  "28", "ip_version": 4, "subnetpool_id":
  "e49703d8-27f4-4a16-9bf4-91a6cf00fff3", "name": "MySubnetFromPool"}}'

  This appears to stem from prefixlen missing as a query parameter and
  property in the python-openstacksdk here:

  
https://github.com/openstack/python-openstacksdk/blob/master/openstack/network/v2/subnet.py#L32
  
https://github.com/openstack/python-openstacksdk/blob/master/openstack/network/v2/subnet.py#L43

  The Neutron docs do not show prefixlen as a subnet as a valid
  property, which could be why:

  https://developer.openstack.org/api-ref/network/v2/index.html#create-
  subnet

  I was able to patch the openstack SDK in my environment and got the
  client to work. Please let me know if you have any questions!

To manage notifications about this bug go to:
https://bugs.launchpad.net/neutron/+bug/1754062/+subscriptions

-- 
Mailing list: https://launchpad.net/~yahoo-eng-team
Post to     : yahoo-eng-team@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yahoo-eng-team
More help   : https://help.launchpad.net/ListHelp

Reply via email to