@@ -201,10 +201,10 @@ def _schedule_agent_create_service(self, context, loadbalancer,
201201 context , loadbalancer , agent , ** kwargs )
202202 return agent , service
203203
204+ @log_helpers .log_method_call
204205 def _append_listeners (self , context , service , listener ):
205206
206207 if not listener :
207- service ['listeners' ] = []
208208 return
209209
210210 def get_db_listener ():
@@ -226,8 +226,11 @@ def get_db_listener():
226226 [{'id' : l7_policy .id } for l7_policy in listener .l7_policies ]
227227 if listener .default_pool :
228228 listener_dict ['default_pool_id' ] = listener .default_pool .id
229- service ['listeners' ] = [listener_dict ]
230229
230+ LOG .debug ("append listener %s" , listener_dict )
231+ service ['listeners' ].append (listener_dict )
232+
233+ @log_helpers .log_method_call
231234 def _append_pools_monitors (self , context , service , pool ):
232235
233236 if not pool :
@@ -262,6 +265,7 @@ def get_db_pool():
262265 pool .session_persistence .to_api_dict ()
263266 )
264267
268+ LOG .debug ("append pool %s" , pool_dict )
265269 service ['pools' ] = [pool_dict ]
266270
267271 # Place an empty member list as the initial value.
@@ -284,6 +288,7 @@ def get_db_healthmonitor():
284288 healthmonitor_dict = healthmonitor .to_dict (pool = False )
285289 healthmonitor_dict ['pool_id' ] = pool .id
286290
291+ LOG .debug ("append healthmonitor_dict %s" , healthmonitor_dict )
287292 service ['healthmonitors' ] = [healthmonitor_dict ]
288293
289294
@@ -526,7 +531,12 @@ def create(self, context, pool):
526531 self .api_dict = self ._get_pool_dict (pool )
527532
528533 def append_listeners (context , loadbalancer , service ):
529- self ._append_listeners (context , service , pool .listener )
534+ for listener in loadbalancer .listeners :
535+ if listener .default_pool :
536+ if listener .default_pool .id == pool .id :
537+ LOG .debug ("listener %s has default pool %s" ,
538+ listener .id , pool .id )
539+ self ._append_listeners (context , service , listener )
530540
531541 def append_pools_monitors (context , loadbalancer , service ):
532542 self ._append_pools_monitors (context , service , pool )
@@ -572,7 +582,12 @@ def delete(self, context, pool):
572582 self .api_dict = self ._get_pool_dict (pool )
573583
574584 def append_listeners (context , loadbalancer , service ):
575- self ._append_listeners (context , service , pool .listener )
585+ for listener in loadbalancer .listeners :
586+ if listener .default_pool :
587+ if listener .default_pool .id == pool .id :
588+ LOG .debug ("listener %s has default pool %s" ,
589+ listener .id , pool .id )
590+ self ._append_listeners (context , service , listener )
576591
577592 def append_pools_monitors (context , loadbalancer , service ):
578593 self ._append_pools_monitors (context , service , pool )
0 commit comments