Removed /usr/local from CDPATH
[clearscm.git] / clearadm / vobdetails.cgi
1 #!/usr/local/bin/perl
2
3 =pod
4
5 =head1 NAME $RCSfile: vobdetails.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 vobdetails.cgi: [-u|sage] [-r|egion <region>] -vo|b <vobtag>
34                        [-ve|rbose] [-d|ebug]
35
36  Where:
37    -u|sage:           Displays usage
38    -r|egion <region>: Region to use when looking for the vob
39    -vo|b <vobtag>:    Tag of vob 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 vob
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 Clearadm;
61 use ClearadmWeb;
62 use Clearcase;
63 use Clearcase::Vob;
64 use Clearcase::Vobs;
65 use Display;
66 use Utils;
67
68 my %opts = Vars;
69
70 my $subtitle = 'VOB Details';
71
72 if ($Clearcase::CC->region) {
73   $opts{region} ||= $Clearcase::CC->region;
74 } else {
75   $opts{region} ||= 'Clearcase not installed';
76 } # if
77
78 my $VERSION  = '$Revision: 1.11 $';
79   ($VERSION) = ($VERSION =~ /\$Revision: (.*) /);
80
81 sub DisplayTable($) {
82   my ($vob) = @_;
83
84   my $active = ($vob->active) ? 'YES' : 'NO';
85   my $gpath  = $vob->gpath;
86
87   $gpath = font {-class => 'unknown'}, '&lt;no-gpath&gt;'
88     if $gpath eq '<no-gpath>';
89
90   display start_table {
91     -cellspacing    => 1,
92     -class          => 'main',
93   };
94
95   my $clearadm = Clearadm->new;
96
97   my %clearadmvob = $clearadm->GetVob($vob->tag, $vob->region);
98
99   display start_Tr;
100     display th {class => 'label'},              'Tag:';
101     display td {class => 'data', colspan => 3}, setField $vob->tag;
102     display th {class => 'label'},              'Server:';
103     display td {class => 'data'}, a {
104       href => 'systemdetails.cgi?system=' . $vob->shost
105     }, $vob->shost;
106     display th {class => 'label'},               'Region:';
107     display td {class => 'data', colspan => 3},  $vob->region;
108   display end_Tr;
109
110   display start_Tr;
111     display th {class => 'label'},              'Type:';
112     display td {class => 'data', colspan => 3}, $vob->access;
113     display th {class => 'label'},              'Attributes:';
114     display td {class => 'data'},               $vob->vob_registry_attributes;
115     display th {class => 'label'},              'Mount Opts:';
116     display td {class => 'data', colspan => 3}, $vob->mopts;
117   display end_Tr;
118
119   display start_Tr;
120     display th {class => 'label'},              'Owner:';
121     display td {class => 'data', colspan => 3}, $vob->owner;
122     display th {class => 'label'},              'Active:';
123     display td {class => 'data'},               $active;
124     display th {class => 'label'},              'ACLs Enabled:';
125     display td {class => 'data', colspan => 3}, $vob->aclsEnabled;
126   display end_Tr;
127
128   display start_Tr;
129     display th {class => 'label'},              'Created by:';
130     display td {class => 'data', colspan => 3}, $vob->ownername;
131     display th {class => 'label'},              'on:';
132     display td {class => 'data'},               $vob->created;
133     display th {class => 'label'},              'Atomic Checkin:';
134     display td {class => 'data', colspan => 3}, $vob->atomicCheckin;
135   display end_Tr;
136
137   display start_Tr;
138     display th {class => 'label'},              'Comment:';
139     display td {class => 'data', colspan => 5}, $vob->comment;
140     display th {class => 'label'},              'Schema Version:';
141     display td {class => 'data', colspan => 3}, $vob->schemaVersion;
142   display end_Tr;
143   
144   display start_Tr;
145     display th {class => 'label'},              'Global Path:';
146     display td {class => 'data', colspan => 5}, $gpath;
147     display th {class => 'label'},              'Registry Attributes:';
148     display td {class => 'data', colspan => 3}, $vob->vob_registry_attributes;
149   display end_Tr;
150
151   display start_Tr;
152     display th {class => 'label'},              'Access Path:';
153     display td {class => 'data', colspan => 5}, $vob->access_path;
154     display th {class => 'label'},              'Group:';
155     display td {class => 'data', colspan => 3}, $vob->group;
156   display end_Tr;
157
158   display start_Tr;
159     display th {class => 'label'},              'Family UUID:';
160     display td {class => 'data', colspan => 5}, $vob->family_uuid;
161     display th {class => 'label'},              'Remote Privilage:';
162     display td {class => 'data', colspan => 3}, $vob->remotePrivilege;
163   display end_Tr;
164
165   display start_Tr;
166     display th {class => 'label'},              'Replica UUID:';
167     display td {class => 'data', colspan => 5}, $vob->replica_uuid;
168     display th {class => 'label'},              'Master Replica:';
169     display td {class => 'data', colspan => 3}, $vob->masterReplica;
170   display end_Tr;
171
172   my $groups = join "<br>", $vob->groups;
173
174   display start_Tr;
175     display th {class => 'label'},               'Groups:';
176     display td {class => 'data', colspan => 10}, $groups;
177   display end_Tr;
178
179   my %attributes = $vob->attributes;
180   my $attributes = '';
181
182   for (keys %attributes) {
183     $attributes .= "$_ = $attributes{$_}<br>";
184   } # for
185   
186   display start_Tr;
187     display th {class => 'label'},               'Attributes:';
188     display td {class => 'data', colspan => 10}, $attributes;
189   display end_Tr;
190
191   my %hyperlinks = $vob->hyperlinks;
192   my $hyperlinks = '';
193
194   for (keys %hyperlinks) {
195     $hyperlinks .= "$_ = $hyperlinks{$_}<br>";
196   } # for
197   
198   display start_Tr;
199     display th {class => 'label'},               'Hyperlinks:';
200     display td {class => 'data', colspan => 10}, $hyperlinks;
201   display end_Tr;
202
203   display start_Tr;
204     display th {class => 'labelCentered', colspan => 10}, 'VOB Storage Pools';
205   display end_Tr;
206
207   my $image = $clearadmvob{adminsmall}
208     ? "data:image/png;base64,$clearadmvob{adminsmall}"
209     : "plotstorage.cgi?type=vob&storage=admin&tiny=1&tag=" . $vob->tag;
210
211   display start_Tr;
212     display th {class => 'label'},                                'Admin:';
213     display td {class => 'data', colspan => 4, align => 'center'}, a {href =>
214       'plot.cgi?type=vob&storage=admin&scaling=Day&points=7&region=' . $vob->region . '&tag=' . $vob->tag
215     }, img {
216       src    => $image,
217       border => 0,
218     };
219
220     $image = $clearadmvob{sourcesmall}
221       ? "data:image/png;base64,$clearadmvob{sourcesmall}"
222       : 'plotstorage.cgi?type=vob&storage=source&tiny=1&region=' . $vob->region . '&tag=' . $vob->tag;
223
224     display th {class => 'label'},                                'Source Size:';
225     display td {class => 'data', colspan => 4, align => 'center'}, a {href =>
226       'plot.cgi?type=vob&storage=source&scaling=Day&points=7&region=' . $vob->region . '&tag=' . $vob->tag
227     }, img {
228       src    => $image,
229       border => 0,
230     };
231   display end_Tr;
232
233   display start_Tr;
234     $image = $clearadmvob{dbsmall}
235       ? "data:image/png;base64,$clearadmvob{dbsmall}"
236       : 'plotstorage.cgi?type=vob&storage=db&tiny=1&region=' . $vob->region . '&tag=' . $vob->tag;
237
238     display th {class => 'label'},                                'Database:';
239     display td {class => 'data', colspan => 4, align => 'center'}, a {href =>
240       'plot.cgi?type=vob&storage=db&scaling=Day&points=7&region=' . $vob->region . '&tag=' . $vob->tag
241     }, img {
242       src    => $image,
243       border => 0,
244     };
245
246     $image = $clearadmvob{derivedobjsmall}
247       ? "data:image/png;base64,$clearadmvob{derivedobjsmall}"
248       : 'plotstorage.cgi?type=vob&storage=derivedobj&tiny=1&region=' . $vob->region . '&tag=' . $vob->tag;
249
250     display th {class => 'label'},                                'Derived Obj:';
251     display td {class => 'data', colspan => 4, align => 'center'}, a {href =>
252       'plot.cgi?type=vob&storage=derivedobj&scaling=Day&points=7&region=' . $vob->region . '&tag=' . $vob->tag
253     }, img {
254       src    => $image,
255       border => 0,
256     };
257   display end_Tr;
258
259   display start_Tr;
260     $image = $clearadmvob{cleartextsmall}
261       ? "data:image/png;base64,$clearadmvob{cleartextsmall}"
262       : 'plotstorage.cgi?type=vob&storage=cleartext&tiny=1&region=' . $vob->retion . '&tag=' . $vob->tag;
263
264     display th {class => 'label'},                                'Cleartext:';
265     display td {class => 'data', colspan => 4, align => 'center'}, a {href =>
266       'plot.cgi?type=vob&storage=cleartext&scaling=Day&points=7&region=' . $vob->region . '&tag=' . $vob->tag
267     }, img {
268       src    => $image,
269       border => 0,
270     };
271
272     $image = $clearadmvob{totalsmall}
273       ? "data:image/png;base64,$clearadmvob{totalsmall}"
274       : 'plotstorage.cgi?type=vob&storage=total&tiny=1&region=' . $vob->region . '&tag=' . $vob->tag;
275
276     display th {class => 'label'},                                'Total Size:';
277     display td {class => 'data', colspan => 4, align => 'center'}, a {href =>
278       'plot.cgi?type=vob&storage=total&scaling=Day&points=7&region=' . $vob->region . '&tag=' . $vob->tag
279     }, img {
280       src    => $image,
281       border => 0,
282     };
283   display end_Tr;
284
285   display end_table;
286
287   return;
288 } # DisplayTable
289
290 sub DisplayRegion() {
291   display start_form (action => 'vobdetails.cgi');
292
293   display 'Region ';
294
295   my ($defaultRegion, @regions) = ('', ('Clearcase not installed'));
296
297   display popup_menu(
298     -name     => 'region',
299     -values   => [@regions],
300     -default  => $defaultRegion,
301     -onchange => 'submit();',
302   );
303
304   display submit(
305     -value => 'Go',
306   );
307
308   display end_form;
309   
310   return
311 } # DisplayRegion
312
313 sub DisplayVobs($) {
314   my ($region) = @_;
315
316   my @vobs = Clearcase::Vobs->new ($region);
317
318   unless (@vobs) {
319     push @vobs, 'No VOBs';
320   } # unless
321
322   display start_form(action => 'vobdetails.cgi');
323
324   display 'Region ';
325
326   display popup_menu(
327     -name     => 'region',
328     -values   => [$Clearcase::CC->regions],
329     -default  => $region,
330     -onchange => 'submit();',
331   );
332
333   display b ' VOB: ';
334
335   display popup_menu(
336      -name     => 'vob',
337      -values   => \@vobs,
338      -onchange => 'submit();',
339   );
340
341   display submit(
342     -value     => 'Go',
343   );
344
345   display end_form;
346   
347   return;
348 } # DisplayVobs
349
350 # Main
351 GetOptions(
352   \%opts,
353   'usage'        => sub { Usage },
354   'verbose'      => sub { set_verbose },
355   'debug'        => sub { set_debug },
356   'vob=s',
357   'region=s',
358 ) or Usage "Invalid parameter";
359
360 # Announce ourselves
361 verbose "$FindBin::Script v$VERSION";
362
363 heading $subtitle;
364
365 display h1 {
366   -class => 'center',
367 }, $subtitle;
368
369 unless ($opts{tag}) {
370   unless ($opts{region}) {
371     DisplayRegion;
372   } else {
373     DisplayVobs $opts{region};
374   } # unless
375
376   exit;
377 } # unless
378
379 my $vob = Clearcase::Vob->new($opts{tag}, $opts{region});
380
381 DisplayTable $vob;
382
383 footing;
384
385 =pod
386
387 =head1 CONFIGURATION AND ENVIRONMENT
388
389 DEBUG: If set then $debug is set to this level.
390
391 VERBOSE: If set then $verbose is set to this level.
392
393 TRACE: If set then $trace is set to this level.
394
395 =head1 DEPENDENCIES
396
397 =head2 Perl Modules
398
399 L<CGI>
400
401 L<CGI::Carp|CGI::Carp>
402
403 L<FindBin>
404
405 L<Getopt::Long|Getopt::Long>
406
407 =head2 ClearSCM Perl Modules
408
409 =begin man 
410
411  ClearadmWeb
412  Clearcase
413  Clearcase::View
414  Clearcase::Views
415  Display
416  Utils
417
418 =end man
419
420 =begin html
421
422 <blockquote>
423 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/Clearadm.pm">Clearadm</a><br>
424 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/ClearadmWeb.pm">ClearadmWeb</a><br>
425 <a href="http://clearscm.com/php/scm_man.php?file=lib/Clearcase.pm">Clearcase</a><br>
426 <a href="http://clearscm.com/php/scm_man.php?file=lib/Clearcase/View.pm">Clearcase::View</a><br>
427 <a href="http://clearscm.com/php/scm_man.php?file=lib/Clearcase/Views.pm">Clearcase::Views</a><br>
428 <a href="http://clearscm.com/php/scm_man.php?file=lib/Display.pm">Display</a><br>
429 <a href="http://clearscm.com/php/scm_man.php?file=lib/Utils.pm">Utils</a><br>
430 </blockquote>
431
432 =end html
433
434 =head1 BUGS AND LIMITATIONS
435
436 There are no known bugs in this script
437
438 Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.
439
440 =head1 LICENSE AND COPYRIGHT
441
442 Copyright (c) 2010, ClearSCM, Inc. All rights reserved.
443
444 =cut