File Coverage

blib/lib/Siebel/Lbconfig/Daemon/Action/ListServers.pm
Criterion Covered Total %
statement 15 15 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 20 20 100.0


line stmt bran cond sub pod time code
1             package Siebel::Lbconfig::Daemon::Action::ListServers;
2              
3             our $VERSION = '0.003'; # VERSION
4 2     2   8546 use Moose 2.0401;
  2         41  
  2         17  
5 2     2   13898 use namespace::autoclean 0.13;
  2         50  
  2         15  
6 2     2   634 use Siebel::Srvrmgr::Daemon::ActionStash 0.27;
  2         90650  
  2         65  
7 2     2   14 use Carp;
  2         5  
  2         163  
8 2     2   11 use Scalar::Util qw(blessed);
  2         5  
  2         427  
9              
10             extends 'Siebel::Srvrmgr::Daemon::Action';
11              
12             =pod
13              
14             =head1 NAME
15              
16             Siebel::Lbconfig::Daemon::Action::ListServers - subclass to information from C<list servers> command
17              
18             =head1 DESCRIPTION
19              
20             C<Siebel::Lbconfig::Daemon::Action::ListServers> is a subclass of L<Siebel::Srvrmgr::Daemon::Action>.
21              
22             C<Siebel::Lbconfig::Daemon::Action::ListServers> will simply recover and "return" the output of C<list servers>
23             command. See C<do_parsed> method for details.
24              
25             =head1 EXPORTS
26              
27             Nothing.
28              
29             =head1 METHODS
30              
31             This class implements a single method besides the "hidden" C<_build_exp_output>.
32              
33             =cut
34              
35             override '_build_exp_output' => sub {
36             return 'Siebel::Srvrmgr::ListParser::Output::Tabular::ListServers';
37             };
38              
39             =pod
40              
41             =head2 do_parsed
42              
43             This method is overriden from parent class.
44              
45             It expects the parsed output from C<list servers> command.
46              
47             It returns nothing, but sets the singleton L<Siebel::Srvrmgr::Daemon::ActionStash> with a hash
48             reference containing the Siebel Server name as key and the respect Server Id as value.
49              
50             =cut
51              
52             override 'do_parsed' => sub {
53             my ( $self, $obj ) = @_;
54             my %servers;
55              
56             if ( $obj->isa( $self->get_exp_output ) ) {
57             my $iter = $obj->get_servers_iter;
58              
59             while ( my $server = $iter->() ) {
60             $servers{ $server->get_name } = $server->get_id;
61             }
62              
63             my $stash = Siebel::Srvrmgr::Daemon::ActionStash->instance();
64             $stash->push_stash( \%servers );
65             return 1;
66              
67             }
68             else {
69             confess('object received ISA not '
70             . $self->get_exp_output() . ' but '
71             . blessed($obj) );
72             }
73              
74             };
75              
76             =head1 SEE ALSO
77              
78             =over
79              
80             =item *
81              
82             L<Siebel::Srvrmgr::Daemon::ActionStash>
83              
84             =item *
85              
86             L<Siebel::Srvrmgr::Daemon::Action>
87              
88             =back
89              
90             =head1 AUTHOR
91              
92             Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt>
93              
94             =head1 COPYRIGHT AND LICENSE
95              
96             This software is copyright (c) 2016 of Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt>
97              
98             This file is part of Siebel Monitoring Tools.
99              
100             Siebel Monitoring Tools is free software: you can redistribute it and/or modify
101             it under the terms of the GNU General Public License as published by
102             the Free Software Foundation, either version 3 of the License, or
103             (at your option) any later version.
104              
105             Siebel Monitoring Tools is distributed in the hope that it will be useful,
106             but WITHOUT ANY WARRANTY; without even the implied warranty of
107             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
108             GNU General Public License for more details.
109              
110             You should have received a copy of the GNU General Public License
111             along with Siebel Monitoring Tools. If not, see <http://www.gnu.org/licenses/>.
112              
113             =cut
114              
115             __PACKAGE__->meta->make_immutable;