VMware Cloud Community
redpat_71
Contributor
Contributor
Jump to solution

VM overrides restart delay

Hi,

Just a beginner regarding PowerCli and not sure how to solve the following

We have multiple clusters because of licensing: Oracle, MS SQL and one cluster with application VMs.

Therefore I see no other option than using the HA restart delays to do some orchestration after an HA failure.

Each cluster has production, test, development and acceptance VMs. For production VMs I change the HA restart delay. This way VMs in de database clusters are started before the application VMs.

For all other VMs I want a specific restart delay depending on a custom attribute which tells if the VM is acceptance, test or development. This can be done manually using the VM overrides option in the cluster configuration but how to do this using Powershell so that we can automate this I have really no idea. Google search did not help me this time.

Hopefully someone can show me where to look.

Best regards,

Patrick

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You can use the HARestartPriority parameter on the Set-VM cmdlet.

This gives you access to all the priorities (lowest,low,medium,high,highest and disabled).


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

View solution in original post

Reply
0 Kudos
6 Replies
LucD
Leadership
Leadership
Jump to solution

You can use the HARestartPriority parameter on the Set-VM cmdlet.

This gives you access to all the priorities (lowest,low,medium,high,highest and disabled).


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

Reply
0 Kudos
redpat_71
Contributor
Contributor
Jump to solution

Thank you very much for you very swift reply.

Was thinking about using restart delays only but combining default restart delays with restart priorities should work.

So:

- Oracle + SQL cluster : default restart delay 30 secs

     * PRD     : priority high

     * ACC     : priority medium

     * DEV     : priority low

     * TST      : priority low

- Application VMs : default restart delay 90 secs

     * AD/DNS : restart delay 0 secs

     * PRD     : priority high

     * ACC     : priority medium

     * DEV     : priority low

     * TST      : priority low

Plenty of Set-VM example scripts so I should be able to figure that out.

Sounds like a plan. Thanks again

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Feel free to ask if you get stuck somewhere


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

Reply
0 Kudos
redpat_71
Contributor
Contributor
Jump to solution

Almost there:

This works : Get-VM SRV00220 | Set-VM -HARestartPriority High -Confirm:$false

This works : Get-Datacenter NL001 | Get-Cluster Production | Get-VM | Get-Annotation -CustomAttribute "Application Environment" | where {$_.Value -eq "Acceptance"}

But when I pipe the result of the 2nd to the 1st:

Get-Datacenter NL001 | Get-Cluster Production | Get-VM | Get-Annotation -CustomAttribute "Application Environment" | where {$_.Value -eq "Acceptance"} | Set-VM -HARestartPriority High -Confirm:$false

then I get the error

pastedImage_0.png

I suppose this is caused because output of the 2nd command is not the VM itself. But no idea how to fix it

Some help would be very welcome

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Try like this

Get-Datacenter NL001 | Get-Cluster Production |

Get-VM |

where{Get-Annotation -Entity $_ -CustomAttribute "Application Environment" | where {$_.Value -eq "Acceptance"}} |

Set-VM -HARestartPriority High -Confirm:$false


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

redpat_71
Contributor
Contributor
Jump to solution

Works like a charm

I even think I understand the fix

Dank u wel

Reply
0 Kudos