File Coverage

blib/lib/Siebel/Srvrmgr/ListParser/Output/ListComp/Server.pm
Criterion Covered Total %
statement 23 24 95.8
branch 1 2 50.0
condition 5 6 83.3
subroutine 7 7 100.0
pod 2 2 100.0
total 38 41 92.6


line stmt bran cond sub pod time code
1             package Siebel::Srvrmgr::ListParser::Output::ListComp::Server;
2              
3             =pod
4              
5             =head1 NAME
6              
7             Siebel::Srvrmgr::ListParser::Output::ListComp::Server - class to parse and aggregate information about servers and their components
8              
9             =cut
10              
11 13     13   11754 use Moose;
  13         16  
  13         65  
12 13     13   61141 use MooseX::Storage;
  13         148856  
  13         81  
13 13     13   2269 use namespace::autoclean;
  13         18  
  13         60  
14 13     13   5399 use Siebel::Srvrmgr::ListParser::Output::ListComp::Comp;
  13         29694  
  13         543  
15 13     13   99 use Carp;
  13         30  
  13         4198  
16              
17             =pod
18              
19             =head1 SYNOPSIS
20              
21             use Siebel::Srvrmgr::ListParser::Output::ListComp::Server;
22              
23             Siebel::Srvrmgr::ListParser::Output::ListComp::Server->new(
24             {
25             name => $servername,
26             data => $list_comp_data->{$servername}
27             }
28             );
29              
30             =head1 DESCRIPTION
31              
32             This class represents a server in a Siebel Enterprise and it's related components. This class is meant to be instantied by a method from
33             L<Siebel::Srvrmgr::ListParser::Output::ListComp> object.
34              
35             This class inherits from L<MooseX::Storage>, using the L<MooseX::Storage::IO::StorableFile> trait. See the methods C<load> and C<store> for details.
36              
37             =cut
38              
39             with Storage( io => 'StorableFile' );
40              
41             =head1 ATTRIBUTES
42              
43             =head2 data
44              
45             An hash reference with the original data used to create the object.
46              
47             =cut
48              
49             has data =>
50             ( isa => 'HashRef', is => 'ro', required => 1, reader => 'get_data' );
51              
52             =pod
53              
54             =head2 name
55              
56             A string with the name of the server.
57              
58             =cut
59              
60             has name => ( isa => 'Str', is => 'ro', required => 1, reader => 'get_name' );
61              
62             =pod
63              
64             =head2 comp_attribs
65              
66             A array reference with the components attributes names
67              
68             =cut
69              
70             has 'comp_attribs' => (
71             is => 'ro',
72             isa => 'ArrayRef',
73             reader => 'get_comp_attribs'
74             );
75              
76             =pod
77              
78             =head1 METHODS
79              
80             =head2 get_data
81              
82             Returns an hash reference from the C<data> attribute.
83              
84             =head2 get_name
85              
86             Returns an string from the C<name> attribute.
87              
88             =head2 load
89              
90             Load the object data and methods from a previously serialized object.
91              
92             Expects as a parameter a string the filename (or complete path).
93              
94             =head2 store
95              
96             Stores the object data and methods in a serialized file.
97              
98             Expects as a parameter a string the filename (or complete path).
99              
100             =head2 get_comps
101              
102             Returns an array reference with all components aliases available in the server.
103              
104             =cut
105              
106             sub get_comps {
107              
108 2     2 1 4 my $self = shift;
109              
110 2         2 return [ keys( %{ $self->get_data() } ) ];
  2         87  
111              
112             }
113              
114             =pod
115              
116             =head2 get_comp
117              
118             Expects an string with the component alias.
119              
120             Returns a L<Siebel::Srvrmgr::ListParser::Output::ListComp::Comp> object if the component exists in the server, otherwise returns C<undef>.
121              
122             =cut
123              
124             sub get_comp {
125              
126 630     630 1 547 my $self = shift;
127 630         503 my $alias = shift;
128              
129 630 50       20542 if ( exists( $self->get_data()->{$alias} ) ) {
130              
131 630         19883 my $data_ref = $self->get_data->{$alias};
132 630   100     28240 return Siebel::Srvrmgr::ListParser::Output::ListComp::Comp->new(
      50        
      100        
133             {
134             alias => $alias,
135             name => $data_ref->{CC_NAME},
136             ct_alias => $data_ref->{CT_ALIAS},
137             cg_alias => $data_ref->{CG_ALIAS},
138             run_mode => $data_ref->{CC_RUNMODE},
139             disp_run_state => $data_ref->{CP_DISP_RUN_STATE},
140             num_run_tasks => $data_ref->{CP_NUM_RUN_TASKS},
141             max_tasks => $data_ref->{CP_MAX_TASKS},
142             desc_text => $data_ref->{CC_DESC_TEXT},
143             start_datetime => $data_ref->{CP_START_TIME},
144             end_datetime => $data_ref->{CP_END_TIME},
145             status => $data_ref->{CP_STATUS},
146              
147             # :WORKAROUND:03-02-2015 03:32:57:: in most cases the value from Server Manager is undefined
148             actv_mts_procs => $data_ref->{CP_ACTV_MTS_PROCS} || 0,
149             incarn_no => $data_ref->{CC_INCARN_NO} || 0,
150             max_mts_procs => $data_ref->{CP_MAX_MTS_PROCS} || 0,
151              
152             }
153             );
154              
155             }
156             else {
157              
158 0           return undef;
159              
160             }
161              
162             }
163              
164             =pod
165              
166             =head1 SEE ALSO
167              
168             =over
169              
170             =item *
171              
172             L<Moose>
173              
174             =item *
175              
176             L<MooseX::Storage>
177              
178             =item *
179              
180             L<namespace::autoclean>
181              
182             =item *
183              
184             L<Siebel::Srvrmgr::ListParser::Output::ListComp::Comp>
185              
186             =back
187              
188             =head1 AUTHOR
189              
190             Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt>.
191              
192             =head1 COPYRIGHT AND LICENSE
193              
194             This software is copyright (c) 2012 of Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt>.
195              
196             This file is part of Siebel Monitoring Tools.
197              
198             Siebel Monitoring Tools is free software: you can redistribute it and/or modify
199             it under the terms of the GNU General Public License as published by
200             the Free Software Foundation, either version 3 of the License, or
201             (at your option) any later version.
202              
203             Siebel Monitoring Tools is distributed in the hope that it will be useful,
204             but WITHOUT ANY WARRANTY; without even the implied warranty of
205             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
206             GNU General Public License for more details.
207              
208             You should have received a copy of the GNU General Public License
209             along with Siebel Monitoring Tools. If not, see L<http://www.gnu.org/licenses/>.
210              
211             =cut
212              
213             __PACKAGE__->meta->make_immutable;