Exemplo n.º 1
0
    def test_ComputeCreate_execute_net_list_with_diff(self, mock_driver):
        mgmt_id = 'mock-mgmt-net-id'
        license_id = 'mock-mock-license-net-id'
        boot_list = ['mock-data-net-id-1', 'mock-data-net-id-2']
        net_list = [mgmt_id, boot_list[0], license_id]

        self.conf.config(group=a10constants.A10_CONTROLLER_WORKER_CONF_SECTION,
                         amp_mgmt_network=mgmt_id,
                         amp_boot_network_list=boot_list)
        self.conf.config(group=a10constants.GLM_LICENSE_CONFIG_SECTION,
                         amp_license_network=license_id)

        compute_task = task.ComputeCreate()
        compute_task.compute = mock.MagicMock()
        compute_task.execute(AMPHORA.id,
                             loadbalancer=LB,
                             network_list=net_list)
        args, kwargs = compute_task.compute.build.call_args

        actual_net_ids = kwargs.get('network_ids')
        expected_net_ids = {mgmt_id, license_id,
                            LB.vip.network_id}.union(boot_list)

        self.assertEqual(actual_net_ids[0], mgmt_id)
        self.assertNotEqual(set(actual_net_ids), set(net_list))
        self.assertNotEqual(len(actual_net_ids), len(net_list))
        self.assertEqual(set(actual_net_ids), expected_net_ids)
        self.assertEqual(len(actual_net_ids), len(expected_net_ids))
Exemplo n.º 2
0
 def test_ComputeCreate_execute_lb_only(self, mock_driver):
     self.conf.config(group=a10constants.A10_CONTROLLER_WORKER_CONF_SECTION,
                      amp_boot_network_list=[a10constants.MOCK_NETWORK_ID])
     compute_task = task.ComputeCreate()
     compute_task.compute.build = mock.MagicMock()
     compute_task.execute(AMPHORA.id, loadbalancer=LB)
     args, kwargs = compute_task.compute.build.call_args
     self.assertIn('vip-net-1', kwargs['network_ids'])
Exemplo n.º 3
0
 def test_ComputeCreate_execute_mgmt_only(self, mock_driver):
     self.conf.config(group=a10constants.A10_CONTROLLER_WORKER_CONF_SECTION,
                      amp_mgmt_network=a10constants.MOCK_NETWORK_ID)
     compute_task = task.ComputeCreate()
     compute_task.compute = mock.MagicMock()
     compute_task.execute(AMPHORA.id)
     args, kwargs = compute_task.compute.build.call_args
     self.assertEqual(kwargs.get('network_ids'),
                      [a10constants.MOCK_NETWORK_ID])
Exemplo n.º 4
0
    def _get_failover_create_amphora_subflow(self, prefix):
        """Flow to create amphora for failover"""
        create_amp_flow = linear_flow.Flow(constants.CREATE_AMPHORA_FLOW)
        sf_name = prefix + '-' + a10constants.SPARE_VTHUNDER_CREATE

        create_amp_flow.add(
            database_tasks.CreateAmphoraInDB(name=sf_name + '-' +
                                             constants.CREATE_AMPHORA_INDB,
                                             provides=constants.AMPHORA_ID))
        create_amp_flow.add(
            compute_tasks.ComputeCreate(
                name=sf_name + '-' + constants.COMPUTE_CREATE,
                requires=(constants.AMPHORA_ID, a10constants.NETWORK_LIST),
                provides=constants.COMPUTE_ID))
        create_amp_flow.add(
            database_tasks.UpdateAmphoraComputeId(
                name=sf_name + '-' + constants.UPDATE_AMPHORA_COMPUTEID,
                requires=(constants.AMPHORA_ID, constants.COMPUTE_ID)))

        create_amp_flow.add(
            database_tasks.MarkAmphoraBootingInDB(
                name=sf_name + '-' + constants.MARK_AMPHORA_BOOTING_INDB,
                requires=(constants.AMPHORA_ID, constants.COMPUTE_ID)))
        create_amp_flow.add(
            compute_tasks.ComputeActiveWait(
                name=sf_name + '-' + constants.COMPUTE_WAIT,
                requires=(constants.COMPUTE_ID, constants.AMPHORA_ID),
                provides=constants.COMPUTE_OBJ))
        create_amp_flow.add(
            database_tasks.UpdateAmphoraInfo(
                name=sf_name + '-' + constants.UPDATE_AMPHORA_INFO,
                requires=(constants.AMPHORA_ID, constants.COMPUTE_OBJ),
                provides=constants.AMPHORA))
        create_amp_flow.add(
            a10_database_tasks.CreateSpareVThunderEntry(
                requires=(constants.AMPHORA),
                provides=a10constants.SPARE_VTHUNDER))
        create_amp_flow.add(
            vthunder_tasks.VThunderComputeConnectivityWait(
                name=sf_name + '-' + constants.AMP_COMPUTE_CONNECTIVITY_WAIT,
                requires=constants.AMPHORA,
                rebind={a10constants.VTHUNDER: a10constants.SPARE_VTHUNDER}))
        create_amp_flow.add(
            a10_database_tasks.MarkVThunderStatusInDB(
                rebind={a10constants.VTHUNDER: a10constants.SPARE_VTHUNDER},
                inject={"status": a10constants.READY}))
        create_amp_flow.add(
            vthunder_tasks.UpdateAcosVersionInVthunderEntry(
                name=sf_name + '-' +
                a10constants.UPDATE_ACOS_VERSION_IN_VTHUNDER_ENTRY,
                rebind={a10constants.VTHUNDER: a10constants.SPARE_VTHUNDER}))
        create_amp_flow.add(
            vthunder_tasks.EnableInterfaceOnSpare(
                name=sf_name + '-' + a10constants.ENABLE_VTHUNDER_INTERFACE,
                rebind={a10constants.VTHUNDER: a10constants.SPARE_VTHUNDER}))
        return create_amp_flow
