예제 #1
0
    def test_02_project_vmlifecycle_migrate_instance(self):

        # Validate the following
        # 1. Assign account to projects and verify the resource updates
        # 2. Deploy VM with the accounts added to the project
        # 3. Migrate VM of an accounts added to the project to a new host
        # 4. Resource count should list properly.

        self.debug("Checking memory resource count for project: %s" % self.project.name)
        project_list = Project.list(self.apiclient, id=self.project.id, listall=True)
        self.debug(project_list)
        self.assertIsInstance(project_list, list, "List Projects should return a valid response")
        resource_count = project_list[0].memorytotal
        self.debug(resource_count)

        host = findSuitableHostForMigration(self.apiclient, self.vm.id)
        if host is None:
            self.skipTest(ERROR_NO_HOST_FOR_MIGRATION)
        self.debug("Migrating instance: %s to host: %s" % (self.vm.name, host.name))
        try:
            self.vm.migrate(self.apiclient, host.id)
        except Exception as e:
            self.fail("Failed to migrate instance: %s" % e)

        self.debug("Checking memory resource count for project: %s" % self.project.name)
        project_list = Project.list(self.apiclient, id=self.project.id, listall=True)
        self.assertIsInstance(project_list, list, "List Projects should return a valid response")
        resource_count_after_migrate = project_list[0].memorytotal

        self.assertEqual(
            resource_count, resource_count_after_migrate, "Resource count should be same after migrating the instance"
        )
        return
    def test_03_project_counts_delete_instance(self):

        # Validate the following
        # 1. Assign account to projects and verify the resource updates
        # 2. Deploy VM with the accounts added to the project
        # 3. Destroy VM of an accounts added to the project to a new host
        # 4. Resource count should list properly.

        project_list = Project.list(self.apiclient, id=self.project.id, listall=True)
        self.assertIsInstance(project_list, list, "List Projects should return a valid response")
        resource_count = project_list[0].cputotal

        expected_resource_count = int(self.services["service_offering"]["cpunumber"])

        self.assertEqual(
            resource_count, expected_resource_count, "Resource count should match with the expected resource count"
        )

        self.debug("Destroying instance: %s" % self.vm.name)
        try:
            self.vm.delete(self.apiclient)
        except Exception as e:
            self.fail("Failed to delete instance: %s" % e)

        project_list = Project.list(self.apiclient, id=self.project.id, listall=True)
        self.assertIsInstance(project_list, list, "List Projects should return a valid response")
        resource_count_after_delete = project_list[0].cputotal
        self.assertEqual(
            resource_count_after_delete, 0, "Resource count for %s should be 0" % get_resource_type(resource_id=8)
        )  # CPU
        return
    def test_01_project_vmlifecycle_start_stop_instance(self):

        # Validate the following
        # 1. Assign account to projects and verify the resource updates
        # 2. Deploy VM with the accounts added to the project
        # 3. Stop VM of an accounts added to the project to a new host
        # 4. Resource count should list properly
        # 5. Start VM of an accounts added to the project to a new host
        # 6. Resource count should list properly

        self.debug("Checking memory resource count for project: %s" %
                   self.project.name)
        project_list = Project.list(self.apiclient,
                                    id=self.project.id,
                                    listall=True)
        self.debug(project_list)
        self.assertIsInstance(project_list, list,
                              "List Projects should return a valid response")
        resource_count = project_list[0].memorytotal

        self.debug(resource_count)

        self.debug("Stopping instance: %s" % self.vm.name)
        try:
            self.vm.stop(self.apiclient)
        except Exception as e:
            self.fail("Failed to stop instance: %s" % e)

        self.debug("Checking memory resource count for project: %s" %
                   self.project.name)
        project_list = Project.list(self.apiclient,
                                    id=self.project.id,
                                    listall=True)
        self.assertIsInstance(project_list, list,
                              "List Projects should return a valid response")
        resource_count_after_stop = project_list[0].memorytotal

        self.assertEqual(
            resource_count, resource_count_after_stop,
            "Resource count should be same after stopping the instance")

        self.debug("Starting instance: %s" % self.vm.name)
        try:
            self.vm.start(self.apiclient)
        except Exception as e:
            self.fail("Failed to start instance: %s" % e)

        self.debug("Checking memory resource count for project: %s" %
                   self.project.name)
        project_list = Project.list(self.apiclient,
                                    id=self.project.id,
                                    listall=True)
        self.assertIsInstance(project_list, list,
                              "List Projects should return a valid response")
        resource_count_after_start = project_list[0].memorytotal

        self.assertEqual(
            resource_count, resource_count_after_start,
            "Resource count should be same after starting the instance")
        return
예제 #4
0
    def test_03_project_vmlifecycle_delete_instance(self):

        # Validate the following
        # 1. Assign account to projects and verify the resource updates
        # 2. Deploy VM with the accounts added to the project
        # 3. Destroy VM of an accounts added to the project
        # 4. Resource count should list as 0 after destroying the instance

        self.debug("Checking memory resource count for project: %s" % self.project.name)
        project_list = Project.list(self.apiclient, id=self.project.id, listall=True)
        self.debug(project_list)
        self.assertIsInstance(project_list, list, "List Projects should return a valid response")
        resource_count = project_list[0].memorytotal
        self.debug(resource_count)

        self.debug("Destroying instance: %s" % self.vm.name)
        try:
            self.vm.delete(self.apiclient)
        except Exception as e:
            self.fail("Failed to delete instance: %s" % e)

        # Wait for expunge interval to cleanup Memory
        wait_for_cleanup(self.apiclient, ["expunge.delay", "expunge.interval"])

        self.debug("Checking memory resource count for project: %s" % self.project.name)
        project_list = Project.list(self.apiclient, id=self.project.id, listall=True)
        self.assertIsInstance(project_list, list, "List Projects should return a valid response")
        resource_count_after_delete = project_list[0].memorytotal
        self.assertEqual(
            resource_count_after_delete, 0, "Resource count for %s should be 0" % get_resource_type(resource_id=9)
        )  # RAM
        return
