Example #1
0
    def cli_selected_nodes_deploy(self):
        """Create and deploy environment using Fuel CLI and check CN name
           is equal to the public name passed via UI (user-owned cert)

        Scenario:
            1. Create environment using fuel-qa
            2. Create a cluster using Fuel CLI
            3. Add floating ranges for public network
            4. Provision a controller node using Fuel CLI
            5. Provision two compute+cinder nodes using Fuel CLI
            6. Deploy the controller node using Fuel CLI
            7. Deploy the compute+cinder nodes using Fuel CLI
            8. Verify network
            9. Compare floating ranges
            10. Check that all services work by 'https'
            11. Check that all services have domain name
            12. Find 'CN' value at the output:
                CN value is equal to the value specified
                at certificate provided via Fuel UI
            13. Find keypair data at the output:
                Keypair data is equal to the value specified
                at certificate provided via Fuel UI
            14. Run OSTF

        Duration 50m
        """
        self.env.revert_snapshot("ready_with_3_slaves")
        node_ids = [self.fuel_web.get_nailgun_node_by_devops_node(
            self.env.d_env.nodes().slaves[
                slave_id])['id']for slave_id in range(3)]
        release_id = self.fuel_web.get_releases_list_for_os(
            release_name=OPENSTACK_RELEASE)[0]
        admin_ip = self.ssh_manager.admin_ip
        # Create an environment
        if NEUTRON_SEGMENT_TYPE:
            nst = '--nst={0}'.format(NEUTRON_SEGMENT_TYPE)
        else:
            nst = ''
        cmd = ('fuel env create --name={0} --release={1} {2} --json'.format(
            self.__class__.__name__, release_id, nst))
        env_result =\
            self.ssh_manager.execute_on_remote(admin_ip, cmd,
                                               jsonify=True)['stdout_json']
        cluster_id = env_result['id']
        # Update network parameters
        self.update_cli_network_configuration(cluster_id)
        # Change floating ranges
        current_floating_range = self.get_floating_ranges(cluster_id)
        logger.info("Current floating ranges: {0}".format(
            current_floating_range))
        first_floating_address = current_floating_range[0][0]
        logger.info("First floating address: {0}".format(
            first_floating_address))
        last_floating_address = current_floating_range[0][1]
        logger.info("Last floating address: {0}".format(last_floating_address))
        new_floating_range = generate_floating_ranges(first_floating_address,
                                                      last_floating_address,
                                                      10)
        logger.info("New floating range: {0}".format(new_floating_range))
        self.change_floating_ranges(cluster_id, new_floating_range)
        # Update SSL configuration
        self.update_ssl_configuration(cluster_id)

        # Add and provision a controller node
        logger.info("Add to the cluster \
        and start provisioning a controller node [{0}]".format(node_ids[0]))
        cmd = ('fuel --env-id={0} node set --node {1}\
         --role=controller'.format(cluster_id, node_ids[0]))
        self.ssh_manager.execute_on_remote(admin_ip, cmd)
        cmd = ('fuel --env-id={0} node --provision --node={1} --json'.format(
            cluster_id, node_ids[0]))
        task = self.ssh_manager.execute_on_remote(admin_ip,
                                                  cmd,
                                                  jsonify=True)['stdout_json']
        self.assert_cli_task_success(task, timeout=30 * 60)

        # Add and provision 2 compute+cinder
        logger.info("Add to the cluster and start provisioning two "
                    "compute+cinder nodes [{0},{1}]".format(node_ids[1],
                                                            node_ids[2]))
        cmd = ('fuel --env-id={0} node set --node {1},{2} \
        --role=compute,cinder'.format(cluster_id, node_ids[1], node_ids[2]))
        self.ssh_manager.execute_on_remote(admin_ip, cmd)
        cmd = ('fuel --env-id={0} node --provision \
        --node={1},{2} --json'.format(cluster_id, node_ids[1], node_ids[2]))
        task = self.ssh_manager.execute_on_remote(admin_ip,
                                                  cmd,
                                                  jsonify=True)['stdout_json']
        self.assert_cli_task_success(task, timeout=10 * 60)
        # Deploy the controller node
        cmd = ('fuel --env-id={0} node --deploy --node {1} --json'.format(
            cluster_id, node_ids[0]))
        task = self.ssh_manager.execute_on_remote(admin_ip,
                                                  cmd,
                                                  jsonify=True)['stdout_json']
        self.assert_cli_task_success(task, timeout=60 * 60)
        # Deploy the compute nodes
        cmd = ('fuel --env-id={0} node --deploy --node {1},{2} --json'.format(
            cluster_id, node_ids[1], node_ids[2]))
        task = self.ssh_manager.execute_on_remote(admin_ip,
                                                  cmd,
                                                  jsonify=True)['stdout_json']
        self.assert_cli_task_success(task, timeout=30 * 60)
        # Verify networks
        self.fuel_web.verify_network(cluster_id)
        controller_nodes = self.fuel_web.get_nailgun_cluster_nodes_by_roles(
            cluster_id, ['controller'])
        # Get controller ip address
        controller_node = controller_nodes[0]['ip']
        # Get endpoint list
        endpoint_list = self.get_endpoints(controller_node)
        logger.info(endpoint_list)
        # Check protocol and domain names for endpoints
        for endpoint in endpoint_list:
            logger.debug(("Endpoint {0} use protocol {1}\
            and have domain name {2}".format(endpoint['service_name'],
                                             endpoint['protocol'],
                                             endpoint['domain'])))
            assert_equal(endpoint['protocol'], "https",
                         message=("Endpoint {0} don't use https.".format(
                             endpoint['service_name'])))
            assert_equal(endpoint['domain'], SSL_CN, message=(
                "{0} domain name not equal {1}.".format(
                    endpoint['service_name'], SSL_CN)))
        # Check SSL CNs
        current_ssl_cn = self.get_current_ssl_cn(controller_node)
        logger.info(("CN before cluster deploy {0} \
        and after deploy {1}".format(SSL_CN, current_ssl_cn)))
        assert_equal(SSL_CN, current_ssl_cn, message="SSL CNs are not equal")
        # Check SSL certificate keypairs
        with open(PATH_TO_PEM) as pem_file:
            old_ssl_keypair = pem_file.read().strip()
            current_ssl_keypair = self.get_current_ssl_keypair(controller_node)
            logger.info(("SSL keypair before cluster deploy {0} \
                              and after deploy {1}".format(old_ssl_keypair,
                                                           current_ssl_keypair)
                         ))
            assert_equal(old_ssl_keypair, current_ssl_keypair,
                         message="SSL keypairs are not equal")
            # Check floating ranges are equal after cluster deploy
        actual_floating_ranges = self.hiera_floating_ranges(controller_node)
        logger.info("Current floating ranges: {0}".format(
            actual_floating_ranges))
        assert_equal(actual_floating_ranges, new_floating_range,
                     message="Floating ranges are not equal")
        # Run OSTF
        self.fuel_web.run_ostf(cluster_id=cluster_id,
                               test_sets=['ha', 'smoke', 'sanity'])
        self.env.make_snapshot("cli_selected_nodes_deploy", is_make=True)
