create port with binding_vnic_type param fail HttpException: Bad Request

Bug #1625579 reported by Noam Angel
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack SDK
Fix Released
Undecided
Unassigned

Bug Description

code:

import sys

from openstack import connection
from openstack import profile
from openstack import utils

utils.enable_logging(True,stream=sys.stdout)

prof = profile.Profile()
prof.set_region(prof.ALL, 'RegionOne')

conn = connection.Connection(
    auth_url='http://10.209.24.123:5000/v2.0/',
    profile=prof,
    username="admin",
    project_name="admin",
    password="password")

network = conn.network.find_network("private")
port = conn.network.create_port(
    network_id=network.id,
    name='sriov',
    binding_vnic_type='direct')

debug:

2016-09-20 11:05:11,560 DEBUG: keystoneauth.session REQ: curl -g -i -X GET http://10.209.24.123:5000/v2.0/ -H "Accept: application/json" -H "User-Agent: openstacksdk/0.9.6 keystoneauth1/2.12.1 python-requests/2.11.1 CPython/2.7.12"
2016-09-20 11:05:11,688 DEBUG: keystoneauth.session RESP: [200] Date: Tue, 20 Sep 2016 11:05:11 GMT Server: Apache/2.4.18 (Ubuntu) Vary: X-Auth-Token x-openstack-request-id: req-73740749-5d3c-486e-b4e4-60ab85637c3f Content-Length: 347 Keep-Alive: timeout=5, max=100 Connection: Keep-Alive Content-Type: application/json
RESP BODY: {"version": {"status": "deprecated", "updated": "2016-08-04T00:00:00Z", "media-types": [{"base": "application/json", "type": "application/vnd.openstack.identity-v2.0+json"}], "id": "v2.0", "links": [{"href": "http://10.209.24.123/identity/v2.0/", "rel": "self"}, {"href": "http://docs.openstack.org/", "type": "text/html", "rel": "describedby"}]}}

2016-09-20 11:05:11,689 DEBUG: keystoneauth.identity.v2 Making authentication request to http://10.209.24.123/identity/v2.0/tokens
2016-09-20 11:05:11,905 DEBUG: keystoneauth.session REQ: curl -g -i -X GET http://10.209.24.123:9696 -H "User-Agent: openstacksdk/0.9.6 keystoneauth1/2.12.1 python-requests/2.11.1 CPython/2.7.12" -H "X-Auth-Token: {SHA1}fca409f063c6d86e0521c0499696e2e99428e973"
2016-09-20 11:05:11,929 DEBUG: keystoneauth.session RESP: [200] Content-Type: application/json; charset=UTF-8 Content-Length: 121 Date: Tue, 20 Sep 2016 11:05:11 GMT Connection: keep-alive
RESP BODY: {"versions": [{"status": "CURRENT", "id": "v2.0", "links": [{"href": "http://10.209.24.123:9696/v2.0", "rel": "self"}]}]}

2016-09-20 11:05:11,930 DEBUG: keystoneauth.session REQ: curl -g -i -X GET http://10.209.24.123:9696/v2.0/networks/private -H "User-Agent: openstacksdk/0.9.6 keystoneauth1/2.12.1 python-requests/2.11.1 CPython/2.7.12" -H "X-Auth-Token: {SHA1}fca409f063c6d86e0521c0499696e2e99428e973"
2016-09-20 11:05:12,018 DEBUG: keystoneauth.session RESP: [404] Content-Length: 52 Content-Type: text/plain; charset=UTF-8 X-Openstack-Request-Id: req-d3d93683-4133-419c-91fe-2a195c47efe1 Date: Tue, 20 Sep 2016 11:05:12 GMT Connection: keep-alive
RESP BODY: 404 Not Found

The resource could not be found.

