Add json output for ignition
Signed-off-by: Christian Goll <cgoll@suse.com>
This commit is contained in:
committed by
Jonathon Anderson
parent
45539a0d1f
commit
a7df560a30
@@ -2,13 +2,16 @@ package overlay
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/hpcng/warewulf/internal/pkg/container"
|
||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||
warewulfconf "github.com/hpcng/warewulf/internal/pkg/config"
|
||||
"github.com/hpcng/warewulf/internal/pkg/container"
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
)
|
||||
|
||||
@@ -100,3 +103,20 @@ func templateContainerFileInclude(containername string, filepath string) string
|
||||
}
|
||||
return strings.TrimSuffix(string(content), "\n")
|
||||
}
|
||||
|
||||
func createIgnitionJson(node *node.NodeInfo) string {
|
||||
conf, rep, err := node.GetConfig()
|
||||
if len(conf.Storage.Disks) == 0 && len(conf.Storage.Filesystems) == 0 {
|
||||
wwlog.Debug("no disks or filesystems present, don't create a json object")
|
||||
return ""
|
||||
}
|
||||
if err != nil {
|
||||
wwlog.Error("disk, filesystem configuration has following error: ", fmt.Sprint(err))
|
||||
return fmt.Sprint(err)
|
||||
}
|
||||
if rep != "" {
|
||||
wwlog.Warn("%s storage configuration has following non fatal problems: %s", node.Id, rep)
|
||||
}
|
||||
tmpYaml, _ := json.Marshal(&conf)
|
||||
return string(tmpYaml)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user