Skip to content

Instantly share code, notes, and snippets.

@kclinden
Created January 29, 2019 13:07
Show Gist options
  • Select an option

  • Save kclinden/20ea961f9e9ec688610cc3c47286e2f5 to your computer and use it in GitHub Desktop.

Select an option

Save kclinden/20ea961f9e9ec688610cc3c47286e2f5 to your computer and use it in GitHub Desktop.
vRO Action to get the SCSI Controller number for a vm and bus number
//Description: vRO Action to get the SCSI Controller number for a vm and bus number
//Inputs: [VC:VirtualMachine] vm, [Number] scsiBusNumber
//Return Type: number
//Inputs: vm, scsiBusNumber
//Outputs scsiControllerKey
scsiControllerKey = -1;
var devices = vm.config.hardware.device;
var isScsiBusNumberInvalid = true;
if(scsiBusNumber==null || scsiBusNumber<0)
scsiBusNumber=0;
if ( devices != null ) {
for ( device in devices ) {
if ( devices[device] instanceof VcVirtualBusLogicController || devices[device] instanceof VcVirtualLsiLogicController
|| devices[device] instanceof VcParaVirtualSCSIController || devices[device] instanceof VcVirtualLsiLogicSASController ) {
if(scsiBusNumber==devices[device].busNumber){
scsiControllerKey = devices[device].key;
isScsiBusNumberInvalid = false;
System.log( "SCSI controller found. (Key: " + scsiControllerKey + ")" );
break;
}
}
}
}
if(isScsiBusNumberInvalid){
System.log( "SCSI controller not found. The bus number entered is invalid" );
}
return scsiControllerKey;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment