├── govc-gocmomi.png ├── scripts ├── create-standalone.sh ├── apply-licenses.sh ├── create-cluster.sh ├── create-vcsa-vm.sh └── create-esxi-vm.sh ├── README.md └── cmdlets └── USAGE.md /govc-gocmomi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/collabnix/govc/HEAD/govc-gocmomi.png -------------------------------------------------------------------------------- /scripts/create-standalone.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | # Create a Datacenter and connect the underlying ESXi host to vCenter VM 4 | 5 | esx_host=$(govc env -x GOVC_URL_HOST) 6 | esx_user=$(govc env GOVC_USERNAME) 7 | esx_pass=$(govc env GOVC_PASSWORD) 8 | vc_ip=${1-$(govc vm.ip "$USER-vcsa")} 9 | 10 | unset GOVC_DATACENTER 11 | export GOVC_INSECURE=1 GOVC_URL="Administrator@vsphere.local:${esx_pass}@${vc_ip}" 12 | 13 | dc_name=dc1 14 | if [ -z "$(govc ls "/${dc_name}")" ] ; then 15 | echo "Creating datacenter ${dc_name}..." 16 | govc datacenter.create "$dc_name" 17 | fi 18 | 19 | govc host.add -hostname "$esx_host" -username "$esx_user" -password "$esx_pass" -noverify 20 | -------------------------------------------------------------------------------- /scripts/apply-licenses.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | # Copyright 2017 VMware, Inc. All Rights Reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | export GOVC_INSECURE=true 19 | 20 | govc license.add "$VCSA_LICENSE" "$ESX_LICENSE" >/dev/null 21 | 22 | govc license.assign "$VCSA_LICENSE" >/dev/null 23 | 24 | govc find / -type h | xargs -I% -n1 govc license.assign -host % "$ESX_LICENSE" >/dev/null 25 | 26 | echo "Assigned licenses..." 27 | govc license.assigned.ls 28 | 29 | echo "" 30 | echo "License usage..." 31 | govc license.ls 32 | -------------------------------------------------------------------------------- /scripts/create-cluster.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | # Copyright 2017-2018 VMware, Inc. All Rights Reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # Configure a vCenter cluster with vSAN datastore, DVS and DVPGs 18 | 19 | export GOVC_INSECURE=1 20 | export GOVC_USERNAME=${GOVC_USERNAME:-"Administrator@vsphere.local"} 21 | if [ -z "$GOVC_PASSWORD" ] ; then 22 | # extract password from $GOVC_URL 23 | GOVC_PASSWORD=$(govc env GOVC_PASSWORD) 24 | fi 25 | 26 | usage() { 27 | echo "Usage: $0 [-d DATACENTER] [-c CLUSTER] VCSA_IP ESX_IP..." 1>&2 28 | exit 1 29 | } 30 | 31 | # Defaults 32 | dc_name="dc1" 33 | cluster_name="cluster1" 34 | vsan_vnic="vmk0" 35 | 36 | while getopts c:d: flag 37 | do 38 | case $flag in 39 | c) 40 | cluster_name=$OPTARG 41 | ;; 42 | d) 43 | dc_name=$OPTARG 44 | ;; 45 | *) 46 | usage 47 | ;; 48 | esac 49 | done 50 | 51 | shift $((OPTIND-1)) 52 | 53 | if [ $# -lt 2 ] ; then 54 | usage 55 | fi 56 | 57 | vc_ip=$1 58 | shift 59 | 60 | unset GOVC_DATACENTER 61 | export GOVC_URL="${GOVC_USERNAME}:${GOVC_PASSWORD}@${vc_ip}" 62 | 63 | cluster_path="/$dc_name/host/$cluster_name" 64 | dvs_path="/$dc_name/network/DSwitch" 65 | public_network="/$dc_name/network/PublicNetwork" 66 | internal_network="/$dc_name/network/InternalNetwork" 67 | 68 | if [ -z "$(govc ls "/$dc_name")" ] ; then 69 | echo "Creating datacenter ${dc_name}..." 70 | govc datacenter.create "$dc_name" 71 | fi 72 | 73 | export GOVC_DATACENTER="$dc_name" 74 | 75 | if [ -z "$(govc ls "$cluster_path")" ] ; then 76 | echo "Creating cluster ${cluster_path}..." 77 | govc cluster.create "$cluster_name" 78 | fi 79 | 80 | if [ -z "$(govc ls "$dvs_path")" ] ; then 81 | echo "Creating dvs ${dvs_path}..." 82 | govc dvs.create -product-version 6.0.0 -folder "$(dirname "$dvs_path")" "$(basename "$dvs_path")" 83 | fi 84 | 85 | if [ -z "$(govc ls "$public_network")" ] ; then 86 | govc dvs.portgroup.add -dvs "$dvs_path" -type earlyBinding -nports 16 "$(basename "$public_network")" 87 | fi 88 | 89 | if [ -z "$(govc ls "$internal_network")" ] ; then 90 | govc dvs.portgroup.add -dvs "$dvs_path" -type ephemeral "$(basename "$internal_network")" 91 | fi 92 | 93 | hosts=() 94 | vsan_hosts=() 95 | 96 | for host_ip in "$@" ; do 97 | host_path="$cluster_path/$host_ip" 98 | hosts+=($host_path) 99 | 100 | if [ -z "$(govc ls "$host_path")" ] ; then 101 | echo "Adding host ($host_ip) to cluster $cluster_name" 102 | govc cluster.add -cluster "$cluster_path" -noverify -force \ 103 | -hostname "$host_ip" -username root -password "$GOVC_PASSWORD" 104 | fi 105 | 106 | unclaimed=$(govc host.storage.info -host "$host_path" -unclaimed | tail -n+2 | wc -l) 107 | if [ "$unclaimed" -eq 2 ] ; then 108 | echo "Enabling vSAN traffic on ${vsan_vnic} for ${host_path}..." 109 | govc host.vnic.service -host "$host_path" -enable vsan "$vsan_vnic" 110 | vsan_hosts+=($host_path) 111 | else 112 | echo "Skipping vSAN configuration for ${host_path}: $unclaimed unclaimed disks" 113 | fi 114 | done 115 | 116 | govc dvs.add -dvs "$dvs_path" -pnic vmnic1 "${hosts[@]}" 117 | 118 | echo "Enabling DRS for ${cluster_path}..." 119 | govc cluster.change -drs-enabled "$cluster_path" 120 | 121 | if [ ${#vsan_hosts[@]} -ge 3 ] ; then 122 | echo "Enabling vSAN for ${cluster_path}..." 123 | govc cluster.change -vsan-enabled -vsan-autoclaim "$cluster_path" 124 | fi 125 | 126 | echo "Enabling HA for ${cluster_path}..." 127 | govc cluster.change -ha-enabled "$cluster_path" 128 | 129 | echo "Granting Admin permissions for user root..." 130 | govc permissions.set -principal root -role Admin 131 | 132 | echo "Done." 133 | -------------------------------------------------------------------------------- /scripts/create-vcsa-vm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | # Copyright 2017-2018 VMware, Inc. All Rights Reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # Create a VCSA VM 18 | 19 | usage() { 20 | echo "Usage: $0 [-n VM_NAME] [-i VCSA_OVA] [-a IP] ESX_URL" 1>&2 21 | exit 1 22 | } 23 | 24 | export GOVC_INSECURE=1 25 | 26 | name=vcsa 27 | 28 | # 6.7.0U1 https://docs.vmware.com/en/VMware-vSphere/6.7/rn/vsphere-esxi-vcenter-server-67-release-notes.html 29 | ova=VMware-vCenter-Server-Appliance-6.7.0.20000-10244745_OVF10.ova 30 | 31 | while getopts a:i:n: flag 32 | do 33 | case $flag in 34 | a) 35 | ip=$OPTARG 36 | ;; 37 | i) 38 | ova=$OPTARG 39 | ;; 40 | n) 41 | name=$OPTARG 42 | ;; 43 | *) 44 | usage 45 | ;; 46 | esac 47 | done 48 | 49 | if [ -d "$ova" ] ; then 50 | ova=$(ls "$ova"/*.ovf) 51 | fi 52 | 53 | shift $((OPTIND-1)) 54 | 55 | if [ $# -ne 1 ] ; then 56 | usage 57 | fi 58 | 59 | export GOVC_URL=$1 60 | 61 | network=${GOVC_NETWORK:-$(basename "$(govc ls network)")} 62 | product=$(govc about -json | jq -r .About.ProductLineId) 63 | # Use the same password as GOVC_URL 64 | password=$(govc env GOVC_PASSWORD) 65 | 66 | if [ -z "$password" ] ; then 67 | echo "password not set" 68 | exit 1 69 | fi 70 | 71 | opts=( 72 | cis.vmdir.password=$password 73 | cis.appliance.root.passwd=$password 74 | cis.appliance.root.shell=/bin/bash 75 | cis.deployment.node.type=embedded 76 | cis.vmdir.domain-name=vsphere.local 77 | cis.vmdir.site-name=VCSA 78 | cis.appliance.net.addr.family=ipv4 79 | cis.appliance.ssh.enabled=True 80 | cis.ceip_enabled=False 81 | cis.deployment.autoconfig=True 82 | ) 83 | 84 | if [ -z "$ip" ] ; then 85 | mode=dhcp 86 | ntp=0.pool.ntp.org 87 | else 88 | mode=static 89 | 90 | # Derive net config from the ESX server 91 | config=$(govc host.info -k -json | jq -r .HostSystems[].Config) 92 | gateway=$(jq -r .Network.IpRouteConfig.DefaultGateway <<<"$config") 93 | dns=$(jq -r .Network.DnsConfig.Address[0] <<<"$config") 94 | ntp=$(jq -r .DateTimeInfo.NtpConfig.Server[0] <<<"$config") 95 | route=$(jq -r ".Network.RouteTableInfo.IpRoute[] | select(.DeviceName == \"vmk0\") | select(.Gateway == \"0.0.0.0\")" <<<"$config") 96 | prefix=$(jq -r .PrefixLength <<<"$route") 97 | 98 | opts+=(cis.appliance.net.addr=$ip 99 | cis.appliance.net.prefix=$prefix 100 | cis.appliance.net.dns.servers=$dns 101 | cis.appliance.net.gateway=$gateway) 102 | fi 103 | 104 | opts+=( 105 | cis.appliance.ntp.servers="$ntp" 106 | cis.appliance.net.mode=$mode 107 | ) 108 | 109 | if [ "$product" = "ws" ] ; then 110 | # workstation does not suport NFC 111 | dir=$(govc datastore.info -json | jq -r .Datastores[0].Info.Url) 112 | 113 | ovftool --name="$name" --acceptAllEulas "$ova" "$dir" 114 | vmx="$name/${name}.vmx" 115 | printf "guestinfo.%s\n" "${opts[@]}" >> "$dir/$vmx" 116 | govc vm.register "$vmx" 117 | govc vm.network.change -vm "$name" -net NAT ethernet-0 118 | else 119 | props=$(printf -- "guestinfo.%s\n" "${opts[@]}" | \ 120 | jq --slurp -R 'split("\n") | map(select(. != "")) | map(split("=")) | map({"Key": .[0], "Value": .[1]})') 121 | 122 | cat < 8 | 9 | # Content 10 | 11 | [Lab #0 - Getting Started with GOVC](https://github.com/collabnix/govc/blob/master/README.md#installation)
12 | [Lab #1 - Creating a New Datacenter](https://github.com/collabnix/govc/blob/master/README.md#lab-1)
13 | [Lab #2 - Adding ESXi to the Cluster](https://github.com/collabnix/govc/blob/master/README.md#how-to-add-esxi-host-to-this-cluster)
14 | [Lab #3 - Deploy Virtual Machine from ISO Image](https://github.com/collabnix/govc/blob/master/README.md#lab-3)
15 | [Lab #4 - Deploy Virtual Machine from template](https://github.com/collabnix/govc/blob/master/README.md#lab-4)
16 | [Lab #5 - Demonstrating Storage vMotion](https://github.com/collabnix/govc/blob/master/README.md#lab-5)
17 | 18 | # Ready Scripts 19 | 20 | [Configure a vCenter cluster with vSAN datastore, DVS and DVPGs ](https://github.com/collabnix/govc/blob/master/scripts/create-cluster.sh)
21 | [Create a Datacenter and connect the underlying ESXi host to vCenter VM](https://github.com/collabnix/govc/blob/master/scripts/create-standalone.sh)
22 | [Create a VM and boot stateless ESXi via cdrom/iso](https://github.com/collabnix/govc/blob/master/scripts/create-esxi-vm.sh)
23 | [Create VCSA VM](https://github.com/collabnix/govc/blob/master/scripts/create-vcsa-vm.sh)
24 | 25 | 26 | # List of GOVC Commands 27 | 28 | [Overall Commands Available](https://github.com/collabnix/govc/blob/master/cmdlets/USAGE.md)
29 | 30 | ## Installation 31 | 32 | You can find prebuilt govc binaries on the releases page. 33 | 34 | Download and install a binary locally like this: 35 | 36 | 37 | ## Install GOVC on Ubuntu 18.04 38 | 39 | ``` 40 | wget https://github.com/vmware/govmomi/releases/download/v0.19.0/govc_linux_amd64.gz 41 | gunzip govc_linux_amd64.gz 42 | mv govc_linux_amd64 govc 43 | cp -rf govc /usr/local/bin/ 44 | chmod +x /usr/local/bin/govc 45 | ``` 46 | 47 | ## Export the credentials: 48 | 49 | ``` 50 | export GOVC_URL='root:password@' 51 | ``` 52 | 53 | ## Disable certificate verification. 54 | 55 | ``` 56 | export GOVC_INSECURE=1 57 | ``` 58 | 59 | ## Listing the Datacenter 60 | 61 | ``` 62 | govc ls 63 | ``` 64 | 65 | ## Listing ESXi Host 66 | 67 | ``` 68 | /ha-datacenter/vm 69 | /ha-datacenter/vm/CSERACKPAS61 70 | /ha-datacenter/vm/CSELABDNS.local (1) 71 | ``` 72 | 73 | ## How to do vMotion? 74 | 75 | Say, I have VM in datastore1 and I want to migrate it to "Local" datastore. I can run the below command to perform it: 76 | 77 | ``` 78 | govc vm.migrate -ds Local PhotonOS 79 | [31-01-19 16:59:43] migrating VirtualMachine:vm-673... OK 80 | ``` 81 | 82 | ## How to disable firewall? 83 | 84 | ``` 85 | govc host.esxcli -host= network firewall set --enabled false 86 | ``` 87 | 88 | ## How to enable sfcb service? 89 | 90 | ``` 91 | govc host.esxcli -host= system wbem set -e 1 92 | ``` 93 | 94 | ## How to configure NTP 95 | 96 | ``` 97 | govc host.date.change -host -server 98 | govc host.service -host enable ntpd 99 | govc host.service -host start ntpd 100 | ``` 101 | 102 | ## Deploy VM from Template 103 | 104 | ``` 105 | govc vm.clone -vm= -on=true -waitip=false -host= -ds= newVMname 106 | govc vm.clone -vm=windows8Server64Guest-template -on=true -waitip=false -host=XXX.XXX.XXX.XXX -ds=ESX67 windows8Server64Guest 107 | ``` 108 | ## Create new folder inside datastore 109 | 110 | ``` 111 | govc datastore.mkdir -ds=datastorename newfolder 112 | ``` 113 | 114 | ## Copying VM files to different folder 115 | 116 | ``` 117 | govc datastore.cp -ds=dastorename VM1/VM1.vmdk newfolder/VM1.vmdk 118 | ``` 119 | 120 | ## Unregistering VM from VC 121 | 122 | ``` 123 | govc vm.unregister VMname 124 | ``` 125 | 126 | 127 | # Lab #1: 128 | 129 | ## Creating a new Datacenter 130 | 131 | ``` 132 | govc datacenter.create demo 133 | ``` 134 | 135 | ## Fetching Demo Datacenter Information 136 | 137 | ``` 138 | # govc datacenter.info demo 139 | Name: demo 140 | Path: /demo 141 | Hosts: 0 142 | Clusters: 0 143 | Virtual Machines: 0 144 | Networks: 0 145 | Datastores: 0 146 | 147 | ``` 148 | 149 | ## Creating a new cluster 150 | 151 | ``` 152 | govc cluster.create -dc=demo democluster 153 | 154 | ``` 155 | 156 | ## How to add ESXi Host to this Cluster 157 | 158 | - First we need to take care of cert and put it under thumbprint variable 159 | 160 | ``` 161 | thumbprint=$(govc about.cert -k -u -thumbprint | awk '{print $2}') 162 | ``` 163 | 164 | - Now add the ESXi host flawlessly 165 | 166 | ``` 167 | govc cluster.add -cluster democluster -hostname -username root -password -thumbprint $thumbprint 168 | ``` 169 | 170 | 171 | 172 | ## How to remove ESXI Host from this cluster 173 | 174 | - This is a 2 step process. First, put the ESXi host in maintenance mode by running below command: 175 | 176 | ``` 177 | govc host.maintenance.enter -dc=demo 178 | ``` 179 | 180 | - Now you can remove ESXi 181 | 182 | ``` 183 | govc host.remove -dc=demo 184 | ``` 185 | 186 | 187 | -------------------------------------------------------------------------------- /scripts/create-esxi-vm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | # This script creates a VM and boot stateless ESXi via cdrom/iso 4 | 5 | set -o pipefail 6 | 7 | usage() { 8 | cat <<'EOF' 9 | Usage: $0 [-d DISK_GB] [-m MEM_GB] [-i ESX_ISO] [-s] ESX_URL VM_NAME 10 | 11 | GOVC_* environment variables also apply, see https://github.com/vmware/govmomi/tree/master/govc#usage 12 | If GOVC_USERNAME is set, it is used to create an account on the ESX vm. Default is to use the existing root account. 13 | If GOVC_PASSWORD is set, the account password will be set to this value. Default is to use the given ESX_URL password. 14 | EOF 15 | } 16 | 17 | disk=48 18 | mem=16 19 | # 6.7.0U1 https://docs.vmware.com/en/VMware-vSphere/6.7/rn/vsphere-esxi-vcenter-server-67-release-notes.html 20 | iso=VMware-VMvisor-6.7.0-10302608.x86_64.iso 21 | 22 | while getopts d:hi:m:s flag 23 | do 24 | case $flag in 25 | d) 26 | disk=$OPTARG 27 | ;; 28 | h) 29 | usage 30 | exit 31 | ;; 32 | i) 33 | iso=$OPTARG 34 | ;; 35 | m) 36 | mem=$OPTARG 37 | ;; 38 | s) 39 | standalone=true 40 | ;; 41 | *) 42 | usage 1>&2 43 | exit 1 44 | ;; 45 | esac 46 | done 47 | 48 | shift $((OPTIND-1)) 49 | 50 | if [ $# -ne 2 ] ; then 51 | usage 52 | exit 1 53 | fi 54 | 55 | if [[ "$iso" == *"-Installer-"* ]] ; then 56 | echo "Invalid iso name (need stateless, not installer): $iso" 1>&2 57 | exit 1 58 | fi 59 | 60 | export GOVC_INSECURE=1 61 | export GOVC_URL=$1 62 | network=${GOVC_NETWORK:-"VM Network"} 63 | username=$GOVC_USERNAME 64 | password=$GOVC_PASSWORD 65 | unset GOVC_USERNAME GOVC_PASSWORD 66 | 67 | guest=${GUEST:-"vmkernel65Guest"} 68 | 69 | if [ -z "$password" ] ; then 70 | # extract password from $GOVC_URL 71 | password=$(govc env GOVC_PASSWORD) 72 | fi 73 | 74 | shift 75 | 76 | name=$1 77 | shift 78 | 79 | echo -n "Checking govc version..." 80 | govc version -require 0.15.0 81 | 82 | if [ "$(govc env -x GOVC_URL_HOST)" = "." ] ; then 83 | if [ "$(uname -s)" = "Darwin" ]; then 84 | PATH="/Applications/VMware Fusion.app/Contents/Library:$PATH" 85 | fi 86 | 87 | dir="${name}.vmwarevm" 88 | vmx="$dir/${name}.vmx" 89 | 90 | if [ -d "$dir" ] ; then 91 | if vmrun list | grep -q "$vmx" ; then 92 | vmrun stop "$vmx" hard 93 | fi 94 | rm -rf "$dir" 95 | fi 96 | 97 | mkdir "$dir" 98 | vmware-vdiskmanager -c -s "${disk}GB" -a lsilogic -t 1 "$dir/${name}.vmdk" 2>/dev/null 99 | 100 | cat > "$vmx" < /dev/null 2>&1 ; then 152 | govc datastore.upload "$iso" "$boot" 153 | fi 154 | 155 | echo "Creating vm ${name}..." 156 | govc vm.create -on=false -net "$network" -m $((mem*1024)) -c 2 -g "$guest" -net.adapter=vmxnet3 -disk.controller pvscsi "$name" 157 | 158 | echo "Adding a second nic for ${name}..." 159 | govc vm.network.add -net "$network" -net.adapter=vmxnet3 -vm "$name" 160 | 161 | echo "Enabling nested hv for ${name}..." 162 | govc vm.change -vm "$name" -nested-hv-enabled 163 | 164 | echo "Enabling Mac Learning dvFilter for ${name}..." 165 | seq 0 1 | xargs -I% govc vm.change -vm "$name" \ 166 | -e ethernet%.filter4.name=dvfilter-maclearn \ 167 | -e ethernet%.filter4.onFailure=failOpen 168 | 169 | echo "Adding cdrom device to ${name}..." 170 | id=$(govc device.cdrom.add -vm "$name") 171 | 172 | echo "Inserting $boot into $name cdrom device..." 173 | govc device.cdrom.insert -vm "$name" -device "$id" "$boot" 174 | 175 | if [ -n "$standalone" ] ; then 176 | echo "Creating $name disk for use by ESXi..." 177 | govc vm.disk.create -vm "$name" -name "$name"/disk1 -size "${disk}G" 178 | fi 179 | 180 | echo "Powering on $name VM..." 181 | govc vm.power -on "$name" 182 | 183 | echo "Waiting for $name ESXi IP..." 184 | vm_ip=$(govc vm.ip "$name") 185 | 186 | ! govc events -n 100 "vm/$name" | grep -E 'warning|error' 187 | fi 188 | 189 | esx_url="root:@${vm_ip}" 190 | echo "Waiting for $name hostd (via GOVC_URL=$esx_url)..." 191 | while true; do 192 | if govc about -u "$esx_url" 2>/dev/null; then 193 | break 194 | fi 195 | 196 | printf "." 197 | sleep 1 198 | done 199 | 200 | if [ -z "$standalone" ] ; then 201 | # Create disk for vSAN after boot so they are unclaimed 202 | echo "Creating $name disks for use by vSAN..." 203 | govc vm.disk.create -vm "$name" -name "$name"/vsan-cache -size "$((disk/2))G" 204 | govc vm.disk.create -vm "$name" -name "$name"/vsan-store -size "${disk}G" 205 | fi 206 | 207 | # Set target to the ESXi VM 208 | GOVC_URL="$esx_url" 209 | 210 | if [ -z "$standalone" ] ; then 211 | echo "Rescanning ${name} HBA for new devices..." 212 | disk=($(govc host.storage.info -rescan | grep /vmfs/devices/disks | awk '{print $1}' | sort)) 213 | 214 | echo "Marking ${name} disk ${disk[0]} as SSD..." 215 | govc host.storage.mark -ssd "${disk[0]}" 216 | 217 | echo "Marking ${name} disk ${disk[1]} as HDD..." 218 | govc host.storage.mark -ssd=false "${disk[1]}" 219 | fi 220 | 221 | echo "Configuring NTP for ${name}..." 222 | govc host.date.change -server 0.pool.ntp.org 223 | 224 | for id in TSM TSM-SSH ntpd ; do 225 | printf "Enabling service %s for ${name}...\n" $id 226 | govc host.service enable $id 227 | govc host.service start $id 228 | done 229 | 230 | if [ -z "$username" ] ; then 231 | username=root 232 | action="update" 233 | else 234 | action="create" 235 | fi 236 | 237 | echo "Disabling VSAN device monitoring for ${name}..." 238 | govc host.esxcli system settings advanced set -o /LSOM/VSANDeviceMonitoring -i 0 239 | 240 | # A setting of 1 means that vSwp files are created thin, with 0% Object Space Reservation 241 | govc host.esxcli system settings advanced set -o /VSAN/SwapThickProvisionDisabled -i 1 242 | govc host.esxcli system settings advanced set -o /VSAN/FakeSCSIReservations -i 1 243 | 244 | echo "ESX host account $action for user $username on ${name}..." 245 | govc host.account.$action -id $username -password "$password" 246 | 247 | echo "Granting Admin permissions for user $username on ${name}..." 248 | govc permissions.set -principal $username -role Admin 249 | 250 | echo "Enabling guest ARP inspection to get vm IPs without vmtools on ${name}..." 251 | govc host.esxcli system settings advanced set -o /Net/GuestIPHack -i 1 252 | 253 | echo "Opening firewall for serial port traffic for ${name}..." 254 | govc host.esxcli network firewall ruleset set -r remoteSerialPort -e true 255 | 256 | echo "Setting hostname for ${name}..." 257 | govc host.esxcli system hostname set -H "$name" 258 | 259 | echo "Enabling MOB for ${name}..." 260 | govc host.option.set Config.HostAgent.plugins.solo.enableMob true 261 | 262 | if which sshpass >/dev/null && [ -e ~/.ssh/id_rsa.pub ] ; then 263 | echo "Adding ssh authorized key to ${name}..." 264 | sshpass -p "$password" scp \ 265 | -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null -oLogLevel=error \ 266 | ~/.ssh/id_rsa.pub "root@$vm_ip:/etc/ssh/keys-root/authorized_keys" 267 | fi 268 | 269 | echo "Done: GOVC_URL=${username}:${password}@${vm_ip}" 270 | -------------------------------------------------------------------------------- /cmdlets/USAGE.md: -------------------------------------------------------------------------------- 1 | # govc usage 2 | 3 | This document is generated from `govc -h` and `govc $cmd -h` commands. 4 | 5 | The following common options are filtered out in this document, 6 | but appear via `govc $cmd -h`: 7 | 8 | ``` 9 | -cert= Certificate [GOVC_CERTIFICATE] 10 | -debug=false Store debug logs [GOVC_DEBUG] 11 | -dump=false Enable output dump 12 | -json=false Enable JSON output 13 | -k=false Skip verification of server certificate [GOVC_INSECURE] 14 | -key= Private key [GOVC_PRIVATE_KEY] 15 | -persist-session=true Persist session to disk [GOVC_PERSIST_SESSION] 16 | -tls-ca-certs= TLS CA certificates file [GOVC_TLS_CA_CERTS] 17 | -tls-known-hosts= TLS known hosts file [GOVC_TLS_KNOWN_HOSTS] 18 | -u= ESX or vCenter URL [GOVC_URL] 19 | -vim-namespace=urn:vim25 Vim namespace [GOVC_VIM_NAMESPACE] 20 | -vim-version=6.0 Vim version [GOVC_VIM_VERSION] 21 | -dc= Datacenter [GOVC_DATACENTER] 22 | -host.dns= Find host by FQDN 23 | -host.ip= Find host by IP address 24 | -host.ipath= Find host by inventory path 25 | -host.uuid= Find host by UUID 26 | -vm.dns= Find VM by FQDN 27 | -vm.ip= Find VM by IP address 28 | -vm.ipath= Find VM by inventory path 29 | -vm.path= Find VM by path to .vmx file 30 | -vm.uuid= Find VM by UUID 31 | ``` 32 | 33 |
Contents 34 | 35 | - [about](#about) 36 | - [about.cert](#aboutcert) 37 | - [cluster.add](#clusteradd) 38 | - [cluster.change](#clusterchange) 39 | - [cluster.create](#clustercreate) 40 | - [cluster.group.change](#clustergroupchange) 41 | - [cluster.group.create](#clustergroupcreate) 42 | - [cluster.group.ls](#clustergroupls) 43 | - [cluster.group.remove](#clustergroupremove) 44 | - [cluster.override.change](#clusteroverridechange) 45 | - [cluster.override.info](#clusteroverrideinfo) 46 | - [cluster.override.remove](#clusteroverrideremove) 47 | - [cluster.rule.change](#clusterrulechange) 48 | - [cluster.rule.create](#clusterrulecreate) 49 | - [cluster.rule.info](#clusterruleinfo) 50 | - [cluster.rule.ls](#clusterrulels) 51 | - [cluster.rule.remove](#clusterruleremove) 52 | - [datacenter.create](#datacentercreate) 53 | - [datacenter.info](#datacenterinfo) 54 | - [datastore.cluster.change](#datastoreclusterchange) 55 | - [datastore.cluster.info](#datastoreclusterinfo) 56 | - [datastore.cp](#datastorecp) 57 | - [datastore.create](#datastorecreate) 58 | - [datastore.disk.create](#datastorediskcreate) 59 | - [datastore.disk.inflate](#datastorediskinflate) 60 | - [datastore.disk.info](#datastorediskinfo) 61 | - [datastore.disk.shrink](#datastorediskshrink) 62 | - [datastore.download](#datastoredownload) 63 | - [datastore.info](#datastoreinfo) 64 | - [datastore.ls](#datastorels) 65 | - [datastore.mkdir](#datastoremkdir) 66 | - [datastore.mv](#datastoremv) 67 | - [datastore.remove](#datastoreremove) 68 | - [datastore.rm](#datastorerm) 69 | - [datastore.tail](#datastoretail) 70 | - [datastore.upload](#datastoreupload) 71 | - [datastore.vsan.dom.ls](#datastorevsandomls) 72 | - [datastore.vsan.dom.rm](#datastorevsandomrm) 73 | - [device.boot](#deviceboot) 74 | - [device.cdrom.add](#devicecdromadd) 75 | - [device.cdrom.eject](#devicecdromeject) 76 | - [device.cdrom.insert](#devicecdrominsert) 77 | - [device.connect](#deviceconnect) 78 | - [device.disconnect](#devicedisconnect) 79 | - [device.floppy.add](#devicefloppyadd) 80 | - [device.floppy.eject](#devicefloppyeject) 81 | - [device.floppy.insert](#devicefloppyinsert) 82 | - [device.info](#deviceinfo) 83 | - [device.ls](#devicels) 84 | - [device.remove](#deviceremove) 85 | - [device.scsi.add](#devicescsiadd) 86 | - [device.serial.add](#deviceserialadd) 87 | - [device.serial.connect](#deviceserialconnect) 88 | - [device.serial.disconnect](#deviceserialdisconnect) 89 | - [device.usb.add](#deviceusbadd) 90 | - [disk.create](#diskcreate) 91 | - [disk.ls](#diskls) 92 | - [disk.register](#diskregister) 93 | - [disk.rm](#diskrm) 94 | - [disk.snapshot.create](#disksnapshotcreate) 95 | - [disk.snapshot.ls](#disksnapshotls) 96 | - [disk.snapshot.rm](#disksnapshotrm) 97 | - [disk.tags.attach](#disktagsattach) 98 | - [disk.tags.detach](#disktagsdetach) 99 | - [dvs.add](#dvsadd) 100 | - [dvs.create](#dvscreate) 101 | - [dvs.portgroup.add](#dvsportgroupadd) 102 | - [dvs.portgroup.change](#dvsportgroupchange) 103 | - [dvs.portgroup.info](#dvsportgroupinfo) 104 | - [env](#env) 105 | - [events](#events) 106 | - [export.ovf](#exportovf) 107 | - [extension.info](#extensioninfo) 108 | - [extension.register](#extensionregister) 109 | - [extension.setcert](#extensionsetcert) 110 | - [extension.unregister](#extensionunregister) 111 | - [fields.add](#fieldsadd) 112 | - [fields.info](#fieldsinfo) 113 | - [fields.ls](#fieldsls) 114 | - [fields.rename](#fieldsrename) 115 | - [fields.rm](#fieldsrm) 116 | - [fields.set](#fieldsset) 117 | - [find](#find) 118 | - [firewall.ruleset.find](#firewallrulesetfind) 119 | - [folder.create](#foldercreate) 120 | - [folder.info](#folderinfo) 121 | - [guest.chmod](#guestchmod) 122 | - [guest.chown](#guestchown) 123 | - [guest.download](#guestdownload) 124 | - [guest.getenv](#guestgetenv) 125 | - [guest.kill](#guestkill) 126 | - [guest.ls](#guestls) 127 | - [guest.mkdir](#guestmkdir) 128 | - [guest.mktemp](#guestmktemp) 129 | - [guest.mv](#guestmv) 130 | - [guest.ps](#guestps) 131 | - [guest.rm](#guestrm) 132 | - [guest.rmdir](#guestrmdir) 133 | - [guest.run](#guestrun) 134 | - [guest.start](#gueststart) 135 | - [guest.touch](#guesttouch) 136 | - [guest.upload](#guestupload) 137 | - [host.account.create](#hostaccountcreate) 138 | - [host.account.remove](#hostaccountremove) 139 | - [host.account.update](#hostaccountupdate) 140 | - [host.add](#hostadd) 141 | - [host.autostart.add](#hostautostartadd) 142 | - [host.autostart.configure](#hostautostartconfigure) 143 | - [host.autostart.info](#hostautostartinfo) 144 | - [host.autostart.remove](#hostautostartremove) 145 | - [host.cert.csr](#hostcertcsr) 146 | - [host.cert.import](#hostcertimport) 147 | - [host.cert.info](#hostcertinfo) 148 | - [host.date.change](#hostdatechange) 149 | - [host.date.info](#hostdateinfo) 150 | - [host.disconnect](#hostdisconnect) 151 | - [host.esxcli](#hostesxcli) 152 | - [host.info](#hostinfo) 153 | - [host.maintenance.enter](#hostmaintenanceenter) 154 | - [host.maintenance.exit](#hostmaintenanceexit) 155 | - [host.option.ls](#hostoptionls) 156 | - [host.option.set](#hostoptionset) 157 | - [host.portgroup.add](#hostportgroupadd) 158 | - [host.portgroup.change](#hostportgroupchange) 159 | - [host.portgroup.info](#hostportgroupinfo) 160 | - [host.portgroup.remove](#hostportgroupremove) 161 | - [host.reconnect](#hostreconnect) 162 | - [host.remove](#hostremove) 163 | - [host.service](#hostservice) 164 | - [host.service.ls](#hostservicels) 165 | - [host.shutdown](#hostshutdown) 166 | - [host.storage.info](#hoststorageinfo) 167 | - [host.storage.mark](#hoststoragemark) 168 | - [host.storage.partition](#hoststoragepartition) 169 | - [host.vnic.info](#hostvnicinfo) 170 | - [host.vnic.service](#hostvnicservice) 171 | - [host.vswitch.add](#hostvswitchadd) 172 | - [host.vswitch.info](#hostvswitchinfo) 173 | - [host.vswitch.remove](#hostvswitchremove) 174 | - [import.ova](#importova) 175 | - [import.ovf](#importovf) 176 | - [import.spec](#importspec) 177 | - [import.vmdk](#importvmdk) 178 | - [license.add](#licenseadd) 179 | - [license.assign](#licenseassign) 180 | - [license.assigned.ls](#licenseassignedls) 181 | - [license.decode](#licensedecode) 182 | - [license.label.set](#licenselabelset) 183 | - [license.ls](#licensels) 184 | - [license.remove](#licenseremove) 185 | - [logs](#logs) 186 | - [logs.download](#logsdownload) 187 | - [logs.ls](#logsls) 188 | - [ls](#ls) 189 | - [metric.change](#metricchange) 190 | - [metric.info](#metricinfo) 191 | - [metric.interval.change](#metricintervalchange) 192 | - [metric.interval.info](#metricintervalinfo) 193 | - [metric.ls](#metricls) 194 | - [metric.reset](#metricreset) 195 | - [metric.sample](#metricsample) 196 | - [object.collect](#objectcollect) 197 | - [object.destroy](#objectdestroy) 198 | - [object.method](#objectmethod) 199 | - [object.mv](#objectmv) 200 | - [object.reload](#objectreload) 201 | - [object.rename](#objectrename) 202 | - [option.ls](#optionls) 203 | - [option.set](#optionset) 204 | - [permissions.ls](#permissionsls) 205 | - [permissions.remove](#permissionsremove) 206 | - [permissions.set](#permissionsset) 207 | - [pool.change](#poolchange) 208 | - [pool.create](#poolcreate) 209 | - [pool.destroy](#pooldestroy) 210 | - [pool.info](#poolinfo) 211 | - [role.create](#rolecreate) 212 | - [role.ls](#rolels) 213 | - [role.remove](#roleremove) 214 | - [role.update](#roleupdate) 215 | - [role.usage](#roleusage) 216 | - [session.login](#sessionlogin) 217 | - [session.logout](#sessionlogout) 218 | - [session.ls](#sessionls) 219 | - [session.rm](#sessionrm) 220 | - [snapshot.create](#snapshotcreate) 221 | - [snapshot.remove](#snapshotremove) 222 | - [snapshot.revert](#snapshotrevert) 223 | - [snapshot.tree](#snapshottree) 224 | - [sso.service.ls](#ssoservicels) 225 | - [sso.user.create](#ssousercreate) 226 | - [sso.user.id](#ssouserid) 227 | - [sso.user.ls](#ssouserls) 228 | - [sso.user.rm](#ssouserrm) 229 | - [sso.user.update](#ssouserupdate) 230 | - [tags.attach](#tagsattach) 231 | - [tags.attached.ls](#tagsattachedls) 232 | - [tags.category.create](#tagscategorycreate) 233 | - [tags.category.info](#tagscategoryinfo) 234 | - [tags.category.ls](#tagscategoryls) 235 | - [tags.category.rm](#tagscategoryrm) 236 | - [tags.category.update](#tagscategoryupdate) 237 | - [tags.create](#tagscreate) 238 | - [tags.detach](#tagsdetach) 239 | - [tags.info](#tagsinfo) 240 | - [tags.ls](#tagsls) 241 | - [tags.rm](#tagsrm) 242 | - [tags.update](#tagsupdate) 243 | - [task.cancel](#taskcancel) 244 | - [tasks](#tasks) 245 | - [vapp.destroy](#vappdestroy) 246 | - [vapp.power](#vapppower) 247 | - [version](#version) 248 | - [vm.change](#vmchange) 249 | - [vm.clone](#vmclone) 250 | - [vm.console](#vmconsole) 251 | - [vm.create](#vmcreate) 252 | - [vm.destroy](#vmdestroy) 253 | - [vm.disk.attach](#vmdiskattach) 254 | - [vm.disk.change](#vmdiskchange) 255 | - [vm.disk.create](#vmdiskcreate) 256 | - [vm.guest.tools](#vmguesttools) 257 | - [vm.info](#vminfo) 258 | - [vm.ip](#vmip) 259 | - [vm.keystrokes](#vmkeystrokes) 260 | - [vm.markastemplate](#vmmarkastemplate) 261 | - [vm.markasvm](#vmmarkasvm) 262 | - [vm.migrate](#vmmigrate) 263 | - [vm.network.add](#vmnetworkadd) 264 | - [vm.network.change](#vmnetworkchange) 265 | - [vm.option.info](#vmoptioninfo) 266 | - [vm.power](#vmpower) 267 | - [vm.question](#vmquestion) 268 | - [vm.rdm.attach](#vmrdmattach) 269 | - [vm.rdm.ls](#vmrdmls) 270 | - [vm.register](#vmregister) 271 | - [vm.unregister](#vmunregister) 272 | - [vm.upgrade](#vmupgrade) 273 | - [vm.vnc](#vmvnc) 274 | 275 |
276 | 277 | ## about 278 | 279 | ``` 280 | Usage: govc about [OPTIONS] 281 | 282 | Display About info for HOST. 283 | 284 | System information including the name, type, version, and build number. 285 | 286 | Examples: 287 | govc about 288 | govc about -json | jq -r .About.ProductLineId 289 | 290 | Options: 291 | -l=false Include service content 292 | ``` 293 | 294 | ## about.cert 295 | 296 | ``` 297 | Usage: govc about.cert [OPTIONS] 298 | 299 | Display TLS certificate info for HOST. 300 | 301 | If the HOST certificate cannot be verified, about.cert will return with exit code 60 (as curl does). 302 | If the '-k' flag is provided, about.cert will return with exit code 0 in this case. 303 | The SHA1 thumbprint can also be used as '-thumbprint' for the 'host.add' and 'cluster.add' commands. 304 | 305 | Examples: 306 | govc about.cert -k -json | jq -r .ThumbprintSHA1 307 | govc about.cert -k -show | sudo tee /usr/local/share/ca-certificates/host.crt 308 | govc about.cert -k -thumbprint | tee -a ~/.govmomi/known_hosts 309 | 310 | Options: 311 | -show=false Show PEM encoded server certificate only 312 | -thumbprint=false Output host hash and thumbprint only 313 | ``` 314 | 315 | ## cluster.add 316 | 317 | ``` 318 | Usage: govc cluster.add [OPTIONS] 319 | 320 | Add HOST to CLUSTER. 321 | 322 | The host is added to the cluster specified by the 'cluster' flag. 323 | 324 | Examples: 325 | thumbprint=$(govc about.cert -k -u host.example.com -thumbprint | awk '{print $2}') 326 | govc cluster.add -cluster ClusterA -hostname host.example.com -username root -password pass -thumbprint $thumbprint 327 | govc cluster.add -cluster ClusterB -hostname 10.0.6.1 -username root -password pass -noverify 328 | 329 | Options: 330 | -cluster= Cluster [GOVC_CLUSTER] 331 | -connect=true Immediately connect to host 332 | -force=false Force when host is managed by another VC 333 | -hostname= Hostname or IP address of the host 334 | -license= Assign license key 335 | -noverify=false Accept host thumbprint without verification 336 | -password= Password of administration account on the host 337 | -thumbprint= SHA-1 thumbprint of the host's SSL certificate 338 | -username= Username of administration account on the host 339 | ``` 340 | 341 | ## cluster.change 342 | 343 | ``` 344 | Usage: govc cluster.change [OPTIONS] CLUSTER... 345 | 346 | Change configuration of the given clusters. 347 | 348 | Examples: 349 | govc cluster.change -drs-enabled -vsan-enabled -vsan-autoclaim ClusterA 350 | govc cluster.change -drs-enabled=false ClusterB 351 | 352 | Options: 353 | -drs-enabled= Enable DRS 354 | -drs-mode= DRS behavior for virtual machines: manual, partiallyAutomated, fullyAutomated 355 | -ha-enabled= Enable HA 356 | -vsan-autoclaim= Autoclaim storage on cluster hosts 357 | -vsan-enabled= Enable vSAN 358 | ``` 359 | 360 | ## cluster.create 361 | 362 | ``` 363 | Usage: govc cluster.create [OPTIONS] CLUSTER 364 | 365 | Create CLUSTER in datacenter. 366 | 367 | The cluster is added to the folder specified by the 'folder' flag. If not given, 368 | this defaults to the host folder in the specified or default datacenter. 369 | 370 | Examples: 371 | govc cluster.create ClusterA 372 | govc cluster.create -folder /dc2/test-folder ClusterB 373 | 374 | Options: 375 | -folder= Inventory folder [GOVC_FOLDER] 376 | ``` 377 | 378 | ## cluster.group.change 379 | 380 | ``` 381 | Usage: govc cluster.group.change [OPTIONS] NAME... 382 | 383 | Set cluster group members. 384 | 385 | Examples: 386 | govc cluster.group.change -name my_group vm_a vm_b vm_c # set 387 | govc cluster.group.change -name my_group vm_a vm_b vm_c $(govc cluster.group.ls -name my_group) vm_d # add 388 | govc cluster.group.ls -name my_group | grep -v vm_b | xargs govc cluster.group.change -name my_group vm_a vm_b vm_c # remove 389 | 390 | Options: 391 | -cluster= Cluster [GOVC_CLUSTER] 392 | -name= Cluster group name 393 | ``` 394 | 395 | ## cluster.group.create 396 | 397 | ``` 398 | Usage: govc cluster.group.create [OPTIONS] 399 | 400 | Create cluster group. 401 | 402 | One of '-vm' or '-host' must be provided to specify the group type. 403 | 404 | Examples: 405 | govc cluster.group.create -name my_vm_group -vm vm_a vm_b vm_c 406 | govc cluster.group.create -name my_host_group -host host_a host_b host_c 407 | 408 | Options: 409 | -cluster= Cluster [GOVC_CLUSTER] 410 | -host=false Create cluster Host group 411 | -name= Cluster group name 412 | -vm=false Create cluster VM group 413 | ``` 414 | 415 | ## cluster.group.ls 416 | 417 | ``` 418 | Usage: govc cluster.group.ls [OPTIONS] 419 | 420 | List cluster groups and group members. 421 | 422 | Examples: 423 | govc cluster.group.ls -cluster my_cluster 424 | govc cluster.group.ls -cluster my_cluster -name my_group 425 | 426 | Options: 427 | -cluster= Cluster [GOVC_CLUSTER] 428 | -name= Cluster group name 429 | ``` 430 | 431 | ## cluster.group.remove 432 | 433 | ``` 434 | Usage: govc cluster.group.remove [OPTIONS] 435 | 436 | Remove cluster group. 437 | 438 | Examples: 439 | govc cluster.group.remove -cluster my_cluster -name my_group 440 | 441 | Options: 442 | -cluster= Cluster [GOVC_CLUSTER] 443 | -name= Cluster group name 444 | ``` 445 | 446 | ## cluster.override.change 447 | 448 | ``` 449 | Usage: govc cluster.override.change [OPTIONS] 450 | 451 | Change cluster VM overrides. 452 | 453 | Examples: 454 | govc cluster.override.change -cluster cluster_1 -vm vm_1 -ha-restart-priority high 455 | govc cluster.override.change -cluster cluster_1 -vm vm_2 -drs-enabled=false 456 | govc cluster.override.change -cluster cluster_1 -vm vm_3 -drs-enabled -drs-mode fullyAutomated 457 | 458 | Options: 459 | -cluster= Cluster [GOVC_CLUSTER] 460 | -drs-enabled= Enable DRS 461 | -drs-mode= DRS behavior for virtual machines: manual, partiallyAutomated, fullyAutomated 462 | -ha-restart-priority= HA restart priority: disabled, low, medium, high 463 | -vm= Virtual machine [GOVC_VM] 464 | ``` 465 | 466 | ## cluster.override.info 467 | 468 | ``` 469 | Usage: govc cluster.override.info [OPTIONS] 470 | 471 | Cluster VM overrides info. 472 | 473 | Examples: 474 | govc cluster.override.info 475 | govc cluster.override.info -json 476 | 477 | Options: 478 | -cluster= Cluster [GOVC_CLUSTER] 479 | ``` 480 | 481 | ## cluster.override.remove 482 | 483 | ``` 484 | Usage: govc cluster.override.remove [OPTIONS] 485 | 486 | Remove cluster VM overrides. 487 | 488 | Examples: 489 | govc cluster.override.remove -cluster cluster_1 -vm vm_1 490 | 491 | Options: 492 | -cluster= Cluster [GOVC_CLUSTER] 493 | -vm= Virtual machine [GOVC_VM] 494 | ``` 495 | 496 | ## cluster.rule.change 497 | 498 | ``` 499 | Usage: govc cluster.rule.change [OPTIONS] NAME... 500 | 501 | Change cluster rule. 502 | 503 | Examples: 504 | govc cluster.rule.change -cluster my_cluster -name my_rule -enable=false 505 | 506 | Options: 507 | -cluster= Cluster [GOVC_CLUSTER] 508 | -enable= Enable rule 509 | -host-affine-group= Host affine group name 510 | -host-anti-affine-group= Host anti-affine group name 511 | -l=false Long listing format 512 | -mandatory= Enforce rule compliance 513 | -name= Cluster rule name 514 | -vm-group= VM group name 515 | ``` 516 | 517 | ## cluster.rule.create 518 | 519 | ``` 520 | Usage: govc cluster.rule.create [OPTIONS] NAME... 521 | 522 | Create cluster rule. 523 | 524 | Rules are not enabled by default, use the 'enable' flag to enable upon creation or cluster.rule.change after creation. 525 | 526 | One of '-affinity', '-anti-affinity', '-depends' or '-vm-host' must be provided to specify the rule type. 527 | 528 | With '-affinity' or '-anti-affinity', at least 2 vm NAME arguments must be specified. 529 | 530 | With '-depends', vm group NAME and vm group dependency NAME arguments must be specified. 531 | 532 | With '-vm-host', use the '-vm-group' flag combined with the '-host-affine-group' and/or '-host-anti-affine-group' flags. 533 | 534 | Examples: 535 | govc cluster.rule.create -name pod1 -enable -affinity vm_a vm_b vm_c 536 | govc cluster.rule.create -name pod2 -enable -anti-affinity vm_d vm_e vm_f 537 | govc cluster.rule.create -name pod3 -enable -mandatory -vm-host -vm-group my_vms -host-affine-group my_hosts 538 | govc cluster.rule.create -name pod4 -depends vm_group_app vm_group_db 539 | 540 | Options: 541 | -affinity=false Keep Virtual Machines Together 542 | -anti-affinity=false Separate Virtual Machines 543 | -cluster= Cluster [GOVC_CLUSTER] 544 | -depends=false Virtual Machines to Virtual Machines 545 | -enable= Enable rule 546 | -host-affine-group= Host affine group name 547 | -host-anti-affine-group= Host anti-affine group name 548 | -l=false Long listing format 549 | -mandatory= Enforce rule compliance 550 | -name= Cluster rule name 551 | -vm-group= VM group name 552 | -vm-host=false Virtual Machines to Hosts 553 | ``` 554 | 555 | ## cluster.rule.info 556 | 557 | ``` 558 | Usage: govc cluster.rule.info [OPTIONS] 559 | 560 | Provides detailed infos about cluster rules, their types and rule members. 561 | 562 | Examples: 563 | govc cluster.rule.info -cluster my_cluster 564 | govc cluster.rule.info -cluster my_cluster -name my_rule 565 | 566 | Options: 567 | -cluster= Cluster [GOVC_CLUSTER] 568 | -l=false Long listing format 569 | -name= Cluster rule name 570 | ``` 571 | 572 | ## cluster.rule.ls 573 | 574 | ``` 575 | Usage: govc cluster.rule.ls [OPTIONS] 576 | 577 | List cluster rules and rule members. 578 | 579 | Examples: 580 | govc cluster.rule.ls -cluster my_cluster 581 | govc cluster.rule.ls -cluster my_cluster -name my_rule 582 | govc cluster.rule.ls -cluster my_cluster -l 583 | govc cluster.rule.ls -cluster my_cluster -name my_rule -l 584 | 585 | Options: 586 | -cluster= Cluster [GOVC_CLUSTER] 587 | -l=false Long listing format 588 | -name= Cluster rule name 589 | ``` 590 | 591 | ## cluster.rule.remove 592 | 593 | ``` 594 | Usage: govc cluster.rule.remove [OPTIONS] 595 | 596 | Remove cluster rule. 597 | 598 | Examples: 599 | govc cluster.group.remove -cluster my_cluster -name my_rule 600 | 601 | Options: 602 | -cluster= Cluster [GOVC_CLUSTER] 603 | -l=false Long listing format 604 | -name= Cluster rule name 605 | ``` 606 | 607 | ## datacenter.create 608 | 609 | ``` 610 | Usage: govc datacenter.create [OPTIONS] NAME... 611 | 612 | Options: 613 | -folder= Inventory folder [GOVC_FOLDER] 614 | ``` 615 | 616 | ## datacenter.info 617 | 618 | ``` 619 | Usage: govc datacenter.info [OPTIONS] [PATH]... 620 | 621 | Options: 622 | ``` 623 | 624 | ## datastore.cluster.change 625 | 626 | ``` 627 | Usage: govc datastore.cluster.change [OPTIONS] CLUSTER... 628 | 629 | Change configuration of the given datastore clusters. 630 | 631 | Examples: 632 | govc datastore.cluster.change -drs-enabled ClusterA 633 | govc datastore.cluster.change -drs-enabled=false ClusterB 634 | 635 | Options: 636 | -drs-enabled= Enable Storage DRS 637 | -drs-mode= Storage DRS behavior: manual, automated 638 | ``` 639 | 640 | ## datastore.cluster.info 641 | 642 | ``` 643 | Usage: govc datastore.cluster.info [OPTIONS] [PATH]... 644 | 645 | Options: 646 | ``` 647 | 648 | ## datastore.cp 649 | 650 | ``` 651 | Usage: govc datastore.cp [OPTIONS] SRC DST 652 | 653 | Copy SRC to DST on DATASTORE. 654 | 655 | Examples: 656 | govc datastore.cp foo/foo.vmx foo/foo.vmx.old 657 | govc datastore.cp -f my.vmx foo/foo.vmx 658 | govc datastore.cp disks/disk1.vmdk disks/disk2.vmdk 659 | govc datastore.cp disks/disk1.vmdk -dc-target DC2 disks/disk2.vmdk 660 | govc datastore.cp disks/disk1.vmdk -ds-target NFS-2 disks/disk2.vmdk 661 | 662 | Options: 663 | -dc-target= Datacenter destination (defaults to -dc) 664 | -ds= Datastore [GOVC_DATASTORE] 665 | -ds-target= Datastore destination (defaults to -ds) 666 | -f=false If true, overwrite any identically named file at the destination 667 | -t=true Use file type to choose disk or file manager 668 | ``` 669 | 670 | ## datastore.create 671 | 672 | ``` 673 | Usage: govc datastore.create [OPTIONS] HOST... 674 | 675 | Create datastore on HOST. 676 | 677 | Examples: 678 | govc datastore.create -type nfs -name nfsDatastore -remote-host 10.143.2.232 -remote-path /share cluster1 679 | govc datastore.create -type vmfs -name vmfsDatastore -disk=mpx.vmhba0:C0:T0:L0 cluster1 680 | govc datastore.create -type local -name localDatastore -path /var/datastore host1 681 | 682 | Options: 683 | -disk= Canonical name of disk (VMFS only) 684 | -force=false Ignore DuplicateName error if datastore is already mounted on a host 685 | -host= Host system [GOVC_HOST] 686 | -mode=readOnly Access mode for the mount point (readOnly|readWrite) 687 | -name= Datastore name 688 | -password= Password to use when connecting (CIFS only) 689 | -path= Local directory path for the datastore (local only) 690 | -remote-host= Remote hostname of the NAS datastore 691 | -remote-path= Remote path of the NFS mount point 692 | -type= Datastore type (NFS|NFS41|CIFS|VMFS|local) 693 | -username= Username to use when connecting (CIFS only) 694 | ``` 695 | 696 | ## datastore.disk.create 697 | 698 | ``` 699 | Usage: govc datastore.disk.create [OPTIONS] VMDK 700 | 701 | Create VMDK on DS. 702 | 703 | Examples: 704 | govc datastore.mkdir disks 705 | govc datastore.disk.create -size 24G disks/disk1.vmdk 706 | govc datastore.disk.create disks/parent.vmdk disk/child.vmdk 707 | 708 | Options: 709 | -a=lsiLogic Disk adapter 710 | -d=thin Disk format 711 | -ds= Datastore [GOVC_DATASTORE] 712 | -f=false Force 713 | -size=10.0GB Size of new disk 714 | -uuid= Disk UUID 715 | ``` 716 | 717 | ## datastore.disk.inflate 718 | 719 | ``` 720 | Usage: govc datastore.disk.inflate [OPTIONS] VMDK 721 | 722 | Inflate VMDK on DS. 723 | 724 | Examples: 725 | govc datastore.disk.inflate disks/disk1.vmdk 726 | 727 | Options: 728 | -ds= Datastore [GOVC_DATASTORE] 729 | ``` 730 | 731 | ## datastore.disk.info 732 | 733 | ``` 734 | Usage: govc datastore.disk.info [OPTIONS] VMDK 735 | 736 | Query VMDK info on DS. 737 | 738 | Examples: 739 | govc datastore.disk.info disks/disk1.vmdk 740 | 741 | Options: 742 | -c=false Chain format 743 | -d=false Include datastore in output 744 | -ds= Datastore [GOVC_DATASTORE] 745 | -p=true Include parents 746 | -uuid=false Include disk UUID 747 | ``` 748 | 749 | ## datastore.disk.shrink 750 | 751 | ``` 752 | Usage: govc datastore.disk.shrink [OPTIONS] VMDK 753 | 754 | Shrink VMDK on DS. 755 | 756 | Examples: 757 | govc datastore.disk.shrink disks/disk1.vmdk 758 | 759 | Options: 760 | -copy= Perform shrink in-place mode if false, copy-shrink mode otherwise 761 | -ds= Datastore [GOVC_DATASTORE] 762 | ``` 763 | 764 | ## datastore.download 765 | 766 | ``` 767 | Usage: govc datastore.download [OPTIONS] SOURCE DEST 768 | 769 | Copy SOURCE from DS to DEST on the local system. 770 | 771 | If DEST name is "-", source is written to stdout. 772 | 773 | Examples: 774 | govc datastore.download vm-name/vmware.log ./local.log 775 | govc datastore.download vm-name/vmware.log - | grep -i error 776 | 777 | Options: 778 | -ds= Datastore [GOVC_DATASTORE] 779 | -host= Host system [GOVC_HOST] 780 | ``` 781 | 782 | ## datastore.info 783 | 784 | ``` 785 | Usage: govc datastore.info [OPTIONS] [PATH]... 786 | 787 | Options: 788 | ``` 789 | 790 | ## datastore.ls 791 | 792 | ``` 793 | Usage: govc datastore.ls [OPTIONS] [FILE]... 794 | 795 | Options: 796 | -R=false List subdirectories recursively 797 | -a=false Do not ignore entries starting with . 798 | -ds= Datastore [GOVC_DATASTORE] 799 | -l=false Long listing format 800 | -p=false Append / indicator to directories 801 | ``` 802 | 803 | ## datastore.mkdir 804 | 805 | ``` 806 | Usage: govc datastore.mkdir [OPTIONS] DIRECTORY 807 | 808 | Options: 809 | -ds= Datastore [GOVC_DATASTORE] 810 | -namespace=false Return uuid of namespace created on vsan datastore 811 | -p=false Create intermediate directories as needed 812 | ``` 813 | 814 | ## datastore.mv 815 | 816 | ``` 817 | Usage: govc datastore.mv [OPTIONS] SRC DST 818 | 819 | Move SRC to DST on DATASTORE. 820 | 821 | Examples: 822 | govc datastore.mv foo/foo.vmx foo/foo.vmx.old 823 | govc datastore.mv -f my.vmx foo/foo.vmx 824 | 825 | Options: 826 | -dc-target= Datacenter destination (defaults to -dc) 827 | -ds= Datastore [GOVC_DATASTORE] 828 | -ds-target= Datastore destination (defaults to -ds) 829 | -f=false If true, overwrite any identically named file at the destination 830 | -t=true Use file type to choose disk or file manager 831 | ``` 832 | 833 | ## datastore.remove 834 | 835 | ``` 836 | Usage: govc datastore.remove [OPTIONS] HOST... 837 | 838 | Remove datastore from HOST. 839 | 840 | Examples: 841 | govc datastore.remove -ds nfsDatastore cluster1 842 | govc datastore.remove -ds nasDatastore host1 host2 host3 843 | 844 | Options: 845 | -ds= Datastore [GOVC_DATASTORE] 846 | -host= Host system [GOVC_HOST] 847 | ``` 848 | 849 | ## datastore.rm 850 | 851 | ``` 852 | Usage: govc datastore.rm [OPTIONS] FILE 853 | 854 | Remove FILE from DATASTORE. 855 | 856 | Examples: 857 | govc datastore.rm vm/vmware.log 858 | govc datastore.rm vm 859 | govc datastore.rm -f images/base.vmdk 860 | 861 | Options: 862 | -ds= Datastore [GOVC_DATASTORE] 863 | -f=false Force; ignore nonexistent files and arguments 864 | -namespace=false Path is uuid of namespace on vsan datastore 865 | -t=true Use file type to choose disk or file manager 866 | ``` 867 | 868 | ## datastore.tail 869 | 870 | ``` 871 | Usage: govc datastore.tail [OPTIONS] PATH 872 | 873 | Output the last part of datastore files. 874 | 875 | Examples: 876 | govc datastore.tail -n 100 vm-name/vmware.log 877 | govc datastore.tail -n 0 -f vm-name/vmware.log 878 | 879 | Options: 880 | -c=-1 Output the last NUM bytes 881 | -ds= Datastore [GOVC_DATASTORE] 882 | -f=false Output appended data as the file grows 883 | -host= Host system [GOVC_HOST] 884 | -n=10 Output the last NUM lines 885 | ``` 886 | 887 | ## datastore.upload 888 | 889 | ``` 890 | Usage: govc datastore.upload [OPTIONS] SOURCE DEST 891 | 892 | Copy SOURCE from the local system to DEST on DS. 893 | 894 | If SOURCE name is "-", read source from stdin. 895 | 896 | Examples: 897 | govc datastore.upload -ds datastore1 ./config.iso vm-name/config.iso 898 | genisoimage ... | govc datastore.upload -ds datastore1 - vm-name/config.iso 899 | 900 | Options: 901 | -ds= Datastore [GOVC_DATASTORE] 902 | ``` 903 | 904 | ## datastore.vsan.dom.ls 905 | 906 | ``` 907 | Usage: govc datastore.vsan.dom.ls [OPTIONS] [UUID]... 908 | 909 | List vSAN DOM objects in DS. 910 | 911 | Examples: 912 | govc datastore.vsan.dom.ls 913 | govc datastore.vsan.dom.ls -ds vsanDatastore -l 914 | govc datastore.vsan.dom.ls -l d85aa758-63f5-500a-3150-0200308e589c 915 | 916 | Options: 917 | -ds= Datastore [GOVC_DATASTORE] 918 | -l=false Long listing 919 | -o=false List orphan objects 920 | ``` 921 | 922 | ## datastore.vsan.dom.rm 923 | 924 | ``` 925 | Usage: govc datastore.vsan.dom.rm [OPTIONS] UUID... 926 | 927 | Remove vSAN DOM objects in DS. 928 | 929 | Examples: 930 | govc datastore.vsan.dom.rm d85aa758-63f5-500a-3150-0200308e589c 931 | govc datastore.vsan.dom.rm -f d85aa758-63f5-500a-3150-0200308e589c 932 | govc datastore.vsan.dom.ls -o | xargs govc datastore.vsan.dom.rm 933 | 934 | Options: 935 | -ds= Datastore [GOVC_DATASTORE] 936 | -f=false Force delete 937 | -v=false Print deleted UUIDs to stdout, failed to stderr 938 | ``` 939 | 940 | ## device.boot 941 | 942 | ``` 943 | Usage: govc device.boot [OPTIONS] 944 | 945 | Configure VM boot settings. 946 | 947 | Examples: 948 | govc device.boot -vm $vm -delay 1000 -order floppy,cdrom,ethernet,disk 949 | govc device.boot -vm $vm -order - # reset boot order 950 | 951 | Options: 952 | -delay=0 Delay in ms before starting the boot sequence 953 | -order= Boot device order [-,floppy,cdrom,ethernet,disk] 954 | -retry=false If true, retry boot after retry-delay 955 | -retry-delay=0 Delay in ms before a boot retry 956 | -setup=false If true, enter BIOS setup on next boot 957 | -vm= Virtual machine [GOVC_VM] 958 | ``` 959 | 960 | ## device.cdrom.add 961 | 962 | ``` 963 | Usage: govc device.cdrom.add [OPTIONS] 964 | 965 | Add CD-ROM device to VM. 966 | 967 | Examples: 968 | govc device.cdrom.add -vm $vm 969 | govc device.ls -vm $vm | grep ide- 970 | govc device.cdrom.add -vm $vm -controller ide-200 971 | govc device.info cdrom-* 972 | 973 | Options: 974 | -controller= IDE controller name 975 | -vm= Virtual machine [GOVC_VM] 976 | ``` 977 | 978 | ## device.cdrom.eject 979 | 980 | ``` 981 | Usage: govc device.cdrom.eject [OPTIONS] 982 | 983 | Eject media from CD-ROM device. 984 | 985 | If device is not specified, the first CD-ROM device is used. 986 | 987 | Examples: 988 | govc device.cdrom.eject -vm vm-1 989 | govc device.cdrom.eject -vm vm-1 -device floppy-1 990 | 991 | Options: 992 | -device= CD-ROM device name 993 | -vm= Virtual machine [GOVC_VM] 994 | ``` 995 | 996 | ## device.cdrom.insert 997 | 998 | ``` 999 | Usage: govc device.cdrom.insert [OPTIONS] ISO 1000 | 1001 | Insert media on datastore into CD-ROM device. 1002 | 1003 | If device is not specified, the first CD-ROM device is used. 1004 | 1005 | Examples: 1006 | govc device.cdrom.insert -vm vm-1 -device cdrom-3000 images/boot.iso 1007 | 1008 | Options: 1009 | -device= CD-ROM device name 1010 | -ds= Datastore [GOVC_DATASTORE] 1011 | -vm= Virtual machine [GOVC_VM] 1012 | ``` 1013 | 1014 | ## device.connect 1015 | 1016 | ``` 1017 | Usage: govc device.connect [OPTIONS] DEVICE... 1018 | 1019 | Connect DEVICE on VM. 1020 | 1021 | Examples: 1022 | govc device.connect -vm $name cdrom-3000 1023 | 1024 | Options: 1025 | -vm= Virtual machine [GOVC_VM] 1026 | ``` 1027 | 1028 | ## device.disconnect 1029 | 1030 | ``` 1031 | Usage: govc device.disconnect [OPTIONS] DEVICE... 1032 | 1033 | Disconnect DEVICE on VM. 1034 | 1035 | Examples: 1036 | govc device.disconnect -vm $name cdrom-3000 1037 | 1038 | Options: 1039 | -vm= Virtual machine [GOVC_VM] 1040 | ``` 1041 | 1042 | ## device.floppy.add 1043 | 1044 | ``` 1045 | Usage: govc device.floppy.add [OPTIONS] 1046 | 1047 | Add floppy device to VM. 1048 | 1049 | Examples: 1050 | govc device.floppy.add -vm $vm 1051 | govc device.info floppy-* 1052 | 1053 | Options: 1054 | -vm= Virtual machine [GOVC_VM] 1055 | ``` 1056 | 1057 | ## device.floppy.eject 1058 | 1059 | ``` 1060 | Usage: govc device.floppy.eject [OPTIONS] 1061 | 1062 | Eject image from floppy device. 1063 | 1064 | If device is not specified, the first floppy device is used. 1065 | 1066 | Examples: 1067 | govc device.floppy.eject -vm vm-1 1068 | 1069 | Options: 1070 | -device= Floppy device name 1071 | -vm= Virtual machine [GOVC_VM] 1072 | ``` 1073 | 1074 | ## device.floppy.insert 1075 | 1076 | ``` 1077 | Usage: govc device.floppy.insert [OPTIONS] IMG 1078 | 1079 | Insert IMG on datastore into floppy device. 1080 | 1081 | If device is not specified, the first floppy device is used. 1082 | 1083 | Examples: 1084 | govc device.floppy.insert -vm vm-1 vm-1/config.img 1085 | 1086 | Options: 1087 | -device= Floppy device name 1088 | -ds= Datastore [GOVC_DATASTORE] 1089 | -vm= Virtual machine [GOVC_VM] 1090 | ``` 1091 | 1092 | ## device.info 1093 | 1094 | ``` 1095 | Usage: govc device.info [OPTIONS] [DEVICE]... 1096 | 1097 | Device info for VM. 1098 | 1099 | Examples: 1100 | govc device.info -vm $name 1101 | govc device.info -vm $name disk-* 1102 | govc device.info -vm $name -json ethernet-0 | jq -r .Devices[].MacAddress 1103 | 1104 | Options: 1105 | -net= Network [GOVC_NETWORK] 1106 | -net.adapter=e1000 Network adapter type 1107 | -net.address= Network hardware address 1108 | -vm= Virtual machine [GOVC_VM] 1109 | ``` 1110 | 1111 | ## device.ls 1112 | 1113 | ``` 1114 | Usage: govc device.ls [OPTIONS] 1115 | 1116 | List devices for VM. 1117 | 1118 | Examples: 1119 | govc device.ls -vm $name 1120 | govc device.ls -vm $name disk-* 1121 | govc device.ls -vm $name -json | jq '.Devices[].Name' 1122 | 1123 | Options: 1124 | -boot=false List devices configured in the VM's boot options 1125 | -vm= Virtual machine [GOVC_VM] 1126 | ``` 1127 | 1128 | ## device.remove 1129 | 1130 | ``` 1131 | Usage: govc device.remove [OPTIONS] DEVICE... 1132 | 1133 | Remove DEVICE from VM. 1134 | 1135 | Examples: 1136 | govc device.remove -vm $name cdrom-3000 1137 | govc device.remove -vm $name disk-1000 1138 | govc device.remove -vm $name -keep disk-* 1139 | 1140 | Options: 1141 | -keep=false Keep files in datastore 1142 | -vm= Virtual machine [GOVC_VM] 1143 | ``` 1144 | 1145 | ## device.scsi.add 1146 | 1147 | ``` 1148 | Usage: govc device.scsi.add [OPTIONS] 1149 | 1150 | Add SCSI controller to VM. 1151 | 1152 | Examples: 1153 | govc device.scsi.add -vm $vm 1154 | govc device.scsi.add -vm $vm -type pvscsi 1155 | govc device.info -vm $vm {lsi,pv}* 1156 | 1157 | Options: 1158 | -hot=false Enable hot-add/remove 1159 | -sharing=noSharing SCSI sharing 1160 | -type=lsilogic SCSI controller type (lsilogic|buslogic|pvscsi|lsilogic-sas) 1161 | -vm= Virtual machine [GOVC_VM] 1162 | ``` 1163 | 1164 | ## device.serial.add 1165 | 1166 | ``` 1167 | Usage: govc device.serial.add [OPTIONS] 1168 | 1169 | Add serial port to VM. 1170 | 1171 | Examples: 1172 | govc device.serial.add -vm $vm 1173 | govc device.info -vm $vm serialport-* 1174 | 1175 | Options: 1176 | -vm= Virtual machine [GOVC_VM] 1177 | ``` 1178 | 1179 | ## device.serial.connect 1180 | 1181 | ``` 1182 | Usage: govc device.serial.connect [OPTIONS] URI 1183 | 1184 | Connect service URI to serial port. 1185 | 1186 | If "-" is given as URI, connects file backed device with file name of 1187 | device name + .log suffix in the VM Config.Files.LogDirectory. 1188 | 1189 | Defaults to the first serial port if no DEVICE is given. 1190 | 1191 | Examples: 1192 | govc device.ls | grep serialport- 1193 | govc device.serial.connect -vm $vm -device serialport-8000 telnet://:33233 1194 | govc device.info -vm $vm serialport-* 1195 | govc device.serial.connect -vm $vm "[datastore1] $vm/console.log" 1196 | govc device.serial.connect -vm $vm - 1197 | govc datastore.tail -f $vm/serialport-8000.log 1198 | 1199 | Options: 1200 | -client=false Use client direction 1201 | -device= serial port device name 1202 | -vm= Virtual machine [GOVC_VM] 1203 | -vspc-proxy= vSPC proxy URI 1204 | ``` 1205 | 1206 | ## device.serial.disconnect 1207 | 1208 | ``` 1209 | Usage: govc device.serial.disconnect [OPTIONS] 1210 | 1211 | Disconnect service URI from serial port. 1212 | 1213 | Examples: 1214 | govc device.ls | grep serialport- 1215 | govc device.serial.disconnect -vm $vm -device serialport-8000 1216 | govc device.info -vm $vm serialport-* 1217 | 1218 | Options: 1219 | -device= serial port device name 1220 | -vm= Virtual machine [GOVC_VM] 1221 | ``` 1222 | 1223 | ## device.usb.add 1224 | 1225 | ``` 1226 | Usage: govc device.usb.add [OPTIONS] 1227 | 1228 | Add USB device to VM. 1229 | 1230 | Examples: 1231 | govc device.usb.add -vm $vm 1232 | govc device.usb.add -type xhci -vm $vm 1233 | govc device.info usb* 1234 | 1235 | Options: 1236 | -auto=true Enable ability to hot plug devices 1237 | -ehci=true Enable enhanced host controller interface (USB 2.0) 1238 | -type=usb USB controller type (usb|xhci) 1239 | -vm= Virtual machine [GOVC_VM] 1240 | ``` 1241 | 1242 | ## disk.create 1243 | 1244 | ``` 1245 | Usage: govc disk.create [OPTIONS] NAME 1246 | 1247 | Create disk NAME on DS. 1248 | 1249 | Examples: 1250 | govc disk.create -size 24G my-disk 1251 | 1252 | Options: 1253 | -datastore-cluster= Datastore cluster [GOVC_DATASTORE_CLUSTER] 1254 | -ds= Datastore [GOVC_DATASTORE] 1255 | -keep= Keep disk after VM is deleted 1256 | -pool= Resource pool [GOVC_RESOURCE_POOL] 1257 | -size=10.0GB Size of new disk 1258 | ``` 1259 | 1260 | ## disk.ls 1261 | 1262 | ``` 1263 | Usage: govc disk.ls [OPTIONS] [ID]... 1264 | 1265 | List disk IDs on DS. 1266 | 1267 | Examples: 1268 | govc disk.ls 1269 | govc disk.ls -l -T 1270 | govc disk.ls -l e9b06a8b-d047-4d3c-b15b-43ea9608b1a6 1271 | govc disk.ls -c k8s-region -t us-west-2 1272 | 1273 | Options: 1274 | -T=false List attached tags 1275 | -c= Query tag category 1276 | -ds= Datastore [GOVC_DATASTORE] 1277 | -l=false Long listing format 1278 | -t= Query tag name 1279 | ``` 1280 | 1281 | ## disk.register 1282 | 1283 | ``` 1284 | Usage: govc disk.register [OPTIONS] PATH [NAME] 1285 | 1286 | Register existing disk on DS. 1287 | 1288 | Examples: 1289 | govc disk.register disks/disk1.vmdk my-disk 1290 | 1291 | Options: 1292 | -ds= Datastore [GOVC_DATASTORE] 1293 | ``` 1294 | 1295 | ## disk.rm 1296 | 1297 | ``` 1298 | Usage: govc disk.rm [OPTIONS] ID 1299 | 1300 | Remove disk ID on DS. 1301 | 1302 | Examples: 1303 | govc disk.rm ID 1304 | 1305 | Options: 1306 | -ds= Datastore [GOVC_DATASTORE] 1307 | ``` 1308 | 1309 | ## disk.snapshot.create 1310 | 1311 | ``` 1312 | Usage: govc disk.snapshot.create [OPTIONS] ID DESC 1313 | 1314 | Create snapshot of ID on DS. 1315 | 1316 | Examples: 1317 | govc disk.snapshot.create b9fe5f17-3b87-4a03-9739-09a82ddcc6b0 my-disk-snapshot 1318 | 1319 | Options: 1320 | -ds= Datastore [GOVC_DATASTORE] 1321 | ``` 1322 | 1323 | ## disk.snapshot.ls 1324 | 1325 | ``` 1326 | Usage: govc disk.snapshot.ls [OPTIONS] ID 1327 | 1328 | List snapshots for disk ID on DS. 1329 | 1330 | Examples: 1331 | govc snapshot.disk.ls -l 9b06a8b-d047-4d3c-b15b-43ea9608b1a6 1332 | 1333 | Options: 1334 | -ds= Datastore [GOVC_DATASTORE] 1335 | -l=false Long listing format 1336 | ``` 1337 | 1338 | ## disk.snapshot.rm 1339 | 1340 | ``` 1341 | Usage: govc disk.snapshot.rm [OPTIONS] ID SID 1342 | 1343 | Remove disk ID snapshot ID on DS. 1344 | 1345 | Examples: 1346 | govc disk.snapshot.rm ffe6a398-eb8e-4eaa-9118-e1f16b8b8e3c ecbca542-0a25-4127-a585-82e4047750d6 1347 | 1348 | Options: 1349 | -ds= Datastore [GOVC_DATASTORE] 1350 | ``` 1351 | 1352 | ## disk.tags.attach 1353 | 1354 | ``` 1355 | Usage: govc disk.tags.attach [OPTIONS] NAME ID 1356 | 1357 | Attach tag NAME to disk ID. 1358 | 1359 | Examples: 1360 | govc disk.tags.attach -c k8s-region k8s-region-us $id 1361 | 1362 | Options: 1363 | -c= Tag category 1364 | ``` 1365 | 1366 | ## disk.tags.detach 1367 | 1368 | ``` 1369 | Usage: govc disk.tags.detach [OPTIONS] NAME ID 1370 | 1371 | Detach tag NAME from disk ID. 1372 | 1373 | Examples: 1374 | govc disk.tags.detach -c k8s-region k8s-region-us $id 1375 | 1376 | Options: 1377 | -c= Tag category 1378 | ``` 1379 | 1380 | ## dvs.add 1381 | 1382 | ``` 1383 | Usage: govc dvs.add [OPTIONS] HOST... 1384 | 1385 | Add hosts to DVS. 1386 | 1387 | Examples: 1388 | govc dvs.add -dvs dvsName -pnic vmnic1 hostA hostB hostC 1389 | 1390 | Options: 1391 | -dvs= DVS path 1392 | -host= Host system [GOVC_HOST] 1393 | -pnic=vmnic0 Name of the host physical NIC 1394 | ``` 1395 | 1396 | ## dvs.create 1397 | 1398 | ``` 1399 | Usage: govc dvs.create [OPTIONS] DVS 1400 | 1401 | Create DVS (DistributedVirtualSwitch) in datacenter. 1402 | 1403 | The dvs is added to the folder specified by the 'folder' flag. If not given, 1404 | this defaults to the network folder in the specified or default datacenter. 1405 | 1406 | Examples: 1407 | govc dvs.create DSwitch 1408 | govc dvs.create -product-version 5.5.0 DSwitch 1409 | 1410 | Options: 1411 | -folder= Inventory folder [GOVC_FOLDER] 1412 | -product-version= DVS product version 1413 | ``` 1414 | 1415 | ## dvs.portgroup.add 1416 | 1417 | ``` 1418 | Usage: govc dvs.portgroup.add [OPTIONS] NAME 1419 | 1420 | Add portgroup to DVS. 1421 | 1422 | Examples: 1423 | govc dvs.create DSwitch 1424 | govc dvs.portgroup.add -dvs DSwitch -type earlyBinding -nports 16 ExternalNetwork 1425 | govc dvs.portgroup.add -dvs DSwitch -type ephemeral InternalNetwork 1426 | 1427 | Options: 1428 | -dvs= DVS path 1429 | -nports=128 Number of ports 1430 | -type=earlyBinding Portgroup type (earlyBinding|lateBinding|ephemeral) 1431 | -vlan=0 VLAN ID 1432 | ``` 1433 | 1434 | ## dvs.portgroup.change 1435 | 1436 | ``` 1437 | Usage: govc dvs.portgroup.change [OPTIONS] PATH 1438 | 1439 | Change DVS portgroup configuration. 1440 | 1441 | Examples: 1442 | govc dvs.portgroup.change -nports 26 ExternalNetwork 1443 | govc dvs.portgroup.change -vlan 3214 ExternalNetwork 1444 | 1445 | Options: 1446 | -nports=0 Number of ports 1447 | -type=earlyBinding Portgroup type (earlyBinding|lateBinding|ephemeral) 1448 | -vlan=0 VLAN ID 1449 | ``` 1450 | 1451 | ## dvs.portgroup.info 1452 | 1453 | ``` 1454 | Usage: govc dvs.portgroup.info [OPTIONS] DVS 1455 | 1456 | Portgroup info for DVS. 1457 | 1458 | Examples: 1459 | govc dvs.portgroup.info DSwitch 1460 | govc dvs.portgroup.info -pg InternalNetwork DSwitch 1461 | govc find / -type DistributedVirtualSwitch | xargs -n1 govc dvs.portgroup.info 1462 | 1463 | Options: 1464 | -active=false Filter by port active or inactive status 1465 | -connected=false Filter by port connected or disconnected status 1466 | -count=0 Number of matches to return (0 = unlimited) 1467 | -inside=true Filter by port inside or outside status 1468 | -pg= Distributed Virtual Portgroup 1469 | -r=false Show DVS rules 1470 | -uplinkPort=false Filter for uplink ports 1471 | -vlan=0 Filter by VLAN ID (0 = unfiltered) 1472 | ``` 1473 | 1474 | ## env 1475 | 1476 | ``` 1477 | Usage: govc env [OPTIONS] 1478 | 1479 | Output the environment variables for this client. 1480 | 1481 | If credentials are included in the url, they are split into separate variables. 1482 | Useful as bash scripting helper to parse GOVC_URL. 1483 | 1484 | Options: 1485 | -x=false Output variables for each GOVC_URL component 1486 | ``` 1487 | 1488 | ## events 1489 | 1490 | ``` 1491 | Usage: govc events [OPTIONS] [PATH]... 1492 | 1493 | Display events. 1494 | 1495 | Examples: 1496 | govc events vm/my-vm1 vm/my-vm2 1497 | govc events /dc1/vm/* /dc2/vm/* 1498 | govc events -type VmPoweredOffEvent -type VmPoweredOnEvent 1499 | govc ls -t HostSystem host/* | xargs govc events | grep -i vsan 1500 | 1501 | Options: 1502 | -f=false Follow event stream 1503 | -force=false Disable number objects to monitor limit 1504 | -l=false Long listing format 1505 | -n=25 Output the last N events 1506 | -type=[] Include only the specified event types 1507 | ``` 1508 | 1509 | ## export.ovf 1510 | 1511 | ``` 1512 | Usage: govc export.ovf [OPTIONS] DIR 1513 | 1514 | Export VM. 1515 | 1516 | Examples: 1517 | govc export.ovf -vm $vm DIR 1518 | 1519 | Options: 1520 | -f=false Overwrite existing 1521 | -i=false Include image files (*.{iso,img}) 1522 | -name= Specifies target name (defaults to source name) 1523 | -sha=0 Generate manifest using SHA 1, 256, 512 or 0 to skip 1524 | -vm= Virtual machine [GOVC_VM] 1525 | ``` 1526 | 1527 | ## extension.info 1528 | 1529 | ``` 1530 | Usage: govc extension.info [OPTIONS] [KEY]... 1531 | 1532 | Options: 1533 | ``` 1534 | 1535 | ## extension.register 1536 | 1537 | ``` 1538 | Usage: govc extension.register [OPTIONS] 1539 | 1540 | Options: 1541 | -update=false Update extension 1542 | ``` 1543 | 1544 | ## extension.setcert 1545 | 1546 | ``` 1547 | Usage: govc extension.setcert [OPTIONS] ID 1548 | 1549 | Set certificate for the extension ID. 1550 | 1551 | The '-cert-pem' option can be one of the following: 1552 | '-' : Read the certificate from stdin 1553 | '+' : Generate a new key pair and save locally to ID.crt and ID.key 1554 | ... : Any other value is passed as-is to ExtensionManager.SetCertificate 1555 | 1556 | Examples: 1557 | govc extension.setcert -cert-pem + -org Example com.example.extname 1558 | 1559 | Options: 1560 | -cert-pem=- PEM encoded certificate 1561 | -org=VMware Organization for generated certificate 1562 | ``` 1563 | 1564 | ## extension.unregister 1565 | 1566 | ``` 1567 | Usage: govc extension.unregister [OPTIONS] 1568 | 1569 | Options: 1570 | ``` 1571 | 1572 | ## fields.add 1573 | 1574 | ``` 1575 | Usage: govc fields.add [OPTIONS] NAME 1576 | 1577 | Add a custom field type with NAME. 1578 | 1579 | Examples: 1580 | govc fields.add my-field-name # adds a field to all managed object types 1581 | govc fields.add -type VirtualMachine my-vm-field-name # adds a field to the VirtualMachine type 1582 | 1583 | Options: 1584 | -type= Managed object type 1585 | ``` 1586 | 1587 | ## fields.info 1588 | 1589 | ``` 1590 | Usage: govc fields.info [OPTIONS] PATH... 1591 | 1592 | Display custom field values for PATH. 1593 | 1594 | Also known as "Custom Attributes". 1595 | 1596 | Examples: 1597 | govc fields.info vm/* 1598 | govc fields.info -n my-field-name vm/* 1599 | 1600 | Options: 1601 | -n= Filter by custom field name 1602 | ``` 1603 | 1604 | ## fields.ls 1605 | 1606 | ``` 1607 | Usage: govc fields.ls [OPTIONS] 1608 | 1609 | List custom field definitions. 1610 | 1611 | Examples: 1612 | govc fields.ls 1613 | 1614 | Options: 1615 | ``` 1616 | 1617 | ## fields.rename 1618 | 1619 | ``` 1620 | Usage: govc fields.rename [OPTIONS] KEY NAME 1621 | 1622 | Options: 1623 | ``` 1624 | 1625 | ## fields.rm 1626 | 1627 | ``` 1628 | Usage: govc fields.rm [OPTIONS] KEY... 1629 | 1630 | Options: 1631 | ``` 1632 | 1633 | ## fields.set 1634 | 1635 | ``` 1636 | Usage: govc fields.set [OPTIONS] KEY VALUE PATH... 1637 | 1638 | Set custom field values for PATH. 1639 | 1640 | Examples: 1641 | govc fields.set my-field-name field-value vm/my-vm 1642 | govc fields.set -add my-new-global-field-name field-value vm/my-vm 1643 | govc fields.set -add -type VirtualMachine my-new-vm-field-name field-value vm/my-vm 1644 | 1645 | Options: 1646 | -add=false Adds the field if it does not exist. Use the -type flag to specify the managed object type to which the field is added. Using -add and omitting -kind causes a new, global field to be created if a field with the provided name does not already exist. 1647 | -type= Managed object type on which to add the field if it does not exist. This flag is ignored unless -add=true 1648 | ``` 1649 | 1650 | ## find 1651 | 1652 | ``` 1653 | Usage: govc find [OPTIONS] [ROOT] [KEY VAL]... 1654 | 1655 | Find managed objects. 1656 | 1657 | ROOT can be an inventory path or ManagedObjectReference. 1658 | ROOT defaults to '.', an alias for the root folder or DC if set. 1659 | 1660 | Optional KEY VAL pairs can be used to filter results against object instance properties. 1661 | Use the govc 'object.collect' command to view possible object property keys. 1662 | 1663 | The '-type' flag value can be a managed entity type or one of the following aliases: 1664 | 1665 | a VirtualApp 1666 | c ClusterComputeResource 1667 | d Datacenter 1668 | f Folder 1669 | g DistributedVirtualPortgroup 1670 | h HostSystem 1671 | m VirtualMachine 1672 | n Network 1673 | o OpaqueNetwork 1674 | p ResourcePool 1675 | r ComputeResource 1676 | s Datastore 1677 | w DistributedVirtualSwitch 1678 | 1679 | Examples: 1680 | govc find 1681 | govc find /dc1 -type c 1682 | govc find vm -name my-vm-* 1683 | govc find . -type n 1684 | govc find . -type m -runtime.powerState poweredOn 1685 | govc find . -type m -datastore $(govc find -i datastore -name vsanDatastore) 1686 | govc find . -type s -summary.type vsan 1687 | govc find . -type h -hardware.cpuInfo.numCpuCores 16 1688 | 1689 | Options: 1690 | -i=false Print the managed object reference 1691 | -maxdepth=-1 Max depth 1692 | -name=* Resource name 1693 | -type=[] Resource type 1694 | ``` 1695 | 1696 | ## firewall.ruleset.find 1697 | 1698 | ``` 1699 | Usage: govc firewall.ruleset.find [OPTIONS] 1700 | 1701 | Find firewall rulesets matching the given rule. 1702 | 1703 | For a complete list of rulesets: govc host.esxcli network firewall ruleset list 1704 | For a complete list of rules: govc host.esxcli network firewall ruleset rule list 1705 | 1706 | Examples: 1707 | govc firewall.ruleset.find -direction inbound -port 22 1708 | govc firewall.ruleset.find -direction outbound -port 2377 1709 | 1710 | Options: 1711 | -c=true Check if esx firewall is enabled 1712 | -direction=outbound Direction 1713 | -enabled=true Find enabled rule sets if true, disabled if false 1714 | -host= Host system [GOVC_HOST] 1715 | -port=0 Port 1716 | -proto=tcp Protocol 1717 | -type=dst Port type 1718 | ``` 1719 | 1720 | ## folder.create 1721 | 1722 | ``` 1723 | Usage: govc folder.create [OPTIONS] PATH... 1724 | 1725 | Create folder with PATH. 1726 | 1727 | Examples: 1728 | govc folder.create /dc1/vm/folder-foo 1729 | govc object.mv /dc1/vm/vm-foo-* /dc1/vm/folder-foo 1730 | govc folder.create -pod /dc1/datastore/sdrs 1731 | govc object.mv /dc1/datastore/iscsi-* /dc1/datastore/sdrs 1732 | 1733 | Options: 1734 | -pod=false Create folder(s) of type StoragePod (DatastoreCluster) 1735 | ``` 1736 | 1737 | ## folder.info 1738 | 1739 | ``` 1740 | Usage: govc folder.info [OPTIONS] [PATH]... 1741 | 1742 | Options: 1743 | ``` 1744 | 1745 | ## guest.chmod 1746 | 1747 | ``` 1748 | Usage: govc guest.chmod [OPTIONS] MODE FILE 1749 | 1750 | Change FILE MODE on VM. 1751 | 1752 | Examples: 1753 | govc guest.chmod -vm $name 0644 /var/log/foo.log 1754 | 1755 | Options: 1756 | -l=: Guest VM credentials [GOVC_GUEST_LOGIN] 1757 | -vm= Virtual machine [GOVC_VM] 1758 | ``` 1759 | 1760 | ## guest.chown 1761 | 1762 | ``` 1763 | Usage: govc guest.chown [OPTIONS] UID[:GID] FILE 1764 | 1765 | Change FILE UID and GID on VM. 1766 | 1767 | Examples: 1768 | govc guest.chown -vm $name UID[:GID] /var/log/foo.log 1769 | 1770 | Options: 1771 | -l=: Guest VM credentials [GOVC_GUEST_LOGIN] 1772 | -vm= Virtual machine [GOVC_VM] 1773 | ``` 1774 | 1775 | ## guest.download 1776 | 1777 | ``` 1778 | Usage: govc guest.download [OPTIONS] SOURCE DEST 1779 | 1780 | Copy SOURCE from the guest VM to DEST on the local system. 1781 | 1782 | If DEST name is "-", source is written to stdout. 1783 | 1784 | Examples: 1785 | govc guest.download -l user:pass -vm=my-vm /var/log/my.log ./local.log 1786 | govc guest.download -l user:pass -vm=my-vm /etc/motd - 1787 | 1788 | Options: 1789 | -f=false If set, the local destination file is clobbered 1790 | -l=: Guest VM credentials [GOVC_GUEST_LOGIN] 1791 | -vm= Virtual machine [GOVC_VM] 1792 | ``` 1793 | 1794 | ## guest.getenv 1795 | 1796 | ``` 1797 | Usage: govc guest.getenv [OPTIONS] [NAME]... 1798 | 1799 | Read NAME environment variables from VM. 1800 | 1801 | Examples: 1802 | govc guest.getenv -vm $name 1803 | govc guest.getenv -vm $name HOME 1804 | 1805 | Options: 1806 | -l=: Guest VM credentials [GOVC_GUEST_LOGIN] 1807 | -vm= Virtual machine [GOVC_VM] 1808 | ``` 1809 | 1810 | ## guest.kill 1811 | 1812 | ``` 1813 | Usage: govc guest.kill [OPTIONS] 1814 | 1815 | Kill process ID on VM. 1816 | 1817 | Examples: 1818 | govc guest.kill -vm $name -p 12345 1819 | 1820 | Options: 1821 | -l=: Guest VM credentials [GOVC_GUEST_LOGIN] 1822 | -p=[] Process ID 1823 | -vm= Virtual machine [GOVC_VM] 1824 | ``` 1825 | 1826 | ## guest.ls 1827 | 1828 | ``` 1829 | Usage: govc guest.ls [OPTIONS] PATH 1830 | 1831 | List PATH files in VM. 1832 | 1833 | Examples: 1834 | govc guest.ls -vm $name /tmp 1835 | 1836 | Options: 1837 | -l=: Guest VM credentials [GOVC_GUEST_LOGIN] 1838 | -s=false Simple path only listing 1839 | -vm= Virtual machine [GOVC_VM] 1840 | ``` 1841 | 1842 | ## guest.mkdir 1843 | 1844 | ``` 1845 | Usage: govc guest.mkdir [OPTIONS] PATH 1846 | 1847 | Create directory PATH in VM. 1848 | 1849 | Examples: 1850 | govc guest.mkdir -vm $name /tmp/logs 1851 | govc guest.mkdir -vm $name -p /tmp/logs/foo/bar 1852 | 1853 | Options: 1854 | -l=: Guest VM credentials [GOVC_GUEST_LOGIN] 1855 | -p=false Create intermediate directories as needed 1856 | -vm= Virtual machine [GOVC_VM] 1857 | ``` 1858 | 1859 | ## guest.mktemp 1860 | 1861 | ``` 1862 | Usage: govc guest.mktemp [OPTIONS] 1863 | 1864 | Create a temporary file or directory in VM. 1865 | 1866 | Examples: 1867 | govc guest.mktemp -vm $name 1868 | govc guest.mktemp -vm $name -d 1869 | govc guest.mktemp -vm $name -t myprefix 1870 | govc guest.mktemp -vm $name -p /var/tmp/$USER 1871 | 1872 | Options: 1873 | -d=false Make a directory instead of a file 1874 | -l=: Guest VM credentials [GOVC_GUEST_LOGIN] 1875 | -p= If specified, create relative to this directory 1876 | -s= Suffix 1877 | -t= Prefix 1878 | -vm= Virtual machine [GOVC_VM] 1879 | ``` 1880 | 1881 | ## guest.mv 1882 | 1883 | ``` 1884 | Usage: govc guest.mv [OPTIONS] SOURCE DEST 1885 | 1886 | Move (rename) files in VM. 1887 | 1888 | Examples: 1889 | govc guest.mv -vm $name /tmp/foo.sh /tmp/bar.sh 1890 | govc guest.mv -vm $name -n /tmp/baz.sh /tmp/bar.sh 1891 | 1892 | Options: 1893 | -l=: Guest VM credentials [GOVC_GUEST_LOGIN] 1894 | -n=false Do not overwrite an existing file 1895 | -vm= Virtual machine [GOVC_VM] 1896 | ``` 1897 | 1898 | ## guest.ps 1899 | 1900 | ``` 1901 | Usage: govc guest.ps [OPTIONS] 1902 | 1903 | List processes in VM. 1904 | 1905 | By default, unless the '-e', '-p' or '-U' flag is specified, only processes owned 1906 | by the '-l' flag user are displayed. 1907 | 1908 | The '-x' and '-X' flags only apply to processes started by vmware-tools, 1909 | such as those started with the govc guest.start command. 1910 | 1911 | Examples: 1912 | govc guest.ps -vm $name 1913 | govc guest.ps -vm $name -e 1914 | govc guest.ps -vm $name -p 12345 1915 | govc guest.ps -vm $name -U root 1916 | 1917 | Options: 1918 | -U= Select by process UID 1919 | -X=false Wait for process to exit 1920 | -e=false Select all processes 1921 | -l=: Guest VM credentials [GOVC_GUEST_LOGIN] 1922 | -p=[] Select by process ID 1923 | -vm= Virtual machine [GOVC_VM] 1924 | -x=false Output exit time and code 1925 | ``` 1926 | 1927 | ## guest.rm 1928 | 1929 | ``` 1930 | Usage: govc guest.rm [OPTIONS] PATH 1931 | 1932 | Remove file PATH in VM. 1933 | 1934 | Examples: 1935 | govc guest.rm -vm $name /tmp/foo.log 1936 | 1937 | Options: 1938 | -l=: Guest VM credentials [GOVC_GUEST_LOGIN] 1939 | -vm= Virtual machine [GOVC_VM] 1940 | ``` 1941 | 1942 | ## guest.rmdir 1943 | 1944 | ``` 1945 | Usage: govc guest.rmdir [OPTIONS] PATH 1946 | 1947 | Remove directory PATH in VM. 1948 | 1949 | Examples: 1950 | govc guest.rmdir -vm $name /tmp/empty-dir 1951 | govc guest.rmdir -vm $name -r /tmp/non-empty-dir 1952 | 1953 | Options: 1954 | -l=: Guest VM credentials [GOVC_GUEST_LOGIN] 1955 | -r=false Recursive removal 1956 | -vm= Virtual machine [GOVC_VM] 1957 | ``` 1958 | 1959 | ## guest.run 1960 | 1961 | ``` 1962 | Usage: govc guest.run [OPTIONS] NAME [ARG]... 1963 | 1964 | Run program NAME in VM and display output. 1965 | 1966 | This command depends on govmomi/toolbox running in the VM guest and does not work with standard VMware tools. 1967 | 1968 | If the program NAME is an HTTP verb, the toolbox's http.RoundTripper will be used as the HTTP transport. 1969 | 1970 | Examples: 1971 | govc guest.run -vm $name kubectl get pods 1972 | govc guest.run -vm $name -d - kubectl create -f - Group ID 2044 | -l=: Guest VM credentials [GOVC_GUEST_LOGIN] 2045 | -perm=0 File permissions 2046 | -uid= User ID 2047 | -vm= Virtual machine [GOVC_VM] 2048 | ``` 2049 | 2050 | ## host.account.create 2051 | 2052 | ``` 2053 | Usage: govc host.account.create [OPTIONS] 2054 | 2055 | Create local account on HOST. 2056 | 2057 | Examples: 2058 | govc host.account.create -id $USER -password password-for-esx60 2059 | 2060 | Options: 2061 | -description= The description of the specified account 2062 | -host= Host system [GOVC_HOST] 2063 | -id= The ID of the specified account 2064 | -password= The password for the specified account id 2065 | ``` 2066 | 2067 | ## host.account.remove 2068 | 2069 | ``` 2070 | Usage: govc host.account.remove [OPTIONS] 2071 | 2072 | Remove local account on HOST. 2073 | 2074 | Examples: 2075 | govc host.account.remove -id $USER 2076 | 2077 | Options: 2078 | -description= The description of the specified account 2079 | -host= Host system [GOVC_HOST] 2080 | -id= The ID of the specified account 2081 | -password= The password for the specified account id 2082 | ``` 2083 | 2084 | ## host.account.update 2085 | 2086 | ``` 2087 | Usage: govc host.account.update [OPTIONS] 2088 | 2089 | Update local account on HOST. 2090 | 2091 | Examples: 2092 | govc host.account.update -id root -password password-for-esx60 2093 | 2094 | Options: 2095 | -description= The description of the specified account 2096 | -host= Host system [GOVC_HOST] 2097 | -id= The ID of the specified account 2098 | -password= The password for the specified account id 2099 | ``` 2100 | 2101 | ## host.add 2102 | 2103 | ``` 2104 | Usage: govc host.add [OPTIONS] 2105 | 2106 | Add host to datacenter. 2107 | 2108 | The host is added to the folder specified by the 'folder' flag. If not given, 2109 | this defaults to the host folder in the specified or default datacenter. 2110 | 2111 | Examples: 2112 | thumbprint=$(govc about.cert -k -u host.example.com -thumbprint | awk '{print $2}') 2113 | govc host.add -hostname host.example.com -username root -password pass -thumbprint $thumbprint 2114 | govc host.add -hostname 10.0.6.1 -username root -password pass -noverify 2115 | 2116 | Options: 2117 | -connect=true Immediately connect to host 2118 | -folder= Inventory folder [GOVC_FOLDER] 2119 | -force=false Force when host is managed by another VC 2120 | -hostname= Hostname or IP address of the host 2121 | -noverify=false Accept host thumbprint without verification 2122 | -password= Password of administration account on the host 2123 | -thumbprint= SHA-1 thumbprint of the host's SSL certificate 2124 | -username= Username of administration account on the host 2125 | ``` 2126 | 2127 | ## host.autostart.add 2128 | 2129 | ``` 2130 | Usage: govc host.autostart.add [OPTIONS] VM... 2131 | 2132 | Options: 2133 | -host= Host system [GOVC_HOST] 2134 | -start-action=powerOn Start Action 2135 | -start-delay=-1 Start Delay 2136 | -start-order=-1 Start Order 2137 | -stop-action=systemDefault Stop Action 2138 | -stop-delay=-1 Stop Delay 2139 | -wait=systemDefault Wait for Hearbeat Setting (systemDefault|yes|no) 2140 | ``` 2141 | 2142 | ## host.autostart.configure 2143 | 2144 | ``` 2145 | Usage: govc host.autostart.configure [OPTIONS] 2146 | 2147 | Options: 2148 | -enabled= Enable autostart 2149 | -host= Host system [GOVC_HOST] 2150 | -start-delay=0 Start delay 2151 | -stop-action= Stop action 2152 | -stop-delay=0 Stop delay 2153 | -wait-for-heartbeat= Wait for hearbeat 2154 | ``` 2155 | 2156 | ## host.autostart.info 2157 | 2158 | ``` 2159 | Usage: govc host.autostart.info [OPTIONS] 2160 | 2161 | Options: 2162 | -host= Host system [GOVC_HOST] 2163 | ``` 2164 | 2165 | ## host.autostart.remove 2166 | 2167 | ``` 2168 | Usage: govc host.autostart.remove [OPTIONS] VM... 2169 | 2170 | Options: 2171 | -host= Host system [GOVC_HOST] 2172 | ``` 2173 | 2174 | ## host.cert.csr 2175 | 2176 | ``` 2177 | Usage: govc host.cert.csr [OPTIONS] 2178 | 2179 | Generate a certificate-signing request (CSR) for HOST. 2180 | 2181 | Options: 2182 | -host= Host system [GOVC_HOST] 2183 | -ip=false Use IP address as CN 2184 | ``` 2185 | 2186 | ## host.cert.import 2187 | 2188 | ``` 2189 | Usage: govc host.cert.import [OPTIONS] FILE 2190 | 2191 | Install SSL certificate FILE on HOST. 2192 | 2193 | If FILE name is "-", read certificate from stdin. 2194 | 2195 | Options: 2196 | -host= Host system [GOVC_HOST] 2197 | ``` 2198 | 2199 | ## host.cert.info 2200 | 2201 | ``` 2202 | Usage: govc host.cert.info [OPTIONS] 2203 | 2204 | Display SSL certificate info for HOST. 2205 | 2206 | Options: 2207 | -host= Host system [GOVC_HOST] 2208 | ``` 2209 | 2210 | ## host.date.change 2211 | 2212 | ``` 2213 | Usage: govc host.date.change [OPTIONS] 2214 | 2215 | Change date and time for HOST. 2216 | 2217 | Examples: 2218 | govc host.date.change -date "$(date -u)" 2219 | govc host.date.change -server time.vmware.com 2220 | govc host.service enable ntpd 2221 | govc host.service start ntpd 2222 | 2223 | Options: 2224 | -date= Update the date/time on the host 2225 | -host= Host system [GOVC_HOST] 2226 | -server= IP or FQDN for NTP server(s) 2227 | -tz= Change timezone of the host 2228 | ``` 2229 | 2230 | ## host.date.info 2231 | 2232 | ``` 2233 | Usage: govc host.date.info [OPTIONS] 2234 | 2235 | Display date and time info for HOST. 2236 | 2237 | Options: 2238 | -host= Host system [GOVC_HOST] 2239 | ``` 2240 | 2241 | ## host.disconnect 2242 | 2243 | ``` 2244 | Usage: govc host.disconnect [OPTIONS] 2245 | 2246 | Disconnect HOST from vCenter. 2247 | 2248 | Options: 2249 | -host= Host system [GOVC_HOST] 2250 | ``` 2251 | 2252 | ## host.esxcli 2253 | 2254 | ``` 2255 | Usage: govc host.esxcli [OPTIONS] COMMAND [ARG]... 2256 | 2257 | Invoke esxcli command on HOST. 2258 | 2259 | Output is rendered in table form when possible, unless disabled with '-hints=false'. 2260 | 2261 | Examples: 2262 | govc host.esxcli network ip connection list 2263 | govc host.esxcli system settings advanced set -o /Net/GuestIPHack -i 1 2264 | govc host.esxcli network firewall ruleset set -r remoteSerialPort -e true 2265 | govc host.esxcli network firewall set -e false 2266 | 2267 | Options: 2268 | -hints=true Use command info hints when formatting output 2269 | -host= Host system [GOVC_HOST] 2270 | ``` 2271 | 2272 | ## host.info 2273 | 2274 | ``` 2275 | Usage: govc host.info [OPTIONS] 2276 | 2277 | Options: 2278 | -host= Host system [GOVC_HOST] 2279 | ``` 2280 | 2281 | ## host.maintenance.enter 2282 | 2283 | ``` 2284 | Usage: govc host.maintenance.enter [OPTIONS] HOST... 2285 | 2286 | Put HOST in maintenance mode. 2287 | 2288 | While this task is running and when the host is in maintenance mode, 2289 | no VMs can be powered on and no provisioning operations can be performed on the host. 2290 | 2291 | Options: 2292 | -evacuate=false Evacuate powered off VMs 2293 | -host= Host system [GOVC_HOST] 2294 | -timeout=0 Timeout 2295 | ``` 2296 | 2297 | ## host.maintenance.exit 2298 | 2299 | ``` 2300 | Usage: govc host.maintenance.exit [OPTIONS] HOST... 2301 | 2302 | Take HOST out of maintenance mode. 2303 | 2304 | This blocks if any concurrent running maintenance-only host configurations operations are being performed. 2305 | For example, if VMFS volumes are being upgraded. 2306 | 2307 | The 'timeout' flag is the number of seconds to wait for the exit maintenance mode to succeed. 2308 | If the timeout is less than or equal to zero, there is no timeout. 2309 | 2310 | Options: 2311 | -host= Host system [GOVC_HOST] 2312 | -timeout=0 Timeout 2313 | ``` 2314 | 2315 | ## host.option.ls 2316 | 2317 | ``` 2318 | Usage: govc host.option.ls [OPTIONS] [NAME] 2319 | 2320 | List option with the given NAME. 2321 | 2322 | If NAME ends with a dot, all options for that subtree are listed. 2323 | 2324 | Examples: 2325 | govc host.option.ls 2326 | govc host.option.ls Config.HostAgent. 2327 | govc host.option.ls Config.HostAgent.plugins.solo.enableMob 2328 | 2329 | Options: 2330 | -host= Host system [GOVC_HOST] 2331 | ``` 2332 | 2333 | ## host.option.set 2334 | 2335 | ``` 2336 | Usage: govc host.option.set [OPTIONS] NAME VALUE 2337 | 2338 | Set option NAME to VALUE. 2339 | 2340 | Examples: 2341 | govc host.option.set Config.HostAgent.plugins.solo.enableMob true 2342 | govc host.option.set Config.HostAgent.log.level verbose 2343 | 2344 | Options: 2345 | -host= Host system [GOVC_HOST] 2346 | ``` 2347 | 2348 | ## host.portgroup.add 2349 | 2350 | ``` 2351 | Usage: govc host.portgroup.add [OPTIONS] NAME 2352 | 2353 | Add portgroup to HOST. 2354 | 2355 | Examples: 2356 | govc host.portgroup.add -vswitch vSwitch0 -vlan 3201 bridge 2357 | 2358 | Options: 2359 | -host= Host system [GOVC_HOST] 2360 | -vlan=0 VLAN ID 2361 | -vswitch= vSwitch Name 2362 | ``` 2363 | 2364 | ## host.portgroup.change 2365 | 2366 | ``` 2367 | Usage: govc host.portgroup.change [OPTIONS] NAME 2368 | 2369 | Change configuration of HOST portgroup NAME. 2370 | 2371 | Examples: 2372 | govc host.portgroup.change -allow-promiscuous -forged-transmits -mac-changes "VM Network" 2373 | govc host.portgroup.change -vswitch-name vSwitch1 "Management Network" 2374 | 2375 | Options: 2376 | -allow-promiscuous= Allow promiscuous mode 2377 | -forged-transmits= Allow forged transmits 2378 | -host= Host system [GOVC_HOST] 2379 | -mac-changes= Allow MAC changes 2380 | -name= Portgroup name 2381 | -vlan-id=-1 VLAN ID 2382 | -vswitch-name= vSwitch name 2383 | ``` 2384 | 2385 | ## host.portgroup.info 2386 | 2387 | ``` 2388 | Usage: govc host.portgroup.info [OPTIONS] 2389 | 2390 | Options: 2391 | -host= Host system [GOVC_HOST] 2392 | ``` 2393 | 2394 | ## host.portgroup.remove 2395 | 2396 | ``` 2397 | Usage: govc host.portgroup.remove [OPTIONS] NAME 2398 | 2399 | Remove portgroup from HOST. 2400 | 2401 | Examples: 2402 | govc host.portgroup.remove bridge 2403 | 2404 | Options: 2405 | -host= Host system [GOVC_HOST] 2406 | ``` 2407 | 2408 | ## host.reconnect 2409 | 2410 | ``` 2411 | Usage: govc host.reconnect [OPTIONS] 2412 | 2413 | Reconnect HOST to vCenter. 2414 | 2415 | This command can also be used to change connection properties (hostname, fingerprint, username, password), 2416 | without disconnecting the host. 2417 | 2418 | Options: 2419 | -force=false Force when host is managed by another VC 2420 | -host= Host system [GOVC_HOST] 2421 | -hostname= Hostname or IP address of the host 2422 | -noverify=false Accept host thumbprint without verification 2423 | -password= Password of administration account on the host 2424 | -sync-state=false Sync state 2425 | -thumbprint= SHA-1 thumbprint of the host's SSL certificate 2426 | -username= Username of administration account on the host 2427 | ``` 2428 | 2429 | ## host.remove 2430 | 2431 | ``` 2432 | Usage: govc host.remove [OPTIONS] HOST... 2433 | 2434 | Remove HOST from vCenter. 2435 | 2436 | Options: 2437 | -host= Host system [GOVC_HOST] 2438 | ``` 2439 | 2440 | ## host.service 2441 | 2442 | ``` 2443 | Usage: govc host.service [OPTIONS] ACTION ID 2444 | 2445 | Apply host service ACTION to service ID. 2446 | 2447 | Where ACTION is one of: start, stop, restart, status, enable, disable 2448 | 2449 | Examples: 2450 | govc host.service enable TSM-SSH 2451 | govc host.service start TSM-SSH 2452 | 2453 | Options: 2454 | -host= Host system [GOVC_HOST] 2455 | ``` 2456 | 2457 | ## host.service.ls 2458 | 2459 | ``` 2460 | Usage: govc host.service.ls [OPTIONS] 2461 | 2462 | List HOST services. 2463 | 2464 | Options: 2465 | -host= Host system [GOVC_HOST] 2466 | ``` 2467 | 2468 | ## host.shutdown 2469 | 2470 | ``` 2471 | Usage: govc host.shutdown [OPTIONS] HOST... 2472 | 2473 | Shutdown HOST. 2474 | 2475 | Options: 2476 | -f=false Force shutdown when host is not in maintenance mode 2477 | -host= Host system [GOVC_HOST] 2478 | -r=false Reboot host 2479 | ``` 2480 | 2481 | ## host.storage.info 2482 | 2483 | ``` 2484 | Usage: govc host.storage.info [OPTIONS] 2485 | 2486 | Show HOST storage system information. 2487 | 2488 | Examples: 2489 | govc find / -type h | xargs -n1 govc host.storage.info -unclaimed -host 2490 | 2491 | Options: 2492 | -host= Host system [GOVC_HOST] 2493 | -refresh=false Refresh the storage system provider 2494 | -rescan=false Rescan all host bus adapters 2495 | -rescan-vmfs=false Rescan for new VMFSs 2496 | -t=lun Type (hba,lun) 2497 | -unclaimed=false Only show disks that can be used as new VMFS datastores 2498 | ``` 2499 | 2500 | ## host.storage.mark 2501 | 2502 | ``` 2503 | Usage: govc host.storage.mark [OPTIONS] DEVICE_PATH 2504 | 2505 | Mark device at DEVICE_PATH. 2506 | 2507 | Options: 2508 | -host= Host system [GOVC_HOST] 2509 | -local= Mark as local 2510 | -ssd= Mark as SSD 2511 | ``` 2512 | 2513 | ## host.storage.partition 2514 | 2515 | ``` 2516 | Usage: govc host.storage.partition [OPTIONS] DEVICE_PATH 2517 | 2518 | Show partition table for device at DEVICE_PATH. 2519 | 2520 | Options: 2521 | -host= Host system [GOVC_HOST] 2522 | ``` 2523 | 2524 | ## host.vnic.info 2525 | 2526 | ``` 2527 | Usage: govc host.vnic.info [OPTIONS] 2528 | 2529 | Options: 2530 | -host= Host system [GOVC_HOST] 2531 | ``` 2532 | 2533 | ## host.vnic.service 2534 | 2535 | ``` 2536 | Usage: govc host.vnic.service [OPTIONS] SERVICE DEVICE 2537 | 2538 | 2539 | Enable or disable service on a virtual nic device. 2540 | 2541 | Where SERVICE is one of: vmotion|faultToleranceLogging|vSphereReplication|vSphereReplicationNFC|management|vsan|vSphereProvisioning 2542 | Where DEVICE is one of: vmk0|vmk1|... 2543 | 2544 | Examples: 2545 | govc host.vnic.service -host hostname -enable vsan vmk0 2546 | govc host.vnic.service -host hostname -enable=false vmotion vmk1 2547 | 2548 | Options: 2549 | -enable=true Enable service 2550 | -host= Host system [GOVC_HOST] 2551 | ``` 2552 | 2553 | ## host.vswitch.add 2554 | 2555 | ``` 2556 | Usage: govc host.vswitch.add [OPTIONS] NAME 2557 | 2558 | Options: 2559 | -host= Host system [GOVC_HOST] 2560 | -mtu=0 MTU 2561 | -nic= Bridge nic device 2562 | -ports=128 Number of ports 2563 | ``` 2564 | 2565 | ## host.vswitch.info 2566 | 2567 | ``` 2568 | Usage: govc host.vswitch.info [OPTIONS] 2569 | 2570 | Options: 2571 | -host= Host system [GOVC_HOST] 2572 | ``` 2573 | 2574 | ## host.vswitch.remove 2575 | 2576 | ``` 2577 | Usage: govc host.vswitch.remove [OPTIONS] NAME 2578 | 2579 | Options: 2580 | -host= Host system [GOVC_HOST] 2581 | ``` 2582 | 2583 | ## import.ova 2584 | 2585 | ``` 2586 | Usage: govc import.ova [OPTIONS] PATH_TO_OVA 2587 | 2588 | Options: 2589 | -ds= Datastore [GOVC_DATASTORE] 2590 | -folder= Inventory folder [GOVC_FOLDER] 2591 | -host= Host system [GOVC_HOST] 2592 | -name= Name to use for new entity 2593 | -options= Options spec file path for VM deployment 2594 | -pool= Resource pool [GOVC_RESOURCE_POOL] 2595 | ``` 2596 | 2597 | ## import.ovf 2598 | 2599 | ``` 2600 | Usage: govc import.ovf [OPTIONS] PATH_TO_OVF 2601 | 2602 | Options: 2603 | -ds= Datastore [GOVC_DATASTORE] 2604 | -folder= Inventory folder [GOVC_FOLDER] 2605 | -host= Host system [GOVC_HOST] 2606 | -name= Name to use for new entity 2607 | -options= Options spec file path for VM deployment 2608 | -pool= Resource pool [GOVC_RESOURCE_POOL] 2609 | ``` 2610 | 2611 | ## import.spec 2612 | 2613 | ``` 2614 | Usage: govc import.spec [OPTIONS] PATH_TO_OVF_OR_OVA 2615 | 2616 | Options: 2617 | -verbose=false Verbose spec output 2618 | ``` 2619 | 2620 | ## import.vmdk 2621 | 2622 | ``` 2623 | Usage: govc import.vmdk [OPTIONS] PATH_TO_VMDK [REMOTE_DIRECTORY] 2624 | 2625 | Options: 2626 | -ds= Datastore [GOVC_DATASTORE] 2627 | -folder= Inventory folder [GOVC_FOLDER] 2628 | -force=false Overwrite existing disk 2629 | -pool= Resource pool [GOVC_RESOURCE_POOL] 2630 | ``` 2631 | 2632 | ## license.add 2633 | 2634 | ``` 2635 | Usage: govc license.add [OPTIONS] KEY... 2636 | 2637 | Options: 2638 | ``` 2639 | 2640 | ## license.assign 2641 | 2642 | ``` 2643 | Usage: govc license.assign [OPTIONS] KEY 2644 | 2645 | Assign licenses to HOST or CLUSTER. 2646 | 2647 | Examples: 2648 | govc license.assign $VCSA_LICENSE_KEY 2649 | govc license.assign -host a_host.example.com $ESX_LICENSE_KEY 2650 | govc license.assign -cluster a_cluster $VSAN_LICENSE_KEY 2651 | 2652 | Options: 2653 | -cluster= Cluster [GOVC_CLUSTER] 2654 | -host= Host system [GOVC_HOST] 2655 | -name= Display name 2656 | -remove=false Remove assignment 2657 | ``` 2658 | 2659 | ## license.assigned.ls 2660 | 2661 | ``` 2662 | Usage: govc license.assigned.ls [OPTIONS] 2663 | 2664 | Options: 2665 | -id= Entity ID 2666 | ``` 2667 | 2668 | ## license.decode 2669 | 2670 | ``` 2671 | Usage: govc license.decode [OPTIONS] KEY... 2672 | 2673 | Options: 2674 | -feature= List licenses with given feature 2675 | ``` 2676 | 2677 | ## license.label.set 2678 | 2679 | ``` 2680 | Usage: govc license.label.set [OPTIONS] LICENSE KEY VAL 2681 | 2682 | Set license labels. 2683 | 2684 | Examples: 2685 | govc license.label.set 00000-00000-00000-00000-00000 team cnx # add/set label 2686 | govc license.label.set 00000-00000-00000-00000-00000 team "" # remove label 2687 | govc license.ls -json | jq '.[] | select(.Labels[].Key == "team") | .LicenseKey' 2688 | 2689 | Options: 2690 | ``` 2691 | 2692 | ## license.ls 2693 | 2694 | ``` 2695 | Usage: govc license.ls [OPTIONS] 2696 | 2697 | Options: 2698 | -feature= List licenses with given feature 2699 | ``` 2700 | 2701 | ## license.remove 2702 | 2703 | ``` 2704 | Usage: govc license.remove [OPTIONS] KEY... 2705 | 2706 | Options: 2707 | ``` 2708 | 2709 | ## logs 2710 | 2711 | ``` 2712 | Usage: govc logs [OPTIONS] 2713 | 2714 | View VPX and ESX logs. 2715 | 2716 | The '-log' option defaults to "hostd" when connected directly to a host or 2717 | when connected to VirtualCenter and a '-host' option is given. Otherwise, 2718 | the '-log' option defaults to "vpxd:vpxd.log". The '-host' option is ignored 2719 | when connected directly to a host. See 'govc logs.ls' for other '-log' options. 2720 | 2721 | Examples: 2722 | govc logs -n 1000 -f 2723 | govc logs -host esx1 2724 | govc logs -host esx1 -log vmkernel 2725 | 2726 | Options: 2727 | -f=false Follow log file changes 2728 | -host= Host system [GOVC_HOST] 2729 | -log= Log file key 2730 | -n=25 Output the last N log lines 2731 | ``` 2732 | 2733 | ## logs.download 2734 | 2735 | ``` 2736 | Usage: govc logs.download [OPTIONS] [PATH]... 2737 | 2738 | Generate diagnostic bundles. 2739 | 2740 | A diagnostic bundle includes log files and other configuration information. 2741 | 2742 | Use PATH to include a specific set of hosts to include. 2743 | 2744 | Examples: 2745 | govc logs.download 2746 | govc logs.download host-a host-b 2747 | 2748 | Options: 2749 | -default=true Specifies if the bundle should include the default server 2750 | ``` 2751 | 2752 | ## logs.ls 2753 | 2754 | ``` 2755 | Usage: govc logs.ls [OPTIONS] 2756 | 2757 | List diagnostic log keys. 2758 | 2759 | Examples: 2760 | govc logs.ls 2761 | govc logs.ls -host host-a 2762 | 2763 | Options: 2764 | -host= Host system [GOVC_HOST] 2765 | ``` 2766 | 2767 | ## ls 2768 | 2769 | ``` 2770 | Usage: govc ls [OPTIONS] [PATH]... 2771 | 2772 | List inventory items. 2773 | 2774 | Examples: 2775 | govc ls -l '*' 2776 | govc ls -t ClusterComputeResource host 2777 | govc ls -t Datastore host/ClusterA/* | grep -v local | xargs -n1 basename | sort | uniq 2778 | 2779 | Options: 2780 | -L=false Follow managed object references 2781 | -i=false Print the managed object reference 2782 | -l=false Long listing format 2783 | -t= Object type 2784 | ``` 2785 | 2786 | ## metric.change 2787 | 2788 | ``` 2789 | Usage: govc metric.change [OPTIONS] NAME... 2790 | 2791 | Change counter NAME levels. 2792 | 2793 | Examples: 2794 | govc metric.change -level 1 net.bytesRx.average net.bytesTx.average 2795 | 2796 | Options: 2797 | -device-level=0 Level for the per device counter 2798 | -i=0 Interval ID 2799 | -level=0 Level for the aggregate counter 2800 | ``` 2801 | 2802 | ## metric.info 2803 | 2804 | ``` 2805 | Usage: govc metric.info [OPTIONS] PATH [NAME]... 2806 | 2807 | Metric info for NAME. 2808 | 2809 | If PATH is a value other than '-', provider summary and instance list are included 2810 | for the given object type. 2811 | 2812 | If NAME is not specified, all available metrics for the given INTERVAL are listed. 2813 | An object PATH must be provided in this case. 2814 | 2815 | Examples: 2816 | govc metric.info vm/my-vm 2817 | govc metric.info -i 300 vm/my-vm 2818 | govc metric.info - cpu.usage.average 2819 | govc metric.info /dc1/host/cluster cpu.usage.average 2820 | 2821 | Options: 2822 | -i=0 Interval ID 2823 | ``` 2824 | 2825 | ## metric.interval.change 2826 | 2827 | ``` 2828 | Usage: govc metric.interval.change [OPTIONS] 2829 | 2830 | Change historical metric intervals. 2831 | 2832 | Examples: 2833 | govc metric.interval.change -i 300 -level 2 2834 | govc metric.interval.change -i 86400 -enabled=false 2835 | 2836 | Options: 2837 | -enabled= Enable or disable 2838 | -i=0 Interval ID 2839 | -level=0 Level 2840 | ``` 2841 | 2842 | ## metric.interval.info 2843 | 2844 | ``` 2845 | Usage: govc metric.interval.info [OPTIONS] 2846 | 2847 | List historical metric intervals. 2848 | 2849 | Examples: 2850 | govc metric.interval.info 2851 | govc metric.interval.info -i 300 2852 | 2853 | Options: 2854 | -i=0 Interval ID 2855 | ``` 2856 | 2857 | ## metric.ls 2858 | 2859 | ``` 2860 | Usage: govc metric.ls [OPTIONS] PATH 2861 | 2862 | List available metrics for PATH. 2863 | 2864 | Examples: 2865 | govc metric.ls /dc1/host/cluster1 2866 | govc metric.ls datastore/* 2867 | govc metric.ls vm/* | grep mem. | xargs govc metric.sample vm/* 2868 | 2869 | Options: 2870 | -i=0 Interval ID 2871 | -l=false Long listing format 2872 | ``` 2873 | 2874 | ## metric.reset 2875 | 2876 | ``` 2877 | Usage: govc metric.reset [OPTIONS] NAME... 2878 | 2879 | Reset counter NAME to the default level of data collection. 2880 | 2881 | Examples: 2882 | govc metric.reset net.bytesRx.average net.bytesTx.average 2883 | 2884 | Options: 2885 | -i=0 Interval ID 2886 | ``` 2887 | 2888 | ## metric.sample 2889 | 2890 | ``` 2891 | Usage: govc metric.sample [OPTIONS] PATH... NAME... 2892 | 2893 | Sample for object PATH of metric NAME. 2894 | 2895 | Interval ID defaults to 20 (realtime) if supported, otherwise 300 (5m interval). 2896 | 2897 | By default, INSTANCE '*' samples all instances and the aggregate counter. 2898 | An INSTANCE value of '-' will only sample the aggregate counter. 2899 | An INSTANCE value other than '*' or '-' will only sample the given instance counter. 2900 | 2901 | If PLOT value is set to '-', output a gnuplot script. If non-empty with another 2902 | value, PLOT will pipe the script to gnuplot for you. The value is also used to set 2903 | the gnuplot 'terminal' variable, unless the value is that of the DISPLAY env var. 2904 | Only 1 metric NAME can be specified when the PLOT flag is set. 2905 | 2906 | Examples: 2907 | govc metric.sample host/cluster1/* cpu.usage.average 2908 | govc metric.sample -plot .png host/cluster1/* cpu.usage.average | xargs open 2909 | govc metric.sample vm/* net.bytesTx.average net.bytesTx.average 2910 | govc metric.sample -instance vmnic0 vm/* net.bytesTx.average 2911 | govc metric.sample -instance - vm/* net.bytesTx.average 2912 | 2913 | Options: 2914 | -d=30 Limit object display name to D chars 2915 | -i=0 Interval ID 2916 | -instance=* Instance 2917 | -n=6 Max number of samples 2918 | -plot= Plot data using gnuplot 2919 | -t=false Include sample times 2920 | ``` 2921 | 2922 | ## object.collect 2923 | 2924 | ``` 2925 | Usage: govc object.collect [OPTIONS] [MOID] [PROPERTY]... 2926 | 2927 | Collect managed object properties. 2928 | 2929 | MOID can be an inventory path or ManagedObjectReference. 2930 | MOID defaults to '-', an alias for 'ServiceInstance:ServiceInstance' or the root folder if a '-type' flag is given. 2931 | 2932 | If a '-type' flag is given, properties are collected using a ContainerView object where MOID is the root of the view. 2933 | 2934 | By default only the current property value(s) are collected. To wait for updates, use the '-n' flag or 2935 | specify a property filter. A property filter can be specified by prefixing the property name with a '-', 2936 | followed by the value to match. 2937 | 2938 | The '-R' flag sets the Filter using the given XML encoded request, which can be captured by 'vcsim -trace' for example. 2939 | It can be useful for replaying property filters created by other clients and converting filters to Go code via '-O -dump'. 2940 | 2941 | Examples: 2942 | govc object.collect - content 2943 | govc object.collect -s HostSystem:ha-host hardware.systemInfo.uuid 2944 | govc object.collect -s /ha-datacenter/vm/foo overallStatus 2945 | govc object.collect -s /ha-datacenter/vm/foo -guest.guestOperationsReady true # property filter 2946 | govc object.collect -type m / name runtime.powerState # collect properties for multiple objects 2947 | govc object.collect -json -n=-1 EventManager:ha-eventmgr latestEvent | jq . 2948 | govc object.collect -json -s $(govc object.collect -s - content.perfManager) description.counterType | jq . 2949 | govc object.collect -R create-filter-request.xml # replay filter 2950 | govc object.collect -R create-filter-request.xml -O # convert filter to Go code 2951 | govc object.collect -s vm/my-vm summary.runtime.host | xargs govc ls -L # inventory path of VM's host 2952 | govc object.collect -json -type m / config.hardware.device | \ # use -json + jq to search array elements 2953 | jq -r '. | select(.ChangeSet[].Val.VirtualDevice[].MacAddress == "00:50:56:bc:5e:3c") | \ 2954 | [.Obj.Type, .Obj.Value] | join(":")' | xargs govc ls -L 2955 | 2956 | Options: 2957 | -O=false Output the CreateFilter request itself 2958 | -R= Raw XML encoded CreateFilter request 2959 | -n=0 Wait for N property updates 2960 | -s=false Output property value only 2961 | -type=[] Resource type. If specified, MOID is used for a container view root 2962 | -wait=0s Max wait time for updates 2963 | ``` 2964 | 2965 | ## object.destroy 2966 | 2967 | ``` 2968 | Usage: govc object.destroy [OPTIONS] PATH... 2969 | 2970 | Destroy managed objects. 2971 | 2972 | Examples: 2973 | govc object.destroy /dc1/network/dvs /dc1/host/cluster 2974 | 2975 | Options: 2976 | ``` 2977 | 2978 | ## object.method 2979 | 2980 | ``` 2981 | Usage: govc object.method [OPTIONS] PATH... 2982 | 2983 | Enable or disable methods for managed objects. 2984 | 2985 | Examples: 2986 | govc object.method -name Destroy_Task -enable=false /dc1/vm/foo 2987 | govc object.collect /dc1/vm/foo disabledMethod | grep --color Destroy_Task 2988 | govc object.method -name Destroy_Task -enable /dc1/vm/foo 2989 | 2990 | Options: 2991 | -enable=true Enable method 2992 | -name= Method name 2993 | -reason= Reason for disabling method 2994 | -source=govc Source ID 2995 | ``` 2996 | 2997 | ## object.mv 2998 | 2999 | ``` 3000 | Usage: govc object.mv [OPTIONS] PATH... FOLDER 3001 | 3002 | Move managed entities to FOLDER. 3003 | 3004 | Examples: 3005 | govc folder.create /dc1/host/example 3006 | govc object.mv /dc2/host/*.example.com /dc1/host/example 3007 | 3008 | Options: 3009 | ``` 3010 | 3011 | ## object.reload 3012 | 3013 | ``` 3014 | Usage: govc object.reload [OPTIONS] PATH... 3015 | 3016 | Reload managed object state. 3017 | 3018 | Examples: 3019 | govc datastore.upload $vm.vmx $vm/$vm.vmx 3020 | govc object.reload /dc1/vm/$vm 3021 | 3022 | Options: 3023 | ``` 3024 | 3025 | ## object.rename 3026 | 3027 | ``` 3028 | Usage: govc object.rename [OPTIONS] PATH NAME 3029 | 3030 | Rename managed objects. 3031 | 3032 | Examples: 3033 | govc object.rename /dc1/network/dvs1 Switch1 3034 | 3035 | Options: 3036 | ``` 3037 | 3038 | ## option.ls 3039 | 3040 | ``` 3041 | Usage: govc option.ls [OPTIONS] [NAME] 3042 | 3043 | List option with the given NAME. 3044 | 3045 | If NAME ends with a dot, all options for that subtree are listed. 3046 | 3047 | Examples: 3048 | govc option.ls 3049 | govc option.ls config.vpxd.sso. 3050 | govc option.ls config.vpxd.sso.sts.uri 3051 | 3052 | Options: 3053 | ``` 3054 | 3055 | ## option.set 3056 | 3057 | ``` 3058 | Usage: govc option.set [OPTIONS] NAME VALUE 3059 | 3060 | Set option NAME to VALUE. 3061 | 3062 | Examples: 3063 | govc option.set log.level info 3064 | govc option.set logger.Vsan verbose 3065 | 3066 | Options: 3067 | ``` 3068 | 3069 | ## permissions.ls 3070 | 3071 | ``` 3072 | Usage: govc permissions.ls [OPTIONS] [PATH]... 3073 | 3074 | List the permissions defined on or effective on managed entities. 3075 | 3076 | Examples: 3077 | govc permissions.ls 3078 | govc permissions.ls /dc1/host/cluster1 3079 | 3080 | Options: 3081 | -a=true Include inherited permissions defined by parent entities 3082 | -i=false Use moref instead of inventory path 3083 | ``` 3084 | 3085 | ## permissions.remove 3086 | 3087 | ``` 3088 | Usage: govc permissions.remove [OPTIONS] [PATH]... 3089 | 3090 | Removes a permission rule from managed entities. 3091 | 3092 | Examples: 3093 | govc permissions.remove -principal root 3094 | govc permissions.remove -principal $USER@vsphere.local /dc1/host/cluster1 3095 | 3096 | Options: 3097 | -group=false True, if principal refers to a group name; false, for a user name 3098 | -i=false Use moref instead of inventory path 3099 | -principal= User or group for which the permission is defined 3100 | ``` 3101 | 3102 | ## permissions.set 3103 | 3104 | ``` 3105 | Usage: govc permissions.set [OPTIONS] [PATH]... 3106 | 3107 | Set the permissions managed entities. 3108 | 3109 | Examples: 3110 | govc permissions.set -principal root -role Admin 3111 | govc permissions.set -principal $USER@vsphere.local -role Admin /dc1/host/cluster1 3112 | 3113 | Options: 3114 | -group=false True, if principal refers to a group name; false, for a user name 3115 | -i=false Use moref instead of inventory path 3116 | -principal= User or group for which the permission is defined 3117 | -propagate=true Whether or not this permission propagates down the hierarchy to sub-entities 3118 | -role=Admin Permission role name 3119 | ``` 3120 | 3121 | ## pool.change 3122 | 3123 | ``` 3124 | Usage: govc pool.change [OPTIONS] POOL... 3125 | 3126 | Change the configuration of one or more resource POOLs. 3127 | 3128 | POOL may be an absolute or relative path to a resource pool or a (clustered) 3129 | compute host. If it resolves to a compute host, the associated root resource 3130 | pool is returned. If a relative path is specified, it is resolved with respect 3131 | to the current datacenter's "host" folder (i.e. /ha-datacenter/host). 3132 | 3133 | Paths to nested resource pools must traverse through the root resource pool of 3134 | the selected compute host, i.e. "compute-host/Resources/nested-pool". 3135 | 3136 | The same globbing rules that apply to the "ls" command apply here. For example, 3137 | POOL may be specified as "*/Resources/*" to expand to all resource pools that 3138 | are nested one level under the root resource pool, on all (clustered) compute 3139 | hosts in the current datacenter. 3140 | 3141 | Options: 3142 | -cpu.expandable= CPU expandable reservation 3143 | -cpu.limit= CPU limit in MHz 3144 | -cpu.reservation= CPU reservation in MHz 3145 | -cpu.shares= CPU shares level or number 3146 | -mem.expandable= Memory expandable reservation 3147 | -mem.limit= Memory limit in MB 3148 | -mem.reservation= Memory reservation in MB 3149 | -mem.shares= Memory shares level or number 3150 | -name= Resource pool name 3151 | ``` 3152 | 3153 | ## pool.create 3154 | 3155 | ``` 3156 | Usage: govc pool.create [OPTIONS] POOL... 3157 | 3158 | Create one or more resource POOLs. 3159 | 3160 | POOL may be an absolute or relative path to a resource pool. The parent of the 3161 | specified POOL must be an existing resource pool. If a relative path is 3162 | specified, it is resolved with respect to the current datacenter's "host" 3163 | folder (i.e. /ha-datacenter/host). The basename of the specified POOL is used 3164 | as the name for the new resource pool. 3165 | 3166 | The same globbing rules that apply to the "ls" command apply here. For example, 3167 | the path to the parent resource pool in POOL may be specified as "*/Resources" 3168 | to expand to the root resource pools on all (clustered) compute hosts in the 3169 | current datacenter. 3170 | 3171 | For example: 3172 | */Resources/test Create resource pool "test" on all (clustered) 3173 | compute hosts in the current datacenter. 3174 | somehost/Resources/*/nested Create resource pool "nested" in every 3175 | resource pool that is a direct descendant of 3176 | the root resource pool on "somehost". 3177 | 3178 | Options: 3179 | -cpu.expandable=true CPU expandable reservation 3180 | -cpu.limit=-1 CPU limit in MHz 3181 | -cpu.reservation=0 CPU reservation in MHz 3182 | -cpu.shares=normal CPU shares level or number 3183 | -mem.expandable=true Memory expandable reservation 3184 | -mem.limit=-1 Memory limit in MB 3185 | -mem.reservation=0 Memory reservation in MB 3186 | -mem.shares=normal Memory shares level or number 3187 | ``` 3188 | 3189 | ## pool.destroy 3190 | 3191 | ``` 3192 | Usage: govc pool.destroy [OPTIONS] POOL... 3193 | 3194 | Destroy one or more resource POOLs. 3195 | 3196 | POOL may be an absolute or relative path to a resource pool or a (clustered) 3197 | compute host. If it resolves to a compute host, the associated root resource 3198 | pool is returned. If a relative path is specified, it is resolved with respect 3199 | to the current datacenter's "host" folder (i.e. /ha-datacenter/host). 3200 | 3201 | Paths to nested resource pools must traverse through the root resource pool of 3202 | the selected compute host, i.e. "compute-host/Resources/nested-pool". 3203 | 3204 | The same globbing rules that apply to the "ls" command apply here. For example, 3205 | POOL may be specified as "*/Resources/*" to expand to all resource pools that 3206 | are nested one level under the root resource pool, on all (clustered) compute 3207 | hosts in the current datacenter. 3208 | 3209 | Options: 3210 | -children=false Remove all children pools 3211 | ``` 3212 | 3213 | ## pool.info 3214 | 3215 | ``` 3216 | Usage: govc pool.info [OPTIONS] POOL... 3217 | 3218 | Retrieve information about one or more resource POOLs. 3219 | 3220 | POOL may be an absolute or relative path to a resource pool or a (clustered) 3221 | compute host. If it resolves to a compute host, the associated root resource 3222 | pool is returned. If a relative path is specified, it is resolved with respect 3223 | to the current datacenter's "host" folder (i.e. /ha-datacenter/host). 3224 | 3225 | Paths to nested resource pools must traverse through the root resource pool of 3226 | the selected compute host, i.e. "compute-host/Resources/nested-pool". 3227 | 3228 | The same globbing rules that apply to the "ls" command apply here. For example, 3229 | POOL may be specified as "*/Resources/*" to expand to all resource pools that 3230 | are nested one level under the root resource pool, on all (clustered) compute 3231 | hosts in the current datacenter. 3232 | 3233 | Options: 3234 | -a=false List virtual app resource pools 3235 | -p=true List resource pools 3236 | ``` 3237 | 3238 | ## role.create 3239 | 3240 | ``` 3241 | Usage: govc role.create [OPTIONS] NAME [PRIVILEGE]... 3242 | 3243 | Create authorization role. 3244 | 3245 | Optionally populate the role with the given PRIVILEGE(s). 3246 | 3247 | Examples: 3248 | govc role.create MyRole 3249 | govc role.create NoDC $(govc role.ls Admin | grep -v Datacenter.) 3250 | 3251 | Options: 3252 | -i=false Use moref instead of inventory path 3253 | ``` 3254 | 3255 | ## role.ls 3256 | 3257 | ``` 3258 | Usage: govc role.ls [OPTIONS] [NAME] 3259 | 3260 | List authorization roles. 3261 | 3262 | If NAME is provided, list privileges for the role. 3263 | 3264 | Examples: 3265 | govc role.ls 3266 | govc role.ls Admin 3267 | 3268 | Options: 3269 | -i=false Use moref instead of inventory path 3270 | ``` 3271 | 3272 | ## role.remove 3273 | 3274 | ``` 3275 | Usage: govc role.remove [OPTIONS] NAME 3276 | 3277 | Remove authorization role. 3278 | 3279 | Examples: 3280 | govc role.remove MyRole 3281 | govc role.remove MyRole -force 3282 | 3283 | Options: 3284 | -force=false Force removal if role is in use 3285 | -i=false Use moref instead of inventory path 3286 | ``` 3287 | 3288 | ## role.update 3289 | 3290 | ``` 3291 | Usage: govc role.update [OPTIONS] NAME [PRIVILEGE]... 3292 | 3293 | Update authorization role. 3294 | 3295 | Set, Add or Remove role PRIVILEGE(s). 3296 | 3297 | Examples: 3298 | govc role.update MyRole $(govc role.ls Admin | grep VirtualMachine.) 3299 | govc role.update -r MyRole $(govc role.ls Admin | grep VirtualMachine.GuestOperations.) 3300 | govc role.update -a MyRole $(govc role.ls Admin | grep Datastore.) 3301 | govc role.update -name RockNRole MyRole 3302 | 3303 | Options: 3304 | -a=false Add given PRIVILEGE(s) 3305 | -i=false Use moref instead of inventory path 3306 | -name= Change role name 3307 | -r=false Remove given PRIVILEGE(s) 3308 | ``` 3309 | 3310 | ## role.usage 3311 | 3312 | ``` 3313 | Usage: govc role.usage [OPTIONS] NAME... 3314 | 3315 | List usage for role NAME. 3316 | 3317 | Examples: 3318 | govc role.usage 3319 | govc role.usage Admin 3320 | 3321 | Options: 3322 | -i=false Use moref instead of inventory path 3323 | ``` 3324 | 3325 | ## session.login 3326 | 3327 | ``` 3328 | Usage: govc session.login [OPTIONS] 3329 | 3330 | Session login. 3331 | 3332 | The session.login command is optional, all other govc commands will auto login when given credentials. 3333 | The session.login command can be used to: 3334 | - Persist a session without writing to disk via the '-cookie' flag 3335 | - Acquire a clone ticket 3336 | - Login using a clone ticket 3337 | - Login using a vCenter Extension certificate 3338 | - Issue a SAML token 3339 | - Renew a SAML token 3340 | - Login using a SAML token 3341 | - Avoid passing credentials to other govc commands 3342 | 3343 | Examples: 3344 | govc session.login -u root:password@host 3345 | ticket=$(govc session.login -u root@host -clone) 3346 | govc session.login -u root@host -ticket $ticket 3347 | govc session.login -u host -extension com.vmware.vsan.health -cert rui.crt -key rui.key 3348 | token=$(govc session.login -u host -cert user.crt -key user.key -issue) # HoK token 3349 | bearer=$(govc session.login -u user:pass@host -issue) # Bearer token 3350 | token=$(govc session.login -u host -cert user.crt -key user.key -issue -token "$bearer") 3351 | govc session.login -u host -cert user.crt -key user.key -token "$token" 3352 | token=$(govc session.login -u host -cert user.crt -key user.key -renew -lifetime 24h -token "$token") 3353 | 3354 | Options: 3355 | -clone=false Acquire clone ticket 3356 | -cookie= Set HTTP cookie for an existing session 3357 | -extension= Extension name 3358 | -issue=false Issue SAML token 3359 | -l=false Output session cookie 3360 | -lifetime=10m0s SAML token lifetime 3361 | -renew=false Renew SAML token 3362 | -ticket= Use clone ticket for login 3363 | -token= Use SAML token for login or as issue identity 3364 | ``` 3365 | 3366 | ## session.logout 3367 | 3368 | ``` 3369 | Usage: govc session.logout [OPTIONS] 3370 | 3371 | Logout the current session. 3372 | 3373 | The session.logout command can be used to end the current persisted session. 3374 | The session.rm command can be used to remove sessions other than the current session. 3375 | 3376 | Examples: 3377 | govc session.logout 3378 | 3379 | Options: 3380 | ``` 3381 | 3382 | ## session.ls 3383 | 3384 | ``` 3385 | Usage: govc session.ls [OPTIONS] 3386 | 3387 | List active sessions. 3388 | 3389 | Examples: 3390 | govc session.ls 3391 | govc session.ls -json | jq -r .CurrentSession.Key 3392 | 3393 | Options: 3394 | ``` 3395 | 3396 | ## session.rm 3397 | 3398 | ``` 3399 | Usage: govc session.rm [OPTIONS] KEY... 3400 | 3401 | Remove active sessions. 3402 | 3403 | Examples: 3404 | govc session.ls | grep root 3405 | govc session.rm 5279e245-e6f1-4533-4455-eb94353b213a 3406 | 3407 | Options: 3408 | ``` 3409 | 3410 | ## snapshot.create 3411 | 3412 | ``` 3413 | Usage: govc snapshot.create [OPTIONS] NAME 3414 | 3415 | Create snapshot of VM with NAME. 3416 | 3417 | Examples: 3418 | govc snapshot.create -vm my-vm happy-vm-state 3419 | 3420 | Options: 3421 | -d= Snapshot description 3422 | -m=true Include memory state 3423 | -q=false Quiesce guest file system 3424 | -vm= Virtual machine [GOVC_VM] 3425 | ``` 3426 | 3427 | ## snapshot.remove 3428 | 3429 | ``` 3430 | Usage: govc snapshot.remove [OPTIONS] NAME 3431 | 3432 | Remove snapshot of VM with given NAME. 3433 | 3434 | NAME can be the snapshot name, tree path, moid or '*' to remove all snapshots. 3435 | 3436 | Examples: 3437 | govc snapshot.remove -vm my-vm happy-vm-state 3438 | 3439 | Options: 3440 | -c=true Consolidate disks 3441 | -r=false Remove snapshot children 3442 | -vm= Virtual machine [GOVC_VM] 3443 | ``` 3444 | 3445 | ## snapshot.revert 3446 | 3447 | ``` 3448 | Usage: govc snapshot.revert [OPTIONS] [NAME] 3449 | 3450 | Revert to snapshot of VM with given NAME. 3451 | 3452 | If NAME is not provided, revert to the current snapshot. 3453 | Otherwise, NAME can be the snapshot name, tree path or moid. 3454 | 3455 | Examples: 3456 | govc snapshot.revert -vm my-vm happy-vm-state 3457 | 3458 | Options: 3459 | -s=false Suppress power on 3460 | -vm= Virtual machine [GOVC_VM] 3461 | ``` 3462 | 3463 | ## snapshot.tree 3464 | 3465 | ``` 3466 | Usage: govc snapshot.tree [OPTIONS] 3467 | 3468 | List VM snapshots in a tree-like format. 3469 | 3470 | The command will exit 0 with no output if VM does not have any snapshots. 3471 | 3472 | Examples: 3473 | govc snapshot.tree -vm my-vm 3474 | govc snapshot.tree -vm my-vm -D -i 3475 | 3476 | Options: 3477 | -C=false Print the current snapshot name only 3478 | -D=false Print the snapshot creation date 3479 | -c=true Print the current snapshot 3480 | -f=false Print the full path prefix for snapshot 3481 | -i=false Print the snapshot id 3482 | -vm= Virtual machine [GOVC_VM] 3483 | ``` 3484 | 3485 | ## sso.service.ls 3486 | 3487 | ``` 3488 | Usage: govc sso.service.ls [OPTIONS] 3489 | 3490 | List platform services. 3491 | 3492 | Examples: 3493 | govc sso.service.ls 3494 | govc sso.service.ls -t vcenterserver -P vmomi 3495 | govc sso.service.ls -t sso:sts 3496 | govc sso.service.ls -t sso:sts -U 3497 | govc sso.service.ls -t sso:sts -json | jq -r .[].ServiceEndpoints[].Url 3498 | 3499 | Options: 3500 | -P= Endpoint protocol 3501 | -T= Endpoint type 3502 | -U=false List endpoint URL(s) only 3503 | -l=false Long listing format 3504 | -n= Node ID 3505 | -p= Service product 3506 | -s= Site ID 3507 | -t= Service type 3508 | ``` 3509 | 3510 | ## sso.user.create 3511 | 3512 | ``` 3513 | Usage: govc sso.user.create [OPTIONS] NAME 3514 | 3515 | Create SSO users. 3516 | 3517 | Examples: 3518 | govc sso.user.create -C "$(cat cert.pem)" -A -R Administrator NAME # solution user 3519 | govc sso.user.create -p password NAME # person user 3520 | 3521 | Options: 3522 | -A= ActAsUser role for solution user WSTrust 3523 | -C= Certificate for solution user 3524 | -R= Role for solution user (RegularUser|Administrator) 3525 | -d= User description 3526 | -f= First name 3527 | -l= Last name 3528 | -m= Email address 3529 | -p= Password 3530 | ``` 3531 | 3532 | ## sso.user.id 3533 | 3534 | ``` 3535 | Usage: govc sso.user.id [OPTIONS] NAME 3536 | 3537 | Print SSO user and group IDs. 3538 | 3539 | Examples: 3540 | govc sso.user.id 3541 | govc sso.user.id Administrator 3542 | govc sso.user.id -json Administrator 3543 | 3544 | Options: 3545 | ``` 3546 | 3547 | ## sso.user.ls 3548 | 3549 | ``` 3550 | Usage: govc sso.user.ls [OPTIONS] 3551 | 3552 | List SSO users. 3553 | 3554 | Examples: 3555 | govc sso.user.ls -s 3556 | 3557 | Options: 3558 | -s=false List solution users 3559 | ``` 3560 | 3561 | ## sso.user.rm 3562 | 3563 | ``` 3564 | Usage: govc sso.user.rm [OPTIONS] NAME 3565 | 3566 | Remove SSO users. 3567 | 3568 | Examples: 3569 | govc sso.user.rm NAME 3570 | 3571 | Options: 3572 | ``` 3573 | 3574 | ## sso.user.update 3575 | 3576 | ``` 3577 | Usage: govc sso.user.update [OPTIONS] NAME 3578 | 3579 | Update SSO users. 3580 | 3581 | Examples: 3582 | govc sso.user.update -C "$(cat cert.pem)" NAME 3583 | govc sso.user.update -p password NAME 3584 | 3585 | Options: 3586 | -A= ActAsUser role for solution user WSTrust 3587 | -C= Certificate for solution user 3588 | -R= Role for solution user (RegularUser|Administrator) 3589 | -d= User description 3590 | -f= First name 3591 | -l= Last name 3592 | -m= Email address 3593 | -p= Password 3594 | ``` 3595 | 3596 | ## tags.attach 3597 | 3598 | ``` 3599 | Usage: govc tags.attach [OPTIONS] NAME PATH 3600 | 3601 | Attach tag NAME to object PATH. 3602 | 3603 | Examples: 3604 | govc tags.attach k8s-region-us /dc1 3605 | govc tags.attach -c k8s-region us-ca1 /dc1/host/cluster1 3606 | 3607 | Options: 3608 | -c= Tag category 3609 | ``` 3610 | 3611 | ## tags.attached.ls 3612 | 3613 | ``` 3614 | Usage: govc tags.attached.ls [OPTIONS] NAME 3615 | 3616 | List attached tags or objects. 3617 | 3618 | Examples: 3619 | govc tags.attached.ls k8s-region-us 3620 | govc tags.attached.ls -json k8s-zone-us-ca1 | jq . 3621 | govc tags.attached.ls -r /dc1/host/cluster1 3622 | govc tags.attached.ls -json -r /dc1 | jq . 3623 | 3624 | Options: 3625 | -r=false List tags attached to resource 3626 | ``` 3627 | 3628 | ## tags.category.create 3629 | 3630 | ``` 3631 | Usage: govc tags.category.create [OPTIONS] NAME 3632 | 3633 | Create tag category. 3634 | 3635 | This command will output the ID of the new tag category. 3636 | 3637 | Examples: 3638 | govc tags.category.create -d "Kubernetes region" -t Datacenter k8s-region 3639 | govc tags.category.create -d "Kubernetes zone" k8s-zone 3640 | 3641 | Options: 3642 | -d= Description 3643 | -m=false Allow multiple tags per object 3644 | -t=[] Object types 3645 | ``` 3646 | 3647 | ## tags.category.info 3648 | 3649 | ``` 3650 | Usage: govc tags.category.info [OPTIONS] [NAME] 3651 | 3652 | Display category info. 3653 | 3654 | If NAME is provided, display info for only that category. 3655 | Otherwise display info for all categories. 3656 | 3657 | Examples: 3658 | govc tags.category.info 3659 | govc tags.category.info k8s-zone 3660 | 3661 | Options: 3662 | ``` 3663 | 3664 | ## tags.category.ls 3665 | 3666 | ``` 3667 | Usage: govc tags.category.ls [OPTIONS] 3668 | 3669 | List all categories. 3670 | 3671 | Examples: 3672 | govc tags.category.ls 3673 | govc tags.category.ls -json | jq . 3674 | 3675 | Options: 3676 | ``` 3677 | 3678 | ## tags.category.rm 3679 | 3680 | ``` 3681 | Usage: govc tags.category.rm [OPTIONS] NAME 3682 | 3683 | Delete category NAME. 3684 | 3685 | Fails if category is used by any tag, unless the '-f' flag is provided. 3686 | 3687 | Examples: 3688 | govc tags.category.rm k8s-region 3689 | govc tags.category.rm -f k8s-zone 3690 | 3691 | Options: 3692 | -f=false Delete tag regardless of attached objects 3693 | ``` 3694 | 3695 | ## tags.category.update 3696 | 3697 | ``` 3698 | Usage: govc tags.category.update [OPTIONS] NAME 3699 | 3700 | Update category. 3701 | 3702 | The '-t' flag can only be used to add new object types. Removing category types is not supported by vCenter. 3703 | 3704 | Examples: 3705 | govc tags.category.update -n k8s-vcp-region -d "Kubernetes VCP region" k8s-region 3706 | govc tags.category.update -t ClusterComputeResource k8s-zone 3707 | 3708 | Options: 3709 | -d= Description 3710 | -m= Allow multiple tags per object 3711 | -n= Name of category 3712 | -t=[] Object types 3713 | ``` 3714 | 3715 | ## tags.create 3716 | 3717 | ``` 3718 | Usage: govc tags.create [OPTIONS] NAME 3719 | 3720 | Create tag. 3721 | 3722 | The '-c' option to specify a tag category is required. 3723 | This command will output the ID of the new tag. 3724 | 3725 | Examples: 3726 | govc tags.create -d "Kubernetes Zone US CA1" -c k8s-zone k8s-zone-us-ca1 3727 | 3728 | Options: 3729 | -c= Category name 3730 | -d= Description of tag 3731 | ``` 3732 | 3733 | ## tags.detach 3734 | 3735 | ``` 3736 | Usage: govc tags.detach [OPTIONS] NAME PATH 3737 | 3738 | Detach tag NAME from object PATH. 3739 | 3740 | Examples: 3741 | govc tags.detach k8s-region-us /dc1 3742 | govc tags.detach -c k8s-region us-ca1 /dc1/host/cluster1 3743 | 3744 | Options: 3745 | -c= Tag category 3746 | ``` 3747 | 3748 | ## tags.info 3749 | 3750 | ``` 3751 | Usage: govc tags.info [OPTIONS] NAME 3752 | 3753 | Display tags info. 3754 | 3755 | If NAME is provided, display info for only that tag. Otherwise display info for all tags. 3756 | 3757 | Examples: 3758 | govc tags.info 3759 | govc tags.info k8s-zone-us-ca1 3760 | govc tags.info -c k8s-zone 3761 | 3762 | Options: 3763 | -C=true Display category name instead of ID 3764 | -c= Category name 3765 | ``` 3766 | 3767 | ## tags.ls 3768 | 3769 | ``` 3770 | Usage: govc tags.ls [OPTIONS] 3771 | 3772 | List tags. 3773 | 3774 | Examples: 3775 | govc tags.ls 3776 | govc tags.ls -c k8s-zone 3777 | govc tags.ls -json | jq . 3778 | govc tags.ls -c k8s-region -json | jq . 3779 | 3780 | Options: 3781 | -c= Category name 3782 | ``` 3783 | 3784 | ## tags.rm 3785 | 3786 | ``` 3787 | Usage: govc tags.rm [OPTIONS] NAME 3788 | 3789 | Delete tag NAME. 3790 | 3791 | Fails if tag is attached to any object, unless the '-f' flag is provided. 3792 | 3793 | Examples: 3794 | govc tags.rm k8s-zone-us-ca1 3795 | govc tags.rm -f -c k8s-zone us-ca2 3796 | 3797 | Options: 3798 | -c= Tag category 3799 | -f=false Delete tag regardless of attached objects 3800 | ``` 3801 | 3802 | ## tags.update 3803 | 3804 | ``` 3805 | Usage: govc tags.update [OPTIONS] NAME 3806 | 3807 | Update tag. 3808 | 3809 | Examples: 3810 | govc tags.update -d "K8s zone US-CA1" k8s-zone-us-ca1 3811 | govc tags.update -d "K8s zone US-CA1" -c k8s-zone us-ca1 3812 | 3813 | Options: 3814 | -c= Tag category 3815 | -d= Description of tag 3816 | -n= Name of tag 3817 | ``` 3818 | 3819 | ## task.cancel 3820 | 3821 | ``` 3822 | Usage: govc task.cancel [OPTIONS] ID... 3823 | 3824 | Cancel tasks. 3825 | 3826 | Examples: 3827 | govc task.cancel task-759 3828 | 3829 | Options: 3830 | ``` 3831 | 3832 | ## tasks 3833 | 3834 | ``` 3835 | Usage: govc tasks [OPTIONS] [PATH] 3836 | 3837 | Display info for recent tasks. 3838 | 3839 | When a task has completed, the result column includes the task duration on success or 3840 | error message on failure. If a task is still in progress, the result column displays 3841 | the completion percentage and the task ID. The task ID can be used as an argument to 3842 | the 'task.cancel' command. 3843 | 3844 | By default, all recent tasks are included (via TaskManager), but can be limited by PATH 3845 | to a specific inventory object. 3846 | 3847 | Examples: 3848 | govc tasks 3849 | govc tasks -f 3850 | govc tasks -f /dc1/host/cluster1 3851 | 3852 | Options: 3853 | -f=false Follow recent task updates 3854 | -l=false Use long task description 3855 | -n=25 Output the last N tasks 3856 | ``` 3857 | 3858 | ## vapp.destroy 3859 | 3860 | ``` 3861 | Usage: govc vapp.destroy [OPTIONS] VAPP... 3862 | 3863 | Options: 3864 | ``` 3865 | 3866 | ## vapp.power 3867 | 3868 | ``` 3869 | Usage: govc vapp.power [OPTIONS] 3870 | 3871 | Options: 3872 | -force=false Force (If force is false, the shutdown order in the vApp is executed. If force is true, all virtual machines are powered-off (regardless of shutdown order)) 3873 | -off=false Power off 3874 | -on=false Power on 3875 | -suspend=false Power suspend 3876 | -vapp.ipath= Find vapp by inventory path 3877 | ``` 3878 | 3879 | ## version 3880 | 3881 | ``` 3882 | Usage: govc version [OPTIONS] 3883 | 3884 | Options: 3885 | -require= Require govc version >= this value 3886 | ``` 3887 | 3888 | ## vm.change 3889 | 3890 | ``` 3891 | Usage: govc vm.change [OPTIONS] 3892 | 3893 | Change VM configuration. 3894 | 3895 | To add ExtraConfig variables that can read within the guest, use the 'guestinfo.' prefix. 3896 | 3897 | Examples: 3898 | govc vm.change -vm $vm -mem.reservation 2048 3899 | govc vm.change -vm $vm -e smc.present=TRUE -e ich7m.present=TRUE 3900 | # Enable both cpu and memory hotplug on a guest: 3901 | govc vm.change -vm $vm -e vcpu.hotadd=true -e mem.hotadd=true 3902 | govc vm.change -vm $vm -e guestinfo.vmname $vm 3903 | # Read the variable set above inside the guest: 3904 | vmware-rpctool "info-get guestinfo.vmname" 3905 | 3906 | Options: 3907 | -annotation= VM description 3908 | -c=0 Number of CPUs 3909 | -cpu.limit= CPU limit in MHz 3910 | -cpu.reservation= CPU reservation in MHz 3911 | -cpu.shares= CPU shares level or number 3912 | -e=[] ExtraConfig. = 3913 | -g= Guest OS 3914 | -m=0 Size in MB of memory 3915 | -mem.limit= Memory limit in MB 3916 | -mem.reservation= Memory reservation in MB 3917 | -mem.shares= Memory shares level or number 3918 | -name= Display name 3919 | -nested-hv-enabled= Enable nested hardware-assisted virtualization 3920 | -sync-time-with-host= Enable SyncTimeWithHost 3921 | -vm= Virtual machine [GOVC_VM] 3922 | ``` 3923 | 3924 | ## vm.clone 3925 | 3926 | ``` 3927 | Usage: govc vm.clone [OPTIONS] NAME 3928 | 3929 | Clone VM to NAME. 3930 | 3931 | Examples: 3932 | govc vm.clone -vm template-vm new-vm 3933 | govc vm.clone -vm template-vm -link new-vm 3934 | govc vm.clone -vm template-vm -snapshot s-name new-vm 3935 | govc vm.clone -vm template-vm -link -snapshot s-name new-vm 3936 | govc vm.clone -vm template-vm -snapshot $(govc snapshot.tree -vm template-vm -C) new-vm 3937 | 3938 | Options: 3939 | -annotation= VM description 3940 | -c=0 Number of CPUs 3941 | -customization= Customization Specification Name 3942 | -datastore-cluster= Datastore cluster [GOVC_DATASTORE_CLUSTER] 3943 | -ds= Datastore [GOVC_DATASTORE] 3944 | -folder= Inventory folder [GOVC_FOLDER] 3945 | -force=false Create VM if vmx already exists 3946 | -host= Host system [GOVC_HOST] 3947 | -link=false Creates a linked clone from snapshot or source VM 3948 | -m=0 Size in MB of memory 3949 | -net= Network [GOVC_NETWORK] 3950 | -net.adapter=e1000 Network adapter type 3951 | -net.address= Network hardware address 3952 | -on=true Power on VM 3953 | -pool= Resource pool [GOVC_RESOURCE_POOL] 3954 | -snapshot= Snapshot name to clone from 3955 | -template=false Create a Template 3956 | -vm= Virtual machine [GOVC_VM] 3957 | -waitip=false Wait for VM to acquire IP address 3958 | ``` 3959 | 3960 | ## vm.console 3961 | 3962 | ``` 3963 | Usage: govc vm.console [OPTIONS] VM 3964 | 3965 | Generate console URL or screen capture for VM. 3966 | 3967 | One of VMRC, VMware Player, VMware Fusion or VMware Workstation must be installed to 3968 | open VMRC console URLs. 3969 | 3970 | Examples: 3971 | govc vm.console my-vm 3972 | govc vm.console -capture screen.png my-vm # screen capture 3973 | govc vm.console -capture - my-vm | display # screen capture to stdout 3974 | open $(govc vm.console my-vm) # MacOSX VMRC 3975 | open $(govc vm.console -h5 my-vm) # MacOSX H5 3976 | xdg-open $(govc vm.console my-vm) # Linux VMRC 3977 | xdg-open $(govc vm.console -h5 my-vm) # Linux H5 3978 | 3979 | Options: 3980 | -capture= Capture console screen shot to file 3981 | -h5=false Generate HTML5 UI console link 3982 | -vm= Virtual machine [GOVC_VM] 3983 | ``` 3984 | 3985 | ## vm.create 3986 | 3987 | ``` 3988 | Usage: govc vm.create [OPTIONS] NAME 3989 | 3990 | Create VM. 3991 | 3992 | For a list of possible '-g' IDs, see: 3993 | http://pubs.vmware.com/vsphere-6-5/topic/com.vmware.wssdk.apiref.doc/vim.vm.GuestOsDescriptor.GuestOsIdentifier.html 3994 | 3995 | Examples: 3996 | govc vm.create vm-name 3997 | govc vm.create -m 2048 -c 2 -g freebsd64Guest -net.adapter vmxnet3 -disk.controller pvscsi vm-name 3998 | 3999 | Options: 4000 | -annotation= VM description 4001 | -c=1 Number of CPUs 4002 | -datastore-cluster= Datastore cluster [GOVC_DATASTORE_CLUSTER] 4003 | -disk= Disk path (to use existing) OR size (to create new, e.g. 20GB) 4004 | -disk-datastore= Datastore for disk file 4005 | -disk.controller=scsi Disk controller type 4006 | -ds= Datastore [GOVC_DATASTORE] 4007 | -firmware=bios Firmware type [bios|efi] 4008 | -folder= Inventory folder [GOVC_FOLDER] 4009 | -force=false Create VM if vmx already exists 4010 | -g=otherGuest Guest OS ID 4011 | -host= Host system [GOVC_HOST] 4012 | -iso= ISO path 4013 | -iso-datastore= Datastore for ISO file 4014 | -link=true Link specified disk 4015 | -m=1024 Size in MB of memory 4016 | -net= Network [GOVC_NETWORK] 4017 | -net.adapter=e1000 Network adapter type 4018 | -net.address= Network hardware address 4019 | -on=true Power on VM. Default is true if -disk argument is given. 4020 | -pool= Resource pool [GOVC_RESOURCE_POOL] 4021 | -version= ESXi hardware version [5.5|6.0|6.5|6.7] 4022 | ``` 4023 | 4024 | ## vm.destroy 4025 | 4026 | ``` 4027 | Usage: govc vm.destroy [OPTIONS] VM... 4028 | 4029 | Power off and delete VM. 4030 | 4031 | When a VM is destroyed, any attached virtual disks are also deleted. 4032 | Use the 'device.remove -vm VM -keep disk-*' command to detach and 4033 | keep disks if needed, prior to calling vm.destroy. 4034 | 4035 | Examples: 4036 | govc vm.destroy my-vm 4037 | 4038 | Options: 4039 | ``` 4040 | 4041 | ## vm.disk.attach 4042 | 4043 | ``` 4044 | Usage: govc vm.disk.attach [OPTIONS] 4045 | 4046 | Attach existing disk to VM. 4047 | 4048 | Examples: 4049 | govc vm.disk.attach -vm $name -disk $name/disk1.vmdk 4050 | govc vm.disk.attach -vm $name -disk $name/shared.vmdk -link=false -sharing sharingMultiWriter 4051 | govc device.remove -vm $name -keep disk-* # detach disk(s) 4052 | 4053 | Options: 4054 | -controller= Disk controller 4055 | -disk= Disk path name 4056 | -ds= Datastore [GOVC_DATASTORE] 4057 | -link=true Link specified disk 4058 | -mode= Disk mode (persistent|nonpersistent|undoable|independent_persistent|independent_nonpersistent|append) 4059 | -persist=true Persist attached disk 4060 | -sharing= Sharing (sharingNone|sharingMultiWriter) 4061 | -vm= Virtual machine [GOVC_VM] 4062 | ``` 4063 | 4064 | ## vm.disk.change 4065 | 4066 | ``` 4067 | Usage: govc vm.disk.change [OPTIONS] 4068 | 4069 | Change some properties of a VM's DISK 4070 | 4071 | In particular, you can change the DISK mode, and the size (as long as it is bigger) 4072 | 4073 | Examples: 4074 | govc vm.disk.change -vm VM -disk.key 2001 -size 10G 4075 | govc vm.disk.change -vm VM -disk.label "BDD disk" -size 10G 4076 | govc vm.disk.change -vm VM -disk.name "hard-1000-0" -size 12G 4077 | govc vm.disk.change -vm VM -disk.filePath "[DS] VM/VM-1.vmdk" -mode nonpersistent 4078 | 4079 | Options: 4080 | -disk.filePath= Disk file name 4081 | -disk.key=0 Disk unique key 4082 | -disk.label= Disk label 4083 | -disk.name= Disk name 4084 | -mode= Disk mode (persistent|nonpersistent|undoable|independent_persistent|independent_nonpersistent|append) 4085 | -sharing= Sharing (sharingNone|sharingMultiWriter) 4086 | -size=0B New disk size 4087 | -vm= Virtual machine [GOVC_VM] 4088 | ``` 4089 | 4090 | ## vm.disk.create 4091 | 4092 | ``` 4093 | Usage: govc vm.disk.create [OPTIONS] 4094 | 4095 | Create disk and attach to VM. 4096 | 4097 | Examples: 4098 | govc vm.disk.create -vm $name -name $name/disk1 -size 10G 4099 | govc vm.disk.create -vm $name -name $name/disk2 -size 10G -eager -thick -sharing sharingMultiWriter 4100 | 4101 | Options: 4102 | -controller= Disk controller 4103 | -ds= Datastore [GOVC_DATASTORE] 4104 | -eager=false Eagerly scrub new disk 4105 | -mode=persistent Disk mode (persistent|nonpersistent|undoable|independent_persistent|independent_nonpersistent|append) 4106 | -name= Name for new disk 4107 | -sharing= Sharing (sharingNone|sharingMultiWriter) 4108 | -size=10.0GB Size of new disk 4109 | -thick=false Thick provision new disk 4110 | -vm= Virtual machine [GOVC_VM] 4111 | ``` 4112 | 4113 | ## vm.guest.tools 4114 | 4115 | ``` 4116 | Usage: govc vm.guest.tools [OPTIONS] VM... 4117 | 4118 | Manage guest tools in VM. 4119 | 4120 | Examples: 4121 | govc vm.guest.tools -mount VM 4122 | govc vm.guest.tools -unmount VM 4123 | govc vm.guest.tools -upgrade -options "opt1 opt2" VM 4124 | 4125 | Options: 4126 | -mount=false Mount tools CD installer in the guest 4127 | -options= Installer options 4128 | -unmount=false Unmount tools CD installer in the guest 4129 | -upgrade=false Upgrade tools in the guest 4130 | ``` 4131 | 4132 | ## vm.info 4133 | 4134 | ``` 4135 | Usage: govc vm.info [OPTIONS] VM... 4136 | 4137 | Display info for VM. 4138 | 4139 | Examples: 4140 | govc vm.info $vm 4141 | govc vm.info -json $vm 4142 | govc find . -type m -runtime.powerState poweredOn | xargs govc vm.info 4143 | 4144 | Options: 4145 | -e=false Show ExtraConfig 4146 | -g=true Show general summary 4147 | -r=false Show resource summary 4148 | -t=false Show ToolsConfigInfo 4149 | -waitip=false Wait for VM to acquire IP address 4150 | ``` 4151 | 4152 | ## vm.ip 4153 | 4154 | ``` 4155 | Usage: govc vm.ip [OPTIONS] VM... 4156 | 4157 | List IPs for VM. 4158 | 4159 | By default the vm.ip command depends on vmware-tools to report the 'guest.ipAddress' field and will 4160 | wait until it has done so. This value can also be obtained using: 4161 | 4162 | govc vm.info -json $vm | jq -r .VirtualMachines[].Guest.IpAddress 4163 | 4164 | When given the '-a' flag, only IP addresses for which there is a corresponding virtual nic are listed. 4165 | If there are multiple nics, the listed addresses will be comma delimited. The '-a' flag depends on 4166 | vmware-tools to report the 'guest.net' field and will wait until it has done so for all nics. 4167 | Note that this list includes IPv6 addresses if any, use '-v4' to filter them out. IP addresses reported 4168 | by tools for which there is no virtual nic are not included, for example that of the 'docker0' interface. 4169 | 4170 | These values can also be obtained using: 4171 | 4172 | govc vm.info -json $vm | jq -r .VirtualMachines[].Guest.Net[].IpConfig.IpAddress[].IpAddress 4173 | 4174 | When given the '-n' flag, filters '-a' behavior to the nic specified by MAC address or device name. 4175 | 4176 | The 'esxcli' flag does not require vmware-tools to be installed, but does require the ESX host to 4177 | have the /Net/GuestIPHack setting enabled. 4178 | 4179 | The 'wait' flag default to 1hr (original default was infinite). If a VM does not obtain an IP within 4180 | the wait time, the command will still exit with status 0. 4181 | 4182 | Examples: 4183 | govc vm.ip $vm 4184 | govc vm.ip -wait 5m $vm 4185 | govc vm.ip -a -v4 $vm 4186 | govc vm.ip -n 00:0c:29:57:7b:c3 $vm 4187 | govc vm.ip -n ethernet-0 $vm 4188 | govc host.esxcli system settings advanced set -o /Net/GuestIPHack -i 1 4189 | govc vm.ip -esxcli $vm 4190 | 4191 | Options: 4192 | -a=false Wait for an IP address on all NICs 4193 | -esxcli=false Use esxcli instead of guest tools 4194 | -n= Wait for IP address on NIC, specified by device name or MAC 4195 | -v4=false Only report IPv4 addresses 4196 | -wait=1h0m0s Wait time for the VM obtain an IP address 4197 | ``` 4198 | 4199 | ## vm.keystrokes 4200 | 4201 | ``` 4202 | Usage: govc vm.keystrokes [OPTIONS] VM 4203 | 4204 | Send Keystrokes to VM. 4205 | 4206 | Examples: 4207 | Default Scenario 4208 | govc vm.keystrokes -vm $vm -s "root" # writes 'root' to the console 4209 | govc vm.keystrokes -vm $vm -c 0x15 # writes an 'r' to the console 4210 | govc vm.keystrokes -vm $vm -r 1376263 # writes an 'r' to the console 4211 | govc vm.keystrokes -vm $vm -c 0x28 # presses ENTER on the console 4212 | govc vm.keystrokes -vm $vm -c 0x4c -la true -lc true # sends CTRL+ALT+DEL to console 4213 | 4214 | Options: 4215 | -c= USB HID Code (hex) 4216 | -la=false Enable/Disable Left Alt 4217 | -lc=false Enable/Disable Left Control 4218 | -lg=false Enable/Disable Left Gui 4219 | -ls=false Enable/Disable Left Shift 4220 | -r=0 Raw USB HID Code Value (int32) 4221 | -ra=false Enable/Disable Right Alt 4222 | -rc=false Enable/Disable Right Control 4223 | -rg=false Enable/Disable Right Gui 4224 | -rs=false Enable/Disable Right Shift 4225 | -s= Raw String to Send 4226 | -vm= Virtual machine [GOVC_VM] 4227 | ``` 4228 | 4229 | ## vm.markastemplate 4230 | 4231 | ``` 4232 | Usage: govc vm.markastemplate [OPTIONS] VM... 4233 | 4234 | Mark VM as a virtual machine template. 4235 | 4236 | Examples: 4237 | govc vm.markastemplate $name 4238 | 4239 | Options: 4240 | ``` 4241 | 4242 | ## vm.markasvm 4243 | 4244 | ``` 4245 | Usage: govc vm.markasvm [OPTIONS] VM... 4246 | 4247 | Mark VM template as a virtual machine. 4248 | 4249 | Examples: 4250 | govc vm.markasvm $name -host host1 4251 | govc vm.markasvm $name -pool cluster1/Resources 4252 | 4253 | Options: 4254 | -host= Host system [GOVC_HOST] 4255 | -pool= Resource pool [GOVC_RESOURCE_POOL] 4256 | ``` 4257 | 4258 | ## vm.migrate 4259 | 4260 | ``` 4261 | Usage: govc vm.migrate [OPTIONS] VM... 4262 | 4263 | Migrates VM to a specific resource pool, host or datastore. 4264 | 4265 | Examples: 4266 | govc vm.migrate -host another-host vm-1 vm-2 vm-3 4267 | govc vm.migrate -pool another-pool vm-1 vm-2 vm-3 4268 | govc vm.migrate -ds another-ds vm-1 vm-2 vm-3 4269 | 4270 | Options: 4271 | -ds= Datastore [GOVC_DATASTORE] 4272 | -host= Host system [GOVC_HOST] 4273 | -pool= Resource pool [GOVC_RESOURCE_POOL] 4274 | -priority=defaultPriority The task priority 4275 | ``` 4276 | 4277 | ## vm.network.add 4278 | 4279 | ``` 4280 | Usage: govc vm.network.add [OPTIONS] 4281 | 4282 | Add network adapter to VM. 4283 | 4284 | Examples: 4285 | govc vm.network.add -vm $vm -net "VM Network" -net.adapter e1000e 4286 | govc device.info -vm $vm ethernet-* 4287 | 4288 | Options: 4289 | -net= Network [GOVC_NETWORK] 4290 | -net.adapter=e1000 Network adapter type 4291 | -net.address= Network hardware address 4292 | -vm= Virtual machine [GOVC_VM] 4293 | ``` 4294 | 4295 | ## vm.network.change 4296 | 4297 | ``` 4298 | Usage: govc vm.network.change [OPTIONS] DEVICE 4299 | 4300 | Change network DEVICE configuration. 4301 | 4302 | Note that '-net' is currently required with '-net.address', even when not changing the VM network. 4303 | 4304 | Examples: 4305 | govc vm.network.change -vm $vm -net PG2 ethernet-0 4306 | govc vm.network.change -vm $vm -net PG2 -net.address 00:00:0f:2e:5d:69 ethernet-0 4307 | govc device.info -vm $vm ethernet-* 4308 | 4309 | Options: 4310 | -net= Network [GOVC_NETWORK] 4311 | -net.adapter=e1000 Network adapter type 4312 | -net.address= Network hardware address 4313 | -vm= Virtual machine [GOVC_VM] 4314 | ``` 4315 | 4316 | ## vm.option.info 4317 | 4318 | ``` 4319 | Usage: govc vm.option.info [OPTIONS] [GUEST_ID]... 4320 | 4321 | VM config options for CLUSTER. 4322 | 4323 | The config option data contains information about the execution environment for a VM 4324 | in the given CLUSTER, and optionally for a specific HOST. 4325 | 4326 | This command only supports '-json' or '-dump' output, defaulting to the latter. 4327 | 4328 | Examples: 4329 | govc vm.option.info -cluster C0 4330 | govc vm.option.info -cluster C0 ubuntu64Guest 4331 | govc vm.option.info -cluster C0 -json | jq .GuestOSDescriptor[].Id 4332 | govc vm.option.info -host my_hostname 4333 | govc vm.option.info -vm my_vm 4334 | 4335 | Options: 4336 | -cluster= Cluster [GOVC_CLUSTER] 4337 | -host= Host system [GOVC_HOST] 4338 | -vm= Virtual machine [GOVC_VM] 4339 | ``` 4340 | 4341 | ## vm.power 4342 | 4343 | ``` 4344 | Usage: govc vm.power [OPTIONS] 4345 | 4346 | Options: 4347 | -M=false Use Datacenter.PowerOnMultiVM method instead of VirtualMachine.PowerOnVM 4348 | -force=false Force (ignore state error and hard shutdown/reboot if tools unavailable) 4349 | -off=false Power off 4350 | -on=false Power on 4351 | -r=false Reboot guest 4352 | -reset=false Power reset 4353 | -s=false Shutdown guest 4354 | -suspend=false Power suspend 4355 | -wait=true Wait for the operation to complete 4356 | ``` 4357 | 4358 | ## vm.question 4359 | 4360 | ``` 4361 | Usage: govc vm.question [OPTIONS] 4362 | 4363 | Options: 4364 | -answer= Answer to question 4365 | -vm= Virtual machine [GOVC_VM] 4366 | ``` 4367 | 4368 | ## vm.rdm.attach 4369 | 4370 | ``` 4371 | Usage: govc vm.rdm.attach [OPTIONS] 4372 | 4373 | Attach DEVICE to VM with RDM. 4374 | 4375 | Examples: 4376 | govc vm.rdm.attach -vm VM -device /vmfs/devices/disks/naa.000000000000000000000000000000000 4377 | 4378 | Options: 4379 | -device= Device Name 4380 | -vm= Virtual machine [GOVC_VM] 4381 | ``` 4382 | 4383 | ## vm.rdm.ls 4384 | 4385 | ``` 4386 | Usage: govc vm.rdm.ls [OPTIONS] 4387 | 4388 | List available devices that could be attach to VM with RDM. 4389 | 4390 | Examples: 4391 | govc vm.rdm.ls -vm VM 4392 | 4393 | Options: 4394 | -vm= Virtual machine [GOVC_VM] 4395 | ``` 4396 | 4397 | ## vm.register 4398 | 4399 | ``` 4400 | Usage: govc vm.register [OPTIONS] VMX 4401 | 4402 | Add an existing VM to the inventory. 4403 | 4404 | VMX is a path to the vm config file, relative to DATASTORE. 4405 | 4406 | Examples: 4407 | govc vm.register path/name.vmx 4408 | govc vm.register -template -host $host path/name.vmx 4409 | 4410 | Options: 4411 | -ds= Datastore [GOVC_DATASTORE] 4412 | -folder= Inventory folder [GOVC_FOLDER] 4413 | -host= Host system [GOVC_HOST] 4414 | -name= Name of the VM 4415 | -pool= Resource pool [GOVC_RESOURCE_POOL] 4416 | -template=false Mark VM as template 4417 | ``` 4418 | 4419 | ## vm.unregister 4420 | 4421 | ``` 4422 | Usage: govc vm.unregister [OPTIONS] VM... 4423 | 4424 | Remove VM from inventory without removing any of the VM files on disk. 4425 | 4426 | Options: 4427 | ``` 4428 | 4429 | ## vm.upgrade 4430 | 4431 | ``` 4432 | Usage: govc vm.upgrade [OPTIONS] 4433 | 4434 | Upgrade VMs to latest hardware version 4435 | 4436 | Examples: 4437 | govc vm.upgrade -vm $vm_name 4438 | govc vm.upgrade -version=$version -vm $vm_name 4439 | govc vm.upgrade -version=$version -vm.uuid $vm_uuid 4440 | 4441 | Options: 4442 | -version=0 Target vm hardware version, by default -- latest available 4443 | -vm= Virtual machine [GOVC_VM] 4444 | ``` 4445 | 4446 | ## vm.vnc 4447 | 4448 | ``` 4449 | Usage: govc vm.vnc [OPTIONS] VM... 4450 | 4451 | Enable or disable VNC for VM. 4452 | 4453 | Port numbers are automatically chosen if not specified. 4454 | 4455 | If neither -enable or -disable is specified, the current state is returned. 4456 | 4457 | Examples: 4458 | govc vm.vnc -enable -password 1234 $vm | awk '{print $2}' | xargs open 4459 | 4460 | Options: 4461 | -disable=false Disable VNC 4462 | -enable=false Enable VNC 4463 | -password= VNC password 4464 | -port=-1 VNC port (-1 for auto-select) 4465 | -port-range=5900-5999 VNC port auto-select range 4466 | ``` 4467 | 4468 | --------------------------------------------------------------------------------