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


Python ProvisionRequest.availability_zone方法代码示例

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


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

示例1: test_reboot_required

# 需要导入模块: from gen.agent.ttypes import ProvisionRequest [as 别名]
# 或者: from gen.agent.ttypes.ProvisionRequest import availability_zone [as 别名]
    def test_reboot_required(self):
        """
        Test that reboot required flag is set when all the required agent
        parameters are set.
        """
        self.agent._parse_options(["--config-path", self.agent_conf_dir])
        # Check that reboot required is false until we set all the params
        self.assertFalse(self.agent.reboot_required)

        req = ProvisionRequest()
        req.availability_zone = "test1"
        req.datastores = ["ds3", "ds4"]
        req.networks = ["Public"]
        addr = ServerAddress(host="localhost", port=2345)
        req.address = addr
        req.environment = {}
        req.environment["hypervisor"] = "fake"
        self.agent.update_config(req)
        # Verify that the bootstrap is still false as zk config is not
        # specified.
        self.assertFalse(self.agent.bootstrap_ready)
        self.assertTrue(self.agent.reboot_required)

        req = ProvisionRequest()
        req.availability_zone = "test1"
        req.datastores = ["ds3", "ds4"]
        req.networks = ["Public"]
        addr = ServerAddress(host="localhost", port=2345)
        req.address = addr
        req.environment = {}
        req.environment["hypervisor"] = "fake"
        self.agent.update_config(req)
        self.assertTrue(self.agent.reboot_required)
开发者ID:tomzhang,项目名称:photon-controller,代码行数:35,代码来源:test_agent_config.py

示例2: _update_agent_invalid_config

# 需要导入模块: from gen.agent.ttypes import ProvisionRequest [as 别名]
# 或者: from gen.agent.ttypes.ProvisionRequest import availability_zone [as 别名]
 def _update_agent_invalid_config(self):
     """
     Negative test case to update the agent with an invalid config
     """
     req = ProvisionRequest()
     req.availability_zone = "bootstrap_availability_zone_id"
     req.datastores = ["bootstrap_datastore"]
     req.networks = ["Bootstrap Network"]
     addr = ServerAddress(host="foobar", port=8835)
     req.address = addr
     req.chairman_server = [ServerAddress("h1", 13000),
                            ServerAddress("h2", 13000)]
     req.memory_overcommit = 0.5
     res = self.control_client.provision(req)
     self.assertEqual(res.result, ProvisionResultCode.INVALID_CONFIG)
开发者ID:aasthabh,项目名称:photon-controller,代码行数:17,代码来源:agent_common_tests.py

示例3: _update_agent_config

# 需要导入模块: from gen.agent.ttypes import ProvisionRequest [as 别名]
# 或者: from gen.agent.ttypes.ProvisionRequest import availability_zone [as 别名]
    def _update_agent_config(self):
        """
        Update the agent config using the bootstrap interface.
        Verifies that thrift requests after a config update return back
        SYSTEM_ERROR and the agent is stopped.
        :return the request we used to configure the host with.
        """
        req = ProvisionRequest()
        req.availability_zone = "bootstrap_availability_zone_id"
        req.datastores = ["bootstrap_datastore"]
        req.networks = ["Bootstrap Network"]
        addr = ServerAddress(host="foobar", port=8835)
        req.address = addr
        req.chairman_server = [ServerAddress("h1", 13000),
                               ServerAddress("h2", 13000)]
        req.memory_overcommit = 2.0
        res = self.control_client.provision(req)
        self.assertEqual(res.result, ProvisionResultCode.OK)

        # Now check that the agent went down and all requests fail until the
        # agent restarts.
        # Use a time greater than the restart poll thread.
        remaining_sleep_time = 15
        sleep_time = 0.5
        agent_restarted = False
        while 0 < remaining_sleep_time:
            try:
                res = self.control_client.get_agent_status()
                # Verify that the response is restarting
                self.assertEqual(res.status, AgentStatusCode.RESTARTING)
                time.sleep(sleep_time)
                remaining_sleep_time -= sleep_time
            except TTransport.TTransportException:
                agent_restarted = True
                break
            except:
                logger.debug("Caught exception, assuming restart: ",
                             exc_info=True)
                agent_restarted = True
                break
        self.assertTrue(agent_restarted)
        return req
开发者ID:aasthabh,项目名称:photon-controller,代码行数:44,代码来源:agent_common_tests.py

示例4: _provision_host

