
VMware, Inc. 29
Chapter 3 Using the vSphere Command-Line Interface
Table 3‐3listsoptionsnotusedasconnectionoptionsthatyoucanusewhenyourunavicfg-vCLIcommand.
Using vCLI Commands in Scripts
Mostadministratorsrunscriptstoperformthesametaskrepeatedlyortoperformataskonmultiplehosts.
YoucanrunvCLIcommandsfromoneadministrationserveragainstmultipletargetservers.
Forexample,whenanewdatastorebecomesavailableinyourenvironment,youmustmakethatdatastore
availabletoeachESXi
host.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
ThescriptitselfaddstheNASdatatoeachhostdefinedinVIHOSTS.
#!/bin/bash
VI_CONFIG_FILE=/home/admin/viconfig
VIHOSTS=(esxi_server_a esx_server_b esxi_server_c)
--server <server>
VI_SERVER=<server>
UsesthespecifiedESXiorvCenterServersystem.Defaultislocalhost.
If--serverpointstoavCenterServersystem,youusethe--vihostoption
tospecifytheESXihostonwhichyouwanttorunthecommand.Acommand
issupportedforvCenterServerifthe--vihostoption
isdefined.
--servicepath <path>
VI_SERVICEPATH=<path>
UsesthespecifiedservicepathtoconnecttotheESXihost.Defaultis
/sdk/webService.
--sessionfile <file>
VI_SESSIONFILE=<file>
Usesthespecifiedsessionfiletoloadapreviouslysavedsession.Thesession
mustbeunexpired.
--url <url>
VI_URL=<url>
ConnectstothespecifiedvSphereWebServicesSDKURL.
--username <u_name>
VI_USERNAME=<u_name>
Usesthespecifiedusername.
If--serverspecifiesavCen ter Serversystem,theusernameand
passwordapplytothatserver.IfyoucanlogintothevCenterServer
system,youneednoadditionalauthenticationtoruncommandsonthe
ESXihoststhatservermanages.
If--serverspecifiesanESXisystem,theusernameandpasswordapply
tothatsystem.
Ifyoudonotspecifyausernameandpasswordonthecommandline,the
systempromptsyouanddoesnotechoyourinputtothescreen.
--vihost <host>
-h <host>
VI_HOST=<esxi_host>
WhenyourunavCLIcommandwiththe
--serveroptionpointingtoa
vCenterServersystem,use--vihosttospecifytheESXihosttorunthe
commandagainst.
N
OTE:Thisoptionisnotsupportedforeachcommand.Ifsupported,the
optionisincludedwhenyourun<cmd> --help.
Table 3-3. vCLI Common Options
Option Description
--help Printsabriefusagemessage.Themessagelistsfirsteachcommand‐specificoptionandthen
eachofthecommonoptions.
--verbose Displaysadditionaldebugginginformation.
--version Displaysversioninformation.
Table 3-2. vCLI Connection Options (Continued)
Option and Environment Variable Description
Comentarios a estos manuales