Example #2
0
    def cli_selected_nodes_deploy(self):
        """Create and deploy environment using Fuel CLI and check CN name
           is equal to the public name passed via UI (user-owned cert)

        Scenario:
            1. Create environment using fuel-qa
            2. Create a cluster using Fuel CLI
            3. Add floating ranges for public network
            4. Get cluster settings
            5. Provision a controller node using Fuel CLI
            6. Provision two compute+cinder nodes using Fuel CLI
            7. Deploy the controller node using Fuel CLI
            8. Deploy the compute+cinder nodes using Fuel CLI
            9. Compare network settings after compute deployment task
            10. Verify network
            11. Check that all services work by 'https'
            12. Check that all services have domain name
            13. Find 'CN' value at the output:
                CN value is equal to the value specified
                at certificate provided via Fuel UI
            14. Find keypair data at the output:
                Keypair data is equal to the value specified
                at certificate provided via Fuel UI
            15. Compare floating ranges
            16. Get deployment-info
            17. Get cluster settings after deployment task
            18. Compare cluster settings after deploy and before deploy
            19. Run OSTF


        Duration 50m
        """
        self.env.revert_snapshot("ready_with_3_slaves")
        node_ids = sorted([node['id'] for node in
                           self.fuel_web.client.list_nodes()])
        release_id = self.fuel_web.get_releases_list_for_os(
            release_name=OPENSTACK_RELEASE)[0]
        admin_ip = self.ssh_manager.admin_ip
        # Create an environment
        self.show_step(1)
        if NEUTRON_SEGMENT_TYPE:
            nst = '--nst={0}'.format(NEUTRON_SEGMENT_TYPE)
        else:
            nst = ''
        self.show_step(2)
        cmd = ('fuel env create --name={0} --release={1} {2} --json'.format(
            self.__class__.__name__, release_id, nst))
        env_result =\
            self.ssh_manager.execute_on_remote(admin_ip, cmd,
                                               jsonify=True)['stdout_json']
        cluster_id = env_result['id']
        self.show_step(3)
        # Update network parameters
        self.update_cli_network_configuration(cluster_id)
        # Change floating ranges
        current_floating_range = self.get_floating_ranges(cluster_id)
        logger.info("Current floating ranges: {0}".format(
            current_floating_range))
        first_floating_address = current_floating_range[0][0]
        logger.info("First floating address: {0}".format(
            first_floating_address))
        last_floating_address = current_floating_range[0][1]
        logger.info("Last floating address: {0}".format(last_floating_address))
        new_floating_range = generate_floating_ranges(first_floating_address,
                                                      last_floating_address,
                                                      10)
        logger.info("New floating range: {0}".format(new_floating_range))
        self.change_floating_ranges(cluster_id, new_floating_range)
        # Update SSL configuration
        self.update_ssl_configuration(cluster_id)

        # Get cluster settings before deploy
        self.show_step(4)
        cluster_settings = self.download_settings(cluster_id)
        self.show_step(5)
        # Add and provision a controller node
        logger.info("Add to the cluster \
        and start provisioning a controller node [{0}]".format(node_ids[0]))
        cmd = ('fuel --env-id={0} node set --node {1}\
         --role=controller'.format(cluster_id, node_ids[0]))
        self.ssh_manager.execute_on_remote(admin_ip, cmd)
        self.update_node_interfaces(node_ids[0])
        cmd = ('fuel --env-id={0} node --provision --node={1} --json'.format(
            cluster_id, node_ids[0]))
        task = self.ssh_manager.execute_on_remote(admin_ip,
                                                  cmd,
                                                  jsonify=True)['stdout_json']
        self.assert_cli_task_success(task, timeout=30 * 60)
        self.show_step(6)
        # Add and provision 2 compute+cinder
        logger.info("Add to the cluster and start provisioning two "
                    "compute+cinder nodes [{0},{1}]".format(node_ids[1],
                                                            node_ids[2]))
        cmd = ('fuel --env-id={0} node set --node {1},{2} \
        --role=compute,cinder'.format(cluster_id, node_ids[1], node_ids[2]))
        self.ssh_manager.execute_on_remote(admin_ip, cmd)
        for node_id in (node_ids[1], node_ids[2]):
            self.update_node_interfaces(node_id)
        cmd = ('fuel --env-id={0} node --provision \
        --node={1},{2} --json'.format(cluster_id, node_ids[1], node_ids[2]))
        task = self.ssh_manager.execute_on_remote(admin_ip,
                                                  cmd,
                                                  jsonify=True)['stdout_json']
        self.assert_cli_task_success(task, timeout=10 * 60)
        self.show_step(7)
        # Deploy the controller node
        cmd = ('fuel --env-id={0} node --deploy --node {1} --json'.format(
            cluster_id, node_ids[0]))
        task = self.ssh_manager.execute_on_remote(admin_ip,
                                                  cmd,
                                                  jsonify=True)['stdout_json']
        self.assert_cli_task_success(task, timeout=60 * 60)

        self.assert_all_tasks_completed(cluster_id=cluster_id)

        self.show_step(8)
        # Deploy the compute nodes
        cmd = ('fuel --env-id={0} node --deploy --node {1},{2} --json'.format(
            cluster_id, node_ids[1], node_ids[2]))
        task = self.ssh_manager.execute_on_remote(admin_ip,
                                                  cmd,
                                                  jsonify=True)['stdout_json']

        self.wait_cli_task_status(task=task, status='running')
        # Fuel 9.1 is async, so we should wait for real task start
        network_settings = self.get_networks(cluster_id)

        self.assert_cli_task_success(task, timeout=30 * 60)

        self.assert_all_tasks_completed(cluster_id=cluster_id)
        # Verify networks
        self.show_step(9)
        network_configuration = self.get_net_config_cli()
        assert_equal(network_settings,
                     network_configuration,
                     message='Network settings are not equal before'
                             ' and after deploy')
        self.show_step(10)
        self.fuel_web.verify_network(cluster_id)
        controller_nodes = self.fuel_web.get_nailgun_cluster_nodes_by_roles(
            cluster_id, ['controller'])
        # Get controller ip address
        controller_node = controller_nodes[0]['ip']
        # Get endpoint list
        endpoint_list = self.get_endpoints(controller_node)
        logger.info(endpoint_list)
        # Check protocol and domain names for endpoints
        self.show_step(11)
        self.show_step(12)
        for endpoint in endpoint_list:
            logger.debug(("Endpoint {0} use protocol {1}\
            and have domain name {2}".format(endpoint['service_name'],
                                             endpoint['protocol'],
                                             endpoint['domain'])))
            assert_equal(endpoint['protocol'], "https",
                         message=("Endpoint {0} don't use https.".format(
                             endpoint['service_name'])))
            assert_equal(endpoint['domain'], SSL_CN, message=(
                "{0} domain name not equal {1}.".format(
                    endpoint['service_name'], SSL_CN)))
        self.show_step(13)
        current_ssl_cn = self.get_current_ssl_cn(controller_node)
        logger.info(("CN before cluster deploy {0} \
        and after deploy {1}".format(SSL_CN, current_ssl_cn)))
        assert_equal(SSL_CN, current_ssl_cn, message="SSL CNs are not equal")
        self.show_step(14)
        with open(PATH_TO_PEM) as pem_file:
            old_ssl_keypair = pem_file.read().strip()
            current_ssl_keypair = self.get_current_ssl_keypair(controller_node)
            logger.info(
                "SSL keypair before cluster deploy:\n"
                "{0}\n"
                "and after deploy:\n"
                "{1}".format(old_ssl_keypair, current_ssl_keypair)
            )
            assert_equal(old_ssl_keypair, current_ssl_keypair,
                         message="SSL keypairs are not equal")
        self.show_step(15)
        actual_floating_ranges = self.hiera_floating_ranges(controller_node)
        logger.info("Current floating ranges: {0}".format(
            actual_floating_ranges))
        assert_equal(actual_floating_ranges, new_floating_range,
                     message="Floating ranges are not equal")
        # Get deployment task id
        task_id = self.get_first_task_id_by_name(cluster_id, 'deployment')
        self.show_step(16)
        # Get deployment info
        self.get_deployment_info_cli(task_id)
        self.show_step(17)
        # Get cluster settings after deploy
        cluster_config = self.get_cluster_config_cli(task_id)
        self.show_step(18)
        # Compare cluster settings
        assert_equal(cluster_settings,
                     cluster_config,
                     message='Cluster settings are not equal before'
                             ' and after deploy')
        self.show_step(19)
        # Run OSTF
        self.fuel_web.run_ostf(cluster_id=cluster_id,
                               test_sets=['ha', 'smoke', 'sanity'])
        self.env.make_snapshot("cli_selected_nodes_deploy", is_make=True)
