VMware Cloud Community
sjesse
Leadership
Leadership
Jump to solution

Check host status before creating snapshot

We have created an automated patching process for linux that creates snapshots before the virtual machines are patched. It works for the most part but we sometimes get the

The operation is not allowed in the current state of the host

and I am hoping there is a way we can check for this. I'm wondering if anyone has tried something similar, I'm thinking of getting creative and having the script check for the event somehow, but I can't think of the best process right now.

Any help is appreciated.

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

The most common technique I know that this is done with, is to add the snapshot method to the DisabledMethod property.

You could check with something like this

$vmName = 'MyVM'

Get-VM -Name $vmName |

Select Name,@{N='Snapshot Possible';E={$_.Extensiondata.DisabledMethod -notcontains 'CreateSnapshot_Task'}}

The moment you vMotion or svMotion that VM, you'll notice that the 'Snapshot Possible' changes to $false.


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

View solution in original post

5 Replies
LucD
Leadership
Leadership
Jump to solution

Can you share some more info on why this message comes?
In what state is the host (I assume you mean a VM by that)?


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

0 Kudos
sjesse
Leadership
Leadership
Jump to solution

I'm pretty sure its because the host was placed in maintenance mode, but I'm wondering if any long running vmotion would cause this.. I was looking at the events for the vm in the web client

pastedImage_0.png

and we where doing esxi host updates at the same time frame. The migration took 10 minutes and in the middle is when it tried the snapshot. I know manual snapshots aren't possible while a vmotion is in progress, but I think backup programs check for this somehow, and I was hoping there is a powershell way.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

The most common technique I know that this is done with, is to add the snapshot method to the DisabledMethod property.

You could check with something like this

$vmName = 'MyVM'

Get-VM -Name $vmName |

Select Name,@{N='Snapshot Possible';E={$_.Extensiondata.DisabledMethod -notcontains 'CreateSnapshot_Task'}}

The moment you vMotion or svMotion that VM, you'll notice that the 'Snapshot Possible' changes to $false.


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

sjesse
Leadership
Leadership
Jump to solution

Thanks. A side question is there a good reference on what is in extensiondata, is it just the api reference?

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Yes, I'm afraid it is the only reference to find out what lives behind ExtensionData and in the objects returned by the Get-View cmdlet.


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