Skip to content

Instantly share code, notes, and snippets.

@matthewcosgrove
Last active October 30, 2020 14:49
Show Gist options
  • Save matthewcosgrove/c149216b951de0051f48b9bec8436b4f to your computer and use it in GitHub Desktop.
Save matthewcosgrove/c149216b951de0051f48b9bec8436b4f to your computer and use it in GitHub Desktop.
govc pool.info -json /drinks-dc/host/drinks-cl/Resources/chardonnay | jq -r '.ResourcePools[].Vm[] | join(":")' | xargs govc ls -L
# relative path - not guaranteed to be unique
govc pool.info ${GOVC_RESOURCE_POOL}
# absolute path
govc pool.info /${GOVC_DATACENTER}/host/${GOVC_CLUSTER}/Resources/${GOVC_RESOURCE_POOL}
# relative path
govc datastore.info "${GOVC_DATASTORE}"
# moids (can be browsed via https://VSPHERE_SERVER/mob) See https://code.vmware.com/doc/preview?id=4205#/doc/PG_Appx_Using_MOB.21.2.html#994699
# https://${GOVC_URL}/mob/?moid=ServiceInstance&method=retrieveContent
# from https://registry.terraform.io/providers/hashicorp/vsphere/latest/docs#locating-managed-object-ids
# $ govc ls -l -i /dc1/vm
# VirtualMachine:vm-123 /dc1/vm/foobar
# Folder:group-v234 /dc1/vm/subfolder
inventory_path="/${GOVC_DATACENTER}/vm/"
govc ls -l -i "${inventory_path}"
ubuntu@mgmt-tools:~/deploy-tools-vm$ govc vm.power -off local-test-ubuntu-tools-vm-3d82cd64
Powering off VirtualMachine:vm-2599... OK
ubuntu@mgmt-tools:~/deploy-tools-vm$ govc vm.customize -vm local-test-ubuntu-tools-vm-3d82cd64 -name local-test-ubuntu-tools-vm-3d82cd64
govc: The number of network adapter settings in the customization specification: 0 does not match the number of network adapters present in the virtual machine: 1.
ubuntu@mgmt-tools:~/deploy-tools-vm$ govc vm.customize -vm local-test-ubuntu-tools-vm-3d82cd64 -name local-test-ubuntu-tools-vm-3d82cd64 -ip dhcp
ubuntu@mgmt-tools:~/deploy-tools-vm$ govc vm.power -on local-test-ubuntu-tools-vm-3d82cd64
Powering on VirtualMachine:vm-2599... OK
ubuntu@mgmt-tools:~/deploy-tools-vm$ govc vm.power -off local-test-ubuntu-tools-vm-3d82cd64
Powering off VirtualMachine:vm-2599... OK
ubuntu@mgmt-tools:~/deploy-tools-vm$ govc vm.customize -vm local-test-ubuntu-tools-vm-3d82cd64 -name local-test-ubuntu-tools-vm-3d82cd64 -ip 10.0.0.2 -netmask 255.255.255.0
ubuntu@mgmt-tools:~/deploy-tools-vm$ govc vm.power -on local-test-ubuntu-tools-vm-3d82cd64
Powering on VirtualMachine:vm-2599... OK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment