line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ************************************************************************* |
2
|
|
|
|
|
|
|
# Copyright (c) 2014-2016, SUSE LLC |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# All rights reserved. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Redistribution and use in source and binary forms, with or without |
7
|
|
|
|
|
|
|
# modification, are permitted provided that the following conditions are met: |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# 1. Redistributions of source code must retain the above copyright notice, |
10
|
|
|
|
|
|
|
# this list of conditions and the following disclaimer. |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
# 2. Redistributions in binary form must reproduce the above copyright |
13
|
|
|
|
|
|
|
# notice, this list of conditions and the following disclaimer in the |
14
|
|
|
|
|
|
|
# documentation and/or other materials provided with the distribution. |
15
|
|
|
|
|
|
|
# |
16
|
|
|
|
|
|
|
# 3. Neither the name of SUSE LLC nor the names of its contributors may be |
17
|
|
|
|
|
|
|
# used to endorse or promote products derived from this software without |
18
|
|
|
|
|
|
|
# specific prior written permission. |
19
|
|
|
|
|
|
|
# |
20
|
|
|
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
21
|
|
|
|
|
|
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
22
|
|
|
|
|
|
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
23
|
|
|
|
|
|
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
24
|
|
|
|
|
|
|
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
25
|
|
|
|
|
|
|
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
26
|
|
|
|
|
|
|
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
27
|
|
|
|
|
|
|
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
28
|
|
|
|
|
|
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
29
|
|
|
|
|
|
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
30
|
|
|
|
|
|
|
# POSSIBILITY OF SUCH DAMAGE. |
31
|
|
|
|
|
|
|
# ************************************************************************* |
32
|
|
|
|
|
|
|
# |
33
|
|
|
|
|
|
|
# Component commands |
34
|
|
|
|
|
|
|
package App::Dochazka::CLI::Commands::Component; |
35
|
|
|
|
|
|
|
|
36
|
20
|
|
|
20
|
|
294
|
use 5.012; |
|
20
|
|
|
|
|
46
|
|
37
|
20
|
|
|
20
|
|
78
|
use strict; |
|
20
|
|
|
|
|
25
|
|
|
20
|
|
|
|
|
334
|
|
38
|
20
|
|
|
20
|
|
61
|
use warnings; |
|
20
|
|
|
|
|
18
|
|
|
20
|
|
|
|
|
530
|
|
39
|
|
|
|
|
|
|
|
40
|
20
|
|
|
20
|
|
61
|
use App::CELL qw( $CELL ); |
|
20
|
|
|
|
|
21
|
|
|
20
|
|
|
|
|
1562
|
|
41
|
20
|
|
|
20
|
|
84
|
use App::Dochazka::CLI qw( $debug_mode ); |
|
20
|
|
|
|
|
24
|
|
|
20
|
|
|
|
|
1318
|
|
42
|
20
|
|
|
20
|
|
7091
|
use App::Dochazka::CLI::Shared qw( shared_generate_report ); |
|
20
|
|
|
|
|
27
|
|
|
20
|
|
|
|
|
943
|
|
43
|
20
|
|
|
20
|
|
87
|
use App::Dochazka::CLI::Util qw( parse_test rest_error ); |
|
20
|
|
|
|
|
25
|
|
|
20
|
|
|
|
|
809
|
|
44
|
20
|
|
|
20
|
|
72
|
use Data::Dumper; |
|
20
|
|
|
|
|
349
|
|
|
20
|
|
|
|
|
737
|
|
45
|
20
|
|
|
20
|
|
69
|
use Exporter 'import'; |
|
20
|
|
|
|
|
19
|
|
|
20
|
|
|
|
|
380
|
|
46
|
20
|
|
|
20
|
|
62
|
use Web::MREST::CLI qw( send_req ); |
|
20
|
|
|
|
|
20
|
|
|
20
|
|
|
|
|
4903
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 NAME |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
App::Dochazka::CLI::Commands::Component - Component commands |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 PACKAGE VARIABLES |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
63
|
|
|
|
|
|
|
component_path |
64
|
|
|
|
|
|
|
generate_report |
65
|
|
|
|
|
|
|
); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 FUNCTIONS |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
The functions in this module are called from the parser when it recognizes a command. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 component_path |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
COMPONENT PATH |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
N.B. Work In Progress, unclear whether it will ever be useful |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub component_path { |
85
|
0
|
0
|
|
0
|
1
|
|
print "Entering " . __PACKAGE__ . "::component_path\n" if $debug_mode; |
86
|
0
|
|
|
|
|
|
my ( $ts, $th ) = @_; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# parse test |
89
|
0
|
0
|
|
|
|
|
return parse_test( $ts, $th ) if $ts eq 'PARSE_TEST'; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# print debug info |
92
|
0
|
0
|
|
|
|
|
if ( $debug_mode ) { |
93
|
0
|
|
|
|
|
|
print "Entering " . __PACKAGE__ . "::component_path\n"; |
94
|
0
|
|
|
|
|
|
print Dumper( $th ); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
my $status = send_req( 'POST', 'component/path', $th->{_REST} ); |
98
|
0
|
0
|
|
|
|
|
return rest_error( $status, "COMPONENT PATH" ) unless $status->ok; |
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
return $CELL->status_ok( 'DOCHAZKA_CLI_NORMAL_COMPLETION', payload => $status->payload ); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 generate_report |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
GENERATE REPORT _PATH $PARAMETERS_JSON |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Example $PARAMETERS_JSON: { "name" : "John Doe" } |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub generate_report { |
113
|
0
|
0
|
|
0
|
1
|
|
print "Entering " . __PACKAGE__ . "::generate_report\n" if $debug_mode; |
114
|
0
|
|
|
|
|
|
my ( $ts, $th ) = @_; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
# parse test |
117
|
0
|
0
|
|
|
|
|
return parse_test( $ts, $th ) if $ts eq 'PARSE_TEST'; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# print debug info |
120
|
0
|
0
|
|
|
|
|
if ( $debug_mode ) { |
121
|
0
|
|
|
|
|
|
print "Entering " . __PACKAGE__ . "::generate_report\n"; |
122
|
0
|
|
|
|
|
|
print Dumper( $th ); |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
|
my $path = $th->{_PATH}; |
126
|
0
|
|
|
|
|
|
my $entity = "{ \"path\": \"$path\""; |
127
|
0
|
0
|
|
|
|
|
$entity .= ", \"parameters\": " . $th->{_JSON} if $th->{_JSON}; |
128
|
0
|
|
|
|
|
|
$entity .= " }"; |
129
|
0
|
|
|
|
|
|
return shared_generate_report( $entity ); |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
1; |