Example #3
0
    def cli_selected_nodes_deploy(self):
        """Create and deploy environment using Fuel CLI and check CN name
           is equal to the public name passed via UI (user-owned cert)

        Scenario:
            1. Create environment using fuel-qa
            2. Create a cluster using Fuel CLI
            3. Add floating ranges for public network
            4. Get cluster settings
            5. Provision a controller node using Fuel CLI
            6. Provision two compute+cinder nodes using Fuel CLI
            7. Deploy the controller node using Fuel CLI
            8. Deploy the compute+cinder nodes using Fuel CLI
            9. Compare network settings after compute deployment task
            10. Verify network
            11. Check that all services work by 'https'
            12. Check that all services have domain name
            13. Find 'CN' value at the output:
                CN value is equal to the value specified
                at certificate provided via Fuel UI
            14. Find keypair data at the output:
                Keypair data is equal to the value specified
                at certificate provided via Fuel UI
            15. Compare floating ranges
            16. Get deployment-info
            17. Get cluster settings after deployment task
            18. Compare cluster settings after deploy and before deploy
            19. Run OSTF


        Duration 50m
        """
        self.env.revert_snapshot("ready_with_3_slaves")
        node_ids = sorted(
            [node['id'] for node in self.fuel_web.client.list_nodes()])
        release_id = self.fuel_web.get_releases_list_for_os(
            release_name=OPENSTACK_RELEASE)[0]
        admin_ip = self.ssh_manager.admin_ip
        # Create an environment
        self.show_step(1)
        if NEUTRON_SEGMENT_TYPE:
            nst = '--nst={0}'.format(NEUTRON_SEGMENT_TYPE)
        else:
            nst = ''
        self.show_step(2)
        cmd = ('fuel env create --name={0} --release={1} {2} --json'.format(
            self.__class__.__name__, release_id, nst))
        env_result =\
            self.ssh_manager.execute_on_remote(admin_ip, cmd,
                                               jsonify=True)['stdout_json']
        cluster_id = env_result['id']
        self.show_step(3)
        # Update network parameters
        self.update_cli_network_configuration(cluster_id)
        # Change floating ranges
        current_floating_range = self.get_floating_ranges(cluster_id)
        logger.info(
            "Current floating ranges: {0}".format(current_floating_range))
        first_floating_address = current_floating_range[0][0]
        logger.info(
            "First floating address: {0}".format(first_floating_address))
        last_floating_address = current_floating_range[0][1]
        logger.info("Last floating address: {0}".format(last_floating_address))
        new_floating_range = generate_floating_ranges(first_floating_address,
                                                      last_floating_address,
                                                      10)
        logger.info("New floating range: {0}".format(new_floating_range))
        self.change_floating_ranges(cluster_id, new_floating_range)
        # Update SSL configuration
        self.update_ssl_configuration(cluster_id)

        # Get cluster settings before deploy
        self.show_step(4)
        cluster_settings = self.download_settings(cluster_id)
        self.show_step(5)
        # Add and provision a controller node
        logger.info("Add to the cluster \
        and start provisioning a controller node [{0}]".format(node_ids[0]))
        cmd = ('fuel --env-id={0} node set --node {1}\
         --role=controller'.format(cluster_id, node_ids[0]))
        self.ssh_manager.execute_on_remote(admin_ip, cmd)
        self.update_node_interfaces(node_ids[0])
        cmd = ('fuel --env-id={0} node --provision --node={1} --json'.format(
            cluster_id, node_ids[0]))
        task = self.ssh_manager.execute_on_remote(admin_ip, cmd,
                                                  jsonify=True)['stdout_json']
        self.assert_cli_task_success(task, timeout=30 * 60)
        self.show_step(6)
        # Add and provision 2 compute+cinder
        logger.info("Add to the cluster and start provisioning two "
                    "compute+cinder nodes [{0},{1}]".format(
                        node_ids[1], node_ids[2]))
        cmd = ('fuel --env-id={0} node set --node {1},{2} \
        --role=compute,cinder'.format(cluster_id, node_ids[1], node_ids[2]))
        self.ssh_manager.execute_on_remote(admin_ip, cmd)
        for node_id in (node_ids[1], node_ids[2]):
            self.update_node_interfaces(node_id)
        cmd = ('fuel --env-id={0} node --provision \
        --node={1},{2} --json'.format(cluster_id, node_ids[1], node_ids[2]))
        task = self.ssh_manager.execute_on_remote(admin_ip, cmd,
                                                  jsonify=True)['stdout_json']
        self.assert_cli_task_success(task, timeout=10 * 60)
        self.show_step(7)
        # Deploy the controller node
        cmd = ('fuel --env-id={0} node --deploy --node {1} --json'.format(
            cluster_id, node_ids[0]))
        task = self.ssh_manager.execute_on_remote(admin_ip, cmd,
                                                  jsonify=True)['stdout_json']
        self.assert_cli_task_success(task, timeout=60 * 60)

        self.assert_all_tasks_completed(cluster_id=cluster_id)

        self.show_step(8)
        # Deploy the compute nodes
        cmd = ('fuel --env-id={0} node --deploy --node {1},{2} --json'.format(
            cluster_id, node_ids[1], node_ids[2]))
        task = self.ssh_manager.execute_on_remote(admin_ip, cmd,
                                                  jsonify=True)['stdout_json']

        self.wait_cli_task_status(task=task, status='running')
        # Fuel 9.1 is async, so we should wait for real task start
        network_settings = self.get_networks(cluster_id)

        self.assert_cli_task_success(task, timeout=30 * 60)

        self.assert_all_tasks_completed(cluster_id=cluster_id)
        # Verify networks
        self.show_step(9)
        network_configuration = self.get_net_config_cli()
        assert_equal(network_settings,
                     network_configuration,
                     message='Network settings are not equal before'
                     ' and after deploy')
        self.show_step(10)
        self.fuel_web.verify_network(cluster_id)
        controller_nodes = self.fuel_web.get_nailgun_cluster_nodes_by_roles(
            cluster_id, ['controller'])
        # Get controller ip address
        controller_node = controller_nodes[0]['ip']
        # Get endpoint list
        endpoint_list = self.get_endpoints(controller_node)
        logger.info(endpoint_list)
        # Check protocol and domain names for endpoints
        self.show_step(11)
        self.show_step(12)
        for endpoint in endpoint_list:
            logger.debug(("Endpoint {0} use protocol {1}\
            and have domain name {2}".format(endpoint['service_name'],
                                             endpoint['protocol'],
                                             endpoint['domain'])))
            assert_equal(endpoint['protocol'],
                         "https",
                         message=("Endpoint {0} don't use https.".format(
                             endpoint['service_name'])))
            assert_equal(endpoint['domain'],
                         SSL_CN,
                         message=("{0} domain name not equal {1}.".format(
                             endpoint['service_name'], SSL_CN)))
        self.show_step(13)
        current_ssl_cn = self.get_current_ssl_cn(controller_node)
        logger.info(("CN before cluster deploy {0} \
        and after deploy {1}".format(SSL_CN, current_ssl_cn)))
        assert_equal(SSL_CN, current_ssl_cn, message="SSL CNs are not equal")
        self.show_step(14)
        with open(PATH_TO_PEM) as pem_file:
            old_ssl_keypair = pem_file.read().strip()
            current_ssl_keypair = self.get_current_ssl_keypair(controller_node)
            logger.info("SSL keypair before cluster deploy:\n"
                        "{0}\n"
                        "and after deploy:\n"
                        "{1}".format(old_ssl_keypair, current_ssl_keypair))
            assert_equal(old_ssl_keypair,
                         current_ssl_keypair,
                         message="SSL keypairs are not equal")
        self.show_step(15)
        actual_floating_ranges = self.hiera_floating_ranges(controller_node)
        logger.info(
            "Current floating ranges: {0}".format(actual_floating_ranges))
        assert_equal(actual_floating_ranges,
                     new_floating_range,
                     message="Floating ranges are not equal")
        # Get deployment task id
        task_id = self.get_first_task_id_by_name(cluster_id, 'deployment')
        self.show_step(16)
        # Get deployment info
        self.get_deployment_info_cli(task_id)
        self.show_step(17)
        # Get cluster settings after deploy
        cluster_config = self.get_cluster_config_cli(task_id)
        self.show_step(18)
        # Compare cluster settings
        assert_equal(cluster_settings,
                     cluster_config,
                     message='Cluster settings are not equal before'
                     ' and after deploy')
        self.show_step(19)
        # Run OSTF
        self.fuel_web.run_ostf(cluster_id=cluster_id,
                               test_sets=['ha', 'smoke', 'sanity'])
        self.env.make_snapshot("cli_selected_nodes_deploy", is_make=True)
