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

Python base.Account类代码示例

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

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



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

示例1: test_03_delete_instance

    def test_03_delete_instance(self):
        """Test Deploy VM with specified GB RAM & verify the usage"""

        # Validate the following
        # 1. Create compute offering with specified RAM & Deploy VM as root admin
        # 2. List Resource count for the root admin Memory usage
        # 3. Delete instance, resource count should be 0 after delete operation.

        account_list = Account.list(self.apiclient, id=self.account.id)
        self.assertIsInstance(account_list, list, "List Accounts should return a valid response")
        resource_count = account_list[0].memorytotal

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

        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)

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

        account_list = Account.list(self.apiclient, id=self.account.id)
        self.assertIsInstance(account_list, list, "List Accounts should return a valid response")
        resource_count_after_delete = account_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:tianshangjun,项目名称:cloudstack,代码行数:34,代码来源:test_memory_limits.py


示例2: deploy_account

    def deploy_account(self, account_data, domain):
        self.logger.debug('>>>  ACCOUNT  =>  Creating "%s"...', account_data['username'])
        account = None
        if not self.randomizeNames:
            account_list = Account.list(api_client=self.api_client, name=account_data['username'], listall=True)
            if isinstance(account_list, list) and len(account_list) >= 1:
                if account_list[0].name == account_data['username']:
                    account = account_list[0]
                    self.logger.debug('>>>  ACCOUNT  =>  Loaded from (pre) existing account,  ID: %s', account.id)
                    return

        if not account:
            account = Account.create(
                api_client=self.api_client,
                services=account_data,
                domainid=domain.uuid,
                randomizeID=self.randomizeNames
            )
        self.resources_to_cleanup.append(account)
        self.dynamic_names['accounts'][account_data['username']] = account.name

        self.logger.debug('>>>  ACCOUNT  =>  ID: %s  =>  Name: %s  =>  State: %s  =>  Domain: %s', account.id,
                          account.name, account.state, account.domainid)

        self.deploy_vpcs(account_data['vpcs'], account)
        self.deploy_isolatednetworks(account_data['isolatednetworks'], account)
        self.deploy_vms(account_data['virtualmachines'], account)
        self.deploy_vpcs_publicipaddresses(account_data['vpcs'], account_data['virtualmachines'])
        self.deploy_isolatednetworks_publicipaddresses(account_data['isolatednetworks'], account_data['virtualmachines'])
        self.deploy_privatenetworks(account_data['privatenetworks'], account, domain)
        self.deploy_vpcs_privategateways(account_data['vpcs'])
        self.enable_vpcs_localvpngateway(account_data['vpcs'])
        self.deploy_vpcs_remotevpngateways(account_data['vpcs'], account)
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:33,代码来源:testScenarioManager.py


示例3: setupAccounts

    def setupAccounts(self):

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

        self.child_do_admin_1 = Account.create(
                                self.apiclient,
                                self.services["account"],
                                admin=True,
                                domainid=self.child_domain_1.id
                                )
        # Cleanup the resources created at end of test
        self.cleanup.append(self.child_do_admin_1)
        self.cleanup.append(self.child_domain_1)

        self.debug("Creating a domain under: %s" % self.domain.name)

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

        self.child_do_admin_2 = Account.create(
                                    self.apiclient,
                                    self.services["account"],
                                    admin=True,
                                    domainid=self.child_domain_2.id)
        # Cleanup the resources created at end of test
        self.cleanup.append(self.child_do_admin_2)
        self.cleanup.append(self.child_domain_2)

        return
开发者ID:MANIKANDANVEN,项目名称:cloudstack,代码行数:33,代码来源:test_memory_limits.py


示例4: setupAccounts

    def setupAccounts(self):

        self.debug("Creating a sub-domain under: %s" % self.domain.name)

        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
        )
        # Cleanup the resources created at end of test
        self.cleanup.append(self.child_do_admin)
        self.cleanup.append(self.child_domain)

        Resources.updateLimit(
            self.apiclient,
            resourcetype=8,
            max=16,
            account=self.child_do_admin.name,
            domainid=self.child_do_admin.domainid,
        )

        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)

        # Cleanup the resources created at end of test
        self.cleanup.append(self.admin)
        self.cleanup.append(self.domain)

        Resources.updateLimit(
            self.apiclient, resourcetype=8, max=16, account=self.admin.name, domainid=self.admin.domainid
        )
        return
