Tuesday, October 4, 2011

Managing HOST using vCLI

  • Stopping, Rebooting and Examining Hosts with vicfg-hostops
  • Entering and Exiting Maintenance Mode with vicfg-hostops
$ vicfg-hostops --operation shutdown $ vicfg-hostops --operation shutdown --force $ vicfg-hosops --operation shutdown --cluster $ vicfg-hostops --operation shutdown --datacenter $ vicfg-hostops --operation reboot $ vicfg-hostops --operation reboot --force $ vicfg-hostops --operation reboot --cluster $ vicfg-hostops --operation reboot --datacenter $ vicfg-hostops --operation info
In Windows, vicfg-hostops.pl is used.
C:\>vicfg-hostops.pl --server esx1.virtuallab.com --username root --password esxsvr40 --operation info
Host Name : esx1.virtuallab.com
Manufacturer : VMware, Inc.
Model : VMware Virtual Platform
Processor Type : Intel(R) Core(TM) i3-2310M CPU @ 2.10GHz
CPU Cores : 2 CPUs x 2087 GHz
Memory Capacity : 2047 MB
VMotion Enabled : no
In Maintenance Mode : no
Last Boot Time : 2011-10-04T09:30:29.668805+09:00
$ vicfg-hostops --operation enter
C:\>vicfg-hostops.pl --server esx1.virtuallab.com --username root --password esxsvr40 --operation enter Host esx1.virtuallab.com entered into maintenance mode successfully. C:\>vicfg-hostops.pl --server esx1.virtuallab.com --username root --password esxsvr40 --operation info

<><>
Host Name : esx1.virtuallab.com
Manufacturer : VMware, Inc.
Model : VMware Virtual Platform
Processor Type : Intel(R) Core(TM) i3-2310M CPU @ 2.10GHz
CPU Cores : 2 CPUs x 2087 GHz
Memory Capacity : 2047 MB
VMotion Enabled : no
In Maintenance Mode : yes
Last Boot Time : 2011-10-04T09:30:29.668805+09:00
C:\>vicfg-hostops.pl --server esx1.virtuallab.com --username root --password esxsvr40 --operation exit Host esx1.virtuallab.com exited from maintenance mode successfully. C:\>vicfg-hostops.pl --server esx1.virtuallab.com --username root --password esxsvr40 --operation info
Host Name : esx1.virtuallab.com
Manufacturer : VMware, Inc.
Model : VMware Virtual Platform
Processor Type : Intel(R) Core(TM) i3-2310M CPU @ 2.10GHz
CPU Cores : 2 CPUs x 2087 GHz
Memory Capacity : 2047 MB
VMotion Enabled : no
In Maintenance Mode : no
Last Boot Time : 2011-10-04T09:30:29.668805+09:00
[changho@changhocho ~]$ vicfg-hostops --help
Synopsis: /usr/bin/vicfg-hostops OPTIONS
Command-specific options:
--action
-a
"Specify the action for powered on virtual machine (poweroff | suspend). Default is suspend."
--cluster
-c
"Name of the cluster (optional)."
--datacenter
-d
"Name of the datacenter (optional)."
--force
-f
"Optional for reboot and shutdown operation. Flag to force the host that is not in maintenance mode
to be rebooted/shutdown. If not specified, operation will fail for host not in maintenance mode."
--operation (required)
-o
"Operation to perform (enter | exit | reboot | shutdown | info)."
--vihost
-h
"The host to use when connecting via Virtual Center."

