Moved warewulfd commandline program into wwctl
This commit is contained in:
6
Makefile
6
Makefile
@@ -40,7 +40,7 @@ lint:
|
|||||||
@echo Running golangci-lint...
|
@echo Running golangci-lint...
|
||||||
@$(GOLANGCI_LINT) run --build-tags "$(WW_BUILD_GO_BUILD_TAGS)" ./...
|
@$(GOLANGCI_LINT) run --build-tags "$(WW_BUILD_GO_BUILD_TAGS)" ./...
|
||||||
|
|
||||||
all: vendor warewulfd wwctl wwclient
|
all: vendor wwctl wwclient
|
||||||
|
|
||||||
files: all
|
files: all
|
||||||
install -d -m 0755 /var/warewulf/
|
install -d -m 0755 /var/warewulf/
|
||||||
@@ -60,9 +60,6 @@ services: files
|
|||||||
# sudo systemctl enable tftp
|
# sudo systemctl enable tftp
|
||||||
# sudo systemctl restart tftp
|
# sudo systemctl restart tftp
|
||||||
|
|
||||||
warewulfd:
|
|
||||||
cd cmd/warewulfd; go build -mod vendor -tags "$(WW_BUILD_GO_BUILD_TAGS)" -o ../../warewulfd
|
|
||||||
|
|
||||||
wwctl:
|
wwctl:
|
||||||
cd cmd/wwctl; go build -mod vendor -tags "$(WW_BUILD_GO_BUILD_TAGS)" -o ../../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
|
cd cmd/wwclient; CGO_ENABLED=0 GOOS=linux go build -mod vendor -a -ldflags '-extldflags -static' -o ../../wwclient
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f warewulfd
|
|
||||||
rm -f wwclient
|
rm -f wwclient
|
||||||
rm -f wwctl
|
rm -f wwctl
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/hpcng/warewulf/internal/app/warewulfd"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
root := warewulfd.GetRootCommand()
|
|
||||||
|
|
||||||
root.Execute()
|
|
||||||
}
|
|
||||||
@@ -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
|
|
||||||
}
|
|
||||||
@@ -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
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,11 @@
|
|||||||
package server
|
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 (
|
var (
|
||||||
baseCmd = &cobra.Command{
|
baseCmd = &cobra.Command{
|
||||||
@@ -12,6 +17,10 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
baseCmd.AddCommand(start.GetCommand())
|
||||||
|
baseCmd.AddCommand(status.GetCommand())
|
||||||
|
baseCmd.AddCommand(stop.GetCommand())
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRootCommand returns the root cobra.Command for the application.
|
// GetRootCommand returns the root cobra.Command for the application.
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package start
|
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 {
|
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||||
|
|
||||||
return nil
|
return warewulfd.RunServer()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
package status
|
package status
|
||||||
|
|
||||||
import "github.com/spf13/cobra"
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||||
|
fmt.Printf("Not implemented yet\n")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package stop
|
package stop
|
||||||
|
|
||||||
import "github.com/spf13/cobra"
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||||
|
fmt.Printf("Not implemented yet\n")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package response
|
package warewulfd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/hpcng/warewulf/internal/pkg/container"
|
"github.com/hpcng/warewulf/internal/pkg/container"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package response
|
package warewulfd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package response
|
package warewulfd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/hpcng/warewulf/internal/pkg/kernel"
|
"github.com/hpcng/warewulf/internal/pkg/kernel"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package response
|
package warewulfd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/hpcng/warewulf/internal/pkg/kernel"
|
"github.com/hpcng/warewulf/internal/pkg/kernel"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package response
|
package warewulfd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package response
|
package warewulfd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/hpcng/warewulf/internal/pkg/config"
|
"github.com/hpcng/warewulf/internal/pkg/config"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package response
|
package warewulfd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
27
internal/pkg/warewulfd/warewulfd.go
Normal file
27
internal/pkg/warewulfd/warewulfd.go
Normal 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
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user