Created
January 29, 2019 13:05
-
-
Save kclinden/337d027f44ef8ba913cf919a590742e4 to your computer and use it in GitHub Desktop.
vRO Action to get next SCSI bus number for a given VC:VirtualMachine
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 next SCSI bus number for a given VC:VirtualMachine | |
| //Inputs: [VC:VirtualMachine] virtualMachine | |
| //Return Type: number | |
| //Get next scsi bus number | |
| var devices = virtualMachine.config.hardware.device; | |
| if (devices != null) { | |
| var highBusNumber = -1; | |
| for each (device in devices){ | |
| System.debug(device); | |
| var is_controller = device instanceof VcParaVirtualSCSIController || device instanceof VcVirtualLsiLogicController || device instanceof VcVirtualLsiLogicSASController; | |
| if (is_controller){ | |
| var contollerKey = device.key; | |
| var busNumber = device.busNumber; | |
| System.log("Controller Key: " + contollerKey); | |
| System.log("Controller Bus Number: " + busNumber); | |
| if(busNumber > highBusNumber){ | |
| highBusNumber = busNumber; | |
| System.log("New high bus number is " + highBusNumber); | |
| } //highBusNumber | |
| } //is_controller | |
| } //For each device in devices | |
| var nextBusNumber = highBusNumber + 1; | |
| System.log("The next bus nubmer will be: " + nextBusNumber); | |
| } // if device | |
| return nextBusNumber; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment