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


Python Host.enableMaintenance方法代码示例

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


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

示例1: setUpClass

# 需要导入模块: from marvin.lib.base import Host [as 别名]
# 或者: from marvin.lib.base.Host import enableMaintenance [as 别名]
    def setUpClass(cls):
        cls.testClient = super(TestVPCHostMaintenance, cls).getClsTestClient()
        cls.api_client = cls.testClient.getApiClient()

        cls.services = Services().services
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.api_client)
        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
        cls.template = get_template(
            cls.api_client,
            cls.zone.id,
            cls.services["ostype"]
        )
        cls.services["virtual_machine"]["zoneid"] = cls.zone.id
        cls.services["virtual_machine"]["template"] = cls.template.id
        cls.services["mode"] = cls.zone.networktype

        cls.vpc_off = VpcOffering.create(
            cls.api_client,
            cls.services["vpc_offering"]
        )
        cls.vpc_off.update(cls.api_client, state='Enabled')
        cls.hosts = Host.list(
            cls.api_client,
            zoneid=cls.zone.id,
            listall=True,
            type='Routing'
        )

        if isinstance(cls.hosts, list):
            for host in cls.hosts:
                Host.enableMaintenance(
                    cls.api_client,
                    id=host.id
                )

                timeout = cls.services["timeout"]
                while True:
                    time.sleep(cls.services["sleep"])
                    hosts_states = Host.list(
                        cls.api_client,
                        id=host.id,
                        listall=True
                    )
                    if hosts_states[
                            0].resourcestate == 'PrepareForMaintenance':
                        # Wait for sometimetill host goes in maintenance state
                        time.sleep(cls.services["sleep"])
                    elif hosts_states[0].resourcestate == 'Maintenance':
                        time.sleep(cls.services["sleep"])
                        break
                    elif timeout == 0:
                        raise unittest.SkipTest(
                            "Failed to enable maintenance mode on %s" %
                            host.name)
                    timeout = timeout - 1

        cls._cleanup = [
            cls.vpc_off
        ]
        return
开发者ID:K0zka,项目名称:cloudstack,代码行数:63,代码来源:test_vpc_on_host_maintenance.py

示例2: test_01_enable_maintenance_with_vpc_nw

# 需要导入模块: from marvin.lib.base import Host [as 别名]
# 或者: from marvin.lib.base.Host import enableMaintenance [as 别名]
    def test_01_enable_maintenance_with_vpc_nw(self):
        """ Test enable Maintenance Mode on Hosts which have VPC elements
        """

        # Validate the following
        # 1. Create a VPC with cidr - 10.1.1.1/16
        # 2. Add network1(10.1.1.1/24) and network2(10.1.2.1/24) to this VPC.
        # 3. Deploy vm1 and vm2 in network1 and vm3 and vm4 in network2. Make
        #    sure vm1 and vm3 are deployed on one host in the cluster while
        #    vm2 and vm4 are deployed on the other host in the cluster. This
        #    can be done using host's tags & service offerings with host tags
        # Steps:
        # 1.Enable Maintenance on one of host on which VPCVR is present
        # Validations:
        # 1. Successfully push the host into maintenance mode.
        # 2. VMs present on the above host should successfully migrate to the
        #    other host present in the cluster

        Host.update(self.apiclient, id=self.hosts[0].id, hosttags="hosttag1,hosttag2")
        Host.update(self.apiclient, id=self.hosts[1].id, hosttags="hosttag1,hosttag2")

        self.validate_vm_deployment()
        self.debug("Stop the host on which the VPC virtual router is running")
        try:
            Host.enableMaintenance(self.apiclient, id=self.vpcvr.hostid)
        except Exception as e:
            self.fail("Failed to enable maintenance mode on host: %s" % e)

        self.debug("Check if all instances belonging to the account are up again?")
        routers = Router.list(self.apiclient, account=self.account.name, domainid=self.account.domainid, listall=True)
        self.assertEqual(isinstance(routers, list), True, "List routers shall return a valid VPCVR for account")

        router = routers[0]

        try:

            timeout = self.services["timeout"]
            self.debug("Timeout Value %d : " % timeout)
            while True:
                list_router_response = Router.list(self.apiclient, id=router.id, state="Running")

                if list_router_response is not None:
                    break
                elif timeout == 0:
                    raise Exception("Router state should be running after migration")

                time.sleep(self.services["sleep"])
                timeout = timeout - 1
                self.debug("Waiting for %d seconds - %d tries left" % (self.services["sleep"], timeout))

            self.debug("Verified that the Router is in Running State")

        except Exception as e:
            self.fail("Failed to find the Router in Running state %s " % e)

        vms = VirtualMachine.list(
            self.apiclient, account=self.account.name, domainid=self.account.domainid, listall=True
        )
        self.assertEqual(isinstance(vms, list), True, "VM response should return instances running for account")
        for vm in vms:
            self.assertEqual(vm.state, "Running", "Vm state should be running after migration")
        return
开发者ID:mariocar,项目名称:cloudstack,代码行数:64,代码来源:test_vpc_host_maintenance.py

示例3: test_01_enable_maintenance_with_vpc_nw

# 需要导入模块: from marvin.lib.base import Host [as 别名]
# 或者: from marvin.lib.base.Host import enableMaintenance [as 别名]
    def test_01_enable_maintenance_with_vpc_nw(self):
        """ Test enable Maintenance Mode on Hosts which have VPC elements
        """

        # Validate the following
        # 1. Create a VPC with cidr - 10.1.1.1/16
        # 2. Add network1(10.1.1.1/24) and network2(10.1.2.1/24) to this VPC.
        # 3. Deploy vm1 and vm2 in network1 and vm3 and vm4 in network2. Make
        #    sure vm1 and vm3 are deployed on one host in the cluster while
        #    vm2 and vm4 are deployed on the other host in the cluster. This
        #    can be done using host's tags & service offerings with host tags
        # Steps:
        # 1.Enable Maintenance on one of host on which VPCVR is present
        # Validations:
        # 1. Successfully push the host into maintenance mode.
        # 2. VMs present on the above host should successfully migrate to the
        #    other host present in the cluster

        self.validate_vm_deployment()
        self.debug("Stop the host on which the VPC virtual router is running")
        try:
            Host.enableMaintenance(self.apiclient, id=self.vpcvr.hostid)
        except Exception as e:
            self.fail("Failed to enable maintenance mode on host: %s" % e)

        self.debug(
            "Check if all instances belonging to the account are up again?")
        routers = Router.list(
                              self.apiclient,
                              account=self.account.name,
                              domainid=self.account.domainid,
                              listall=True
                              )
        self.assertEqual(
                         isinstance(routers, list),
                         True,
                         "List routers shall return a valid VPCVR for account"
                         )
        for router in routers:
            self.assertEqual(
                             router.state,
                             "Running",
                             "Router state should be running after migration"
                             )
        vms = VirtualMachine.list(
                                  self.apiclient,
                                  account=self.account.name,
                                  domainid=self.account.domainid,
                                  listall=True
                                  )
        self.assertEqual(
                    isinstance(vms, list),
                    True,
                    "VM response should return instances running for account"
                    )
        for vm in vms:
            self.assertEqual(
                             vm.state,
                             "Ruuning",
                             "Vm state should be running after migration"
                             )
        return
开发者ID:Skotha,项目名称:cloudstack,代码行数:64,代码来源:test_vpc_host_maintenance.py


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