Commit Graph

40 Commits

Author SHA1 Message Date
Bence Romsics 0390ada97c port-hints: api extension
api extension
db model
db migration
ovo (including changes affecting push rpc)
extension driver
policies

To enable this:

* neutron-db-manage upgrade 6f1145bff34c
* ml2_conf.ini:
  [ml2]
  extension_drivers += port_hints

This patch also bumps neutron-lib requirement to 3.5.0.

Change-Id: I80816618285d742775bc0534510c0f874f84ed2e
Partial-Bug: #1990842
Related-Change (spec): https://review.opendev.org/c/openstack/neutron-specs/+/862133
Related-Change (n-lib api-def): https://review.opendev.org/c/openstack/neutron-lib/+/870080
2023-05-09 11:49:17 +02:00
Rodolfo Alonso Hernandez b6750fb2b8 [OVN] Add vnic_type and binding profile capabilities to LSP info
In order to decide if a port is a hardware offloaded port by just
reading the OVN Logical_Switch_Port register, it is needed the
VNIC type and the binding profile cababilities.

The maintenance task will only update those LSP ports that belong
to direct Neutron ports to avoid an unnecessary database load.

Related-Bug: #1998608
Change-Id: I5febe9d3eeef6c5b5f6d972b9e8ebfef541458ac
2023-01-18 05:01:21 +01:00
Rodolfo Alonso Hernandez 572185e1fd Delete the PB level registers when deleting the duplicated PB
The ``neutron-remove-duplicated-port-bindings`` script removes the
duplicated port binding registers ("ml2_port_bindings" table) that
have status=INACTIVE.

This patch also removes the corresponding port binding levels
("ml2_port_binding_levels" table) associated to those inactive port
bindings.

Closes-Bug: #2000078

Change-Id: I12fa0764cd0ff509f1859b61060d64cc5a54a7b9
2023-01-02 11:05:12 +00:00
Rodolfo Alonso Hernandez c5b76a8393 Script to remove duplicated port bindings
A new script to remove the duplicated port bindings was added. This
script will list all ``ml2_port_bindings`` records in the database,
finding those ones with the same port ID. Then the script removes
those ones with status=INACTIVE. This script is useful to remove
those leftovers that remain in the database after a failed live
migration.

"dry_run" mode is possible if selected in "[cli_script] dry_run"
boolean config option. The duplicated port bindings are printed in
the shell but not deleted.

Related-Bug: #1979072

Change-Id: I0de5fbb70eb852f82bd311616557985d1ce89bbf
2022-08-18 08:13:56 +00:00
Rodolfo Alonso Hernandez 77ac42d2ee SR-IOV agent can handle ports with same MAC addresses
SR-IOV agent can handle ports with same MAC address (located in
different networks). The agent can retrieve, from the system, the
MAC address and the PCI slot; because the PCI slot is unique per
port in the same host, this parameter is used to match with the
Neutron port ID stored in the database (published via RPC).

RPC API bumped to version 1.9.

Closes-Bug: #1791159

Change-Id: Id8c3e0485bebc55c778ecaadaabca1c28ec56205
2021-06-03 16:02:18 +00:00
Rodolfo Alonso Hernandez 8912ea5575 Add port device profile extension
Added a new port extension: device profile (``port_device_profile``).
This extension adds the "device_profile" parameter to the "port" API
and specifies the device profile per port. This parameter is a
string.

This parameter is passed to Nova and Nova retrieves the requested
device profile from Cyborg. Reference:
  https://docs.openstack.org/api-ref/accelerator/v2/index.html#
    device-profiles

For backwards compatibility, this parameter will be "None" by
default.

Closes-Bug: #1906602
Depends-On: https://review.opendev.org/c/openstack/neutron-lib/+/767586

Change-Id: I1202a8388e64ae4270ef4ca118993504ae7c1731
2021-01-22 16:17:30 +00:00
Rodolfo Alonso Hernandez a217a5d290 Add port NUMA affinity policy
Added a new port extension: NUMA affinity policy. This extension adds
the "numa_affinity_policy" parameter to the "port" API and specifies
the NUMA affinity policy per port.

This parameter is passed to Nova when a virtual machine is created.
Nova will use this information to schedule the virtual machine.

For backwards compatibility, this parameter will be "None" by default.

Depends-On: https://review.opendev.org/#/c/740058/
Closes-Bug: #1886798

