def extended_tests_reset_vcenter(self, openstack_ip):
        """Common verification of dvs_reboot_vcenter* test cases.

        :param openstack_ip: type string, openstack ip
        """
        os_conn = os_actions.OpenStackActions(
            openstack_ip, SERVTEST_USERNAME,
            SERVTEST_PASSWORD,
            SERVTEST_TENANT)

        # Create security group with rules for ssh and ping
        security_group = os_conn.create_sec_group_for_ssh()

        _sec_groups = os_conn.neutron.list_security_groups()['security_groups']
        _serv_tenant_id = os_conn.get_tenant(SERVTEST_TENANT).id
        default_sg = [sg for sg in _sec_groups
                      if sg['tenant_id'] == _serv_tenant_id and
                      sg['name'] == 'default'][0]

        network = os_conn.nova.networks.find(label=self.inter_net_name)

        # Create access point server
        _, access_point_ip = openstack.create_access_point(
            os_conn=os_conn,
            nics=[{'net-id': network.id}],
            security_groups=[security_group.name, default_sg['name']])

        self.show_step(11)
        self.show_step(12)
        instances = openstack.create_instances(
            os_conn=os_conn,
            nics=[{'net-id': network.id}],
            vm_count=1,
            security_groups=[default_sg['name']])
        openstack.verify_instance_state(os_conn)

        # Get private ips of instances
        ips = [os_conn.get_nova_instance_ip(i, net_name=self.inter_net_name)
               for i in instances]
        time.sleep(30)
        self.show_step(13)
        openstack.ping_each_other(ips=ips, access_point_ip=access_point_ip)

        self.show_step(14)
        vcenter_name = [name for name in self.WORKSTATION_NODES
                        if 'vcenter' in name].pop()
        node = vmrun.Vmrun(
            self.host_type,
            self.path_to_vmx_file.format(vcenter_name),
            host_name=self.host_name,
            username=self.WORKSTATION_USERNAME,
            password=self.WORKSTATION_PASSWORD)
        node.reset()

        self.show_step(15)
        wait(lambda: not icmp_ping(self.VCENTER_IP),
             interval=1,
             timeout=10,
             timeout_msg='vCenter is still available.')

        self.show_step(16)
        wait(lambda: icmp_ping(self.VCENTER_IP),
             interval=5,
             timeout=120,
             timeout_msg='vCenter is not available.')

        self.show_step(17)
        openstack.ping_each_other(ips=ips, access_point_ip=access_point_ip)
    def dvs_regression(self):
        """Deploy cluster with plugin and vmware datastore backend.

        Scenario:
            1. Revert to dvs_bvt snapshot.
            2. Create non default network net_1.
            3. Launch instances with created network in nova and vcenter az.
            4. Create Security groups.
            5. Attached created security groups to instances.
            6. Check connection between instances from different az.

        Duration: 1.8 hours
        """
        self.show_step(1)
        self.env.revert_snapshot("dvs_bvt")

        cluster_id = self.fuel_web.get_last_created_cluster()

        os_ip = self.fuel_web.get_public_vip(cluster_id)
        os_conn = os_actions.OpenStackActions(os_ip, SERVTEST_USERNAME,
                                              SERVTEST_PASSWORD,
                                              SERVTEST_TENANT)

        tenant = os_conn.get_tenant(SERVTEST_TENANT)

        # Create non default network with subnet
        self.show_step(2)

        logger.info('Create network {}'.format(self.net_data[0].keys()[0]))
        net_1 = os_conn.create_network(network_name=self.net_data[0].keys()[0],
                                       tenant_id=tenant.id)['network']

        subnet = os_conn.create_subnet(
            subnet_name=net_1['name'],
            network_id=net_1['id'],
            cidr=self.net_data[0][self.net_data[0].keys()[0]],
            ip_version=4)

        # Check that network are created
        assert_true(os_conn.get_network(net_1['name'])['id'] == net_1['id'])

        # Add net_1 to default router
        router = os_conn.get_router(os_conn.get_network(self.ext_net_name))
        os_conn.add_router_interface(router_id=router["id"],
                                     subnet_id=subnet["id"])

        self.show_step(3)

        # Launch 2 vcenter VMs and 2 nova VMs in the tenant network net_01
        openstack.create_instances(os_conn=os_conn,
                                   vm_count=1,
                                   nics=[{
                                       'net-id': net_1['id']
                                   }])

        # Launch 2 vcenter VMs and 2 nova VMs in the default network
        net_1 = os_conn.nova.networks.find(label=self.inter_net_name)
        instances = openstack.create_instances(os_conn=os_conn,
                                               vm_count=1,
                                               nics=[{
                                                   'net-id': net_1.id
                                               }])
        openstack.verify_instance_state(os_conn)

        self.show_step(4)

        # Create security groups SG_1 to allow ICMP traffic.
        # Add Ingress rule for ICMP protocol to SG_1
        # Create security groups SG_2 to allow TCP traffic 22 port.
        # Add Ingress rule for TCP protocol to SG_2
        sec_name = ['SG1', 'SG2']
        sg1 = os_conn.nova.security_groups.create(sec_name[0], "descr")
        sg2 = os_conn.nova.security_groups.create(sec_name[1], "descr")
        rulesets = [
            {
                # ssh
                'ip_protocol': 'tcp',
                'from_port': 22,
                'to_port': 22,
                'cidr': '0.0.0.0/0',
            },
            {
                # ping
                'ip_protocol': 'icmp',
                'from_port': -1,
                'to_port': -1,
                'cidr': '0.0.0.0/0',
            }
        ]
        os_conn.nova.security_group_rules.create(sg1.id, **rulesets[0])
        os_conn.nova.security_group_rules.create(sg2.id, **rulesets[1])

        # Remove default security group and attach SG_1 and SG2 to VMs
        self.show_step(5)

        srv_list = os_conn.get_servers()
        for srv in srv_list:
            srv.remove_security_group(srv.security_groups[0]['name'])
            srv.add_security_group(sg1.id)
            srv.add_security_group(sg2.id)
        fip = openstack.create_and_assign_floating_ips(os_conn, instances)

        # Check ping between VMs
        self.show_step(6)

        ip_pair = dict.fromkeys(fip)
        for key in ip_pair:
            ip_pair[key] = [value for value in fip if key != value]
        openstack.check_connection_vms(ip_pair)
    def dvs_vcenter_bind_port(self):
        """Check abilities to bind port on DVS to VM, disable/enable this port.

        Scenario:
            1. Revert snapshot to dvs_vcenter_systest_setup.
            2. Create private networks net01 with subnet.
            3. Launch instance VM_1 in the net01 with
               image TestVM and flavor m1.micro in nova az.
            4. Launch instance VM_2 in the net01 with
               image TestVM-VMDK and flavor m1.micro in vcenter az.
            5. Disable sub_net port of instances.
            6. Check instances are not available.
            7. Enable sub_net port of all instances.
            8. Verify that instances communicate between each other.
               Send icmp ping between instances.

        Duration: 1,5 hours

        """
        self.show_step(1)
        self.env.revert_snapshot("dvs_vcenter_systest_setup")

        cluster_id = self.fuel_web.get_last_created_cluster()

        os_ip = self.fuel_web.get_public_vip(cluster_id)
        os_conn = os_actions.OpenStackActions(
            os_ip, SERVTEST_USERNAME,
            SERVTEST_PASSWORD,
            SERVTEST_TENANT)

        # Create security group with rules for ssh and ping
        security_group = os_conn.create_sec_group_for_ssh()

        self.show_step(2)
        net = self.networks[0]
        net_1 = os_conn.create_network(network_name=net['name'])['network']

        subnet = os_conn.create_subnet(
            subnet_name=net['subnets'][0]['name'],
            network_id=net_1['id'],
            cidr=net['subnets'][0]['cidr'])

        logger.info("Check network was created.")
        assert_true(os_conn.get_network(net_1['name'])['id'] == net_1['id'])

        logger.info("Add net_1 to default router")
        router = os_conn.get_router(os_conn.get_network(self.ext_net_name))
        os_conn.add_router_interface(router_id=router["id"],
                                     subnet_id=subnet["id"])

        self.show_step(3)
        self.show_step(4)
        instances = openstack.create_instances(
            os_conn=os_conn,
            nics=[{'net-id': net_1['id']}],
            vm_count=1,
            security_groups=[security_group.name])
        openstack.verify_instance_state(os_conn)

        ports = os_conn.neutron.list_ports()['ports']
        fips = openstack.create_and_assign_floating_ips(os_conn, instances)

        inst_ips = [os_conn.get_nova_instance_ip(i, net_name=net_1['name'])
                    for i in instances]
        inst_ports = [p for p in ports
                      if p['fixed_ips'][0]['ip_address'] in inst_ips]

        self.show_step(5)
        _body = {'port': {'admin_state_up': False}}
        for port in inst_ports:
            os_conn.neutron.update_port(port=port['id'], body=_body)

        self.show_step(6)
        try:
            openstack.ping_each_other(fips)
        except Exception as e:
            logger.info(e)
        else:
            fail('Ping is available between instances')

        self.show_step(7)
        _body = {'port': {'admin_state_up': True}}
        for port in inst_ports:
            os_conn.neutron.update_port(port=port['id'], body=_body)

        self.show_step(8)
        openstack.ping_each_other(fips, timeout=90)
    def dvs_destructive_setup_2(self):
        """Verify that vmclusters migrate after reset controller.

        Scenario:
            1. Upload plugins to the master node.
            2. Install plugin.
            3. Configure cluster with 2 vcenter clusters.
            4. Add 3 node with controller role.
            5. Add 2 node with compute role.
            6. Configure vcenter.
            7. Deploy the cluster.
            8. Run smoke OSTF tests
            9. Launch instances. 1 per az. Assign floating ips.
            10. Make snapshot.

        Duration: 1.8 hours
        Snapshot: dvs_destructive_setup_2
        """
        self.show_step(1)
        self.env.revert_snapshot("ready_with_5_slaves")

        plugin.install_dvs_plugin(self.ssh_manager.admin_ip)

        self.show_step(2)
        cluster_id = self.fuel_web.create_cluster(
            name=self.__class__.__name__,
            mode=DEPLOYMENT_MODE,
            settings={
                "net_provider": 'neutron',
                "net_segment_type": NEUTRON_SEGMENT_TYPE
            }
        )
        plugin.enable_plugin(cluster_id, self.fuel_web)

        self.show_step(3)
        self.show_step(4)
        self.fuel_web.update_nodes(cluster_id,
                                   {'slave-01': ['controller'],
                                    'slave-02': ['controller'],
                                    'slave-03': ['controller'],
                                    'slave-04': ['compute'],
                                    'slave-05': ['compute']})
        self.show_step(6)
        self.fuel_web.vcenter_configure(cluster_id, multiclusters=True)

        self.show_step(7)
        self.fuel_web.deploy_cluster_wait(cluster_id)

        self.show_step(8)
        self.fuel_web.run_ostf(cluster_id=cluster_id, test_sets=['smoke'])

        self.show_step(9)
        os_ip = self.fuel_web.get_public_vip(cluster_id)
        os_conn = os_actions.OpenStackActions(
            os_ip, SERVTEST_USERNAME,
            SERVTEST_PASSWORD,
            SERVTEST_TENANT)

        security_group = os_conn.create_sec_group_for_ssh()

        network = os_conn.nova.networks.find(label=self.inter_net_name)
        instances = openstack.create_instances(
            os_conn=os_conn,
            nics=[{'net-id': network.id}],
            vm_count=1,
            security_groups=[security_group.name])
        openstack.verify_instance_state(os_conn)
        openstack.create_and_assign_floating_ips(os_conn, instances)

        self.show_step(10)
        self.env.make_snapshot("dvs_destructive_setup_2", is_make=True)
    def dvs_destructive_setup_2(self):
        """Verify that vmclusters should be migrate after reset controller.

        Scenario:
            1. Upload plugins to the master node
            2. Install plugin.
            3. Create cluster with vcenter.
            4. Add 3 node with controller role.
            5. Add 2 node with compute role.
            6. Deploy the cluster.
            7. Launch instances.

        Duration: 1.8 hours

        """
        self.env.revert_snapshot("ready_with_5_slaves")

        plugin.install_dvs_plugin(
            self.env.d_env.get_admin_remote())

        # Configure cluster with 2 vcenter clusters and vcenter glance
        cluster_id = self.fuel_web.create_cluster(
            name=self.__class__.__name__,
            mode=DEPLOYMENT_MODE,
            settings={
                "net_provider": 'neutron',
                "net_segment_type": NEUTRON_SEGMENT_TYPE
            }
        )
        plugin.enable_plugin(cluster_id, self.fuel_web)

        # Assign role to node
        self.fuel_web.update_nodes(
            cluster_id,
            {'slave-01': ['controller'],
             'slave-02': ['controller'],
             'slave-03': ['controller'],
             'slave-04': ['compute'],
             'slave-05': ['compute']}
        )
        # Configure VMWare vCenter settings
        self.fuel_web.vcenter_configure(cluster_id, multiclusters=True)

        self.fuel_web.deploy_cluster_wait(cluster_id)

        self.fuel_web.run_ostf(
            cluster_id=cluster_id, test_sets=['smoke'])

        os_ip = self.fuel_web.get_public_vip(cluster_id)
        os_conn = os_actions.OpenStackActions(
            os_ip, SERVTEST_USERNAME,
            SERVTEST_PASSWORD,
            SERVTEST_TENANT)

        # create security group with rules for ssh and ping
        security_group = os_conn.create_sec_group_for_ssh()

        network = os_conn.nova.networks.find(label=self.inter_net_name)
        instances = openstack.create_instances(
            os_conn=os_conn, nics=[{'net-id': network.id}], vm_count=1,
            security_groups=[security_group.name]
        )
        openstack.verify_instance_state(os_conn)

        for instance in instances:
            os_conn.assign_floating_ip(instance)

        self.env.make_snapshot("dvs_destructive_setup_2", is_make=True)
    def extended_tests_reset_vcenter(self, openstack_ip):
        """Common verification of dvs_reboot_vcenter* test cases.

        :param openstack_ip: type string, openstack ip
        """
        admin = os_actions.OpenStackActions(
            openstack_ip, SERVTEST_USERNAME,
            SERVTEST_PASSWORD,
            SERVTEST_TENANT)

        # create security group with rules for ssh and ping
        security_group = admin.create_sec_group_for_ssh()

        default_sg = [
            sg
            for sg in admin.neutron.list_security_groups()['security_groups']
            if sg['tenant_id'] == admin.get_tenant(SERVTEST_TENANT).id
            if sg['name'] == 'default'][0]

        network = admin.nova.networks.find(label=self.inter_net_name)

        # create access point server
        access_point, access_point_ip = openstack.create_access_point(
            os_conn=admin, nics=[{'net-id': network.id}],
            security_groups=[security_group.name, default_sg['name']])

        self.show_step(13)
        self.show_step(14)
        instances = openstack.create_instances(
            os_conn=admin, nics=[{'net-id': network.id}],
            vm_count=1,
            security_groups=[default_sg['name']])
        openstack.verify_instance_state(admin)

        # Get private ips of instances
        ips = []
        for instance in instances:
            ips.append(admin.get_nova_instance_ip(
                instance, net_name=self.inter_net_name))
        time.sleep(30)
        self.show_step(15)
        for ip in ips:
            ping_result = openstack.remote_execute_command(
                access_point_ip, ip, "ping -c 5 {}".format(ip))
            assert_true(
                ping_result['exit_code'] == 0,
                "Ping isn't available from {0} to {1}".format(ip, ip)
            )

        self.show_step(16)
        vcenter_name = [
            name for name in self.WORKSTATION_NODES if 'vcenter' in name].pop()
        node = vmrun.Vmrun(
            self.host_type,
            self.path_to_vmx_file.format(vcenter_name),
            host_name=self.host_name,
            username=self.WORKSTATION_USERNAME,
            password=self.WORKSTATION_PASSWORD)
        node.reset()

        self.show_step(17)
        wait(lambda: not icmp_ping(
            self.VCENTER_IP), interval=1, timeout=10,
            timeout_msg='Vcenter is still availabled.')

        self.show_step(18)
        wait(lambda: icmp_ping(
            self.VCENTER_IP), interval=5, timeout=120,
            timeout_msg='Vcenter is not availabled.')

        self.show_step(20)
        for ip in ips:
            ping_result = openstack.remote_execute_command(
                access_point_ip, ip, "ping -c 5 {}".format(ip))
            assert_true(
                ping_result['exit_code'] == 0,
                "Ping isn't available from {0} to {1}".format(ip, ip)
            )
