Remote/Winsvc.pm

filter: Statementstmt 100% 9 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 100% 12 / 12 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Remote/Winexe.pm ↑ Summary Remote/Wmi.pm »
1 #
2 # $Id$
3 #
4 # remote::winsvc Brik
5 #
6 package Metabrik::Remote::Winsvc;
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use base qw(Metabrik::Remote::Winexe Metabrik::Client::Smbclient);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 sub brik_properties {
13 return {
14 revision => '$Revision$',
15 tags => [ qw(unstable) ],
16 author => 'GomoR <GomoR[at]metabrik.org>',
17 license => 'http://opensource.org/licenses/BSD-3-Clause',
18 attributes => {
19 host => [ qw(host) ], # Inherited
20 user => [ qw(username) ], # Inherited
21 password => [ qw(password) ], # Inherited
22 domain => [ qw(domain) ], # Inherited
23 },
24 commands => {
25 start => [ qw(service host|OPTIONAL user|OPTIONAL password|OPTIONAL) ],
26 stop => [ qw(service host|OPTIONAL user|OPTIONAL password|OPTIONAL) ],
27 restart => [ qw(service host|OPTIONAL user|OPTIONAL password|OPTIONAL) ],
28 },
29 };
30 }
31  
32 sub start {
33 my $self = shift;
34 my ($service, $host, $user, $password) = @_;
35  
36 $host ||= $self->host;
37 $user ||= $self->user;
38 $password ||= $self->password;
39 $self->brik_help_run_undef_arg('start', $service) or return;
40 $self->brik_help_set_undef_arg('host', $host) or return;
41 $self->brik_help_set_undef_arg('user', $user) or return;
42 $self->brik_help_set_undef_arg('password', $password) or return;
43  
44 my $cmd = "\"cmd.exe /c sc start $service\"";
45  
46 return $self->execute($cmd);
47 }
48  
49 sub stop {
50 my $self = shift;
51 my ($service, $host, $user, $password) = @_;
52  
53 $host ||= $self->host;
54 $user ||= $self->user;
55 $password ||= $self->password;
56 $self->brik_help_run_undef_arg('stop', $service) or return;
57 $self->brik_help_set_undef_arg('host', $host) or return;
58 $self->brik_help_set_undef_arg('user', $user) or return;
59 $self->brik_help_set_undef_arg('password', $password) or return;
60  
61 my $cmd = "\"cmd.exe /c sc stop $service\"";
62  
63 return $self->execute($cmd);
64 }
65  
66 sub restart {
67 my $self = shift;
68  
69 $self->stop(@_) or return;
70 $self->start(@_) or return;
71  
72 return 1;
73 }
74  
75 1;
76  
77 __END__
« Remote/Winexe.pm ↑ Summary Remote/Wmi.pm »