Пример #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_DNSConfiguration_execute_no_vthunder_warn(self):
     dns_task = task.DNSConfiguration()
     dns_task.axapi_client = self.client_mock
     task_path = "a10_octavia.controller.worker.tasks.glm_tasks"
     log_message = str("No vthunder therefore dns cannot be assigned.")
     expected_log = ["WARNING:{}:{}".format(task_path, log_message)]
     with self.assertLogs(task_path, level='WARN') as cm:
         dns_task.execute(None)
         self.assertEqual(expected_log, cm.output)
Пример #3
0
 def test_DNSConfiguration_execute_no_network_id_warn(self):
     vthunder = copy.deepcopy(VTHUNDER)
     dns_task = task.DNSConfiguration()
     dns_task.axapi_client = self.client_mock
     task_path = "a10_octavia.controller.worker.tasks.glm_tasks"
     log_message = str("No networks were configured therefore "
                       "nameservers cannot be set on the "
                       "vThunder-Amphora {}").format(a10constants.MOCK_VTHUNDER_ID)
     expected_log = ["WARNING:{}:{}".format(task_path, log_message)]
     with self.assertLogs(task_path, level='WARN') as cm:
         dns_task.execute(vthunder)
         self.assertEqual(expected_log, cm.output)
Пример #4
0
    def test_DNSConfiguration_execute_no_dns(self, network_driver_mock):
        self.conf.config(group=a10constants.GLM_LICENSE_CONFIG_SECTION,
                         amp_license_network=DNS_NETWORK.id)
        vthunder = copy.deepcopy(VTHUNDER)
        dns_net = copy.deepcopy(DNS_NETWORK)
        network_driver_mock.get_network.return_value = dns_net
        dns_subnet = copy.deepcopy(DNS_SUBNET).to_dict()
        network_driver_mock.show_subnet_detailed.return_value = {'subnet': dns_subnet}

        dns_task = task.DNSConfiguration()
        dns_task.axapi_client = self.client_mock
        dns_task.execute(vthunder)
        self.client_mock.dns.set.assert_not_called()
Пример #5
0
    def test_DNSConfiguration_execute_with_secondary_fail(self, network_driver_mock):
        self.conf.config(group=a10constants.GLM_LICENSE_CONFIG_SECTION,
                         amp_license_network=DNS_NETWORK.id,
                         secondary_dns=SECONDARY_DNS)
        vthunder = copy.deepcopy(VTHUNDER)
        dns_net = copy.deepcopy(DNS_NETWORK)
        network_driver_mock.get_network.return_value = dns_net
        dns_subnet = copy.deepcopy(DNS_SUBNET).to_dict()
        network_driver_mock.show_subnet_detailed.return_value = {'subnet': dns_subnet}

        dns_task = task.DNSConfiguration()
        dns_task.axapi_client = self.client_mock
        self.assertRaises(a10_ex.PrimaryDNSMissing, dns_task.execute, vthunder)
Пример #6
0
    def test_DNSConfiguration_execute_use_license_net_primary_only(self, network_driver_mock):
        self.conf.config(group=a10constants.GLM_LICENSE_CONFIG_SECTION,
                         amp_license_network=DNS_NETWORK.id, primary_dns=PRIMARY_DNS)
        vthunder = copy.deepcopy(VTHUNDER)
        dns_net = copy.deepcopy(DNS_NETWORK)
        network_driver_mock.get_network.return_value = dns_net
        dns_subnet = copy.deepcopy(DNS_SUBNET).to_dict()
        network_driver_mock.show_subnet_detailed.return_value = {'subnet': dns_subnet}

        dns_task = task.DNSConfiguration()
        dns_task.axapi_client = self.client_mock
        dns_task.execute(vthunder)
        args, kwargs = self.client_mock.dns.set.call_args
        self.assertEqual(args, (PRIMARY_DNS, None))
