From daa0e48cd6db07039fe81f05b91e30dee0a869bd Mon Sep 17 00:00:00 2001 From: My Name Date: Thu, 29 Jan 2026 12:32:43 +0000 Subject: [PATCH] Added host orchestrator endpoint for cvd restart --- frontend/src/host_orchestrator/orchestrator/controller.go | 2 ++ frontend/src/host_orchestrator/orchestrator/cvd/cvd.go | 7 +++++++ .../host_orchestrator/orchestrator/execcvdcommandaction.go | 6 ++++++ 3 files changed, 15 insertions(+) diff --git a/frontend/src/host_orchestrator/orchestrator/controller.go b/frontend/src/host_orchestrator/orchestrator/controller.go index 511f304a971..7e7efd9a649 100644 --- a/frontend/src/host_orchestrator/orchestrator/controller.go +++ b/frontend/src/host_orchestrator/orchestrator/controller.go @@ -88,6 +88,8 @@ func (c *Controller) AddRoutes(router *mux.Router) { httpHandler(newExecCVDInstanceCommandHandler(c.Config, c.OperationManager, &powerwashCvdCommand{}))).Methods("POST") router.Handle("/cvds/{group}/{name}/:powerbtn", httpHandler(newExecCVDInstanceCommandHandler(c.Config, c.OperationManager, &powerbtnCvdCommand{}))).Methods("POST") + router.Handle("/cvds/{group}/{name}/:restart", + httpHandler(newExecCVDInstanceCommandHandler(c.Config, c.OperationManager, &restartCvdCommand{}))).Methods("POST") router.Handle("/cvds/{group}/{name}/:start_screen_recording", httpHandler(newExecCVDInstanceCommandHandler(c.Config, c.OperationManager, &startScreenRecordingCvdCommand{}))).Methods("POST") router.Handle("/cvds/{group}/{name}/:stop_screen_recording", diff --git a/frontend/src/host_orchestrator/orchestrator/cvd/cvd.go b/frontend/src/host_orchestrator/orchestrator/cvd/cvd.go index 7e62faf6719..23453c9238a 100644 --- a/frontend/src/host_orchestrator/orchestrator/cvd/cvd.go +++ b/frontend/src/host_orchestrator/orchestrator/cvd/cvd.go @@ -439,6 +439,13 @@ func (i *Instance) PowerWash() error { return err } +func (i *Instance) Restart() error { + args := i.selectorArgs() + args = append(args, "restart") + _, err := i.cli.exec(CVDBin, args...) + return err +} + func (i *Instance) Resume() error { args := i.selectorArgs() args = append(args, "resume") diff --git a/frontend/src/host_orchestrator/orchestrator/execcvdcommandaction.go b/frontend/src/host_orchestrator/orchestrator/execcvdcommandaction.go index e654a823767..33a30f9c162 100644 --- a/frontend/src/host_orchestrator/orchestrator/execcvdcommandaction.go +++ b/frontend/src/host_orchestrator/orchestrator/execcvdcommandaction.go @@ -96,6 +96,12 @@ func (a *powerbtnCvdCommand) exec(cvd *cvd.CLI, sel cvd.InstanceSelector) error return cvd.LazySelectInstance(sel).PowerBtn() } +type restartCvdCommand struct{} + +func (a *restartCvdCommand) exec(cvd *cvd.CLI, sel cvd.InstanceSelector) error { + return cvd.LazySelectInstance(sel).Restart() +} + type startScreenRecordingCvdCommand struct{} func (a *startScreenRecordingCvdCommand) exec(cvd *cvd.CLI, sel cvd.InstanceSelector) error {