VMware Cloud Community
Gabrie1
Commander
Commander

Start-VM and DRS Manual

Running Citrix VMs under VSPP license it is profitable for us to shutdown Citrix VMs that are not in use at night, so there is a script shutting them down at 22:00hrs and performing a power-on at 6:00. 

The cluster has DRS set to manual so we can manually keep 1-1 vCPU-Core ratio and we notice that when doing a Start-VM, DRS decides to move the VM to a different host (sometimes). Which is strange since DRS at manual level, should make a recommendation but not force a movement.

We've been doing this for over a year now and only recently noticed that DRS still moves VMs sometimes when powering on. So we're not completely sure if the DRS behaviour has changed or it may never have worked as we thought it would.

In the tasks/events of the VM we can see DRS deciding to move the VM when powering on through Start-VM. When powering on the VM through the GUI, I get the question with the recommended placement.

Checking the api for PowerOnVM_Task it mentions:
(optional) The host where the virtual machine is to be powered on. If no host is specified, the current associated host is used. This field must specify a host that is part of the same compute resource that the virtual machine is currently associated with. If this host is not compatible, the current host association is used.

So I'm confused on why the VM is moved by DRS when DRS is set to manual. There are no DRS rules, VM overrides, affinitiy etc, in place.

vCenter 6.7.0 build 17712750

http://www.GabesVirtualWorld.com
Reply
0 Kudos
13 Replies
LucD
Leadership
Leadership

I suspect that the Start-VM cmdlet might use the PowerOnMultiVM_Task method on the Datacenter (instead of the PowerOnVM_Task on the VirtualMachine object).
That, even when managed manually by DRS, seems to force a DRS recommendation.

You could try to adapt your script to call the PowerOnVM_Task on the VirtualMachine object instead of Start-VM, to check if that makes a difference.


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

Reply
0 Kudos
Gabrie1
Commander
Commander

Thx Luc for replying.

Well the nightly script runs as a PHP script and does calls the PowerOnVM_Task. I was using the powercli Start-VM to test what is happening, believing it was the same. 

Reading the PowerOnVM_Task, it looks as if it has the same behaviour:

When powering on a virtual machine in a cluster, the system might implicitly or due to the host argument, do an implicit relocation of the virtual machine to another host. Hence, errors related to this relocation can be thrown. If the cluster is a DRS cluster, DRS will be invoked if the virtual machine can be automatically placed by DRS (see DrsBehavior). Because this method does not return a DRS ClusterRecommendation, no vmotion nor host power operations will be done as part of a DRS-facilitated power on. To have DRS consider such operations use PowerOnMultiVM_Task. As of vSphere API 5.1, use of this method with vCenter Server is deprecated; use PowerOnMultiVM_Task instead.

 

http://www.GabesVirtualWorld.com
Reply
0 Kudos
LucD
Leadership
Leadership

The text for PowerOnMultiVM_Task does read a bit differently imho.

If any virtual machine in the list is manually managed by DRS, or DRS has to migrate any manually managed virtual machine or power on any manually managed host in order to power on these virtual machines, a DRS recommendation will be generated, and the users need to manually apply the recommendation for actually powering on these virtual machines. Otherwise, all the virtual machine will be automatically powered on. The virtual machines on stand alone hosts or DRS disabled will be powered-on on the current host. The DRS automatically managed virtual machines will be powered-on on the recommended hosts.

When powering on a virtual machine in a cluster, the system might do an implicit relocation of the virtual machine to another host.

Manual DRS is not the same as disabled DRS.


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

Reply
0 Kudos
Gabrie1
Commander
Commander

If I read that correctly, when DRS is set to manual, it will generate a recommendation and the user needs to apply it. Would it then mean the VM is not powered on. Or would we have to check the recommendation after the power on action and then apply it.

http://www.GabesVirtualWorld.com
Reply
0 Kudos
LucD
Leadership
Leadership

Not sure.
Feel free to experiment


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

Reply
0 Kudos
erki72
Enthusiast
Enthusiast

Have you found a solution? I would be interested too

Reply
0 Kudos
Gabrie1
Commander
Commander

No, both API calls give the same result, DRS moves the VM to a different host then the host the VM is on. 

http://www.GabesVirtualWorld.com
Reply
0 Kudos
erki72
Enthusiast
Enthusiast

Thanks for the quick reply.
That's bad. I'm still looking for a command without having to disable DRS for that...

Reply
0 Kudos
Gabrie1
Commander
Commander

Well, what you can do (haven't tested yet) is to first retrieve the name of the host the VM is on and add that name as an option to the start command.

http://www.GabesVirtualWorld.com
Reply
0 Kudos
LucD
Leadership
Leadership

Afaik, the Start-VM cmdlet does not have that option.

The API method PowerOnVM_Task does.

$vmName = 'TestVM'
$esxName = 'MyEsx'

$vm = Get-VM -Name $vmName
$esx = Get-VMHost -Name $esxName

$vm.ExtensionData.PowerOnVM($esx.ExtensionData.MoRef)


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

Reply
0 Kudos
erki72
Enthusiast
Enthusiast

Hi @LucD 

Sorry, I don't always have maintenance windows to move VMs. That's why it took me so long to answer.
DRS level is on manual and I did it as below. It didn't work that way. The switched off VM starts on any host

foreach ($vmlist in (Get-Content -Path $list))
    {
    $vm = Get-VM -Name $vmlist 
    $vm.ExtensionData.PowerOnVM($esx.ExtensionData.MoRef)
    Sleep 10
    } 

 

Reply
0 Kudos
Gabrie1
Commander
Commander

Hmmm, then there is just one thing left. Which is crazy, but should work:

- lookup the host the VM is on

- power on the VM

- VMotion the VM to that specific host

 

http://www.GabesVirtualWorld.com
Reply
0 Kudos
LucD
Leadership
Leadership

That last code is not what I posted.
It doesn't get the ESXi node the VM is currently on.


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

Reply
0 Kudos