log: use log.Print instead of fmt.Print
This commit is contained in:
parent
fac805dc11
commit
81ffa056bd
@ -17,6 +17,7 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"sync"
|
||||
"time"
|
||||
@ -160,37 +161,37 @@ func main() {
|
||||
|
||||
ds := selectDatasource(dss)
|
||||
if ds == nil {
|
||||
fmt.Println("No datasources available in time")
|
||||
log.Println("No datasources available in time")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Printf("Fetching user-data from datasource of type %q\n", ds.Type())
|
||||
log.Printf("Fetching user-data from datasource of type %q\n", ds.Type())
|
||||
userdataBytes, err := ds.FetchUserdata()
|
||||
if err != nil {
|
||||
fmt.Printf("Failed fetching user-data from datasource: %v\nContinuing...\n", err)
|
||||
log.Printf("Failed fetching user-data from datasource: %v. Continuing...\n", err)
|
||||
failure = true
|
||||
}
|
||||
|
||||
if report, err := validate.Validate(userdataBytes); err == nil {
|
||||
ret := 0
|
||||
for _, e := range report.Entries() {
|
||||
fmt.Println(e)
|
||||
log.Println(e)
|
||||
ret = 1
|
||||
}
|
||||
if flags.validate {
|
||||
os.Exit(ret)
|
||||
}
|
||||
} else {
|
||||
fmt.Printf("Failed while validating user_data (%q)\n", err)
|
||||
log.Printf("Failed while validating user_data (%q)\n", err)
|
||||
if flags.validate {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Printf("Fetching meta-data from datasource of type %q\n", ds.Type())
|
||||
log.Printf("Fetching meta-data from datasource of type %q\n", ds.Type())
|
||||
metadata, err := ds.FetchMetadata()
|
||||
if err != nil {
|
||||
fmt.Printf("Failed fetching meta-data from datasource: %v\n", err)
|
||||
log.Printf("Failed fetching meta-data from datasource: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
@ -216,7 +217,7 @@ func main() {
|
||||
failure = true
|
||||
}
|
||||
|
||||
fmt.Println("Merging cloud-config from meta-data and user-data")
|
||||
log.Println("Merging cloud-config from meta-data and user-data")
|
||||
cc := mergeConfigs(ccu, metadata)
|
||||
|
||||
var ifaces []network.InterfaceGenerator
|
||||
@ -233,19 +234,19 @@ func main() {
|
||||
err = fmt.Errorf("Unsupported network config format %q", flags.convertNetconf)
|
||||
}
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to generate interfaces: %v\n", err)
|
||||
log.Printf("Failed to generate interfaces: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
if err = initialize.Apply(cc, ifaces, env); err != nil {
|
||||
fmt.Printf("Failed to apply cloud-config: %v\n", err)
|
||||
log.Printf("Failed to apply cloud-config: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if script != nil {
|
||||
if err = runScript(*script, env); err != nil {
|
||||
fmt.Printf("Failed to run script: %v\n", err)
|
||||
log.Printf("Failed to run script: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
@ -265,7 +266,7 @@ func mergeConfigs(cc *config.CloudConfig, md datasource.Metadata) (out config.Cl
|
||||
|
||||
if md.Hostname != "" {
|
||||
if out.Hostname != "" {
|
||||
fmt.Printf("Warning: user-data hostname (%s) overrides metadata hostname (%s)\n", out.Hostname, md.Hostname)
|
||||
log.Printf("Warning: user-data hostname (%s) overrides metadata hostname (%s)\n", out.Hostname, md.Hostname)
|
||||
} else {
|
||||
out.Hostname = md.Hostname
|
||||
}
|
||||
@ -330,7 +331,7 @@ func selectDatasource(sources []datasource.Datasource) datasource.Datasource {
|
||||
|
||||
duration := datasourceInterval
|
||||
for {
|
||||
fmt.Printf("Checking availability of %q\n", s.Type())
|
||||
log.Printf("Checking availability of %q\n", s.Type())
|
||||
if s.IsAvailable() {
|
||||
ds <- s
|
||||
return
|
||||
@ -368,7 +369,7 @@ func selectDatasource(sources []datasource.Datasource) datasource.Datasource {
|
||||
func runScript(script config.Script, env *initialize.Environment) error {
|
||||
err := initialize.PrepWorkspace(env.Workspace())
|
||||
if err != nil {
|
||||
fmt.Printf("Failed preparing workspace: %v\n", err)
|
||||
log.Printf("Failed preparing workspace: %v\n", err)
|
||||
return err
|
||||
}
|
||||
path, err := initialize.PersistScriptInWorkspace(script, env.Workspace())
|
||||
|
@ -16,8 +16,8 @@ package configdrive
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
|
||||
@ -93,7 +93,7 @@ func (cd *configDrive) openstackVersionRoot() string {
|
||||
}
|
||||
|
||||
func (cd *configDrive) tryReadFile(filename string) ([]byte, error) {
|
||||
fmt.Printf("Attempting to read from %q\n", filename)
|
||||
log.Printf("Attempting to read from %q\n", filename)
|
||||
data, err := cd.readFile(filename)
|
||||
if os.IsNotExist(err) {
|
||||
err = nil
|
||||
|
@ -18,6 +18,7 @@ import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
@ -61,7 +62,7 @@ func (ms metadataService) FetchMetadata() (datasource.Metadata, error) {
|
||||
return metadata, err
|
||||
}
|
||||
metadata.SSHPublicKeys[name] = sshkey
|
||||
fmt.Printf("Found SSH key for %q\n", name)
|
||||
log.Printf("Found SSH key for %q\n", name)
|
||||
}
|
||||
} else if _, ok := err.(pkg.ErrNotFound); !ok {
|
||||
return metadata, err
|
||||
|
@ -16,8 +16,8 @@ package waagent
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net"
|
||||
"os"
|
||||
"path"
|
||||
@ -108,7 +108,7 @@ func (a *waagent) Type() string {
|
||||
}
|
||||
|
||||
func (a *waagent) tryReadFile(filename string) ([]byte, error) {
|
||||
fmt.Printf("Attempting to read from %q\n", filename)
|
||||
log.Printf("Attempting to read from %q\n", filename)
|
||||
data, err := a.readFile(filename)
|
||||
if os.IsNotExist(err) {
|
||||
err = nil
|
||||
|
@ -15,7 +15,6 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"os/exec"
|
||||
@ -59,7 +58,7 @@ func downNetworkInterfaces(interfaces []network.InterfaceGenerator) error {
|
||||
if systemInterface, ok := sysInterfaceMap[iface.Name()]; ok {
|
||||
log.Printf("Taking down interface %q\n", systemInterface.Name)
|
||||
if err := netlink.NetworkLinkDown(systemInterface); err != nil {
|
||||
fmt.Printf("Error while downing interface %q (%s). Continuing...\n", systemInterface.Name, err)
|
||||
log.Printf("Error while downing interface %q (%s). Continuing...\n", systemInterface.Name, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user