Merge "Add label support to baremetal power commands"
This commit is contained in:
commit
ba4cbc0445
@ -21,6 +21,14 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
flagLabel = "labels"
|
||||
flagLabelShort = "l"
|
||||
flagLabelDescription = "Label(s) to filter desired baremetal host documents"
|
||||
|
||||
flagName = "name"
|
||||
flagNameShort = "n"
|
||||
flagNameDescription = "Name to filter desired baremetal host document"
|
||||
|
||||
flagPhase = "phase"
|
||||
flagPhaseDescription = "airshipctl phase that contains the desired baremetal host document(s)"
|
||||
)
|
||||
|
@ -26,13 +26,16 @@ import (
|
||||
|
||||
// NewPowerOffCommand provides a command to shutdown a remote host.
|
||||
func NewPowerOffCommand(rootSettings *environment.AirshipCTLSettings) *cobra.Command {
|
||||
var labels string
|
||||
var name string
|
||||
var phase string
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "poweroff BAREMETAL_HOST_DOC_NAME",
|
||||
Use: "poweroff",
|
||||
Short: "Shutdown a baremetal host",
|
||||
Args: cobra.ExactArgs(1),
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
m, err := remote.NewManager(rootSettings, phase, remote.ByName(args[0]))
|
||||
m, err := remote.NewManager(rootSettings, phase, remote.ByLabel(labels), remote.ByName(name))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -50,6 +53,8 @@ func NewPowerOffCommand(rootSettings *environment.AirshipCTLSettings) *cobra.Com
|
||||
}
|
||||
|
||||
flags := cmd.Flags()
|
||||
flags.StringVarP(&labels, flagLabel, flagLabelShort, "", flagLabelDescription)
|
||||
flags.StringVarP(&name, flagName, flagNameShort, "", flagNameDescription)
|
||||
flags.StringVar(&phase, flagPhase, config.BootstrapPhase, flagPhaseDescription)
|
||||
|
||||
return cmd
|
||||
|
@ -26,13 +26,16 @@ import (
|
||||
|
||||
// NewPowerOnCommand provides a command with the capability to power on baremetal hosts.
|
||||
func NewPowerOnCommand(rootSettings *environment.AirshipCTLSettings) *cobra.Command {
|
||||
var labels string
|
||||
var name string
|
||||
var phase string
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "poweron BAREMETAL_HOST_DOC_NAME",
|
||||
Use: "poweron",
|
||||
Short: "Power on a host",
|
||||
Args: cobra.ExactArgs(1),
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
m, err := remote.NewManager(rootSettings, phase, remote.ByName(args[0]))
|
||||
m, err := remote.NewManager(rootSettings, phase, remote.ByLabel(labels), remote.ByName(name))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -42,7 +45,7 @@ func NewPowerOnCommand(rootSettings *environment.AirshipCTLSettings) *cobra.Comm
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Fprintf(cmd.OutOrStdout(), "Powered on remote host %s\n", args[0])
|
||||
fmt.Fprintf(cmd.OutOrStdout(), "Powered on remote host %s\n", host.HostName)
|
||||
}
|
||||
|
||||
return nil
|
||||
@ -50,6 +53,8 @@ func NewPowerOnCommand(rootSettings *environment.AirshipCTLSettings) *cobra.Comm
|
||||
}
|
||||
|
||||
flags := cmd.Flags()
|
||||
flags.StringVarP(&labels, flagLabel, flagLabelShort, "", flagLabelDescription)
|
||||
flags.StringVarP(&name, flagName, flagNameShort, "", flagNameDescription)
|
||||
flags.StringVar(&phase, flagPhase, config.BootstrapPhase, flagPhaseDescription)
|
||||
|
||||
return cmd
|
||||
|
@ -26,13 +26,16 @@ import (
|
||||
|
||||
// NewPowerStatusCommand provides a command to retrieve the power status of a baremetal host.
|
||||
func NewPowerStatusCommand(rootSettings *environment.AirshipCTLSettings) *cobra.Command {
|
||||
var labels string
|
||||
var name string
|
||||
var phase string
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "powerstatus BAREMETAL_HOST_DOC_NAME",
|
||||
Use: "powerstatus",
|
||||
Short: "Retrieve the power status of a baremetal host",
|
||||
Args: cobra.ExactArgs(1),
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
m, err := remote.NewManager(rootSettings, phase, remote.ByName(args[0]))
|
||||
m, err := remote.NewManager(rootSettings, phase, remote.ByLabel(labels), remote.ByName(name))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -52,6 +55,8 @@ func NewPowerStatusCommand(rootSettings *environment.AirshipCTLSettings) *cobra.
|
||||
}
|
||||
|
||||
flags := cmd.Flags()
|
||||
flags.StringVarP(&labels, flagLabel, flagLabelShort, "", flagLabelDescription)
|
||||
flags.StringVarP(&name, flagName, flagNameShort, "", flagNameDescription)
|
||||
flags.StringVar(&phase, flagPhase, config.BootstrapPhase, flagPhaseDescription)
|
||||
|
||||
return cmd
|
||||
|
@ -26,13 +26,16 @@ import (
|
||||
|
||||
// NewRebootCommand provides a command with the capability to reboot baremetal hosts.
|
||||
func NewRebootCommand(rootSettings *environment.AirshipCTLSettings) *cobra.Command {
|
||||
var labels string
|
||||
var name string
|
||||
var phase string
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "reboot BAREMETAL_HOST_DOC_NAME",
|
||||
Use: "reboot",
|
||||
Short: "Reboot a host",
|
||||
Args: cobra.ExactArgs(1),
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
m, err := remote.NewManager(rootSettings, phase, remote.ByName(args[0]))
|
||||
m, err := remote.NewManager(rootSettings, phase, remote.ByLabel(labels), remote.ByName(name))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -50,6 +53,8 @@ func NewRebootCommand(rootSettings *environment.AirshipCTLSettings) *cobra.Comma
|
||||
}
|
||||
|
||||
flags := cmd.Flags()
|
||||
flags.StringVarP(&labels, flagLabel, flagLabelShort, "", flagLabelDescription)
|
||||
flags.StringVarP(&name, flagName, flagNameShort, "", flagNameDescription)
|
||||
flags.StringVar(&phase, flagPhase, config.BootstrapPhase, flagPhaseDescription)
|
||||
|
||||
return cmd
|
||||
|
@ -1,8 +1,10 @@
|
||||
Shutdown a baremetal host
|
||||
|
||||
Usage:
|
||||
poweroff BAREMETAL_HOST_DOC_NAME [flags]
|
||||
poweroff [flags]
|
||||
|
||||
Flags:
|
||||
-h, --help help for poweroff
|
||||
-l, --labels string Label(s) to filter desired baremetal host documents
|
||||
-n, --name string Name to filter desired baremetal host document
|
||||
--phase string airshipctl phase that contains the desired baremetal host document(s) (default "bootstrap")
|
||||
|
@ -1,8 +1,10 @@
|
||||
Power on a host
|
||||
|
||||
Usage:
|
||||
poweron BAREMETAL_HOST_DOC_NAME [flags]
|
||||
poweron [flags]
|
||||
|
||||
Flags:
|
||||
-h, --help help for poweron
|
||||
-l, --labels string Label(s) to filter desired baremetal host documents
|
||||
-n, --name string Name to filter desired baremetal host document
|
||||
--phase string airshipctl phase that contains the desired baremetal host document(s) (default "bootstrap")
|
||||
|
@ -1,8 +1,10 @@
|
||||
Retrieve the power status of a baremetal host
|
||||
|
||||
Usage:
|
||||
powerstatus BAREMETAL_HOST_DOC_NAME [flags]
|
||||
powerstatus [flags]
|
||||
|
||||
Flags:
|
||||
-h, --help help for powerstatus
|
||||
-l, --labels string Label(s) to filter desired baremetal host documents
|
||||
-n, --name string Name to filter desired baremetal host document
|
||||
--phase string airshipctl phase that contains the desired baremetal host document(s) (default "bootstrap")
|
||||
|
@ -1,8 +1,10 @@
|
||||
Reboot a host
|
||||
|
||||
Usage:
|
||||
reboot BAREMETAL_HOST_DOC_NAME [flags]
|
||||
reboot [flags]
|
||||
|
||||
Flags:
|
||||
-h, --help help for reboot
|
||||
-l, --labels string Label(s) to filter desired baremetal host documents
|
||||
-n, --name string Name to filter desired baremetal host document
|
||||
--phase string airshipctl phase that contains the desired baremetal host document(s) (default "bootstrap")
|
||||
|
Loading…
Reference in New Issue
Block a user