trunk: avoid redundant refetch of subports on create

Instead of triggering refetch for added sub ports, just populate the
sub_ports fields with objects we already have.

Change-Id: Idefa57323687619a63ff5cb8a57d6600413f7271
Partially-Implements: bp/adopt-oslo-versioned-objects-for-db
This commit is contained in:
Ihar Hrachyshka 2016-07-28 16:24:00 +02:00
parent f03693fdc8
commit 2d2689f3fa
1 changed files with 6 additions and 4 deletions

View File

@ -111,10 +111,12 @@ class Trunk(base.NeutronDbObject):
except o_db_exc.DBReferenceError:
raise n_exc.PortNotFound(port_id=self.port_id)
for sub_port in sub_ports:
sub_port.trunk_id = self.id
sub_port.create()
self.load_synthetic_db_fields()
if sub_ports:
for sub_port in sub_ports:
sub_port.trunk_id = self.id
sub_port.create()
self.sub_ports.append(sub_port)
self.obj_reset_changes(['sub_ports'])
# TODO(ivc): add support for 'sub_ports' in 'Trunk.update' for
# consistency with 'Trunk.create'