2016-09-20 11:05:12,019 DEBUG: keystoneauth.session Request returned failure status: 404
2016-09-20 11:05:12,029 DEBUG: keystoneauth.session REQ: curl -g -i -X GET http://10.209.24.123:9696/v2.0/networks -H "User-Agent: openstacksdk/0.9.6 keystoneauth1/2.12.1 python-requests/2.11.1 CPython/2.7.12" -H "Accept: application/json" -H "X-Auth-Token: {SHA1}fca409f063c6d86e0521c0499696e2e99428e973"
2016-09-20 11:05:12,160 DEBUG: keystoneauth.session RESP: [200] Content-Type: application/json Content-Length: 1435 X-Openstack-Request-Id: req-7a4e168d-3317-48de-a4ac-15a102f61f4e Date: Tue, 20 Sep 2016 11:05:12 GMT Connection: keep-alive
RESP BODY: {"networks": [{"provider:physical_network": "public", "ipv6_address_scope": null, "revision_number": 4, "port_security_enabled": true, "mtu": 1500, "id": "588721ab-e608-495c-b52e-4e44064023ea", "router:external": true, "availability_zone_hints": [], "availability_zones": ["nova"], "ipv4_address_scope": null, "shared": false, "project_id": "c571b72babf14ecf8a2848f7809e4d9e", "status": "ACTIVE", "subnets": ["b0e5bdde-c1be-43dc-8f29-a47e403cd6e9"], "description": "", "tags": [], "updated_at": "2016-09-18T15:16:07", "is_default": true, "provider:segmentation_id": null, "name": "public", "admin_state_up": true, "tenant_id": "c571b72babf14ecf8a2848f7809e4d9e", "created_at": "2016-09-18T15:16:02", "provider:network_type": "flat"}, {"provider:physical_network": "default", "ipv6_address_scope": null, "revision_number": 4, "port_security_enabled": true, "mtu": 1500, "id": "d6df020f-9ac3-46b6-951c-cd56eef6fa94", "router:external": false, "availability_zone_hints": [], "availability_zones": ["nova"], "ipv4_address_scope": null, "shared": false, "project_id": "0e4cf4ed23fb4562b04e3407226b1f44", "status": "ACTIVE", "subnets": ["0eae6c0d-5ef0-4c31-87d9-07142fac25c5"], "description": "", "tags": [], "updated_at": "2016-09-18T15:15:51", "provider:segmentation_id": 16, "name": "private", "admin_state_up": true, "tenant_id": "0e4cf4ed23fb4562b04e3407226b1f44", "created_at": "2016-09-18T15:15:48", "provider:network_type": "vlan"}]}

2016-09-20 11:05:28,460 DEBUG: keystoneauth.session REQ: curl -g -i -X POST http://10.209.24.123:9696/v2.0/ports -H "User-Agent: openstacksdk/0.9.6 keystoneauth1/2.12.1 python-requests/2.11.1 CPython/2.7.12" -H "Content-Type: application/json" -H "X-Auth-Token: {SHA1}fca409f063c6d86e0521c0499696e2e99428e973" -d '{"port": {"network_id": "d6df020f-9ac3-46b6-951c-cd56eef6fa94", "binding_vnic_type": "direct", "name": "sriov", "binding:vnic_type": "direct"}}'
2016-09-20 11:05:28,507 DEBUG: keystoneauth.session RESP: [400] Content-Length: 118 Content-Type: application/json; charset=UTF-8 X-Openstack-Request-Id: req-4ef0d07d-f2cb-491b-b1a3-7b73fd6091ea Date: Tue, 20 Sep 2016 11:05:28 GMT Connection: keep-alive
RESP BODY: {"NeutronError": {"message": "Unrecognized attribute(s) 'binding_vnic_type'", "type": "HTTPBadRequest", "detail": ""}}

