VMware Cloud Community
Sergio81
Contributor
Contributor
Jump to solution

Get all virtual disk from a VM in workflow

Hi,

because on VRA/VRO 7.0.1 reconfigure VM does not have the lifecycle event broker, i need to retrive some information about VM to synchronize the new state on the database.

I can't find the method to get the name of virtual disk and their SCSI id

i need something like this:

Server-1

'Hard Disk 1' 'SCSI (0:0)'

'Hard Disk 2' 'SCSI (0:1)'

'Hard Disk 3' 'SCSI (0:2)'

Server-2

'Hard Disk 1' 'SCSI (0:0)'

'Hard Disk 2' 'SCSI (0:1)'

[...]


Now i use this simple test script in VRO Javascript Workflow:


var vms = VcPlugin.getAllVirtualMachines();

for(i in vms){

    var vm = vms[i];

    vmInfo(vm);

var devices = vm.config.hardware.device;

if ( devices != null )  {

    for ( device in devices )  {

var label_name = devices[device].deviceInfo.label

System.log( "label name:" + label_name );

var summary_name = devices[device].deviceInfo.summaryl

System.log( "summary name:" + summary_name );

        if ( devices[device] instanceof VcVirtualBusLogicController || devices[device] instanceof VcVirtualLsiLogicController

        || devices[device] instanceof VcParaVirtualSCSIController || devices[device] instanceof VcVirtualLsiLogicSASController )  {

scsiControllerKey = devices[device].key;

bus = devices[device];

busNumber = devices[device].busNumber;

//           System.log( "SCSI controller found. (Key: " + scsiControllerKey + ")" );

// System.log(" Bus Number: "+busNumber);

break;

        }

    }

}

but print an output like this:

[...]

2016-06-06 16:25:48.707] [I] label name:Video card

[2016-06-06 16:25:48.709] [I] summary name:undefined

[2016-06-06 16:25:48.711] [I] label name:VMCI device

[2016-06-06 16:25:48.714] [I] summary name:undefined

[2016-06-06 16:25:48.716] [I] label name:SCSI controller 0

[2016-06-06 16:25:48.718] [I] summary name:undefined

[2016-06-06 16:25:48.720] [I] SCSI controller found. (Key: 1000)

[2016-06-06 16:25:48.722] [I]  Bus Number: 0

[...]

can someone help me?

Thanks so much

Sergio

Reply
0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi Sergio,

Here is some sample code  (the input parameter is vm of type virtual machine):

var devices = vm.config.hardware.device;

for each (controller in devices) {

  var is_scsi = controller instanceof VcVirtualBusLogicController || controller instanceof VcVirtualLsiLogicController

       || controller instanceof VcParaVirtualSCSIController || controller instanceof VcVirtualLsiLogicSASController;

  if (!is_scsi) {

    continue;

  }

  var controller_label = controller.deviceInfo.label;

  System.log("SCSI controller found: " + controller_label);

  for each (device in devices) {

    if (device.controllerKey == controller.key) {

      var scsi_id = controller.busNumber + ":" + device.unitNumber;

      System.log("    device found:  '" + device.deviceInfo.label + "'  'SCSI (" + scsi_id + ")'");

    }

  }

}

SCSI ID is a combination of controller's bus number and device's unit number.

View solution in original post

2 Replies
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi Sergio,

Here is some sample code  (the input parameter is vm of type virtual machine):

var devices = vm.config.hardware.device;

for each (controller in devices) {

  var is_scsi = controller instanceof VcVirtualBusLogicController || controller instanceof VcVirtualLsiLogicController

       || controller instanceof VcParaVirtualSCSIController || controller instanceof VcVirtualLsiLogicSASController;

  if (!is_scsi) {

    continue;

  }

  var controller_label = controller.deviceInfo.label;

  System.log("SCSI controller found: " + controller_label);

  for each (device in devices) {

    if (device.controllerKey == controller.key) {

      var scsi_id = controller.busNumber + ":" + device.unitNumber;

      System.log("    device found:  '" + device.deviceInfo.label + "'  'SCSI (" + scsi_id + ")'");

    }

  }

}

SCSI ID is a combination of controller's bus number and device's unit number.

Sergio81
Contributor
Contributor
Jump to solution

Perfect !!

Thank you very much

Reply
0 Kudos