Skip to content

Commit 31685a9

Browse files
SuperStrongDinosauradelva1984
authored andcommitted
Added host orchestrator endpoint for cvd restart
1 parent dfcb9cd commit 31685a9

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

frontend/src/host_orchestrator/orchestrator/controller.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ func (c *Controller) AddRoutes(router *mux.Router) {
8888
httpHandler(newExecCVDInstanceCommandHandler(c.Config, c.OperationManager, &powerwashCvdCommand{}))).Methods("POST")
8989
router.Handle("/cvds/{group}/{name}/:powerbtn",
9090
httpHandler(newExecCVDInstanceCommandHandler(c.Config, c.OperationManager, &powerbtnCvdCommand{}))).Methods("POST")
91+
router.Handle("/cvds/{group}/{name}/:restart",
92+
httpHandler(newExecCVDInstanceCommandHandler(c.Config, c.OperationManager, &restartCvdCommand{}))).Methods("POST")
9193
router.Handle("/cvds/{group}/{name}/:start_screen_recording",
9294
httpHandler(newExecCVDInstanceCommandHandler(c.Config, c.OperationManager, &startScreenRecordingCvdCommand{}))).Methods("POST")
9395
router.Handle("/cvds/{group}/{name}/:stop_screen_recording",

frontend/src/host_orchestrator/orchestrator/cvd/cvd.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,13 @@ func (i *Instance) PowerWash() error {
439439
return err
440440
}
441441

442+
func (i *Instance) Restart() error {
443+
args := i.selectorArgs()
444+
args = append(args, "restart")
445+
_, err := i.cli.exec(CVDBin, args...)
446+
return err
447+
}
448+
442449
func (i *Instance) Resume() error {
443450
args := i.selectorArgs()
444451
args = append(args, "resume")

frontend/src/host_orchestrator/orchestrator/execcvdcommandaction.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ func (a *powerbtnCvdCommand) exec(cvd *cvd.CLI, sel cvd.InstanceSelector) error
9696
return cvd.LazySelectInstance(sel).PowerBtn()
9797
}
9898

99+
type restartCvdCommand struct{}
100+
101+
func (a *restartCvdCommand) exec(cvd *cvd.CLI, sel cvd.InstanceSelector) error {
102+
return cvd.LazySelectInstance(sel).Restart()
103+
}
104+
99105
type startScreenRecordingCvdCommand struct{}
100106

101107
func (a *startScreenRecordingCvdCommand) exec(cvd *cvd.CLI, sel cvd.InstanceSelector) error {

0 commit comments

Comments
 (0)