예제 #7
0
    def extended_tests_reset_vcenter(self, openstack_ip):
        """Common verification of dvs_reboot_vcenter* test cases.

        :param openstack_ip: type string, openstack ip
        """
        os_conn = os_actions.OpenStackActions(openstack_ip, SERVTEST_USERNAME,
                                              SERVTEST_PASSWORD,
                                              SERVTEST_TENANT)

        # Create security group with rules for ssh and ping
        security_group = os_conn.create_sec_group_for_ssh()

        _sec_groups = os_conn.neutron.list_security_groups()['security_groups']
        _serv_tenant_id = os_conn.get_tenant(SERVTEST_TENANT).id
        default_sg = [
            sg for sg in _sec_groups
            if sg['tenant_id'] == _serv_tenant_id and sg['name'] == 'default'
        ][0]

        network = os_conn.nova.networks.find(label=self.inter_net_name)

        # Create access point server
        _, access_point_ip = openstack.create_access_point(
            os_conn=os_conn,
            nics=[{
                'net-id': network.id
            }],
            security_groups=[security_group.name, default_sg['name']])

        self.show_step(11)
        self.show_step(12)
        instances = openstack.create_instances(
            os_conn=os_conn,
            nics=[{
                'net-id': network.id
            }],
            vm_count=1,
            security_groups=[default_sg['name']])
        openstack.verify_instance_state(os_conn)

        # Get private ips of instances
        ips = [
            os_conn.get_nova_instance_ip(i, net_name=self.inter_net_name)
            for i in instances
        ]
        time.sleep(30)
        self.show_step(13)
        openstack.ping_each_other(ips=ips, access_point_ip=access_point_ip)

        self.show_step(14)
        vcenter_name = [
            name for name in self.WORKSTATION_NODES if 'vcenter' in name
        ].pop()
        node = vmrun.Vmrun(self.host_type,
                           self.path_to_vmx_file.format(vcenter_name),
                           host_name=self.host_name,
                           username=self.WORKSTATION_USERNAME,
                           password=self.WORKSTATION_PASSWORD)
        node.reset()

        self.show_step(15)
        wait(lambda: not icmp_ping(self.VCENTER_IP),
             interval=1,
             timeout=10,
             timeout_msg='vCenter is still available.')

        self.show_step(16)
        wait(lambda: icmp_ping(self.VCENTER_IP),
             interval=5,
             timeout=120,
             timeout_msg='vCenter is not available.')

        self.show_step(17)
        openstack.ping_each_other(ips=ips, access_point_ip=access_point_ip)
    def dvs_vcenter_bind_port(self):
        """Check abilities to bind port on DVS to VM, disable/enable this port.

        Scenario:
            1. Revert snapshot to dvs_vcenter_destructive_setup
            2. Create private networks net01 with sunet.
            3. Launch instances VM_1 and VM_2 in the net01
               with image TestVM and flavor m1.micro in nova az.
            4. Launch instances VM_3 and VM_4 in the net01
               with image TestVM-VMDK and flavor m1.micro in nova az.
            4. Bind sub_net port of instances.
            5. Check instances are not available.
            6. Enable sub_net port of all instances.
            7. Verify that instances should communicate between each other.
               Send icmp ping between instances.


        Duration: 1,5 hours

        """
        self.env.revert_snapshot("dvs_vcenter_systest_setup")

        cluster_id = self.fuel_web.get_last_created_cluster()

        # Create new network
        os_ip = self.fuel_web.get_public_vip(cluster_id)
        os_conn = os_actions.OpenStackActions(
            os_ip, SERVTEST_USERNAME,
            SERVTEST_PASSWORD,
            SERVTEST_TENANT)

        # create security group with rules for ssh and ping
        security_group = os_conn.create_sec_group_for_ssh()

        logger.info("Create non default network with subnet.")
        logger.info('Create network {}'.format(self.net_data[0].keys()[0]))
        network = os_conn.create_network(
            network_name=self.net_data[0].keys()[0])['network']

        subnet = os_conn.create_subnet(
            subnet_name=network['name'],
            network_id=network['id'],
            cidr=self.net_data[0][self.net_data[0].keys()[0]])

        logger.info("Check that network are created.")
        assert_true(
            os_conn.get_network(network['name'])['id'] == network['id']
        )

        logger.info("Add net_1 to default router")
        router = os_conn.get_router(os_conn.get_network(self.ext_net_name))
        os_conn.add_router_interface(
            router_id=router["id"],
            subnet_id=subnet["id"])

        #  Launch instance VM_1 and VM_2
        instances = openstack.create_instances(
            os_conn=os_conn, nics=[{'net-id': network['id']}], vm_count=1,
            security_groups=[security_group.name]
        )
        openstack.verify_instance_state(os_conn)

        ports = os_conn.neutron.list_ports()['ports']
        floating_ip = openstack.create_and_assign_floating_ips(
            os_conn, instances)
        instance_ports = []
        for instance in instances:
            instance_addr = os_conn.get_nova_instance_ip(
                instance, net_name=network['name'])
            for port in ports:
                port_addr = port['fixed_ips'][0]['ip_address']
                if instance_addr == port_addr:
                    instance_ports.append(port)
        for port in instance_ports:
            os_conn.neutron.update_port(
                port['id'], {'port': {'admin_state_up': False}}
            )

        controller = self.fuel_web.get_nailgun_primary_node(
            self.env.d_env.nodes().slaves[0]
        )
        with self.fuel_web.get_ssh_for_node(controller.name) as ssh_controller:
            # Verify that not connection to instances
            try:
                openstack.check_connection_vms(
                    os_conn, floating_ip, remote=ssh_controller,
                    command='pingv4')
            except Exception as e:
                logger.info(str(e))

            # Enable sub_net ports of instances
            for port in instance_ports:
                os_conn.neutron.update_port(
                    port['id'], {'port': {'admin_state_up': True}}
                )

                instance.reboot()
                wait(
                    lambda:
                    os_conn.get_instance_detail(instance).status == "ACTIVE",
                    timeout=300)

            time.sleep(60)  # need time after reboot to get ip by instance

            # Verify that instances should communicate between each other.
            # Send icmp ping between instances
            openstack.check_connection_vms(
                os_conn, floating_ip, remote=ssh_controller,
                command='pingv4')
