예제 #1
0
    def get_glm_license_subflow(self, prefix, role):
        sf_name = prefix + '-' + a10constants.ACTIVATE_GLM_LICENSE_SUBFLOW
        glm_license_subflow = linear_flow.Flow(sf_name)

        if role == constants.ROLE_BACKUP:
            glm_license_subflow.add(
                vthunder_tasks.SetVThunderHostname(
                    name=sf_name + '-' + a10constants.SET_VTHUNDER_HOSTNAME,
                    requires=constants.AMPHORA,
                    rebind={
                        a10constants.VTHUNDER: a10constants.BACKUP_VTHUNDER
                    }))
            glm_license_subflow.add(
                glm_tasks.ConfigureForwardProxyServer(
                    name=sf_name + '-' + a10constants.CONFIGURE_PROXY_SERVER,
                    requires=constants.FLAVOR,
                    rebind={
                        a10constants.VTHUNDER: a10constants.BACKUP_VTHUNDER
                    }))
            glm_license_subflow.add(
                glm_tasks.DNSConfiguration(
                    name=sf_name + '-' +
                    a10constants.CONFIGURE_DNS_NAMESERVERS,
                    requires=constants.FLAVOR,
                    rebind={
                        a10constants.VTHUNDER: a10constants.BACKUP_VTHUNDER
                    },
                ))
            glm_license_subflow.add(
                glm_tasks.ActivateFlexpoolLicense(
                    name=sf_name + '-' +
                    a10constants.ACTIVATE_FLEXPOOL_LICENSE,
                    requires=(constants.AMPHORA, constants.FLAVOR),
                    rebind={
                        a10constants.VTHUNDER: a10constants.BACKUP_VTHUNDER
                    },
                ))
        else:
            glm_license_subflow.add(
                vthunder_tasks.SetVThunderHostname(
                    name=sf_name + '-' + a10constants.SET_VTHUNDER_HOSTNAME,
                    requires=(constants.AMPHORA, a10constants.VTHUNDER)))
            glm_license_subflow.add(
                glm_tasks.ConfigureForwardProxyServer(
                    name=sf_name + '-' + a10constants.CONFIGURE_PROXY_SERVER,
                    requires=(constants.FLAVOR, a10constants.VTHUNDER)))
            glm_license_subflow.add(
                glm_tasks.DNSConfiguration(
                    name=sf_name + '-' +
                    a10constants.CONFIGURE_DNS_NAMESERVERS,
                    requires=(constants.FLAVOR, a10constants.VTHUNDER)))
            glm_license_subflow.add(
                glm_tasks.ActivateFlexpoolLicense(
                    name=sf_name + '-' +
                    a10constants.ACTIVATE_FLEXPOOL_LICENSE,
                    requires=(constants.AMPHORA, a10constants.VTHUNDER,
                              constants.FLAVOR),
                ))
        return glm_license_subflow
예제 #2
0
    def test_ActiveFlexpoolLicense_execute_fail_LicenseOptionNotAllowed_burst(self):
        self.conf.config(group=a10constants.GLM_LICENSE_CONFIG_SECTION,
                         amp_license_network=DNS_NETWORK.id,
                         flexpool_token=a10constants.MOCK_FLEXPOOL_TOKEN)
        vthunder = copy.deepcopy(VTHUNDER)
        amphora = copy.deepcopy(AMPHORA)
        interfaces = {
            'interface': {
                'ethernet-list': []
            }
        }

        flexpool_task = task.ActivateFlexpoolLicense()
        flexpool_task.axapi_client = self.client_mock
        flexpool_task.axapi_client.interface.get_list.return_value = interfaces
        flexpool_task.axapi_client.glm.create.side_effect = acos_errors.LicenseOptionNotAllowed()

        flexpool_task.axapi_client = self.client_mock
        task_path = "a10_octavia.controller.worker.tasks.glm_tasks"
        log_message = ("A specified configuration option is "
                       "incompatible with license type provided. "
                       "This error can occur when the license request has "
                       "failed due to connection issue. Please check your "
                       "configured GLM network and dns settings.")
        expected_log = ["ERROR:{}:{}".format(task_path, log_message)]
        with self.assertLogs(task_path, level='ERROR') as cm:
            try:
                flexpool_task.execute(vthunder, amphora)
            except Exception:
                pass
            self.assertEqual(expected_log, cm.output)
예제 #3
0
    def test_ActivateFlexpoolLicense_revert_deactivate_license(self):
        vthunder = copy.deepcopy(VTHUNDER)
        amphora = copy.deepcopy(AMPHORA)
        flexpool_task = task.ActivateFlexpoolLicense()
        flexpool_task.axapi_client = self.client_mock

        flexpool_task.revert(vthunder, amphora)
        self.client_mock.delete.glm_license.post.assert_called()
예제 #4
0
 def test_ActivateFlexpoolLicense_execute_no_vthunder_warn(self):
     flexpool_task = task.ActivateFlexpoolLicense()
     flexpool_task.axapi_client = self.client_mock
     task_path = "a10_octavia.controller.worker.tasks.glm_tasks"
     log_message = str("No vthunder therefore licensing cannot occur.")
     expected_log = ["WARNING:{}:{}".format(task_path, log_message)]
     with self.assertLogs(task_path, level='WARN') as cm:
         flexpool_task.execute(None, None)
         self.assertEqual(expected_log, cm.output)
예제 #5
0
    def test_ActivateFlexpoolLicense_execute_success(self):
        self.conf.config(group=a10constants.GLM_LICENSE_CONFIG_SECTION,
                         amp_license_network=DNS_NETWORK.id,
                         flexpool_token=a10constants.MOCK_FLEXPOOL_TOKEN)
        vthunder = copy.deepcopy(VTHUNDER)
        amphora = copy.deepcopy(AMPHORA)
        interfaces = {
            'interface': {
                'ethernet-list': []
            }
        }
        expected_call = self._template_glm_call()

        flexpool_task = task.ActivateFlexpoolLicense()
        flexpool_task.axapi_client = self.client_mock
        flexpool_task.axapi_client.interface.get_list.return_value = interfaces

        flexpool_task.execute(vthunder, amphora)
        args, kwargs = self.client_mock.glm.create.call_args
        self.assertEqual(kwargs, expected_call)
예제 #6
0
    def test_ActivateFlexpoolLicense_execute_iface_up(self):
        self.conf.config(group=a10constants.GLM_LICENSE_CONFIG_SECTION,
                         amp_license_network=DNS_NETWORK.id,
                         flexpool_token=a10constants.MOCK_FLEXPOOL_TOKEN)
        vthunder = copy.deepcopy(VTHUNDER)
        amphora = copy.deepcopy(AMPHORA)
        interfaces = {
            'interface': {
                'ethernet-list': [{
                    'ifnum': 2,
                    'action': 'disable'
                }]
            }
        }

        flexpool_task = task.ActivateFlexpoolLicense()
        flexpool_task.axapi_client = self.client_mock
        flexpool_task.axapi_client.interface.get_list.return_value = interfaces

        flexpool_task.execute(vthunder, amphora)
        self.client_mock.system.action.setInterface.assert_called_with(2)