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


Python Host.listForMigration方法代码示例

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


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

示例1: get_target_host

# 需要导入模块: from marvin.lib.base import Host [as 别名]
# 或者: from marvin.lib.base.Host import listForMigration [as 别名]
    def get_target_host(self, secured, virtualmachineid):
        target_hosts = Host.listForMigration(self.apiclient,
                                             virtualmachineid=virtualmachineid)
        for host in target_hosts:
            h = list_hosts(self.apiclient,type='Routing', id=host.id)[0]
            if h.details.secured == secured:
                return h

        cloudstackTestCase.skipTest(self, "No target hosts available, skipping test.")
开发者ID:PCextreme,项目名称:cloudstack,代码行数:11,代码来源:test_vm_life_cycle.py

示例2: migrate_vm

# 需要导入模块: from marvin.lib.base import Host [as 别名]
# 或者: from marvin.lib.base.Host import listForMigration [as 别名]
 def migrate_vm(self, vm):
     self.debug("Checking if a host is available for migration?")
     hosts = Host.listForMigration(self.api_client)
     self.assertEqual(isinstance(hosts, list), True,
                      "List hosts should return a valid list"
                      )
     # Remove the host of current VM from the hosts list
     hosts[:] = [host for host in hosts if host.id != vm.hostid]
     if len(hosts) <= 0:
         self.skipTest("No host available for migration. Test requires at-least 2 hosts")
     host = hosts[0]
     self.debug("Migrating VM-ID: %s to Host: %s" % (vm.id, host.id))
     try:
         vm.migrate(self.api_client, hostid=host.id)
     except Exception as e:
         self.fail("Failed to migrate instance, %s" % e)
开发者ID:DKrul,项目名称:cloudstack,代码行数:18,代码来源:nuageTestCase.py

示例3: findSuitableHostForMigration

# 需要导入模块: from marvin.lib.base import Host [as 别名]
# 或者: from marvin.lib.base.Host import listForMigration [as 别名]
def findSuitableHostForMigration(apiclient, vmid):
    """Returns a suitable host for VM migration"""
    suitableHost = None
    try:
        hosts = Host.listForMigration(apiclient, virtualmachineid=vmid)
    except Exception as e:
        raise Exception("Exception while getting hosts list suitable for migration: %s" % e)

    suitablehosts = []
    if isinstance(hosts, list) and len(hosts) > 0:
        suitablehosts = [
            host for host in hosts if (str(host.resourcestate).lower() == "enabled" and str(host.state).lower() == "up")
        ]
        if len(suitablehosts) > 0:
            suitableHost = suitablehosts[0]

    return suitableHost
开发者ID:rafaelthedevops,项目名称:cloudstack,代码行数:19,代码来源:common.py

示例4: test_01_concurrent_snapshots

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

#.........这里部分代码省略.........

        for snapshot in self.snapshot_pool:
            self.assertTrue(
                is_snapshot_on_nfs(
                    self.apiclient,
                    self.dbclient,
                    self.config,
                    self.zone.id,
                    snapshot.id))

        for snapshot in self.snapshot_pool:
            snapshot.delete(self.apiclient)

        self.snapshot_pool = []

        for rec_snap_pol in self.rec_policy_pool:
            rec_snap_pol.delete(self.apiclient)

        self.rec_policy_pool = []

        # Step 5

        try:
            thread_pool = []
            for i in range(4):
                create_snapshot_thread_1 = Thread(
                    target=CreateSnapshot,
                    args=(
                        self,
                        self.root_pool[i],
                        False))
                thread_pool.append(create_snapshot_thread_1)

            destinationHost = Host.listForMigration(
                self.apiclient,
                virtualmachineid=self.vm_pool[3].id)
            migrate_volume_thread_1 = Thread(target=MigrateRootVolume,
                                             args=(self,
                                                   self.vm_pool[3],
                                                   destinationHost[0]))

            thread_pool.append(migrate_volume_thread_1)

            for thread in thread_pool:
                thread.start()

            for thread in thread_pool:
                thread.join()

        except Exception as e:
            raise Exception(
                "Warning: Exception unable to start thread : %s" %
                e)

        snapshots = list_snapshots(
            self.apiclient,
            account=self.account.name,
            domainid=self.account.domainid,
            listall=True
        )

        for snapshot in self.snapshot_pool:
            self.assertTrue(snapshot.id in any(
                s.id) for s in snapshots)

        for snapshot in self.snapshot_pool:
