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


Python VimClient.get_networks方法代码示例

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


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

示例1: TestRemoteAgent

# 需要导入模块: from host.hypervisor.esx.vim_client import VimClient [as 别名]
# 或者: from host.hypervisor.esx.vim_client.VimClient import get_networks [as 别名]

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

        dst_image, _ = self._create_test_image(image_id)

        datastore = self._find_configured_datastore_in_host_config()
        transfer_image_request = TransferImageRequest(
            source_image_id=image_id,
            source_datastore_id=datastore.id,
            destination_host=ServerAddress(host="localhost", port=8835),
            destination_datastore_id=datastore.id,
            destination_image_id=image_id_2)
        res = self.host_client.transfer_image(transfer_image_request)
        self.assertEqual(res.result, TransferImageResultCode.OK)

        # clean up images created in test
        self._delete_image(dst_image)
        xfered_image = Image(image_id_2, datastore)
        self._delete_image(xfered_image)

    def test_host_config_after_provision(self):
        """
        Test if the agent returns the correct HostConfig
        after being provisioned
        """
        host_config_request = Host.GetConfigRequest()
        res = self.host_client.get_host_config(host_config_request)
        self.assertEqual(res.result, GetConfigResultCode.OK)

        hostConfig = res.hostConfig
        datastores = [ds.name for ds in hostConfig.datastores]
        containsDs = [ds for ds in self.get_all_datastores()
                      if ds in datastores]
        self.assertEqual(containsDs, self.get_all_datastores())
        networks = [net.id for net in hostConfig.networks]
        self.assertEqual(networks, self.vim_client.get_networks())
        self.assertEqual(hostConfig.address, ServerAddress(host=self.server,
                                                           port=8835))
        self.assertTrue(hostConfig.management_only)
        # get_host_config reports datastore id for image datastore  even if it
        # was provisioned with a datastore name.
        image_datastore_name = self.get_image_datastore()
        image_datastore_id = None
        for ds in hostConfig.datastores:
            if ds.name == image_datastore_name:
                image_datastore_id = ds.id
        self.assertEqual(list(hostConfig.image_datastore_ids)[0],
                         image_datastore_id)

    def _generate_new_iso_ds_path(self):
        if (self._remote_iso_file.lower().rfind(".iso") !=
                len(self._remote_iso_file) - 4):
            raise ValueError()

        return "%s-%s.iso" % (self._remote_iso_file[:-4], str(uuid.uuid4()))

    def _make_new_iso_copy(self, file_manager, new_iso_path):
        copy_task = file_manager.CopyFile(self._remote_iso_file, None,
                                          new_iso_path, None)
        task.WaitForTask(copy_task)

    def test_attach_cdrom(self):
        """
        Tests attach iso code path.
        1. Attach an iso to a non existent VM. Check correct error
        2. Attach a non existent iso file to a valid VM. Check correct error
        3. Attach a real iso if specified to a VM. Verify it succeeds.
        Test should pass the iso path as [datastore_name]/path/to/iso.iso
开发者ID:hartsock,项目名称:photon-controller,代码行数:70,代码来源:test_remote_agent.py


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