handle rdm disks
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2023-10-27 11:59:11 +11:00
parent 497e74fae7
commit a81f8e044c

12
main.go
View File

@@ -9,6 +9,7 @@ import (
"log"
"net/url"
"os"
"reflect"
"strings"
"time"
_ "time/tzdata"
@@ -142,8 +143,7 @@ func processVMs(client *govmomi.Client) error {
}
}
if vm.Config != nil && vm.Config.Hardware.Device != nil {
if len(vm.Config.Hardware.Device) > 0 {
if vm.Config != nil && len(vm.Config.Hardware.Device) > 0 {
for _, device := range vm.Config.Hardware.Device {
//fmt.Printf("device: %v\n", 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
// Sharing can be sharingNone or sharingMultiWriter
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" {
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 {
fmt.Printf("vm %s has no config\n", vm.Name)
} else if vm.Config.Hardware.Device == nil {
fmt.Printf("vm %s has no hardware device\n", vm.Name)
} else {
fmt.Printf("vm %s is something strange\n", vm.Name)
}
}