Exemple #1
0
    def test_update_default_quota_for_new_tenant(self):
        result = True

        self.update_default_quota_list(
            subnet=3,
            virtual_network=3,
            floating_ip=10,
            logical_router=10,
            security_group_rule=10,
            virtual_machine_interface=5,
            security_group=5)

        project_name = 'Project'
        isolated_creds = IsolatedCreds(
            project_name,
            self.admin_inputs,
            ini_file=self.ini_file,
            logger=self.logger)
        isolated_creds.setUp()
        project_obj = isolated_creds.create_tenant()
        isolated_creds.create_and_attach_user_to_tenant()
        proj_inputs = isolated_creds.get_inputs()
        proj_connection = isolated_creds.get_conections()
        resource_dict = self.create_quota_test_resources(
            proj_inputs,
            proj_connection,
            vn_count=3,
            router_count=10,
            secgrp_count=4,
            secgep_rule_count=9,
            fip_count=10,
            port_count=5)

        for item in resource_dict.keys():
            if item != 'vn_fix':
                if None in resource_dict[item]:
                    result = False
                    self.logger.error(
                        "Error while creating resource within quota limit for %s please check logs " %
                        (item))

        (vn_name, vn_fix) = resource_dict['vn_fix']._vn_fixtures[1]
        sg_objs = resource_dict['sg_grps']

        response_dict = self.verify_quota_limit(
            proj_inputs,
            proj_connection,
            vn_fix,
            sg_objs[0])
        for item in response_dict.keys():
            if response_dict[item]:
                result = False
                self.logger.error("Quota limit not followed for %s " % (item))

        assert result, 'Quota tests failed'
    def test_quota_update_of_new_project_by_admin(self):
        '''Launch two custom tenants, quota update by admin tenant should be successful
           quota update of one custom tenant by other should fail
        '''
        result = True
        quota_dict = {
            'subnet': 3,
            'router': 5,
            'network': 3,
            'floatingip': 4,
            'port': 5,
            'security_group': 4,
            'security_group_rule': 6
        }

        project_name = get_random_name('project1')
        isolated_creds = IsolatedCreds(project_name,
                                       self.admin_inputs,
                                       ini_file=self.ini_file,
                                       logger=self.logger)
        isolated_creds.setUp()
        project_obj = isolated_creds.create_tenant()
        isolated_creds.create_and_attach_user_to_tenant()
        proj_inputs = isolated_creds.get_inputs()
        proj_connection = isolated_creds.get_conections()

        project_name1 = get_random_name('project2')
        isolated_creds1 = IsolatedCreds(project_name1,
                                        self.admin_inputs,
                                        ini_file=self.ini_file,
                                        logger=self.logger)
        isolated_creds1.setUp()
        project_obj1 = isolated_creds1.create_tenant()
        isolated_creds1.create_and_attach_user_to_tenant()
        proj_inputs1 = isolated_creds1.get_inputs()
        proj_connection1 = isolated_creds1.get_conections()

        self.logger.info(
            "Update quota for tenant %s to: \n %s by admin tenat " %
            (proj_inputs1.project_name, quota_dict))
        quota_rsp = self.admin_connections.quantum_h.update_quota(
            project_obj1.uuid, quota_dict)
        quota_show_dict = self.admin_connections.quantum_h.show_quota(
            project_obj1.uuid)

        for neutron_obj in quota_rsp['quota']:
            if quota_rsp['quota'][neutron_obj] != quota_show_dict['quota'][
                    neutron_obj]:
                self.logger.error(
                    "Quota update unsuccessful for %s for %s tenant " %
                    (neutron_obj, project_name1))
                result = False
        assert result, 'Quota update by admin tenant failed'
        self.logger.info("Quota for tenant %s updated to : \n %s" %
                         (proj_inputs1.project_name, quota_show_dict))
        self.logger.info(
            "Try to update quota for tenant %s to : \n %s by tenant %s" %
            (proj_inputs1.project_name, quota_dict, proj_inputs.project_name))
        result1 = proj_connection.quantum_h.update_quota(
            project_obj1.uuid, quota_dict)
        assert not result1, 'Quota update of %s by %s successful not expected' % (
            project_name1, project_name)
        self.logger.info(
            "Quota for tenant %s still set to : \n %s as expected " %
            (proj_inputs1.project_name, quota_show_dict))
    def test_quota_update_of_new_project_by_admin(self):
        '''Launch two custom tenants, quota update by admin tenant should be successful
           quota update of one custom tenant by other should fail
        '''
        result = True
        quota_dict = {
            'subnet': 3,
            'router': 5,
            'network': 3,
            'floatingip': 4,
            'port': 5,
            'security_group': 4,
            'security_group_rule': 6}

        project_name = get_random_name('project1')
        isolated_creds = IsolatedCreds(
            project_name,
            self.admin_inputs,
            ini_file=self.ini_file,
            logger=self.logger)
        isolated_creds.setUp()
        project_obj = isolated_creds.create_tenant()
        isolated_creds.create_and_attach_user_to_tenant()
        proj_inputs = isolated_creds.get_inputs()
        proj_connection = isolated_creds.get_conections()

        project_name1 = get_random_name('project2')
        isolated_creds1 = IsolatedCreds(
            project_name1,
            self.admin_inputs,
            ini_file=self.ini_file,
            logger=self.logger)
        isolated_creds1.setUp()
        project_obj1 = isolated_creds1.create_tenant()
        isolated_creds1.create_and_attach_user_to_tenant()
        proj_inputs1 = isolated_creds1.get_inputs()
        proj_connection1 = isolated_creds1.get_conections()

        self.logger.info(
            "Update quota for tenant %s to: \n %s by admin tenat " %
            (proj_inputs1.project_name, quota_dict))
        quota_rsp = self.admin_connections.quantum_h.update_quota(
            project_obj1.uuid,
            quota_dict)
        quota_show_dict = self.admin_connections.quantum_h.show_quota(
            project_obj1.uuid)

        for neutron_obj in quota_rsp['quota']:
            if quota_rsp['quota'][neutron_obj] != quota_show_dict[
                    'quota'][neutron_obj]:
                self.logger.error(
                    "Quota update unsuccessful for %s for %s tenant " %
                    (neutron_obj, project_name1))
                result = False
        assert result, 'Quota update by admin tenant failed'
        self.logger.info(
            "Quota for tenant %s updated to : \n %s" %
            (proj_inputs1.project_name, quota_show_dict))
        self.logger.info(
            "Try to update quota for tenant %s to : \n %s by tenant %s" %
            (proj_inputs1.project_name,
             quota_dict,
             proj_inputs.project_name))
        result1 = proj_connection.quantum_h.update_quota(
            project_obj1.uuid,
            quota_dict)
        assert not result1, 'Quota update of %s by %s successful not expected' % (
            project_name1, project_name)
        self.logger.info(
            "Quota for tenant %s still set to : \n %s as expected " %
            (proj_inputs1.project_name, quota_show_dict))