开发者ID:tianshangjun,项目名称:cloudstack,代码行数:34,代码来源:test_cpu_domain_limits.py


示例5: setUpClass

    def setUpClass(cls):
        cls.testClient = super(TestTemplates, 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)
        cls.user = 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.userapiclient = cls.testClient.getUserApiClient(UserName=cls.account.name, DomainName=cls.domain.name)

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


示例6: setUpClass

    def setUpClass(cls):

        testClient = super(TestlistTemplatesDomainAdmin, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls.testdata = testClient.getParsedTestDataConfig()
        cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
        cls.hypervisor = cls.testClient.getHypervisorInfo()
        builtin_info = get_builtin_template_info(cls.apiclient, cls.zone.id)
        cls.testdata["privatetemplate"]["url"] = builtin_info[0]
        cls.testdata["privatetemplate"]["hypervisor"] = builtin_info[1]
        cls.testdata["privatetemplate"]["format"] = builtin_info[2]
        cls.cleanup = []

        # Create 2 domain admin accounts

        cls.domain1 = Domain.create(cls.apiclient, cls.testdata["domain"])

        cls.domain2 = Domain.create(cls.apiclient, cls.testdata["domain"])

        cls.account1 = Account.create(cls.apiclient, cls.testdata["account"], admin=True, domainid=cls.domain1.id)

        cls.account2 = Account.create(cls.apiclient, cls.testdata["account2"], admin=True, domainid=cls.domain2.id)

        cls.debug("Created account %s in domain %s" % (cls.account1.name, cls.domain1.id))
        cls.debug("Created account %s in domain %s" % (cls.account2.name, cls.domain2.id))

        cls.cleanup.append(cls.account1)
        cls.cleanup.append(cls.account2)
        cls.cleanup.append(cls.domain1)
        cls.cleanup.append(cls.domain2)
开发者ID:ikarin,项目名称:cloudstack,代码行数:30,代码来源:test_escalation_listTemplateDomainAdmin.py


示例7: setupAccount

    def setupAccount(self, accountType):
        """Setup the account required for the test"""

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

            self.account = Account.create(self.apiclient, self.services["account"],
                                      domainid=self.domain.id, admin=True)
            self.cleanup.append(self.account)
            if accountType == CHILD_DOMAIN_ADMIN:
                self.cleanup.append(self.domain)

            self.virtualMachine = VirtualMachine.create(self.api_client, self.services["virtual_machine"],
                            accountid=self.account.name, domainid=self.account.domainid,
                            diskofferingid=self.disk_offering.id,
                            serviceofferingid=self.service_offering.id)

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

            self.assertEqual(validateList(accounts)[0], PASS,
                             "accounts list validation failed")

            self.initialResourceCount = int(accounts[0].primarystoragetotal)
        except Exception as e:
            return [FAIL, e]
        return [PASS, None]
开发者ID:Accelerite,项目名称:cloudstack,代码行数:29,代码来源:test_ps_limits.py


示例8: test_03_multiplecore_delete_instance

    def test_03_multiplecore_delete_instance(self):
        """Test Deploy VM with multiple core CPU & verify the usage"""

        # Validate the following
        # 1. Deploy VM with multiple core CPU & verify the usage
        # 2. Destroy VM & verify update resource count of Root Admin Account
        # 3. Resource count should list properly.

        account_list = Account.list(self.apiclient, id=self.account.id)
        self.assertIsInstance(account_list,
                              list,
                              "List Accounts should return a valid response"
                              )
        resource_count = account_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)

        account_list = Account.list(self.apiclient, id=self.account.id)
        self.assertIsInstance(account_list,
                              list,
                              "List Accounts should return a valid response"
                              )
        resource_count = account_list[0].cputotal
        self.assertEqual(resource_count, 0 , "Resource count for %s should be 0" % get_resource_type(resource_id=8))#CPU
        return
开发者ID:Accelerite,项目名称:cloudstack,代码行数:34,代码来源:test_cpu_limits.py


