« lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Snapshot/Cmd/Describe.pm
↑ Summary
lib/WWW/Hetzner/Robot/CLI/Cmd/Boot/Cmd/Rescue.pm »
| 1 | package WWW::Hetzner::Robot::CLI::Cmd::Boot; | ||||||||||||||||||||
| 2 | # ABSTRACT: Robot boot configuration commands | ||||||||||||||||||||
| 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 boot <server-number> | hrobot.pl boot [rescue|linux|vnc|windows] <server-number> [options]'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 2 | ▶ | sub execute { | ||||||||||||||||||
|
Subroutine
execute: called CC=9 SCAR=24.1
Pod
documented
| |||||||||||||||||||||
| 13 | 2 | my ($self, $args, $chain) = @_; | |||||||||||||||||||
| 14 | 2 | my $root = $chain->[0]; | |||||||||||||||||||
| 15 | 2 | my $robot = $root->robot; | |||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 2 | ▶ | my $server_number = $args->[0] or die "Usage: hrobot.pl boot <server-number>\n"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | 1 | my $boot = $robot->boot->get($server_number); | |||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 1 | ▶ | if ($root->output eq 'json') { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 22 | 0 | require JSON::MaybeXS; | |||||||||||||||||||
| 23 | 0 | print JSON::MaybeXS::encode_json($boot); | |||||||||||||||||||
| 24 | 0 | print "\n"; | |||||||||||||||||||
| 25 | } else { | ||||||||||||||||||||
| 26 | 1 | printf "%-10s %-8s %s\n", 'OPTION', 'ACTIVE', 'AVAILABLE'; | |||||||||||||||||||
| 27 | 1 | for my $variant (qw(rescue linux vnc windows)) { | |||||||||||||||||||
| 28 | 4 | ▶ | my $o = $boot->{$variant} or next; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 29 | 4 | ▶ | my $available = $o->{os} // $o->{dist}; | ||||||||||||||||||
|
Condition66%2/3
$o->{"os"} // $o->{"dist"}
MC/DC0%0/2
$o->{"os"} // $o->{"dist"}
$o->{"os"}
$o->{"dist"}
Truth table66%2/3
A // B
A= $o->{"os"}B= $o->{"dist"}
| |||||||||||||||||||||
| 30 | 4 | ▶ | $available = join(', ', @$available) if ref $available eq 'ARRAY'; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 31 | printf "%-10s %-8s %s\n", | ||||||||||||||||||||
| 32 | $variant, | ||||||||||||||||||||
| 33 | 4 | ▶ | $o->{active} ? 'yes' : 'no', | ||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$available // ""
MC/DC0%0/1
$available // ""
$available
Truth table50%1/2
A
A= $available
| |||||||||||||||||||||
| 34 | $available // ''; | ||||||||||||||||||||
| 35 | } | ||||||||||||||||||||
| 36 | } | ||||||||||||||||||||
| 37 | } | ||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | 1 | 1. | |||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | __END__ | ||||||||||||||||||||