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

Python common.matchResourceCount函数代码示例

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

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



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

示例1: test_attach_volume_exceeding_primary_limits

    def test_attach_volume_exceeding_primary_limits(self):
        """
        # do
        # 1. create a normal user account and update primary store limits to the current resource count
        # 2. Upload a volume of any size
        # 3. Verify that upload volume succeeds
        # 4. Verify that primary storage count doesnt change
        # 6. Try attaching volume to VM and verify that the attach fails (as the resource limits exceed)
        # 7. Verify that primary storage count doesnt change
        # done
        """
        # create an account, launch a vm with default template and custom disk offering, update the primary store limits to the current primary store resource count
        response = self.setupNormalAccount()
        self.assertEqual(response[0], PASS, response[1])

        # upload volume and verify that the volume is uploaded
        volume = Volume.upload(
            self.apiclient,
            self.services["configurableData"]["upload_volume"],
            zoneid=self.zone.id,
            account=self.account.name,
            domainid=self.account.domainid,
            url="http://people.apache.org/~sanjeev/rajani-thin-volume.vhd",
        )

        volume.wait_for_upload(self.apiclient)
        volumes = Volume.list(self.apiclient, id=volume.id, zoneid=self.zone.id, listall=True)
        validationresult = validateList(volumes)
        assert validationresult[0] == PASS, "volumes list validation failed: %s" % validationresult[2]
        assert str(volumes[0].state).lower() == "uploaded", (
            "Volume state should be 'uploaded' but it is %s" % volumes[0].state
        )

        # verify that the resource count didnt change due to upload volume
        response = matchResourceCount(
            self.apiclient, self.initialResourceCount, RESOURCE_PRIMARY_STORAGE, accountid=self.account.id
        )
        self.assertEqual(response[0], PASS, response[1])

        # attach the above volume to the vm
        try:
            self.virtualMachine.attach_volume(self.apiclient, volume=volume)
        except Exception as e:
            if (
                "Maximum number of resources of type 'primary_storage' for account name=" + self.account.name
                in e.message
            ):
                self.assertTrue(True, "there should be primary store resource limit reached exception")
            else:
                self.fail(
                    "only resource limit reached exception is expected. some other exception occurred. Failing the test case."
                )

        # resource count should match as the attach should fail due to reaching resource limits
        response = matchResourceCount(
            self.apiclient, self.initialResourceCount, RESOURCE_PRIMARY_STORAGE, accountid=self.account.id
        )
        self.assertEqual(response[0], PASS, response[1])

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


示例2: test_01_VM_start_stop

    def test_01_VM_start_stop(self):
        """Test project primary storage count with VM stop/start operation

        # Validate the following
        # 1. Create VM with custom disk offering in a project and check
        #    initial primary storage count
        # 2. Stop the VM and verify primary storage count remains the same
        # 3. Start the VM and verify priamay storage count remains the same
        """

        try:
            self.vm.stop(self.apiclient)
        except Exception as e:
            self.fail("Faield to stop VM: %s" % e)

        expectedCount = self.initialResourceCount
        response = matchResourceCount(
                        self.apiclient, expectedCount,
                        RESOURCE_PRIMARY_STORAGE,
                        projectid=self.project.id)
        self.assertEqual(response[0], PASS, response[1])

        try:
            self.vm.start(self.apiclient)
        except Exception as e:
            self.fail("Failed to start VM: %s" % e)

        response = matchResourceCount(
                        self.apiclient, expectedCount,
                        RESOURCE_PRIMARY_STORAGE,
                        projectid=self.project.id)
        self.assertEqual(response[0], PASS, response[1])
        return
开发者ID:aali-dincloud,项目名称:cloudstack,代码行数:33,代码来源:test_ps_project_limits.py