# 需要导入模块: from gen.agent.ttypes import ProvisionRequest [as 别名]
# 或者: from gen.agent.ttypes.ProvisionRequest import availability_zone [as 别名]
    def _provision_host(self, datastore):
        """ Provisions the agents on the remote hosts """
        req = ProvisionRequest()
        req.availability_zone = "test"
        req.datastores = [datastore]
        req.networks = ["VM Network"]
        req.address = ServerAddress(host="localhost", port=8835)
        req.chairman_server = [ServerAddress("localhost", 13000)]
        req.memory_overcommit = 2.0
        req.image_datastores = set([ImageDatastore(name=datastore, used_for_vms=True)])
        res = self.agent_client.provision(req)

        # This will trigger a restart if the agent config changes, which
        # will happen the first time provision_hosts is called.
        self.assertEqual(res.result, ProvisionResultCode.OK)

        # If a restart is required subsequent calls will fail.
        # This is an indirect way to determine if a restart is required.
        host_config_request = Host.GetConfigRequest()
        res = self.host_client.get_host_config(host_config_request)

        if res.result != GetConfigResultCode.OK:
            # Sleep for 15 s for the agent to reboot and come back up
            time.sleep(15)
开发者ID:tomzhang,项目名称:photon-controller,代码行数:26,代码来源:test_thin_copy.py

示例5: test_agent_config_update

# 需要导入模块: from gen.agent.ttypes import ProvisionRequest [as 别名]
# 或者: from gen.agent.ttypes.ProvisionRequest import availability_zone [as 别名]
    def test_agent_config_update(self):
        """ Test that updating the config using the RPC struct works """
        self.agent._parse_options(["--config-path", self.agent_conf_dir,
                                   "--availability-zone", "test",
                                   "--hostname", "localhost",
                                   "--port", "1234",
                                   "--datastores", "ds1, ds2"])
        expected_image_ds = [{"name": "ds3", "used_for_vms": True}]

        # Without chairman config we can't be provision ready
        self.assertFalse(self.agent.bootstrap_ready)
        self.assertTrue(self.agent.provision_ready)
        self.assertFalse(self.agent.reboot_required)

        req = ProvisionRequest()
        req.availability_zone = "test1"
        req.datastores = ["ds3", "ds4"]
        req.networks = ["Public"]
        req.memory_overcommit = 1.5
        req.image_datastores = set([ImageDatastore("ds3", True)])
        addr = ServerAddress(host="localhost", port=2345)
        req.chairman_server = [ServerAddress("h1", 13000),
                               ServerAddress("h2", 13000)]
        req.address = addr
        req.environment = {}
        req.environment["hypervisor"] = "fake"
        req.host_id = "host1"
        self.agent.update_config(req)

        assert_that(self.agent.availability_zone, equal_to("test1"))
        assert_that(self.agent.hostname, equal_to("localhost"))
        assert_that(self.agent.host_port, equal_to(2345))
        assert_that(self.agent.datastores, equal_to(["ds3", "ds4"]))
        assert_that(self.agent.networks, equal_to(["Public"]))
        assert_that(self.agent.options.hypervisor, equal_to("fake"))
        assert_that(self.agent.chairman_list,
                    equal_to([ServerAddress("h1", 13000),
                              ServerAddress("h2", 13000)]))
        assert_that(self.agent.memory_overcommit,
                    equal_to(1.5))
        assert_that(self.agent.image_datastores, equal_to(expected_image_ds))
        assert_that(self.agent.host_id, equal_to("host1"))

        self.assertTrue(self.agent.bootstrap_ready)
        self.assertTrue(self.agent.reboot_required)

        # Verify we are able to unset all the configuration.
        req = ProvisionRequest()

        self.agent.update_config(req)
        assert_that(self.agent.availability_zone, equal_to(None))
        assert_that(self.agent.hostname, equal_to(None))
        assert_that(self.agent.host_port, equal_to(8835))
        assert_that(self.agent.datastores, equal_to([]))
        assert_that(self.agent.networks, equal_to([]))
        assert_that(self.agent.chairman_list, equal_to([]))
        # Unsetting memory overcommit should set it to the default value.
        self.assertEqual(self.agent.memory_overcommit, 1.0)

        self.assertFalse(self.agent.bootstrap_ready)
        assert_that(self.agent.image_datastores, equal_to(expected_image_ds))
        assert_that(self.agent.host_id, equal_to(None))

        # Test an invalid update and verify the update doesn't have any side
        # effects.
        req = ProvisionRequest()
        req.availability_zone = "test1"
        req.datastores = ["ds3", "ds4"]
        req.networks = ["Public"]
        req.memory_overcommit = 0.5
        addr = ServerAddress(host="localhost", port=2345)
        req.chairman_server = [ServerAddress("h1", 13000),
                               ServerAddress("h2", 13000)]
        req.address = addr
        req.environment = {}
        req.environment["hypervisor"] = "fake"

        # Verify an exception is raised.
        self.assertRaises(InvalidConfig, self.agent.update_config, req)
        assert_that(self.agent.availability_zone, equal_to(None))
        assert_that(self.agent.hostname, equal_to(None))
        assert_that(self.agent.host_port, equal_to(8835))
        assert_that(self.agent.datastores, equal_to([]))
        assert_that(self.agent.networks, equal_to([]))
        assert_that(self.agent.chairman_list, equal_to([]))
        self.assertFalse(self.agent.bootstrap_ready)
        self.assertEqual(self.agent.memory_overcommit, 1.0)

        # input an invalid datastore for image.
        req.image_datastores = set([ImageDatastore("ds5", False)])
        req.memory_overcommit = 2.0
        self.assertRaises(InvalidConfig, self.agent.update_config, req)
