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


Python ProvisionRequest.image_datastore_info方法代码示例

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


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

示例1: provision_hosts

# 需要导入模块: from gen.agent.ttypes import ProvisionRequest [as 别名]
# 或者: from gen.agent.ttypes.ProvisionRequest import image_datastore_info [as 别名]
    def provision_hosts(self, mem_overcommit=2.0,
                        datastores=None, used_for_vms=True,
                        image_ds=None, host_id=None,
                        deployment_id="test-deployment"):
        """ Provisions the agents on the remote hosts """
        if datastores is None:
            datastores = self.get_all_datastores()
            image_datastore = self.get_image_datastore()
        elif image_ds:
            image_datastore = image_ds
        else:
            image_datastore = datastores[0]

        req = ProvisionRequest()
        req.datastores = datastores
        req.address = ServerAddress(host=self.server, port=8835)
        req.memory_overcommit = mem_overcommit
        req.image_datastore_info = ImageDatastore(
            name=image_datastore,
            used_for_vms=used_for_vms)
        req.image_datastores = set([req.image_datastore_info])
        req.management_only = True
        req.auth_enabled = False
        if host_id:
            req.host_id = host_id
        else:
            req.host_id = self.host_id

        if deployment_id:
            req.deployment_id = deployment_id
        else:
            req.deployment_id = self.deployment_id

        res = self.control_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)

        # Wait for up to 60 seconds for the agent to reboot.
        count = 0
        while count < 60:
            try:
                res = self.control_client.get_agent_status()
                if res.status == AgentStatusCode.OK:
                    # Agent is up
                    return
            except:
                logger.exception("Can't connect to agent")
            count += 1
            time.sleep(1)
            # Reconnect the clients
            self._close_agent_connections()
            self.client_connections()
        self.fail("Cannot connect to agent %s after provisioning" % self.server)
        return host_id
开发者ID:vmware,项目名称:photon-controller,代码行数:58,代码来源:test_remote_agent.py


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