Example #4
0
    def cli_selected_nodes_deploy(self):
        """Create and deploy environment using Fuel CLI and check CN name
           is equal to the public name passed via UI (user-owned cert)

        Scenario:
            1. Create environment using fuel-qa
            2. Create a cluster using Fuel CLI
            3. Add floating ranges for public network
            4. Provision a controller node using Fuel CLI
            5. Provision two compute+cinder nodes using Fuel CLI
            6. Deploy the controller node using Fuel CLI
            7. Deploy the compute+cinder nodes using Fuel CLI
            8. Verify network
            9. Compare floating ranges
            10. Check that all services work by 'https'
            11. Check that all services have domain name
            12. Find 'CN' value at the output:
                CN value is equal to the value specified
                at certificate provided via Fuel UI
            13. Find keypair data at the output:
                Keypair data is equal to the value specified
                at certificate provided via Fuel UI
            14. Run OSTF

        Duration 50m
        """
        self.env.revert_snapshot("ready_with_3_slaves")
        node_ids = [self.fuel_web.get_nailgun_node_by_devops_node(
            self.env.d_env.nodes().slaves[
                slave_id])['id']for slave_id in range(3)]
        release_id = self.fuel_web.get_releases_list_for_os(
            release_name=OPENSTACK_RELEASE)[0]
        admin_ip = self.ssh_manager.admin_ip
        # Create an environment
        if NEUTRON_SEGMENT_TYPE:
            nst = '--nst={0}'.format(NEUTRON_SEGMENT_TYPE)
        else:
            nst = ''
        cmd = ('fuel env create --name={0} --release={1} {2} --json'.format(
            self.__class__.__name__, release_id, nst))
        env_result =\
            self.ssh_manager.execute_on_remote(admin_ip, cmd,
                                               jsonify=True)['stdout_json']
        cluster_id = env_result['id']
        # Update network parameters
        self.update_cli_network_configuration(cluster_id)
        # Change floating ranges
        current_floating_range = self.get_floating_ranges(cluster_id)
        logger.info("Current floating ranges: {0}".format(
            current_floating_range))
        first_floating_address = current_floating_range[0][0]
        logger.info("First floating address: {0}".format(
            first_floating_address))
        last_floating_address = current_floating_range[0][1]
        logger.info("Last floating address: {0}".format(last_floating_address))
        new_floating_range = generate_floating_ranges(first_floating_address,
                                                      last_floating_address,
                                                      10)
        logger.info("New floating range: {0}".format(new_floating_range))
        self.change_floating_ranges(cluster_id, new_floating_range)
        # Update SSL configuration
        self.update_ssl_configuration(cluster_id)

        # Add and provision a controller node
        logger.info("Add to the cluster \
        and start provisioning a controller node [{0}]".format(node_ids[0]))
        cmd = ('fuel --env-id={0} node set --node {1}\
         --role=controller'.format(cluster_id, node_ids[0]))
        self.ssh_manager.execute_on_remote(admin_ip, cmd)
        cmd = ('fuel --env-id={0} node --provision --node={1} --json'.format(
            cluster_id, node_ids[0]))
        task = self.ssh_manager.execute_on_remote(admin_ip,
                                                  cmd,
                                                  jsonify=True)['stdout_json']
        self.assert_cli_task_success(task, timeout=30 * 60)

        # Add and provision 2 compute+cinder
        logger.info("Add to the cluster and start provisioning two "
                    "compute+cinder nodes [{0},{1}]".format(node_ids[1],
                                                            node_ids[2]))
        cmd = ('fuel --env-id={0} node set --node {1},{2} \
        --role=compute,cinder'.format(cluster_id, node_ids[1], node_ids[2]))
        self.ssh_manager.execute_on_remote(admin_ip, cmd)
        cmd = ('fuel --env-id={0} node --provision \
        --node={1},{2} --json'.format(cluster_id, node_ids[1], node_ids[2]))
        task = self.ssh_manager.execute_on_remote(admin_ip,
                                                  cmd,
                                                  jsonify=True)['stdout_json']
        self.assert_cli_task_success(task, timeout=10 * 60)
        # Deploy the controller node
        cmd = ('fuel --env-id={0} node --deploy --node {1} --json'.format(
            cluster_id, node_ids[0]))
        task = self.ssh_manager.execute_on_remote(admin_ip,
                                                  cmd,
                                                  jsonify=True)['stdout_json']
        self.assert_cli_task_success(task, timeout=60 * 60)
        # Deploy the compute nodes
        cmd = ('fuel --env-id={0} node --deploy --node {1},{2} --json'.format(
            cluster_id, node_ids[1], node_ids[2]))
        task = self.ssh_manager.execute_on_remote(admin_ip,
                                                  cmd,
                                                  jsonify=True)['stdout_json']
        self.assert_cli_task_success(task, timeout=30 * 60)
        # Verify networks
        self.fuel_web.verify_network(cluster_id)
        controller_nodes = self.fuel_web.get_nailgun_cluster_nodes_by_roles(
            cluster_id, ['controller'])
        # Get controller ip address
        controller_node = controller_nodes[0]['ip']
        # Get endpoint list
        endpoint_list = self.get_endpoints(controller_node)
        logger.info(endpoint_list)
        # Check protocol and domain names for endpoints
        for endpoint in endpoint_list:
            logger.debug(("Endpoint {0} use protocol {1}\
            and have domain name {2}".format(endpoint['service_name'],
                                             endpoint['protocol'],
                                             endpoint['domain'])))
            assert_equal(endpoint['protocol'], "https",
                         message=("Endpoint {0} don't use https.".format(
                             endpoint['service_name'])))
            assert_equal(endpoint['domain'], SSL_CN, message=(
                "{0} domain name not equal {1}.".format(
                    endpoint['service_name'], SSL_CN)))
        # Check SSL CNs
        current_ssl_cn = self.get_current_ssl_cn(controller_node)
        logger.info(("CN before cluster deploy {0} \
        and after deploy {1}".format(SSL_CN, current_ssl_cn)))
        assert_equal(SSL_CN, current_ssl_cn, message="SSL CNs are not equal")
        # Check SSL certificate keypairs
        with open(PATH_TO_PEM) as pem_file:
            old_ssl_keypair = pem_file.read().strip()
            current_ssl_keypair = self.get_current_ssl_keypair(controller_node)
            logger.info(("SSL keypair before cluster deploy {0} \
                              and after deploy {1}".format(old_ssl_keypair,
                                                           current_ssl_keypair)
                         ))
            assert_equal(old_ssl_keypair, current_ssl_keypair,
                         message="SSL keypairs are not equal")
            # Check floating ranges are equal after cluster deploy
        actual_floating_ranges = self.hiera_floating_ranges(controller_node)
        logger.info("Current floating ranges: {0}".format(
            actual_floating_ranges))
        assert_equal(actual_floating_ranges, new_floating_range,
                     message="Floating ranges are not equal")
        # Run OSTF
        self.fuel_web.run_ostf(cluster_id=cluster_id,
                               test_sets=['ha', 'smoke', 'sanity'])
        self.env.make_snapshot("cli_selected_nodes_deploy", is_make=True)
