Delete ClearCase Views Script

I mentioned a script a little bit verbose, but which won’t remove any local storage and won’t either clean the CCRC session.dat:

nuke_view.pl: you can use it to remove all views from a workstation (which may not be available anymore)

cleartool lsview -host myHostname -quick | xargs ccperl nuke_view.pl

The -quick option is very important to quickly get the list of views for a given workstation.

## This script should be used to cleanup a view when 'ct rmview' will not
## work (such as when the viewstore directory has been deleted.
##
## Note: The view storage directory will have to manually deleted if it still exists.

use strict;

#sub NukeView();
#sub DoIt();

foreach(@ARGV) {
        NukeView($_);
}


##############################################################
sub NukeView {

        my $view2del = $_[0];

        print "Processing $view2del...\n";

        my @lines = `cleartool lsview -l $view2del`;

        my $tag;
        my $uuid;
        foreach(@lines) {
                chomp;
                $tag = $1 if /^Tag: (\S+)/;
                $uuid = $1 if /^View uuid: (\S+)/;

                s/^/\t/;

                print "$_\n";
        }

        if ( $tag eq '' or $uuid eq '' ) {
                print "Error! $view2del: unable to get tag and/or uuid\n";
                return 0;
        }

        my $err_count = 0;

        print "\tremoving tag...\n";
        my $cmd = "cleartool rmtag -view $tag";
        $err_count += 1 if DoIt($cmd);

        print "\tunregistering view storage...\n";
        $cmd = "cleartool unreg -view -uuid $uuid";
        $err_count += 1 if DoIt($cmd);

        print "\tremoving view references...\n";
        $cmd = "cleartool rmview -force -avobs -uuid $uuid";
        $err_count += 1 if DoIt($cmd);

        if ( $err_count == 0 ) {
                print "Success! removed view $view2del\n";
        }
        else {
                print "Error! errors occured while removing $view2del\n";
        }
}

#############################################
sub DoIt {
        my $ret = system($_[0]) / 256;
        print "Error! cmd failed: $_[0]\n" if $ret != 0;
        return $ret;
}

The extra steps needed for removing CCWeb Views are described in this IBM technote:

Note: For ClearCase 7.1.1.1 or 7.1.1.2 the session.dat file is no longer generated from ClearCase 7.1.1.1 as a result of APAR PM03334: session.dat no longer need to be cleaned.

Remove the view storage and cached files stored on CCWeb server.

By default, view.stg (CCRC / CCWeb view storage), view.dat and VOB’s cached files are stored in the following location:

  • Windows®: C:\Program Files\Rational\ClearCase\var\ccweb\<user>\<view_tag>
  • UNIX® / Linux®: /var/adm/rational/clearcase/ccweb/<user>/<view_tag>

Remove the <view_tag> folder located in the location above. This will remove view’s storage files, view.dat and VOB’s cached files and will let the user create a new view using the same / original view’s name.

Note: It may also be necessary to manually remove the view workspace if the view is still present on the CCRC client. This can done by navigating to the defined workspace on the client system (by default C:\Documents and Settings\<user-name>\view_tag) and removing the view workspace.
This path to the workspace is listed in the session .dat file. The entry looks like this: -workroot "c:/web_dev2". This may become useful in a case where the user did not use the default location.

CCRC view roots are also cached in a file on the client in the User Profile.
Check the following file and remove the already removed view from that list as well.

C:\Documents and Settings\<user-name>\.ccase_wvreg

Leave a Comment