Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

ESXi (Free) Management

Exploring management options for an ESXi server in a home/lab environment.

  • It's so fucking rad that ESXi free doesn't provide a web interface. /sarcasm
  • Having a dedicated Windows VM for ESXi management is suck.
  • Running vSphere Client in Wine/Crossover requires hacks to install and doesn't work correctly.
  • How much does it cost to get a license for a lab environment?
  • Can we use the DCUI (Direct Console User Interface) without a license? (Answer: YES, via a directly console, over SSH, but we can only do very basic things)
  • Can we use the CLI/SDK/API tools? (Answer: PARTIALLY, Without a license it's locked down to read-only)
  • Can we SSH to the bare-metal host and use command line tools for manaagement? (Answer: YES, but we have to enable SSH)

License

TL;DR: Even the cheapest license (vSphere Server Essentials) is expensive for a home lab. This only includes server essentials for 1 user. :/

  • Base Price: USD 495.00

  • Required support: USD 65.00/year

  • vSphere Essentials Kits are for small businesses and combine virtualization for up to three physical servers with centralized management with vCenter for Essentials

  • This kit includes 6 CPU licenses of vSphere Essentials (for 3 servers with up to 2 processors each) and 1 license for vCenter Server Essentials.

    • vSphere ESXi Hypervisor (3x)
    • vCenter Server Essentials (1x)
    • vCenter Operations Manager Foundation (1x)
  • Compare vSphere Essentials Kits

  • vSphere License Pricing

  • VMware vSphere Essentials Kit

Official CLI & API

TL;DR: Without a license, the CLI & API tools are read-only. However, the DCUI is unlocked, even in the free version.

vCLI, PowerCLI, and vSphere SDK for Perl are limited to read-only access for the free vSphere Hypervisor edition. To enable full functionality > iof vCLI on a VMware ESXi host, the host must be licensed with vSphere Essentials, vSphere Essential Plus, vSphere Standard, vSphere Advanced, vSphere Enterprise, or vSphere Enterprise Plus.

-- source

DCUI

TL;DR: We can access the DCUI over SSH without a license, but we have to enable SSH access first. We only perform very basic management functions through DCUI.

DCUI Management:

  • Change root password
  • Configure NIC Hardware
  • COnfigure NIC Vlans
  • Configure NIC IP/IPv6
  • Configure VLANs
  • Configure DNS & DNS Suffixes

Access over SSH:

  1. Enable SSH access
  2. ssh root@$ESXI_HOST
  3. export TERM=linux
  4. dcui
  5. Use Fn-F2 to login
  6. Use Ctrl-c to exit

CLI over SSH

TL;DR: We can perform remote management via the shell environment on the host, but first we must enable SSH access. Not sure yet if these get locked down when trial ends. I think they don't, because it appears that the free (fat) client uses them.

Enabling SSH Access

Enabling from the DCUI:

  1. Access the direct console of the ESXi host, press F2, and provide credentials when prompted.
  2. Scroll to Troubleshooting Options, and press Enter.
  3. Select Enable ESXi Shell and press Enter.

Enabling SSH from the vSphere Client:

  1. Select the host, click the Configuration tab, and click Security Profile in the Software panel.
  2. In the Services section, click Properties.
  3. Select ESXi Shell and click Options.
  4. Change the ESXi Shell options.
  5. Click 'Start' button.
  6. Check 'Start and stop with host'.

Partial List of CLI Commands

The documentation on the internal commands is not readily available, so it takes some searching & testing to figure out how to use them.

Command Alias Description
/bin/chkconfig [-l] Shows daemons running on hypervisor. Can also be used for configuration.
/bin/dcui N/A Provides console screen to ssh session
/bin/esxcfg-advcfg N/A N/A
/bin/esxcfg-dumppart
/bin/esxcfg-fcoe
/bin/esxcfg-hwiscsi
/bin/esxcfg-info
/bin/esxcfg-init
/bin/esxcfg-ipsec
/bin/esxcfg-mpath
/bin/esxcfg-nics
/bin/esxcfg-route
/bin/esxcfg-module
/bin/esxcfg-nas
/bin/esxcfg-resgrp
/bin/esxcfg-rescan
/bin/esxcfg-scsidevs
/bin/esxcfg-swiscsi
/bin/esxcfg-vmknic
/bin/esxcfg-vswitch
/bin/esxcfg-volume
/bin/esxcli /bin/esxcli.py
/bin/esxhpcli
/bin/esxhpedit
/bin/esxtop Same as linux top for vmware
/bin/esxupdate
/bin/vim-cmd /bin/hostd
/bin/vmkload_mod [-l] List loaded kernel modules
/bin/vsish Vmware interactive shell
/usr/lib/vmware/esxcli

vim-cmd

Command Description
vim-cmd vmsvc/getallvms List all VMs registered to this host (This reveals the Vmid needed for other commands)
vim-cmd vmsvc/get.config $VMID Get Summary for a Specific VM
vim-cmd vmsvc/get.guest $VMID Get Configuration for a Specific VM
vim-cmd vmsvc/register $VMXPATH Register a VM
vim-cmd vmsvc/unregister $VMID Unregister a VM
vim-cmd vmsvc/power.getstate $VMID Get power state of a VM
vim-cmd vmsvc/power.on $VMID Power on a VM
vim-cmd vmsvc/power.off $VMID Power off a VM (hard)
vim-cmd vmsvc/power.shutdown 30 Shutdown a Specific VM (soft)
vim-cmd vmsvc/power.reboot $VMID Reboots vmid referenced from getallvms command
vim-cmd vmsvc/destroy $VMID Deletes the vmdk and vmx files from disk
vim-cmd vmsvc/get.snapshot $VMID List a Specific VM’s Snapshots
vim-cmd vmsvc/tools.install $VMID Install VMware Tools for VM with ID
vim-cmd hostsvc/net/info Provides information about hypervisor networking
vim-cmd hostsvc/maintenance_mode_exit Takes hypervisor out of maintenance mode
vim-cmd hostsvc/maintenance_mode_enter Puts hypervisor into maintenance mode
vim-cmd hostsvc/enable_esx_shell Enable ESXi Shell
vim-cmd hostsvc/disable_esx_shell Disable ESXi Shell
vim-cmd hostsvc/start_esx_shell Start ESXi Shell
vim-cmd hostsvc/enable_ssh Enable the ssh daemon
vim-cmd hostsvc/start_ssh Start ssh daemon
vim-cmd hostsvc/disable_ssh Disable ssh daemon
vim-cmd hostsvc/datastore/rename OldName NewName Rename a datastore
vim-cmd hostsvc/advopt/update DCUI.Access string root,william,tuan control which local users have full admin privileges to the DCUI

esxcli

Command Description
esxcli network ip route ipv4/ipv6 VMkernel routes
esxcli network ip interface tag (tag VMkernel traffic types)
esxcli storage core path list Get a list of all storage pathes
esxcli storage core path list -d naa.600000e00d11000000111a2400000000 Get storage pathes for a specific drive
esxcli storage filesystem list Get a list of all storage devices
esxcli storage nmp device list Show Storage Array Type and Path selection policies of disk devices
esxcli system settings advanced list Get all
esxcli system settings advanced set -o /UserVars/SuppressShellWarning -i 1 Set one, i.e. disable the shell respectively ssh warnings
esxcli system settings advanced set -o /UserVars/ESXiShellInteractiveTimeOut -i 3600 shell session will automatically logout based on configured idle time (in seconds)
esxcli system maintenanceMode set -e true -t 0 enter maintenance mode
esxcli system maintenanceMode (maintenance mode)
esxcli system snmp (SNMP)

esxcfg-*

Command Description
esxcfg-info Lists a LOT of information about the esx host
esxcfg-module -q Get a list of all enabled kernel modules
esxcfg-module -g lpfc820 Get parameters of a kernel modul, i.e. an Emulex FC HBA module
esxcfg-module -i lpfc820 Get info of a module with all possible parameters and a description of each
esxcfg-nics -l Lists information about NIC's. Can also be used for configuration.
esxcfg-vswitch -l Lists information about virtual switching. Can also be used for configuration.

Misc

esxcli vms vm list ( esxcli vm process list) - lists VM and the world id, you can kill, send NMI mask using vm-support command.(esxcli vm process kill ,

vm-support -V, vm-support -x ,vm-support -X - captures screenshot,etc.,

vmdumper vmdumper: [options]

vim-cmd vmsvc/device.getdevices $id|egrep -i "vmdk|compat" vim-cmd vmsvc/get.datastores 35 vim-cmd vmsvc/device.diskaddexisting vim-cmd hostsvc/datastore/summary datastore2 vim-cmd hostsvc/refresh_services vim-cmd vmsvc/message

To find the ip addresses allocated

for vm in vim-cmd vmsvc/getallvms | awk '{print $1}'|grep -v -i vmid; do vim-cmd vmsvc/get.summary $vm |grep -i ipAdd done

References:

CLI Scripting

References

Some helpful resources.

Guides & Articles

Code & Tools

Python

  • pyvmomi - Python SDK for the VMware vSphere API that allows you to manage ESX, ESXi, and vCenter.
  • pyvmomi-community-samples - Community contributed samples for the pyVmomi library.
  • pyvmomi-tools - Incubator project for additional pyVmomi based tools and libraries as needed by the development community.

Third-Party

  • pyvsphere - Python API for interaction with the vSphere Web Services SDK.
  • esxi-tools - A collection of Python tools and scripts to automate the management of a remote ESXi host.
  • esxi-util - python scripts to operate ESXi server.
  • py-vconnector - VMware vSphere Connector Module for Python.
  • django-vsphere - django-vsphere is an app for Django to have a centralized dashboard for all your VMWare vSphere ESXi.

Misc

  • vEMan - Manage ESX servers natively from Linux desktop.
  • esxi-simple-web - Basic controls for esxi host in the browser.
  • ESXi-PoC-Client - C++ client to communicate with ESXi Web-service and dump virtual machines information.
  • pi-control - Control & monitor ESXi hypervisor from raspberry-pi.
  • suseviclient - Lightweight tool for ESXi management from Linux box.
  • vmmng - Simple, yet effective, VMWare ESXi comand line wrapper written in Ruby.
  • RVC - Ruby vSphere Console - Linux console UI for vSphere, built on the RbVmomi bindings to the vSphere API.
@jderrien

This comment has been minimized.

Copy link

commented May 10, 2015

Good write up, thanks for sharing.

@RenTamu

This comment has been minimized.

Copy link

commented Aug 2, 2017

How to execute unmap command in esxi server using pyvmomi?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.