Delete ClearCase Views Script
(This is a repost of a deleted questio开发者_如何学Gon) (on request)
What is the best ClearCase View deletion Script? I found the following on http://www.cmcrossroads.com/forums?func=view&id=44045&catid=31 written by Yossi Sidi below
The 2 things this script misses are the deletion of the entries in the session.dat file for CCRC views and the cleaning of server view storage and cached file directories.
The manual steps can be found here: http://www-01.ibm.com/support/docview.wss?uid=swg21172246
rmview.pl
==============
#
# rmview.pl
#
# This script is used to delete a view..
# ---------------------------------------------------
# Fetching the UUID of the view :
# Cleartool describe -long vob:vob_name (lists all views)
# -or-
# cleartool lsview -long <View_name>
# ------------------------------------------------------------------------
# Remove sequence:-
# Cleartool rmview -force -uuid <uuid> (from a VIEW contents directory)
# Cleartool unreg -view -uuid <uuid>
# Cleartool rmtag -view VIEW_NAME
#
# Arguments:
# view tag name :
#
# ASSUMED: You must be in a VOB with a view set when this tool
# is used.
#
# Author: Yossi Sidi
# email: yossis@corrigent.com
# URL: [url=http://www.corrigent.com" target="_blank]http://www.corrigent.com[/url]
# Date: Sep. 14, 2003
############################################################
# History: 14/10/03 : Created for Corrigent
############################################################
########################
######## MAIN ########----------------------------------------------------------------
########################
$DIV1="*************************************************************n";
$USAGE=""USAGE ccperl.exe $0 view tag name \n EXAMPLE: ccperl.exe $0 ""My_view"" "";
if ($#ARGV == 0)
{
$view_name = $ARGV[0];
}
else
{
`clearprompt yes_no -mask abort -default abort -pre -prompt $USAGE`;
exit 1;
}
select STDOUT;
$| = 1; # Do not buffer the STDOUT file so ccperl prog.pl >out.txt
# will have the correct sequence of report lines
printf ($DIV1);
printf ("View Propertiesn");
printf (" View Tag: $view_namen");
printf ($DIV1);
printf ("n");
$COMMAND = "cleartool lsview -l $view_name";
@dl = `"$COMMAND"`;
$view_uuid = "";
foreach $dl (@dl) {
chomp ($dl);
printf ("$dln");
if ( $dl =~ /^View uuid: / ) {
$view_uuid = $'; #' reset syntax highlighter
}
}
if ( $#dl > 0 ) {
# Cleartool rmview -force -all -uuid <uuid> (from a VIEW contents directory)
# Cleartool unreg -view -uuid <uuid>
# Cleartool rmtag -view VIEW_NAME
$rmview = "cleartool rmview -force -all -uuid $view_uuid";
$unreg = "cleartool unreg -view -uuid $view_uuid";
$rmtag = "cleartool rmtag -view $view_name";
printf ($DIV1);
printf ("Removing commandsn");
printf ($DIV1);
printf ("n");
printf ("n$rmview n");
@dl = `"$rmview"`;
printf ("n$unreg n");
@dl = `"$unreg"`;
printf ("n$rmtag n");
@dl = `"$rmtag"`;
}
exit 0;
(hmmm... interesting here is that the stackoverflow colorcoding goes wild after Perl's $' .... mini bug)
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
精彩评论