A bunch of changes including reworking the assets -> node API
This commit is contained in:
@@ -13,7 +13,7 @@ nodegroups:
|
||||
system overlay: test
|
||||
netdevs:
|
||||
eth0:
|
||||
hwaddr: xx:xx:xx:xx:aa
|
||||
hwaddr: xx:xx:xx:xx:xx:aa
|
||||
ipaddr: 192.168.1.1
|
||||
netmask: 255.255.255.0
|
||||
gateway: 192.168.1.1
|
||||
@@ -37,7 +37,7 @@ nodegroups:
|
||||
gateway: 192.168.1.1
|
||||
type: ethernet
|
||||
ib0:
|
||||
hwaddr: xx:xx:xx:xx:xx
|
||||
hwaddr: xx:xx:xx:xx:xx:xx
|
||||
ipaddr: x.x.x.x
|
||||
netmask: x.x.x.x
|
||||
gateway: x.x.x.x
|
||||
@@ -47,11 +47,11 @@ nodegroups:
|
||||
ipmi ipaddr: x.x.x.x
|
||||
netdevs:
|
||||
eth0:
|
||||
hwaddr: xx:xx:xx:xx:xx
|
||||
hwaddr: xx:xx:xx:xx:xx:xx
|
||||
ipaddr: 192.168.1.101
|
||||
netmask: 255.255.255.0
|
||||
gateway: 192.168.1.1
|
||||
ib0:
|
||||
hwaddr: xx:xx:xx:xx:xx
|
||||
hwaddr: xx:xx:xx:xx:xx:xx
|
||||
ipaddr: x.x.x.x
|
||||
netmask: x.x.x.x
|
||||
|
||||
@@ -2,8 +2,8 @@ package response
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/hpcng/warewulf/internal/pkg/assets"
|
||||
"github.com/hpcng/warewulf/internal/pkg/config"
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
"log"
|
||||
"net/http"
|
||||
@@ -26,13 +26,20 @@ type iPxeTemplate struct {
|
||||
func IpxeSend(w http.ResponseWriter, req *http.Request) {
|
||||
url := strings.Split(req.URL.Path, "/")
|
||||
|
||||
nodes, err := node.New()
|
||||
if err != nil {
|
||||
log.Printf("Could not read node configuration file: %s\n", err)
|
||||
w.WriteHeader(503)
|
||||
return
|
||||
}
|
||||
|
||||
if url[2] == "" {
|
||||
log.Printf("ERROR: Bad iPXE request from %s\n", req.RemoteAddr)
|
||||
return
|
||||
}
|
||||
|
||||
hwaddr := strings.ReplaceAll(url[2], "-", ":")
|
||||
node, err := assets.FindByHwaddr(hwaddr)
|
||||
node, err := nodes.FindByHwaddr(hwaddr)
|
||||
if err != nil {
|
||||
log.Printf("Could not find HW Addr: %s: %s\n", hwaddr, err)
|
||||
w.WriteHeader(404)
|
||||
|
||||
@@ -2,8 +2,8 @@ package response
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/hpcng/warewulf/internal/pkg/assets"
|
||||
"github.com/hpcng/warewulf/internal/pkg/config"
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"log"
|
||||
"net/http"
|
||||
"strconv"
|
||||
@@ -12,6 +12,12 @@ import (
|
||||
|
||||
func RuntimeOverlaySend(w http.ResponseWriter, req *http.Request) {
|
||||
config := config.New()
|
||||
nodes, err := node.New()
|
||||
if err != nil {
|
||||
log.Printf("Could not read node configuration file: %s\n", err)
|
||||
w.WriteHeader(503)
|
||||
return
|
||||
}
|
||||
|
||||
remote := strings.Split(req.RemoteAddr, ":")
|
||||
port, err := strconv.Atoi(remote[1])
|
||||
@@ -34,7 +40,7 @@ func RuntimeOverlaySend(w http.ResponseWriter, req *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
node, err := assets.FindByIpaddr(remote[0])
|
||||
node, err := nodes.FindByIpaddr(remote[0])
|
||||
if err != nil {
|
||||
fmt.Printf("Could not find node by IP address: %s\n", remote[0])
|
||||
w.WriteHeader(404)
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package response
|
||||
|
||||
import (
|
||||
"github.com/hpcng/warewulf/internal/pkg/assets"
|
||||
"fmt"
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"github.com/hpcng/warewulf/internal/pkg/errors"
|
||||
"io"
|
||||
"log"
|
||||
@@ -11,23 +12,29 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func getSanity(req *http.Request) (assets.NodeInfo, error) {
|
||||
func getSanity(req *http.Request) (node.NodeInfo, error) {
|
||||
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], "-", ":")
|
||||
node, err := assets.FindByHwaddr(hwaddr)
|
||||
ret, err = nodes.FindByHwaddr(hwaddr)
|
||||
if err != nil {
|
||||
return node, errors.New("Could not find node by HW address")
|
||||
return ret, errors.New("Could not find node by HW address")
|
||||
}
|
||||
|
||||
if node.Fqdn == "" {
|
||||
if ret.Fqdn == "" {
|
||||
log.Printf("UNKNOWN: %15s: %s\n", hwaddr, req.URL.Path)
|
||||
return node, errors.New("Unknown node HW address: " + hwaddr)
|
||||
return ret, errors.New("Unknown node HW address: " + hwaddr)
|
||||
} else {
|
||||
log.Printf("REQ: %15s: %s\n", node.Fqdn, req.URL.Path)
|
||||
log.Printf("REQ: %15s: %s\n", ret.Fqdn, req.URL.Path)
|
||||
}
|
||||
|
||||
return node, nil
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func sendFile(w http.ResponseWriter, filename string, sendto string) error {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package build
|
||||
|
||||
import (
|
||||
"github.com/hpcng/warewulf/internal/pkg/assets"
|
||||
"github.com/hpcng/warewulf/internal/pkg/kernel"
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"github.com/hpcng/warewulf/internal/pkg/overlay"
|
||||
"github.com/hpcng/warewulf/internal/pkg/vnfs"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
@@ -12,12 +12,18 @@ import (
|
||||
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
var nodes []assets.NodeInfo
|
||||
var nodes []node.NodeInfo
|
||||
showHelp := true
|
||||
|
||||
n, err := node.New()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not open node configuration: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if len(args) > 0 {
|
||||
var err error
|
||||
nodes, err = assets.SearchByName(args[0])
|
||||
nodes, err = n.SearchByName(args[0])
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not find nodes for search term: %s\n", args[0])
|
||||
os.Exit(1)
|
||||
@@ -25,7 +31,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
|
||||
} else {
|
||||
var err error
|
||||
nodes, err = assets.FindAllNodes()
|
||||
nodes, err = n.FindAllNodes()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not get list of nodes: %s\n", err)
|
||||
os.Exit(1)
|
||||
@@ -82,73 +88,3 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
func CobraRunEA(cmd *cobra.Command, args []string) error {
|
||||
var nodeList []assets.NodeInfo
|
||||
|
||||
if buildAll == true {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Building all components\n")
|
||||
buildVnfs = true
|
||||
buildKernel = true
|
||||
buildSystemOverlay = true;
|
||||
buildRuntimeOverlay = true;
|
||||
}
|
||||
|
||||
if len(args) >= 1 {
|
||||
nodeList, _ = assets.SearchByName(args[0])
|
||||
} else {
|
||||
nodeList, _ = assets.FindAllNodes()
|
||||
}
|
||||
|
||||
if len(nodeList) == 0 {
|
||||
wwlog.Printf(wwlog.ERROR, "No nodes found matching: '%s'\n", args[0])
|
||||
os.Exit(255)
|
||||
} else {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Found matching nodes for build: %d\n", len(nodeList))
|
||||
}
|
||||
|
||||
if buildVnfs == true {
|
||||
// wwlog.Printf(wwlog.INFO, "===============================================================================\n")
|
||||
|
||||
err := vnfs.Build(nodeList, buildForce)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(255)
|
||||
}
|
||||
}
|
||||
|
||||
if buildKernel == true {
|
||||
// wwlog.Printf(wwlog.INFO, "===============================================================================\n")
|
||||
|
||||
err := kernel.Build(nodeList, buildForce)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(255)
|
||||
}
|
||||
}
|
||||
|
||||
if buildSystemOverlay == true {
|
||||
// wwlog.Printf(wwlog.INFO, "===============================================================================\n")
|
||||
err := system_overlay.Build(nodeList, buildForce)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(255)
|
||||
}
|
||||
}
|
||||
|
||||
if buildRuntimeOverlay == true {
|
||||
// wwlog.Printf(wwlog.INFO, "===============================================================================\n")
|
||||
err := runtime_overlay.Build(nodeList, buildForce)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(255)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
*/
|
||||
@@ -1,20 +1,26 @@
|
||||
package build
|
||||
|
||||
import (
|
||||
"github.com/hpcng/warewulf/internal/pkg/assets"
|
||||
"github.com/hpcng/warewulf/internal/pkg/kernel"
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
"github.com/spf13/cobra"
|
||||
"os"
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
var nodes []assets.NodeInfo
|
||||
var nodes []node.NodeInfo
|
||||
set := make(map[string]int)
|
||||
|
||||
n, err := node.New()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not open node configuration: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if len(args) == 1 && ByNode == true {
|
||||
var err error
|
||||
nodes, err = assets.SearchByName(args[0])
|
||||
nodes, err = n.SearchByName(args[0])
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not find nodes for search term: %s\n", args[0])
|
||||
os.Exit(1)
|
||||
@@ -26,7 +32,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
|
||||
} else if BuildAll == true {
|
||||
var err error
|
||||
nodes, err = assets.FindAllNodes()
|
||||
nodes, err = n.FindAllNodes()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not get list of nodes: %s\n", err)
|
||||
os.Exit(1)
|
||||
|
||||
59
internal/app/wwctl/node/list/main.go
Normal file
59
internal/app/wwctl/node/list/main.go
Normal file
@@ -0,0 +1,59 @@
|
||||
package list
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
"github.com/spf13/cobra"
|
||||
"os"
|
||||
)
|
||||
|
||||
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
var err error
|
||||
var nodes []node.NodeInfo
|
||||
|
||||
n, err := node.New()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not open node configuration: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if len(args) > 0 {
|
||||
nodes, err = n.SearchByNameList(args)
|
||||
} else {
|
||||
nodes, err = n.FindAllNodes()
|
||||
}
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Cloud not get nodeList: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if ShowNet == true {
|
||||
fmt.Printf("%-22s %-10s %-20s %-16s %-16s %-16s %s\n", "NODE NAME", "DEVICE", "HWADDR", "IPADDR", "NETMASK", "GATEWAY", "TYPE")
|
||||
|
||||
for _, node := range nodes {
|
||||
for name, dev := range node.NetDevs {
|
||||
fmt.Printf("%-22s %-10s %-20s %-16s %-16s %-16s %s\n", node.Fqdn, name, dev.Hwaddr, dev.Ipaddr, dev.Netmask, dev.Gateway, dev.Type)
|
||||
}
|
||||
}
|
||||
|
||||
} else if ShowIpmi == true {
|
||||
fmt.Printf("%-22s %-16s %-20s %-20s\n", "NODE NAME", "IPMI IPADDR", "IPMI USERNAME", "IPMI PASSWORD")
|
||||
|
||||
for _, node := range nodes {
|
||||
fmt.Printf("%-22s %-16s %-20s %-20s\n", node.Fqdn, node.IpmiIpaddr, node.IpmiUserName, node.IpmiPassword)
|
||||
}
|
||||
|
||||
} else {
|
||||
fmt.Printf("%-22s %-30s %-30s %-16s %-16s\n", "NODE NAME", "KERNEL NAME", "VNFS IMAGE", "SYSTEM OVERLAY", "RUNTIME OVERLAY")
|
||||
|
||||
for _, node := range nodes {
|
||||
fmt.Printf("%-22s %-30s %-30s %-16s %-16s\n", node.Fqdn, node.KernelVersion, node.Vnfs, node.SystemOverlay, node.RuntimeOverlay)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return nil
|
||||
}
|
||||
25
internal/app/wwctl/node/list/root.go
Normal file
25
internal/app/wwctl/node/list/root.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package list
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
var (
|
||||
baseCmd = &cobra.Command{
|
||||
Use: "list",
|
||||
Short: "List all nodes",
|
||||
Long: "List all nodes",
|
||||
RunE: CobraRunE,
|
||||
}
|
||||
ShowNet bool
|
||||
ShowIpmi bool
|
||||
)
|
||||
|
||||
func init() {
|
||||
baseCmd.PersistentFlags().BoolVarP(&ShowNet, "net", "n", false, "Show node network configurations")
|
||||
baseCmd.PersistentFlags().BoolVarP(&ShowIpmi, "ipmi", "i", false, "Show node IPMI configurations")
|
||||
|
||||
}
|
||||
|
||||
// GetRootCommand returns the root cobra.Command for the application.
|
||||
func GetCommand() *cobra.Command {
|
||||
return baseCmd
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package poweroff
|
||||
|
||||
import (
|
||||
"github.com/hpcng/warewulf/internal/pkg/assets"
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"github.com/hpcng/warewulf/internal/pkg/power"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
"github.com/spf13/cobra"
|
||||
@@ -9,14 +9,17 @@ import (
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
|
||||
var returnErr error = nil
|
||||
var nodeList []node.NodeInfo
|
||||
|
||||
var nodeList []assets.NodeInfo
|
||||
n, err := node.New()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not open node configuration: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if len(args) >= 1 {
|
||||
//nodeList, _ = assets.SearchByName(args[0])
|
||||
nodeList, _ = assets.SearchByNameList(args)
|
||||
nodeList, _ = n.SearchByNameList(args)
|
||||
} else {
|
||||
wwlog.Printf(wwlog.ERROR, "No requested nodes\n")
|
||||
os.Exit(255)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package poweron
|
||||
|
||||
import (
|
||||
"github.com/hpcng/warewulf/internal/pkg/assets"
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"github.com/hpcng/warewulf/internal/pkg/power"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
"github.com/spf13/cobra"
|
||||
@@ -9,14 +9,17 @@ import (
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
|
||||
var returnErr error = nil
|
||||
var nodeList []node.NodeInfo
|
||||
|
||||
var nodeList []assets.NodeInfo
|
||||
n, err := node.New()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not open node configuration: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if len(args) >= 1 {
|
||||
//nodeList, _ = assets.SearchByName(args[0])
|
||||
nodeList, _ = assets.SearchByNameList(args)
|
||||
nodeList, _ = n.SearchByNameList(args)
|
||||
} else {
|
||||
wwlog.Printf(wwlog.ERROR, "No requested nodes\n")
|
||||
os.Exit(255)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package powerstatus
|
||||
|
||||
import (
|
||||
"github.com/hpcng/warewulf/internal/pkg/assets"
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"github.com/hpcng/warewulf/internal/pkg/power"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
"github.com/spf13/cobra"
|
||||
@@ -9,14 +9,17 @@ import (
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
|
||||
var returnErr error = nil
|
||||
var nodeList []node.NodeInfo
|
||||
|
||||
var nodeList []assets.NodeInfo
|
||||
n, err := node.New()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not open node configuration: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if len(args) >= 1 {
|
||||
//nodeList, _ = assets.SearchByName(args[0])
|
||||
nodeList, _ = assets.SearchByNameList(args)
|
||||
nodeList, _ = n.SearchByNameList(args)
|
||||
} else {
|
||||
wwlog.Printf(wwlog.ERROR, "No requested nodes\n")
|
||||
os.Exit(255)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/node/list"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/node/poweron"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/node/poweroff"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/node/powerstatus"
|
||||
@@ -19,6 +20,8 @@ func init() {
|
||||
baseCmd.AddCommand(poweron.GetCommand())
|
||||
baseCmd.AddCommand(poweroff.GetCommand())
|
||||
baseCmd.AddCommand(powerstatus.GetCommand())
|
||||
baseCmd.AddCommand(list.GetCommand())
|
||||
|
||||
}
|
||||
|
||||
// GetRootCommand returns the root cobra.Command for the application.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package build
|
||||
|
||||
import (
|
||||
"github.com/hpcng/warewulf/internal/pkg/assets"
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"github.com/hpcng/warewulf/internal/pkg/overlay"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
"github.com/spf13/cobra"
|
||||
@@ -9,10 +9,16 @@ import (
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
var updateNodes []assets.NodeInfo
|
||||
var updateNodes []node.NodeInfo
|
||||
|
||||
n, err := node.New()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not open node configuration: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if len(args) > 0 && BuildAll == false {
|
||||
nodes, err := assets.FindAllNodes()
|
||||
nodes, err := n.FindAllNodes()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Cloud not get nodeList: %s\n", err)
|
||||
os.Exit(1)
|
||||
@@ -27,7 +33,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
} else {
|
||||
var err error
|
||||
updateNodes, err = assets.FindAllNodes()
|
||||
updateNodes, err = n.FindAllNodes()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Cloud not get nodeList: %s\n", err)
|
||||
os.Exit(1)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package chmod
|
||||
|
||||
import (
|
||||
"github.com/hpcng/warewulf/internal/pkg/assets"
|
||||
"github.com/hpcng/warewulf/internal/pkg/config"
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"github.com/hpcng/warewulf/internal/pkg/overlay"
|
||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
@@ -49,13 +49,19 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
if NoOverlayUpdate == false {
|
||||
nodes, err := assets.FindAllNodes()
|
||||
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, "Cloud not get nodeList: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
var updateNodes []assets.NodeInfo
|
||||
var updateNodes []node.NodeInfo
|
||||
|
||||
for _, node := range nodes {
|
||||
if SystemOverlay == true && node.SystemOverlay == overlayName {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package create
|
||||
|
||||
import (
|
||||
"github.com/hpcng/warewulf/internal/pkg/assets"
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"github.com/hpcng/warewulf/internal/pkg/overlay"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
"github.com/spf13/cobra"
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
|
||||
if len(args) < 1 {
|
||||
cmd.Help()
|
||||
os.Exit(1)
|
||||
@@ -34,13 +33,19 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
if NoOverlayUpdate == false {
|
||||
nodes, err := assets.FindAllNodes()
|
||||
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, "Cloud not get nodeList: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
var updateNodes []assets.NodeInfo
|
||||
var updateNodes []node.NodeInfo
|
||||
|
||||
for _, node := range nodes {
|
||||
if SystemOverlay == true && node.SystemOverlay == args[0] {
|
||||
|
||||
@@ -2,8 +2,8 @@ package delete
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/hpcng/warewulf/internal/pkg/assets"
|
||||
"github.com/hpcng/warewulf/internal/pkg/config"
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"github.com/hpcng/warewulf/internal/pkg/overlay"
|
||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
@@ -95,13 +95,19 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
if NoOverlayUpdate == false {
|
||||
nodes, err := assets.FindAllNodes()
|
||||
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, "Cloud not get nodeList: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
var updateNodes []assets.NodeInfo
|
||||
var updateNodes []node.NodeInfo
|
||||
|
||||
for _, node := range nodes {
|
||||
if SystemOverlay == true && node.SystemOverlay == args[0] {
|
||||
|
||||
@@ -2,8 +2,8 @@ package edit
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/hpcng/warewulf/internal/pkg/assets"
|
||||
"github.com/hpcng/warewulf/internal/pkg/config"
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"github.com/hpcng/warewulf/internal/pkg/overlay"
|
||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
@@ -93,13 +93,19 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
if NoOverlayUpdate == false {
|
||||
nodes, err := assets.FindAllNodes()
|
||||
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, "Cloud not get nodeList: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
var updateNodes []assets.NodeInfo
|
||||
var updateNodes []node.NodeInfo
|
||||
|
||||
for _, node := range nodes {
|
||||
if SystemOverlay == true && node.SystemOverlay == args[0] {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package imprt
|
||||
|
||||
import (
|
||||
"github.com/hpcng/warewulf/internal/pkg/assets"
|
||||
"github.com/hpcng/warewulf/internal/pkg/config"
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"github.com/hpcng/warewulf/internal/pkg/overlay"
|
||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
@@ -45,13 +45,19 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
if NoOverlayUpdate == false {
|
||||
nodes, err := assets.FindAllNodes()
|
||||
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, "Cloud not get nodeList: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
var updateNodes []assets.NodeInfo
|
||||
var updateNodes []node.NodeInfo
|
||||
|
||||
for _, node := range nodes {
|
||||
if SystemOverlay == true && node.SystemOverlay == overlayName {
|
||||
|
||||
@@ -2,8 +2,8 @@ package list
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/hpcng/warewulf/internal/pkg/assets"
|
||||
"github.com/hpcng/warewulf/internal/pkg/config"
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"github.com/hpcng/warewulf/internal/pkg/overlay"
|
||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
@@ -17,7 +17,13 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
set := make(map[string]int)
|
||||
var o []string
|
||||
var err error
|
||||
var nodeList []assets.NodeInfo
|
||||
var nodeList []node.NodeInfo
|
||||
|
||||
n, err := node.New()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not open node configuration: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if SystemOverlay == true {
|
||||
if ListLong == false {
|
||||
@@ -39,7 +45,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
nodeList, err = assets.FindAllNodes()
|
||||
nodeList, err = n.FindAllNodes()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not get node configuration: %s\n", err)
|
||||
return err
|
||||
|
||||
@@ -2,8 +2,8 @@ package mkdir
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/hpcng/warewulf/internal/pkg/assets"
|
||||
"github.com/hpcng/warewulf/internal/pkg/config"
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"github.com/hpcng/warewulf/internal/pkg/overlay"
|
||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
@@ -42,13 +42,19 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
fmt.Printf("Created directory within overlay: %s:%s\n", args[0], args[1])
|
||||
|
||||
if NoOverlayUpdate == false {
|
||||
nodes, err := assets.FindAllNodes()
|
||||
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, "Cloud not get nodeList: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
var updateNodes []assets.NodeInfo
|
||||
var updateNodes []node.NodeInfo
|
||||
|
||||
for _, node := range nodes {
|
||||
if SystemOverlay == true && node.SystemOverlay == args[0] {
|
||||
|
||||
@@ -2,7 +2,7 @@ package build
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/hpcng/warewulf/internal/pkg/assets"
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"github.com/hpcng/warewulf/internal/pkg/vnfs"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
"github.com/spf13/cobra"
|
||||
@@ -10,12 +10,18 @@ import (
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
var nodes []assets.NodeInfo
|
||||
var nodes []node.NodeInfo
|
||||
set := make(map[string]int)
|
||||
|
||||
n, err := node.New()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not open node configuration: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if len(args) == 1 && ByNode == true {
|
||||
var err error
|
||||
nodes, err = assets.SearchByName(args[0])
|
||||
nodes, err = n.SearchByName(args[0])
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not find nodes for search term: %s\n", args[0])
|
||||
os.Exit(1)
|
||||
@@ -27,7 +33,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
|
||||
} else if BuildAll == true {
|
||||
var err error
|
||||
nodes, err = assets.FindAllNodes()
|
||||
nodes, err = n.FindAllNodes()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not get list of nodes: %s\n", err)
|
||||
os.Exit(1)
|
||||
|
||||
27
internal/app/wwctl/vnfs/list/main.go
Normal file
27
internal/app/wwctl/vnfs/list/main.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package list
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/hpcng/warewulf/internal/pkg/config"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
"github.com/spf13/cobra"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
config := config.New()
|
||||
|
||||
files, err := ioutil.ReadDir(config.VnfsImageParentDir())
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
for _, f := range files {
|
||||
fmt.Println(f.Name())
|
||||
}
|
||||
|
||||
fmt.Printf("VNFS LIST: work in progress: %s\n", config.VnfsImageParentDir())
|
||||
return nil
|
||||
}
|
||||
25
internal/app/wwctl/vnfs/list/root.go
Normal file
25
internal/app/wwctl/vnfs/list/root.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package list
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
var (
|
||||
baseCmd = &cobra.Command{
|
||||
Use: "list",
|
||||
Short: "List VNFS images",
|
||||
Long: "List VNFS images ",
|
||||
RunE: CobraRunE,
|
||||
}
|
||||
SystemOverlay bool
|
||||
BuildAll bool
|
||||
)
|
||||
|
||||
func init() {
|
||||
baseCmd.PersistentFlags().BoolVarP(&SystemOverlay, "system", "s", false, "Show System Overlays as well")
|
||||
baseCmd.PersistentFlags().BoolVarP(&BuildAll, "all", "a", false, "Build all overlays (runtime and system)")
|
||||
|
||||
}
|
||||
|
||||
// GetRootCommand returns the root cobra.Command for the application.
|
||||
func GetCommand() *cobra.Command {
|
||||
return baseCmd
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package vnfs
|
||||
|
||||
import (
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/vnfs/build"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/vnfs/list"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@@ -16,7 +17,7 @@ var (
|
||||
|
||||
func init() {
|
||||
baseCmd.AddCommand(build.GetCommand())
|
||||
|
||||
baseCmd.AddCommand(list.GetCommand())
|
||||
}
|
||||
|
||||
// GetRootCommand returns the root cobra.Command for the application.
|
||||
|
||||
@@ -84,6 +84,14 @@ func (self *Config) RuntimeOverlayDir() string {
|
||||
return path.Join(self.OverlayDir(), "/runtime")
|
||||
}
|
||||
|
||||
func (self *Config) VnfsImageParentDir() string {
|
||||
return fmt.Sprintf("%s/provision/vnfs/", self.LocalStateDir)
|
||||
}
|
||||
|
||||
func (self *Config) VnfsChrootParentDir() string {
|
||||
return fmt.Sprintf("%s/chroot/", self.LocalStateDir)
|
||||
}
|
||||
|
||||
func (self *Config) SystemOverlaySource(overlayName string) string {
|
||||
if overlayName == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "System overlay name is not defined\n")
|
||||
@@ -141,20 +149,6 @@ func (self *Config) KmodsImage(kernelVersion string) string {
|
||||
return fmt.Sprintf("%s/provision/kernel/kmods-%s.img", self.LocalStateDir, kernelVersion)
|
||||
}
|
||||
|
||||
func (self *Config) VnfsImage(vnfsNameClean string) string {
|
||||
if vnfsNameClean == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "VNFS name is not defined\n")
|
||||
return ""
|
||||
}
|
||||
|
||||
if util.TaintCheck(vnfsNameClean, "^[a-zA-Z0-9-._:]+$") == false {
|
||||
wwlog.Printf(wwlog.ERROR, "Runtime overlay name contains illegal characters: %s\n", vnfsNameClean)
|
||||
return ""
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s/provision/vnfs/%s.img.gz", self.LocalStateDir, vnfsNameClean)
|
||||
}
|
||||
|
||||
func (self *Config) SystemOverlayImage(nodeName string) string {
|
||||
if nodeName == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "Node name is not defined\n")
|
||||
@@ -183,6 +177,21 @@ func (self *Config) RuntimeOverlayImage(nodeName string) string {
|
||||
return fmt.Sprintf("%s/provision/overlays/runtime/%s.img", self.LocalStateDir, nodeName)
|
||||
}
|
||||
|
||||
|
||||
func (self *Config) VnfsImage(vnfsNameClean string) string {
|
||||
if vnfsNameClean == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "VNFS name is not defined\n")
|
||||
return ""
|
||||
}
|
||||
|
||||
if util.TaintCheck(vnfsNameClean, "^[a-zA-Z0-9-._:]+$") == false {
|
||||
wwlog.Printf(wwlog.ERROR, "Runtime overlay name contains illegal characters: %s\n", vnfsNameClean)
|
||||
return ""
|
||||
}
|
||||
|
||||
return path.Join(self.VnfsImageParentDir(), vnfsNameClean)
|
||||
}
|
||||
|
||||
func (self *Config) VnfsChroot(vnfsNameClean string) string {
|
||||
if vnfsNameClean == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "VNFS name is not defined\n")
|
||||
@@ -194,6 +203,6 @@ func (self *Config) VnfsChroot(vnfsNameClean string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s/chroot/%s.img", self.LocalStateDir, vnfsNameClean)
|
||||
return path.Join(self.VnfsChrootParentDir(), vnfsNameClean)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
package assets
|
||||
package node
|
||||
|
||||
import (
|
||||
"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/vnfs"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
"gopkg.in/yaml.v2"
|
||||
"io/ioutil"
|
||||
// "os"
|
||||
|
||||
// "os"
|
||||
"regexp"
|
||||
|
||||
"github.com/hpcng/warewulf/internal/pkg/errors"
|
||||
)
|
||||
|
||||
const ConfigFile = "/etc/warewulf/nodes.conf"
|
||||
@@ -50,6 +46,8 @@ type nodeEntry struct {
|
||||
KernelVersion string `yaml:"kernel version"`
|
||||
KernelArgs string `yaml:"kernel args"`
|
||||
IpmiIpaddr string `yaml:"ipmi ipaddr"`
|
||||
IpmiUserName string `yaml:"ipmi username"`
|
||||
IpmiPassword string `yaml:"ipmi password"`
|
||||
NetDevs map[string]netDevs
|
||||
}
|
||||
|
||||
@@ -74,25 +72,32 @@ type NodeInfo struct {
|
||||
KernelVersion string
|
||||
KernelArgs string
|
||||
IpmiIpaddr string
|
||||
IpmiUserName string
|
||||
IpmiPassword string
|
||||
NetDevs map[string]netDevs
|
||||
}
|
||||
|
||||
func FindAllNodes() ([]NodeInfo, error) {
|
||||
var c nodeYaml
|
||||
var ret []NodeInfo
|
||||
config := config.New()
|
||||
type nodeInfoContainer struct {
|
||||
Nodes []NodeInfo
|
||||
}
|
||||
|
||||
|
||||
func New() (nodeInfoContainer, error) {
|
||||
var c nodeYaml
|
||||
var ret nodeInfoContainer
|
||||
|
||||
config := config.New()
|
||||
|
||||
wwlog.Printf(wwlog.DEBUG, "Opening configuration file: %s\n", ConfigFile)
|
||||
data, err := ioutil.ReadFile(ConfigFile)
|
||||
if err != nil {
|
||||
fmt.Printf("error reading node configuration file\n")
|
||||
return nil, err
|
||||
return ret, err
|
||||
}
|
||||
|
||||
err = yaml.Unmarshal(data, &c)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return ret, err
|
||||
}
|
||||
|
||||
for groupname, group := range c.NodeGroups {
|
||||
@@ -102,6 +107,8 @@ func FindAllNodes() ([]NodeInfo, error) {
|
||||
n.GroupName = groupname
|
||||
n.HostName = node.Hostname
|
||||
n.IpmiIpaddr = node.IpmiIpaddr
|
||||
n.IpmiUserName = node.IpmiUserName
|
||||
n.IpmiPassword = node.IpmiPassword
|
||||
|
||||
n.Vnfs = group.Vnfs
|
||||
n.SystemOverlay = group.SystemOverlay
|
||||
@@ -161,7 +168,7 @@ func FindAllNodes() ([]NodeInfo, error) {
|
||||
v := vnfs.New(n.Vnfs)
|
||||
n.VnfsDir = config.VnfsChroot(v.NameClean())
|
||||
|
||||
ret = append(ret, n)
|
||||
ret.Nodes = append(ret.Nodes, n)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,15 +176,17 @@ func FindAllNodes() ([]NodeInfo, error) {
|
||||
}
|
||||
|
||||
|
||||
func FindByHwaddr(hwa string) (NodeInfo, error) {
|
||||
|
||||
|
||||
func (nodes *nodeInfoContainer) FindAllNodes() ([]NodeInfo, error) {
|
||||
return nodes.Nodes, nil
|
||||
}
|
||||
|
||||
|
||||
func (nodes *nodeInfoContainer) FindByHwaddr(hwa string) (NodeInfo, error) {
|
||||
var ret NodeInfo
|
||||
|
||||
nodeList, err := FindAllNodes()
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
|
||||
for _, node := range nodeList {
|
||||
for _, node := range nodes.Nodes {
|
||||
for _, dev := range node.NetDevs {
|
||||
if dev.Hwaddr == hwa {
|
||||
return node, nil
|
||||
@@ -188,15 +197,10 @@ func FindByHwaddr(hwa string) (NodeInfo, error) {
|
||||
return ret, errors.New("No nodes found with HW Addr: " + hwa)
|
||||
}
|
||||
|
||||
func FindByIpaddr(ipaddr string) (NodeInfo, error) {
|
||||
func (nodes *nodeInfoContainer) FindByIpaddr(ipaddr string) (NodeInfo, error) {
|
||||
var ret NodeInfo
|
||||
|
||||
nodeList, err := FindAllNodes()
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
|
||||
for _, node := range nodeList {
|
||||
for _, node := range nodes.Nodes {
|
||||
for _, dev := range node.NetDevs {
|
||||
if dev.Ipaddr == ipaddr {
|
||||
return node, nil
|
||||
@@ -207,15 +211,10 @@ func FindByIpaddr(ipaddr string) (NodeInfo, error) {
|
||||
return ret, errors.New("No nodes found with IP Addr: " + ipaddr)
|
||||
}
|
||||
|
||||
func SearchByName(search string) ([]NodeInfo, error) {
|
||||
func (nodes *nodeInfoContainer) SearchByName(search string) ([]NodeInfo, error) {
|
||||
var ret []NodeInfo
|
||||
|
||||
nodeList, err := FindAllNodes()
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
|
||||
for _, node := range nodeList {
|
||||
for _, node := range nodes.Nodes {
|
||||
b, _ := regexp.MatchString(search, node.Fqdn)
|
||||
if b == true {
|
||||
ret = append(ret, node)
|
||||
@@ -225,16 +224,11 @@ func SearchByName(search string) ([]NodeInfo, error) {
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func SearchByNameList(searchList []string) ([]NodeInfo, error) {
|
||||
func (nodes *nodeInfoContainer) SearchByNameList(searchList []string) ([]NodeInfo, error) {
|
||||
var ret []NodeInfo
|
||||
|
||||
nodeList, err := FindAllNodes()
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
|
||||
for _, search := range searchList {
|
||||
for _, node := range nodeList {
|
||||
for _, node := range nodes.Nodes {
|
||||
b, _ := regexp.MatchString(search, node.Fqdn)
|
||||
if b == true {
|
||||
ret = append(ret, node)
|
||||
@@ -244,94 +238,3 @@ func SearchByNameList(searchList []string) ([]NodeInfo, error) {
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
/*
|
||||
func FindAllVnfs() ([]string, error) {
|
||||
var ret []string
|
||||
set := make(map[string]bool)
|
||||
|
||||
nodeList, err := FindAllNodes()
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
|
||||
for _, node := range nodeList {
|
||||
if node.Vnfs != "" {
|
||||
set[node.Vnfs] = true
|
||||
}
|
||||
}
|
||||
|
||||
for entry := range set {
|
||||
ret = append(ret, entry)
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func FindAllKernels() ([]string, error) {
|
||||
var ret []string
|
||||
set := make(map[string]bool)
|
||||
|
||||
nodeList, err := FindAllNodes()
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
|
||||
for _, node := range nodeList {
|
||||
if node.KernelVersion != "" {
|
||||
set[node.KernelVersion] = true
|
||||
}
|
||||
}
|
||||
|
||||
for entry := range set {
|
||||
ret = append(ret, entry)
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func ListSystemOverlays() ([]string, error) {
|
||||
var ret []string
|
||||
set := make(map[string]bool)
|
||||
|
||||
nodeList, err := FindAllNodes()
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
|
||||
for _, node := range nodeList {
|
||||
if node.SystemOverlay != "" {
|
||||
set[node.SystemOverlay] = true
|
||||
}
|
||||
}
|
||||
|
||||
for entry := range set {
|
||||
ret = append(ret, entry)
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func ListRuntimeOverlays() ([]string, error) {
|
||||
var ret []string
|
||||
set := make(map[string]bool)
|
||||
|
||||
nodeList, err := FindAllNodes()
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
|
||||
for _, node := range nodeList {
|
||||
if node.RuntimeOverlay != "" {
|
||||
set[node.RuntimeOverlay] = true
|
||||
}
|
||||
}
|
||||
|
||||
for entry := range set {
|
||||
ret = append(ret, entry)
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
*/
|
||||
@@ -2,9 +2,9 @@ package overlay
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/hpcng/warewulf/internal/pkg/assets"
|
||||
"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"
|
||||
@@ -53,7 +53,7 @@ func RuntimeOverlayInit(name string) error {
|
||||
}
|
||||
|
||||
|
||||
func RuntimeBuild(nodeList []assets.NodeInfo, force bool) error {
|
||||
func RuntimeBuild(nodeList []node.NodeInfo, force bool) error {
|
||||
config := config.New()
|
||||
|
||||
wwlog.SetIndent(4)
|
||||
|
||||
@@ -2,9 +2,9 @@ package overlay
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/hpcng/warewulf/internal/pkg/assets"
|
||||
"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"
|
||||
@@ -53,7 +53,7 @@ func SystemOverlayInit(name string) error {
|
||||
}
|
||||
|
||||
|
||||
func SystemBuild(nodeList []assets.NodeInfo, force bool) error {
|
||||
func SystemBuild(nodeList []node.NodeInfo, force bool) error {
|
||||
config := config.New()
|
||||
|
||||
wwlog.SetIndent(4)
|
||||
|
||||
Reference in New Issue
Block a user