summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-05-31 20:49:21 +0000
committerGerrit Code Review <review@openstack.org>2017-05-31 20:49:21 +0000
commitd16074b0b545aeaf38216e54b074abb501c64868 (patch)
tree6e08db40347e1fde2614233b6cea0c54b2337352
parent66073fa1f5f68dee808677c96750cfb1c0e69874 (diff)
parentbd7055daf23f03fe2e939e6d585885341422978c (diff)
Merge "Allow offloading lookups in driver contexts" into stable/newton
-rw-r--r--neutron/plugins/ml2/driver_context.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/neutron/plugins/ml2/driver_context.py b/neutron/plugins/ml2/driver_context.py
index f050313..d18bb25 100644
--- a/neutron/plugins/ml2/driver_context.py
+++ b/neutron/plugins/ml2/driver_context.py
@@ -38,12 +38,15 @@ class MechanismDriverContext(object):
38class NetworkContext(MechanismDriverContext, api.NetworkContext): 38class NetworkContext(MechanismDriverContext, api.NetworkContext):
39 39
40 def __init__(self, plugin, plugin_context, network, 40 def __init__(self, plugin, plugin_context, network,
41 original_network=None): 41 original_network=None, segments=None):
42 super(NetworkContext, self).__init__(plugin, plugin_context) 42 super(NetworkContext, self).__init__(plugin, plugin_context)
43 self._network = network 43 self._network = network
44 self._original_network = original_network 44 self._original_network = original_network
45 self._segments = segments_db.get_network_segments( 45 if segments is None:
46 plugin_context.session, network['id']) 46 self._segments = segments_db.get_network_segments(
47 plugin_context.session, network['id'])
48 else:
49 self._segments = segments
47 50
48 @property 51 @property
49 def current(self): 52 def current(self):
@@ -88,8 +91,11 @@ class PortContext(MechanismDriverContext, api.PortContext):
88 super(PortContext, self).__init__(plugin, plugin_context) 91 super(PortContext, self).__init__(plugin, plugin_context)
89 self._port = port 92 self._port = port
90 self._original_port = original_port 93 self._original_port = original_port
91 self._network_context = NetworkContext(plugin, plugin_context, 94 if isinstance(network, NetworkContext):
92 network) if network else None 95 self._network_context = network
96 else:
97 self._network_context = NetworkContext(
98 plugin, plugin_context, network) if network else None
93 self._binding = binding 99 self._binding = binding
94 self._binding_levels = binding_levels 100 self._binding_levels = binding_levels
95 self._segments_to_bind = None 101 self._segments_to_bind = None