Exemplo n.º 1
0
def TestAddDevice(vm1, device, allowVMotion, ctlr):
    Log("Testing adding of device '" + device.description + "' for VM " +
        vm1.GetConfig().GetName() + " allowVmotion:" + str(allowVMotion))
    cspec = Vim.Vm.ConfigSpec()

    cspec = vmconfig.AddUSBDev(cspec,
                               cfgInfo=vm1.GetConfig(),
                               devName=device.name,
                               allowVMotion=allowVMotion,
                               ctlr=ctlr)
    # Hot-add the devices
    vm.Reconfigure(vm1, cspec)

    # Check for device presence in VM's config
    usbDev = CheckDevice(vm1, Vim.Vm.Device.VirtualUSB, "USB device")
    ctlrDev = vmconfig.GetControllers(vmconfig.GetCfgOption(None), ctlr,
                                      vm1.GetConfig(), Vim.Vm.ConfigSpec())[0]
    if ctlrDev.key != usbDev.controllerKey:
        raise Exception("Wrong controller for USB device:" +
                        str(usbDev.controllerKey))
Exemplo n.º 2
0
def main():
   supportedArgs = [ (["h:", "host="], "localhost", "Host name", "host"),
                     (["u:", "user="******"root", "User name", "user"),
                     (["p:", "pwd="], "ca$hc0w", "Password", "pwd"),
                     (["d:", "disk="], "/vmfs/devices/", "Disk", "disk"),
                     (["s:", "ds="], "storage1", "Datastore 1", "ds"),
                     (["f:", "file="], "[datastore1] rdm/rdm.vmdk", "Virtual Disk", "file"),
                     (["v:", "vmname="], "RdmVM", "Name of the virtual machine", "vmname"),
                     (["i:", "numiter="], "1", "Number of iterations", "iter") ]

   supportedToggles = [ (["usage", "help"], False, "Show usage information", "usage"),
                        (["runall", "r"], True, "Run all the tests", "runall"),
                        (["nodelete"], False, "Dont delete vm on completion", "nodelete") ]

   args = arguments.Arguments(sys.argv, supportedArgs, supportedToggles)
   if args.GetKeyValue("usage") == True:
      args.Usage()
      sys.exit(0)

   # Connect
   si = SmartConnect(host=args.GetKeyValue("host"),
                     user=args.GetKeyValue("user"),
                     pwd=args.GetKeyValue("pwd"))
   atexit.register(Disconnect, si)

   # Process command line
   vmname = args.GetKeyValue("vmname")
   numiter = int(args.GetKeyValue("iter"))
   runall = args.GetKeyValue("runall")
   noDelete = args.GetKeyValue("nodelete")
   disk = args.GetKeyValue("disk")
   ds = args.GetKeyValue("ds")
   rdmDiskFile = args.GetKeyValue("file")


   status = "PASS"

   for i in range(numiter):
       bigClock = StopWatch()
       vm1 = None
       try:
           ## Cleanup old VMs
           vm1 = folder.Find(vmname)
           if vm1 != None:
               vm1.Destroy()

           Log("Creating VM: " + str(vmname))

           ## Add scsi disk
           Log("Adding a new rdm disk to VM: " + str(vmname))
           cspec = Vim.Vm.ConfigSpec()
           cspec = vmconfig.CreateDefaultSpec(name = vmname, datastoreName = ds)
           cspec = vmconfig.AddScsiCtlr(cspec)

           # Get config options and targets
           cfgOption = vmconfig.GetCfgOption(None)
           cfgTarget = vmconfig.GetCfgTarget(None)

           rdmBacking = Vim.Vm.Device.VirtualDisk.RawDiskMappingVer1BackingInfo()
           rdmBacking.SetFileName("");
           rdmBacking.SetDeviceName(disk);
           rdmBacking.SetCompatibilityMode("physicalMode");
           rdmBacking.SetDiskMode("");
           rdmBacking.SetParent(None);

           diskDev = Vim.Vm.Device.VirtualDisk()
           diskDev.SetKey(vmconfig.GetFreeKey(cspec))
           diskDev.SetBacking(rdmBacking)
           ctlrs = vmconfig.GetControllers(cfgOption, Vim.Vm.Device.VirtualSCSIController, None, cspec)

           # XXX Fix this up
           for ctlrIdx in range(len(ctlrs)):
              freeSlot = vmconfig.GetFreeSlot(cspec, None, cfgOption, ctlrs[ctlrIdx])
              if (freeSlot >= 0):
                 diskDev.SetControllerKey(ctlrs[ctlrIdx].GetKey())
                 diskDev.SetUnitNumber(-1)
                 diskDev.SetCapacityInKB(long(4096))
                 break


           vmconfig.AddDeviceToSpec(cspec, diskDev, \
                    Vim.Vm.Device.VirtualDeviceSpec.Operation.add, \
                    Vim.Vm.Device.VirtualDeviceSpec.FileOperation.create)

           Log("create VM: " + str(vmname) + " with the RDM disk")
           vmFolder = vm.GetVmFolder()
           resPool = vm.GetResourcePool()

           task = vmFolder.CreateVm(cspec, resPool)
           WaitForTask(task)
           Log("Finished Reconfiguring VM: " + str(vmname));
           vm1 = task.info.result

           Log("Now reconfiguring VM: " + str(vmname));

           cspec = Vim.Vm.ConfigSpec()

           rdmBacking = Vim.Vm.Device.VirtualDisk.RawDiskMappingVer1BackingInfo()
           rdmBacking.SetFileName(rdmDiskFile);
           rdmBacking.SetCompatibilityMode("physicalMode");
           rdmBacking.SetDiskMode("persistent");
           rdmBacking.SetParent(None);

           diskDev = Vim.Vm.Device.VirtualDisk()
           diskDev.SetKey(vmconfig.GetFreeKey(cspec))
           diskDev.SetBacking(rdmBacking)
           ctlrs = vmconfig.GetControllers(cfgOption, Vim.Vm.Device.VirtualSCSIController, vm1.GetConfig(), cspec)
           # XXX Fix this up
           for ctlrIdx in range(len(ctlrs)):
              freeSlot = vmconfig.GetFreeSlot(cspec, vm1.GetConfig(), cfgOption, ctlrs[ctlrIdx])
              if (freeSlot >= 0):
                 diskDev.SetControllerKey(ctlrs[ctlrIdx].GetKey())
                 diskDev.SetUnitNumber(-1)
                 diskDev.SetCapacityInKB(long(4096))
                 break


           vmconfig.AddDeviceToSpec(cspec, diskDev, \
                    Vim.Vm.Device.VirtualDeviceSpec.Operation.add, \
                    Vim.Vm.Device.VirtualDeviceSpec.FileOperation.create)
           vm.Reconfigure(vm1, cspec)
           task = vmFolder.ReconfigVm(cspec, resPool)
           WaitForTask(task)
           Log("Finished Reconfiguring VM: " + str(vmname));


       except Exception as e:
           status = "FAIL"
           Log("Caught exception : " + str(e))
   Log("TEST RUN COMPLETE: " + status)
Exemplo n.º 3
0
def test1():
    Log("\nTEST 1 Start\n")
    try:
        #------------------------------------------------
        # Add a disk without VFlash Cache Reservation set
        #------------------------------------------------
        vmConfig = vm1.GetConfig()
        vmRuntime = vm1.GetRuntime()
        vFlashCacheReservation = vmConfig.GetVFlashCacheReservation()
        vFlashCacheAllocation = vmRuntime.GetVFlashCacheAllocation()
        Log("\n\nTotal VFlash Cache Reservation before addition: " +
            str(vFlashCacheReservation) +
            "\nTotal VFlash Cache Allocation  before addition: " +
            str(vFlashCacheAllocation))

        cspec = Vim.Vm.ConfigSpec()

        # Get config options and targets
        cfgOption = vmconfig.GetCfgOption(None)
        cfgTarget = vmconfig.GetCfgTarget(None)

        p = re.compile("\[" + datastore + "\]")
        for device in vmConfig.hardware.device:
            try:
                if device.backing and device.backing.fileName and p.search(
                        device.backing.fileName):
                    diskDev = device
                    break
            except Exception as e:
                Log("Checking disk..")

        backing = diskDev.GetBacking()
        backing.SetFileName("[" + datastore + "] " + str(vmname) +
                            "/regressionCheckDisk.vmdk")
        diskDev.SetBacking(backing)
        diskDev.SetVFlashCacheConfigInfo(None)

        ctlrs = vmconfig.GetControllers(cfgOption,
                                        Vim.Vm.Device.VirtualSCSIController,
                                        vm1.GetConfig(), cspec)
        diskDev.SetControllerKey(ctlrs[0].GetKey())
        diskDev.SetUnitNumber(-1)
        diskDev.SetCapacityInKB(long(4096))
        diskDev.SetCapacityInBytes(long(4096) * 1024)

        vmconfig.AddDeviceToSpec(cspec, diskDev, \
                  Vim.Vm.Device.VirtualDeviceSpec.Operation.add, \
                  Vim.Vm.Device.VirtualDeviceSpec.FileOperation.create)

        Log("Calling Reconfigure...")
        vm.Reconfigure(vm1, cspec)
        Log("Finished Reconfiguring VM: " + str(vmname))

        vmConfig = vm1.GetConfig()
        vmRuntime = vm1.GetRuntime()
        vFlashCacheReservation = vmConfig.GetVFlashCacheReservation()
        vFlashCacheAllocation = vmRuntime.GetVFlashCacheAllocation()
        Log("\n\nTotal VFlash Cache Reservation after addition: " +
            str(vFlashCacheReservation) +
            "\nTotal VFlash Cache Allocation  after addition: " +
            str(vFlashCacheAllocation))

        #--------------------------------------------------
        # check the virtual disk for VFlashCacheConfigInfo
        #--------------------------------------------------
        p = re.compile("regressionCheckDisk.vmdk")
        found = "false"
        for device in vmConfig.hardware.device:
            try:
                if device.backing and device.backing.fileName and p.search(
                        device.backing.fileName):
                    diskDev = device
                    found = "true"
                    break
            except Exception as e:
                Log("Checking disk..")

        if (found == "true"):
            Log("Added disk found")
        else:
            Log("Added disk not found")
            sys.exit("ERROR")

        Log("VFlash Cache Configuration to be set on the disk")
        print(diskDev.GetVFlashCacheConfigInfo())

        #----------------------------------------------
        # delete the disk and check VFlash Reservation
        #----------------------------------------------
        Log("Deleting the disk now.")
        cspec = Vim.Vm.ConfigSpec()

        vmconfig.AddDeviceToSpec(cspec, diskDev, \
                   Vim.Vm.Device.VirtualDeviceSpec.Operation.remove, \
                   Vim.Vm.Device.VirtualDeviceSpec.FileOperation.destroy)

        Log("Calling Reconfigure...")
        vm.Reconfigure(vm1, cspec)
        Log("Finished Reconfiguring VM: " + str(vmname))

        vmConfig = vm1.GetConfig()
        vmRuntime = vm1.GetRuntime()
        vFlashCacheReservation = vmConfig.GetVFlashCacheReservation()
        vFlashCacheAllocation = vmRuntime.GetVFlashCacheAllocation()
        Log("\n\nTotal VFlash Cache Reservation after deletion: " +
            str(vFlashCacheReservation) +
            "\nTotal VFlash Cache Allocation  after deletion: " +
            str(vFlashCacheAllocation))

    except Exception as e:
        Log("Caught exception : " + str(e))

    Log("\nTEST 1 End\n")
Exemplo n.º 4
0
def test3():
    Log("\nTEST 3 Start\n")
    try:
        #---------------------------------------------
        # Add a disk with VFlash Cache Reservation set
        #---------------------------------------------
        vmConfig = vm1.GetConfig()
        vmRuntime = vm1.GetRuntime()
        vFlashCacheReservation = vmConfig.GetVFlashCacheReservation()
        vFlashCacheAllocation = vmRuntime.GetVFlashCacheAllocation()
        Log("\n\nTotal VFlash Cache Reservation before addition: " +
            str(vFlashCacheReservation) +
            "\nTotal VFlash Cache Allocation before addition: " +
            str(vFlashCacheAllocation))

        cspec = Vim.Vm.ConfigSpec()

        # Get config options and targets
        cfgOption = vmconfig.GetCfgOption(None)
        cfgTarget = vmconfig.GetCfgTarget(None)

        #------------------
        # Disk 1: vFC 4MB
        #------------------
        # VFlash Cache Configuration
        vfcInfo = Vim.Vm.Device.VirtualDisk.VFlashCacheConfigInfo()
        vfcInfo.SetReservationInMB(4)

        p = re.compile("\[" + datastore + "\]")
        for device in vmConfig.hardware.device:
            try:
                if device.backing and device.backing.fileName and p.search(
                        device.backing.fileName):
                    diskDev = device
                    break
            except Exception as e:
                Log("Checking disk..")

        backing = diskDev.GetBacking()
        backing.SetFileName("[" + datastore + "] " + str(vmname) +
                            "/VMVFlashCacheDisk_01.vmdk")

        diskDev.SetBacking(backing)
        diskDev.SetVFlashCacheConfigInfo(vfcInfo)

        Log("VFlash Cache Configuration to be set on the disk")
        print(diskDev.GetVFlashCacheConfigInfo())

        ctlrs = vmconfig.GetControllers(cfgOption,
                                        Vim.Vm.Device.VirtualSCSIController,
                                        vm1.GetConfig(), cspec)
        diskDev.SetControllerKey(ctlrs[0].GetKey())
        diskDev.SetUnitNumber(-1)
        diskDev.SetCapacityInKB(long(8192))
        diskDev.SetCapacityInBytes(long(8192) * 1024)

        vmconfig.AddDeviceToSpec(cspec, diskDev, \
                  Vim.Vm.Device.VirtualDeviceSpec.Operation.add, \
                  Vim.Vm.Device.VirtualDeviceSpec.FileOperation.create)

        Log("Calling Reconfigure...")
        vm.Reconfigure(vm1, cspec)
        Log("Finished Reconfiguring VM: " + str(vmname))

        #------------------
        # Disk 2: vFC 0
        #------------------
        cspec = Vim.Vm.ConfigSpec()

        # Get config options and targets
        cfgOption = vmconfig.GetCfgOption(None)
        cfgTarget = vmconfig.GetCfgTarget(None)

        # VFlash Cache Configuration
        vfcInfo = Vim.Vm.Device.VirtualDisk.VFlashCacheConfigInfo()
        vfcInfo.SetReservationInMB(0)

        p = re.compile("\[" + datastore + "\]")
        for device in vmConfig.hardware.device:
            try:
                if device.backing and device.backing.fileName and p.search(
                        device.backing.fileName):
                    diskDev = device
                    break
            except Exception as e:
                Log("Checking disk..")

        backing = diskDev.GetBacking()
        backing.SetFileName("[" + datastore + "] " + str(vmname) +
                            "/VMVFlashCacheDisk_02.vmdk")

        diskDev.SetBacking(backing)
        diskDev.SetVFlashCacheConfigInfo(vfcInfo)

        Log("VFlash Cache Configuration to be set on the disk")
        print(diskDev.GetVFlashCacheConfigInfo())

        ctlrs = vmconfig.GetControllers(cfgOption,
                                        Vim.Vm.Device.VirtualSCSIController,
                                        vm1.GetConfig(), cspec)
        diskDev.SetControllerKey(ctlrs[0].GetKey())
        diskDev.SetUnitNumber(-1)
        diskDev.SetCapacityInKB(long(8192))
        diskDev.SetCapacityInBytes(long(8192) * 1024)

        vmconfig.AddDeviceToSpec(cspec, diskDev, \
                  Vim.Vm.Device.VirtualDeviceSpec.Operation.add, \
                  Vim.Vm.Device.VirtualDeviceSpec.FileOperation.create)

        Log("Calling Reconfigure...")
        vm.Reconfigure(vm1, cspec)
        Log("Finished Reconfiguring VM: " + str(vmname))

        vmConfig = vm1.GetConfig()
        vmRuntime = vm1.GetRuntime()
        vFlashCacheReservation = vmConfig.GetVFlashCacheReservation()
        vFlashCacheAllocation = vmRuntime.GetVFlashCacheAllocation()
        Log("\n\nTotal VFlash Cache Reservation after addition: " +
            str(vFlashCacheReservation) +
            "\nTotal VFlash Cache Allocation  after addition: " +
            str(vFlashCacheAllocation))

        #--------------------------------------------------
        # check the virtual disk for VFlashCacheConfigInfo
        #--------------------------------------------------
        p = re.compile("VMVFlashCacheDisk")
        for device in vmConfig.hardware.device:
            try:
                if device.backing and device.backing.fileName and p.search(
                        device.backing.fileName):
                    diskDev = device
                    Log("VFlash Cache Configuration set on the disk")
                    print(diskDev.GetVFlashCacheConfigInfo())
            except Exception as e:
                Log("Checking disk..")

        #----------------------------------------------
        # Edit the device
        #----------------------------------------------
        Log("Editing the disk now.")

        # Disk 1: set vFC to 0
        # Disk 2: set vFC to 8MB

        cspec = Vim.Vm.ConfigSpec()
        p = re.compile("VMVFlashCacheDisk_01")
        found = "false"
        for device in vmConfig.hardware.device:
            try:
                if device.backing and device.backing.fileName and p.search(
                        device.backing.fileName):
                    diskDev = device
                    found = "true"
                    break
            except Exception as e:
                Log("Checking disk..")

        if (found == "true"):
            Log("VFlash Cache Configuration set on the disk")
            print(diskDev.GetVFlashCacheConfigInfo())
        else:
            Log("Added disk 1 not found")
            sys.exit("ERROR")

        vfcInfo = diskDev.GetVFlashCacheConfigInfo()
        vfcInfo.SetReservationInMB(0)
        diskDev.SetVFlashCacheConfigInfo(vfcInfo)

        vmconfig.AddDeviceToSpec(cspec, diskDev, \
                   Vim.Vm.Device.VirtualDeviceSpec.Operation.edit)

        Log("Calling Reconfigure... Setting vFC Reservation to 0")
        vm.Reconfigure(vm1, cspec)
        Log("Finished Reconfiguring VM: " + str(vmname))

        cspec = Vim.Vm.ConfigSpec()
        p = re.compile("VMVFlashCacheDisk_02")
        found = "false"
        for device in vmConfig.hardware.device:
            try:
                if device.backing and device.backing.fileName and p.search(
                        device.backing.fileName):
                    diskDev = device
                    found = "true"
                    break
            except Exception as e:
                Log("Checking disk..")

        if (found == "true"):
            Log("VFlash Cache Configuration set on the disk")
            print(diskDev.GetVFlashCacheConfigInfo())
        else:
            Log("Added disk 2 not found")
            sys.exit("ERROR")

        vfcInfo = Vim.Vm.Device.VirtualDisk.VFlashCacheConfigInfo()
        vfcInfo.SetReservationInMB(8)
        diskDev.SetVFlashCacheConfigInfo(vfcInfo)

        vmconfig.AddDeviceToSpec(cspec, diskDev, \
                   Vim.Vm.Device.VirtualDeviceSpec.Operation.edit)

        Log("Calling Reconfigure... Setting vFC Reservation to 8")
        vm.Reconfigure(vm1, cspec)
        Log("Finished Reconfiguring VM: " + str(vmname))

        vmConfig = vm1.GetConfig()
        vmRuntime = vm1.GetRuntime()
        vFlashCacheReservation = vmConfig.GetVFlashCacheReservation()
        vFlashCacheAllocation = vmRuntime.GetVFlashCacheAllocation()
        Log("\n\nTotal VFlash Cache Reservation after edit: " +
            str(vFlashCacheReservation) +
            "\nTotal VFlash Cache Allocation  after edit: " +
            str(vFlashCacheAllocation))

        #------------------------------------------------------------
        # check and delete the virtual disk for VFlashCacheConfigInfo
        #------------------------------------------------------------
        p = re.compile("VMVFlashCacheDisk")
        for device in vmConfig.hardware.device:
            try:
                if device.backing and device.backing.fileName and p.search(
                        device.backing.fileName):
                    diskDev = device
                    Log("VFlash Cache Configuration set on the disk")
                    print(diskDev.GetVFlashCacheConfigInfo())

                    Log("Deleting the disk now.")
                    cspec = Vim.Vm.ConfigSpec()

                    vmconfig.AddDeviceToSpec(cspec, diskDev, \
                               Vim.Vm.Device.VirtualDeviceSpec.Operation.remove, \
                               Vim.Vm.Device.VirtualDeviceSpec.FileOperation.destroy)
                    vm.Reconfigure(vm1, cspec)

            except Exception as e:
                Log("Checking disk..")

        vmConfig = vm1.GetConfig()
        vmRuntime = vm1.GetRuntime()
        vFlashCacheReservation = vmConfig.GetVFlashCacheReservation()
        vFlashCacheAllocation = vmRuntime.GetVFlashCacheAllocation()
        Log("\n\nTotal VFlash Cache Reservation after deletion: " +
            str(vFlashCacheReservation) +
            "\nTotal VFlash Cache Allocation  after deletion: " +
            str(vFlashCacheAllocation))

    except Exception as e:
        Log("Caught exception : " + str(e))

    Log("\nTEST 3 End\n")
Exemplo n.º 5
0
def test2():
    Log("\nTEST 2 Start\n")
    try:
        #---------------------------------------------
        # Add a disk with VFlash Cache Reservation set
        #---------------------------------------------
        vmConfig = vm1.GetConfig()
        vmRuntime = vm1.GetRuntime()
        vFlashCacheReservation = vmConfig.GetVFlashCacheReservation()
        vFlashCacheAllocation = vmRuntime.GetVFlashCacheAllocation()
        Log("\n\nTotal VFlash Cache Reservation before addition: " +
            str(vFlashCacheReservation) +
            "\nTotal VFlash Cache Allocation  before addition: " +
            str(vFlashCacheAllocation))

        cspec = Vim.Vm.ConfigSpec()

        # Get config options and targets
        cfgOption = vmconfig.GetCfgOption(None)
        cfgTarget = vmconfig.GetCfgTarget(None)

        # VFlash Cache Configuration
        vfcInfo = Vim.Vm.Device.VirtualDisk.VFlashCacheConfigInfo()

        p = re.compile("\[" + datastore + "\]")
        for device in vmConfig.hardware.device:
            try:
                if device.backing and device.backing.fileName and p.search(
                        device.backing.fileName):
                    diskDev = device
                    break
            except Exception as e:
                Log("Checking disk..")

        backing = diskDev.GetBacking()
        backing.SetFileName("[" + datastore + "] " + str(vmname) +
                            "/VMVFlashCacheDisk.vmdk")

        diskDev.SetBacking(backing)
        diskDev.SetVFlashCacheConfigInfo(vfcInfo)

        Log("VFlash Cache Configuration to be set on the disk")
        print(diskDev.GetVFlashCacheConfigInfo())

        ctlrs = vmconfig.GetControllers(cfgOption,
                                        Vim.Vm.Device.VirtualSCSIController,
                                        vm1.GetConfig(), cspec)
        diskDev.SetControllerKey(ctlrs[0].GetKey())
        diskDev.SetUnitNumber(-1)
        diskDev.SetCapacityInKB(long(65536))
        diskDev.SetCapacityInBytes(long(65536) * 1024)

        vmconfig.AddDeviceToSpec(cspec, diskDev, \
                  Vim.Vm.Device.VirtualDeviceSpec.Operation.add, \
                  Vim.Vm.Device.VirtualDeviceSpec.FileOperation.create)

        Log("Calling Reconfigure...")
        vm.Reconfigure(vm1, cspec)
        Log("Finished Reconfiguring VM: " + str(vmname))

        vmConfig = vm1.GetConfig()
        vmRuntime = vm1.GetRuntime()
        vFlashCacheReservation = vmConfig.GetVFlashCacheReservation()
        vFlashCacheAllocation = vmRuntime.GetVFlashCacheAllocation()
        Log("\n\nTotal VFlash Cache Reservation after addition: " +
            str(vFlashCacheReservation) +
            "\nTotal VFlash Cache Allocation  after addition: " +
            str(vFlashCacheAllocation))

        #--------------------------------------------------
        # check the virtual disk for VFlashCacheConfigInfo
        #--------------------------------------------------
        p = re.compile("VMVFlashCacheDisk.vmdk")
        found = "false"
        for device in vmConfig.hardware.device:
            try:
                if device.backing and device.backing.fileName and p.search(
                        device.backing.fileName):
                    diskDev = device
                    found = "true"
                    break
            except Exception as e:
                Log("Checking disk..")

        if (found == "true"):
            Log("VFlash Cache Configuration set on the disk")
            print(diskDev.GetVFlashCacheConfigInfo())
        else:
            Log("Added disk not found")
            sys.exit("ERROR")

        #-----------------------------------------------
        # Try Edit the device with wrong blockSizeInKB
        #-----------------------------------------------
        Log("Editing the disk now.")
        cspec = Vim.Vm.ConfigSpec()

        vfcInfo = diskDev.GetVFlashCacheConfigInfo()
        vfcInfo.SetBlockSizeInKB(100)
        diskDev.SetVFlashCacheConfigInfo(vfcInfo)

        Log("Calling Reconfigure with below config info...")
        print(diskDev.GetVFlashCacheConfigInfo())

        vmconfig.AddDeviceToSpec(cspec, diskDev, \
                   Vim.Vm.Device.VirtualDeviceSpec.Operation.edit)

        Log("Calling Reconfigure...")
        try:
            vm.Reconfigure(vm1, cspec)
        except Exception as e:
            Log("As expected, got the exception." + str(e))

        #--------------------------------------------------------------------------
        # Try Edit the device with wrong blockSizeInKB and reservation combination
        #--------------------------------------------------------------------------
        Log("Editing the disk now.")
        cspec = Vim.Vm.ConfigSpec()

        vfcInfo = diskDev.GetVFlashCacheConfigInfo()
        vfcInfo.SetBlockSizeInKB(256)
        vfcInfo.SetReservationInMB(64)
        diskDev.SetVFlashCacheConfigInfo(vfcInfo)

        Log("Calling Reconfigure with below config info...")
        print(diskDev.GetVFlashCacheConfigInfo())

        vmconfig.AddDeviceToSpec(cspec, diskDev, \
                   Vim.Vm.Device.VirtualDeviceSpec.Operation.edit)

        Log("Calling Reconfigure...")
        try:
            vm.Reconfigure(vm1, cspec)
        except Exception as e:
            Log("As expected, got the exception." + str(e))

        #-------------------------------------------------------------
        # Try editing with unsupported CacheMode, CacheConsistencytype
        #-------------------------------------------------------------
        vfcInfo = Vim.Vm.Device.VirtualDisk.VFlashCacheConfigInfo()
        vfcInfo.SetCacheMode("write_back")
        diskDev.SetVFlashCacheConfigInfo(vfcInfo)

        Log("Calling Reconfigure with below config info...")
        print(diskDev.GetVFlashCacheConfigInfo())

        vmconfig.AddDeviceToSpec(cspec, diskDev, \
                   Vim.Vm.Device.VirtualDeviceSpec.Operation.edit)

        Log("Calling Reconfigure...")

        try:
            vm.Reconfigure(vm1, cspec)
        except Exception as e:
            Log("As expected, got the exception." + str(e))

        vfcInfo = Vim.Vm.Device.VirtualDisk.VFlashCacheConfigInfo()
        vfcInfo.SetCacheConsistencyType("weak")
        diskDev.SetVFlashCacheConfigInfo(vfcInfo)

        Log("Calling Reconfigure with below config info...")
        print(diskDev.GetVFlashCacheConfigInfo())

        vmconfig.AddDeviceToSpec(cspec, diskDev, \
                   Vim.Vm.Device.VirtualDeviceSpec.Operation.edit)

        Log("Calling Reconfigure...")
        try:
            vm.Reconfigure(vm1, cspec)

        except Exception as e:
            Log("As expected, got the exception." + str(e))

        #--------------------------------------------------
        # Try editing with supported reservation > diskSize
        #--------------------------------------------------
        vfcInfo = Vim.Vm.Device.VirtualDisk.VFlashCacheConfigInfo()
        diskSize = diskDev.GetCapacityInKB() / 1024
        vfcInfo.SetReservationInMB(diskSize + 10)
        diskDev.SetVFlashCacheConfigInfo(vfcInfo)

        Log("Calling Reconfigure with below config info...")
        print(diskDev.GetVFlashCacheConfigInfo())

        vmconfig.AddDeviceToSpec(cspec, diskDev, \
                   Vim.Vm.Device.VirtualDeviceSpec.Operation.edit)

        Log("Calling Reconfigure...")

        try:
            vm.Reconfigure(vm1, cspec)
        except Exception as e:
            Log("As expected, got the exception." + str(e))

        #----------------------------------------------
        # Edit the device
        #----------------------------------------------
        Log("Editing the disk now.")
        cspec = Vim.Vm.ConfigSpec()

        vfcInfo = diskDev.GetVFlashCacheConfigInfo()
        vfcInfo.SetReservationInMB(4)
        vfcInfo.SetBlockSizeInKB(4)
        # provide empty string for vFlashModule, mode and consistency type
        vfcInfo.SetVFlashModule("")
        vfcInfo.SetCacheMode(" ")
        vfcInfo.SetCacheConsistencyType("  ")

        diskDev.SetVFlashCacheConfigInfo(vfcInfo)

        Log("Calling Reconfigure with below config info...")
        print(diskDev.GetVFlashCacheConfigInfo())

        vmconfig.AddDeviceToSpec(cspec, diskDev, \
                   Vim.Vm.Device.VirtualDeviceSpec.Operation.edit)

        Log("Calling Reconfigure...")
        vm.Reconfigure(vm1, cspec)
        Log("Finished Reconfiguring VM: " + str(vmname))

        vmConfig = vm1.GetConfig()
        vmRuntime = vm1.GetRuntime()
        vFlashCacheReservation = vmConfig.GetVFlashCacheReservation()
        vFlashCacheAllocation = vmRuntime.GetVFlashCacheAllocation()
        Log("\n\nTotal VFlash Cache Reservation after edit: " +
            str(vFlashCacheReservation) +
            "\nTotal VFlash Cache Allocation  after edit: " +
            str(vFlashCacheAllocation))

        #--------------------------------------------------
        # check the virtual disk for VFlashCacheConfigInfo
        #--------------------------------------------------
        found = "false"
        p = re.compile("VMVFlashCacheDisk.vmdk")
        for device in vmConfig.hardware.device:
            try:
                if device.backing and device.backing.fileName and p.search(
                        device.backing.fileName):
                    diskDev = device
                    found = "true"
                    break
            except Exception as e:
                Log("Checking disk..")

        if (found == "true"):
            Log("VFlash Cache Configuration set on the disk")
            print(diskDev.GetVFlashCacheConfigInfo())

            cacheInfo = diskDev.GetVFlashCacheConfigInfo()
            if cacheInfo.GetReservationInMB() != 4:
                Log("Unexpected value of Reservation!" + "\nReceived: " +
                    str(cacheInfo.GetReservationInMB()) + "\nRequired: 4")
                sys.exit("ERROR")
            if cacheInfo.GetBlockSizeInKB() != 4:
                Log("Unexpected value of BlockSize!" + "\nReceived: " +
                    str(cacheInfo.GetBlockSizeInKB()) + "\nRequired: 4")
                sys.exit("ERROR")
        else:
            Log("Edited disk not found!")
            sys.exit("ERROR")

        #----------------------------------------------
        # delete the disk and check VFlash Reservation
        #----------------------------------------------
        Log("Deleting the disk now.")
        cspec = Vim.Vm.ConfigSpec()

        vmconfig.AddDeviceToSpec(cspec, diskDev, \
                   Vim.Vm.Device.VirtualDeviceSpec.Operation.remove, \
                   Vim.Vm.Device.VirtualDeviceSpec.FileOperation.destroy)

        Log("Calling Reconfigure...")
        vm.Reconfigure(vm1, cspec)
        Log("Finished Reconfiguring VM: " + str(vmname))

        vmConfig = vm1.GetConfig()
        vmRuntime = vm1.GetRuntime()
        vFlashCacheReservation = vmConfig.GetVFlashCacheReservation()
        vFlashCacheAllocation = vmRuntime.GetVFlashCacheAllocation()
        Log("\n\nTotal VFlash Cache Reservation after deletion: " +
            str(vFlashCacheReservation) +
            "\nTotal VFlash Cache Allocation  after deletion: " +
            str(vFlashCacheAllocation))

    except Exception as e:
        Log("Caught exception : " + str(e))

    Log("\nTEST 2 End\n")
def test2():
   Log("\nTEST 2 Start\n");
   try:

      #------------------------------
      # Hot-addition:
      # Disk 2: vFC 4MB
      #------------------------------
      vmConfig = vm1.GetConfig();

      cspec = Vim.Vm.ConfigSpec()
      cfgOption = vmconfig.GetCfgOption(None)

      # VFlash Cache Configuration
      vfcInfo = Vim.Vm.Device.VirtualDisk.VFlashCacheConfigInfo();
      vfcInfo.SetReservationInMB(4);

      p = re.compile("\[" + datastore + "\]");
      for device in vmConfig.hardware.device:
         try:
            if device.backing and device.backing.fileName and p.search(device.backing.fileName):
               diskDev = device
               break
         except Exception as e:
            Log("Checking disk..")

      backing = diskDev.GetBacking()
      backing.SetFileName("[" + datastore + "] " + str(vmname) + "/VMVFlashCacheDisk_hot_01.vmdk");
      backing.SetUuid(None)

      diskDev.SetBacking(backing);
      diskDev.SetVFlashCacheConfigInfo(vfcInfo);

      Log("VFlash Cache Configuration to be set on the disk")
      print(diskDev.GetVFlashCacheConfigInfo())

      ctlrs = vmconfig.GetControllers(cfgOption, Vim.Vm.Device.VirtualSCSIController, vm1.GetConfig(), cspec)

      for ctlrIdx in range(len(ctlrs)):
          freeSlot = vmconfig.GetFreeSlot(cspec, vm1.GetConfig(), cfgOption, ctlrs[ctlrIdx])
          if (freeSlot >= 0):
             diskDev.SetControllerKey(ctlrs[ctlrIdx].GetKey())
             diskDev.SetUnitNumber(-1)
             diskDev.SetCapacityInKB(long(8192))
             diskDev.SetCapacityInBytes(long(8192) * 1024)
             break

      vmconfig.AddDeviceToSpec(cspec, diskDev, \
                Vim.Vm.Device.VirtualDeviceSpec.Operation.add, \
                Vim.Vm.Device.VirtualDeviceSpec.FileOperation.create)

      Log("Calling Reconfigure...")
      vm.Reconfigure(vm1, cspec)
      Log("Finished Reconfiguring VM: " + str(vmname));


      vmConfig = vm1.GetConfig();
      vmRuntime = vm1.GetRuntime()
      vFlashCacheReservation = vmConfig.GetVFlashCacheReservation()
      vFlashCacheAllocation = vmRuntime.GetVFlashCacheAllocation()
      Log("\n\nTotal VFlash Cache Reservation after addition: " + str(vFlashCacheReservation) +
            "\nTotal VFlash Cache Allocation  after addition: " + str(vFlashCacheAllocation))

      #--------------------------------------------------
      # check the virtual disk for VFlashCacheConfigInfo
      #--------------------------------------------------
      p = re.compile("VMVFlashCacheDisk_hot_");
      found = "false"
      diskDev1 = None

      for device in vmConfig.hardware.device:
         try:
            if device.backing and device.backing.fileName and p.search(device.backing.fileName):
               diskDev1 = device
               print(diskDev1.GetVFlashCacheConfigInfo())
               found = "true"
         except Exception as e:
            Log("Checking disk..")

      if (found == "true"):
         Log("Added disk found")
      else:
         Log("Added disk not found")
         sys.exit("ERROR");


      #--------------------------------------------------
      # Try editing vFC configuration, it should not fail
      #--------------------------------------------------
      Log("Editing the disk now.")
      cspec = Vim.Vm.ConfigSpec()
      ctlrs = vmconfig.GetControllers(cfgOption, Vim.Vm.Device.VirtualSCSIController, vm1.GetConfig(), cspec)

      vfcInfo = Vim.Vm.Device.VirtualDisk.VFlashCacheConfigInfo();
      vfcInfo.SetReservationInMB(8);
      vfcInfo.SetBlockSizeInKB(16);
      diskDev1.SetVFlashCacheConfigInfo(vfcInfo);

      vmconfig.AddDeviceToSpec(cspec, diskDev1, \
                 Vim.Vm.Device.VirtualDeviceSpec.Operation.edit)

      Log("Calling Reconfigure...")
      vm.Reconfigure(vm1, cspec)
      Log("Finished Reconfiguring VM: " + str(vmname));


      vmConfig = vm1.GetConfig();
      found = "false"
      diskDev1 = None

      for device in vmConfig.hardware.device:
         try:
            if device.backing and device.backing.fileName and p.search(device.backing.fileName):
               diskDev1 = device
               print(diskDev1.GetVFlashCacheConfigInfo())
               found = "true"
         except Exception as e:
            Log("Checking disk..")


      if (found == "true"):
         Log("Added disk found")
      else:
         Log("Added disk not found")
         sys.exit("ERROR");

      vmConfig = vm1.GetConfig();
      vmRuntime = vm1.GetRuntime()
      vFlashCacheReservation = vmConfig.GetVFlashCacheReservation()
      vFlashCacheAllocation = vmRuntime.GetVFlashCacheAllocation()
      Log("\n\nTotal VFlash Cache Reservation after edit: " + str(vFlashCacheReservation) +
            "\nTotal VFlash Cache Allocation  after edit: " + str(vFlashCacheAllocation))

      #----------------------------------------------
      # Try editing device with invalid params
      #----------------------------------------------

      # Invalid Module Name
      cspec = Vim.Vm.ConfigSpec()

      vfcInfo = Vim.Vm.Device.VirtualDisk.VFlashCacheConfigInfo();
      vfcInfo.SetVFlashModule("abcd");
      diskDev1.SetVFlashCacheConfigInfo(vfcInfo);

      vmconfig.AddDeviceToSpec(cspec, diskDev1, \
                 Vim.Vm.Device.VirtualDeviceSpec.Operation.edit)

      Log("Calling Reconfigure for invalid module name")
      try:
         vm.Reconfigure(vm1, cspec)
      except Exception as e:
         Log("As expected reconfig failed with exception: " + str(e));

      # Invalid reservation
      cspec = Vim.Vm.ConfigSpec()

      vfcInfo = Vim.Vm.Device.VirtualDisk.VFlashCacheConfigInfo();
      vfcInfo.SetReservationInMB(1);
      diskDev1.SetVFlashCacheConfigInfo(vfcInfo);

      vmconfig.AddDeviceToSpec(cspec, diskDev1, \
                 Vim.Vm.Device.VirtualDeviceSpec.Operation.edit)

      Log("Calling Reconfigure for invalid reservation")
      try:
         vm.Reconfigure(vm1, cspec)
      except Exception as e:
         Log("As expected reconfig failed with exception: " + str(e));


      # Invalid reservation (> available)a
      vffs = vFlashManager.GetVFlashConfigInfo().GetVFlashResourceConfigInfo().GetVffs();
      cspec = Vim.Vm.ConfigSpec()

      vfcInfo = Vim.Vm.Device.VirtualDisk.VFlashCacheConfigInfo();
      vfcInfo.SetReservationInMB((vffs.GetCapacity() / 1024/1024) + 10);
      diskDev1.SetVFlashCacheConfigInfo(vfcInfo);

      vmconfig.AddDeviceToSpec(cspec, diskDev1, \
                 Vim.Vm.Device.VirtualDeviceSpec.Operation.edit)

      Log("Calling Reconfigure for invalid reservation (> available)")
      try:
         vm.Reconfigure(vm1, cspec)
      except Exception as e:
         Log("As expected reconfig failed with exception: " + str(e));

      # Invalid reservation (> vmdk size)
      vfcInfo = Vim.Vm.Device.VirtualDisk.VFlashCacheConfigInfo();
      vfcInfo.SetReservationInMB((diskDev1.GetCapacityInKB() / 1024)+ 10);
      diskDev1.SetVFlashCacheConfigInfo(vfcInfo);

      vmconfig.AddDeviceToSpec(cspec, diskDev1, \
                 Vim.Vm.Device.VirtualDeviceSpec.Operation.edit)

      Log("Calling Reconfigure for invalid reservation (> vmdksize)")
      try:
         vm.Reconfigure(vm1, cspec)
      except Exception as e:
         Log("As expected reconfig failed with exception: " + str(e));

      # Invalid blockSize
      cspec = Vim.Vm.ConfigSpec()
      vfcInfo.SetReservationInMB(1);

      vfcInfo = Vim.Vm.Device.VirtualDisk.VFlashCacheConfigInfo();
      vfcInfo.SetBlockSizeInKB(2);
      diskDev1.SetVFlashCacheConfigInfo(vfcInfo);

      vmconfig.AddDeviceToSpec(cspec, diskDev1, \
                 Vim.Vm.Device.VirtualDeviceSpec.Operation.edit)

      Log("Calling Reconfigure for invalid block size")
      try:
         vm.Reconfigure(vm1, cspec)
      except Exception as e:
         Log("As expected reconfig failed with exception: " + str(e));


      # Invalid CacheMode
      cspec = Vim.Vm.ConfigSpec()

      vfcInfo = Vim.Vm.Device.VirtualDisk.VFlashCacheConfigInfo();
      vfcInfo.SetCacheMode("abcd");
      diskDev1.SetVFlashCacheConfigInfo(vfcInfo);

      vmconfig.AddDeviceToSpec(cspec, diskDev1, \
                 Vim.Vm.Device.VirtualDeviceSpec.Operation.edit)

      Log("Calling Reconfigure for invalid cache mode")
      try:
         vm.Reconfigure(vm1, cspec)
      except Exception as e:
         Log("As expected reconfig failed with exception: " + str(e));

      # write_back not supported! Should get exception.
      cspec = Vim.Vm.ConfigSpec()
      vfcInfo = Vim.Vm.Device.VirtualDisk.VFlashCacheConfigInfo();
      vfcInfo.SetCacheMode("write_back");
      diskDev1.SetVFlashCacheConfigInfo(vfcInfo);
      vmconfig.AddDeviceToSpec(cspec, diskDev1, \
                 Vim.Vm.Device.VirtualDeviceSpec.Operation.edit)

      Log("Calling Reconfigure for unsupported cache mode: \"write_back\"")
      try:
         vm.Reconfigure(vm1, cspec)
      except Exception as e:
         Log("As expected reconfig failed with exception: " + str(e));

      # Invalid Cache Consistency type
      cspec = Vim.Vm.ConfigSpec()

      vfcInfo = Vim.Vm.Device.VirtualDisk.VFlashCacheConfigInfo();
      vfcInfo.SetCacheConsistencyType("abcd");
      diskDev1.SetVFlashCacheConfigInfo(vfcInfo);

      vmconfig.AddDeviceToSpec(cspec, diskDev1, \
                 Vim.Vm.Device.VirtualDeviceSpec.Operation.edit)

      Log("Calling Reconfigure for invalid cache consistency type")
      try:
         vm.Reconfigure(vm1, cspec)
      except Exception as e:
         Log("As expected reconfig failed with exception: " + str(e));

      # weak is not supported! Should get exception.
      cspec = Vim.Vm.ConfigSpec()
      vfcInfo = Vim.Vm.Device.VirtualDisk.VFlashCacheConfigInfo();
      vfcInfo.SetCacheConsistencyType("weak");
      diskDev1.SetVFlashCacheConfigInfo(vfcInfo);

      vmconfig.AddDeviceToSpec(cspec, diskDev1, \
                 Vim.Vm.Device.VirtualDeviceSpec.Operation.edit)

      Log("Calling Reconfigure for unsupported cache consistency type: \"weak\"")

      try:
         vm.Reconfigure(vm1, cspec)
      except Exception as e:
         Log("As expected reconfig failed with exception: " + str(e));


      #------------------------
      # Set back default values
      #------------------------
      Log("Editing the disk now.")
      cspec = Vim.Vm.ConfigSpec()
      ctlrs = vmconfig.GetControllers(cfgOption, Vim.Vm.Device.VirtualSCSIController, vm1.GetConfig(), cspec)

      vfcInfo = Vim.Vm.Device.VirtualDisk.VFlashCacheConfigInfo();
      diskDev1.SetVFlashCacheConfigInfo(vfcInfo);

      vmconfig.AddDeviceToSpec(cspec, diskDev1, \
                 Vim.Vm.Device.VirtualDeviceSpec.Operation.edit)

      Log("Calling Reconfigure...")
      vm.Reconfigure(vm1, cspec)
      Log("Finished Reconfiguring VM: " + str(vmname));


      vmConfig = vm1.GetConfig();
      found = "false"
      diskDev1 = None

      for device in vmConfig.hardware.device:
         try:
            if device.backing and device.backing.fileName and p.search(device.backing.fileName):
               diskDev1 = device
               print(diskDev1.GetVFlashCacheConfigInfo())
               found = "true"
         except Exception:
            Log("Checking disk..")


      if (found == "true"):
         Log("Added disk found")
      else:
         Log("Added disk not found")
         sys.exit("ERROR");

      vmConfig = vm1.GetConfig();
      vmRuntime = vm1.GetRuntime()
      vFlashCacheReservation = vmConfig.GetVFlashCacheReservation()
      vFlashCacheAllocation = vmRuntime.GetVFlashCacheAllocation()
      Log("\n\nTotal VFlash Cache Reservation after edit: " + str(vFlashCacheReservation) +
            "\nTotal VFlash Cache Allocation  after edit: " + str(vFlashCacheAllocation))


      #----------------------------------
      # Set 0 as VFlash Cache reservation
      #----------------------------------
      Log("Editing the disk now.")
      cspec = Vim.Vm.ConfigSpec()
      ctlrs = vmconfig.GetControllers(cfgOption, Vim.Vm.Device.VirtualSCSIController, vm1.GetConfig(), cspec)

      vfcInfo = Vim.Vm.Device.VirtualDisk.VFlashCacheConfigInfo();
      vfcInfo.SetReservationInMB(0);
      diskDev1.SetVFlashCacheConfigInfo(vfcInfo);

      vmconfig.AddDeviceToSpec(cspec, diskDev1, \
                 Vim.Vm.Device.VirtualDeviceSpec.Operation.edit)

      Log("Calling Reconfigure...")
      vm.Reconfigure(vm1, cspec)
      Log("Finished Reconfiguring VM: " + str(vmname));


      vmConfig = vm1.GetConfig();
      found = "false"
      diskDev1 = None

      for device in vmConfig.hardware.device:
         try:
            if device.backing and device.backing.fileName and p.search(device.backing.fileName):
               diskDev1 = device
               print(diskDev1.GetVFlashCacheConfigInfo())
               found = "true"
         except Exception as e:
            Log("Checking disk..")


      if (found == "true"):
         Log("Added disk found")
      else:
         Log("Added disk not found")
         sys.exit("ERROR");

      vmConfig = vm1.GetConfig();
      vmRuntime = vm1.GetRuntime()
      vFlashCacheReservation = vmConfig.GetVFlashCacheReservation()
      vFlashCacheAllocation = vmRuntime.GetVFlashCacheAllocation()
      Log("\n\nTotal VFlash Cache Reservation after edit: " + str(vFlashCacheReservation) +
            "\nTotal VFlash Cache Allocation  after edit: " + str(vFlashCacheAllocation))

      #-------------------------------------
      # Set NULL as VFlash Cache reservation
      #-------------------------------------
      Log("Editing the disk now.")
      cspec = Vim.Vm.ConfigSpec()
      ctlrs = vmconfig.GetControllers(cfgOption, Vim.Vm.Device.VirtualSCSIController, vm1.GetConfig(), cspec)

      diskDev1.SetVFlashCacheConfigInfo(None);

      vmconfig.AddDeviceToSpec(cspec, diskDev1, \
                 Vim.Vm.Device.VirtualDeviceSpec.Operation.edit)

      Log("Calling Reconfigure...")
      vm.Reconfigure(vm1, cspec)
      Log("Finished Reconfiguring VM: " + str(vmname));


      vmConfig = vm1.GetConfig();
      found = "false"
      diskDev1 = None

      for device in vmConfig.hardware.device:
         try:
            if device.backing and device.backing.fileName and p.search(device.backing.fileName):
               diskDev1 = device
               print(diskDev1.GetVFlashCacheConfigInfo())
               found = "true"
         except Exception:
            Log("Checking disk..")


      if (found == "true"):
         Log("Added disk found")
      else:
         Log("Added disk not found")
         sys.exit("ERROR");

      vmConfig = vm1.GetConfig();
      vmRuntime = vm1.GetRuntime()
      vFlashCacheReservation = vmConfig.GetVFlashCacheReservation()
      vFlashCacheAllocation = vmRuntime.GetVFlashCacheAllocation()
      Log("\n\nTotal VFlash Cache Reservation after edit: " + str(vFlashCacheReservation) +
            "\nTotal VFlash Cache Allocation  after edit: " + str(vFlashCacheAllocation))


      #----------------------------------------------
      # delete the disk and check VFlash Reservation
      #----------------------------------------------
      Log("Deleting the disk now.")
      cspec = Vim.Vm.ConfigSpec()
      ctlrs = vmconfig.GetControllers(cfgOption, Vim.Vm.Device.VirtualSCSIController, vm1.GetConfig(), cspec)

      vmconfig.AddDeviceToSpec(cspec, diskDev1, \
                 Vim.Vm.Device.VirtualDeviceSpec.Operation.remove, \
                 Vim.Vm.Device.VirtualDeviceSpec.FileOperation.destroy)

      Log("Calling Reconfigure...")
      vm.Reconfigure(vm1, cspec)
      Log("Finished Reconfiguring VM: " + str(vmname));

      vmConfig = vm1.GetConfig();
      vmRuntime = vm1.GetRuntime()
      vFlashCacheReservation = vmConfig.GetVFlashCacheReservation()
      vFlashCacheAllocation = vmRuntime.GetVFlashCacheAllocation()
      Log("\n\nTotal VFlash Cache Reservation after deletion: " + str(vFlashCacheReservation) +
            "\nTotal VFlash Cache Allocation  after deletion: " + str(vFlashCacheAllocation))

   except Exception as e:
           Log("Caught exception : " + str(e))

   Log("\nTEST 2 End\n");