Exemplo n.º 1
0
    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
Exemplo n.º 2
0
 def test_SetThunderLastWriteMem_execute_update(self):
     db_task = task.SetThunderLastWriteMem()
     vthunder = copy.deepcopy(VTHUNDER)
     db_task.vthunder_repo.update_last_write_mem = mock.Mock()
     db_task.execute(vthunder, True, True)
     db_task.vthunder_repo.update_last_write_mem.assert_called_once_with(
         mock.ANY,
         vthunder.ip_address,
         vthunder.partition_name,
         last_write_mem=mock.ANY)