예제 #5
0
    def test_03_project_counts_delete_instance(self):

        # Validate the following
        # 1. Assign account to projects and verify the resource updates
        # 2. Deploy VM with the accounts added to the project
        # 3. Destroy VM of an accounts added to the project to a new host
        # 4. Resource count should list properly.

        project_list = Project.list(self.apiclient, id=self.project.id, listall=True)
        self.assertIsInstance(project_list,
                              list,
                              "List Projects should return a valid response"
                              )
        resource_count = project_list[0].cputotal

        expected_resource_count = int(self.service_offering.cpunumber)

        self.assertEqual(resource_count, expected_resource_count,
                         "Resource count should match with the expected resource count")

        self.debug("Destroying instance: %s" % self.vm.name)
        try:
            self.vm.delete(self.apiclient)
        except Exception as e:
            self.fail("Failed to delete instance: %s" % e)

        project_list = Project.list(self.apiclient, id=self.project.id, listall=True)
        self.assertIsInstance(project_list,
                              list,
                              "List Projects should return a valid response"
                              )
        resource_count_after_delete = project_list[0].cputotal
        self.assertEqual(resource_count_after_delete, 0 , "Resource count for %s should be 0" % get_resource_type(resource_id=8))#CPU
        return
    def test_01_project_counts_start_stop_instance(self):

        # Validate the following
        # 1. Assign account to projects and verify the resource updates
        # 2. Deploy VM with the accounts added to the project
        # 3. Stop VM of an accounts added to the project.
        # 4. Resource count should list properly.

        project_list = Project.list(self.apiclient,
                                    id=self.project.id,
                                    listall=True)
        self.debug(project_list)
        self.assertIsInstance(project_list, list,
                              "List Projects should return a valid response")
        resource_count = project_list[0].cputotal

        expected_resource_count = int(
            self.services["service_offering"]["cpunumber"])

        self.assertEqual(
            resource_count, expected_resource_count,
            "Resource count should match with the expected resource count")

        self.debug("Stopping instance: %s" % self.vm.name)
        try:
            self.vm.stop(self.apiclient)
        except Exception as e:
            self.fail("Failed to stop instance: %s" % e)

        project_list = Project.list(self.apiclient,
                                    id=self.project.id,
                                    listall=True)
        self.assertIsInstance(project_list, list,
                              "List Projects should return a valid response")
        resource_count_after_stop = project_list[0].cputotal

        self.assertEqual(
            resource_count, resource_count_after_stop,
            "Resource count should be same after stopping the instance")

        self.debug("Starting instance: %s" % self.vm.name)
        try:
            self.vm.start(self.apiclient)
        except Exception as e:
            self.fail("Failed to start instance: %s" % e)

        project_list = Project.list(self.apiclient,
                                    id=self.project.id,
                                    listall=True)
        self.assertIsInstance(project_list, list,
                              "List Projects should return a valid response")
        resource_count_after_start = project_list[0].cputotal

        self.assertEqual(
            resource_count, resource_count_after_start,
            "Resource count should be same after starting the instance")
        return
    def test_01_project_vmlifecycle_start_stop_instance(self):

        # Validate the following
        # 1. Assign account to projects and verify the resource updates
        # 2. Deploy VM with the accounts added to the project
        # 3. Stop VM of an accounts added to the project to a new host
        # 4. Resource count should list properly
        # 5. Start VM of an accounts added to the project to a new host
        # 6. Resource count should list properly

        self.debug("Checking memory resource count for project: %s" % self.project.name)
        project_list = Project.list(self.apiclient, id=self.project.id, listall=True)
        self.debug(project_list)
        self.assertIsInstance(project_list,
                              list,
                              "List Projects should return a valid response"
                              )
        resource_count = project_list[0].memorytotal

        self.debug(resource_count)

        self.debug("Stopping instance: %s" % self.vm.name)
        try:
            self.vm.stop(self.apiclient)
        except Exception as e:
            self.fail("Failed to stop instance: %s" % e)

        self.debug("Checking memory resource count for project: %s" % self.project.name)
        project_list = Project.list(self.apiclient, id=self.project.id, listall=True)
        self.assertIsInstance(project_list,
                              list,
                              "List Projects should return a valid response"
                              )
        resource_count_after_stop = project_list[0].memorytotal

        self.assertEqual(resource_count, resource_count_after_stop,
                         "Resource count should be same after stopping the instance")

        self.debug("Starting instance: %s" % self.vm.name)
        try:
            self.vm.start(self.apiclient)
        except Exception as e:
            self.fail("Failed to start instance: %s" % e)

        self.debug("Checking memory resource count for project: %s" % self.project.name)
        project_list = Project.list(self.apiclient, id=self.project.id, listall=True)
        self.assertIsInstance(project_list,
                              list,
                              "List Projects should return a valid response"
                              )
        resource_count_after_start = project_list[0].memorytotal

        self.assertEqual(resource_count, resource_count_after_start,
                         "Resource count should be same after starting the instance")
        return
    def test_01_project_counts_start_stop_instance(self):

        # Validate the following
        # 1. Assign account to projects and verify the resource updates
        # 2. Deploy VM with the accounts added to the project
        # 3. Stop VM of an accounts added to the project.
        # 4. Resource count should list properly.

        project_list = Project.list(self.apiclient, id=self.project.id, listall=True)
        self.debug(project_list)
        self.assertIsInstance(project_list,
                              list,
                              "List Projects should return a valid response"
                              )
        resource_count = project_list[0].cputotal

        expected_resource_count = int(self.services["service_offering"]["cpunumber"])

        self.assertEqual(resource_count, expected_resource_count,
                         "Resource count should match with the expected resource count")

        self.debug("Stopping instance: %s" % self.vm.name)
        try:
            self.vm.stop(self.apiclient)
        except Exception as e:
            self.fail("Failed to stop instance: %s" % e)

        project_list = Project.list(self.apiclient, id=self.project.id, listall=True)
        self.assertIsInstance(project_list,
                              list,
                              "List Projects should return a valid response"
                              )
        resource_count_after_stop = project_list[0].cputotal

        self.assertEqual(resource_count, resource_count_after_stop,
                         "Resource count should be same after stopping the instance")

        self.debug("Starting instance: %s" % self.vm.name)
        try:
            self.vm.start(self.apiclient)
        except Exception as e:
            self.fail("Failed to start instance: %s" % e)

        project_list = Project.list(self.apiclient, id=self.project.id, listall=True)
        self.assertIsInstance(project_list,
                              list,
                              "List Projects should return a valid response"
                              )
        resource_count_after_start = project_list[0].cputotal

        self.assertEqual(resource_count, resource_count_after_start,
                         "Resource count should be same after starting the instance")
        return
    def setupProjectAccounts(self):

        self.debug("Creating a domain under: %s" % self.domain.name)
        self.domain = Domain.create(self.apiclient,
                                    services=self.services["domain"],
                                    parentdomainid=self.domain.id)
        self.admin = Account.create(
            self.apiclient,
            self.services["account"],
            admin=True,
            domainid=self.domain.id
        )

        # Create project as a domain admin
        self.project = Project.create(self.apiclient,
                                      self.services["project"],
                                      account=self.admin.name,
                                      domainid=self.admin.domainid)
        # Cleanup created project at end of test
        self.cleanup.append(self.project)
        self.cleanup.append(self.admin)
        self.cleanup.append(self.domain)
        self.debug("Created project with domain admin with name: %s" %
                   self.project.name)

        projects = Project.list(self.apiclient, id=self.project.id,
                                listall=True)

        self.assertEqual(isinstance(projects, list), True,
                         "Check for a valid list projects response")
        project = projects[0]
        self.assertEqual(project.name, self.project.name,
                         "Check project name from list response")
        return
