Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This section describes the VSS Command Line Interface in detail.

Anchor
Help
Help
Anchor
Use-Help
Use-Help
Help

To get help when using the VSS CLI, you can add --help option to the end of a command. For example:

...

Code Block
languagebash
linenumbersfalse
vss-cli compute vm ls -f name=%VM% -s name=desc

moref    name                  folder.path                                         cpu_count    memory_gb  power_state    ip_address
-------  --------------------  ------------------------------------------------  -----------  -----------  -------------  ------------
vm-1274  1910T-TestVM1         VSS > Development                                           1            2  poweredOff
vm-1270  1910T-TestVM2         VSS > Development                                           1            2  poweredOff
vm-1258  1910T-TestVM3         VSS > Development                                           1            1  poweredOff

Anchor
Command-Structure
Command-Structure
Anchor
Use-Command-Structure
Use-Command-Structure
Command Structure

The VSS CLI command structure is compose by the base vss-cli command followed by options, subgroups, sub-commands, options and arguments.

...

Parameters take different types of input values such as numbers, strings, lists, tuples, and JSON data structures as strings.

Anchor
Parameter-Values
Parameter-Values
Anchor
Use-Parameter-Values
Use-Parameter-Values
Parameter Values

VSS CLI options vary from simple string, boolean or numeric values to JSON data structures as input parameters on the command line.

Anchor
Common

...

Common
Anchor
Use-Common
Use-Common
Common

String parameters can contain alphanumeric characters and spaces surrounded by quotes. The following example renames a virtual machine:

...

Some VSS CLI options and arguments require data to be formatted as JSON, such as reconfiguring a virtual machine guest operating system specification (hostname, domain, dns, ip, subnet and gateway) upon deployment. The option --custom-spec expects the following JSON data structure:

Code Block
languagepythonjson
linenumbersfalse
{
 "dhcp": false,
 "ip": "192.168.1.23",
 "gateway": ["192.168.1.1"],
 "dns": ["192.168.1.1"],
 "hostname": "vm1",
 "domain": "utoronto.ca"
}

...

Code Block
languagebash
linenumbersfalse
vss-cli compute vm mk from-template --source FrontEnd-1 \
  --description 'New virtual machine' \
  --custom-spec "{\"dhcp\": false, \"ip\": \"192.168.1.23\", \"gateway\": [\"192.168.1.1\"],
   \"dns\": [\"192.168.1.1\"], \"hostname\": \"vm1\", \"domain\": \"utoronto.ca\"}" VM1

Anchor
Command-Output
Command-Output
Anchor
Use-Command-Output
Use-Command-Output
Command Output

The VSS CLI supports the following formats:

...

Info

Environment variable VSS_OUTPUT always overrides any value set in the -o/--output option.

Anchor
Table
Table
Anchor
Use-Table
Use-Table
Table

The table format presents the VSS CLI output into tab-delimited lines, helpful when using grep, sed, and awk on Unix or Windows PowerShell.

...

Code Block
languagebash
linenumbersfalse
vss --output=json compute vm ls
[
    {
    "moref": "vm-1270",
    "name": "1910T-TestVM1",
    "provisioned_gb": 2.18,
    "tools_running_status": "guestToolsNotRunning",
    "tools_version": "0",
    "tools_version_status": "guestToolsNotInstalled",
    "uncommitted_bytes": 2338168320,
    "unshared_bytes": 996,
    "updated_on": "2020-04-21 Tue 02:10:03 EDT",
    "uuid": "5030f8d5-fa01-8eff-bb21-8d1ee7e6c230",
    "version": "vmx-15"
    ...
    }
]

Anchor
YAML
YAML
Anchor
Use-YAML
Use-YAML
YAML

As with JSON, YAML can be easily decoded by many programming languages. The VSS CLI can provide the yaml output as follows:

Code Block
languagebash
linenumbersfalse
 vss-cli --output=yaml compute vm ls -f name=%TEST% -s name desc

- moref: vm-2173
   name: 2004P-test-vm-centos
   provisioned_gb: 2.18
   tools_running_status: guestToolsNotRunning
   tools_version: '0'
   tools_version_status: guestToolsNotInstalled
   uncommitted_bytes: 2338168320
   unshared_bytes: 996
   updated_on: 2020-04-21 Tue 02:10:03 EDT
   uuid: 5030f8d5-fa01-8eff-bb21-8d1ee7e6c230
   version: vmx-15

Anchor
Auto-completion
Auto-completion
Anchor
Use-Auto-completion
Use-Auto-completion
Auto-completion

Bash completion support is provided by [Click][Click] and will complete sub commands and parameters. Sub commands are always listed whereas parameters only if at least a dash has been provided. Example:

Code Block
languagebash
linenumbersfalse
vss-cli compute <TAB><TAB>
account    compute    configure  request    stor       token

vss-cli -<TAB><TAB>
--config      --no-verbose  --output      --verbose     --version     -c            -o

Anchor
Source-File
Source-File
Anchor
Use-Source-File
Use-Source-File
Source File

To activate completion in bash or zsh or fish is recommended to use a generated script and source it to ensure responsiveness:

...

After modifying the shell config, you need to start a new shell in order for the changes to be loaded.

Anchor
Source
Source
Anchor
Use-Source
Use-Source
Source

However, there’s also a non-persistent method:

...

Code Block
languagebash
linenumbersfalse
source <(vss-cli completion zsh)

Anchor
Shell
Shell
Anchor
Use-Shell
Use-Shell
Shell

The VSS CLI provides a REPL interactive shell with tab-completion, suggestions and command history.

...