2016-09-20 11:05:28,508 DEBUG: keystoneauth.session Request returned failure status: 400
Traceback (most recent call last):
  File "/usr/lib/pycharm-community/helpers/pydev/pydevd.py", line 1580, in <module>
    globals = debugger.run(setup['file'], None, None, is_module)
  File "/usr/lib/pycharm-community/helpers/pydev/pydevd.py", line 964, in run
    pydev_imports.execfile(file, globals, locals) # execute the script
  File "/qa/qa/cloudx/python/projects/amichay/openstack-testing/test/test.py", line 43, in <module>
    binding_vnic_type='direct')
  File "/qa/qa/cloudx/python/venv/amichay/testing2.7/local/lib/python2.7/site-packages/openstack/network/v2/_proxy.py", line 1070, in create_port
    return self._create(_port.Port, **attrs)
  File "/qa/qa/cloudx/python/venv/amichay/testing2.7/local/lib/python2.7/site-packages/openstack/proxy.py", line 179, in _create
    return res.create(self.session)
  File "/qa/qa/cloudx/python/venv/amichay/testing2.7/local/lib/python2.7/site-packages/openstack/resource.py", line 582, in create
    resp = self.create_by_id(session, self._attrs, self.id, path_args=self)
  File "/qa/qa/cloudx/python/venv/amichay/testing2.7/local/lib/python2.7/site-packages/openstack/resource.py", line 561, in create_by_id
    resp = session.post(url, endpoint_filter=cls.service, **args)
  File "/qa/qa/cloudx/python/venv/amichay/testing2.7/local/lib/python2.7/site-packages/keystoneauth1/session.py", line 675, in post
    return self.request(url, 'POST', **kwargs)
  File "/qa/qa/cloudx/python/venv/amichay/testing2.7/local/lib/python2.7/site-packages/openstack/session.py", line 52, in map_exceptions_wrapper
    http_status=e.http_status, cause=e)
openstack.exceptions.HttpException: HttpException: Bad Request

Tags: network
Noam Angel (noama)
description: updated
Noam Angel (noama)
tags: added: network
Revision history for this message
Brian Curtin (brian.curtin) wrote :

Based on the logs, the exception, and the documentation for a POST to /ports, binding_vnic_type is not a valid parameter.

Revision history for this message
Noam Angel (noama) wrote :

If you will inspect the curl's you will see that vnic_type appear twice one with the class parametrr and second with the correct key binding:vnic_type. Somewhere in the resource it should be deleted

Revision history for this message
Noam Angel (noama) wrote :

http://developer.openstack.org/sdks/python/openstacksdk/users/resources/network/v2/port.html#openstack.network.v2.port.Port

there is definitely a param called "binding_vnic_type".
you can see the api request to create port it transform "binding_vnic_type" to "binding:vnic_type" but does not remove "binding_vnic_type" from the request.

Revision history for this message
Brian Curtin (brian.curtin) wrote :

I still don’t see anything about any form of that parameter in the REST API docs anymore (http://developer.openstack.org/api-ref/networking/v2/?expanded=create-port-detail), but assuming it's still a real name, network code still uses the original resource module and not resource2, so to solve this you’ll probably have to override openstack.resource.Resource.create for in the openstack.network.v2.port.Port resource in order to make sure it only sends one (and the correct) name.

There's a change underway to shift network to use resource2, where this would not be a problem, but if you need this immediately it's easiest to just do that override as network will be a large transition to make.

Revision history for this message
Brian Curtin (brian.curtin) wrote :

FYI this change will solve the problem once it's both merged and released: https://review.openstack.org/#/c/364052

That's a part of a larger set of changes, so it solves a whole lot more than this individual problem, but I'll see if it might just make sense to wait for it to be done or if we should go on with what I showed you in IRC.

Revision history for this message
Noam Angel (noama) wrote :

Great. I'm around on IRC if need testing or you want me to commit the change

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on python-openstacksdk (master)

Change abandoned by Brian Curtin (<email address hidden>) on branch: master
Review: https://review.openstack.org/408628
Reason: https://review.openstack.org/#/c/364052 fixes this problem

Noam Angel (noama)
Changed in python-openstacksdk:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.