【发布时间】:2017-02-07 08:59:26
【问题描述】:
我正在开发一个管理 vsphere Esx 5.5 上的虚拟机的 Web 界面。我的程序是使用 .net 网络表单(不是 MVC)开发的。
我关注了 jeffpaton 的帖子(使用 VMware.Vim),这些帖子帮助了我(感谢您,Jeff)https://communities.vmware.com/thread/434579。
但现在我冻结了这个主题。克隆 VM 后,我不知道如何等待任务。我的网站使用 vmware.vim 向 Vsphere Esx 启动 vsphere 命令。我需要知道 vpshere 何时完成他的工作以启动另一条指令。
我尝试使用 PropertyCollector 但我不知道如何使用它:
我红了这篇文章但没有成功:
这是我尝试的代码的一部分,但我被阻止了。我使用 jeffpaton 函数。
using VMware.Vim;
...
VimClient client;
string serverUrl = "..."
client.Connect("https://" + serverUrl + "/sdk");
client.Login(userLogin, userPassword);
...
ManagedObjectReference cloneTask_MoRef = null;
//1 waiting the cloning task
cloneTask_MoRef = sourceVm.cloneVM_Task(sourceVm.Parent, "cloneName", mySpec);
if (cloneTask_MoRef == null) {
//error
}else
{
PropertyCollector pc = new PropertyCollector(client, cloneTask_MoRef);
PropertyFilterSpec[] pfs = null;
RetrieveOptions ro = new RetrieveOptions();
RetrieveResult rResult = new RetrieveResult();
//PropertySpec
//pc.CreateFilter(pfs, true);
//rResult = pc.RetrievePropertiesEx(pfs,ro);
//
//2 PowerOn the CloneVM
cloneVM = this.vimClientTools.getVirtualMachines(selectedDC, cloneName)[0];
//3 waiting the powerOn Task...
//What could i do to know if the task is over or in progress ? :-(
我需要一些帮助。如果有人有建议开始...
谢谢大家。
【问题讨论】: