Книга: Mastering VMware® Infrastructure3

Remote Command-Line Interface (RCLI)

Remote Command-Line Interface (RCLI)

With no console operating system to connect to, ESXi would seem to be limited in its management capability. However, for those environments with many servers whose administrators refuse to perform tasks repeatedly through the VI Client, VMware now provides a remote command-line interface for host management. This tool is available in two formats:

? Remote CLI installable package for installation on Windows or Linux

? Remote CLI virtual machine appliance

Both tools can be downloaded from the VMware website. The Remote CLIs support a long list of commands for managing ESX Server hosts. The tools are based on the VMware Infrastructure (VI) Perl Toolkit, which relies on Perl and a few other libraries.

CLI and Scripting

Before we go any further with the command-line tools and scripting, I want to be sure that you are aware of the various security concerns and implications. All of these commands will require the submission of a user name and password. Depending on how you implement the command, the password might be presented on the screen in clear text or it might be stored in a file in clear text. As you look at configuring ESX Server, hosts using scripts and command-line tools ensure that you have adopted the appropriate security methods to prevent improper uses, ranging from determining passwords to high-level accounts. For example, if you create configuration files, limit the permissions (even read permissions) to ensure that unauthorized users cannot read the files and thereby discover passwords to elevated accounts.

In addition to these security concerns, let me address another issue for those who might be new to the idea of scripting. You do not have to do this. While it is certainly true that scripting can save time, keep in mind that it is only true for those who have achieved a high level of proficiency in the scripting methods and only in those environments with a significant number of hosts to manage. The remaining portions of this chapter will most likely come across as a time-consuming effort for those unfamiliar with scripting technologies. So maybe you are asking yourself, “When should I use scripting?” The answer varies, but you can apply some common sense to the situation by considering the following:

? What would be the length of your learning curve to perform scripting versus just performing the task through the VI Client? If you only have a handful of hosts, it might be quicker to use the VI Client than it would be to figure out how to script from the ground up.

? How often will you be performing this task? If you have ten hosts with six network adapters that are all used in virtual switches and there is no intention of adding more adapters and configuring more virtual switches, then creating a script to add virtual switches to the ten hosts would be a waste of time. On top of that, if you are only adding one or two new ESX Server hosts per year, it might be less administratively cumbersome to manually configure each new server with the necessary virtual switches. On the other hand, if you were adding one or two new ESX Server hosts per week, then generating a script to create virtual switches might make the learning curve worth it.

In conclusion, I know that many of you who are getting into virtualization management and have long been Windows administrators may not be experts in the realm of scripting, especially in Perl. So understand that scripting is an option that is beneficial in some, but not necessarily all, cases. It is up to you to decide whether to learn to script or whether to use the graphical tools, even if they do incur extra time. VMware has done an excellent job in structuring the VI3 suite of products around the idea that scripting is an option, not a mandate. 

For each of the remote CLI commands, the following options are available as part of the command execution: 

--config Specifies the location of the configuration to be used, which must be a location accessible from the current directory. The equivalent variable used in a configuration file is VICONFIG.

--password Specifies the password for use in combination with the --username parameter. If the username and password are not specified in the execution string, you will be prompted for them. The equivalent variable used in a configuration file is VI PASSWORD.

--portnumber Used to specify the port used to connect to the ESX Server host. The default port is 443. The equivalent variable used in a configuration file is VIPORTNUMBER.

--protocol Used to specify the protocol used to connect to the ESX Server host. The default protocol is HTTPS. The equivalent variable used in a configuration file is VIPROTOCOL.

--server Used to identify the server against which the command should be run. The default is the localhost. The equivalent variable used in a configuration file is VISERVER. 

--servicepath Used to identify the service path to connect to the ESX Server host. The default is /sdk/webService. The equivalent variable used in a configuration file is VISERVICEPATH.

--sessionfile Used to reference a saved session file. The equivalent variable used in a configuration file is VISESSIONFILE.

--url Used to connect to the VI SDK specified in the URL. The equivalent variable used in a configuration file is VIURL.

--username Used to specify the username for the authentication context. If the username and password are not specified, you will be prompted for them. The equivalent variable used in a configuration file is VIUSERNAME.

--verbose Used to provide more detail in the debugging information. The equivalent variable used in a configuration file is VIVERBOSE.

--version Used to display version information. 

Using --help 

