Merge branch 'main' of https://github.com/ctrliq/warewulf into main

This commit is contained in:
Niko Kivel
2021-02-18 13:37:32 +01:00
89 changed files with 541 additions and 218 deletions

16
.editorconfig Normal file
View File

@@ -0,0 +1,16 @@
root = true
[*]
end_of_line = lf
insert_final_newline = true
[*.go]
indent_style = space
indent_size = 4
[Makefile]
indent_style = tab
[*.{yaml,yml}]
indent_style = space
indent_size = 2

View File

@@ -1,6 +1,6 @@
.PHONY: all .PHONY: all
VERSION := 4.0 VERSION := 4.0.0
# auto installed tooling # auto installed tooling
TOOLS_DIR := .tools TOOLS_DIR := .tools

View File

@@ -2,14 +2,15 @@ package main
import ( import (
"fmt" "fmt"
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"log" "log"
"net" "net"
"net/http" "net/http"
"os" "os"
"os/exec" "os/exec"
"time" "time"
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
) )
func main() { func main() {

View File

@@ -4,9 +4,8 @@ import (
"github.com/hpcng/warewulf/internal/app/wwctl" "github.com/hpcng/warewulf/internal/app/wwctl"
) )
func main() { func main() {
root := wwctl.GetRootCommand() root := wwctl.GetRootCommand()
root.Execute() root.Execute()
} }

1
go.sum
View File

@@ -110,6 +110,7 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s= github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s=
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=

View File

@@ -8,6 +8,6 @@ import (
func main() { func main() {
nodeDB, _ := node.New() nodeDB, _ := node.New()
nodes, _ := nodeDB.FindAllNodes() nodes, _ := nodeDB.FindAllNodes()
// wwlog.SetLevel(wwlog.DEBUG) // wwlog.SetLevel(wwlog.DEBUG)
overlay.OverlayBuild(nodes, "runtime") overlay.OverlayBuild(nodes, "runtime")
} }

View File

@@ -1,12 +1,13 @@
package build package build
import ( import (
"os"
"github.com/hpcng/warewulf/internal/pkg/container" "github.com/hpcng/warewulf/internal/pkg/container"
"github.com/hpcng/warewulf/internal/pkg/kernel" "github.com/hpcng/warewulf/internal/pkg/kernel"
"github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os"
) )
func CobraRunE(cmd *cobra.Command, args []string) error { func CobraRunE(cmd *cobra.Command, args []string) error {

View File

@@ -2,15 +2,16 @@ package dhcp
import ( import (
"fmt" "fmt"
"os"
"path"
"strings"
"text/template"
"github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/warewulfconf" "github.com/hpcng/warewulf/internal/pkg/warewulfconf"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os"
"path"
"strings"
"text/template"
) )
type dhcpTemplate struct { type dhcpTemplate struct {

View File

@@ -3,13 +3,14 @@ package hosts
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"os"
"text/template"
"github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/warewulfconf" "github.com/hpcng/warewulf/internal/pkg/warewulfconf"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os"
"text/template"
) )
type TemplateStruct struct { type TemplateStruct struct {

View File

@@ -2,11 +2,12 @@ package nfs
import ( import (
"fmt" "fmt"
"os"
"github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/warewulfconf" "github.com/hpcng/warewulf/internal/pkg/warewulfconf"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os"
) )
func CobraRunE(cmd *cobra.Command, args []string) error { func CobraRunE(cmd *cobra.Command, args []string) error {

View File

@@ -2,13 +2,14 @@ package configure
import ( import (
"fmt" "fmt"
"os"
"github.com/hpcng/warewulf/internal/app/wwctl/configure/dhcp" "github.com/hpcng/warewulf/internal/app/wwctl/configure/dhcp"
"github.com/hpcng/warewulf/internal/app/wwctl/configure/hosts" "github.com/hpcng/warewulf/internal/app/wwctl/configure/hosts"
"github.com/hpcng/warewulf/internal/app/wwctl/configure/nfs" "github.com/hpcng/warewulf/internal/app/wwctl/configure/nfs"
"github.com/hpcng/warewulf/internal/app/wwctl/configure/ssh" "github.com/hpcng/warewulf/internal/app/wwctl/configure/ssh"
"github.com/hpcng/warewulf/internal/app/wwctl/configure/tftp" "github.com/hpcng/warewulf/internal/app/wwctl/configure/tftp"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os"
) )
var ( var (

View File

@@ -2,11 +2,12 @@ package ssh
import ( import (
"fmt" "fmt"
"os"
"path"
"github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os"
"path"
) )
func CobraRunE(cmd *cobra.Command, args []string) error { func CobraRunE(cmd *cobra.Command, args []string) error {

View File

@@ -2,13 +2,14 @@ package tftp
import ( import (
"fmt" "fmt"
"os"
"path"
"github.com/hpcng/warewulf/internal/pkg/staticfiles" "github.com/hpcng/warewulf/internal/pkg/staticfiles"
"github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/warewulfconf" "github.com/hpcng/warewulf/internal/pkg/warewulfconf"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os"
"path"
) )
func CobraRunE(cmd *cobra.Command, args []string) error { func CobraRunE(cmd *cobra.Command, args []string) error {

View File

@@ -2,11 +2,12 @@ package build
import ( import (
"fmt" "fmt"
"os"
"github.com/hpcng/warewulf/internal/pkg/container" "github.com/hpcng/warewulf/internal/pkg/container"
"github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os"
) )
func CobraRunE(cmd *cobra.Command, args []string) error { func CobraRunE(cmd *cobra.Command, args []string) error {

View File

@@ -2,11 +2,12 @@ package delete
import ( import (
"fmt" "fmt"
"os"
"github.com/hpcng/warewulf/internal/pkg/container" "github.com/hpcng/warewulf/internal/pkg/container"
"github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os"
) )
func CobraRunE(cmd *cobra.Command, args []string) error { func CobraRunE(cmd *cobra.Command, args []string) error {

View File

@@ -4,13 +4,14 @@ package child
import ( import (
"fmt" "fmt"
"os"
"path"
"syscall"
"github.com/hpcng/warewulf/internal/pkg/container" "github.com/hpcng/warewulf/internal/pkg/container"
"github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os"
"path"
"syscall"
) )
func CobraRunE(cmd *cobra.Command, args []string) error { func CobraRunE(cmd *cobra.Command, args []string) error {

View File

@@ -4,12 +4,13 @@ package exec
import ( import (
"fmt" "fmt"
"github.com/hpcng/warewulf/internal/pkg/container"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra"
"os" "os"
"os/exec" "os/exec"
"syscall" "syscall"
"github.com/hpcng/warewulf/internal/pkg/container"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra"
) )
func CobraRunE(cmd *cobra.Command, args []string) error { func CobraRunE(cmd *cobra.Command, args []string) error {

View File

@@ -2,15 +2,69 @@ package imprt
import ( import (
"fmt" "fmt"
"os"
"path"
"strconv"
"github.com/containers/image/v5/types"
"github.com/hpcng/warewulf/internal/pkg/container" "github.com/hpcng/warewulf/internal/pkg/container"
"github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/warewulfd"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os"
"path"
) )
func setOCICredentials(sCtx *types.SystemContext) error {
username, userSet := os.LookupEnv("WAREWULF_OCI_USERNAME")
password, passSet := os.LookupEnv("WAREWULF_OCI_PASSWORD")
if userSet || passSet {
if userSet && passSet {
sCtx.DockerAuthConfig = &types.DockerAuthConfig{
Username: username,
Password: password,
}
} else {
return fmt.Errorf("oci username and password env vars must be specified together")
}
}
return nil
}
func setNoHTTPSOpts(sCtx *types.SystemContext) error {
val, ok := os.LookupEnv("WAREWULF_OCI_NOHTTPS")
if !ok {
return nil
}
noHTTPS, err := strconv.ParseBool(val)
if err != nil {
return fmt.Errorf("while parsing insecure http option: %v", err)
}
// only set this if we want to disable, otherwise leave as undefined
if noHTTPS {
sCtx.DockerInsecureSkipTLSVerify = types.NewOptionalBool(true)
}
sCtx.OCIInsecureSkipTLSVerify = noHTTPS
return nil
}
func getSystemContext() (sCtx *types.SystemContext, err error) {
sCtx = &types.SystemContext{}
if err := setOCICredentials(sCtx); err != nil {
return nil, err
}
if err := setNoHTTPSOpts(sCtx); err != nil {
return nil, err
}
return sCtx, nil
}
func CobraRunE(cmd *cobra.Command, args []string) error { func CobraRunE(cmd *cobra.Command, args []string) error {
var name string var name string
uri := args[0] uri := args[0]
@@ -45,7 +99,12 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
} }
} }
err := container.PullURI(uri, name) sCtx, err := getSystemContext()
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
}
err = container.PullURI(uri, name, sCtx)
if err != nil { if err != nil {
wwlog.Printf(wwlog.ERROR, "Could not pull image: %s\n", err) wwlog.Printf(wwlog.ERROR, "Could not pull image: %s\n", err)
os.Exit(1) os.Exit(1)
@@ -79,6 +138,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
} }
nodeDB.Persist() nodeDB.Persist()
fmt.Printf("Set default profile to container: %s\n", name) fmt.Printf("Set default profile to container: %s\n", name)
warewulfd.DaemonReload()
} }

View File

@@ -2,12 +2,13 @@ package list
import ( import (
"fmt" "fmt"
"os"
"github.com/hpcng/warewulf/internal/pkg/container" "github.com/hpcng/warewulf/internal/pkg/container"
"github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os"
) )
func CobraRunE(cmd *cobra.Command, args []string) error { func CobraRunE(cmd *cobra.Command, args []string) error {

View File

@@ -1,10 +1,11 @@
package add package add
import ( import (
"os"
"github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os"
) )
func CobraRunE(cmd *cobra.Command, args []string) error { func CobraRunE(cmd *cobra.Command, args []string) error {
@@ -26,4 +27,4 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
nodeDB.Persist() nodeDB.Persist()
return nil return nil
} }

View File

@@ -4,11 +4,11 @@ import "github.com/spf13/cobra"
var ( var (
baseCmd = &cobra.Command{ baseCmd = &cobra.Command{
Use: "add", Use: "add",
Short: "Add", Short: "Add",
Long: "Add", Long: "Add",
RunE: CobraRunE, RunE: CobraRunE,
Args: cobra.MinimumNArgs(1), Args: cobra.MinimumNArgs(1),
} }
SetController string SetController string
) )

View File

@@ -2,11 +2,12 @@ package delete
import ( import (
"fmt" "fmt"
"os"
"github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/manifoldco/promptui" "github.com/manifoldco/promptui"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os"
) )
func CobraRunE(cmd *cobra.Command, args []string) error { func CobraRunE(cmd *cobra.Command, args []string) error {
@@ -19,7 +20,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
os.Exit(1) os.Exit(1)
} }
nodes, err := nodeDB. FindAllNodes() nodes, err := nodeDB.FindAllNodes()
if err != nil { if err != nil {
wwlog.Printf(wwlog.ERROR, "Could not load all nodes: %s\n", err) wwlog.Printf(wwlog.ERROR, "Could not load all nodes: %s\n", err)
os.Exit(1) os.Exit(1)
@@ -32,10 +33,10 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
} else { } else {
for _, n := range nodes { for _, n := range nodes {
if n.Cid.Get() == c { if n.Cid.Get() == c {
numNodes ++ numNodes++
} }
} }
count ++ count++
} }
} }
@@ -58,4 +59,4 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
} }
return nil return nil
} }

View File

@@ -4,11 +4,11 @@ import "github.com/spf13/cobra"
var ( var (
baseCmd = &cobra.Command{ baseCmd = &cobra.Command{
Use: "delete", Use: "delete",
Short: "Delete", Short: "Delete",
Long: "Delete", Long: "Delete",
RunE: CobraRunE, RunE: CobraRunE,
Args: cobra.MinimumNArgs(1), Args: cobra.MinimumNArgs(1),
} }
SetController string SetController string
) )

View File

@@ -3,10 +3,11 @@ package list
import "C" import "C"
import ( import (
"fmt" "fmt"
"os"
"github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os"
) )
func CobraRunE(cmd *cobra.Command, args []string) error { func CobraRunE(cmd *cobra.Command, args []string) error {

View File

@@ -4,10 +4,10 @@ import "github.com/spf13/cobra"
var ( var (
baseCmd = &cobra.Command{ baseCmd = &cobra.Command{
Use: "list", Use: "list",
Short: "List", Short: "List",
Long: "List", Long: "List",
RunE: CobraRunE, RunE: CobraRunE,
} }
ShowAll bool ShowAll bool
) )

View File

@@ -1,19 +1,18 @@
package controller package controller
import ( import (
"github.com/spf13/cobra"
"github.com/hpcng/warewulf/internal/app/wwctl/controller/add" "github.com/hpcng/warewulf/internal/app/wwctl/controller/add"
"github.com/hpcng/warewulf/internal/app/wwctl/controller/delete" "github.com/hpcng/warewulf/internal/app/wwctl/controller/delete"
"github.com/hpcng/warewulf/internal/app/wwctl/controller/list" "github.com/hpcng/warewulf/internal/app/wwctl/controller/list"
"github.com/hpcng/warewulf/internal/app/wwctl/controller/set" "github.com/hpcng/warewulf/internal/app/wwctl/controller/set"
"github.com/spf13/cobra"
) )
var ( var (
baseCmd = &cobra.Command{ baseCmd = &cobra.Command{
Use: "controller", Use: "controller",
Short: "Controller management", Short: "Controller management",
Long: "Management of group settings and power management", Long: "Management of group settings and power management",
} }
) )

View File

@@ -2,11 +2,12 @@ package set
import ( import (
"fmt" "fmt"
"os"
"github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/manifoldco/promptui" "github.com/manifoldco/promptui"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os"
) )
func CobraRunE(cmd *cobra.Command, args []string) error { func CobraRunE(cmd *cobra.Command, args []string) error {

View File

@@ -2,17 +2,19 @@ package imprt
import ( import (
"fmt" "fmt"
"os"
"github.com/hpcng/warewulf/internal/pkg/kernel" "github.com/hpcng/warewulf/internal/pkg/kernel"
"github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/warewulfd"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os"
) )
func CobraRunE(cmd *cobra.Command, args []string) error { func CobraRunE(cmd *cobra.Command, args []string) error {
for _, arg := range args { for _, arg := range args {
output, err := kernel.Build(arg) output, err := kernel.Build(arg, OptRoot)
if err != nil { if err != nil {
wwlog.Printf(wwlog.ERROR, "Failed building kernel: %s\n", err) wwlog.Printf(wwlog.ERROR, "Failed building kernel: %s\n", err)
os.Exit(1) os.Exit(1)
@@ -43,6 +45,8 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
} }
nodeDB.Persist() nodeDB.Persist()
fmt.Printf("Set default kernel version to: %s\n", args[0]) fmt.Printf("Set default kernel version to: %s\n", args[0])
warewulfd.DaemonReload()
} }
} }

View File

@@ -16,12 +16,14 @@ var (
BuildAll bool BuildAll bool
ByNode bool ByNode bool
SetDefault bool SetDefault bool
OptRoot string
) )
func init() { func init() {
baseCmd.PersistentFlags().BoolVarP(&BuildAll, "all", "a", false, "Build all overlays (runtime and system)") baseCmd.PersistentFlags().BoolVarP(&BuildAll, "all", "a", false, "Build all overlays (runtime and system)")
baseCmd.PersistentFlags().BoolVarP(&ByNode, "node", "n", false, "Build overlay for a particular node(s)") baseCmd.PersistentFlags().BoolVarP(&ByNode, "node", "n", false, "Build overlay for a particular node(s)")
baseCmd.PersistentFlags().BoolVar(&SetDefault, "setdefault", false, "Set this kernel for the default profile") baseCmd.PersistentFlags().BoolVar(&SetDefault, "setdefault", false, "Set this kernel for the default profile")
baseCmd.PersistentFlags().StringVarP(&OptRoot, "root", "r", "/", "Import kernel from root (chroot) directory")
} }
// GetRootCommand returns the root cobra.Command for the application. // GetRootCommand returns the root cobra.Command for the application.

View File

@@ -2,11 +2,12 @@ package list
import ( import (
"fmt" "fmt"
"os"
"github.com/hpcng/warewulf/internal/pkg/kernel" "github.com/hpcng/warewulf/internal/pkg/kernel"
"github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os"
) )
func CobraRunE(cmd *cobra.Command, args []string) error { func CobraRunE(cmd *cobra.Command, args []string) error {

View File

@@ -2,10 +2,11 @@ package add
import ( import (
"fmt" "fmt"
"os"
"github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os"
) )
func CobraRunE(cmd *cobra.Command, args []string) error { func CobraRunE(cmd *cobra.Command, args []string) error {

View File

@@ -1,11 +1,12 @@
package console package console
import ( import (
"os"
"github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/power" "github.com/hpcng/warewulf/internal/pkg/power"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os"
) )
func CobraRunE(cmd *cobra.Command, args []string) error { func CobraRunE(cmd *cobra.Command, args []string) error {
@@ -57,4 +58,3 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
return returnErr return returnErr
} }

View File

@@ -2,11 +2,12 @@ package delete
import ( import (
"fmt" "fmt"
"os"
"github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/manifoldco/promptui" "github.com/manifoldco/promptui"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os"
) )
func CobraRunE(cmd *cobra.Command, args []string) error { func CobraRunE(cmd *cobra.Command, args []string) error {

View File

@@ -2,12 +2,13 @@ package list
import ( import (
"fmt" "fmt"
"github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra"
"os" "os"
"sort" "sort"
"strings" "strings"
"github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra"
) )
func CobraRunE(cmd *cobra.Command, args []string) error { func CobraRunE(cmd *cobra.Command, args []string) error {

View File

@@ -2,13 +2,15 @@ package set
import ( import (
"fmt" "fmt"
"os"
"github.com/hpcng/warewulf/internal/pkg/container" "github.com/hpcng/warewulf/internal/pkg/container"
"github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/warewulfd"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/manifoldco/promptui" "github.com/manifoldco/promptui"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os"
) )
func CobraRunE(cmd *cobra.Command, args []string) error { func CobraRunE(cmd *cobra.Command, args []string) error {
@@ -274,6 +276,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if result == "y" || result == "yes" { if result == "y" || result == "yes" {
nodeDB.Persist() nodeDB.Persist()
warewulfd.DaemonReload()
} }
} }

View File

@@ -1,11 +1,12 @@
package build package build
import ( import (
"os"
"github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/overlay" "github.com/hpcng/warewulf/internal/pkg/overlay"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os"
) )
func CobraRunE(cmd *cobra.Command, args []string) error { func CobraRunE(cmd *cobra.Command, args []string) error {

View File

@@ -7,7 +7,6 @@ var (
Use: "build [flags] <overlay name>", Use: "build [flags] <overlay name>",
Short: "(Re)build an overlay", Short: "(Re)build an overlay",
Long: "This command will build a system or runtime overlay.", Long: "This command will build a system or runtime overlay.",
Args: cobra.MinimumNArgs(1),
RunE: CobraRunE, RunE: CobraRunE,
} }
SystemOverlay bool SystemOverlay bool

View File

@@ -1,15 +1,16 @@
package chmod package chmod
import ( import (
"os"
"path"
"strconv"
"github.com/hpcng/warewulf/internal/pkg/config" "github.com/hpcng/warewulf/internal/pkg/config"
"github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/overlay" "github.com/hpcng/warewulf/internal/pkg/overlay"
"github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os"
"path"
"strconv"
) )
func CobraRunE(cmd *cobra.Command, args []string) error { func CobraRunE(cmd *cobra.Command, args []string) error {

View File

@@ -1,11 +1,12 @@
package create package create
import ( import (
"os"
"github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/overlay" "github.com/hpcng/warewulf/internal/pkg/overlay"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os"
) )
func CobraRunE(cmd *cobra.Command, args []string) error { func CobraRunE(cmd *cobra.Command, args []string) error {

View File

@@ -2,14 +2,15 @@ package delete
import ( import (
"fmt" "fmt"
"os"
"path"
"github.com/hpcng/warewulf/internal/pkg/config" "github.com/hpcng/warewulf/internal/pkg/config"
"github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/overlay" "github.com/hpcng/warewulf/internal/pkg/overlay"
"github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os"
"path"
) )
func CobraRunE(cmd *cobra.Command, args []string) error { func CobraRunE(cmd *cobra.Command, args []string) error {

View File

@@ -2,15 +2,16 @@ package edit
import ( import (
"fmt" "fmt"
"os"
"path"
"path/filepath"
"github.com/hpcng/warewulf/internal/pkg/config" "github.com/hpcng/warewulf/internal/pkg/config"
"github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/overlay" "github.com/hpcng/warewulf/internal/pkg/overlay"
"github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os"
"path"
"path/filepath"
) )
func CobraRunE(cmd *cobra.Command, args []string) error { func CobraRunE(cmd *cobra.Command, args []string) error {

View File

@@ -1,14 +1,15 @@
package imprt package imprt
import ( import (
"os"
"path"
"github.com/hpcng/warewulf/internal/pkg/config" "github.com/hpcng/warewulf/internal/pkg/config"
"github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/overlay" "github.com/hpcng/warewulf/internal/pkg/overlay"
"github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os"
"path"
) )
func CobraRunE(cmd *cobra.Command, args []string) error { func CobraRunE(cmd *cobra.Command, args []string) error {

View File

@@ -2,14 +2,15 @@ package list
import ( import (
"fmt" "fmt"
"os"
"syscall"
"github.com/hpcng/warewulf/internal/pkg/config" "github.com/hpcng/warewulf/internal/pkg/config"
"github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/overlay" "github.com/hpcng/warewulf/internal/pkg/overlay"
"github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os"
"syscall"
) )
func CobraRunE(cmd *cobra.Command, args []string) error { func CobraRunE(cmd *cobra.Command, args []string) error {

View File

@@ -2,14 +2,15 @@ package mkdir
import ( import (
"fmt" "fmt"
"os"
"path"
"github.com/hpcng/warewulf/internal/pkg/config" "github.com/hpcng/warewulf/internal/pkg/config"
"github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/overlay" "github.com/hpcng/warewulf/internal/pkg/overlay"
"github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os"
"path"
) )
func CobraRunE(cmd *cobra.Command, args []string) error { func CobraRunE(cmd *cobra.Command, args []string) error {

View File

@@ -2,13 +2,14 @@ package show
import ( import (
"fmt" "fmt"
"io/ioutil"
"os"
"path"
"github.com/hpcng/warewulf/internal/pkg/config" "github.com/hpcng/warewulf/internal/pkg/config"
"github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"io/ioutil"
"os"
"path"
) )
func CobraRunE(cmd *cobra.Command, args []string) error { func CobraRunE(cmd *cobra.Command, args []string) error {

View File

@@ -1,10 +1,11 @@
package add package add
import ( import (
"os"
"github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os"
) )
func CobraRunE(cmd *cobra.Command, args []string) error { func CobraRunE(cmd *cobra.Command, args []string) error {

View File

@@ -2,12 +2,13 @@ package delete
import ( import (
"fmt" "fmt"
"os"
"github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/manifoldco/promptui" "github.com/manifoldco/promptui"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os"
) )
func CobraRunE(cmd *cobra.Command, args []string) error { func CobraRunE(cmd *cobra.Command, args []string) error {

View File

@@ -2,10 +2,11 @@ package list
import ( import (
"fmt" "fmt"
"os"
"github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os"
) )
func CobraRunE(cmd *cobra.Command, args []string) error { func CobraRunE(cmd *cobra.Command, args []string) error {

View File

@@ -2,13 +2,15 @@ package set
import ( import (
"fmt" "fmt"
"os"
"github.com/hpcng/warewulf/internal/pkg/container" "github.com/hpcng/warewulf/internal/pkg/container"
"github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/warewulfd"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/manifoldco/promptui" "github.com/manifoldco/promptui"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os"
) )
func CobraRunE(cmd *cobra.Command, args []string) error { func CobraRunE(cmd *cobra.Command, args []string) error {
@@ -251,6 +253,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if result == "y" || result == "yes" { if result == "y" || result == "yes" {
nodeDB.Persist() nodeDB.Persist()
warewulfd.DaemonReload()
} }
} else { } else {

View File

@@ -2,6 +2,8 @@ package ready
import ( import (
"fmt" "fmt"
"os"
"github.com/hpcng/warewulf/internal/pkg/config" "github.com/hpcng/warewulf/internal/pkg/config"
"github.com/hpcng/warewulf/internal/pkg/container" "github.com/hpcng/warewulf/internal/pkg/container"
"github.com/hpcng/warewulf/internal/pkg/kernel" "github.com/hpcng/warewulf/internal/pkg/kernel"
@@ -9,7 +11,6 @@ import (
"github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os"
) )
func CobraRunE(cmd *cobra.Command, args []string) error { func CobraRunE(cmd *cobra.Command, args []string) error {

View File

@@ -0,0 +1,10 @@
package reload
import (
"github.com/hpcng/warewulf/internal/pkg/warewulfd"
"github.com/spf13/cobra"
)
func CobraRunE(cmd *cobra.Command, args []string) error {
return warewulfd.DaemonReload()
}

View File

@@ -0,0 +1,19 @@
package reload
import "github.com/spf13/cobra"
var (
baseCmd = &cobra.Command{
Use: "reload",
Short: "Reload the Warewulf server configuration",
RunE: CobraRunE,
}
)
func init() {
}
// GetRootCommand returns the root cobra.Command for the application.
func GetCommand() *cobra.Command {
return baseCmd
}

View File

@@ -0,0 +1,11 @@
package restart
import (
"github.com/hpcng/warewulf/internal/pkg/warewulfd"
"github.com/spf13/cobra"
)
func CobraRunE(cmd *cobra.Command, args []string) error {
warewulfd.DaemonStop()
return warewulfd.DaemonStart()
}

View File

@@ -0,0 +1,19 @@
package restart
import "github.com/spf13/cobra"
var (
baseCmd = &cobra.Command{
Use: "restart",
Short: "Restart the Warewulf server",
RunE: CobraRunE,
}
)
func init() {
}
// GetRootCommand returns the root cobra.Command for the application.
func GetCommand() *cobra.Command {
return baseCmd
}

View File

@@ -1,6 +1,8 @@
package server package server
import ( import (
"github.com/hpcng/warewulf/internal/app/wwctl/server/reload"
"github.com/hpcng/warewulf/internal/app/wwctl/server/restart"
"github.com/hpcng/warewulf/internal/app/wwctl/server/start" "github.com/hpcng/warewulf/internal/app/wwctl/server/start"
"github.com/hpcng/warewulf/internal/app/wwctl/server/status" "github.com/hpcng/warewulf/internal/app/wwctl/server/status"
"github.com/hpcng/warewulf/internal/app/wwctl/server/stop" "github.com/hpcng/warewulf/internal/app/wwctl/server/stop"
@@ -20,6 +22,9 @@ func init() {
baseCmd.AddCommand(start.GetCommand()) baseCmd.AddCommand(start.GetCommand())
baseCmd.AddCommand(status.GetCommand()) baseCmd.AddCommand(status.GetCommand())
baseCmd.AddCommand(stop.GetCommand()) baseCmd.AddCommand(stop.GetCommand())
baseCmd.AddCommand(restart.GetCommand())
baseCmd.AddCommand(reload.GetCommand())
} }
// GetRootCommand returns the root cobra.Command for the application. // GetRootCommand returns the root cobra.Command for the application.

View File

@@ -2,9 +2,10 @@ package config
import ( import (
"fmt" "fmt"
"path"
"github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"path"
) )
const ( const (

View File

@@ -2,12 +2,13 @@ package container
import ( import (
"fmt" "fmt"
"github.com/hpcng/warewulf/internal/pkg/errors"
"github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"os" "os"
"os/exec" "os/exec"
"path" "path"
"github.com/hpcng/warewulf/internal/pkg/errors"
"github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
) )
func Build(name string, buildForce bool) (string, error) { func Build(name string, buildForce bool) (string, error) {

View File

@@ -2,13 +2,15 @@ package container
import ( import (
"context" "context"
"os"
"github.com/containers/image/v5/types"
"github.com/hpcng/warewulf/internal/pkg/config" "github.com/hpcng/warewulf/internal/pkg/config"
"github.com/hpcng/warewulf/internal/pkg/errors" "github.com/hpcng/warewulf/internal/pkg/errors"
"github.com/hpcng/warewulf/internal/pkg/oci" "github.com/hpcng/warewulf/internal/pkg/oci"
"os"
) )
func PullURI(uri string, name string) error { func PullURI(uri string, name string, sCtx *types.SystemContext) error {
OciBlobCacheDir := config.LocalStateDir + "/oci/blobs" OciBlobCacheDir := config.LocalStateDir + "/oci/blobs"
err := os.MkdirAll(OciBlobCacheDir, 0755) err := os.MkdirAll(OciBlobCacheDir, 0755)
@@ -29,13 +31,15 @@ func PullURI(uri string, name string) error {
p, err := oci.NewPuller( p, err := oci.NewPuller(
oci.OptSetBlobCachePath(OciBlobCacheDir), oci.OptSetBlobCachePath(OciBlobCacheDir),
oci.OptSetSystemContext(nil), oci.OptSetSystemContext(sCtx),
) )
if err != nil { if err != nil {
return err return err
} }
p.GenerateID(context.Background(), uri) if _, err := p.GenerateID(context.Background(), uri); err != nil {
return err
}
if err := p.Pull(context.Background(), uri, fullPath); err != nil { if err := p.Pull(context.Background(), uri, fullPath); err != nil {
return err return err

View File

@@ -1,13 +1,14 @@
package container package container
import ( import (
"io/ioutil"
"os"
"path"
"github.com/hpcng/warewulf/internal/pkg/config" "github.com/hpcng/warewulf/internal/pkg/config"
"github.com/hpcng/warewulf/internal/pkg/errors" "github.com/hpcng/warewulf/internal/pkg/errors"
"github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"io/ioutil"
"os"
"path"
) )
func ValidName(name string) bool { func ValidName(name string) bool {

View File

@@ -2,14 +2,15 @@ package kernel
import ( import (
"fmt" "fmt"
"github.com/hpcng/warewulf/internal/pkg/config"
"github.com/hpcng/warewulf/internal/pkg/errors"
"github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"io/ioutil" "io/ioutil"
"os" "os"
"os/exec" "os/exec"
"path" "path"
"github.com/hpcng/warewulf/internal/pkg/config"
"github.com/hpcng/warewulf/internal/pkg/errors"
"github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
) )
func ParentDir() string { func ParentDir() string {
@@ -69,10 +70,10 @@ func ListKernels() ([]string, error) {
return ret, nil return ret, nil
} }
func Build(kernelVersion string) (string, error) { func Build(kernelVersion string, root string) (string, error) {
kernelImage := "/boot/vmlinuz-" + kernelVersion kernelImage := path.Join(root, "/boot/vmlinuz-"+kernelVersion)
kernelDrivers := "/lib/modules/" + kernelVersion kernelDrivers := path.Join(root, "/lib/modules/"+kernelVersion)
kernelDestination := KernelImage(kernelVersion) kernelDestination := KernelImage(kernelVersion)
driversDestination := KmodsImage(kernelVersion) driversDestination := KmodsImage(kernelVersion)

View File

@@ -2,13 +2,14 @@ package node
import ( import (
"fmt" "fmt"
"github.com/hpcng/warewulf/internal/pkg/errors"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"gopkg.in/yaml.v2"
"io/ioutil" "io/ioutil"
"regexp" "regexp"
"sort" "sort"
"strings" "strings"
"github.com/hpcng/warewulf/internal/pkg/errors"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"gopkg.in/yaml.v2"
) )
const ConfigFile = "/etc/warewulf/nodes.conf" const ConfigFile = "/etc/warewulf/nodes.conf"

View File

@@ -2,9 +2,10 @@ package node
import ( import (
"fmt" "fmt"
"os"
"github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"os"
) )
/****** /******

View File

@@ -1,10 +1,11 @@
package node package node
import ( import (
"os"
"github.com/hpcng/warewulf/internal/pkg/errors" "github.com/hpcng/warewulf/internal/pkg/errors"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
"os"
) )
/**** /****

View File

@@ -100,7 +100,7 @@ func (p *puller) GenerateID(ctx context.Context, uri string) (string, error) {
return "", fmt.Errorf("unable to parse uri: %v", err) return "", fmt.Errorf("unable to parse uri: %v", err)
} }
src, err := ref.NewImageSource(ctx, nil) src, err := ref.NewImageSource(ctx, p.sysCtx)
if err != nil { if err != nil {
return "", err return "", err
} }

View File

@@ -1,11 +1,12 @@
package overlay package overlay
import ( import (
"github.com/hpcng/warewulf/internal/pkg/container"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"io/ioutil" "io/ioutil"
"path" "path"
"strings" "strings"
"github.com/hpcng/warewulf/internal/pkg/container"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
) )
func templateFileInclude(path string) string { func templateFileInclude(path string) string {

View File

@@ -2,11 +2,6 @@ package overlay
import ( import (
"fmt" "fmt"
"github.com/hpcng/warewulf/internal/pkg/config"
"github.com/hpcng/warewulf/internal/pkg/errors"
"github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"io/ioutil" "io/ioutil"
"os" "os"
"os/exec" "os/exec"
@@ -15,6 +10,12 @@ import (
"regexp" "regexp"
"strings" "strings"
"text/template" "text/template"
"github.com/hpcng/warewulf/internal/pkg/config"
"github.com/hpcng/warewulf/internal/pkg/errors"
"github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
) )
type TemplateStruct struct { type TemplateStruct struct {

View File

@@ -1,8 +1,8 @@
package power package power
import ( import (
"os/exec"
"os" "os"
"os/exec"
) )
type IPMIResult struct { type IPMIResult struct {
@@ -16,7 +16,7 @@ type IPMI struct {
User string User string
Password string Password string
AuthType string AuthType string
result IPMIResult result IPMIResult
} }
func (ipmi *IPMI) Result() (string, error) { func (ipmi *IPMI) Result() (string, error) {
@@ -96,4 +96,3 @@ func (ipmi *IPMI) SensorList() (string, error) {
func (ipmi *IPMI) Console() error { func (ipmi *IPMI) Console() error {
return ipmi.IPMIInteractiveCommand("sol", "activate") return ipmi.IPMIInteractiveCommand("sol", "activate")
} }

View File

@@ -1,10 +1,9 @@
package power package power
//type PowerControl interface { //type PowerControl interface {
//PowerOn() (result string, err error) //PowerOn() (result string, err error)
//PowerOff() (result string, err error) //PowerOff() (result string, err error)
//PowerStatus() (result string, err error) //PowerStatus() (result string, err error)
//} //}
type PowerOnInterface interface { type PowerOnInterface interface {
@@ -18,5 +17,3 @@ type PowerOffInterface interface {
type PowerStatusInterface interface { type PowerStatusInterface interface {
PowerStatus() (result string, err error) PowerStatus() (result string, err error)
} }

View File

@@ -1,8 +1,9 @@
package staticfiles package staticfiles
import ( import (
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"io/ioutil" "io/ioutil"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
) )
func WriteData(source string, dest string) error { func WriteData(source string, dest string) error {

View File

@@ -1,9 +1,9 @@
package util package util
import ( import (
"bufio"
"crypto/sha256" "crypto/sha256"
"fmt" "fmt"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"io" "io"
"math/rand" "math/rand"
"os" "os"
@@ -11,8 +11,8 @@ import (
"path/filepath" "path/filepath"
"regexp" "regexp"
"time" "time"
"bufio"
// "strings" "github.com/hpcng/warewulf/internal/pkg/wwlog"
) )
func DirModTime(path string) (time.Time, error) { func DirModTime(path string) (time.Time, error) {

View File

@@ -2,10 +2,11 @@ package vnfs
import ( import (
"fmt" "fmt"
"github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"os" "os"
"path" "path"
"github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
) )
func BuildContainerdir(vnfs VnfsObject, buildForce bool) { func BuildContainerdir(vnfs VnfsObject, buildForce bool) {
@@ -51,7 +52,7 @@ func BuildContainerdir(vnfs VnfsObject, buildForce bool) {
wwlog.Printf(wwlog.ERROR, "Could not create symlink for Chroot: %s\n", err) wwlog.Printf(wwlog.ERROR, "Could not create symlink for Chroot: %s\n", err)
os.Exit(1) os.Exit(1)
} }
err = os.Rename(vnfs.Chroot + "-link", vnfs.Chroot) err = os.Rename(vnfs.Chroot+"-link", vnfs.Chroot)
if err != nil { if err != nil {
wwlog.Printf(wwlog.ERROR, "Could not rename link: %s\n", err) wwlog.Printf(wwlog.ERROR, "Could not rename link: %s\n", err)
os.Exit(1) os.Exit(1)

View File

@@ -3,11 +3,12 @@ package vnfs
import ( import (
"context" "context"
"fmt" "fmt"
"os"
"path"
"github.com/hpcng/warewulf/internal/pkg/config" "github.com/hpcng/warewulf/internal/pkg/config"
"github.com/hpcng/warewulf/internal/pkg/oci" "github.com/hpcng/warewulf/internal/pkg/oci"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"os"
"path"
) )
func BuildDocker(vnfs VnfsObject, buildForce bool) { func BuildDocker(vnfs VnfsObject, buildForce bool) {

View File

@@ -1,15 +1,16 @@
package vnfs package vnfs
import ( import (
"io/ioutil"
"os"
"path"
"strings"
"github.com/hpcng/warewulf/internal/pkg/config" "github.com/hpcng/warewulf/internal/pkg/config"
"github.com/hpcng/warewulf/internal/pkg/errors" "github.com/hpcng/warewulf/internal/pkg/errors"
"github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
"io/ioutil"
"os"
"path"
"strings"
) )
type VnfsObject struct { type VnfsObject struct {

View File

@@ -2,11 +2,12 @@ package warewulfconf
import ( import (
"fmt" "fmt"
"io/ioutil"
"net"
"github.com/brotherpowers/ipsubnet" "github.com/brotherpowers/ipsubnet"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
"io/ioutil"
"net"
) )
func New() (ControllerConf, error) { func New() (ControllerConf, error) {
@@ -15,7 +16,7 @@ func New() (ControllerConf, error) {
wwlog.Printf(wwlog.DEBUG, "Opening Warewulf configuration file: %s\n", ConfigFile) wwlog.Printf(wwlog.DEBUG, "Opening Warewulf configuration file: %s\n", ConfigFile)
data, err := ioutil.ReadFile(ConfigFile) data, err := ioutil.ReadFile(ConfigFile)
if err != nil { if err != nil {
fmt.Printf("error reading node configuration file\n") fmt.Printf("error reading Warewulf configuration file\n")
return ret, err return ret, err
} }

View File

@@ -1,9 +1,10 @@
package warewulfconf package warewulfconf
import ( import (
"os"
"github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"os"
) )
const ConfigFile = "/etc/warewulf/warewulf.conf" const ConfigFile = "/etc/warewulf/warewulf.conf"

View File

@@ -1,9 +1,10 @@
package warewulfconf package warewulfconf
import ( import (
"os"
"github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/hpcng/warewulf/internal/pkg/wwlog"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
"os"
) )
func (self *ControllerConf) Persist() error { func (self *ControllerConf) Persist() error {

View File

@@ -1,9 +1,10 @@
package warewulfd package warewulfd
import ( import (
"github.com/hpcng/warewulf/internal/pkg/container"
"log" "log"
"net/http" "net/http"
"github.com/hpcng/warewulf/internal/pkg/container"
) )
func ContainerSend(w http.ResponseWriter, req *http.Request) { func ContainerSend(w http.ResponseWriter, req *http.Request) {

View File

@@ -2,14 +2,15 @@ package warewulfd
import ( import (
"fmt" "fmt"
"github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"io/ioutil" "io/ioutil"
"os" "os"
"os/exec" "os/exec"
"strconv" "strconv"
"syscall" "syscall"
"time" "time"
"github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
) )
const ( const (
@@ -83,6 +84,34 @@ func DaemonStatus() error {
return nil return nil
} }
func DaemonReload() error {
if util.IsFile(WAREWULFD_PIDFILE) == false {
wwlog.Printf(wwlog.INFO, "Warewulf daemon process not running (%s)\n", WAREWULFD_PIDFILE)
return nil
}
dat, err := ioutil.ReadFile(WAREWULFD_PIDFILE)
if err != nil {
return err
}
pid, _ := strconv.Atoi(string(dat))
process, err := os.FindProcess(pid)
if err != nil {
fmt.Printf("Failed to find process: %s\n", err)
return err
} else {
err := process.Signal(syscall.Signal(syscall.SIGHUP))
if err != nil {
fmt.Printf("SIGCONT on pid %d returned: %v\n", pid, err)
return err
}
}
return nil
}
func DaemonStop() error { func DaemonStop() error {
if util.IsFile(WAREWULFD_PIDFILE) == false { if util.IsFile(WAREWULFD_PIDFILE) == false {

View File

@@ -2,15 +2,16 @@ package warewulfd
import ( import (
"fmt" "fmt"
"github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/overlay"
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"log" "log"
"net/http" "net/http"
"strconv" "strconv"
"strings" "strings"
"text/template" "text/template"
"github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/overlay"
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
) )
type iPxeTemplate struct { type iPxeTemplate struct {
@@ -30,19 +31,14 @@ func IpxeSend(w http.ResponseWriter, req *http.Request) {
url := strings.Split(req.URL.Path, "/") url := strings.Split(req.URL.Path, "/")
var unconfiguredNode bool var unconfiguredNode bool
nodeDB, err := node.New()
if err != nil {
log.Printf("Could not read node configuration file: %s\n", err)
w.WriteHeader(503)
return
}
if url[2] == "" { if url[2] == "" {
log.Printf("ERROR: Bad iPXE request from %s\n", req.RemoteAddr) log.Printf("ERROR: Bad iPXE request from %s\n", req.RemoteAddr)
w.WriteHeader(404) w.WriteHeader(404)
return return
} }
hwaddr := strings.ReplaceAll(url[2], "-", ":")
conf, err := warewulfconf.New() conf, err := warewulfconf.New()
if err != nil { if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err) wwlog.Printf(wwlog.ERROR, "%s\n", err)
@@ -50,16 +46,22 @@ func IpxeSend(w http.ResponseWriter, req *http.Request) {
return return
} }
hwaddr := strings.ReplaceAll(url[2], "-", ":") nodeobj, err := GetNode(hwaddr)
n, err := nodeDB.FindByHwaddr(hwaddr)
if err != nil { if err != nil {
// If we failed to find a node, let's see if we can add one... // If we failed to find a node, let's see if we can add one...
var netdev string var netdev string
nodeDB, err := node.New()
if err != nil {
log.Printf("Could not read node configuration file: %s\n", err)
w.WriteHeader(503)
return
}
wwlog.Printf(wwlog.VERBOSE, "Node was not found, looking for discoverable nodes...\n") wwlog.Printf(wwlog.VERBOSE, "Node was not found, looking for discoverable nodes...\n")
n, netdev, err = nodeDB.FindDiscoverableNode() n, netdev, err := nodeDB.FindDiscoverableNode()
if err != nil { if err != nil {
wwlog.Printf(wwlog.WARN, "No nodes are set as discoverable...\n") wwlog.Printf(wwlog.WARN, "No nodes are set as discoverable...\n")
unconfiguredNode = true unconfiguredNode = true
@@ -79,6 +81,7 @@ func IpxeSend(w http.ResponseWriter, req *http.Request) {
wwlog.Printf(wwlog.ERROR, "Could not persist new node configuration while adding node: %s\n", n.Id.Get()) wwlog.Printf(wwlog.ERROR, "Could not persist new node configuration while adding node: %s\n", n.Id.Get())
unconfiguredNode = true unconfiguredNode = true
} else { } else {
nodeobj = n
wwlog.Printf(wwlog.INFO, "Building System Overlay:\n") wwlog.Printf(wwlog.INFO, "Building System Overlay:\n")
_ = overlay.BuildSystemOverlay([]node.NodeInfo{n}) _ = overlay.BuildSystemOverlay([]node.NodeInfo{n})
wwlog.Printf(wwlog.INFO, "Building Runtime Overlay:\n") wwlog.Printf(wwlog.INFO, "Building Runtime Overlay:\n")
@@ -110,9 +113,10 @@ func IpxeSend(w http.ResponseWriter, req *http.Request) {
return return
} else { } else {
log.Printf("IPXE: %15s: %s\n", n.Id.Get(), req.URL.Path)
ipxeTemplate := fmt.Sprintf("/etc/warewulf/ipxe/%s.ipxe", n.Ipxe.Get()) log.Printf("IPXE: %15s: %s\n", nodeobj.Id.Get(), req.URL.Path)
ipxeTemplate := fmt.Sprintf("/etc/warewulf/ipxe/%s.ipxe", nodeobj.Ipxe.Get())
tmpl, err := template.ParseFiles(ipxeTemplate) tmpl, err := template.ParseFiles(ipxeTemplate)
if err != nil { if err != nil {
@@ -122,14 +126,14 @@ func IpxeSend(w http.ResponseWriter, req *http.Request) {
var replace iPxeTemplate var replace iPxeTemplate
replace.Fqdn = n.Id.Get() replace.Fqdn = nodeobj.Id.Get()
replace.Ipaddr = conf.Ipaddr replace.Ipaddr = conf.Ipaddr
replace.Port = strconv.Itoa(conf.Warewulf.Port) replace.Port = strconv.Itoa(conf.Warewulf.Port)
replace.Hostname = n.Id.Get() replace.Hostname = nodeobj.Id.Get()
replace.Hwaddr = url[2] replace.Hwaddr = url[2]
replace.ContainerName = n.ContainerName.Get() replace.ContainerName = nodeobj.ContainerName.Get()
replace.KernelArgs = n.KernelArgs.Get() replace.KernelArgs = nodeobj.KernelArgs.Get()
replace.KernelVersion = n.KernelVersion.Get() replace.KernelVersion = nodeobj.KernelVersion.Get()
err = tmpl.Execute(w, replace) err = tmpl.Execute(w, replace)
if err != nil { if err != nil {
@@ -137,7 +141,7 @@ func IpxeSend(w http.ResponseWriter, req *http.Request) {
return return
} }
log.Printf("SEND: %15s: %s\n", n.Id.Get(), ipxeTemplate) log.Printf("SEND: %15s: %s\n", nodeobj.Id.Get(), ipxeTemplate)
} }
return return

View File

@@ -1,9 +1,10 @@
package warewulfd package warewulfd
import ( import (
"github.com/hpcng/warewulf/internal/pkg/kernel"
"log" "log"
"net/http" "net/http"
"github.com/hpcng/warewulf/internal/pkg/kernel"
) )
func KernelSend(w http.ResponseWriter, req *http.Request) { func KernelSend(w http.ResponseWriter, req *http.Request) {

View File

@@ -1,9 +1,10 @@
package warewulfd package warewulfd
import ( import (
"github.com/hpcng/warewulf/internal/pkg/kernel"
"log" "log"
"net/http" "net/http"
"github.com/hpcng/warewulf/internal/pkg/kernel"
) )
func KmodsSend(w http.ResponseWriter, req *http.Request) { func KmodsSend(w http.ResponseWriter, req *http.Request) {

View File

@@ -0,0 +1,65 @@
package warewulfd
import (
"sync"
"github.com/hpcng/warewulf/internal/pkg/errors"
"github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
)
type nodeDB struct {
lock sync.RWMutex
NodeInfo map[string]node.NodeInfo
}
var (
db nodeDB
)
func LoadNodeDB() error {
var TmpMap map[string]node.NodeInfo
TmpMap = make(map[string]node.NodeInfo)
wwlog.Printf(wwlog.INFO, "Loading the node Database\n")
DB, err := node.New()
if err != nil {
return err
}
nodes, err := DB.FindAllNodes()
if err != nil {
return err
}
for _, n := range nodes {
for _, netdev := range n.NetDevs {
wwlog.Printf(wwlog.DEBUG, "Caching node entry: '%s' -> %s\n", netdev.Hwaddr.Get(), n.Id.Get())
TmpMap[netdev.Hwaddr.Get()] = n
}
}
db.lock.Lock()
defer db.lock.Unlock()
db.NodeInfo = TmpMap
return nil
}
func GetNode(val string) (node.NodeInfo, error) {
db.lock.RLock()
defer db.lock.RUnlock()
if _, ok := db.NodeInfo[val]; ok {
wwlog.Printf(wwlog.DEBUG, "Found node:\n%+v\n", db.NodeInfo[val])
return db.NodeInfo[val], nil
}
wwlog.Printf(wwlog.VERBOSE, "Node not found in DB: %s\n", val)
var empty node.NodeInfo
return empty, errors.New("No node found")
}

View File

@@ -2,13 +2,14 @@ package warewulfd
import ( import (
"fmt" "fmt"
"github.com/hpcng/warewulf/internal/pkg/config"
"github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
"log" "log"
"net/http" "net/http"
"strconv" "strconv"
"strings" "strings"
"github.com/hpcng/warewulf/internal/pkg/config"
"github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
) )
func RuntimeOverlaySend(w http.ResponseWriter, req *http.Request) { func RuntimeOverlaySend(w http.ResponseWriter, req *http.Request) {

View File

@@ -1,9 +1,10 @@
package warewulfd package warewulfd
import ( import (
"github.com/hpcng/warewulf/internal/pkg/config"
"log" "log"
"net/http" "net/http"
"github.com/hpcng/warewulf/internal/pkg/config"
) )
func SystemOverlaySend(w http.ResponseWriter, req *http.Request) { func SystemOverlaySend(w http.ResponseWriter, req *http.Request) {

View File

@@ -1,35 +1,31 @@
package warewulfd package warewulfd
import ( import (
"fmt"
"github.com/hpcng/warewulf/internal/pkg/errors"
"github.com/hpcng/warewulf/internal/pkg/node"
"io" "io"
"log" "log"
"net/http" "net/http"
"os" "os"
"strconv" "strconv"
"strings" "strings"
"github.com/hpcng/warewulf/internal/pkg/errors"
"github.com/hpcng/warewulf/internal/pkg/node"
) )
func getSanity(req *http.Request) (node.NodeInfo, error) { func getSanity(req *http.Request) (node.NodeInfo, error) {
url := strings.Split(req.URL.Path, "/") url := strings.Split(req.URL.Path, "/")
var ret node.NodeInfo
nodes, err := node.New()
if err != nil {
return ret, errors.New(fmt.Sprintf("%s", err))
}
hwaddr := strings.ReplaceAll(url[2], "-", ":") hwaddr := strings.ReplaceAll(url[2], "-", ":")
ret, err = nodes.FindByHwaddr(hwaddr)
nodeobj, err := GetNode(hwaddr)
if err != nil { if err != nil {
var ret node.NodeInfo
return ret, errors.New("Could not find node by HW address") return ret, errors.New("Could not find node by HW address")
} }
log.Printf("REQ: %15s: %s\n", ret.Id.Get(), req.URL.Path) log.Printf("REQ: %15s: %s\n", nodeobj.Id.Get(), req.URL.Path)
return ret, nil return nodeobj, nil
} }
func sendFile(w http.ResponseWriter, filename string, sendto string) error { func sendFile(w http.ResponseWriter, filename string, sendto string) error {

View File

@@ -1,8 +1,12 @@
package warewulfd package warewulfd
import ( import (
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"net/http" "net/http"
"os"
"os/signal"
"syscall"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
) )
// TODO: https://github.com/danderson/netboot/blob/master/pixiecore/dhcp.go // TODO: https://github.com/danderson/netboot/blob/master/pixiecore/dhcp.go
@@ -10,6 +14,23 @@ import (
func RunServer() error { func RunServer() error {
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGHUP)
go func() {
for _ = range c {
err := LoadNodeDB()
if err != nil {
wwlog.Printf(wwlog.WARN, "Could not load database: %s\n", err)
}
}
}()
err := LoadNodeDB()
if err != nil {
wwlog.Printf(wwlog.WARN, "Could not load database: %s\n", err)
}
wwlog.Printf(wwlog.DEBUG, "Registering handlers for the web service\n") wwlog.Printf(wwlog.DEBUG, "Registering handlers for the web service\n")
http.HandleFunc("/ipxe/", IpxeSend) http.HandleFunc("/ipxe/", IpxeSend)
@@ -21,7 +42,11 @@ func RunServer() error {
wwlog.Printf(wwlog.VERBOSE, "Starting HTTPD REST service\n") wwlog.Printf(wwlog.VERBOSE, "Starting HTTPD REST service\n")
http.ListenAndServe(":9873", nil) err = http.ListenAndServe(":9873", nil)
if err != nil {
wwlog.Printf(wwlog.ERROR, "Could not start listening service: %s\n", err)
os.Exit(1)
}
return nil return nil
} }

View File

@@ -6,17 +6,17 @@ import (
) )
const ( const (
CRITICAL = 0 CRITICAL = 0
ERROR = 1 ERROR = 1
WARN = 2 WARN = 2
INFO = 3 INFO = 3
VERBOSE = 4 VERBOSE = 4
DEBUG = 5 DEBUG = 5
) )
var ( var (
logLevel = INFO logLevel = INFO
Indent string Indent string
) )
func SetLevel(level int) { func SetLevel(level int) {
@@ -37,17 +37,17 @@ func SetIndent(i int) {
func prefixLevel(level int) { func prefixLevel(level int) {
if level == DEBUG { if level == DEBUG {
log.SetPrefix("[DEBUG] "+Indent) log.SetPrefix("[DEBUG] " + Indent)
} else if level == VERBOSE { } else if level == VERBOSE {
log.SetPrefix("[VERBOSE] "+Indent) log.SetPrefix("[VERBOSE] " + Indent)
} else if level == INFO { } else if level == INFO {
log.SetPrefix("[INFO] "+Indent) log.SetPrefix("[INFO] " + Indent)
} else if level == WARN { } else if level == WARN {
log.SetPrefix("[WARN] "+Indent) log.SetPrefix("[WARN] " + Indent)
} else if level == ERROR { } else if level == ERROR {
log.SetPrefix("[ERROR] "+Indent) log.SetPrefix("[ERROR] " + Indent)
} else if level == CRITICAL { } else if level == CRITICAL {
log.SetPrefix("[CRITICAL] "+Indent) log.SetPrefix("[CRITICAL] " + Indent)
} }
} }
@@ -57,14 +57,14 @@ func Println(level int, message string) {
log.Println(message) log.Println(message)
} }
log.SetPrefix("[LOG] "+Indent) log.SetPrefix("[LOG] " + Indent)
} }
func Printf(level int, message string, a...interface{}) { func Printf(level int, message string, a ...interface{}) {
if level <= logLevel { if level <= logLevel {
prefixLevel(level) prefixLevel(level)
log.Printf(message, a...) log.Printf(message, a...)
} }
log.SetPrefix("[LOG] "+Indent) log.SetPrefix("[LOG] " + Indent)
} }

View File

@@ -84,8 +84,7 @@ ipmitool channel setaccess 1 2 link=on ipmi=on callin=on privilege=4
ipmitool sol set force-encryption true 1 ipmitool sol set force-encryption true 1
ipmitool sol set force-authentication true 1 ipmitool sol set force-authentication true 1
ipmitool sol set privilege-level admin 1 ipmitool sol set privilege-level admin 1
#ipmitool sol payload enable 1 4 ipmitool sol payload enable 1 2
ipmitool sol payload enable 1 2 1
ipmitool sol set enabled true 1 1 ipmitool sol set enabled true 1 1
speed=38.4 # 19.2 38.4 115.2 speed=38.4 # 19.2 38.4 115.2
ipmitool sol set non-volatile-bit-rate $speed 1 ipmitool sol set non-volatile-bit-rate $speed 1

View File

@@ -44,5 +44,5 @@ rm -rf $RPM_BUILD_ROOT
/var/warewulf /var/warewulf
%changelog %changelog
* Tue Jan 26 14:46:24 JST 2021 Brian Clemens <bclemens@ctrliq.com> - 4.0.0 * Tue Jan 26 2021 14:46:24 JST Brian Clemens <bclemens@ctrliq.com> - 4.0.0
- Initial release - Initial release