Exemplo n.º 5
0
 def test_ComputeCreate_execute_glm_only(self, mock_driver):
     self.conf.config(group=a10constants.GLM_LICENSE_CONFIG_SECTION,
                      amp_license_network=a10constants.MOCK_NETWORK_ID)
     self.conf.config(group=a10constants.A10_CONTROLLER_WORKER_CONF_SECTION,
                      amp_boot_network_list=['mock-network-id-2'])
     compute_task = task.ComputeCreate()
     compute_task.compute.build = mock.MagicMock()
     compute_task.execute(AMPHORA.id)
     args, kwargs = compute_task.compute.build.call_args
     self.assertIn('mock-network-1', kwargs.get('network_ids'))
Exemplo n.º 6
0
 def test_ComputeCreate_execute_mgmt_is_lb(self, mock_driver):
     loadbalancer = copy.deepcopy(LB)
     loadbalancer.vip.network_id = a10constants.MOCK_NETWORK_ID
     self.conf.config(group=a10constants.A10_CONTROLLER_WORKER_CONF_SECTION,
                      amp_mgmt_network=a10constants.MOCK_NETWORK_ID)
     compute_task = task.ComputeCreate()
     compute_task.compute.build = mock.MagicMock()
     compute_task.execute(AMPHORA.id, loadbalancer=loadbalancer)
     args, kwargs = compute_task.compute.build.call_args
     self.assertEqual(kwargs.get('network_ids'),
                      [a10constants.MOCK_NETWORK_ID])
Exemplo n.º 7
0
    def test_ComputeCreate_execute_boot_only(self, mock_driver):
        boot_list = [a10constants.MOCK_NETWORK_ID, 'mock-network-id-2']
        self.conf.config(group=a10constants.A10_CONTROLLER_WORKER_CONF_SECTION,
                         amp_boot_network_list=boot_list)
        compute_task = task.ComputeCreate()
        compute_task.compute = mock.MagicMock()
        compute_task.execute(AMPHORA.id)
        args, kwargs = compute_task.compute.build.call_args

        actual_net_ids = kwargs.get('network_ids')
        self.assertEqual(set(boot_list), set(actual_net_ids))
        self.assertEqual(len(boot_list), len(actual_net_ids))
Exemplo n.º 8
0
    def test_ComputeCreate_execute_glm_in_boot(self, mock_driver):
        boot_list = ['mock-mgmt-net-id', a10constants.MOCK_NETWORK_ID]

        self.conf.config(group=a10constants.A10_CONTROLLER_WORKER_CONF_SECTION,
                         amp_boot_network_list=boot_list)
        self.conf.config(group=a10constants.GLM_LICENSE_CONFIG_SECTION,
                         amp_license_network=a10constants.MOCK_NETWORK_ID)

        compute_task = task.ComputeCreate()
        compute_task.compute = mock.MagicMock()
        compute_task.execute(AMPHORA.id)
        args, kwargs = compute_task.compute.build.call_args

        actual_net_ids = kwargs.get('network_ids')
        self.assertIn(a10constants.MOCK_NETWORK_ID, actual_net_ids)
        self.assertEqual(len(actual_net_ids), len(boot_list))