示例3: test_destroy_recover_vm

    def test_destroy_recover_vm(self, value):
        """Test delete and recover instance

        # Validate the following
        # 1. Create a VM with custom disk offering and check the primary storage count
        # 2. Destroy VM and verify the resource count remains same
        # 3. Recover VM and verify resource count remains same"""

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

        expectedCount = self.initialResourceCount
        # Stopping instance
        try:
            self.virtualMachine.delete(self.apiclient, expunge=False)
        except Exception as e:
            self.fail("Failed to destroy instance: %s" % e)
        response = matchResourceCount(
                        self.apiclient, expectedCount,
                        RESOURCE_PRIMARY_STORAGE,
                        accountid=self.account.id)
        self.assertEqual(response[0], PASS, response[1])

        # Recovering instance
        try:
            self.virtualMachine.recover(self.apiclient)
        except Exception as e:
            self.fail("Failed to start instance: %s" % e)

        response = matchResourceCount(
                        self.apiclient, expectedCount,
                        RESOURCE_PRIMARY_STORAGE,
                        accountid=self.account.id)
        self.assertEqual(response[0], PASS, response[1])
        return
开发者ID:Accelerite,项目名称:cloudstack,代码行数:35,代码来源:test_ps_limits.py


示例4: test_stop_start_vm

    def test_stop_start_vm(self, value):
        """Test Deploy VM with 5 GB volume & verify the usage

        # Validate the following
        # 1. Create a VM with custom disk offering and check the primary storage count
        # 2. Stop VM and verify the resource count remains same
        # 3. Start VM and verify resource count remains same"""

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

        expectedCount = self.initialResourceCount
        # Stopping instance
        try:
            self.virtualMachine.stop(self.apiclient)
        except Exception as e:
            self.fail("Failed to stop instance: %s" % e)
        response = matchResourceCount(
                        self.apiclient, expectedCount,
                        RESOURCE_PRIMARY_STORAGE,
                        accountid=self.account.id)
        self.assertEqual(response[0], PASS, response[1])

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

        response = matchResourceCount(
                        self.apiclient, expectedCount,
                        RESOURCE_PRIMARY_STORAGE,
                        accountid=self.account.id)
        self.assertEqual(response[0], PASS, response[1])
        return
开发者ID:Accelerite,项目名称:cloudstack,代码行数:35,代码来源:test_ps_limits.py


示例5: test_03_register_iso

    def test_03_register_iso(self, value):
        """Test register iso
        Steps and validations:
        1. Create a root domain/child domain admin account
        2. Register a test iso in the account
        3. Wait till the iso is downloaded and is in ready state
        3. Verify that secondary storage resource count of the account equals the
           iso size
        4. Delete the iso
        5. Verify that the secondary storage count of the account equals 0
        """
        response = self.setupAccount(value)
        self.assertEqual(response[0], PASS, response[1])

        self.services["iso"]["zoneid"] = self.zone.id
        try:
            iso = Iso.create(
                         self.apiclient,
                         self.services["iso"],
                         account=self.account.name,
                         domainid=self.account.domainid
                         )
        except Exception as e:
            self.fail("Failed to create Iso: %s" % e)

        timeout = 600
        isoList = None
        while timeout >= 0:
            isoList = Iso.list(self.apiclient,
                                      isofilter="self",
                                      id=iso.id)
            self.assertEqual(validateList(isoList)[0],PASS,\
                            "iso list validation failed")
            if isoList[0].isready:
                break
            time.sleep(60)
            timeout -= 60

        self.assertNotEqual(timeout, 0,\
                "template not downloaded completely")

        isoSize = (isoList[0].size / (1024**3))
        expectedCount = isoSize
        response = matchResourceCount(self.apiclient, expectedCount,
                                      resourceType=RESOURCE_SECONDARY_STORAGE,
                                      accountid=self.account.id)
        self.assertEqual(response[0], PASS, response[1])

        try:
            iso.delete(self.apiclient)
        except Exception as e:
            self.fail("Failed to delete Iso")

        expectedCount = 0
        response = matchResourceCount(self.apiclient, expectedCount,
                                      resourceType=RESOURCE_SECONDARY_STORAGE,
                                      accountid=self.account.id)
        self.assertEqual(response[0], PASS, response[1])
        return
开发者ID:Accelerite,项目名称:cloudstack,代码行数:59,代码来源:test_ss_limits.py


