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

How to move extra disks to second controller

$
0
0

Hi,

 

I am trying to accomplish a pretty simple task, and it should be easy enough, but I cannot get it to work. I hope someone inhere will be able to figure out why.

 

I want to move all disks in a VM (Except for the first OS disk: Harddisk 1) to a second Para Virtual Controller (Controller 1) The controller is already added to the machine.

 

I have the following code, that runs successfully, but it does not accomplish the job, and I cannot figure out why. The environment is vSphere 6, and the vRO is version 7.0

 

Best Regards

Brian

 

var runtime = vm.config
var hardware = runtime.hardware;
var devices  = hardware.device;


var foundController = false;
var correctControllerType = false;


var disks = [];


var deviceConfigSpecs = new VcVirtualMachineConfigSpec();
deviceConfigSpecs.deviceChange = new Array();


System.log("deviceChange: " + deviceConfigSpecs.deviceChange);

//System.log("Number of Devices: " + devices.length);


for (var i in devices) {
  if (((devices[i].deviceInfo.label).indexOf("Hard disk 1") == -1) && ((devices[i].deviceInfo.label).indexOf("Hard disk") > -1)) {  System.log(i + " " + "deviceInfo Label: " + i + " - " + devices[i].deviceInfo.label);  System.log(i + " " + "Backing: " + i + " - " + devices[i].backing);  System.log(i + " " + "ControllerKey: " + i + " - " + devices[i].controllerKey);  disks.push(devices[i]);  }
}




if (disks.length > 0) { // Multiple disks found  for (var i in devices) {  if ( devices[i].deviceInfo.label == "SCSI controller 1") {  var controllerType = devices[i].deviceInfo.summary;  if (controllerType.indexOf("VMware paravirtual SCSI") > -1) {  System.log("Found Correct Controller for Disks");  var deviceControllerKey = devices[i].key;  }  }  }  if (deviceControllerKey) {  var unit = 1;  for (var i in disks) {  System.log("Checking Controller Key: " + deviceControllerKey + " for Disk: " + disks[i].deviceInfo.label + " with key: " + disks[i].controllerKey);  if (true) { // (disk[i].controllerKey != deviceControllerKey) {  var deviceConfigSpec = new VcVirtualDeviceConfigSpec();  deviceConfigSpec.operation = VcVirtualDeviceConfigSpecOperation.edit;  deviceConfigSpec.device = new VcVirtualDisk;  deviceConfigSpec.device = disks[i];  deviceConfigSpec.device.controllerKey = deviceControllerKey;  deviceConfigSpec.device.unitNumber = unit++;  deviceConfigSpecs.deviceChange.push(deviceConfigSpec);  System.log("Settings Controller Key: " + deviceControllerKey + " for Disk: " + disks[i].deviceInfo.label + " - unit: " + unit);  }  }  task = vm.reconfigVM_Task( deviceConfigSpecs );  }
}

Viewing all articles
Browse latest Browse all 6251

Trending Articles



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