def get_write_memory_flow(self, vthunder, store): """Perform write memory for thunder """ sf_name = 'a10-house-keeper' + '-' + a10constants.WRITE_MEMORY_THUNDER_FLOW write_memory_flow = linear_flow.Flow(sf_name) vthunder_store = {} vthunder_store[vthunder.vthunder_id] = vthunder write_memory_flow.add( a10_database_tasks.GetActiveLoadBalancersByThunder( requires=a10constants.VTHUNDER, rebind={a10constants.VTHUNDER: vthunder.vthunder_id}, name='{flow}-{id}'.format( id=vthunder.vthunder_id, flow='GetActiveLoadBalancersByThunder'), provides=a10constants.LOADBALANCERS_LIST)) write_memory_flow.add( a10_database_tasks.MarkLoadBalancersPendingUpdateInDB( name='{flow}-{id}'.format( id=vthunder.vthunder_id, flow='MarkLoadBalancersPendingUpdateInDB'), requires=a10constants.LOADBALANCERS_LIST)) write_memory_flow.add( vthunder_tasks.WriteMemoryHouseKeeper( requires=(a10constants.VTHUNDER, a10constants.LOADBALANCERS_LIST, a10constants.WRITE_MEM_SHARED_PART), rebind={a10constants.VTHUNDER: vthunder.vthunder_id}, name='{flow}-{partition}-{id}'.format( id=vthunder.vthunder_id, flow='WriteMemory-' + a10constants.WRITE_MEMORY_THUNDER_FLOW, partition=a10constants.WRITE_MEM_FOR_SHARED_PARTITION), provides=a10constants.WRITE_MEM_SHARED)) write_memory_flow.add( vthunder_tasks.WriteMemoryHouseKeeper( requires=(a10constants.VTHUNDER, a10constants.LOADBALANCERS_LIST), rebind={a10constants.VTHUNDER: vthunder.vthunder_id}, name='{flow}-{partition}-{id}'.format( id=vthunder.vthunder_id, flow='WriteMemory-' + a10constants.WRITE_MEMORY_THUNDER_FLOW, partition=a10constants.WRITE_MEM_FOR_LOCAL_PARTITION), provides=a10constants.WRITE_MEM_PRIVATE)) write_memory_flow.add( a10_database_tasks.SetThunderLastWriteMem( requires=(a10constants.VTHUNDER, a10constants.WRITE_MEM_SHARED, a10constants.WRITE_MEM_PRIVATE), rebind={a10constants.VTHUNDER: vthunder.vthunder_id}, name='{flow}-{id}'.format(id=vthunder.vthunder_id, flow='SetThunderLastWriteMem'))) write_memory_flow.add( a10_database_tasks.MarkLoadBalancersActiveInDB( name='{flow}-{id}'.format(id=vthunder.vthunder_id, flow='MarkLoadBalancersActiveInDB'), requires=a10constants.LOADBALANCERS_LIST)) store.update(vthunder_store) return write_memory_flow
def test_MarkLoadBalancersPendingUpdateInDB_execute(self): lb_task = task.MarkLoadBalancersPendingUpdateInDB() lb_list = [] lb_list.append(LB) lb_task.loadbalancer_repo.update = mock.Mock() lb_task.execute(lb_list) lb_task.loadbalancer_repo.update.assert_called_once_with( mock.ANY, LB.id, provisioning_status=mock.ANY)
def get_failover_vcs_vthunder_flow(self): """Perform failover for VCS vthunder device""" sf_name = 'a10-house-keeper-failover-vcs-vthunder' failover_flow = linear_flow.Flow(sf_name) failover_flow.add( a10_database_tasks.GetComputeVThundersAndLoadBalancers( name=sf_name + '-' + a10constants.GET_LBS_BY_THUNDER, requires=a10constants.VTHUNDER, provides=(a10constants.VTHUNDER_LIST, a10constants.LOADBALANCERS_LIST))) # Switch role may not necessary failover_flow.add( a10_database_tasks.SetVThunderToStandby( name=sf_name + '-' + a10constants.SET_VTHUNDER_TO_STANDBY, requires=a10constants.VTHUNDER_LIST)) failover_flow.add( a10_database_tasks.LoadBalancerListToErrorOnRevertTask( name=sf_name + '-' + a10constants.MARK_LB_LIST_ERROR_ON_REVERT, requires=a10constants.LOADBALANCERS_LIST)) failover_flow.add( a10_database_tasks.MarkLoadBalancersPendingUpdateInDB( name=sf_name + '-' + a10constants.MARK_LB_PENIND_UPDATE_IN_DB, requires=a10constants.LOADBALANCERS_LIST)) failover_flow.add( a10_network_tasks.GetVThunderNetworkList( name=sf_name + '-' + a10constants.GET_VTHUNDER_NETWORK_LIST, requires=a10constants.VTHUNDER, provides=a10constants.NETWORK_LIST)) failover_flow.add(self._get_failover_amphora_subflow(sf_name)) failover_flow.add(self._get_failover_configure_vcs_subflow(sf_name)) failover_flow.add( compute_tasks.DeleteStaleCompute(name=sf_name + '-' + 'delete-stale-compute', requires=(a10constants.VTHUNDER))) failover_flow.add( a10_database_tasks.FailoverPostDbUpdate( name=sf_name + '-' + a10constants.POST_FAILOVER_DB_UPDATE, requires=(a10constants.VTHUNDER, a10constants.SPARE_VTHUNDER))) failover_flow.add( a10_database_tasks.DeleteStaleSpareVThunder( name=sf_name + '-' + a10constants.DELETE_STALE_SPARE_VTHUNDER, requires=(a10constants.SPARE_VTHUNDER))) failover_flow.add( a10_database_tasks.MarkLoadBalancersActiveInDB( name=sf_name + '-' + a10constants.MARK_LB_ACTIVE_IN_DB, requires=a10constants.LOADBALANCERS_LIST)) return failover_flow
def test_MarkLoadBalancersPendingUpdateInDB_execute_for_empty_list(self): lb_task = task.MarkLoadBalancersPendingUpdateInDB() lb_list = [] lb_task.loadbalancer_repo.update = mock.Mock() lb_task.execute(lb_list) lb_task.loadbalancer_repo.update.assert_not_called()