| 1 | package Tapper::CLI::Cobbler; | ||||||||||||||||||||||||||||
| 2 | 72 | our $AUTHORITY = 'cpan:TAPPER'; | |||||||||||||||||||||||||||
| 3 | 72 | $Tapper::CLI::Cobbler::VERSION = '5.0.8'; | |||||||||||||||||||||||||||
| 4 | 72 | ▶ | use 5.010; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 72 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 72 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | sub host_new | ||||||||||||||||||||||||||||
| 13 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
host_new: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 14 | 0 | my ($c) = @_; | |||||||||||||||||||||||||||
| 15 | 0 | $c->getopt( 'name=s','from=s', 'mac=s', 'quiet|q', 'help|?' ); | |||||||||||||||||||||||||||
| 16 | 0 | ▶ | if ( $c->options->{help} or not $c->options->{name}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$c->options->{"help"} or not $c->options->{"name"}
MC/DC0%0/2
$c->options->{"help"} or not $c->options->{"name"}
$c->options->{"help"}
not $c->options->{"name"}
Truth table0%0/3
A or not(B)
A= $c->options->{"help"}B= not $c->options->{"name"}
| |||||||||||||||||||||||||||||
| 17 | 0 | ▶ | say STDERR "Missing required parameter --name!" unless $c->options->{name}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 18 | 0 | say STDERR "$0 cobbler-host-add --name=s [ --quiet|q ] [ --from=s ]"; | |||||||||||||||||||||||||||
| 19 | 0 | say STDERR "\n\ Required Arguments:"; | |||||||||||||||||||||||||||
| 20 | 0 | say STDERR " --name Name of the new system"; | |||||||||||||||||||||||||||
| 21 | 0 | say STDERR "\n Optional arguments:"; | |||||||||||||||||||||||||||
| 22 | 0 | say STDERR " --from Copy values of that system, default value is 'default'"; | |||||||||||||||||||||||||||
| 23 | 0 | say STDERR " --mac Provide mac address (will try to fetch from database if empty)"; | |||||||||||||||||||||||||||
| 24 | 0 | say STDERR " --quit Stay silent"; | |||||||||||||||||||||||||||
| 25 | 0 | say STDERR " --help Print this help message and exit"; | |||||||||||||||||||||||||||
| 26 | 0 | exit -1; | |||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | 0 | my $name = $c->options->{name}; | |||||||||||||||||||||||||||
| 29 | 0 | my %options; | |||||||||||||||||||||||||||
| 30 | 0 | $options{default} = $c->options->{default}; | |||||||||||||||||||||||||||
| 31 | 0 | $options{mac} = $c->options->{mac}; | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 0 | require Tapper::Cmd::Cobbler; | |||||||||||||||||||||||||||
| 34 | 0 | my $cmd = Tapper::Cmd::Cobbler->new(); | |||||||||||||||||||||||||||
| 35 | 0 | my $output = $cmd->host_new($name, \%options); | |||||||||||||||||||||||||||
| 36 | 0 | ▶ | return $output if $output; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 0 | ▶ | if (not $c->options->{quiet}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | 0 | return "Added host $name to cobbler"; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | 0 | return; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | sub host_del | ||||||||||||||||||||||||||||
| 46 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
host_del: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 47 | 0 | my ($c) = @_; | |||||||||||||||||||||||||||
| 48 | 0 | $c->getopt( 'name=s', 'quiet|q', 'help|?' ); | |||||||||||||||||||||||||||
| 49 | 0 | ▶ | if ( $c->options->{help} or not $c->options->{name}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$c->options->{"help"} or not $c->options->{"name"}
MC/DC0%0/2
$c->options->{"help"} or not $c->options->{"name"}
$c->options->{"help"}
not $c->options->{"name"}
Truth table0%0/3
A or not(B)
A= $c->options->{"help"}B= not $c->options->{"name"}
| |||||||||||||||||||||||||||||
| 50 | 0 | ▶ | say STDERR "Missing required parameter --name!" unless $c->options->{name}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | 0 | say STDERR "$0 cobbler-host-del --name=s [ --quiet|q ]"; | |||||||||||||||||||||||||||
| 52 | 0 | say STDERR "\n\ Required Arguments:"; | |||||||||||||||||||||||||||
| 53 | 0 | say STDERR " --name Name of the new system"; | |||||||||||||||||||||||||||
| 54 | 0 | say STDERR "\n Optional arguments:"; | |||||||||||||||||||||||||||
| 55 | 0 | say STDERR " --quiet Stay silent"; | |||||||||||||||||||||||||||
| 56 | 0 | say STDERR " --help Print this help message and exit"; | |||||||||||||||||||||||||||
| 57 | 0 | exit -1; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | 0 | my $name = $c->options->{name}; | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 0 | require Tapper::Cmd::Cobbler; | |||||||||||||||||||||||||||
| 62 | 0 | my $cmd = Tapper::Cmd::Cobbler->new(); | |||||||||||||||||||||||||||
| 63 | 0 | my $output = $cmd->host_del($name); | |||||||||||||||||||||||||||
| 64 | 0 | ▶ | die $output if $output; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 0 | ▶ | if (not $c->options->{quiet}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | 0 | return "Host $name removed from cobbler"; | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | 0 | return; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | sub host_list | ||||||||||||||||||||||||||||
| 75 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
host_list: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 76 | 0 | my ($c) = @_; | |||||||||||||||||||||||||||
| 77 | 0 | $c->getopt( 'name=s', 'status', 'help|?' ); | |||||||||||||||||||||||||||
| 78 | 0 | ▶ | if ( $c->options->{help}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | 0 | say STDERR "\n Optional arguments:"; | |||||||||||||||||||||||||||
| 80 | 0 | say STDERR " --name Show system with that name"; | |||||||||||||||||||||||||||
| 81 | 0 | say STDERR " --status Show system with that status (one of development,testing,acceptance,production)"; | |||||||||||||||||||||||||||
| 82 | 0 | say STDERR " --help Print this help message and exit"; | |||||||||||||||||||||||||||
| 83 | 0 | exit -1; | |||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 0 | require Tapper::Cmd::Cobbler; | |||||||||||||||||||||||||||
| 87 | 0 | my $cmd = Tapper::Cmd::Cobbler->new(); | |||||||||||||||||||||||||||
| 88 | 0 | my @output = $cmd->host_list(); | |||||||||||||||||||||||||||
| 89 | 0 | print join "\n",@output; | |||||||||||||||||||||||||||
| 90 | 0 | return; | |||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | sub setup | ||||||||||||||||||||||||||||
| 96 | 71 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
setup: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 97 | 71 | my ($c) = @_; | |||||||||||||||||||||||||||
| 98 | 71 | $c->register('cobbler-host-add', \&host_new, 'Add a new host to cobbler by copying from existing one'); | |||||||||||||||||||||||||||
| 99 | 71 | $c->register('cobbler-host-new', \&host_new, 'Alias for cobbler-host-add'); | |||||||||||||||||||||||||||
| 100 | 71 | $c->register('cobbler-host-del', \&host_del, 'Remove an existing host from cobbler'); | |||||||||||||||||||||||||||
| 101 | 71 | $c->register('cobbler-host-list', \&host_list, 'Show host known to cobbler'); | |||||||||||||||||||||||||||
| 102 | 71 | ▶ | if ($c->can('group_commands')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 103 | 0 | $c->group_commands('Cobbler commands', 'cobbler-host-add', 'cobbler-host-new', 'cobbler-host-del', 'cobbler-host-list' ); | |||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | 71 | return; | |||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 72 | 1; # End of Tapper::CLI | |||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | __END__ | ||||||||||||||||||||||||||||