VMware Cloud Community
Naineyess
Enthusiast
Enthusiast

Automate the process for "Extend a Basic Volume"

Hi,

I am trying to automate the steps for disk extention of a VM (OS:- Windows as well as Linux) by using Orchestrator.

Please help me if anybody has any idea about this ..

Thanks !!

4 Replies
ChristianWehner
VMware Employee
VMware Employee

Hi Nayneyess,

take a look into the community, there are few posts about how to extend or add disks to a VM. Some samples:

Re: disk resizing

Re: CloneVm to SDRS Cluster / Storage Pod

Extend VMDK

How to extend a virtual Disk in a Workflow

There is also the way to get familiar with Onyx Onyx – VMware Labs where you are able to "record" what you are doing within vCenter (like executing an edit of a vm where you extended a disk of the vm) and seeing all necessary API calls which are needed. This API calls are even formatted in javascript and nearly "ready to run" with vRO Smiley Wink

Hope this helps to go further and invention your Extend a Basic Volume workflow Smiley Happy

BR, Chris

0 Kudos
john23
Commander
Commander

HAve u prepared any workflow for diskextension...??

Thanks -A Read my blogs: www.openwriteup.com
0 Kudos
Naineyess
Enthusiast
Enthusiast

Yeah I am using the script to increase the hard disk size, I am successful on that and now I want to automate the "extend basic volume" of the VM by using some script..

var devices = vm.config.hardware.device;

var firstDisk = null;

var diskSize = -1;

var newSizeInKB = newSize * 1024 * 1024;

System.log("devices " +devices);

//Finds the first VM disk

for (var i in devices)

    if (devices[i] instanceof VcVirtualDisk)

{

         firstDisk = devices[i];

System.log("first device " +firstDisk);

  

diskSize = firstDisk.capacityInKB;

System.log("old value" +diskSize);

//if (diskSize < 0 || newSizeInKB <= diskSize)

//System.log("No disk found, or the newSize is too small");; //No disk found, or the newSize is too small

var _key = firstDisk.key;

var _controllerKey = firstDisk.controllerKey;

var _unitNumber = firstDisk.unitNumber;

var _backing = firstDisk.backing;

var _newDiskSizeInKB = newSizeInKB;

System.log("key:" + _key + "\nControllerKey:" + _controllerKey + "\nUnitNumber:" + _unitNumber + "\nBacking:" + _backing);

if (_unitNumber == 0)

{

var _newVirtualDevice = new VcVirtualDisk();

_newVirtualDevice.controllerKey = _controllerKey;

_newVirtualDevice.key = _key;

_newVirtualDevice.backing = _backing;

_newVirtualDevice.unitNumber = _unitNumber;

_newVirtualDevice.capacityInKB = _newDiskSizeInKB;

System.log("key:" + _newVirtualDevice.key + "\nControllerKey:" + _newVirtualDevice.controllerKey + "\nUnitNumber:" + _newVirtualDevice.unitNumber + "\nBacking:" + _newVirtualDevice.backing + "\nNew Size:" + _newVirtualDevice.capacityInKB);

var _virtualDeviceConfigSpec = new VcVirtualDeviceConfigSpec();

_virtualDeviceConfigSpec.device = _newVirtualDevice;

_virtualDeviceConfigSpec.operation = VcVirtualDeviceConfigSpecOperation.edit;

//_virtualDeviceConfigSpec.fileOperation = VcVirtualDeviceConfigSpecFileOperation.replace;

var _virtualMachineConfigSpec = new VcVirtualMachineConfigSpec();

var changedDevices = new Array();

changedDevices.push(_virtualDeviceConfigSpec);

_virtualMachineConfigSpec.deviceChange = changedDevices;

actionResult = vm.reconfigVM_Task(_virtualMachineConfigSpec)

}

}

john23
Commander
Commander

thanks

Thanks -A Read my blogs: www.openwriteup.com
0 Kudos