Fixes for new API
This commit is contained in:
@@ -2,8 +2,8 @@ package response
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/hpcng/warewulf/internal/pkg/config"
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
"log"
|
||||
"net/http"
|
||||
@@ -13,16 +13,15 @@ import (
|
||||
)
|
||||
|
||||
type iPxeTemplate struct {
|
||||
Hostname string
|
||||
Fqdn string
|
||||
Vnfs string
|
||||
Hwaddr string
|
||||
Ipaddr string
|
||||
Port string
|
||||
Kernelargs string
|
||||
Hostname string
|
||||
Fqdn string
|
||||
Vnfs string
|
||||
Hwaddr string
|
||||
Ipaddr string
|
||||
Port string
|
||||
Kernelargs string
|
||||
}
|
||||
|
||||
|
||||
func IpxeSend(w http.ResponseWriter, req *http.Request) {
|
||||
url := strings.Split(req.URL.Path, "/")
|
||||
|
||||
@@ -47,9 +46,13 @@ func IpxeSend(w http.ResponseWriter, req *http.Request) {
|
||||
}
|
||||
|
||||
if node.Id.Defined() == true {
|
||||
conf := config.New()
|
||||
conf, err := warewulfconf.New()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
log.Printf("IPXE: %15s: %s\n", node.Fqdn.Get(), req.URL.Path)
|
||||
log.Printf("IPXE: %15s: %s\n", node.Id.Get(), req.URL.Path)
|
||||
|
||||
// TODO: Fix template path to use config package
|
||||
ipxeTemplate := fmt.Sprintf("/etc/warewulf/ipxe/%s.ipxe", node.Ipxe.Get())
|
||||
@@ -62,10 +65,10 @@ func IpxeSend(w http.ResponseWriter, req *http.Request) {
|
||||
|
||||
var replace iPxeTemplate
|
||||
|
||||
replace.Fqdn = node.Fqdn.Get()
|
||||
replace.Fqdn = node.Id.Get()
|
||||
replace.Ipaddr = conf.Ipaddr
|
||||
replace.Port = strconv.Itoa(conf.Port)
|
||||
replace.Hostname = node.HostName.Get()
|
||||
replace.Port = strconv.Itoa(conf.Warewulf.Port)
|
||||
replace.Hostname = node.Id.Get()
|
||||
replace.Hwaddr = url[2]
|
||||
replace.Vnfs = node.Vnfs.Get()
|
||||
replace.Kernelargs = node.KernelArgs.Get()
|
||||
@@ -76,7 +79,7 @@ func IpxeSend(w http.ResponseWriter, req *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
log.Printf("SEND: %15s: %s\n", node.Fqdn.Get(), ipxeTemplate)
|
||||
log.Printf("SEND: %15s: %s\n", node.Id.Get(), ipxeTemplate)
|
||||
|
||||
} else {
|
||||
log.Printf("ERROR: iPXE request from unknown Node (hwaddr=%s)\n", url[2])
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
)
|
||||
|
||||
func KernelSend(w http.ResponseWriter, req *http.Request) {
|
||||
config := config.New()
|
||||
|
||||
node, err := getSanity(req)
|
||||
if err != nil {
|
||||
@@ -19,16 +18,16 @@ func KernelSend(w http.ResponseWriter, req *http.Request) {
|
||||
if node.KernelVersion.Defined() == true {
|
||||
fileName := config.KernelImage(node.KernelVersion.Get())
|
||||
|
||||
err := sendFile(w, fileName, node.Fqdn.Get())
|
||||
err := sendFile(w, fileName, node.Id.Get())
|
||||
if err != nil {
|
||||
log.Printf("ERROR: %s\n", err)
|
||||
} else {
|
||||
log.Printf("SEND: %15s: %s\n", node.Fqdn.Get(), fileName)
|
||||
log.Printf("SEND: %15s: %s\n", node.Id.Get(), fileName)
|
||||
}
|
||||
|
||||
} else {
|
||||
w.WriteHeader(503)
|
||||
log.Printf("ERROR: No 'kernel version' set for node %s\n", node.Fqdn.Get())
|
||||
log.Printf("ERROR: No 'kernel version' set for node %s\n", node.Id.Get())
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
)
|
||||
|
||||
func KmodsSend(w http.ResponseWriter, req *http.Request) {
|
||||
config := config.New()
|
||||
|
||||
node, err := getSanity(req)
|
||||
if err != nil {
|
||||
@@ -19,16 +18,16 @@ func KmodsSend(w http.ResponseWriter, req *http.Request) {
|
||||
if node.KernelVersion.Defined() == true {
|
||||
fileName := config.KmodsImage(node.KernelVersion.Get())
|
||||
|
||||
err := sendFile(w, fileName, node.Fqdn.Get())
|
||||
err := sendFile(w, fileName, node.Id.Get())
|
||||
if err != nil {
|
||||
log.Printf("ERROR: %s\n", err)
|
||||
} else {
|
||||
log.Printf("SEND: %15s: %s\n", node.Fqdn.Get(), fileName)
|
||||
log.Printf("SEND: %15s: %s\n", node.Id.Get(), fileName)
|
||||
}
|
||||
|
||||
} else {
|
||||
w.WriteHeader(503)
|
||||
log.Printf("ERROR: No 'kernel version' set for node %s\n", node.Fqdn.Get())
|
||||
log.Printf("ERROR: No 'kernel version' set for node %s\n", node.Id.Get())
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"github.com/hpcng/warewulf/internal/pkg/config"
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
|
||||
"log"
|
||||
"net/http"
|
||||
"strconv"
|
||||
@@ -11,7 +12,13 @@ import (
|
||||
)
|
||||
|
||||
func RuntimeOverlaySend(w http.ResponseWriter, req *http.Request) {
|
||||
config := config.New()
|
||||
conf, err := warewulfconf.New()
|
||||
if err != nil {
|
||||
log.Printf("Could not read Warewulf configuration file: %s\n", err)
|
||||
w.WriteHeader(503)
|
||||
return
|
||||
}
|
||||
|
||||
nodes, err := node.New()
|
||||
if err != nil {
|
||||
log.Printf("Could not read node configuration file: %s\n", err)
|
||||
@@ -32,7 +39,7 @@ func RuntimeOverlaySend(w http.ResponseWriter, req *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if config.InsecureRuntime == false {
|
||||
if conf.Warewulf.Secure == true {
|
||||
if port >= 1024 {
|
||||
log.Panicf("DENIED: Connection coming from non-privledged port: %s\n", req.RemoteAddr)
|
||||
w.WriteHeader(401)
|
||||
@@ -52,21 +59,21 @@ func RuntimeOverlaySend(w http.ResponseWriter, req *http.Request) {
|
||||
w.WriteHeader(404)
|
||||
return
|
||||
} else {
|
||||
log.Printf("REQ: %15s: %s\n", node.Fqdn.Get(), req.URL.Path)
|
||||
log.Printf("REQ: %15s: %s\n", node.Id.Get(), req.URL.Path)
|
||||
}
|
||||
|
||||
if node.RuntimeOverlay.Defined() == true {
|
||||
fileName := config.RuntimeOverlayImage(node.Fqdn.Get())
|
||||
fileName := config.RuntimeOverlayImage(node.Id.Get())
|
||||
|
||||
err := sendFile(w, fileName, node.Fqdn.Get())
|
||||
err := sendFile(w, fileName, node.Id.Get())
|
||||
if err != nil {
|
||||
log.Printf("ERROR: %s\n", err)
|
||||
} else {
|
||||
log.Printf("SEND: %15s: %s\n", node.Fqdn.Get(), fileName)
|
||||
log.Printf("SEND: %15s: %s\n", node.Id.Get(), fileName)
|
||||
}
|
||||
} else {
|
||||
w.WriteHeader(503)
|
||||
log.Printf("ERROR: No 'runtime system-overlay' set for node %s\n", node.Fqdn.Get())
|
||||
log.Printf("ERROR: No 'runtime system-overlay' set for node %s\n", node.Id.Get())
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
@@ -7,8 +7,6 @@ import (
|
||||
)
|
||||
|
||||
func SystemOverlaySend(w http.ResponseWriter, req *http.Request) {
|
||||
config := config.New()
|
||||
|
||||
node, err := getSanity(req)
|
||||
if err != nil {
|
||||
w.WriteHeader(404)
|
||||
@@ -17,17 +15,17 @@ func SystemOverlaySend(w http.ResponseWriter, req *http.Request) {
|
||||
}
|
||||
|
||||
if node.SystemOverlay.Defined() == true {
|
||||
fileName := config.SystemOverlayImage(node.Fqdn.Get())
|
||||
fileName := config.SystemOverlayImage(node.Id.Get())
|
||||
|
||||
err := sendFile(w, fileName, node.Fqdn.Get())
|
||||
err := sendFile(w, fileName, node.Id.Get())
|
||||
if err != nil {
|
||||
log.Printf("ERROR: %s\n", err)
|
||||
} else {
|
||||
log.Printf("SEND: %15s: %s\n", node.Fqdn.Get(), fileName)
|
||||
log.Printf("SEND: %15s: %s\n", node.Id.Get(), fileName)
|
||||
}
|
||||
} else {
|
||||
w.WriteHeader(503)
|
||||
log.Printf("ERROR: No 'system system-overlay' set for node %s\n", node.Fqdn.Get())
|
||||
log.Printf("ERROR: No 'system system-overlay' set for node %s\n", node.Id.Get())
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
@@ -27,12 +27,7 @@ func getSanity(req *http.Request) (node.NodeInfo, error) {
|
||||
return ret, errors.New("Could not find node by HW address")
|
||||
}
|
||||
|
||||
if ret.Fqdn.Defined() == false {
|
||||
log.Printf("UNKNOWN: %15s: %s\n", hwaddr, req.URL.Path)
|
||||
return ret, errors.New("Unknown node HW address: " + hwaddr)
|
||||
} else {
|
||||
log.Printf("REQ: %15s: %s\n", ret.Fqdn.Get(), req.URL.Path)
|
||||
}
|
||||
log.Printf("REQ: %15s: %s\n", ret.Id.Get(), req.URL.Path)
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
@@ -20,19 +20,19 @@ func VnfsSend(w http.ResponseWriter, req *http.Request) {
|
||||
v, err := vnfs.Load(node.Vnfs.Get())
|
||||
if err != nil {
|
||||
w.WriteHeader(503)
|
||||
log.Printf("ERROR: Could not load VNFS: %s\n", node.Fqdn.Get())
|
||||
log.Printf("ERROR: Could not load VNFS: %s\n", node.Id.Get())
|
||||
return
|
||||
}
|
||||
|
||||
err = sendFile(w, v.Image, node.Fqdn.Get())
|
||||
err = sendFile(w, v.Image, node.Id.Get())
|
||||
if err != nil {
|
||||
log.Printf("ERROR1: %s\n", err)
|
||||
} else {
|
||||
log.Printf("SEND: %15s: %s\n", node.Fqdn.Get(), v.Image)
|
||||
log.Printf("SEND: %15s: %s\n", node.Id.Get(), v.Image)
|
||||
}
|
||||
} else {
|
||||
w.WriteHeader(503)
|
||||
log.Printf("ERROR: No VNFS set for node %s\n", node.Fqdn.Get())
|
||||
log.Printf("ERROR: No VNFS set for node %s\n", node.Id.Get())
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
package add
|
||||
|
||||
import (
|
||||
"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 {
|
||||
nodeDB, err := node.New()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Failed opening node database: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
for _, g := range args {
|
||||
err = nodeDB.AddGroup(SetController, g)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
nodeDB.Persist()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
package add
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
var (
|
||||
baseCmd = &cobra.Command{
|
||||
Use: "add",
|
||||
Short: "Add a new node group",
|
||||
Long: "Add a new node group ",
|
||||
RunE: CobraRunE,
|
||||
Args: cobra.MinimumNArgs(1),
|
||||
}
|
||||
SetController string
|
||||
)
|
||||
|
||||
func init() {
|
||||
baseCmd.PersistentFlags().StringVarP(&SetController, "controller", "c", "localhost", "Controller to add group to")
|
||||
|
||||
}
|
||||
|
||||
// GetRootCommand returns the root cobra.Command for the application.
|
||||
func GetCommand() *cobra.Command {
|
||||
return baseCmd
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
package delete
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
"github.com/manifoldco/promptui"
|
||||
"github.com/spf13/cobra"
|
||||
"os"
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
var count int
|
||||
var numNodes int
|
||||
|
||||
nodeDB, err := node.New()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Failed to open node database: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
nodes, err := nodeDB. FindAllNodes()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not load all nodes: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
for _, g := range args {
|
||||
err := nodeDB.DelGroup(SetController, g)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
} else {
|
||||
for _, n := range nodes {
|
||||
if n.Gid.Get() == g {
|
||||
numNodes ++
|
||||
}
|
||||
}
|
||||
count ++
|
||||
}
|
||||
}
|
||||
|
||||
if count > 0 {
|
||||
q := fmt.Sprintf("Are you sure you want to delete %d group(s) (%d nodes)", count, numNodes)
|
||||
|
||||
prompt := promptui.Prompt{
|
||||
Label: q,
|
||||
IsConfirm: true,
|
||||
}
|
||||
|
||||
result, _ := prompt.Run()
|
||||
|
||||
if result == "y" || result == "yes" {
|
||||
nodeDB.Persist()
|
||||
}
|
||||
|
||||
} else {
|
||||
wwlog.Printf(wwlog.INFO, "No groups found\n")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package delete
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
var (
|
||||
baseCmd = &cobra.Command{
|
||||
Use: "delete",
|
||||
Short: "Add a new node group",
|
||||
Long: "Add a new node group ",
|
||||
RunE: CobraRunE,
|
||||
}
|
||||
SetController string
|
||||
)
|
||||
|
||||
func init() {
|
||||
baseCmd.PersistentFlags().StringVarP(&SetController, "controller", "c", "default", "Controller to add group to")
|
||||
}
|
||||
|
||||
// GetRootCommand returns the root cobra.Command for the application.
|
||||
func GetCommand() *cobra.Command {
|
||||
return baseCmd
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package list
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
"github.com/spf13/cobra"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
nodeDB, err := node.New()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not open node configuration: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
groups, err := nodeDB.FindAllGroups()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not find all nodes: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if ShowAll == true {
|
||||
for _, group := range groups {
|
||||
fmt.Printf("################################################################################\n")
|
||||
fmt.Printf("%-20s %-18s %8s: %s\n", group.Id.Get(), "Id", group.Id.Source(), group.Id.Print())
|
||||
fmt.Printf("%-20s %-18s %8s: %s\n", group.Id.Get(), "Controller", group.Cid.Source(), group.Cid.Print())
|
||||
fmt.Printf("%-20s %-18s %8s: %s\n", group.Id.Get(), "DomainName", group.DomainName.Source(), group.DomainName.Print())
|
||||
fmt.Printf("%-20s %-18s %8s: %s\n", group.Id.Get(), "VNFS", group.Vnfs.Source(), group.Vnfs.Print())
|
||||
fmt.Printf("%-20s %-18s %8s: %s\n", group.Id.Get(), "KernelVersion", group.KernelVersion.Source(), group.KernelVersion.Print())
|
||||
fmt.Printf("%-20s %-18s %8s: %s\n", group.Id.Get(), "KernelArgs", group.KernelArgs.Source(), group.KernelArgs.Print())
|
||||
fmt.Printf("%-20s %-18s %8s: %s\n", group.Id.Get(), "RuntimeOverlay", group.RuntimeOverlay.Source(), group.RuntimeOverlay.Print())
|
||||
fmt.Printf("%-20s %-18s %8s: %s\n", group.Id.Get(), "SystemOverlay", group.SystemOverlay.Source(), group.SystemOverlay.Print())
|
||||
fmt.Printf("%-20s %-18s %8s: %s\n", group.Id.Get(), "IPMI Netmask", group.IpmiNetmask.Source(), group.IpmiNetmask.Print())
|
||||
fmt.Printf("%-20s %-18s %8s: %s\n", group.Id.Get(), "IPMI UserName", group.IpmiUserName.Source(), group.IpmiUserName.Print())
|
||||
fmt.Printf("%-20s %-18s %8s: %s\n", group.Id.Get(), "IPMI Password", group.IpmiPassword.Source(), group.IpmiPassword.Print())
|
||||
fmt.Printf("%-20s %-18s %8s: %s\n", group.Id.Get(), "Ipxe", group.Ipxe.Source(), group.Ipxe.Print())
|
||||
fmt.Printf("%-20s %-18s %8s: %s\n", group.Id.Get(), "Profiles", "group", strings.Join(group.Profiles, ","))
|
||||
|
||||
}
|
||||
} else {
|
||||
fmt.Printf("%-22s %-16s %-16s %s\n", "GROUP NAME", "DOMAINNAME", "CONTROLLER", "PROFILES")
|
||||
for _, g := range groups {
|
||||
fmt.Printf("%-22s %-16s %-16s %s\n", g.Id.Get(), g.DomainName.Get(), g.Cid.Get(), strings.Join(g.Profiles, ","))
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package list
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
var (
|
||||
baseCmd = &cobra.Command{
|
||||
Use: "list",
|
||||
Short: "List group configurations",
|
||||
Long: "List group configurations ",
|
||||
RunE: CobraRunE,
|
||||
}
|
||||
ShowAll bool
|
||||
)
|
||||
|
||||
func init() {
|
||||
baseCmd.PersistentFlags().BoolVarP(&ShowAll, "all", "a", false, "Show all node configurations")
|
||||
|
||||
}
|
||||
|
||||
// GetRootCommand returns the root cobra.Command for the application.
|
||||
func GetCommand() *cobra.Command {
|
||||
return baseCmd
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/group/add"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/group/delete"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/group/list"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/group/set"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
baseCmd = &cobra.Command{
|
||||
Use: "group",
|
||||
Short: "Group management",
|
||||
Long: "Management of group settings and power management",
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
baseCmd.AddCommand(list.GetCommand())
|
||||
baseCmd.AddCommand(set.GetCommand())
|
||||
baseCmd.AddCommand(add.GetCommand())
|
||||
baseCmd.AddCommand(delete.GetCommand())
|
||||
}
|
||||
|
||||
// GetRootCommand returns the root cobra.Command for the application.
|
||||
func GetCommand() *cobra.Command {
|
||||
return baseCmd
|
||||
}
|
||||
@@ -1,183 +0,0 @@
|
||||
package set
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
"github.com/manifoldco/promptui"
|
||||
"github.com/spf13/cobra"
|
||||
"os"
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
var err error
|
||||
var groups []node.GroupInfo
|
||||
|
||||
nodeDB, err := node.New()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not open node configuration: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Cloud not get nodeList: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if len(args) == 0 {
|
||||
args = append(args, "default")
|
||||
}
|
||||
|
||||
if SetGroupAll == true {
|
||||
groups, err = nodeDB.FindAllGroups()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
} else {
|
||||
var tmp []node.GroupInfo
|
||||
tmp, err = nodeDB.FindAllGroups()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
for _, a := range args {
|
||||
for _, g := range tmp {
|
||||
if g.Id.Get() == a {
|
||||
groups = append(groups, g)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, g := range groups {
|
||||
|
||||
if SetDomainName != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Group: %s, Setting domain name to: %s\n", g.Id, SetDomainName)
|
||||
|
||||
g.DomainName.SetGroup(SetDomainName)
|
||||
err := nodeDB.GroupUpdate(g)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
if SetVnfs != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Group: %s, Setting VNFS to: %s\n", g.Id, SetVnfs)
|
||||
|
||||
g.Vnfs.SetGroup(SetVnfs)
|
||||
err := nodeDB.GroupUpdate(g)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
if SetKernel != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Group: %s, Setting kernel to: %s\n", g.Id, SetKernel)
|
||||
|
||||
g.KernelVersion.SetGroup(SetKernel)
|
||||
err := nodeDB.GroupUpdate(g)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
if SetIpmiNetmask != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Group: %s, Setting IPMI username to: %s\n", g.Id, SetIpmiNetmask)
|
||||
|
||||
g.IpmiNetmask.SetGroup(SetIpmiNetmask)
|
||||
err := nodeDB.GroupUpdate(g)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
if SetIpmiUsername != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Group: %s, Setting IPMI username to: %s\n", g.Id, SetIpmiUsername)
|
||||
|
||||
g.IpmiUserName.SetGroup(SetIpmiUsername)
|
||||
err := nodeDB.GroupUpdate(g)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
if SetIpmiPassword != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Group: %s, Setting IPMI password to: %s\n", g.Id, SetIpmiPassword)
|
||||
|
||||
g.IpmiPassword.SetGroup(SetIpmiPassword)
|
||||
err := nodeDB.GroupUpdate(g)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
if SetSystemOverlay != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Group: %s, Setting system overlay to: %s\n", g.Id, SetSystemOverlay)
|
||||
|
||||
g.SystemOverlay.SetGroup(SetSystemOverlay)
|
||||
err := nodeDB.GroupUpdate(g)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
if SetRuntimeOverlay != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Group: %s, Setting runtime overlay to: %s\n", g.Id, SetRuntimeOverlay)
|
||||
|
||||
g.RuntimeOverlay.SetGroup(SetRuntimeOverlay)
|
||||
err := nodeDB.GroupUpdate(g)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
if len(SetAddProfile) > 0 {
|
||||
for _, p := range SetAddProfile {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Adding profile to '%s': '%s'\n", g.Id, p)
|
||||
g.Profiles = util.SliceAddUniqueElement(g.Profiles, p)
|
||||
}
|
||||
err := nodeDB.GroupUpdate(g)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
if len(SetDelProfile) > 0 {
|
||||
for _, p := range SetDelProfile {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Removing profile to '%s': '%s'\n", g.Id, p)
|
||||
g.Profiles = util.SliceRemoveElement(g.Profiles, p)
|
||||
}
|
||||
err := nodeDB.GroupUpdate(g)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if len(groups) > 0 {
|
||||
q := fmt.Sprintf("Are you sure you want to modify %d group(s)", len(groups))
|
||||
|
||||
prompt := promptui.Prompt{
|
||||
Label: q,
|
||||
IsConfirm: true,
|
||||
}
|
||||
|
||||
result, _ := prompt.Run()
|
||||
|
||||
if result == "y" || result == "yes" {
|
||||
nodeDB.Persist()
|
||||
}
|
||||
|
||||
} else {
|
||||
fmt.Printf("No groups found\n")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package set
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
var (
|
||||
baseCmd = &cobra.Command{
|
||||
Use: "set",
|
||||
Short: "Set group configurations",
|
||||
Long: "Set group configurations ",
|
||||
RunE: CobraRunE,
|
||||
}
|
||||
SetVnfs string
|
||||
SetKernel string
|
||||
SetDomainName string
|
||||
SetIpxe string
|
||||
SetRuntimeOverlay string
|
||||
SetSystemOverlay string
|
||||
SetClearNodes bool
|
||||
SetIpmiNetmask string
|
||||
SetIpmiUsername string
|
||||
SetIpmiPassword string
|
||||
SetGroupAll bool
|
||||
SetAddProfile []string
|
||||
SetDelProfile []string
|
||||
)
|
||||
|
||||
func init() {
|
||||
baseCmd.PersistentFlags().StringVarP(&SetVnfs, "vnfs", "V", "", "Set node Virtual Node File System (VNFS)")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetKernel, "kernel", "K", "", "Set Kernel version for nodes")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetDomainName, "domain", "D", "", "Set the node's domain name")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetIpxe, "ipxe", "P", "", "Set the node's iPXE template name")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetRuntimeOverlay, "runtime", "R", "", "Set the node's runtime overlay")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetSystemOverlay, "system", "S", "", "Set the node's system overlay")
|
||||
baseCmd.PersistentFlags().StringVar(&SetIpmiNetmask, "ipminetmask", "", "Set the node's IPMI netmask")
|
||||
baseCmd.PersistentFlags().StringVar(&SetIpmiUsername, "ipmiuser", "", "Set the node's IPMI username")
|
||||
baseCmd.PersistentFlags().StringVar(&SetIpmiPassword, "ipmipass", "", "Set the node's IPMI password")
|
||||
|
||||
baseCmd.PersistentFlags().StringSliceVarP(&SetAddProfile, "addprofile", "p", []string{}, "Add Profile(s) to group")
|
||||
baseCmd.PersistentFlags().StringSliceVarP(&SetDelProfile, "delprofile", "r", []string{}, "Remove Profile(s) to group")
|
||||
|
||||
baseCmd.PersistentFlags().BoolVarP(&SetClearNodes, "clear", "c", false, "Clear node configurations when setting parent group")
|
||||
baseCmd.PersistentFlags().BoolVarP(&SetGroupAll, "all", "a", false, "Set all nodes")
|
||||
|
||||
}
|
||||
|
||||
// GetRootCommand returns the root cobra.Command for the application.
|
||||
func GetCommand() *cobra.Command {
|
||||
return baseCmd
|
||||
}
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
config := config.New()
|
||||
nconfig, _ := node.New()
|
||||
nodes, _ := nconfig.FindAllNodes()
|
||||
nodemap := make(map[string]int)
|
||||
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
config := config.New()
|
||||
var overlaySourceDir string
|
||||
overlayName := args[0]
|
||||
fileName := args[2]
|
||||
|
||||
@@ -14,7 +14,6 @@ import (
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
var overlayPath string
|
||||
config := config.New()
|
||||
|
||||
if SystemOverlay == true {
|
||||
overlayPath = config.SystemOverlaySource(args[0])
|
||||
|
||||
@@ -14,8 +14,7 @@ import (
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
config := config.New()
|
||||
editor := config.Editor
|
||||
editor := os.Getenv("EDITOR")
|
||||
var overlaySourceDir string
|
||||
|
||||
if SystemOverlay == true {
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
config := config.New()
|
||||
overlayName := args[0]
|
||||
source := args[1]
|
||||
var dest string
|
||||
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
config := config.New()
|
||||
set := make(map[string]int)
|
||||
var o []string
|
||||
var err error
|
||||
@@ -54,11 +53,11 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
for _, node := range nodeList {
|
||||
if SystemOverlay == true {
|
||||
if node.SystemOverlay.Get() != "" {
|
||||
set[node.SystemOverlay.Get()] ++
|
||||
set[node.SystemOverlay.Get()]++
|
||||
}
|
||||
} else {
|
||||
if node.RuntimeOverlay.Get() != "" {
|
||||
set[node.RuntimeOverlay.Get()] ++
|
||||
set[node.RuntimeOverlay.Get()]++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
config := config.New()
|
||||
var overlaySourceDir string
|
||||
// mode := uint32(strconv.ParseUint(PermMode, 8, 32))
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
config := config.New()
|
||||
var overlaySourceDir string
|
||||
overlayName := args[0]
|
||||
fileName := args[1]
|
||||
@@ -44,4 +43,4 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
fmt.Print(string(f))
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
config := config.New()
|
||||
|
||||
n, err := node.New()
|
||||
if err != nil {
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/overlay"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/profile"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/ready"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/service"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/vnfs"
|
||||
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
@@ -36,7 +37,7 @@ func init() {
|
||||
rootCmd.AddCommand(kernel.GetCommand())
|
||||
// rootCmd.AddCommand(group.GetCommand())
|
||||
rootCmd.AddCommand(profile.GetCommand())
|
||||
//rootCmd.AddCommand(service.GetCommand())
|
||||
rootCmd.AddCommand(service.GetCommand())
|
||||
rootCmd.AddCommand(ready.GetCommand())
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"github.com/brotherpowers/ipsubnet"
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
"github.com/spf13/cobra"
|
||||
"net"
|
||||
@@ -28,133 +29,120 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
func ConfigureDHCP() error {
|
||||
var d dhcpTemplate
|
||||
var templateFile string
|
||||
|
||||
nodeDB, err := node.New()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not open node configuration: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
controllers, err := nodeDB.FindAllControllers()
|
||||
controller, err := warewulfconf.New()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if controller.Ipaddr == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "The Warewulf IP Address is not properly configured\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if controller.Netmask == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "The Warewulf Netmask is not properly configured\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if controller.Dhcp.Enabled == false {
|
||||
wwlog.Printf(wwlog.INFO, "This system is not configured as a Warewulf DHCP controller\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if controller.Dhcp.RangeStart == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "Configuration is not defined: `dhcpd range start`\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if controller.Dhcp.RangeEnd == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "Configuration is not defined: `dhcpd range end`\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if controller.Dhcp.ConfigFile == "" {
|
||||
controller.Dhcp.ConfigFile = "/etc/dhcp/dhcpd.conf"
|
||||
}
|
||||
|
||||
nodes, err := nodeDB.FindAllNodes()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not find all controllers: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
for _, controller := range controllers {
|
||||
var templateFile string
|
||||
var d dhcpTemplate
|
||||
var configured bool
|
||||
for _, node := range nodes {
|
||||
d.Nodes = append(d.Nodes, node)
|
||||
}
|
||||
|
||||
addrs, err := net.InterfaceAddrs()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not get network interfaces: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
for _, address := range addrs {
|
||||
if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
|
||||
if ipnet.IP.String() == controller.Ipaddr {
|
||||
m, _ := ipnet.Mask.Size()
|
||||
sub := ipsubnet.SubnetCalculator(ipnet.IP.String(), m)
|
||||
|
||||
d.Ipaddr = ipnet.IP.String()
|
||||
d.Network = sub.GetNetworkPortion()
|
||||
d.Netmask = sub.GetSubnetMask()
|
||||
d.RangeStart = controller.Services.Dhcp.RangeStart
|
||||
d.RangeEnd = controller.Services.Dhcp.RangeEnd
|
||||
configured = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hostname, err := os.Hostname()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not obtain system's hostname\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
if hostname != controller.Fqdn {
|
||||
wwlog.Printf(wwlog.WARN, "The system hostname does not match Warewulf config: %s != %s\n", hostname, controller.Fqdn)
|
||||
}
|
||||
|
||||
if configured == false {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not identify this system in the Warewulf configuration by it's IP address\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if controller.Services.Dhcp.ConfigFile == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not locate the DHCP configuration file for this controller\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if _, ok := nodeDB.Controllers[controller.Id]; !ok {
|
||||
wwlog.Printf(wwlog.ERROR, "We should never get here, but since we did, Hello! %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
nodes, err := nodeDB.FindAllNodes()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not find all controllers: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
for _, node := range nodes {
|
||||
d.Nodes = append(d.Nodes, node)
|
||||
}
|
||||
|
||||
if controller.Services.Dhcp.Template == "" {
|
||||
templateFile = "/etc/warewulf/dhcp/default-dhcpd.conf"
|
||||
if controller.Dhcp.Template == "" {
|
||||
templateFile = "/etc/warewulf/dhcp/default-dhcpd.conf"
|
||||
} else {
|
||||
if strings.HasPrefix(controller.Dhcp.Template, "/") {
|
||||
templateFile = controller.Dhcp.Template
|
||||
} else {
|
||||
if strings.HasPrefix(controller.Services.Dhcp.Template, "/") {
|
||||
templateFile = controller.Services.Dhcp.Template
|
||||
} else {
|
||||
templateFile = fmt.Sprintf("/etc/warewulf/dhcp/%s-dhcpd.conf", controller.Services.Dhcp.Template)
|
||||
}
|
||||
templateFile = fmt.Sprintf("/etc/warewulf/dhcp/%s-dhcpd.conf", controller.Dhcp.Template)
|
||||
}
|
||||
}
|
||||
|
||||
tmpl, err := template.New(path.Base(templateFile)).ParseFiles(templateFile)
|
||||
tmpl, err := template.New(path.Base(templateFile)).ParseFiles(templateFile)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
mask := net.IPMask(net.ParseIP(controller.Netmask).To4())
|
||||
size, _ := mask.Size()
|
||||
|
||||
sub := ipsubnet.SubnetCalculator(controller.Ipaddr, size)
|
||||
|
||||
d.Ipaddr = controller.Ipaddr
|
||||
d.Network = sub.GetNetworkPortion()
|
||||
d.Netmask = sub.GetSubnetMask()
|
||||
d.RangeStart = controller.Dhcp.RangeStart
|
||||
d.RangeEnd = controller.Dhcp.RangeEnd
|
||||
|
||||
if DoConfig == true {
|
||||
fmt.Printf("Writing the DHCP configuration file\n")
|
||||
configWriter, err := os.OpenFile(controller.Dhcp.ConfigFile, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0640)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
defer configWriter.Close()
|
||||
err = tmpl.Execute(configWriter, d)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if DoConfig == true {
|
||||
fmt.Printf("Writing the DHCP configuration file\n")
|
||||
configWriter, err := os.OpenFile(controller.Services.Dhcp.ConfigFile, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0640)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
defer configWriter.Close()
|
||||
err = tmpl.Execute(configWriter, d)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Printf("Enabling and restarting the DHCP services\n")
|
||||
if controller.Services.Dhcp.EnableCmd != "" {
|
||||
util.ExecInteractive("/bin/sh", "-c", controller.Services.Dhcp.EnableCmd)
|
||||
} else {
|
||||
util.ExecInteractive("/bin/sh", "-c", "systemctl enable dhcpd")
|
||||
}
|
||||
if controller.Services.Dhcp.RestartCmd != "" {
|
||||
util.ExecInteractive("/bin/sh", "-c", controller.Services.Dhcp.RestartCmd)
|
||||
} else {
|
||||
util.ExecInteractive("/bin/sh", "-c", "systemctl restart dhcpd")
|
||||
}
|
||||
|
||||
fmt.Printf("Enabling and restarting the DHCP services\n")
|
||||
if controller.Dhcp.Enable != "" {
|
||||
util.ExecInteractive("/bin/sh", "-c", controller.Dhcp.Enable)
|
||||
} else {
|
||||
err = tmpl.Execute(os.Stdout, d)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
util.ExecInteractive("/bin/sh", "-c", "systemctl enable dhcpd")
|
||||
}
|
||||
if controller.Dhcp.Restart != "" {
|
||||
util.ExecInteractive("/bin/sh", "-c", controller.Dhcp.Restart)
|
||||
} else {
|
||||
util.ExecInteractive("/bin/sh", "-c", "systemctl restart dhcpd")
|
||||
}
|
||||
|
||||
} else {
|
||||
err = tmpl.Execute(os.Stdout, d)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Just in case we get here, we've now finished the loop
|
||||
break
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -29,7 +29,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
|
||||
for _, node := range nodes {
|
||||
if node.Vnfs.Defined() == true {
|
||||
set[node.Vnfs.Get()] ++
|
||||
set[node.Vnfs.Get()]++
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,12 +43,13 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
|
||||
for _, node := range nodes {
|
||||
if node.Vnfs.Defined() == true {
|
||||
set[node.Vnfs.Get()] ++
|
||||
wwlog.Printf(wwlog.VERBOSE, "Adding VNFS to list: %s (%s)\n", node.Vnfs.Get(), node.Id.Get())
|
||||
set[node.Vnfs.Get()]++
|
||||
}
|
||||
}
|
||||
|
||||
} else if len(args) == 1 {
|
||||
set[args[0]] ++
|
||||
set[args[0]]++
|
||||
} else {
|
||||
cmd.Usage()
|
||||
os.Exit(1)
|
||||
@@ -64,4 +65,4 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,13 +14,12 @@ import (
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
config := config.New()
|
||||
nconfig, _ := node.New()
|
||||
nodes, _ := nconfig.FindAllNodes()
|
||||
nodemap := make(map[string]int)
|
||||
|
||||
for _, n := range nodes {
|
||||
nodemap[n.Vnfs.Get()] ++
|
||||
nodemap[n.Vnfs.Get()]++
|
||||
}
|
||||
|
||||
images, _ := ioutil.ReadDir(config.VnfsImageParentDir())
|
||||
@@ -32,7 +31,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
v, err := vnfs.Load(file.Name())
|
||||
if err == nil {
|
||||
var vnfs_size int64
|
||||
if util.IsFile( config.VnfsImage(file.Name())) {
|
||||
if util.IsFile(config.VnfsImage(file.Name())) {
|
||||
s, _ := os.Stat(config.VnfsImage(file.Name()))
|
||||
vnfs_size = s.Size() / 1024
|
||||
}
|
||||
@@ -48,7 +47,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
|
||||
if util.IsDir(path.Join(config.VnfsImageParentDir(), file.Name())) {
|
||||
var vnfs_size int64
|
||||
if util.IsFile( config.VnfsImage(file.Name())) {
|
||||
if util.IsFile(config.VnfsImage(file.Name())) {
|
||||
s, _ := os.Stat(config.VnfsImage(file.Name()))
|
||||
vnfs_size = s.Size() / 1024
|
||||
}
|
||||
@@ -61,4 +60,4 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user