VMware Cloud Community
Marcel00M
Contributor
Contributor

Vi Toolkit 1.5: It is possible to remove a VM in VC when its host is not responding?

Hello @All

following situation:

HA ist turned off. cluster with 4 hosts (ESX 3.5 and VC 2.5) and one host ist down (powered off - hard)

When using remove-vm VNNAME it promts an question to perfom this action. But after that I get an error: Unable to communicate with the remote host...

(The command does not have any further Options that helps me.)

So that behavior might be expectet to you (when the Host is down... it is down g)

But someone told me, with Vi Toolkit I can unregister a VM in VC also when its host is down.

The target of this is to write a script for a failover of a host (for reasons that i dont want to explain, we can't use HA now).

If i just register the VM on an remaining host, I get a summary question when I power on the "old" host (and i don't want to change the UUID of the VM).

(Thats imho not the a clean or healthy solution)

It is an way do remove this VM in the database?

thx for your help! Smiley Happy

0 Kudos
9 Replies
LucD
Leadership
Leadership

Did you also try the UnregisterVM method on the VirtualMachine object ?

(Get-Vm VMNAME | Get-View).UnregisterVM()


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

0 Kudos
Marcel00M
Contributor
Contributor

Yes with the same result (unable to communicate with the remote host)

0 Kudos
Marcel00M
Contributor
Contributor

an workaround (I have testet succsessfully) is to remove the "crashed" host from the cluster and register and power on its vm´s on another host. After an adding back the "crashd" host in the cluster, the test VM was not anymore in VM the list of the "crashed host" (and not double in VC and no further probelms occur). at all this workaround should be sufficient for an workaround (wich the script is)... anyway i am interesseted in a solution (question in the subject).

0 Kudos
LucD
Leadership
Leadership

I'm not sure I understand exactly what you're asking for.

Do you want a PowerCLI script that does what you did manually ?

- remove crashed host

- register VMs on another host

- start VMs


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

0 Kudos
Marcel00M
Contributor
Contributor

No we have a complete script. But what dont work is the thing in the subject of this thread (remove a VM in VC when its host is not responding).

The developer of this script was just temporary available and I want to complete it by implementing this functionality (with the removing/deregister...)

I diden´t have Powershell experience at all... My home is the Linux Bash and I write my Scripts there with ESX Commands (Normaly thats sufficient for what I need).

But for this one functionality in the subject whe needed the API (and exactly that diden´t work )

I have installed the Toolkit a few days before. But if I have the syntax, I can find out what to do to add this functionality to the script.

But also if whe use the workaround with the removing of the "crashed" host, the script works without changing it. So a clean solution would be to add this functionality to the script.

0 Kudos
admin
Immortal
Immortal

I don't know of any way to remove a VM from a disconnected ESX host via the API, it's an API limitation.

Marcel00M
Contributor
Contributor

OK

But thank you all for your answers!

0 Kudos
admin
Immortal
Immortal

Try something like this:

Connect-VIServer -Server $VC -User administrator -password $VCpassword
$h = Get-VMHost -Name $addr
if ($h -eq $null) {
write-host "$addr: Not found in Virtual Center"
return
}
$cState = $h.State
if ($cState -eq "NotResponding") {
$hv = Get-View $h.ID
$hv.DisconnectHost()
$h = Get-VMHost -Name $addr
Remove-VMHost -VMHost $h -Confirm:$false
return
}
if ($cState -ne "Connected") {
Set-VMHost -VMHost $h -State Connected
$h = Get-VMHost -Name $addr
if ($h.State -ne "Connected") {
if ($cState -eq "NotResponding") {
$hv = Get-View $h.ID
$hv.DisconnectHost()
}
}
}
Remove-VMHost -VMHost $h -Confirm:$false
Disconnect-VIServer -Confirm:$false

lance

0 Kudos
Marcel00M
Contributor
Contributor

Sehr geehrte Damen und Herren,

ich bin bis zum 15.06.2009 nicht im Hause.

Ihre Mail wird nicht weitergeleitet.

Bitte wenden Sie sich an (11.06 Feiertag NRW):

Frank.Foerster@t-systems.com

TPG-Bi@t-systems.com (Verteiler)

Team Hotline: 0521 92158855

MfG

Marcel Möckel

0 Kudos