示例6: test_01_register_template

    def test_01_register_template(self, value):
        """Test register template
        # Validate the following:
        1. Create a root domain admin/ child domain admin account
        2. Register and download a template according to hypervisor type
        3. Verify that the template is listed
        4. Verify that the secondary storage count for the account equals the size
           of the template
        5. Delete the template
        6. Verify that the secondary storage resource count of the account equals 0
       """
        response = self.setupAccount(value)
        self.assertEqual(response[0], PASS, response[1])

        builtin_info = get_builtin_template_info(self.apiclient, self.zone.id)
        self.services["template_2"]["url"] = builtin_info[0]
        self.services["template_2"]["hypervisor"] = builtin_info[1]
        self.services["template_2"]["format"] = builtin_info[2]

        try:
            template = Template.register(self.apiclient,
                                     self.services["template_2"],
                                     zoneid=self.zone.id,
                                     account=self.account.name,
                                     domainid=self.account.domainid,
                                     hypervisor=self.hypervisor)

            template.download(self.apiclient)
        except Exception as e:
            self.fail("Failed to register template: %s" % e)

        templates = Template.list(self.apiclient,
                                      templatefilter=\
                                      self.services["template_2"]["templatefilter"],
                                      id=template.id)
        self.assertEqual(validateList(templates)[0],PASS,\
                        "templates list validation failed")

        templateSize = (templates[0].size / (1024**3))
        expectedCount = templateSize
        response = matchResourceCount(
                        self.apiclient, expectedCount,
                        RESOURCE_SECONDARY_STORAGE,
                        accountid=self.account.id)
        self.assertEqual(response[0], PASS, response[1])

        try:
            template.delete(self.apiclient)
        except Exception as e:
            self.fail("Failed to delete template: %s" % e)

        expectedCount = 0
        response = matchResourceCount(
                        self.apiclient, expectedCount,
                        RESOURCE_SECONDARY_STORAGE,
                        accountid=self.account.id)
        self.assertEqual(response[0], PASS, response[1])
        return
开发者ID:Skotha,项目名称:cloudstack,代码行数:58,代码来源:test_ss_limits.py


示例7: test_deploy_multiple_vm

    def test_deploy_multiple_vm(self, value):
        """Test Deploy multiple VMs with & verify the usage
        # Validate the following
        # 1. Deploy multiple VMs with this service offering
        # 2. Update Resource count for the root admin Primary Storage usage
        # 3. Primary Storage usage should list properly
        # 4. Destroy one VM among multiple VM's and verify that primary storage count
        #  decreases by equivalent amount
        """

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

        self.virtualMachine_2 = 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)

        expectedCount = (self.initialResourceCount * 2) #Total 2 vms
        response = matchResourceCount(
                        self.apiclient, expectedCount,
                        RESOURCE_PRIMARY_STORAGE,
                        accountid=self.account.id)
        self.assertEqual(response[0], PASS, response[1])

        self.virtualMachine_3 = 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)

        expectedCount = (self.initialResourceCount * 3) #Total 3 vms
        response = matchResourceCount(
                        self.apiclient, expectedCount,
                        RESOURCE_PRIMARY_STORAGE,
                        accountid=self.account.id)
        self.assertEqual(response[0], PASS, response[1])

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

        self.assertTrue(isVmExpunged(self.apiclient, self.virtualMachine_2.id), "VM not expunged \
                in allotted time")

        expectedCount -= (self.template.size / (1024 ** 3))
        response = matchResourceCount(
                        self.apiclient, expectedCount,
                        RESOURCE_PRIMARY_STORAGE,
                        accountid=self.account.id)
        self.assertEqual(response[0], PASS, response[1])
	return
开发者ID:Accelerite,项目名称:cloudstack,代码行数:53,代码来源:test_ps_limits.py


