Start and Manage a VM Without Using vSphere Client

You’re familiar with features in VMware vSphere that can help bring up critical virtual infrastructure after a widespread datacenter outage — planned or otherwise — but did you also know that it’s possible to power on a virtual machine and even determine the dynamic IP address of a guest OS using a simple command-line utility?  This could be handy after a disaster or if you normally rely on a Windows virtual machine to run the vSphere Client and don’t feel like firing up Fusion for one quick task.

Power on and SSH to a Linux VM from Mac OS X

Consider this real-world situation:  You are working remotely on your Mac and need to log into a powered-off Linux VM back in the datacenter.  Don’t fret — if you can ssh to the host using Tech Support Mode (VMware ESXi 4.1 shown here), you are most of the way there.  Thanks to vim-cmd you can find your VM, power it on, and learn the guest OS IP address in no time:

Let’s break it down step by step:

1. Use grep to find the ID of your VM (1008 in this example):

~ # vim-cmd vmsvc/getallvms | grep -i CENTOS1
1008   CENTOS1      [CX4-01-LUN9] CENTOS1/CENTOS1.vmx         centos64Guest

2. Quick sanity check to verify the VM is actually powered off:

~ # vim-cmd vmsvc/get.summary 1008 | egrep '(power|ip)'
      powerState = "poweredOff",
      ipAddress = ,

3. Power on, wait a few moments, and check status again:

~ # vim-cmd vmsvc/power.on 1008
Powering on VM:
~ # vim-cmd vmsvc/get.summary 1008 | egrep '(power|ip)'
      powerState = "poweredOn",
      ipAddress = "10.136.234.38",
~ #

4.  Connect with ssh (or RDP, if targeting a Windows VM) and get on with things

Enjoy!

Related posts:

  1. VI Client SSL thumbprint cache cleanup
  2. Easily view guest IP addresses with vSphere Client
  3. Exclusive: Hyper-V 2013 Product Roadmap
  4. Idle RHEV Hypervisors save power?
  5. Half the VM reboots on Patch Tuesday

Tags: , ,

  1. dave’s avatar

    Thanks for the steps.

    It looks like you have to have VMWare guest tools installed in order to get the ip address this way. Is this true?

    ~ # vim-cmd vmsvc/get.summary 16 | egrep ‘(power|ip)’
    powerState = “poweredOn”,
    ipAddress = ,

    We don’t install the guest tools:

    guest = (vim.vm.Summary.GuestSummary) {
    dynamicType = ,
    guestId = ,
    guestFullName = ,
    toolsStatus = “toolsNotInstalled”,
    toolsVersionStatus = “guestToolsNotInstalled”,
    toolsRunningStatus = “guestToolsNotRunning”,
    hostName = ,
    ipAddress = ,
    },

    Reply

    1. Eric Gray’s avatar

      Yes. You are running Tools aren’t you?

      Reply

  2. Yura’s avatar

    Very thanks for it! You are safe my life! :)
    sorry for my english (:

    Reply

  3. Yura’s avatar

    Im lost vCenter on blade array, and i’l need up it. Very thanks for help!

    Reply

Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>