예제 #10
0
def matchResourceCount(apiclient, expectedCount, resourceType,
                              accountid=None, projectid=None):
    """Match the resource count of account/project with the expected
    resource count"""
    try:
        resourceholderlist = None
        if accountid:
            resourceholderlist = Account.list(apiclient, id=accountid)
        elif projectid:
            resourceholderlist = Project.list(apiclient, id=projectid, listall=True)
        validationresult = validateList(resourceholderlist)
        assert validationresult[0] == PASS,\
               "accounts list validation failed"
        if resourceType == RESOURCE_PRIMARY_STORAGE:
            resourceCount = resourceholderlist[0].primarystoragetotal
        elif resourceType == RESOURCE_SECONDARY_STORAGE:
            resourceCount = resourceholderlist[0].secondarystoragetotal
        elif resourceType == RESOURCE_CPU:
            resourceCount = resourceholderlist[0].cputotal
        elif resourceType == RESOURCE_MEMORY:
            resourceCount = resourceholderlist[0].memorytotal
        assert str(resourceCount) == str(expectedCount),\
                "Resource count %s should match with the expected resource count %s" %\
                (resourceCount, expectedCount)
    except Exception as e:
        return [FAIL, e]
    return [PASS, None]
예제 #11
0
def matchResourceCount(apiclient, expectedCount, resourceType, accountid=None, projectid=None):
    """Match the resource count of account/project with the expected
    resource count"""
    try:
        resourceholderlist = None
        if accountid:
            resourceholderlist = Account.list(apiclient, id=accountid)
        elif projectid:
            resourceholderlist = Project.list(apiclient, id=projectid, listall=True)
        validationresult = validateList(resourceholderlist)
        assert validationresult[0] == PASS, "accounts list validation failed"
        if resourceType == RESOURCE_PRIMARY_STORAGE:
            resourceCount = resourceholderlist[0].primarystoragetotal
        elif resourceType == RESOURCE_SECONDARY_STORAGE:
            resourceCount = resourceholderlist[0].secondarystoragetotal
        elif resourceType == RESOURCE_CPU:
            resourceCount = resourceholderlist[0].cputotal
        elif resourceType == RESOURCE_MEMORY:
            resourceCount = resourceholderlist[0].memorytotal
        assert str(resourceCount) == str(
            expectedCount
        ), "Resource count %s should match with the expected resource count %s" % (resourceCount, expectedCount)
    except Exception as e:
        return [FAIL, e]
    return [PASS, None]
예제 #12
0
    def setupProjectAccounts(self):

        self.debug("Creating a domain under: %s" % self.domain.name)
        self.domain = Domain.create(self.apiclient,
                                        services=self.testdata["domain"],
                                        parentdomainid=self.domain.id)
        self.admin = Account.create(
                            self.apiclient,
                            self.testdata["account"],
                            admin=True,
                            domainid=self.domain.id
                            )

        # Create project as a domain admin
        self.project = Project.create(self.apiclient,
                                 self.testdata["project"],
                                 account=self.admin.name,
                                 domainid=self.admin.domainid)
        # Cleanup created project at end of test
        self.cleanup.append(self.project)
        self.cleanup.append(self.admin)
        self.cleanup.append(self.domain)
        self.debug("Created project with domain admin with name: %s" %
                                                        self.project.name)

        projects = Project.list(self.apiclient, id=self.project.id,
                                listall=True)

        self.assertEqual(isinstance(projects, list), True,
                        "Check for a valid list projects response")
        project = projects[0]
        self.assertEqual(project.name, self.project.name,
                        "Check project name from list response")
        return