Change-Id: Ie3d68c098ddb727ab8333aa1de4064e67a4f00a7
2020-11-13 15:49:34 +00:00
Bence Romsics da45bbbff4 Auto-delete dhcp ports on segment delete
Subnet delete triggers dhcp port deletion but asynchronously,
therefore in the condition described in the bug report we may
get a conflict when deleting the segment too fast after the subnet.

Here we follow the example of how we auto-delete ports in net delete.

Please also find a fullstack test in Related-Change below.

Change-Id: Iba02f5a2211b18c2deb9097daad6be5e7d21faf8
Closes-Bug: #1878632
Related-Change: https://review.opendev.org/728904
2020-07-08 15:15:08 +02:00
Rodolfo Alonso Hernandez dc655cabcb Remove OVO unneeded compatibility conversions
OVOs and commit introducing the removed conversion:
- PortDNS:
  * https://review.opendev.org/#/c/457035/: included in Pike
- Port:
  * https://review.opendev.org/#/c/465423/: included in Pike
- Trunk:
  * https://review.opendev.org/#/c/382659/: included in Ocata
- QosRuleType:
  * https://review.opendev.org/#/c/475260/: included in Pike

Change-Id: I9353fa1b660212f244abf74921ebc90f0a2333b7
Related-Bug: #1828437
2020-06-03 17:15:31 +00:00
Brian Haley 7594bb0627 Remove the dependency on the "mock" package
Now that we are python3 only, we should move to using the built
in version of mock that supports all of our testing needs and
remove the dependency on the "mock" package.

This patch moves all references to "import mock" to
"from unittest import mock". It also cleans up some new line
inconsistency.

Fixed an inconsistency in the OVSBridge.deferred() definition
as it needs to also have an *args argument.

Fixed an issue where an l3-agent test was mocking
functools.partial, causing a python3.8 failure.

Unit tests only, removing from tests/base.py affects
functional tests which need additional work.

Change-Id: I40e8a8410840c3774c72ae1a8054574445d66ece
2020-04-28 18:05:37 -04:00
Rodolfo Alonso Hernandez 2ccddef913 Improve port retrieval when validating auto address
Improve port retrieval in method
"_validate_auto_address_subnet_delete". Instead of requesting each
port individually, a single DB query is executed to retrieve all
the ports with IP allocation in a in a subnet.

Change-Id: I7875142ebecd17663e17847fb14997200d7ae5c8
Related-Bug: #1865138
2020-04-14 12:50:49 +00:00
Zuul 8c08045c69 Merge "Fix update of network's segmentation id for network with ports" 2019-07-09 22:49:23 +00:00
Slawek Kaplonski 3367e2081b Fix update of network's segmentation id for network with ports
Filter neutron_lib.objects.utils.NotIn, designed to work with OVO objects
was used in db query and because of that ports belong to network wasn't
filtered by vif_type thus if there were any ports in network, it was not
possible to change its segmentation id.

Change-Id: I6ad2047c310e111bffe0942af12af1f642963b18
Closes-Bug: #1832985
2019-07-07 19:16:11 +00:00
Rodolfo Alonso Hernandez 66fca96e52 Add qos_network_policy_id to Port OVO
Added field "qos_network_policy_id" to Port OVO. This parameter
will be used to retrieve the QoS policy bound to the port network.
This reduces the number of calls to the database by creating a join
between the QosNetworkPolicyBinding table and the Port table, based
on the network ID.

This backref association is not persistent (marked as "viewonly").
This relationship is using for loading the QoS policy ID of the
port network in the Port OVO.

Related-Bug: #1834484

Change-Id: I219a925d5e269b8c73a0481daa879d72c399fd8f
2019-07-01 11:11:31 +00:00
Boden R 03ec94ce5e use test tools from neutron-lib
This patch switches the code over to use neutron-lib's test tools module
where appropriate rather than using neutron's.
This includes removing the following functions/classes from neutron and
using them from lib instead:
- get_random_EUI
- get_random_ip_network
- reset_random_seed
- OpenFixture

Change-Id: I0fbfcc7919f1b17b6bb0026fa9b98f157168255e
2019-06-05 06:21:04 -06:00
Hamdy Khader b4243ad3f7 Add Smart NIC representor port to integration bridge
In case of Smart NIC vNIC type neutron should mimic nova-compute
that plug the port to the ovs bridge.

