X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=lib%2FClearcase%2FView.pm;h=3405e40d000cc35a7608ce6da5d582632154f01a;hb=252d1ff39d76bc3a23c2c330e4529f72550bcded;hp=77cfc6a9f5a156e14c7bf4e0de3e95ba1530eb48;hpb=1140ca8d56832ae529db0f353112ac192cdf9432;p=clearscm.git diff --git a/lib/Clearcase/View.pm b/lib/Clearcase/View.pm index 77cfc6a..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,8 +127,8 @@ use warnings; use Clearcase; use Display; -sub new ($) { - my ($class, $tag) = @_; +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; 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,14 +1176,9 @@ Returns: =cut return $self->{tag}; - } # tag - -# Alias name to tag -sub name() { - goto &tag; -} # name +} # tag -sub text_mode () { +sub text_mode() { my ($self) = @_; =pod @@ -1213,7 +1216,7 @@ Returns: return $self->{text_mode}; } # tag -sub type () { +sub type() { my ($self) = @_; =pod @@ -1248,10 +1251,10 @@ Returns: =cut - return $self->{type} ? $self->{type} : 'Unknown'; + return $self->{type}; } # type -sub ucm () { +sub ucm() { my ($self) = @_; =pod @@ -1289,7 +1292,7 @@ Returns: return $self->{ucm}; } # ucm -sub uuid () { +sub uuid() { my ($self) = @_; =pod @@ -1327,7 +1330,7 @@ Returns: return $self->{uuid}; } # uuid -sub exists () { +sub exists() { my ($self) = @_; =pod @@ -1362,13 +1365,13 @@ 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 (;$$$) { - my ($self, $host, $vws, $opts) = @_; +sub create(;$$$) { + my ($self, $host, $vws, $region) = @_; =pod @@ -1414,6 +1417,8 @@ Ouput from cleartool =cut + $region ||= $Clearcase::CC->region; + if ($self->exists) { $self->updateViewInfo; @@ -1422,19 +1427,15 @@ Ouput from cleartool my ($status, @output); - $opts ||= ''; - if ($host && $vws) { - ($status, @output) = $Clearcase::CC->execute( - "mkview -tag $self->{tag} $opts " . - "-host $host -hpath $vws -gpath $vws $vws" - ); + ($status, @output) = + $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} $opts -stgloc -auto" - ); + ($status, @output) = + $Clearcase::CC->execute("mkview -tag $self->{tag} -stgloc -auto"); } # if $self->updateViewInfo; @@ -1442,9 +1443,8 @@ Ouput from cleartool return ($status, @output); } # create -# TODO Is this used? -sub createUCM ($$) { - my ($self, $stream, $pvob) = @_; +sub createUCM($$) { + my ($self, $stream, $pvob, $region) = @_; =pod @@ -1490,14 +1490,18 @@ Array of output =cut - return (0, ()) if $self->exists; + $region ||= $Clearcase::CC->region; + + return (0, ()) + if $self->exists; # Update object members - $self->{pvob} = $pvob; + $self->{stream} = $stream; + $self->{pvob} = $pvob; # 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) @@ -1508,7 +1512,7 @@ Array of output return ($status, @output); } # createUCM -sub remove () { +sub remove() { my ($self) = @_; =pod @@ -1549,19 +1553,18 @@ Ouput from cleartool =cut - return (0, ()) unless $self->exists; + return (0, ()) + unless $self->exists; my ($status, @output); if ($self->dynamic) { - $self->stop; - - ($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 @@ -1569,7 +1572,7 @@ Ouput from cleartool return ($status, @output); } # remove -sub start () { +sub start() { my ($self) = @_; =pod @@ -1610,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 @@ -1654,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 @@ -1698,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 @@ -1749,13 +1752,15 @@ Ouput from cleartool return ($status, @output); } # set -sub updateViewInfo () { +sub updateViewInfo($$) { my ($self) = @_; - my ($status, @output) = $Clearcase::CC->execute ( - "lsview -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... @@ -1767,7 +1772,7 @@ sub updateViewInfo () { $self->{ucm} = 0; $self->{additional_groups} = ''; - foreach (@output) { + for (@output) { if (/Global path: (.*)/) { $self->{gpath} = $1; } elsif (/Server host: (.*)/) { @@ -1808,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; @@ -1840,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