Neutron port bulk creation procedure ignores binding:vnic_type parameter

Bug #1940074 reported by Andrey Bubyr
18
This bug affects 4 people
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Medium
Unassigned

Bug Description

Bulk port creation does not honor binding:vnic_type field. It implicitly uses
binding:vnic_type: normal

Example of bulk creation API call:
curl -v --location --request POST 'https://<neutron_url>/v2.0/ports' --header 'Content-Type: application/json' --header 'X-Auth-Token: <redacted>' --data-raw '{
  "ports" : [ {
    "name" : "port1",
    "admin_state_up" : true,
    "network_id" : "c2a3464a-dbea-40c9-b421-9313e33992be",
    "binding:vnic_type" : "direct"
  }, {
    "name" : "port2",
    "admin_state_up" : true,
    "network_id" : "27dd162f-e8ac-4b21-84f4-e4dff6836fa0",
    "binding:vnic_type" : "macvtap"
  }]
}'

At the same time vnic_type is honored in 'single port' mode of this API, f.e. with payload like
  "port" : {
    "name" : "port_single",
    "admin_state_up" : true,
    "network_id" : "c2a3464a-dbea-40c9-b421-9313e33992be",
    "binding:vnic_type" : "direct"
  }
}'

Seems that binding:vnic_type from port parameters is not passed thru inside create_port_bulk() function. I've found a workaround. The following line should be added after
https://review.opendev.org/plugins/gitiles/openstack/neutron/+/refs/heads/master/neutron/plugins/ml2/plugin.py#1594:

                port_dict[portbindings.VNIC_TYPE] = pdata.get(
                    portbindings.VNIC_TYPE)

Andrey Bubyr (abubyr)
description: updated
Revision history for this message
Slawek Kaplonski (slaweq) wrote :

Thx Andrey for bug report. Are You going to push Your fix to review?

Changed in neutron:
status: New → Confirmed
importance: Undecided → Medium
tags: added: api low-hanging-fruit
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (master)

Fix proposed to branch: master
Review: https://review.opendev.org/c/openstack/neutron/+/804746

Changed in neutron:
status: Confirmed → In Progress
Revision history for this message
Andrey Bubyr (abubyr) wrote :

Please correct/extend this patch if needed as I have a little expertise in Openstack development area. Thanks!

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

Reviewed: https://review.opendev.org/c/openstack/neutron/+/804746
Committed: https://opendev.org/openstack/neutron/commit/3640ffa0c6968a2f802a9809e4f318fb229dad7d
Submitter: "Zuul (22348)"
Branch: master

commit 3640ffa0c6968a2f802a9809e4f318fb229dad7d
Author: Oleg Bondarev <email address hidden>
Date: Thu Aug 19 21:56:47 2021 +0800

    Handle all portbinding attrs in case of bulk port creation

    Bulk port creation should honor binding:vnic_type
    and binding:profile attributes from request.

    Closes-Bug: #1940074
    Change-Id: I99d27d568f66c6330f6373843d096c6ee1b4ec54

Changed in neutron:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron 19.0.0.0rc1

This issue was fixed in the openstack/neutron 19.0.0.0rc1 release candidate.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (stable/wallaby)

Fix proposed to branch: stable/wallaby
Review: https://review.opendev.org/c/openstack/neutron/+/863663

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (stable/victoria)

Fix proposed to branch: stable/victoria
Review: https://review.opendev.org/c/openstack/neutron/+/863664

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/wallaby)

Reviewed: https://review.opendev.org/c/openstack/neutron/+/863663
Committed: https://opendev.org/openstack/neutron/commit/85126425c529fbee74ae8a9a7289e3ba28665228
Submitter: "Zuul (22348)"
Branch: stable/wallaby

commit 85126425c529fbee74ae8a9a7289e3ba28665228
Author: Oleg Bondarev <email address hidden>
Date: Thu Aug 19 21:56:47 2021 +0800

    Handle all portbinding attrs in case of bulk port creation

    Bulk port creation should honor binding:vnic_type
    and binding:profile attributes from request.

    Closes-Bug: #1940074
    Change-Id: I99d27d568f66c6330f6373843d096c6ee1b4ec54
    (cherry picked from commit 3640ffa0c6968a2f802a9809e4f318fb229dad7d)

tags: added: in-stable-wallaby
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/victoria)

Reviewed: https://review.opendev.org/c/openstack/neutron/+/863664
Committed: https://opendev.org/openstack/neutron/commit/ae2d009866291857aa6ef682fb818f85a4e7e780
Submitter: "Zuul (22348)"
Branch: stable/victoria

commit ae2d009866291857aa6ef682fb818f85a4e7e780
Author: Oleg Bondarev <email address hidden>
Date: Thu Aug 19 21:56:47 2021 +0800

    Handle all portbinding attrs in case of bulk port creation

    Bulk port creation should honor binding:vnic_type
    and binding:profile attributes from request.

    Closes-Bug: #1940074
    Change-Id: I99d27d568f66c6330f6373843d096c6ee1b4ec54
    (cherry picked from commit 3640ffa0c6968a2f802a9809e4f318fb229dad7d)
    (cherry picked from commit 85126425c529fbee74ae8a9a7289e3ba28665228)

tags: added: in-stable-victoria
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron victoria-eom

This issue was fixed in the openstack/neutron victoria-eom release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron wallaby-eom

This issue was fixed in the openstack/neutron wallaby-eom release.

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.