| 1 | package App::Ordo::Command::Cluster::Kill; | ||
| 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 kill" } | ||
| 9 | sub summary { "Kill all running jobs in a cluster" } | ||
| 10 | sub usage { "<path>" } | ||
| 11 | |||
| 12 | sub option_spec { | ||
| 13 | return {}; | ||
| 14 | } | ||
| 15 | |||
| 16 | sub execute { | ||
| 17 | my ($self, $opt, $name) = @_; | ||
| 18 | |||
| 19 | unless ($name) { | ||
| 20 | say colored(["bold red"], "Usage: cluster kill <path>"); | ||
| 21 | return; | ||
| 22 | } | ||
| 23 | |||
| 24 | my $payload = { name => $name }; | ||
| 25 | |||
| 26 | my $res = $self->api->call('kill_cluster', $payload); | ||
| 27 | |||
| 28 | if ($res->{success}) { | ||
| 29 | say colored(["bold yellow"], "All running jobs in cluster '$name' killed"); | ||
| 30 | } else { | ||
| 31 | say colored(["bold red"], "Failed to kill cluster: " . ($res->{message} || 'unknown error')); | ||
| 32 | } | ||
| 33 | } | ||
| 34 | |||
| 35 | 1; |