• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

about/H24-May-2018-238163

cli/H24-May-2018-214136

cluster/H24-May-2018-1,6851,106

datacenter/H24-May-2018-245170

datastore/H24-May-2018-2,3881,646

device/H24-May-2018-1,7941,173

dvs/H24-May-2018-694452

emacs/H24-May-2018-2,2001,813

env/H24-May-2018-10464

events/H24-May-2018-18849

examples/lib/H24-May-2018-4536

export/H24-May-2018-252181

extension/H24-May-2018-450308

fields/H24-May-2018-396244

flags/H24-May-2018-3,4172,347

folder/H24-May-2018-254178

host/H24-May-2018-5,1243,464

importx/H24-May-2018-1,168839

license/H24-May-2018-612389

logs/H24-May-2018-357237

ls/H24-May-2018-17637

metric/H24-May-2018-1,194567

object/H24-May-2018-1,241847

option/H24-May-2018-264183

permissions/H24-May-2018-431278

pool/H24-May-2018-612414

role/H24-May-2018-463295

session/H24-May-2018-557399

sso/H24-May-2018-740507

task/H24-May-2018-302207

test/H24-May-2018-6,1204,170

vapp/H24-May-2018-229161

version/H24-May-2018-6839

vm/H24-May-2018-6,7144,715

.gitignoreH A D24-May-20187 21

CHANGELOG.mdH A D24-May-20188.4 KiB365185

README.mdH A D24-May-20186.7 KiB212134

USAGE.mdH A D24-May-201898.7 KiB3,8972,842

build.shH A D24-May-2018890 3829

main.goH A D24-May-20183.4 KiB8968

main_test.goH A D24-May-20181 KiB3915

release.shH A D24-May-20182.5 KiB12085

usage.shH A D24-May-20182 KiB6349

README.md

