Prior to Vmware server 2.0, vmware-cmd was the command line tool for the managements of the virtual machines. In Vmware 2.0, vmware-vim-cmd is the tool that can be used for command line management and automation. Here are some of the example on how to use it.

List all Virtual guests running on vmware server:

[root@foo-vm12 bin]# /usr/vmware/bin/vmware-vim-cmd vmsvc/getallvms
Vmid       Name                         File      Guest OS          Version
112    win67dl   [standard] win67dl/win67dl.vmx   winNetEnterpriseGuest   vmx-07
128    win68dl   [standard] win68dl/win68dl.vmx   winNetEnterpriseGuest   vmx-07
16     win73dl   [standard] win73dl/win73dl.vmx   winXPProGuest           vmx-07
32     win74dl   [standard] win74dl/win74dl.vmx   winXPProGuest           vmx-07
48     win75dl   [standard] win75dl/win75dl.vmx   winXPProGuest           vmx-07
[root@foo-vm12 bin]#

Get the information of a guest :

[root@foo-vm12 bin]# /usr/vmware/bin/vmware-vim-cmd vmsvc/get.guest  128
Guest information:

(vim.vm.GuestInfo) {
   dynamicType = <unset>,
   toolsStatus = “toolsOk”,
   toolsVersion = “116503”,
   guestId = “winNetEnterpriseGuest”,

   hostName = “win68dl”,
   ipAddress = “164.81.69.100”,
   net = (vim.vm.GuestInfo.NicInfo) [
      (vim.vm.GuestInfo.NicInfo) {
         dynamicType = <unset>,

         deviceConfigId = 4000,
      }
   ],
   disk = (vim.vm.GuestInfo.DiskInfo) [
      (vim.vm.GuestInfo.DiskInfo) {

   guestState = “running”,
}
[root@foo-vm12 bin]#

Get detailed configuration of the guest, using “vmsvc/get.config”.

[root@foo-vm12 bin]# /usr/vmware/bin/vmware-vim-cmd vmsvc/get.config 128
Configuration:

(vim.vm.ConfigInfo) {
   dynamicType = <unset>,
   changeVersion = “2008-11-14T18:10:02.621749Z”,
   modified = “1970-01-01T00:00:00Z”,
   name = “win68dl”,
   version = “vmx-07”,
   instanceUuid = “”,
<cut>

Get power state of a virtual machine:

[root@foo-vm12 bin]# /usr/vmware/bin/vmware-vim-cmd vmsvc/power.getstate 128
Retrieved runtime info
Powered on
[root@foo-vm12 bin]#

Power off a virtual machine :

[root@foo-vm12 bin]# /usr/vmware/bin/vmware-vim-cmd vmsvc/power.off 128
Powered off
[root@foo-vm12 bin]#

Power on a virtual machine :

[root@foo-vm12 bin]# /usr/vmware/bin/vmware-vim-cmd vmsvc/power.on 128
Powered on
[root@foo-vm12 bin]#

The commands – “power.off power.on power.reboot power.reset power.shutdown” are used for power management.

Get network information of a virtual machine :

[root@foo-vm12 bin]# /usr/vmware/bin/vmware-vim-cmd vmsvc/get.networks 128
Networks:

(vim.Network.Summary) {
   dynamicType = <unset>,
   network = ‘vim.Network:HaNetwork-Bridged’,
   name = “Bridged”,
   accessible = true,
   ipConfig = (vim.Network.IpConfigInfo) null,
}

To destroy (delete) a VM:

This command stops a vm and unregisters it.

[root@foo-vm12 bin]# /usr/vmware/bin/vmware-vim-cmd vmsvc/destroy 128
Deleted.
[root@foo-vm12 bin]#

To know about the Vmware server information :

[root@foo-vm12 bin]# /usr/vmware/bin/vmware-vim-cmd hostsvc/hostconfig
(vim.host.ConfigInfo) {
   dynamicType = <unset>,
   host = ‘vim.HostSystem:ha-host’,
   product = (vim.AboutInfo) {
      dynamicType = <unset>,
      name = “VMware Server”,
      fullName = “VMware Server 2.0.0 “,
      vendor = “VMware, Inc.”,
      version = “2.0.0”,
      build = “116503”,
      localeVersion = “INTL”,
      localeBuild = “000”,
      osType = “linux-x64”,
      productLineId = “gsx”,
      apiType = “HostAgent”,
      apiVersion = “2.5u2server”,
   }
<cut here>

0 Shares:
Leave a Reply

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

You May Also Like
Read More

Load Average

A very good article on Unix Load averages and how it is calculated [ http://www.linuxjournal.com/article/9001 ] . Worth…