Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 167985

Re: Using ComputeResource and AddStandaloneHost_Task

$
0
0

Hi,

 

Firstly it's better for you to use converter 5.1 with converter 5.1 SDK examples as they have improved SSL handling. This version supports older VC targets also, so you shouldn't have compatibility issues if your VC is older.

VMware vCenter Converter Standalone

 

Based on the 5.1 examples following code, added to Program.buildTargetVMLocation() will place the VM on exact host in the target VC, no matter if the host is in cluster or not. Note that the value for HostSystem managed object reference is in the format "host-[number]". It's the runtime ID of the host for the given VC server - it's the hostname of the esx (which i think is a problem in your code).

 

ManagedObjectReference hostMor = new ManagedObjectReference();

hostMor.setType("HostSystem");

hostMor.set_value("host-10"); //the managed object ID for the given host

targetVMLocation.setHost(hostMor);

 

To obtain the managed object ID manually for a given host, you can use VC's managed object browser (the URL should be: https://<your-vc-ip>/mob). Login then navigate trough objects properties content > rootFolder > childEntity (you'll see you datacenter name) > hostFolder. At this level you'll see current host which are out of clusters and the clusters. If desired host is in a cluster navigate in that cluster. For the "host" property you'll see list of the host ID's (mapped to their host names for vc5.1)

To obtain host If automatically you'll have to use the VC SDK, or this very good alternative: VMware Infrastructure (vSphere) Java API


Note, that converter 5.1 examples code prompts for SSL thumbprint confirmation for the source and the target as the converter 5.1 always verify peer to which it connects. It should be easy to figure out how to do it the code to always says "yes" to the peer, if this is what your application needs.

 

Also note that if your target cluster is in DRS mode probably you don't want to specify exact host in it, to let the DRS do its job. In the case that code you should add to buildTargetVMLocation() will look like:

 

ManagedObjectReference computeMor = new ManagedObjectReference();

computeMor.setType("ClusterComputeResource");

computeMor.set_value("domain-c7"); //the managed object ID for the given compute resource

targetVMLocation.setComputeResource(computeMor);

 

Again, manually you can obtain cluster computer resource ID through the mob. To do it from code. you'll have to interact with the VC API.

 

HTH,

Zaro


Viewing all articles
Browse latest Browse all 167985

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>