Created
January 29, 2019 13:07
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //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