This commit is contained in:
12
main.go
12
main.go
@@ -9,6 +9,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
_ "time/tzdata"
|
_ "time/tzdata"
|
||||||
@@ -142,8 +143,7 @@ func processVMs(client *govmomi.Client) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if vm.Config != nil && vm.Config.Hardware.Device != nil {
|
if vm.Config != nil && len(vm.Config.Hardware.Device) > 0 {
|
||||||
if len(vm.Config.Hardware.Device) > 0 {
|
|
||||||
for _, device := range vm.Config.Hardware.Device {
|
for _, device := range vm.Config.Hardware.Device {
|
||||||
//fmt.Printf("device: %v\n", device)
|
//fmt.Printf("device: %v\n", device)
|
||||||
//fmt.Println("Type of variable1:", reflect.TypeOf(device))
|
//fmt.Println("Type of variable1:", reflect.TypeOf(device))
|
||||||
@@ -174,7 +174,9 @@ func processVMs(client *govmomi.Client) error {
|
|||||||
// See https://github.com/vmware/govmomi/blob/main/vim25/types/enum.go#L7538
|
// See https://github.com/vmware/govmomi/blob/main/vim25/types/enum.go#L7538
|
||||||
// Sharing can be sharingNone or sharingMultiWriter
|
// Sharing can be sharingNone or sharingMultiWriter
|
||||||
backing := vdisk.VirtualDevice.Backing
|
backing := vdisk.VirtualDevice.Backing
|
||||||
sharingType := backing.(*types.VirtualDiskFlatVer2BackingInfo).Sharing
|
fmt.Println("Type of backing:", reflect.TypeOf(backing))
|
||||||
|
if info, ok := backing.(*types.VirtualDiskFlatVer2BackingInfo); ok {
|
||||||
|
sharingType := info.Sharing
|
||||||
|
|
||||||
if sharingType == "sharingMultiWriter" {
|
if sharingType == "sharingMultiWriter" {
|
||||||
fmt.Printf("VM %s is using MultiWriter on disk %ss\n", vm.Name, diskLabel)
|
fmt.Printf("VM %s is using MultiWriter on disk %ss\n", vm.Name, diskLabel)
|
||||||
@@ -192,8 +194,8 @@ func processVMs(client *govmomi.Client) error {
|
|||||||
}
|
}
|
||||||
} else if vm.Config == nil {
|
} else if vm.Config == nil {
|
||||||
fmt.Printf("vm %s has no config\n", vm.Name)
|
fmt.Printf("vm %s has no config\n", vm.Name)
|
||||||
} else if vm.Config.Hardware.Device == nil {
|
} else {
|
||||||
fmt.Printf("vm %s has no hardware device\n", vm.Name)
|
fmt.Printf("vm %s is something strange\n", vm.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user