PowerCLI – Disable Storage IO Control and statistics collection

PowerCLI
[ult_tab_element tab_style=”Style_6″ tab_title_color=”#7fbb00″ tab_background_color=”#282828″ tab_hover_title_color=”#7fbb00″ tab_hover_background_color=”#282828″ acttab_title=”#7fbb00″ acttab_background=”#282828″ title_font_style=”font-weight:bold;” title_font_size=”desktop:18px;” main_title_typograpy=”” main_desc_typograpy=””][single_tab title=”Goal” tab_id=”1634521314188-0″]
  • Goal – A PowerCLI script that will select “Disable Storage I/O Control and statistics collection” on all datastores in an SDRS cluster.
  • Upgrading ESXi hosts from VMware 6.7 to 7.0 may inadvertently turn on Storage I/O Control (SIOC) and may cause a performance issue if the settings are incorrect.
    https://www.dell.com/support/kbdoc/en-us/000182816/dell-emc-unity-esxi-host-upgrades-from-vmware-6-7-to-7-0-may-cause-performance-issues-if-sioc-is-turned-on-user-correctable
  • For an HPE HF array, the same large blocks size (128-256k) appear when there are no VMs on a datastore/volume. While the Dell post points to an upgrade, this is for new new datastores to see how SIOC with statistics is enabled.
  • Minting a volume/datastore using the current method or the Nimble Storage vCenter plug-in has Storage I/O Control (SIOC) Disabled. No option to choose a SDRS cluster.
  • When the datastore is addred to a SDRS cluster with “Enable I/O metric for SDRS recommendations” Enabled. SIOC is Enabled. When moved outside the SDRS cluster, SIOC remain Enabled.
  • When the datastore is addred to a SDRS cluster with “Enable I/O metric for SDRS recommendations” Disabled, the datastore remains SIOC as Disabled
  • Recap – New datastores have SIOC disabled. If the SDRS cluster has I/O metrics enabled, SIOC will be enabled when a datastore is added. If I/O metrics are disabled for the SDRS cluster, then SOIC will remain disabled when added to the SDRS cluster.
  • This PowerCLI script covers the Cluster object for net-new datastores, but not existing datastores
    https://vmscribble.com/powercli/change-sdrs-vm-affinity-io-metric-space-threshold-by-cluster-script/
[/single_tab][single_tab title=”Testing” tab_id=”1634521314219-8″]
  • Issue. The native Set-Datastore StorageIOControlEnabled cmdlet will choose the 2nd “Disable Storage I/O Control but enable statistics collection” with “Include I/O statistics for SDRS” checked. The goal is to pick the 3rd one “Disable Storage I/O Control and statistics collection” since the statistics collection is the issue.
    https://developer.vmware.com/docs/powercli/latest/vmware.vimautomation.core/commands/set-datastore/
  • Running the vCenter – Developer Center – Code Capture amid making the change to a datastore showed:#—————– Start of code capture —————–#—————ConfigureDatastoreIORM_Task—————
    $datastore = New-Object VMware.Vim.ManagedObjectReference
    $datastore.Type = ‘Datastore’
    $datastore.Value = ‘datastore-3013’
    $spec = New-Object VMware.Vim.StorageIORMConfigSpec
    $spec.StatsAggregationDisabled = $true
    $spec.StatsCollectionEnabled = $false
    $spec.Enabled = $false
    $_this = Get-View -Id ‘StorageResourceManager-StorageResourceManager’
    $_this.ConfigureDatastoreIORM_Task($datastore, $spec)#—————– End of code capture —————–
  • Searching for spec.StatsCollectionEnabled
    https://github.com/vmware/PowerCLI-Example-Scripts/blob/master/Scripts/DatastoreSIOCStatistics.ps1
    Testing function Set-DatastoreSIOCStatCollection -Datastore realDSname -Disable hit or miss. I would see the “Configure Storage I/O Control on datastore” task complete, but the change was not made all of the time eventhough “SIOCStatCollection” in the output reported False. No reason why.
    The fix. Edit line 58 and add 2 more lines to mirrot the code capture output. Success!} elseif ($Disable) {$spec.statsCollectionEnabled = $falseNew Lines 58-60:
    $spec.StatsAggregationDisabled = $true
    $spec.StatsCollectionEnabled = $false
    $spec.Enabled = $false
  • Since I wanted to have the script only make the change on DS inside the SDRS cluster.
    I found https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Need-a-quick-one-line-script-to-disable-SIOC-on-all-Datastores/m-p/2164439I was not able to create a oneliner for all 3 specs, so I broke it down by all 3.
    Start-Sleep -seconds 5 was added to resolve “The operation is not allowed in the current state”
[/single_tab][single_tab title=”The Script” tab_id=”1634521355622-2-0″]
#  Found  https://vmscribble.com/powercli/powercli-disable-storage-io-control-and-statistics-collection
#  thanks - https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Need-a-quick-one-line-script-to-disable-SIOC-on-all-Datastores/m-p/2164439
# thanks https://github.com/vmware/PowerCLI-Example-Scripts/blob/master/Scripts/DatastoreSIOCStatistics.ps1


Write-Host  "
This PowerCLI script will Disable Storage I/O Control and statistics collection on all datastores in a SDRS cluster
"

#Variables
$vCenter = Read-Host "Enter the FQDN of the vCenter"
$DSClusterName = Read-Host "Enter the SDRS Cluster Name"

# Connect to the vCenter
Connect-VIServer $vCenter | Out-Null

# List Datastores inside the SDRS Cluster
$DS = Get-DatastoreCluster -Name $DSClusterName | Get-Datastore

# https://vdc-repo.vmware.com/vmwb-repository/dcr-public/6b586ed2-655c-49d9-9029-bc416323cb22/fa0b429a-a695-4c11-b7d2-2cbc284049dc/doc/vim.StorageResourceManager.IORMConfigSpec.html

$viewStorageRM = Get-View -Id "StorageResourceManager-StorageResourceManager" 
$spec1 = New-Object VMware.Vim.StorageIORMConfigSpec -Property @{"Enabled" = $false}
$spec2 = New-Object VMware.Vim.StorageIORMConfigSpec -Property @{"StatsCollectionEnabled" = $false}
$spec3 = New-Object VMware.Vim.StorageIORMConfigSpec -Property @{"StatsAggregationDisabled" = $true}


Write-Output "Changing datastore: $($DS.Name)"

# Pause as added to resolve - The operation is not allowed in the current state
$DS | %{$viewStorageRM.ConfigureDatastoreIORM_Task($_.Id, $spec1)}
Start-Sleep -seconds 5
$DS | %{$viewStorageRM.ConfigureDatastoreIORM_Task($_.Id, $spec2)}
Start-Sleep -seconds 5
$DS | %{$viewStorageRM.ConfigureDatastoreIORM_Task($_.Id, $spec3)}


# Disconnect from the vCenter
Disconnect-VIServer $vCenter -Confirm:$false
[/single_tab][/ult_tab_element]