For any of the commands listed below, you can type the command followed by --help to get a look at the parameters that can be passed in. 

Here is a list of commands with explanations and samples: 

resxtop This command provides real-time monitoring of ESX CPU, memory, disk, and network adapter utilization. To run resxtop on an ESX host with an IP address of 172.30.0.105, use the following command:

resxtop -server 172.30.0.105 -username root

Once the tool is running, use the C, M, D, and N keys to switch between CPU, memory, disk, and network counters, respectively. Figures 13.25 and 13.26 show the resxtop output for CPU and memory. 


Figure 13.25 The resxtop Remote CLI command provides CPU utilization data.

svmotion This command performs the storage migration process of moving the disk files of a virtual machine to a different LUN.

vicfg-advcfg This option is not recommended for customer use. This command is typically used only under the guidance of VMware technical support.


Figure 13.26 Pressing the M key makes resxtop display data regarding memory utilization.

vicfg-cfgbackup This tool allows for the backup and restore of the configuration data of an ESXi host.

vicfg-dumppart This tool allows for querying, setting, and scanning the diagnostic data "dumps" of an ESX Server host.

vicfg-mpath This tool allows for the configuration of multipathing settings for fibre channel or iSCSI LUNs.

vicfg-nas This tool provides settings and parameters for managing NFS access for your ESX Server host. For example, the following syntax adds a NAS datastore named NFSDS to a server named silo107.vdc.local. The NFS server is named nfs1.vdc.local and has a directory named /iso that is shared:

vicfg-nas --server silo107.vdc.local --username root --password -a -o nfs1.vdc.local -s /iso NFSDS

vicfg-nics This tool provides management of physical network adapters. Figure 13.27 shows a simple listing of all network adapters on a server with an IP address of 172.30.01 using the following syntax:

vicfg-nics --server 172.30.0.105 --username root --list


Figure 13.27 The vicfg-nics tool can identify details about network adapters.

vicfg-ntp This command allows for the configuration of NTP servers for the 3i hosts.

vicfg-rescan This command executes a remote HBA rescan.

vicfg-route This command allows for setting the IP address of the default gateway for the VMkernel.

vicfg-snmp This command allows for the configuration of SNMP for ESX Server hosts.

vicfg-syslog This command allows for the specification of the remote syslog server for an ESX Server host.

vicfg-vmhbadevs This command provides information regarding the LUNs available to an ESX Server host.

vicfg-vmknic This command allows for the configuration of VMkernel network adapters.

vicfg-vswitch This command allows for adding, removing, and modifying virtual switches and virtual switch properties. Review the following examples. Keep in mind that the parameters of --server and --username (and then a password) would be required to run the commands against a remote host.

To add a new virtual switch named vSwitch3:

vicfg-vswitch --add vSwitch3

To add a new port group named TestVMs to vSwitch3:

vicfg-vswitch --add-pg="TestVMs" vSwitch3

To list all the virtual switches:

vicfg-vswitch -l

vihostupdate This command allows for the management of software updates on an ESXi host. It provides the necessary parameters for applying software updates and monitoring installed updates.

ESX Updates

While the command-line tool might be attractive to the hard-core command-line junkie types, software updates and patch monitoring are best performed using the new VMware Update Manager that is built into VirtualCenter 2.5. 

vifs This command allows copying, removing, getting, and putting on files and directories. 

vmkfstools This command allows for the creation and manipulation of file systems (VMFS), virtual disks (VMDK), logical volumes, and physical storage devices.

All of these commands can be combined with the use of a configuration file to simplify the scripting syntax. A configuration file is a file accessible by the system where the remote command line is being generated (Windows host, Linux host, or virtual appliance) that allows for commonly used parameters to be stored in a file and then referenced as part of the CLI command execution. A configuration file for a host named silo101.vdc.local would include information as shown here:

VI_SERVER=silo101.vdc.local
VI_USERNAME= root
VI_PASSWORD = learnvmware
 

This configuration file is then called in during the execution of the command as shown in the following syntax. This command would create an NFS datastore named NFS ISOs on the host silo101.vdc.local that points to an /iso directory on an NFS server named nfsserver.learn.vmw:

vicfg-nas --config <path to config file> -a -o nfsserver.learn.vmw -s /iso NFS_ISOs

Оглавление книги


Генерация: 1.069. Запросов К БД/Cache: 3 / 1
поделиться
Вверх Вниз