VMware {code} Community
fsckit
Enthusiast
Enthusiast

vmdkManagement.pl only adds disks to SCSI controller 0

Looking for help with this lamw-vghetto script. The subroutine, addExistingVMDK, hard-codes controller => "SCSI controller 0". Change this 0 to any other valid controller number, and if fails with this error:

Error:

SOAP Fault:

-----------

Fault string: Invalid configuration for device '0'.

Fault detail: InvalidDeviceSpec

I've verified that I am getting back a valid controller from find_device().

Has anyone successfully user vmdkManagement.pl or other Perl script to add virtual disks to a VM on a second SCSI controller? 

I am able to do this directly on the ESXi host using 'vim-cmd vmsvc/device.diskaddexisting ...'.  I'd prefer doing this remotely from the vMA though.

Thanks.

0 Kudos
2 Replies
fsckit
Enthusiast
Enthusiast

I actually figured this out. Problem is the way the script calculates SCSI target number ("$diskUnitNumber"). It assumes that the first disk is target 0. If someone made the first disk on a new controller target 1 (as is common for our Paravirtual controllers), the new SCSI target number will be one less than it should be.

0 Kudos
lharker
Contributor
Contributor

You can actually use any existing SCSI controller number on a VM AND add disks 6-15 if you do the following:

Replace:

 my $unitNumber = $#{$controller->device} + 1;

With this Snipit from LINCVZs fix of vdiskcreate.pl:

        my $unitNumber;
        my $vm_vdisk_number = $#{$controller->device} + 1;
        if ($vm_vdisk_number < 7) {
           $unitNumber = $vm_vdisk_number;
        }
        elsif ($vm_vdisk_number == 15) {
           die "ERR: one SCSI controller cannot have more than 15 virtual disks\n";
        }
        else {
           $unitNumber = $vm_vdisk_number + 1;
        }

0 Kudos