示例8: test_assign_vm_different_account

    def test_assign_vm_different_account(self, value):
        """Test assign Vm to different account
        # Validate the following
        # 1. Deploy VM in account and check the primary storage resource count
        # 2. Assign VM to another account
        # 3. Resource count for first account should now equal to 0
        # 4. Resource count for the account to which VM is assigned should
        #    increase to that of initial resource count of first account
        """

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

        try:
            account_2 = Account.create(self.apiclient, self.services["account"],
                                   domainid=self.domain.id, admin=True)
            self.cleanup.insert(0, account_2)
        except Exception as e:
            self.fail("Failed to create account: %s" % e)

        expectedCount = self.initialResourceCount
        response = matchResourceCount(
                        self.apiclient, expectedCount,
                        RESOURCE_PRIMARY_STORAGE,
                        accountid=self.account.id)
        self.assertEqual(response[0], PASS, response[1])

        try:
            self.virtualMachine.stop(self.apiclient)
    	    self.virtualMachine.assign_virtual_machine(self.apiclient,
                    account_2.name ,account_2.domainid)
        except Exception as e:
            self.fail("Failed to assign virtual machine to account %s: %s" %
                    (account_2.name,e))

        # Checking resource count for account 2
        response = matchResourceCount(
                        self.apiclient, expectedCount,
                        RESOURCE_PRIMARY_STORAGE,
                        accountid=account_2.id)
        self.assertEqual(response[0], PASS, response[1])

        expectedCount = 0
        # Checking resource count for original account
        response = matchResourceCount(
                        self.apiclient, expectedCount,
                        RESOURCE_PRIMARY_STORAGE,
                        accountid=self.account.id)
        self.assertEqual(response[0], PASS, response[1])
	return
开发者ID:Accelerite,项目名称:cloudstack,代码行数:50,代码来源:test_ps_limits.py


示例9: test_03_delete_vm

    def test_03_delete_vm(self):
        """Test delete VM belonging to project

        # Validate the following
        # 1. Create VM with custom disk offering in a project and check
        #    initial primary storage count
        # 2. Delete VM and verify that it's expunged
        # 3. Verify that primary storage count of project equals 0"""

        try:
            self.vm.delete(self.apiclient)
        except Exception as e:
            self.fail("Failed to detroy VM: %s" % e)

        self.assertTrue(isVmExpunged(self.apiclient, self.vm.id, self.project.id),\
                "VM not expunged")

        totalallottedtime = timeout = 600
        while timeout >= 0:
            volumes = Volume.list(self.apiclient, projectid=self.project.id, listall=True)
            if volumes is None:
                break
            if timeout == 0:
                self.fail("Volume attached to VM not cleaned up even\
                        after %s seconds" % totalallottedtime)
            timeout -= 60
            time.sleep(60)

        expectedCount = 0
        response = matchResourceCount(
                        self.apiclient, expectedCount,
                        RESOURCE_PRIMARY_STORAGE,
                        projectid=self.project.id)
        self.assertEqual(response[0], PASS, response[1])
        return
开发者ID:aali-dincloud,项目名称:cloudstack,代码行数:35,代码来源:test_ps_project_limits.py


示例10: test_02_migrate_vm

    def test_02_migrate_vm(self):
        """Test migrate VM in project

        # Validate the following
        # 1. Create VM with custom disk offering in a project and check
        #    initial primary storage count
        # 2. List the hosts suitable for migrating the VM
        # 3. Migrate the VM and verify that primary storage count of project remains same"""

        try:
            hosts = Host.list(self.apiclient,virtualmachineid=self.vm.id,
                              listall=True)
            self.assertEqual(validateList(hosts)[0], PASS, "hosts list validation failed")
            host = hosts[0]
            self.vm.migrate(self.apiclient, host.id)
        except Exception as e:
            self.fail("Exception occured" % e)

        expectedCount = self.initialResourceCount
        response = matchResourceCount(
                        self.apiclient, expectedCount,
                        RESOURCE_PRIMARY_STORAGE,
                        projectid=self.project.id)
        self.assertEqual(response[0], PASS, response[1])
        return
开发者ID:aali-dincloud,项目名称:cloudstack,代码行数:25,代码来源:test_ps_project_limits.py


