def get_rack_vthunder_for_lb_subflow(self,
                                         vthunder_conf,
                                         prefix,
                                         role=constants.ROLE_STANDALONE):
        """ reload the loadbalancer and make entry in database"""

        sf_name = prefix + '-' + constants.GET_AMPHORA_FOR_LB_SUBFLOW

        amp_for_lb_flow = linear_flow.Flow(sf_name)

        amp_for_lb_flow.add(
            database_tasks.ReloadLoadBalancer(
                name=sf_name + '-' + 'reload_loadbalancer',
                requires=constants.LOADBALANCER_ID,
                provides=constants.LOADBALANCER))
        amp_for_lb_flow.add(
            a10_database_tasks.CreateRackVthunderEntry(
                name=sf_name + '-' + 'create_rack_vThunder_entry_in_database',
                inject={a10constants.VTHUNDER_CONFIG: vthunder_conf},
                requires=(constants.LOADBALANCER,
                          a10constants.VTHUNDER_CONFIG)))
        amp_for_lb_flow.add(
            a10_database_tasks.GetVThunderByLoadBalancer(
                requires=constants.LOADBALANCER,
                provides=a10constants.VTHUNDER))
        amp_for_lb_flow.add(
            vthunder_tasks.HandleACOSPartitionChange(
                name=sf_name + '-' + a10constants.CHANGE_PARTITION,
                requires=a10constants.VTHUNDER))
        return amp_for_lb_flow
Esempio n. 2
0
 def test_HandleACOSPartitionChange_execute_create_partition(
         self, mock_utils):
     mock_client = mock.Mock()
     mock_client.system.partition.get.side_effect = acos_errors.NotFound()
     mock_utils.get_axapi_client.return_value = mock_client
     mock_thunder = copy.deepcopy(VTHUNDER)
     mock_thunder.partition_name = "PartitionA"
     task.HandleACOSPartitionChange().execute(mock_thunder)
     mock_client.system.partition.create.assert_called_with("PartitionA")
Esempio n. 3
0
 def test_HandleACOSPartitionChange_execute_partition_found_active(
         self, mock_utils):
     partition = {'status': 'Active'}
     mock_client = mock.Mock()
     mock_client.system.partition.get.return_value = partition
     mock_utils.get_axapi_client.return_value = mock_client
     mock_thunder = copy.deepcopy(VTHUNDER)
     mock_thunder.partition_name = "PartitionA"
     task.HandleACOSPartitionChange().execute(mock_thunder)
     mock_client.system.partition.create.assert_not_called()
Esempio n. 4
0
 def test_HandleACOSPartitionChange_execute_partition_found_not_active(
         self, mock_utils):
     partition = {'status': 'Not-Active'}
     mock_client = mock.Mock()
     mock_client.system.partition.get.return_value = partition
     mock_utils.get_axapi_client.return_value = mock_client
     mock_thunder = copy.deepcopy(VTHUNDER)
     mock_thunder.partition_name = "PartitionA"
     expected_error = exceptions.PartitionNotActiveError
     task_function = task.HandleACOSPartitionChange().execute
     self.assertRaises(expected_error, task_function, mock_thunder)
Esempio n. 5
0
 def test_HandleACOSPartitionChange_execute_create_partition_fail(
         self, mock_utils):
     mock_client = mock.Mock()
     mock_client.system.partition.get.side_effect = acos_errors.NotFound()
     mock_client.system.action.write_memory.side_effect = acos_errors.ACOSException(
     )
     mock_utils.get_axapi_client.return_value = mock_client
     mock_thunder = copy.deepcopy(VTHUNDER)
     mock_thunder.partition_name = "PartitionA"
     expected_error = acos_errors.ACOSException
     task_function = task.HandleACOSPartitionChange().execute
     self.assertRaises(expected_error, task_function, mock_thunder)