Automation

 View Only
  • 1.  Scripting SDRS maintenance mode

    Posted Nov 27, 2018 03:51 PM

    Looking for a script that would move a list of datastores (one at a time) into an SDRS cluster, put the datastore into maintenane mode to vacate it, and continue until list is complete.

    Anyone have something similar that they have used ? We have a script to move VMs across datastores but in this instance we must use SDRS maintenance mode because of the contents of them.

    Any help is appreciated

    Thanks all



  • 2.  RE: Scripting SDRS maintenance mode
    Best Answer

    Posted Nov 27, 2018 04:03 PM

    Not sure how you are going to place all datastores in the datastorecluster in maintenance mode.
    On the last datastore, where will the VMs be moved to?

    In any case, you can create a DSC, add datastores and place a datastore in SDRS maintenance mode with regular PowerCLI cmdlets.

    See this short snippet

    $datacenterName = 'MyDC'

    $dsNames = 'DS1','DS2'

    $dc = Get-Datacenter -Name $datacenterName

    $dsc = New-DatastoreCluster -Name TempDSC -Location $dc

    Get-Datastore -Name $dsNames | Move-Datastore -Destination $dsc

    Get-Datastore -Name $dsNames |

    Select -First 1 |

    Set-Datastore -MaintenanceMode:$true  -EvacuateAutomatically -Confirm:$false



  • 3.  RE: Scripting SDRS maintenance mode

    Posted Nov 27, 2018 04:14 PM

    Thanks LucD..

    For more clarity we have SDRS clusters that were running all vmfs5 datastores. We have provisioned new vmfs6 datastores into said clusters and removed all the older vmfs5 ones.  The goal is to move one vmfs5 datastore into the sdrs cluster which now has a bunch of new vmfs6 datastores, place it in maintenance and vacate it so the data ends up on the new vmfs6 datastores.  That is the reason for doing one at a time so we do not move data amongst the older vmfs5 datastores.  The end result is all our data that we cannot move via our normal svmotion scripts will be on our newly provisioned vmfs6 datastores.

    Hope this helps .

    I will see if i can tweak what you provided to make it work for my needs.



  • 4.  RE: Scripting SDRS maintenance mode

    Posted Nov 27, 2018 04:47 PM

    Ok, got it.
    Let me know if you can get it to work.



  • 5.  RE: Scripting SDRS maintenance mode

    Posted Nov 27, 2018 04:57 PM

    Looks like when i populate more than one Datastore name  for the variable $dsNames it only works on the first and fails on the remainder. It moves them all into the SDRS at once instead of serially which may be part of the issue.

    It works great for single Datastores



  • 6.  RE: Scripting SDRS maintenance mode

    Posted Nov 27, 2018 05:07 PM

    You could handle that by ysing a ForEach loop, handle one datastore at the time.

    Place it in maintenance mode, wait till all VMs have been svMotioned from the datastore, then continue with the next datastore.



  • 7.  RE: Scripting SDRS maintenance mode

    Posted Nov 27, 2018 05:14 PM

    Something like this?

    $dsNames = 'DS1','DS2'

    $dscName = 'DSC'

    $dsc = Get-DatastoreCluster -Name $dscName

    foreach($ds in Get-Datastore -Name $dsNames){

        Move-Datastore -Datastore $ds -Destination $dsc

        Set-Datastore -Datastore $ds -MaintenanceMode:$true -EvacuateAutomatically -Confirm:$false

        while((Get-VM -Datastore $ds).Count -ne 0){

            sleep 5

        }

    }



  • 8.  RE: Scripting SDRS maintenance mode

    Posted Nov 27, 2018 05:44 PM

    Testing now, stay tuned

    Appreciate the help and effort on this



  • 9.  RE: Scripting SDRS maintenance mode

    Posted Mar 10, 2021 11:10 AM

    Hi,

    will this also evacuate off Templates?

     

    Thanks,

    Joe



  • 10.  RE: Scripting SDRS maintenance mode

    Posted Mar 10, 2021 12:04 PM

    I'm afraid not.
    One way is to convert the templates temporarily to VMs, before activating SDRS maintenance.