Merge pull request #1440 from JasonYangShadow/issue/1439
wwctl should return non-zero exit code on wwctl power sub-commands
This commit is contained in:
@@ -49,6 +49,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
- Fix excessive line spacing issue when listing nodes. #1241
|
||||
- Return non-zero exit code on node sub-commands #1421
|
||||
- Fix panic when getting a long container list before building the container. #1391
|
||||
- Return non-zero exit code on power sub-commands #1439
|
||||
|
||||
## v4.5.8, unreleased
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package powercycle
|
||||
package cycle
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -17,14 +17,12 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
|
||||
nodeDB, err := node.New()
|
||||
if err != nil {
|
||||
wwlog.Error("Could not open node configuration: %s", err)
|
||||
os.Exit(1)
|
||||
return fmt.Errorf("could not open node configuration: %s", err)
|
||||
}
|
||||
|
||||
nodes, err := nodeDB.FindAllNodes()
|
||||
if err != nil {
|
||||
wwlog.Error("Could not get node list: %s", err)
|
||||
os.Exit(1)
|
||||
return fmt.Errorf("could not get node list: %s", err)
|
||||
}
|
||||
|
||||
if len(args) > 0 {
|
||||
@@ -36,8 +34,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
if len(nodes) == 0 {
|
||||
fmt.Printf("No nodes found\n")
|
||||
os.Exit(1)
|
||||
return fmt.Errorf("no nodes found")
|
||||
}
|
||||
|
||||
batchpool := batch.New(50)
|
||||
@@ -1,4 +1,4 @@
|
||||
package powercycle
|
||||
package cycle
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package poweroff
|
||||
package off
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -17,14 +17,12 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
|
||||
nodeDB, err := node.New()
|
||||
if err != nil {
|
||||
wwlog.Error("Could not open node configuration: %s", err)
|
||||
os.Exit(1)
|
||||
return fmt.Errorf("could not open node configuration: %s", err)
|
||||
}
|
||||
|
||||
nodes, err := nodeDB.FindAllNodes()
|
||||
if err != nil {
|
||||
wwlog.Error("Could not get node list: %s", err)
|
||||
os.Exit(1)
|
||||
return fmt.Errorf("could not get node list: %s", err)
|
||||
}
|
||||
|
||||
if len(args) > 0 {
|
||||
@@ -36,8 +34,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
if len(nodes) == 0 {
|
||||
fmt.Printf("No nodes found\n")
|
||||
os.Exit(1)
|
||||
return fmt.Errorf("no nodes found")
|
||||
}
|
||||
|
||||
batchpool := batch.New(50)
|
||||
@@ -1,4 +1,4 @@
|
||||
package poweroff
|
||||
package off
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package poweron
|
||||
package on
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -17,14 +17,12 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
|
||||
nodeDB, err := node.New()
|
||||
if err != nil {
|
||||
wwlog.Error("Could not open node configuration: %s", err)
|
||||
os.Exit(1)
|
||||
return fmt.Errorf("could not open node configuration: %s", err)
|
||||
}
|
||||
|
||||
nodes, err := nodeDB.FindAllNodes()
|
||||
if err != nil {
|
||||
wwlog.Error("Could not get node list: %s", err)
|
||||
os.Exit(1)
|
||||
return fmt.Errorf("could not get node list: %s", err)
|
||||
}
|
||||
|
||||
if len(args) > 0 {
|
||||
@@ -36,8 +34,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
if len(nodes) == 0 {
|
||||
fmt.Printf("No nodes found\n")
|
||||
os.Exit(1)
|
||||
return fmt.Errorf("no nodes found")
|
||||
}
|
||||
|
||||
batchpool := batch.New(50)
|
||||
@@ -1,4 +1,4 @@
|
||||
package poweron
|
||||
package on
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package powerreset
|
||||
package reset
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -17,14 +17,12 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
|
||||
nodeDB, err := node.New()
|
||||
if err != nil {
|
||||
wwlog.Error("Could not open node configuration: %s", err)
|
||||
os.Exit(1)
|
||||
return fmt.Errorf("could not open node configuration: %s", err)
|
||||
}
|
||||
|
||||
nodes, err := nodeDB.FindAllNodes()
|
||||
if err != nil {
|
||||
wwlog.Error("Cloud not get nodeList: %s", err)
|
||||
os.Exit(1)
|
||||
return fmt.Errorf("cloud not get nodeList: %s", err)
|
||||
}
|
||||
|
||||
if len(args) > 0 {
|
||||
@@ -36,8 +34,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
if len(nodes) == 0 {
|
||||
fmt.Printf("No nodes found\n")
|
||||
os.Exit(1)
|
||||
return fmt.Errorf("no nodes found")
|
||||
}
|
||||
|
||||
batchpool := batch.New(50)
|
||||
@@ -1,4 +1,4 @@
|
||||
package powerreset
|
||||
package reset
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package powersoft
|
||||
package soft
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -17,14 +17,12 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
|
||||
nodeDB, err := node.New()
|
||||
if err != nil {
|
||||
wwlog.Error("Could not open node configuration: %s", err)
|
||||
os.Exit(1)
|
||||
return fmt.Errorf("could not open node configuration: %s", err)
|
||||
}
|
||||
|
||||
nodes, err := nodeDB.FindAllNodes()
|
||||
if err != nil {
|
||||
wwlog.Error("Cloud not get nodeList: %s", err)
|
||||
os.Exit(1)
|
||||
return fmt.Errorf("could not get nodeList: %s", err)
|
||||
}
|
||||
|
||||
if len(args) > 0 {
|
||||
@@ -36,8 +34,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
if len(nodes) == 0 {
|
||||
fmt.Printf("No nodes found\n")
|
||||
os.Exit(1)
|
||||
return fmt.Errorf("no nodes found")
|
||||
}
|
||||
|
||||
batchpool := batch.New(50)
|
||||
@@ -1,4 +1,4 @@
|
||||
package powersoft
|
||||
package soft
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package powerstatus
|
||||
package status
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -17,14 +17,12 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
|
||||
nodeDB, err := node.New()
|
||||
if err != nil {
|
||||
wwlog.Error("Could not open node configuration: %s", err)
|
||||
os.Exit(1)
|
||||
return fmt.Errorf("could not open node configuration: %s", err)
|
||||
}
|
||||
|
||||
nodes, err := nodeDB.FindAllNodes()
|
||||
if err != nil {
|
||||
wwlog.Error("Could not get node list: %s", err)
|
||||
os.Exit(1)
|
||||
return fmt.Errorf("could not get node list: %s", err)
|
||||
}
|
||||
|
||||
if len(args) > 0 {
|
||||
@@ -36,8 +34,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
if len(nodes) == 0 {
|
||||
fmt.Printf("No nodes found\n")
|
||||
os.Exit(1)
|
||||
return fmt.Errorf("no nodes found")
|
||||
}
|
||||
|
||||
batchpool := batch.New(50)
|
||||
@@ -1,4 +1,4 @@
|
||||
package powerstatus
|
||||
package status
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
Reference in New Issue
Block a user