Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
This document supports the version of each product listed and supports all subsequent versions until the document is replaced by a new edition. To check for more recent editions of this document, see http://www.vmware.com/support/pubs.
EN-000886-00
You can find the most up-to-date technical documentation on the VMware Web site at: http://www.vmware.com/support/ The VMware Web site also provides the latest product updates. If you have comments about this documentation, submit your feedback to: docfeedback@vmware.com
Copyright 20102012 VMware, Inc. All rights reserved. This product is protected by U.S. and international copyright and intellectual property laws. VMware products are covered by one or more patents listed at http://www.vmware.com/go/patents. VMware is a registered trademark or trademark of VMware, Inc. in the United States and/or other jurisdictions. All other marks and names mentioned herein may be trademarks of their respective companies.
VMware, Inc.
Contents
AboutThisBook
1 ManagingvSpherewithCommandLineInterfaces 7
OverviewofvSphereCommandLineInterfaces 7 UsingthevSphereCommandLineInterface 8 UsingESXCLI 8 ESXCLISyntax 8 RunningESXCLIvCLICommands 9 CommandSyntax 9 CommandSupportwhenHostandvCLIVersionDoNotMatch 9 RunningESXCLICommandsintheESXiShell 9 ESXiShellAccesswiththeDirectConsole 10 EnablingLocalESXiShellAccess 10 UsingtheLocalESXiShell 11 RemoteESXiShellAccesswithSSH 11 EnablingSSHfortheESXiShell 11 UsingtheESXiShellwithSSH 12
2 InstallingvCLI 13
InstallationOverview 13 OverviewofLinuxInstallationProcess 14 InstallingthevCLIPackageonRedHatEnterpriseLinux 16 InstallingRequiredPrerequisiteSoftwareforRedHatEnterpriseLinux 16 InstallingthevCLIPackageonRHEL(NoInternetAccess) 16 InstallingvCLIonLinuxSystemswithInternetAccess 17 InstallingRequiredPrerequisiteSoftwareforLinuxSystemswithInternetAccess 17 InstallingthevCLIPackageonaLinuxSystemwithInternetAccess 18 RunningCommandsonLinux 19 UninstallingthevCLIPackageonLinux 19 InstallingandUninstallingvCLIonWindows 19 RunningCommandsonWindows 20 UninstallingthevCLIPackageonWindows 20 EnablingCertificateVerification 21 DeployingvMA 21
3 UsingthevSphereCommandLineInterface 23
OverviewofRunningCommands 23 SpecifyingAuthenticationInformation 24 OrderofPrecedenceforvCLIAuthentication 24 UsingaSessionFile 24 UsingEnvironmentVariables 25 UsingaConfigurationFile 25 UsingCommandLineOptions 26 UsingMicrosoftWindowsSecuritySupportProviderInterface 27 vCLIandLockdownMode 27 CommonOptionsforvCLIExecution 27 UsingvCLICommandsinScripts 29
VMware, Inc. 3
ESXCLICommandHierarchies 31
esxcliesxcliNamespace 31 esxclifcoeNamespace 31 esxclihardwareNamespace 32 esxcliiscsiNamespace 32 esxclinetworkNamespace 33 esxclischedNamespace 34 esxclisoftwareNamespace 34 esxclistorageNamespace 35 esxclisystemNamespace 36 esxclivmNamespace 36
VMware, Inc.
Intended Audience
ThisbookisforexperiencedWindowsorLinuxsystemadministratorswhoarefamiliarwithvSphere administrationtasksanddatacenteroperations.
Document Feedback
VMwarewelcomesyoursuggestionsforimprovingourdocumentation.Ifyouhavecomments,sendyour feedbacktodocfeedback@vmware.com.
Related Documentation
ThedocumentationforvCLIisavailableinthevSphereDocumentationCenterandonthevCLI documentationpage.Gotohttp://www.vmware.com/support/pubs,selectVMwareAdministration Products,andselectvSphereCommandLineInterface.
CommandLineManagementinvSphere5forServiceConsoleUsersisatechnicalnoteforuserswhoare currentlyusingESXserviceconsolecommands,scripts,agents,orlogs.Youlearnhowtotransitiontoan offhostimplementationortousetheESXiShellinspecialcases. vSphereCommandLineInterfaceConceptsandExamplespresentsusageexamplesformanycommands,such assettingupsoftwareandhardwareiSCSI,addingvirtualswitches,settingupActiveDirectory authentication,andsoon.ThedocumentincludesthesameexamplewiththeESXCLIcommandandwith thevicfg-command. vSphereCommandLineInterfaceReferenceisareferencetobothESXCLIcommandsandvicfg-commands. Thevicfg-commandhelpisgeneratedfromthePODavailableforeachcommand,runpod2htmlfor anyvicfg-commandtogenerateindividualHTMLfilesinteractively.TheESXCLIreferenceinformation isgeneratedfromtheESXCLIhelp.
VMware, Inc.
Support Offerings
TofindouthowVMwaresupportofferingscanhelpmeetyourbusinessneeds,goto http://www.vmware.com/support/services.
VMware, Inc.
See UsingESXCLIonpage 8 InstallingvCLIon page 13 vSphereCommandLine ConceptsandExamples vSphereManagement AssistantGuide vSphereCommandLine InterfaceReference
ESXCLIcommands
YoucanalsorunESXCLIcommandsfromthevSpherePowerCLI promptbyusingtheGet-EsxClicmdlet. esxcfg-commands AvailableintheESXiShell.esxcfg-commandsarestillincluded inthisreleasebutaredeprecated.MigratetoESXCLIwhere possible.ESXCLIreplacementsexistformostcommands. IntroducedinvSphere3toallowuserstomanagehostsremotely. InstallthevCLIpackageontheserverofyourchoice,ordeploya vMAvirtualmachineandtargettheESXisystemthatyouwant manipulate. YoucanrunthecommandsagainstESXisystemsoragainsta vCenterServersystem.IfyoutargetavCenterServersystem,use the--vihostoptiontospecifythetargetESXisystem. Note:IftheESXisystemisinlockdownmode,youmustrun commandsagainstthevCenterServersystemthatmanagesyour ESXisystem. CommandLineManagement ofvSphere5forService ConsoleUsers InstallingvCLIonpage 13 vSphereCommandLine ConceptsandExamples vSphereCommandLine InterfaceReference
vicfg-andother vCLIcommands
VMware, Inc.
localclicommands
Using ESXCLI
YoucanmanagemanyaspectsofanESXihostwiththeESXCLIcommandset.YoucanrunESXCLIcommands asvCLIcommandsorrunthemintheESXiShellintroubleshootingsituations. YoucanalsorunESXCLIcommandsfromthePowerCLIshellbyusingtheGet-EsxClicmdlet.SeethevSphere PowerCLIAdministrationGuideandthevSpherePowerCLIReference. ThesetofESXCLIcommandsavailableonahostdependsonthehostconfiguration.ThevSphere CommandLineInterfaceReferencelistshelpinformationforallESXCLIcommands.Runesxcli --server <MyESXi> --helpbeforeyourunacommandonahosttoverifythatthecommandisdefinedonthehostyou aretargeting.
ESXCLI Syntax
EachESXCLI5commandusesthesamesyntax.
esxcli [dispatcher options] <namespace> [<namespace> ...] <cmd> [cmd options]
VMware, Inc.
command.Reportsonormodifiesstateonthesystem.
Command Syntax
Afterinstallation,runESXCLIcommandsagainstaspecifichostbyfirstspecifyingalldispatcheroptions.If thetargetserverisavCenterServersystem,specifythetargetESXihostbeforeanyESXCLInamespaces, commands,andsupportedoptions.
esxcli --server myESXi --username user1 --password 'my_password' storage nfs list esxcli --server myVCServer --username user1 --password 'my_pwd' --vihost myESXi.mycompany.com storage nfs list
Youcanuse--helpatanylevelofesxcliforhelponavailablenamespaces,commands,oroptions.
VMware, Inc.
Ifyoudonothaveaccesstothedirectconsole,youcanenabletheESXiShellfromthevSphereClient. To enable the local or remote ESXi Shell from the vSphere Client 1 2 3 4 Selectthehost,clicktheConfigurationtab,andclickSecurityProfileintheSoftwarepanel. IntheServicessection,clickProperties. SelectESXiShellandclickOptions. ChangetheESXiShelloptions.
TochangetheStartuppolicyacrossreboots,clickStartandstopwithhostandrebootthehost. Totemporarilystartorstoptheservice,clicktheStartorStopbutton.
ClickOK.
10
VMware, Inc.
SeevSphereInstallationandSetupdocumentationforinformationonserialportsetup.
VMware, Inc.
11
3 4 5
TochangetheStartuppolicyacrossreboots,clickStartandstopwithhostandrebootthehost. Totemporarilystartorstoptheservice,clicktheStartorStopbutton.
ClickOK.
AfteryouhaveenabledSSH,youlogintotheESXiShellremotelyandrunESXiShellcommands.
12
VMware, Inc.
Installing vCLI
InstallationOverviewonpage 13 OverviewofLinuxInstallationProcessonpage 14 InstallingthevCLIPackageonRedHatEnterpriseLinuxonpage 16 InstallingvCLIonLinuxSystemswithInternetAccessonpage 17 RunningCommandsonLinuxonpage 19 UninstallingthevCLIPackageonLinuxonpage 19 InstallingandUninstallingvCLIonWindowsonpage 19 RunningCommandsonWindowsonpage 20 EnablingCertificateVerificationonpage 21 DeployingvMAonpage 21
Installation Overview
YoucaninstallavCLIpackageonasupportedplatformordeploythevMAvirtualmachineonanESXihost.
VMware, Inc.
13
14
VMware, Inc.
XMLLibXML1.63 libwwwperl5.805 LWPProtocolhttps6.02 XMLLibXMLCommon0.13 XMLNamespaceSupport1.09 XMLSAX0.16 DataDump1.15 URI1.37 UUID0.03 SOAPLite0.710.08 HTMLParser3.60 version0.78 ClassMethodMaker2.10
IfarecommendedPerlmoduleisnotfoundatall,theinstallerinstallsitusingCPAN. YoumustmeettheinstallationprerequisitesortheinstallercannotinstallthePerl modulesandstops.SeeInstallingvCLIonLinuxSystemswithInternetAccesson page 17. Ifalowerversionofarecommendedmoduleisfound,theinstallerdoesnotinstalla differentversionfromCPANandproceedswithinstallation.Aftercompleting installation,theinstallerdisplaysamessagethattheversiononthesystemdoesnot matchtherecommendedversion,andrecommendsthatyouinstalltheversionvCLI wastestedwith.Youcaninstallthemodulesusingthepackageinstallerforyour platform,theinstallationCD,orCPAN. Ifahigherversionofarecommendedmoduleisfound,theinstallerproceedswith installationanddoesnotdisplayamessageafterinstallation.
Note:TheinstallerdoesnotoverwriteexistingversionsofrecommendedPerlmodules. Youmustexplicitlyupdatethosemodulesyourself.
DeleteexistingversionsofvSphere-CLI.xxxx.tar.gzanddeletethevmware-vsphere-cli-distrib directory.
Avmware-vsphere-vcli-distribdirectoryiscreated. 2 Loginassuperuserandruntheinstaller:
/<location>/sudo vmware-vsphere-cli-distrib/vmware-install.pl
3 4 5
16
VMware, Inc.
Acompleteinstallationprocesshasthefollowingresult:
Ifyouacceptedthedefaultsduringinstallation,youcanfindtheinstalledsoftwareinthefollowinglocations:
Installing Required Prerequisite Software for Linux Systems with Internet Access
Ifrequiredprerequisitesoftwareisnotinstalled,theinstallerstopsandrequeststhatyouinstallit.Installation ofprerequisitesoftwaredependsontheplatformthatyouareusing. Table 2-1. Installing Required Prerequisite Software
Platform RHEL5.5,32bit RHEL5.5,64bit SLES10,32bit SLES10,64bit Installation Installprerequisitesusingyum,theRHELpackageinstaller(recommended),orfromthe installationDVD.Forexample: yum install openssl-devel libxml2-dev e2fsprogs-dev InstalltheprerequisitepackagesfromtheSLES10andSLES11SDKDVD.Whenyouinsertthe DVD,itofferstoautorun.Canceltheautorundialogboxandusetheyastpackageinstallerto installOpenSSLorothermissingrequiredpackages.
VMware, Inc.
17
SomeusersmightbeauthorizedtousetheNovellCustomerCenteranduseyasttoretrieve missingpackagesfromthere. Ubuntu10.04,32bit Ubuntu10.04,64bit 1.ConnecttotheInternet. 2.Updatethelocalrepositoryoflibrariesfromaterminalwindow. sudo apt-get update 3.Installtherequiredlibrariesfromaterminalwindow.
32bit.sudo apt-get install build-essential gcc uuid uuid-dev perl libssl-dev perl-doc liburi-perl libxml-libxml-perl libcrypt-ssleay-perl 64bit.sudo apt-get install ia32-libs build-essential gcc uuid uuid-dev perl libssl-dev perl-doc liburi-perl libxml-libxml-perl libcrypt-ssleay-perl
ForUbuntu10.0464bit,youmustinstallthe32bitcompatibilitylibrariesortheresxtopand
ESXCLIcommandsdonotwork.
Runtheinstaller:
sudo vmware-vsphere-cli-distrib/vmware-install.pl
Specifyaninstallationdirectory,orpressEntertoacceptthedefault,whichis/usr/bin. Acompleteinstallationprocesshasthefollowingresult:
Ifyouacceptedthedefaultsduringinstallation,youcanfindtheinstalledsoftwareinthefollowinglocations:
vCLIscripts/usr/bin
18
VMware, Inc.
vSphereSDKforPerlutilityapplications/usr/lib/vmware-vcli/apps vSphereSDKforPerlsamplescripts/usr/share/doc/vmware-vcli/samples
Specifyconnectionoptionsinaconfigurationfileorpassthemonthecommandline.Theextension.pl isnotrequiredonLinux.Forexample:
esxcli --server <server> --username snow\-white --password dwarf\$ network ip interface list vicfg-mpath --server <server> --username snow\-white --password dwarf\$ --list
IMPORTANTIfyouwanttorunESXCLIcommandsincludedinvCLIfromaWindowssystem,youmusthave theVisualC++2008redistributablefor32bitinstalledonthatsystem.Findvcredist_x86.exeforVisualC++ 2008andinstallitonyourWindowssystem. To install the vCLI Package on Windows 1 DownloadthevCLIWindowsinstallerpackage. YoucanfindtheinstallerontheVMwareCommunitiespage.
VMware, Inc.
19
2 3
4 5
6 7
Rebootyoursystem. Withoutreboot,pathsettingsmightnotbecorrectonyourWindowsplatform.
Forexample:
esxcli --server <server> --username snow-white --password dwarf$ network ip interface list vicfg-mpath.pl --server <server> --username snow-white --password dwarf$ --list
ThesystemuninstallsthevSphereSDKforPerl,thevCLI,andallprerequisitesoftware.
20
VMware, Inc.
HTTPS_CA_FILETheCAfile. HTTPS_CA_DIRTheCAdirectory.
Deploying vMA
Asanalternativetoapackageinstallation,youcandeployvMAonanESXihostandrunvCLIcommandsfrom there.vMAisavirtualmachineyoucanusetorunscriptstomanageESXisystems.vMAincludesaLinux environment,vCLI,andotherprepackagedsoftware. SettingupvMAconsistsofafewtasks.ThevSphereManagementAssistantGuidediscusseseachtaskindetail. 1 DeployvMAtoanESXisystemthatmeetsthehardwareprerequisites. SeethevSphereManagementAssistantGuideforprerequisitesanddeploymentdetails. 2 ConfigurevMA. WhenyoubootvMA,youmustspecifythefollowingrequiredconfigurationinformationwhen prompted:
VMware, Inc.
21
22
VMware, Inc.
3f
VMware, Inc.
23
Followoneofthefollowingapproachesforprotectingpasswords.
IfyouarerunningvMA,youcansetuptargetserversandrunmostvCLIcommandsagainsttargetservers withoutadditionalauthentication.SeethevSphereManagementAssistantGuide.
24
VMware, Inc.
Ifyouspecifyaserver,butnousernameorpassword,thescriptpromptsyou. 3 WhenyourunvCLIcommands,passinthesessionfileusingthe--sessionfileoption.
<command> --sessionfile <sessionfile_location> <command_options>
VMware, Inc.
25
PassintheconfigurationfilewhenyourunvCLIcommands,asfollows:
<command> --config <my_saved_config> <option>
Forexample:
esxcli --config <my_saved_config> network ip interface list vicfg-mpath --config <my_saved_config> --list
Ifyouhavesetupyoursystemtorunthisfile,youcanrunscriptsonthespecifiedserverafterwards.
ForothervCLIcommands,uselongorshortoptions.Anequalsignisnotsupported.
<vicfg- command> --server <vc_server> --username <privileged_user> --password <pw> --vihost <esx_host> --<option_name option_value>
Windows
esxcli --server <server> --username snow-white --password dwarf$ network ip interface list vicfg-mpath.pl --server <server> --username snow-white --password dwarf$ --list
26
VMware, Inc.
IfyouhaveproblemsrunningacommandonanESXihostdirectly(withoutspecifyingavCenterServer target),checkwhetherlockdownmodeisenabledonthathost.SeethevSphereSecuritydocumentation.
Youcanuse--encodingtospecifytheencodingvCLIshouldmaptowhenit isrunonaforeignlanguagesystem. --passthroughauth VI_PASSTHROUGHAUTH Ifyouspecifythisoption,thesystemusestheMicrosoftWindowsSecurity SupportProviderInterface(SSPI)forauthentication.Trustedusersarenot promptedforausernameandpassword.SeetheMicrosoftWebsitefora detaileddiscussionofSSPI. ThisoptionissupportedonlyifyouarerunningvCLIonaWindowssystem andareconnectingtoavCenterServersystem. --passthroughauthpackage <package> VI_PASSTHROUGHAUTHPACKAGE= <package> Usethisoptionwith--passthroughauthtospecifyadomainlevel authenticationprotocoltobeusedbyWindows.Bydefault,SSPIusesthe Negotiateprotocol,whichmeansthatclientandservertrytonegotiatea protocolthatbothsupport. IfthevCenterServersystemtowhichyouareconnectingisconfiguredtouse aspecificprotocol,youcanspecifythatprotocolusingthisoption. ThisoptionissupportedonlyifyouarerunningvCLIonaWindowssystem andconnectingtoavCenterServersystem. --password <passwd> VI_PASSWORD=<passwd> Usesthespecifiedpassword(usedwith--username)tologintotheserver.
Usetheemptystring(' 'onLinuxand onWindows)toindicateno password. Ifyoudonotspecifyausernameandpasswordonthecommandline,the systempromptsyouanddoesnotechoyourinputtothescreen. --portnumber <number> VI_PORTNUMBER=<number> --protocol <HTTP|HTTPS> VI_PROTOCOL=<HTTP|HTTPS> --savesessionfile <file> VI_SAVESESSIONFILE=<file> Usesthespecifiedporttoconnecttothesystemspecifiedby--server.Default is443. Usesthespecifiedprotocoltoconnecttothesystemspecifiedby--server. DefaultisHTTPS. Savesasessiontothespecifiedfile.Thesessionexpiresifithasbeenunused for30minutes.
28
VMware, Inc.
--servicepath <path> VI_SERVICEPATH=<path> --sessionfile <file> VI_SESSIONFILE=<file> --url <url> VI_URL=<url> --username <u_name> VI_USERNAME=<u_name>
Ifyoudonotspecifyausernameandpasswordonthecommandline,the systempromptsyouanddoesnotechoyourinputtothescreen. --vihost <host> -h <host WhenyourunavCLIcommandwiththe--serveroptionpointingtoa vCenterServersystem,use--vihosttospecifytheESXihosttorunthe commandagainst. NOTE:Thisoptionisnotsupportedforeachcommand.Ifsupported,the optionisincludedwhenyourun<cmd> --help.
VMware, Inc.
29
ThescriptitselfaddstheNASdatastorebycallingthedifferentconfigurationfiles.
#!bin/sh for i in {"esxi_server_a","esx_server_b","esxi_server_c"} do echo "Adding NAS datastore for $i..." esxcli --config /host.conf storage nfs add -H <hostname> -s <sharepoint> -v <volumename> esxcli --config <config.file> storage nfs list done
30
VMware, Inc.
esxcliesxcliNamespaceonpage 31 esxclifcoeNamespaceonpage 31 esxclihardwareNamespaceonpage 32 esxcliiscsiNamespaceonpage 32 esxclinetworkNamespaceonpage 33 esxclischedNamespaceonpage 34 esxclisoftwareNamespaceonpage 34 esxclistorageNamespaceonpage 35 esxclisystemNamespaceonpage 36 esxclivmNamespaceonpage 36
VMware, Inc.
31
32
VMware, Inc.
ipv6[get|set] address [add|list|remove] tag [add|get|remove] ipsec[set] sa [add|list|remove] sp [add|list|remove] route neighbor[list] nic[down|get|list|set|up] stats[get] vlan port stats[get] filter sroivmic[list] vm sriovnicvf[list] [list] port[list] vswitch dvs vmware[list] lacp[getconfig| getstats|get status|set] vxlan[list] configstats[get |set] networklist stats[get] stats[get|set] ipv4 [add|list|remove] ipv6 [add|list|remove]
VMware, Inc.
33
networkmapping [list|reset] networkportlist networkportstats [list|reset] networkstats[list |reset] stats[reset] vmknic[list|reset] vmknic multicastgroup list vmknicstats[list| reset] standard[add| list|remove|set] policy[get] failover[get|set] security[get|set] shaping[get|set] portgroup [add|list|remove |set] policy[set] failover[get|set]
34
VMware, Inc.
VMware, Inc.
35
coredump
processlist
secpolicy settings
shutdown [poweroff|reboot] snmp[get|hash|set|test] stats syslog[mark|reload] visorfs[get] uptimeget config[get|set] ramdisk[add|list| remove] tardisk[list] time[get|set] uuidget versionget visorfsget ramdisk [add|list|remove] tardisklist welcomemsg[get|set] logger[list|set]
esxcli vm Namespace
Theesxcli vmnamespaceincludesaprocessnamespacewithalistcommandandakillcommand.
36
VMware, Inc.
Index
A
Active Directory 21 authentication information 24
P
Perl 13 precedence 24 prerequisites Red Hat Enterprise Linux 5.2 16
C
command-line connection parameters 26 configuration files for authentication 25 usage 25 connection options 24, 27 cp936 encoding 28 creating session files 25 credential store precedence 24
R
Red Hat Enterprise Linux 5.2 16 required parameters 24 running commands from vMA 21 Linux 16, 24 Windows 19
D
DCUI 10 deploying vMA 21 direct console 10
S
scripts with vCLI commands 29 session files 24, 25 Shift_JIS encoding 28 SSPI protocol 27
E
encoding cp936 28 Shift_JIS 28 ESXCLI command hierarchies 31 execution options 27
U
uninstalling Linux 19 on Linux 19 on Windows 20 Using 26 using session files 25
I
installing vCLI Linux 16, 24 Windows 19 installing vMA 21
V
vCLI command-line 26 configuration files 25 environment variables 25 execution options 27 installing on Linux 16, 24 installing on Windows 19 vCLI package installing on Linux 14 installing on Windows 19 uninstalling 19 unpacking 16, 18 vMA 21 environment variables 25 installing 21 multiple configuration files 26 vSphere Management Assistant 21
L
Linux installing vCLI 16, 24 running vCLI commands 19, 26 vCLI 16 lockdown mode 27
M
Microsoft Windows Security Support Provider Interface 27
O
options 27 order of precedence 24
VMware, Inc.
37
W
Windows executing commands 26 installing vCLI 19 running vCLI commands 20 using vCLI 19
38
VMware, Inc.