Check if a port can be bound to a virtual bridge

If port VNIC type is "normal", the port can be bound to a virtual bridge;
e.g.: Linux Bridge, OVS.

Change-Id: I0dab235bd492538c7fa909dace08fad2267a589d
Partial-Bug: #1566951
This commit is contained in:
Rodolfo Alonso Hernandez 2018-11-02 10:29:20 +00:00
parent 0ecceacb3e
commit 29f128cd1f
2 changed files with 16 additions and 0 deletions

View File

@ -26,6 +26,7 @@ from neutron_lib._i18n import _
from neutron_lib.api import attributes
from neutron_lib.api.definitions import network as net_apidef
from neutron_lib.api.definitions import port as port_apidef
from neutron_lib.api.definitions import portbindings as pb
from neutron_lib.api.definitions import portbindings_extended as pb_ext
from neutron_lib.api.definitions import subnet as subnet_apidef
from neutron_lib import constants
@ -382,3 +383,12 @@ def get_port_binding_by_status_and_host(bindings, status, host='',
return binding
if raise_if_not_found:
raise exceptions.PortBindingNotFound(port_id=port_id, host=host)
def can_port_be_bound_to_virtual_bridge(port):
"""Returns if port can be bound to a virtual bridge (e.g.: LB, OVS)
:param port: (dict) A port dictionary.
:returns: True if the port VNIC type is 'normal'; False in any other case.
"""
return port[pb.VNIC_TYPE] == pb.VNIC_NORMAL

View File

@ -0,0 +1,6 @@
---
features:
- |
Add ``can_port_be_bound_to_virtual_bridge`` function in
``neutron_lib.plugins.utils``. This function checks if a port, depending
on the VNIC type, can be bound to a virtual bridge.