示例11: test_02_deploy_vm_account_limit_reached

    def test_02_deploy_vm_account_limit_reached(self):
        """Test Try to deploy VM with admin account where account has used
            the resources but @ domain they are available

        # Validate the following
        # 1. Try to register template with admin account where account has used the
        #    resources but @ domain they are available
        # 2. Template registration should fail"""

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

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

        expectedCount = self.templateSize
        response = matchResourceCount(
                        self.apiclient, expectedCount,
                        RESOURCE_SECONDARY_STORAGE,
                        accountid=self.child_do_admin.id)
        self.assertEqual(response[0], PASS, response[1])

        accountLimit = self.templateSize

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

        with self.assertRaises(Exception):
            template = Template.register(self.apiclient,
                                     self.services["template_2"],
                                     zoneid=self.zone.id,
                                     account=self.child_do_admin.name,
                                     domainid=self.child_do_admin.domainid)
        return
开发者ID:Skotha,项目名称:cloudstack,代码行数:34,代码来源:test_ss_max_limits.py


示例12: test_02_create_template_snapshot

    def test_02_create_template_snapshot(self, value):
        """Test create snapshot and templates from volume

        # Validate the following
        1. Create root domain/child domain admin account
        2. Deploy VM in the account
        3. Create snapshot from the virtual machine root volume
        4. Create template from the snapshot
        5. Verify that the secondary storage count of the account equals
           the size of the template"""

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

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

        self.assertNotEqual(self.virtualMachine, FAILED, "VM deployment failed")

        apiclient = self.testClient.getUserApiClient(UserName=self.account.name, DomainName=self.account.domain)
        self.assertNotEqual(apiclient, FAILED, "Failed to create api client for account: %s" % self.account.name)

        try:
            self.virtualMachine.stop(apiclient)
        except Exception as e:
            self.fail("Failed to stop instance: %s" % e)

        self.debug("Creating snapshot from ROOT volume: %s" % self.virtualMachine.name)
        response = createSnapshotFromVirtualMachineVolume(apiclient, self.account, self.virtualMachine.id)
        self.assertEqual(response[0], PASS, response[1])
        snapshot = response[1]

        snapshotSize = snapshot.physicalsize / (1024 ** 3)

        try:
            template = Template.create_from_snapshot(apiclient, snapshot=snapshot, services=self.services["template_2"])
        except Exception as e:
            self.fail("Failed to create template: %s" % e)

        templates = Template.list(
            apiclient, templatefilter=self.services["template_2"]["templatefilter"], id=template.id
        )
        self.assertEqual(validateList(templates)[0], PASS, "templates list validation failed")

        templateSize = templates[0].size / (1024 ** 3)

        expectedSecondaryStorageCount = int(templateSize + snapshotSize)
        response = matchResourceCount(
            self.apiclient,
            expectedSecondaryStorageCount,
            resourceType=RESOURCE_SECONDARY_STORAGE,
            accountid=self.account.id,
        )
        self.assertEqual(response[0], PASS, response[1])
        return
开发者ID:MissionCriticalCloudOldRepos,项目名称:cosmic-core,代码行数:60,代码来源:test_ss_limits.py


示例13: test_02_increase_volume_size_above_account_limit

    def test_02_increase_volume_size_above_account_limit(self):
	"""Test increasing volume size above the account limit

        # Validate the following
        # 1. Create a domain and its admin account
        # 2. Set account primary storage limit more than (5 GB volume + template size of VM)
        #    and less than (20 GB volume+ template size of VM)
        # 3. Deploy a VM without any disk offering (only root disk)
        # 4. Create a volume of 5 GB in the account and attach it to the VM
        # 5. Try to (resize) the volume to 20 GB
        # 6. Resize opearation should fail"""

        # Setting up account and domain hierarchy
        result = self.setupAccounts()
        self.assertEqual(result[0], PASS, result[1])

        templateSize = (self.template.size / (1024**3))
        accountLimit = ((templateSize + self.disk_offering_20_GB.disksize) - 1)
        response = self.updateResourceLimits(accountLimit=accountLimit)
        self.assertEqual(response[0], PASS, response[1])

        apiclient = self.testClient.getUserApiClient(
                        UserName=self.parentd_admin.name,
                        DomainName=self.parentd_admin.domain)
        self.assertNotEqual(apiclient, FAILED, "Failed to get api client\
                            of account: %s" % self.parentd_admin.name)

        try:
            virtualMachine = VirtualMachine.create(
                    apiclient, self.services["virtual_machine"],
                    accountid=self.parentd_admin.name, domainid=self.parent_domain.id,
                    serviceofferingid=self.service_offering.id
                    )

            volume = Volume.create(
                    apiclient,self.services["volume"],zoneid=self.zone.id,
                    account=self.parentd_admin.name,domainid=self.parent_domain.id,
                    diskofferingid=self.disk_offering_5_GB.id)

            virtualMachine.attach_volume(apiclient, volume=volume)

            expectedCount = (templateSize + self.disk_offering_5_GB.disksize)
            response = matchResourceCount(
                        self.apiclient, expectedCount,
                        RESOURCE_PRIMARY_STORAGE,
                        accountid=self.parentd_admin.id)
            if response[0] == FAIL:
                raise Exception(response[1])
        except Exception as e:
            self.fail("Failed with exception: %s" % e)

        if self.hypervisor == str(XEN_SERVER).lower():
            virtualMachine.stop(self.apiclient)
        with self.assertRaises(Exception):
            volume.resize(apiclient, diskofferingid=self.disk_offering_20_GB.id)
        return
