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


Python DiskOffering.list方法代码示例

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


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

示例1: test_02_list_all_diskofferings_with_noparams

# 需要导入模块: from marvin.lib.base import DiskOffering [as 别名]
# 或者: from marvin.lib.base.DiskOffering import list [as 别名]
    def test_02_list_all_diskofferings_with_noparams(self):
        """
        Test List Disk Offerings with No Parameters
        """

        diskofferingvailable=0
        listdiskofferings=DiskOffering.list(self.user_api_client)

        self.assertEqual(
                            isinstance(listdiskofferings, list),
                            True,
                            "Check list Disk Offerings response returns a valid list"
                        )

        for diskoffering1 in listdiskofferings:
            if diskoffering1.name=="Small":
                diskofferingvailable=diskofferingvailable+1
            elif diskoffering1.name=="Medium":
                diskofferingvailable=diskofferingvailable+1
            elif diskoffering1.name=="Large":
                diskofferingvailable=diskofferingvailable+1
            elif diskoffering1.name=="Custom":
                diskofferingvailable=diskofferingvailable+1

        if diskofferingvailable<4:
            self.fail("All the default disk offerings are not listed")
开发者ID:EdwardBetts,项目名称:blackhole,代码行数:28,代码来源:test_interop_xd_ccp.py

示例2: test_create_volume_under_domain

# 需要导入模块: from marvin.lib.base import DiskOffering [as 别名]
# 或者: from marvin.lib.base.DiskOffering import list [as 别名]
    def test_create_volume_under_domain(self):
        """Create a volume under a non-root domain as non-root-domain user

        1. Create a domain under ROOT
        2. Create a user within this domain
        3. As user in step 2. create a volume with standard disk offering
        4. Ensure the volume is created in the domain and available to the
           user in his listVolumes call
        """
        dom = Domain.create(self.apiclient, services={}, name="NROOT", parentdomainid=self.domain.id)
        self.cleanup.append(dom)
        self.assertTrue(dom is not None, msg="Domain creation failed")

        domuser = Account.create(
            apiclient=self.apiclient, services=self.services["account"], admin=False, domainid=dom.id
        )
        self.cleanup.insert(-2, domuser)
        self.assertTrue(domuser is not None)

        domapiclient = self.testClient.getUserApiClient(UserName=domuser.name, DomainName=dom.name)

        diskoffering = DiskOffering.list(self.apiclient)
        self.assertTrue(isinstance(diskoffering, list), msg="DiskOffering list is not a list?")
        self.assertTrue(len(diskoffering) > 0, "no disk offerings in the deployment")

        vol = Volume.create(
            domapiclient,
            services=self.services["volume"],
            zoneid=self.zone.id,
            account=domuser.name,
            domainid=dom.id,
            diskofferingid=diskoffering[0].id,
        )
        self.assertTrue(vol is not None, "volume creation fails in domain %s as user %s" % (dom.name, domuser.name))

        listed_vol = Volume.list(domapiclient, id=vol.id)
        self.assertTrue(
            listed_vol is not None and isinstance(listed_vol, list),
            "invalid response from listVolumes for volume %s" % vol.id,
        )
        self.assertTrue(
            listed_vol[0].id == vol.id,
            "Volume returned by list volumes %s not matching with queried\
                    volume %s in domain %s"
            % (listed_vol[0].id, vol.id, dom.name),
        )
开发者ID:bheuvel,项目名称:cloudstack,代码行数:48,代码来源:test_volumes.py

示例3: test_15_restore_vm_with_template_id