Пример #7
0
    def test_DNSConfiguration_revert_delete_dns(self, network_driver_mock):
        self.conf.config(group=a10constants.GLM_LICENSE_CONFIG_SECTION,
                         amp_license_network=DNS_NETWORK.id,
                         secondary_dns=SECONDARY_DNS)
        vthunder = copy.deepcopy(VTHUNDER)
        dns_net = copy.deepcopy(DNS_NETWORK)
        network_driver_mock.get_network.return_value = dns_net
        dns_subnet = copy.deepcopy(DNS_SUBNET).to_dict()
        network_driver_mock.show_subnet_detailed.return_value = {'subnet': dns_subnet}

        dns_task = task.DNSConfiguration()
        dns_task.axapi_client = self.client_mock
        dns_task.revert(vthunder)
        args, kwargs = self.client_mock.dns.delete.call_args
        self.assertEqual(args, (None, SECONDARY_DNS))
Пример #8
0
    def test_DNSConfiguration_execute_use_first_amp_boot_net(self, network_driver_mock):
        self.conf.config(group=a10constants.GLM_LICENSE_CONFIG_SECTION,
                         primary_dns=PRIMARY_DNS, secondary_dns=SECONDARY_DNS)
        self.conf.config(group=a10constants.A10_CONTROLLER_WORKER_CONF_SECTION,
                         amp_boot_network_list=[DNS_NETWORK.id, 'random-net'])
        vthunder = copy.deepcopy(VTHUNDER)
        dns_net = copy.deepcopy(DNS_NETWORK)
        network_driver_mock.get_network.return_value = dns_net
        dns_subnet = copy.deepcopy(DNS_SUBNET).to_dict()
        network_driver_mock.show_subnet_detailed.return_value = {'subnet': dns_subnet}

        dns_task = task.DNSConfiguration()
        dns_task.axapi_client = self.client_mock
        dns_task.execute(vthunder)
        args, kwargs = self.client_mock.dns.set.call_args
        self.assertEqual(args, (PRIMARY_DNS, SECONDARY_DNS))
Пример #9
0
    def test_DNSConfiguration_execute_flavor_dns_precedence(self, network_driver_mock):
        flavor = {'dns': {'primary-dns': PRIMARY_DNS, 'secondary-dns': SECONDARY_DNS}}
        self.conf.config(group=a10constants.GLM_LICENSE_CONFIG_SECTION,
                         amp_license_network=DNS_NETWORK.id,
                         primary_dns='1.0.1.0', secondary_dns='0.1.0.1')
        vthunder = copy.deepcopy(VTHUNDER)
        dns_net = copy.deepcopy(DNS_NETWORK)
        dns_subnet = copy.deepcopy(DNS_SUBNET).to_dict()
        dns_subnet['dns_nameservers'] = ['8.8.8.8', '8.8.4.4']
        network_driver_mock.get_network.return_value = dns_net
        network_driver_mock.show_subnet_detailed.return_value = {'subnet': dns_subnet}

        dns_task = task.DNSConfiguration()
        dns_task.axapi_client = self.client_mock
        dns_task.execute(vthunder, flavor)
        args, kwargs = self.client_mock.dns.set.call_args
        self.assertEqual(args, (PRIMARY_DNS, SECONDARY_DNS))
Пример #10
0
    def test_DNSConfiguration_execute_too_many_network_dns_warn(self, network_driver_mock):
        self.conf.config(group=a10constants.GLM_LICENSE_CONFIG_SECTION,
                         amp_license_network=DNS_NETWORK.id)
        vthunder = copy.deepcopy(VTHUNDER)
        dns_net = copy.deepcopy(DNS_NETWORK)
        dns_subnet = copy.deepcopy(DNS_SUBNET).to_dict()
        dns_subnet['dns_nameservers'] = [PRIMARY_DNS, SECONDARY_DNS, '3.3.3.3']
        network_driver_mock.get_network.return_value = dns_net
        network_driver_mock.show_subnet_detailed.return_value = {'subnet': dns_subnet}

        dns_task = task.DNSConfiguration()
        dns_task.axapi_client = self.client_mock

        task_path = "a10_octavia.controller.worker.tasks.glm_tasks"
        log_message = ("More than one DNS nameserver detected on subnet {}. "
                       "Using {} as primary and {} as secondary.".format(
                           DNS_SUBNET.id, PRIMARY_DNS, SECONDARY_DNS))
        expected_log = ["WARNING:{}:{}".format(task_path, log_message)]
        with self.assertLogs(task_path, level='WARN') as cm:
            dns_task.execute(vthunder)
            self.assertEqual(expected_log, cm.output)