Common VI options:
--config (variable VI_CONFIG)
Location of the VI Perl configuration file
--credstore (variable VI_CREDSTORE)
Name of the credential store file defaults to /.vmware/credstore/vicredentials.xml on Linux and /VMware/credstore/vicredentials.xml on Windows
--encoding (variable VI_ENCODING, default 'utf8')
Encoding: utf8, cp936 (Simplified Chinese), iso-8859-1 (German), shiftjis (Japanese)
--help
Display usage information for the script
--passthroughauth (variable VI_PASSTHROUGHAUTH)
Attempt to use pass-through authentication
--passthroughauthpackage (variable VI_PASSTHROUGHAUTHPACKAGE, default 'Negotiate')
Pass-through authentication negotiation package
--password (variable VI_PASSWORD)
Password
--portnumber (variable VI_PORTNUMBER)
Port used to connect to server
--protocol (variable VI_PROTOCOL, default 'https')
Protocol used to connect to server
--savesessionfile (variable VI_SAVESESSIONFILE)
File to save session ID/cookie to utilize
--server (variable VI_SERVER, default 'localhost')
VI server to connect to. Required if url is not present
--servicepath (variable VI_SERVICEPATH, default '/sdk/webService')
Service path used to connect to server
--sessionfile (variable VI_SESSIONFILE)
File containing session ID/cookie to utilize
--url (variable VI_URL)
VI SDK URL to connect to. Required if server is not present
--username (variable VI_USERNAME)
Username
--verbose (variable VI_VERBOSE)
Display additional debugging information
--version
Display version information for the script

  • Backing Up Configuration Information with vicfg-cfgbackup

C:\>vicfg-cfgbackup.pl --server esx1.virtuallab.com --username root --password esxsvr40 --save
Operation not supported on this host.

This will not work on ESX host.
C:\>vicfg-cfgbackup.pl --server esx2.virtuallab.com --username root --password esxsvr40 --save
a backup file name must be specified when saving.
For a summary of command usage, type 'C:\Program Files (x86)\VMware\VMware vSphere CLI\bin\vicfg-cfgbackup.pl --help'.
For documentation, type 'perldoc C:\Program Files (x86)\VMware\VMware vSphere CLI\bin\vicfg-cfgbackup.pl'.
This will work on ESXi host but there is missing parameter.
Try again with correct parameter.
C:\Users\Administrator.W2K8PDC>vicfg-cfgbackup.pl --server esx2.virtuallab.com --username root --password esxsvr40 --save esx2cfg.save
Saving firmware configuration to esx2cfg.save ...
C:\>dir
Volume in drive C has no label.
Volume Serial Number is 8824-A01A
Directory of C:\Users\Administrator.W2K8PDC
10/04/2011 04:41 PM <dir> .
10/04/2011 04:41 PM <dir> ..
09/16/2011 01:37 PM <dir> Contacts
09/21/2011 12:46 PM <dir> Desktop
09/21/2011 12:45 PM <dir> Documents
09/16/2011 01:37 PM <dir> Downloads
10/04/2011 04:41 PM 45,806 esx2cfg.save
09/26/2011 04:47 PM 0 esxcli.log
09/16/2011 01:37 PM <dir> Favorites
09/16/2011 01:37 PM <dir> Links
09/16/2011 01:37 PM <dir> Music
09/16/2011 01:37 PM <dir> Pictures
09/16/2011 01:37 PM <dir> Saved Games
09/16/2011 01:37 PM <dir> Searches
09/16/2011 01:37 PM <dir> Videos
2 File(s) 45,806 bytes
13 Dir(s) 20,258,390,016 bytes free
C:\Users\Administrator.W2K8PDC>vicfg-cfgbackup.pl --help
Synopsis: C:\Program Files (x86)\VMware\VMware vSphere CLI\bin\vicfg-cfgbackup.pl OPTIONS [<backupfile>]
Command-specific options:
--force
-f
Force the restore of the configuration.
--load
-l
Restore configuration onto the host
--quiet
-q
Do not prompt for user confirmation.
--reset
-r
Resets host, restore to factory settings.
--save
-s
Backup the host configuration.

Common VI options:

  • Managing Host Updates with vihostupdate
C:\>vihostupdate.pl --server esx1.virtuallab.com --username root --password esxsvr40 --query
---------Bulletin ID--------- -----Installed----- ----------------Summary-----------------
ESX410-Update01 2011-09-21T08:29:58 VMware ESX 4.1 Complete Update 1
C:\>vihostupdate.pl --help
Synopsis: C:\Program Files (x86)\VMware\VMware vSphere CLI\bin\vihostupdate.pl OPTIONS
Command-specific options:
--bulletin
-B
Parameter to specify the selective bulletin(s) to install. Use
comma to specify multiple bulletins (eg. bulletin1,bulletin2).
All bulletins will be installed if this option is not specified.
--bundle
-b
Parameter to specify the location of the offline bundle. For install operation, multiple
offline bundles can be specified using comma separator with no space (eg. bundle1,bundle2).

