tweak logging messages
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:
29
main.go
29
main.go
@@ -180,7 +180,7 @@ func processVMs(client *govmomi.Client) error {
|
|||||||
sharingType := info.Sharing
|
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 %s\n", vm.Name, diskLabel)
|
||||||
|
|
||||||
result := MultiWriterResults{
|
result := MultiWriterResults{
|
||||||
VmName: vm.Name,
|
VmName: vm.Name,
|
||||||
@@ -389,6 +389,7 @@ func updateConfluencePage(api *goconfluence.API, vCenterHostname string, pageId
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
var err error
|
||||||
// Command line flags
|
// Command line flags
|
||||||
vURL := flag.String("url", "", "The URL of a vCenter server, eg https://server.domain.example/sdk")
|
vURL := flag.String("url", "", "The URL of a vCenter server, eg https://server.domain.example/sdk")
|
||||||
vUser := flag.String("user", "", "The username to use when connecting to vCenter")
|
vUser := flag.String("user", "", "The username to use when connecting to vCenter")
|
||||||
@@ -404,6 +405,18 @@ func main() {
|
|||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
// Print logs to file
|
||||||
|
/*
|
||||||
|
f, err := os.OpenFile("log.txt", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("error opening file: %v", err)
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
log.SetOutput(f)
|
||||||
|
*/
|
||||||
|
|
||||||
|
fmt.Printf("Starting execution. Built on %s from sha1 %s\n", buildTime, sha1ver)
|
||||||
|
|
||||||
if len(*vURL) == 0 {
|
if len(*vURL) == 0 {
|
||||||
panic("Unable to connect to empty vCenter URL")
|
panic("Unable to connect to empty vCenter URL")
|
||||||
}
|
}
|
||||||
@@ -425,16 +438,6 @@ func main() {
|
|||||||
*cToken = val
|
*cToken = val
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print logs to file
|
|
||||||
f, err := os.OpenFile("log.txt", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("error opening file: %v", err)
|
|
||||||
}
|
|
||||||
defer f.Close()
|
|
||||||
log.SetOutput(f)
|
|
||||||
|
|
||||||
fmt.Printf("Starting execution. Built on %s from sha1 %s\n", buildTime, sha1ver)
|
|
||||||
|
|
||||||
// So we can convert vCenter UTC to our local timezone
|
// So we can convert vCenter UTC to our local timezone
|
||||||
fmt.Printf("Setting timezone to '%s'\n", *vTZ)
|
fmt.Printf("Setting timezone to '%s'\n", *vTZ)
|
||||||
location, err = time.LoadLocation(*vTZ)
|
location, err = time.LoadLocation(*vTZ)
|
||||||
@@ -455,7 +458,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
vCenterHostname := u.Host
|
vCenterHostname := u.Host
|
||||||
|
|
||||||
log.Printf("Connecting to vCenter %s\n", u)
|
fmt.Printf("Connecting to vCenter %s\n", u)
|
||||||
u.User = url.UserPassword(*vUser, *vPass)
|
u.User = url.UserPassword(*vUser, *vPass)
|
||||||
|
|
||||||
ctx, cancel = context.WithCancel(context.Background())
|
ctx, cancel = context.WithCancel(context.Background())
|
||||||
@@ -472,7 +475,7 @@ func main() {
|
|||||||
// Find scsi bus sharing and multi writer VMs
|
// Find scsi bus sharing and multi writer VMs
|
||||||
err = processVMs(c)
|
err = processVMs(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error processing list of VMs : %s\n", err)
|
fmt.Printf("Error processing list of VMs : %s\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user