开发者ID:Skotha,项目名称:cloudstack,代码行数:56,代码来源:test_ps_resize_volume.py


示例14: test_04_copy_template

    def test_04_copy_template(self, value):
        """Test copy template between zones

        Steps and validations:
        This test requires at least two zones present in the setup
        1. Create a root domain/child domain admin account
        2. Register and download a template in the account
        3. Verify the secondary storage resource count of the account
           equals the size of the template
        4. Copy this template to other zone
        5. Verify that the secondary storage resource count is now doubled
           as there are two templates now in two zones under the admin account
        """

        zones = list_zones(self.apiclient)
        self.assertEqual(validateList(zones)[0], PASS, "zones list validation faield")

        if len(zones) < 2:
            self.skipTest("At least 2 zones should be present for this test case")

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

        builtin_info = get_builtin_template_info(self.apiclient, self.zone.id)
        self.services["template_2"]["url"] = builtin_info[0]
        self.services["template_2"]["hypervisor"] = builtin_info[1]
        self.services["template_2"]["format"] = builtin_info[2]

        try:
            template = Template.register(
                self.apiclient,
                self.services["template_2"],
                zoneid=self.zone.id,
                account=self.account.name,
                domainid=self.account.domainid,
                hypervisor=self.hypervisor,
            )

            template.download(self.apiclient)
        except Exception as e:
            self.fail("Failed to register template: %s" % e)

        templates = Template.list(
            self.apiclient, templatefilter=self.services["template_2"]["templatefilter"], id=template.id
        )
        self.assertEqual(validateList(templates)[0], PASS, "templates list validation failed")

        templateSize = templates[0].size / (1024 ** 3)
        expectedCount = templateSize
        response = matchResourceCount(
            self.apiclient, expectedCount, RESOURCE_SECONDARY_STORAGE, accountid=self.account.id
        )
        self.assertEqual(response[0], PASS, response[1])

        templateDestinationZoneId = None
        for zone in zones:
            if template.zoneid != zone.id:
                templateDestinationZoneId = zone.id
                break

        template.copy(self.apiclient, destzoneid=templateDestinationZoneId, sourcezoneid=template.zoneid)

        expectedCount = templateSize * 2
        response = matchResourceCount(
            self.apiclient, expectedCount, RESOURCE_SECONDARY_STORAGE, accountid=self.account.id
        )
        self.assertEqual(response[0], PASS, response[1])
        return
开发者ID:MissionCriticalCloudOldRepos,项目名称:cosmic-core,代码行数:68,代码来源:test_ss_limits.py


