VMware Cloud Community
ayaz4324
Contributor
Contributor

Adding Disk to a Specific SCSI ID (2:2) without VM power cycle

I am using VMware powercli API to add a Hard drive to an existing VM on a specific controller slot such as 2:2 or 3:3 but I am not able to do that without having the VM in power off state. We some 3rd application that is allowing us to add hard disk to any controller slot without requiring the VM to powered off.

here is the powercli code snippet where I am trying to change the controller unit number of the hard drive

Using powercli 5.5 plugin

$hd = Get-HardDisk -VM $vm |
  Where {$_.ExtensionData.Backing.UUid -eq $hd.ExtensionData.Backing.Uuid}

$vm = Get-View (Get-VM $vm).ID
$specVM = New-Object VMware.Vim.VirtualMachineConfigSpec
$specVM.deviceChange = @()
$specVM.deviceChange += New-Object VMware.Vim.VirtualDeviceConfigSpec
$specVM.deviceChange[0].operation = "edit"
$specVM.deviceChange[0].device = $hd.ExtensionData
$specVM.deviceChange[0].device.unitNumber = $controllerUnitNum
$vm.ExtensionData.ReconfigVM_Task($specVM)

The reconfig VM operation fails with the following error message:

The attempted operation cannot be performed in the current state (Powered on).

Are there any properties that can be set to allow hot swap the controller unit number? Any suggestion will be highly appreciated.

Thank You

Ayaz Ahmed

Atos Cloud Operations

0 Kudos
6 Replies
LucD
Leadership
Leadership

This is a safety measure in vSphere afaik.

Since you are using the API method, I don't see how you could avoid this.

Which might be that 3th party tool that permits you to do that ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
ayaz4324
Contributor
Contributor

We are using a 3rd Party tool called CPO from Cisco that allows us to add the disk into any SCSI ID (x:y, controller : unit number) but the problem is it names .vmdk files that not consistent VMware's naming convention e.g. [DATA_STORE] <VM_NAME>/<VM_NAME>_3.vmdk which is causing our svMotion of data stores are failing

Thanks

Ayaz

0 Kudos
LucD
Leadership
Leadership

Is that Cisco Process Orchestrator ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
ayaz4324
Contributor
Contributor

That is correct. It names the .vmk by adding additional random numbers in name extension which is causing all the issues for svMotion.

0 Kudos
LucD
Leadership
Leadership

I have been playing with fixing PCI bus# and SCSI id#, but my code is not foolproof.

On a side note, which guest OS do you have running in those VMs ?

Or is it a mix ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
ayaz4324
Contributor
Contributor

It's a mix of various Linux distributions and Windows 2K8-2K12 STD and ENT

0 Kudos