--install
-i

Install the host with selective bulletins from the bundle, the depot or local offline bundle.

--list
-l

List the bulletins in the bundle or in the depot.

--metadata
-m

Parameter to specify the location of the depot metadata.zip

--nosigcheck
-c

Ignore integrity checking during install operation (unsupported).

--query
-q

Query the bulletins that are already installed in the host.

--remove
-r

Remove selective bulletins from the host.

--scan
-s

Scan the host against the bundle or the depot for applicable bulletins.


Common VI options:

  • Managing VMkernel Modules with vicfg-module

C:\>vicfg-module.pl --server esx1.virtuallab.com --username root --password esxsvr40 --query


Name IDLoaded
vmkernel 0Yes
vmkapiv1_0_0_0_vmkernel_shim1Yes
vmklinux 2Yes
random 3Yes
dm 4Yes
nmp 5Yes
vmw_satp_local 6Yes
vmw_satp_default_aa 7Yes
vmw_psp_lib 8Yes
vmw_psp_fixed 9Yes
vmw_psp_rr 10Yes
vmw_psp_mru 11Yes
vmw_psp_fixed_ap 12Yes
vmw_satp_alua 13Yes
vmw_satp_cx 14Yes
libata 15Yes
mask_path_plugin 16Yes
vaai_filter 17Yes
vmw_vaaip_emc 18Yes
vmkapiv1_0_0_0_nmp_shim 19Yes
vmci 20Yes
iscsi_trans 21Yes
hub 22Yes
netsched 23Yes
e1000 24Yes
iscsi_linux 25Yes
ata_piix 26Yes
mptspi 27Yes
lvmdriver 28Yes
deltadisk 29Yes
multiextent 30Yes
dvsdev 31Yes
etherswitch 32Yes
shaper 33Yes
cdp 34Yes
tcpip3 35Yes
cosShadow 36Yes
dvfilter 37Yes
vmkapiv1_0_0_0_dvfilter_shim38Yes
vmfs3 39Yes
nfsclient 40Yes
vmkstatelogger 41Yes
migrate 42Yes
cbt 43Yes
iscsi_vmk 44Yes
pclassify 45Yes
C:\>vicfg-module.pl --help
Synopsis: C:\Program Files (x86)\VMware\VMware vSphere CLI\bin\vicfg-module.pl OPTIONS []


Command-specific options:
--get-options
-g

Get the option string configured to be passed to the module
when it is loaded.

--list
-l
List the set of modules on the host (valid for vSphere 4.0 and later).

--query
-q
Query enabled modules options (valid for vSphere 4.0 and later).

--set-options
-s

Set the option string to be passed to the module when it is loaded.

--vihost
-h
The host to use when connecting via Virtual Center (valid for vSphere 4.0 and later)

Common VI options:


  • Using vicfg-authconfig for Active Directory Configuration

C:\>vicfg-authconfig.pl --help

Synopsis: C:\Program Files (x86)\VMware\VMware vSphere CLI\bin\vicfg-authconfig.pl OPTIONS


Command-specific options:
--adpassword
-w
Active Directory password. To be used in conjunction with joindomain option.
--adusername
-U
Active Directory username. To be used in conjunction with joindomain option.
--authscheme
-t
Specify the type of authenticaton scheme. Currently only AD is supported.
--currentdomain
-c
Prints out the currently joined domain.
--force
-f
This flag is only used with leavecurrentdomain option. If specified, any
permissions on entities for AD users will be deleted. If not specified and such
permissions exist, the operation will fail.
--getremoteauthstore
-a
Prints out only the active authentication mechanism.
--joindomain
-j
Join a particular Active Directory domain.
--leavecurrentdomain
-L
Leaves the current Active Directory domain.
--listauthstores
-l
Prints out the different authentication mechanisms supported.
--vihost
-h
The host to use when connecting via Virtual Center.

Common VI options:

No comments: