This section describes the VSS Command Line Interface in detail.
HelpTo get help when using the VSS CLI, you can add --help
option to the end of a command. For example:
...
Code Block |
---|
language | bash |
---|
linenumbers | false |
---|
|
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 StructureThe 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 ValuesVSS CLI options vary from simple string, boolean or numeric values to JSON data structures as input parameters on the command line.
...
CommonString 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 |
---|
language | pythonjson |
---|
linenumbers | false |
---|
|
{
"dhcp": false,
"ip": "192.168.1.23",
"gateway": ["192.168.1.1"],
"dns": ["192.168.1.1"],
"hostname": "vm1",
"domain": "utoronto.ca"
} |
...
Code Block |
---|
language | bash |
---|
linenumbers | false |
---|
|
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 OutputThe VSS CLI supports the following formats:
...
Info |
---|
Environment variable VSS_OUTPUT always overrides any value set in the -o/--output option. |
TableThe 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 |
---|
language | bash |
---|
linenumbers | false |
---|
|
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"
...
}
] |
YAMLAs with JSON, YAML can be easily decoded by many programming languages. The VSS CLI can provide the yaml
output as follows:
Code Block |
---|
language | bash |
---|
linenumbers | false |
---|
|
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-completionBash 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 |
---|
language | bash |
---|
linenumbers | false |
---|
|
vss-cli compute <TAB><TAB>
account compute configure request stor token
vss-cli -<TAB><TAB>
--config --no-verbose --output --verbose --version -c -o |
Anchor |
---|
| Use-Source-File |
---|
| Use-Source-File |
---|
|
Source FileTo 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.
SourceHowever, there’s also a non-persistent method:
...
Code Block |
---|
language | bash |
---|
linenumbers | false |
---|
|
source <(vss-cli completion zsh) |
ShellThe VSS CLI provides a REPL interactive shell with tab-completion, suggestions and command history.
...