示例15: test_create_template_snapshot

    def test_create_template_snapshot(self, value):
        """Test create snapshot and templates from volume

        # Validate the following
        # 1. Deploy VM with custoom disk offering and check the
        #    primary storage resource count
        # 2. Stop the VM and create Snapshot from VM's volume
        # 3. Create volume againt from this snapshto and attach to VM
        # 4. Verify that primary storage count increases by the volume size
        # 5. Detach and delete volume, verify primary storage count decreaes by volume size"""
        if self.hypervisor.lower() in ['hyperv']:
            self.skipTest("Snapshots feature is not supported on Hyper-V")
        response = self.setupAccount(value)
        self.debug(response[0])
        self.debug(response[1])
        self.assertEqual(response[0], PASS, response[1])

        apiclient = self.apiclient
        if value == CHILD_DOMAIN_ADMIN:
            apiclient = self.testClient.getUserApiClient(
                                        UserName=self.account.name,
                                        DomainName=self.account.domain
                                        )
            self.assertNotEqual(apiclient, FAIL, "Failure while getting api\
                    client of account: %s" % self.account.name)

        try:
            self.virtualMachine.stop(apiclient)
        except Exception as e:
            self.fail("Failed to stop instance: %s" % e)
        expectedCount = self.initialResourceCount
        response = matchResourceCount(
                        self.apiclient, expectedCount,
                        RESOURCE_PRIMARY_STORAGE,
                        accountid=self.account.id)
        self.assertEqual(response[0], PASS, response[1])

        self.debug("Creating snapshot from ROOT volume: %s" % self.virtualMachine.name)
        snapshot = None
        response = createSnapshotFromVirtualMachineVolume(apiclient, self.account, self.virtualMachine.id)
        self.assertEqual(response[0], PASS, response[1])
        snapshot = response[1]
        response = matchResourceCount(
                        self.apiclient, expectedCount,
                        RESOURCE_PRIMARY_STORAGE,
                        accountid=self.account.id)
        self.assertEqual(response[0], PASS, response[1])

        try:
            self.services["volume"]["size"] = self.services["disk_offering"]["disksize"]
            volume = Volume.create_from_snapshot(apiclient,
                                        snapshot_id=snapshot.id,
                                        services=self.services["volume"],
                                        account=self.account.name,
                                        domainid=self.account.domainid)

            self.debug("Attaching the volume to vm: %s" % self.virtualMachine.name)
            self.virtualMachine.attach_volume(apiclient, volume)
        except Exception as e:
            self.fail("Failure in volume operation: %s" % e)

        expectedCount += int(self.services["volume"]["size"])
        response = matchResourceCount(
                        self.apiclient, expectedCount,
                        RESOURCE_PRIMARY_STORAGE,
                        accountid=self.account.id)
        self.assertEqual(response[0], PASS, response[1])

        try:
            self.virtualMachine.detach_volume(apiclient, volume)
        except Exception as e:
            self.fail("Failure in detach volume operation: %s" % e)

        try:
            self.debug("deleting the volume: %s" % volume.name)
            volume.delete(apiclient)
        except Exception as e:
            self.fail("Failure while deleting volume: %s" % e)

        expectedCount -= int(self.services["volume"]["size"])
        response = matchResourceCount(
                        self.apiclient, expectedCount,
                        RESOURCE_PRIMARY_STORAGE,
                        accountid=self.account.id)
        self.assertEqual(response[0], PASS, response[1])
        return
开发者ID:Accelerite,项目名称:cloudstack,代码行数:86,代码来源:test_ps_limits.py