예제 #13
0
    def setUp(self):
        self.apiclient = self.testClient.getApiClient()
        self.dbclient = self.testClient.getDbConnection()

        self.cleanup = []
        response = self.setupProjectAccounts()
        self.assertEqual(response[0], PASS, response[1])

        try:
            self.vm = VirtualMachine.create(
                self.apiclient,
                self.services["virtual_machine"],
                templateid=self.template.id,
                projectid=self.project.id,
                serviceofferingid=self.service_offering.id)
            projects = Project.list(self.apiclient,
                                    id=self.project.id,
                                    listall=True)
            self.assertEqual(validateList(projects)[0], PASS,\
                    "projects list validation failed")
            self.initialResourceCount = projects[0].primarystoragetotal
        except Exception as e:
            self.tearDown()
            self.skipTest("Exception occured in setup: %s" % e)
        return
    def test_02_project_vmlifecycle_migrate_instance(self):

        # Validate the following
        # 1. Assign account to projects and verify the resource updates
        # 2. Deploy VM with the accounts added to the project
        # 3. Migrate VM of an accounts added to the project to a new host
        # 4. Resource count should list properly.

        if self.hypervisor.lower() in ['lxc']:
            self.skipTest("vm migrate feature is not supported on %s" %
                          self.hypervisor.lower())

        self.debug("Checking memory resource count for project: %s" %
                   self.project.name)
        project_list = Project.list(self.apiclient,
                                    id=self.project.id,
                                    listall=True)
        self.debug(project_list)
        self.assertIsInstance(project_list, list,
                              "List Projects should return a valid response")
        resource_count = project_list[0].memorytotal
        self.debug(resource_count)

        host = findSuitableHostForMigration(self.apiclient, self.vm.id)
        if host is None:
            self.skipTest(ERROR_NO_HOST_FOR_MIGRATION)
        self.debug("Migrating instance: %s to host: %s" %
                   (self.vm.name, host.name))
        try:
            self.vm.migrate(self.apiclient, host.id)
        except Exception as e:
            self.fail("Failed to migrate instance: %s" % e)

        self.debug("Checking memory resource count for project: %s" %
                   self.project.name)
        project_list = Project.list(self.apiclient,
                                    id=self.project.id,
                                    listall=True)
        self.assertIsInstance(project_list, list,
                              "List Projects should return a valid response")
        resource_count_after_migrate = project_list[0].memorytotal

        self.assertEqual(
            resource_count, resource_count_after_migrate,
            "Resource count should be same after migrating the instance")
        return
    def test_02_project_counts_migrate_instance(self):

        # Validate the following
        # 1. Assign account to projects and verify the resource updates
        # 2. Deploy VM with the accounts added to the project
        # 3. Migrate VM of an accounts added to the project to a new host
        # 4. Resource count should list properly.
        self.hypervisor = self.testClient.getHypervisorInfo()

        project_list = Project.list(self.apiclient,
                                    id=self.project.id,
                                    listall=True)
        self.assertIsInstance(project_list, list,
                              "List Projects should return a valid response")
        resource_count = project_list[0].cputotal

        expected_resource_count = int(
            self.services["service_offering"]["cpunumber"])

        self.assertEqual(
            resource_count, expected_resource_count,
            "Resource count should match with the expected resource count")

        host = findSuitableHostForMigration(self.apiclient, self.vm.id)
        if host is None:
            self.skipTest(ERROR_NO_HOST_FOR_MIGRATION)
        self.debug("Migrating instance: %s to host: %s" %
                   (self.vm.name, host.name))
        try:
            self.vm.migrate(self.apiclient, host.id)
        except Exception as e:
            self.fail("Failed to migrate instance: %s" % e)

        project_list = Project.list(self.apiclient,
                                    id=self.project.id,
                                    listall=True)
        self.assertIsInstance(project_list, list,
                              "List Projects should return a valid response")
        resource_count_after_migrate = project_list[0].cputotal

        self.assertEqual(
            resource_count, resource_count_after_migrate,
            "Resource count should be same after migrating the instance")
        return
    def test_02_project_counts_migrate_instance(self):

        # Validate the following
        # 1. Assign account to projects and verify the resource updates
        # 2. Deploy VM with the accounts added to the project
        # 3. Migrate VM of an accounts added to the project to a new host
        # 4. Resource count should list properly.
        self.hypervisor = self.testClient.getHypervisorInfo()
        if self.hypervisor.lower() in ['lxc']:
            self.skipTest("vm migrate feature is not supported on %s" % self.hypervisor.lower())

        project_list = Project.list(self.apiclient, id=self.project.id, listall=True)
        self.assertIsInstance(project_list,
                              list,
                              "List Projects should return a valid response"
                              )
        resource_count = project_list[0].cputotal

        expected_resource_count = int(self.services["service_offering"]["cpunumber"])

        self.assertEqual(resource_count, expected_resource_count,
                         "Resource count should match with the expected resource count")

        host = findSuitableHostForMigration(self.apiclient, self.vm.id)
        if host is None:
            self.skipTest(ERROR_NO_HOST_FOR_MIGRATION)
        self.debug("Migrating instance: %s to host: %s" %
                                                    (self.vm.name, host.name))
        try:
            self.vm.migrate(self.apiclient, host.id)
        except Exception as e:
            self.fail("Failed to migrate instance: %s" % e)

        project_list = Project.list(self.apiclient, id=self.project.id, listall=True)
        self.assertIsInstance(project_list,
                              list,
                              "List Projects should return a valid response"
                              )
        resource_count_after_migrate = project_list[0].cputotal

        self.assertEqual(resource_count, resource_count_after_migrate,
                         "Resource count should be same after migrating the instance")
        return
예제 #17
0
    def test_03_deploy_vm_project_limit_reached(self):
        """Test TTry to deploy VM with admin account where account has not used
        the resources but @ project they are not available

        # Validate the following
        # 1. Try to deploy VM with admin account where account has not used the
        #    resources but @ project they are not available
        # 2. Deploy VM should error out saying  ResourceAllocationException
        #    with "resource limit exceeds"""

        self.virtualMachine = VirtualMachine.create(
            self.api_client,
            self.services["virtual_machine"],
            projectid=self.project.id,
            serviceofferingid=self.service_offering.id)

        try:
            projects = Project.list(self.apiclient,
                                    id=self.project.id,
                                    listall=True)
        except Exception as e:
            self.fail("failed to get projects list: %s" % e)

        self.assertEqual(
            validateList(projects)[0], PASS, "projects list validation failed")
        self.initialResourceCount = int(projects[0].primarystoragetotal)

        projectLimit = self.initialResourceCount + 3

        self.debug("Setting up account and domain hierarchy")
        response = self.updatePrimaryStorageLimits(projectLimit=projectLimit)
        self.assertEqual(response[0], PASS, response[1])

        self.services["volume"]["size"] = self.services["disk_offering"][
            "disksize"] = 2

        try:
            disk_offering = DiskOffering.create(
                self.apiclient, services=self.services["disk_offering"])
            self.cleanup.append(disk_offering)
            Volume.create(self.apiclient,
                          self.services["volume"],
                          zoneid=self.zone.id,
                          projectid=self.project.id,
                          diskofferingid=disk_offering.id)
        except Exception as e:
            self.fail("Exception occurred: %s" % e)

        with self.assertRaises(Exception):
            Volume.create(self.apiclient,
                          self.services["volume"],
                          zoneid=self.zone.id,
                          projectid=self.project.id,
                          diskofferingid=disk_offering.id)
        return
    def test_03_project_vmlifecycle_delete_instance(self):

        # Validate the following
        # 1. Assign account to projects and verify the resource updates
        # 2. Deploy VM with the accounts added to the project
        # 3. Destroy VM of an accounts added to the project
        # 4. Resource count should list as 0 after destroying the instance

        self.debug("Checking memory resource count for project: %s" %
                   self.project.name)
        project_list = Project.list(self.apiclient,
                                    id=self.project.id,
                                    listall=True)
        self.debug(project_list)
        self.assertIsInstance(project_list, list,
                              "List Projects should return a valid response")
        resource_count = project_list[0].memorytotal
        self.debug(resource_count)

        self.debug("Destroying instance: %s" % self.vm.name)
        try:
            self.vm.delete(self.apiclient)
        except Exception as e:
            self.fail("Failed to delete instance: %s" % e)

        # Wait for expunge interval to cleanup Memory
        wait_for_cleanup(self.apiclient, ["expunge.delay", "expunge.interval"])

        self.debug("Checking memory resource count for project: %s" %
                   self.project.name)
        project_list = Project.list(self.apiclient,
                                    id=self.project.id,
                                    listall=True)
        self.assertIsInstance(project_list, list,
                              "List Projects should return a valid response")
        resource_count_after_delete = project_list[0].memorytotal
        self.assertEqual(resource_count_after_delete, 0,
                         "Resource count for %s should be 0" %
                         get_resource_type(resource_id=9))  #RAM
        return
