Skip to content

Commit

Permalink
feat(instance): add wait command
Browse files Browse the repository at this point in the history
  • Loading branch information
kindermoumoute committed Feb 26, 2020
1 parent 0f259d3 commit 052e0cf
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/namespaces/instance/v1/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func GetCommands() *core.Commands {
serverStopCommand(),
serverStandbyCommand(),
serverRebootCommand(),
serverWaitCommand(),
serverDeleteCommand(),
serverAttachVolumeCommand(),
serverDetachVolumeCommand(),
Expand Down
21 changes: 21 additions & 0 deletions internal/namespaces/instance/v1/custom_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,27 @@ func serverRebootCommand() *core.Command {
}
}

func serverWaitCommand() *core.Command {
return &core.Command{
Short: `Wait for server to reach a stable state`,
Long: `Wait for server to reach a stable state. This command is equivalent to using the --wait flag when performing an action on a server.`,
Namespace: "instance",
Resource: "server",
Verb: "wait",
ArgsType: reflect.TypeOf(instanceActionRequest{}),
Run: func(ctx context.Context, argsI interface{}) (i interface{}, err error) {
return waitForServerFunc()(ctx, argsI, nil)
},
ArgSpecs: serverActionArgSpecs,
Examples: []*core.Example{
{
Short: "Wait for a server to reach a stable state",
Request: `{"server_id": "11111111-1111-1111-1111-111111111111"}`,
},
},
}
}

func waitForServerFunc() core.WaitFunc {
return func(ctx context.Context, argsI, _ interface{}) (interface{}, error) {
return instance.NewAPI(core.ExtractClient(ctx)).WaitForServer(&instance.WaitForServerRequest{
Expand Down

0 comments on commit 052e0cf

Please sign in to comment.