Stale Virtual Machine Swapfile location in ESXi

While attempting to configure Virtual Machine Swapfile location in ESXi, I get an error
The object has already been deleted or has not been completely created“.

In vCenter, after navigating to Configuration-> Virtual Machine Swapfile location, the “Edit” is greyed out disallowing me to configure the swapfile location.

The problem is, it was pointing to a datastore that is no longer mounted.
Ssh to the host:

~ # grep -i HostLocalSwapDir  /etc/vmware/esx.conf
/adv/Mem/HostLocalSwapDir = "/vmfs/volumes/0391a5b2-65784bc7"
/adv/Mem/HostLocalSwapDirEnabled = "1"
~ # ls -l /vmfs/volumes/0391a5b2-65784bc7
ls: /vmfs/volumes/0391a5b2-65784bc7: No such file or directory

The host has been re-purposed from a different cluster and its datastores had been unmounted, including the swap datastore. To fix this

1) vi /etc/vmware/esx.conf and I replaced the stale datastore with the new swap datastore. This did not resolve the issue

2) Next I restarted hostd “/etc/init.d/hostd restart” after which I could configure the swapfile location from the vCenter GUI.

Stale Virtual Machine Swapfile location in ESXi

Find all ESXi hosts in a subnet

I have got a task to clear subnets off non-VMware hosts so we can turn on dhcp, PXE for Auto Deploy. I have identified inactive IPs and our DNS admin reclaimed them. I need a way to verify the active IPs are VMware ESXi.

My first method is to ssh to the IPs and run vmware -v in a for loop.

for i in `cat list`
do 
    ssh -q -o "BatchMode yes" root@$i vmware -v
done

We have ssh keys setup but for every subnet there are a bunch of hosts where I cannot ssh with keys. I do not have the time to fix them all.
Continue reading “Find all ESXi hosts in a subnet”

Find all ESXi hosts in a subnet