VMware Cloud Community
pamiller21
Enthusiast
Enthusiast
Jump to solution

Putting a vHost into Maint Mode

Hey all,

I was looking for a method to put a vHost into maintenance mode, but first evacuating the VMs using DRS.  I am having some issues finding the terms for the second part.

Thanks,

Andy

1 Solution

Accepted Solutions
BenLiebowitz
Expert
Expert
Jump to solution

I think adding the -Evacuate switch to the set-vmhost cmd should move the powered off VMs. 

Ben Liebowitz, VCP vExpert 2015, 2016, & 2017 If you found my post helpful, please mark it as helpful or answered to award points.

View solution in original post

0 Kudos
8 Replies
jpsider
Expert
Expert
Jump to solution

Hi Andy,

Do you want to user DRS? or just move the vm?

Here is a link to the Move-vm cmdlet.

Spotlight on the Move-VM Cmdlet including PowerCLI 6.5 Enhancements - VMware PowerCLI Blog - VMware ...

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Is your DRS set to automatic mode?
If yes, the VMs should be vMotion-ed when you set the host to maintenance mode with the Set-VMHost cmdlet.

If not, can you set the DRS mode temporarily to FyllyAutomated with the Set-Cluster cmdlet?

$esxName = 'MyESX'

$cluster = Get-Cluster -VMHost $esxName

if($cluster.DrsAutomationLevel -ne 'FullyAutmated'){

    Set-Cluster -Cluster $cluster -DrsAutomationLevel FullyAutomated -Confirm:$false

}

Set-VMHost -VMHost $esxName -State Maintenance -Confirm:$false

Or is it something completely different you want to do?


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

pamiller21
Enthusiast
Enthusiast
Jump to solution

This is nearly what I am looking for.  It puts the vhost into maintenance mode, but it does not migrate off all VMs (powered off ones included).  Is there an additional switch for this?

0 Kudos
LucD
Leadership
Leadership
Jump to solution

There can be several reasons for that.
Is the cluster DRS configured with FullyAutomated?

Do the VMs perhaps have ISOs mounted on the CD/DVD devices?

Are there Host-VM affinity rules prohibiting the move?

Is HA admission control enabled?

Is there sufficient capacity on the other nodes in the cluster to host the VMs?

Perhaps show a screenshot of the cluster settings


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

0 Kudos
BenLiebowitz
Expert
Expert
Jump to solution

I think adding the -Evacuate switch to the set-vmhost cmd should move the powered off VMs. 

Ben Liebowitz, VCP vExpert 2015, 2016, & 2017 If you found my post helpful, please mark it as helpful or answered to award points.
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Good idea Ben, but isn't that switch only for re-registration of powered off VMs?
But definitely a switch you should add.


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

0 Kudos
BenLiebowitz
Expert
Expert
Jump to solution

I've never worried about moving powered off VMs via PowerCLI...  Typically I patch via PowerCLI and the VMs migrate via DRS and anything left is unavailable for about 30 minutes at most. 

If that doesn't work, going along the route of doing it manually may work too...  You'd need to script disabling DRS, moving the VMs, and then setting maintenance mode.  Finally, you'll want to re-enable DRS again.

This post from Damian Karlson for way back may get you started.

Ghetto host evacuation: PowerCLI — DAMIAN KARLSON

Ben Liebowitz, VCP vExpert 2015, 2016, & 2017 If you found my post helpful, please mark it as helpful or answered to award points.
0 Kudos
pamiller21
Enthusiast
Enthusiast
Jump to solution

I already had the clusters setup for Auto for DRS and it worked simply when I told a vhost to manually go into maint mode.  I added the -evacuation switch and it worked perfect, both powered on and off VMs moved.

Thanks guys,
Andy

0 Kudos