mirror of
https://github.com/kubereboot/kured.git
synced 2026-05-19 23:07:37 +00:00
Without this, the interface and the code to reboot is a bit more complex than it should be. We do not need setters and getters, as we are just instanciating a single instance of a rebooter interface. We create it based on user input, then pass the object around. This should cleanup the code. Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
23 lines
641 B
Go
23 lines
641 B
Go
package reboot
|
|
|
|
import (
|
|
"github.com/kubereboot/kured/pkg/util"
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
// CommandRebooter holds context-information for a command reboot.
|
|
type CommandRebooter struct {
|
|
NodeID string
|
|
RebootCommand []string
|
|
}
|
|
|
|
// NewCommandReboot creates a new command-rebooter which needs full privileges on the host.
|
|
|
|
// Reboot triggers the command-reboot.
|
|
func (c CommandRebooter) Reboot() {
|
|
log.Infof("Running command: %s for node: %s", c.RebootCommand, c.NodeID)
|
|
if err := util.NewCommand(c.RebootCommand[0], c.RebootCommand[1:]...).Run(); err != nil {
|
|
log.Fatalf("Error invoking reboot command: %v", err)
|
|
}
|
|
}
|