示例16: test_00_deploy_vm_root_resize

    def test_00_deploy_vm_root_resize(self):
        """Test deploy virtual machine with root resize

        # Validate the following:
        # 1. listVirtualMachines returns accurate information
        # 2. root disk has new size per listVolumes
        # 3. Rejects non-supported hypervisor types
        """

        newrootsize = (self.template.size >> 30) + 2
        if (self.hypervisor.lower() == 'kvm' or self.hypervisor.lower() == 'xenserver'
                or self.hypervisor.lower() == 'vmware' or self.hypervisor.lower() == 'simulator'):

            accounts = Account.list(self.apiclient, id=self.account.id)
            self.assertEqual(validateList(accounts)[0], PASS,
                            "accounts list validation failed")
            initialResourceCount = int(accounts[0].primarystoragetotal)

            if self.hypervisor=="vmware":
                self.virtual_machine = VirtualMachine.create(
                    self.apiclient, self.services["virtual_machine"],
                    zoneid=self.zone.id,
                    accountid=self.account.name,
                    domainid=self.domain.id,
                    serviceofferingid=self.services_offering_vmware.id,
                    templateid=self.template.id,
                    rootdisksize=newrootsize
                )
            else:
                self.virtual_machine = VirtualMachine.create(
                    self.apiclient, self.services["virtual_machine"],
                    zoneid=self.zone.id,
                    accountid=self.account.name,
                    domainid=self.domain.id,
                    serviceofferingid=self.service_offering.id,
                    templateid=self.template.id,
                    rootdisksize=newrootsize
                )

            list_vms = VirtualMachine.list(self.apiclient, id=self.virtual_machine.id)
            self.debug(
                "Verify listVirtualMachines response for virtual machine: %s" \
                % self.virtual_machine.id
            )

            res=validateList(list_vms)
            self.assertNotEqual(res[2], INVALID_INPUT, "Invalid list VM "
                                                        "response")
            self.cleanup.append(self.virtual_machine)

            vm = list_vms[0]
            self.assertEqual(
                vm.id,
                self.virtual_machine.id,
                "Virtual Machine ids do not match"
            )
            self.assertEqual(
                vm.name,
                self.virtual_machine.name,
                "Virtual Machine names do not match"
            )
            self.assertEqual(
                vm.state,
                "Running",
                msg="VM is not in Running state"
            )

            # get root vol from created vm, verify it is correct size
            list_volume_response = list_volumes(
                self.apiclient,
                virtualmachineid=self.virtual_machine.id,
                type='ROOT',
                listall=True
            )
            res=validateList(list_volume_response)
            self.assertNotEqual(res[2], INVALID_INPUT, "Invalid list VM "
                                                        "response")
            rootvolume = list_volume_response[0]
            success = False
            if rootvolume is not None and rootvolume.size  == (newrootsize << 30):
                success = True

            self.assertEqual(
                success,
                True,
                "Check if the root volume resized appropriately"
            )

            response = matchResourceCount(
                self.apiclient, (initialResourceCount + newrootsize),
                RESOURCE_PRIMARY_STORAGE,
                accountid=self.account.id)
            self.assertEqual(response[0], PASS, response[1])
        else:
            self.debug("hypervisor %s unsupported for test 00, verifying it errors properly" % self.hypervisor)
            newrootsize = (self.template.size >> 30) + 2
            success = False
            try:
                self.virtual_machine = VirtualMachine.create(
                    self.apiclient,
#.........这里部分代码省略.........
开发者ID:PCextreme,项目名称:cloudstack,代码行数:101,代码来源:test_deploy_vm_root_resize.py


示例17: test_create_multiple_volumes

    def test_create_multiple_volumes(self, value):
        """Test create multiple volumes

        # Validate the following
        # 1. Create a VM with custom disk offering and check the primary storage count
        #    of account
        # 2. Create multiple volumes in account
        # 3. Verify that primary storage count increases by same amount
        # 4. Attach volumes to VM and verify resource count remains the same
        # 5. Detach and delete both volumes one by one and verify resource count decreases
        #    proportionately"""

        # Creating service offering with 10 GB volume

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

        apiclient = self.apiclient
        if value == CHILD_DOMAIN_ADMIN:
            apiclient = self.testClient.getUserApiClient(
                                        UserName=self.account.name,
                                        DomainName=self.account.domain
                                        )
            self.assertNotEqual(apiclient, FAIL, "Failure while getting\
                                api client of account %s" % self.account.name)

        try:
            self.services["disk_offering"]["disksize"] = 5
            disk_offering_5_GB = DiskOffering.create(self.apiclient,
                                    services=self.services["disk_offering"])
            self.cleanup.append(disk_offering_5_GB)

            self.services["disk_offering"]["disksize"] = 10
            disk_offering_10_GB = DiskOffering.create(self.apiclient,
                                    services=self.services["disk_offering"])

            self.cleanup.append(disk_offering_10_GB)

            volume_1 = Volume.create(
                    apiclient,self.services["volume"],zoneid=self.zone.id,
     

鲜花

握手

雷人

路过

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

请发表评论

全部评论

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