File Coverage

blib/lib/Siebel/Lbconfig/Daemon/Action/AOM.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::AOM;
2              
3             our $VERSION = '0.003'; # VERSION
4 2     2   12040 use Moose 2.0401;
  2         72  
  2         22  
5 2     2   14506 use namespace::autoclean 0.13;
  2         49  
  2         30  
6 2     2   180 use Siebel::Srvrmgr::Daemon::ActionStash 0.27;
  2         44  
  2         42  
7 2     2   11 use Carp;
  2         7  
  2         159  
8 2     2   12 use Scalar::Util qw(blessed);
  2         5  
  2         678  
9              
10             extends 'Siebel::Srvrmgr::Daemon::Action';
11              
12             =pod
13              
14             =head1 NAME
15              
16             Siebel::Lbconfig::Daemon::Action::AOM - subclass of Siebel::Srvrmgr::Daemon::Action to select and return AOM objects
17              
18             =head1 DESCRIPTION
19              
20             Siebel::Lbconfig::Daemon::Action::AOM will take action on a C<list comps> output, identify the AOMs available and select them
21             following a criteria (see C<do_parsed> method).
22              
23             As a subclass of L<Siebel::Srvrmgr::Daemon::Action>, you should be using it together with a subclass of L<Siebel::Srvrmgr::Daemon>
24             to handle C<list comps> output.
25              
26             =head1 EXPORTS
27              
28             Nothing.
29              
30             =head1 METHODS
31              
32             This class implements a single method besides the "hidden" C<_build_exp_output>.
33              
34             =cut
35              
36             override '_build_exp_output' => sub {
37             return 'Siebel::Srvrmgr::ListParser::Output::Tabular::ListComp';
38             };
39              
40             =pod
41              
42             =head2 do_parsed
43              
44             This method is overrired from parent class.
45              
46             Given the parsed output of a C<list comps> command, it will search for all available AOMs following this criteria:
47              
48             =over
49              
50             =item *
51              
52             The component run mode is interactive.
53              
54             =item *
55              
56             The component type is "AppObjMgr" or "EAIObjMgr".
57              
58             =item *
59              
60             The component is being executed
61              
62             =item *
63              
64             The component is configured to auto start as soon as the Siebel Server is up and running.
65              
66             =item *
67              
68             There is more than one server executing the component.
69              
70             =back
71              
72             There is no sense using this class if the output does not include more than one Siebel Server.
73              
74             This method doesn't return anything, but results are store in the L<Siebel::Srvrmgr::Daemon::ActionStash>
75             singleton. Be sure to use to retrieve the results from it. Results are stored as a hash reference, being the
76             component alias the key and the respective server the value.
77              
78             =cut
79              
80             override 'do_parsed' => sub {
81             my ( $self, $obj ) = @_;
82             my %comps;
83              
84             if ( $obj->isa( $self->get_exp_output ) ) {
85              
86             foreach my $servername ( @{ $obj->get_servers } ) {
87             my $server = $obj->get_server($servername);
88              
89             foreach my $alias ( @{ $server->get_comps } ) {
90             my $comp = $server->get_comp($alias);
91              
92             if (
93             ( $comp->get_run_mode eq 'Interactive' )
94             and ( ( $comp->get_ct_alias eq 'AppObjMgr' )
95             or ( $comp->get_ct_alias eq 'EAIObjMgr' ) )
96             and ( ( $comp->get_disp_run_state eq 'Online' )
97             or ( $comp->get_disp_run_state eq 'Running' ) )
98             and ( $comp->is_auto_start )
99             )
100             {
101              
102             if ( exists( $comps{$alias} ) ) {
103             push( @{ $comps{$alias} }, $servername );
104             }
105             else {
106             $comps{$alias} = [$servername];
107             }
108             }
109             }
110              
111             }
112              
113             foreach my $alias ( keys(%comps) ) {
114             delete $comps{$alias} unless ( scalar( @{ $comps{$alias} } ) > 1 );
115             }
116              
117             my $stash = Siebel::Srvrmgr::Daemon::ActionStash->instance();
118             $stash->push_stash( \%comps );
119             return 1;
120              
121             }
122             else {
123             confess('object received ISA not '
124             . $self->get_exp_output() . ' but '
125             . blessed($obj) );
126             }
127              
128             };
129              
130             =head1 SEE ALSO
131              
132             =over
133              
134             =item *
135              
136             L<Siebel::Srvrmgr::Daemon::ActionStash>
137              
138             =item *
139              
140             L<Siebel::Srvrmgr::Daemon::Action>
141              
142             =back
143              
144             =head1 AUTHOR
145              
146             Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt>
147              
148             =head1 COPYRIGHT AND LICENSE
149              
150             This software is copyright (c) 2016 of Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt>
151              
152             This file is part of Siebel Monitoring Tools.
153              
154             Siebel Monitoring Tools is free software: you can redistribute it and/or modify
155             it under the terms of the GNU General Public License as published by
156             the Free Software Foundation, either version 3 of the License, or
157             (at your option) any later version.
158              
159             Siebel Monitoring Tools is distributed in the hope that it will be useful,
160             but WITHOUT ANY WARRANTY; without even the implied warranty of
161             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
162             GNU General Public License for more details.
163              
164             You should have received a copy of the GNU General Public License
165             along with Siebel Monitoring Tools. If not, see <http://www.gnu.org/licenses/>.
166              
167             =cut
168              
169             __PACKAGE__->meta->make_immutable;
170