6.0
Table Of Contents
- Getting Started with vSphere Command-Line Interfaces
- Contents
- About This Book
- Managing vSphere with Command-Line Interfaces
- Installing vCLI
- Running Host Management Commands in the ESXi Shell
- Running vCLI Host Management Commands
- Overview of Running vCLI Host Management Commands
- Protecting Passwords
- Authenticating Through vCenter Server and vCenter Single Sign-On
- Authenticating Directly to the Host
- Trust Relationship Requirement for ESXCLI Commands
- Common Options for vCLI Host Management Command Execution
- Using vCLI Commands in Scripts
- Running Host Management Commands from a Windows System
- Running Host Management Commands from a Linux System
- Running DCLI Commands
- Index
Getting Started with vSphere Command-Line Interfaces
30 VMware, Inc.
vicfg-nics -l --username <sso_username> --password "<admin_pwd>" --server <vc_HOSTNAME_OR_IP>
--psc <psc_HOSTNAME_OR_IP> --vihost <esxi_HOSTNAME_OR_IP>
UsingasessionfileresultsinlessoverheadandbetterperformancethanconnectingtothePlatformServices
Controllerrepeatedly.
Authenticating Directly to the Host
vCLIoffersseveraloptionsforauthenticatingdirectlytothehost.
Using a Session File
Youcancreateasessionfilewiththesave_sessionscript.Thescriptisinthe/apps/sessiondirectoryof
thevSphereSDKforPerl,whichisincludedinthevCLIpackage.Youcanusethesessionfile,whichdoesnot
revealpasswordinformation,whenyourunvCLIcommands.Ifthesessionfile
isnotusedfor30 minutes,it
expires.
Ifyouuseasessionfile,otherconnectionoptionsareignored.
To create and use a session file
1 Connecttothedirectorywherethescriptislocated.
Forexample:
2Runsave_session.
Youcanusethesave_session.plscriptorthe--savesessionfileoptiontothevCLIcommand.You
mustspecifytheserver
toconnecttoandthenameofasessionfileinwhichthescriptsavesan
authenticationcookie.
save_session --savesessionfile <location> --server <server>
Forexample:
Ifyouspecifyaserver,butnousernameorpassword,thescriptpromptsyou.
3WhenyourunvCLIcommands,passinthesessionfileusingthe
--sessionfileoption.
<command> --sessionfile <sessionfile_location> <command_options>
Forexample:
Using Environment Variables
OnLinux,youcansetenvironmentvariablesinaLinuxbashprofileoronthecommandlinebyusinga
commandlikethefollowing:
export VI_SERVER=<your_server_name_or_address>
Windows:
cd C:\Program Files\VMware\VMware vSphere CLI\Perl\apps\session
Linux:
cd /usr/share/lib/vmware-vcli/apps/session
Windows:
save_session.pl --savesessionfile C:\Temp\my_session --server my_server
--username <username> --password <password>
Linux:
save_session --savesessionfile /tmp/vimsession --server <servername_or_address>
--username <username> --password <password>
Windows:
esxcli --sessionfile C:\Temp\my_session network ip interface list
vicfg-mpath.pl --sessionfile C:\Temp\my_session --list
Linux:
esxcli --sessionfile /tmp/vimsession network ip interface list
vicfg-mpath --sessionfile /tmp/vimsession --list