Exemplo n.º 9
0
    def get_create_vthunder_flow(self):
        """Flow to create a spare amphora."""

        create_vthunder_flow = linear_flow.Flow(constants.CREATE_AMPHORA_FLOW)
        sf_name = a10constants.SPARE_VTHUNDER_CREATE
        create_vthunder_flow.add(
            database_tasks.CreateAmphoraInDB(name=sf_name + '-' +
                                             constants.CREATE_AMPHORA_INDB,
                                             provides=constants.AMPHORA_ID))

        create_vthunder_flow.add(
            compute_tasks.ComputeCreate(name=sf_name + '-' +
                                        constants.COMPUTE_CREATE,
                                        requires=(
                                            constants.AMPHORA_ID,
                                            constants.BUILD_TYPE_PRIORITY,
                                        ),
                                        provides=constants.COMPUTE_ID))
        create_vthunder_flow.add(
            database_tasks.UpdateAmphoraComputeId(
                name=sf_name + '-' + constants.UPDATE_AMPHORA_COMPUTEID,
                requires=(constants.AMPHORA_ID, constants.COMPUTE_ID)))

        create_vthunder_flow.add(
            database_tasks.MarkAmphoraBootingInDB(
                name=sf_name + '-' + constants.MARK_AMPHORA_BOOTING_INDB,
                requires=(constants.AMPHORA_ID, constants.COMPUTE_ID)))
        create_vthunder_flow.add(
            compute_tasks.ComputeActiveWait(
                name=sf_name + '-' + constants.COMPUTE_WAIT,
                requires=(constants.COMPUTE_ID, constants.AMPHORA_ID),
                provides=constants.COMPUTE_OBJ))
        create_vthunder_flow.add(
            database_tasks.UpdateAmphoraInfo(
                name=sf_name + '-' + constants.UPDATE_AMPHORA_INFO,
                requires=(constants.AMPHORA_ID, constants.COMPUTE_OBJ),
                provides=constants.AMPHORA))
        create_vthunder_flow.add(
            a10_database_tasks.CreateSpareVThunderEntry(
                requires=(constants.AMPHORA), provides=a10constants.VTHUNDER))
        create_vthunder_flow.add(
            vthunder_tasks.VThunderComputeConnectivityWait(
                name=sf_name + '-' + constants.AMP_COMPUTE_CONNECTIVITY_WAIT,
                requires=(a10constants.VTHUNDER, constants.AMPHORA)))
        return create_vthunder_flow
