load neutron objects using neutron-lib

To access neutron objects we're moving to a dynamic plugin approach as
shown in the depends on and related patches.

This patch removes the imports of neutron.objects and uses neutron-lib
to load them instead. The remaining base object import will be addressed
later.

It also bumps neutron-lib up to 1.14.0.

Change-Id: Ia0904a2c97749fb13604a44fee3c96c40588e0b2
Depends-On: https://review.openstack.org/#/c/570060/
This commit is contained in:
Boden R 2018-05-24 15:42:53 -06:00
parent 4b5b0b7ce4
commit ce0edffa81
2 changed files with 8 additions and 6 deletions

View File

@ -16,7 +16,7 @@ keystoneauth1>=3.4.0 # Apache-2.0
keystonemiddleware>=4.17.0 # Apache-2.0
netaddr>=0.7.18 # BSD
netifaces>=0.10.4 # MIT
neutron-lib>=1.13.0 # Apache-2.0
neutron-lib>=1.14.0 # Apache-2.0
retrying!=1.3.0,>=1.2.3 # Apache-2.0
SQLAlchemy!=1.1.5,!=1.1.6,!=1.1.7,!=1.1.8,>=1.0.10 # MIT
WebOb>=1.7.1 # MIT

View File

@ -14,9 +14,9 @@
# under the License.
from neutron.objects import ports as ports_object
from neutron.services.qos import qos_plugin
from neutron_lib.api.definitions import portbindings
from neutron_lib.objects import registry as obj_reg
from oslo_log import log
import tricircle.common.client as t_client
@ -41,7 +41,7 @@ class TricircleQosPlugin(qos_plugin.QoSPlugin):
def _get_ports_with_policy(self, context, policy):
networks_ids = policy.get_bound_networks()
ports_with_net_policy = ports_object.Port.get_objects(
ports_with_net_policy = obj_reg.load_class('Port').get_objects(
context, network_id=networks_ids)
# Filter only these ports which don't have overwritten policy
@ -51,7 +51,7 @@ class TricircleQosPlugin(qos_plugin.QoSPlugin):
]
ports_ids = policy.get_bound_ports()
ports_with_policy = ports_object.Port.get_objects(
ports_with_policy = obj_reg.load_class('Port').get_objects(
context, id=ports_ids)
t_ports = list(set(ports_with_policy + ports_with_net_policy))
@ -64,7 +64,8 @@ class TricircleQosPlugin(qos_plugin.QoSPlugin):
b_region_name = b_pod['region_name']
b_client = self._get_client(region_name=b_region_name)
b_port = b_client.get_ports(t_ctx, b_port_id)
new_binding = ports_object.PortBinding(
new_binding = obj_reg.new_instance(
'PortBinding',
port_id=t_port.id,
vif_type=b_port.get('binding:vif_type',
portbindings.VIF_TYPE_UNBOUND),
@ -73,7 +74,8 @@ class TricircleQosPlugin(qos_plugin.QoSPlugin):
)
t_port.binding = new_binding
else:
new_binding = ports_object.PortBinding(
new_binding = obj_reg.new_instance(
'PortBinding',
port_id=t_port.id,
vif_type=portbindings.VIF_TYPE_UNBOUND,
vnic_type=portbindings.VNIC_NORMAL