govc.sh - wrapper which sets VSphere specific settings and runs govc.
Other things to install:
- libshell (http://git.altlinux.org/people/legion/packages/?p=libshell.git;a=summary)
- jq
- govc (https://github.com/vmware/govmomi/tree/master/govc)
- git clone libshell, install shell-* files to /usr/local/bin or somewhere in $PATH
- install govc binary to dir within $PATH
- install govc.sh wrapper to dir within $PATH
- create minimal cofiguration with vsphere login/passwd:
cat ~/.terraformware.conf
....
vsphere_username = <user>@<domain>
vsphere_password = <base64 encoded password string>
- create Vsphere DC layout:
cat ~/.vs-dc.ini
# global settings are not really needed
# but ease the usage
[global]
location=ams
[ams]
url=ams-prd-vc01.xxxxx
dc=AMS-PRD-DC01
[brq]
url=brq-prd-vc02.xxxxx
dc=BRQ-PRD-DC01
$ govc.sh --help
Usage: Usage: govc.sh [-l DC] [options] <cmd> <vm>
Options:
-l, --location=<FRA|PAR> VSphere DC location (FRA or PAR);
-V, --version print program version and exit;
-h, --help show this text and exit;
-j, --json use json output.
Command shortcuts (takes VM as last argument):
poweron
poweroff
suspend
pstate Shows current VM power state
info
disk_info
disk_shrink
disk_extend <size>
disk_change <mode>
memory_extend <size>Mb
memory_hotadd_check
memory_hotadd_enable
cpu_add <nr>
cpu_remove <nr>
cpu_hotadd_check
cpu_hotadd_enable
cpu_hotremove_check
cpu_hotremove_enable
ls_snapshot
create_snapshot
delete_snapshot <name> Delete defined snapshot
revert_snapshot <name> Revert to defined snapshot
Advanced usage:
govc.sh [options] -- <govc direct cmd>
$ govc.sh -l fra -- find vm -name wiki*
vm/AMS_UBUNTU/<vmname>
$ govc.sh -l fra -- object.collect -s vm/AMS_UBUNTU/<vmname> config.memoryHotAddEnabled
false
$ govc.sh -l fra poweroff test-nginx01-fra
$ govc.sh -l fra memory_hotadd_enable test-nginx01-fra
$ govc.sh -l fra poweron test-nginx01-fra
$ govc.sh -l fra memory_hotadd_check test-nginx01-fra
govc.sh: Enabled
$ govc.sh -l fra cpu_hotremove_check test-nginx01-fra
govc.sh: Enabled
$ govc.sh -l fra cpu_remove 1 test-nginx01-fra
govc.sh: Cannot remove CPUs from a running VM
$ govc.sh -l fra poweroff test-nginx01-fra
Shutdown guest VirtualMachine:vm-5749... OK
$ govc.sh -l fra cpu_remove 1 test-nginx01-fra
govc.sh: Changing CPU count 4->3 ..
$ govc.sh -l fra poweron test-nginx01-fra
...
$ govc.sh -l fra cpu_add 1 test-nginx01-fra
govc.sh: Changing CPU count 3->4 ..