예제 #19
0
    def test_03_deploy_vm_project_limit_reached(self):
        """Test TTry to deploy VM with admin account where account has not used
        the resources but @ project they are not available

        # Validate the following
        # 1. Try to deploy VM with admin account where account has not used the
        #    resources but @ project they are not available
        # 2. Deploy VM should error out saying  ResourceAllocationException
        #    with "resource limit exceeds"""

        self.virtualMachine = VirtualMachine.create(self.api_client, self.services["virtual_machine"],
                            projectid=self.project.id,
                            diskofferingid=self.disk_offering.id,
                            serviceofferingid=self.service_offering.id)

        try:
            projects = Project.list(self.apiclient, id=self.project.id, listall=True)
        except Exception as e:
            self.fail("failed to get projects list: %s" % e)

        self.assertEqual(validateList(projects)[0], PASS,
            "projects list validation failed")
        self.initialResourceCount = int(projects[0].primarystoragetotal)

        projectLimit = self.initialResourceCount + 3

        self.debug("Setting up account and domain hierarchy")
        response = self.updatePrimaryStorageLimits(projectLimit=projectLimit)
        self.assertEqual(response[0], PASS, response[1])

        self.services["volume"]["size"] = self.services["disk_offering"]["disksize"] = 2

        try:
            disk_offering = DiskOffering.create(self.apiclient,
                                    services=self.services["disk_offering"])
            self.cleanup.append(disk_offering)
            Volume.create(self.apiclient,
                                   self.services["volume"],
                                   zoneid=self.zone.id,
                                   projectid=self.project.id,
                                   diskofferingid=disk_offering.id)
        except Exception as e:
            self.fail("Exception occured: %s" % e)

        with self.assertRaises(Exception):
            Volume.create(self.apiclient,
                                   self.services["volume"],
                                   zoneid=self.zone.id,
                                   projectid=self.project.id,
                                   diskofferingid=disk_offering.id)
        return
예제 #20
0
    def test_03_deploy_vm_project_limit_reached(self):
        """Test TTry to deploy VM with admin account where account has not used
        the resources but @ project they are not available

        # Validate the following
        # 1. Try to register template with admin account where account has not used the
        #    resources but @ project they are not available
        # 2. Template registration should error out saying  ResourceAllocationException
        #    with "resource limit exceeds"""

        response = self.setupAccounts()
        self.assertEqual(response[0], PASS, response[1])

        response = self.registerTemplate(inProject=True)
        self.assertEqual(response[0], PASS, response[1])

        try:
            projects = Project.list(self.userapiclient,
                                    id=self.project.id,
                                    listall=True)
        except Exception as e:
            self.fail("failed to get projects list: %s" % e)

        self.assertEqual(
            validateList(projects)[0], PASS, "projects list validation failed")
        self.assertEqual(
            self.templateSize, projects[0].secondarystoragetotal,
            "Resource count %s\
                 not matching with the expcted count: %s" %
            (projects[0].secondarystoragetotal, self.templateSize))

        projectLimit = self.templateSize

        response = self.updateSecondaryStorageLimits(projectLimit=projectLimit)
        self.assertEqual(response[0], PASS, response[1])

        with self.assertRaises(Exception):
            template = Template.register(self.userapiclient,
                                         self.services["template_2"],
                                         zoneid=self.zone.id,
                                         projectid=self.project.id)
            template.delete(self.userapiclient)
        return
    def setUp(self):
        self.apiclient = self.testClient.getApiClient()
        self.dbclient = self.testClient.getDbConnection()

        self.cleanup = []
        response = self.setupProjectAccounts()
        self.assertEqual(response[0], PASS, response[1])

        try:
            self.vm = VirtualMachine.create(
                        self.apiclient,self.services["virtual_machine"],
                        templateid=self.template.id,projectid=self.project.id,
                        serviceofferingid=self.service_offering.id)
            projects = Project.list(self.apiclient,id=self.project.id, listall=True)
            self.assertEqual(validateList(projects)[0], PASS,\
                    "projects list validation failed")
            self.initialResourceCount = projects[0].primarystoragetotal
        except Exception as e:
            self.tearDown()
            self.skipTest("Exception occured in setup: %s" % e)
        return
예제 #22
0
    def test_03_deploy_vm_project_limit_reached(self):
        """Test TTry to deploy VM with admin account where account has not used
        the resources but @ project they are not available

        # Validate the following
        # 1. Try to register template with admin account where account has not used the
        #    resources but @ project they are not available
        # 2. Template registration should error out saying  ResourceAllocationException
        #    with "resource limit exceeds"""

        response = self.setupAccounts()
        self.assertEqual(response[0], PASS, response[1])

        response = self.registerTemplate(inProject=True)
        self.assertEqual(response[0], PASS, response[1])

        try:
            projects = Project.list(self.userapiclient, id=self.project.id, listall=True)
        except Exception as e:
            self.fail("failed to get projects list: %s" % e)

        self.assertEqual(validateList(projects)[0], PASS,
            "projects list validation failed")
        self.assertEqual(self.templateSize, projects[0].secondarystoragetotal, "Resource count %s\
                 not matching with the expcted count: %s" %
                 (projects[0].secondarystoragetotal, self.templateSize))

        projectLimit = self.templateSize

        response = self.updateSecondaryStorageLimits(projectLimit=projectLimit)
        self.assertEqual(response[0], PASS, response[1])

        with self.assertRaises(Exception):
            template = Template.register(self.userapiclient,
                                     self.services["template_2"],
                                     zoneid=self.zone.id,
                                     projectid=self.project.id)
            template.delete(self.userapiclient)
        return
예제 #23
0
    def test_02_project_disk_offerings(self):
        """ Test project disk offerings
        """

        # Validate the following
        # 1. Create a project.
        # 2. List service offerings for the project. All disk offerings
        #    available in the domain can be used for project resource creation

        # Create project as a domain admin
        project = Project.create(
            self.apiclient, self.services["project"], account=self.account.name, domainid=self.account.domainid
        )
        # Cleanup created project at end of test
        self.cleanup.append(project)
        self.debug("Created project with domain admin with ID: %s" % project.id)

        list_projects_reponse = Project.list(self.apiclient, id=project.id, listall=True)

        self.assertEqual(isinstance(list_projects_reponse, list), True, "Check for a valid list projects response")
        list_project = list_projects_reponse[0]

        self.assertNotEqual(len(list_projects_reponse), 0, "Check list project response returns a valid project")

        self.assertEqual(project.name, list_project.name, "Check project name from list response")
        self.debug("Create a data volume for project: %s" % project.id)
        # Create a volume for project
        volume = Volume.create(
            self.apiclient,
            self.services["volume"],
            zoneid=self.zone.id,
            diskofferingid=self.disk_offering.id,
            projectid=project.id,
        )
        self.cleanup.append(volume)
        # Verify Volume state
        self.assertEqual(volume.state in ["Allocated", "Ready"], True, "Check Volume state is Ready or not")
        return
