extended tstruct for templating
- tstruct is in new datastructure.go - updated fstab.ww to new syntax
This commit is contained in:
38
internal/pkg/overlay/datastructure.go
Normal file
38
internal/pkg/overlay/datastructure.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package overlay
|
||||
|
||||
import (
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
|
||||
)
|
||||
|
||||
type TemplateStruct struct {
|
||||
Id string
|
||||
Hostname string
|
||||
ClusterName string
|
||||
Container string
|
||||
KernelVersion string
|
||||
KernelArgs string
|
||||
Init string
|
||||
Root string
|
||||
IpmiIpaddr string
|
||||
IpmiNetmask string
|
||||
IpmiPort string
|
||||
IpmiGateway string
|
||||
IpmiUserName string
|
||||
IpmiPassword string
|
||||
IpmiInterface string
|
||||
RuntimeOverlay string
|
||||
SystemOverlay string
|
||||
NetDevs map[string]*node.NetDevs
|
||||
Tags map[string]string
|
||||
Keys map[string]string
|
||||
AllNodes []node.NodeInfo
|
||||
BuildHost string
|
||||
BuildTime string
|
||||
BuildSource string
|
||||
Ipaddr string
|
||||
Netmask string
|
||||
Network string
|
||||
Dhcp warewulfconf.DhcpConf
|
||||
Nfs warewulfconf.NfsConf
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"text/template"
|
||||
"time"
|
||||
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||
@@ -19,31 +20,6 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type TemplateStruct struct {
|
||||
Id string
|
||||
Hostname string
|
||||
ClusterName string
|
||||
Container string
|
||||
KernelVersion string
|
||||
KernelArgs string
|
||||
Init string
|
||||
Root string
|
||||
IpmiIpaddr string
|
||||
IpmiNetmask string
|
||||
IpmiPort string
|
||||
IpmiGateway string
|
||||
IpmiUserName string
|
||||
IpmiPassword string
|
||||
IpmiInterface string
|
||||
RuntimeOverlay string
|
||||
SystemOverlay string
|
||||
NetDevs map[string]*node.NetDevs
|
||||
Tags map[string]string
|
||||
Keys map[string]string
|
||||
AllNodes []node.NodeInfo
|
||||
NFSMounts []string
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
func BuildSystemOverlay(nodeList []node.NodeInfo) error {
|
||||
@@ -234,18 +210,15 @@ func BuildOverlay(nodeInfo node.NodeInfo, overlayName string) error {
|
||||
tstruct.Tags[keyname] = key.Get()
|
||||
}
|
||||
tstruct.AllNodes = allNodes
|
||||
for _, export := range controller.Nfs.ExportsExtended {
|
||||
if export.Mount {
|
||||
var mountOpts string
|
||||
if export.MountOptions == "" {
|
||||
mountOpts = "defaults"
|
||||
} else {
|
||||
mountOpts = export.MountOptions
|
||||
}
|
||||
tstruct.NFSMounts = append(tstruct.NFSMounts, fmt.Sprintf("%s:%s %s nfs %s 0 0\n", controller.Ipaddr, export.Path, export.Path, mountOpts))
|
||||
}
|
||||
}
|
||||
|
||||
tstruct.Nfs = *controller.Nfs
|
||||
tstruct.Dhcp = *controller.Dhcp
|
||||
tstruct.Ipaddr = controller.Ipaddr
|
||||
tstruct.Netmask = controller.Netmask
|
||||
tstruct.Network = controller.Network
|
||||
hostname, _ := os.Hostname()
|
||||
tstruct.BuildHost = hostname
|
||||
dt := time.Now()
|
||||
tstruct.BuildTime = dt.Format("01-02-2006 15:04:05 MST")
|
||||
wwlog.Printf(wwlog.DEBUG, "Changing directory to OverlayDir: %s\n", OverlaySourceDir)
|
||||
err = os.Chdir(OverlaySourceDir)
|
||||
if err != nil {
|
||||
@@ -275,6 +248,7 @@ func BuildOverlay(nodeInfo node.NodeInfo, overlayName string) error {
|
||||
wwlog.Printf(wwlog.DEBUG, "Created directory in overlay: %s\n", location)
|
||||
|
||||
} else if filepath.Ext(location) == ".ww" {
|
||||
tstruct.BuildSource = path.Join(OverlaySourceDir, location)
|
||||
wwlog.Printf(wwlog.VERBOSE, "Evaluating overlay template file: %s\n", location)
|
||||
|
||||
destFile := strings.TrimSuffix(location, ".ww")
|
||||
|
||||
Reference in New Issue
Block a user