0

I have a go client initialized to connect to a vCenter as follows. I am trying to get the version of the vCenter using the client. I did not find a very good source for this.

Which arguments to use inside retrieve() API to get the version and other information related to vCenter cluster?

import (
    "context"
    "fmt"
    "net/url"

    "github.com/vmware/govmomi"
)

func main() {

    vURL := url.URL{
        Scheme: "https",
        Host:   "10.30.8.34",
        Path:   "sdk",
    }

    ctx, cancel := context.WithCancel(context.Background())
    defer cancel()

    client, err := govmomi.NewClient(ctx, vURL, true)
    if err != nil {
        fmt.Printf("Logging in error: %s\n", err.Error())
        return
    }

    fmt.Println("Log in successful")
    client.Logout(ctx)
}
AnilJ
  • 1,951
  • 2
  • 33
  • 60
  • 1
    Once you have the govmomi client object, you can use `client.ServiceContent.About.Version` to get the vcenter version – Abhay Gupta May 26 '21 at 17:41

1 Answers1

0

Are you looking for VsanHostConfigInfoEx?

type VsanHostConfigInfoEx struct {
    types.VsanHostConfigInfo

    EncryptionInfo              *VsanHostEncryptionInfo             `xml:"encryptionInfo,omitempty"`
    DataEfficiencyInfo          *VsanDataEfficiencyConfig           `xml:"dataEfficiencyInfo,omitempty"`
    ResyncIopsLimitInfo         *ResyncIopsInfo                     `xml:"resyncIopsLimitInfo,omitempty"`
    ExtendedConfig              *VsanExtendedConfig                 `xml:"extendedConfig,omitempty"`
    DatastoreInfo               BaseVsanDatastoreConfig             `xml:"datastoreInfo,omitempty,typeattr"`
    UnmapConfig                 *VsanUnmapConfig                    `xml:"unmapConfig,omitempty"`
    WitnessHostConfig           []VsanWitnessHostConfig             `xml:"witnessHostConfig,omitempty"`
    InternalExtendedConfig      *VsanInternalExtendedConfig         `xml:"internalExtendedConfig,omitempty"`
    MetricsConfig               *VsanMetricsConfig                  `xml:"metricsConfig,omitempty"`
    UnicastConfig               *VsanHostServerClusterUnicastConfig `xml:"unicastConfig,omitempty"`
    DataInTransitEncryptionInfo *VsanInTransitEncryptionInfo        `xml:"dataInTransitEncryptionInfo,omitempty"`
}

which implements VsanHostConfigInfo

type VsanHostConfigInfo struct {
    DynamicData
    Enabled         *bool                          `xml:"enabled"`
    HostSystem      *ManagedObjectReference        `xml:"hostSystem,omitempty"`
    ClusterInfo     *VsanHostConfigInfoClusterInfo `xml:"clusterInfo,omitempty"`
    StorageInfo     *VsanHostConfigInfoStorageInfo `xml:"storageInfo,omitempty"`
    NetworkInfo     *VsanHostConfigInfoNetworkInfo `xml:"networkInfo,omitempty"`
    FaultDomainInfo *VsanHostFaultDomainInfo       `xml:"faultDomainInfo,omitempty"`
}
s0xzwasd
  • 2,895
  • 3
  • 17
  • 26