Extend the Neutron OVS mechanism driver and Neutron OVS Agent to bind
the Neutron port for the baremetal host with Smart NIC. This will allow
the Neutron OVS Agent to configure the pipeline of the OVS running on
the Smart NIC and leverage the pipeline features such as: VXLAN,
Security Groups and ARP Responder.

Story: #2003346
Closes-Bug: #1785608
Change-Id: I6d520d3bac2e9ceb30b5b6197c6eb0f958cc3659
2019-05-23 10:54:36 +03:00
Nate Johnston f721c3dcc7 Add argument to get ports by SG to allow excluding owners
When code needs to load a list of all ports that are not router
interfaces, they tend to fetch the port information into memory and then
iterate over the ports, inspecting each port's device_owner.  For large
numbers of ports this is presumably inefficient.  This came up in a
discussion of just such a part in the code [1].

A more efficient solution is to perform this filtering in SQL.  This
change adds an argument to an existing method in the Port object to do
that.

[1] https://review.openstack.org/580721

Change-Id: I742d8a79175209e42f8bd6319956e960c73201ee
2018-10-03 20:05:16 +00:00
Shashank Kumar Shankar cfec395b8f Integration of Port Binding Level OVO
This patch integrates Port Binding Level OVO in /plugin/ml2/db.py
and introduces context instead of session for usage in object
operations.

Change-Id: Ifa779f5f70a7502bd96b34d64a84d272af2a6886
Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db
Co-Authored-By: Anindita Das <anindita.das@intel.com>
Co-Authored-By: Slawek Kaplonski <slawek@kaplonski.pl>
2018-09-17 07:00:45 +00:00
Miguel Lavalle 03db94ebaa Pluralize binding relationship in Port
As a consequence of implementing multiple bindings for ports, [1] made
the following attributes lists:

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

This patch pluralizes their names to 'port_bindings' and 'bindings'
respectively

[1] Ie31d4e27e3f55edfe334c4029ca9ed685e684c39

Change-Id: I4ebe47cf9d51a700310aad8dcccc82fea3f00a16
2018-07-13 19:37:36 -05:00
Jakub Libosvar f7b62a7f29 Multiple port binding for ML2
Functionality is added to the ML2 plugin to handle multiple port
bindings

Co-Authored-By: Anindita Das <anindita.das@intel.com>
Co-Authored-By: Miguel Lavalle <miguel.lavalle@huawei.com>

Partial-Bug: #1580880

Change-Id: Ie31d4e27e3f55edfe334c4029ca9ed685e684c39
2018-07-13 18:14:50 -05:00
Ihar Hrachyshka 752c33e92b objects: don't refetch a non-list object field if it's None
When an object field has the value of corresponding model attribute set to
None, it means that it's indeed unset, and there is no need to refetch it from
the database (it will still be None).

This becomes a more noticeable problem when we introduce security field to
Network (part of I57395d0f646ffa3089c1ac6c5a68d952ccd0b42c) that is exactly
this type of field, because with the auto-expiry patch included
(I0d65d19204da8ce30addfa5faff68544534b7853) those redundant fetches trigger
actual SELECT statements that affect performance and break
test_get_objects_queries_constant regression test case.

The patch also changes the type of 'distributed_binding' Port object field from
ObjectField to ListOfObjectFields, and also renames the field into
'distributed_bindings' to reflect actual possibilities allowed by database
schema. Note this patch is NOT expected to enable actual support for multiple
binding values, which would belong to a separate patch, but just attempts to
apply the minimal needed changes required because of the other changes included
while making sure that consequent changes for the field don't need to change
object definition.

Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db
Change-Id: I833b07fdbb4a57bdf8bd4255e61098ec512d1a5b
2018-06-25 15:23:10 +07:00
Ihar Hrachyshka b74af5ff65 Fixed PortBindingLevelDbObjectTestCase
The test class was not inheriting from testlib_api.SqlTestCase which
means that the test cases were never executed.

Once it was executed, it became obvious that the object has an issue
with SQL query scalability. Specifically, it was failing the
test_get_objects_queries_constant test case that validates that the
number of queries to fetch a single object is the same as for multiple
objects. This happens because PortBindingLevel's 'segment' synthetic
field is not constructed from db model relationship but through issuing
a get_object OVO call that triggers a query per fetched PortBindingLevel
object.

