• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python base.Project类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_02_project_vmlifecycle_migrate_instance

    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,代码行数:33,代码来源:test_mm_project_limits.py


示例2: setupProjectAccounts

    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,代码行数:34,代码来源:test_cpu_project_limits.py


示例3: test_03_project_counts_delete_instance

    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,代码行数:31,代码来源:test_cpu_project_limits.py


示例4: test_03_project_vmlifecycle_delete_instance

    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,代码行数:32,代码来源:test_mm_project_limits.py


示例5: test_01_project_vmlifecycle_start_stop_instance

    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,代码行数:55,代码来源:test_mm_project_limits.py


示例6: test_01_project_counts_start_stop_instance

    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,代码行数:53,代码来源:test_cpu_project_limits.py


示例7: setUpClass

    def setUpClass(cls):
        cls.testClient = super(TestResourceLimitsProject, cls).getClsTestClient()
        cls.api_client = cls.testClient.getApiClient()
        cls.hypervisor = cls.testClient.getHypervisorInfo()
        cls.services = Services().services
        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
        cls.services["mode"] = cls.zone.networktype

        cls.template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"])
        cls.services["server"]["zoneid"] = cls.zone.id

        # Create Domains, Account etc
        cls.domain = Domain.create(cls.api_client, cls.services["domain"])

        cls.account = Account.create(cls.api_client, cls.services["account"], domainid=cls.domain.id)

        cls.userapiclient = cls.testClient.getUserApiClient(UserName=cls.account.name, DomainName=cls.account.domain)

        # Create project as a domain admin
        cls.project = Project.create(
            cls.api_client, cls.services["project"], account=cls.account.name, domainid=cls.account.domainid
        )
        cls.services["account"] = cls.account.name

        # Create Service offering and disk offerings etc
        cls.service_offering = ServiceOffering.create(cls.api_client, cls.services["service_offering"])
        cls.disk_offering = DiskOffering.create(cls.api_client, cls.services["disk_offering"])
        cls._cleanup = [cls.project, cls.service_offering, cls.disk_offering, cls.account, cls.domain]
        return
开发者ID:vaddanak,项目名称:challenges,代码行数:29,代码来源:test_project_limits.py


示例8: setUpClass

    def setUpClass(cls):
        cls.testClient = super(TestPublicIpAddress, cls).getClsTestClient()
        cls.api_client = cls.testClient.getApiClient()

        cls.services = Services().services
        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
        cls.services["mode"] = cls.zone.networktype

        cls.template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"])
        cls.services["server"]["zoneid"] = cls.zone.id

        # Create Domains, Account etc
        cls.domain = Domain.create(cls.api_client, cls.services["domain"])

        cls.account = Account.create(cls.api_client, cls.services["account"], domainid=cls.domain.id)
        # Create project as a domain admin
        cls.project = Project.create(
            cls.api_client, cls.services["project"], account=cls.account.name, domainid=cls.account.domainid
        )
        cls.services["account"] = cls.account.name

        # Create Service offering and disk offerings etc
        cls.service_offering = ServiceOffering.create(cls.api_client, cls.services["service_offering"])
        cls.virtual_machine = VirtualMachine.create(
            cls.api_client,
            cls.services["server"],
            templateid=cls.template.id,
            serviceofferingid=cls.service_offering.id,
            projectid=cls.project.id,
        )

        cls._cleanup = [cls.project, cls.service_offering, cls.account, cls.domain]
        return
开发者ID:maksimov,项目名称:cloudstack,代码行数:33,代码来源:test_project_resources.py


示例9: setupAccounts

    def setupAccounts(self):

        try:
            self.child_domain = Domain.create(self.apiclient,services=self.services["domain"],
                                          parentdomainid=self.domain.id)

            self.child_do_admin = Account.create(self.apiclient, self.services["account"], admin=True,
                                             domainid=self.child_domain.id)

            self.userapiclient = self.testClient.getUserApiClient(
                                    UserName=self.child_do_admin.name,
                                    DomainName=self.child_do_admin.domain)

            # Create project as a domain admin
            self.project = Project.create(self.apiclient, self.services["project"],
                                      account=self.child_do_admin.name,
                                      domainid=self.child_do_admin.domainid)

            # Cleanup created project at end of test
            self.cleanup.append(self.project)

            # Cleanup accounts created
            self.cleanup.append(self.child_do_admin)
            self.cleanup.append(self.child_domain)
        except Exception as e:
            return [FAIL, e]
        return [PASS, None]
