VMware {code} Community
schmidwi
Contributor
Contributor
Jump to solution

Specify destination datastore

Can anyone tell me how to specify the destinaion datastore for a conversion task.  For now, it is choosing a (seemingly random) default datastore based on the host (also a seemingly random default selection).

I can't seem to find anything about a datastore in the target definition.

Thanks,

William

Tags (3)
Reply
0 Kudos
1 Solution

Accepted Solutions
peevs
VMware Employee
VMware Employee
Jump to solution

Hello,

First to answer about the host selection.

If you target a VC and your want VM to be deployed on specific ESX you have to set the "host" property of "ConverterTargetVmSpecManagedVmLocation".

Host property is ManagedObjecReference to "HostSystem" (see the ref. guide). So the code should look like similar to (java):

ConverterTargetVmSpecManagedVmLocation targetVMLocation = new ConverterTargetVmSpecManagedVmLocation();

........

ManagedObjectReference targetESX = new ManagedObjectReference();
targetESX.setType("HostSystem");
targetESX.set_value("host-93"); //can get the actual value through the VC API

targetVMLocation.setHost(targetESX);

To answer the second question - about the storage selection.

If you want to select certain datastore for the target VM when managed destination is used you have to set the "vmxDatastoreName" property of "ConverterStorageParams" data object ( it is property of ConverterCloningParams, which is prop. of ConverterConversionParams, which are prop of the ConversionJobSpec).

If you want virtual disks of the VM (.vmdk file) to be stored on datastore different than VMX datastore, you have to set "datastoreName" property of the ConverterStorageParamsManagedTargetDiskParams data object (which have to be set as prop of "ConverterStorageParams" object)

I hope this helps.

View solution in original post

Reply
0 Kudos
17 Replies
peevs
VMware Employee
VMware Employee
Jump to solution

Hello,

First to answer about the host selection.

If you target a VC and your want VM to be deployed on specific ESX you have to set the "host" property of "ConverterTargetVmSpecManagedVmLocation".

Host property is ManagedObjecReference to "HostSystem" (see the ref. guide). So the code should look like similar to (java):

ConverterTargetVmSpecManagedVmLocation targetVMLocation = new ConverterTargetVmSpecManagedVmLocation();

........

ManagedObjectReference targetESX = new ManagedObjectReference();
targetESX.setType("HostSystem");
targetESX.set_value("host-93"); //can get the actual value through the VC API

targetVMLocation.setHost(targetESX);

To answer the second question - about the storage selection.

If you want to select certain datastore for the target VM when managed destination is used you have to set the "vmxDatastoreName" property of "ConverterStorageParams" data object ( it is property of ConverterCloningParams, which is prop. of ConverterConversionParams, which are prop of the ConversionJobSpec).

If you want virtual disks of the VM (.vmdk file) to be stored on datastore different than VMX datastore, you have to set "datastoreName" property of the ConverterStorageParamsManagedTargetDiskParams data object (which have to be set as prop of "ConverterStorageParams" object)

I hope this helps.

Reply
0 Kudos
schmidwi
Contributor
Contributor
Jump to solution

I just wanted to mention that this reply was SPOT ON.  I'm not sure how I missed this the first time, but tried your suggestions, and it works PERFECTLY!

Thanks.

Reply
0 Kudos
FrancoR
Contributor
Contributor
Jump to solution

Hello,

I have some problem setting up the destination datastore with the datastoreName property of the ConverterStorageParamsManagedTargetDiskParams data object, the property is totally ignored at runtime. I'm not a developer so there's hight possibility of my mistake. Could you post a little sample about using this property and how to set ConverterStorageParamsManagedTargetDiskParams as ConverterStorageParam ?

Thank You

FrancoR

Reply
0 Kudos
schmidwi
Contributor
Contributor
Jump to solution

Here is an exerpt of code from my Perl script.  I hope it helps.  This may or my not run as is since I just yanked out the relevant bits, but hopefully it gives you an idea how to specify the desitnation datastore.  The key is in the VirtualMachineRelocateSpec

Reply
0 Kudos
TinoMager
Contributor
Contributor
Jump to solution

Hello everyone,

I got some trouble with specification of datastore for a new VM too.

When I set the key of my datastore (in format of "datastore-XXXX") or the name of the datastore from vCenter for the vmxDatastoreName property, the API throws an exception of type ConverterImportDestinationNoDatastoreFault with the text "Unable to find the datastore 'datastore-XXXX."

What format has the vmxDatastoreName have to be? Is the scheme of "datastore-XXXX" correct?

What could cause the problem, that the datastore can't be found?

I would be very thankful about your advice,

Tino

Reply
0 Kudos
patanassov
VMware Employee
VMware Employee
Jump to solution