예제 #24
0
    def test_01_create_list_domain_account_project(self):
        """ Verify list domain, account and project return expected response
        """
        # Validate the following
        # 1. Create domain
        # 2. list domain, 'cpulimit' should be included in response
        # 3. list domain with details=min, 'cpulimit' should not be included in response.

        # 4. create account in the domain
        # 5. list account, 'cpulimit' should be included in response
        # 6. list account with details=min, 'cpulimit' should not be included in response.

        # 7. create project in the domain
        # 8. list project, 'cpulimit' should be included in response
        # 9. list project with details=min, 'cpulimit' should not be included in response.

        # Create new domain
        self.user_domain = Domain.create(self.apiclient,
                                         self.services["domain"],
                                         parentdomainid=self.domain.id)

        list_domain_response = Domain.list(self.apiclient,
                                           id=self.user_domain.id)

        self.assertEqual(isinstance(list_domain_response, list), True,
                         "Check list response returns a valid list")

        self.assertIsNotNone(list_domain_response[0].cpulimit,
                             "'cpulimit' should be included in response")

        list_domain_response = Domain.list(self.apiclient,
                                           details="min",
                                           id=self.user_domain.id)

        self.assertEqual(isinstance(list_domain_response, list), True,
                         "Check list response returns a valid list")

        self.assertIsNone(list_domain_response[0].cpulimit,
                          "'cpulimit' should not be included in response")

        # Create account
        self.account = Account.create(self.apiclient,
                                      self.services["account"],
                                      admin=True,
                                      domainid=self.user_domain.id)

        list_account_response = Account.list(self.apiclient,
                                             id=self.account.id)

        self.assertEqual(isinstance(list_account_response, list), True,
                         "Check list response returns a valid list")

        self.assertIsNotNone(list_account_response[0].cpulimit,
                             "'cpulimit' should be included in response")

        list_account_response = Account.list(self.apiclient,
                                             details="min",
                                             id=self.account.id)

        self.assertEqual(isinstance(list_account_response, list), True,
                         "Check list response returns a valid list")

        self.assertIsNone(list_account_response[0].cpulimit,
                          "'cpulimit' should not be included in response")

        # Create project
        self.project = Project.create(self.apiclient,
                                      self.services["project"],
                                      account=self.account.name,
                                      domainid=self.account.domainid)

        list_project_response = Project.list(self.apiclient,
                                             listall="true",
                                             id=self.project.id)

        self.assertEqual(isinstance(list_project_response, list), True,
                         "Check list response returns a valid list")

        self.assertIsNotNone(list_project_response[0].cpulimit,
                             "'cpulimit' should be included in response")

        list_project_response = Project.list(self.apiclient,
                                             details="min",
                                             listall="true",
                                             id=self.project.id)

        self.assertEqual(isinstance(list_project_response, list), True,
                         "Check list response returns a valid list")

        self.assertIsNone(list_project_response[0].cpulimit,
                          "'cpulimit' should not be included in response")

        self.cleanup.append(self.project)
        self.cleanup.append(self.account)
        self.cleanup.append(self.user_domain)
예제 #25
0
    def test_02_project_limits_normal_user(self):
        """ Test project limits for normal user
        """
        # Validate the following
        # 1. Create a Project
        # 2. Reduce the projects limits as a domain admin. Verify resource
        #    count is updated
        # 3. Reduce the projects limits as a project user owner who is not a
        #    domain admin. Resource count should fail

        # Create project as a domain admin
        project = Project.create(
                                 self.apiclient,
                                 self.services["project"],
                                 account=self.admin.name,
                                 domainid=self.admin.domainid
                                 )
        # Cleanup created project at end of test
        self.cleanup.append(project)
        self.debug("Created project with domain admin with ID: %s" %
                                                                project.id)

        list_projects_reponse = Project.list(
                                             self.apiclient,
                                             id=project.id,
                                             listall=True
                                             )

        self.assertEqual(
                            isinstance(list_projects_reponse, list),
                            True,
                            "Check for a valid list projects response"
                            )
        list_project = list_projects_reponse[0]

        self.assertNotEqual(
                    len(list_projects_reponse),
                    0,
                    "Check list project response returns a valid project"
                    )

        self.assertEqual(
                            project.name,
                            list_project.name,
                            "Check project name from list response"
                            )
        # Get the resource limits for ROOT domain
        resource_limits = list_resource_limits(self.apiclient)

        self.assertEqual(
                         isinstance(resource_limits, list),
                         True,
                         "List resource API should return a valid list"
                         )
        self.assertNotEqual(
                         len(resource_limits),
                         0,
                         "List resource API response should not be empty"
                         )

        # Reduce resource limits for project
        # Resource: 0 - Instance. Number of instances a user can create.
        # Resource: 1 - IP. Number of public IP addresses a user can own.
        # Resource: 2 - Volume. Number of disk volumes a user can create.
        # Resource: 3 - Snapshot. Number of snapshots a user can create.
        # Resource: 4 - Template. Number of templates that a user can
        #               register/create
        for resource in resource_limits:
            update_resource_limit(
                                    self.apiclient,
                                    resource.resourcetype,
                                    max=1,
                                    projectid=project.id
                                    )
            self.debug(
            "Updating resource (ID: %s) limit for project: %s" % (
                                                                  resource,
                                                                  project.id
                                                                  ))
        resource_limits = list_resource_limits(
                                                self.apiclient,
                                                projectid=project.id
                                                )
        self.assertEqual(
                         isinstance(resource_limits, list),
                         True,
                         "List resource API should return a valid list"
                         )
        self.assertNotEqual(
                         len(resource_limits),
                         0,
                         "List resource API response should not be empty"
                         )
        for resource in resource_limits:
            self.assertEqual(
                         resource.max,
                         1,
                         "Resource limit should be updated to 1"
                         )

        self.debug("Adding %s user to project: %s" % (
                                                self.user.name,
                                                project.name
                                                ))

        # Add user to the project
        project.addAccount(
                           self.apiclient,
                           self.user.name,
                           )

        # Get the resource limits for domain
        resource_limits = list_resource_limits(
                                                self.apiclient,
                                                domainid=self.domain.id
                                                )
        self.assertEqual(
                         isinstance(resource_limits, list),
                         True,
                         "List resource API should return a valid list"
                         )
        self.assertNotEqual(
                         len(resource_limits),
                         0,
                         "List resource API response should not be empty"
                         )

        for resource in resource_limits:
            #with self.assertRaises(Exception):
            self.debug(
                    "Attempting to update resource limit by user: %s" % (
                                                        self.user.name
                                                        ))
            # Update project resource limits to 3
            update_resource_limit(
                                    self.apiclient,
                                    resource.resourcetype,
                                    account=self.user.name,
                                    domainid=self.user.domainid,
                                    max=3,
                                    projectid=project.id
                                )
        return