# 需要导入模块: from marvin.lib.base import DiskOffering [as 别名]
# 或者: from marvin.lib.base.DiskOffering import list [as 别名]
    def test_15_restore_vm_with_template_id(self):

        """
        Test restoring Virtual Machine with template id
        """

        noffering=NetworkOffering.list(
                     self.user_api_client,
                     name="DefaultIsolatedNetworkOfferingWithSourceNatService"
                     )
        vm1network=Network.create(
                                 self.user_api_client,
                                self.services["network"],
                                accountid=self.account.name,
                                domainid=self.account.domainid,
                                networkofferingid=noffering[0].id,
                                zoneid=self.zone.id
                                 )

        list_nw_response = Network.list(
                                            self.user_api_client,
                                            id=vm1network.id
                                            )
        self.assertEqual(
                            isinstance(list_nw_response, list),
                            True,
                            "Check list response returns a valid networks list"
                        )

        restorevm = VirtualMachine.create(
            self.user_api_client,
            self.services["small"],
            networkids=vm1network.id,
            accountid=self.account.name,
            domainid=self.account.domainid,
            serviceofferingid=self.service_offering.id,
            mode=self.services['mode'],
            startvm="true"
        )


        time.sleep(600)

        list_vm_response = VirtualMachine.list(
                                            self.user_api_client,
                                            id=restorevm.id
                                            )
        self.assertEqual(
                            list_vm_response[0].state,
                            "Running",
                            "Check virtual machine is in running state"
                        )


        custom_disk_offering=DiskOffering.list(
                                self.user_api_client,
                                 name="custom"
                                 )

        newvolume = Volume.create(
            self.user_api_client,
            self.services["volume"],
            zoneid=self.zone.id,
            account=self.account.name,
            domainid=self.domain.id,
            diskofferingid=custom_disk_offering[0].id,
            size=1
        )

                # Attach volume to VM
        cmd = attachVolume.attachVolumeCmd()
        cmd.id = newvolume.id
        cmd.virtualmachineid = restorevm.id
        cmd.deviceid=1
        vol1=self.user_api_client.attachVolume(cmd)

        cmd = restoreVirtualMachine.restoreVirtualMachineCmd()
        cmd.virtualmachineid = restorevm.id
        cmd.templateid = self.xtemplate.id
        self.user_api_client.restoreVirtualMachine(cmd)

        time.sleep(600)

        list_vm_response = VirtualMachine.list(
                                            self.user_api_client,
                                            id=restorevm.id
                                            )
        self.assertEqual(
                            isinstance(list_vm_response, list),
                            True,
                            "Check list response returns a valid list"
                        )

        self.assertNotEqual(
                            len(list_vm_response),
                            0,
                            "Check VM available in List Virtual Machines"
                        )

        self.assertEqual(
#.........这里部分代码省略.........
开发者ID:EdwardBetts,项目名称:blackhole,代码行数:103,代码来源:test_interop_xd_ccp.py

示例4: test_06_attachvolume_to_a_stopped_vm

# 需要导入模块: from marvin.lib.base import DiskOffering [as 别名]
# 或者: from marvin.lib.base.DiskOffering import list [as 别名]
    def test_06_attachvolume_to_a_stopped_vm(self):
        """
        Test Attach Volume To A Stopped VM
        """

        list_vm_response = VirtualMachine.list(
                                                 self.user_api_client,
                                                 id=self.virtual_machine.id
                                                 )

        self.assertEqual(
            list_vm_response[0].state,
            'Stopped',
             msg="Check if VM is in Stopped state"
        )
        custom_disk_offering=DiskOffering.list(
                                self.user_api_client,
                                 name="custom"
                                 )

        self.__class__.volume = Volume.create(
            self.user_api_client,
            self.services["volume"],
            zoneid=self.zone.id,
            account=self.account.name,
            domainid=self.account.domainid,
            diskofferingid=custom_disk_offering[0].id,
            size=1
        )

                # Check List Volume response for newly created volume
        list_volume_response = Volume.list(
                    self.user_api_client,
                    id=self.volume.id
                )
        self.assertNotEqual(
                    list_volume_response,
                    None,
                    "Check if volume exists in ListVolumes"
                )

                # Attach volume to VM
        cmd = attachVolume.attachVolumeCmd()
        cmd.id = self.volume.id
        cmd.virtualmachineid = self.virtual_machine.id
        cmd.deviceid=1
        vol1=self.user_api_client.attachVolume(cmd)

            # Check all volumes attached to same VM
        list_volume_response = Volume.list(
                self.user_api_client,
                virtualmachineid=self.virtual_machine.id,
                type='DATADISK',
                listall=True
            )
        self.assertNotEqual(
                list_volume_response,
                None,
                "Check if volume exists in ListVolumes")
        self.assertEqual(
                isinstance(list_volume_response, list),
                True,
                "Check list volumes response for valid list")

        self.assertEqual(
                list_volume_response[0].deviceid,
                1,
                "Check listed volume device id is 1")

        return
开发者ID:EdwardBetts,项目名称:blackhole,代码行数:72,代码来源:test_interop_xd_ccp.py


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