开发者ID:m8cool,项目名称:cloudstack,代码行数:27,代码来源:test_ss_max_limits.py


示例10: matchResourceCount

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,代码行数:25,代码来源:common.py


示例11: test_01_service_offerings

    def test_01_service_offerings(self):
        """ Test service offerings in a project
        """
        # Validate the following
        # 1. Create a project.
        # 2. List service offerings for the project. All SO 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)

        self.debug(
            "Deploying VM instance for project: %s & service offering: %s" % (project.id, self.service_offering.id)
        )
        virtual_machine = VirtualMachine.create(
            self.apiclient,
            self.services["server"],
            templateid=self.template.id,
            serviceofferingid=self.service_offering.id,
            projectid=project.id,
        )
        # Verify VM state
        self.assertEqual(virtual_machine.state, "Running", "Check VM state is Running or not")

        return
开发者ID:maksimov,项目名称:cloudstack,代码行数:30,代码来源:test_project_resources.py


示例12: setupAccounts

    def setupAccounts(self, account_limit=2, domain_limit=2, project_limit=2):

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

        self.debug("domain crated with domain id %s" % self.child_domain.id)

        self.child_do_admin = Account.create(self.apiclient,
            self.testdata["account"],
            admin=True,
            domainid=self.child_domain.id)

        self.debug("domain admin created for domain id %s" %
                   self.child_do_admin.domainid)

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

        # Cleanup accounts created
        self.cleanup.append(self.child_do_admin)
        self.cleanup.append(self.child_domain)

        self.debug("Updating the CPU resource count for domain: %s" %
                   self.child_domain.name)
        # Update resource limits for account 1
        responses = Resources.updateLimit(self.apiclient,
            resourcetype=8,
            max=account_limit,
            account=self.child_do_admin.name,
            domainid=self.child_do_admin.domainid)

        self.debug("CPU Resource count for child domain admin account is now: %s" %
                   responses.max)

        self.debug("Updating the CPU limit for project")
        responses = Resources.updateLimit(self.apiclient,
            resourcetype=8,
            max=project_limit,
            projectid=self.project.id)

        self.debug("CPU Resource count for project is now")
        self.debug(responses.max)

        self.debug("Updating the CPU limit for domain only")
        responses = Resources.updateLimit(self.apiclient,
            resourcetype=8,
            max=domain_limit,
            domainid=self.child_domain.id)

        self.debug("CPU Resource count for domain %s with id %s is now %s" %
                   (responses.domain, responses.domainid, responses.max))

        return
开发者ID:PCextreme,项目名称:cloudstack,代码行数:60,代码来源:test_cpu_max_limits.py


示例13: create_domain_account_user

 def create_domain_account_user(parentDomain=None):
     domain  =  Domain.create(cls.api_client,
                              cls.services["domain"],
                              parentdomainid=parentDomain.id if parentDomain else None)
     cls._cleanup.append(domain)
     # Create an Account associated with domain
     account = Account.create(cls.api_client,
                              cls.services["account"],
                              domainid=domain.id)
     cls._cleanup.append(account)
     # Create an User, Project, Volume associated with account
     user    = User.create(cls.api_client,
                           cls.services["user"],
                           account=account.name,
                           domainid=account.domainid)
     cls._cleanup.append(user)
     project = Project.create(cls.api_client,
                              cls.services["project"],
                              account=account.name,
                              domainid=account.domainid)
     cls._cleanup.append(project)
     volume  = Volume.create(cls.api_client,
                             cls.services["volume"],
                             zoneid=cls.zone.id,
                             account=account.name,
                             domainid=account.domainid,
                             diskofferingid=cls.disk_offering.id)
     cls._cleanup.append(volume)
     return {'domain':domain, 'account':account, 'user':user, 'project':project, 'volume':volume}
