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


Python StoragePool.listForMigration方法代码示例

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


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

示例1: test_01_migrateVolume

# 需要导入模块: from marvin.lib.base import StoragePool [as 别名]
# 或者: from marvin.lib.base.StoragePool import listForMigration [as 别名]
 def test_01_migrateVolume(self):
     """
     @Desc:Volume is not retaining same uuid when migrating from one
           storage to another.
     Step1:Create a volume/data disk
     Step2:Verify UUID of the volume
     Step3:Migrate the volume to another primary storage within
           the cluster
     Step4:Migrating volume to new primary storage should succeed
     Step5:volume UUID should not change even after migration
     """
     vol = Volume.create(
         self.apiclient,
         self.services["volume"],
         diskofferingid=self.disk_offering.id,
         zoneid=self.zone.id,
         account=self.account.name,
         domainid=self.account.domainid,
     )
     self.assertIsNotNone(vol, "Failed to create volume")
     vol_res = Volume.list(self.apiclient, id=vol.id)
     self.assertEqual(validateList(vol_res)[0], PASS, "Invalid response returned for list volumes")
     vol_uuid = vol_res[0].id
     try:
         self.virtual_machine.attach_volume(self.apiclient, vol)
     except Exception as e:
         self.fail("Attaching data disk to vm failed with error %s" % e)
     pools = StoragePool.listForMigration(self.apiclient, id=vol.id)
     if not pools:
         self.skipTest(
             "No suitable storage pools found for volume migration.\
                     Skipping"
         )
     self.assertEqual(validateList(pools)[0], PASS, "invalid pool response from findStoragePoolsForMigration")
     pool = pools[0]
     self.debug("Migrating Volume-ID: %s to Pool: %s" % (vol.id, pool.id))
     try:
         Volume.migrate(self.apiclient, volumeid=vol.id, storageid=pool.id, livemigrate="true")
     except Exception as e:
         self.fail("Volume migration failed with error %s" % e)
     migrated_vols = Volume.list(
         self.apiclient, virtualmachineid=self.virtual_machine.id, listall="true", type="DATADISK"
     )
     self.assertEqual(validateList(migrated_vols)[0], PASS, "invalid volumes response after migration")
     migrated_vol_uuid = migrated_vols[0].id
     self.assertEqual(
         vol_uuid,
         migrated_vol_uuid,
         "Volume is not retaining same uuid when migrating from one\
                 storage to another",
     )
     self.virtual_machine.detach_volume(self.apiclient, vol)
     self.cleanup.append(vol)
     return
开发者ID:bheuvel,项目名称:cloudstack,代码行数:56,代码来源:test_volumes.py

示例2: test_01_positive_test_1

# 需要导入模块: from marvin.lib.base import StoragePool [as 别名]
# 或者: from marvin.lib.base.StoragePool import listForMigration [as 别名]

