Book Image

VMware Virtual SAN Cookbook

By : Jeffrey M Ransom Taylor, Patrick Carmichael, Simon Gallagher, Jeffrey Taylor
Book Image

VMware Virtual SAN Cookbook

By: Jeffrey M Ransom Taylor, Patrick Carmichael, Simon Gallagher, Jeffrey Taylor

Overview of this book

Table of Contents (18 chapters)
VMware Virtual SAN Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

RVC scripting and redirects


As RVC provides its own shell, standard *NIX shell structures likes pipes, redirects, and loops are not available. This makes scripting RVC operations and redirecting outputs more difficult than in a standard *NIX or Windows command shell.

Due to these difficulties, it is easiest to record a session output using PuTTY or another terminal emulator if using SSH to a Linux-based RVC instance. For Windows, copying and pasting to a text file is a possibility.

Executing RVC operations as a single command

To execute RVC commands in this manner, the command syntax is as follows:

rvc <username>@<domain>:<password>@<vCenter_address> -c "<commands>"

For example, to run the vsan.disks_stats command, the command line will be the following:

rvc <username>@<domain>:<password>@<vCenter_address> -c "vsan.disks_stats /<vCenter>/<datacenter>/computers/<cluster>"

As RVC is formally launching and logging in, it will remain logged in after the command-execution finishes. For this reason, it is recommended that you add the quit command to any command executed with the -c flag. Multiple commands can be passed to VSAN serially by the addition of more -c flags.

For example, to run the vsan.disks_stats command followed by the vsan.check_limits command and then quit, the command line will be the following:

rvc <username>@<domain>:<password>@<vCenter_address> -c "vsan.disks_stats /<vCenter>/<datacenter>/computers/<cluster>" -c "vsan.check_limits /<vCenter>/<datacenter>/computers/<cluster>" -c "quit"

Redirecting RVC output to a file

To redirect the output from RVC commands, those commands must be invoked with RVC itself, and provided as a single command, as outlined previously. The output will then go to standard out and can subsequently be redirected to a file, or be piped, according to standard conventions in your shell.

Avoiding the use of plain-text passwords in the RVC command

If you do not wish to have the password revealed in plain text, it can be omitted, but this adds complication to the command. If you do not supply the password, you will still be prompted to enter it. If using a standard *NIX or Windows redirect, however, the prompt for the password will also be redirected and it will be invisible. If you choose to execute a redirect without providing a password on the command line, you can wait a few seconds and then type the password and strike Enter. This will be accepted by the command and it will subsequently execute.

If using a Linux version of RVC, this can be mitigated to some degree by the tee command, if it is available. tee redirects output to the file of your choice, but also echoes the same output to the console. Through the use of tee, you will still be able to see the prompt for the password and redirect the output. That command line would look like the following:

rvc <arguments> |tee /path/to/output/file

The tee command is available in the vCenter Server Appliance.