Extend and optimize relocatable build config infrastructure
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
|
||||
@@ -84,12 +85,12 @@ func Configure(show bool) error {
|
||||
d.Nodes = append(d.Nodes, nodes...)
|
||||
|
||||
if controller.Dhcp.Template == "" {
|
||||
templateFile = "/etc/warewulf/dhcp/default-dhcpd.conf"
|
||||
templateFile = path.Join(buildconfig.SYSCONFDIR, "warewulf/dhcp/default-dhcpd.conf")
|
||||
} else {
|
||||
if strings.HasPrefix(controller.Dhcp.Template, "/") {
|
||||
templateFile = controller.Dhcp.Template
|
||||
} else {
|
||||
templateFile = fmt.Sprintf("/etc/warewulf/dhcp/%s-dhcpd.conf", controller.Dhcp.Template)
|
||||
templateFile = path.Join(buildconfig.SYSCONFDIR, "warewulf/dhcp/"+controller.Dhcp.Template+"dhcpd.conf")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,10 @@ package hosts
|
||||
import (
|
||||
"bytes"
|
||||
"os"
|
||||
"path"
|
||||
"text/template"
|
||||
|
||||
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
|
||||
@@ -26,7 +28,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
func Configure(show bool) error {
|
||||
var replace TemplateStruct
|
||||
|
||||
if !util.IsFile("/etc/warewulf/hosts.tmpl") {
|
||||
if !util.IsFile(path.Join(buildconfig.SYSCONFDIR, "warewulf/hosts.tmpl")) {
|
||||
wwlog.Printf(wwlog.WARN, "Template not found, not updating host file\n")
|
||||
return nil
|
||||
}
|
||||
@@ -43,7 +45,7 @@ func Configure(show bool) error {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
tmpl, err := template.ParseFiles("/etc/warewulf/hosts.tmpl")
|
||||
tmpl, err := template.ParseFiles(path.Join(buildconfig.SYSCONFDIR, "warewulf/hosts.tmpl"))
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not parse hosts template: %s\n", err)
|
||||
os.Exit(1)
|
||||
|
||||
@@ -101,7 +101,7 @@ func Configure(show bool) error {
|
||||
fmt.Printf("%s %s/%s\n", export.Path, controller.Network, controller.Netmask)
|
||||
}
|
||||
fmt.Printf("\n")
|
||||
fmt.Printf("SYSTEM OVERLAY: default/etc/fstab:\n")
|
||||
fmt.Printf("SYSTEM OVERLAY: wwinit/etc/fstab:\n")
|
||||
for _, export := range controller.Nfs.Exports {
|
||||
fmt.Printf("%s:%s %s nfs defaults 0 0\n", controller.Ipaddr, export, export)
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"os"
|
||||
"path"
|
||||
|
||||
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
|
||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
"github.com/pkg/errors"
|
||||
@@ -19,15 +20,17 @@ func Configure(show bool) error {
|
||||
if os.Getuid() == 0 {
|
||||
fmt.Printf("Updating system keys\n")
|
||||
|
||||
err := os.MkdirAll("/etc/warewulf/keys", 0755)
|
||||
wwkeydir := path.Join(buildconfig.SYSCONFDIR, "/etc/warewulf/keys") + "/"
|
||||
|
||||
err := os.MkdirAll(path.Join(buildconfig.SYSCONFDIR, "warewulf/keys"), 0755)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not create base directory: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if !util.IsFile("/etc/warewulf/keys/ssh_host_rsa_key") {
|
||||
if !util.IsFile(wwkeydir + "ssh_host_rsa_key") {
|
||||
fmt.Printf("Setting up key: ssh_host_rsa_key\n")
|
||||
err = util.ExecInteractive("ssh-keygen", "-q", "-t", "rsa", "-f", "/etc/warewulf/keys/ssh_host_rsa_key", "-C", "", "-N", "")
|
||||
err = util.ExecInteractive("ssh-keygen", "-q", "-t", "rsa", "-f", wwkeydir+"ssh_host_rsa_key", "-C", "", "-N", "")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to exec ssh-keygen command")
|
||||
}
|
||||
@@ -35,9 +38,9 @@ func Configure(show bool) error {
|
||||
fmt.Printf("Skipping, key already exists: ssh_host_rsa_key\n")
|
||||
}
|
||||
|
||||
if !util.IsFile("/etc/warewulf/keys/ssh_host_dsa_key") {
|
||||
if !util.IsFile(wwkeydir + "ssh_host_dsa_key") {
|
||||
fmt.Printf("Setting up key: ssh_host_dsa_key\n")
|
||||
err = util.ExecInteractive("ssh-keygen", "-q", "-t", "dsa", "-f", "/etc/warewulf/keys/ssh_host_dsa_key", "-C", "", "-N", "")
|
||||
err = util.ExecInteractive("ssh-keygen", "-q", "-t", "dsa", "-f", wwkeydir+"ssh_host_dsa_key", "-C", "", "-N", "")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to exec ssh-keygen command")
|
||||
}
|
||||
@@ -45,9 +48,9 @@ func Configure(show bool) error {
|
||||
fmt.Printf("Skipping, key already exists: ssh_host_dsa_key\n")
|
||||
}
|
||||
|
||||
if !util.IsFile("/etc/warewulf/keys/ssh_host_ecdsa_key") {
|
||||
if !util.IsFile(wwkeydir + "ssh_host_ecdsa_key") {
|
||||
fmt.Printf("Setting up key: ssh_host_ecdsa_key\n")
|
||||
err = util.ExecInteractive("ssh-keygen", "-q", "-t", "ecdsa", "-f", "/etc/warewulf/keys/ssh_host_ecdsa_key", "-C", "", "-N", "")
|
||||
err = util.ExecInteractive("ssh-keygen", "-q", "-t", "ecdsa", "-f", wwkeydir+"ssh_host_ecdsa_key", "-C", "", "-N", "")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to exec ssh-keygen command")
|
||||
}
|
||||
@@ -55,9 +58,9 @@ func Configure(show bool) error {
|
||||
fmt.Printf("Skipping, key already exists: ssh_host_ecdsa_key\n")
|
||||
}
|
||||
|
||||
if !util.IsFile("/etc/warewulf/keys/ssh_host_ed25519_key") {
|
||||
if !util.IsFile(wwkeydir + "ssh_host_ed25519_key") {
|
||||
fmt.Printf("Setting up key: ssh_host_ed25519_key\n")
|
||||
err = util.ExecInteractive("ssh-keygen", "-q", "-t", "ed25519", "-f", "/etc/warewulf/keys/ssh_host_ed25519_key", "-C", "", "-N", "")
|
||||
err = util.ExecInteractive("ssh-keygen", "-q", "-t", "ed25519", "-f", wwkeydir+"ssh_host_ed25519_key", "-C", "", "-N", "")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to exec ssh-keygen command")
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"os"
|
||||
"path"
|
||||
|
||||
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
|
||||
"github.com/hpcng/warewulf/internal/pkg/staticfiles"
|
||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
|
||||
@@ -23,40 +24,35 @@ func Configure(show bool) error {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if controller.Tftp.TftpRoot == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "Tftp root directory is not configured in warewulfd.conf\n")
|
||||
if buildconfig.TFTPDIR == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "Tftp root directory is not configured by build\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if !util.IsDir(controller.Tftp.TftpRoot) {
|
||||
wwlog.Printf(wwlog.ERROR, "Configured TFTP Root directory does not exist: %s\n", controller.Tftp.TftpRoot)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
err = os.MkdirAll(path.Join(controller.Tftp.TftpRoot, "warewulf"), 0755)
|
||||
err = os.MkdirAll(path.Join(buildconfig.TFTPDIR, "warewulf"), 0755)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if !show {
|
||||
fmt.Printf("Writing PXE files to: %s\n", path.Join(controller.Tftp.TftpRoot, "warewulf"))
|
||||
err = staticfiles.WriteData("files/tftp/x86.efi", path.Join(controller.Tftp.TftpRoot, "warewulf/x86.efi"))
|
||||
fmt.Printf("Writing PXE files to: %s\n", path.Join(buildconfig.TFTPDIR, "warewulf"))
|
||||
err = staticfiles.WriteData("files/tftp/x86.efi", path.Join(buildconfig.TFTPDIR, "warewulf/x86.efi"))
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
err = staticfiles.WriteData("files/tftp/i386.efi", path.Join(controller.Tftp.TftpRoot, "warewulf/i386.efi"))
|
||||
err = staticfiles.WriteData("files/tftp/i386.efi", path.Join(buildconfig.TFTPDIR, "warewulf/i386.efi"))
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
err = staticfiles.WriteData("files/tftp/i386.kpxe", path.Join(controller.Tftp.TftpRoot, "warewulf/i386.kpxe"))
|
||||
err = staticfiles.WriteData("files/tftp/i386.kpxe", path.Join(buildconfig.TFTPDIR, "warewulf/i386.kpxe"))
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
err = staticfiles.WriteData("files/tftp/arm64.efi", path.Join(controller.Tftp.TftpRoot, "warewulf/arm64.efi"))
|
||||
err = staticfiles.WriteData("files/tftp/arm64.efi", path.Join(buildconfig.TFTPDIR, "warewulf/arm64.efi"))
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
package ready
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/hpcng/warewulf/internal/pkg/overlay"
|
||||
"github.com/hpcng/warewulf/internal/pkg/container"
|
||||
"github.com/hpcng/warewulf/internal/pkg/kernel"
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
|
||||
n, err := node.New()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not open node configuration: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
nodes, err := n.FindAllNodes()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not get node list: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Printf("%-25s %-10s %-6s %-6s %-6s %-6s %-6s\n", "NODE NAME", "STATUS", "VNFS", "KERNEL", "KMODS", "SYS-OL", "RUN-OL")
|
||||
|
||||
for _, node := range nodes {
|
||||
var vnfs_good bool
|
||||
var kernel_good bool
|
||||
var kmods_good bool
|
||||
var systemo_good bool
|
||||
var runtimeo_good bool
|
||||
status := true
|
||||
|
||||
if node.ContainerName.Get() != "" {
|
||||
vnfsImage := container.ImageFile(node.ContainerName.Get())
|
||||
|
||||
if util.IsFile(vnfsImage) {
|
||||
vnfs_good = true
|
||||
} else {
|
||||
status = false
|
||||
wwlog.Printf(wwlog.VERBOSE, "VNFS not found: %s, %s\n", node.Id.Get(), vnfsImage)
|
||||
}
|
||||
} else {
|
||||
status = false
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node Kernel not defined: %s\n", node.Id.Get())
|
||||
}
|
||||
|
||||
if node.KernelVersion.Get() != "" {
|
||||
if util.IsFile(kernel.KernelImage(node.KernelVersion.Get())) {
|
||||
kernel_good = true
|
||||
} else {
|
||||
status = false
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node Kernel not found: %s, %s\n", node.Id.Get(), node.KernelVersion.Get())
|
||||
}
|
||||
if util.IsFile(kernel.KmodsImage(node.KernelVersion.Get())) {
|
||||
kmods_good = true
|
||||
} else {
|
||||
status = false
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node Kmods not found: %s, %s\n", node.Id.Get(), node.KernelVersion.Get())
|
||||
}
|
||||
} else {
|
||||
status = false
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node Kernel version not defined: %s\n", node.Id.Get())
|
||||
}
|
||||
|
||||
if node.SystemOverlay.Get() != "" {
|
||||
if util.IsFile(overlay.SystemOverlayImage(node.Id.Get())) {
|
||||
systemo_good = true
|
||||
} else {
|
||||
status = false
|
||||
wwlog.Printf(wwlog.VERBOSE, "System Overlay not found: %s\n", overlay.SystemOverlayImage(node.Id.Get()))
|
||||
}
|
||||
} else {
|
||||
status = false
|
||||
wwlog.Printf(wwlog.VERBOSE, "System Overlay not defined: %s\n", node.Id.Get())
|
||||
}
|
||||
|
||||
fmt.Printf("%-25s %-10t %-6t %-6t %-6t %-6t %-6t\n", node.Id.Get(), status, vnfs_good, kernel_good, kmods_good, systemo_good, runtimeo_good)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package ready
|
||||
|
||||
import (
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
baseCmd = &cobra.Command{
|
||||
DisableFlagsInUseLine: true,
|
||||
Use: "ready [OPTIONS]",
|
||||
Short: "Warewulf status check",
|
||||
Long: "Provides the current status of all Warewulf nodes.",
|
||||
RunE: CobraRunE,
|
||||
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
if len(args) != 0 {
|
||||
return nil, cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
|
||||
nodeDB, _ := node.New()
|
||||
nodes, _ := nodeDB.FindAllNodes()
|
||||
var node_names []string
|
||||
for _, node := range nodes {
|
||||
node_names = append(node_names, node.Id.Get())
|
||||
}
|
||||
return node_names, cobra.ShellCompDirectiveNoFileComp
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
// GetRootCommand returns the root cobra.Command for the application.
|
||||
func GetCommand() *cobra.Command {
|
||||
return baseCmd
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/node/console"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/node/delete"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/node/list"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/node/ready"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/node/sensors"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/node/set"
|
||||
nodestatus "github.com/hpcng/warewulf/internal/app/wwctl/node/status"
|
||||
@@ -30,7 +29,6 @@ func init() {
|
||||
baseCmd.AddCommand(add.GetCommand())
|
||||
baseCmd.AddCommand(delete.GetCommand())
|
||||
baseCmd.AddCommand(console.GetCommand())
|
||||
baseCmd.AddCommand(ready.GetCommand())
|
||||
baseCmd.AddCommand(nodestatus.GetCommand())
|
||||
}
|
||||
|
||||
|
||||
16
internal/pkg/buildconfig/buildconfig.go.in
Normal file
16
internal/pkg/buildconfig/buildconfig.go.in
Normal file
@@ -0,0 +1,16 @@
|
||||
package buildconfig
|
||||
|
||||
const (
|
||||
BINDIR = "@BINDIR@"
|
||||
SYSCONFDIR = "@SYSCONFDIR@"
|
||||
LOCALSTATEDIR = "@LOCALSTATEDIR@"
|
||||
SRVDIR = "@SRVDIR@"
|
||||
TFTPDIR = "@TFTPDIR@"
|
||||
FIREWALLDDIR = "@FIREWALLDDIR@"
|
||||
SYSTEMDDIR = "@SYSTEMDDIR@"
|
||||
WWOVERLAYDIR = "@WWOVERLAYDIR@"
|
||||
WWCHROOTDIR = "@WWCHROOTDIR@"
|
||||
WWPROVISIONDIR = "@WWPROVISIONDIR@"
|
||||
VERSION = "@VERSION@"
|
||||
RELEASE = "@RELEASE@"
|
||||
)
|
||||
27
internal/pkg/container/config.go
Normal file
27
internal/pkg/container/config.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package container
|
||||
|
||||
import (
|
||||
"path"
|
||||
|
||||
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
|
||||
)
|
||||
|
||||
func SourceParentDir() string {
|
||||
return buildconfig.WWCHROOTDIR
|
||||
}
|
||||
|
||||
func SourceDir(name string) string {
|
||||
return path.Join(SourceParentDir(), name)
|
||||
}
|
||||
|
||||
func RootFsDir(name string) string {
|
||||
return path.Join(SourceDir(name), "rootfs")
|
||||
}
|
||||
|
||||
func ImageParentDir() string {
|
||||
return path.Join(buildconfig.WWPROVISIONDIR, "container/")
|
||||
}
|
||||
|
||||
func ImageFile(name string) string {
|
||||
return path.Join(ImageParentDir(), name+".img.gz")
|
||||
}
|
||||
@@ -3,11 +3,9 @@ package container
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
|
||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
)
|
||||
@@ -20,26 +18,6 @@ func ValidName(name string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func SourceParentDir() string {
|
||||
return path.Join(warewulfconf.DataStore(), "chroots")
|
||||
}
|
||||
|
||||
func SourceDir(name string) string {
|
||||
return path.Join(SourceParentDir(), name)
|
||||
}
|
||||
|
||||
func RootFsDir(name string) string {
|
||||
return path.Join(SourceDir(name), "rootfs")
|
||||
}
|
||||
|
||||
func ImageParentDir() string {
|
||||
return path.Join(warewulfconf.DataStore(), "provision/container/")
|
||||
}
|
||||
|
||||
func ImageFile(name string) string {
|
||||
return path.Join(ImageParentDir(), name+".img.gz")
|
||||
}
|
||||
|
||||
func ListSources() ([]string, error) {
|
||||
var ret []string
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
|
||||
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
|
||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
)
|
||||
@@ -26,8 +26,8 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
func ParentDir() string {
|
||||
return path.Join(warewulfconf.DataStore(), "provision/kernel")
|
||||
func KernelImageTopDir() string {
|
||||
return path.Join(buildconfig.WWPROVISIONDIR, "kernel")
|
||||
}
|
||||
|
||||
func KernelImage(kernelName string) string {
|
||||
@@ -41,7 +41,7 @@ func KernelImage(kernelName string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
return path.Join(ParentDir(), kernelName, "vmlinuz")
|
||||
return path.Join(KernelImageTopDir(), kernelName, "vmlinuz")
|
||||
}
|
||||
|
||||
func GetKernelVersion(kernelName string) string {
|
||||
@@ -49,7 +49,7 @@ func GetKernelVersion(kernelName string) string {
|
||||
wwlog.Printf(wwlog.ERROR, "Kernel Name is not defined\n")
|
||||
return ""
|
||||
}
|
||||
kernelVersion, err := ioutil.ReadFile(path.Join(ParentDir(), kernelName, "version"))
|
||||
kernelVersion, err := ioutil.ReadFile(KernelVersionFile(kernelName))
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
@@ -67,10 +67,10 @@ func KmodsImage(kernelName string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
return path.Join(ParentDir(), kernelName, "kmods.img")
|
||||
return path.Join(KernelImageTopDir(), kernelName, "kmods.img")
|
||||
}
|
||||
|
||||
func KernelVersion(kernelName string) string {
|
||||
func KernelVersionFile(kernelName string) string {
|
||||
if kernelName == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "Kernel Name is not defined\n")
|
||||
return ""
|
||||
@@ -81,20 +81,20 @@ func KernelVersion(kernelName string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
return path.Join(ParentDir(), kernelName, "version")
|
||||
return path.Join(KernelImageTopDir(), kernelName, "version")
|
||||
}
|
||||
|
||||
func ListKernels() ([]string, error) {
|
||||
var ret []string
|
||||
|
||||
err := os.MkdirAll(ParentDir(), 0755)
|
||||
err := os.MkdirAll(KernelImageTopDir(), 0755)
|
||||
if err != nil {
|
||||
return ret, errors.New("Could not create Kernel parent directory: " + ParentDir())
|
||||
return ret, errors.New("Could not create Kernel parent directory: " + KernelImageTopDir())
|
||||
}
|
||||
|
||||
wwlog.Printf(wwlog.DEBUG, "Searching for Kernel image directories: %s\n", ParentDir())
|
||||
wwlog.Printf(wwlog.DEBUG, "Searching for Kernel image directories: %s\n", KernelImageTopDir())
|
||||
|
||||
kernels, err := ioutil.ReadDir(ParentDir())
|
||||
kernels, err := ioutil.ReadDir(KernelImageTopDir())
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
@@ -109,12 +109,12 @@ func ListKernels() ([]string, error) {
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func Build(kernelVersion string, kernelName string, root string) (string, error) {
|
||||
func Build(kernelVersion, kernelName, root string) (string, error) {
|
||||
kernelDrivers := path.Join(root, "/lib/modules/"+kernelVersion)
|
||||
kernelDriversRelative := path.Join("/lib/modules/"+kernelVersion)
|
||||
kernelDriversRelative := path.Join("/lib/modules/" + kernelVersion)
|
||||
kernelDestination := KernelImage(kernelName)
|
||||
driversDestination := KmodsImage(kernelName)
|
||||
versionDestination := KernelVersion(kernelName)
|
||||
versionDestination := KernelVersionFile(kernelName)
|
||||
var kernelSource string
|
||||
|
||||
// Create the destination paths just in case it doesn't exist
|
||||
@@ -223,7 +223,7 @@ func Build(kernelVersion string, kernelName string, root string) (string, error)
|
||||
}
|
||||
|
||||
func DeleteKernel(name string) error {
|
||||
fullPath := path.Join(ParentDir(), name)
|
||||
fullPath := path.Join(KernelImageTopDir(), name)
|
||||
|
||||
wwlog.Printf(wwlog.VERBOSE, "Removing path: %s\n", fullPath)
|
||||
return os.RemoveAll(fullPath)
|
||||
|
||||
@@ -3,14 +3,23 @@ package node
|
||||
import (
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"path"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
var ConfigFile = "/etc/warewulf/nodes.conf"
|
||||
var ConfigFile string
|
||||
|
||||
func init() {
|
||||
if ConfigFile == "" {
|
||||
ConfigFile = path.Join(buildconfig.SYSCONFDIR, "warewulf/nodes.conf")
|
||||
}
|
||||
}
|
||||
|
||||
func New() (nodeYaml, error) {
|
||||
var ret nodeYaml
|
||||
|
||||
@@ -3,13 +3,11 @@ package overlay
|
||||
import (
|
||||
"path"
|
||||
|
||||
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
|
||||
)
|
||||
|
||||
func OverlaySourceTopDir() string {
|
||||
return path.Join(warewulfconf.DataStore(), "overlays/")
|
||||
return buildconfig.WWOVERLAYDIR
|
||||
}
|
||||
|
||||
func OverlaySourceDir(overlayName string) string {
|
||||
@@ -17,68 +15,5 @@ func OverlaySourceDir(overlayName string) string {
|
||||
}
|
||||
|
||||
func OverlayImage(nodeName string, overlayName string) string {
|
||||
return path.Join(warewulfconf.DataStore(), "/provision/overlays/", nodeName, overlayName + ".img")
|
||||
}
|
||||
func SystemOverlayDir() string {
|
||||
return path.Join(OverlaySourceTopDir(), "/system")
|
||||
}
|
||||
|
||||
func RuntimeOverlayDir() string {
|
||||
return path.Join(OverlaySourceTopDir(), "/runtime")
|
||||
}
|
||||
|
||||
func SystemOverlaySource(overlayName string) string {
|
||||
if overlayName == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "System overlay name is not defined\n")
|
||||
return ""
|
||||
}
|
||||
|
||||
if !util.ValidString(overlayName, "^[a-zA-Z0-9-._]+$") {
|
||||
wwlog.Printf(wwlog.ERROR, "System overlay name contains illegal characters: %s\n", overlayName)
|
||||
return ""
|
||||
}
|
||||
|
||||
return path.Join(SystemOverlayDir(), overlayName)
|
||||
}
|
||||
|
||||
func RuntimeOverlaySource(overlayName string) string {
|
||||
if overlayName == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "Runtime overlay name is not defined\n")
|
||||
return ""
|
||||
}
|
||||
|
||||
if !util.ValidString(overlayName, "^[a-zA-Z0-9-._]+$") {
|
||||
wwlog.Printf(wwlog.ERROR, "Runtime overlay name contains illegal characters: %s\n", overlayName)
|
||||
return ""
|
||||
}
|
||||
|
||||
return path.Join(RuntimeOverlayDir(), overlayName)
|
||||
}
|
||||
|
||||
func SystemOverlayImage(nodeName string) string {
|
||||
if nodeName == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "Node name is not defined\n")
|
||||
return ""
|
||||
}
|
||||
|
||||
if !util.ValidString(nodeName, "^[a-zA-Z0-9-._:]+$") {
|
||||
wwlog.Printf(wwlog.ERROR, "System overlay name contains illegal characters: %s\n", nodeName)
|
||||
return ""
|
||||
}
|
||||
|
||||
return path.Join(warewulfconf.DataStore(), "/provision/overlays/runtime/", nodeName + ".img")
|
||||
}
|
||||
|
||||
func RuntimeOverlayImage(nodeName string) string {
|
||||
if nodeName == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "Node name is not defined\n")
|
||||
return ""
|
||||
}
|
||||
|
||||
if !util.ValidString(nodeName, "^[a-zA-Z0-9-._:]+$") {
|
||||
wwlog.Printf(wwlog.ERROR, "System overlay name contains illegal characters: %s\n", nodeName)
|
||||
return ""
|
||||
}
|
||||
|
||||
return path.Join(warewulfconf.DataStore(), "/provision/overlays/system/", nodeName + ".img")
|
||||
return path.Join(buildconfig.WWPROVISIONDIR, "overlays/", nodeName, overlayName+".img")
|
||||
}
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
package version
|
||||
|
||||
var Version string = "development"
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
|
||||
)
|
||||
|
||||
func GetVersion() string {
|
||||
return Version
|
||||
return fmt.Sprintf("%s-%s", buildconfig.VERSION, buildconfig.RELEASE)
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package warewulfconf
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"errors"
|
||||
"path"
|
||||
|
||||
"github.com/brotherpowers/ipsubnet"
|
||||
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
@@ -14,6 +16,14 @@ import (
|
||||
|
||||
var cachedConf ControllerConf
|
||||
|
||||
var ConfigFile string
|
||||
|
||||
func init() {
|
||||
if ConfigFile == "" {
|
||||
ConfigFile = path.Join(buildconfig.SYSCONFDIR, "warewulf/warewulf.conf")
|
||||
}
|
||||
}
|
||||
|
||||
func New() (ControllerConf, error) {
|
||||
var ret ControllerConf = *defaultConfig()
|
||||
|
||||
@@ -32,8 +42,8 @@ func New() (ControllerConf, error) {
|
||||
return ret, err
|
||||
}
|
||||
|
||||
// TODO: Need to add comprehensive config file validator
|
||||
// TODO: Change function to guess default IP address and/or mask from local system
|
||||
// TODO: Need to add comprehensive config file validator
|
||||
// TODO: Change function to guess default IP address and/or mask from local system
|
||||
if ret.Ipaddr == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "IP address is not configured in warewulfd.conf\n")
|
||||
return ret, errors.New("no IP Address")
|
||||
@@ -63,7 +73,7 @@ func New() (ControllerConf, error) {
|
||||
|
||||
} else {
|
||||
wwlog.Printf(wwlog.DEBUG, "Returning cached warewulf config object\n")
|
||||
// If cached struct isn't empty, use it as the return value
|
||||
// If cached struct isn't empty, use it as the return value
|
||||
ret = cachedConf
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
package warewulfconf
|
||||
|
||||
const defaultPort int = 9983
|
||||
const defaultPort int = 9983
|
||||
|
||||
var (
|
||||
ConfigFile string = "/etc/warewulf/warewulf.conf"
|
||||
defaultDataStore string = "/var/lib/warewulf"
|
||||
)
|
||||
var defaultDataStore string = "/var/lib/warewulf"
|
||||
|
||||
func defaultConfig() *ControllerConf {
|
||||
Warewulf := &WarewulfConf{
|
||||
@@ -30,8 +27,8 @@ func defaultConfig() *ControllerConf {
|
||||
SystemdName: "tftp",
|
||||
}
|
||||
Nfs := &NfsConf{
|
||||
Enabled: true,
|
||||
Exports: []string{"/home",},
|
||||
Enabled: true,
|
||||
Exports: []string{"/home"},
|
||||
SystemdName: "nfs-server",
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package warewulfd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"path"
|
||||
"strconv"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"github.com/hpcng/warewulf/internal/pkg/overlay"
|
||||
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
|
||||
@@ -100,7 +101,7 @@ func IpxeSend(w http.ResponseWriter, req *http.Request) {
|
||||
if unconfiguredNode {
|
||||
daemonLogf("IPXEREQ: %s (unknown/unconfigured node)\n", hwaddr)
|
||||
|
||||
tmpl, err := template.ParseFiles("/etc/warewulf/ipxe/unconfigured.ipxe")
|
||||
tmpl, err := template.ParseFiles(path.Join(buildconfig.SYSCONFDIR, "/warewulf/ipxe/unconfigured.ipxe"))
|
||||
if err != nil {
|
||||
daemonLogf("ERROR: Could not parse unconfigured node IPXE template: %s\n", err)
|
||||
return
|
||||
@@ -120,7 +121,7 @@ func IpxeSend(w http.ResponseWriter, req *http.Request) {
|
||||
|
||||
} else {
|
||||
|
||||
ipxeTemplate := fmt.Sprintf("/etc/warewulf/ipxe/%s.ipxe", nodeobj.Ipxe.Get())
|
||||
ipxeTemplate := path.Join(buildconfig.SYSCONFDIR, "warewulf/ipxe/"+nodeobj.Ipxe.Get()+".ipxe")
|
||||
|
||||
tmpl, err := template.ParseFiles(ipxeTemplate)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user