Remove trailing newline from wwlog

I noticed that some wwlog calls included a trailing newline, but others
did not. I tested both in isolation and discovered that the behavior was
consistent regardless of whether a trailing newline was included. I
further confirmed in code that wwlog appends a trailing newline
automatically if it is not present; so a trailing newline is unnecessary
in individual calls.

This commit removes trailing newlines from all calls to make them
consistent. It also replaces two calls to wwlog.Printf. (see #534)

Signed-off-by: Jonathon Anderson <janderson@ciq.co>
This commit is contained in:
Jonathon Anderson
2022-09-15 12:38:03 -06:00
parent fc39209fbb
commit 0b3e862bea
58 changed files with 327 additions and 327 deletions

View File

@@ -13,30 +13,30 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if allFunctions {
err = configure.Dhcp()
if err != nil {
wwlog.Error("%s\n", err)
wwlog.Error("%s", err)
os.Exit(1)
}
err = configure.NFS()
if err != nil {
wwlog.Error("%s\n", err)
wwlog.Error("%s", err)
os.Exit(1)
}
err = configure.SSH()
if err != nil {
wwlog.Error("%s\n", err)
wwlog.Error("%s", err)
os.Exit(1)
}
err = configure.TFTP()
if err != nil {
wwlog.Error("%s\n", err)
wwlog.Error("%s", err)
os.Exit(1)
}
err = configure.Hostfile()
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
wwlog.Error("%s", err)
os.Exit(1)
}

View File

@@ -19,14 +19,14 @@ import (
func CobraRunE(cmd *cobra.Command, args []string) error {
if os.Getpid() != 1 {
wwlog.Error("PID is not 1: %d\n", os.Getpid())
wwlog.Error("PID is not 1: %d", os.Getpid())
os.Exit(1)
}
containerName := args[0]
if !container.ValidSource(containerName) {
wwlog.Error("Unknown Warewulf container: %s\n", containerName)
wwlog.Error("Unknown Warewulf container: %s", containerName)
os.Exit(1)
}
containerPath := container.RootFsDir(containerName)
@@ -36,8 +36,8 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
fileStat, _ = os.Stat(path.Join(containerPath, "/etc/group"))
unixStat = fileStat.Sys().(*syscall.Stat_t)
groupTime := time.Unix(int64(unixStat.Ctim.Sec), int64(unixStat.Ctim.Nsec))
wwlog.Debug("passwd: %v\n", passwdTime)
wwlog.Debug("group: %v\n", groupTime)
wwlog.Debug("passwd: %v", passwdTime)
wwlog.Debug("group: %v", groupTime)
err := syscall.Mount("", "/", "", syscall.MS_PRIVATE|syscall.MS_REC, "")
if err != nil {
@@ -90,7 +90,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
err = syscall.Exec(args[1], args[1:], os.Environ())
if err != nil {
wwlog.Error("%s\n", err)
wwlog.Error("%s", err)
os.Exit(1)
}
fileStat, _ = os.Stat(path.Join(containerPath, "/etc/passwd"))
@@ -98,13 +98,13 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if passwdTime.Before(time.Unix(int64(unixStat.Ctim.Sec), int64(unixStat.Ctim.Nsec))) {
wwlog.Warn("/etc/passwd has been modified, maybe you want to run syncuser")
}
wwlog.Debug("passwd: %v\n", time.Unix(int64(unixStat.Ctim.Sec), int64(unixStat.Ctim.Nsec)))
wwlog.Debug("passwd: %v", time.Unix(int64(unixStat.Ctim.Sec), int64(unixStat.Ctim.Nsec)))
fileStat, _ = os.Stat(path.Join(containerPath, "/etc/group"))
unixStat = fileStat.Sys().(*syscall.Stat_t)
if groupTime.Before(time.Unix(int64(unixStat.Ctim.Sec), int64(unixStat.Ctim.Nsec))) {
wwlog.Warn("/etc/group has been modified, maybe you want to run syncuser")
}
wwlog.Debug("group: %v\n", time.Unix(int64(unixStat.Ctim.Sec), int64(unixStat.Ctim.Nsec)))
wwlog.Debug("group: %v", time.Unix(int64(unixStat.Ctim.Sec), int64(unixStat.Ctim.Nsec)))
return nil
}

View File

@@ -9,7 +9,7 @@ import (
)
func CobraRunE(cmd *cobra.Command, args []string) error {
wwlog.Error("This command does not work on non-Linux hosts\n")
wwlog.Error("This command does not work on non-Linux hosts")
return nil
}

View File

@@ -18,7 +18,7 @@ import (
)
func runContainedCmd(args []string) error {
wwlog.Verbose("Running contained command: %s\n", args[1:])
wwlog.Verbose("Running contained command: %s", args[1:])
c := exec.Command("/proc/self/exe", append([]string{"container", "exec", "__child"}, args...)...)
c.SysProcAttr = &syscall.SysProcAttr{
@@ -41,7 +41,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
var allargs []string
if !container.ValidSource(containerName) {
wwlog.Error("Unknown Warewulf container: %s\n", containerName)
wwlog.Error("Unknown Warewulf container: %s", containerName)
os.Exit(1)
}
@@ -57,20 +57,20 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
fileStat, _ = os.Stat(path.Join(containerPath, "/etc/group"))
unixStat = fileStat.Sys().(*syscall.Stat_t)
groupTime := time.Unix(int64(unixStat.Ctim.Sec), int64(unixStat.Ctim.Nsec))
wwlog.Debug("passwd: %v\n", passwdTime)
wwlog.Debug("group: %v\n", groupTime)
wwlog.Debug("passwd: %v", passwdTime)
wwlog.Debug("group: %v", groupTime)
err := runContainedCmd(allargs)
if err != nil {
wwlog.Error("Failed executing container command: %s\n", err)
wwlog.Error("Failed executing container command: %s", err)
os.Exit(1)
}
if util.IsFile(path.Join(container.RootFsDir(allargs[0]), "/etc/warewulf/container_exit.sh")) {
wwlog.Verbose("Found clean script: /etc/warewulf/container_exit.sh\n")
wwlog.Verbose("Found clean script: /etc/warewulf/container_exit.sh")
err = runContainedCmd([]string{allargs[0], "/bin/sh", "/etc/warewulf/container_exit.sh"})
if err != nil {
wwlog.Error("Failed executing exit script: %s\n", err)
wwlog.Error("Failed executing exit script: %s", err)
os.Exit(1)
}
}
@@ -79,31 +79,31 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
syncuids := false
if passwdTime.Before(time.Unix(int64(unixStat.Ctim.Sec), int64(unixStat.Ctim.Nsec))) {
if !SyncUser {
wwlog.Warn("/etc/passwd has been modified, maybe you want to run syncuser\n")
wwlog.Warn("/etc/passwd has been modified, maybe you want to run syncuser")
}
syncuids = true
}
wwlog.Debug("passwd: %v\n", time.Unix(int64(unixStat.Ctim.Sec), int64(unixStat.Ctim.Nsec)))
wwlog.Debug("passwd: %v", time.Unix(int64(unixStat.Ctim.Sec), int64(unixStat.Ctim.Nsec)))
fileStat, _ = os.Stat(path.Join(containerPath, "/etc/group"))
unixStat = fileStat.Sys().(*syscall.Stat_t)
if groupTime.Before(time.Unix(int64(unixStat.Ctim.Sec), int64(unixStat.Ctim.Nsec))) {
if !SyncUser {
wwlog.Warn("/etc/group has been modified, maybe you want to run syncuser\n")
wwlog.Warn("/etc/group has been modified, maybe you want to run syncuser")
}
syncuids = true
}
wwlog.Debug("group: %v\n", time.Unix(int64(unixStat.Ctim.Sec), int64(unixStat.Ctim.Nsec)))
wwlog.Debug("group: %v", time.Unix(int64(unixStat.Ctim.Sec), int64(unixStat.Ctim.Nsec)))
if syncuids && SyncUser {
err = container.SyncUids(containerName, true)
if err != nil {
wwlog.Error("Error in user sync, fix error and run 'syncuser' manually, but trying to build container: %s\n", err)
wwlog.Error("Error in user sync, fix error and run 'syncuser' manually, but trying to build container: %s", err)
}
}
fmt.Printf("Rebuilding container...\n")
err = container.Build(containerName, false)
if err != nil {
wwlog.Error("Could not build container %s: %s\n", containerName, err)
wwlog.Error("Could not build container %s: %s", containerName, err)
os.Exit(1)
}

View File

@@ -9,7 +9,7 @@ import (
)
func CobraRunE(cmd *cobra.Command, args []string) error {
wwlog.Error("This command does not work on non-Linux hosts\n")
wwlog.Error("This command does not work on non-Linux hosts")
return nil
}

View File

@@ -12,7 +12,7 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) {
containerInfo, err := container.ContainerList()
if err != nil {
wwlog.Error("%s\n", err)
wwlog.Error("%s", err)
return
}

View File

@@ -20,7 +20,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
var allargs []string
if !container.ValidSource(containerName) {
wwlog.Error("Unknown Warewulf container: %s\n", containerName)
wwlog.Error("Unknown Warewulf container: %s", containerName)
os.Exit(1)
}

View File

@@ -16,7 +16,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
err := container.SyncUids(containerName, !write)
if err != nil {
wwlog.Error("Error in synchronize: %s\n", err)
wwlog.Error("Error in synchronize: %s", err)
os.Exit(1)
}

View File

@@ -14,7 +14,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
nodeDB, err := node.New()
if err != nil {
wwlog.Error("Could not open nodeDB: %s\n", err)
wwlog.Error("Could not open nodeDB: %s", err)
os.Exit(1)
}
@@ -24,14 +24,14 @@ ARG_LOOP:
for _, arg := range args {
for _, n := range nodes {
if n.Kernel.Override.Get() == arg {
wwlog.Error("Kernel is configured for nodes, skipping: %s\n", arg)
wwlog.Error("Kernel is configured for nodes, skipping: %s", arg)
continue ARG_LOOP
}
}
err := kernel.DeleteKernel(arg)
if err != nil {
wwlog.Error("Could not delete kernel: %s\n", arg)
wwlog.Error("Could not delete kernel: %s", arg)
} else {
fmt.Printf("Kernel has been deleted: %s\n", arg)
}

View File

@@ -39,7 +39,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
} else {
kernelVersion, err = kernel.FindKernelVersion(OptRoot)
if err != nil {
wwlog.Error("could not detect kernel under %s\n", OptRoot)
wwlog.Error("could not detect kernel under %s", OptRoot)
os.Exit(1)
}
}
@@ -51,7 +51,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
output, err := kernel.Build(kernelVersion, kernelName, OptRoot)
if err != nil {
wwlog.Error("Failed building kernel: %s\n", err)
wwlog.Error("Failed building kernel: %s", err)
os.Exit(1)
} else {
fmt.Printf("%s: %s\n", kernelName, output)
@@ -61,15 +61,15 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
nodeDB, err := node.New()
if err != nil {
wwlog.Error("Could not open node configuration: %s\n", err)
wwlog.Error("Could not open node configuration: %s", err)
os.Exit(1)
}
//TODO: Don't loop through profiles, instead have a nodeDB function that goes directly to the map
profiles, _ := nodeDB.FindAllProfiles()
for _, profile := range profiles {
wwlog.Debug("Looking for profile default: %s\n", profile.Id.Get())
wwlog.Debug("Looking for profile default: %s", profile.Id.Get())
if profile.Id.Get() == "default" {
wwlog.Debug("Found profile default, setting kernel version to: %s\n", args[0])
wwlog.Debug("Found profile default, setting kernel version to: %s", args[0])
profile.Kernel.Override.Set(args[0])
err := nodeDB.ProfileUpdate(profile)
if err != nil {

View File

@@ -14,7 +14,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
kernels, err := kernel.ListKernels()
if err != nil {
wwlog.Error("%s\n", err)
wwlog.Error("%s", err)
os.Exit(1)
}

View File

@@ -16,13 +16,13 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
nodeDB, err := node.New()
if err != nil {
wwlog.Error("Could not open node configuration: %s\n", err)
wwlog.Error("Could not open node configuration: %s", err)
os.Exit(1)
}
nodes, err := nodeDB.FindAllNodes()
if err != nil {
wwlog.Error("Could not get node list: %s\n", err)
wwlog.Error("Could not get node list: %s", err)
os.Exit(1)
}
@@ -44,7 +44,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
for _, node := range nodes {
if node.Ipmi.Ipaddr.Get() == "" {
wwlog.Error("%s: No IPMI IP address\n", node.Id.Get())
wwlog.Error("%s: No IPMI IP address", node.Id.Get())
continue
}
@@ -61,7 +61,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
err := ipmiCmd.Console()
if err != nil {
wwlog.Error("%s: Console problem\n", node.Id.Get())
wwlog.Error("%s: Console problem", node.Id.Get())
returnErr = err
continue
}

View File

@@ -17,13 +17,13 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
nodeDB, err := node.New()
if err != nil {
wwlog.Error("Could not open node configuration: %s\n", err)
wwlog.Error("Could not open node configuration: %s", err)
os.Exit(1)
}
nodes, err := nodeDB.FindAllNodes()
if err != nil {
wwlog.Error("Could not get node list: %s\n", err)
wwlog.Error("Could not get node list: %s", err)
os.Exit(1)
}
@@ -48,7 +48,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
for _, node := range nodes {
if node.Ipmi.Ipaddr.Get() == "" {
wwlog.Error("%s: No IPMI IP address\n", node.Id.Get())
wwlog.Error("%s: No IPMI IP address", node.Id.Get())
continue
}
var ipmiInterface = "lan"
@@ -92,7 +92,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
out, err := result.Result()
if err != nil {
wwlog.Error("%s: %s\n", result.NodeName, out)
wwlog.Error("%s: %s", result.NodeName, out)
returnErr = err
continue
}

View File

@@ -21,12 +21,12 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) {
controller, err := warewulfconf.New()
if err != nil {
wwlog.Error("%s\n", err)
wwlog.Error("%s", err)
os.Exit(1)
}
if controller.Ipaddr == "" {
wwlog.Error("The Warewulf Server IP Address is not properly configured\n")
wwlog.Error("The Warewulf Server IP Address is not properly configured")
os.Exit(1)
}
@@ -46,7 +46,7 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) {
fmt.Print("\033[H\033[2J")
_, height, err = term.GetSize(0)
if err != nil {
wwlog.Warn("Could not get terminal height, using 24\n")
wwlog.Warn("Could not get terminal height, using 24")
height = 24
}
}
@@ -54,7 +54,7 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) {
fmt.Printf("%-20s %-20s %-25s %-10s\n", "NODENAME", "STAGE", "SENT", "LASTSEEN (s)")
fmt.Printf("%s\n", strings.Repeat("=", 80))
wwlog.Verbose("Building sort index\n")
wwlog.Verbose("Building sort index")
var statuses []*wwapiv1.NodeStatus
if len(args) > 0 {
nodeList := hostlist.Expand(args)
@@ -72,7 +72,7 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) {
}
}
wwlog.Verbose("Sorting index\n")
wwlog.Verbose("Sorting index")
if SetSortLast {
sort.Slice(statuses, func(i, j int) bool {
if statuses[i].Lastseen > statuses[j].Lastseen {
@@ -84,7 +84,7 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) {
}
})
} else if SetSortReverse {
wwlog.Verbose("Reversing sort order\n")
wwlog.Verbose("Reversing sort order")
sort.Slice(statuses, func(i, j int) bool {
return statuses[i].NodeName > statuses[j].NodeName
})
@@ -95,7 +95,7 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) {
})
}
wwlog.Verbose("Printing results\n")
wwlog.Verbose("Printing results")
for i := 0; i < len(statuses); i++ {
o := statuses[i]
if SetTime > 0 && o.Lastseen < SetTime {

View File

@@ -16,18 +16,18 @@ import (
func CobraRunE(cmd *cobra.Command, args []string) error {
controller, err := warewulfconf.New()
if err != nil {
wwlog.Error("%s\n", err)
wwlog.Error("%s", err)
os.Exit(1)
}
nodeDB, err := node.New()
if err != nil {
wwlog.Error("Could not open node configuration: %s\n", err)
wwlog.Error("Could not open node configuration: %s", err)
os.Exit(1)
}
nodes, err := nodeDB.FindAllNodes()
if err != nil {
wwlog.Error("Could not get node list: %s\n", err)
wwlog.Error("Could not get node list: %s", err)
os.Exit(1)
}
@@ -81,7 +81,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if BuildHost || (!BuildHost && !BuildNodes && len(args) == 0 && controller.Warewulf.EnableHostOverlay) {
err := overlay.BuildHostOverlay()
if err != nil {
wwlog.Warn("host overlay could not be built: %s\n", err)
wwlog.Warn("host overlay could not be built: %s", err)
}
}
@@ -93,7 +93,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
if err != nil {
wwlog.Warn("Some overlays failed to be generated: %s\n", err)
wwlog.Warn("Some overlays failed to be generated: %s", err)
}
}
return nil

View File

@@ -19,27 +19,27 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
permissionMode, err := strconv.ParseUint(args[2], 8, 32)
if err != nil {
wwlog.Error("Could not convert requested mode: %s\n", err)
wwlog.Error("Could not convert requested mode: %s", err)
os.Exit(1)
}
overlaySourceDir = overlay.OverlaySourceDir(overlayName)
if !util.IsDir(overlaySourceDir) {
wwlog.Error("Overlay does not exist: %s\n", overlayName)
wwlog.Error("Overlay does not exist: %s", overlayName)
os.Exit(1)
}
overlayFile := path.Join(overlaySourceDir, fileName)
if !util.IsFile(overlayFile) && !util.IsDir(overlayFile) {
wwlog.Error("File does not exist within overlay: %s:%s\n", overlayName, fileName)
wwlog.Error("File does not exist within overlay: %s:%s", overlayName, fileName)
os.Exit(1)
}
err = os.Chmod(overlayFile, os.FileMode(permissionMode))
if err != nil {
wwlog.Error("Could not set permission: %s\n", err)
wwlog.Error("Could not set permission: %s", err)
os.Exit(1)
}

View File

@@ -23,14 +23,14 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
uid, err = strconv.Atoi(args[2])
if err != nil {
wwlog.Error("UID is not an integer: %s\n", args[2])
wwlog.Error("UID is not an integer: %s", args[2])
os.Exit(1)
}
if len(args) > 3 {
gid, err = strconv.Atoi(args[3])
if err != nil {
wwlog.Error("GID is not an integer: %s\n", args[3])
wwlog.Error("GID is not an integer: %s", args[3])
os.Exit(1)
}
} else {
@@ -40,20 +40,20 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
overlaySourceDir = overlay.OverlaySourceDir(overlayName)
if !util.IsDir(overlaySourceDir) {
wwlog.Error("Overlay does not exist: %s\n", overlayName)
wwlog.Error("Overlay does not exist: %s", overlayName)
os.Exit(1)
}
overlayFile := path.Join(overlaySourceDir, fileName)
if !util.IsFile(overlayFile) && !util.IsDir(overlayFile) {
wwlog.Error("File does not exist within overlay: %s:%s\n", overlayName, fileName)
wwlog.Error("File does not exist within overlay: %s:%s", overlayName, fileName)
os.Exit(1)
}
err = os.Chown(overlayFile, uid, gid)
if err != nil {
wwlog.Error("Could not set ownership: %s\n", err)
wwlog.Error("Could not set ownership: %s", err)
os.Exit(1)
}

View File

@@ -12,7 +12,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
err := overlay.OverlayInit(args[0])
if err != nil {
wwlog.Error("%s\n", err)
wwlog.Error("%s", err)
os.Exit(1)
}

View File

@@ -25,12 +25,12 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
overlayPath = overlay.OverlaySourceDir(overlayName)
if overlayPath == "" {
wwlog.Error("Overlay name did not resolve: '%s'\n", overlayName)
wwlog.Error("Overlay name did not resolve: '%s'", overlayName)
os.Exit(1)
}
if !util.IsDir(overlayPath) {
wwlog.Error("Overlay does not exist: %s\n", overlayName)
wwlog.Error("Overlay does not exist: %s", overlayName)
os.Exit(1)
}
@@ -55,22 +55,22 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
removePath := path.Join(overlayPath, fileName)
if !util.IsDir(removePath) && !util.IsFile(removePath) {
wwlog.Error("Path to remove doesn't exist in overlay: %s\n", removePath)
wwlog.Error("Path to remove doesn't exist in overlay: %s", removePath)
os.Exit(1)
}
if Force {
err := os.RemoveAll(removePath)
if err != nil {
wwlog.Error("Failed deleting file from overlay: %s:%s\n", overlayName, overlayPath)
wwlog.Error("%s\n", err)
wwlog.Error("Failed deleting file from overlay: %s:%s", overlayName, overlayPath)
wwlog.Error("%s", err)
os.Exit(1)
}
} else {
err := os.Remove(removePath)
if err != nil {
wwlog.Error("Failed deleting overlay: %s:%s\n", overlayName, overlayPath)
wwlog.Error("%s\n", err)
wwlog.Error("Failed deleting overlay: %s:%s", overlayName, overlayPath)
wwlog.Error("%s", err)
os.Exit(1)
}
}
@@ -79,13 +79,13 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
// Cleanup any empty directories left behind...
i := path.Dir(removePath)
for i != overlayPath {
wwlog.Debug("Evaluating directory to remove: %s\n", i)
wwlog.Debug("Evaluating directory to remove: %s", i)
err := os.Remove(i)
if err != nil {
break
}
wwlog.Verbose("Removed empty directory: %s\n", i)
wwlog.Verbose("Removed empty directory: %s", i)
i = path.Dir(i)
}
}

View File

@@ -26,34 +26,34 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
overlaySourceDir = overlay.OverlaySourceDir(overlayName)
if !util.IsDir(overlaySourceDir) {
wwlog.Error("Overlay does not exist: %s\n", overlayName)
wwlog.Error("Overlay does not exist: %s", overlayName)
os.Exit(1)
}
overlayFile := path.Join(overlaySourceDir, fileName)
wwlog.Debug("Will edit overlay file: %s\n", overlayFile)
wwlog.Debug("Will edit overlay file: %s", overlayFile)
if CreateDirs {
err := os.MkdirAll(path.Dir(overlayFile), 0755)
if err != nil {
wwlog.Error("Could not create directory: %s\n", path.Dir(overlayFile))
wwlog.Error("Could not create directory: %s", path.Dir(overlayFile))
os.Exit(1)
}
} else {
if !util.IsDir(path.Dir(overlayFile)) {
wwlog.Error("Can not create file, parent directory does not exist, try adding the\n")
wwlog.Error("'--parents' option to create the directory.\n")
wwlog.Error("Can not create file, parent directory does not exist, try adding the")
wwlog.Error("'--parents' option to create the directory.")
os.Exit(1)
}
}
if !util.IsFile(overlayFile) && filepath.Ext(overlayFile) == ".ww" {
wwlog.Verbose("This is a new file, creating some default content\n")
wwlog.Verbose("This is a new file, creating some default content")
w, err := os.OpenFile(overlayFile, os.O_RDWR|os.O_CREATE, os.FileMode(PermMode))
if err != nil {
wwlog.Warn("Could not create file for writing: %s\n", err)
wwlog.Warn("Could not create file for writing: %s", err)
}
fmt.Fprintf(w, "# This is a Warewulf Template file.\n")
@@ -72,7 +72,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
err := util.ExecInteractive(editor, overlayFile)
if err != nil {
wwlog.Error("Editor process existed with non-zero\n")
wwlog.Error("Editor process existed with non-zero")
os.Exit(1)
}

View File

@@ -25,11 +25,11 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
dest = source
}
wwlog.Verbose("Copying '%s' into overlay '%s:%s'\n", source, overlayName, dest)
wwlog.Verbose("Copying '%s' into overlay '%s:%s'", source, overlayName, dest)
overlaySource = overlay.OverlaySourceDir(overlayName)
if !util.IsDir(overlaySource) {
wwlog.Error("Overlay does not exist: %s\n", overlayName)
wwlog.Error("Overlay does not exist: %s", overlayName)
os.Exit(1)
}
@@ -50,13 +50,13 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if !NoOverlayUpdate {
n, err := node.New()
if err != nil {
wwlog.Error("Could not open node configuration: %s\n", err)
wwlog.Error("Could not open node configuration: %s", err)
os.Exit(1)
}
nodes, err := n.FindAllNodes()
if err != nil {
wwlog.Error("Could not get node list: %s\n", err)
wwlog.Error("Could not get node list: %s", err)
os.Exit(1)
}

View File

@@ -38,7 +38,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if util.IsDir(path) {
files := util.FindFiles(path)
wwlog.Debug("Iterating overlay path: %s\n", path)
wwlog.Debug("Iterating overlay path: %s", path)
if ListContents {
var fileCount int
for file := range files {
@@ -68,7 +68,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
} else {
wwlog.Error("system/%s (path not found:%s)\n", overlays[o], path)
wwlog.Error("system/%s (path not found:%s)", overlays[o], path)
}
}

View File

@@ -19,17 +19,17 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
overlaySourceDir = overlay.OverlaySourceDir(overlayName)
if !util.IsDir(overlaySourceDir) {
wwlog.Error("Overlay does not exist: %s\n", overlayName)
wwlog.Error("Overlay does not exist: %s", overlayName)
os.Exit(1)
}
overlayDir := path.Join(overlaySourceDir, dirName)
wwlog.Debug("Will create directory in overlay: %s:%s\n", overlayName, dirName)
wwlog.Debug("Will create directory in overlay: %s:%s", overlayName, dirName)
err := os.MkdirAll(overlayDir, os.FileMode(PermMode))
if err != nil {
wwlog.Error("Could not create directory: %s\n", path.Dir(overlayDir))
wwlog.Error("Could not create directory: %s", path.Dir(overlayDir))
os.Exit(1)
}

View File

@@ -26,48 +26,48 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
overlaySourceDir = overlay.OverlaySourceDir(overlayName)
if !util.IsDir(overlaySourceDir) {
wwlog.Error("Overlay does not exist: %s\n", overlayName)
wwlog.Error("Overlay does not exist: %s", overlayName)
os.Exit(1)
}
overlayFile := path.Join(overlaySourceDir, fileName)
if !util.IsFile(overlayFile) {
wwlog.Error("File does not exist within overlay: %s:%s\n", overlayName, fileName)
wwlog.Error("File does not exist within overlay: %s:%s", overlayName, fileName)
os.Exit(1)
}
if NodeName == "" {
f, err := ioutil.ReadFile(overlayFile)
if err != nil {
wwlog.Error("Could not read file: %s\n", err)
wwlog.Error("Could not read file: %s", err)
os.Exit(1)
}
fmt.Print(string(f))
} else {
if !util.IsFile(overlayFile) {
wwlog.Debug("%s is not a file\n", overlayFile)
wwlog.Error("%s:%s is not a file\n", overlayName, fileName)
wwlog.Debug("%s is not a file", overlayFile)
wwlog.Error("%s:%s is not a file", overlayName, fileName)
os.Exit(1)
}
if filepath.Ext(overlayFile) != ".ww" {
wwlog.Warn("%s lacks the '.ww' suffix, will not be rendered in an overlay\n", fileName)
wwlog.Warn("%s lacks the '.ww' suffix, will not be rendered in an overlay", fileName)
}
nodeDB, err := node.New()
if err != nil {
wwlog.Error("Could not open node configuration: %s\n", err)
wwlog.Error("Could not open node configuration: %s", err)
os.Exit(1)
}
nodes, err := nodeDB.FindAllNodes()
if err != nil {
wwlog.Error("Could not get node list: %s\n", err)
wwlog.Error("Could not get node list: %s", err)
os.Exit(1)
}
filteredNodes := node.FilterByName(nodes, []string{NodeName})
if len(filteredNodes) != 1 {
wwlog.Error("%v does not identify a single node\n", NodeName)
wwlog.Error("%v does not identify a single node", NodeName)
os.Exit(1)
}
tstruct := overlay.InitStruct(filteredNodes[0])
@@ -87,11 +87,11 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
line := bufferScanner.Text()
filenameFromTemplate := reg.FindAllStringSubmatch(line, -1)
if len(filenameFromTemplate) != 0 {
wwlog.Debug("Found multifile comment, new filename %s\n", filenameFromTemplate[0][1])
wwlog.Debug("Found multifile comment, new filename %s", filenameFromTemplate[0][1])
if foundFileComment {
if !Quiet {
wwlog.Info("backupFile: %v\nwriteFile: %v\n", backupFile, writeFile)
wwlog.Info("Filename: %s\n\n", destFileName)
wwlog.Info("backupFile: %v\nwriteFile: %v", backupFile, writeFile)
wwlog.Info("Filename: %s\n", destFileName)
}
wwlog.Info("%s", outBuffer.String())
outBuffer.Reset()
@@ -103,8 +103,8 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
}
if !Quiet {
wwlog.Info("backupFile: %v\nwriteFile: %v\n", backupFile, writeFile)
wwlog.Info("Filename: %s\n\n", destFileName)
wwlog.Info("backupFile: %v\nwriteFile: %v", backupFile, writeFile)
wwlog.Info("Filename: %s\n", destFileName)
}
fmt.Print(outBuffer.String())
}

View File

@@ -17,13 +17,13 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
nodeDB, err := node.New()
if err != nil {
wwlog.Error("Could not open node configuration: %s\n", err)
wwlog.Error("Could not open node configuration: %s", err)
os.Exit(1)
}
nodes, err := nodeDB.FindAllNodes()
if err != nil {
wwlog.Error("Could not get node list: %s\n", err)
wwlog.Error("Could not get node list: %s", err)
os.Exit(1)
}
@@ -47,7 +47,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
for _, node := range nodes {
if node.Ipmi.Ipaddr.Get() == "" {
wwlog.Error("%s: No IPMI IP address\n", node.Id.Get())
wwlog.Error("%s: No IPMI IP address", node.Id.Get())
continue
}
var ipmiInterface = "lan"
@@ -85,7 +85,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
out, err := result.Result()
if err != nil {
wwlog.Error("%s: %s\n", result.NodeName, out)
wwlog.Error("%s: %s", result.NodeName, out)
returnErr = err
continue
}

View File

@@ -17,13 +17,13 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
nodeDB, err := node.New()
if err != nil {
wwlog.Error("Could not open node configuration: %s\n", err)
wwlog.Error("Could not open node configuration: %s", err)
os.Exit(1)
}
nodes, err := nodeDB.FindAllNodes()
if err != nil {
wwlog.Error("Could not get node list: %s\n", err)
wwlog.Error("Could not get node list: %s", err)
os.Exit(1)
}
@@ -47,7 +47,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
for _, node := range nodes {
if node.Ipmi.Ipaddr.Get() == "" {
wwlog.Error("%s: No IPMI IP address\n", node.Id.Get())
wwlog.Error("%s: No IPMI IP address", node.Id.Get())
continue
}
var ipmiInterface = "lan"
@@ -85,7 +85,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
out, err := result.Result()
if err != nil {
wwlog.Error("%s: %s\n", result.NodeName, out)
wwlog.Error("%s: %s", result.NodeName, out)
returnErr = err
continue
}

View File

@@ -17,13 +17,13 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
nodeDB, err := node.New()
if err != nil {
wwlog.Error("Could not open node configuration: %s\n", err)
wwlog.Error("Could not open node configuration: %s", err)
os.Exit(1)
}
nodes, err := nodeDB.FindAllNodes()
if err != nil {
wwlog.Error("Could not get node list: %s\n", err)
wwlog.Error("Could not get node list: %s", err)
os.Exit(1)
}
@@ -47,7 +47,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
for _, node := range nodes {
if node.Ipmi.Ipaddr.Get() == "" {
wwlog.Error("%s: No IPMI IP address\n", node.Id.Get())
wwlog.Error("%s: No IPMI IP address", node.Id.Get())
continue
}
var ipmiInterface = "lan"
@@ -85,7 +85,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
out, err := result.Result()
if err != nil {
wwlog.Error("%s: %s\n", result.NodeName, out)
wwlog.Error("%s: %s", result.NodeName, out)
returnErr = err
continue
}

View File

@@ -17,13 +17,13 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
nodeDB, err := node.New()
if err != nil {
wwlog.Error("Could not open node configuration: %s\n", err)
wwlog.Error("Could not open node configuration: %s", err)
os.Exit(1)
}
nodes, err := nodeDB.FindAllNodes()
if err != nil {
wwlog.Error("Cloud not get nodeList: %s\n", err)
wwlog.Error("Cloud not get nodeList: %s", err)
os.Exit(1)
}
@@ -47,7 +47,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
for _, node := range nodes {
if node.Ipmi.Ipaddr.Get() == "" {
wwlog.Error("%s: No IPMI IP address\n", node.Id.Get())
wwlog.Error("%s: No IPMI IP address", node.Id.Get())
continue
}
var ipmiInterface = "lan"
@@ -85,7 +85,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
out, err := result.Result()
if err != nil {
wwlog.Error("%s: %s\n", result.NodeName, out)
wwlog.Error("%s: %s", result.NodeName, out)
returnErr = err
continue
}

View File

@@ -17,13 +17,13 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
nodeDB, err := node.New()
if err != nil {
wwlog.Error("Could not open node configuration: %s\n", err)
wwlog.Error("Could not open node configuration: %s", err)
os.Exit(1)
}
nodes, err := nodeDB.FindAllNodes()
if err != nil {
wwlog.Error("Cloud not get nodeList: %s\n", err)
wwlog.Error("Cloud not get nodeList: %s", err)
os.Exit(1)
}
@@ -47,7 +47,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
for _, node := range nodes {
if node.Ipmi.Ipaddr.Get() == "" {
wwlog.Error("%s: No IPMI IP address\n", node.Id.Get())
wwlog.Error("%s: No IPMI IP address", node.Id.Get())
continue
}
var ipmiInterface = "lan"
@@ -85,7 +85,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
out, err := result.Result()
if err != nil {
wwlog.Error("%s: %s\n", result.NodeName, out)
wwlog.Error("%s: %s", result.NodeName, out)
returnErr = err
continue
}

View File

@@ -17,13 +17,13 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
nodeDB, err := node.New()
if err != nil {
wwlog.Error("Could not open node configuration: %s\n", err)
wwlog.Error("Could not open node configuration: %s", err)
os.Exit(1)
}
nodes, err := nodeDB.FindAllNodes()
if err != nil {
wwlog.Error("Could not get node list: %s\n", err)
wwlog.Error("Could not get node list: %s", err)
os.Exit(1)
}
@@ -47,7 +47,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
for _, node := range nodes {
if node.Ipmi.Ipaddr.Get() == "" {
wwlog.Error("%s: No IPMI IP address\n", node.Id.Get())
wwlog.Error("%s: No IPMI IP address", node.Id.Get())
continue
}
var ipmiInterface = "lan"
@@ -85,7 +85,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
out, err := result.Result()
if err != nil {
wwlog.Error("%s: %s\n", result.NodeName, out)
wwlog.Error("%s: %s", result.NodeName, out)
returnErr = err
continue
}

View File

@@ -16,13 +16,13 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
nodeDB, err := node.New()
if err != nil {
wwlog.Error("Failed to open node database: %s\n", err)
wwlog.Error("Failed to open node database: %s", err)
os.Exit(1)
}
profiles, err := nodeDB.FindAllProfiles()
if err != nil {
wwlog.Error("Could not load all profiles: %s\n", err)
wwlog.Error("Could not load all profiles: %s", err)
os.Exit(1)
}
@@ -31,13 +31,13 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if p.Id.Get() == r {
nodes, err := nodeDB.FindAllNodes()
if err != nil {
wwlog.Error("Could not load all nodes: %s\n", err)
wwlog.Error("Could not load all nodes: %s", err)
os.Exit(1)
}
for _, n := range nodes {
for _, np := range n.Profiles.GetSlice() {
if np == r {
wwlog.Verbose("Removing profile from node %s: %s\n", n.Id.Get(), r)
wwlog.Verbose("Removing profile from node %s: %s", n.Id.Get(), r)
n.Profiles.SliceRemoveElement(r)
err := nodeDB.NodeUpdate(n)
if err != nil {
@@ -58,7 +58,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
found = true
err := nodeDB.DelProfile(r)
if err != nil {
wwlog.Error("%s\n", err)
wwlog.Error("%s", err)
}
}
}

View File

@@ -14,13 +14,13 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
nodeDB, err := node.New()
if err != nil {
wwlog.Error("Could not open node configuration: %s\n", err)
wwlog.Error("Could not open node configuration: %s", err)
os.Exit(1)
}
profiles, err := nodeDB.FindAllProfiles()
if err != nil {
wwlog.Error("Could not find all nodes: %s\n", err)
wwlog.Error("Could not find all nodes: %s", err)
os.Exit(1)
}

View File

@@ -21,13 +21,13 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
nodeDB, err := node.New()
if err != nil {
wwlog.Error("Could not open node configuration: %s\n", err)
wwlog.Error("Could not open node configuration: %s", err)
os.Exit(1)
}
nodes, err := nodeDB.FindAllNodes()
if err != nil {
wwlog.Error("Could not get node list: %s\n", err)
wwlog.Error("Could not get node list: %s", err)
os.Exit(1)
}
@@ -63,7 +63,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
fmt.Printf("%s: %s %s\n", nodename, SshPath, strings.Join(command, " "))
} else {
wwlog.Debug("Sending command to node '%s': %s\n", nodename, command)
wwlog.Debug("Sending command to node '%s': %s", nodename, command)
var stdout, stderr bytes.Buffer
cmd := exec.Command(SshPath, command...)
cmd.Stdin = os.Stdin