|
29 | 29 | from neutron_lib.api.definitions import portbindings |
30 | 30 | from neutron_lib import constants as neutron_const |
31 | 31 | from neutron_lib import exceptions as q_exc |
32 | | - |
33 | 32 | from oslo_log import helpers as log_helpers |
34 | 33 | from oslo_log import log as logging |
35 | 34 |
|
36 | | - |
37 | 35 | LOG = logging.getLogger(__name__) |
38 | 36 |
|
39 | 37 |
|
@@ -179,6 +177,7 @@ def get_active_loadbalancers(self, context, env, group=None, host=None): |
179 | 177 | } |
180 | 178 | ) |
181 | 179 | if host: |
| 180 | + LOG.debug('get active lb with host %s' % host) |
182 | 181 | return [lb for lb in loadbalancers if lb['agent_host'] == host] |
183 | 182 | else: |
184 | 183 | return loadbalancers |
@@ -327,6 +326,44 @@ def pool_destroyed(self, context, pool_id=None): |
327 | 326 | """Agent confirmation hook that pool has been destroyed.""" |
328 | 327 | self.driver.plugin.db.delete_pool(context, pool_id) |
329 | 328 |
|
| 329 | + @log_helpers.log_method_call |
| 330 | + def update_member_status_in_batch(self, context, members=[]): |
| 331 | + """Agent confirmations hook to update member status in batch.""" |
| 332 | + length = len(members) |
| 333 | + LOG.debug('before updating status in batch %d', length) |
| 334 | + for member in members: |
| 335 | + try: |
| 336 | + pool_id = member['pool_id'] |
| 337 | + address = member['address'] |
| 338 | + port = member['protocol_port'] |
| 339 | + status = member['state'] |
| 340 | + model = models.MemberV2 |
| 341 | + |
| 342 | + query = self.driver.plugin.db._model_query( |
| 343 | + context, model).filter( |
| 344 | + model.pool_id == pool_id, |
| 345 | + model.address == address, |
| 346 | + model.protocol_port == port) |
| 347 | + |
| 348 | + resource = query.one() |
| 349 | + if not resource: |
| 350 | + LOG.debug("no resource found.") |
| 351 | + continue |
| 352 | + |
| 353 | + self.driver.plugin.db.update_status( |
| 354 | + context, |
| 355 | + model, |
| 356 | + resource.id, |
| 357 | + None, |
| 358 | + status |
| 359 | + ) |
| 360 | + # we only deal with Not found exception and skip all the others |
| 361 | + except Exception as e: |
| 362 | + LOG.error('Exception: update_pool_status_in_batch: %s', |
| 363 | + e.message) |
| 364 | + LOG.debug('end updating status in batch %d.', length) |
| 365 | + return |
| 366 | + |
330 | 367 | @log_helpers.log_method_call |
331 | 368 | def update_member_status(self, context, member_id=None, |
332 | 369 | provisioning_status=None, |
|
0 commit comments