add time diff to output
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
44
main.go
44
main.go
@@ -16,14 +16,17 @@ import (
|
|||||||
"github.com/vmware/govmomi"
|
"github.com/vmware/govmomi"
|
||||||
"github.com/vmware/govmomi/find"
|
"github.com/vmware/govmomi/find"
|
||||||
"github.com/vmware/govmomi/view"
|
"github.com/vmware/govmomi/view"
|
||||||
|
"github.com/vmware/govmomi/vim25/methods"
|
||||||
"github.com/vmware/govmomi/vim25/mo"
|
"github.com/vmware/govmomi/vim25/mo"
|
||||||
|
"github.com/vmware/govmomi/vim25/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
type HostTimeErrors struct {
|
type HostTimeErrors struct {
|
||||||
HostName string
|
HostName string
|
||||||
HostTime time.Time
|
HostTime time.Time
|
||||||
Cluster string
|
HostTimeDrift string
|
||||||
Vcenter string
|
Cluster string
|
||||||
|
Vcenter string
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -189,6 +192,30 @@ func main() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// test triggering update
|
||||||
|
// Call RefreshDateTimeSystem method using methods.RefreshDateTimeSystem
|
||||||
|
refreshReq := &types.RefreshDateTimeSystem{
|
||||||
|
This: dts.Reference(),
|
||||||
|
}
|
||||||
|
_, err = methods.RefreshDateTimeSystem(ctx, c.Client, refreshReq)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Failed to refresh datetime system for host %s: %v", hs.Name, err)
|
||||||
|
} else {
|
||||||
|
//prettyPrint(refreshResp)
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Call UpdateDateTime method using methods.UpdateDateTime - this will manually set the ESXi clock
|
||||||
|
updateReq := &types.UpdateDateTime{
|
||||||
|
This: dts.Reference(),
|
||||||
|
DateTime: time.Now().UTC(),
|
||||||
|
}
|
||||||
|
_, err = methods.UpdateDateTime(ctx, c.Client, updateReq)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// Get the current ESXi time which is UTC
|
// Get the current ESXi time which is UTC
|
||||||
hostTime, err := dts.Query(ctx)
|
hostTime, err := dts.Query(ctx)
|
||||||
|
|
||||||
@@ -212,10 +239,11 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
thisResult := HostTimeErrors{
|
thisResult := HostTimeErrors{
|
||||||
HostName: hs.Name,
|
HostName: hs.Name,
|
||||||
Cluster: clusterName,
|
Cluster: clusterName,
|
||||||
Vcenter: u.Host,
|
Vcenter: u.Host,
|
||||||
HostTime: esxiTimeLocal,
|
HostTime: esxiTimeLocal,
|
||||||
|
HostTimeDrift: diff.String(),
|
||||||
}
|
}
|
||||||
|
|
||||||
hostTimeErrors = append(hostTimeErrors, thisResult)
|
hostTimeErrors = append(hostTimeErrors, thisResult)
|
||||||
|
Reference in New Issue
Block a user