lib/WWW/Hetzner/Robot/CLI/Cmd/Boot/Cmd/Windows.pm

filter: Statementstmt 84.0% 37 / 44 Branchbran 41.6% 10 / 24 Conditioncond 45.4% 5 / 11 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 62.6% 57 / 91 CC 18 SCAR 27.3
CC
18
Cov
66%
execute
23.5
_print_windows
11.1
BEGIN
1.0
CRAP 15.4
« 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
BranchTrueFalseTotal
my $server_number = $args->[0] or die "Usage: hrobot.pl boot windows <server-number> [--enable --os <os> --lang <lang> | --disable]\n" 1 0 1
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
BranchTrueFalseTotal
if $self->enable and $self->disable 0 1 1
Condition33%1/3
$self->enable and $self->disable
!ll&&!rl&&r
100
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
ABresult
0X0
100
111
46 if $self->enable && $self->disable;
47  
48 1 my $windows;
49 1 ▶ if ($self->enable) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->enable) { } 0 1 1
elsif ($self->disable) { } 0 1 1
50 0 ▶ die "--os is required with --enable\n" unless $self->os;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->os 0 0 0
51 0 ▶ die "--lang is required with --enable\n" unless $self->lang;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->lang 0 0 0
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
BranchTrueFalseTotal
if ($root->output eq 'json') { } 0 1 1
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
BranchTrueFalseTotal
if $self->enable 0 1 1
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
BranchTrueFalseTotal
if ref $os eq "ARRAY" 1 0 1
77 1 my $lang = $w->{lang};
78 1 ▶ $lang = join(', ', @$lang) if ref $lang eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $lang eq "ARRAY" 1 0 1
79 1 ▶ print "Server Number: ", $w->{server_number} // '', "\n";
Condition50%1/2
$w->{"server_number"} // ""
l!l
10
MC/DC0%0/1
$w->{"server_number"} // ""
$w->{"server_number"}
Truth table50%1/2
A
A= $w->{"server_number"}
Aresult
11
00
80 1 ▶ print "Server IP: ", $w->{server_ip} // '', "\n";
Condition50%1/2
$w->{"server_ip"} // ""
l!l
10
MC/DC0%0/1
$w->{"server_ip"} // ""
$w->{"server_ip"}
Truth table50%1/2
A
A= $w->{"server_ip"}
Aresult
11
00
81 1 ▶ print "Active: ", $w->{active} ? 'yes' : 'no', "\n";
Branch: 1 branch
BranchTrueFalseTotal
$w->{'active'} ? : 0 1 1
82 1 ▶ print "OS: ", $os // '', "\n";
Condition50%1/2
$os // ""
l!l
10
MC/DC0%0/1
$os // ""
$os
Truth table50%1/2
A
A= $os
Aresult
11
00
83 1 ▶ print "Lang: ", $lang // '', "\n";
Condition50%1/2
$lang // ""
l!l
10
MC/DC0%0/1
$lang // ""
$lang
Truth table50%1/2
A
A= $lang
Aresult
11
00
84 1 ▶ print "Password: ", $w->{password}, "\n" if defined $w->{password};
Branch: 1 branch
BranchTrueFalseTotal
if defined $w->{"password"} 0 1 1
85 }
86  
87 1 1.
88  
89 __END__
« lib/WWW/Hetzner/Robot/CLI/Cmd/Boot/Cmd/Vnc.pm ↑ Summary lib/WWW/Hetzner/Robot/CLI/Cmd/Server/Cmd/Describe.pm »