6.0
Table Of Contents
- vSphere Command-Line Interface Concepts and Examples
- Contents
- About This Book
- vSphere CLI Command Overviews
- Introduction
- List of Available Host Management Commands
- Targets and Protocols for vCLI Host Management Commands
- Supported Platforms for vCLI Commands
- Commands with an esxcfg Prefix
- ESXCLI Overview
- Connection Options for vCLI Host Management Commands
- Connection Options for DCLI Commands
- vCLI Host Management Commands and Lockdown Mode
- Managing Hosts
- Managing Files
- Managing Storage
- Introduction to Storage
- Examining LUNs
- Detaching Devices and Removing a LUN
- Working with Permanent Device Loss
- Managing Paths
- Managing Path Policies
- Scheduling Queues for Virtual Machine I/O
- Managing NFS/NAS Datastores
- Monitoring and Managing SAN Storage
- Monitoring and Managing Virtual SAN Storage
- Monitoring vSphere Flash Read Cache
- Monitoring and Managing Virtual Volumes
- Migrating Virtual Machines with svmotion
- Configuring FCoE Adapters
- Scanning Storage Adapters
- Retrieving SMART Information
- Managing iSCSI Storage
- iSCSI Storage Overview
- Protecting an iSCSI SAN
- Command Syntax for esxcli iscsi and vicfg-iscsi
- iSCSI Storage Setup with ESXCLI
- iSCSI Storage Setup with vicfg-iscsi
- Listing and Setting iSCSI Options
- Listing and Setting iSCSI Parameters
- Enabling iSCSI Authentication
- Setting Up Ports for iSCSI Multipathing
- Managing iSCSI Sessions
- Managing Third-Party Storage Arrays
- Managing NMP with esxcli storage nmp
- Path Claiming with esxcli storage core claiming
- Managing Claim Rules
- Managing Users
- Managing Virtual Machines
- vmware-cmd Overview
- Listing and Registering Virtual Machines
- Retrieving Virtual Machine Attributes
- Managing Virtual Machine Snapshots with vmware-cmd
- Powering Virtual Machines On and Off
- Connecting and Disconnecting Virtual Devices
- Working with the AnswerVM API
- Forcibly Stopping Virtual Machines with EXCLI
- Managing vSphere Networking
- Introduction to vSphere Networking
- Retrieving Basic Networking Information
- Network Troubleshooting
- Setting Up vSphere Networking with vSphere Standard Switches
- Setting Up Virtual Switches and Associating a Switch with a Network Interface
- Retrieving Information About Virtual Switches
- Adding and Deleting Virtual Switches
- Checking, Adding, and Removing Port Groups
- Managing Uplinks and Port Groups
- Setting the Port Group VLAN ID
- Managing Uplink Adapters
- Adding and Modifying VMkernel Network Interfaces
- Setting Up vSphere Networking with vSphere Distributed Switch
- Managing Standard Networking Services in the vSphere Environment
- Setting the DNS Configuration
- Adding and Starting an NTP Server
- Managing the IP Gateway
- Setting Up IPsec
- Managing the ESXi Firewall
- Monitoring VXLAN
- Monitoring ESXi Hosts
- Index
VMware, Inc. 107
Chapter 8 Managing Virtual Machines
To list, unregister, and register virtual machines
1Runvmware-cmd -ltolistallregisteredvirtualmachinesonaserver.
vmware-cmd -H <vc_server> -U <login_user> -P <login_password> --vihost <esx_host> -l
ThecommandliststheVMXfileforeachvirtualmachine.
/vmfs/volumes/<storage>/winxpPro-sp2/winxpPro-sp2.vmx
/vmfs/volumes/<storage>/RHEL-lsi/RHEL-lsi.vmx
/vmfs/volumes/<storage>/VIMA0809/VIMA0809.vmx
.....
2Runvmware-cmd -s unregistertoremoveavirtualmachinefromtheinventory.
vmware-cmd -H <vc_server> -U <login_user> -P <login_password> --vihost <esx_host>
-s unregister /vmfs/volumes/Storage2/testvm/testvm.vmx
Thesystemreturns0toindicatesuccess,1toindicatefailure.
3Runvmware-cmd -lagaintoverifythatthevirtualmachinewasremovedfromtheinventory.
4Runvmware-cmd -s registertoaddthevirtualmachinebacktotheinventory.
vmware-cmd -H <vc_server> -U <login_user -P <login_password --vihost <esx_host> -s register
/vmfs/volumes/Storage2/testvm/testvm.vmx
Thesystemreturns0toindicatesuccess,1toindicatefailure.
Retrieving Virtual Machine Attributes
vmware-cmdincludesoptionsforretrievinginformationaboutavirtualmachine.Eachoptionrequiresthat
youspecifythevirtualmachinepath(see“FormatforSpecifyingVirtualMachines”onpage 106).Youmust
alsospecifyconnectionoptions,whichdifferfromothervCLIcommands(see“ConnectionOptionsfor
vmware‐cmd”onpage 106).
Youcanuse
vmware-cmdoptionstoretrieveanumberofdifferentvirtualmachineattributes.Foracomplete
listofoptions,seethevSphereCLIReference.
Theguestinfooptionallowsyoutoretrieveinformationabouttheguestoperatingsystem.Forexample,
youcanretrievethenumberofremoteconsolesallowedbyavirtualmachinebyusingguestinforwith
theRemoteDisplay.maxConnectionsvariable.
vmware-cmd -H <vc_system> -U <user> -P <password> --vihost <esx_host>
/vmfs/volumes/Storage2/testvm/testvm.vmx getguestinfo RemoteDisplay.maxConnections
TheHardeningGuideincludesadditionalinformationaboutvariablesyoucanuseinconjunctionwith
guestinfo.Acompletelistisnotavailable.
Thegetuptimeoptionretrievestheuptimeoftheguestoperatingsystemonthevirtualmachine,in
seconds.
vmware-cmd -H <vc_system> -U <user> -P <password> --vihost <esx_host>
/vmfs/volumes/Storage2/testvm/testvm.vmx getuptime
getuptime() = 17921
Thegetproductinfo productoptionliststheVMwareproductthatthevirtualmachinerunson.
vmware-cmd -H <vc_system> -U <user> -P <password> --vihost <esx_host>
/vmfs/volumes/Storage2/testvm/testvm.vmx getproductinfo product
NOTEWhenyourunagainstavCenterServersystem,youmustspecifythedatacenterandtheresource
pooltoregisterthevirtualmachinein.Thedefaultdatacenterisha-datacenterandthedefaultresource
poolisResources.
WhenyourunagainstanESXihost,youusuallydonotspecifythe
resourcepoolanddatacenter.
However,iftwovirtualmachineswiththesamenameexistintworesourcepools,youmustspecifythe
resourcepool.