Пример #1
0
    def deploy_vnf(self):
        """Deploy Clearwater IMS."""
        start_time = time.time()

        self.cloud.create_security_group_rule('default',
                                              port_range_min=22,
                                              port_range_max=22,
                                              protocol='tcp',
                                              direction='ingress')

        self.__logger.info("Upload VNFD")
        descriptor = self.vnf['descriptor']
        self.cfy_client.blueprints.upload(descriptor.get('file_name'),
                                          descriptor.get('name'))

        self.image_alt = self.publish_image_alt()
        self.flavor_alt = self.create_flavor_alt()
        self.vnf['inputs'].update(
            dict(
                image_id=self.image_alt.id,
                flavor_id=self.flavor_alt.id,
            ))

        self.__logger.info("Create VNF Instance")
        self.cfy_client.deployments.create(descriptor.get('name'),
                                           descriptor.get('name'),
                                           self.vnf.get('inputs'))

        wait_for_execution(self.cfy_client,
                           get_execution_id(self.cfy_client,
                                            descriptor.get('name')),
                           self.__logger,
                           timeout=300)

        self.__logger.info("Start the VNF Instance deployment")
        execution = self.cfy_client.executions.start(descriptor.get('name'),
                                                     'install')
        # Show execution log
        execution = wait_for_execution(self.cfy_client,
                                       execution,
                                       self.__logger,
                                       timeout=3600)

        self.__logger.info(execution)
        if execution.status != 'terminated':
            self.details['vnf'].update(status='FAIL',
                                       duration=time.time() - start_time)
            return False

        ellis_ip = self.cfy_client.deployments.outputs.get(
            self.vnf['descriptor'].get('name'))['outputs']['ellis_ip']
        self.clearwater = clearwater.ClearwaterTesting(self.case_name,
                                                       ellis_ip)
        self.clearwater.availability_check_by_creating_numbers()

        self.details['vnf'].update(status='PASS',
                                   duration=time.time() - start_time)
        self.result += 1 / 3 * 100
        return True
Пример #2
0
    def deploy_vnf(self):
        """Deploy Clearwater IMS."""
        start_time = time.time()

        self.image_alt = self.publish_image_alt()
        self.flavor_alt = self.create_flavor_alt()
        # KeyPair + Image + Flavor OK

        descriptor = self.vnf['descriptor']
        parameters = self.vnf['parameters']

        parameters['public_mgmt_net_id'] = self.ext_net.id
        parameters['public_sig_net_id'] = self.ext_net.id
        parameters['flavor'] = self.flavor_alt.name
        parameters['image'] = self.image_alt.name
        parameters['key_name'] = self.keypair.name
        parameters['external_mgmt_dns_ip'] = env.get('NAMESERVER')
        parameters['external_sig_dns_ip'] = env.get('NAMESERVER')

        self.__logger.info("Create Heat Stack")
        self.stack = self.cloud.create_stack(
            name=descriptor.get('name'),
            template_file=descriptor.get('file_name'),
            wait=True,
            **parameters)
        self.__logger.debug("stack: %s", self.stack)

        servers = self.cloud.list_servers(detailed=True)
        self.__logger.debug("servers: %s", servers)
        for server in servers:
            if not self.check_regex_in_console(
                    server.name, regex='Cloud-init .* finished at ', loop=60):
                return False
            if 'ellis' in server.name:
                self.__logger.debug("server: %s", server)
                ellis_ip = server.public_v4

        assert ellis_ip
        self.clearwater = clearwater.ClearwaterTesting(self.case_name,
                                                       ellis_ip)
        # This call can take time and many retry because Heat is
        # an infrastructure orchestrator so when Heat say "stack created"
        # it means that all OpenStack ressources are created but not that
        # Clearwater are up and ready (Cloud-Init script still running)
        self.clearwater.availability_check_by_creating_numbers()

        duration = time.time() - start_time

        self.details['vnf'].update(status='PASS', duration=duration)
        self.result += 1 / 3 * 100

        return True
Пример #3
0
    def setUp(self):
        with mock.patch('functest.opnfv_tests.vnf.ims.cloudify_ims.'
                        'os.makedirs'):
            self.ims_vnf = clearwater.ClearwaterTesting("foo", "0.0.0.0")

        self.mock_post = mock.Mock()
        attrs = {'status_code': 201, 'cookies': ""}
        self.mock_post.configure_mock(**attrs)

        self.mock_post_200 = mock.Mock()
        attrs = {'status_code': 200, 'cookies': ""}
        self.mock_post_200.configure_mock(**attrs)

        self.mock_post_500 = mock.Mock()
        attrs = {'status_code': 500, 'cookies': ""}
        self.mock_post_200.configure_mock(**attrs)