예제 #9
0
    def dvs_vcenter_bind_port(self):
        """Check abilities to bind port on DVS to VM, disable/enable this port.

        Scenario:
            1. Revert snapshot to dvs_vcenter_systest_setup.
            2. Create private networks net01 with subnet.
            3. Launch instance VM_1 in the net01 with
               image TestVM and flavor m1.micro in nova az.
            4. Launch instance VM_2 in the net01 with
               image TestVM-VMDK and flavor m1.micro in vcenter az.
            5. Disable sub_net port of instances.
            6. Check instances are not available.
            7. Enable sub_net port of all instances.
            8. Verify that instances communicate between each other.
               Send icmp ping between instances.

        Duration: 1,5 hours

        """
        self.show_step(1)
        self.env.revert_snapshot("dvs_vcenter_systest_setup")

        cluster_id = self.fuel_web.get_last_created_cluster()

        os_ip = self.fuel_web.get_public_vip(cluster_id)
        os_conn = os_actions.OpenStackActions(os_ip, SERVTEST_USERNAME,
                                              SERVTEST_PASSWORD,
                                              SERVTEST_TENANT)

        # Create security group with rules for ssh and ping
        security_group = os_conn.create_sec_group_for_ssh()

        self.show_step(2)
        net = self.networks[0]
        net_1 = os_conn.create_network(network_name=net['name'])['network']

        subnet = os_conn.create_subnet(subnet_name=net['subnets'][0]['name'],
                                       network_id=net_1['id'],
                                       cidr=net['subnets'][0]['cidr'])

        logger.info("Check network was created.")
        assert_true(os_conn.get_network(net_1['name'])['id'] == net_1['id'])

        logger.info("Add net_1 to default router")
        router = os_conn.get_router(os_conn.get_network(self.ext_net_name))
        os_conn.add_router_interface(router_id=router["id"],
                                     subnet_id=subnet["id"])

        self.show_step(3)
        self.show_step(4)
        instances = openstack.create_instances(
            os_conn=os_conn,
            nics=[{
                'net-id': net_1['id']
            }],
            vm_count=1,
            security_groups=[security_group.name])
        openstack.verify_instance_state(os_conn)

        ports = os_conn.neutron.list_ports()['ports']
        fips = openstack.create_and_assign_floating_ips(os_conn, instances)

        inst_ips = [
            os_conn.get_nova_instance_ip(i, net_name=net_1['name'])
            for i in instances
        ]
        inst_ports = [
            p for p in ports if p['fixed_ips'][0]['ip_address'] in inst_ips
        ]

        self.show_step(5)
        _body = {'port': {'admin_state_up': False}}
        for port in inst_ports:
            os_conn.neutron.update_port(port=port['id'], body=_body)

        self.show_step(6)
        try:
            openstack.ping_each_other(fips)
        except Exception as e:
            logger.info(e)
        else:
            fail('Ping is available between instances')

        self.show_step(7)
        _body = {'port': {'admin_state_up': True}}
        for port in inst_ports:
            os_conn.neutron.update_port(port=port['id'], body=_body)

        self.show_step(8)
        openstack.ping_each_other(fips, timeout=90)
