0 Replies Latest reply on Sep 5, 2019 9:07 AM by omrsafetyo

    How to apply SDRS recommendations while adding a new disk

    omrsafetyo Novice

      I am trying to solve an issue where currently, we have rather large datastore clusters (many datastores) but each datastore is running with ~15% free space.  We try to keep this around that threshold to ensure we can take snapshots for backups, but as a minimum, we want each DS to have > 500GB free space.

       

      So currently in VRO, I have a check that looks at a new VM build, or a request for an additional disk, or disk extension, and it checks all the Datastores in the DS cluster to ensure that some datastore has enough room to accommodate the full size of the requested disks, with the wiggle room (500GB) - basically, go find the DS with the most free space, and see if it has [requested size] + [500GB] space available.  If not, it fails the WF, and doesn't do the operation.  We have SDRS run on a 12 hour interval so as to prevent IO stunning mid-day.

       

       

      I would like to improve this to use SDRS recommendations to add the disk where space is available automatically, and apply any other SDRS migrations that might be necessary to accommodate.   For instance, if I have ~1.3TB free on each DS, and someone requests a 1.5TB drive, I'd like to be able to create the drive while applying DRS - push around the disks until I have enough room to put a 1.5 TB disk.  Right now, we instead add a new DS to the cluster, and then re-submit the request.

       

      It looks like I should be able to use applyStorageDrsRecommendation_Task to do this.  According to the documentation (https://www.vmware.com/support/orchestrator/doc/vro-vsphere65-api/html/VcStorageResourceManager.html ) I should be able to use this with the AddDisk API:

       

       

       

      Applies a recommendation from the recommendation list. Each recommendation can be applied only once. In the case of CreateVm and CloneVm a VirtualMachine is returned. Other workflows don't have a return value.

      Requires Resource.ApplyRecommendation privilege on the storage pod. Additionally, depending on the workflow where this API is called from, it may require the privileges of invoking one of following APIs:

       

      CreateVm {@link vim.Folder#createVm}

      AddDisk {@link vim.VirtualMachine#reconfigure}

      RelocateVm {@link vim.VirtualMachine#relocate}

      CloneVm {@link vim.VirtualMachine#clone}

       

      However, I'm not sure how to apply that when I go to run my reconfigVM_Task.

       

      I found this thread: Adding multiple disks using SDRS on VRO

       

      With the solution code:

       

      1. for (var i in myarray) { 
      2.   myVcTask = managedObject.applyStorageDrsRecommendation_Task(myKey); 
      3.   actionResult = System.getModule("com.vmware.library.vc.basic").vim3WaitTaskEnd(myVcTask, progress, pollRate); 
      4.   ... // other code inside loop 

       

      I'm just not sure what myKey represents.  Would that just be my config spec?  The documentation suggests the only parameter for the applyStorageDrsRecommendation_Task is a string.   I was just going to modify (a copy of) the built-in Add Disk WF for my purposes:

       

      var configSpec = new VcVirtualMachineConfigSpec();

      var deviceConfigSpecs = new Array();

      var deviceConfigSpec;

       

       

      // Add/Create the disk

      deviceConfigSpec = System.getModule("com.vmware.library.vc.vm.spec.config.device").createVirtualDiskFlatVer2ConfigSpec(

      diskSize, datastore, scsiControllerKey, diskIndex, VcVirtualDiskMode.fromString(diskMode.name), thinProvisioned );

      deviceConfigSpecs[0] = deviceConfigSpec;

       

       

      // List of devices

      configSpec.deviceChange = deviceConfigSpecs;

       

       

      // Launch the reconfigVM task

      task = vm.reconfigVM_Task( configSpec );

       

       

      Any suggestions?