72b486b79d11e50c79ab793cee1c04f0958cc12a
[clearscm.git] / clearadm / viewdetails.cgi
1 #!/usr/local/bin/perl
2
3 =pod
4
5 =head1 NAME $RCSfile: viewdetails.cgi,v $
6
7 View Details
8
9 =head1 VERSION
10
11 =over
12
13 =item Author
14
15 Andrew DeFaria <Andrew@ClearSCM.com>
16
17 =item Revision
18
19 $Revision: 1.11 $
20
21 =item Created:
22
23 Mon Oct 25 11:10:47 PDT 2008
24
25 =item Modified:
26
27 $Date: 2011/01/14 16:51:58 $
28
29 =back
30
31 =head1 SYNOPSIS
32
33  Usage viewdetails.cgi: [-u|sage] [-r|egion <region>] -vi|ew <viewname>
34                         [-ve|rbose] [-d|ebug]
35
36  Where:
37    -u|sage:           Displays usage
38    -r|egion <region>: Region to use when looking for the view
39    -vi|ew<viewname>:  Name of view to display details for
40
41    -ve|rbose:         Be verbose
42    -d|ebug:           Output debug messages
43
44 =head2 DESCRIPTION
45
46 This script display the details for the given view
47
48 =cut
49
50 use strict;
51 use warnings;
52
53 use FindBin;
54 use Getopt::Long;
55 use CGI qw (:standard :cgi-lib *table start_Tr end_Tr);
56 use CGI::Carp 'fatalsToBrowser';
57
58 use lib "$FindBin::Bin/lib", "$FindBin::Bin/../lib";
59
60 use ClearadmWeb;
61 use Clearcase;
62 use Clearcase::View;
63 use Clearcase::Views;
64 use Display;
65 use Utils;
66
67 my %opts = Vars;
68
69 my $subtitle = 'View Details';
70
71 if ($Clearcase::CC->region) {
72   $opts{region} ||= $Clearcase::CC->region;
73 } else {
74   $opts{region} ||= 'Clearcase not installed';
75 } # if
76
77 my $VERSION  = '$Revision: 1.11 $';
78   ($VERSION) = ($VERSION =~ /\$Revision: (.*) /);
79
80 sub DisplayTable ($) {
81   my ($view) = @_;
82
83   my $permissions     = setField $view->owner_mode
84                       . setField $view->group_mode
85                       . setField $view->other_mode;
86   my $active          = ($view->active) ? 'YES' : 'NO';
87   my $gpath           = $view->gpath;
88
89   $gpath = font {-class => 'unknown'}, '&lt;no-gpath&gt;'
90     if $gpath eq '<no-gpath>';
91
92   display start_table {
93     -cellspacing    => 1,
94     -class          => 'main',
95   };
96
97   display start_Tr;
98     display th {class => 'label'},              'Tag:';
99     display td {class => 'data', colspan => 3}, setField $view->tag;
100     display th {class => 'label'},              'Server:';
101     display td {class => 'data'}, a {
102       href => 'systemdetails.cgi?system=' . $view->shost
103     }, $view->shost;
104     display th {class => 'label'},               'Region:';
105     display td {class => 'data'},                 $view->region;
106   display end_Tr;
107
108   display start_Tr;
109     display th {class => 'label'},              'Properties:';
110     display td {class => 'data', colspan => 3}, $view->properties;
111     display th {class => 'label'},              'Text Mode:';
112     display td {class => 'data'},               $view->text_mode;
113     display th {class => 'label'},              'Permission:';
114     display td {class => 'data'},               $permissions;
115   display end_Tr;
116
117   display start_Tr;
118     display th {class => 'label'},              'Owner:';
119     display td {class => 'data', colspan => 3}, $view->owner;
120     display th {class => 'label'},              'Active:';
121     display td {class => 'data', colspan => 3}, $active;
122   display end_Tr;
123
124   display start_Tr;
125     display th {class => 'label'},              'Created by:';
126     display td {class => 'data', colspan => 3}, $view->created_by;
127     display th {class => 'label'},              'on:';
128     display td {class => 'data', colspan => 3}, $view->created_date;
129   display end_Tr;
130
131   display start_Tr;
132     display th {class => 'label'},              'CS Updated by:';
133     display td {class => 'data', colspan => 3}, $view->cs_updated_by;
134     display th {class => 'label'},              'on:';
135     display td {class => 'data', colspan => 3}, $view->cs_updated_date;
136   display end_Tr;
137
138   display start_Tr;
139     display th {class => 'label'},              'Global Path:';
140     display td {class => 'data', colspan => 7}, $gpath;
141   display end_Tr;
142
143   display start_Tr;
144     display th {class => 'label'},              'Access Path:';
145     display td {class => 'data', colspan => 7}, $view->access_path;
146   display end_Tr;
147
148   display start_Tr;
149     display th {class => 'label'},              'UUID:';
150     display td {class => 'data', colspan => 7}, $view->uuid;
151   display end_Tr;
152
153   display start_Tr;
154     display th {class => 'labelCentered', colspan => 10}, 'View Storage Pools';
155   display end_Tr;
156
157   display start_Tr;
158     display th {class => 'label'},                                'Database:';
159     display td {class => 'data', colspan => 3, align => 'center'}, a {href =>
160        "plot.cgi?type=view&storage=private&tag=" . $view->tag
161     }, img {
162       src    => "plotstorage.cgi?type=view&storage=private&tiny=1&tag=" . $view->tag,
163       border => 0,
164     };
165     display th {class => 'label'},                                'Private:';
166     display td {class => 'data', colspan => 5, align => 'center'}, a {href =>
167        "plot.cgi?type=view&storage=db&tag=" . $view->tag
168     }, img {
169       src    => "plotstorage.cgi?type=view&storage=db&tiny=1&tag=" . $view->tag,
170       border => 0,
171     };
172   display end_Tr;
173
174   display start_Tr;
175     display th {class => 'label'},                                'Admin:';
176     display td {class => 'data', colspan => 3, align => 'center'}, a {href =>
177        "plot.cgi?type=view&storage=admin&tag=" . $view->tag
178     }, img {
179       src    => "plotstorage.cgi?type=view&storage=admin&tiny=1&tag=" . $view->tag,
180       border => 0,
181     };
182     display th {class => 'label'},                                'Total Space:';
183     display td {class => 'data', colspan => 5, align => 'center'}, a {href =>
184        "plot.cgi?type=view&storage=total&tag=" . $view->tag
185     }, img {
186       src    => "plotstorage.cgi?type=view&storage=total&tiny=1&tag=" . $view->tag,
187       border => 0,
188     };
189   display end_Tr;
190
191   display end_table;
192   
193   return
194 } # DisplayTable
195
196 sub DisplayRegion {
197   display start_form (action => 'viewdetails.cgi');
198
199   display 'Region ';
200
201   my ($defaultRegion, @regions) = ('', ('Clearcase not installed'));
202
203   display popup_menu (
204     -name     => 'region',
205     -values   => [@regions],
206     -default  => $defaultRegion,
207     -onchange => 'submit();',
208   );
209
210   display submit (
211     -value => 'Go',
212   );
213
214   display end_form;
215   
216   return
217 } # DisplayRegion
218
219 sub DisplayViews ($) {
220   my ($region) = @_;
221
222   my $views = Clearcase::Views->new ($region);
223   my @views = $views->views;
224
225   unless (@views) {
226     push @views, 'No Views';
227   } # unless
228
229   display start_form (action => 'viewdetails.cgi');
230
231   display 'Region ';
232
233   display popup_menu (
234     -name     => 'region',
235     -values   => [$Clearcase::CC->regions],
236     -default  => $region,
237     -onchange => 'submit();',
238   );
239
240   display b ' View: ';
241
242   display popup_menu (
243      -name     => 'view',
244      -values   => \@views,
245      -onchange => 'submit();',
246   );
247
248   display submit (
249     -value     => 'Go',
250   );
251
252   display end_form;
253   
254   return;
255 } # DisplayViews
256
257 # Main
258 GetOptions (
259   \%opts,
260   'usage'        => sub { Usage },
261   'verbose'      => sub { set_verbose },
262   'debug'        => sub { set_debug },
263   'view=s',
264   'region=s',
265 ) or Usage "Invalid parameter";
266
267 # Announce ourselves
268 verbose "$FindBin::Script v$VERSION";
269
270 heading $subtitle;
271
272 display h1 {
273   -class => 'center',
274 }, $subtitle;
275
276 unless ($opts{tag}) {
277   unless ($opts{region}) {
278     DisplayRegion;
279   } else {
280     DisplayViews $opts{region};
281   } # unless
282
283   exit;
284 } # unless
285
286 my $view = Clearcase::View->new ($opts{tag}, $opts{region});
287
288 DisplayTable $view;
289
290 footing;
291
292 =pod
293
294 =head1 CONFIGURATION AND ENVIRONMENT
295
296 DEBUG: If set then $debug is set to this level.
297
298 VERBOSE: If set then $verbose is set to this level.
299
300 TRACE: If set then $trace is set to this level.
301
302 =head1 DEPENDENCIES
303
304 =head2 Perl Modules
305
306 L<CGI>
307
308 L<CGI::Carp|CGI::Carp>
309
310 L<FindBin>
311
312 L<Getopt::Long|Getopt::Long>
313
314 =head2 ClearSCM Perl Modules
315
316 =begin man 
317
318  ClearadmWeb
319  Clearcase
320  Clearcase::View
321  Clearcase::Views
322  Display
323  Utils
324
325 =end man
326
327 =begin html
328
329 <blockquote>
330 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/ClearadmWeb.pm">ClearadmWeb</a><br>
331 <a href="http://clearscm.com/php/scm_man.php?file=lib/Clearcase.pm">Clearcase</a><br>
332 <a href="http://clearscm.com/php/scm_man.php?file=lib/Clearcase/View.pm">Clearcase::View</a><br>
333 <a href="http://clearscm.com/php/scm_man.php?file=lib/Clearcase/Views.pm">Clearcase::Views</a><br>
334 <a href="http://clearscm.com/php/scm_man.php?file=lib/Display.pm">Display</a><br>
335 <a href="http://clearscm.com/php/scm_man.php?file=lib/Utils.pm">Utils</a><br>
336 </blockquote>
337
338 =end html
339
340 =head1 BUGS AND LIMITATIONS
341
342 There are no known bugs in this script
343
344 Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.
345
346 =head1 LICENSE AND COPYRIGHT
347
348 Copyright (c) 2010, ClearSCM, Inc. All rights reserved.
349
350 =cut