@@ -109,6 +109,16 @@ def run(self, event, row, old):
109
109
self .agent .resync ()
110
110
111
111
112
+ class PortBindingCreateWithChassis (PortBindingEvent ):
113
+ EVENT = PortBindingEvent .ROW_CREATE
114
+
115
+ def match_fn (self , event , row , old ):
116
+ self ._log_msg = "Port %s in datapath %s bound to our chassis on insert"
117
+ if not (super ().match_fn (event , row , old ) and row .chassis ):
118
+ return False
119
+ return row .chassis [0 ].name == self .agent .chassis
120
+
121
+
112
122
class PortBindingUpdatedEvent (PortBindingEvent ):
113
123
EVENT = PortBindingEvent .ROW_UPDATE
114
124
@@ -316,6 +326,7 @@ def start(self):
316
326
tables = ('Encap' , 'Port_Binding' , 'Datapath_Binding' , 'SB_Global' ,
317
327
'Chassis' )
318
328
events = (PortBindingUpdatedEvent (self ),
329
+ PortBindingCreateWithChassis (self ),
319
330
PortBindingDeletedEvent (self ),
320
331
SbGlobalUpdateEvent (self ),
321
332
)
@@ -345,7 +356,8 @@ def start(self):
345
356
self ._proxy .run ()
346
357
347
358
# Do the initial sync.
348
- self .sync ()
359
+ # Provisioning handled by PortBindingCreateWithChassis
360
+ self .sync (provision = False )
349
361
350
362
# Register the agent with its corresponding Chassis
351
363
self .register_metadata_agent ()
@@ -396,7 +408,7 @@ def get_networks_datapaths(self):
396
408
return set (p .datapath for p in self ._vif_ports (ports ))
397
409
398
410
@_sync_lock
399
- def sync (self ):
411
+ def sync (self , provision = True ):
400
412
"""Agent sync.
401
413
402
414
This function will make sure that all networks with ports in our
@@ -423,8 +435,9 @@ def sync(self):
423
435
# resync all network namespaces based on the associated datapaths,
424
436
# even those that are already running. This is to make sure
425
437
# everything within each namespace is up to date.
426
- for datapath in net_datapaths :
427
- self .provision_datapath (datapath )
438
+ if provision :
439
+ for datapath in net_datapaths :
440
+ self .provision_datapath (datapath )
428
441
429
442
@staticmethod
430
443
def _get_veth_name (datapath ):
0 commit comments