Repository navigation
How can I get VirtualMachineDefinedProfileSpec from VirtualMachineProfileSpec? #3192
|
I am trying to get the profile id from VsanPerfsvcConfig. I've tried asserting the type and force converting it but those don't work. I see in the debug log that vsphere SOAP is indeed responding with VirtualMachineDefinedProfileSpec. Is there a way I can convert them back and forth? |
Answered by
dougm
Sep 27, 2023
Replies: 1 comment
|
I haven't used the vsan API much myself, but looks like generated code just needs to use interface type for that field. The vsan package needs updating in general, patch below in the meantime. diff --git a/govc/vsan/info.go b/govc/vsan/info.go
index 7d3438d4..3840ca08 100644
--- a/govc/vsan/info.go
+++ b/govc/vsan/info.go
@@ -26,6 +26,7 @@ import (
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
+ vim "github.com/vmware/govmomi/vim25/types"
"github.com/vmware/govmomi/vsan"
"github.com/vmware/govmomi/vsan/types"
)
@@ -118,6 +119,11 @@ func (r *infoResult) Write(w io.Writer) error {
}
fmt.Fprintf(tw, " Unmap Enabled:\t%t\n", unmapEnabled)
+
+ switch p := cluster.Info.PerfsvcConfig.Profile.(type) {
+ case *vim.VirtualMachineDefinedProfileSpec:
+ fmt.Fprintf(tw, " Profile ID:\t%s\n", p.ProfileId)
+ }
}
return tw.Flush()
diff --git a/vsan/types/types.go b/vsan/types/types.go
index b8b8e110..1e39643f 100644
--- a/vsan/types/types.go
+++ b/vsan/types/types.go
@@ -5799,7 +5799,7 @@ type VsanPerfsvcConfig struct {
types.DynamicData
Enabled bool `xml:"enabled"`
- Profile *types.VirtualMachineProfileSpec `xml:"profile,omitempty"`
+ Profile types.BaseVirtualMachineProfileSpec `xml:"profile,omitempty"`
DiagnosticMode *bool `xml:"diagnosticMode"`
VerboseMode *bool `xml:"verboseMode"`
} |
0 replies
Answer selected by
tenthirtyam
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I haven't used the vsan API much myself, but looks like generated code just needs to use interface type for that field. The vsan package needs updating in general, patch below in the meantime.