开发者ID:tomzhang,项目名称:photon-controller,代码行数:94,代码来源:test_agent_config.py

示例6: test_agent_config_set_availability_zone

# 需要导入模块: from gen.agent.ttypes import ProvisionRequest [as 别名]
# 或者: from gen.agent.ttypes.ProvisionRequest import availability_zone [as 别名]
    def test_agent_config_set_availability_zone(self):
        """ Test that updating the config using the RPC struct works """
        self.agent._parse_options(["--config-path", self.agent_conf_dir,
                                   "--availability-zone", "test",
                                   "--hostname", "localhost",
                                   "--port", "1234",
                                   "--datastores", "ds1, ds2"])
        expected_image_ds = [{"name": "ds3", "used_for_vms": True}]

        # Without chairman config we can't be ready
        self.assertFalse(self.agent.bootstrap_ready)
        self.assertTrue(self.agent.provision_ready)
        self.assertFalse(self.agent.reboot_required)

        req = ProvisionRequest()
        req.availability_zone = "test1"
        req.datastores = ["ds3", "ds4"]
        req.networks = ["Public"]
        req.memory_overcommit = 1.5
        req.image_datastores = set([ImageDatastore("ds3", True)])
        addr = ServerAddress(host="localhost", port=2345)
        req.chairman_server = [ServerAddress("h1", 13000),
                               ServerAddress("h2", 13000)]
        req.address = addr
        req.host_id = "host1"
        self.agent.update_config(req)

        assert_that(self.agent.availability_zone, equal_to("test1"))
        assert_that(self.agent.hostname, equal_to("localhost"))
        assert_that(self.agent.host_port, equal_to(2345))
        assert_that(self.agent.datastores, equal_to(["ds3", "ds4"]))
        assert_that(self.agent.networks, equal_to(["Public"]))
        assert_that(self.agent.chairman_list,
                    equal_to([ServerAddress("h1", 13000),
                              ServerAddress("h2", 13000)]))
        assert_that(self.agent.memory_overcommit,
                    equal_to(1.5))
        assert_that(self.agent.image_datastores, equal_to(expected_image_ds))
        assert_that(self.agent.host_id, equal_to("host1"))

        self.assertTrue(self.agent.bootstrap_ready)
        self.assertTrue(self.agent.reboot_required)

        # Verify we are able to update availability zone only.
        setZone = SetAvailabilityZoneRequest()
        setZone.availability_zone = "test2"

        self.agent.set_availability_zone(setZone)
        assert_that(self.agent.availability_zone, equal_to("test2"))
        assert_that(self.agent.hostname, equal_to("localhost"))
        assert_that(self.agent.host_port, equal_to(2345))
        assert_that(self.agent.datastores, equal_to(["ds3", "ds4"]))
        assert_that(self.agent.networks, equal_to(["Public"]))
        assert_that(self.agent.chairman_list,
                    equal_to([ServerAddress("h1", 13000),
                              ServerAddress("h2", 13000)]))
        assert_that(self.agent.memory_overcommit,
                    equal_to(1.5))
        assert_that(self.agent.image_datastores, equal_to(expected_image_ds))
        assert_that(self.agent.host_id, equal_to("host1"))

        self.assertTrue(self.agent.bootstrap_ready)
        self.assertTrue(self.agent.reboot_required)
开发者ID:cgvarela,项目名称:photon-controller,代码行数:65,代码来源:test_agent_config.py


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