1# govc
2
3govc is a vSphere CLI built on top of govmomi.
4
5The CLI is designed to be a user friendly CLI alternative to the GUI and well suited for automation tasks.
6It also acts as a [test harness](test) for the govmomi APIs and provides working examples of how to use the APIs.
7
8## Installation
9
10You can find prebuilt govc binaries on the [releases page](https://github.com/vmware/govmomi/releases).
11
12Download and install a binary locally like this:
13
14``` console
15% curl -L $URL_TO_BINARY | gunzip > /usr/local/bin/govc
16% chmod +x /usr/local/bin/govc
17```
18
19### Source
20
21To build govc from source, first install the [Go toolchain](https://golang.org/dl/).
22
23Make sure to set the environment variable [GOPATH](https://github.com/golang/go/wiki/SettingGOPATH).
24
25You can then install the latest govc from github using:
26
27``` console
28% go get -u github.com/vmware/govmomi/govc
29```
30
31Make sure `$GOPATH/bin` is in your `PATH` to use the version installed from source.
32
33If you've made local modifications to the repository at `$GOPATH/src/github.com/vmware/govmomi`, you can install using:
34
35``` console
36% go install github.com/vmware/govmomi/govc
37```
38
39## Usage
40
41For the complete list of commands and flags, refer to the [USAGE](USAGE.md) document.
42
43Common flags include:
44
45* `-u`: ESXi or vCenter URL (ex: `user:pass@host`)
46* `-debug`: Trace requests and responses (to `~/.govmomi/debug`)
47
48Managed entities can be referred to by their absolute path or by their relative
49path. For example, when specifying a datastore to use for a subcommand, you can
50either specify it as `/mydatacenter/datastore/mydatastore`, or as
51`mydatastore`. If you're not sure about the name of the datastore, or even the
52full path to the datastore, you can specify a pattern to match. Both
53`/*center/*/my*` (absolute) and `my*store` (relative) will resolve to the same
54datastore, given there are no other datastores that match those globs.
55
56The relative path in this example can only be used if the command can
57umambigously resolve a datacenter to use as origin for the query. If no
58datacenter is specified, govc defaults to the only datacenter, if there is only
59one. The datacenter itself can be specified as a pattern as well, enabling the
60following arguments: `-dc='my*' -ds='*store'`. The datastore pattern is looked
61up and matched relative to the datacenter which itself is specified as a
62pattern.
63
64Besides specifying managed entities as arguments, they can also be specified
65using environment variables. The following environment variables are used by govc
66to set defaults:
67
68* `GOVC_URL`: URL of ESXi or vCenter instance to connect to.
69
70    The URL scheme defaults to `https` and the URL path defaults to `/sdk`.
71    This means that specifying `user:pass@host` is equivalent to
72    `https://user:pass@host/sdk`.
73
74    If username or password includes special characters like `\`, `#` or `:` you can use
75    `GOVC_USERNAME` and `GOVC_PASSWORD` to have a simple `GOVC_URL`
76
77    When using govc against VMware Workstation, GOVC_URL can be set to "localhost"
78    without a user or pass, in which case local ticket based authentication is used.
79
80* `GOVC_USERNAME`: USERNAME to use if not specified in GOVC_URL.
81
82* `GOVC_PASSWORD`: PASSWORD to use if not specified in GOVC_URL.
83
84* `GOVC_TLS_CA_CERTS`: Override system root certificate authorities.
85
86    ``` console
87    $ export GOVC_TLS_CA_CERTS=~/.govc_ca.crt
88    # Use path separator to specify multiple files:
89    $ export GOVC_TLS_CA_CERTS=~/ca-certificates/bar.crt:~/ca-certificates/foo.crt
90    ```
91
92* `GOVC_TLS_KNOWN_HOSTS`: File(s) for thumbprint based certificate verification.
93
94    Thumbprint based verification can be used in addition to or as an alternative to
95    `GOVC_TLS_CA_CERTS` for self-signed certificates.  Example:
96
97    ``` console
98    $ export GOVC_TLS_KNOWN_HOSTS=~/.govc_known_hosts
99    $ govc about.cert -u host -k -thumbprint | tee -a $GOVC_TLS_KNOWN_HOSTS
100    $ govc about -u user:pass@host
101    ```
102
103* `GOVC_TLS_HANDSHAKE_TIMEOUT`: Limits the time spent performing the TLS handshake.
104
105* `GOVC_INSECURE`: Disable certificate verification.
106
107    This option sets Go's `tls.Config.InsecureSkipVerify` flag and is false by default.
108    Quoting https://golang.org/pkg/crypto/tls/#Config:
109    > `InsecureSkipVerify` controls whether a client verifies the
110    > server's certificate chain and host name.
111    >
112    > If `InsecureSkipVerify` is true, TLS accepts any certificate
113    > presented by the server and any host name in that certificate.
114    >
115    > In this mode, TLS is susceptible to man-in-the-middle attacks.
116    > This should be used only for testing.
117
118* `GOVC_DATACENTER`
119
120* `GOVC_DATASTORE`
121
122* `GOVC_NETWORK`
123
124* `GOVC_RESOURCE_POOL`
125
126* `GOVC_HOST`
127
128* `GOVC_GUEST_LOGIN`: Guest credentials for guest operations
129
130* `GOVC_VIM_NAMESPACE`: Vim namespace defaults to `urn:vim25`
131
132* `GOVC_VIM_VERSION`: Vim version defaults to `6.0`
133
134## Troubleshooting
135
136### Environment variables
137
138If you're using environment variables to set `GOVC_URL`, verify the values are set as expected:
139
140``` console
141% govc env
142```
143
144### Connection issues
145
146Check your proxy settings:
147
148``` console
149% env | grep -i https_proxy
150```
151
152Test connection using curl:
153``` console
154% curl --verbose -k -X POST https://x.x.x.x/sdk
155```
156
157### MSYS2 (Windows)
158
159Inventory path arguments with a leading '/' are subject
160to [Posix path conversion](http://www.mingw.org/wiki/Posix_path_conversion).
161
162## Examples
163
164Several examples are embedded in the govc command [help](USAGE.md)
165
166* [Upload ssh public key to a VM](examples/lib/ssh.sh)
167
168* [Create a CoreOS VM](https://github.com/vmware/govmomi/blob/master/toolbox/toolbox-test.sh)
169
170* [Create a Debian VM](https://github.com/kubernetes/kubernetes/tree/master/cluster/vsphere)
171
172* [Create a Windows VM](https://github.com/dougm/govc-windows-box/blob/master/provision-esx.sh)
173
174* [Create an ESX VM](../scripts/vcsa/create-esxi-vm.sh)
175
176* [Create a vCenter VM](../scripts/vcsa/create-vcsa-vm.sh)
177
178* [Create a Cluster](../scripts/vcsa/create-cluster.sh)
179
180## Status
181
182Changes to the cli are subject to [semantic versioning](http://semver.org).
183
184Refer to the [CHANGELOG](CHANGELOG.md) for version to version changes.
185
186When new govc commands or flags are added, the PATCH version will be incremented.  This enables you to require a minimum
187version from within a script, for example:
188
189``` console
190% govc version -require 0.14
191```
192
193## Projects using govc
194
195* [Emacs govc package](./emacs)
196
197* [Kubernetes vSphere Provider](https://github.com/kubernetes/kubernetes/tree/master/cluster/vsphere)
198
199* [VMware VIC Engine](https://github.com/vmware/vic)
200
201* [vSphere Docker Volume Service](https://github.com/vmware/docker-volume-vsphere)
202
203* [golang/build](https://github.com/golang/build)
204
205## Related projects
206
207* [rvc](https://github.com/vmware/rvc)
208
209## License
210
211govc is available under the [Apache 2 license](../LICENSE).
212