add subcommands for clustctl daemon
- start: starts the clustvirt daemon - stop: stops the clustvirt daemon - restart: first stops then starts the daemon - reload: attempt to reload the clustvirt configuration after making changes
This commit is contained in:
parent
68c2c29fa9
commit
ece374d1a9
@ -1,6 +1,23 @@
|
||||
/*
|
||||
Copyright © 2024 NAME HERE <EMAIL ADDRESS>
|
||||
Copyright © 2024 Matthew Stobbs <matthew@stobbs.ca
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
package cmd
|
||||
|
||||
@ -13,13 +30,8 @@ import (
|
||||
// configCmd represents the config command
|
||||
var configCmd = &cobra.Command{
|
||||
Use: "config",
|
||||
Short: "A brief description of your command",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Short: "Configure the clustvirt daemon",
|
||||
Long: `Allows for editing the clustvirt daemon configuration using command line flags`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("config called")
|
||||
},
|
||||
|
@ -1,5 +1,23 @@
|
||||
/*
|
||||
Copyright © 2024 NAME HERE <EMAIL ADDRESS>
|
||||
Copyright © 2024 Matthew Stobbs <matthew@stobbs.ca
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
package cmd
|
||||
|
||||
@ -13,7 +31,9 @@ import (
|
||||
var daemonCmd = &cobra.Command{
|
||||
Use: "daemon",
|
||||
Short: "Control the clustvirt daemon process",
|
||||
Long: `Used to start, stop, restart and reload the clustvirt daemon process`,
|
||||
Long: `Allows for starting, restarting, stopping, and reloading the clustvirt daemon process.
|
||||
The clustvirt daemon is responsible for connecting to libvirtd hosts, and provides the
|
||||
REST API and WebUI to manage the cluster.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("daemon called")
|
||||
},
|
||||
|
34
cmd/clusterctl/cmd/reload.go
Normal file
34
cmd/clusterctl/cmd/reload.go
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
Copyright © 2024 NAME HERE <EMAIL ADDRESS>
|
||||
*/
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// reloadCmd represents the reload command
|
||||
var reloadCmd = &cobra.Command{
|
||||
Use: "reload",
|
||||
Short: "Reload the clustvirt daemon configuration",
|
||||
Long: `Sends SIGUSR1 to the clustvirt daemon process, indicating the server should reload it's configuration`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("reload called")
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
daemonCmd.AddCommand(reloadCmd)
|
||||
|
||||
// Here you will define your flags and configuration settings.
|
||||
|
||||
// Cobra supports Persistent Flags which will work for this command
|
||||
// and all subcommands, e.g.:
|
||||
// reloadCmd.PersistentFlags().String("foo", "", "A help for foo")
|
||||
|
||||
// Cobra supports local flags which will only run when this command
|
||||
// is called directly, e.g.:
|
||||
// reloadCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||
}
|
35
cmd/clusterctl/cmd/restart.go
Normal file
35
cmd/clusterctl/cmd/restart.go
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
Copyright © 2024 NAME HERE <EMAIL ADDRESS>
|
||||
*/
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// restartCmd represents the restart command
|
||||
var restartCmd = &cobra.Command{
|
||||
Use: "restart",
|
||||
Short: "Restart the clustvirt daemon process",
|
||||
Long: `Some configuration requires the daemon to restart itself.
|
||||
This command sends the SIGUSR2 signal, telling the daemon to restart`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("restart called")
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
daemonCmd.AddCommand(restartCmd)
|
||||
|
||||
// Here you will define your flags and configuration settings.
|
||||
|
||||
// Cobra supports Persistent Flags which will work for this command
|
||||
// and all subcommands, e.g.:
|
||||
// restartCmd.PersistentFlags().String("foo", "", "A help for foo")
|
||||
|
||||
// Cobra supports local flags which will only run when this command
|
||||
// is called directly, e.g.:
|
||||
// restartCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||
}
|
35
cmd/clusterctl/cmd/start.go
Normal file
35
cmd/clusterctl/cmd/start.go
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
Copyright © 2024 NAME HERE <EMAIL ADDRESS>
|
||||
*/
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// startCmd represents the start command
|
||||
var startCmd = &cobra.Command{
|
||||
Use: "start",
|
||||
Short: "Start the clustvirt daemon",
|
||||
Long: `Starts the clustvirt daemon loading configuration from files,
|
||||
ENV variables, and command line flags in that order.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("start called")
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
daemonCmd.AddCommand(startCmd)
|
||||
|
||||
// Here you will define your flags and configuration settings.
|
||||
|
||||
// Cobra supports Persistent Flags which will work for this command
|
||||
// and all subcommands, e.g.:
|
||||
// startCmd.PersistentFlags().String("foo", "", "A help for foo")
|
||||
|
||||
// Cobra supports local flags which will only run when this command
|
||||
// is called directly, e.g.:
|
||||
// startCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||
}
|
36
cmd/clusterctl/cmd/stop.go
Normal file
36
cmd/clusterctl/cmd/stop.go
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
Copyright © 2024 NAME HERE <EMAIL ADDRESS>
|
||||
*/
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// stopCmd represents the stop command
|
||||
var stopCmd = &cobra.Command{
|
||||
Use: "stop",
|
||||
Short: "Stop the clustvirt daemon",
|
||||
Long: `Stop the clustvirt daemon, waiting for all processes to exit cleanly.
|
||||
Triggers the SIGTERM signal to the daemon process. Can be configured
|
||||
to send a SIGKILL after a timeout to forcibly terminate the process.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("stop called")
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
daemonCmd.AddCommand(stopCmd)
|
||||
|
||||
// Here you will define your flags and configuration settings.
|
||||
|
||||
// Cobra supports Persistent Flags which will work for this command
|
||||
// and all subcommands, e.g.:
|
||||
// stopCmd.PersistentFlags().String("foo", "", "A help for foo")
|
||||
|
||||
// Cobra supports local flags which will only run when this command
|
||||
// is called directly, e.g.:
|
||||
// stopCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||
}
|
Loading…
Reference in New Issue
Block a user