Hello everybody.
I have little question: How should I use this function to create virtual disk on ESX server?
What machine I have to specify in connection parameters? What exactly path to the disk have to be?
I have machine with moref 256 registered. It has path "[datastore1] Ubuntu/Ubuntu.vmx"
All goes fine, but function VixDiskLib_Create() return Error code 3 with text "One of the parameters was invalid".
My code:
char tempStr[MAX_PATH];
VixError vixError;StringCbCopy(VixConnectParams.serverName,24,"192.168.1.240");
StringCbCopy(VixConnectParams.creds.uid.userName,21,"login");
StringCbCopy(VixConnectParams.creds.uid.password,128,"password");
VixConnectParams.port = 902;
VixConnectParams.credType=VIXDISKLIB_CRED_UID;StringCbCopy(tempStr,MAX_PATH,"moref=256");
VixConnectParams.vmxSpec=tempStr;
vixError= VixDiskLib_InitEx(1,
0,
NULL,
NULL,
NULL,
NULL,
NULL);
if(vixError!=VIX_OK)
return false;vixError= VixDiskLib_ConnectEx(&VixConnectParams,
false,
NULL,
NULL,
&VixConnection);
if(vixError!=VIX_OK)
return false;VixDiskLibCreateParams createParams;
createParams.adapterType=VIXDISKLIB_ADAPTER_SCSI_LSILOGIC;
createParams.capacity=536870912;
createParams.diskType=VIXDISKLIB_DISK_MONOLITHIC_SPARSE;
createParams.hwVersion=VIXDISKLIB_HWVERSION_CURRENT;//opening disk
vixError=VixDiskLib_Create(VixConnection,
"[datastore1] Ubuntu/test.vmdk",
&createParams,
NULL,
NULL);
if(vixError!=VIX_OK)
{
char *r=VixDiskLib_GetErrorText(vixError,NULL);
return false;
}
Error 3 also means that it is not able to find the path!?
Are you able to create a vmdk locally on your dev machine?
Also are you able to read a VMDK from your ESX machine VixDiskLib_Open & VixDiskLib_Read as a test?
Regards
Ashutosh
Yes I can open, read and write virtual disk on ESX. Also I can create this disk locally.
Ooops: Hope this helps. From the API guide:
Creating Remote Disk
As stated in “Support for Managed Disk” on page 26, VixDiskLib_Create() does not support managed disk.
To create a managed disk on the remote ESX/ESXi host, first create a hosted disk on the local Workstation, then
convert the hosted disk into managed disk with VixDiskLib_Clone() over the network.
To create remote managed disk using the sample program, type the following commands:
./vix-disklib-sample -create -cap 1000000 virtdisk.vmdk
./vix-disklib-sample -clone virtdisk.vmdk -host esx3i -user root -password secret vmfsdisk.vmdk
You could write a virtual‐machine provisioning application to perform the following steps:
1 Create a hosted disk VMDK with 2GB capacity, using VixDiskLib_Create().
2 Write image of the guest OS and application software into the VMDK, using VixDiskLib_Write().
3 Clone the hosted disk VMDK onto the VMFS file system of the ESX/ESXi host.
vixError = VixDiskLib_Clone(appGlobals.connection, appGlobals.diskPath,
srcConnection, appGlobals.srcPath,
&createParams, CloneProgressFunc, NULL, TRUE);
In this call, appGlobals.connection and appGolbals.diskPath represent the remote VMDK on the
ESX/ESXi host, while srcConnection and appGlobals.srcPath represent the local hosted VMDK.
4 Power on the new guest OS to get a new virtual machine.
On Workstation, the VixVMPowerOn() function in the VIX API does this. For ESX/ESXi hosts, you must
use the PowerOnVM_Task method. As easy way to use this method is in the VMware vSphere Perl Toolkit,
which has the PowerOnVM_Task() call (non‐blocking), and the PowerOnVM() call (synchronous).
5 Provision and deploy the new virtual machine on the ESX/ESXi host.
Thank you for reply. I've allready read documentation before. And I tried this call:
vixError=VixDiskLib_Clone(VixConnection,
"[datastore1] Ubuntu/Ubuntu.vmdk",
localConnection,
"c:\\temp\\Ubuntu.vmdk",
&createParams,
NULL,
NULL,
true);
As result I get vixError=4 with text "A file was not found". So I came here and read that on ESX "must be a .vmdk file existed".