Can snapshots be deleted from workbench in V13?
search cancel

Can snapshots be deleted from workbench in V13?

book

Article ID: 9980

calendar_today

Updated On:

Products

CA Harvest Software Change Manager - OpenMake Meister CA Harvest Software Change Manager

Issue/Introduction

When users want to delete a snapshot, Harvest provides 2 methods for doing this. The first is to login to the Administrator Tool, navigate to your project, and in the “View Snapshot” state, right click on the name of your snapshot and delete it. The second is a command line utility called “hdelss”. But what if users want this functionality from within Workbench?

Environment

CA Harvest SCM all versions and platforms

Resolution

This can be done with the following steps:

  1. Users belonging to groups who have “Update Access” to a repository can delete snapshots. In the Administrator Tool, you will need to navigate to the “Repositories” tab, and to the repository for your project. Right click and select “Properties”, then select the “Access” tab. You can add user groups to the “Update Access” list from there. (Control Object Access - Repository Access)

  2. This is going to involve passing the user’s password to a UDP script we’re going to build. To make this possible we need to set a flag in the SCM database, then restart the broker. Scripts are provided to accomplish this for both Oracle databases and SQL Server databases. On the broker machine you will need to execute this script:

    On the Windows platform for an Oracle database:
    sqlplus userid@servicename/password @"%CA_SCM_HOME%\Database\EnableSysVarPw.sql"

    On the Windows platform for a SQL Server database:
    sqlcmd -d dbname -i "%CA_SCM_HOME%\Database\EnableSysVarPw_sqlserver.sql" -U userid -P password -e -b -o log_file.txt

    On the Unix or Linux platform for an Oracle database:
    sqlplus userid@servicename/password @"$CA_SCM_HOME/Database/EnableSysVarPw.sql
    After executing the script you will need to stop and restart the broker.
    (Use the System Variables - Password System Variable)

  3. Snapshots can be deleted without logging into the Administrator Tool by using the hdelss command line utility. You will need to create a batch script in the appropriate language for the operating system of your broker machine to accept parameters from the command line and execute the “hdelss” command. What follows is an example of a Windows batch script that will accept the input parameters, set the name of the log file to accept the result and then execute the hdelss command:
    echo off
    set _broker=%1
    set _project=%2
    set _userid=%3
    set _password=%4
    set _snapshot=%5

    for /f "tokens=2 delims==." %%I in ('wmic os get localdatetime /format:list') do set datetime=%%I
    set log_filename=hdelss_%datetime%.log

    echo %date% %time% -- User %_userid% is deleting snapshot %_snapshot% > %log_filename%
    echo. >> %log_filename%
    hdelss %_snapshot% -b %_broker% -en %_project% -usr %_userid% -pw %_password% -oa %log_filename%
    type %log_filename%
    (Command Reference - hdelss Command-Delete Snapshot View)

  4. With all these pieces in place, the next step is to create a UDP process in the “View Snapshots” state of your project that will execute your “delete snapshot” script:


    Provide a name, and in the “Program” field provide the syntax for your command. You can use the Harvest System variables to pass in broker name, project name, userid and password, as in the following example:
    (program field = “C:\scmscripts\deleteSnapshot.bat [broker] [project] [user] [password]”)
    Be sure that “Type” is set to “Server” and that the “Allow Additional Parameters” checkbox is checked.

    Make sure to select the “Access” tab and add any necessary user groups to the Execute Access list for this new UDP process so that users authorized to delete snapshots can execute the process.

  5. Once everything is set, you can test the script by logging into Workbench, creating a test snapshot, and then trying to delete it. Right click on the “View Snapshots” state and select your “Delete Snapshot” UDP process. There is not a way to “pass in” the name of the snapshot to be deleted with a Harvest System variable, so you will need to type the snapshot name into the “Additional Command Line Parameters field” and then clicked OK. If the name of the snapshot contains any spaces or special characters, please enclose the name in double-quotes.


    The result in the Output Log area show that the command was successful:



Additional Information

This method is offered as an example only and should be used as a starting point with which to develop your own method.  Broadcom does not offer support or enhancement for this suggested approach.