Moved warewulfd commandline program into wwctl

This commit is contained in:
Gregory Kurtzer
2020-12-11 23:30:29 -08:00
parent c53c97dbcf
commit 90246f227f
16 changed files with 60 additions and 93 deletions

View File

@@ -40,7 +40,7 @@ lint:
@echo Running golangci-lint...
@$(GOLANGCI_LINT) run --build-tags "$(WW_BUILD_GO_BUILD_TAGS)" ./...
all: vendor warewulfd wwctl wwclient
all: vendor wwctl wwclient
files: all
install -d -m 0755 /var/warewulf/
@@ -60,9 +60,6 @@ services: files
# sudo systemctl enable tftp
# sudo systemctl restart tftp
warewulfd:
cd cmd/warewulfd; go build -mod vendor -tags "$(WW_BUILD_GO_BUILD_TAGS)" -o ../../warewulfd
wwctl:
cd cmd/wwctl; go build -mod vendor -tags "$(WW_BUILD_GO_BUILD_TAGS)" -o ../../wwctl
@@ -70,7 +67,6 @@ wwclient:
cd cmd/wwclient; CGO_ENABLED=0 GOOS=linux go build -mod vendor -a -ldflags '-extldflags -static' -o ../../wwclient
clean:
rm -f warewulfd
rm -f wwclient
rm -f wwctl

View File

@@ -1,12 +0,0 @@
package main
import (
"github.com/hpcng/warewulf/internal/app/warewulfd"
)
func main() {
root := warewulfd.GetRootCommand()
root.Execute()
}

View File

@@ -1,39 +0,0 @@
package warewulfd
import (
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra"
)
var (
baseCmd = &cobra.Command{
Use: "warewulfd",
Short: "Warewulf Daemon Service",
Long: "This is the primary Warewulf system for provisioning nodes",
RunE: CobraRunE,
PersistentPreRunE: rootPersistentPreRunE,
}
verboseArg bool
debugArg bool
)
func init() {
baseCmd.PersistentFlags().BoolVarP(&verboseArg, "verbose", "v", false, "Run with increased verbosity.")
baseCmd.PersistentFlags().BoolVarP(&debugArg, "debug", "d", false, "Run with debugging messages enabled.")
}
// GetRootCommand returns the root cobra.Command for the application.
func GetRootCommand() *cobra.Command {
return baseCmd
}
func rootPersistentPreRunE(cmd *cobra.Command, args []string) error {
if verboseArg == true {
wwlog.SetLevel(wwlog.VERBOSE)
} else if debugArg == true {
wwlog.SetLevel(wwlog.DEBUG)
} else {
wwlog.SetLevel(wwlog.INFO)
}
return nil
}

View File

@@ -1,24 +0,0 @@
package warewulfd
import (
"github.com/hpcng/warewulf/internal/app/warewulfd/response"
"github.com/spf13/cobra"
"net/http"
)
// TODO: https://github.com/danderson/netboot/blob/master/pixiecore/dhcp.go
// TODO: https://github.com/pin/tftp
func CobraRunE(cmd *cobra.Command, args []string) error {
http.HandleFunc("/ipxe/", response.IpxeSend)
http.HandleFunc("/kernel/", response.KernelSend)
http.HandleFunc("/kmods/", response.KmodsSend)
http.HandleFunc("/container/", response.ContainerSend)
http.HandleFunc("/overlay-system/", response.SystemOverlaySend)
http.HandleFunc("/overlay-runtime", response.RuntimeOverlaySend)
http.ListenAndServe(":9873", nil)
return nil
}

View File

@@ -1,6 +1,11 @@
package server
import "github.com/spf13/cobra"
import (
"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/stop"
"github.com/spf13/cobra"
)
var (
baseCmd = &cobra.Command{
@@ -12,6 +17,10 @@ var (
)
func init() {
baseCmd.AddCommand(start.GetCommand())
baseCmd.AddCommand(status.GetCommand())
baseCmd.AddCommand(stop.GetCommand())
}
// GetRootCommand returns the root cobra.Command for the application.

View File

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

View File

@@ -1,8 +1,12 @@
package status
import "github.com/spf13/cobra"
import (
"fmt"
"github.com/spf13/cobra"
)
func CobraRunE(cmd *cobra.Command, args []string) error {
fmt.Printf("Not implemented yet\n")
return nil
}

View File

@@ -1,8 +1,11 @@
package stop
import "github.com/spf13/cobra"
import (
"fmt"
"github.com/spf13/cobra"
)
func CobraRunE(cmd *cobra.Command, args []string) error {
fmt.Printf("Not implemented yet\n")
return nil
}

View File

@@ -1,4 +1,4 @@
package response
package warewulfd
import (
"github.com/hpcng/warewulf/internal/pkg/container"

View File

@@ -1,4 +1,4 @@
package response
package warewulfd
import (
"fmt"

View File

@@ -1,4 +1,4 @@
package response
package warewulfd
import (
"github.com/hpcng/warewulf/internal/pkg/kernel"

View File

@@ -1,4 +1,4 @@
package response
package warewulfd
import (
"github.com/hpcng/warewulf/internal/pkg/kernel"

View File

@@ -1,4 +1,4 @@
package response
package warewulfd
import (
"fmt"

View File

@@ -1,4 +1,4 @@
package response
package warewulfd
import (
"github.com/hpcng/warewulf/internal/pkg/config"

View File

@@ -1,4 +1,4 @@
package response
package warewulfd
import (
"fmt"

View File

@@ -0,0 +1,27 @@
package warewulfd
import (
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"net/http"
)
// TODO: https://github.com/danderson/netboot/blob/master/pixiecore/dhcp.go
// TODO: https://github.com/pin/tftp
func RunServer() error {
wwlog.Printf(wwlog.DEBUG, "Registering handlers for the web service\n")
http.HandleFunc("/ipxe/", IpxeSend)
http.HandleFunc("/kernel/", KernelSend)
http.HandleFunc("/kmods/", KmodsSend)
http.HandleFunc("/container/", ContainerSend)
http.HandleFunc("/overlay-system/", SystemOverlaySend)
http.HandleFunc("/overlay-runtime", RuntimeOverlaySend)
wwlog.Printf(wwlog.VERBOSE, "Starting HTTPD REST service\n")
http.ListenAndServe(":9873", nil)
return nil
}