Hello everyone,
I’ve didn’t write any posts for a really long time. This short article will be about vRO workflow used for 2nd-day actions in vRA to limit IOPS on disks.
vRO Part:
First, we need to create our vRO script:
var devices = vm.config.hardware.device;
var disks = new Array();
for (i=0;i<devices.length;i++) { if(devices[i].DeviceInfo.Label.indexOf('Hard disk')>=0){
disks.push(devices[i]);
}
}
for each (disk in disks){
System.log("Current IOPS limit for disk - "+disk.DeviceInfo.Label+ " is " + disk.storageIOAllocation.limit);
var newVMSpec = new VcVirtualMachineConfigSpec() ;
var newDiskSpec = new VcVirtualDeviceConfigSpec() ;
disk.storageIOAllocation.limit = newIOLimit;
System.log("New IOPS limit for disk - "+disk.DeviceInfo.Label+ " is " + disk.storageIOAllocation.limit);
newDiskSpec.device = disk;
newDiskSpec.operation=VcVirtualDeviceConfigSpecOperation.edit;
var deviceChange = new Array();
deviceChange.push(newDiskSpec);
newVMSpec.deviceChange = deviceChange;
vm.reconfigVM_Task(newVMSpec);
}
var disks = new Array();
for (i=0;i<devices.length;i++) { if(devices[i].DeviceInfo.Label.indexOf('Hard disk')>=0){
disks.push(devices[i]);
}
}
for each (disk in disks){
System.log("Current IOPS limit for disk - "+disk.DeviceInfo.Label+ " is " + disk.storageIOAllocation.limit);
var newVMSpec = new VcVirtualMachineConfigSpec() ;
var newDiskSpec = new VcVirtualDeviceConfigSpec() ;
disk.storageIOAllocation.limit = newIOLimit;
System.log("New IOPS limit for disk - "+disk.DeviceInfo.Label+ " is " + disk.storageIOAllocation.limit);
newDiskSpec.device = disk;
newDiskSpec.operation=VcVirtualDeviceConfigSpecOperation.edit;
var deviceChange = new Array();
deviceChange.push(newDiskSpec);
newVMSpec.deviceChange = deviceChange;
vm.reconfigVM_Task(newVMSpec);
}
Set Input Parameters:
- vm – VC:VirtualMachine
- newIOLimit- number
In here this IOPS limit will apply for all Disks on the VM.
vRA part:
- Go to design tab XaaS-Resource Actions and create new one
- Choose Required Workflow from the Orchestrator
- input parameter VM:
- Choose the proper Name . also you can choose Criterias – only exact Buiseness Group for example.
- Customize the input view for the end user. For numbers I prefer to use Sliders (as they look awesome!) dont forget to add constraints
- Publish the Action:
- Go To Entitlements and assign it to the business group:
- Go to your items and click actions: you should be able to see it:
- We check the request status:
- vRO workflow run successfully:
- We check vCenter:
Now we can let users choose the IOPS of their VM’s HDDs.
Hope it was interesting for you!