#.........这里部分代码省略.........
                                            diskofferingid=self.disk_offering_1.id,
                                            zoneid=self.zone.id
                                            )
        list_volume = Volume.list(self.apiclient,
                                  id=self.migrate_volume.id
                                  )
        self.assertEqual(validateList(list_volume)[0], PASS, "Check List volume response for volume %s" % self.migrate_volume.id)
        self.assertEqual(list_volume[0].id, str(self.migrate_volume.id), "volume does not exist %s" % self.migrate_volume.id)
        self.debug("volume id %s got created successfuly" % list_volume[0].id)

        self.virtual_machine_1.attach_volume(self.userapiclient,
                                             self.migrate_volume
                                             )
        verify_attach_volume(self, self.virtual_machine_1.id, self.migrate_volume.id)

        self.virtual_machine_1.detach_volume(self.userapiclient,
                                             volume=self.migrate_volume
                                             )
        verify_detach_volume(self, self.virtual_machine_1.id, self.migrate_volume.id)

        list_volume = Volume.list(self.apiclient,
                                  id=self.migrate_volume.id
                                  )
        self.assertEqual(validateList(list_volume)[0], PASS, "Check List volume response for volume %s" % self.migrate_volume.id)
        self.assertEqual(list_volume[0].id, str(self.migrate_volume.id), "volume does not exist %s" % self.migrate_volume.id)
        self.debug("volume id %s got created successfuly" % list_volume[0].id)
        list_pool = StoragePool.list(self.apiclient,
                                     id=list_volume[0].storageid
                                     )
        self.assertEqual(validateList(list_pool)[0], PASS, "Check List pool response for storage id %s" % list_volume[0].storageid)
        self.assertGreater(len(list_pool), 0, "Check the list list storagepoolresponse for vm id:  %s" % list_volume[0].storageid)
        list_pools = StoragePool.list(self.apiclient,
                                      scope=list_pool[0].scope
                                      )
        self.assertEqual(validateList(list_pools)[0], PASS, "Check List pool response for scope %s" % list_pool[0].scope)
        self.assertGreater(len(list_pools), 0, "Check the list vm response for scope :%s" % list_volume[0].scope)
        storagepoolid = None
        for i in range(len(list_pools)):
            if list_volume[0].storageid != list_pools[i].id:
                storagepoolid = list_pools[i].id
                break
            else:
                self.debug("No pool available for volume migration ")

        if storagepoolid is not None:
            try:
                volume_migrate = Volume.migrate(self.apiclient,
                                                storageid=storagepoolid,
                                                volumeid=self.migrate_volume.id
                                                )
            except Exception as e:
                raise Exception("Volume migration failed with error %s" % e)

            self.virtual_machine_2.attach_volume(self.userapiclient,
                                                 self.migrate_volume
                                                 )
            verify_attach_volume(self, self.virtual_machine_2.id, self.migrate_volume.id)

            pool_for_migration = StoragePool.listForMigration(self.apiclient,
                                                              id=self.migrate_volume.id
                                                              )
            self.assertEqual(validateList(pool_for_migration)[0], PASS, "Check list pool For Migration response for volume %s" % self.migrate_volume.id)
            self.assertGreater(len(pool_for_migration), 0, "Check the listForMigration response for volume :%s" % self.migrate_volume.id)
            try:
                volume_migrate = Volume.migrate(self.apiclient,
                                                storageid=pool_for_migration[0].id,
                                                volumeid=self.migrate_volume.id,
                                                livemigrate=True
                                                )
            except Exception as e:
                raise Exception("Volume migration failed with error %s" % e)
        else:
            try:
                self.migrate_volume.delete(self.userapiclient
                                           )
                self.debug("volume id:%s got deleted successfully " % self.migrate_volume.id)
            except Exception as e:
                raise Exception("Volume deletion failed with error %s" % e)
        # 16.Upload volume of size smaller  than storage.max.volume.upload.size(leaving the negative case)
        self.testdata["upload_volume"]["format"] = "VHD"
        volume_upload = Volume.upload(self.userapiclient,
                                      self.testdata["upload_volume"],
                                      zoneid=self.zone.id
                                      )
        volume_upload.wait_for_upload(self.userapiclient
                                      )
        self.debug("volume id :%s got uploaded successfully is " % volume_upload.id)

        # 20.Detach data disk from vm 2 and delete the volume
        self.virtual_machine_2.detach_volume(self.userapiclient,
                                             volume=self.volume
                                             )
        verify_detach_volume(self, self.virtual_machine_2.id, self.volume.id)

        try:
            self.volume.delete(self.userapiclient
                               )
            self.debug("volume id:%s got deleted successfully " % self.volume.id)
        except Exception as e:
            raise Exception("Volume deletion failed with error %s" % e)
开发者ID:woduxi,项目名称:cloudstack,代码行数:104,代码来源:testpath_volumelifecycle.py

示例3: test_11_migrate_volume_and_change_offering

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

    # Validates the following
    #
    # 1. Creates a new Volume with a small disk offering
    #
    # 2. Migrates the Volume to another primary storage and changes the offering
    #
    # 3. Verifies the Volume has new offering when migrated to the new storage.

        small_offering = list_disk_offering(
            self.apiclient,
            name = "Small"
        )[0]

        large_offering = list_disk_offering(
            self.apiclient,
            name = "Large"
        )[0]
        volume = Volume.create(
            self.apiClient,
            self.services,
            zoneid = self.zone.id,
            account = self.account.name,
            domainid = self.account.domainid,
            diskofferingid = small_offering.id
        )
        self.debug("Created a small volume: %s" % volume.id)

        self.virtual_machine.attach_volume(self.apiclient, volume=volume)

        if self.virtual_machine.hypervisor == "KVM":
            self.virtual_machine.stop(self.apiclient)

        pools = StoragePool.listForMigration(
            self.apiclient,
            id=volume.id
            )

        pool = None

        if pools and len(pools) > 0:
            pool = pools[0]
        else:
            raise self.skipTest("Not enough storage pools found, skipping test")
        
        if hasattr(pool, 'tags'):
            StoragePool.update(self.apiclient, id=pool.id, tags="")

        self.debug("Migrating Volume-ID: %s to Pool: %s" % (volume.id, pool.id))
        Volume.migrate(
            self.apiclient,
            volumeid = volume.id,
            storageid = pool.id,
            newdiskofferingid = large_offering.id
        )
        if self.virtual_machine.hypervisor == "KVM":
            self.virtual_machine.start(self.apiclient
        )
        migrated_vol = Volume.list(
            self.apiclient,
            id = volume.id
        )[0]
        self.assertEqual(
            migrated_vol.diskofferingname,
            large_offering.name,
            "Offering name did not match with the new one "
        )
        return
开发者ID:PCextreme,项目名称:cloudstack,代码行数:71,代码来源:test_volumes.py


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