mirror of
https://github.com/Oxalide/vsphere-influxdb-go.git
synced 2023-10-10 13:36:51 +02:00
check if there are clusters before retrieving configuration; don't get respool config twice
This commit is contained in:
parent
b47e66dea1
commit
9508bf0dae
@ -297,18 +297,22 @@ func (vcenter *VCenter) Query(config Configuration, InfluxDBClient influxclient.
|
|||||||
|
|
||||||
//Retrieve properties for Cluster(s)
|
//Retrieve properties for Cluster(s)
|
||||||
var clmo []mo.ClusterComputeResource
|
var clmo []mo.ClusterComputeResource
|
||||||
err = pc.Retrieve(ctx, clusterRefs, []string{"name", "configuration", "host"}, &clmo)
|
if len(clusterRefs) > 0 {
|
||||||
if err != nil {
|
err = pc.Retrieve(ctx, clusterRefs, []string{"name", "configuration", "host"}, &clmo)
|
||||||
fmt.Println(err)
|
if err != nil {
|
||||||
return
|
fmt.Println(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Retrieve properties for ResourcePool
|
//Retrieve properties for ResourcePool
|
||||||
var rpmo []mo.ResourcePool
|
var rpmo []mo.ResourcePool
|
||||||
err = pc.Retrieve(ctx, respoolRefs, []string{"summary"}, &rpmo)
|
if len(respoolRefs) > 0 {
|
||||||
if err != nil {
|
err = pc.Retrieve(ctx, respoolRefs, []string{"summary"}, &rpmo)
|
||||||
fmt.Println(err)
|
if err != nil {
|
||||||
return
|
fmt.Println(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve summary property for all datastores
|
// Retrieve summary property for all datastores
|
||||||
@ -322,12 +326,12 @@ func (vcenter *VCenter) Query(config Configuration, InfluxDBClient influxclient.
|
|||||||
// Initialize the map that will hold the VM MOR to ResourcePool reference
|
// Initialize the map that will hold the VM MOR to ResourcePool reference
|
||||||
vmToPool := make(map[types.ManagedObjectReference]string)
|
vmToPool := make(map[types.ManagedObjectReference]string)
|
||||||
|
|
||||||
|
var respool []mo.ResourcePool
|
||||||
// Retrieve properties for ResourcePools
|
// Retrieve properties for ResourcePools
|
||||||
if len(respoolRefs) > 0 {
|
if len(respoolRefs) > 0 {
|
||||||
if debug == true {
|
if debug == true {
|
||||||
stdlog.Println("going inside ResourcePools")
|
stdlog.Println("going inside ResourcePools")
|
||||||
}
|
}
|
||||||
var respool []mo.ResourcePool
|
|
||||||
err = pc.Retrieve(ctx, respoolRefs, []string{"name", "config", "vm"}, &respool)
|
err = pc.Retrieve(ctx, respoolRefs, []string{"name", "config", "vm"}, &respool)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
@ -631,12 +635,12 @@ func (vcenter *VCenter) Query(config Configuration, InfluxDBClient influxclient.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var respool []mo.ResourcePool
|
// var respool []mo.ResourcePool
|
||||||
err = pc.Retrieve(ctx, respoolRefs, []string{"name", "config", "vm"}, &respool)
|
// err = pc.Retrieve(ctx, respoolRefs, []string{"name", "config", "vm"}, &respool)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
errlog.Println(err)
|
// errlog.Println(err)
|
||||||
continue
|
// continue
|
||||||
}
|
// }
|
||||||
|
|
||||||
for _, pool := range respool {
|
for _, pool := range respool {
|
||||||
respoolFields := map[string]interface{}{
|
respoolFields := map[string]interface{}{
|
||||||
|
Loading…
Reference in New Issue
Block a user