| 1 | # | ||||||||||||||||||||
| 2 | # (c) Jan Gehring <jan.gehring@gmail.com> | ||||||||||||||||||||
| 3 | # | ||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | package Rex::Service::SunOS::svcadm; | ||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 1 | ▶ | use v5.14.4; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 1 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 1 | our $VERSION = '1.16.1'; # VERSION | |||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 1 | ▶ | use Rex::Helper::Run; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | 1 | ▶ | use Rex::Logger; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | 1 | ▶ | use Rex::Commands::Fs; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 1 | ▶ | use base qw(Rex::Service::Base); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | 0 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 19 | 0 | my $that = shift; | |||||||||||||||||||
| 20 | 0 | ▶ | my $proto = ref($that) || $that; | ||||||||||||||||||
|
Condition0%0/3
ref $that || $that
MC/DC0%0/2
ref $that || $that
ref $that
$that
Truth table0%0/3
A || B
A= ref $thatB= $that
| |||||||||||||||||||||
| 21 | 0 | my $self = $proto->SUPER::new(@_); | |||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 0 | bless( $self, $proto ); | |||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | $self->{commands} = { | ||||||||||||||||||||
| 26 | 0 | start => 'svcadm enable %s >/dev/null', | |||||||||||||||||||
| 27 | restart => 'svcadm restart %s >/dev/null', | ||||||||||||||||||||
| 28 | stop => 'svcadm disable %s >/dev/null', | ||||||||||||||||||||
| 29 | reload => 'svcadm refresh %s >/dev/null', | ||||||||||||||||||||
| 30 | }; | ||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | 0 | return $self; | |||||||||||||||||||
| 33 | } | ||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 0 | ▶ | sub status { | ||||||||||||||||||
|
Subroutine
status: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 36 | 0 | my ( $self, $service, $options ) = @_; | |||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 0 | my ($state) = map { /state\s+([a-z]+)/ } eval { i_run "svcs -l $service"; }; | |||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | 0 | ▶ | if ( $state eq "online" ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 41 | 0 | return 1; | |||||||||||||||||||
| 42 | } | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 0 | return 0; | |||||||||||||||||||
| 45 | } | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | 0 | ▶ | sub ensure { | ||||||||||||||||||
|
Subroutine
ensure: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||
| 48 | 0 | my ( $self, $service, $options ) = @_; | |||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | 0 | my $what = $options->{ensure}; | |||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | 0 | ▶ | if ( $what =~ /^stop/ ) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 53 | 0 | $self->stop( $service, $options ); | |||||||||||||||||||
| 54 | } | ||||||||||||||||||||
| 55 | ▶ | elsif ( $what =~ /^start/ || $what =~ m/^run/ ) { | |||||||||||||||||||
|
Condition0%0/3
$what =~ /^start/u or $what =~ /^run/u
MC/DC0%0/2
$what =~ /^start/u or $what =~ /^run/u
$what =~ /^start/u
$what =~ /^run/u
Truth table0%0/3
A or B
A= $what =~ /^start/uB= $what =~ /^run/u
| |||||||||||||||||||||
| 56 | 0 | $self->start( $service, $options ); | |||||||||||||||||||
| 57 | } | ||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | 0 | return 1; | |||||||||||||||||||
| 60 | } | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 0 | ▶ | sub action { | ||||||||||||||||||
|
Subroutine
action: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 63 | 0 | my ( $self, $service, $action ) = @_; | |||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | 0 | my $ret_val; | |||||||||||||||||||
| 66 | eval { | ||||||||||||||||||||
| 67 | 0 | i_run "svcadm $action $service >/dev/null", nohup => 1; | |||||||||||||||||||
| 68 | 0 | $ret_val = 1; | |||||||||||||||||||
| 69 | 0 | ▶ | } or do { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 70 | 0 | $ret_val = 0; | |||||||||||||||||||
| 71 | }; | ||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | 0 | return $ret_val; | |||||||||||||||||||
| 74 | } | ||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | 1 | 1; | |||||||||||||||||||