Exemplo n.º 10
0
    def _get_create_amp_for_lb_subflow(self, prefix, role):
        """Flow to create a new vThunder for lb."""

        sf_name = prefix + '-' + constants.CREATE_AMP_FOR_LB_SUBFLOW
        create_amp_for_lb_subflow = linear_flow.Flow(sf_name)
        create_amp_for_lb_subflow.add(
            database_tasks.CreateAmphoraInDB(name=sf_name + '-' +
                                             constants.CREATE_AMPHORA_INDB,
                                             provides=constants.AMPHORA_ID))
        # VIP subnet integration at bootup
        create_amp_for_lb_subflow.add(
            database_tasks.ReloadLoadBalancer(
                name=sf_name + '-' + constants.RELOADLOAD_BALANCER,
                requires=constants.LOADBALANCER_ID,
                provides=constants.LOADBALANCER))
        require_server_group_id_condition = (
            role in (constants.ROLE_BACKUP, constants.ROLE_MASTER)
            and CONF.a10_nova.enable_anti_affinity)

        if require_server_group_id_condition:
            create_amp_for_lb_subflow.add(
                compute_tasks.ComputeCreate(
                    name=sf_name + '-' + constants.COMPUTE_CREATE,
                    requires=(constants.AMPHORA_ID,
                              constants.BUILD_TYPE_PRIORITY,
                              constants.SERVER_GROUP_ID,
                              constants.LOADBALANCER),
                    provides=constants.COMPUTE_ID))
        else:
            create_amp_for_lb_subflow.add(
                compute_tasks.ComputeCreate(
                    name=sf_name + '-' + constants.COMPUTE_CREATE,
                    requires=(constants.AMPHORA_ID,
                              constants.BUILD_TYPE_PRIORITY,
                              constants.LOADBALANCER),
                    provides=constants.COMPUTE_ID))

        create_amp_for_lb_subflow.add(
            database_tasks.UpdateAmphoraComputeId(
                name=sf_name + '-' + constants.UPDATE_AMPHORA_COMPUTEID,
                requires=(constants.AMPHORA_ID, constants.COMPUTE_ID)))
        create_amp_for_lb_subflow.add(
            database_tasks.MarkAmphoraBootingInDB(
                name=sf_name + '-' + constants.MARK_AMPHORA_BOOTING_INDB,
                requires=(constants.AMPHORA_ID, constants.COMPUTE_ID)))
        create_amp_for_lb_subflow.add(
            compute_tasks.ComputeActiveWait(
                name=sf_name + '-' + constants.COMPUTE_WAIT,
                requires=(constants.COMPUTE_ID, constants.AMPHORA_ID),
                provides=constants.COMPUTE_OBJ))
        create_amp_for_lb_subflow.add(
            database_tasks.UpdateAmphoraInfo(
                name=sf_name + '-' + constants.UPDATE_AMPHORA_INFO,
                requires=(constants.AMPHORA_ID, constants.COMPUTE_OBJ),
                provides=constants.AMPHORA))
        # create vThunder entry in custom DB
        create_amp_for_lb_subflow.add(
            a10_database_tasks.CreateVThunderEntry(
                name=sf_name + '-' + a10constants.CREATE_VTHUNDER_ENTRY,
                requires=(constants.AMPHORA, constants.LOADBALANCER),
                inject={
                    a10constants.ROLE: role,
                    a10constants.STATUS: constants.PENDING_CREATE
                }))
        # Get VThunder details from database
        create_amp_for_lb_subflow.add(
            a10_database_tasks.GetVThunderByLoadBalancer(
                name=sf_name + '-' + a10constants.VTHUNDER_BY_LB,
                requires=constants.LOADBALANCER,
                provides=a10constants.VTHUNDER))
        create_amp_for_lb_subflow.add(
            vthunder_tasks.VThunderComputeConnectivityWait(
                name=sf_name + '-' +
                a10constants.WAIT_FOR_VTHUNDER_CONNECTIVITY,
                requires=(a10constants.VTHUNDER, constants.AMPHORA)))
        create_amp_for_lb_subflow.add(
            database_tasks.MarkAmphoraAllocatedInDB(
                name=sf_name + '-' + constants.MARK_AMPHORA_ALLOCATED_INDB,
                requires=(constants.AMPHORA, constants.LOADBALANCER_ID)))
        create_amp_for_lb_subflow.add(
            database_tasks.ReloadAmphora(name=sf_name + '-' +
                                         constants.RELOAD_AMPHORA,
                                         requires=constants.AMPHORA_ID,
                                         provides=constants.AMPHORA))
        create_amp_for_lb_subflow.add(
            a10_network_tasks.GetLBResourceSubnet(
                name=sf_name + '-' + a10constants.GET_LB_RESOURCE,
                rebind={a10constants.LB_RESOURCE: constants.LOADBALANCER},
                provides=constants.SUBNET))
        create_amp_for_lb_subflow.add(
            vthunder_tasks.AllowL2DSR(
                name=sf_name + '-' + a10constants.ALLOW_L2DSR,
                requires=(constants.SUBNET, constants.AMPHORA)))
        if role == constants.ROLE_MASTER:
            create_amp_for_lb_subflow.add(
                database_tasks.MarkAmphoraMasterInDB(
                    name=sf_name + '-' + constants.MARK_AMP_MASTER_INDB,
                    requires=constants.AMPHORA))
        elif role == constants.ROLE_BACKUP:
            create_amp_for_lb_subflow.add(
                database_tasks.MarkAmphoraBackupInDB(
                    name=sf_name + '-' + constants.MARK_AMP_BACKUP_INDB,
                    requires=constants.AMPHORA))
        elif role == constants.ROLE_STANDALONE:
            create_amp_for_lb_subflow.add(
                database_tasks.MarkAmphoraStandAloneInDB(
                    name=sf_name + '-' + constants.MARK_AMP_STANDALONE_INDB,
                    requires=constants.AMPHORA))

        return create_amp_for_lb_subflow
