| 1 | package App::Ordo::Command::Cluster::Reset; | ||
| 2 | use Moo; | ||
| 3 | use feature qw(say); | ||
| 4 | extends 'App::Ordo::Command::Base'; | ||
| 5 | |||
| 6 | use Term::ANSIColor qw(colored); | ||
| 7 | |||
| 8 | sub name { "cluster reset" } | ||
| 9 | sub summary { "Reset cluster and all jobs to ready state" } | ||
| 10 | sub usage { "<path>" } | ||
| 11 | |||
| 12 | sub option_spec { {} } | ||
| 13 | |||
| 14 | sub execute { | ||
| 15 | my ($self, $opt, $path) = @_; | ||
| 16 | |||
| 17 | unless ($path) { | ||
| 18 | say colored(["bold red"], "Usage: cluster reset <path>"); | ||
| 19 | return; | ||
| 20 | } | ||
| 21 | |||
| 22 | my $res = $self->api->call('reset_cluster', { name => $path }); | ||
| 23 | |||
| 24 | if ($res->{success}) { | ||
| 25 | say colored(["bold cyan"], "Cluster '$path' and all jobs reset to ready"); | ||
| 26 | } else { | ||
| 27 | say colored(["bold red"], "Failed: " . ($res->{message} || 'unknown error')); | ||
| 28 | } | ||
| 29 | } | ||
| 30 | |||
| 31 | 1; |