rlaborius
Contributor
Contributor

Help with VirtualDisk.controllerKey

Hi

i'm writing a script to create a vm.

I have some problems with the VirtualDisk.controllerKey.

Can anyone say, what i'm doing wrong ?

sub create_conf_spec {

     my $controller =
         VirtualDeviceConfigSpec->new
          (device => VirtualLsiLogicController->new
                     (key => 0,
                      device => [0],
                      busNumber => 0,
                      sharedBus => VirtualSCSISharing->new('noSharing')),
           operation => VirtualDeviceConfigSpecOperation->new( 'add' ) );

      my $idespec = VirtualDeviceConfigSpec->new

               ( device => VirtualIDEController->new

                    (busNumber => 0,

                    key => int(200), # IDE Controllers start at 200

                    device => [0],

                    deviceInfo => Description->new

                         ( label => "My IDE 0",

                         summary => "My IDE 0 Label" )),

                    operation => VirtualDeviceConfigSpecOperation->new( 'add' ) );

      my $cdspec = VirtualDeviceConfigSpec->new

     ( device => VirtualCdrom->new

           ( backing => VirtualCdromRemotePassthroughBackingInfo->new

                ( deviceName => "/vmfs/volumes/LD-Pool/android-x86-1.6-r2.iso",

               exclusive => 0),

          connectable => VirtualDeviceConnectInfo->new

                ( allowGuestControl => 1,

                connected => 0, # why is this needed, documented as not needed

                startConnected => 1 ),

          controllerKey => $idespec->device->key,

          key => int(3000), #All CDrom seem have a key starting at 3000

           unitNumber => 0),

           operation => VirtualDeviceConfigSpecOperation->new( 'add' ) );

}

# create virtual device config spec for disk
# ==========================================
sub create_virtual_disk {
   my %args = @_;
   my $ds_path = $args{ds_path};
   my $disksize = $args{disksize};
   my $disk_backing_info =
      VirtualDiskFlatVer2BackingInfo->new(diskMode => 'persistent',
                                          fileName => $ds_path,
                                          thinProvisioned => 'true');
   my $disk = VirtualDisk->new(backing => $disk_backing_info,
                               controllerKey => 0,
                               key => 0,
                               unitNumber => 0,
                               capacityInKB => $disksize);
   my $disk_vm_dev_conf_spec =
      VirtualDeviceConfigSpec->new(device => $disk,
               fileOperation => VirtualDeviceConfigSpecFileOperation->new('create'),
               operation => VirtualDeviceConfigSpecOperation->new('add'));
   return $disk_vm_dev_conf_spec;
}
thanks

0 Kudos
0 Replies