예제 #26
0
    def test_01_project_limits(self):
        """ Test project limits for domain admin
        """
        # Validate the following
        # 1. Create a Project. Verify once projects are created, they inherit
        #    a default set of resource limits as configured by the Cloud Stack
        #    ROOT admin.
        # 2. Reduce Project resources limits. Verify limits can be reduced by
        #    the Project Owner of each project and project limit applies to
        #    number of virtual instances, disk volumes, snapshots, IP address.
        #    Also, verify resource limits for the project are independent of
        #    account resource limits
        # 3. Increase Projects Resources limits above domains limit. Verify
        #    project can't have more resources than domain level limit allows.
        # 4. Create Resource more than its set limit for the parent domain.
        #    Verify resource allocation should fail giving proper message

        # Create project as a domain admin
        project = Project.create(
                                 self.apiclient,
                                 self.services["project"],
                                 account=self.admin.name,
                                 domainid=self.admin.domainid
                                 )
        # Cleanup created project at end of test
        self.cleanup.append(project)
        self.debug("Created project with domain admin with ID: %s" %
                                                                project.id)

        list_projects_reponse = Project.list(
                                             self.apiclient,
                                             id=project.id,
                                             listall=True
                                             )

        self.assertEqual(
                            isinstance(list_projects_reponse, list),
                            True,
                            "Check for a valid list projects response"
                            )
        list_project = list_projects_reponse[0]

        self.assertNotEqual(
                    len(list_projects_reponse),
                    0,
                    "Check list project response returns a valid project"
                    )

        self.assertEqual(
                            project.name,
                            list_project.name,
                            "Check project name from list response"
                            )
        # Get the resource limits for ROOT domain
        resource_limits = list_resource_limits(self.apiclient)

        self.assertEqual(
                         isinstance(resource_limits, list),
                         True,
                         "List resource API should return a valid list"
                         )
        self.assertNotEqual(
                         len(resource_limits),
                         0,
                         "List resource API response should not be empty"
                         )

        # Reduce resource limits for project
        # Resource: 0 - Instance. Number of instances a user can create.
        # Resource: 1 - IP. Number of public IP addresses a user can own.
        # Resource: 2 - Volume. Number of disk volumes a user can create.
        # Resource: 3 - Snapshot. Number of snapshots a user can create.
        # Resource: 4 - Template. Number of templates that a user can
        #               register/create
        for resource in resource_limits:
            update_resource_limit(
                                    self.apiclient,
                                    resource.resourcetype,
                                    max=1,
                                    projectid=project.id
                                    )
            self.debug(
            "Updating resource (ID: %s) limit for project: %s" % (
                                                                  resource,
                                                                  project.id
                                                                  ))
        resource_limits = list_resource_limits(
                                                self.apiclient,
                                                projectid=project.id
                                                )
        self.assertEqual(
                         isinstance(resource_limits, list),
                         True,
                         "List resource API should return a valid list"
                         )
        self.assertNotEqual(
                         len(resource_limits),
                         0,
                         "List resource API response should not be empty"
                         )
        for resource in resource_limits:
            self.assertEqual(
                         resource.max,
                         1,
                         "Resource limit should be updated to 1"
                         )

        # Get the resource limits for domain
        resource_limits = list_resource_limits(
                                                self.apiclient,
                                                domainid=self.domain.id
                                                )
        self.assertEqual(
                         isinstance(resource_limits, list),
                         True,
                         "List resource API should return a valid list"
                         )
        self.assertNotEqual(
                         len(resource_limits),
                         0,
                         "List resource API response should not be empty"
                         )

        for resource in resource_limits:
            # Update domain resource limits to 2
            update_resource_limit(
                                        self.apiclient,
                                        resource.resourcetype,
                                        domainid=self.domain.id,
                                        max=1
                                      )
            max_value = 2
            self.debug(
                "Attempting to update project: %s resource limit to: %s" % (
                                                            project.id,
                                                            max_value
                                                            ))
            # Update project resource limits to 3
            update_resource_limit(
                                    self.apiclient,
                                    resource.resourcetype,
                                    max=max_value,
                                    projectid=project.id
                                  )

        # Verify project can't have more resources then limit set for domain by adding volumes.
        volume = Volume.create(
                          self.apiclient,
                          self.services["volume"],
                          zoneid=self.zone.id,
                          diskofferingid=self.disk_offering.id,
                          projectid=project.id
                        )
        # Exception should be raised for second volume
        with self.assertRaises(Exception):
            Volume.create(
                          self.apiclient,
                          self.services["volume"],
                          zoneid=self.zone.id,
                          diskofferingid=self.disk_offering.id,
                          projectid=project.id
                        )
        volume.delete(self.apiclient);

        return
