| 1 | package Tapper::CLI::Host; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 72 | our $AUTHORITY = 'cpan:TAPPER'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 72 | $Tapper::CLI::Host::VERSION = '5.0.8'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 72 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 72 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 72 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 72 | ▶ | use English qw/ -no_match_vars /; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | sub host_feature_summary | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
host_feature_summary: called CC=1 SCAR=2.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | my ($host) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | return join(",", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | map { $_->value } | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | sort { $a->entry cmp $b->entry } | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | grep { $_->entry =~ /^(key_word|socket_type|revision)$/ } | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | $host->features->all | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | sub i_add_queues { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
i_add_queues: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | my ( $or_host, $s_type, $ar_queues ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | require Tapper::Model; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | my $i_success_counter = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | foreach my $s_queue ( @{$ar_queues} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | my $or_queue = | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | Tapper::Model::model('TestrunDB') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | ->resultset('Queue') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | ->search({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | name => $s_queue, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | },{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | prefetch => [qw/ queuehosts deniedhosts /], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | ->first | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | if ( $s_type eq 'bound' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | if ( grep { $_ == $or_host->id } $or_queue->deniedhosts->get_column('host_id')->all ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | die "error: you cannot add an bound-queue '$s_queue' for a already denied queue for host '" . $or_host->name . "'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | elsif ( grep { $_ == $or_host->id } $or_queue->queuehosts->get_column('host_id')->all ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | die "error: queue '$s_queue' already bound to host '" . $or_host->name . "'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | Tapper::Model::model('TestrunDB') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | ->resultset('QueueHost') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | ->new({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | host_id => $or_host->id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | queue_id => $or_queue->id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | ->insert() | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | $i_success_counter++; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | die "error: cannot add queue '$s_queue'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | elsif ( $s_type eq 'denied' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | if ( $or_queue->queuehosts->count ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | die "error: you cannot add an denied-queue '$s_queue' for a already bind queue for host '" . $or_host->name . "'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | elsif ( $or_queue->deniedhosts->count ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | die "error: queue '$s_queue' already denied for host '" . $or_host->name . "'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | Tapper::Model::model('TestrunDB') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | ->resultset('DeniedHost') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | ->new({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | host_id => $or_host->id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | queue_id => $or_queue->id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | ->insert() | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | $i_success_counter++; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | die "error: cannot add queue '$s_queue'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | warn "unknown type '$s_type' for sub i_delete_queues"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | die "error: internal processing error\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | die "error: did not find queue '$s_queue'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | return $i_success_counter; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | sub i_delete_queues { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
i_delete_queues: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | my ( $or_host, $s_type, $ar_queues ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | my $s_relation_table; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | if ( $s_type eq 'bound' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | $s_relation_table = 'QueueHost'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | elsif ( $s_type eq 'denied' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | $s_relation_table = 'DeniedHost'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | die "error: unknown type '$s_type' for sub i_delete_queues\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | require Tapper::Model; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | my $i_success_counter = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | foreach my $s_queue ( @{$ar_queues} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | if ( $s_queue eq '' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | Tapper::Model::model('TestrunDB') | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | ->resultset( $s_relation_table ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | ->search({host_id => $or_host->id}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | ->delete_all | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | my $or_queue = | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | Tapper::Model::model('TestrunDB') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | ->resultset('Queue') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | ->search({name => $s_queue}, {rows => 1}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | ->first | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | my $or_queue_host = | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | Tapper::Model::model('TestrunDB') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | ->resultset( $s_relation_table ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | ->search({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | host_id => $or_host->id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | queue_id => $or_queue->id | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | if ( $or_queue_host->count ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | $i_success_counter += $or_queue_host->delete_all; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | die "error: queue '$s_queue' isn't related with host '" . $or_host->name . "'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | die "error: no such queue '$s_queue'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | return $i_success_counter; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 2 | ▶ | sub b_update_grub { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
b_update_grub: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 2 | my ( $s_hostname ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 2 | require Tapper::Model; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 2 | Tapper::Model::model('TestrunDB') | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | ->resultset('Message') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | ->new({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | type => 'action', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | message => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | action => 'updategrub', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | host => $s_hostname, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | ->insert | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 1 | ▶ | sub hr_get_hosts_by_options { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hr_get_hosts_by_options: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 1 | my ( $hr_options ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 1 | require Tapper::Model; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | my %h_host_ids = map { $_ => q## } @{$hr_options->{id}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 1 | foreach my $s_name ( @{$hr_options->{name}} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 1 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | my $or_host = | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | Tapper::Model::model('TestrunDB') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | ->resultset('Host') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | ->find({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | name => $s_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | is_deleted => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 1 | $h_host_ids{$or_host->id} = $or_host; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | die "error: Can't find host by name '$s_name'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 1 | return \%h_host_ids; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | sub ar_get_free_host_parameters { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ar_get_free_host_parameters: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | 'id|i=i@' , 'free particular hosts', 'Can be given multiple times.', | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 'name|n=s@' , 'free by host name', 'Can be given multiple times.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 'comment|c=s' , 'describe why the host is freed', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 'verbose|v' , 'print all output, without only print ids', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 'help|?' , 'Print this help message and exit.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | sub b_free_host { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
b_free_host: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | my ( $or_app_rad ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | my $ar_parameters = ar_get_free_host_parameters(); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | $or_app_rad->getopt( map { $_->[0] } @{$ar_parameters} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | my $hr_options = $or_app_rad->options; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | if ( $hr_options->{help} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | say {*STDERR} "Usage: $PROGRAM_NAME host-free [options]"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | require Tapper::CLI::Base; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | Tapper::CLI::Base::b_print_help( $ar_parameters ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | if ( !$hr_options->{id} && !$hr_options->{name} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$hr_options->{"id"} or $hr_options->{"name"}
MC/DC0%0/2
$hr_options->{"id"} or $hr_options->{"name"}
$hr_options->{"id"}
$hr_options->{"name"}
Truth table0%0/3
A or B
A= $hr_options->{"id"}B= $hr_options->{"name"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | die "error: missing parameter 'id' or 'name'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | my $hr_host_ids = hr_get_hosts_by_options( $hr_options ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | my @a_sorted_hosts = sort { $hr_host_ids->{$a} cmp $hr_host_ids->{$b} } keys %{$hr_host_ids}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | foreach my $i_host_id ( @a_sorted_hosts ){ | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | my $or_host = $hr_host_ids->{$i_host_id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | # host object isn't set by loop above. look for object by id. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | if (! $or_host ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | if (! | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | $or_host = | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | Tapper::Model::model('TestrunDB') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | ->resultset('Host') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | ->find( $i_host_id ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | die "Can't find host by id '$i_host_id'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | my @a_testrun_ids = | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | Tapper::Model::model('TestrunDB') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | ->resultset('TestrunScheduling') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | ->search({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | host_id => $i_host_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | status => 'running', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | }, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | select => ['testrun_id'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | ->get_column('testrun_id') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | ->all | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | my $hr_msg = { 'state' => 'quit', }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | if ( $hr_options->{comment} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | $hr_msg->{error} = $hr_options->{comment}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | for my $i_testrun_id ( @a_testrun_ids ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | if (! | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | Tapper::Model::model('TestrunDB') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | ->resultset('Message') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | ->new({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | testrun_id => $i_testrun_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | message => $i_host_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | ->insert | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | die "freeing host failed: $i_host_id\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | if ( $hr_options->{verbose} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | say "info: freeing host successful: $i_host_id"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | say "info: host is already free: $i_host_id"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 1 | ▶ | sub ar_get_delete_parameters { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ar_get_delete_parameters: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 1 | [ 'id|i=i@' , 'delete particular hosts', 'Can be given multiple times.', ], | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | [ 'name|n=s@' , 'delete by host name', 'Can be given multiple times.', ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | [ 'force|f' , 'really execute the command', ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | [ 'verbose|v' , 'print all output, without only print ids', ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | [ 'help|?' , 'Print this help message and exit.', ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 1 | ▶ | sub b_delete { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
b_delete: called CC=11 SCAR=30.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 1 | my ( $or_app_rad ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 1 | require Tapper::Model; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 1 | my $ar_parameters = ar_get_delete_parameters(); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 1 | $or_app_rad->getopt( map { $_->[0] } @{$ar_parameters} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 1 | my $hr_options = $or_app_rad->options; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 1 | ▶ | if ( $hr_options->{help} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | say {*STDERR} "Usage: $PROGRAM_NAME host-delete [options]"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | require Tapper::CLI::Base; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | Tapper::CLI::Base::b_print_help( $ar_parameters ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 1 | ▶ | if ( !$hr_options->{id} && !$hr_options->{name} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$hr_options->{"id"} or $hr_options->{"name"}
MC/DC0%0/2
$hr_options->{"id"} or $hr_options->{"name"}
$hr_options->{"id"}
$hr_options->{"name"}
Truth table33%1/3
A or B
A= $hr_options->{"id"}B= $hr_options->{"name"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | die "error: missing parameter 'id' or 'name'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 1 | my $hr_host_ids = hr_get_hosts_by_options( $hr_options ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 1 | ▶ | if (! $hr_options->{force} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | say {*STDERR} "info: Skip actual host-delete unless --force is used."; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | foreach my $i_host_id ( sort { $hr_host_ids->{$a} cmp $hr_host_ids->{$b} } keys %{$hr_host_ids} ){ | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 1 | my $or_host = $hr_host_ids->{$i_host_id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | # host object isn't set by loop above. look for object by id. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 1 | ▶ | if (! $or_host ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | ▶ | if (! | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | $or_host = | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | Tapper::Model::model('TestrunDB') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | ->resultset('Host') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | ->find( $i_host_id ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | die "Can't find host by id '$i_host_id'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 1 | my $s_name = $or_host->name; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 1 | ▶ | if (! b_update_grub( $s_name ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | die "error: Can't update grub by id '$i_host_id'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 1 | require DateTime; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 1 | $or_host->active( 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 1 | $or_host->is_deleted( 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 1 | $or_host->updated_at( DateTime->now->strftime('%F %T') ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 1 | ▶ | if ( $or_host->update() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 1 | ▶ | if ( $hr_options->{verbose} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | say "info: Deleted host $s_name: $i_host_id"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | die "error: Can't update host by id '$i_host_id'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | sub print_hosts_verbose | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_hosts_verbose: called CC=20 SCAR=34.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 1 | my ($hosts, $verbosity_level) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 1 | ▶ | $verbosity_level //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$verbosity_level //= 0
MC/DC0%0/1
$verbosity_level //= 0
$verbosity_level
Truth table50%1/2
A
A= $verbosity_level
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | # calculate width of columns | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 1 | my %max = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | name => length('Name'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | features => length ('Features'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | comment => length('Comment'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | bindqueue => length('Bound Queues'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | denyqueue => length('Denied Queues'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | pool => length('Pool count (used/all)'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 1 | ▶ | my @a_host = $hosts->isa('DBIx::Class::ResultSet') ? $hosts->all : $hosts; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | HOST: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 1 | foreach my $host ( @a_host ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 1 | my $features = host_feature_summary($host); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 1 | ▶ | $max{name} = length($host->name) if length($host->name) > $max{name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 1 | ▶ | $max{features} = length($features) if length($features) > $max{features}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 1 | ▶ | $max{comment} = length($host->comment) if length($host->comment) > $max{comment}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 1 | my $tmp_length = length(join ", ", map {$_->queue->name} $host->queuehosts->all); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 1 | ▶ | $max{bindqueue} = $tmp_length if $tmp_length > $max{bindqueue} ; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | $tmp_length = length(join ", ", map {$_->queue->name} $host->denied_from_queue->all); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 1 | ▶ | $max{denyqueue} = $tmp_length if $tmp_length > $max{bindqueue} ; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | my ($name_length, $feature_length, $comment_length, $bq_length, $dq_length, $pool_length) = | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 1 | ($max{name}, $max{features}, $max{comment}, $max{bindqueue}, $max{denyqueue}, $max{pool}); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | # use printf to get the wanted field width | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 1 | ▶ | if ($verbosity_level > 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | printf("%5s | %${name_length}s | %-${feature_length}s | %11s | %10s | %${comment_length}s | %-${bq_length}s | %-${dq_length}s | %-${pool_length}s\n", | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 'ID', 'Name', 'Features', 'Active', 'Testrun ID', 'Comment', 'Bound Queues', 'Denied Queues', 'Pool Count (used/all)'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 1 | printf("%5s | %${name_length}s | %-${feature_length}s | %11s | %10s | %${bq_length}s | %${dq_length}s | %-${pool_length}s\n", | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 'ID', 'Name', 'Features', 'Active', 'Testrun ID', 'Bound Queues', 'Denied Queues', 'Pool Count (used/all)'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 1 | $comment_length = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 1 | say "="x(5+$name_length+$feature_length+11+length('Testrun ID')+$comment_length+$bq_length+$dq_length+$pool_length+7*length(' | ')); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 1 | require Tapper::Model; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 1 | foreach my $host ( @a_host ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 1 | my ($name_length, $feature_length, $queue_length) = ($max{name}, $max{features}, $max{queue}); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 1 | my $testrun_id = 'unknown id'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 1 | ▶ | if (not $host->free) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 1 | my $job_rs = Tapper::Model::model('TestrunDB')->resultset('TestrunScheduling')->search({host_id => $host->id, status => 'running'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 1 | ▶ | $testrun_id = $job_rs->search({}, {rows => 1})->first->testrun_id if $job_rs->count; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 1 | my $features = host_feature_summary($host); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 1 | ▶ | my $output = sprintf("%5d | %${name_length}s | %-${feature_length}s | %11s | %10s | ", | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | $host->id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | $host->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | $features, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | $host->is_deleted ? 'deleted' : ( $host->active ? 'active' : 'deactivated' ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | $host->free ? 'free' : "$testrun_id", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 1 | ▶ | if ($verbosity_level > 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | $output .= sprintf("%${comment_length}s | ", $host->comment); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | $output .= sprintf("%-${bq_length}s | %-${dq_length}s", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 1 | ▶ | $host->queuehosts->count ? join(", ", map {$_->queue->name} $host->queuehosts->all) : '', | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | ▶ | $host->denied_from_queue->count ? join(", ", map {$_->queue->name} $host->denied_from_queue->all) : '' | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 1 | ▶ | $output .= sprintf(" | %-${pool_length}s", $host->is_pool ? ($host->pool_count-$host->pool_free)."/".$host->pool_count : '-'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 1 | say $output; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | sub select_hosts | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
select_hosts: called CC=7 SCAR=19.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 3 | my ($opt) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 3 | my %options= (order_by => 'name'); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 3 | my %search; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 3 | ▶ | $search{active} = 1 if $opt->{active}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 3 | ▶ | $search{is_deleted} = [ 0, undef ] unless $opt->{all}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 3 | ▶ | $search{free} = 1 if $opt->{free}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 3 | ▶ | $search{pool_count} = { not => undef } if $opt->{pool}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | # ignore all options if host is requested by name | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 3 | ▶ | %search = (name => $opt->{name}) if $opt->{name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 3 | require Tapper::Model; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 3 | ▶ | if ($opt->{queue}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 2 | my @queue_ids = map {$_->id} Tapper::Model::model('TestrunDB')->resultset('Queue')->search({name => {-in => [ @{$opt->{queue}} ]}}); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 2 | $search{queue_id} = { -in => [ @queue_ids ]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 2 | $options{join} = 'queuehosts'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 2 | $options{'+select'} = 'queuehosts.queue_id'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 2 | $options{'+as'} = 'queue_id'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 3 | my $hosts = Tapper::Model::model('TestrunDB')->resultset('Host')->search(\%search, \%options); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 3 | return $hosts; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | sub print_hosts_yaml | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_hosts_yaml: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | my ($hosts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | ▶ | while (my $host = $hosts->next ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | my %host_data = (name => $host->name, | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | comment => $host->comment, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | free => $host->free, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | active => $host->active, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | is_deleted => $host->is_deleted, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | host_id => $host->id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | my $job = $host->testrunschedulings->search({status => 'running'}, {rows => 1})->first; # this should always be only one | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | ▶ | if ($job) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | $host_data{running_testrun} = $job->testrun->id; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | $host_data{running_since} = $job->testrun->starttime_testrun->iso8601; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | ▶ | if ($host->queuehosts->count > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | my @queues = map {$_->queue->name} $host->queuehosts->all; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | $host_data{queues} = \@queues; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | my %features; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | foreach my $feature ($host->features->all) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | $features{$feature->entry} = $feature->value; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | $host_data{features} = \%features; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | require YAML::XS; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | print YAML::XS::Dump(\%host_data); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | sub print_hosts_json | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_hosts_json: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | my ($hosts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | my @info; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | ▶ | while (my $host = $hosts->next ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | my %host_data = (name => $host->name, | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | comment => $host->comment, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | free => $host->free, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | active => $host->active, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | is_deleted => $host->is_deleted, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | host_id => $host->id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | my $job = $host->testrunschedulings->search({status => 'running'}, {rows => 1})->first; # this should always be only one | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | ▶ | if ($job) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | $host_data{running_testrun} = $job->testrun->id; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | $host_data{running_since} = $job->testrun->starttime_testrun->iso8601; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | ▶ | if ($host->queuehosts->count > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | my @queues = map {$_->queue->name} $host->queuehosts->all; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | $host_data{queues} = \@queues; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | my %features; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | foreach my $feature ($host->features->all) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | $features{$feature->entry} = $feature->value; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | $host_data{features} = \%features; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | push @info, \%host_data; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | require JSON::XS; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | print JSON::XS->new->utf8->encode(\@info); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | print "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | sub listhost | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
listhost: called CC=6 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 3 | my ($c) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 3 | $c->getopt( 'free', 'name=s@', 'active', 'queue=s@', 'pool', 'all|a', 'verbose|v+', 'yaml', 'json', 'help|?' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 3 | ▶ | if ( $c->options->{help} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | say STDERR "$0 host-list [ --verbose|v ] [ --free ] | [ --name=s ] [--pool] [ --active ] [ --queue=s@ ] [ --all|a] [ --yaml ] [ --json ]"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | say STDERR " --verbose Increase verbosity level, without show only names, level one shows all but comments, level two shows all including comments"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | say STDERR " --free List only free hosts"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | say STDERR " --name Find host by name, implies verbose"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | say STDERR " --active List only active hosts"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | say STDERR " --queue List only hosts bound to this queue"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | say STDERR " --pool List only pool hosts, even deleted ones"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | say STDERR " --all List all hosts, even deleted ones"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | say STDERR " --help Print this help message and exit"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | say STDERR " --yaml Print information in YAML format, implies verbose"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | say STDERR " --json Print information in JSON format, implies verbose, yaml takes precedence over json"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 3 | my $hosts = select_hosts($c->options); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 3 | ▶ | if ($c->options->{yaml}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | print_hosts_yaml($hosts); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | } elsif ($c->options->{json}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | print_hosts_json($hosts); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | } elsif ($c->options->{verbose}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 1 | print_hosts_verbose($hosts, $c->options->{verbose}); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 2 | foreach my $host ($hosts->all) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 4 | say sprintf("%10d | %s", $host->id, $host->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | sub host_deny | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
host_deny: called CC=20 SCAR=42.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 2 | my ($c) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 2 | $c->getopt( 'host=s@','queue=s@','really' ,'off','help|?' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 2 | ▶ | if ( $c->options->{help} or not (@{$c->options->{host} || []} and $c->options->{queue} )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition37%3/8
$c->options->{"help"} or not @{$c->options->{"host"} or [];} && $c->options->{"queue"}
@{$c->options->{'host'} or [];} && $c->options->{'queue'}
$c->options->{'host'} || []
MC/DC0%0/3
$c->options->{"help"} or not @{$c->options->{"host"} or [];} && $c->options->{"queue"}
$c->options->{"help"}
@{$c->options->{'host'} or [];}
$c->options->{'queue'}
MC/DC0%0/1
$c->options->{'host'} || []
$c->options->{'host'}
Truth table25%1/4
A or not(B && C)
A= $c->options->{"help"}B= @{$c->options->{'host'} or [];}C= $c->options->{'queue'}
Truth table50%1/2
A
A= $c->options->{'host'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | ▶ | say STDERR "At least one queuename has to be provided!" unless @{$c->options->{queue} || []}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$c->options->{'queue'} || []
MC/DC0%0/1
$c->options->{'queue'} || []
$c->options->{'queue'}
Truth table0%0/2
A
A= $c->options->{'queue'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | ▶ | say STDERR "At least one hostname has to be provided!" unless @{$c->options->{host} || []}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$c->options->{'host'} || []
MC/DC0%0/1
$c->options->{'host'} || []
$c->options->{'host'}
Truth table0%0/2
A
A= $c->options->{'host'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | say STDERR "$0 host-deny --host=s@ --queue=s@ [--off] [--really]"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | say STDERR " --host Deny this host for testruns of all given queues"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | say STDERR " --queue Deny this queue to put testruns on all given hosts"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | say STDERR " --off Remove previously installed denial of host/queue combination"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | say STDERR " --really Force denial of host/queue combination even if it does not make sense (e.g. because host is also bound to queue)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 2 | require Tapper::Model; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 2 | my @queue_results; my @host_results; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 2 | foreach my $queue_name ( @{$c->options->{queue}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 2 | my $queue_r = Tapper::Model::model('TestrunDB')->resultset('Queue')->search({name => $queue_name}, {rows => 1})->first; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 2 | ▶ | die "No such queue: '$queue_name'\n" unless $queue_r; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 2 | push @queue_results, $queue_r; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 2 | foreach my $host_name ( @{$c->options->{host}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 2 | my $host_r = Tapper::Model::model('TestrunDB')->resultset('Host')->search({name => $host_name}, {rows => 1})->first; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 2 | ▶ | die "No such host: '$host_name'\n" unless $host_r; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 2 | push @host_results, $host_r; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 2 | foreach my $queue_r (@queue_results) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | HOST: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 2 | foreach my $host_r (@host_results) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 2 | ▶ | if ($c->options->{off}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 1 | my $deny_r = Tapper::Model::model('TestrunDB')->resultset('DeniedHost')->search({queue_id => $queue_r->id, | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | host_id => $host_r->id, }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | {rows => 1} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | )->first; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 1 | ▶ | $deny_r->delete if $deny_r; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 1 | ▶ | if ($host_r->queuehosts->search({queue_id => $queue_r->id}, {rows => 1})->first) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | my $msg = 'Host '.$host_r->name.' is bound to from queue '.$queue_r->name; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | ▶ | if ($c->options->{really}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | say STDERR "SUCCESS: $msg. Will still deny it too, because you requested it."; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | say STDERR "ERROR: $msg. This does not make sense. Will not deny it from the queue. You can override it with --really"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | next HOST; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | # don't deny twice | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 1 | ▶ | next HOST if $host_r->denied_from_queue->search({queue_id => $queue_r->id}, {rows => 1})->first; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 1 | Tapper::Model::model('TestrunDB')->resultset('DeniedHost')->new({queue_id => $queue_r->id, | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | host_id => $host_r->id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | })->insert; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | sub host_bind | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
host_bind: called CC=20 SCAR=42.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 2 | my ($c) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 2 | $c->getopt( 'host=s@','queue=s@','really' ,'off','help|?' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 2 | ▶ | if ( $c->options->{help} or not (@{$c->options->{host} || []} and $c->options->{queue} )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition37%3/8
$c->options->{"help"} or not @{$c->options->{"host"} or [];} && $c->options->{"queue"}
@{$c->options->{'host'} or [];} && $c->options->{'queue'}
$c->options->{'host'} || []
MC/DC0%0/3
$c->options->{"help"} or not @{$c->options->{"host"} or [];} && $c->options->{"queue"}
$c->options->{"help"}
@{$c->options->{'host'} or [];}
$c->options->{'queue'}
MC/DC0%0/1
$c->options->{'host'} || []
$c->options->{'host'}
Truth table25%1/4
A or not(B && C)
A= $c->options->{"help"}B= @{$c->options->{'host'} or [];}C= $c->options->{'queue'}
Truth table50%1/2
A
A= $c->options->{'host'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 0 | ▶ | say STDERR "At least one queuename has to be provided!" unless @{$c->options->{queue} || []}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$c->options->{'queue'} || []
MC/DC0%0/1
$c->options->{'queue'} || []
$c->options->{'queue'}
Truth table0%0/2
A
A= $c->options->{'queue'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | ▶ | say STDERR "At least one hostname has to be provided!" unless @{$c->options->{host} || []}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$c->options->{'host'} || []
MC/DC0%0/1
$c->options->{'host'} || []
$c->options->{'host'}
Truth table0%0/2
A
A= $c->options->{'host'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | say STDERR "$0 host-bind --host=s@ --queue=s@ [--off] [--really]"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 0 | say STDERR " --host Bind this hosts to all given queues (can be given multiple times)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | say STDERR " --queue Bind all given hosts to this queue (can be given multiple times)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | say STDERR " --off Remove previously installed host/queue bindings"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | say STDERR " --really Force binding host/queue combination even if it does not make sense (e.g. because host is also denied from queue)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 2 | require Tapper::Model; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 2 | my @queue_results; my @host_results; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 2 | foreach my $queue_name ( @{$c->options->{queue}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 2 | my $queue_r = Tapper::Model::model('TestrunDB')->resultset('Queue')->search({name => $queue_name}, {rows => 1})->first; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 2 | ▶ | die "No such queue: '$queue_name'\n" unless $queue_r; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 2 | push @queue_results, $queue_r; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 2 | foreach my $host_name ( @{$c->options->{host}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 2 | my $host_r = Tapper::Model::model('TestrunDB')->resultset('Host')->search({name => $host_name}, {rows => 1})->first; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 2 | ▶ | die "No such host: '$host_name'\n" unless $host_r; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 2 | push @host_results, $host_r; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 2 | foreach my $queue_r (@queue_results) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 2 | foreach my $host_r (@host_results) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 2 | ▶ | if ($c->options->{off}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 1 | my $bind_r = Tapper::Model::model('TestrunDB')->resultset('QueueHost')->search({queue_id => $queue_r->id, | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | host_id => $host_r->id }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | {rows => 1} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | )->first; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 1 | ▶ | $bind_r->delete if $bind_r; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 1 | ▶ | if ($host_r->denied_from_queue->single({queue_id => $queue_r->id})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 0 | my $msg = 'Host '.$host_r->name.' is denied from from queue '.$queue_r->name; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 0 | ▶ | if ($c->options->{really}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | say STDERR "SUCCESS: $msg. Will still deny it too, because you requested it."; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | say STDERR "ERROR: $msg. This does not make sense. Will not bind it to the queue. You can override it with --really"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 0 | next HOST; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | # don't bind twice | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 1 | ▶ | next HOST if $host_r->queuehosts->search({queue_id => $queue_r->id}, {rows => 1})->first; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 1 | Tapper::Model::model('TestrunDB')->resultset('QueueHost')->new({queue_id => $queue_r->id, | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | host_id => $host_r->id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | })->insert; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | sub host_new | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 7 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
host_new: called CC=12 SCAR=26.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 7 | my ($c) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 7 | $c->getopt( 'name=s', 'queue=s@', 'active', 'pool_count=s', 'verbose|v', 'help|?' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 7 | ▶ | if ( $c->options->{help} or not $c->options->{name}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/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 table33%1/3
A or not(B)
A= $c->options->{"help"}B= not $c->options->{"name"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | ▶ | say STDERR "Host name missing!" unless $c->options->{name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | say STDERR "$0 host-new --name=s [ --queue=s@ ] [--pool_count=s] [--verbose|-v] [--help|-?]"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 0 | say STDERR " --name Name of the new host)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | say STDERR " --queue Bind host to this queue, can be given multiple times)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | say STDERR " --active Make host active; without it host will be initially deactivated)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | say STDERR " --verbose More verbose output)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 7 | require Tapper::Model; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 7 | ▶ | if ($c->options->{queue}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 4 | foreach my $queue (@{$c->options->{queue}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 6 | my $queue_rs = Tapper::Model::model('TestrunDB')->resultset('Queue')->search({name => $queue}); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 6 | ▶ | if (not $queue_rs->count) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 1 | say STDERR "No such queue: $queue"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 1 | my @queue_names = map {$_->name} Tapper::Model::model('TestrunDB')->resultset('Queue')->all; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 1 | say STDERR "Existing queues: ",join ", ",@queue_names; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | my $host = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | name => $c->options->{name}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | active => $c->options->{active}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | free => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | pool_free => $c->options->{pool_count} ? $c->options->{pool_count} : undef, # need to turn 0 into undef, because 0 makes $host->is_pool true | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 7 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 7 | my $newhost = Tapper::Model::model('TestrunDB')->resultset('Host')->new($host); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 7 | $newhost->insert(); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 7 | ▶ | die "Can't create new host\n" if not $newhost; # actually, on this place DBIC should have died already | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 7 | ▶ | if ($c->options->{queue}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 4 | foreach my $queue (@{$c->options->{queue}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 6 | my $queue_rs = Tapper::Model::model('TestrunDB')->resultset('Queue')->search({name => $queue}); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 6 | ▶ | if (not $queue_rs->count) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 1 | $newhost->delete(); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 1 | say STDERR qq(Did not find queue "$queue"); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 6 | my $queue_host = Tapper::Model::model('TestrunDB')->resultset('QueueHost')->new({ | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | host_id => $newhost->id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | queue_id => $queue_rs->search({}, {rows => 1})->first->id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 5 | $queue_host->insert(); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 6 | return $newhost->id; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 5 | ▶ | sub ar_get_host_update_parameters { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ar_get_host_update_parameters: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 5 | [ 'id|i=i' , 'change host with this id; this or selectbyname is required', ], | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | [ 'selectbyname=s' , 'change host with this name; this or id is required', ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | [ 'name|n=s' , 'update name', ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | [ 'comment|c:s' , 'Set a new comment for the host', ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | [ 'addboundqueue=s@' , 'Bind host to named queue without deleting other bindings (queue has to exists already)', ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | [ 'delboundqueue:s@' , q#delete queue from this host's bindings, empty string means 'all bindings'#, ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | [ 'adddeniedqueue=s@' , 'mark host as denied for a specific queue', ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | [ 'deldeniedqueue:s@' , 'remove denied queue for host', ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | [ 'active|a=i' , 'set active flag to this value, possible values 0 (inactive) and 1 (active)', ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | [ 'free=i' , 'set free flag; possible values: 0=not-free, 1=free; setting free=1 fails when a testrun runs there', ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | [ 'verbose|v' , 'some more informational output', ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | [ 'help|?' , 'Print this help message and exit.', ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 5 | ▶ | sub b_host_update { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
b_host_update: called CC=26 SCAR=43.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 5 | my ( $or_app_rad ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 5 | my $ar_parameters = ar_get_host_update_parameters(); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 5 | $or_app_rad->getopt( map { $_->[0] } @{$ar_parameters} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 5 | my $hr_options = $or_app_rad->options; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 5 | ▶ | if ( $hr_options->{help} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 0 | say {*STDERR} "Usage: $PROGRAM_NAME host-update [options]"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 0 | require Tapper::CLI::Base; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 0 | Tapper::CLI::Base::b_print_help( $ar_parameters ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 5 | ▶ | if ( defined $hr_options->{active} && !grep { $hr_options->{active} == $_ } 0,1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $hr_options->{"active"} and not grep({$hr_options->{"active"} == $_;} 0, 1)
MC/DC0%0/2
defined $hr_options->{"active"} and not grep({$hr_options->{"active"} == $_;} 0, 1)
defined $hr_options->{"active"}
not grep({$hr_options->{"active"} == $_;} 0, 1)
Truth table66%2/3
A and not(B)
A= defined $hr_options->{"active"}B= not grep({$hr_options->{"active"} == $_;} 0, 1)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 0 | die "error: parameter '$hr_options->{active}' is not valid for 'active'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 5 | my $or_host; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 5 | require Tapper::Model; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 5 | ▶ | if ( $hr_options->{id} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | 3 | $or_host = Tapper::Model::model('TestrunDB')->resultset('Host')->find( $hr_options->{id} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | } elsif ( $hr_options->{selectbyname} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | # There should be only one host with the name | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 0 | $or_host = Tapper::Model::model('TestrunDB')->resultset('Host')->search({ name => $hr_options->{selectbyname} })->first; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 2 | die "error: missing required parameter 'id' or 'selectbyname'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 3 | ▶ | if ( $or_host ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 3 | my $b_update = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 3 | ▶ | if ( defined $hr_options->{active} && $hr_options->{active} != $or_host->active ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $hr_options->{"active"} and $hr_options->{"active"} != $or_host->active
MC/DC50%1/2
defined $hr_options->{"active"} and $hr_options->{"active"} != $or_host->active
defined $hr_options->{"active"}
$hr_options->{"active"} != $or_host->active
Truth table66%2/3
A and B
A= defined $hr_options->{"active"}B= $hr_options->{"active"} != $or_host->active
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 2 | $b_update = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 2 | $or_host->active( $hr_options->{active} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 2 | ▶ | if ( $hr_options->{active} == 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 1 | b_update_grub( $or_host->name ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 3 | ▶ | if ( $hr_options->{name} && $hr_options->{name} ne $or_host->name ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$hr_options->{"name"} and $hr_options->{"name"} ne $or_host->name
MC/DC0%0/2
$hr_options->{"name"} and $hr_options->{"name"} ne $or_host->name
$hr_options->{"name"}
$hr_options->{"name"} ne $or_host->name
Truth table33%1/3
A and B
A= $hr_options->{"name"}B= $hr_options->{"name"} ne $or_host->name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 0 | $b_update = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 0 | $or_host->name( $hr_options->{name} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 3 | ▶ | if ( defined $hr_options->{comment} && $hr_options->{comment} ne $or_host->comment ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $hr_options->{"comment"} and $hr_options->{"comment"} ne $or_host->comment
MC/DC0%0/2
defined $hr_options->{"comment"} and $hr_options->{"comment"} ne $or_host->comment
defined $hr_options->{"comment"}
$hr_options->{"comment"} ne $or_host->comment
Truth table33%1/3
A and B
A= defined $hr_options->{"comment"}B= $hr_options->{"comment"} ne $or_host->comment
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 0 | $b_update = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 0 | $or_host->comment( $hr_options->{comment} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | 3 | ▶ | if ( defined $hr_options->{free} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 0 | $b_update = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | ▶ | if ($hr_options->{free} == 1 and | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$hr_options->{"free"} == 1 and not $or_host->free and Tapper::Model::model("TestrunDB")->resultset("TestrunScheduling")->search({"host_id", $or_host->id, "status", "running"})->count
$hr_options->{"free"} == 1 and not $or_host->free
MC/DC0%0/3
$hr_options->{"free"} == 1 and not $or_host->free and Tapper::Model::model("TestrunDB")->resultset("TestrunScheduling")->search({"host_id", $or_host->id, "status", "running"})->count
$hr_options->{"free"} == 1
not $or_host->free
Tapper::Model::model("TestrunDB")->resultset("TestrunScheduling")->search({"host_id", $or_host->id, "status", "running"})->count
Truth table0%0/4
A and not(B) and C
A= $hr_options->{"free"} == 1B= not $or_host->freeC= Tapper::Model::model("TestrunDB")->resultset("TestrunScheduling")->search({"host_id", $or_host->id, "status", "running"})->count
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | not $or_host->free and | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | Tapper::Model::model('TestrunDB')->resultset('TestrunScheduling')->search({host_id => $or_host->id, status => 'running'})->count) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 0 | die "error: cannot free a used host (id=".$or_host->id.")\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | $or_host->free( $hr_options->{free} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 3 | for my $s_type (qw/ bound denied /) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 6 | ▶ | if ( $hr_options->{"add${s_type}queue"} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 0 | ▶ | $b_update ||= i_add_queues( $or_host, $s_type, $hr_options->{"add${s_type}queue"} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$b_update ||= i_add_queues($or_host, $s_type, $$hr_options{"add${s_type}queue"})
MC/DC0%0/2
$b_update ||= i_add_queues($or_host, $s_type, $$hr_options{"add${s_type}queue"})
$b_update
i_add_queues($or_host, $s_type, $$hr_options{"add${s_type}queue"})
Truth table0%0/3
A ||= B
A= $b_updateB= i_add_queues($or_host, $s_type, $$hr_options{"add${s_type}queue"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 6 | ▶ | if ( defined $hr_options->{"del${s_type}queue"} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 1 | ▶ | $b_update ||= i_delete_queues( $or_host, $s_type, $hr_options->{"del${s_type}queue"} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$b_update ||= i_delete_queues($or_host, $s_type, $$hr_options{"del${s_type}queue"})
MC/DC0%0/2
$b_update ||= i_delete_queues($or_host, $s_type, $$hr_options{"del${s_type}queue"})
$b_update
i_delete_queues($or_host, $s_type, $$hr_options{"del${s_type}queue"})
Truth table33%1/3
A ||= B
A= $b_updateB= i_delete_queues($or_host, $s_type, $$hr_options{"del${s_type}queue"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 3 | ▶ | if ( $b_update ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 2 | require DateTime; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 2 | $or_host->updated_at( DateTime->now->strftime('%F %T') ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | 2 | ▶ | if (! $or_host->update ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 0 | die "error: cannot update host\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | 1 | say {*STDERR} "info: nothing to update"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 3 | ▶ | if ( $hr_options->{verbose} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | 0 | print_hosts_verbose( $or_host ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 0 | die "error: no such host = $hr_options->{id}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | sub setup | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 71 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setup: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | 71 | my ($c) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 71 | $c->register('host-list' , \&listhost , 'Show all hosts matching a given condition'); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 71 | $c->register('host-deny' , \&host_deny , 'Setup or remove forbidden host/queue combinations'); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 71 | $c->register('host-bind' , \&host_bind , 'Setup or remove host/queue bindings'); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 71 | $c->register('host-new' , \&host_new , 'Create a new host by name'); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | 71 | $c->register('host-update' , \&b_host_update , 'update host data'); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 71 | $c->register('host-delete' , \&b_delete , 'Delete a host'); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | #TODO: full implementation remaining | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | # $c->register('host-free' , \&b_free_host , 'Free host'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | 71 | ▶ | if ($c->can('group_commands')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | 0 | $c->group_commands( | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 'Host commands', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | 'host-list', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 'host-new', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 'host-update', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 'host-delete', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | 'host-bind', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 'host-deny', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | 71 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 72 | 1; # End of Tapper::CLI | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||