Quantcast
Channel: VMware Communities : Discussion List - vRealize Orchestrator
Viewing all articles
Browse latest Browse all 6251

Vco script for setting virtual flash read cache not working

$
0
0

The following script locates vim hosts, virtual machines and tries to configure flash read cache for the virtual disks.

I can see completed "reconfigure virtual machine" tasks in the vsphere server but when I open virtual machine configuration, no changes are made regarding virtual flash read cache.

Could someone help me to figure out what the problem is?

 

 

var vimHosts = VcPlugin.getVimHosts();

 

 

 

 

System.log(vimHosts.length + " Vim hosts found");

 

 

 

 

for (var i = 0; i < vimHosts.length; i++)

{

  var vimHost = vimHosts[i];

 

  System.log("Vim host Id: '" + vimHost.id + "'");

 

 

 

 

  var vms = vimHost.getAllVirtualMachines();

 

 

 

 

  if (vms != null)

  {

  for (var j = 0; j < vms.length; j++)

  {

  var vm = vms[j];

 

 

 

 

  System.log("--- VM '" + vm.name + "'");

 

 

 

 

  for each (var device in vm.config.hardware.device)

  {

  if (device instanceof VcVirtualDisk)

  {

  System.log("      ---- Disk: '" + device.deviceInfo.label + "' '" + device.capacityInKB + "'");

 

  var vflashConfig = device.vFlashCacheConfigInfo;

 

  if (vflashConfig != null)

  {

  System.log("           ---- vFlash Module:'" + vflashConfig.vFlashModule + "'");

  System.log("           ---- vFlash Cache Mode:'" + vflashConfig.cacheMode + "'");

  System.log("           ---- vFlash Cache Consistency Type:'" + vflashConfig.cacheConsistencyType + "'");

  System.log("           ---- vFlash Blocksize:'" + vflashConfig.blockSizeInKB + "'");

  System.log("           ---- vFlash Reservation:'" + vflashConfig.reservationInMB + "'");

  }

 

  var spec = new VcVirtualMachineConfigSpec();

  spec.deviceChange = [];

  var VirtualDeviceConfigSpec = new VcVirtualDeviceConfigSpec();

  VirtualDeviceConfigSpec.operation = VcVirtualDeviceConfigSpecOperation.edit;

 

  var vflashConfigMod = new VcVirtualDiskVFlashCacheConfigInfo();

 

  vflashConfigMod.blockSizeInKB="4";

 

  if (device.capacityInKB < 204800)

  {

  var z =  device.capacityInKB / 1024;

  vflashConfigMod.reservationInMB=z;

  }

  else if (device.capacityInKB < 6291456)

  {

  vflashConfigMod.reservationInMB="180";

  }

  else

  {

  vflashConfigMod.reservationInMB="280";

  }

 

  vflashConfigMod.cacheConsistencyType="strong";

  vflashConfigMod.cacheMode="write_thru";

  vflashConfigMod.vFlashModule="vfc";

 

  device.vFlashCacheConfigInfo=vflashConfigMod;

 

  VirtualDeviceConfigSpec[0] = device;

 

  spec.deviceChange[0] = VirtualDeviceConfigSpec;

 

  task = vm.reconfigVM_Task( spec );

 

 

 

 

  }

  }

  }

  }

}


Viewing all articles
Browse latest Browse all 6251

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>