예제 #27
0
    def test_02_project_limits_normal_user(self):
        """ Test project limits for normal user
        """
        # Validate the following
        # 1. Create a Project
        # 2. Reduce the projects limits as a domain admin. Verify resource
        #    count is updated
        # 3. Reduce the projects limits as a project user owner who is not a
        #    domain admin. Resource count should fail

        # Create project as a domain admin
        project = Project.create(
                                 self.apiclient,
                                 self.services["project"],
                                 account=self.admin.name,
                                 domainid=self.admin.domainid
                                 )
        # Cleanup created project at end of test
        self.cleanup.append(project)
        self.debug("Created project with domain admin with ID: %s" %
                                                                project.id)

        list_projects_reponse = Project.list(
                                             self.apiclient,
                                             id=project.id,
                                             listall=True
                                             )

        self.assertEqual(
                            isinstance(list_projects_reponse, list),
                            True,
                            "Check for a valid list projects response"
                            )
        list_project = list_projects_reponse[0]

        self.assertNotEqual(
                    len(list_projects_reponse),
                    0,
                    "Check list project response returns a valid project"
                    )

        self.assertEqual(
                            project.name,
                            list_project.name,
                            "Check project name from list response"
                            )
        # Get the resource limits for ROOT domain
        resource_limits = list_resource_limits(self.apiclient)

        self.assertEqual(
                         isinstance(resource_limits, list),
                         True,
                         "List resource API should return a valid list"
                         )
        self.assertNotEqual(
                         len(resource_limits),
                         0,
                         "List resource API response should not be empty"
                         )

        # Reduce resource limits for project
        # Resource: 0 - Instance. Number of instances a user can create.
        # Resource: 1 - IP. Number of public IP addresses a user can own.
        # Resource: 2 - Volume. Number of disk volumes a user can create.
        # Resource: 3 - Snapshot. Number of snapshots a user can create.
        # Resource: 4 - Template. Number of templates that a user can
        #               register/create
        for resource in resource_limits:
            update_resource_limit(
                                    self.apiclient,
                                    resource.resourcetype,
                                    max=1,
                                    projectid=project.id
                                    )
            self.debug(
            "Updating resource (ID: %s) limit for project: %s" % (
                                                                  resource,
                                                                  project.id
                                                                  ))
        resource_limits = list_resource_limits(
                                                self.apiclient,
                                                projectid=project.id
                                                )
        self.assertEqual(
                         isinstance(resource_limits, list),
                         True,
                         "List resource API should return a valid list"
                         )
        self.assertNotEqual(
                         len(resource_limits),
                         0,
                         "List resource API response should not be empty"
                         )
        for resource in resource_limits:
            self.assertEqual(
                         resource.max,
                         1,
                         "Resource limit should be updated to 1"
                         )

        self.debug("Adding %s user to project: %s" % (
                                                self.user.name,
                                                project.name
                                                ))

        # Add user to the project
        project.addAccount(
                           self.apiclient,
                           self.user.name,
                           )

        # Get the resource limits for domain
        resource_limits = list_resource_limits(
                                                self.apiclient,
                                                domainid=self.domain.id
                                                )
        self.assertEqual(
                         isinstance(resource_limits, list),
                         True,
                         "List resource API should return a valid list"
                         )
        self.assertNotEqual(
                         len(resource_limits),
                         0,
                         "List resource API response should not be empty"
                         )

        for resource in resource_limits:
            #with self.assertRaises(Exception):
            self.debug(
                    "Attempting to update resource limit by user: %s" % (
                                                        self.user.name
                                                        ))
            # Update project resource limits to 3
            update_resource_limit(
                                    self.apiclient,
                                    resource.resourcetype,
                                    account=self.user.name,
                                    domainid=self.user.domainid,
                                    max=3,
                                    projectid=project.id
                                )
        return
예제 #28
0
    def test_01_project_limits(self):
        """ Test project limits for domain admin
        """
        # Validate the following
        # 1. Create a Project. Verify once projects are created, they inherit
        #    a default set of resource limits as configured by the Cloud Stack
        #    ROOT admin.
        # 2. Reduce Project resources limits. Verify limits can be reduced by
        #    the Project Owner of each project and project limit applies to
        #    number of virtual instances, disk volumes, snapshots, IP address.
        #    Also, verify resource limits for the project are independent of
        #    account resource limits
        # 3. Increase Projects Resources limits above domains limit. Verify
        #    project can't have more resources than domain level limit allows.
        # 4. Create Resource more than its set limit for the parent domain.
        #    Verify resource allocation should fail giving proper message

        # Create project as a domain admin
        project = Project.create(
                                 self.apiclient,
                                 self.services["project"],
                                 account=self.admin.name,
                                 domainid=self.admin.domainid
                                 )
        # Cleanup created project at end of test
        self.cleanup.append(project)
        self.debug("Created project with domain admin with ID: %s" %
                                                                project.id)

        list_projects_reponse = Project.list(
                                             self.apiclient,
                                             id=project.id,
                                             listall=True
                                             )

        self.assertEqual(
                            isinstance(list_projects_reponse, list),
                            True,
                            "Check for a valid list projects response"
                            )
        list_project = list_projects_reponse[0]

        self.assertNotEqual(
                    len(list_projects_reponse),
                    0,
                    "Check list project response returns a valid project"
                    )

        self.assertEqual(
                            project.name,
                            list_project.name,
                            "Check project name from list response"
                            )
        # Get the resource limits for ROOT domain
        resource_limits = list_resource_limits(self.apiclient)

        self.assertEqual(
                         isinstance(resource_limits, list),
                         True,
                         "List resource API should return a valid list"
                         )
        self.assertNotEqual(
                         len(resource_limits),
                         0,
                         "List resource API response should not be empty"
                         )

        # Reduce resource limits for project
        # Resource: 0 - Instance. Number of instances a user can create.
        # Resource: 1 - IP. Number of public IP addresses a user can own.
        # Resource: 2 - Volume. Number of disk volumes a user can create.
        # Resource: 3 - Snapshot. Number of snapshots a user can create.
        # Resource: 4 - Template. Number of templates that a user can
        #               register/create
        for resource in resource_limits:
            update_resource_limit(
                                    self.apiclient,
                                    resource.resourcetype,
                                    max=1,
                                    projectid=project.id
                                    )
            self.debug(
            "Updating resource (ID: %s) limit for project: %s" % (
                                                                  resource,
                                                                  project.id
                                                                  ))
        resource_limits = list_resource_limits(
                                                self.apiclient,
                                                projectid=project.id
                                                )
        self.assertEqual(
                         isinstance(resource_limits, list),
                         True,
                         "List resource API should return a valid list"
                         )
        self.assertNotEqual(
                         len(resource_limits),
                         0,
                         "List resource API response should not be empty"
                         )
        for resource in resource_limits:
            self.assertEqual(
                         resource.max,
                         1,
                         "Resource limit should be updated to 1"
                         )

        # Get the resource limits for domain
        resource_limits = list_resource_limits(
                                                self.apiclient,
                                                domainid=self.domain.id
                                                )
        self.assertEqual(
                         isinstance(resource_limits, list),
                         True,
                         "List resource API should return a valid list"
                         )
        self.assertNotEqual(
                         len(resource_limits),
                         0,
                         "List resource API response should not be empty"
                         )

        for resource in resource_limits:
            # Update domain resource limits to 2
            update_resource_limit(
                                        self.apiclient,
                                        resource.resourcetype,
                                        domainid=self.domain.id,
                                        max=1
                                      )
            max_value = 2
            self.debug(
                "Attempting to update project: %s resource limit to: %s" % (
                                                            project.id,
                                                            max_value
                                                            ))
            # Update project resource limits to 3
            update_resource_limit(
                                    self.apiclient,
                                    resource.resourcetype,
                                    max=max_value,
                                    projectid=project.id
                                  )

        # Verify project can't have more resources then limit set for domain by adding volumes.
        volume = Volume.create(
                          self.apiclient,
                          self.services["volume"],
                          zoneid=self.zone.id,
                          diskofferingid=self.disk_offering.id,
                          projectid=project.id
                        )
        # Exception should be raised for second volume
        with self.assertRaises(Exception):
            Volume.create(
                          self.apiclient,
                          self.services["volume"],
                          zoneid=self.zone.id,
                          diskofferingid=self.disk_offering.id,
                          projectid=project.id
                        )
        volume.delete(self.apiclient);

        return