| 1 | package WWW::Hetzner::Robot::CLI::Cmd::Reset; | ||||||||||
| 2 | # ABSTRACT: Reset a dedicated server | ||||||||||
| 3 | |||||||||||
| 4 | 1 | our $VERSION = '0.102'; | |||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use MooX::Cmd; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use MooX::Options protect_argv => 0, usage_string => 'USAGE: hrobot.pl reset <server-number> [--type sw|hw|man]'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | |||||||||||
| 11 | 1 | option type => ( | |||||||||
| 12 | is => 'ro', | ||||||||||
| 13 | format => 's', | ||||||||||
| 14 | short => 't', | ||||||||||
| 15 | doc => 'Reset type: sw (software), hw (hardware), man (manual)', | ||||||||||
| 16 | default => 'sw', | ||||||||||
| 17 | ); | ||||||||||
| 18 | |||||||||||
| 19 | 1 | ▶ | sub execute { | ||||||||
|
Subroutine
execute: called CC=3 SCAR=12.3
Pod
undocumented
| |||||||||||
| 20 | 1 | my ($self, $args, $chain) = @_; | |||||||||
| 21 | 1 | my $root = $chain->[0]; | |||||||||
| 22 | 1 | my $robot = $root->robot; | |||||||||
| 23 | |||||||||||
| 24 | 1 | ▶ | my $server_number = $args->[0] or die "Usage: hrobot.pl reset <server-number> [--type sw|hw|man]\n"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | |||||||||||
| 26 | 1 | my $result = $robot->reset->execute($server_number, $self->type); | |||||||||
| 27 | |||||||||||
| 28 | 1 | ▶ | if ($root->output eq 'json') { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | 0 | require JSON::MaybeXS; | |||||||||
| 30 | 0 | print JSON::MaybeXS::encode_json($result); | |||||||||
| 31 | 0 | print "\n"; | |||||||||
| 32 | } else { | ||||||||||
| 33 | 1 | print "Reset initiated for server $server_number (type: ", $self->type, ")\n"; | |||||||||
| 34 | } | ||||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | 1 | 1; | |||||||||
| 38 | |||||||||||
| 39 | __END__ | ||||||||||