开发者ID:PCextreme,项目名称:cloudstack,代码行数:29,代码来源:test_assign_vm.py


示例14: test_06_volumes_per_project

    def test_06_volumes_per_project(self):
        """Test Volumes limit per project
        """
        # Validate the following
        # 1. set max no of volume per project to 1.
        # 2. Create 1 VM in this project
        # 4. Try to Create another VM in the project. It should give the user
        #    an appropriate error that Volume limit is exhausted and an alert
        #    should be generated.

        if self.hypervisor.lower() == 'lxc':
            if not find_storage_pool_type(self.apiclient, storagetype='rbd'):
                self.skipTest("RBD storage type is required for data volumes for LXC")
        self.project_1 = Project.create(
                         self.api_client,
                         self.services["project"],
                         account=self.account.name,
                         domainid=self.account.domainid
                         )
        self.cleanup.append(self.project_1)

        self.debug(
            "Updating volume resource limits for project: %s" %
                                                    self.project_1.id)
        # Set usage_vm=1 for Account 1
        update_resource_limit(
                              self.apiclient,
                              2, # Volume
                              max=1,
                              projectid=self.project_1.id
                              )

        self.debug("Deploying VM for project: %s" % self.project_1.id)
        virtual_machine_1 = VirtualMachine.create(
                                self.apiclient,
                                self.services["server"],
                                templateid=self.template.id,
                                serviceofferingid=self.service_offering.id,
                                projectid=self.project_1.id
                                )
        # Verify VM state
        self.assertEqual(
                            virtual_machine_1.state,
                            'Running',
                            "Check VM state is Running or not"
                        )

        # 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=self.project_1.id
                        )
        return
开发者ID:Accelerite,项目名称:cloudstack,代码行数:57,代码来源:test_project_limits.py


示例15: test_02_project_counts_migrate_instance

    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,代码行数:43,代码来源:test_cpu_project_limits.py


示例16: test_03_deploy_vm_project_limit_reached

    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,代码行数:51,代码来源:test_ps_max_limits.py


示例17: test_02_project_disk_offerings

    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,代码行数:38,代码来源:test_project_resources.py


示例18: test_maxAccountNetworks

    def test_maxAccountNetworks(self):
        """Test Limit number of guest account specific networks
        """

        # Steps for validation
        # 1. Fetch max.account.networks from configurations
        # 2. Create an account. Create account more that max.accout.network
        # 3. Create network should fail

        self.debug("Creating project with '%s' as admin" % self.account.name)
        # 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)

        config = Configurations.list(self.apiclient, name="max.project.networks", listall=True)
        self.assertEqual(isinstance(config, list), True, "List configurations hsould have max.project.networks")

        config_value = int(config[0].value)
        self.debug("max.project.networks: %s" % config_value)

        for ctr in range(config_value):
            # Creating network using the network offering created
            self.debug("Creating network with network offering: %s" % self.network_offering.id)
            network = Network.create(
                self.apiclient,
                self.services["network"],
                projectid=project.id,
                networkofferingid=self.network_offering.id,
                zoneid=self.zone.id,
            )
            self.debug("Created network with ID: %s" % network.id)
        self.debug("Creating network in account already having networks : %s" % config_value)

        with self.assertRaises(Exception):
            Network.create(
                self.apiclient,
                self.services["network"],
                projectid=project.id,
                networkofferingid=self.network_offering.id,
                zoneid=self.zone.id,
            )
        self.debug("Create network failed (as expected)")
        return
开发者ID:vaddanak,项目名称:challenges,代码行数:47,代码来源:test_project_limits.py


示例19: setUp

    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,代码行数:21,代码来源:test_ps_project_limits.py


示例20: setupProjectAccounts

    def setupProjectAccounts(self):

        try:
            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)
        except Exception as e:
            return [FAIL, e]
        return [PASS, None]
开发者ID:aali-dincloud,项目名称:cloudstack,代码行数:21,代码来源:test_ps_project_limits.py



注:本文中的marvin.lib.base.Project类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python base.PublicIPAddress类代码示例发布时间:2022-05-27
下一篇:
Python base.PhysicalNetwork类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap