Vmware Getting Started With VSphere Command Line Interfaces V Center Server 6.0 Sphere Esxi Vcenter 60 Interface Qg En

User Manual: vmware vCenter Server - 6.0 - Getting Started with vSphere Command-Line Interfaces Free User Guide for VMware vCenter Software, Manual

Open the PDF directly: View PDF PDF.
Page Count: 46

Getting Started with vSphere
Command-Line Interfaces
ESXi 6.0
vCenter Server 6.0
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--001469-00
VMware, Inc.
3401 Hillview Ave.
Palo Alto, CA 94304
www.vmware.com
2VMware, Inc.
Getting Started with vSphere Command-Line Interfaces
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 © 2007–2015 VMware, Inc. All rights reserved. Copyright and trademark information
VMware, Inc. 3
Contents
AboutThisBook 5
1ManagingvSpherewithCommandLineInterfaces 7
OverviewofvSphereCommandLineInterfaces 8
UsingESXCLIforHostManagement 10
ESXCLISyntax 10
RunningESXCLIvCLICommands 10
ESXCLICommandSupportwhenHostandvCLIVersionDoNotMatch 11
UsingPowerCLItoManageHostsandVirtualMachines 11
UsingDCLItoManagevCenterServices 11
DCLISyntax 12
vCLIPackageContents 12
2InstallingvCLI 15
InstallationOverview 15
OverviewofLinuxInstallationProcess 16
InstallingthevCLIPackageonRedHatEnterpriseLinux 18
InstallingRequiredPrerequisiteSoftwareforRedHatEnterpriseLinux 18
InstallingthevCLIPackageonRHEL(NoInternetAccess) 18
InstallingvCLIonLinuxSystemswithInternetAccess 19
InstallingRequiredPrerequisiteSoftwareforLinuxSystemswithInternetAccess 19
InstallingthevCLIPackageonaLinuxSystemwithInternetAccess 20
UninstallingthevCLIPackageonLinux 21
InstallingandUninstallingvCLIonWindows 21
UninstallingthevCLIPackageonWindows 22
EnablingCertificateVerification 22
DeployingvMA 22
3RunningHostManagementCommandsintheESXiShell 23
ESXiShellAccesswiththeDirectConsole 23
EnablingLocalESXiShellAccess 23
ESXiShellTimeout 24
UsingtheESXiShell 24
RemoteESXiShellAccesswithSSH 24
EnablingSSHfortheESXiShell 25
UsingtheESXiShellwithSSH 25
LockdownMode 26
RunningESXCLICommandsintheESXiShell 26
4RunningvCLIHostManagementCommands 27
OverviewofRunningvCLIHostManagementCommands 27
TargetingtheHostDirectly 27
TargetaHostThatisManagedbyavCenterServerSystem 28
ProtectingPasswords 28
OrderofPrecedenceforvCLIHostManagementCommands 29
AuthenticatingThroughvCenterServerandvCenterSingleSignOn 29
Examples 29
Getting Started with vSphere Command-Line Interfaces
4VMware, Inc.
AuthenticatingDirectlytotheHost 30
UsingaSessionFile 30
UsingEnvironmentVariables 30
UsingaConfigurationFile 31
UsingCommandLineOptions 31
UsingMicrosoftWindowsSecuritySupportProviderInterface 32
vCLIandLockdownMode 32
TrustRelationshipRequirementforESXCLICommands 33
DownloadingandInstallingthevCenterServerCertificate 33
Usingthe‐‐cacertsfileOption 33
Usingthe‐‐thumbprintOption 33
UsingtheCredentialStore 34
CommonOptionsforvCLIHostManagementCommandExecution 34
UsingvCLICommandsinScripts 36
RunningHostManagementCommandsfromaWindowsSystem 37
RunningHostManagementCommandsfromaLinuxSystem 37
5RunningDCLICommands 39
OverviewofRunningDCLICommands 39
DCLISyntax 40
DCLIOptions 40
RunningDCLICommands 41
DisplayingHelpInformationforDCLICommands 41
RunningDCLICommandsIncludedinthevCLIPackage 42
RunningDCLICommandsonthevCenterServerAppliance 42
UsingDCLIwithaCredentialStoreFile 42
OrderofPrecedenceforDCLIAuthentication 43
Input,Output,andReturnCodes 43
UsingDCLIwithVariables 43
DCLIHistoryFile 44
VMware, Inc. 5
GettingStartedwithvSphereCommandLineInterfacesgivesanoverviewofcommandlineinterfacesin
vSphere 5.0andlaterandgetsyoustartedwithESXiShellcommandsandvCLI(VMware®vSphere
CommandLineInterface)commands.ThisbookalsoincludesinstructionsforinstallingvCLIandareference
toconnectionparameters.
Intended Audience
ThisbookisforexperiencedWindowsorLinuxsystemadministratorswhoarefamiliarwithvSphere
administrationtasksanddatacenteroperations.
VMware Technical Publications Glossary
VMwareTechnicalPublicationsprovidesaglossaryoftermsthatmightbeunfamiliartoyou.Fordefinitions
oftermsastheyareusedinVMwaretechnicaldocumentation,gotohttp://www.vmware.com/support/pubs.
Document Feedback
VMwarewelcomesyoursuggestionsforimprovingourdocumentation.Ifyouhavecomments,sendyour
feedbacktodocfeedback@vmware.com.
Related Documentation
ThedocumentationforvCLIisavailableinthevSphereDocumentationCenterandonthevCLI
documentationpage.Gotohttp://www.vmware.com/support/developer/vcli.
CommandLineManagementinvSphere5andvSphere6forServiceConsoleUsersisatechnicalnoteforusers
whoarecurrentlyusingESXserviceconsolecommands,scripts,agents,orlogs.Youlearnhowto
transitiontoanoffhostimplementationortousetheESXiShellinspecialcases.
vSphereCommandLineInterfaceConceptsandExamplespresentsusageexamplesformanyhost
managementcommands,andexplainshowtosetupsoftwareandhardwareiSCSI,addvirtualswitches,
placehostsinmaintenancemode,andsoon.ThedocumentincludesthesameexamplewiththeESXCLI
commandandwiththevicfg-command.
vSphereCommandLineInterfaceReferenceisareferencetobothESXCLIcommandsandvicfg-commands.
Thevicfg-commandhelpisgeneratedfromthePODavailableforeachcommand,runpod2htmlfor
anyvicfg-commandtogenerateindividualHTMLfilesinteractively.TheESXCLIreferenceinformation
isgeneratedfromtheESXCLIhelp.
DCLIReferenceisareferencetoDCLIcommandsformanagingvCenterservices.
ThedocumentationforPowerCLIisavailableinthevSphereDocumentationCenterandonthePowerCLI
documentationpage.
About This Book
Getting Started with vSphere Command-Line Interfaces
6VMware, Inc.
ThevSphereSDKforPerldocumentationexplainshowyoucanusethevSphereSDKforPerlandrelated
utilityapplicationstomanageyourvSphereenvironment.
ThevSphereManagementAssistantGuideexplainshowtoinstallandusethevSphereManagementAssistant
(vMA).vMAisavirtualmachinethatincludesvCLIandotherprepackagedsoftware.See“DeployingvMA”
onpage 22.
BackgroundinformationforthetasksdiscussedinthisbookisavailableinthevSpheredocumentationset.The
vSpheredocumentationconsistsofthecombinedVMwarevCenterServerandESXidocumentation.
Technical Support and Education Resources
Thefollowingsectionsdescribethetechnicalsupportresourcesavailabletoyou.Toaccessthecurrentversion
ofthisbookandotherbooks,gotohttp://www.vmware.com/support/pubs.
Online and Telephone Support
Touseonlinesupporttosubmittechnicalsupportrequests,viewyourproductandcontractinformation,and
registeryourproducts,gotohttp://www.vmware.com/support.
Customerswithappropriatesupportcontractsshouldusetelephonesupportforthefastestresponseon
priority1issues.Gotohttp://www.vmware.com/support/phone_support.
Support Offerings
TofindouthowVMwaresupportofferingscanhelpmeetyourbusinessneeds,goto
http://www.vmware.com/support/services.
VMware Professional Services
VMwareEducationServicescoursesofferextensivehandsonlabs,casestudyexamples,andcoursematerials
designedtobeusedasonthejobreferencetools.Coursesareavailableonsite,intheclassroom,andlive
online.Foronsitepilotprograms andimplementationbestpractices,VMwareConsultingServicesprovides
offeringsto helpyouassess,plan,build,andmanageyourvirtualenvironment.Toaccessinformationabout
educationclasses,certificationprograms,andconsultingservices,gotohttp://www.vmware.com/services.
VMware, Inc. 7
1
vSpheresupportsseveralcommandlineinterfacesformanagingyourvirtualinfrastructureincludingasetof
ESXiShellcommands,PowerCLIcommands,andDCLIcommandsformanagementofvCenterservices.You
canruncommandslocally,fromanadministrationserver,orfromscripts.
YoucanchoosetheCLIbestsuitedforyourneeds,andwritescriptstoautomateyourmanagementtasks.
Thischapterincludesthefollowingtopics:
“OverviewofvSphereCommandLineInterfaces”onpage 8
“UsingESXCLIforHostManagement”onpage 10
“UsingPowerCLItoManageHostsandVirtualMachines”onpage 11
“UsingDCLItoManagevCenterServices”onpage 11
“vCLIPackageContents”onpage 12
Managing vSphere with
Command-Line Interfaces
1
Getting Started with vSphere Command-Line Interfaces
8VMware, Inc.
Overview of vSphere Command-Line Interfaces
vSphereincludescommandsformanagingdifferentaspectsofyourenvironment.ThefollowingCLIsare
availableformanaginghosts,eitherdirectlyorthroughthevCenterServersystemthatmanagesthehost.
Figure 1-1. vSphere CLIs for host management.
ThefollowingcommandsetsareavailableandarediscussedeitherinthismanualorotherVMware
documentation.
Command set Description See
ESXCLIcommands ManagemanyaspectsofanESXihost.YoucanrunESXCLI
commandsremotelyorintheESXiShell.
vCLIpackage.InstallthevCLIpackageontheserverofyour
choice,ordeployavMAvirtualmachineandtargettheESXi
systemthatyouwantmanipulate.YoucanrunESXCLI
commandsagainstavCenterServersystemandtargetthe
hostindirectly.RunningagainstvCenterServersystemsby
usingthe-vihostparameterisrequiredifthehostisin
lockdownmode.
ESXiShell.RunESXCLIcommandsinthelocalESXishell
tomanagethathost.
YoucanalsorunESXCLIcommandsfromthevSpherePowerCLI
promptbyusingtheGet-EsxClicmdlet.
“UsingESXCLIforHost
Management”onpage 10
“InstallingvCLI”on
page 15
vSphereCommandLine
ConceptsandExamples
vSphereManagement
AssistantGuide
vSphereCommandLine
InterfaceReference
vicfg-andother
vCLIcommands
Allowuserstomanagehostsremotely.InstallthevCLIpackage
onaWindowsorLinuxsystemordeployavMAvirtualmachine,
andtargettheESXisystemthatyouwantmanipulate.
YoucanrunthecommandsagainstESXisystemsoragainsta
vCenterServersystem.IfyoutargetavCenterServersystem,use
the--vihostoptiontospecifythetargetESXisystem.
Note:IftheESXisystemisinstrictlockdownmode,youmustrun
commandsagainstthevCenterServersystemthatmanagesyour
ESXisystem.
“InstallingvCLI”onpage 15
vSphereCommandLine
ConceptsandExamples
vSphereCommandLine
InterfaceReference
ESXi ESXi
vCenter Server
API
API API
ESXCLI
esxcfg-*
ESXCLI
esxcfg-*
Linux vSphere
Management
Assistant
Windows
vCLI
vicfg-*
ESXCLI
Others (esxtop, vimcmd, vsish, rvc...)
PowerCLI
VMware, Inc. 9
Chapter 1 Managing vSphere with Command-Line Interfaces
esxcfg-commands AvailableintheESXiShell.esxcfg-commandsarestillincluded
inthisreleasebutaredeprecated.MigratetoESXCLIwhere
possible.
CommandLineManagement
ofvSphere5andvSphere6
forServiceConsoleUsers
DCLIcommands ManageVMwareSDDCservices.
DCLIisaCLIclienttothevCloudSuiteSDKinterfacefor
managingVMwareSDDCservices.ADCLIcommandtalkstoa
vCloudSuiteAPIendpointtolocaterelevantinformation,and
thenexecutesthecommandanddisplaysresulttotheuser.
YoucanrunDCLIcommandsasfollows.
vCenterServerappliance.RunDCLIcommandsfromthe
vCenterServerApplianceshell.See“RunningDCLI
CommandsonthevCenterServerAppliance”onpage 42.
vCenterServerWindowscommandprompt.InstallvCenter
ServeronasupportedWindowssystemandrunDCLI
commandsfromthecommandprompt.
vCLIpackage.
OpenacommandpromptonaLinuxorWindows
systemonwhichyouinstalledvCLI.Entercommands
intothatcommandprompt,specifyingconnection
options.See“RunningDCLICommands”onpage 41.
AccessthevMALinuxconsole.DCLIdoesnotsupport
thevifastpassconnections.
PreparescriptsthatincludeDCLIcommandsandrunthe
scriptsasvCLIscriptsfromthevCenterServerWindows
commandpromptorfromthevCenterServerAppliance
shell.
“RunningDCLI
Commands”onpage 39
SeethevCloudSuiteSDK
documentationfor
informationabout
currentlysupported
servicesandhowthey
interact.
VMwarePowerCLI
cmdlets
VMwarevSpherePowerCLIprovidesaWindowsPowerShell
interfacetothevSphereAPI.vSpherePowerCLIincludes
PowerShellcmdletsforadministeringvSpherecomponents.
vSpherePowerCLIincludesmorethan370cmdlets,asetof
samplescripts,andafunctionlibraryformanagementand
automation.ThevSphereImageBuilderPowerCLIandthe
vSphereAutoDeployPowerCLIareincludedwhenyouinstall
vSpherePowerCLI.
VMwarePowerCLI
documentationset.
localclicommands SetofcommandsforusewithVMwareTechnicalSupport.
localclicommandsareequivalenttoESXCLIcommands,but
bypassthehostedaemon(hostd).Thelocalclicommandsare
onlyforsituationswhenhostdisunavailableandcannotbe
restarted.Afteryourunalocalclicommand,youmustrestart
hostd.RunESXCLIcommandsaftertherestart.
Warning:Ifyouusealocalclicommand,aninconsistent
systemstateandpotentialfailurecanresult.
pktcap-uwutility Enablesyoutomonitorthetrafficthatflowsthroughphysical
networkadapters,VMkerneladapters,andvirtualmachine
adapters,andtoanalyzethepacketinformationbyusing
conventionalnetworkanalysistoolssuchasWireshark.
vSphereNetworking
documentation
dir-cli
vecs-cli
certool
CommandsformanagingthevCenterSingleSignOnand
certificateinfrastructure.
vSphereSecurity
documentation
appliancesh EnablesyoutoconfigureandtroubleshootthevCenterServer
Applianceandtomonitortheprocessesandservicesrunningin
theappliance.
vCenterServerAppliance
Configuration
documentation
Command set Description See
Getting Started with vSphere Command-Line Interfaces
10 VMware, Inc.
Using ESXCLI for Host Management
YoucanmanagemanyaspectsofanESXihostwithcommandsintheESXCLIcommandset.Youcanrun
ESXCLIcommandsasvCLIcommands,orrunthemintheESXiShellintroubleshootingsituations.
YoucanalsorunESXCLIcommandsfromthePowerCLIshellbyusingtheGet-EsxClicmdlet.SeethevSphere
PowerCLIAdministrationGuideandthevSpherePowerCLIReference.
ThesetofESXCLIcommandsthatareavailableonahostdependsonthehostconfiguration.ThevSphere
CommandLineInterfaceReferencelistshelpinformationforallESXCLIcommands.Youcanrunesxcli
--server <MyESXi> --helpbeforeyourunacommandonahosttomakesurethatthecommandisdefined
onthehostyouaretargeting.
ESXCLI Syntax
EachESXCLIcommandusesthesamesyntax.
esxcli [dispatcher options] <namespace> [<namespace> ...] <cmd> [cmd options]
dispatcheroptions.Predefinedoptionsforconnectioninformationsuchastargethost,username,andso
on.SeeChapter 4,“RunningvCLIHostManagementCommands,”onpage 27.Notrequiredwhenyou
runthecommandintheESXiShell.IfthetargetserverisavCenterServersystem,specifythetargetESXi
hostbeforeanyESXCLInamespaces,commands,andsupportedoptions.
ManyESXCLIcommandsgenerateoutputyoumightwanttouseinyourapplication.Youcanrunesxcli
withthe--formatterdispatcheroptionandsendtheresultingoutputasinputtoaparser.
namespace.GroupsESXCLIcommands.vSphere5.0andlatersupportnestednamespaces.
command.Reportsonormodifiesstateonthesystem.
Examples
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
options.Manycommandssupportoneormoreoptions,displayedinthehelporthevCLIReference.For
somecommands,multipleoptionvalues,separatedbyspaces,arepossible.
Example
esxcli system module parameters set -m <module> -p "a=1 b=1 c=1"
Running ESXCLI vCLI Commands
YoucanrunanESXCLIvCLIcommandintheESXiShellfortroubleshootingandremotelyagainstaspecific
hostoragainstavCenterServersystem.Youhavethefollowingchoices:
DeploythevMAapplianceonanESXisystemandauthenticateagainstasetoftargetservers.Youcan
thenrunESXCLIcommandsagainstanytargetserverbyspecifyingthe--hostdispatcheroption.No
additionalauthenticationisrequired.SeethevSphereManagementAssistantGuide.
IMPORTANTStartingwithvSphere6.0,ESXCLIexpectsatrustrelationshipbetweenthetargethostand
thesystemonwhichyourunthecommand.Youcanestablishthisrelationshipinoneoftheseways:
Usethe--cacertsfileoptionorVI_CACERTFILE variable
Storethethumbprintinthesessionfile.
Specifythethumbprintwiththe--thumbprintoptionorVI_THUMBPRINTvariable.
Youcanpassinthethumbprintthatisreturnedintheerrorifyoutrustthehostyouaretargeting.See
“TrustRelationshipRequirementforESXCLICommands”onpage 33foranexample.
VMware, Inc. 11
Chapter 1 Managing vSphere with Command-Line Interfaces
InstallthevCLIpackageononeofthesupportedWindowsorLinuxsystems.TheESXCLIcommandset
isincluded.SpecifyconnectionoptionstoruncommandsagainstanESXihostdirectly,ortargetavCenter
ServersystemandspecifytheESXihosttorunthecommandagainst.See“InstallingvCLI”onpage 15.
SeeChapter 4,“RunningvCLIHostManagementCommands,”onpage 27.
ESXCLI Command Support when Host and vCLI Version Do Not Match
WhenyourunanESXCLIvCLIcommand,youmustknowthecommandssupportedonthetargethost
specifiedwith--serverorasavMAtarget.Forexample:
IfyouruncommandsagainstESXi4.xhosts,ESXCLI4.xcommandsaresupported.
IfyouruncommandsagainstESXi5.0hosts,ESXCLI5.0commandsaresupported.ESXCLI5.1
commandsthatwereincludedinESXCLI5.0arealsosupported.
IfyouruncommandsagainstESXi5.1hosts,ESXCLI5.1andESXCLI5.0commandsaresupported.
VMwarepartnersmightdevelopcustomESXCLIcommandsthatyoucanrunonhostswherethepartnerVIB
isinstalled.
Runesxcli --server <target> --helpforalistofnamespacessupportedonthetarget.Youcandrill
downintothenamespacesforadditionalhelp.
Using PowerCLI to Manage Hosts and Virtual Machines
VMwarevSpherePowerCLIcontainssnapinsandmodulesbasedonMicrosoftPowerShellforautomating
vSphereandvCloudDirectoradministration.PowerCLIprovidesC#andPowerShellinterfacestovSphere
andotherVMwareproductadministration.
vSpherePowerCLIisbasedonMicrosoftPowerShellandusesthePowerShellbasicsyntaxandconcepts.
MicrosoftPowerShellisbothacommandlineandscriptingenvironment,designedforWindows.Itusesthe
.NETobjectmodelandprovidesadministratorswithsystemadministrationandautomationcapabilities.To
workwithPowerShell,youruncommands,whicharecalledcmdlets.
PowerShellsupportsfeaturessuchaspipelines,wildcards,andeasyaccesstocommandlinehelp.
YoucanuseESXCLIcommandsfromthevSpherePowerCLIconsole,asfollows:
Throughthecmdlet,whichprovidesdirectaccesstotheESXCLInamespaces,applications,and
commands.
Through.NETmethods,whichyouusetocreatemanagedobjectsthatcorrespondtospecificESXCLI
applications.ToaccesstheESXCLI,youcancallmethodsonthesemanagedobjects.
SeethevSpherePowerCLIUser’sGuideinthevSpheredocumentationcenter.
Using DCLI to Manage vCenter Services
TheDCLIcommandsetallowsyoutomanagevCenterservicesthatarenewinvSphere6.0.Youcannot
manageservicesthatwerepartofvSphere5.5fromDCLI.DCLIisnotahostmanagementCLI.
DCLI(DatacenterCLI)isaCLIclientofthevCloudSuiteSDK.DCLIworkslikethis:
1TheuserrunsacommandintheDCLIdirectoryandspecifiesausername.
NOTEStartingwithvSphere6.0,atrustrelationshipmustexistbetweenthehostfromwhichyourun
ESXCLIcommandsandthetargetESXihostorvCenterServersystem.SeeAppendix 4,“Trust
RelationshipRequirementforESXCLICommands,”onpage 33.
NOTETorunanESXCLIcommandfromPowerCLI,youmustprovidevaluesforallparameters.Ifyou
wanttoomitagivenparameter,pass$nullasitsargument.
Getting Started with vSphere Command-Line Interfaces
12 VMware, Inc.
2Iftheuserisnotyetauthenticated,DCLIpromptsforapassword.
3Theuserspecifiesapassword.
4ThecommandconnectstothevCenterSingleSignOnserviceandcheckswhethertheuserspecifiedon
thecommandlineorinacertificatestorefilecanauthenticate.
5Iftheusercanauthenticate,DCLIcommunicateswiththevCenterServerandexecutethevCloudSuite
SDKcommandthatcorrespondstotheDCLIcommand.DifferentvCenterServersystemssupport
differentservices.
6DCLIdisplaystheresultoranerrortotheuser.
YoucanrunDCLIcommandsasfollows.
vCLIpackage.InstallthevCLIpackageontheserverofyourchoice,ordeployavMAvirtualmachine.
YoucanthenrunDCLIcommandsagainstanendpoint.See“RunningDCLICommands”onpage 41.
vCenterServerappliance.RunDCLIcommandsfromthevCenterServerApplianceshell.See“Running
DCLICommandsonthevCenterServerAppliance”onpage 42.
vCenterServerWindowscommandprompt.InstallvCenterServeronasupportedWindowssystemand
runDCLIcommandsfromthecommandprompt.
DCLI Syntax
EachDCLIcommandusesthesamesyntax.
Thecommandnamecanbefollowedbyconnectionandformattingoptions,eachprecededbya+sign.You
alsospecifythenamespace,thecommand,andthecommandoptions.Namespacesarenested.
dcli +[DCLI options] <namespace> [<namespace> ...] <cmd> --[cmd option] [option value]
DCLIoptions.PredefinedoptionsforconnectioninformationincludingthevCloudSuiteSDKendpoint
andformattingoptions.Alwaysprecededbya+sign.
NotrequiredwhenyourunthecommandinthevCenterServerApplianceshellorfromthecommand
promptofavCenterServerWindowsinstallation.
namespace.GroupsDCLIcommands.NamespacescorrespondtothevCloudSuiteSDKnamespacesand
arenested.
command.Reportsonormodifiesstateonthesystem.
optionandvalue.Commandoptionandvaluepairs.
Example
$dcli +server <vcenter-IP> com vmware cis tagging tag list
vCLI Package Contents
vCLIisnotacommandsetbutapackageofseveralcommandsets.YouusuallyinstallvCLIonan
administrationserverandrunscriptsfromthereagainstotherhostsor,forDCLI,againstvCenterServer
systems.SomevCLIcommandscanalsoberunlocallyontheESXihostorthevCenterServersystem.
WhenyouinstallthevCLIpackage,thefollowingcommandsetsbecomeavailable.
DCLICommands.TheDCLIcommandsarenewinvSphere6.0,andareavailableformanagingvCenter
servicesthatarenewinvSphere6.0.ThesecommandsareavailableaspartofvCLI,fromthevCenter
ServerVirtualAppliance,andfromthecommandpromptofavCenterServerWindowsinstallation.
HostManagementCommands.Includesthefollowingcommandsets.
NOTETheorderinwhichDCLIoptionsareprovidedonthecommandlineisnotimportant.However,you
mustspecifyDCLIoptionswithaplus(+)andcommandspecificoptionswithaminus().
VMware, Inc. 13
Chapter 1 Managing vSphere with Command-Line Interfaces
ESXCLIcommands.TheESXCLIcommandsincludedinthevCLIpackageareequivalenttothe
ESXCLIcommandsavailableintheESXiShell.
vicfg‐commands.Thevicfg-commandsetissimilartothedeprecatedesxcfg-commandsetin
theESXiShell.
Miscellaneouscommands.AsmallsetofcommandsformanagingandmonitoringESXihosts,
includingvmkfstoolsandresxtop.Inmanycases,equivalentbutslightlydifferentcommandsare
availableintheESXiShell.
YoucanrunvCLIcommandsfromaWindowsorLinuxsystem,orusevMA.
InstallthevCLIcommandsetontheWindowsorLinuxsystemfromwhichyouwanttoadministeryour
ESXisystemsandrunvCLIcommands.See“InstallingvCLI”onpage 15.
DeployavMAvirtualmachinetoanESXisystemandrunvCLIcommandsfromthere.
AfteryouhaveinstalledthevCLIpackage,youcanrunthehostmanagementcommandsinthesetagainst
ESXihosts.YoucanruntheDCLIcommandsagainstaserverbyspecifyingtheIPaddressandcanmanagethe
servicesassociatedwiththatserver.
YoumustspecifyconnectionparameterswhenyourunavCLIcommand.Theconnectionparametersdiffer
forDCLIcommandsandforothercommands.See“RunningvCLIHostManagementCommands”onpage 27
and“RunningDCLICommands”onpage 41.
IMPORTANTESXiShellisintendedforexperiencedusersonly.Minorerrorsintheshellcanresultin
seriousproblems.InsteadofrunningcommandsdirectlyintheESXiShell,usevCLIorPowerCLI.
Getting Started with vSphere Command-Line Interfaces
14 VMware, Inc.
VMware, Inc. 15
2
YoucaninstallavCLIpackageonaLinuxoraMicrosoftWindowssystem,ordeploythevSphere
ManagementAssistant(vMA)onanESXihost.
Thischapterincludesthefollowingtopics:
“InstallationOverview”onpage 15
“OverviewofLinuxInstallationProcess”onpage 16
“InstallingthevCLIPackageonRedHatEnterpriseLinux”onpage 18
“InstallingvCLIonLinuxSystemswithInternetAccess”onpage 19
“UninstallingthevCLIPackageonLinux”onpage 21
“InstallingandUninstallingvCLIonWindows”onpage 21
“UninstallingthevCLIPackageonWindowsonpage 22
“EnablingCertificateVerificationonpage 22
“DeployingvMA”onpage 22
Installation Overview
YoucaninstallavCLIpackageonasupportedplatformordeploythevMAvirtualmachineonanESXihost.
InstallablePackage.InstallavCLIpackageonaphysicalorvirtualmachine.See“InstallingthevCLI
PackageonRedHatEnterpriseLinux”onpage 18,“InstallingvCLIonLinuxSystemswithInternet
Access”onpage 19,and“InstallingandUninstallingvCLIonWindowsonpage 21.
ThevCLIinstallerinstallsbothvSphereSDKforPerlandvCLIbecausemanyvCLIcommandsrunontop
ofthevSphereSDKforPerl.Thecontentsoftheinstallerpackagediffersfordifferentplatforms.
Installing vCLI 2
Platform Installation Process
Windows TheinstallationpackageincludesvCLI,vSphereSDKforPerl,andprerequisitePerl
modules.
RedHatEnterprise
Linux
Youmustinstallrequiredsoftware.See“InstallingRequiredPrerequisiteSoftwareforRed
HatEnterpriseLinux”onpage 18.
TheinstallerforRHELpromptsyouwhetheryouwanttoinstallothermissingmodules
fromtheInternetorfromthepackage.
IfyouhaveInternetaccess,youcanhavetheinstallerdownloadPerlmodulesfrom
CPAN.
TheinstallercaninsteadinstallPerlmodulesthatitdoesnotfindonyoursystemfrom
theinstallerpackage.
SLESandUbuntu YoumustinstallrequiredsoftwareandyoumusthaveInternetaccess.See“Installing
RequiredPrerequisiteSoftwareforLinuxSystemswithInternetAccess”onpage 19.
TheinstallerdownloadsotherPerlmodulesfromCPAN.
Getting Started with vSphere Command-Line Interfaces
16 VMware, Inc.
Afterinstallation,youcanrunvCLIcommandsandvSphereSDKforPerlutilityapplicationsfromthe
operatingsystemcommandline.Eachtimeyourunacommand,youspecifythetargetserverconnection
optionsdirectlyorindirectly.YoucanalsowritescriptsandmanageyourvSphereenvironmentusing
thosescripts.
vSphereManagementAssistant(vMA).DeployvMA,avirtualmachinethatadministratorscanuseto
runscriptsthatmanagevSphere,onanESXihost.vMAincludesvCLI,vSphereSDKforPerl,andother
prepackagedsoftwareinaLinuxenvironment.
vMAsupportsnoninteractivelogin.IfyouestablishanESXihostasatargetserver,youcanrunvCLIhost
managementcommandsandvSphereSDKforPerlcommandsagainstthatserverwithoutadditional
authentication.IfyouestablishavCenterServersystemasatargetserver,youcanrunmostvCLI
commandsagainstallESXisystemsthatservermanageswithoutadditionalauthentication.See
“DeployingvMA”onpage 22.
Overview of Linux Installation Process
TheinstallationscriptforvCLIissupportedontheLinuxdistributionsthatarelistedintheReleaseNotes.
ThevCLIpackageinstallerinstallsthevCLIscriptsandthevSphereSDKforPerl.Theinstallationproceedsas
follows.
1Theinstallercheckswhetherthefollowingrequiredprerequisitepackagesareinstalledonthesystem:
2Iftherequiredsoftwareisfound,theinstallerproceeds.Otherwise,theinstallerstopsandinformsyou
thatyoumustinstallthesoftware.See“InstallingRequiredPrerequisiteSoftwareforRedHatEnterprise
Linux”onpage 18and“InstallingRequiredPrerequisiteSoftwareforLinuxSystemswithInternet
Access”onpage 19forinstructions.
3TheinstallercheckswhetherthefollowingPerlmodulesarefound,andwhetherthecorrectversionis
installed.
CryptSSLeay0.55(0.550.9.7or0.550.9.8)
IOCompressBase2.037
CompressZlib2.037
IOCompressZlib2.037
CompressRawZlib2.037
ArchiveZip1.28
DataDumper2.121
XMLLibXML1.63
libwwwperl5.805
LWPProtocolhttps6.02
XMLLibXMLCommon0.13
XMLNamespaceSupport1.09
Perl Perlversion5.8.8orversion5.10mustbeinstalledonyoursystem.
OpenSSL ThevCLIrequiresSSLbecausemostconnectionsbetweenthesystemonwhichyourunthecommand
andthetargetvSpheresystemareencryptedwithSSL.
TheOpenSSLlibrary(libssl-develpackage)isnotincludedinthedefaultLinuxdistribution.See
“InstallingRequiredPrerequisiteSoftwareforRedHatEnterpriseLinux”onpage 18and“Installing
RequiredPrerequisiteSoftwareforLinuxSystemswithInternetAccess”onpage 19.
LibXML2 UsedforXMLparsing.ThevCLIclientrequires2.6.26orhigherversion.Ifyouhaveanolderversion
installed,pleaseupgradeto2.6.26orhigher.
Thelibxml2packageisnotincludedinthedefaultLinuxdistribution.See“InstallingRequired
PrerequisiteSoftwareforRedHatEnterpriseLinux”onpage 18and“InstallingRequiredPrerequisite
SoftwareforLinuxSystemswithInternetAccess”onpage 19.
uuid Includedinuuid-develforSLES11andine2fsprogs-develforotherLinuxplatforms.Requiredby
theUUIDPerlmodule.
VMware, Inc. 17
Chapter 2 Installing vCLI
XMLSAX0.16
DataDump1.15
URI1.37
UUID0.03
SOAPLite0.710.08
HTMLParser3.60
version0.78
ClassMethodMaker2.10
JSONPP2.27203
DevelStackTrace131
ClassDataInheritable0.08
ConvertASN10.26
CyrptOpenSSLRSA0.28
CryptX5090.51
ExceptionClass1.37
MIMEBase643.14
UUIDRandom0.04
Socket6023
IOSocketINET62.71
NetINET6Glue0.600_1
EarlierversionsoflibwwwperlincludetheLWPProtocolhttpsmodule.Morerecentversionsof
libwwwperldonotincludetheLWPProtocolhttpsmoduleandyouhavetoinstallthatmodule.
4TheinstallerproceedsdependingontheLinuxdistribution.
NOTEIfyouintendtorunvCLIcommandswithSSLcertification,besuretocheckthatLWP::UserAgent
6.00orlaterisinstalled.Theinstallerdoesnotcheckthismodule,andearlierversionsdonotworkwith
SSL.
Linux distribution Installer behavior
RHEL(NoInternet
access)
OnRHEL,theinstallerallowsyoutoinstallPerlmoduleswithCPANifInternetaccessis
available.
IfnoInternetaccessisavailable,andamoduleisnotcurrentlyonyoursystem,theinstaller
installsit.Ifadifferentversionofamoduleisfound,theinstallerdoesnotinstallitand
proceedswithinstallation.Attheendoftheinstallationprocess,theinstallerinformsyou
iftheversiononthesystemdoesnotmatchtherecommendedversion,andrecommends
thatyouinstalltheversionthatvCLIwastestedwith.Youcaninstallthemodulesusingthe
packageinstallerforyourplatform,theinstallationCD,orCPAN.
Note:TheinstallerdoesnotoverwriteexistingversionsofrecommendedPerlmodules.
Youmustexplicitlyupdatethosemodulesyourself.
AllLinux
distributions
(Internetaccess)
TheinstallerproceedsdependingonwhetherthePerlmodulesarefound.
IfarecommendedPerlmoduleisnotfoundatall,theinstallerinstallsitusingCPAN.
YoumustmeettheinstallationprerequisitesortheinstallercannotinstallthePerl
modulesandstops.See“InstallingvCLIonLinuxSystemswithInternetAccess”on
page 19.
Ifalowerversionofarecommendedmoduleisfound,theinstallerdoesnotinstalla
differentversionfromCPANandproceedswithinstallation.Aftercompleting
installation,theinstallerdisplaysamessagethattheversiononthesystemdoesnot
matchtherecommendedversion,andrecommendsthatyouinstalltheversionvCLI
wastestedwith.Youcaninstallthemodulesusingthepackageinstallerforyour
platform,theinstallationCD,orCPAN.
Ifahigherversionofarecommendedmoduleisfound,theinstallerproceedswith
installationanddoesnotdisplayamessageafterinstallation.
Note:TheinstallerdoesnotoverwriteexistingversionsofrecommendedPerlmodules.
Youmustexplicitlyupdatethosemodulesyourself.
Getting Started with vSphere Command-Line Interfaces
18 VMware, Inc.
5AfterallrequiredsoftwareandallprerequisitePerlmodulesareinstalled,youcaninstallvCLI.See
“InstallingthevCLIPackageonRedHatEnterpriseLinux”onpage 18andInstallingthevCLIPackage
onaLinuxSystemwithInternetAccess”onpage 20.
IfapreviousversionofvCLI,RemoteCLI,orvSphereSDKforPerlisinstalledonyoursystem,andyouinstall
vCLIinadifferentdirectory,youmustresetthePATHenvironmentvariable.Youcandosobeforeorafterthe
installation,usingthecommandappropriateforyourdistributionandshell(setenv,export,andsoon).If
youdonotresetthepath,thesystemmightstilllookforexecutablesintheoldlocation.
Installing the vCLI Package on Red Hat Enterprise Linux
vCLIissupportedonRedHatEnterpriseLinuxversionsthatarelistedintheReleaseNotes.OnRHEL,the
vSphereSDKforPerlinstallerpromptsyouwhetheryouwanttoinstallrequiredPerlmodulesfromthe
installationpackageorfromCPAN.Followthesestepstoinstallthesoftware.
1Installrequiredprerequisitesoftware.See“InstallingRequiredPrerequisiteSoftwareforRedHat
EnterpriseLinux”onpage 18.
2Whenprompted,directtheinstallertoinstalladditionalprerequisitesfromtheinstallationpackage(see
“InstallingthevCLIPackageonRHEL(NoInternetAccess)”onpage 18)orfromCPAN(see“Installing
thevCLIPackageonaLinuxSystemwithInternetAccess”onpage 20).
Installing Required Prerequisite Software for Red Hat Enterprise Linux
PrerequisitesoftwareonRHELincludesrequiredsoftwareandrecommendedPerlmodules.
Required Software
Ifrequiredsoftwareisnotinstalled,thevCLIinstallerstops.Youcaninstallprerequisitesusingyum,theRHEL
packageinstaller(recommended),orfromtheinstallationDVD,asfollows:
Recommended Perl Modules
Whentheinstallerfinishes,itmightissueawarningthattheversionofamoduleinstalledonyoursystemdoes
notmatchtheversionwithwhichvCLIwastested.InstallthatversionusingyumorCPANtoresolvetheissue.
See“OverviewofLinuxInstallationProcess”onpage 16foracompletelistofmodules.
Installing the vCLI Package on RHEL (No Internet Access)
BeforeyouinstallvCLI,youmustremoveallpreviousversionsofthatsoftware.Theprocessdiffersfrom
simplyuninstallingvCLI.
To remove previous versions of vCLI
1Runtheuninstallscript,forexample,ifyouinstalledvCLIinthedefaultlocation,runthefollowing
command:
/usr/bin/vmware-uninstall-vSphere-CLI.pl
2 DeleteexistingversionsofvSphere-CLI.xxxx.tar.gzanddeletethevmware-vsphere-cli-distrib
directory.
RHEL6.332bit yum install e2fsprogs-devel libuuid-devel
yum install perl-XML-LibXML
RHEL6.364bit yum install e2fsprogs-devel libuuid-devel
yum install glibc.i686
yum install perl-XML-LibXML
NOTETheinstallerdoesnotoverwriteexistingPerlmodules.
VMware, Inc. 19
Chapter 2 Installing vCLI
To install vCLI on RHEL
1UntarthevCLIbinarythatyoudownloaded.
tar –zxvf VMware-vSphere-CLI-6.X.X-XXXXX.XXXX.x86_64.tar.gz
Avmware-vsphere-vcli-distribdirectoryiscreated.
2Loginassuperuserandruntheinstaller:
/<location>/sudo vmware-vsphere-cli-distrib/vmware-install.pl
3Toacceptthelicenseterms,typeyesandpressEnter.
4ToinstallPerlmoduleslocally,typeyesandpressEnter.
5Specifyaninstallationdirectory,orpressEntertoacceptthedefault,whichis/usr/bin.
Acompleteinstallationprocesshasthefollowingresult:
Asuccessmessageappears.
Theinstallerlistsdifferentversionnumbersforrequiredmodules(ifany).
Thepromptreturnstotheshellprompt.
Ifyouacceptedthedefaultsduringinstallation,youcanfindtheinstalledsoftwareinthefollowinglocations:
vCLIscripts/usr/bin
vSphereSDKforPerlutilityapplications/usr/lib/vmware-vcli/apps
vSphereSDKforPerlsamplescripts/usr/share/doc/vmware-vcli/samples
SeethevSphereSDKforPerldocumentationforareferencetoallutilityapplications.
AfteryouinstallthevCLI,youcantesttheinstallationbyrunningacommandfromthecommandprompt.See
“RunningHostManagementCommandsfromaLinuxSystem”onpage 37.
Installing vCLI on Linux Systems with Internet Access
BeforeyoucaninstallthevCLIpackageonaLinuxsystemwithInternetaccess,thatsystemmustmeet
followingprerequisites.
Internetaccess.YoumusthaveInternetaccesswhenyouruntheinstallerbecausetheinstallerusesCPAN
toinstallprerequisitePerlmodules.
DevelopmentToolsandLibraries.YoumustinstalltheDevelopmentToolsandLibrariesfortheLinux
platformthatyouareworkingwithbeforeyouinstallvCLIandprerequisitePerlmodules.
Proxysettings.IfyoursystemisusingaproxyforInternetaccess,youmustsetthehttp://andftp://
proxies,asfollows:
export http_proxy=<proxy_server>:port
export ftp_proxy=<proxy_server>:port
Installing Required Prerequisite Software for Linux Systems with Internet
Access
Ifrequiredprerequisitesoftwareisnotinstalled,theinstallerstopsandrequeststhatyouinstallit.Installation
ofprerequisitesoftwaredependsontheplatformthatyouareusing.SeetheReleaseNotesforthesupported
versionsofeachLinuxplatform.
Getting Started with vSphere Command-Line Interfaces
20 VMware, Inc.
Installing the vCLI Package on a Linux System with Internet Access
InstallthevCLIpackageandrunacommandtoverifyinstallationwassuccessful.
To install vCLI
1Loginasroot.
2UntarthevCLIbinarythatyoudownloaded.
tar –zxvf VMware-vSphere-CLI-6.X.X-XXXXX.i386.tar.gz
Avmware-vsphere-vcli-distribdirectoryiscreated.
3 (Optional)IfyourserverusesaproxytoaccesstheInternet,andifyourhttp://andftp://proxywere
notsetwhenyouinstalledprerequisitesoftware,setthemnow.
export http_proxy=<proxy_server>:port
export ftp_proxy=<proxy_server>:port
4Runtheinstaller:
sudo vmware-vsphere-cli-distrib/vmware-install.pl
5Toacceptthelicenseterms,typeyesandpressEnter.
TheinstallerconnectstoCPANandinstallsprerequisitesoftware.Establishingaconnectionmighttakea
longtime.
6OnRHEL,whenpromptedtoinstallprecompiledPerlmodules,typenoandpressEntertouseCPAN
TheinstallerconnectstoCPANandinstallsprerequisitesoftware.Establishingaconnectionmighttakea
longtime.
7Specifyaninstallationdirectory,orpressEntertoacceptthedefault,whichis/usr/bin.
Table 2-1. Installing Required Prerequisite Software
Platform Installation
RHEL6.332bit FindtherequiredmodulesontheinstallationDVD,oruseyumtoinstallthem.
yum install e2fsprogs-devel libuuid-devel
yum install perl-XML-LibXML
RHEL6.364bit FindtherequiredmodulesontheinstallationDVD,oruseyumtoinstallthem.
yum install e2fsprogs-devel libuuid-devel
yum install glibc.i686
yum install perl-XML-LibXML
SUSEEnterprise InstalltheprerequisitepackagesfromtheSLESSDKDVD.WhenyouinserttheDVD,itoffersto
autorun.CanceltheautorundialogboxandusetheyastpackageinstallertoinstallOpenSSLor
othermissingrequiredpackages.
SLES1164bit.yast -i openssl-devel libuuid-devel libuuid-devel-32bit
SLES1132bit.yast -i openssl-devel libuuid-devel
SomeusersmightbeauthorizedtousetheNovellCustomerCenteranduseyasttoretrieve
missingpackagesfromthere.
Ubuntu1.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,theresxtopandESXCLIcommandsdonotworkifyoudonotinstall
the32bitcompatibilitylibraries.
VMware, Inc. 21
Chapter 2 Installing vCLI
Acompleteinstallationprocesshasthefollowingresult:
Asuccessmessageappears.
Theinstallerlistsdifferentversionnumbersforrequiredmodules(ifany).
Thepromptreturnstotheshellprompt.
Ifyouacceptedthedefaultsduringinstallation,youcanfindtheinstalledsoftwareinthefollowinglocations:
vCLIscripts/usr/bin
vSphereSDKforPerlutilityapplications/usr/lib/vmware-vcli/apps
vSphereSDKforPerlsamplescripts/usr/share/doc/vmware-vcli/samples
SeethevSphereSDKforPerldocumentationforareferencetoallutilityapplications.AfteryouinstallvCLI,
youcantesttheinstallationbyrunningavCLIcommandorvSphereSDKforPerlutilityapplicationfromthe
commandprompt.
Uninstalling the vCLI Package on Linux
YoucanuseascriptincludedintheinstallationtouninstallthevCLIpackage.
To uninstall vCLI on Linux
1 ChangetothedirectorywhereyouinstalledvCLI(defaultis/usr/bin).
2Runthevmware-uninstall-vSphere-CLI.pl script.
ThecommanduninstallsvCLIandthevSphereSDKforPerl.
Installing and Uninstalling vCLI on Windows
BeforeyoucanrunvCLIcommandsfromyourWindowssystem,youmustinstallthevCLIpackageandtest
theinstallationbyrunningacommand.
ThevCLIinstallationpackageforWindowsincludestheActivePerlruntimefromActiveStateSoftwareand
requiredPerlmodulesandlibraries.ThevCLIissupportedontheWindowsplatformsthatarelistedinthe
ReleaseNotes.
To install the vCLI Package on Windows
1 DownloadthevCLIWindowsinstallerpackage.
YoucanfindtheinstallerintheAutomationToolsandSDKssectionoftheDrivers&Toolstabofthe
vSpheredownloadpage.
2Starttheinstaller.
3 (Optional)IfpromptedtoremoveolderversionsofvSphereSDKforPerlorvCLI,youcaneitheraccept
orcanceltheinstallation,andinstallthevCLIpackageonadifferentsystem.
4ClickNextintheWelcomepage.
5ToinstallthevCLIinanondefaultdirectory,clickChangeandselectthedirectory.
ThedefaultlocationisC:\Program Files\VMware\VMware vSphere CLI.
6ClickNext.
IMPORTANTIfyouwanttorunESXCLIcommandsincludedinvCLIfromaWindowssystem,youmusthave
theVisualC++2008redistributablefor32bitinstalledonthatsystem.Findvcredist_x86.exeforVisualC++
2008andinstallitonyourWindowssystem.
IMPORTANTTheinstallerreplacesboththevSphereSDKforPerlandvCLI.Tokeepanolderversion,
installthispackageonadifferentsystem.
Getting Started with vSphere Command-Line Interfaces
22 VMware, Inc.
7ClickInstalltoproceedwiththeinstallation.
Theinstallationmighttakeseveralminutestocomplete.
8 Rebootyoursystem.
Withoutreboot,pathsettingsmightnotbecorrectonyourWindowsplatform.
Uninstalling the vCLI Package on Windows
YoucanuninstallthevCLIpackageasyouwouldotherprograms.
To uninstall vCLI on Windows
1FindtheoptionforaddingandremovingprogramsontheWindowsoperatingsystemyouareusing.
2Inthepanelthatappears,selectVMwarevSphereCLI,andclickRemove.
3ClickYeswhenprompted.
ThesystemuninstallsthevSphereSDKforPerl,thevCLI,andallprerequisitesoftware.
Enabling Certificate Verification
ThevSphereSDKforPerlandvCLIuseCrypt::SSLEaytosupportcertificateverification.Crypt::SSLEay
allowsverificationofcertificatessignedbyaCertificateAuthority(CA)ifyousetthefollowingtwovariables:
HTTPS_CA_FILETheCAfile.
HTTPS_CA_DIRTheCAdirectory.
SeetheCrypt::SSLEaydocumentationfordetailsonsetup.
Deploying vMA
Asanalternativetoapackageinstallation,youcandeployvMAonanESXihostandrunvCLIcommandsfrom
there.vMAisavirtualmachineyoucanusetorunscriptstomanageESXisystems.vMAincludesaLinux
environment,vCLI,andotherprepackagedsoftware.
SettingupvMAconsistsofafewtasks.ThevSphereManagementAssistantGuidediscusseseachtaskindetail.
1DeployvMAtoanESXisystemthatmeetsthehardwareprerequisites.
SeethevSphereManagementAssistantGuideforprerequisitesanddeploymentdetails.
2ConfigurevMA.
WhenyoubootvMA,youmustspecifythefollowingrequiredconfigurationinformationwhen
prompted:
Networkinformation(thedefaultisoftenacceptable)
HostnameforvMA.
Passwordfortheviadminuser.TheviadminuserhassuperuserprivilegesonvMA.Youcannotlog
intovMAastherootuser.
3 (Optional)AddavCenterServersystemoroneormoreESXisystemsastargets.YouconfigurevMAfor
ActiveDirectoryauthenticationandcanthenaddESXiandvCenterServersystemstovMAwithout
havingtostorepasswordsinthevMAcredentialstore.SeethevSphereManagementAssistantGuide.
CAUTIONIfthetwoenvironmentvariablesHTTPS_CA_FILEandHTTPS_CA_DIRaresetincorrectlyorifa
problemwiththecertificateexists,vCLIcommandsdonotcomplete,anddonotprinterrororwarning
messages.UseHTTPS_DEBUGfortroubleshootingbeforerunningvCLIcommands.
VMware, Inc. 23
3f
Inmostcases,installingvCLIandrunningcommandsfromaremotesystem,withoneormorehostsastargets,
isrecommended.However,formaintenanceandtroubleshootingtasksyoumightprefertorunESXCLI
commandsintheESXiShellorconnecttotheESXiShellwithSSH.
Youfirstestablishaccess,andcanthenruncommands.
“ESXiShellAccesswiththeDirectConsole”onpage 23
“RemoteESXiShellAccesswithSSH”onpage 24
“LockdownMode”onpage 26
“RunningESXCLICommandsintheESXiShell”onpage 26
ESXi Shell Access with the Direct Console
AnESXisystemincludesaDirectConsoleUserInterface(DCUI)thatallowsyoutostartandstopthesystem
andtoperformalimitedsetofmaintenanceandtroubleshootingtasks.Thedirectconsoleallowsaccesstothe
ESXiShell,whichisdisabledbydefault.YoucanenabletheESXiShellinthedirectconsoleorbyusingthe
vSphereWebClient.Youcanenablelocalshellaccessorremoteshellaccess:
LocalshellaccessallowsyoutologintotheshelldirectlyfromtheDirectConsole.See“EnablingLocal
ESXiShellAccess”onpage 23.
Remoteshell(SSH)accessallowsyoutoconnecttothehostusingashellsuchasPuTTY,specifyauser
nameandpassword,andruncommandsintheshell.See“RemoteESXiShellAccesswithSSH”on
page 24.
TheESXiShellincludesallESXCLIcommands,asetofdeprecatedesxcfg-commands,andasetof
commandsfortroubleshootingandremediation.
Enabling Local ESXi Shell Access
YoucanenabletheESXiShellfromthedirectconsoleorfromthevSphereWebClientorthevSphereClient.
Ifyouhaveaccesstothedirectconsole,youcanenabletheESXiShellfromthere.
To enable the ESXi Shell in the direct console
1AtthedirectconsoleoftheESXihost,pressF2andprovidecredentialswhenprompted.
2ScrolltoTroubleshootingOptionsandpressEnter.
Running Host Management
Commands in the ESXi Shell 3
IMPORTANTAllESXCLIcommandsthatareavailableintheESXiShellarealsoincludedinthevCLIpackage.
VMwarerecommendsyouinstallthevCLIpackageonasupportedWindowsorLinuxsystemordeploythe
vMAvirtualappliance,andruncommandsagainstyourESXihosts.RuncommandsintheESXiShelldirectly
orthroughSSHonlyintroubleshootingsituations.
Getting Started with vSphere Command-Line Interfaces
24 VMware, Inc.
3 ChooseEnableESXiShellandpressEnter.
Ontheleft,EnableESXiShellchangestoDisableESXiShell.Ontheright,ESXiShellisDisabled
changestoESXiShellisEnabled.
4PressEscuntilyoureturntothemaindirectconsolescreen.
IfyoudonothaveaccesstotheDirectConsoleInterface,youcanenabletheESXiShellfromthevSphereWeb
Client.
To enable the ESXi Shell from the vSphere Web Client or the vSphere Client
1 Selectthehost,clickManage,andkeepSettingsselected.
2ClickSecurityProfile.
3IntheServicessection,clickEdit.
4 SelectESXiShell.
Totemporarilystartorstoptheservice,clicktheStartorStopbutton.
TochangetheStartuppolicyacrossreboots,selectStartandstopwithhostandrebootthehost.
5ClickOK.
AfteryouhaveenabledtheESXiShell,youcanuseitfromthatmonitororthroughaserialport.
ESXi Shell Timeout
TheESXiShellsupportsatimeoutforESXiShellavailabilityandatimeoutforidleESXiShellsessions.
Availabilitytimeout:Theavailabilitytimeoutsettingistheamountoftimethatcanelapsebeforeyou
mustloginaftertheESXiShellisenabled.Afterthetimeoutperiod,theserviceisdisabledandusersare
notallowedtologin.
Idletimeout:IfauserenablestheESXiShellonahost,butforgetstologoutofthesession,theidlesession
remainsconnectedindefinitely
YoucansetbothtimeoutvaluesfromtheDirectConsoleUserInterface,fromthevSphereWebClient,orfrom
thevSphereClient.SeethevSphereSecuritydocumentinthevSphereDocumentationCenterfordetailed
instructions.
Using the ESXi Shell
AfteryouenabletheESXiShellinthedirectconsole,youcanuseitfromthemaindirectconsolescreenor
remotelythroughaserialport.
To use the local ESXi Shell
1Atthemaindirectconsolescreen,pressAltF1toopenavirtualconsolewindowtothehost.
2Providecredentialswhenprompted.
Whenyoutypethepassword,charactersarenotdisplayedontheconsole.
3Entershellcommandstoperformmanagementtasks.
4Tologout,typeexitintheshell.
5Toreturntothedirectconsole,typeAltF2.
SeevSphereInstallationandSetupdocumentationforinformationonserialportsetup.
Remote ESXi Shell Access with SSH
IfSSHconnectionsareenabledforyourESXihost,youcanrunshellcommandsbyusingaSecureShellclient
suchasSSHorPuTTY.
VMware, Inc. 25
Chapter 3 Running Host Management Commands in the ESXi Shell
Enabling SSH for the ESXi Shell
Bydefault,remotecommandexecutionisdisabledonanESXihost,andyoucannotlogintothehostusinga
remoteshell.YoucanenableremotecommandexecutionfromthedirectconsoleorfromthevSphereWeb
Client.
To enable SSH access in the direct console
1AtthedirectconsoleoftheESXihost,pressF2andprovidecredentialswhenprompted.
2ScrolltoTroubleshootingOptionsandpressEnter.
3 ChooseEnableSSHandpressEnteronce.
Ontheleft,EnableSSHchangestoDisableSSH.Ontheright,SSHisDisabledchangestoSSHis
Enabled.
4PressEscuntilyoureturntothemaindirectconsolescreen.
To enable SSH from the vSphere Client
1 SelectthehostandclicktheConfigurationtab.
2ClickSecurityProfileintheSoftwarepanel.
3IntheServicessection,clickProperties.
4 SelectSSHandclickOptions.
5 ChangetheSSHoptions.
TochangetheStartuppolicyacrossreboots,clickStartandstopwithhostandrebootthehost.
Totemporarilystartorstoptheservice,clicktheStartorStopbutton.
6ClickOK.
To enable SSH from the vSphere Web Client
1 Selectthehost,clickManage,andkeepSettingsselected.
2ClickSecurityProfile.
3IntheServicessection,clickEdit.
4 SelectSSH.
Totemporarilystartorstoptheservice,clicktheStartorStopbutton.
TochangetheStartuppolicyacrossreboots,selectStartandstopwithhostandrebootthehost.
5ClickOK.
AfteryouhaveenabledSSH,youlogintotheESXiShellremotelyandrunESXiShellcommands.
Using the ESXi Shell with SSH
IfSSHisenabledonyourESXihost,youcanruncommandsonthatshellusinganSSHclient.
To access the remote ESXi Shell
1OpenanSSHclient.
2SpecifytheIPaddressordomainnameoftheESXihost.
PrecisedirectionsvarydependingontheSSHclientthatyouareusing.Seevendordocumentationand
support.
3Providecredentialswhenprompted.
Getting Started with vSphere Command-Line Interfaces
26 VMware, Inc.
Lockdown Mode
ToincreasethesecurityofyourESXihosts,youcanputtheminlockdownmode.Inlockdownmode,all
operationsmustbeperformedthroughvCenterServer.Bydefault,onlythevCenterServersystem,
representedbythevpxuseruser,hasauthenticationpermissions.Nootheruserscanperformoperations
againstahostinLockdownMode.
vSphere5.xandlatersupportsnormallockdownmode,asdiscussedinthevSphere5.xdocumentationcenter.
vSphere6.0andlatersupportsfinergrainedmanagement:
Innormallockdownmode,youcanadduserstotheDCUI.Accessadvancedoptionwhichcanaccessthe
DirectConsoleUserInterfaceregardlessoftheirprivilegesonthehost.StartingwithvSphere6.0,youcan
alsousethevSphereWebClienttoaddExceptionusers,whichcanaccesstheDirectConsoleUser
Interfaceiftheyhavehostmanagementprivileges.
Instrictlockdownmode,userscannotaccesstheDirectConsoleUserInterface.IfvCenterServerbecomes
unavailable,thehostcannolongerbemanaged.
Whenahostisinnormalorstrictlockdownmode,youcannotrunvSphereCLIcommandsagainstthehost
directly.Instead,youtargetthevCenterServersystemthatmanagesthehostwiththe--serveroptionand
specifytheESXihostwiththe--vihostoption.
Whenyouenablestrictlockdownmode,theDirectConsoleUserInterfaceserviceisdisabled.
YoucanenablelockdownmodeusingtheAddHostwizardtoaddahosttovCenterServer,usingthevSphere
WebClienttomanageahost,orusingtheDirectConsoleUserInterface(DCUI).
SeethevSphereSecuritydocumentationfordetailsonLockdownModeinvSphere6.0.
Running ESXCLI Commands in the ESXi Shell
ESXCLIcommandsintheESXiShellarefullysupportedunlesstheyaremarkedasinternalintheonlinehelp.
TheESXiShellisdisabledbydefault.YoumustenabletheESXiShellbeforeyoucanruncommandsinthe
shell.See“ESXiShellAccesswiththeDirectConsole”onpage 23.
To run an ESXCLI command in the shell
1Log
intotheshell.
2Runthecommand.Forexample,tolistNASstoragedevices,runthefollowingcommand.
esxcli storage nfs list
Youcanuse--helpatanylevelofesxcliforhelponavailablenamespaces,commands,oroptions.
VMware, Inc. 27
4f
YoucanrunvSphereCommandLineInterface(vCLI)hostmanagementcommandsfromthecommandline
ofthesystemwhereyouinstalledthepackage,fromthevMAcommandline,andfromscripts.
Hostmanagementcommands,whichincludeESXCLIandvicfg-commands,requireataminimumthe
targetservertorunthecommandon.Usersmustauthenticatetothehost,andcanonlyperformtasksthatthey
areauthorizedtoperform.
Thischapterincludesthefollowingtopics:
“OverviewofRunningvCLIHostManagementCommands”onpage 27
“ProtectingPasswords”onpage 28
AuthenticatingThroughvCenterServerandvCenterSingleSignOn”onpage 29
AuthenticatingDirectlytotheHost”onpage 30
“TrustRelationshipRequirementforESXCLICommands”onpage 33
“CommonOptionsforvCLIHostManagementCommandExecution”onpage 34
“UsingvCLICommandsinScripts”onpage 36
“RunningHostManagementCommandsfromaWindowsSystem”onpage 37
“RunningHostManagementCommandsfromaLinuxSystem”onpage 37
Overview of Running vCLI Host Management Commands
YoucanrunvCLIcommandsinteractivelyorinscripts,andyoucantargetthehostdirectlyortargetavCenter
Serversystemthatmanagesthehost.
Targeting the Host Directly
YoucantargetthehostdirectlyfromanadministrationserveronwhichyouinstalledVCLI,usevMA,orrun
scripts.
OpenacommandpromptonaLinuxorWindowssystemonwhichyouinstalledvCLI.Entercommands
intothatcommandprompt,specifyingconnectionoptions.SeeAuthenticatingDirectlytotheHost”on
page 30.
Running vCLI Host Management
Commands
4
NOTESee“RunningDCLICommands”onpage 39forinformationaboutDCLIcommands,whichyoucan
usetomanagevCenterServerservices.
IMPORTANTIfanESXisystemthatyoutargetisinlockdownmode,youcannotrunvCLIcommandsagainst
thatsystemdirectly.YoumusttargetavCenterServersystemthatmanagestheESXisystemandusethe
--vihostoptiontospecifytheESXitarget.See“vCLIandLockdownMode”onpage 32.
Getting Started with vSphere Command-Line Interfaces
28 VMware, Inc.
AccessthevMALinuxconsole.SetuptargetserversandrunvCLIcommandsagainstthetargetswithout
additionalauthentication.
PreparescriptsthatcontainvCLIcommands.ThenrunthescriptsfromasystemthathasthevCLI
packageinstalledorfromthevMALinuxconsole.See“UsingvCLICommandsinScripts”onpage 36.
WhenyouruncommandsagainstanESXihost,youmustbeauthenticatedforthathost.
Target a Host That is Managed by a vCenter Server System
WhenyoutargetahostthatismanagedbyavCenterServersystem,youcanruncommandsindifferentways.
SpecifythevCenterSingleSignOnservicewith--pscand,ifmultiplevCenterServersystemsare
associatedwiththevCenterSingleSignOnservice,thevCenterServersystemwith--server.Specify
alsothehostwith--vihost.
SpecifythevCenterServersystemwith--serverandtheESXihostwith--vihost.
SpecifyonlytheESXihostwith--vihost.
WhenyoucanauthenticatetoavCenterSingleSignOnserviceortoavCenterServersystem,youcantarget
allESXihoststhatvCenterServermanageswithoutadditionalauthentication.SeeAuthenticatingThrough
vCenterServerandvCenterSingleSignOn”onpage 29.
Protecting Passwords
Followoneofthefollowingapproachesforprotectingpasswords.
IfyouuseavCLIhostmanagementcommandinteractivelyanddonotspecifyausernameandpassword,
youarepromptedforthem.Thescreendoesnotechothepasswordyoutype.
Fornoninteractiveuse,youcancreateasessionfileusingthesave_sessionoption.See“UsingaSession
File”onpage 30.
TargetavCenterServersystemandauthenticatetovCenterSingleSignOn.Youcansavethe
correspondingsessionanduseitforsubsequentconnections.SeeAuthenticatingThroughvCenter
ServerandvCenterSingleSignOn”onpage 29.
Usevariablesorconfigurationfiles.
IfyouarerunningonaWindowssystem,youcanusethe--passthroughauthoption.Iftheuserwho
runsthecommandwiththatoptionisaknownActiveDirectoryuser,nopasswordisrequired.
IfyouarerunningvMA,youcansetuptargetserversandrunmostvCLIcommandsagainsttargetservers
withoutadditionalauthentication.SeethevSphereManagementAssistantGuide.
vCLIallowsyoutorunscriptsagainstmultipletargetserversfromthesameadministrationserver.Youmust
havethecorrectprivilegestoperformtheactionsoneachtarget,andyoumustauthenticatetothetarget.
NOTEDifferentcommandsetsinthevCLIpackagerequiredifferentconnectionoptions.
CAUTIONIfyouspecifypasswordsinplaintext,youriskexposingthepasswordtootherusers.Thepassword
mightalsobecomeexposedinbackupfiles.Donotprovideplaintextpasswordsonproductionsystems.
IMPORTANTAdministratorscanplaceESXihostsinlockdownmodeforenhancedsecurity.Bydefault,not
eventherootusercanrunvCLIcommandsdirectlyagainstESXihostsinlockdownmode.See“vCLIand
LockdownMode”onpage 32andthevSphereSecuritydocumentation.
VMware, Inc. 29
Chapter 4 Running vCLI Host Management Commands
Order of Precedence for vCLI Host Management Commands
WhenyourunavCLIhostmanagementcommand,authenticationhappensintheorderofprecedenceshown
inTable 41.Thisorderofprecedencealwaysapplies.Thatmeans,forexample,thatyoucannotoverridean
environmentvariablesettinginaconfigurationfile.
IfyouareauthenticatingthroughvCenterSingleSignOn,theorderofprecedenceispreserved,forexample,
informationyouspecifyonthecommandlineoverridesinformationinanenvironmentvariable.
Authenticating Through vCenter Server and vCenter Single Sign-On
ForallESXihoststhataremanagedbyavCenterServersystemthatisintegratedwithvCenterSingleSignOn
6.0andlater,youcanauthenticatedirectlytothevCenterServersystem,oryoucanauthorizetovCenter
ServerthroughvCenterSingleSignOn.
BestpracticeistoauthenticatethroughvCenterSingleSignOn.ThevCenterSingleSignOnserviceis
includedinthePlatformServicesController.ThePlatformServicesControllercanbeembeddedinyour
vCenterServerinstallation,oronePlatformServicesControllercanhandleauthentication,certificate
management,andsomeothertasksformultiplevCenterServersystems.
Youusethe--pscoptionand,optionally,the--server option.
psc‐SpecifiesthePlatformServicesControllerinstanceassociatedwiththevCenterServersystemthat
managesthehost.
server‐SpecifiesthevCenterServersystemthatmanagesthehost.RequiredifthePlatformServices
ControllerinstanceisassociatedwithmorethanonevCenterServersystem.
vihost‐SpecifiestheESXihost,asinearlierversionsofvCLI.
Examples
vicfg-nics -l --username <sso_username> --password "<admin_pwd>" --server <vc_HOSTNAME_OR_IP>
--psc <psc_HOSTNAME_OR_IP> --vihost <esxi_HOSTNAME_OR_IP>
esxcli --server <vc_HOSTNAME_OR_IP> --vihost <esxi_HOSTNAME_OR_IP> --username <USERNAME>
--password <PASSWORD> --psc <psc_HOSTNAME_OR_IP> hardware clock get
IfthespecifieduserisknowntovCenterSingleSignOn,asessioniscreated.Youcansavethesessionwiththe
--savesessionfileargument,andlaterusethatsessionwiththe--sessionfile argument.Forexample,
youcansavethesessionbyrunningthiscommand:
NOTEAvailableoptionsandorderofprecedencearedifferentforDCLI.See“OrderofPrecedenceforDCLI
Authentication”onpage 43.
Table 4-1. vCLI Authentication Precedence
Authentication Description See
Commandline Password(--password),sessionfile
(--sessionfile),orconfigurationfile
(--config)specifiedonthecommandline.
“UsingaSessionFile”onpage 30
Environment
variable
Passwordspecifiedinanenvironmentvariable.“UsingEnvironmentVariablesonpage 30
Configurationfile Passwordspecifiedinaconfigurationfile.“UsingaConfigurationFile”onpage 31
Currentaccount
(ActiveDirectory)
Currentaccountinformationusedtoestablish
anSSPIconnection.AvailableonlyonWindows.
“UsingMicrosoftWindowsSecuritySupport
ProviderInterface”onpage 32
Credentialstore Passwordretrievedfromthecredentialstore.vSphereWebServicesSDKProgrammingGuide
andvSphereSDKforPerlProgrammingGuide.
Prompttheuserfor
apassword.
Passwordisnotechoedtoscreen.
NOTEYoucannotusethisapproachifvCenterServerisintegratedwithvCenterSingleSignOn5.0.
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.Ifthesessionfileisnotusedfor30 minutes,it
expires.
Ifyouuseasessionfile,otherconnectionoptionsareignored.
To create and use a session file
1 Connecttothedirectorywherethescriptislocated.
Forexample:
2Runsave_session.
Youcanusethesave_session.plscriptorthe--savesessionfileoptiontothevCLIcommand.You
mustspecifytheservertoconnecttoandthenameofasessionfileinwhichthescriptsavesan
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
VMware, Inc. 31
Chapter 4 Running vCLI Host Management Commands
OnWindows,youcansetenvironmentvariablesintheEnvironmentpropertiesdialogboxoftheSystem
controlpanel.Forthecurrentsession,youcansetenvironmentvariablesatthecommandlinebyusinga
commandlikethefollowing:
set VI_SERVER=<your_server_name_or_address>
See“UsingvCLICommandsinScripts”onpage 36foranenvironmentvariableexample.
Using a Configuration File
Youcanuseatextfilethatcontainsvariablenamesandsettingsasaconfigurationfile.Variablescorresponding
totheoptionsareshowninTable 42,“vCLIConnectionOptions,”onpage 34.
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
IfyouhavemultiplevCenterServerorESXisystemsandyouadministereachsystemindividually,youcan
createmultipleconfigurationfileswithdifferentnames.Torunacommandorasetofcommandsonaserver,
youpassinthe--configoptionwiththeappropriatefilenameatthecommandline.
Thefollowingexampleillustratesthecontentsofaconfigurationfile:
VI_PSC = XX.XXX.XXX.XX
VI_USERNAME = administrator@vsphere.local
VI_PASSWORD = admin_password
VI_PROTOCOL = https
VI_SERVER = my_vc
Ifyouhavesetupyoursystemtorunthisfile,youcanrunscriptsagainstthespecifiedESXihostafterwards.
Using Command-Line Options
Youcanpassincommandlineoptionsusingoptionnameandoptionvaluepairsinmostcases.ForESXCLI
commands,youcanuselongorshortoptions.Anequalsignbetweenoptionnameandoptionvalueis
optional.
esxcli --server <vc_HOSTNAME_OR_IP> --username <privileged_user> --password <pw> --vihost
<esxi_HOSTNAME_OR_IP> <namespace> [<namespace]...> <command>
--<option_name=option_value>
ForothervCLIcommands,uselongorshortoptions.Anequalsignisnotsupported.
<vicfg- command> --server <vc_HOSTNAME_OR_IP> --username <privileged_user> --password <pw>
--vihost <esxi_HOSTNAME_OR_IP> --<option_name option_value>
Someoptions,suchas--help,havenovalue.
Thefollowingexamplesconnecttotheserverasusersnow-whitewithpassworddwarf$.
IMPORTANTDonotuseescapecharactersinenvironmentvariables.
CAUTIONLimitreadaccesstoaconfigurationfilethatcontainsusercredentials.
IMPORTANTEnclosepasswordsandothertextwithspecialcharactersinquotationmarks.
WhenrunningcommandsonWindows,usedoublequotes(“ “).WhenrunningcommandsonLinux,use
singlequotes(‘ ‘)orabackslash(\)asanescapecharacter.
Getting Started with vSphere Command-Line Interfaces
32 VMware, Inc.
Linux
esxcli --server <esxi_HOSTNAME_OR_IP> --username snow\-white --password dwarf\$ network ip
interface list
esxcli --server <esxi_HOSTNAME_OR_IP> --username snow\-white --password ‘dwarf$’ network ip
interface list
vicfg-mpath --server <esxi_HOSTNAME_OR_IP> --username snow\-white --password dwarf\$ --list
vicfg-mpath --server <esxi_HOSTNAME_OR_IP> --username ‘snow-white’ --password ‘dwarf$’ --list
Windows
esxcli --server <esxi_HOSTNAME_OR_IP> --username “snow-white” --password “dwarf$” network ip
interface list
vicfg-mpath.pl --server <esxo_HOSTNAME_OR_IP> --username “snow-white” --password “dwarf$” --list
Using Microsoft Windows Security Support Provider Interface
The--passthroughauthoption,whichisavailableifyourunvCLIcommandsfromaMicrosoftWindows
system,allowsyoutousetheMicrosoftWindowsSecuritySupportProviderInterface(SSPI).SeetheMicrosoft
WebsiteforadetaileddiscussionofSSPI.
Youcanuse--passthroughauthtoestablishaconnectionwithavCenterServersystem.Aftertheconnection
hasbeenestablished,authenticationforthevCenterServersystemoranyESXisystemitmanagesisnolonger
required.Using--passthroughauthpassesthecredentialsoftheuserwhorunsthecommandtothetarget
vCenterServersystem.Noadditionalauthenticationisrequirediftheuserwhorunsthecommandisknown
bythecomputerfromwhichyouaccessthevCenterServersystemandbythecomputerrunningthevCenter
Serversoftware.
IfvCLIcommandsandthevCenterServersoftwarerunonthesamecomputer,theuserneedsonlyalocal
accounttorunthecommand.IfthevCLIcommandandthevCenterServersoftwarerunondifferent
machines,theuserwhorunsthecommandmusthaveanaccountinadomaintrustedbybothmachines.
SSPIsupportsseveralprotocols.Bydefault,itselectstheNegotiateprotocol,whereclientandservertryto
findaprotocolthatbothsupport.Youcanuse--passthroughauthpackagetoexplicitlyspecifyaprotocol
thatissupportedbySSPI.Kerberos,theWindowsstandardfordomainlevelauthentication,isused
frequently.IfthevCenterServersystemisconfiguredtoacceptonlyaspecificprotocol,specifyingtheprotocol
with --passthroughauthpackagemightberequiredforsuccessfulauthentication.Ifyouuse
--passthroughauth,youdonothavetospecifyauthenticationinformationbyusingotheroptions.
Example
esxcli --server <vc_HOSTNAME_OR_IP> --passthroughauth --passthroughauthpackage “Kerberos”
--vihost <esxi_HOSTNAME_OR_IP> network ip interface list
vicfg-mpath.pl --server <vc_HOSTNAME_OR_IP> --passthroughauth --passthroughauthpackage
“Kerberos” --vihost <esxi_HOSTNAME_OR_IP> --list
ConnectstoaserverthatissetuptouseSSPI.Whenatrusteduserrunsthecommand,thesystemcallsthe
ESXCLIcommandorvicfg-mpathwiththe--listoption.Thesystemdoesnotpromptforausernameand
password.
vCLI and Lockdown Mode
LockdownmodecandisablealldirectrootaccesstoESXimachines.TomakechangestoESXisystemsin
lockdownmodeyoumustgothroughavCenterServersystemthatmanagestheESXisystem.Youcanusethe
vSphereWebClientorvCLIcommandsthatsupportthe--vihostoption.Thefollowingcommandscannot
runagainstvCenterServersystemsandarethereforenotavailableinlockdownmode:
vifs
vicfg-user
vicfg-cfgbackup
vihostupdate
vmkfstools
VMware, Inc. 33
Chapter 4 Running vCLI Host Management Commands
vicfg-ipsec
IfyouhaveproblemsrunningacommandonanESXihostdirectly(withoutspecifyingavCenterServer
target),checkwhetherlockdownmodeisenabledonthathost.SeethevSphereSecuritydocumentation.
Trust Relationship Requirement for ESXCLI Commands
StartingwithvSphere6.0,ESXCLIcheckswhetheratrustrelationshipexistsbetweenthemachinewhereyou
runtheESXCLIcommandandtheESXihost.Anerrorresultsifthetrustrelationshipdoesnotexist.
Toestablishthetrustrelationship,youhavetheseoptions.
Downloading and Installing the vCenter Server Certificate
YoucandownloadthevCenterServerrootcertificateusingaWebbrowserandaddittothetrustedcertificates
onthemachinewhereyouplanonrunningESXCLIcommands.
To download the certificate
1TypetheURLofthevCenterServersystemorvCenterServerVirtualApplianceintoaWebBrowser.
2ClicktheDownloadtrustedrootcertificateslink.
3 Changetheextensionofthedownloadedfileto.zip.(ThefileisaZIPfileofallcertificatesinthe
TRUSTED_ROOTSstore).
4ExtracttheZIPfile.
Theresultisacertsfolder.Thefolderincludesfileswiththeextension.0..1,andsoon,whichare
certificates,andfileswiththeextension.r0,r1,andsoonwhichareCRLfilesassociatedwiththe
certificates.
5Addthetrustedrootcertificatestothelistoftrustedroots.Theprocessdiffersdependingontheplatform
youareon.
YoucannowrunESXCLIcommandsagainstanyhostthatismanagedbythetrustedvCenterServerwithout
supplyingadditionalinformationifyouspecifythevCenterServerinthe--serveroptionandtheESXihost
inthe--vihostoption.
Using the --cacertsfile Option
Usingacertificatetoestablishthetrustrelationshipisthemostsecureoption.Youcanspecifythecertificate
withthe--cacertsfileparameterortheVI_CACERTFILEvariable.
Using the --thumbprint Option
Youcansupplythethumbprintforthetargetserver(ESXihostorvCenterServersystem)inthe--thumbprint
parameter(VI_THUMBPRINTvariable).
Whenyourunacommand,ESXCLIchecksfirstwhetheracertificatefileisavailable.Ifnot,ESXCLIchecks
whetherathumbprintofthetargetserverisavailable.Ifnot,anerrorlikethefollowingresults:
Connect to sof-40583-srv failed. Server SHA-1 thumbprint:
5D:01:06:63:55:9D:DF:FE:38:81:6E:2C:FA:71:BC:Usin63:82:C5:16:51 (not trusted).
Youcanrunthecommandwiththethumbprinttoestablishthetrustrelationship,oraddthethumbprintto
theVI_THUMBPRINTvariable.Forexample,usingthethumbprintoftheESXihostabove,youcanrunthe
followingcommand:
esxcli --server myESXi --username user1 --password 'my_password' --thumbprint
5D:01:06:63:55:9D:DF:FE:38:81:6E:2C:FA:71:BC:63:82:C5:16:51 storage nfs list
Getting Started with vSphere Command-Line Interfaces
34 VMware, Inc.
Using the Credential Store
YourvCLIinstallationincludesacredentialstore.Youcanmanagethecredentialstorewiththe
credstore-adminutilityapplication,whichislocatedinthe/Perl/apps/generaldirectoryinsidethe
VMwarevSphereCLIdirectory.
To establish trust for a user with the credential store
1AddtheuserandpasswordforthetargetESXihosttothelocalcredentialstore.
credstore_admin.pl add --server <esxi_HOSTNAME_OR_IP> --username <user> --password <pwd>
2AddthethumbprintforthetargetESXihost.Thisthumbprintwasreturnedintheerrorwhenyou
attemptedtoconnecttothehost.
credstore_admin.pl add --server <esxi_HOSTNAME_OR_IP> --thumbprint <thumbprint>
3Ifyouareusinganondefaultcredentialstorefile,youhavetopassitinwiththe--credstoreoption.
Otherwise,thisuserwillbeabletoaccessthehostwithoutauthenticationgoingforward.
Common Options for vCLI Host Management Command Execution
Table 42listsoptionsthatareavailableforallvCLIhostmanagementcommandsinalphabeticalorder.The
tableincludesoptionsforuseonthecommandlineandvariablesforuseinconfigurationfiles.Optionsfor
executingDCLIcommandsaredifferent.
See“RunningHostManagementCommandsfromaWindowsSystem”onpage 37and“RunningHost
ManagementCommandsfromaLinuxSystem”onpage 37.
IMPORTANTUpdatingthecredentialstoreisatwostepprocess.Firstyouaddtheuserandpasswordforthe
server,andthenyouaddthethumbprintfortheserver.
IMPORTANTStartingwithvSphere5.5,vCLIsupportsbothIPv4andIPv6connections.
Table 4-2. vCLI Connection Options
Option and Environment Variable Description
--cacertsfile <certsfile>
-t <certs_file>
VI_CACERTFILE=<cert_file_path>
ESXCLIcommandsonly.
UsedtospecifytheCA(CertificateAuthority)certificatefile,inPEMformat,
toverifytheidentityofthevCenterServersystemorESXisystemtorunthe
commandon.
InvCLI6.0andlater,youcanonlyrunESXCLIcommandsifatrust
relationshipexistsbetweenthehostyouarerunningthecommandonandthe
systemyouaretargetingwiththe--serveroption(ESXihostorvCenter
Serversystem).YoucanestablishthetrustrelationshipbyspecifyingtheCA
certificatefileorbypassinginthethumbprintforeachtargetserver(ESXihost
orvCenterServersystem).
--config <cfg_file_full_path>
VI_CONFIG=<cfg_file_full_path>
Usestheconfigurationfileatthespecifiedlocation.
Specifyapaththatisreadablefromthecurrentdirectory.
--credstore <credstore>
VI_CREDSTORE=<credstore>
Nameofacredentialstorefile.Defaultsto
<HOME>/.vmware/credstore/vicredentials.xmlonLinuxand
<APPDATA>/VMware/credstore/vicredentials.xmlonWindows.
CommandsforsettingupthecredentialstoreareincludedinthevSphereSDK
forPerl,whichisinstalledwithvCLI.ThevSphereSDKforPerlProgramming
Guideexplainshowtomanagethecredentialstore.
--encoding <encoding>
VI_ENCODING=<encoding>
Specifiestheencodingtobeused.Severalencodingsaresupported.
utf8
cp936(SimplifiedChinese)
shftjis(Japanese)
iso-885901(German).
Youcanuse--encodingtospecifytheencodingvCLIshouldmaptowhenit
isrunonaforeignlanguagesystem.
VMware, Inc. 35
Chapter 4 Running vCLI Host Management Commands
--passthroughauth
VI_PASSTHROUGHAUTH
Ifyouspecifythisoption,thesystemusestheMicrosoftWindowsSecurity
SupportProviderInterface(SSPI)forauthentication.Trustedusersarenot
promptedforausernameandpassword.SeetheMicrosoftWebsitefora
detaileddiscussionofSSPI.
ThisoptionissupportedonlyifyouareconnectingtoavCenterServersystem.
--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.
If--serverspecifiesavCenterServersystem,theusernameandpassword
applytothatserver.IfyoucanlogintothevCenterServersystem,you
neednoadditionalauthenticationtoruncommandsontheESXihoststhat
servermanages.
If--serverspecifiesanESXihost,theusernameandpasswordapplyto
thatserver.
Usetheemptystring(' 'onLinuxand“ “onWindows)toindicateno
password.
Ifyoudonotspecifyausernameandpasswordonthecommandline,the
systempromptsyouanddoesnotechoyourinputtothescreen.
--portnumber <number>
VI_PORTNUMBER=<number>
Usesthespecifiedporttoconnecttothesystemspecifiedby--server.Default
is443.
--protocol <HTTP|HTTPS>
VI_PROTOCOL=<HTTP|HTTPS>
Usesthespecifiedprotocoltoconnecttothesystemspecifiedby--server.
DefaultisHTTPS.
--psc <hostname_or_IP>
VI_PSC=<hostname_or_IP>
HostnameorIPaddressofthePlatformServicesControllerinstancethatis
associatedwiththevCenterServersystemthatmanagesthehost.Inmany
cases,thePlatformServicesControllerisembeddedinthevCenterServer
system,butexternalPlatformServicesControllerinstancesaresupportedas
well.Forthosecases,usethe--serveroptiontospecifythevCenterServer
systemthatmanagesthehost.
ThisoptionimpliesuserauthenticationwithvCenterSingleSignOn.Theuser
youspecifymustbeabletoauthenticatetovCenterSingleSignOn.
--savesessionfile <file>
VI_SAVESESSIONFILE=<file>
Savesasessiontothespecifiedfile.Thesessionexpiresifithasbeenunused
for30minutes.
--server <server>
VI_SERVER=<server>
UsesthespecifiedESXiorvCenterServersystem.Defaultislocalhost.
If--serverpointstoavCenterServersystem,youcanalsospecifythe--psc
optiontologintothevCenterServersystemwithvCenterSingleSignOn.
Usethe--vihostoptiontospecifytheESXihostthatyouwanttorunthe
commandagainst.SeeAuthenticatingThroughvCenterServerandvCenter
SingleSignOn”onpage 29.
--servicepath <path>
VI_SERVICEPATH=<path>
UsesthespecifiedservicepathtoconnecttotheESXihost.Defaultis
/sdk/webService.
--sessionfile <file>
VI_SESSIONFILE=<file>
Usesthespecifiedsessionfiletoloadapreviouslysavedsession.Thesession
mustbeunexpired.
--thumbprint <thumbprint>
VI_THUMBPRINT=<thumbprint>
ExpectedSHA1hostcertificatethumbprintifnoCAcertificatesfileis
providedinthe--cacertsfile argument.Thethumbprintisreturnedbythe
serverintheerrormessageifyouattempttorunacommandwithout
specifyingathumbprintorcertificatefile.
--url <url>
VI_URL=<url>
ConnectstothespecifiedvSphereWebServicesSDKURL.
Table 4-2. vCLI Connection Options (Continued)
Option and Environment Variable Description
Getting Started with vSphere Command-Line Interfaces
36 VMware, Inc.
Table 43listsoptionsnotusedasconnectionoptionsthatyoucanusewhenyourunavicfg-vCLIcommand.
Using vCLI Commands in Scripts
Mostadministratorsrunscriptstoperformthesametaskrepeatedlyortoperformataskonmultiplehosts.
YoucanrunvCLIcommandsfromoneadministrationserveragainstmultipletargetservers.
Forexample,whenanewdatastorebecomesavailableinyourenvironment,youmustmakethatdatastore
availabletoeachESXihost.ThefollowingsamplescriptillustrateshowtomakeaNASdatastoreavailableto
threehosts(esxi_server_a,esx_server_b,andesxi_server_c).
Thesampleassumesthataconfigurationfile/home/admin/.visdkrc.<hostname>existsforeachhost.For
example,theconfigurationfileforesxi_server_ahasthefollowingcontents:
VI_SERVER = esxi_server_a
VI_USERNAME = root
VI_PASSWORD = xysfdjkat
ThescriptaddstheNASdatastoretoeachhostdefinedinVIHOSTS.
#!/bin/bash
VI_CONFIG_FILE=/home/admin/viconfig
VIHOSTS=(esxi_server_a esx_server_b esxi_server_c)
for VIHOST in ${VIHOSTS[@]}
do
echo "Adding NAS datastore for ${VIHOST} ..."
esxcli --config ${VI_CONFIG_FILE} storage nfs add --host ${VIHOST} --share <share point>
--volume-name <volume name>
esxcli --config ${VI_CONFIG_FILE} storage nfs list
done
--username <u_name>
VI_USERNAME=<u_name>
Usesthespecifiedusername.
If--serverspecifiesavCenterServersystem,theusernameand
passwordapplytothatserver.IfyoucanlogintothevCenterServer
system,youneednoadditionalauthenticationtoruncommandsonthe
ESXihoststhatservermanages.
If--serverspecifiesanESXisystem,theusernameandpasswordapply
tothatsystem.
Ifyoudonotspecifyausernameandpasswordonthecommandline,the
systempromptsyouanddoesnotechoyourinputtothescreen.
--vihost <host>
-h <host>
WhenyourunavCLIcommandwiththe--serveroptionpointingtoa
vCenterServersystem,use--vihosttospecifytheESXihosttorunthe
commandagainst.
NOTE:Thisoptionisnotsupportedforeachcommand.Ifsupported,the
optionisincludedwhenyourun<cmd> --help.
Table 4-3. vCLI Common Options
Option Description
--help Printsabriefusagemessage.Themessagelistsfirsteachcommandspecificoptionandthen
eachofthecommonoptions.
--verbose Displaysadditionaldebugginginformation.
--version Displaysversioninformation.
Table 4-2. vCLI Connection Options (Continued)
Option and Environment Variable Description
VMware, Inc. 37
Chapter 4 Running vCLI Host Management Commands
Running Host Management Commands from a Windows System
AfteryouinstallvCLIandrebootyoursystem,youcantesttheinstallationbyrunningavCLIorSDKforPerl
commandfromtheWindowscommandprompt.
To run a vCLI command on Windows
1FromtheWindowsStartmenu,choosePrograms>VMware>VMwarevSphereCLI>Command
Prompt.
AcommandpromptshellforthelocationwherevCLIisinstalledappears.YouhaveeasyaccesstovCLI
andtovSphereSDKforPerlcommandsfromthatlocation.
2Runthecommand,passinginconnectionoptionsandotheroptions.
OnWindows,theextension.plisrequiredforvicfg-commands,butnotforESXCLI.
<command>.pl <conn_options> <params>
Forexample:
esxcli --server <esxi_HOSTNAME_OR_IP> --username “snow-white” --password “dwarf$” network ip
interface list
vicfg-mpath.pl --server <esxi_HOSTNAME_OR_IP> --username “snow-white” --password “dwarf$”
--list
Thesystempromptsyouforausernameandpassword.
Running Host Management Commands from a Linux System
Afterinstallation,youcanrunvCLIcommandsandvSphereSDKforPerlutilityapplicationsatthecommand
prompt.
To run a vCLI command on Linux
1Openacommandprompt.
2 (Optional)ChangetothedirectorywhereyouinstalledthevCLI(defaultis/usr/bin).
3Runthecommand,includingtheconnectionoptions.
<command> <conn_options> <params>
Specifyconnectionoptionsinaconfigurationfileorpassthemonthecommandline.Theextension.pl
isnotrequiredonLinux.Forexample:
esxcli --server <esxi_HOSTNAME_OR_IP> --username snow\-white --password dwarf\$ network ip
interface list
vicfg-mpath --server <esxi_HOSTNAME_OR_IP> --username snow\-white --password dwarf\$ --list
Thesystempromptsyouforausernameandpasswordforthetargetserver.
Getting Started with vSphere Command-Line Interfaces
38 VMware, Inc.
VMware, Inc. 39
5f
YoucanrunDCLIcommandsasvCLIcommands,fromthevCenterServerApplianceshell,andfromthe
commandpromptofavCenterServerWindowsinstallation.
“OverviewofRunningDCLICommands”onpage 39
“RunningDCLICommands”onpage 41
“Input,Output,andReturnCodes”onpage 43
“UsingDCLIwithVariablesonpage 43
“DCLIHistoryFile”onpage 44
Overview of Running DCLI Commands
YoucanrunDCLIcommandsinteractivelyorinscriptsinseveralways.
RunDCLIcommandslocallyfromthevCenterServerApplianceshell.
RunDCLIcommandslocallyfromyourvCenterServeronWindowscommandprompt.
RunDCLIcommandsthatareincludedinthevCLIpackage.
OpenacommandpromptonaLinuxorWindowssystemonwhichyouinstalledvCLI.Enter
commandsintothatcommandprompt,specifyingconnectionoptions.
AccessthevMALinuxconsole.DCLIdoesnotsupportthevifastpassconnectionsavailablefrom
vMA.
PreparescriptsthatcontainDCLIcommands.ThenrunthescriptsasvCLIscripts,fromthevCenter
ServerWindowscommandprompt,orfromthevCenterServerApplianceshell.Usethecredentialstore
optionstoauthenticate,passwordsarenotsupportedinscripts.
Running DCLI Commands
5
IMPORTANTAuthenticationoptionsforDCLIcommandsdifferfromoptionsforvCLIhostmanagement
commands.
IMPORTANTUserswhorunDCLIcommandstomonitorandmanagevCenterservicesmusthavethe
appropriateprivileges.
WhenyourunDCLIcommandsincludedwithvCLI,youmustbeauserwhocanauthenticatetovCenter
SingleSignOnandwhoisalsoauthorizedtoperformtheservice,forexample,managevCentertags.
WhenyourunDCLIcommandsfromthevCenterServerApplianceshell,DCLIallowsyoutorunmany
commandswithoutadditionalauthentication.However,formanagementofcertainservices,youmight
bepromptedforausernameandpassword.
Getting Started with vSphere Command-Line Interfaces
40 VMware, Inc.
DCLI Syntax
EachDCLIcommandusesthesamesyntax.
ThecommandnameisfollowedbyDCLIconnectionandformattingoptions,eachprecededbya+sign.After
theDCLIoptionscomethenamespace,thecommand,andthecommandoptions,asinthefollowingexample:
dcli +[DCLI options] <namespace> [<namespace> ...] <cmd> --[cmd option] [option value]
DCLIoptions.Predefinedoptionsforconnectioninformationandformattingoptions.Alwayspreceded
bya+sign.
NotrequiredwhenyourunthecommandonthelocalhostattheWindowscommandpromptorthe
vCenterServerApplianceshell.
namespace.GroupsDCLIcommands.NamespacescorrespondtothevCloudSuiteSDKnamespaces.
command.Reportsonormodifiesstateonthesystem.
optionandvalue.Commandoptionandvaluepairsprecededbyminusminus(--).
Example
$dcli +server my_remote_vc +username user42 com vmware cis tagging tag list
DCLI Options
YoucanruneachDCLIcommandwithconnectionorformattingoptionsprecededbya+.
Formanyoftheoptions,youcaninsteadusevariables,discussedinTable 53,“VariablesSupportedbyDCLI,”
onpage 43.
dcli [+server SERVER_IP]
[+interactive]
[+prompt PROMPT]
[+ssl-cert-file SSL_CERT_FILE]
[+ssl-key-file SSL_KEY_FILE]
[+cacert-file CACERT_FILE]
[+more]
[+formatter {simple,table,xml,json,html,csv}]
[+loglevel {debug, info, warning, error}]
[+username USERNAME] [+password]
[+credstore-file CREDSTORE_FILE]
[+credstore-add | +credstore-remove | +credstore-list]
[+session-manager SESSION_MANAGER] [args [args ...]]
Theseoptionsallowyoutoprovidethefollowinginformation.Ifyouareenteringoptionsinteractively,tab
completionissupportedonLinuxsystems.Inallcases,youcanspecifyapartialoptionaslongastheoption
isnotambiguous.Forexample,+iindicatesinteractive,butyouhavetospecify,ataminimum,+credstore-a
todisambiguatethatoption.
Table 5-1. DCLI Options
Option Description Default
server ThevCenterServersystemtowhichDCLIconnects.localhost
interactive RunsDCLIininteractiveshellmode,whichsupportstab
completionofcommands,options,andsomeoptionvalues.Italso
supportssavingthecommandhistoryacrossDCLIsessions.
InteractivemodeisfasterbecauseDCLIcachesthelistof
commandsavailableonavCenterServersystem.
prompt Promptthattheinteractiveshelluses.dcli>
ssl-key-file
ssl-cert-file
cacert-file
IftheCLIclientconnectstoavCenterServersystemthatisusing
HTTPSconnections,youcanusetheseoptionstoprovideSSL
authenticationoptions.
more Displayspagewiseoutput.
VMware, Inc. 41
Chapter 5 Running DCLI Commands
Running DCLI Commands
YoucandisplayhelpinformationforDCLIcommands,andrunthecommandsfromasystemwherevCLIis
installed,fromthevCenterServerApplianceshell,orfromavCenterServeronWindowscommandprompt.
Displaying Help Information for DCLI Commands
Youcandisplayhelpforeachnamespaceandcommandbyusingthe--helpcommandlineoption.Because
theavailablecommandsdependentirelyontheservicesthatareavailableinthevCenterenvironmentthatyou
aretargeting,youmustincludetheserverforaccuratehelpinformation.Helpreturnsthefollowing
informationforacommand:
Eachinputoption
Whethertheoptionisrequired
Inputtype
formatter Outputformatter,oneofthefollowing:
simple
table
xml
json
html
csv
Defaultistableforlistsof
structuresandsimplefor
allotheroutput.
loglevel Theloglevel,oneofdebug,info,warning,orerror.info
username Ifyourunfromthelocalshell,mostDCLIcommandsdonot
requiretheusername.IfyouarerunningvCLIcommands,theuser
youspecifymustbeabletoauthenticatetothevCenterServer
system.
Theuseryouspecifymusthavetheprivilegestoperformthetask,
asspecifiedthroughvCenterServerroles.
Youarepromptedforthepassword.Thepasswordisnotechoedto
screen.
credstore-file Pathtothecredentialstorefiletouseforcredentialstoreoperations
orforreadinglogincredentials.
Usethisoptiononlyifthedefaultcredentialstorefilenamedoes
notworkinyourenvironment.
Bydefault,thecredentialstorefileisinthe
.dcli\.dcli_credstoredirectoryinsidethehomedirectory.
$HOME/.dcli/.dcli_cr
edstore
credstore-add AddslogincredentialsenteredforacommandtotheDCLI
credentialstorefile.
ThisoptionstorestheserverIPaddress,sessionmanager,
usernameandpasswordforthecommandbeingexecuted.Ifan
entryalreadyexists,thecommandupdatestheentry.
dclidirectoryinsidethe
homedirectory.
$HOME/dcli
credstore-remove RemovesanentryfromtheDCLIcredentialstorefile.
ThisoptionremovestheentryforaspecifiedserverIPaddressand
usernameifonlyonesessionmanagerispresentforatargetserver
anduser.
Inrarecases,informationaboutmultiplesessionmanagerentries
ispresent.Youhavetoprovidethesessionmanagerwiththe
session-manager option.
credstore-list ListsallentriesstoredintheDCLIcredentialstorefile.Eachentry
includestheserverIPaddress,sessionmanager,andusername.
session-manager Usethisoptionifyouusethecredstore-removeoptionthesame
usernameandpasswordarestoredthroughmultiplesession
managers.Notusuallyrequired.
Table 5-1. DCLI Options
Option Description Default
Getting Started with vSphere Command-Line Interfaces
42 VMware, Inc.
Example
dcli com vmware cis tagging tag create --help
usage: com vmware cis tagging tag create [-h] --create-spec-name CREATE_SPEC_NAME
--create-spec-description CREATE_SPEC_DESCRIPTION --create-spec-category-id
CREATE_SPEC_CATEGORY_ID
Creates a tag
Input Arguments:
-h, --help show this help message and exit
--create-spec-name CREATE_SPEC_NAME
The display name of the tag (required string)
--create-spec-description CREATE_SPEC_DESCRIPTION
The description of the tag (required string)
--create-spec-category-id CREATE_SPEC_CATEGORY_ID
The unique identifier of the parent category in which this tag will be
created (required string)
Running DCLI Commands Included in the vCLI Package
YourunvCLIcommandsfromanadministrationserveronwhichyouinstalledthevCLIpackage.After
installation,openacommandpromptintheVMware\VMware DCLI folder,whichisatthesamelevelasthe
VMwarevSphereCLIfolder.
Youspecifyaserver,username,andpassword.Ifyouspecifycredstore-add,DCLIcreatesacredentialstore
fileonthelocalmachineandyouarenolongerrequiredtospecifytheusernameandpasswordwhenyourun
DCLIcommandsagain.
Running DCLI Commands on the vCenter Server Appliance
TherootuseronthevCenterServerAppliancecanrunDCLIcommandsfromtheapplianceshell.
1SSHintotheshellorlogintotheshelldirectlyastherootuser.
Theadministrator@vsphere.localuserdoesnothaveprivilegestorunDCLIcommands.
2Youcanruncommandsindividually,orstarttheinteractiveDCLIshell.Theinteractiveshellhasseveral
advantagesincludingtabcompletionandahistoryfile.
>dcli +interactive
3Youcanlistcommands,displayhelpforcommands,andexecutecommands.Intheexamplebelow,the
interactiveshellusesthedcli>prompt,thedefault.
dcli> com vmware vapi metadata cli command list
Using DCLI with a Credential Store File
ToavoidtypingintheusernameandpasswordeachtimeyourunaDCLIcommand,youcanaddthecurrent
userandtheassociatedpasswordandserverIPaddresstoacredentialstorefilebyusingthecredstore-add
optiononthecommandline.
Passwordsareencryptedinthecredentialstorefile,butifyouwanttoremovecredentialstoreinformation,
youcanuse+credstore-removetodoso.
Bydefault,thecredentialstorefileislocatedin<homedir>/.dcli/.dcli_credstore,butyoucanchangethe
locationwiththe+credstore-fileoption.
Examples
Thefollowingexamplesillustratehowyoucaninteractwiththecredentialstore.
1Addanewcredentialstoreentry.
dcli com vmware cis tagging tag list +credstore-add +username user1
2Removeacredentialstoreentry.
VMware, Inc. 43
Chapter 5 Running DCLI Commands
dcli +credstore-remove +server <server> +username user1
3Listallcredentialstoreentries.
dcli +credstore-list
Order of Precedence for DCLI Authentication
WhenyourunaDCLIcommand,authenticationhappensintheorderofprecedenceshowninTable 52,
“DCLIAuthenticationPrecedence,”onpage 43.Thisorderofprecedencealwaysapplies.Thatmeans,for
example,thatyoucanoverrideanenvironmentvariablesettingfromthecommandline.
IfyouareauthenticatingthroughvCenterSingleSignOn,theorderofprecedenceispreserved.
Input, Output, and Return Codes
DCLIsupportsthefollowinginputarguments.
Basictypes.Youcanenterbasictypeslikestring,int,double,orbooleanonthecommandline.
Listtypes.ProvidethesameoptionmultipletimesonthecommandlineandDCLItreatsitasalist.
Structure.Forstructureinputfieldsusethedotnotation.Forexample,id.pathisthepathfieldintheid
structure.
Currentlysupportedoutputformattertypesaresimple,xml,html,table,csvandjson.Youcanchangethe
outputformatbypassingtheformatteroptiontoDCLI.
ForscriptingpurposesDCLIreturnsanonzeroerrorcodeforanunsuccessfulcommand.Toseethelast
commandstatusininteractivemode,runthe$?command.
Using DCLI with Variables
YoucanpredefineasetofvariablesintheenvironmentwhereyourunDCLIcommandssoyoudon’thaveto
passtheoptionseachtimeyourunacommand.Thefollowingenvironmentvariablesaresupported.
Table 5-2. DCLI Authentication Precedence
Authentication Description
Commandline Usernameandpassword,specifiedonthecommandlinetakesprecedence,evenifacredential
storeexists.
Environment
variable
Ausernamespecifiedinanenvironmentvariabletakesprecedenceoverusernamesinthe
credentialstore,butnotoverthecommandline.
Credentialstore Usernameandpasswordretrievedfromthecredentialstore.Acustomcredentialstorefileata
nondefaultlocationhasprecedenceoverafileatthedefaultlocation.
Table 5-3. Variables Supported by DCLI
Variable Description
DCLI_SERVER SetthisvariabletopasstheserverIPaddress.
Passingtheserveroptiononthecommandlineoverridesthisvariable.
DCLI_SSLCERTFILE SetthisvariabletopassthepathofyourSSLcertificatefile.
Passingthessl-cert-fileoptiononthecommandlineoverridesthisvariable.
DCLI_SSLKEYFILE SetthisvariabletopassthepathofyourSSLkeyfile.
Passingthessl-key-file optiononthecommandlineoverridesthisvariable.
DCLI_CACERTFILE SetthisvariabletopassthepathofaCAcertificatefile.
Passingthecacert-fileoptiononthecommandlineoverridesthisvariable.
DCLI_USERNAME Setthisvariabletopasstheusernamerequiredforauthentication
Passingtheusernameoptiononcommandlineoverridesthisvariable.
Getting Started with vSphere Command-Line Interfaces
44 VMware, Inc.
DCLI History File
DCLImaintainsahistoryfileforeachDCLIclientthatrunsininteractivemode.Thefilestoresinformationon
aperuserbasisandnotonaperclientbasis.
SpecifythemaximumnumberofcommandstobestoredwiththeDCLI_HISTSIZEvariable.Defaultis500
commands.
Youcanfindthefileatthefollowinglocation:
Windows:C:\Users\<username>\AppData\VMware\vapi\dcli.log
vCenterServerAppliance:/var/log/vmware/vapi/dcli.log
DCLI_CREDFILE SetthisvariabletopointtoaDCLIcredentialstorefile.Defaultvalueis
~/.dcli/.dcli_credstore
Passingthecredstore-fileoptiononthecommandlineoverridesvariable.
DCLI_HISTFILE SetthisvariabletopointtoaDCLIinteractiveshellhistoryfilepath.Defaultvalueis
~/.dcli/.dcli_history.
DCLI_HISTSIZE SetthisvariabletospecifythemaximumnumberofcommandstobestoredintheDCLI
interactiveshellhistory.Defaultis500.
DCLI_LOGFILE SetthisvariabletospecifythelogfileforDCLI.
Table 5-3. Variables Supported by DCLI
Variable Description
VMware, Inc. 45
Index
A
Active Directory 22
authentication information 30
C
command-line connection parameters 31
configuration files
for authentication 31
usage 31
connection options 30, 34
cp936 encoding 34
creating session files 30
credential store precedence 29, 43
D
DCUI 23
deploying vMA 22
direct console 23
E
encoding
cp936 34
Shift_JIS 34
execution options 34
I
installing vCLI
Linux 18, 30
Windows 21
installing vMA 22
L
Linux
installing vCLI 18, 30
running vCLI commands 32, 37
vCLI 18
lockdown mode 32
M
Microsoft Windows Security Support Provider
Interface 32
O
options 34
order of precedence 29
P
Perl 15
precedence 29
prerequisites
Red Hat Enterprise Linux 5.2 18
R
Red Hat Enterprise Linux 5.2 18
required parameters 30
running commands
from vMA 22
Linux 18, 30
Windows 21
S
scripts with vCLI commands 36
session files 30
Shift_JIS encoding 34
SSPI protocol 32
U
uninstalling
Linux 21
on Linux 21
on Windows 22
Using 31
using session files 30
V
vCLI
command-line 31
configuration files 31
environment variables 30, 31
execution options 34
installing on Linux 18, 30
installing on Windows 21
vCLI package
installing on Linux 16
installing on Windows 21
uninstalling 21
unpacking 18, 20
vMA 22
environment variables 31
installing 22
multiple configuration files 31
vSphere Management Assistant 22
Getting Started with vSphere Command-Line Interfaces
46 VMware, Inc.
vSphere SDK for Perl 15
W
Windows
executing commands 32
installing vCLI 21
running vCLI commands 37
using vCLI 21

Navigation menu