- Community Home
- >
- Storage
- >
- Around the Storage Block
- >
- Reload inaccessible or invalid VMs
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- 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...