| 1 | package Tapper::MCP::Net::Reset::PM211MIP; | ||||||||||||||||||||||||||||
| 2 | 1 | our $AUTHORITY = 'cpan:TAPPER'; | |||||||||||||||||||||||||||
| 3 | 1 | $Tapper::MCP::Net::Reset::PM211MIP::VERSION = '5.0.9'; | |||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use LWP::UserAgent; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 1 | extends 'Tapper::Base'; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | sub reset_host | ||||||||||||||||||||||||||||
| 13 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
reset_host: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 14 | 0 | my ($self, $host, $options) = @_; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 0 | $self->log->info("Reboot via Infratec PM211MIP multi-socket outlet"); | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 0 | my $ip = $options->{ip}; | |||||||||||||||||||||||||||
| 19 | 0 | my $user = $options->{user}; | |||||||||||||||||||||||||||
| 20 | 0 | my $passwd = $options->{passwd}; | |||||||||||||||||||||||||||
| 21 | 0 | my $outletnr = $options->{outletnr}{$host}; | |||||||||||||||||||||||||||
| 22 | 0 | my $uri = "http://$ip/sw?u=$user&p=$passwd&o=$outletnr&f="; | |||||||||||||||||||||||||||
| 23 | 0 | my $uri_off = $uri."off"; | |||||||||||||||||||||||||||
| 24 | 0 | my $uri_on = $uri."on"; | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 0 | my $ua = LWP::UserAgent->new; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 0 | $self->log->info("turn off '$host' via $uri_off"); | |||||||||||||||||||||||||||
| 29 | 0 | my $response1 = $ua->get($uri_off)->decoded_content; | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 0 | my $sleep = 5; | |||||||||||||||||||||||||||
| 32 | 0 | $self->log->info("sleep $sleep seconds"); | |||||||||||||||||||||||||||
| 33 | 0 | sleep $sleep; | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 0 | $self->log->info("turn on '$host' via $uri_on"); | |||||||||||||||||||||||||||
| 36 | 0 | my $response2 = $ua->get($uri_on)->decoded_content; | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 0 | ▶ | my $error = $response1 =~ /Done\./ && $response2 =~ /Done\./ ? 0 : 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$response1 =~ /Done\./ and $response2 =~ /Done\./
MC/DC0%0/2
$response1 =~ /Done\./ and $response2 =~ /Done\./
$response1 =~ /Done\./
$response2 =~ /Done\./
Truth table0%0/3
A and B
A= $response1 =~ /Done\./B= $response2 =~ /Done\./
| |||||||||||||||||||||||||||||
| 39 | 0 | my $retval = $response1."\n".$response2; | |||||||||||||||||||||||||||
| 40 | 0 | return ($error, $retval); | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 1 | 1; | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | __END__ | ||||||||||||||||||||||||||||