示例9: setUpClass

    def setUpClass(cls):
        testClient = super(TestSameVMName, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls.testdata = testClient.getParsedTestDataConfig()

        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.apiclient)
        cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())

        cls.template = get_template(
            cls.apiclient,
            cls.zone.id,
            cls.testdata["ostype"])

        cls._cleanup = []

        cls.mgtSvrDetails = cls.config.__dict__["mgtSvr"][0].__dict__
        try:
            cls.skiptest = False

            if cls.hypervisor.lower() not in ['vmware']:
                cls.skiptest = True

            # Create an account
            cls.account_1 = Account.create(
                cls.apiclient,
                cls.testdata["account"],
                domainid=cls.domain.id
            )
            cls.account_2 = Account.create(
                cls.apiclient,
                cls.testdata["account"],
                domainid=cls.domain.id
            )

            # Create user api client of the account
            cls.userapiclient_1 = testClient.getUserApiClient(
                UserName=cls.account_1.name,
                DomainName=cls.account_1.domain
            )

            cls.userapiclient_2 = testClient.getUserApiClient(
                UserName=cls.account_2.name,
                DomainName=cls.account_2.domain
            )
           # Create Service offering
            cls.service_offering = ServiceOffering.create(
                cls.apiclient,
                cls.testdata["service_offering"],
            )

            cls._cleanup = [
                cls.account_1,
                cls.account_2,
                cls.service_offering,
            ]
        except Exception as e:
            cls.tearDownClass()
            raise e
        return
开发者ID:rarotonga82,项目名称:cloudstack,代码行数:60,代码来源:testpath_same_vm_name.py


示例10: setUp

    def setUp(self):
        self.apiclient = self.testClient.getApiClient()
        self.hypervisor = self.testClient.getHypervisorInfo()
        self.dbclient = self.testClient.getDbConnection()
        self.cleanup = []

        self.services = Services().services
        # Get Zone, Domain and templates
        self.domain = get_domain(self.apiclient)
        self.account = Account.create(
                            self.apiclient,
                            self.services["account"],
                            domainid=self.domain.id
                            )
        self.newdomain = Domain.create(
                           self.apiclient,
                           self.services["testdomain"],
                           parentdomainid=self.domain.id
                           )
        self.newdomain_account = Account.create(
                           self.apiclient,
                           self.services["account"],
                           admin=True,
                           domainid=self.newdomain.id
                           )
        self.cleanup = [
                        self.account,
                        self.newdomain_account,
                        self.newdomain,
                        ]
开发者ID:HitherTech,项目名称:cloudstack,代码行数:30,代码来源:test_templates.py


示例11: test_02_multiple_core_vm_migrate_instance

    def test_02_multiple_core_vm_migrate_instance(self):
        """Test Deploy VM with 4 core CPU & verify the usage"""

        # Validate the following
        # 1. Create two domains and set specific resource (cpu) limit for them
        # 2. Create compute offering with 4 core CPU & deploy vm
        # 3. Update Resource count for the domains
        # 4. Migrate instance to new host and check resource count
        # 5. Resource count should list properly.
        self.hypervisor = self.testClient.getHypervisorInfo()

        self.debug("Setting up account and domain hierarchy")
        self.setupAccounts()
        users = {self.domain: self.admin,
                 self.child_domain: self.child_do_admin
                 }
        for domain, admin in users.items():
            self.account = admin
            self.domain = domain

            api_client = self.testClient.getUserApiClient(
                UserName=self.account.name,
                DomainName=self.account.domain)

            self.debug("Creating an instance with service offering: %s" %
                       self.service_offering.name)
            vm = self.createInstance(service_off=self.service_offering, api_client=api_client)

            account_list = Account.list(self.apiclient, id=self.account.id)
            self.assertIsInstance(account_list,
                list,
                "List Accounts should return a valid response"
            )
            resource_count = account_list[0].cputotal

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

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

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

            account_list = Account.list(self.apiclient, id=self.account.id)
            self.assertIsInstance(account_list,
                list,
                "List Accounts should return a valid response"
            )
            resource_count_after_migrate = account_list[0].cputotal

            self.assertEqual(resource_count, resource_count_after_migrate,
                "Resource count should be same as before, after migrating the instance")
        return
