Ejemplo 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
Ejemplo n.º 2
0
 def test_WriteMemoryHouseKeeper_execute_save_shared_mem(self):
     mock_thunder = copy.deepcopy(VTHUNDER)
     mock_thunder.loadbalancer_id = a10constants.MOCK_LOAD_BALANCER_ID
     lb_list = []
     lb_list.append(LB)
     mock_task = task.WriteMemoryHouseKeeper()
     mock_task.axapi_client = self.client_mock
     mock_task.execute(mock_thunder, lb_list, True)
     self.client_mock.system.action.write_memory.assert_called_with(
         partition='shared')
Ejemplo n.º 3
0
 def test_WriteMemoryHouseKeeper_execute_save_specific_partition_mem(self):
     thunder = copy.deepcopy(VTHUNDER)
     thunder.loadbalancer_id = a10constants.MOCK_LOAD_BALANCER_ID
     lb_list = []
     lb_list.append(LB)
     thunder.partition_name = "testPartition"
     mock_task = task.WriteMemoryHouseKeeper()
     mock_task.axapi_client = self.client_mock
     mock_task.execute(thunder, lb_list)
     self.client_mock.system.action.write_memory.assert_called_with(
         partition='specified', specified_partition='testPartition')