To fix the issue, the patch added a new 'segment' relationship to
PortBindingLevel db model, and made OVO use attributes from the
relationship to construct 'segment' synthetic field.

Another issue revealed by enabling the test class is that foreign_key
definition for the 'segment' synthetic field located in NetworkSegment
object refers to 'segment_id' field but the field with this name is not
defined on PortBindingLevel object. The easiest thing we can do to
resolve the discrepancy is adding the 'segment_id' UUID typed field to
PortBindingLevel, which is what the patch does. (An alternative could be
hacking our way around the lack of the field, building another layer of
complexity in the base OVO class for this special case; I figured it's
probably counterproductive, and we can live with 'segment_id' field even
though it's arguably somewhat redundant - 'segment' object field already
carries the ID.)

Adding a new field to PortBindingLevel object means that we need to bump
its version, as well as versions of all objects that use the newly
modified field type for their own fields. The only object that refers to
the type is Port.  That's why we also bump the version of Port object.
To make older agents that use RPC callbacks work with the change, we
also provide corresponding obj_make_compatible methods for both Port and
PortBindingLevel objects.

Change-Id: I1ec56c57f87218520c2080c0b3450f1eabc13224
2018-05-17 10:20:59 +09:00
Ihar Hrachyshka 6f83466307 Allow objects to opt in new engine facade
New facade is enabled by setting new_facade = True for the object of
interest. With new_facade on, all OVO actions will use the new reader /
writer decorator to activate sessions.

There are two new facade decorators added to OVO: db_context_reader and
db_context_write that should be used instead of explicit
autonested_transaction / reader.using / writer.using in OVO context.

All neutron.objects.db.api helpers now receive OVO classes / objects
instead of model classes, since they need to know which type of engine
facade to use for which object. While it means we change signatures for
those helper functions, they are not used anywhere outside neutron tree
except vmware-nsx unit tests, and the latter pass anyway because the
tests completely mock out them disregarding their signatures.

This patch also adds several new OVO objects to be able to continue
using neutron.objects.db.api helpers to persist models that previously
didn't have corresponding OVO classes.

Finally, the patch adds registration for missing options in
neutron/tests/unit/extensions/test_qos_fip.py to be able to debug
failures in those unit tests. Strictly speaking, this change doesn't
belong to the patch, but I include it nevertheless to speed up merge in
time close to release.

There are several non-obvious changes included, specifically:

- in neutron.objects.base, decorator() that refreshes / expunges models
from the active session now opens a subtransaction for the whole span of
call / refresh / expunge, so that we can safely refresh model regardless
of whether caller opened another parent subtransaction (it was not the
case for create_subnetpool in base db plugin code).

- in neutron.db.l3_fip_qos, removed code that updates obj.db_model
relationship directly after corresponding insertions for child policy
binding model. This code is not needed because the only caller to the
_process_extra_fip_qos_update method refetches latest state of floating
ip OVO object anyway, and this code triggers several unit test failures.

- unit tests checking that a single commit happens for get_object and
get_objects are no longer valid for new facade objects that use reader
decorator that doesn't commit but close. This change is as intended, so
unit tests were tweaked to check close for new facade objects.

Change-Id: I15ec238c18a464f977f7d1079605b82965052311
Related-Bug: #1746996
2018-02-09 04:07:34 +00:00
Sławek Kapłoński e7c0ec17df Fix Port OVO filtering based on security groups
Filtering of port OVO based on ids of security groups which
are used by ports is now available.

Closes-Bug: 1744447

Change-Id: Ie5a3effe668db119d40728be5357f0851bdcebbe
2018-01-22 15:43:46 +01:00
Jenkins 94d32069cd Merge "Add QoS policy port binding OVO" 2017-07-06 17:59:09 +00:00
Kevin Benton 1db5ace55e OVO: Allow port queries based on security_group_ids
This is needed to retrieve all ports in a given set of
security groups.

Partially-Implements: blueprint push-notifications
Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db
Change-Id: Iffa1bd341d9d20277ec153aa1dac6f61f05ec5bd
2017-06-20 08:33:22 +00:00
Rodolfo Alonso Hernandez 034a7a6f2d Add QoS policy port binding OVO
Added QoS policy port binding OVO. Direct access to 'qos_port_policy_bindings'
DB table is removed.

Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db
Change-Id: I40268f84bef808dcebd5c123fafc7a50a4d036f4
2017-06-09 18:21:36 +00:00
Rodolfo Alonso Hernandez 9d69822e43 Add "default" behaviour to QoS policies
This patch implements the "default" behaviour for QoS policies.
If this flag is enabled for a QoS policy in a project, all
new networks created will have this QoS policy assigned by default.