开发者ID:miguelaferreira,项目名称:cosmic-core,代码行数:60,代码来源:test_cpu_domain_limits.py


示例12: test_02_migrate_vm

    def test_02_migrate_vm(self):
        """Test Deploy VM with specified RAM & verify the usage"""

        # Validate the following
        # 1. Create compute offering with specified RAM & Deploy VM in the created domain
        # 2. List Resource count for the root admin Memory usage
        # 3. Migrate vm to another host, resource count should list properly.

        #Resetting memory count in service offering
        self.services["service_offering"]["memory"] = 2048

        self.debug("Setting up account and domain hierarchy")
        self.setupAccounts()
        users =  { self.child_domain_1: self.child_do_admin_1,
                   self.child_domain_2: self.child_do_admin_2
                 }
        for domain, admin in users.items():
            self.account = admin
            self.domain = domain
            self.debug("Creating an instance with service offering: %s" %
                                                    self.service_offering.name)

            api_client = self.testClient.getUserApiClient(
                            UserName=self.account.name,
                            DomainName=self.account.domain)

            vm = self.createInstance(service_off=self.service_offering, api_client=api_client)

            account_list = Account.list(self.apiclient, id=self.account.id)
            self.assertIsInstance(account_list,
                              list,
                              "List Accounts should return a valid response"
                              )
            resource_count = account_list[0].memorytotal

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

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

            host = findSuitableHostForMigration(self.apiclient, vm.id)
            if host is None:
                self.skipTest(ERROR_NO_HOST_FOR_MIGRATION)
            self.debug("Migrating instance: %s to host: %s" %
                                                        (vm.name, host.name))
            try:
                vm.migrate(self.apiclient, host.id)
            except Exception as e:
                self.fail("Failed to migrate instance: %s" % e)
            account_list = Account.list(self.apiclient, id=self.account.id)
            self.assertIsInstance(account_list,
                              list,
                              "List Accounts should return a valid response"
                              )
            resource_count_after_migrate = account_list[0].memorytotal

            self.assertTrue(resource_count_after_migrate == resource_count,
                            "Resource count should be same after migrating the instance")
        return
开发者ID:Skotha,项目名称:cloudstack,代码行数:59,代码来源:test_mm_domain_limits.py


示例13: setupAccounts

    def setupAccounts(self):

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

        self.debug("Updating the Memory resource count for domain: %s" % self.domain.name)
        Resources.updateLimit(
            self.apiclient,
            resourcetype=9,
            max=4096,
            account=self.parentd_admin.name,
            domainid=self.parentd_admin.domainid,
        )
        self.debug("Creating a sub-domain under: %s" % self.parent_domain.name)
        self.cdomain_1 = Domain.create(
            self.apiclient, services=self.services["domain"], parentdomainid=self.parent_domain.id
        )

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

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

        self.debug("Updating the Memory resource count for domain: %s" % self.cdomain_1.name)
        Resources.updateLimit(self.apiclient, resourcetype=9, max=2048, domainid=self.cadmin_1.domainid)

        self.debug("Updating the Memory resource count for account: %s" % self.cadmin_1.name)
        Resources.updateLimit(
            self.apiclient, resourcetype=9, max=2048, account=self.cadmin_1.name, domainid=self.cadmin_1.domainid
        )

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

        self.debug("Updating the Memory resource count for domain: %s" % self.cdomain_2.name)
        Resources.updateLimit(self.apiclient, resourcetype=9, max=2048, domainid=self.cadmin_2.domainid)

        self.debug("Updating the Memory resource count for domain: %s" % self.cadmin_2.name)
        Resources.updateLimit(
            self.apiclient, resourcetype=9, max=2048, account=self.cadmin_2.name, domainid=self.cadmin_2.domainid
        )

        # Cleanup the resources created at end of test
        self.cleanup.append(self.cadmin_1)
        self.cleanup.append(self.cadmin_2)
        self.cleanup.append(self.cdomain_1)
        self.cleanup.append(self.cdomain_2)
        self.cleanup.append(self.parentd_admin)
        self.cleanup.append(self.parent_domain)

        users = {self.parent_domain: self.parentd_admin, self.cdomain_1: self.cadmin_1, self.cdomain_2: self.cadmin_2}
        return users
