Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add machine power cycle command #97

Merged
merged 2 commits into from
Jul 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion cmd/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,23 @@ Power on will therefore not work if the machine is in the powering off phase.`,
machinePowerResetCmd = &cobra.Command{
Use: "reset <machine ID>",
Short: "power reset a machine",
Long: "reset the machine power. This will ensure a power cycle.",
Long: "(hard) reset the machine power.",
RunE: func(cmd *cobra.Command, args []string) error {
return machinePowerReset(driver, args)
},
PreRun: bindPFlags,
}

machinePowerCycleCmd = &cobra.Command{
Use: "cycle <machine ID>",
Short: "power cycle a machine",
Long: "(soft) cycle the machine power.",
RunE: func(cmd *cobra.Command, args []string) error {
return machinePowerCycle(driver, args)
},
PreRun: bindPFlags,
}

machineUpdateCmd = &cobra.Command{
Use: "update",
Aliases: []string{"firmware-update"},
Expand Down Expand Up @@ -431,6 +441,7 @@ func init() {
machinePowerCmd.AddCommand(machinePowerOnCmd)
machinePowerCmd.AddCommand(machinePowerOffCmd)
machinePowerCmd.AddCommand(machinePowerResetCmd)
machinePowerCmd.AddCommand(machinePowerCycleCmd)
machinePowerCmd.AddCommand(machineBootBiosCmd)
machinePowerCmd.AddCommand(machineBootDiskCmd)
machinePowerCmd.AddCommand(machineBootPxeCmd)
Expand Down Expand Up @@ -804,6 +815,19 @@ func machinePowerReset(driver *metalgo.Driver, args []string) error {
return printer.Print(resp.Machine)
}

func machinePowerCycle(driver *metalgo.Driver, args []string) error {
machineID, err := getMachineID(args)
if err != nil {
return err
}

resp, err := driver.MachinePowerCycle(machineID)
if err != nil {
return err
}
return printer.Print(resp.Machine)
}

func machineUpdateBios(driver *metalgo.Driver, args []string) error {
m, vendor, board, err := firmwareData(args)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/dustin/go-humanize v1.0.0
github.com/fatih/color v1.12.0
github.com/metal-stack/masterdata-api v0.8.7
github.com/metal-stack/metal-go v0.15.1
github.com/metal-stack/metal-go v0.15.2
github.com/metal-stack/metal-lib v0.8.0
github.com/metal-stack/updater v1.1.3
github.com/metal-stack/v v1.0.3
Expand Down
Loading