If a new QoS policy is created or updated with this flag and another
QoS policy in the same project is set as the default policy, the new
one won't be created or updated. To set another QoS policy as default,
the current one must be unset.

DocImpact: A "default" flag is introduced for QoS policies. If this flag
           is enabled in a QoS policy (attached to a project), then all
           networks created in this project would have this QoS policy
           assigned, unless an explicit policy is specified.
APIImpact

Closes-Bug: #1639220
Change-Id: If5ff2b00fa828f93aa089e275ddbd1ff542b79d4
2017-05-26 23:31:36 +00:00
Victor Morales 474bfe289a Refactoring _create_test methods for OVO UTs
Most of the _create_test methods create a property and only uses
its id during their execution.  This change pretends to simplify
the returned data and reduce the number of lines used for the
creation of test data used during the execution of Unit Tests for
Oslo-Versioned Objects.

Change-Id: Icfc251a7d460246e91e260a4ac503d10c4031170
Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db
2017-04-17 12:05:19 -07:00
Carlos Goncalves 89de63de05 Port data plane status extension implementation
Implements the port data plane status extension. Third parties
can report via Neutron API issues in the underlying data plane
affecting connectivity from/to Neutron ports.

Supported statuses:
  - None: no status being reported; default value
  - ACTIVE: all is up and running
  - DOWN: no traffic can flow from/to the Neutron port

Setting attribute available to admin or any user with specific role
(default role: data_plane_integrator).

ML2 extension driver loaded on request via configuration:

  [ml2]
  extension_drivers = data_plane_status

Related-Bug: #1598081
Related-Bug: #1575146

DocImpact: users can get status of the underlying port data plane;
attribute writable by admin users and users granted the
'data-plane-integrator' role.
APIImpact: port now has data_plane_status attr, set on port update

Implements: blueprint port-data-plane-status

Depends-On: I04eef902b3310f799b1ce7ea44ed7cf77c74da04
Change-Id: Ic9e1e3ed9e3d4b88a4292114f4cb4192ac4b3502
2017-04-11 19:56:13 +00:00
Jenkins 1a528e817f Merge "Add DictOfMiscValuesField in OVO for dict usage" 2017-01-13 11:48:49 +00:00
Victor Morales d5f4cdc216 Centralize creation of security group test obj
The creation of security group objects are duplicated in several
places. This patch pretends to consolidate this in a single function
where it can be reused in the future.

Change-Id: I3c2b30c258e665f47ea7d3cffdb6e7333b2944a8
Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db
2017-01-10 14:37:42 -06:00
Artur Korzeniewski cc27af1044 Add DictOfMiscValuesField in OVO for dict usage
Add new field acting as full Pythonic dict equivalent for OVO.
Usage of DictOfStringField is not handling the case, when values should
be boolean, integer, float or list/dict.

Also use new field for Agent, PortBinding and DistributedPortBinding.

Change-Id: Iea3a6de89325401892b4e60ae1eb3a1d75b3ef31
Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db
2017-01-05 07:57:06 +00:00
Sindhu Devale ec153ee9d9 get_random_object_fields() for setting object attr
This patch is to introduce a modified get_random_fields() method to
set the attributes of an object as currently get_random_fields() returns
the modified fields which are suitable to be stored in the database,
however when fields of the objects are assigned with these values
the type won't match. For example, if an object has a custom type field
like DictOfStringField, get_random_fields() generates dict of string
values, however while returning the values it converts the dict to
a string but the object still expects a DictOfStringField type.

Also, everytime get_random_fields() is used for initializing the fields
of an object, modify_fields_to_db() gets called twice, once in the
get_random_fields() method and once while creating the object.

Change-Id: I8a5fc6603e625b0b98d330f6abd8c6588b1a8c31
2016-12-15 09:48:21 +00:00
Ihar Hrachyshka 79e62516af tests: introduce update_obj_fields method in base objects test class
This method can be used by subclasses to inject specific values into
randomly generated values for objects, for example, when we need to link
those automatic test objects to other objects through foreign keys.

