Quantcast
Channel: VMware Communities : Discussion List - ESXi
Viewing all articles
Browse latest Browse all 8132

The operation is not allowed in the current state error while attaching disk through PVSCSI controller

$
0
0

Hi All,

 

I have a requirement where I need to attach multiple disks to a VM through PVSCSI controller. If there are no free PVSCSI controller(or free slot), first I attach PVSCSI controller and then attach disk

Below is the code to attach disks. Sometimes, I get The operation is not allowed in the current state error while attaching the disks. Could you please let me know if there is any way to handle this programatically?

Task Console shows "Reconfiguring Virtual Machine on destination host" in the details column.

 

for idx in range(no_of_disks):

   if idx > 0:

  create_new_cont = False
   controller_key, disk_slot = << Identify the constroller and free slot here>>

   if controller_key is None:

   self.era_logger.INFO("Controller could not be found")

   return None
  else:

   self.era_logger.INFO("Attaching disk to controller:" + str(controller_key)+" Disk slot:"+str(disk_slot))

   self.era_logger.INFO("Info before disk attaching :" + str(controller_key))

   self.log_disk_info(vm)

  spec = vim.vm.ConfigSpec()

  dev_changes = []

  new_disk_kb = int(disk_size)

  disk_spec = vim.vm.device.VirtualDeviceSpec()

  disk_spec.fileOperation = "create"
   disk_spec.operation = vim.vm.device.VirtualDeviceSpec.Operation.add

  disk_spec.device = vim.vm.device.VirtualDisk()

  disk_spec.device.backing = vim.vm.device.VirtualDisk.FlatVer2BackingInfo()

   if disk_type == 'thin':

  disk_spec.device.backing.thinProvisioned = True
   disk_spec.device.backing.diskMode = 'persistent'
   disk_spec.device.unitNumber = disk_slot

  disk_spec.device.capacityInKB = new_disk_kb

  disk_spec.device.controllerKey = controller_key

  dev_changes.append(disk_spec)

  spec.deviceChange = dev_changes

  task = vm.ReconfigVM_Task(spec=spec)

  self.era_logger.INFO("Waiting for disk attach task to finish...")


Viewing all articles
Browse latest Browse all 8132

Trending Articles



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