From aced3c79067456fa740712aaac510c513ec16a0a Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Thu, 31 Aug 2023 10:13:51 +1000 Subject: [PATCH] chatgpt produces rubbish --- log.txt | 144 ++++++++++++++++++++++++++++++++++++++++++++ main.go | 141 ++++++++++++++++++++++++++++++++++++++++--- packages/chatgpt.go | 116 +++++++++++++++++++++++++++++++++++ 3 files changed, 393 insertions(+), 8 deletions(-) create mode 100644 packages/chatgpt.go diff --git a/log.txt b/log.txt index f949258..3dcc6fe 100644 --- a/log.txt +++ b/log.txt @@ -58,3 +58,147 @@ 2023/08/30 19:39:50 Starting execution. Built on from sha1 2023/08/30 19:39:50 Setting timezone to 'Australia/Sydney' 2023/08/30 19:39:50 Connecting to vCenter https://vc.lab.local/sdk +2023/08/30 19:45:22 Starting execution. Built on from sha1 +2023/08/30 19:45:22 Setting timezone to 'Australia/Sydney' +2023/08/30 19:45:22 Connecting to vCenter https://vc.lab.local/sdk +2023/08/30 19:46:39 Starting execution. Built on from sha1 +2023/08/30 19:46:39 Setting timezone to 'Australia/Sydney' +2023/08/30 19:46:39 Connecting to vCenter https://vc.lab.local/sdk +2023/08/30 19:52:17 Starting execution. Built on from sha1 +2023/08/30 19:52:17 Setting timezone to 'Australia/Sydney' +2023/08/30 19:52:17 Connecting to vCenter https://vc.lab.local/sdk +2023/08/30 19:59:03 Starting execution. Built on from sha1 +2023/08/30 19:59:03 Setting timezone to 'Australia/Sydney' +2023/08/30 19:59:03 Connecting to vCenter https://vc.lab.local/sdk +2023/08/30 19:59:56 Starting execution. Built on from sha1 +2023/08/30 19:59:56 Setting timezone to 'Australia/Sydney' +2023/08/30 19:59:56 Connecting to vCenter https://vc.lab.local/sdk +2023/08/30 20:04:15 Starting execution. Built on from sha1 +2023/08/30 20:04:15 Setting timezone to 'Australia/Sydney' +2023/08/30 20:04:15 Connecting to vCenter https://vc.lab.local/sdk +2023/08/30 20:05:31 Starting execution. Built on from sha1 +2023/08/30 20:05:31 Setting timezone to 'Australia/Sydney' +2023/08/30 20:05:31 Connecting to vCenter https://vc.lab.local/sdk +2023/08/30 20:07:47 Starting execution. Built on from sha1 +2023/08/30 20:07:47 Setting timezone to 'Australia/Sydney' +2023/08/30 20:07:47 Connecting to vCenter https://vc.lab.local/sdk +2023/08/30 20:08:19 Starting execution. Built on from sha1 +2023/08/30 20:08:19 Setting timezone to 'Australia/Sydney' +2023/08/30 20:08:19 Connecting to vCenter https://vc.lab.local/sdk +2023/08/30 20:10:09 Starting execution. Built on from sha1 +2023/08/30 20:10:09 Setting timezone to 'Australia/Sydney' +2023/08/30 20:10:09 Connecting to vCenter https://vc.lab.local/sdk +2023/08/30 20:11:36 Starting execution. Built on from sha1 +2023/08/30 20:11:36 Setting timezone to 'Australia/Sydney' +2023/08/30 20:11:36 Connecting to vCenter https://vc.lab.local/sdk +2023/08/30 20:13:33 Starting execution. Built on from sha1 +2023/08/30 20:13:33 Setting timezone to 'Australia/Sydney' +2023/08/30 20:13:33 Connecting to vCenter https://vc.lab.local/sdk +2023/08/30 20:14:15 Starting execution. Built on from sha1 +2023/08/30 20:14:15 Setting timezone to 'Australia/Sydney' +2023/08/30 20:14:15 Connecting to vCenter https://vc.lab.local/sdk +2023/08/30 20:16:05 Starting execution. Built on from sha1 +2023/08/30 20:16:05 Setting timezone to 'Australia/Sydney' +2023/08/30 20:16:05 Connecting to vCenter https://vc.lab.local/sdk +2023/08/30 20:16:25 Starting execution. Built on from sha1 +2023/08/30 20:16:25 Setting timezone to 'Australia/Sydney' +2023/08/30 20:16:25 Connecting to vCenter https://vc.lab.local/sdk +2023/08/30 20:17:03 Starting execution. Built on from sha1 +2023/08/30 20:17:03 Setting timezone to 'Australia/Sydney' +2023/08/30 20:17:03 Connecting to vCenter https://vc.lab.local/sdk +2023/08/30 20:17:24 Starting execution. Built on from sha1 +2023/08/30 20:17:24 Setting timezone to 'Australia/Sydney' +2023/08/30 20:17:24 Connecting to vCenter https://vc.lab.local/sdk +2023/08/30 20:20:42 Starting execution. Built on from sha1 +2023/08/30 20:20:42 Setting timezone to 'Australia/Sydney' +2023/08/30 20:20:42 Connecting to vCenter https://vc.lab.local/sdk +2023/08/30 20:26:28 Starting execution. Built on from sha1 +2023/08/30 20:26:28 Setting timezone to 'Australia/Sydney' +2023/08/30 20:26:28 Connecting to vCenter https://vc.lab.local/sdk +2023/08/31 08:36:51 Starting execution. Built on from sha1 +2023/08/31 08:36:51 Setting timezone to 'Australia/Sydney' +2023/08/31 08:36:51 Connecting to vCenter https://vc.lab.local/sdk +2023/08/31 08:47:43 Starting execution. Built on from sha1 +2023/08/31 08:47:43 Setting timezone to 'Australia/Sydney' +2023/08/31 08:47:43 Connecting to vCenter https://vc.lab.local/sdk +2023/08/31 08:49:01 Starting execution. Built on from sha1 +2023/08/31 08:49:01 Setting timezone to 'Australia/Sydney' +2023/08/31 08:49:01 Connecting to vCenter https://vc.lab.local/sdk +2023/08/31 08:51:06 Starting execution. Built on from sha1 +2023/08/31 08:51:06 Setting timezone to 'Australia/Sydney' +2023/08/31 08:51:06 Connecting to vCenter https://vc.lab.local/sdk +2023/08/31 08:53:45 Starting execution. Built on from sha1 +2023/08/31 08:53:45 Setting timezone to 'Australia/Sydney' +2023/08/31 08:53:45 Connecting to vCenter https://vc.lab.local/sdk +2023/08/31 08:54:33 Starting execution. Built on from sha1 +2023/08/31 08:54:33 Setting timezone to 'Australia/Sydney' +2023/08/31 08:54:33 Connecting to vCenter https://vc.lab.local/sdk +2023/08/31 08:57:13 Starting execution. Built on from sha1 +2023/08/31 08:57:13 Setting timezone to 'Australia/Sydney' +2023/08/31 08:57:13 Connecting to vCenter https://vc.lab.local/sdk +2023/08/31 09:04:50 Starting execution. Built on from sha1 +2023/08/31 09:04:50 Setting timezone to 'Australia/Sydney' +2023/08/31 09:04:50 Connecting to vCenter https://vc.lab.local/sdk +2023/08/31 09:05:31 Starting execution. Built on from sha1 +2023/08/31 09:05:31 Setting timezone to 'Australia/Sydney' +2023/08/31 09:05:31 Connecting to vCenter https://vc.lab.local/sdk +2023/08/31 09:05:45 Starting execution. Built on from sha1 +2023/08/31 09:05:45 Setting timezone to 'Australia/Sydney' +2023/08/31 09:05:45 Connecting to vCenter https://vc.lab.local/sdk +2023/08/31 09:06:02 Starting execution. Built on from sha1 +2023/08/31 09:06:02 Setting timezone to 'Australia/Sydney' +2023/08/31 09:06:02 Connecting to vCenter https://vc.lab.local/sdk +2023/08/31 09:06:09 Starting execution. Built on from sha1 +2023/08/31 09:06:09 Setting timezone to 'Australia/Sydney' +2023/08/31 09:06:09 Connecting to vCenter https://vc.lab.local/sdk +2023/08/31 09:06:30 Starting execution. Built on from sha1 +2023/08/31 09:06:30 Setting timezone to 'Australia/Sydney' +2023/08/31 09:06:30 Connecting to vCenter https://vc.lab.local/sdk +2023/08/31 09:08:46 Starting execution. Built on from sha1 +2023/08/31 09:08:46 Setting timezone to 'Australia/Sydney' +2023/08/31 09:08:46 Connecting to vCenter https://vc.lab.local/sdk +2023/08/31 09:09:14 Starting execution. Built on from sha1 +2023/08/31 09:09:14 Setting timezone to 'Australia/Sydney' +2023/08/31 09:09:14 Connecting to vCenter https://vc.lab.local/sdk +2023/08/31 09:09:23 Starting execution. Built on from sha1 +2023/08/31 09:09:23 Setting timezone to 'Australia/Sydney' +2023/08/31 09:09:23 Connecting to vCenter https://vc.lab.local/sdk +2023/08/31 09:09:31 Starting execution. Built on from sha1 +2023/08/31 09:09:31 Setting timezone to 'Australia/Sydney' +2023/08/31 09:09:31 Connecting to vCenter https://vc.lab.local/sdk +2023/08/31 09:09:40 Starting execution. Built on from sha1 +2023/08/31 09:09:40 Setting timezone to 'Australia/Sydney' +2023/08/31 09:09:40 Connecting to vCenter https://vc.lab.local/sdk +2023/08/31 09:10:22 Starting execution. Built on from sha1 +2023/08/31 09:10:22 Setting timezone to 'Australia/Sydney' +2023/08/31 09:10:22 Connecting to vCenter https://vc.lab.local/sdk +2023/08/31 09:10:59 Starting execution. Built on from sha1 +2023/08/31 09:10:59 Setting timezone to 'Australia/Sydney' +2023/08/31 09:10:59 Connecting to vCenter https://vc.lab.local/sdk +2023/08/31 09:17:39 Starting execution. Built on from sha1 +2023/08/31 09:17:39 Setting timezone to 'Australia/Sydney' +2023/08/31 09:17:39 Connecting to vCenter https://vc.lab.local/sdk +2023/08/31 09:20:38 Starting execution. Built on from sha1 +2023/08/31 09:20:38 Setting timezone to 'Australia/Sydney' +2023/08/31 09:20:38 Connecting to vCenter https://vc.lab.local/sdk +2023/08/31 09:21:58 Starting execution. Built on from sha1 +2023/08/31 09:21:58 Setting timezone to 'Australia/Sydney' +2023/08/31 09:21:58 Connecting to vCenter https://vc.lab.local/sdk +2023/08/31 09:25:03 Starting execution. Built on from sha1 +2023/08/31 09:25:03 Setting timezone to 'Australia/Sydney' +2023/08/31 09:25:03 Connecting to vCenter https://vc.lab.local/sdk +2023/08/31 09:25:22 Starting execution. Built on from sha1 +2023/08/31 09:25:22 Setting timezone to 'Australia/Sydney' +2023/08/31 09:25:22 Connecting to vCenter https://vc.lab.local/sdk +2023/08/31 09:26:15 Starting execution. Built on from sha1 +2023/08/31 09:26:15 Setting timezone to 'Australia/Sydney' +2023/08/31 09:26:15 Connecting to vCenter https://vc.lab.local/sdk +2023/08/31 09:30:53 Starting execution. Built on from sha1 +2023/08/31 09:30:53 Setting timezone to 'Australia/Sydney' +2023/08/31 09:30:53 Connecting to vCenter https://vc.lab.local/sdk +2023/08/31 09:33:02 Starting execution. Built on from sha1 +2023/08/31 09:33:02 Setting timezone to 'Australia/Sydney' +2023/08/31 09:33:02 Connecting to vCenter https://vc.lab.local/sdk +2023/08/31 09:38:30 Starting execution. Built on from sha1 +2023/08/31 09:38:30 Setting timezone to 'Australia/Sydney' +2023/08/31 09:38:30 Connecting to vCenter https://vc.lab.local/sdk diff --git a/main.go b/main.go index e3c864a..31129b2 100644 --- a/main.go +++ b/main.go @@ -7,6 +7,7 @@ import ( "log" "net/url" "os" + "reflect" "strings" "time" _ "time/tzdata" @@ -14,6 +15,7 @@ import ( "github.com/vmware/govmomi" "github.com/vmware/govmomi/object" "github.com/vmware/govmomi/performance" + "github.com/vmware/govmomi/property" "github.com/vmware/govmomi/view" "github.com/vmware/govmomi/vim25" "github.com/vmware/govmomi/vim25/mo" @@ -72,6 +74,30 @@ func findVMByName(ctx context.Context, client *vim25.Client, vmName string) ([]m return result, nil } +func findClusterByName(ctx context.Context, client *vim25.Client, name string) mo.ClusterComputeResource { + // Create a container view so that we can search vCenter + m := view.NewManager(client) + cv, _ := m.CreateContainerView(ctx, c.ServiceContent.RootFolder, []string{"ClusterComputeResource"}, true) + + var clusters []mo.ClusterComputeResource + log.Printf("Searching for Cluster '%s'\n", name) + err := cv.Retrieve(ctx, []string{"ClusterComputeResource"}, []string{"summary", "name"}, &clusters) + if err != nil { + log.Printf("Failed searching for Cluster %s : %s\n", name, err) + return mo.ClusterComputeResource{} + } else { + for _, cluster := range clusters { + if cluster.Name == name { + log.Printf("Found corresponding Cluster with MoRef '%s'\n", cluster.Reference()) + return cluster + } + } + } + + // If we reached here then we didn't find the Cluster + return mo.ClusterComputeResource{} +} + func getMetricIds(counters []types.PerfCounterInfo) []types.PerfMetricId { var metricIds []types.PerfMetricId for _, counter := range counters { @@ -79,6 +105,7 @@ func getMetricIds(counters []types.PerfCounterInfo) []types.PerfMetricId { metricId.CounterId = counter.Key metricIds = append(metricIds, metricId) } + fmt.Printf("metric IDs : '%v'\n", metricIds) return metricIds } @@ -90,7 +117,8 @@ func getSpecificVMMetrics(ctx context.Context, c *vim25.Client, vmName string) { timeNow := time.Now() // Find the performance counters for CPU Entitlement, CPU Consumed, and CPU Demand - counterNames := []string{"cpu.entitlement.latest", "cpu.usage.average", "cpu.demand.average"} + counterNames := []string{"cpu.entitlement.latest", "cpu.usage.average", "cpu.demand.average", "cpu.readiness.average"} + //counterNames := []string{"cpu.entitlement.latest", "cpu.usage.average"} // Retrieve counters name list counters, err := perfManager.CounterInfoByName(ctx) @@ -105,7 +133,11 @@ func getSpecificVMMetrics(ctx context.Context, c *vim25.Client, vmName string) { for _, counter := range counters { for _, counterName := range counterNames { if counter.Name() == counterName { - fmt.Printf("Found counter matching name '%s' : '%v'\n", counterName, counter.PerDeviceLevel) + groupInfo := counter.GroupInfo.GetElementDescription() + nameInfo := counter.NameInfo.GetElementDescription() + + fmt.Printf("Found counter matching name '%s' : '%s';'%s'\n", counterName, groupInfo, nameInfo) + perfCounterInfos = append(perfCounterInfos, *counter) } else { //fmt.Printf("Ignoring '%s' : '%s'\n", counter.StatsType, counter.Name()) @@ -125,7 +157,7 @@ func getSpecificVMMetrics(ctx context.Context, c *vim25.Client, vmName string) { for _, vm := range vmMatches { // Create PerfQuerySpec as per https://github.com/vmware/govmomi/blob/main/performance/example_test.go spec := types.PerfQuerySpec{ - MaxSample: 1800, + //MaxSample: 180, // In one hour there are 180 instances of 20 second intervals MetricId: getMetricIds(perfCounterInfos), IntervalId: 20, StartTime: &startTime, // 1 hour ago @@ -138,6 +170,13 @@ func getSpecificVMMetrics(ctx context.Context, c *vim25.Client, vmName string) { fmt.Printf("Error getting SampleByName : '%s'\n", err) return } + fmt.Printf("Sample result is %d\n", len(sample)) + + /* + for _, v := range sample { + fmt.Printf("%v\n", v.GetPerfEntityMetricBase().Entity) + } + */ result, err := perfManager.ToMetricSeries(ctx, sample) if err != nil { @@ -156,9 +195,10 @@ func getSpecificVMMetrics(ctx context.Context, c *vim25.Client, vmName string) { return } - fmt.Printf("Vm %s has %d metric values\n", name, len(metric.Value)) + fmt.Printf("Vm %s has %d metric values : %v\n", name, len(metric.Value), metric) - for _, v := range metric.Value { + for i, v := range metric.Value { + fmt.Printf("Processing [%d] : '%v'\n", i, v) counter := counters[v.Name] units := counter.UnitInfo.GetElementDescription().Label @@ -169,11 +209,14 @@ func getSpecificVMMetrics(ctx context.Context, c *vim25.Client, vmName string) { } if len(v.Value) != 0 { - fmt.Printf("%s\t%s\t%s\t%s : %v\n", name, instance, v.Name, units, v.ValueCSV()) + //fmt.Printf("%s\t%s\t%s\t%s : %v\n", name, instance, v.Name, units, v.ValueCSV()) + fmt.Printf("%s\t%s\t%s\t%s : %v (%d)\n", name, instance, v.Name, units, v.Value, len(v.Value)) } } } + fmt.Printf("Finished receiving result.\n") + /* // Create a query specification query := perfManager.QueryPerf(ctx, &vim25.QueryPerf{ @@ -197,6 +240,83 @@ func getSpecificVMMetrics(ctx context.Context, c *vim25.Client, vmName string) { } } +// From https://stackoverflow.com/a/33769379 +func Scan(d interface{}) { + v := reflect.ValueOf(d) + i := reflect.Indirect(v) + s := i.Type() + println(s.NumField()) // will print out 0, if you change Host to have 1 field, it prints out 1 +} + +func query(t reflect.Type) { + value := reflect.New(t).Interface() + Scan(value) +} + +func getNumVmsPerDrsScoreBucket(client *govmomi.Client) error { + //properties := []string{"drsVmConfig.numVmPerDrsScoreBucket"} + properties := []string{"configurationEx"} + ctx := context.Background() + m := view.NewManager(client.Client) + + clusters, err := m.CreateContainerView(ctx, client.ServiceContent.RootFolder, []string{"ClusterComputeResource"}, true) + if err != nil { + return err + } + defer clusters.Destroy(ctx) + + var clusterList []mo.ClusterComputeResource + + err = clusters.Retrieve(ctx, []string{"ClusterComputeResource"}, nil, &clusterList) + if err != nil { + return err + } + + for _, cluster := range clusterList { + fmt.Printf("Cluster: %s\n", cluster.Name) + + pc := property.DefaultCollector(client.Client) + + //var clusterProps *types.ComputeResourceSummary + clusterProps := mo.ClusterComputeResource{} + + err := pc.RetrieveOne(ctx, cluster.Reference(), properties, &clusterProps) + if err != nil { + fmt.Printf("Error retrieving property : '%s'\n", err) + return err + } + + foo := clusterProps.ConfigurationEx + bar := foo.GetComputeResourceConfigInfo() + fmt.Printf("foo: %v\n", foo) + fmt.Printf("bar: %v\n", bar) + + /* + // Print properties (fields) + objType := reflect.TypeOf(clusterProps) + for i := 0; i < objType.NumField(); i++ { + field := objType.Field(i) + fmt.Printf("Field %d: %s (Type: %s)\n", i, field.Name, field.Type) + } + + // Print methods + methods := reflect.TypeOf(clusterProps) + for i := 0; i < methods.NumMethod(); i++ { + method := methods.Method(i) + fmt.Printf("Method %d: %s\n", i, method.Name) + } + */ + + //bar := types.ClusterConfigInfoEx(foo).getNumVmsPerDrsScoreBucket() + //fmt.Printf("%v\n", clusterProps) + + //fmt.Printf("Cluster: %s\n", clusterProps.Name) + //fmt.Printf("NumVmsPerDrsScoreBucket: %d\n", clusterProps.DrsVmConfig.NumVmPerDrsScoreBucket) + } + + return nil +} + func main() { // Command line flags vURL := flag.String("url", "", "The URL of a vCenter server, eg https://server.domain.example/sdk") @@ -204,7 +324,7 @@ func main() { vPass := flag.String("password", "", "The password to use when connecting to vCenter") vTZ := flag.String("tz", "Australia/Sydney", "The timezone to use when converting vCenter UTC times") vInsecure := flag.Bool("insecure", true, "Allow insecure connections to vCenter") - vmName := flag.String("vmname", "example-vm", "The vm to query metrics") + //vmName := flag.String("vmname", "example-vm", "The vm to query metrics") //begin := flag.Duration("b", time.Hour, "Begin time") // default BeginTime is 1h ago flag.Parse() @@ -251,5 +371,10 @@ func main() { } defer c.Logout(ctx) - getSpecificVMMetrics(ctx, c.Client, *vmName) + //getSpecificVMMetrics(ctx, c.Client, *vmName) + err = getNumVmsPerDrsScoreBucket(c) + if err != nil { + fmt.Println("Error retrieving NumVmsPerDrsScoreBucket:", err) + return + } } diff --git a/packages/chatgpt.go b/packages/chatgpt.go new file mode 100644 index 0000000..afee2d5 --- /dev/null +++ b/packages/chatgpt.go @@ -0,0 +1,116 @@ +package chatgpt + +import ( + "context" + "fmt" + "log" + "net/url" + + "github.com/vmware/govmomi" + "github.com/vmware/govmomi/property" + "github.com/vmware/govmomi/view" + "github.com/vmware/govmomi/vim25" + "github.com/vmware/govmomi/vim25/mo" +) + +func connectToVCenter() (*govmomi.Client, error) { + vcenterURL := "https://vc.lab.local/sdk" + vcenterUsername := "nathan" + vcenterPassword := "VMware1!" + + u, err := url.Parse(vcenterURL) + if err != nil { + return nil, err + } + + ctx := context.Background() + client, err := govmomi.NewClient(ctx, u, true) + if err != nil { + return nil, err + } + + err = client.Login(ctx, vcenterUsername, vcenterPassword) + if err != nil { + return nil, err + } + + return client, nil +} + +func getClusterConfigInfoEx(ctx context.Context, clusterRef *vim25.ClusterComputeResource) (*vim25.ClusterConfigInfoEx, error) { + properties := []string{"configurationEx"} + + pc := property.DefaultCollector(clusterRef.Client()) + + var clusterProps vim25.ClusterComputeResource + + err := pc.RetrieveOne(ctx, clusterRef.Reference(), properties, &clusterProps) + if err != nil { + return nil, err + } + + return clusterProps.ConfigurationEx, nil +} + +func findClusterByName(ctx context.Context, client *vim25.Client, name string) mo.ClusterComputeResource { + // Create a container view so that we can search vCenter + m := view.NewManager(client) + cv, _ := m.CreateContainerView(ctx, c.ServiceContent.RootFolder, []string{"ClusterComputeResource"}, true) + + var clusters []mo.ClusterComputeResource + log.Printf("Searching for Cluster '%s'\n", name) + err := cv.Retrieve(ctx, []string{"ClusterComputeResource"}, []string{"summary", "name"}, &clusters) + if err != nil { + log.Printf("Failed searching for Cluster %s : %s\n", name, err) + return mo.ClusterComputeResource{} + } else { + for _, cluster := range clusters { + if cluster.Name == name { + log.Printf("Found corresponding Cluster with MoRef '%s'\n", cluster.Reference()) + return cluster + } + } + } + + // If we reached here then we didn't find the Cluster + return mo.ClusterComputeResource{} +} + +func main() { + client, err := connectToVCenter() + if err != nil { + fmt.Println("Error connecting to vCenter:", err) + return + } + defer client.Logout(context.Background()) + + // Specify the cluster reference based on your environment + // For example: clusterRef := &vim25.ClusterComputeResource{} + clusterRef := findClusterByName(context.Background(), client.Client, "Cluster") + + clusterConfigInfoEx, err := getClusterConfigInfoEx(context.Background(), clusterRef) + if err != nil { + fmt.Println("Error retrieving ClusterConfigInfoEx:", err) + return + } + + // Access and print various data from clusterConfigInfoEx + fmt.Printf("Cluster Name: %s\n", clusterConfigInfoEx.Name) + fmt.Printf("Cluster DRS Enabled: %t\n", clusterConfigInfoEx.DrsConfig.Enabled) + // ... other properties ... + + fmt.Println("Cluster DRS Automation Level:") + fmt.Printf(" Default: %s\n", clusterConfigInfoEx.DrsConfig.DefaultVmBehavior) + fmt.Printf(" Enable: %s\n", clusterConfigInfoEx.DrsConfig.Enabled.Value) + fmt.Printf(" Override: %s\n", clusterConfigInfoEx.DrsConfig.VmOverrideBehavior) + + fmt.Printf("Cluster Admission Control: %t\n", clusterConfigInfoEx.AdmissionControlInfo.Enabled) + // ... other properties ... + + // Access and print data about HostGroups + for _, hostGroup := range clusterConfigInfoEx.HostGroup { + fmt.Printf("Host Group Name: %s\n", hostGroup.Name) + fmt.Printf("Host Group Vms: %v\n", hostGroup.Vm) + // ... other properties ... + } +}