- Community Home
- >
- Storage
- >
- Around the Storage Block
- >
- Reload inaccessible or invalid VMs
-
-
Forums
- Products
- Servers and Operating Systems
- Storage
- Software
- Services
- HPE GreenLake
- Company
- Events
- Webinars
- Partner Solutions and Certifications
- Local Language
- China - 简体中文
- Japan - 日本語
- Korea - 한국어
- Taiwan - 繁體中文
-
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
- HPE Blog, Austria, Germany & Switzerland
- Blog HPE, France
- HPE Blog, Italy
- HPE Blog, Japan
- HPE Blog, Middle East
- HPE Blog, Latin America
- HPE Blog, Russia
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
- HPE Blog, Poland
-
Blogs
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Blog, Latin America
- HPE Blog, Middle East
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
-
Information
- Community
- Welcome
- Getting Started
- FAQ
- Ranking Overview
- Rules of Participation
- Tips and Tricks
- Resources
- Announcements
- Email us
- Feedback
- Information Libraries
- Integrated Systems
- Networking
- Servers
- Storage
- Other HPE Sites
- Support Center
- Aruba Airheads Community
- Enterprise.nxt
- HPE Dev Community
- Cloud28+ Community
- Marketplace
-
Forums
-
Forums
-
Blogs
-
Information
-
English
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Receive email notifications
- Printer Friendly Page
- Report Inappropriate Content
Reload inaccessible or invalid VMs
Have you ever had a blip in your network, or a temporary network outage? Has your VMware vSphere environment recovered completely after that? Or did you end up in an annoying situation where your network/FC storage (iSCSI, FCoE, NFS, FC) took a little "longer" to come up, as compared to your ESXi servers? In such cases, you may end up with a situation where the VMs in your vSphere environment show up as "inaccessible". One way to remedy the situation is to unregister each VM and re-register the VM's vmx file to vCenter or the ESXi host. But if you have an environment larger than 10 VMs, this can become a tedious, manual task. Within our QA environments, we often end up breaking things and need a fast, automated way to recover.
Inaccessible VMs
Command-line scripts with vim-cmd
VMware KB 1026043 outlines this solution: reload the VM's vmx file on the ESXi host using the vim-cmd commands:
- Get the VM's Vmid with this command, to identify your VM: #vim-cmd vmsvc/getallvms
- Reload the VMX using the reload command: #vim-cmd vmsvc/reload Vmid
A one-liner script combining the two steps above, to be run on each ESXi server in your environment, as root:
for a in $(vim-cmd vmsvc/getallvms 2>&1 | grep invalid | awk '{print $4}' | cut -d \' -f2); do vim-cmd vmsvc/reload $a; done
In large environments, this can be a tedious job. Within a QA environment with 8 servers too, we wanted this automated. An option was indeed to configure password-less root ssh into each ESXi server, and run the script from a central desktop. But we wanted something more secure, less error-prone and with fewer breaking points.
PowerCLI to the rescue
A little more searching fetched us a PowerCLI one-liner solution! Logging in as administrator in your vCenter, you can execute this and it runs on ALL VMs in your inventory, on ALL ESXi servers.
(Get-View -ViewType VirtualMachine) | ?{$_.Runtime.ConnectionState -eq "invalid" -or $_.Runtime.ConnectionState -eq "inaccessible"} | %{$_.reload()}
Source: from techazine or hypervisor.fr
Let's break it down to understand the parts of this one-liner:
- Get-View -ViewType VirtualMachine
Retrieves all VMs in your vCenter inventory. The next part: - ?{$_.Runtime.ConnectionState -eq "invalid" -or $_.Runtime.ConnectionState -eq "inaccessible"}
This filters the VMs and looks for invalid or inaccessible VMs only. The last part: - %{$_.reload()}
This calls the vSphere reload API.
Voila! Just like that, your VMs are all back online and accessible!
- Back to Blog
- Newer Article
- Older Article
- Back to Blog
- Newer Article
- Older Article
- haniff on: High-performance, low-latency networks for edge an...
- StorageExperts on: Configure vSphere Metro Storage Cluster with HPE N...
- haniff on: Need for speed and efficiency from high performanc...
- haniff on: Efficient networking for HPE’s Alletra cloud-nativ...
- CalvinZito on: What’s new in HPE SimpliVity 4.1.0
- MichaelMattsson on: HPE CSI Driver for Kubernetes v1.4.0 with expanded...
- StorageExperts on: HPE Nimble Storage dHCI Intelligent 1-Click Update...
- ORielly on: Power Loss at the Edge? Protect Your Data with New...
- viraj h on: HPE Primera Storage celebrates one year!
- Ron Dharma on: Introducing Language Bindings for HPE SimpliVity R...
Hewlett Packard Enterprise International
- Communities
- HPE Blogs and Forum
© Copyright 2022 Hewlett Packard Enterprise Development LP