This commit is contained in:
6
main.go
6
main.go
@@ -83,6 +83,7 @@ func getScsiBusSharingVMs(client *govmomi.Client) error {
|
|||||||
pc := property.DefaultCollector(client.Client)
|
pc := property.DefaultCollector(client.Client)
|
||||||
|
|
||||||
// Get a view of all the VMs
|
// Get a view of all the VMs
|
||||||
|
fmt.Printf("Getting VM listing\n")
|
||||||
vms, err := m.CreateContainerView(ctx, client.ServiceContent.RootFolder, []string{"VirtualMachine"}, true)
|
vms, err := m.CreateContainerView(ctx, client.ServiceContent.RootFolder, []string{"VirtualMachine"}, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -90,6 +91,7 @@ func getScsiBusSharingVMs(client *govmomi.Client) error {
|
|||||||
defer vms.Destroy(ctx)
|
defer vms.Destroy(ctx)
|
||||||
|
|
||||||
// Get a view of all the hosts
|
// Get a view of all the hosts
|
||||||
|
fmt.Printf("Getting host listing\n")
|
||||||
hs, err := m.CreateContainerView(ctx, client.ServiceContent.RootFolder, []string{"HostSystem"}, true)
|
hs, err := m.CreateContainerView(ctx, client.ServiceContent.RootFolder, []string{"HostSystem"}, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -103,6 +105,7 @@ func getScsiBusSharingVMs(client *govmomi.Client) error {
|
|||||||
log.Printf("Error retrieving vm list : '%s'\n", err)
|
log.Printf("Error retrieving vm list : '%s'\n", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
fmt.Printf("Found %d VMs\n", len(vmList))
|
||||||
|
|
||||||
// Retrieve all the hosts
|
// Retrieve all the hosts
|
||||||
var hsList []mo.HostSystem
|
var hsList []mo.HostSystem
|
||||||
@@ -111,6 +114,7 @@ func getScsiBusSharingVMs(client *govmomi.Client) error {
|
|||||||
log.Printf("Error retrieving hostsystem list : '%s'\n", err)
|
log.Printf("Error retrieving hostsystem list : '%s'\n", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
fmt.Printf("Found %d hosts\n", len(hsList))
|
||||||
|
|
||||||
// Iterate through VMs and check for SCSI bus sharing
|
// Iterate through VMs and check for SCSI bus sharing
|
||||||
for _, vm := range vmList {
|
for _, vm := range vmList {
|
||||||
@@ -141,7 +145,7 @@ func getScsiBusSharingVMs(client *govmomi.Client) error {
|
|||||||
}
|
}
|
||||||
//fmt.Println(cluster.Name)
|
//fmt.Println(cluster.Name)
|
||||||
clusterName = cluster.Name
|
clusterName = cluster.Name
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user