VMware Cloud Community
lorried82
Enthusiast
Enthusiast

Storage DRS default VM affinity rule

I am trying to find out how I can set the default VM affinity rule for a DataStore Cluster to not keep VMDKs together. The version of vSphere is 6.0

When I look in the Web Client this setting is unchecked. When I am provisioning servers however, the VMDKs are being kept together. When I look in the fat client, I can see the newly provisioned servers have a check mark to keep the VMDKs together. The issue with this is I am not able to get multiple disks provisioned when the server is being built due to size constraints. All I can find if how to remediate servers that are already built, nothing about how this setting can be permanently changed. Any advice? Thanks

0 Kudos
5 Replies
LucD
Leadership
Leadership

Try like this

$dscName = 'DSC'

$dsc = Get-DatastoreCluster -Name $dscName

$si = Get-View ServiceInstance -Server $global:DefaultVIServer

$storMgr = Get-View -id $si.Content.StorageResourceManager -Server $global:DefaultVIServer

$spec = New-Object VMware.Vim.StorageDrsConfigSpec

$spec.PodConfigSpec = New-Object VMware.Vim.StorageDrsPodConfigSpec

$spec.PodConfigSpec.DefaultIntraVmAffinity = $false

$storMgr.ConfigureStorageDrsForPod($dsc.ExtensionData.MoRef,$spec,$true)


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

0 Kudos
lorried82
Enthusiast
Enthusiast

this looks great thank you - how would I first just check the setting to see what it is set to then run it after to confirm?

Also LucD should we be setting the VM storage policy with every build? Or should this set it to no longer manage it at the VM level?

Thanks so much.

0 Kudos
LucD
Leadership
Leadership

You can check the following property

$dscName = 'DSC'

$dsc = Get-DatastoreCluster -Name $dscName


$dsc.ExtensionData.PodStorageDrsEntry.StorageDrsConfig.PodConfig.DefaultIntraVmAffinity

Not exactly sure what you mean by build, but normally that setting should stay to what you set it.


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

0 Kudos
lorried82
Enthusiast
Enthusiast

ok thanks LucD. So when I run that command it comes back as False. However, when I an provisioning servers to that DataStore Cluster, the VMDKs are being kept together. Do you have any thoughts on what cold be happening of have any suggestions?

0 Kudos
LucD
Leadership
Leadership

I don't think that this option is an enforcing option.
The SDRS engine still looks at storage utilization and IO metrics to decide on the placement of files it seems.

I suspect the default VM affinity rule only comes into play when SDRS would be placing the files of a VM on different datastores in the DSC.
Then when the default VM affinity is set to $true, it will keep the files together on the same datastore.
But this is just my interpretation of what I see.

To get an authorative answer, I suggest to open a SR

Btw, I see the same behaviour.
And apparently already in 2012, when this feature was introduced, I find comments that it didn't seem to do what users expected it to be doing.

See Impact of Intra VM affinity rules on Storage DRS - frankdenneman.nl 


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

0 Kudos