VMware Cloud Community
ririmia
Enthusiast
Enthusiast

Set VM Storage Policy to "Datastore Default"

How can I set the Storage Policy to "Datastore Default" ?

I know how to set based on a specific profile ID but I don't know what is the "Datastore Default" ID.

I found the PowerCLI script https://communities.vmware.com/thread/583674:

$vmName = 'MyVM'

Get-VM -Name $vmName | Get-HardDisk | %{

    Get-SpbmEntityConfiguration -HardDisk $_ |

    Set-SpbmEntityConfiguration -StoragePolicy $null -Confirm:$false

}

with JavaScript is not working in this way:

profileUniqueId = null;

var deviceChangeSpec = [];

var changeSpec = [];

var myVcVirtualMachineConfigSpec = new VcVirtualMachineConfigSpec() ;

var myVcVirtualMachineDefinedProfileSpec = new VcVirtualMachineDefinedProfileSpec() ;

myVcVirtualMachineDefinedProfileSpec.profileId = profileUniqueId;

changeSpec.push(myVcVirtualMachineDefinedProfileSpec);

myVcVirtualMachineConfigSpec.vmProfile = changeSpec;

I receive the error:

"com.vmware.vim.vmomi.core.exception.MarshallException: VirtualMachineDefinedProfileSpec required property profileId not set"

What is the right approach with vRO?

Thanks

0 Kudos
2 Replies
ririmia
Enthusiast
Enthusiast

Maybe this can help someone else.

I found out from Cody Hosterman the answer. See the comments from his site Retrieving storage policy of a vm with vro 

Short answer: "The datastore default isn’t really a policy."

My issue start from using two custom Storage Policy with different settings for IOPs.
'Standard' with IOPs:5000 and 'Performance' with IOPs:10000.
We are using the vRO workflow to apply the storage policy based on VM custom attribute.

When we apply from "Datastore Default" to "Standard" everything is OK.
When we change between "Standard" <-> "Performance" the 'Limit - IOPs' value is filled with values 5000 or 10000 (based on what policy is applied).
This will have as a result higher storage latency for VM.
More information: https://vnote42.net/2018/09/20/how-do-io-limits-look-like/ (SIOC v1 vs. v2)

The only solution is actually an workaround. 1st apply a "Default" policy then on the 2nd step apply the desired storage policy (Standard or Performance in my case).
As "Datastore Default" is not actually a policy so this can't be used. Changing only the 'Limit - IOPs' to Unlimited doesn't help either.
If you try to create a custom "Default" by setting the 'Limit - IOPs' to 'Unlimited' the storage latency issue persist.
We choose as Default the built in policy "VVol No Requirements Policy" and is working.

This behavior can be reproduced with GUI so is not a vRO issue. Most likely is a vSphere bug. We have a SR case open. Until they will have a root cause, solution or fix we will use the above workaround.


vSphere version 6.7.0.45000

0 Kudos
KAI33
Contributor
Contributor

Back in time on this subject as i also facing this issue with vRO 8.x

In fact in vRO 7.x (with vcenter plugin 6.5) they were a method to remove the association between the VM and the storage profile

___________________________________________

var myProfileManager = vCenter.storageManagement.pbmProfileManager;
var myPbmServerObjectRef = new PbmServerObjectRef();
myPbmServerObjectRef.key = vm.moref.value;
myPbmServerObjectRef.objectType = "virtualMachine";

myProfileManager.pbmDissociate(myPbmServerObjectRef, vmProfiles[0]);

 ___________________________________________
where :
- vCenter variable is your sdkConnection object
- vm varialbe is your vm object
- vmProfiles contains array of storage policies where you want to remove your VM
 
 
The issue here is that method was deprecated in vRO 7.x but functionnal. With vRO 8.x, it does not exist anymore.
 
So the question remains. What is the prefered method now to remove that storage policy from a VM. I have to do that when i automatically migrating some VMs from VSAN cluster (with storage profiles) to SAN cluster where VMFS datastores have no storage profiles (except the Default Datastore that is not a profile).