Big update of Clearadm
[clearscm.git] / lib / Clearcase / Vobs.pm
1 =pod
2
3 =head1 NAME $RCSfile: Vobs.pm,v $
4
5 Object oriented interface to Clearcase VOBs
6
7 =head1 VERSION
8
9 =over
10
11 =item Author
12
13 Andrew DeFaria <Andrew@ClearSCM.com>
14
15 =item Revision
16
17 $Revision: 1.17 $
18
19 =item Created
20
21 Thu Dec 29 12:07:59 PST 2005
22
23 =item Modified
24
25 $Date: 2011/11/16 19:46:13 $
26
27 =back
28
29 =head1 SYNOPSIS
30
31 Provides access to information about all Clearcase VOBs.
32
33  # Create VOBs object
34  my $vobs = new Clearcase::Vobs;
35
36  display "There are " . $vobs->vobs . " vobs to process";
37
38  # Iterrate through the list of vobs
39  foreach ($vobs->vobs) {
40    my $vob = new Clearcase::Vob $_;
41    ...
42  } # foreach
43
44  # VOBs manipulation
45  display "Umounting all vobs";
46
47  $vobs->umount;
48
49  display "Mounting all vobs";
50
51  $vobs->mount;
52
53 =head1 DESCRIPTION
54
55 This module implements a Clearcase vobs object to  deal with the lists
56 of vobs in the current region.
57
58 =head1 ROUTINES
59
60 The following routines are exported:
61
62 =cut
63
64 package Clearcase::Vobs;
65
66 use strict;
67 use warnings;
68
69 use lib '..';
70
71 use Clearcase;
72 use Display;
73 use OSDep;
74
75 sub new (;$) {
76   my ($class, $host, $region) = @_;
77
78 =pod
79
80 =head2 new (host)
81
82 Construct a new Clearcase Vobs object.
83
84 Parameters:
85
86 =for html <blockquote>
87
88 =over
89
90 =item host
91
92 If host is specified then limit the vob list to only those vobs on that host. If
93 host is not specified then all vobs are considered
94
95 =back
96
97 =for html </blockquote>
98
99 Returns:
100
101 =for html <blockquote>
102
103 =over
104
105 =item Clearcase VOBs object
106
107 =back
108
109 =for html </blockquote>
110
111 =cut
112
113   my $cmd  = 'lsvob -short';
114      $cmd .= " -host $host"     if $host;
115      $cmd .= " -region $region" if $region;
116
117   my ($status, @output) = $Clearcase::CC->execute ($cmd);
118
119   return if $status;
120
121   return bless {
122     vobs => \@output
123   }, $class; # bless
124 } # new
125
126 sub vobs () {
127   my ($self) = @_;
128
129 =pod
130
131 =head3 vobs
132
133 Return a list of VOB tags in an array context or the number of vobs in
134 a scalar context.
135
136 Parameters:
137
138 =for html <blockquote>
139
140 =over
141
142 =over
143
144 =item none
145
146 =back
147
148 =back
149
150 =for html </blockquote>
151
152 Returns:
153
154 =for html <blockquote>
155
156 =over
157
158 =over
159
160 =item List of VOBs or number of VOBs
161
162 Array of VOB tags in an array context or the number of vobs in a scalar context.
163
164 =back
165
166 =back
167
168 =for html </blockquote>
169
170 =cut
171
172   if (wantarray) {
173     my @returnVobs = sort @{$self->{vobs}};
174     
175     return @returnVobs;
176   } else {
177     return scalar @{$self->{vobs}};
178   } #if
179 } # vobs
180
181 sub mount () {
182   my ($self) = @_;
183
184 =pod
185
186 =head3 mount
187
188 Mount all VOBs
189
190 Parameters:
191
192 =for html <blockquote>
193
194 =over
195
196 =over
197
198 =item none
199
200 =back
201
202 =back
203
204 =for html </blockquote>
205
206 Returns:
207
208 =for html <blockquote>
209
210 =over
211
212 =over
213
214 =item $status
215
216 Status from cleartool
217
218 =item @output
219
220 Ouput from cleartool
221
222 =back
223
224 =back
225
226 =for html </blockquote>
227
228 =cut
229
230   my ($status, @output) = $Clearcase::CC->execute ("mount -all");
231
232   return $status;
233 } # mount
234
235 sub umount () {
236   my ($self) = @_;
237
238 =pod
239
240 =head3 umount
241
242 Unmounts all VOBs
243
244 Parameters:
245
246 =for html <blockquote>
247
248 =over
249
250 =over
251
252 =item none
253
254 =back
255
256 =back
257
258 =for html </blockquote>
259
260 Returns:
261
262 =for html <blockquote>
263
264 =over
265
266 =over
267
268 =item $status
269
270 Status from cleartool
271
272 =item @output
273
274 Ouput from cleartool
275
276 =back
277
278 =back
279
280 =for html </blockquote>
281
282 =cut
283
284   my ($status, @output) = $Clearcase::CC->execute ("umount -all");
285
286   return $status;
287 } # umount
288
289 1;
290
291 =pod
292
293 =head2 DEPENDENCIES
294
295 =head3 ClearSCM Perl Modules
296
297 =for html <p><a href="/php/scm_man.php?file=lib/Clearcase.pm">Clearcase</a></p>
298
299 =for html <p><a href="/php/scm_man.php?file=lib/Display.pm">Display</a></p>
300
301 =for html <p><a href="/php/scm_man.php?file=lib/OSDep.pm">OSdep</a></p>
302
303 =head2 BUGS AND LIMITATIONS
304
305 There are no known bugs in this module
306
307 Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.
308
309 =head2 LICENSE AND COPYRIGHT
310
311 Copyright (c) 2007, ClearSCM, Inc. All rights reserved.
312
313 =cut