Make the overlay auto-update configurable

This commit is contained in:
Gregory Kurtzer
2021-09-30 23:02:04 -07:00
parent 2234532ac8
commit 384c4c0286
5 changed files with 28 additions and 14 deletions

View File

@@ -1,13 +1,14 @@
ipaddr: 192.168.1.1
ipaddr: 192.168.200.1
netmask: 255.255.255.0
warewulf:
port: 9873
secure: true
autobuild overlays: true
update interval: 60
dhcp:
enabled: true
range start: 192.168.1.150
range end: 192.168.1.200
range start: 192.168.200.50
range end: 192.168.200.99
template: default
systemd name: dhcpd
tftp:

View File

@@ -23,6 +23,7 @@ type WarewulfConf struct {
Port int `yaml:"port"`
Secure bool `yaml:"secure"`
UpdateInterval int `yaml:"update interval"`
AutobuildOverlays bool `yaml:"autobuild overlays"`
}
type DhcpConf struct {

View File

@@ -7,9 +7,9 @@ import (
"gopkg.in/yaml.v2"
)
func (self *ControllerConf) Persist() error {
func (controller *ControllerConf) Persist() error {
out, err := yaml.Marshal(self)
out, err := yaml.Marshal(controller)
if err != nil {
return err
}

View File

@@ -66,10 +66,12 @@ func RuntimeOverlaySend(w http.ResponseWriter, req *http.Request) {
if n.RuntimeOverlay.Defined() {
fileName := config.RuntimeOverlayImage(n.Id.Get())
if conf.Warewulf.AutobuildOverlays == true {
if !util.IsFile(fileName) || util.PathIsNewer(fileName, node.ConfigFile) || util.PathIsNewer(fileName, config.RuntimeOverlaySource(n.RuntimeOverlay.Get())) {
daemonLogf("BUILD: %15s: Runtime Overlay\n", n.Id.Get())
_ = overlay.BuildRuntimeOverlay([]node.NodeInfo{n})
}
}
err := sendFile(w, fileName, n.Id.Get())
if err != nil {

View File

@@ -7,9 +7,17 @@ import (
"github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/overlay"
"github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
)
func SystemOverlaySend(w http.ResponseWriter, req *http.Request) {
conf, err := warewulfconf.New()
if err != nil {
daemonLogf("ERROR: Could not read Warewulf configuration file: %s\n", err)
w.WriteHeader(503)
return
}
n, err := getSanity(req)
if err != nil {
w.WriteHeader(404)
@@ -20,10 +28,12 @@ func SystemOverlaySend(w http.ResponseWriter, req *http.Request) {
if n.SystemOverlay.Defined() {
fileName := config.SystemOverlayImage(n.Id.Get())
if conf.Warewulf.AutobuildOverlays == true {
if !util.IsFile(fileName) || util.PathIsNewer(fileName, node.ConfigFile) || util.PathIsNewer(fileName, config.SystemOverlaySource(n.SystemOverlay.Get())) {
daemonLogf("BUILD: %15s: System Overlay\n", n.Id.Get())
_ = overlay.BuildSystemOverlay([]node.NodeInfo{n})
}
}
err := sendFile(w, fileName, n.Id.Get())
if err != nil {