当前位置: 首页>>代码示例>>Python>>正文


Python Project.list方法代码示例

本文整理汇总了Python中marvin.lib.base.Project.list方法的典型用法代码示例。如果您正苦于以下问题:Python Project.list方法的具体用法?Python Project.list怎么用?Python Project.list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在marvin.lib.base.Project的用法示例。


在下文中一共展示了Project.list方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_02_project_vmlifecycle_migrate_instance

# 需要导入模块: from marvin.lib.base import Project [as 别名]
# 或者: from marvin.lib.base.Project import list [as 别名]
    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
开发者ID:maksimov,项目名称:cloudstack,代码行数:35,代码来源:test_mm_project_limits.py

示例2: test_03_project_vmlifecycle_delete_instance

# 需要导入模块: from marvin.lib.base import Project [as 别名]
# 或者: from marvin.lib.base.Project import list [as 别名]
    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
开发者ID:maksimov,项目名称:cloudstack,代码行数:34,代码来源:test_mm_project_limits.py

示例3: test_03_project_counts_delete_instance

# 需要导入模块: from marvin.lib.base import Project [as 别名]
# 或者: from marvin.lib.base.Project import list [as 别名]
    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
开发者ID:maksimov,项目名称:cloudstack,代码行数:33,代码来源:test_cpu_project_limits.py

示例4: test_01_project_vmlifecycle_start_stop_instance

# 需要导入模块: from marvin.lib.base import Project [as 别名]
# 或者: from marvin.lib.base.Project import list [as 别名]
    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
开发者ID:MANIKANDANVEN,项目名称:cloudstack,代码行数:57,代码来源:test_mm_project_limits.py

示例5: test_01_project_counts_start_stop_instance

# 需要导入模块: from marvin.lib.base import Project [as 别名]
# 或者: from marvin.lib.base.Project import list [as 别名]
    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
开发者ID:EdwardBetts,项目名称:blackhole,代码行数:55,代码来源:test_cpu_project_limits.py

示例6: matchResourceCount

# 需要导入模块: from marvin.lib.base import Project [as 别名]
# 或者: from marvin.lib.base.Project import list [as 别名]
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]
开发者ID:rafaelthedevops,项目名称:cloudstack,代码行数:27,代码来源:common.py

示例7: setupProjectAccounts

# 需要导入模块: from marvin.lib.base import Project [as 别名]
# 或者: from marvin.lib.base.Project import list [as 别名]
    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
开发者ID:EdwardBetts,项目名称:blackhole,代码行数:36,代码来源:test_cpu_project_limits.py

示例8: test_02_project_counts_migrate_instance

# 需要导入模块: from marvin.lib.base import Project [as 别名]
# 或者: from marvin.lib.base.Project import list [as 别名]
    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
开发者ID:Accelerite,项目名称:cloudstack,代码行数:45,代码来源:test_cpu_project_limits.py

示例9: test_03_deploy_vm_project_limit_reached

# 需要导入模块: from marvin.lib.base import Project [as 别名]
# 或者: from marvin.lib.base.Project import list [as 别名]
    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
开发者ID:K0zka,项目名称:cloudstack,代码行数:53,代码来源:test_ps_max_limits.py

示例10: setUp

# 需要导入模块: from marvin.lib.base import Project [as 别名]
# 或者: from marvin.lib.base.Project import list [as 别名]
    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
开发者ID:aali-dincloud,项目名称:cloudstack,代码行数:23,代码来源:test_ps_project_limits.py

示例11: test_03_deploy_vm_project_limit_reached

# 需要导入模块: from marvin.lib.base import Project [as 别名]
# 或者: from marvin.lib.base.Project import list [as 别名]
    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
开发者ID:m8cool,项目名称:cloudstack,代码行数:41,代码来源:test_ss_max_limits.py

示例12: test_02_project_disk_offerings

# 需要导入模块: from marvin.lib.base import Project [as 别名]
# 或者: from marvin.lib.base.Project import list [as 别名]
    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
开发者ID:maksimov,项目名称:cloudstack,代码行数:40,代码来源:test_project_resources.py

示例13: test_02_project_limits_normal_user

# 需要导入模块: from marvin.lib.base import Project [as 别名]
# 或者: from marvin.lib.base.Project import list [as 别名]
    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"
                         )

#.........这里部分代码省略.........
开发者ID:diejiazhao,项目名称:cloudstack,代码行数:103,代码来源:test_project_limits.py

示例14: test_01_project_limits

# 需要导入模块: from marvin.lib.base import Project [as 别名]
# 或者: from marvin.lib.base.Project import list [as 别名]
    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"
                         )
#.........这里部分代码省略.........
开发者ID:diejiazhao,项目名称:cloudstack,代码行数:103,代码来源:test_project_limits.py


注:本文中的marvin.lib.base.Project.list方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。