开发者ID:tianshangjun,项目名称:cloudstack,代码行数:58,代码来源:test_mm_domain_limits.py


示例14: test_03_delete_vm

    def test_03_delete_vm(self):
        """Test Deploy VM with specified RAM & verify the usage"""

        # Validate the following
        # 1. Create compute offering with specified RAM & Deploy VM in the created domain
        # 2. List Resource count for the root admin Memory usage
        # 3. Delete vm, resource count should list as 0 after delete operation.

        # Resetting the memory count of service offering
        self.services["service_offering"]["memory"] = 2048

        self.debug("Setting up account and domain hierarchy")
        self.setupAccounts()
        users =  { self.child_domain_1: self.child_do_admin_1,
                   self.child_domain_2: self.child_do_admin_2
                 }
        for domain, admin in users.items():
            self.account = admin
            self.domain = domain
            self.debug("Creating an instance with service offering: %s" %
                                                    self.service_offering.name)

            api_client = self.testClient.getUserApiClient(
                            UserName=self.account.name,
                            DomainName=self.account.domain)

            vm = self.createInstance(service_off=self.service_offering, api_client=api_client)

            account_list = Account.list(self.apiclient, id=self.account.id)
            self.assertIsInstance(account_list,
                              list,
                              "List Accounts should return a valid response"
                              )
            resource_count = account_list[0].memorytotal

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

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

            self.debug("Destroying instance: %s" % vm.name)
            try:
                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"])

            account_list = Account.list(self.apiclient, id=self.account.id)
            self.assertIsInstance(account_list,
                              list,
                              "List Accounts should return a valid response"
                              )
            resource_count_after_delete = account_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:Skotha,项目名称:cloudstack,代码行数:57,代码来源:test_mm_domain_limits.py


示例15: test_04_deploy_multiple_vm

    def test_04_deploy_multiple_vm(self):
        """Test Deploy multiple VM with specified RAM & verify the usage"""

        # Validate the following
        # 1. Create compute offering with specified RAM
        # 2. Deploy multiple VMs with this service offering
        # 3. List Resource count for the root admin Memory usage
        # 4. Memory usage should list properly

        account_list = Account.list(self.apiclient, id=self.account.id)
        self.assertIsInstance(account_list,
                              list,
                              "List Accounts should return a valid response"
                              )
        resource_count = account_list[0].memorytotal

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

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

        self.debug("Creating two instances with service offering: %s" %
                                                    self.service_offering.name)
        vm_1 = self.createInstance(service_off=self.service_offering)
        self.createInstance(service_off=self.service_offering)

        account_list = Account.list(self.apiclient, id=self.account.id)
        self.assertIsInstance(account_list,
                              list,
                              "List Accounts should return a valid response"
                              )
        resource_count_new = account_list[0].memorytotal

        expected_resource_count = int(self.services["service_offering"]["memory"]) * 3 #Total 3 VMs

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

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

        account_list = Account.list(self.apiclient, id=self.account.id)
        self.assertIsInstance(account_list,
                              list,
                              "List Accounts should return a valid response"
                              )
        resource_count_after_delete = account_list[0].memorytotal

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

        self.assertEqual(resource_count_after_delete, expected_resource_count,
                         "Resource count should match with the expected resource count")
        return
开发者ID:MANIKANDANVEN,项目名称:cloudstack,代码行数:56,代码来源:test_memory_limits.py


