« lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Subaccount/Cmd/Update.pm
↑ Summary
lib/WWW/Hetzner/CLI/Cmd/Iso.pm »
| 1 | package WWW::Hetzner::Robot::CLI::Cmd::Boot::Cmd::Linux; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Linux installation boot configuration | ||||||||||||||||||||||||||||
| 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 linux <server-number> [--enable --dist <dist> --lang <lang> | --disable]'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 1 | option enable => ( | |||||||||||||||||||||||||||
| 12 | is => 'ro', | ||||||||||||||||||||||||||||
| 13 | short => 'e', | ||||||||||||||||||||||||||||
| 14 | doc => 'Activate the Linux installation', | ||||||||||||||||||||||||||||
| 15 | default => 0, | ||||||||||||||||||||||||||||
| 16 | ); | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 1 | option disable => ( | |||||||||||||||||||||||||||
| 19 | is => 'ro', | ||||||||||||||||||||||||||||
| 20 | short => 'd', | ||||||||||||||||||||||||||||
| 21 | doc => 'Deactivate the Linux installation', | ||||||||||||||||||||||||||||
| 22 | default => 0, | ||||||||||||||||||||||||||||
| 23 | ); | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 1 | option dist => ( | |||||||||||||||||||||||||||
| 26 | is => 'ro', | ||||||||||||||||||||||||||||
| 27 | format => 's', | ||||||||||||||||||||||||||||
| 28 | doc => 'Distribution to install - required with --enable', | ||||||||||||||||||||||||||||
| 29 | ); | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 1 | option lang => ( | |||||||||||||||||||||||||||
| 32 | is => 'ro', | ||||||||||||||||||||||||||||
| 33 | format => 's', | ||||||||||||||||||||||||||||
| 34 | doc => 'Installation language - required with --enable', | ||||||||||||||||||||||||||||
| 35 | ); | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 1 | option key => ( | |||||||||||||||||||||||||||
| 38 | is => 'ro', | ||||||||||||||||||||||||||||
| 39 | format => 's@', | ||||||||||||||||||||||||||||
| 40 | doc => 'Authorized SSH key fingerprint (repeatable)', | ||||||||||||||||||||||||||||
| 41 | autosplit => ',', | ||||||||||||||||||||||||||||
| 42 | ); | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 2 | ▶ | sub execute { | ||||||||||||||||||||||||||
|
Subroutine
execute: called CC=11 SCAR=27.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 45 | 2 | my ($self, $args, $chain) = @_; | |||||||||||||||||||||||||||
| 46 | 2 | my $root = $chain->[0]; | |||||||||||||||||||||||||||
| 47 | 2 | my $robot = $root->robot; | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 2 | ▶ | my $server_number = $args->[0] | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | or die "Usage: hrobot.pl boot linux <server-number> [--enable --dist <dist> --lang <lang> | --disable]\n"; | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 2 | ▶ | die "--enable and --disable are mutually exclusive\n" | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->enable and $self->disable
MC/DC0%0/2
$self->enable and $self->disable
$self->enable
$self->disable
Truth table33%1/3
A and B
A= $self->enableB= $self->disable
| |||||||||||||||||||||||||||||
| 53 | if $self->enable && $self->disable; | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 2 | my $linux; | |||||||||||||||||||||||||||
| 56 | 2 | ▶ | if ($self->enable) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 57 | 2 | ▶ | die "--dist is required with --enable\n" unless $self->dist; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | 2 | ▶ | die "--lang is required with --enable\n" unless $self->lang; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | 2 | ▶ | $linux = $robot->boot->enable_linux( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | $server_number, | ||||||||||||||||||||||||||||
| 61 | dist => $self->dist, | ||||||||||||||||||||||||||||
| 62 | lang => $self->lang, | ||||||||||||||||||||||||||||
| 63 | ($self->key ? (authorized_key => $self->key) : ()), | ||||||||||||||||||||||||||||
| 64 | ); | ||||||||||||||||||||||||||||
| 65 | } elsif ($self->disable) { | ||||||||||||||||||||||||||||
| 66 | 0 | $linux = $robot->boot->disable_linux($server_number); | |||||||||||||||||||||||||||
| 67 | } else { | ||||||||||||||||||||||||||||
| 68 | 0 | $linux = $robot->boot->linux($server_number); | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 2 | ▶ | if ($root->output eq 'json') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | 1 | require JSON::MaybeXS; | |||||||||||||||||||||||||||
| 73 | 1 | print JSON::MaybeXS::encode_json($linux); | |||||||||||||||||||||||||||
| 74 | 1 | print "\n"; | |||||||||||||||||||||||||||
| 75 | } else { | ||||||||||||||||||||||||||||
| 76 | 1 | _print_install($linux); | |||||||||||||||||||||||||||
| 77 | 1 | ▶ | print "\nReset the server to start the installation.\n" if $self->enable; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 1 | ▶ | sub _print_install { | ||||||||||||||||||||||||||
|
Subroutine
_print_install: called CC=9 SCAR=24.1
| |||||||||||||||||||||||||||||
| 82 | 1 | my ($i) = @_; | |||||||||||||||||||||||||||
| 83 | 1 | my $dist = $i->{dist}; | |||||||||||||||||||||||||||
| 84 | 1 | ▶ | $dist = join(', ', @$dist) if ref $dist eq 'ARRAY'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 85 | 1 | my $lang = $i->{lang}; | |||||||||||||||||||||||||||
| 86 | 1 | ▶ | $lang = join(', ', @$lang) if ref $lang eq 'ARRAY'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 87 | 1 | ▶ | print "Server Number: ", $i->{server_number} // '', "\n"; | ||||||||||||||||||||||||||
|
Condition50%1/2
$i->{"server_number"} // ""
MC/DC0%0/1
$i->{"server_number"} // ""
$i->{"server_number"}
Truth table50%1/2
A
A= $i->{"server_number"}
| |||||||||||||||||||||||||||||
| 88 | 1 | ▶ | print "Server IP: ", $i->{server_ip} // '', "\n"; | ||||||||||||||||||||||||||
|
Condition50%1/2
$i->{"server_ip"} // ""
MC/DC0%0/1
$i->{"server_ip"} // ""
$i->{"server_ip"}
Truth table50%1/2
A
A= $i->{"server_ip"}
| |||||||||||||||||||||||||||||
| 89 | 1 | ▶ | print "Active: ", $i->{active} ? 'yes' : 'no', "\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 90 | 1 | ▶ | print "Dist: ", $dist // '', "\n"; | ||||||||||||||||||||||||||
|
Condition50%1/2
$dist // ""
MC/DC0%0/1
$dist // ""
$dist
Truth table50%1/2
A
A= $dist
| |||||||||||||||||||||||||||||
| 91 | 1 | ▶ | print "Lang: ", $lang // '', "\n"; | ||||||||||||||||||||||||||
|
Condition50%1/2
$lang // ""
MC/DC0%0/1
$lang // ""
$lang
Truth table50%1/2
A
A= $lang
| |||||||||||||||||||||||||||||
| 92 | 1 | ▶ | print "Password: ", $i->{password}, "\n" if defined $i->{password}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 1 | 1. | |||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | __END__ | ||||||||||||||||||||||||||||