开发者ID:Accelerite,项目名称:cloudstack,代码行数:70,代码来源:testpath_volume_cuncurrent_snapshots.py

示例5: test_01_find_hosts_for_migration

# 需要导入模块: from marvin.lib.base import Host [as 别名]
# 或者: from marvin.lib.base.Host import listForMigration [as 别名]
    def test_01_find_hosts_for_migration(self):
        """ Test find suitable and not-suitable list of hosts for migration """

        # Steps,
        # 1. Create a Compute service offering with the tag .
        # 2. Create a Guest VM with the compute service offering created above.
        # 3. find hosts to migrate the vm crated above

        # Validations,
        # 1. Ensure that the offering is created with the tag
        # The listServiceOffering API should list show tag
        # 2. Select the newly created VM and ensure that the Compute offering field value lists the compute service offering that was selected.
        # 3. findHostsForMigration cmd should list both suitable and not-suitable hosts

        list_service_response = list_service_offering(self.apiclient, id=self.service_offering_with_tag.id)
        self.assertEqual(
            isinstance(list_service_response, list), True, "listServiceOfferings returned invalid object in response."
        )
        self.assertNotEqual(len(list_service_response), 0, "listServiceOfferings returned empty list.")
        self.assertEqual(list_service_response[0].hosttags, "PREMIUM", "The service offering having tag")

        # create virtual machine with the service offering with Ha enabled
        virtual_machine = VirtualMachine.create(
            self.apiclient,
            self.services["virtual_machine"],
            accountid=self.account.name,
            domainid=self.account.domainid,
            serviceofferingid=self.service_offering_with_tag.id,
        )
        vms = VirtualMachine.list(self.apiclient, id=virtual_machine.id, listall=True)
        self.assertEqual(isinstance(vms, list), True, "listVirtualMachines returned invalid object in response.")
        self.assertNotEqual(len(vms), 0, "listVirtualMachines returned empty list.")
        self.debug("Deployed VM on host: %s" % vms[0].hostid)

        # verify that the virtual machine created on the host with tag
        list_hosts_response = list_hosts(self.apiclient, id=virtual_machine.hostid)
        self.assertEqual(isinstance(list_hosts_response, list), True, "listHosts returned invalid object in response.")

        self.assertNotEqual(len(list_hosts_response), 0, "listHosts returned empty list.")

        host = list_hosts_response[0]

        self.assertEqual(host.hosttags, "PREMIUM", "VM is created on a host having appropriate tag. %s" % host.uuid)

        try:
            list_hosts_response = Host.listForMigration(self.apiclient, virtualmachineid=virtual_machine.id)
        except Exception as e:
            raise Exception("Exception while getting hosts list suitable for migration: %s" % e)

        self.assertEqual(isinstance(list_hosts_response, list), True, "listHosts returned invalid object in response.")

        self.assertNotEqual(len(list_hosts_response), 0, "listHosts returned empty response.")
        suitableHost = set()
        notSuitableHost = set()

        for host in list_hosts_response:
            if host.suitableformigration:
                suitableHost.add(host)
            else:
                notSuitableHost.add(host)

        self.assertTrue(notSuitableHost is not None, "notsuitablehost should not be None")
        self.debug("Suitable Hosts: %s" % suitableHost)
        self.debug("Not suitable Hosts: %s" % notSuitableHost)
开发者ID:tianshangjun,项目名称:cloudstack,代码行数:66,代码来源:find_hosts_for_migration.py


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