Skip navigation
VMware
Up to Discussions in Virtual Disk Development Kit

Developer: Virtual Disk Development Kit

Create and access virtual disks
 

This Question is Not Answered

1 "correct" answer available (10 pts) 1 "helpful" answer available (6 pts)
173 Views 4 Replies Last post: Feb 1, 2012 12:42 AM by EricTreeman RSS
EricTreeman Lurker 4 posts since
Jan 31, 2012
Currently Being Moderated

Jan 31, 2012 5:13 AM

ESX disk creation with VixDiskLib_Create()

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;
}

asshutossh Novice 11 posts since
Jul 4, 2008
Currently Being Moderated
1. Jan 31, 2012 5:33 AM in response to: EricTreeman
Re: ESX disk creation with VixDiskLib_Create()

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

Regards, Ashutosh
asshutossh Novice 11 posts since
Jul 4, 2008
Currently Being Moderated
3. Jan 31, 2012 6:53 AM in response to: EricTreeman
Re: ESX disk creation with VixDiskLib_Create()

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.

Regards, Ashutosh

Bookmarked By (0)

Communities