6.5
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 Commands Available on Different ESXi Hosts
- Trust Relationship Requirement for ESXCLI Commands
- Using ESXCLI Output
- 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
- Detach a Device and Remove a LUN
- Reattach a Device
- Working with Permanent Device Loss
- Managing Paths
- Managing Path Policies
- Scheduling Queues for Virtual Machine I/O
- Managing NFS/NAS Datastores
- Monitor and Manage FibreChannel 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
- Set Up Ports for iSCSI Multipathing
- Managing iSCSI Sessions
- Managing Third-Party Storage Arrays
- Managing Users
- Managing Virtual Machines
- Managing vSphere Networking
- Introduction to vSphere Networking
- Retrieving Basic Networking Information
- Troubleshoot a Networking Setup
- 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
- Managing VMkernel Network Interfaces with ESXCLI
- Add and Configure an IPv4 VMkernel Network Interface with ESXCLI
- Add and Configure an IPv6 VMkernel Network Interface with ESXCLI
- Managing VMkernel Network Interfaces with vicfg-vmknic
- Add and Configure an IPv4 VMkernel Network Interface with vicfg-vmknic
- Add and Configure an IPv6 VMkernel Network Interface with vicfg-vmknic
- Setting Up vSphere Networking with vSphere Distributed Switch
- Managing Standard Networking Services in the vSphere Environment
- Setting the DNS Configuration
- Manage an NTP Server
- Manage the IP Gateway
- Setting Up IPsec
- Manage the ESXi Firewall
- Monitor VXLAN
- Monitoring ESXi Hosts
- Index
The following examples illustrate connecting and disconnecting a virtual device. Device names are case
sensitive.
n
The connectdevice option connects the virtual IDE device CD/DVD Drive 2 to the specied virtual
machine.
vmware-cmd -H <vc_system> -U <user> -P <password> --vihost
<esx_host> /vmfs/volumes/Storage2/testvm/testvm.vmx connectdevice "CD/DVD drive 2"
n
The disconnectdevice option disconnects the virtual device.
vmware-cmd -H <vc_system> -U <user> -P <password> --vihost
<esx_host> /vmfs/volumes/Storage2/testvm/testvm.vmx disconnectdevice "CD/DVD drive 2"
Working with the AnswerVM API
The AnswerVM API allows users to provide input to questions, thereby allowing blocked virtual machine
operations to complete.
The vmware-cmd --answer option allows you to access the input. You can use this option when you want to
congure a virtual machine based on a user's input, such as in the following example situations.
1 The user clones a virtual machine and provides the default virtual disk type.
2 When the user powers on the virtual machine, it prompts for the desired virtual disk type.
Forcibly Stop a Virtual Machine with ESXCLI
You can use ESXCLI to stop a virtual machine forcibly.
In some cases, virtual machines do not respond to the normal shutdown or stop commands. In these cases, it
might be necessary to forcibly shut down the virtual machines. Forcibly shuing down a virtual machine
might result in guest operating system data loss and is similar to pulling the power cable on a physical
machine.
You can forcibly stop virtual machines that are not responding to normal stop operation with the esxcli vm
process kill command. Specify one of the options listed in “Connection Options for vCLI Host
Management Commands,” on page 19 in place of <conn_options>.
Procedure
1 List all running virtual machines on the system to see the World ID of the virtual machine that you
want to stop.
esxcli <conn_options> vm process list
2 Stop the virtual machine by running the following command.
esxcli <conn_options> vm process kill --type <kill_type> --world-id <ID>
The command supports three --type options. Try the types sequentially - soft before hard, hard before
force. The following types are supported through the --type option.
Type Description
soft Gives the VMX process a chance to shut down cleanly, like kill or kill -
SIGTERM.
hard Stops the VMX process immediately, like kill -9 or kill -SIGKILL.
force
Stops the VMX process when other options do not work.
What to do next
If all three options do not work, reboot your ESXi host to resolve the issue.
vSphere Command-Line Interface Concepts and Examples
130 VMware, Inc.