VMware {code} Community
VISDK
Contributor
Contributor
Jump to solution

Changing the order of the disks using VI SDK

Hi,

I am trying to change the order of the disks using the VI SDK API's. Can any one assist me in doing this. Currently I am removing all the diskdevices and doing a ReconfigureVM_Tak followed by addition of disk devices in the prefeered order and again call the ReconfigureVM_Task.

On doing this i end up adding the disks in the same order which was set prior to these operations.

Any kind of help in this is apprciated.

Thx,

Gautham

Reply
0 Kudos
1 Solution

Accepted Solutions
lamw
Community Manager
Community Manager
Jump to solution

So my question is why are you exactly doing this? If the disks are empty, then just put whichever disk you want to be first, first.

The label "Hard disk X" is just for you to know how many disks are attached and which SCSI adapter/bus it's on. If you have disk0-2 added and you remove and you add them back in reverse order, then disk2 will now have label "Hard disk 1" since that is the first disk added. What really matter is the adapter/bus it's on because the OS will see the drives in a certain order which is what I would think where it matters.

At this point you'll never get the labels to be "reverse" as the labels are generated to ensure uniqueness across the number of disks.

Hopefully this makes sense, so the recommendation is to order the drives in the order in which you want the OS to see it, which will be selecting the adapter/bus

e.g. SCSI0:0,SCSI0:1,SCSI0:2...

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

If you find this information useful, please award points for "correct" or "helpful".

View solution in original post

Reply
0 Kudos
8 Replies
lamw
Community Manager
Community Manager
Jump to solution

Are you referring to just modifying the SCSI controller/bus? If so, that can be done while the VM is offline, just make sure you select the right drives to re-arrange and not your boot drive.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

If you find this information useful, please award points for "correct" or "helpful".

Reply
0 Kudos
VISDK
Contributor
Contributor
Jump to solution

Hi Wiliiam,

Thanks for your reply. Here is what I am trying to do. I have create a VM using the CreateVM_Taks with 3 IDE disks attached to it. Let us assume that the order in which these three disks are enumerated are as Disk0, Disk1 and Disk2. There is no data present in any of my disks and also there is no OS installed.Now I would like my disks to be enumerated in the following order. Disk2, Disk0 and Disk1.

So here is what I am doing:

Remove all the disks and reconfigure my VM. Now my VM has no disks attached to it.

Now I will again add the virtual disks in the order Disk2, Disk0 and Disk1 and reconfigure my VM again.

After I do this the disks are still attached as Disk0, Disk1 and Disk2. I am not changing any controller settings here. Not sure how I can get my disks to be enumerated as Disk2, Disk0 and Disk1.

Thx,

Gautham

Reply
0 Kudos
lamw
Community Manager
Community Manager
Jump to solution

So my question is why are you exactly doing this? If the disks are empty, then just put whichever disk you want to be first, first.

The label "Hard disk X" is just for you to know how many disks are attached and which SCSI adapter/bus it's on. If you have disk0-2 added and you remove and you add them back in reverse order, then disk2 will now have label "Hard disk 1" since that is the first disk added. What really matter is the adapter/bus it's on because the OS will see the drives in a certain order which is what I would think where it matters.

At this point you'll never get the labels to be "reverse" as the labels are generated to ensure uniqueness across the number of disks.

Hopefully this makes sense, so the recommendation is to order the drives in the order in which you want the OS to see it, which will be selecting the adapter/bus

e.g. SCSI0:0,SCSI0:1,SCSI0:2...

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

If you find this information useful, please award points for "correct" or "helpful".

Reply
0 Kudos
VISDK
Contributor
Contributor
Jump to solution

Hi William,

Thanks for your explanation. I changed the cotroller settings as you have suggested and it seems to be working. Thanks a bunch for the information.

I also wanted to know if we can query a list of VMDK URL's for a given VM using VDDK by any chance. I know we have an API to do this thorugh SDK but I was wondering if there is anything available with VDDK.

Thanks again for you timely help.

Thx,

Gautham

Reply
0 Kudos
lamw
Community Manager
Community Manager
Jump to solution

When you say URL....which URL are you referring to? Can you please provide an example?

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

If you find this information useful, please award points for "correct" or "helpful".

Reply
0 Kudos
VISDK
Contributor
Contributor
Jump to solution

Disk URL is the absolute path of the vmdk file. For Eg: "[[Storage1 (1)]] new virtual machine_2/new virtual machine_2.vmdk".

Thx,

Gaut

Reply
0 Kudos
lamw
Community Manager
Community Manager
Jump to solution

I believe you can, but you'll need to take a look at the VDDK API documentation on how to extract this information

I know with the vmrun binary which is part of the VDDK toolkit download, you can get the VM's location doing something like

[vi-admin@scofield ]$  vmrun -T esx -h https://esxi4-1.primp-industries.com/sdk -u root -p 'password' list
Total running VMs: 1
[esxi4-1-local-storage-1] VA-Tomcat/VA-Tomcat.vmx

Though if you need further detail, I would say head over to the VDDK forums and their documentation to see how it'll maybe implemented.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

If you find this information useful, please award points for "correct" or "helpful".

Reply
0 Kudos
VISDK
Contributor
Contributor
Jump to solution

Thanks William Appreciate all your time and help.

Reply
0 Kudos