github.com/vmware/govmomi@v0.37.2/scripts/vcsa/create-standalone.sh (about)

     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