New Tool For Virtual Center

Today I had to query virtual center.

I tried the old vmware-vix utility and it just did not work.

Then I found a utility called govc, the binary can be downloaded from here

https://github.com/vmware/govmomi/releases/download/v0.16.0/govc_linux_amd64.gz

It’s a simple gunzip of the file and chmod +x

I renamed it to govc and moved it to /usr/local/bin

It needed some enviromental variables to work, so I created a file

parameters.env

export GOVC_URL='https://vc.example.local/sdk'
export GOVC_INSECURE=true
export GOVC_USERNAME='example\larry'
export GOVC_PASSWORD=someRANDOMPASSWORD

Then sourced the file

source paramaters.env

First thing I did was list

govc list

But then I wanted more, find was pretty cool

govc find /STIA/vm -type m

No screwey gui

I got details for a paticular vm using the vm.info command but it did not give me annotations

I was able to get it using json

govc vm.info -json VMNAME

But it wasn’t formatted right, I downloaded jq and a dependancy

wget http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/j/jq-1.5-1.el7.x86_64.rpm
wget http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/o/oniguruma-5.9.5-3.el7.x86_64.rpm

And was able to read more complex information

govc vm.info -json VMNAME | jq .VirtualMachines[].Config
govc vm.info -json VMNAME | jq .VirtualMachines[].Guest.Net

And I got formatted readable stuff.

 

This entry was posted in Technical, Training, Virtualization. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.