committed by
Jonathon Anderson
parent
c0e5d4bc11
commit
7746854732
@@ -58,6 +58,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Create `/etc/systemd/network/10-persistent-net-<netdev>.link` file per network device
|
||||
- Fix the issue that the same tag added in `node set` is ignored. #967
|
||||
- Change too-verbose warning message level from `Warn` to `Debug`. #1025
|
||||
- Fixed a bug where error occurs when editing node. #1024
|
||||
|
||||
### Changed
|
||||
|
||||
|
||||
@@ -21,7 +21,11 @@ import (
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
canWrite := apiutil.CanWriteConfig()
|
||||
canWrite, err := apiutil.CanWriteConfig()
|
||||
if err != nil {
|
||||
wwlog.Error("While checking whether can write config, err: %w", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
if !canWrite.CanWriteConfig {
|
||||
wwlog.Error("Can't write to config exiting")
|
||||
os.Exit(1)
|
||||
|
||||
@@ -23,6 +23,7 @@ var (
|
||||
for _, node := range nodes {
|
||||
node_names = append(node_names, node.Id.Get())
|
||||
}
|
||||
|
||||
return node_names, cobra.ShellCompDirectiveNoFileComp
|
||||
},
|
||||
}
|
||||
|
||||
@@ -21,7 +21,11 @@ import (
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
canWrite := apiutil.CanWriteConfig()
|
||||
canWrite, err := apiutil.CanWriteConfig()
|
||||
if err != nil {
|
||||
wwlog.Error("While checking whether can write config, err: %w", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
if !canWrite.CanWriteConfig {
|
||||
wwlog.Error("Can't write to config exiting")
|
||||
os.Exit(1)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"syscall"
|
||||
|
||||
"github.com/manifoldco/promptui"
|
||||
@@ -28,14 +29,22 @@ func ConfirmationPrompt(label string) (yes bool) {
|
||||
/*
|
||||
Simple check if the config can be written in case wwctl isn't run as root
|
||||
*/
|
||||
func CanWriteConfig() (canwrite *wwapiv1.CanWriteConfig) {
|
||||
func CanWriteConfig() (canwrite *wwapiv1.CanWriteConfig, err error) {
|
||||
canwrite = new(wwapiv1.CanWriteConfig)
|
||||
err := syscall.Access(node.ConfigFile, syscall.O_RDWR)
|
||||
// node is not initialized yet
|
||||
if node.ConfigFile == "" {
|
||||
_, err := node.New()
|
||||
if err != nil {
|
||||
canwrite.CanWriteConfig = false
|
||||
return canwrite, fmt.Errorf("unable to initialize the node %w", err)
|
||||
}
|
||||
}
|
||||
err = syscall.Access(node.ConfigFile, syscall.O_RDWR)
|
||||
if err != nil {
|
||||
wwlog.Warn("Couldn't open %s:%s", node.ConfigFile, err)
|
||||
canwrite.CanWriteConfig = false
|
||||
} else {
|
||||
canwrite.CanWriteConfig = true
|
||||
}
|
||||
return canwrite
|
||||
return canwrite, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user