예제 #10
0
    def dvs_destructive_setup_2(self):
        """Verify that vmclusters migrate after reset controller.

        Scenario:
            1. Upload plugins to the master node.
            2. Install plugin.
            3. Configure cluster with 2 vcenter clusters.
            4. Add 3 node with controller role.
            5. Add 2 node with compute role.
            6. Configure vcenter.
            7. Deploy the cluster.
            8. Run smoke OSTF tests
            9. Launch instances. 1 per az. Assign floating ips.
            10. Make snapshot.

        Duration: 1.8 hours
        Snapshot: dvs_destructive_setup_2
        """
        self.show_step(1)
        self.env.revert_snapshot("ready_with_5_slaves")

        plugin.install_dvs_plugin(self.ssh_manager.admin_ip)

        self.show_step(2)
        cluster_id = self.fuel_web.create_cluster(name=self.__class__.__name__,
                                                  mode=DEPLOYMENT_MODE,
                                                  settings={
                                                      "net_provider":
                                                      'neutron',
                                                      "net_segment_type":
                                                      NEUTRON_SEGMENT_TYPE
                                                  })
        plugin.enable_plugin(cluster_id, self.fuel_web)

        self.show_step(3)
        self.show_step(4)
        self.fuel_web.update_nodes(
            cluster_id, {
                'slave-01': ['controller'],
                'slave-02': ['controller'],
                'slave-03': ['controller'],
                'slave-04': ['compute'],
                'slave-05': ['compute']
            })
        self.show_step(6)
        self.fuel_web.vcenter_configure(cluster_id, multiclusters=True)

        self.show_step(7)
        self.fuel_web.deploy_cluster_wait(cluster_id)

        self.show_step(8)
        self.fuel_web.run_ostf(cluster_id=cluster_id, test_sets=['smoke'])

        self.show_step(9)
        os_ip = self.fuel_web.get_public_vip(cluster_id)
        os_conn = os_actions.OpenStackActions(os_ip, SERVTEST_USERNAME,
                                              SERVTEST_PASSWORD,
                                              SERVTEST_TENANT)

        security_group = os_conn.create_sec_group_for_ssh()

        network = os_conn.nova.networks.find(label=self.inter_net_name)
        instances = openstack.create_instances(
            os_conn=os_conn,
            nics=[{
                'net-id': network.id
            }],
            vm_count=1,
            security_groups=[security_group.name])
        openstack.verify_instance_state(os_conn)
        openstack.create_and_assign_floating_ips(os_conn, instances)

        self.show_step(10)
        self.env.make_snapshot("dvs_destructive_setup_2", is_make=True)
    def dvs_regression(self):
        """Deploy cluster with plugin and vmware datastore backend.

        Scenario:
            1. Upload plugins to the master node
            2. Install plugin.
            3. Create cluster with vcenter.
            4. Add 3 node with controller role.
            5. Add 2 node with compute + ceph role.
            6. Add 1 node with compute-vmware + cinder vmware role.
            7. Deploy the cluster.
            8. Run OSTF.
            9. Create non default network.
            10. Create Security groups
            11. Launch instances with created network in nova and vcenter az.
            12. Attached created security groups to instances.
            13. Check connection between instances from different az.

        Duration: 1.8 hours
        """
        self.env.revert_snapshot("dvs_bvt")

        cluster_id = self.fuel_web.get_last_created_cluster()

        os_ip = self.fuel_web.get_public_vip(cluster_id)
        os_conn = os_actions.OpenStackActions(
            os_ip, SERVTEST_USERNAME,
            SERVTEST_PASSWORD,
            SERVTEST_TENANT)

        tenant = os_conn.get_tenant(SERVTEST_TENANT)
        # Create non default network with subnet.
        logger.info('Create network {}'.format(self.net_data[0].keys()[0]))
        network = os_conn.create_network(
            network_name=self.net_data[0].keys()[0],
            tenant_id=tenant.id)['network']

        subnet = os_conn.create_subnet(
            subnet_name=network['name'],
            network_id=network['id'],
            cidr=self.net_data[0][self.net_data[0].keys()[0]],
            ip_version=4)

        # Check that network are created.
        assert_true(
            os_conn.get_network(network['name'])['id'] == network['id']
        )
        # Add net_1 to default router
        router = os_conn.get_router(os_conn.get_network(self.ext_net_name))
        os_conn.add_router_interface(
            router_id=router["id"],
            subnet_id=subnet["id"])
        # Launch instance 2 VMs of vcenter and 2 VMs of nova
        # in the tenant network net_01
        openstack.create_instances(
            os_conn=os_conn, vm_count=1,
            nics=[{'net-id': network['id']}]
        )
        # Launch instance 2 VMs of vcenter and 2 VMs of nova
        # in the default network
        network = os_conn.nova.networks.find(label=self.inter_net_name)
        instances = openstack.create_instances(
            os_conn=os_conn, vm_count=1,
            nics=[{'net-id': network.id}])
        openstack.verify_instance_state(os_conn)

        # Create security groups SG_1 to allow ICMP traffic.
        # Add Ingress rule for ICMP protocol to SG_1
        # Create security groups SG_2 to allow TCP traffic 22 port.
        # Add Ingress rule for TCP protocol to SG_2
        sec_name = ['SG1', 'SG2']
        sg1 = os_conn.nova.security_groups.create(
            sec_name[0], "descr")
        sg2 = os_conn.nova.security_groups.create(
            sec_name[1], "descr")
        rulesets = [
            {
                # ssh
                'ip_protocol': 'tcp',
                'from_port': 22,
                'to_port': 22,
                'cidr': '0.0.0.0/0',
            },
            {
                # ping
                'ip_protocol': 'icmp',
                'from_port': -1,
                'to_port': -1,
                'cidr': '0.0.0.0/0',
            }
        ]
        os_conn.nova.security_group_rules.create(
            sg1.id, **rulesets[0]
        )
        os_conn.nova.security_group_rules.create(
            sg2.id, **rulesets[1]
        )
        # Remove default security group and attach SG_1 and SG2 to VMs
        srv_list = os_conn.get_servers()
        for srv in srv_list:
            srv.remove_security_group(srv.security_groups[0]['name'])
            srv.add_security_group(sg1.id)
            srv.add_security_group(sg2.id)
        time.sleep(20)  # need wait to update rules on dvs
        fip = openstack.create_and_assign_floating_ips(os_conn, instances)
        # Check ping between VMs
        controller = self.fuel_web.get_nailgun_primary_node(
            self.env.d_env.nodes().slaves[0]
        )
        with self.fuel_web.get_ssh_for_node(controller.name) as ssh_controller:
            openstack.check_connection_vms(
                os_conn, fip, remote=ssh_controller,
                command='pingv4')
    def extended_tests_reset_vcenter(self, openstack_ip):
        """Common verification of dvs_reboot_vcenter* test cases.

        :param openstack_ip: type string, openstack ip
        """
        admin = os_actions.OpenStackActions(openstack_ip, SERVTEST_USERNAME,
                                            SERVTEST_PASSWORD, SERVTEST_TENANT)

        # create security group with rules for ssh and ping
        security_group = admin.create_sec_group_for_ssh()

        default_sg = [
            sg
            for sg in admin.neutron.list_security_groups()['security_groups']
            if sg['tenant_id'] == admin.get_tenant(SERVTEST_TENANT).id
            if sg['name'] == 'default'
        ][0]

        network = admin.nova.networks.find(label=self.inter_net_name)

        # create access point server
        access_point, access_point_ip = openstack.create_access_point(
            os_conn=admin,
            nics=[{
                'net-id': network.id
            }],
            security_groups=[security_group.name, default_sg['name']])

        self.show_step(13)
        self.show_step(14)
        instances = openstack.create_instances(
            os_conn=admin,
            nics=[{
                'net-id': network.id
            }],
            vm_count=1,
            security_groups=[default_sg['name']])
        openstack.verify_instance_state(admin)

        # Get private ips of instances
        ips = []
        for instance in instances:
            ips.append(
                admin.get_nova_instance_ip(instance,
                                           net_name=self.inter_net_name))
        time.sleep(30)
        self.show_step(15)
        for ip in ips:
            ping_result = openstack.remote_execute_command(
                access_point_ip, ip, "ping -c 5 {}".format(ip))
            assert_true(ping_result['exit_code'] == 0,
                        "Ping isn't available from {0} to {1}".format(ip, ip))

        self.show_step(16)
        vcenter_name = [
            name for name in self.WORKSTATION_NODES if 'vcenter' in name
        ].pop()
        node = vmrun.Vmrun(self.host_type,
                           self.path_to_vmx_file.format(vcenter_name),
                           host_name=self.host_name,
                           username=self.WORKSTATION_USERNAME,
                           password=self.WORKSTATION_PASSWORD)
        node.reset()

        self.show_step(17)
        wait(lambda: not icmp_ping(self.VCENTER_IP),
             interval=1,
             timeout=10,
             timeout_msg='Vcenter is still availabled.')

        self.show_step(18)
        wait(lambda: icmp_ping(self.VCENTER_IP),
             interval=5,
             timeout=120,
             timeout_msg='Vcenter is not availabled.')

        self.show_step(20)
        for ip in ips:
            ping_result = openstack.remote_execute_command(
                access_point_ip, ip, "ping -c 5 {}".format(ip))
            assert_true(ping_result['exit_code'] == 0,
                        "Ping isn't available from {0} to {1}".format(ip, ip))
    def dvs_destructive_setup_2(self):
        """Verify that vmclusters should be migrate after reset controller.

        Scenario:
            1. Upload plugins to the master node
            2. Install plugin.
            3. Create cluster with vcenter.
            4. Add 3 node with controller role.
            5. Add 2 node with compute role.
            6. Deploy the cluster.
            7. Launch instances.

        Duration: 1.8 hours

        """
        self.env.revert_snapshot("ready_with_5_slaves")

        plugin.install_dvs_plugin(self.env.d_env.get_admin_remote())

        # Configure cluster with 2 vcenter clusters and vcenter glance
        cluster_id = self.fuel_web.create_cluster(name=self.__class__.__name__,
                                                  mode=DEPLOYMENT_MODE,
                                                  settings={
                                                      "net_provider":
                                                      'neutron',
                                                      "net_segment_type":
                                                      NEUTRON_SEGMENT_TYPE
                                                  })
        plugin.enable_plugin(cluster_id, self.fuel_web)

        # Assign role to node
        self.fuel_web.update_nodes(
            cluster_id, {
                'slave-01': ['controller'],
                'slave-02': ['controller'],
                'slave-03': ['controller'],
                'slave-04': ['compute'],
                'slave-05': ['compute']
            })
        # Configure VMWare vCenter settings
        self.fuel_web.vcenter_configure(cluster_id, multiclusters=True)

        self.fuel_web.deploy_cluster_wait(cluster_id)

        self.fuel_web.run_ostf(cluster_id=cluster_id, test_sets=['smoke'])

        os_ip = self.fuel_web.get_public_vip(cluster_id)
        os_conn = os_actions.OpenStackActions(os_ip, SERVTEST_USERNAME,
                                              SERVTEST_PASSWORD,
                                              SERVTEST_TENANT)

        # create security group with rules for ssh and ping
        security_group = os_conn.create_sec_group_for_ssh()

        network = os_conn.nova.networks.find(label=self.inter_net_name)
        instances = openstack.create_instances(
            os_conn=os_conn,
            nics=[{
                'net-id': network.id
            }],
            vm_count=1,
            security_groups=[security_group.name])
        openstack.verify_instance_state(os_conn)

        for instance in instances:
            os_conn.assign_floating_ip(instance)

        self.env.make_snapshot("dvs_destructive_setup_2", is_make=True)
    def dvs_vcenter_bind_port(self):
        """Check abilities to bind port on DVS to VM, disable/enable this port.

        Scenario:
            1. Revert snapshot to dvs_vcenter_destructive_setup
            2. Create private networks net01 with sunet.
            3. Launch instances VM_1 and VM_2 in the net01
               with image TestVM and flavor m1.micro in nova az.
            4. Launch instances VM_3 and VM_4 in the net01
               with image TestVM-VMDK and flavor m1.micro in nova az.
            4. Bind sub_net port of instances.
            5. Check instances are not available.
            6. Enable sub_net port of all instances.
            7. Verify that instances should communicate between each other.
               Send icmp ping between instances.


        Duration: 1,5 hours

        """
        self.env.revert_snapshot("dvs_vcenter_systest_setup")

        cluster_id = self.fuel_web.get_last_created_cluster()

        # Create new network
        os_ip = self.fuel_web.get_public_vip(cluster_id)
        os_conn = os_actions.OpenStackActions(os_ip, SERVTEST_USERNAME,
                                              SERVTEST_PASSWORD,
                                              SERVTEST_TENANT)

        # create security group with rules for ssh and ping
        security_group = os_conn.create_sec_group_for_ssh()

        logger.info("Create non default network with subnet.")
        logger.info('Create network {}'.format(self.net_data[0].keys()[0]))
        network = os_conn.create_network(
            network_name=self.net_data[0].keys()[0])['network']

        subnet = os_conn.create_subnet(
            subnet_name=network['name'],
            network_id=network['id'],
            cidr=self.net_data[0][self.net_data[0].keys()[0]])

        logger.info("Check that network are created.")
        assert_true(
            os_conn.get_network(network['name'])['id'] == network['id'])

        logger.info("Add net_1 to default router")
        router = os_conn.get_router(os_conn.get_network(self.ext_net_name))
        os_conn.add_router_interface(router_id=router["id"],
                                     subnet_id=subnet["id"])

        #  Launch instance VM_1 and VM_2
        instances = openstack.create_instances(
            os_conn=os_conn,
            nics=[{
                'net-id': network['id']
            }],
            vm_count=1,
            security_groups=[security_group.name])
        openstack.verify_instance_state(os_conn)

        ports = os_conn.neutron.list_ports()['ports']
        floating_ip = openstack.create_and_assign_floating_ips(
            os_conn, instances)
        instance_ports = []
        for instance in instances:
            instance_addr = os_conn.get_nova_instance_ip(
                instance, net_name=network['name'])
            for port in ports:
                port_addr = port['fixed_ips'][0]['ip_address']
                if instance_addr == port_addr:
                    instance_ports.append(port)
        for port in instance_ports:
            os_conn.neutron.update_port(port['id'],
                                        {'port': {
                                            'admin_state_up': False
                                        }})

        controller = self.fuel_web.get_nailgun_primary_node(
            self.env.d_env.nodes().slaves[0])
        with self.fuel_web.get_ssh_for_node(controller.name) as ssh_controller:
            # Verify that not connection to instances
            try:
                openstack.check_connection_vms(os_conn,
                                               floating_ip,
                                               remote=ssh_controller,
                                               command='pingv4')
            except Exception as e:
                logger.info(str(e))

            # Enable sub_net ports of instances
            for port in instance_ports:
                os_conn.neutron.update_port(port['id'],
                                            {'port': {
                                                'admin_state_up': True
                                            }})

                instance.reboot()
                wait(lambda: os_conn.get_instance_detail(instance).status ==
                     "ACTIVE",
                     timeout=300)

            time.sleep(60)  # need time after reboot to get ip by instance

            # Verify that instances should communicate between each other.
            # Send icmp ping between instances
            openstack.check_connection_vms(os_conn,
                                           floating_ip,
                                           remote=ssh_controller,
                                           command='pingv4')