Change-Id: Ic32ebf5ef055b25e4c765a9bf71ca4657d3b3d70
Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db
2016-11-29 07:29:31 +00:00
Victor Morales 96b8d9a9af Agent to OVO
This patch introduces Agent model class to Oslo Versioned Object.

Given the number of dependencies and methods that use the model class,
the integration patch will be created in separated patch.

Co-Authored-By: Tony Tan <tonytan198211@gmail.com>

Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db
Change-Id: I4145b7f59b58a55c1a76b91618097ff69aee1568
2016-11-10 07:25:17 +00:00
Kevin Benton 660946a921 Fix modify_fields_from_db for vif_details empty str
vif_details is represented as an empty string in our DB schema
when it's not defined. The 'modify_fields_from_db' method was
incorrectly attempting to feed this directly into the json decoder.

Closes-Bug: #1638703
Change-Id: I7b13fb30de71bb4dce4dbab4ffe430e1d0ef8f3a
2016-11-03 23:02:31 +00:00
Manjeet Singh Bhatia 6a011c3f26 Replace create_test_network with network object
This patch will replace the creation of network with
Network object, previously object_db_api was directly
used given now object is introduced we can use it.

Change-Id: I11a73f033171151e97c868108eda39fe178722f4
2016-10-03 16:28:38 +00:00
Artur Korzeniewski 94ee8bc306 Introduce ovo objects for networks
Those objects are intentionally not integrated into the database code so
far. This is to quicken access to their definitions to implement
push-notifications for networks.

Segments are part of the network object. Since we need to reduce the
number of SQL queries executed per resource, and we want to include
segmentation information for networks, Network model was extended with
segments relationship that makes the information available on every
network resource fetch from the database. This change required some
change in test_dhcp_agent_scheduler to expire a session used in the
tests to avoid obsolete segment state to be reused to validate
scheduling.

This implementation of the object is not complete for the job of
updating the resource in database. For example, tags are not yet exposed
on the object; also attributes like availability_zones, or external
network attributes, are not covered. Those attributes are hopefully
needed on server side only, so until we adopt the object for server
side, it should be ok to live without them.

Another database related thing still missing in this patch is lack of
RBAC support for the object. To complete this support,
a real get_bound_tenant_ids should be put onto the object, instead of
the current no-op stub.

This patch also includes some rearrangements that simplified the work.
Specifically, all network related objects are consolidated in the
neutron.objects.network module, instead of being scattered through the
code base. Also, some setup code from test_policy relevant to RBAC was
moved into the base test class so that it can be utilized by other RBAC
enabled objects, like network.

Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db
Partially-Implements: blueprint push-notifications

Co-Authored-By: Victor Morales <victor.morales@intel.com>
Change-Id: I5160d0ab9e8042c356229420739db0ce42842368
2016-09-29 15:36:47 +00:00
Ihar Hrachyshka dcd78423aa Introduce ovo objects for ports
Those objects are intentionally not integrated into the database code so
far. This is to quicken access to their definitions to implement
push-notifications for security groups and ports.

The object embeds segmentation information in addition to what's
available through the model. Specifically, binding_levels field exposes
all ml2 binding levels, that from their side load corresponding network
segment object. The order for level objects in binding_levels list field
is guaranteed to be in the order of level. So the consumers can eg.
access the bottom binding info with:

  port_obj.binding_levels[-1].segment

For PortBindingLevel object, we want to expose segmentation info. This
is achieved through a 'segment' ObjectField. The database model itself
contains segment_id too. There is no reason though to expose it for
Level object in two places (one as a model field, another one through
the ObjectField), so we avoid adding ID field. The base class that
handles loading for ObjectField based synthetic fields was assuming that
objects always have a field per model attribute, so it needed a slight
adjustment to support this case, where we extract foreign_keys
attributes from the model itself if the field is not present on the
object.

Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db
Partially-Implements: blueprint push-notifications

Change-Id: I25de14e42e345d9235dbf4097c298ef5d606de51
Co-Authored-By: Martin Hickey <martin.hickey@ie.ibm.com>
Co-Authored-By: Rossella Sblendido <rsblendido@suse.com>
Co-Authored-By: Manjeet Singh Bhatia <manjeet.s.bhatia@intel.com>
Co-Authored-By: Brandon Logan <brandon.logan@rackspace.com>
Co-Authored-By: Victor Morales <victor.morales@intel.com>
2016-09-28 20:46:19 +00:00