示例16: test_03_multiple_core_vm_delete_instance

    def test_03_multiple_core_vm_delete_instance(self):
        """Test Deploy VM with 4 core CPU & verify the usage"""

        # Validate the following
        # 1. Create two domains and set specific resource (cpu) limit for them
        # 2. Create compute offering with 4 core CPU & deploy vm
        # 3. Update Resource count for the domains
        # 4. delete instance and check resource count
        # 5. Resource count should list properly.

        self.debug("Setting up account and domain hierarchy")
        self.setupAccounts()
        users = {self.domain: self.admin,
                 self.child_domain: self.child_do_admin
                 }
        for domain, admin in users.items():
            self.account = admin
            self.domain = domain

            api_client = self.testClient.getUserApiClient(
                UserName=self.account.name,
                DomainName=self.account.domain)

            self.debug("Creating an instance with service offering: %s" %
                       self.service_offering.name)
            vm = self.createInstance(service_off=self.service_offering, api_client=api_client)

            account_list = Account.list(self.apiclient, id=self.account.id)
            self.assertIsInstance(account_list,
                list,
                "List Accounts should return a valid response"
            )
            resource_count = account_list[0].cputotal

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

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

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

            account_list = Account.list(self.apiclient, id=self.account.id)
            self.assertIsInstance(account_list,
                list,
                "List Accounts should return a valid response"
            )
            resource_count_after_delete = account_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:miguelaferreira,项目名称:cosmic-core,代码行数:55,代码来源:test_cpu_domain_limits.py


示例17: test_02_migrate_instance

    def test_02_migrate_instance(self):
        """Test Deploy VM with specified memory & verify the usage"""

        # Validate the following
        # 1. Create compute offering with specified memory in child domains of root domain & Deploy VM
        # 2. List Resource count
        # 3. Migrate instance to another 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())

        self.debug("Setting up account and domain hierarchy")
        self.setupAccounts()
        users = {self.child_domain_1: self.child_do_admin_1, self.child_domain_2: self.child_do_admin_2}
        for domain, admin in users.items():
            self.account = admin
            self.domain = domain

            api_client = self.testClient.getUserApiClient(UserName=self.account.name, DomainName=self.account.domain)

            self.debug("Creating an instance with service offering: %s" % self.service_offering.name)
            vm = self.createInstance(service_off=self.service_offering, api_client=api_client)

            account_list = Account.list(self.apiclient, id=self.account.id)
            self.assertIsInstance(account_list, list, "List Accounts should return a valid response")
            resource_count = account_list[0].memorytotal

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

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

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

            account_list = Account.list(self.apiclient, id=self.account.id)
            self.assertIsInstance(account_list, list, "List Accounts should return a valid response")
            resource_count_after_migrate = account_list[0].memorytotal

            self.assertEqual(
                resource_count,
                resource_count_after_migrate,
                "Resource count should be same after starting the instance",
            )
        return
开发者ID:tianshangjun,项目名称:cloudstack,代码行数:55,代码来源:test_memory_limits.py


示例18: test_03_delete_instance

    def test_03_delete_instance(self):
        """Test Deploy VM with specified RAM & verify the usage"""

        # Validate the following
        # 1. Create compute offering with specified RAM in child domains of root domain & Deploy VM
        # 2. List Resource count for the Memory usage
        # 3. Delete instance
        # 4. Resource count should list as 0

        self.debug("Setting up account and domain hierarchy")
        self.setupAccounts()
        users = {self.child_domain_1: self.child_do_admin_1,
                 self.child_domain_2: self.child_do_admin_2
                 }
        for domain, admin in users.items():
            self.account = admin
            self.domain = domain

            api_client = self.testClient.getUserApiClient(
                UserName=self.account.name,
                DomainName=self.account.domain)

            self.debug("Creating an instance with service offering: %s" %
                       self.service_offering.name)
            vm = self.createInstance(service_off=self.service_offering, api_client=api_client)

            account_list = Account.list(self.apiclient, id=self.account.id)
            self.assertIsInstance(account_list,
                                  list,
                                  "List Accounts should return a valid response"
                                  )
            resource_count = account_list[0].memorytotal

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

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

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

            account_list = Account.list(self.apiclient, id=self.account.id)
            self.assertIsInstance(account_list,
                                  list,
                                  "List Accounts should return a valid response"
                                  )
            resource_count = account_list[0].memorytotal
            self.assertEqual(resource_count, 0,
                             "Resource count for %s should be 0" % get_resource_type(resource_id=9))  # RAM
        return
开发者ID:EdwardBetts,项目名称:blackhole,代码行数:53,代码来源:test_memory_limits.py


示例19: test_01_multiplecore_start_stop_instance

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python base.Configurations类代码示例发布时间:2022-05-27
下一篇:
Python utils.cleanup_resources函数代码示例发布时间: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