Avoid segment DB lookup in _expand_segment on port
The port context already has a network attached to it that contains all of the segments for that network. In all cases the segments the port wants to lookup should be present here so we can just iterate over them without a separate DB query. Partial-Bug: #1665215 Change-Id: I9014c4e401134f4db908ed989e0095d0ca95b7c9
This commit is contained in:
parent
4134f882cc
commit
2c01ad9c56
|
@ -192,6 +192,12 @@ class PortContext(MechanismDriverContext, api.PortContext):
|
|||
self._original_binding_levels[-1].segment_id)
|
||||
|
||||
def _expand_segment(self, segment_id):
|
||||
for s in self.network.network_segments:
|
||||
if s['id'] == segment_id:
|
||||
return s
|
||||
# TODO(kevinbenton): eliminate the query below. The above should
|
||||
# always return since the port is bound to a network segment. Leaving
|
||||
# in for now for minimally invasive change for back-port.
|
||||
segment = segments_db.get_segment_by_id(self._plugin_context,
|
||||
segment_id)
|
||||
if not segment:
|
||||
|
|
Loading…
Reference in New Issue