Backup edge put enhance

When we try to collect one edge to backup edge pool, we need to first
update edge at the backend and then fresh vnic binding db info. If all
above ops are executed successfully, we can finally collect it to edge
pool.

Change-Id: I7ae90c2c802aa2584b470a7e15c2624618e15c88
This commit is contained in:
linb 2016-05-04 13:32:20 +08:00
parent 4fb4141d49
commit 03d16f3006

View File

@ -650,7 +650,6 @@ class EdgeManager(object):
backup_num = len(backup_router_bindings) backup_num = len(backup_router_bindings)
# collect the edge to pool if pool not full # collect the edge to pool if pool not full
if backup_num < edge_pool_range['maximum_pooled_edges']: if backup_num < edge_pool_range['maximum_pooled_edges']:
LOG.debug("Collect edge: %s to pool", binding['edge_id'])
nsxv_db.delete_nsxv_router_binding( nsxv_db.delete_nsxv_router_binding(
context.session, router_id) context.session, router_id)
backup_router_id = (vcns_const.BACKUP_ROUTER_PREFIX + backup_router_id = (vcns_const.BACKUP_ROUTER_PREFIX +
@ -660,7 +659,7 @@ class EdgeManager(object):
backup_router_id, backup_router_id,
binding['edge_id'], binding['edge_id'],
None, None,
plugin_const.ACTIVE, plugin_const.PENDING_UPDATE,
appliance_size=binding['appliance_size'], appliance_size=binding['appliance_size'],
edge_type=binding['edge_type']) edge_type=binding['edge_type'])
# change edge's name at backend # change edge's name at backend
@ -676,6 +675,12 @@ class EdgeManager(object):
if not dist and binding['edge_id']: if not dist and binding['edge_id']:
nsxv_db.init_edge_vnic_binding( nsxv_db.init_edge_vnic_binding(
context.session, binding['edge_id']) context.session, binding['edge_id'])
if task.status == task_const.TaskStatus.COMPLETED:
nsxv_db.update_nsxv_router_binding(
context.session, backup_router_id,
status=plugin_const.ACTIVE)
LOG.debug("Collect edge: %s to pool", binding['edge_id'])
else: else:
nsxv_db.update_nsxv_router_binding( nsxv_db.update_nsxv_router_binding(
context.session, router_id, context.session, router_id,