shim references for port_binding

As a consequence of implementing multiple port bindings in the Neutron
reference implementation [1], the following attributes were made lists:

- 'port_binding' in the in the SQLAlchemy Port model.
- 'binding' in the Port OVO

As a consequence of this change, these attributes names were changed to
'port_bindings' and 'bindings' respectively. This patch updates the
references to those attributes.

To support neutron envs, both with and without the neutron change [2],
this patch adds a shim to use the proper port binding accessor.
NB: this shim may allow the tests to pass but does not test using the
proper "depends on" approach since that doesn't work today with the 3rd
party VMware NSX CI.

For more details see [1][2].

[1] https://review.openstack.org/#/c/571041
[2] https://review.openstack.org/#/c/414251

Change-Id: I35c24b83150d84a15997c5ebe3e7b51015f87e99
This commit is contained in:
Boden R 2018-06-07 15:33:40 -06:00
parent 675251af75
commit cc09f65ca4

View File

@ -27,6 +27,7 @@ from neutron_lib.plugins import directory
from neutron.db import _resource_extend as resource_extend from neutron.db import _resource_extend as resource_extend
from neutron.db import api as db_api from neutron.db import api as db_api
from neutron.db import portbindings_db as pbin_db from neutron.db import portbindings_db as pbin_db
from neutron.plugins.common import utils as p_utils
from neutron.plugins.ml2 import models as pbin_model from neutron.plugins.ml2 import models as pbin_model
from vmware_nsx._i18n import _ from vmware_nsx._i18n import _
from vmware_nsx.common import nsx_constants from vmware_nsx.common import nsx_constants
@ -156,5 +157,14 @@ class NsxPortBindingMixin(pbin_db.PortBindingMixin):
if port_db.nsx_port_attributes: if port_db.nsx_port_attributes:
port_res[pbin.VNIC_TYPE] = port_db.nsx_port_attributes.vnic_type port_res[pbin.VNIC_TYPE] = port_db.nsx_port_attributes.vnic_type
if port_db.port_binding:
plugin.extend_port_portbinding(port_res, port_db.port_binding) # TODO(boden): remove p_utils check when neutron patch lands
# see https://review.openstack.org/#/c/571041
if hasattr(p_utils, 'get_port_binding_by_status_and_host'):
binding = p_utils.get_port_binding_by_status_and_host(
port_db.port_bindings, constants.ACTIVE)
else:
binding = port_db.port_binding
if binding:
plugin.extend_port_portbinding(port_res, binding)