예제 #15
0
    def dvs_regression(self):
        """Deploy cluster with plugin and vmware datastore backend.

        Scenario:
            1. Upload plugins to the master node
            2. Install plugin.
            3. Create cluster with vcenter.
            4. Add 3 node with controller role.
            5. Add 2 node with compute + ceph role.
            6. Add 1 node with compute-vmware + cinder vmware role.
            7. Deploy the cluster.
            8. Run OSTF.
            9. Create non default network.
            10. Create Security groups
            11. Launch instances with created network in nova and vcenter az.
            12. Attached created security groups to instances.
            13. Check connection between instances from different az.

        Duration: 1.8 hours
        """
        self.env.revert_snapshot("dvs_bvt")

        cluster_id = self.fuel_web.get_last_created_cluster()

        os_ip = self.fuel_web.get_public_vip(cluster_id)
        os_conn = os_actions.OpenStackActions(os_ip, SERVTEST_USERNAME,
                                              SERVTEST_PASSWORD,
                                              SERVTEST_TENANT)

        tenant = os_conn.get_tenant(SERVTEST_TENANT)
        # Create non default network with subnet.
        logger.info('Create network {}'.format(self.net_data[0].keys()[0]))
        network = os_conn.create_network(
            network_name=self.net_data[0].keys()[0],
            tenant_id=tenant.id)['network']

        subnet = os_conn.create_subnet(
            subnet_name=network['name'],
            network_id=network['id'],
            cidr=self.net_data[0][self.net_data[0].keys()[0]],
            ip_version=4)

        # Check that network are created.
        assert_true(
            os_conn.get_network(network['name'])['id'] == network['id'])
        # Add net_1 to default router
        router = os_conn.get_router(os_conn.get_network(self.ext_net_name))
        os_conn.add_router_interface(router_id=router["id"],
                                     subnet_id=subnet["id"])
        # Launch instance 2 VMs of vcenter and 2 VMs of nova
        # in the tenant network net_01
        openstack.create_instances(os_conn=os_conn,
                                   vm_count=1,
                                   nics=[{
                                       'net-id': network['id']
                                   }])
        # Launch instance 2 VMs of vcenter and 2 VMs of nova
        # in the default network
        network = os_conn.nova.networks.find(label=self.inter_net_name)
        instances = openstack.create_instances(os_conn=os_conn,
                                               vm_count=1,
                                               nics=[{
                                                   'net-id': network.id
                                               }])
        openstack.verify_instance_state(os_conn)

        # Create security groups SG_1 to allow ICMP traffic.
        # Add Ingress rule for ICMP protocol to SG_1
        # Create security groups SG_2 to allow TCP traffic 22 port.
        # Add Ingress rule for TCP protocol to SG_2
        sec_name = ['SG1', 'SG2']
        sg1 = os_conn.nova.security_groups.create(sec_name[0], "descr")
        sg2 = os_conn.nova.security_groups.create(sec_name[1], "descr")
        rulesets = [
            {
                # ssh
                'ip_protocol': 'tcp',
                'from_port': 22,
                'to_port': 22,
                'cidr': '0.0.0.0/0',
            },
            {
                # ping
                'ip_protocol': 'icmp',
                'from_port': -1,
                'to_port': -1,
                'cidr': '0.0.0.0/0',
            }
        ]
        os_conn.nova.security_group_rules.create(sg1.id, **rulesets[0])
        os_conn.nova.security_group_rules.create(sg2.id, **rulesets[1])
        # Remove default security group and attach SG_1 and SG2 to VMs
        srv_list = os_conn.get_servers()
        for srv in srv_list:
            srv.remove_security_group(srv.security_groups[0]['name'])
            srv.add_security_group(sg1.id)
            srv.add_security_group(sg2.id)
        time.sleep(20)  # need wait to update rules on dvs
        fip = openstack.create_and_assign_floating_ips(os_conn, instances)
        # Check ping between VMs
        controller = self.fuel_web.get_nailgun_primary_node(
            self.env.d_env.nodes().slaves[0])
        with self.fuel_web.get_ssh_for_node(controller.name) as ssh_controller:
            openstack.check_connection_vms(os_conn,
                                           fip,
                                           remote=ssh_controller,
                                           command='pingv4')