« lib/WWW/Hetzner/Robot/CLI/Cmd/Boot/Cmd/Vnc.pm
↑ Summary
lib/WWW/Hetzner/Robot/CLI/Cmd/Server/Cmd/Describe.pm »
| 1 | package WWW::Hetzner::Robot::CLI::Cmd::Boot::Cmd::Windows; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Windows 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 windows <server-number> [--enable --os <os> --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 Windows installation', | ||||||||||||||||||||||||||||
| 15 | default => 0, | ||||||||||||||||||||||||||||
| 16 | ); | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 1 | option disable => ( | |||||||||||||||||||||||||||
| 19 | is => 'ro', | ||||||||||||||||||||||||||||
| 20 | short => 'd', | ||||||||||||||||||||||||||||
| 21 | doc => 'Deactivate the Windows installation', | ||||||||||||||||||||||||||||
| 22 | default => 0, | ||||||||||||||||||||||||||||
| 23 | ); | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 1 | option os => ( | |||||||||||||||||||||||||||
| 26 | is => 'ro', | ||||||||||||||||||||||||||||
| 27 | format => 's', | ||||||||||||||||||||||||||||
| 28 | doc => 'Windows edition 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 | ▶ | sub execute { | ||||||||||||||||||||||||||
|
Subroutine
execute: called CC=10 SCAR=31.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 38 | 1 | my ($self, $args, $chain) = @_; | |||||||||||||||||||||||||||
| 39 | 1 | my $root = $chain->[0]; | |||||||||||||||||||||||||||
| 40 | 1 | my $robot = $root->robot; | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 1 | ▶ | my $server_number = $args->[0] | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | or die "Usage: hrobot.pl boot windows <server-number> [--enable --os <os> --lang <lang> | --disable]\n"; | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 1 | ▶ | 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
| |||||||||||||||||||||||||||||
| 46 | if $self->enable && $self->disable; | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 1 | my $windows; | |||||||||||||||||||||||||||
| 49 | 1 | ▶ | if ($self->enable) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 50 | 0 | ▶ | die "--os is required with --enable\n" unless $self->os; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | 0 | ▶ | die "--lang is required with --enable\n" unless $self->lang; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | 0 | $windows = $robot->boot->enable_windows( | |||||||||||||||||||||||||||
| 53 | $server_number, | ||||||||||||||||||||||||||||
| 54 | os => $self->os, | ||||||||||||||||||||||||||||
| 55 | lang => $self->lang, | ||||||||||||||||||||||||||||
| 56 | ); | ||||||||||||||||||||||||||||
| 57 | } elsif ($self->disable) { | ||||||||||||||||||||||||||||
| 58 | 0 | $windows = $robot->boot->disable_windows($server_number); | |||||||||||||||||||||||||||
| 59 | } else { | ||||||||||||||||||||||||||||
| 60 | 1 | $windows = $robot->boot->windows($server_number); | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 1 | ▶ | if ($root->output eq 'json') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | 0 | require JSON::MaybeXS; | |||||||||||||||||||||||||||
| 65 | 0 | print JSON::MaybeXS::encode_json($windows); | |||||||||||||||||||||||||||
| 66 | 0 | print "\n"; | |||||||||||||||||||||||||||
| 67 | } else { | ||||||||||||||||||||||||||||
| 68 | 1 | _print_windows($windows); | |||||||||||||||||||||||||||
| 69 | 1 | ▶ | print "\nReset the server to start the installation.\n" if $self->enable; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 1 | ▶ | sub _print_windows { | ||||||||||||||||||||||||||
|
Subroutine
_print_windows: called CC=9 SCAR=24.1
| |||||||||||||||||||||||||||||
| 74 | 1 | my ($w) = @_; | |||||||||||||||||||||||||||
| 75 | 1 | my $os = $w->{os}; | |||||||||||||||||||||||||||
| 76 | 1 | ▶ | $os = join(', ', @$os) if ref $os eq 'ARRAY'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | 1 | my $lang = $w->{lang}; | |||||||||||||||||||||||||||
| 78 | 1 | ▶ | $lang = join(', ', @$lang) if ref $lang eq 'ARRAY'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | 1 | ▶ | print "Server Number: ", $w->{server_number} // '', "\n"; | ||||||||||||||||||||||||||
|
Condition50%1/2
$w->{"server_number"} // ""
MC/DC0%0/1
$w->{"server_number"} // ""
$w->{"server_number"}
Truth table50%1/2
A
A= $w->{"server_number"}
| |||||||||||||||||||||||||||||
| 80 | 1 | ▶ | print "Server IP: ", $w->{server_ip} // '', "\n"; | ||||||||||||||||||||||||||
|
Condition50%1/2
$w->{"server_ip"} // ""
MC/DC0%0/1
$w->{"server_ip"} // ""
$w->{"server_ip"}
Truth table50%1/2
A
A= $w->{"server_ip"}
| |||||||||||||||||||||||||||||
| 81 | 1 | ▶ | print "Active: ", $w->{active} ? 'yes' : 'no', "\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 82 | 1 | ▶ | print "OS: ", $os // '', "\n"; | ||||||||||||||||||||||||||
|
Condition50%1/2
$os // ""
MC/DC0%0/1
$os // ""
$os
Truth table50%1/2
A
A= $os
| |||||||||||||||||||||||||||||
| 83 | 1 | ▶ | print "Lang: ", $lang // '', "\n"; | ||||||||||||||||||||||||||
|
Condition50%1/2
$lang // ""
MC/DC0%0/1
$lang // ""
$lang
Truth table50%1/2
A
A= $lang
| |||||||||||||||||||||||||||||
| 84 | 1 | ▶ | print "Password: ", $w->{password}, "\n" if defined $w->{password}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 1 | 1. | |||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | __END__ | ||||||||||||||||||||||||||||