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:
@@ -40,34 +40,34 @@ func ContainerBuild(cbp *wwapiv1.ContainerBuildParameter) (err error) {
|
||||
for _, c := range containers {
|
||||
if !container.ValidSource(c) {
|
||||
err = fmt.Errorf("VNFS name does not exist: %s", c)
|
||||
wwlog.Error("%s\n", err)
|
||||
wwlog.Error("%s", err)
|
||||
return
|
||||
}
|
||||
|
||||
err = container.Build(c, cbp.Force)
|
||||
if err != nil {
|
||||
wwlog.Error("Could not build container %s: %s\n", c, err)
|
||||
wwlog.Error("Could not build container %s: %s", c, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if cbp.Default {
|
||||
if len(containers) != 1 {
|
||||
wwlog.Error("Can only set default for one container\n")
|
||||
wwlog.Error("Can only set default for one container")
|
||||
} else {
|
||||
var nodeDB node.NodeYaml
|
||||
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)
|
||||
return
|
||||
}
|
||||
|
||||
//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 container name to: %s\n", containers[0])
|
||||
wwlog.Debug("Found profile default, setting container name to: %s", containers[0])
|
||||
profile.ContainerName.Set(containers[0])
|
||||
err := nodeDB.ProfileUpdate(profile)
|
||||
if err != nil {
|
||||
@@ -94,7 +94,7 @@ func ContainerDelete(cdp *wwapiv1.ContainerDeleteParameter) (err 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)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -109,18 +109,18 @@ ARG_LOOP:
|
||||
containerName := cdp.ContainerNames[i]
|
||||
for _, n := range nodes {
|
||||
if n.ContainerName.Get() == containerName {
|
||||
wwlog.Error("Container is configured for nodes, skipping: %s\n", containerName)
|
||||
wwlog.Error("Container is configured for nodes, skipping: %s", containerName)
|
||||
continue ARG_LOOP
|
||||
}
|
||||
}
|
||||
|
||||
if !container.ValidSource(containerName) {
|
||||
wwlog.Error("Container name is not a valid source: %s\n", containerName)
|
||||
wwlog.Error("Container name is not a valid source: %s", containerName)
|
||||
continue
|
||||
}
|
||||
err := container.DeleteSource(containerName)
|
||||
if err != nil {
|
||||
wwlog.Error("Could not remove source: %s\n", containerName)
|
||||
wwlog.Error("Could not remove source: %s", containerName)
|
||||
} else {
|
||||
fmt.Printf("Container has been deleted: %s\n", containerName)
|
||||
}
|
||||
@@ -143,7 +143,7 @@ func ContainerImport(cip *wwapiv1.ContainerImportParameter) (containerName strin
|
||||
}
|
||||
if !container.ValidName(cip.Name) {
|
||||
err = fmt.Errorf("VNFS name contains illegal characters: %s", cip.Name)
|
||||
wwlog.Error("%s\n", err)
|
||||
wwlog.Error("%s", err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -155,53 +155,53 @@ func ContainerImport(cip *wwapiv1.ContainerImportParameter) (containerName strin
|
||||
fmt.Printf("Overwriting existing VNFS\n")
|
||||
err = os.RemoveAll(fullPath)
|
||||
if err != nil {
|
||||
wwlog.Error("%s\n", err)
|
||||
wwlog.Error("%s", err)
|
||||
return
|
||||
}
|
||||
} else if cip.Update {
|
||||
fmt.Printf("Updating existing VNFS\n")
|
||||
} else {
|
||||
err = fmt.Errorf("VNFS Name exists, specify --force, --update, or choose a different name: %s", cip.Name)
|
||||
wwlog.Error("%s\n", err)
|
||||
wwlog.Error("%s", err)
|
||||
return
|
||||
}
|
||||
} else if strings.HasPrefix(cip.Source, "docker://") || strings.HasPrefix(cip.Source, "docker-daemon://") {
|
||||
var sCtx *types.SystemContext
|
||||
sCtx, err = getSystemContext()
|
||||
if err != nil {
|
||||
wwlog.Error("%s\n", err)
|
||||
wwlog.Error("%s", err)
|
||||
// return was missing here. Was that deliberate?
|
||||
}
|
||||
|
||||
err = container.ImportDocker(cip.Source, cip.Name, sCtx)
|
||||
if err != nil {
|
||||
wwlog.Error("Could not import image: %s\n", err)
|
||||
wwlog.Error("Could not import image: %s", err)
|
||||
_ = container.DeleteSource(cip.Name)
|
||||
return
|
||||
}
|
||||
} else if util.IsDir(cip.Source) {
|
||||
err = container.ImportDirectory(cip.Source, cip.Name)
|
||||
if err != nil {
|
||||
wwlog.Error("Could not import image: %s\n", err)
|
||||
wwlog.Error("Could not import image: %s", err)
|
||||
_ = container.DeleteSource(cip.Name)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
err = fmt.Errorf("Invalid dir or uri: %s", cip.Source)
|
||||
wwlog.Error("%s\n", err)
|
||||
wwlog.Error("%s", err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("Updating the container's /etc/resolv.conf\n")
|
||||
err = util.CopyFile("/etc/resolv.conf", path.Join(container.RootFsDir(cip.Name), "/etc/resolv.conf"))
|
||||
if err != nil {
|
||||
wwlog.Warn("Could not copy /etc/resolv.conf into container: %s\n", err)
|
||||
wwlog.Warn("Could not copy /etc/resolv.conf into container: %s", err)
|
||||
}
|
||||
|
||||
fmt.Printf("Building container: %s\n", cip.Name)
|
||||
err = container.Build(cip.Name, true)
|
||||
if err != nil {
|
||||
wwlog.Error("Could not build container %s: %s\n", cip.Name, err)
|
||||
wwlog.Error("Could not build container %s: %s", cip.Name, err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -209,16 +209,16 @@ func ContainerImport(cip *wwapiv1.ContainerImportParameter) (containerName strin
|
||||
var nodeDB node.NodeYaml
|
||||
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)
|
||||
return
|
||||
}
|
||||
|
||||
//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 container name to: %s\n", cip.Name)
|
||||
wwlog.Debug("Found profile default, setting container name to: %s", cip.Name)
|
||||
profile.ContainerName.Set(cip.Name)
|
||||
err = nodeDB.ProfileUpdate(profile)
|
||||
if err != nil {
|
||||
@@ -251,19 +251,19 @@ func ContainerList() (containerInfo []*wwapiv1.ContainerInfo, err error) {
|
||||
|
||||
sources, err = container.ListSources()
|
||||
if err != nil {
|
||||
wwlog.Error("%s\n", err)
|
||||
wwlog.Error("%s", err)
|
||||
return
|
||||
}
|
||||
|
||||
nodeDB, err := node.New()
|
||||
if err != nil {
|
||||
wwlog.Error("%s\n", err)
|
||||
wwlog.Error("%s", err)
|
||||
return
|
||||
}
|
||||
|
||||
nodes, err := nodeDB.FindAllNodes()
|
||||
if err != nil {
|
||||
wwlog.Error("%s\n", err)
|
||||
wwlog.Error("%s", err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ func ContainerList() (containerInfo []*wwapiv1.ContainerInfo, err error) {
|
||||
nodemap[source] = 0
|
||||
}
|
||||
|
||||
wwlog.Debug("Finding kernel version for: %s\n", source)
|
||||
wwlog.Debug("Finding kernel version for: %s", source)
|
||||
kernelVersion := container.KernelVersion(source)
|
||||
|
||||
containerInfo = append(containerInfo, &wwapiv1.ContainerInfo{
|
||||
|
||||
@@ -38,34 +38,34 @@ func ContainerBuild(cbp *wwapiv1.ContainerBuildParameter) (err error) {
|
||||
for _, c := range containers {
|
||||
if !container.ValidSource(c) {
|
||||
err = fmt.Errorf("VNFS name does not exist: %s", c)
|
||||
wwlog.Error("%s\n", err)
|
||||
wwlog.Error("%s", err)
|
||||
return
|
||||
}
|
||||
|
||||
err = container.Build(c, cbp.Force)
|
||||
if err != nil {
|
||||
wwlog.Error("Could not build container %s: %s\n", c, err)
|
||||
wwlog.Error("Could not build container %s: %s", c, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if cbp.Default {
|
||||
if len(containers) != 1 {
|
||||
wwlog.Error("Can only set default for one container\n")
|
||||
wwlog.Error("Can only set default for one container")
|
||||
} else {
|
||||
var nodeDB node.NodeYaml
|
||||
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)
|
||||
return
|
||||
}
|
||||
|
||||
//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 container name to: %s\n", containers[0])
|
||||
wwlog.Debug("Found profile default, setting container name to: %s", containers[0])
|
||||
profile.ContainerName.Set(containers[0])
|
||||
err := nodeDB.ProfileUpdate(profile)
|
||||
if err != nil {
|
||||
@@ -92,7 +92,7 @@ func ContainerDelete(cdp *wwapiv1.ContainerDeleteParameter) (err 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)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -107,22 +107,22 @@ ARG_LOOP:
|
||||
containerName := cdp.ContainerNames[i]
|
||||
for _, n := range nodes {
|
||||
if n.ContainerName.Get() == containerName {
|
||||
wwlog.Error("Container is configured for nodes, skipping: %s\n", containerName)
|
||||
wwlog.Error("Container is configured for nodes, skipping: %s", containerName)
|
||||
continue ARG_LOOP
|
||||
}
|
||||
}
|
||||
|
||||
if !container.ValidSource(containerName) {
|
||||
wwlog.Error("Container name is not a valid source: %s\n", containerName)
|
||||
wwlog.Error("Container name is not a valid source: %s", containerName)
|
||||
continue
|
||||
}
|
||||
err := container.DeleteSource(containerName)
|
||||
if err != nil {
|
||||
wwlog.Error("Could not remove source: %s\n", containerName)
|
||||
wwlog.Error("Could not remove source: %s", containerName)
|
||||
}
|
||||
err = container.DeleteImage(containerName)
|
||||
if err != nil {
|
||||
wwlog.Error("Could not remove image files %s\n", containerName)
|
||||
wwlog.Error("Could not remove image files %s", containerName)
|
||||
}
|
||||
|
||||
fmt.Printf("Container has been deleted: %s\n", containerName)
|
||||
@@ -200,7 +200,7 @@ func ContainerImport(cip *wwapiv1.ContainerImportParameter) (containerName strin
|
||||
wwlog.Info("Updating the container's /etc/resolv.conf")
|
||||
err = util.CopyFile("/etc/resolv.conf", path.Join(container.RootFsDir(cip.Name), "/etc/resolv.conf"))
|
||||
if err != nil {
|
||||
wwlog.Warn("Could not copy /etc/resolv.conf into container: %s\n", err)
|
||||
wwlog.Warn("Could not copy /etc/resolv.conf into container: %s", err)
|
||||
}
|
||||
|
||||
err = container.SyncUids(cip.Name, !cip.SyncUser)
|
||||
@@ -265,19 +265,19 @@ func ContainerList() (containerInfo []*wwapiv1.ContainerInfo, err error) {
|
||||
|
||||
sources, err = container.ListSources()
|
||||
if err != nil {
|
||||
wwlog.Error("%s\n", err)
|
||||
wwlog.Error("%s", err)
|
||||
return
|
||||
}
|
||||
|
||||
nodeDB, err := node.New()
|
||||
if err != nil {
|
||||
wwlog.Error("%s\n", err)
|
||||
wwlog.Error("%s", err)
|
||||
return
|
||||
}
|
||||
|
||||
nodes, err := nodeDB.FindAllNodes()
|
||||
if err != nil {
|
||||
wwlog.Error("%s\n", err)
|
||||
wwlog.Error("%s", err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -291,7 +291,7 @@ func ContainerList() (containerInfo []*wwapiv1.ContainerInfo, err error) {
|
||||
nodemap[source] = 0
|
||||
}
|
||||
|
||||
wwlog.Debug("Finding kernel version for: %s\n", source)
|
||||
wwlog.Debug("Finding kernel version for: %s", source)
|
||||
kernelVersion := container.KernelVersion(source)
|
||||
|
||||
containerInfo = append(containerInfo, &wwapiv1.ContainerInfo{
|
||||
|
||||
@@ -43,7 +43,7 @@ func NodeAdd(nap *wwapiv1.NodeAddParameter) (err error) {
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to add node")
|
||||
}
|
||||
wwlog.Info("Added node: %s\n", a)
|
||||
wwlog.Info("Added node: %s", a)
|
||||
var netName string
|
||||
for netName = range nodeConf.NetDevs {
|
||||
// as map should only have key this should give is the first and
|
||||
@@ -55,12 +55,12 @@ func NodeAdd(nap *wwapiv1.NodeAddParameter) (err error) {
|
||||
// if more nodes are added increment IPv4 address
|
||||
nodeConf.NetDevs[netName].Ipaddr = util.IncrementIPv4(nodeConf.NetDevs[netName].Ipaddr, 1)
|
||||
|
||||
wwlog.Verbose("Incremented IP addr to %s\n", nodeConf.NetDevs[netName].Ipaddr)
|
||||
wwlog.Verbose("Incremented IP addr to %s", nodeConf.NetDevs[netName].Ipaddr)
|
||||
}
|
||||
if nodeConf.Ipmi != nil && nodeConf.Ipmi.Ipaddr != "" {
|
||||
// if more nodes are added increment IPv4 address
|
||||
nodeConf.Ipmi.Ipaddr = util.IncrementIPv4(nodeConf.Ipmi.Ipaddr, 1)
|
||||
wwlog.Verbose("Incremented IP addr to %s\n", nodeConf.Ipmi.Ipaddr)
|
||||
wwlog.Verbose("Incremented IP addr to %s", nodeConf.Ipmi.Ipaddr)
|
||||
}
|
||||
err = nodeDB.NodeUpdate(n)
|
||||
if err != nil {
|
||||
@@ -92,14 +92,14 @@ func NodeDelete(ndp *wwapiv1.NodeDeleteParameter) (err 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)
|
||||
return
|
||||
}
|
||||
|
||||
for _, n := range nodeList {
|
||||
err := nodeDB.DelNode(n.Id.Get())
|
||||
if err != nil {
|
||||
wwlog.Error("%s\n", err)
|
||||
wwlog.Error("%s", err)
|
||||
} else {
|
||||
//count++
|
||||
fmt.Printf("Deleting node: %s\n", n.Id.Print())
|
||||
@@ -130,13 +130,13 @@ func NodeDeleteParameterCheck(ndp *wwapiv1.NodeDeleteParameter, console bool) (n
|
||||
|
||||
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)
|
||||
return
|
||||
}
|
||||
|
||||
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)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -201,13 +201,13 @@ func NodeSetParameterCheck(set *wwapiv1.NodeSetParameter, console bool) (nodeDB
|
||||
|
||||
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)
|
||||
return
|
||||
}
|
||||
|
||||
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)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -229,22 +229,22 @@ func NodeSetParameterCheck(set *wwapiv1.NodeSetParameter, console bool) (nodeDB
|
||||
}
|
||||
|
||||
for _, n := range nodes {
|
||||
wwlog.Verbose("Evaluating node: %s\n", n.Id.Get())
|
||||
wwlog.Verbose("Evaluating node: %s", n.Id.Get())
|
||||
var nodeConf node.NodeConf
|
||||
err = yaml.Unmarshal([]byte(set.NodeConfYaml), &nodeConf)
|
||||
if err != nil {
|
||||
wwlog.Error(fmt.Sprintf("%v\n", err.Error()))
|
||||
wwlog.Error(fmt.Sprintf("%v", err.Error()))
|
||||
return
|
||||
}
|
||||
n.SetFrom(&nodeConf)
|
||||
if set.NetdevDelete != "" {
|
||||
if _, ok := n.NetDevs[set.NetdevDelete]; !ok {
|
||||
err = fmt.Errorf("network device name doesn't exist: %s", set.NetdevDelete)
|
||||
wwlog.Error(fmt.Sprintf("%v\n", err.Error()))
|
||||
wwlog.Error(fmt.Sprintf("%v", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
wwlog.Verbose("Node: %s, Deleting network device: %s\n", n.Id.Get(), set.NetdevDelete)
|
||||
wwlog.Verbose("Node: %s, Deleting network device: %s", n.Id.Get(), set.NetdevDelete)
|
||||
delete(n.NetDevs, set.NetdevDelete)
|
||||
}
|
||||
for _, key := range nodeConf.TagsDel {
|
||||
@@ -262,7 +262,7 @@ func NodeSetParameterCheck(set *wwapiv1.NodeSetParameter, console bool) (nodeDB
|
||||
}
|
||||
err := nodeDB.NodeUpdate(n)
|
||||
if err != nil {
|
||||
wwlog.Error("%s\n", err)
|
||||
wwlog.Error("%s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
@@ -292,22 +292,22 @@ func NodeStatus(nodeNames []string) (nodeStatusResponse *wwapiv1.NodeStatusRespo
|
||||
|
||||
controller, err := warewulfconf.New()
|
||||
if err != nil {
|
||||
wwlog.Error("%s\n", err)
|
||||
wwlog.Error("%s", err)
|
||||
return
|
||||
}
|
||||
|
||||
if controller.Ipaddr == "" {
|
||||
err = fmt.Errorf("the Warewulf Server IP Address is not properly configured")
|
||||
wwlog.Error(fmt.Sprintf("%v\n", err.Error()))
|
||||
wwlog.Error(fmt.Sprintf("%v", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
statusURL := fmt.Sprintf("http://%s:%d/status", controller.Ipaddr, controller.Warewulf.Port)
|
||||
wwlog.Verbose("Connecting to: %s\n", statusURL)
|
||||
wwlog.Verbose("Connecting to: %s", statusURL)
|
||||
|
||||
resp, err := http.Get(statusURL)
|
||||
if err != nil {
|
||||
wwlog.Error("Could not connect to Warewulf server: %s\n", err)
|
||||
wwlog.Error("Could not connect to Warewulf server: %s", err)
|
||||
return
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
@@ -317,7 +317,7 @@ func NodeStatus(nodeNames []string) (nodeStatusResponse *wwapiv1.NodeStatusRespo
|
||||
|
||||
err = decoder.Decode(&wwNodeStatus)
|
||||
if err != nil {
|
||||
wwlog.Error("Could not decode JSON: %s\n", err)
|
||||
wwlog.Error("Could not decode JSON: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -51,13 +51,13 @@ func ProfileSetParameterCheck(set *wwapiv1.NodeSetParameter, console bool) (node
|
||||
|
||||
nodeDB, err = node.New()
|
||||
if err != nil {
|
||||
wwlog.Error("Could not open configuration: %s\n", err)
|
||||
wwlog.Error("Could not open configuration: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
profiles, err := nodeDB.FindAllProfiles()
|
||||
if err != nil {
|
||||
wwlog.Error("Could not get profile list: %s\n", err)
|
||||
wwlog.Error("Could not get profile list: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -78,21 +78,21 @@ func ProfileSetParameterCheck(set *wwapiv1.NodeSetParameter, console bool) (node
|
||||
var pConf node.NodeConf
|
||||
err = yaml.Unmarshal([]byte(set.NodeConfYaml), &pConf)
|
||||
if err != nil {
|
||||
wwlog.Error(fmt.Sprintf("%v\n", err.Error()))
|
||||
wwlog.Error(fmt.Sprintf("%v", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
for _, p := range profiles {
|
||||
if util.InSlice(set.NodeNames, p.Id.Get()) {
|
||||
wwlog.Verbose("Evaluating profile: %s\n", p.Id.Get())
|
||||
wwlog.Verbose("Evaluating profile: %s", p.Id.Get())
|
||||
p.SetFrom(&pConf)
|
||||
if set.NetdevDelete != "" {
|
||||
if _, ok := p.NetDevs[set.NetdevDelete]; !ok {
|
||||
err = fmt.Errorf("network device name doesn't exist: %s", set.NetdevDelete)
|
||||
wwlog.Error(fmt.Sprintf("%v\n", err.Error()))
|
||||
wwlog.Error(fmt.Sprintf("%v", err.Error()))
|
||||
return
|
||||
}
|
||||
wwlog.Verbose("Profile: %s, Deleting network device: %s\n", p.Id.Get(), set.NetdevDelete)
|
||||
wwlog.Verbose("Profile: %s, Deleting network device: %s", p.Id.Get(), set.NetdevDelete)
|
||||
delete(p.NetDevs, set.NetdevDelete)
|
||||
}
|
||||
for _, key := range pConf.TagsDel {
|
||||
@@ -110,7 +110,7 @@ func ProfileSetParameterCheck(set *wwapiv1.NodeSetParameter, console bool) (node
|
||||
}
|
||||
err := nodeDB.ProfileUpdate(p)
|
||||
if err != nil {
|
||||
wwlog.Error("%s\n", err)
|
||||
wwlog.Error("%s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
|
||||
@@ -22,71 +22,71 @@ var (
|
||||
)
|
||||
|
||||
func BINDIR() string {
|
||||
wwlog.Debug("BINDIR = '%s'\n", bindir)
|
||||
wwlog.Debug("BINDIR = '%s'", bindir)
|
||||
return bindir
|
||||
}
|
||||
|
||||
func DATADIR() string {
|
||||
wwlog.Debug("DATADIR = '%s'\n", bindir)
|
||||
wwlog.Debug("DATADIR = '%s'", bindir)
|
||||
return datadir
|
||||
}
|
||||
|
||||
func SYSCONFDIR() string {
|
||||
wwlog.Debug("SYSCONFDIR = '%s'\n", sysconfdir)
|
||||
wwlog.Debug("SYSCONFDIR = '%s'", sysconfdir)
|
||||
return sysconfdir
|
||||
}
|
||||
|
||||
func LOCALSTATEDIR() string {
|
||||
wwlog.Debug("LOCALSTATEDIR = '%s'\n", localstatedir)
|
||||
wwlog.Debug("LOCALSTATEDIR = '%s'", localstatedir)
|
||||
return localstatedir
|
||||
}
|
||||
|
||||
func SRVDIR() string {
|
||||
wwlog.Debug("SRVDIR = '%s'\n", srvdir)
|
||||
wwlog.Debug("SRVDIR = '%s'", srvdir)
|
||||
return srvdir
|
||||
}
|
||||
|
||||
func TFTPDIR() string {
|
||||
wwlog.Debug("TFTPDIR = '%s'\n", tftpdir)
|
||||
wwlog.Debug("TFTPDIR = '%s'", tftpdir)
|
||||
return tftpdir
|
||||
}
|
||||
|
||||
func FIREWALLDDIR() string {
|
||||
wwlog.Debug("FIREWALLDDIR = '%s'\n", firewallddir)
|
||||
wwlog.Debug("FIREWALLDDIR = '%s'", firewallddir)
|
||||
return firewallddir
|
||||
}
|
||||
|
||||
func SYSTEMDDIR() string {
|
||||
wwlog.Debug("SYSTEMDDIR = '%s'\n", systemddir)
|
||||
wwlog.Debug("SYSTEMDDIR = '%s'", systemddir)
|
||||
return systemddir
|
||||
}
|
||||
|
||||
func WWOVERLAYDIR() string {
|
||||
wwlog.Debug("WWOVERLAYDIR = '%s'\n", wwoverlaydir)
|
||||
wwlog.Debug("WWOVERLAYDIR = '%s'", wwoverlaydir)
|
||||
return wwoverlaydir
|
||||
}
|
||||
|
||||
func WWCHROOTDIR() string {
|
||||
wwlog.Debug("WWCHROOTDIR = '%s'\n", wwchrootdir)
|
||||
wwlog.Debug("WWCHROOTDIR = '%s'", wwchrootdir)
|
||||
return wwchrootdir
|
||||
}
|
||||
|
||||
func WWPROVISIONDIR() string {
|
||||
wwlog.Debug("WWPROVISIONDIR = '%s'\n", wwprovisiondir)
|
||||
wwlog.Debug("WWPROVISIONDIR = '%s'", wwprovisiondir)
|
||||
return wwprovisiondir
|
||||
}
|
||||
|
||||
func VERSION() string {
|
||||
wwlog.Debug("VERSION = '%s'\n", version)
|
||||
wwlog.Debug("VERSION = '%s'", version)
|
||||
return version
|
||||
}
|
||||
|
||||
func RELEASE() string {
|
||||
wwlog.Debug("RELEASE = '%s'\n", release)
|
||||
wwlog.Debug("RELEASE = '%s'", release)
|
||||
return release
|
||||
}
|
||||
|
||||
func WWCLIENTDIR() string {
|
||||
wwlog.Debug("WWCLIENTDIR = '%s'\n", wwclientdir)
|
||||
wwlog.Debug("WWCLIENTDIR = '%s'", wwclientdir)
|
||||
return wwclientdir
|
||||
}
|
||||
|
||||
@@ -19,28 +19,28 @@ func Dhcp() error {
|
||||
|
||||
controller, err := warewulfconf.New()
|
||||
if err != nil {
|
||||
wwlog.Error("%s\n", err)
|
||||
wwlog.Error("%s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if !controller.Dhcp.Enabled {
|
||||
wwlog.Info("This system is not configured as a Warewulf DHCP controller\n")
|
||||
wwlog.Info("This system is not configured as a Warewulf DHCP controller")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if controller.Dhcp.RangeStart == "" {
|
||||
wwlog.Error("Configuration is not defined: `dhcpd range start`\n")
|
||||
wwlog.Error("Configuration is not defined: `dhcpd range start`")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if controller.Dhcp.RangeEnd == "" {
|
||||
wwlog.Error("Configuration is not defined: `dhcpd range end`\n")
|
||||
wwlog.Error("Configuration is not defined: `dhcpd range end`")
|
||||
os.Exit(1)
|
||||
}
|
||||
if 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)
|
||||
}
|
||||
} else {
|
||||
wwlog.Info("host overlays are disabled, did not modify/create dhcpd configuration")
|
||||
|
||||
@@ -16,7 +16,7 @@ Creates '/etc/hosts' from the host template.
|
||||
*/
|
||||
func Hostfile() error {
|
||||
if !(util.IsFile(path.Join(overlay.OverlaySourceDir("host"), "/host/etc/hosts.ww"))) {
|
||||
wwlog.Error("'the overlay template '/etc/hosts.ww' does not exists in 'host' overlay\n")
|
||||
wwlog.Error("'the overlay template '/etc/hosts.ww' does not exists in 'host' overlay")
|
||||
os.Exit(1)
|
||||
}
|
||||
var nodeInfo node.NodeInfo
|
||||
@@ -27,12 +27,12 @@ func Hostfile() error {
|
||||
path.Join(overlay.OverlaySourceDir("host"), "/host/etc/hosts.ww"),
|
||||
tstruct)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
wwlog.Error("%s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
info, err := os.Stat(path.Join(overlay.OverlaySourceDir("host"), "/host/etc/hosts.ww"))
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
wwlog.Error("%s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ func NFS() error {
|
||||
|
||||
controller, err := warewulfconf.New()
|
||||
if err != nil {
|
||||
wwlog.Error("%s\n", err)
|
||||
wwlog.Error("%s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ func NFS() error {
|
||||
if 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)
|
||||
}
|
||||
} else {
|
||||
wwlog.Info("host overlays are disabled, did not modify exports")
|
||||
|
||||
@@ -19,7 +19,7 @@ func SSH() error {
|
||||
|
||||
err := os.MkdirAll(path.Join(buildconfig.SYSCONFDIR(), "warewulf/keys"), 0755)
|
||||
if err != nil {
|
||||
wwlog.Error("Could not create base directory: %s\n", err)
|
||||
wwlog.Error("Could not create base directory: %s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
@@ -27,10 +27,10 @@ func SSH() error {
|
||||
keytype := "ssh_host_" + k + "_key"
|
||||
if !util.IsFile(path.Join(wwkeydir, keytype)) {
|
||||
fmt.Printf("Setting up key: %s\n", keytype)
|
||||
wwlog.Debug("Creating new %s key\n", keytype)
|
||||
wwlog.Debug("Creating new %s key", keytype)
|
||||
err = util.ExecInteractive("ssh-keygen", "-q", "-t", k, "-f", path.Join(wwkeydir, keytype), "-C", "", "-N", "")
|
||||
if err != nil {
|
||||
wwlog.Error("Failed to exec ssh-keygen: %s\n", err)
|
||||
wwlog.Error("Failed to exec ssh-keygen: %s", err)
|
||||
return errors.Wrap(err, "failed to exec ssh-keygen command")
|
||||
}
|
||||
} else {
|
||||
@@ -43,7 +43,7 @@ func SSH() error {
|
||||
|
||||
homeDir, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
wwlog.Error("Could not obtain the user's home directory: %s\n", err)
|
||||
wwlog.Error("Could not obtain the user's home directory: %s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
|
||||
@@ -16,13 +16,13 @@ var tftpdir string = path.Join(buildconfig.TFTPDIR(), "warewulf")
|
||||
func TFTP() error {
|
||||
controller, err := warewulfconf.New()
|
||||
if err != nil {
|
||||
wwlog.Error("%s\n", err)
|
||||
wwlog.Error("%s", err)
|
||||
return err
|
||||
}
|
||||
|
||||
err = os.MkdirAll(tftpdir, 0755)
|
||||
if err != nil {
|
||||
wwlog.Error("%s\n", err)
|
||||
wwlog.Error("%s", err)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -30,20 +30,20 @@ func TFTP() error {
|
||||
for _, f := range [4]string{"x86_64.efi", "x86_64.kpxe", "arm64.efi"} {
|
||||
err = util.SafeCopyFile(path.Join(buildconfig.DATADIR(), "warewulf", "ipxe", f), path.Join(tftpdir, f))
|
||||
if err != nil {
|
||||
wwlog.Error("%s\n", err)
|
||||
wwlog.Error("%s", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if !controller.Tftp.Enabled {
|
||||
wwlog.Info("Warewulf does not auto start TFTP services due to disable by warewulf.conf\n")
|
||||
wwlog.Info("Warewulf does not auto start TFTP services due to disable by warewulf.conf")
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
fmt.Printf("Enabling and restarting the TFTP services\n")
|
||||
err = util.SystemdStart(controller.Tftp.SystemdName)
|
||||
if err != nil {
|
||||
wwlog.Error("%s\n", err)
|
||||
wwlog.Error("%s", err)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -23,16 +23,16 @@ var (
|
||||
)
|
||||
|
||||
func KernelFind(container string) string {
|
||||
wwlog.Debug("Finding kernel\n")
|
||||
wwlog.Debug("Finding kernel")
|
||||
container_path := RootFsDir(container)
|
||||
if container_path == "" {
|
||||
return ""
|
||||
}
|
||||
|
||||
for _, kdir := range kernelDirs {
|
||||
wwlog.Debug("Checking kernel directory: %s\n", kdir)
|
||||
wwlog.Debug("Checking kernel directory: %s", kdir)
|
||||
for _, kname := range kernelNames {
|
||||
wwlog.Debug("Checking for kernel name: %s\n", kname)
|
||||
wwlog.Debug("Checking for kernel name: %s", kname)
|
||||
kernelPaths, err := filepath.Glob(path.Join(container_path, kdir, kname))
|
||||
if err != nil {
|
||||
return ""
|
||||
@@ -47,7 +47,7 @@ func KernelFind(container string) string {
|
||||
})
|
||||
|
||||
for _, kernelPath := range kernelPaths {
|
||||
wwlog.Debug("Checking for kernel path: %s\n", kernelPath)
|
||||
wwlog.Debug("Checking for kernel path: %s", kernelPath)
|
||||
if util.IsFile(kernelPath) {
|
||||
return kernelPath
|
||||
}
|
||||
@@ -59,7 +59,7 @@ func KernelFind(container string) string {
|
||||
}
|
||||
|
||||
func KernelVersion(container string) string {
|
||||
wwlog.Debug("Finding kernel version inside container: %s\n", container)
|
||||
wwlog.Debug("Finding kernel version inside container: %s", container)
|
||||
kernel := KernelFind(container)
|
||||
if kernel == "" {
|
||||
return ""
|
||||
|
||||
@@ -69,7 +69,7 @@ func SyncUids(containerName string, showOnly bool) error {
|
||||
if !foundUser {
|
||||
userDb = append(userDb, completeUserInfo{Name: userCont.name,
|
||||
UidHost: -1, GidHost: -1, UidCont: userCont.uid, GidCont: userCont.gid})
|
||||
wwlog.Warn("user: %s:%v:%v not present on host\n", userCont.name, userCont.uid, userCont.gid)
|
||||
wwlog.Warn("user: %s:%v:%v not present on host", userCont.name, userCont.uid, userCont.gid)
|
||||
userOnlyCont = append(userOnlyCont, userCont.name)
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ func SyncUids(containerName string, showOnly bool) error {
|
||||
if user.UidHost == -1 {
|
||||
for _, userCheck := range userDb {
|
||||
if userCheck.UidHost == user.UidCont {
|
||||
wwlog.Warn(fmt.Sprintf("uid(%v) collision for host: %s and container: %s\n",
|
||||
wwlog.Warn(fmt.Sprintf("uid(%v) collision for host: %s and container: %s",
|
||||
user.UidCont, user.Name, userCheck.Name))
|
||||
return errors.New(fmt.Sprintf("user %s only present in container has same uid(%v) as user %s on host,\n"+
|
||||
"add this user to /etc/passwd on host", user.Name, user.UidCont, userCheck.Name))
|
||||
@@ -90,7 +90,7 @@ func SyncUids(containerName string, showOnly bool) error {
|
||||
if user.GidHost == -1 {
|
||||
for _, userCheck := range userDb {
|
||||
if userCheck.GidHost == user.GidCont {
|
||||
wwlog.Warn(fmt.Sprintf("gid(%v) collision for host: %s and container: %s\n",
|
||||
wwlog.Warn(fmt.Sprintf("gid(%v) collision for host: %s and container: %s",
|
||||
user.GidCont, user.Name, userCheck.Name))
|
||||
return errors.New(fmt.Sprintf("user %s only present in container has same gid(%v) as user %s on host,\n"+
|
||||
" add this group to /etc/group on host", user.Name, user.GidCont, userCheck.Name))
|
||||
@@ -101,7 +101,7 @@ func SyncUids(containerName string, showOnly bool) error {
|
||||
|
||||
}
|
||||
if showOnly {
|
||||
wwlog.Info("uid/gid not synced, run \nwwctl container syncuser --write %s\nto synchronize uid/gids.\n", containerName)
|
||||
wwlog.Info("uid/gid not synced, run \nwwctl container syncuser --write %s\nto synchronize uid/gids.", containerName)
|
||||
return nil
|
||||
}
|
||||
// create list of files which need changed ownerships in order to change them later what
|
||||
@@ -109,7 +109,7 @@ func SyncUids(containerName string, showOnly bool) error {
|
||||
for idx, user := range userDb {
|
||||
if (user.UidHost != user.UidCont && user.UidHost != -1) ||
|
||||
(user.GidHost != user.GidCont && user.GidHost != -1 && user.UidHost != -1) {
|
||||
wwlog.Verbose(fmt.Sprintf("host %s:%v:%v <-> container %s:%v:%v\n",
|
||||
wwlog.Verbose(fmt.Sprintf("host %s:%v:%v <-> container %s:%v:%v",
|
||||
user.Name, user.UidHost, user.GidHost, user.Name, user.UidCont, user.GidCont))
|
||||
err = filepath.Walk(fullPath, func(filePath string, info fs.FileInfo, err error) error {
|
||||
// root is always good, if we fail to get UID/GID of a file
|
||||
@@ -144,7 +144,7 @@ func SyncUids(containerName string, showOnly bool) error {
|
||||
if stat, ok := fsInfo.Sys().(*syscall.Stat_t); ok {
|
||||
gid = int(stat.Gid)
|
||||
}
|
||||
wwlog.Debug("%s chown(%v,%v)\n", file, user.UidHost, gid)
|
||||
wwlog.Debug("%s chown(%v,%v)", file, user.UidHost, gid)
|
||||
err = os.Chown(file, user.UidHost, gid)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -162,7 +162,7 @@ func SyncUids(containerName string, showOnly bool) error {
|
||||
if stat, ok := fsInfo.Sys().(*syscall.Stat_t); ok {
|
||||
uid = int(stat.Uid)
|
||||
}
|
||||
wwlog.Debug("%s chown(%v,%v)\n", file, user.UidHost, uid)
|
||||
wwlog.Debug("%s chown(%v,%v)", file, user.UidHost, uid)
|
||||
// only chown files and dirs
|
||||
if fsInfo.IsDir() && fsInfo.Mode().IsRegular() {
|
||||
err = os.Chown(file, uid, user.GidHost)
|
||||
@@ -224,18 +224,18 @@ func createPasswdMap(fileName string) ([]simpleUserInfo, error) {
|
||||
name := entries[0]
|
||||
uid, err := strconv.Atoi(entries[2])
|
||||
if err != nil {
|
||||
wwlog.Warn("could not parse uid(%s) for %s\n", entries[2], name)
|
||||
wwlog.Warn("could not parse uid(%s) for %s", entries[2], name)
|
||||
}
|
||||
gid, err := strconv.Atoi(entries[3])
|
||||
if err != nil {
|
||||
wwlog.Warn("could not parse gid(%s) for %s\n", entries[2], name)
|
||||
wwlog.Warn("could not parse gid(%s) for %s", entries[2], name)
|
||||
}
|
||||
if name != "" {
|
||||
nameDb = append(nameDb, simpleUserInfo{name: name, uid: uid, gid: gid})
|
||||
|
||||
}
|
||||
}
|
||||
wwlog.Debug(fmt.Sprintf("created uid/gid map with %v entries from %s\n", len(nameDb), fileName))
|
||||
wwlog.Debug(fmt.Sprintf("created uid/gid map with %v entries from %s", len(nameDb), fileName))
|
||||
return nameDb, nil
|
||||
}
|
||||
|
||||
@@ -259,6 +259,6 @@ func getEntires(fileName string, names []string) ([]string, error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
wwlog.Debug("file: %s, list: %v\n", fileName, list)
|
||||
wwlog.Debug("file: %s, list: %v", fileName, list)
|
||||
return list, nil
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
|
||||
func ValidName(name string) bool {
|
||||
if !util.ValidString(name, "^[\\w\\-\\.\\:]+$") {
|
||||
wwlog.Warn("VNFS name has illegal characters: %s\n", name)
|
||||
wwlog.Warn("VNFS name has illegal characters: %s", name)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
@@ -25,7 +25,7 @@ func ListSources() ([]string, error) {
|
||||
if err != nil {
|
||||
return ret, errors.New("Could not create VNFS source parent directory: " + SourceParentDir())
|
||||
}
|
||||
wwlog.Debug("Searching for VNFS Rootfs directories: %s\n", SourceParentDir())
|
||||
wwlog.Debug("Searching for VNFS Rootfs directories: %s", SourceParentDir())
|
||||
|
||||
sources, err := ioutil.ReadDir(SourceParentDir())
|
||||
if err != nil {
|
||||
@@ -33,7 +33,7 @@ func ListSources() ([]string, error) {
|
||||
}
|
||||
|
||||
for _, source := range sources {
|
||||
wwlog.Verbose("Found VNFS source: %s\n", source.Name())
|
||||
wwlog.Verbose("Found VNFS source: %s", source.Name())
|
||||
|
||||
if !ValidName(source.Name()) {
|
||||
continue
|
||||
@@ -57,7 +57,7 @@ func ValidSource(name string) bool {
|
||||
}
|
||||
|
||||
if !util.IsDir(fullPath) {
|
||||
wwlog.Verbose("Location is not a VNFS source directory: %s\n", name)
|
||||
wwlog.Verbose("Location is not a VNFS source directory: %s", name)
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ Delete the chroot of a container
|
||||
func DeleteSource(name string) error {
|
||||
fullPath := SourceDir(name)
|
||||
|
||||
wwlog.Verbose("Removing path: %s\n", fullPath)
|
||||
wwlog.Verbose("Removing path: %s", fullPath)
|
||||
return os.RemoveAll(fullPath)
|
||||
}
|
||||
|
||||
@@ -80,9 +80,9 @@ Delete the image of a container
|
||||
func DeleteImage(name string) error {
|
||||
imageFile := ImageFile(name)
|
||||
if util.IsFile(imageFile) {
|
||||
wwlog.Verbose("removing %s for container %s\n", imageFile, name)
|
||||
wwlog.Verbose("removing %s for container %s", imageFile, name)
|
||||
errImg := os.Remove(imageFile)
|
||||
wwlog.Verbose("removing %s for container %s\n", imageFile+".gz", name)
|
||||
wwlog.Verbose("removing %s for container %s", imageFile+".gz", name)
|
||||
errGz := os.Remove(imageFile + ".gz")
|
||||
if errImg != nil {
|
||||
return errors.Errorf("Problems delete %s for container %s: %s\n", imageFile, name, errImg)
|
||||
|
||||
@@ -24,19 +24,19 @@ func init() {
|
||||
func New() (NodeYaml, error) {
|
||||
var ret NodeYaml
|
||||
|
||||
wwlog.Verbose("Opening node configuration file: %s\n", ConfigFile)
|
||||
wwlog.Verbose("Opening node configuration file: %s", ConfigFile)
|
||||
data, err := ioutil.ReadFile(ConfigFile)
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
|
||||
wwlog.Debug("Unmarshaling the node configuration\n")
|
||||
wwlog.Debug("Unmarshaling the node configuration")
|
||||
err = yaml.Unmarshal(data, &ret)
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
|
||||
wwlog.Debug("Returning node object\n")
|
||||
wwlog.Debug("Returning node object")
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
@@ -54,11 +54,11 @@ func (config *NodeYaml) FindAllNodes() ([]NodeInfo, error) {
|
||||
return ret, err
|
||||
}
|
||||
*/
|
||||
wwlog.Debug("Finding all nodes...\n")
|
||||
wwlog.Debug("Finding all nodes...")
|
||||
for nodename, node := range config.Nodes {
|
||||
var n NodeInfo
|
||||
|
||||
wwlog.Debug("In node loop: %s\n", nodename)
|
||||
wwlog.Debug("In node loop: %s", nodename)
|
||||
n.NetDevs = make(map[string]*NetDevEntry)
|
||||
n.Tags = make(map[string]*Entry)
|
||||
n.Kernel = new(KernelEntry)
|
||||
@@ -125,11 +125,11 @@ func (config *NodeYaml) FindAllNodes() ([]NodeInfo, error) {
|
||||
|
||||
for _, profileName := range n.Profiles.GetSlice() {
|
||||
if _, ok := config.NodeProfiles[profileName]; !ok {
|
||||
wwlog.Warn("Profile not found for node '%s': %s\n", nodename, profileName)
|
||||
wwlog.Warn("Profile not found for node '%s': %s", nodename, profileName)
|
||||
continue
|
||||
}
|
||||
// can't call setFrom() as we have to use SetAlt instead of Set for an Entry
|
||||
wwlog.Verbose("Merging profile into node: %s <- %s\n", nodename, profileName)
|
||||
wwlog.Verbose("Merging profile into node: %s <- %s", nodename, profileName)
|
||||
n.SetAltFrom(config.NodeProfiles[profileName], profileName)
|
||||
}
|
||||
ret = append(ret, n)
|
||||
|
||||
@@ -166,7 +166,7 @@ const NoValue = "--"
|
||||
func init() {
|
||||
// Check that nodes.conf is found
|
||||
if !util.IsFile(ConfigFile) {
|
||||
wwlog.Warn("Missing node configuration file\n")
|
||||
wwlog.Warn("Missing node configuration file")
|
||||
// just return silently, as init is also called for bash_completion
|
||||
return
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ func (ent *Entry) Set(val string) {
|
||||
}
|
||||
|
||||
if val == "UNDEF" || val == "DELETE" || val == "UNSET" || val == "--" || val == "nil" {
|
||||
wwlog.Debug("Removing value for %v\n", *ent)
|
||||
wwlog.Debug("Removing value for %v", *ent)
|
||||
ent.value = []string{""}
|
||||
} else {
|
||||
ent.value = []string{val}
|
||||
|
||||
@@ -19,7 +19,7 @@ func (config *NodeYaml) AddNode(nodeID string) (NodeInfo, error) {
|
||||
var node NodeConf
|
||||
var n NodeInfo
|
||||
|
||||
wwlog.Verbose("Adding new node: %s\n", nodeID)
|
||||
wwlog.Verbose("Adding new node: %s", nodeID)
|
||||
|
||||
if _, ok := config.Nodes[nodeID]; ok {
|
||||
return n, errors.New("Nodename already exists: " + nodeID)
|
||||
@@ -43,7 +43,7 @@ func (config *NodeYaml) DelNode(nodeID string) error {
|
||||
return errors.New("Nodename does not exist: " + nodeID)
|
||||
}
|
||||
|
||||
wwlog.Verbose("Deleting node: %s\n", nodeID)
|
||||
wwlog.Verbose("Deleting node: %s", nodeID)
|
||||
delete(config.Nodes, nodeID)
|
||||
|
||||
return nil
|
||||
@@ -69,7 +69,7 @@ func (config *NodeYaml) AddProfile(profileID string) (NodeInfo, error) {
|
||||
var node NodeConf
|
||||
var n NodeInfo
|
||||
|
||||
wwlog.Verbose("Adding new profile: %s\n", profileID)
|
||||
wwlog.Verbose("Adding new profile: %s", profileID)
|
||||
|
||||
if _, ok := config.NodeProfiles[profileID]; ok {
|
||||
return n, errors.New("Profile name already exists: " + profileID)
|
||||
@@ -88,7 +88,7 @@ func (config *NodeYaml) DelProfile(profileID string) error {
|
||||
return errors.New("Profile does not exist: " + profileID)
|
||||
}
|
||||
|
||||
wwlog.Verbose("Deleting profile: %s\n", profileID)
|
||||
wwlog.Verbose("Deleting profile: %s", profileID)
|
||||
delete(config.NodeProfiles, profileID)
|
||||
|
||||
return nil
|
||||
@@ -130,7 +130,7 @@ func (config *NodeYaml) Persist() error {
|
||||
|
||||
file, err := os.OpenFile(ConfigFile, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
|
||||
if err != nil {
|
||||
wwlog.Error("%s\n", err)
|
||||
wwlog.Error("%s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
|
||||
@@ -44,17 +44,17 @@ func InitStruct(nodeInfo node.NodeInfo) TemplateStruct {
|
||||
var tstruct TemplateStruct
|
||||
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("%s\n", err)
|
||||
wwlog.Error("%s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
allNodes, err := nodeDB.FindAllNodes()
|
||||
if err != nil {
|
||||
wwlog.Error("%s\n", err)
|
||||
wwlog.Error("%s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
// init some convininence vars
|
||||
|
||||
@@ -22,10 +22,10 @@ func templateFileInclude(inc string) string {
|
||||
if !strings.HasPrefix(inc, "/") {
|
||||
inc = path.Join(buildconfig.SYSCONFDIR(), "warewulf", inc)
|
||||
}
|
||||
wwlog.Debug("Including file into template: %s\n", inc)
|
||||
wwlog.Debug("Including file into template: %s", inc)
|
||||
content, err := ioutil.ReadFile(inc)
|
||||
if err != nil {
|
||||
wwlog.Verbose("Could not include file into template: %s\n", err)
|
||||
wwlog.Verbose("Could not include file into template: %s", err)
|
||||
}
|
||||
return strings.TrimSuffix(string(content), "\n")
|
||||
}
|
||||
@@ -39,7 +39,7 @@ func templateFileBlock(inc string, abortStr string) (string, error) {
|
||||
if !strings.HasPrefix(inc, "/") {
|
||||
inc = path.Join(buildconfig.SYSCONFDIR(), "warewulf", inc)
|
||||
}
|
||||
wwlog.Debug("Including file block into template: %s\n", inc)
|
||||
wwlog.Debug("Including file block into template: %s", inc)
|
||||
readFile, err := os.Open(inc)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -72,31 +72,31 @@ Reads a file relative to given container.
|
||||
Templates in the file are no evaluated.
|
||||
*/
|
||||
func templateContainerFileInclude(containername string, filepath string) string {
|
||||
wwlog.Verbose("Including file from Container into template: %s:%s\n", containername, filepath)
|
||||
wwlog.Verbose("Including file from Container into template: %s:%s", containername, filepath)
|
||||
|
||||
if containername == "" {
|
||||
wwlog.Warn("Container is not defined for node: %s\n", filepath)
|
||||
wwlog.Warn("Container is not defined for node: %s", filepath)
|
||||
return ""
|
||||
}
|
||||
|
||||
if !container.ValidSource(containername) {
|
||||
wwlog.Warn("Template requires file(s) from non-existant container: %s:%s\n", containername, filepath)
|
||||
wwlog.Warn("Template requires file(s) from non-existant container: %s:%s", containername, filepath)
|
||||
return ""
|
||||
}
|
||||
|
||||
containerDir := container.RootFsDir(containername)
|
||||
|
||||
wwlog.Debug("Including file from container: %s:%s\n", containerDir, filepath)
|
||||
wwlog.Debug("Including file from container: %s:%s", containerDir, filepath)
|
||||
|
||||
if !util.IsFile(path.Join(containerDir, filepath)) {
|
||||
wwlog.Warn("Requested file from container does not exist: %s:%s\n", containername, filepath)
|
||||
wwlog.Warn("Requested file from container does not exist: %s:%s", containername, filepath)
|
||||
return ""
|
||||
}
|
||||
|
||||
content, err := ioutil.ReadFile(path.Join(containerDir, filepath))
|
||||
|
||||
if err != nil {
|
||||
wwlog.Error("Template include failed: %s\n", err)
|
||||
wwlog.Error("Template include failed: %s", err)
|
||||
}
|
||||
return strings.TrimSuffix(string(content), "\n")
|
||||
}
|
||||
|
||||
@@ -200,11 +200,11 @@ func BuildOverlayIndir(nodeInfo node.NodeInfo, overlayNames []string, outputDir
|
||||
return errors.Errorf("overlay names contains illegal characters: %v", overlayNames)
|
||||
}
|
||||
|
||||
wwlog.Verbose("Processing node/overlay: %s/%s\n", nodeInfo.Id.Get(), strings.Join(overlayNames, "-"))
|
||||
wwlog.Verbose("Processing node/overlay: %s/%s", nodeInfo.Id.Get(), strings.Join(overlayNames, "-"))
|
||||
for _, overlayName := range overlayNames {
|
||||
wwlog.Verbose("Building overlay %s for node %s in %s", overlayName, nodeInfo.Id.Get(), outputDir)
|
||||
overlaySourceDir := OverlaySourceDir(overlayName)
|
||||
wwlog.Debug("Starting to build overlay %s\nChanging directory to OverlayDir: %s\n", overlayName, overlaySourceDir)
|
||||
wwlog.Debug("Starting to build overlay %s\nChanging directory to OverlayDir: %s", overlayName, overlaySourceDir)
|
||||
err := os.Chdir(overlaySourceDir)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not change directory to overlay dir")
|
||||
@@ -376,12 +376,12 @@ func RenderTemplateFile(fileName string, data TemplateStruct) (
|
||||
"dec": func(i int) int { return i - 1 },
|
||||
"file": func(str string) string { return fmt.Sprintf("{{ /* file \"%s\" */ }}", str) },
|
||||
"abort": func() string {
|
||||
wwlog.Debug("abort file called in %s\n", fileName)
|
||||
wwlog.Debug("abort file called in %s", fileName)
|
||||
writeFile = false
|
||||
return ""
|
||||
},
|
||||
"nobackup": func() string {
|
||||
wwlog.Debug("not backup for %s\n", fileName)
|
||||
wwlog.Debug("not backup for %s", fileName)
|
||||
backupFile = false
|
||||
return ""
|
||||
},
|
||||
|
||||
@@ -11,40 +11,40 @@ import (
|
||||
|
||||
func CopyFile(src string, dst string) error {
|
||||
|
||||
wwlog.Debug("Copying '%s' to '%s'\n", src, dst)
|
||||
wwlog.Debug("Copying '%s' to '%s'", src, dst)
|
||||
|
||||
// Open source file
|
||||
srcFD, err := os.Open(src)
|
||||
if err != nil {
|
||||
wwlog.Error("Could not open source file %s: %s\n", src, err)
|
||||
wwlog.Error("Could not open source file %s: %s", src, err)
|
||||
return err
|
||||
}
|
||||
defer srcFD.Close()
|
||||
|
||||
srcInfo, err := srcFD.Stat()
|
||||
if err != nil {
|
||||
wwlog.Error("Could not stat source file %s: %s\n", src, err)
|
||||
wwlog.Error("Could not stat source file %s: %s", src, err)
|
||||
return err
|
||||
}
|
||||
|
||||
dstFD, err := os.OpenFile(dst, os.O_RDWR|os.O_CREATE|os.O_TRUNC, srcInfo.Mode())
|
||||
if err != nil {
|
||||
wwlog.Error("Could not create destination file %s: %s\n", dst, err)
|
||||
wwlog.Error("Could not create destination file %s: %s", dst, err)
|
||||
return err
|
||||
}
|
||||
defer dstFD.Close()
|
||||
|
||||
bytes, err := io.Copy(dstFD, srcFD)
|
||||
if err != nil {
|
||||
wwlog.Error("File copy from %s to %s failed.\n %s\n", src, dst, err)
|
||||
wwlog.Error("File copy from %s to %s failed.\n %s", src, dst, err)
|
||||
return err
|
||||
} else {
|
||||
wwlog.Debug("Copied %d bytes from %s to %s.\n", bytes, src, dst)
|
||||
wwlog.Debug("Copied %d bytes from %s to %s.", bytes, src, dst)
|
||||
}
|
||||
|
||||
err = CopyUIDGID(src, dst)
|
||||
if err != nil {
|
||||
wwlog.Error("Ownership copy from %s to %s failed.\n %s\n", src, dst, err)
|
||||
wwlog.Error("Ownership copy from %s to %s failed.\n %s", src, dst, err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
@@ -54,7 +54,7 @@ func SafeCopyFile(src string, dst string) error {
|
||||
var err error
|
||||
// Don't overwrite existing files -- should add force overwrite switch
|
||||
if _, err = os.Stat(dst); err == nil {
|
||||
wwlog.Debug("Destination file %s exists.\n", dst)
|
||||
wwlog.Debug("Destination file %s exists.", dst)
|
||||
} else {
|
||||
err = CopyFile(src, dst)
|
||||
}
|
||||
@@ -68,7 +68,7 @@ func CopyFiles(source string, dest string) error {
|
||||
}
|
||||
|
||||
if info.IsDir() {
|
||||
wwlog.Debug("Creating directory: %s\n", location)
|
||||
wwlog.Debug("Creating directory: %s", location)
|
||||
info, err := os.Stat(source)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -84,7 +84,7 @@ func CopyFiles(source string, dest string) error {
|
||||
}
|
||||
|
||||
} else {
|
||||
wwlog.Debug("Writing file: %s\n", location)
|
||||
wwlog.Debug("Writing file: %s", location)
|
||||
|
||||
err := CopyFile(location, path.Join(dest, location))
|
||||
if err != nil {
|
||||
|
||||
@@ -37,18 +37,18 @@ func New() (ControllerConf, error) {
|
||||
ret.Nfs = &nfsConf
|
||||
err := defaults.Set(&ret)
|
||||
if err != nil {
|
||||
wwlog.Error("Coult initialize default variables\n")
|
||||
wwlog.Error("Coult initialize default variables")
|
||||
return ret, err
|
||||
}
|
||||
// Check if cached config is old before re-reading config file
|
||||
if !cachedConf.current {
|
||||
wwlog.Debug("Opening Warewulf configuration file: %s\n", ConfigFile)
|
||||
wwlog.Debug("Opening Warewulf configuration file: %s", ConfigFile)
|
||||
data, err := ioutil.ReadFile(ConfigFile)
|
||||
if err != nil {
|
||||
wwlog.Warn("Error reading Warewulf configuration file\n")
|
||||
wwlog.Warn("Error reading Warewulf configuration file")
|
||||
}
|
||||
|
||||
wwlog.Debug("Unmarshaling the Warewulf configuration\n")
|
||||
wwlog.Debug("Unmarshaling the Warewulf configuration")
|
||||
err = yaml.Unmarshal(data, &ret)
|
||||
if err != nil {
|
||||
return ret, err
|
||||
@@ -63,12 +63,12 @@ func New() (ControllerConf, error) {
|
||||
localIp := conn.LocalAddr().(*net.UDPAddr)
|
||||
if ret.Ipaddr == "" {
|
||||
ret.Ipaddr = localIp.IP.String()
|
||||
wwlog.Warn("IP address is not configured in warewulfd.conf, using %s\n", ret.Ipaddr)
|
||||
wwlog.Warn("IP address is not configured in warewulfd.conf, using %s", ret.Ipaddr)
|
||||
}
|
||||
if ret.Netmask == "" {
|
||||
mask := localIp.IP.DefaultMask()
|
||||
ret.Netmask = fmt.Sprintf("%d.%d.%d.%d", mask[0], mask[1], mask[2], mask[3])
|
||||
wwlog.Warn("Netmask address is not configured in warewulfd.conf, using %s\n", ret.Netmask)
|
||||
wwlog.Warn("Netmask address is not configured in warewulfd.conf, using %s", ret.Netmask)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,21 +84,21 @@ func New() (ControllerConf, error) {
|
||||
if ret.Ipaddr6 != "" {
|
||||
_, ipv6net, err := net.ParseCIDR(ret.Ipaddr6)
|
||||
if err != nil {
|
||||
wwlog.Error("Invalid ipv6 address specified, mut be CIDR notation: %s\n", ret.Ipaddr6)
|
||||
wwlog.Error("Invalid ipv6 address specified, mut be CIDR notation: %s", ret.Ipaddr6)
|
||||
return ret, errors.New("invalid ipv6 network")
|
||||
}
|
||||
if msize, _ := ipv6net.Mask.Size(); msize > 64 {
|
||||
wwlog.Error("ipv6 mask size must be smaller than 64\n")
|
||||
wwlog.Error("ipv6 mask size must be smaller than 64")
|
||||
return ret, errors.New("invalid ipv6 network size")
|
||||
}
|
||||
}
|
||||
|
||||
wwlog.Debug("Returning warewulf config object\n")
|
||||
wwlog.Debug("Returning warewulf config object")
|
||||
cachedConf = ret
|
||||
cachedConf.current = true
|
||||
|
||||
} else {
|
||||
wwlog.Debug("Returning cached warewulf config object\n")
|
||||
wwlog.Debug("Returning cached warewulf config object")
|
||||
// If cached struct isn't empty, use it as the return value
|
||||
ret = cachedConf
|
||||
}
|
||||
|
||||
@@ -68,12 +68,12 @@ func (s *NfsConf) Unmarshal(unmarshal func(interface{}) error) error {
|
||||
|
||||
func init() {
|
||||
if !util.IsFile(ConfigFile) {
|
||||
wwlog.Error("Configuration file not found: %s\n", ConfigFile)
|
||||
wwlog.Error("Configuration file not found: %s", ConfigFile)
|
||||
// fail silently as this also called by bash_completion
|
||||
}
|
||||
_, err := New()
|
||||
if err != nil {
|
||||
wwlog.Error("Could not read Warewulf configuration file: %s\n", err)
|
||||
wwlog.Error("Could not read Warewulf configuration file: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ func (controller *ControllerConf) Persist() error {
|
||||
|
||||
file, err := os.OpenFile(ConfigFile, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
|
||||
if err != nil {
|
||||
wwlog.Error("%s\n", err)
|
||||
wwlog.Error("%s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ func (controller *ControllerConf) Persist() error {
|
||||
|
||||
_, err = file.WriteString(string(out)+"\n")
|
||||
if err != nil {
|
||||
wwlog.Error("Unable to write to warewulf.conf\n")
|
||||
wwlog.Error("Unable to write to warewulf.conf")
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user