{"id":16407785,"url":"https://github.com/collabnix/govc","last_synced_at":"2025-07-11T18:34:32.001Z","repository":{"id":104073612,"uuid":"168514934","full_name":"collabnix/govc","owner":"collabnix","description":"Managing Virtual Infrastructure using GOVC ","archived":false,"fork":false,"pushed_at":"2020-05-12T18:04:59.000Z","size":234,"stargazers_count":29,"open_issues_count":0,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-04T13:21:18.336Z","etag":null,"topics":["go","vmware"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/collabnix.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-31T11:34:08.000Z","updated_at":"2024-12-17T20:26:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"0e48cf75-a042-4aea-a90d-c4df3e142185","html_url":"https://github.com/collabnix/govc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/collabnix/govc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/collabnix%2Fgovc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/collabnix%2Fgovc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/collabnix%2Fgovc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/collabnix%2Fgovc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/collabnix","download_url":"https://codeload.github.com/collabnix/govc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/collabnix%2Fgovc/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264870774,"owners_count":23676298,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","vmware"],"created_at":"2024-10-11T06:14:47.031Z","updated_at":"2025-07-11T18:34:31.973Z","avatar_url":"https://github.com/collabnix.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Managing VMware vSphere Infrastructure using GOVC \n\ngovc is a vSphere CLI built on top of govmomi.\n\nThe CLI is designed to be a user friendly CLI alternative to the GUI and well suited for automation tasks. It also acts as a test harness for the govmomi APIs and provides working examples of how to use the APIs.\n\n![MyImage](https://github.com/collabnix/govc/blob/master/govc-gocmomi.png)\u003cbr\u003e\n\n# Content\n\n[Lab #0 - Getting Started with GOVC](https://github.com/collabnix/govc/blob/master/README.md#installation)\u003cbr\u003e\n[Lab #1 - Creating a New Datacenter](https://github.com/collabnix/govc/blob/master/README.md#lab-1)\u003cbr\u003e\n[Lab #2 - Adding ESXi to the Cluster](https://github.com/collabnix/govc/blob/master/README.md#how-to-add-esxi-host-to-this-cluster)\u003cbr\u003e\n[Lab #3 - Deploy Virtual Machine from ISO Image](https://github.com/collabnix/govc/blob/master/README.md#lab-3)\u003cbr\u003e\n[Lab #4 - Deploy Virtual Machine from template](https://github.com/collabnix/govc/blob/master/README.md#lab-4)\u003cbr\u003e\n[Lab #5 - Demonstrating Storage vMotion](https://github.com/collabnix/govc/blob/master/README.md#lab-5)\u003cbr\u003e\n\n# Ready Scripts\n\n[Configure a vCenter cluster with vSAN datastore, DVS and DVPGs ](https://github.com/collabnix/govc/blob/master/scripts/create-cluster.sh)\u003cbr\u003e\n[Create a Datacenter and connect the underlying ESXi host to vCenter VM](https://github.com/collabnix/govc/blob/master/scripts/create-standalone.sh)\u003cbr\u003e\n[Create a VM and boot stateless ESXi via cdrom/iso](https://github.com/collabnix/govc/blob/master/scripts/create-esxi-vm.sh)\u003cbr\u003e\n[Create VCSA VM](https://github.com/collabnix/govc/blob/master/scripts/create-vcsa-vm.sh)\u003cbr\u003e\n\n\n# List of GOVC Commands\n\n[Overall Commands Available](https://github.com/collabnix/govc/blob/master/cmdlets/USAGE.md)\u003cbr\u003e\n\n## Installation\n\nYou can find prebuilt govc binaries on the releases page.\n\nDownload and install a binary locally like this:\n\n\n## Install GOVC on Ubuntu 18.04\n\n```\nwget https://github.com/vmware/govmomi/releases/download/v0.19.0/govc_linux_amd64.gz\ngunzip govc_linux_amd64.gz\nmv govc_linux_amd64 govc\ncp -rf govc /usr/local/bin/\nchmod +x /usr/local/bin/govc\n```\n\n## Export the credentials:\n\n```\nexport GOVC_URL='root:password@\u003cIPaddress\u003e'\n```\n\n## Disable certificate verification.\n\n```\nexport GOVC_INSECURE=1\n```\n\n## Listing the Datacenter\n\n```\ngovc ls \n```\n\n## Listing ESXi Host \n\n```\n/ha-datacenter/vm\n/ha-datacenter/vm/CSERACKPAS61\n/ha-datacenter/vm/CSELABDNS.local (1)\n```\n\n##  How to do vMotion?\n\nSay, I have VM in datastore1 and I want to migrate it to \"Local\" datastore. I can run the below command to perform it:\n\n```\ngovc vm.migrate -ds Local PhotonOS\n[31-01-19 16:59:43] migrating VirtualMachine:vm-673... OK\n```\n\n## How to disable firewall?\n\n```\ngovc host.esxcli -host=\u003cIP\u003e network firewall set --enabled false\n```\n\n## How to enable sfcb service?\n\n```\n govc host.esxcli -host=\u003cIp\u003e system wbem set -e 1\n```\n\n## How to configure NTP\n\n```\n govc host.date.change -host \u003cIP\u003e  -server \u003cIP\u003e\n govc host.service -host \u003cIP\u003e enable ntpd\n govc host.service -host \u003cIP\u003e start ntpd\n```\n\n## Deploy VM from Template\n\n```\ngovc vm.clone -vm=\u003ctemplate-name\u003e -on=true -waitip=false -host=\u003ctargethostIP\u003e -ds=\u003ctargetdatastore\u003e newVMname\ngovc vm.clone -vm=windows8Server64Guest-template -on=true -waitip=false -host=XXX.XXX.XXX.XXX -ds=ESX67 windows8Server64Guest\n```\n## Create new folder inside datastore\n\n```\ngovc datastore.mkdir -ds=datastorename newfolder\n```\n\n## Copying VM files to different folder\n\n```\ngovc datastore.cp -ds=dastorename VM1/VM1.vmdk newfolder/VM1.vmdk\n```\n\n## Unregistering VM from VC\n\n```\ngovc vm.unregister VMname\n```\n\n\n# Lab #1: \n\n## Creating a new Datacenter\n\n```\ngovc datacenter.create demo\n```\n\n## Fetching Demo Datacenter Information\n\n```\n# govc datacenter.info demo\nName:                demo\n  Path:              /demo\n  Hosts:             0\n  Clusters:          0\n  Virtual Machines:  0\n  Networks:          0\n  Datastores:        0\n\n```\n\n## Creating a new cluster\n\n```\ngovc cluster.create -dc=demo democluster\n\n```\n\n## How to add ESXi Host to this Cluster\n\n- First we need to take care of cert and put it under thumbprint variable\n\n```\nthumbprint=$(govc about.cert -k -u \u003cESXi IP\u003e -thumbprint | awk '{print $2}') \n```\n\n- Now add the ESXi host flawlessly\n\n```\ngovc cluster.add -cluster democluster -hostname \u003cesxi IP\u003e -username root -password \u003cpassword\u003e -thumbprint $thumbprint \n```\n\n\n\n## How to remove ESXI Host from this cluster\n\n- This is a 2 step process. First, put the ESXi host in maintenance mode by running below command:\n\n```\ngovc host.maintenance.enter -dc=demo \u003cESXi IP\u003e \n```\n\n- Now you can remove ESXi\n\n```\ngovc host.remove -dc=demo \u003cESXi IP\u003e\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcollabnix%2Fgovc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcollabnix%2Fgovc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcollabnix%2Fgovc/lists"}