X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=lib%2FClearcase%2FView.pm;h=3405e40d000cc35a7608ce6da5d582632154f01a;hb=8b6b892a792ff965a5323e429db66a31efd4683f;hp=7a59cd2191bc9ed9b9aed0cc9ed5ef1174074a8f;hpb=e907bf835bb61d8888f2fcd59c90bd071e841cf7;p=clearscm.git diff --git a/lib/Clearcase/View.pm b/lib/Clearcase/View.pm index 7a59cd2..3405e40 100644 --- a/lib/Clearcase/View.pm +++ b/lib/Clearcase/View.pm @@ -46,9 +46,9 @@ fields they are expanded. display_nolf MAGENTA . "Additional groups:\t"; - foreach ($view->additional_groups) { + for ($view->additional_groups) { display_nolf "$_ "; - } # foreach + } # for display ''; @@ -127,7 +127,7 @@ use warnings; use Clearcase; use Display; -sub new ($;$) { +sub new($;$) { my ($class, $tag, $region) = @_; =pod @@ -170,14 +170,19 @@ Returns: =cut - my $self = bless { tag => $tag }, $class; + $region ||= $Clearcase::CC->region; + + my $self = bless { + tag => $tag, + region => $region + }, $class; - $self->updateViewInfo ($region); + $self->updateViewInfo; return $self; } # new -sub accessed_by () { +sub accessed_by() { my ($self) = @_; =pod @@ -215,7 +220,7 @@ Returns: return $self->{accessed_by}; } # accessed_by -sub accessed_date () { +sub accessed_date() { my ($self) = @_; =pod @@ -253,7 +258,7 @@ Returns: return $self->{accessed_date}; } # accessed_date -sub access_path () { +sub access_path() { my ($self) = @_; =pod @@ -291,7 +296,7 @@ Returns: return $self->{access_path}; } # access_path -sub active () { +sub active() { my ($self) = @_; =pod @@ -329,7 +334,7 @@ Returns: return $self->{active}; } # active -sub additional_groups () { +sub additional_groups() { my ($self) = @_; =pod @@ -372,7 +377,7 @@ Returns: } # if } # additional_groups -sub created_by () { +sub created_by() { my ($self) = @_; =pod @@ -410,7 +415,7 @@ Returns: return $self->{created_by}; } # created_by -sub created_date () { +sub created_date() { my ($self) = @_; =pod @@ -448,7 +453,7 @@ Returns: return $self->{created_date}; } # created_date -sub cs_updated_by () { +sub cs_updated_by() { my ($self) = @_; =pod @@ -486,7 +491,7 @@ Returns: return $self->{cs_updated_by}; } # cs_updated_by -sub cs_updated_date () { +sub cs_updated_date() { my ($self) = @_; =pod @@ -524,7 +529,7 @@ Returns: return $self->{cs_updated_date}; } # cs_updated_date -sub dynamic () { +sub dynamic() { my ($self) = @_; =pod @@ -559,10 +564,11 @@ Returns: =cut + return unless $self->{type}; return $self->type eq 'dynamic'; } # dynamic -sub gpath () { +sub gpath() { my ($self) = @_; =pod @@ -600,7 +606,7 @@ Returns: return $self->{gpath}; } # gpath -sub group () { +sub group() { my ($self) = @_; =pod @@ -638,7 +644,7 @@ Returns: return $self->{group}; } # group -sub group_mode () { +sub group_mode() { my ($self) = @_; =pod @@ -676,7 +682,7 @@ Returns: return $self->{group_mode}; } # group_mode -sub host () { +sub host() { my ($self) = @_; =pod @@ -714,7 +720,7 @@ Returns: return $self->{host}; } # host -sub mode () { +sub mode() { my ($self) = @_; =pod @@ -752,7 +758,7 @@ Returns: return $self->{mode}; } # mode -sub modified_by () { +sub modified_by() { my ($self) = @_; =pod @@ -790,7 +796,7 @@ Returns: return $self->{modified_by}; } # modified_by -sub modified_date () { +sub modified_date() { my ($self) = @_; =pod @@ -828,7 +834,7 @@ Returns: return $self->{modified_date}; } # modified_date -sub other_mode () { +sub other_mode() { my ($self) = @_; =pod @@ -866,7 +872,7 @@ Returns: return $self->{other_mode}; } # other_mode -sub owner () { +sub owner() { my ($self) = @_; =pod @@ -904,7 +910,7 @@ Returns: return $self->{owner} } # owner -sub owner_mode () { +sub owner_mode() { my ($self) = @_; =pod @@ -942,7 +948,7 @@ Returns: return $self->{owner_mode} } # owner_mode -sub properties () { +sub properties() { my ($self) = @_; =pod @@ -980,7 +986,7 @@ Returns: return $self->{properties}; } # properties -sub region () { +sub region() { my ($self) = @_; =pod @@ -1018,7 +1024,7 @@ Returns: return $self->{region}; } # region -sub shost () { +sub shost() { my ($self) = @_; =pod @@ -1056,7 +1062,7 @@ Returns: return $self->{shost}; } # shost -sub snapshot () { +sub snapshot() { my ($self) = @_; =pod @@ -1091,10 +1097,11 @@ Returns: =cut + return unless $self->{type}; return $self->type eq 'snapshot'; } # snapshot -sub webview () { +sub webview() { my ($self) = @_; =pod @@ -1129,10 +1136,11 @@ Returns: =cut - return $self->type eq 'webview'; + return unless $self->{type}; + return $self->{type} eq 'webview'; } # webview -sub tag () { +sub tag() { my ($self) = @_; =pod @@ -1168,9 +1176,9 @@ Returns: =cut return $self->{tag}; - } # tag +} # tag -sub text_mode () { +sub text_mode() { my ($self) = @_; =pod @@ -1208,7 +1216,7 @@ Returns: return $self->{text_mode}; } # tag -sub type () { +sub type() { my ($self) = @_; =pod @@ -1243,10 +1251,10 @@ Returns: =cut - return $self->{type} ? $self->{type} : 'Unknown'; + return $self->{type}; } # type -sub ucm () { +sub ucm() { my ($self) = @_; =pod @@ -1284,7 +1292,7 @@ Returns: return $self->{ucm}; } # ucm -sub uuid () { +sub uuid() { my ($self) = @_; =pod @@ -1322,7 +1330,7 @@ Returns: return $self->{uuid}; } # uuid -sub exists () { +sub exists() { my ($self) = @_; =pod @@ -1357,12 +1365,12 @@ Returns: =cut - my ($status, @output) = $Clearcase::CC->execute ("lsview $self->{tag}"); + my ($status, @output) = $Clearcase::CC->execute("lsview -region $self->{region} $self->{tag}"); return !$status; } # exists -sub create (;$$$) { +sub create(;$$$) { my ($self, $host, $vws, $region) = @_; =pod @@ -1412,7 +1420,7 @@ Ouput from cleartool $region ||= $Clearcase::CC->region; if ($self->exists) { - $self->updateViewInfo ($region); + $self->updateViewInfo; return (0, ()) } # if @@ -1421,21 +1429,21 @@ Ouput from cleartool if ($host && $vws) { ($status, @output) = - $Clearcase::CC->execute ("mkview -tag $self->{tag} -region $region " + $Clearcase::CC->execute("mkview -tag $self->{tag} -region $region " . "-host $host -hpath $vws -gpath $vws $vws"); } else { # Note this requires that -stgloc's work and that using -auto is not a # problem. ($status, @output) = - $Clearcase::CC->execute ("mkview -tag $self->{tag} -stgloc -auto"); + $Clearcase::CC->execute("mkview -tag $self->{tag} -stgloc -auto"); } # if - $self->updateViewInfo ($region); + $self->updateViewInfo; return ($status, @output); } # create -sub createUCM ($$) { +sub createUCM($$) { my ($self, $stream, $pvob, $region) = @_; =pod @@ -1493,18 +1501,18 @@ Array of output # Need to create the view my ($status, @output) = - $Clearcase::CC->execute ("mkview -tag $self->{tag} -stream " + $Clearcase::CC->execute("mkview -tag $self->{tag} -stream " . "$self->{stream}\@$self->{pvob} -stgloc -auto"); return ($status, @output) if $status; - $self->updateViewInfo ($region); + $self->updateViewInfo; return ($status, @output); } # createUCM -sub remove () { +sub remove() { my ($self) = @_; =pod @@ -1551,12 +1559,12 @@ Ouput from cleartool my ($status, @output); if ($self->dynamic) { - ($status, @output) = $Clearcase::CC->execute ( + ($status, @output) = $Clearcase::CC->execute( "rmview -force -tag $self->{tag}" ); } else { error 'Removal of snapshot views not implemented yet', 1; - #($status, @output) = $Clearcase::CC->execute ( + #($status, @output) = $Clearcase::CC->execute( # "rmview -force $self->{snapshot_view_pname}" #); } # if @@ -1564,7 +1572,7 @@ Ouput from cleartool return ($status, @output); } # remove -sub start () { +sub start() { my ($self) = @_; =pod @@ -1605,10 +1613,10 @@ Ouput from cleartool =cut - return $Clearcase::CC->execute ("startview $self->{tag}"); + return $Clearcase::CC->execute("startview $self->{tag}"); } # start -sub stop () { +sub stop() { my ($self) = @_; =pod @@ -1649,10 +1657,10 @@ Ouput from cleartool =cut - return $Clearcase::CC->execute ("endview $self->{tag}"); + return $Clearcase::CC->execute("endview $self->{tag}"); } # stop -sub kill () { +sub kill() { my ($self) = @_; =pod @@ -1693,10 +1701,10 @@ Ouput from cleartool =cut - return $Clearcase::CC->execute ("endview -server $self->{tag}"); + return $Clearcase::CC->execute("endview -server $self->{tag}"); } # kill -sub set () { +sub set() { my ($self) = @_; =pod @@ -1744,15 +1752,15 @@ Ouput from cleartool return ($status, @output); } # set -sub updateViewInfo ($$) { - my ($self, $region) = @_; - - $region ||= $Clearcase::CC->region; +sub updateViewInfo($$) { + my ($self) = @_; - my ($status, @output) = $Clearcase::CC->execute ( - "lsview -region $region -long -properties -full $self->{tag}" + my ($status, @output) = $Clearcase::CC->execute( + "lsview -region $self->{region} -long -properties -full $self->{tag}" ); + return if $status; + # Assuming this view is an empty shell of an object that the user may possibly # use the create method on, return our blessings... @@ -1764,7 +1772,7 @@ sub updateViewInfo ($$) { $self->{ucm} = 0; $self->{additional_groups} = ''; - foreach (@output) { + for (@output) { if (/Global path: (.*)/) { $self->{gpath} = $1; } elsif (/Server host: (.*)/) { @@ -1805,19 +1813,26 @@ sub updateViewInfo ($$) { $self->{text_mode} = $1; } elsif (/Properties: (.*)/) { $self->{properties} = $1; - } elsif (/Owner: (\S+)\s+: (\S+) /) { + } elsif (/View owner: (\S+)$/) { + # It is possible that there may be problems enumerating + # -properties and -full when listing views due to servers + # no longer being available. Still the "View owner" line + # denotes the view's owner. + $self->{owner} = $1; + $self->{owner_mode} = ''; + } elsif (/Owner: (\S+)\s+: (\S+)/) { $self->{owner} = $1; $self->{owner_mode} = $2; } elsif (/Group: (.+)\s+:\s+(\S+)\s+/) { $self->{group} = $1; - $self->{group_mode} = $2; - } elsif (/Other:\s+: (\S+) /) { + $self->{group_mode} = $2; + } elsif (/Other:\s+: (\S+)/) { $self->{other_mode} = $1; } elsif (/Additional groups: (.*)/) { my @additional_groups = split /\s+/, $1; $self->{additional_groups} = \@additional_groups; } # if - } # foreach + } # for # Change modes to numeric $self->{mode} = 0; @@ -1837,6 +1852,361 @@ sub updateViewInfo ($$) { return; } # updateViewInfo +sub viewPrivateStorage() { + my ($self) = @_; + +=pod + +=head1 viewPrivateStorage + +Returns the view private storage size for this view. + +Parameters: + +=for html
+ +=over + +=item none + +=back + +=for html+ +Returns: + +=for html
+ +=over + +=item view private storage + +=back + +=for html+ +=cut + + $self->updateViewSpace unless ($self->{viewPrivateStorage}); + + return $self->{viewPrivateStorage}; +} # viewPrivateStorage + +sub viewPrivateStoragePct() { + my ($self) = @_; + +=pod + +=head1 viewPrivateStoragePct + +Returns the view private storage percent for this view. + +Parameters: + +=for html
+ +=over + +=item none + +=back + +=for html+ +Returns: + +=for html
+ +=over + +=item view private storage + +=back + +=for html+ +=cut + + $self->updateViewSpace unless ($self->{viewPrivateStoragePct}); + + return $self->{viewPrivateStoragePct}; +} # viewPrivateStoragePct + +sub viewDatabase() { + my ($self) = @_; + +=pod + +=head1 viewDatabase + +Returns the view database size for this view. + +Parameters: + +=for html
+ +=over + +=item none + +=back + +=for html+ +Returns: + +=for html
+ +=over + +=item view database size + +=back + +=for html+ +=cut + + $self->updateViewSpace unless ($self->{viewDatabase}); + + return $self->{viewDatabase}; +} # viewDatabase + +sub viewDatabasePct() { + my ($self) = @_; + +=pod + +=head1 viewDatabasePct + +Returns the view database percent for this view. + +Parameters: + +=for html
+ +=over + +=item none + +=back + +=for html+ +Returns: + +=for html
+ +=over + +=item view database percent + +=back + +=for html+ +=cut + + $self->updateViewSpace unless ($self->{viewDatabasePct}); + + return $self->{viewDatabasePct}; +} # viewDatabasePct + +sub viewAdmin() { + my ($self) = @_; + +=pod + +=head1 viewAdmin + +Returns the view admin size for this view. + +Parameters: + +=for html
+ +=over + +=item none + +=back + +=for html+ +Returns: + +=for html
+ +=over + +=item view admin size + +=back + +=for html+ +=cut + + $self->updateViewSpace unless ($self->{viewAdmin}); + + return $self->{viewAdmin}; +} # viewAdmin + +sub viewAdminPct() { + my ($self) = @_; + +=pod + +=head1 viewAdminPct + +Returns the view admin percent for this view. + +Parameters: + +=for html
+ +=over + +=item none + +=back + +=for html+ +Returns: + +=for html
+ +=over + +=item view admin percent + +=back + +=for html+ +=cut + + $self->updateViewSpace unless ($self->{viewAdminPct}); + + return $self->{viewAdminPct}; +} # viewAdminPct + +sub viewSpace() { + my ($self) = @_; + +=pod + +=head1 viewSpace + +Returns the view total size for this view. + +Parameters: + +=for html
+ +=over + +=item none + +=back + +=for html+ +Returns: + +=for html
+ +=over + +=item view space + +=back + +=for html+ +=cut + + $self->updateViewSpace unless ($self->{viewSpace}); + + return $self->{viewSpace}; +} # viewSpace + +sub viewSpacePct() { + my ($self) = @_; + +=pod + +=head1 viewSpacePct + +Returns the view database percent for this view. + +Parameters: + +=for html
+ +=over + +=item none + +=back + +=for html+ +Returns: + +=for html
+ +=over + +=item view space percent + +=back + +=for html+ +=cut + + $self->updateViewSpace unless ($self->{viewSpacePct}); + + return $self->{viewSpacePct}; +} # viewSpacePct + +sub updateViewSpace() { + my ($self) = @_; + + my ($status, @output) = $Clearcase::CC->execute( + "space -region $self->{region} -view $self->{tag}" + ); + + $self->{viewPrivateStorage} = 0.0; + $self->{viewPrivateStoragePct} = '0%'; + $self->{viewAdmin} = 0.0; + $self->{viewAdminPct} = '0%'; + $self->{viewDatabase} = 0.0; + $self->{viewDatabasePct} = '0%'; + $self->{viewSpace} = 0.0; + $self->{viewSpacePct} = '0%'; + + for (@output) { + if (/\s*(\S+)\s*(\S+)\s*View private storage/) { + $self->{viewPrivateStorage} = $1; + $self->{viewPrivateStoragePct} = $2; + } elsif (/\s*(\S+)\s*(\S+)\s*View database/) { + $self->{viewDatabase} = $1; + $self->{viewDatabasePct} = $2; + } elsif (/\s*(\S+)\s*(\S+)\s*View administration/) { + $self->{viewAdmin} = $1; + $self->{viewAdminPct} = $2; + } elsif (/\s*(\S+)\s*(\S+)\s*Subtotal/) { + $self->{viewSpace} = $1; + $self->{viewSpacePct} = $2; + } # if + } # for + + return; +} # updateViewSpace + 1; =pod