Example #5
0
    def cli_selected_nodes_deploy(self):
        """Create and deploy environment using Fuel CLI

        Scenario:
            1. Revert snapshot "ready_with_3_slaves"
            2. Create a cluster using Fuel CLI
            3. Add floating ranges for public network
            4. Provision a controller node using Fuel CLI
            5. Provision two compute+cinder nodes using Fuel CLI
            6. Deploy the controller node using Fuel CLI
            7. Deploy the compute+cinder nodes using Fuel CLI
            8. Compare floating ranges
            9. Run OSTF
            10. Make snapshot "cli_selected_nodes_deploy"

        Duration 50m
        """
        self.env.revert_snapshot("ready_with_3_slaves")
        node_ids = [self.fuel_web.get_nailgun_node_by_devops_node(
            self.env.d_env.nodes().slaves[slave_id])['id']
            for slave_id in range(3)]
        release_id = self.fuel_web.get_releases_list_for_os(
            release_name=OPENSTACK_RELEASE)[0]

        with self.env.d_env.get_admin_remote() as remote:

            # Create an environment
            if NEUTRON_SEGMENT_TYPE:
                nst = '--nst={0}'.format(NEUTRON_SEGMENT_TYPE)
            else:
                nst = ''
            cmd = ('fuel env create --name={0} --release={1} '
                   '{2} --json'.format(self.__class__.__name__,
                                       release_id, nst))
            env_result = run_on_remote(remote, cmd, jsonify=True)
            cluster_id = env_result['id']

            # Update network parameters
            self.update_cli_network_configuration(cluster_id)
            # Change floating ranges
            current_floating_range =\
                self.get_floating_ranges(cluster_id)
            logger.info(
                "Current floating ranges: {0}".format(
                    current_floating_range))
            first_floating_address = current_floating_range[0][0]
            logger.info(
                "First floating address: {0}".format(
                    first_floating_address))
            last_floating_address = current_floating_range[0][1]
            logger.info(
                "Last floating address: {0}".format(
                    last_floating_address))
            new_floating_range = generate_floating_ranges(
                first_floating_address,
                last_floating_address, 10)
            logger.info("New floating range: {0}".format(new_floating_range))
            self.change_floating_ranges(cluster_id, new_floating_range)
            # Update SSL configuration
            self.update_ssl_configuration(cluster_id)

            # Add and provision a controller node
            logger.info("Add to the cluster and start provisioning "
                        "a controller node [{0}]".format(node_ids[0]))
            cmd = ('fuel --env-id={0} node set --node {1} --role=controller'
                   .format(cluster_id, node_ids[0]))
            remote.execute(cmd)
            cmd = ('fuel --env-id={0} node --provision --node={1} --json'
                   .format(cluster_id, node_ids[0]))
            task = run_on_remote(remote, cmd, jsonify=True)
            self.assert_cli_task_success(task, timeout=30 * 60)

            # Add and provision 2 compute+cinder
            logger.info("Add to the cluster and start provisioning two "
                        "compute+cinder nodes [{0},{1}]".format(node_ids[1],
                                                                node_ids[2]))
            cmd = ('fuel --env-id={0} node set --node {1},{2} '
                   '--role=compute,cinder'.format(cluster_id,
                                                  node_ids[1], node_ids[2]))
            remote.execute(cmd)
            cmd = ('fuel --env-id={0} node --provision --node={1},{2} --json'
                   .format(cluster_id, node_ids[1], node_ids[2]))
            task = run_on_remote(remote, cmd, jsonify=True)
            self.assert_cli_task_success(task, timeout=10 * 60)

            # Deploy the controller node
            cmd = ('fuel --env-id={0} node --deploy --node {1} --json'
                   .format(cluster_id, node_ids[0]))
            task = run_on_remote(remote, cmd, jsonify=True)
            self.assert_cli_task_success(task, timeout=60 * 60)
            # Deploy the compute nodes
            cmd = ('fuel --env-id={0} node --deploy --node {1},{2} --json'
                   .format(cluster_id, node_ids[1], node_ids[2]))
            task = run_on_remote(remote, cmd, jsonify=True)
            self.assert_cli_task_success(task, timeout=30 * 60)
            # Verify networks
            self.fuel_web.verify_network(cluster_id)
        # Get hiera floating ranges after deploying cluster
        controller_nodes = \
            self.fuel_web.get_nailgun_cluster_nodes_by_roles(
                cluster_id, ['controller'])
        controller_node = controller_nodes[0]['ip']
        actual_floating_ranges = self.hiera_floating_ranges(controller_node)
        logger.info(
            "Current floating ranges: {0}".format(actual_floating_ranges))
        assert_equal(actual_floating_ranges, new_floating_range,
                     message="Floating ranges are not equal")
        # Run OSTF
        self.fuel_web.run_ostf(
            cluster_id=cluster_id,
            test_sets=['ha', 'smoke', 'sanity'])
        self.env.make_snapshot("cli_selected_nodes_deploy", is_make=True)