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