Exemplo n.º 11
0
 def test_ComputeCreate_execute_no_nets(self, mock_driver):
     compute_task = task.ComputeCreate()
     compute_task.compute = mock.MagicMock()
     task_function = compute_task.execute
     expected_error = exceptions.NetworkNotFoundToBootAmphora
     self.assertRaises(expected_error, task_function, AMPHORA.id)
Exemplo n.º 12
0
    def get_create_vthunder_flow(self):
        """Flow to create a spare amphora."""

        create_vthunder_flow = linear_flow.Flow(constants.CREATE_AMPHORA_FLOW)
        sf_name = a10constants.SPARE_VTHUNDER_CREATE
        create_vthunder_flow.add(
            database_tasks.CreateAmphoraInDB(name=sf_name + '-' +
                                             constants.CREATE_AMPHORA_INDB,
                                             provides=constants.AMPHORA_ID))
        create_vthunder_flow.add(
            compute_tasks.ComputeCreate(name=sf_name + '-' +
                                        constants.COMPUTE_CREATE,
                                        requires=(
                                            constants.AMPHORA_ID,
                                            constants.BUILD_TYPE_PRIORITY,
                                        ),
                                        provides=constants.COMPUTE_ID))
        create_vthunder_flow.add(
            database_tasks.UpdateAmphoraComputeId(
                name=sf_name + '-' + constants.UPDATE_AMPHORA_COMPUTEID,
                requires=(constants.AMPHORA_ID, constants.COMPUTE_ID)))
        create_vthunder_flow.add(
            database_tasks.MarkAmphoraBootingInDB(
                name=sf_name + '-' + constants.MARK_AMPHORA_BOOTING_INDB,
                requires=(constants.AMPHORA_ID, constants.COMPUTE_ID)))
        create_vthunder_flow.add(
            compute_tasks.ComputeActiveWait(
                name=sf_name + '-' + constants.COMPUTE_WAIT,
                requires=(constants.COMPUTE_ID, constants.AMPHORA_ID),
                provides=constants.COMPUTE_OBJ))
        create_vthunder_flow.add(
            database_tasks.UpdateAmphoraInfo(
                name=sf_name + '-' + constants.UPDATE_AMPHORA_INFO,
                requires=(constants.AMPHORA_ID, constants.COMPUTE_OBJ),
                provides=constants.AMPHORA))
        create_vthunder_flow.add(
            a10_database_tasks.CreateSpareVThunderEntry(
                requires=(constants.AMPHORA), provides=a10constants.VTHUNDER))
        create_vthunder_flow.add(
            vthunder_tasks.VThunderComputeConnectivityWait(
                name=sf_name + '-' + constants.AMP_COMPUTE_CONNECTIVITY_WAIT,
                requires=(a10constants.VTHUNDER, constants.AMPHORA)))
        create_vthunder_flow.add(
            vthunder_tasks.EnableInterfaceOnSpare(
                name=sf_name + '-' + a10constants.ENABLE_VTHUNDER_INTERFACE,
                requires=(a10constants.VTHUNDER)))
        create_vthunder_flow.add(
            vthunder_tasks.UpdateAcosVersionInVthunderEntry(
                name=sf_name + '-' +
                a10constants.UPDATE_ACOS_VERSION_IN_VTHUNDER_ENTRY,
                requires=(a10constants.VTHUNDER)))
        create_vthunder_flow.add(
            database_tasks.MarkAmphoraReadyInDB(
                name=sf_name + '-' + a10constants.MARK_AMPHORA_READY_INDB,
                requires=(constants.AMPHORA)))
        create_vthunder_flow.add(
            self.get_glm_license_subflow(
                prefix=a10constants.SPARE_VTHUNDER_CREATE,
                role=a10constants.SPARE_VTHUNDER))
        create_vthunder_flow.add(
            vthunder_tasks.CreateHealthMonitorOnVThunder(
                name=sf_name + '-' +
                a10constants.CREATE_HEALTH_MONITOR_ON_SPARE,
                requires=(a10constants.VTHUNDER)))

        create_vthunder_flow.add(
            a10_database_tasks.MarkVThunderStatusInDB(
                requires=(a10constants.VTHUNDER),
                inject={"status": a10constants.READY}))
        return create_vthunder_flow