display_nolf MAGENTA . "Additional groups:\t";
- foreach ($view->additional_groups) {
+ for ($view->additional_groups) {
display_nolf "$_ ";
- } # foreach
+ } # for
display '';
use Clearcase;
use Display;
-sub new ($) {
- my ($class, $tag) = @_;
+sub new($;$) {
+ my ($class, $tag, $region) = @_;
=pod
=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
return $self->{accessed_by};
} # accessed_by
-sub accessed_date () {
+sub accessed_date() {
my ($self) = @_;
=pod
return $self->{accessed_date};
} # accessed_date
-sub access_path () {
+sub access_path() {
my ($self) = @_;
=pod
return $self->{access_path};
} # access_path
-sub active () {
+sub active() {
my ($self) = @_;
=pod
return $self->{active};
} # active
-sub additional_groups () {
+sub additional_groups() {
my ($self) = @_;
=pod
} # if
} # additional_groups
-sub created_by () {
+sub created_by() {
my ($self) = @_;
=pod
return $self->{created_by};
} # created_by
-sub created_date () {
+sub created_date() {
my ($self) = @_;
=pod
return $self->{created_date};
} # created_date
-sub cs_updated_by () {
+sub cs_updated_by() {
my ($self) = @_;
=pod
return $self->{cs_updated_by};
} # cs_updated_by
-sub cs_updated_date () {
+sub cs_updated_date() {
my ($self) = @_;
=pod
return $self->{cs_updated_date};
} # cs_updated_date
-sub dynamic () {
+sub dynamic() {
my ($self) = @_;
=pod
=cut
+ return unless $self->{type};
return $self->type eq 'dynamic';
} # dynamic
-sub gpath () {
+sub gpath() {
my ($self) = @_;
=pod
return $self->{gpath};
} # gpath
-sub group () {
+sub group() {
my ($self) = @_;
=pod
return $self->{group};
} # group
-sub group_mode () {
+sub group_mode() {
my ($self) = @_;
=pod
return $self->{group_mode};
} # group_mode
-sub host () {
+sub host() {
my ($self) = @_;
=pod
return $self->{host};
} # host
-sub mode () {
+sub mode() {
my ($self) = @_;
=pod
return $self->{mode};
} # mode
-sub modified_by () {
+sub modified_by() {
my ($self) = @_;
=pod
return $self->{modified_by};
} # modified_by
-sub modified_date () {
+sub modified_date() {
my ($self) = @_;
=pod
return $self->{modified_date};
} # modified_date
-sub other_mode () {
+sub other_mode() {
my ($self) = @_;
=pod
return $self->{other_mode};
} # other_mode
-sub owner () {
+sub owner() {
my ($self) = @_;
=pod
return $self->{owner}
} # owner
-sub owner_mode () {
+sub owner_mode() {
my ($self) = @_;
=pod
return $self->{owner_mode}
} # owner_mode
-sub properties () {
+sub properties() {
my ($self) = @_;
=pod
return $self->{properties};
} # properties
-sub region () {
+sub region() {
my ($self) = @_;
=pod
return $self->{region};
} # region
-sub shost () {
+sub shost() {
my ($self) = @_;
=pod
return $self->{shost};
} # shost
-sub snapshot () {
+sub snapshot() {
my ($self) = @_;
=pod
=cut
+ return unless $self->{type};
return $self->type eq 'snapshot';
} # snapshot
-sub webview () {
+sub webview() {
my ($self) = @_;
=pod
=cut
- return $self->type eq 'webview';
+ return unless $self->{type};
+ return $self->{type} eq 'webview';
} # webview
-sub tag () {
+sub tag() {
my ($self) = @_;
=pod
=cut
return $self->{tag};
- } # tag
-
-# Alias name to tag
-sub name() {
- goto &tag;
-} # name
+} # tag
-sub text_mode () {
+sub text_mode() {
my ($self) = @_;
=pod
return $self->{text_mode};
} # tag
-sub type () {
+sub type() {
my ($self) = @_;
=pod
=cut
- return $self->{type} ? $self->{type} : 'Unknown';
+ return $self->{type};
} # type
-sub ucm () {
+sub ucm() {
my ($self) = @_;
=pod
return $self->{ucm};
} # ucm
-sub uuid () {
+sub uuid() {
my ($self) = @_;
=pod
return $self->{uuid};
} # uuid
-sub exists () {
+sub exists() {
my ($self) = @_;
=pod
=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
=cut
+ $region ||= $Clearcase::CC->region;
+
if ($self->exists) {
$self->updateViewInfo;
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;
return ($status, @output);
} # create
-# TODO Is this used?
-sub createUCM ($$) {
- my ($self, $stream, $pvob) = @_;
+sub createUCM($$) {
+ my ($self, $stream, $pvob, $region) = @_;
=pod
=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)
return ($status, @output);
} # createUCM
-sub remove () {
+sub remove() {
my ($self) = @_;
=pod
=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
return ($status, @output);
} # remove
-sub start () {
+sub start() {
my ($self) = @_;
=pod
=cut
- return $Clearcase::CC->execute ("startview $self->{tag}");
+ return $Clearcase::CC->execute("startview $self->{tag}");
} # start
-sub stop () {
+sub stop() {
my ($self) = @_;
=pod
=cut
- return $Clearcase::CC->execute ("endview $self->{tag}");
+ return $Clearcase::CC->execute("endview $self->{tag}");
} # stop
-sub kill () {
+sub kill() {
my ($self) = @_;
=pod
=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
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...
$self->{ucm} = 0;
$self->{additional_groups} = '';
- foreach (@output) {
+ for (@output) {
if (/Global path: (.*)/) {
$self->{gpath} = $1;
} elsif (/Server host: (.*)/) {
$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;
return;
} # updateViewInfo
+sub viewPrivateStorage() {
+ my ($self) = @_;
+
+=pod
+
+=head1 viewPrivateStorage
+
+Returns the view private storage size for this view.
+
+Parameters:
+
+=for html <blockquote>
+
+=over
+
+=item none
+
+=back
+
+=for html </blockquote>
+
+Returns:
+
+=for html <blockquote>
+
+=over
+
+=item view private storage
+
+=back
+
+=for html </blockquote>
+
+=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 <blockquote>
+
+=over
+
+=item none
+
+=back
+
+=for html </blockquote>
+
+Returns:
+
+=for html <blockquote>
+
+=over
+
+=item view private storage
+
+=back
+
+=for html </blockquote>
+
+=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 <blockquote>
+
+=over
+
+=item none
+
+=back
+
+=for html </blockquote>
+
+Returns:
+
+=for html <blockquote>
+
+=over
+
+=item view database size
+
+=back
+
+=for html </blockquote>
+
+=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 <blockquote>
+
+=over
+
+=item none
+
+=back
+
+=for html </blockquote>
+
+Returns:
+
+=for html <blockquote>
+
+=over
+
+=item view database percent
+
+=back
+
+=for html </blockquote>
+
+=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 <blockquote>
+
+=over
+
+=item none
+
+=back
+
+=for html </blockquote>
+
+Returns:
+
+=for html <blockquote>
+
+=over
+
+=item view admin size
+
+=back
+
+=for html </blockquote>
+
+=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 <blockquote>
+
+=over
+
+=item none
+
+=back
+
+=for html </blockquote>
+
+Returns:
+
+=for html <blockquote>
+
+=over
+
+=item view admin percent
+
+=back
+
+=for html </blockquote>
+
+=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 <blockquote>
+
+=over
+
+=item none
+
+=back
+
+=for html </blockquote>
+
+Returns:
+
+=for html <blockquote>
+
+=over
+
+=item view space
+
+=back
+
+=for html </blockquote>
+
+=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 <blockquote>
+
+=over
+
+=item none
+
+=back
+
+=for html </blockquote>
+
+Returns:
+
+=for html <blockquote>
+
+=over
+
+=item view space percent
+
+=back
+
+=for html </blockquote>
+
+=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