Hello,

vmxDatastoreName and datastoreName properties should contain the name of the datastore the way you see it in vSphere Client.

Tthe format "datastore-XXXX" is the format of the MoId (managed object id). This scheme applies also to other inventory objects (i.e. VMs are "vm-xxxx"). MoIds are seen using the MOB (managed inventory browser).

Regards,

Plamen

Reply
0 Kudos
shamayel82
Contributor
Contributor
Jump to solution

When I add the code below in my Program.java (sample code in SubmitWinP2VJob), I am getting an Invalid SSL exception.

If i don't apply the below code and execute the code, it then picks up a host on its own and properly performs the P2V.

My theory is if I do not set a host explicitly, it connects to the VC Server and VC Server allots a host, but if I specify a host, the code directly tries to connect to the host and fails with SSL validation. There is no way I can provide the SSL validation with the code as there are multiple clusters with each cluster having a huge number of hosts Smiley Sad .

Any way i can hack the piece where the VC Server allots a host by default. Not able to trace the calls all the way to that functionality, any clues anyone?

ManagedObjectReference hostInformationProvider_SF = new ManagedObjectReference();
  hostInformationProvider_SF.setType("HostSystem");
hostInformationProvider_SF.set_value("xxx.xx.com");
targetVMLocation.setHost(hostInformationProvider_SF);
Reply
0 Kudos
patanassov
VMware Employee
VMware Employee
Jump to solution

This is basically correct - if you connect to VC w/o specifying the host explicitly, VC will choose a host. You can control the cluster my setting the computeResource. However you should set at least the VC address in targetVmLocation, this can also throw an SSL exception. You should get the correct thumbprint from the exception an retry the call. Download the SDK samples for the recently released Converter 5.1; there is code for dealing with this there.

Reply
0 Kudos
mtraspadini
Contributor
Contributor
Jump to solution

Hi,

i am trying to convert an AcronisBackup image. I've used some of the code above, and the job inside the VMWareConverte is created; however, i always see N/A as destination; i passed the destination using the following code:

ManagedObjectReference targetESX = new ManagedObjectReference();
targetESX.setType("HostSystem");
targetESX.set_value("host-93"); //can get the actual value through the VC API

targetVMLocation.setHost(targetESX);

(the same that is into the first post)... but whatever i do, i always find N/A in the destination field of the newly created job into the Converter...

(i'm trying to convert an acronis image and have an ESX datastore managed by VCenter as target)

i tried all the code described in this post (apart from the datastore section, that i didn't even try because i always have N/A as a destination in Converter)

Thanks in advance

Reply
0 Kudos
patanassov
VMware Employee
VMware Employee
Jump to solution

targetVMLocation.setHost(targetESX);

targetVMLocation.setHostName("Target ESX Name");

HTH

Reply
0 Kudos
mtraspadini
Contributor
Contributor
Jump to solution

yes, i've done that (i only include the code i thought was necessary to understand my problem).

I'm using 5.1 SDK  and doing the following (i do not have setHost function):

targetVMLocation.host=targetESX;

targetVMLocation.HostName="Target ESX Name";

Compiles correctly, but N/A as target in the created job in VMWConverter

Thx

Reply
0 Kudos
VcloudUser
Contributor
Contributor
Jump to solution

When I set the key of my datastore the name of the datastore from vCenter for the vmxDatastoreName property, the API throws an exception of type ConverterImportDestinationNoDatastoreFault with the text "Unable to find the datastore 'XXXX." any ideas what might be the problem


Reply
0 Kudos
patanassov
VMware Employee
VMware Employee
Jump to solution

Did you specify the destination host and/or compute resource? If not converter chooses a default which might not see another host's local datastore.

If not the case, pls post the code snippet and the server and worker logs.

Reply
0 Kudos
VcloudUser
Contributor
Contributor
Jump to solution

I specified only the name of the host.. not the mob and also did not specify the compute resource  i.e i specified only targetVMLocation.hostName = "xxx.aa.com";  did not specify the targetVMLocation.host = reference;         targetVMLocation.computeResourceName.

how do i get the server and worker logs.. my bad could not find them so.

Thanks

Reply
0 Kudos
VcloudUser
Contributor
Contributor
Jump to solution

I specified the compute resource name and the host managed object reference info and it worked. i think compute resource name is required to correctly find the specified datastore name?

Reply
0 Kudos
patanassov
VMware Employee
VMware Employee
Jump to solution

Names are only for user reference, they are not used by VC. Either the host moref (managed object reference) or the compute resource moref should be enough.

Reply
0 Kudos
VcloudUser
Contributor
Contributor
Jump to solution

Thanks Plamen.. That makes sense after adding the host moref it solved the issue.

Reply
0 Kudos