Bug 487566 - RFE: simple script to purge snapshot data
Summary: RFE: simple script to purge snapshot data
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Satellite 5
Classification: Red Hat
Component: Server
Version: 520
Hardware: All
OS: Linux
high
high
Target Milestone: ---
Assignee: Brad Buckingham
QA Contact: wes hayutin
URL:
Whiteboard:
Depends On:
Blocks: sat530-snapshots 456995
TreeView+ depends on / blocked
 
Reported: 2009-02-26 18:46 UTC by Todd Warner
Modified: 2009-09-10 19:58 UTC (History)
4 users (show)

Fixed In Version: sat530
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2009-09-10 19:58:47 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Todd Warner 2009-02-26 18:46:13 UTC
SSIA. Need a way to nuke all snapshot data. If you can do it by date, that would be a nicety.

Comment 4 Justin Sherrill 2009-02-27 22:17:00 UTC
John,

How about: 

"Added ability to purge system snapshots via the api."

or something like that.

Comment 5 John Ha 2009-03-01 04:55:47 UTC
Okay, I've added it to the release notes. Thanks!

 RHN Satellite 5.3.0 now has the ability to purge system snapshots via the API

Comment 6 Brad Buckingham 2009-03-03 17:31:04 UTC
Looking over the current APIs available in Spacewalk, it looks like we have some new APIs introduced in SW 0.1 that may satisfy this request.  The APIs are system.listSnapshots, system.deleteSnapshot and system.deleteSnapshots.  See below for details.

We do not currently have a method to "delete snapshots by date".  It is technically feasible; however, the user could use these existing APIs to create a script that uses listSnapshots, retrieves the date from the result and then invokes deleteSnapshot.

Based on this, do you still want us to add the "delete snapshots by date"?


----------------------------------

Method: listSnapshots
Description:
List the snapshots for a given system

Parameters:

    * string sessionKey
    * int serverId

Returns:

    * array:
          o struct - server snapshot
                + int "id"
                + string "reason" - the reason for the snapshot's existence
                + dateTime.iso8601 "created"
                + array "channels"
                      # string labels of channels associated with the snapshot
                + array "groups"
                      # string Names of server groups associated with the snapshot
                + array "entitlements"
                      # string Names of system entitlements associated with the snapshot
                + array "config_channels"
                      # string Labels of config channels the snapshot is associated with.
                + array "tags"
                      # string Tag names associated with this snapshot.
                + string "Invalid_reason" - If the snapshot is invalid, this is the reason (optional).


Method: deleteSnapshot
Description:
Deletes a snapshot with the given snapshot id

Parameters:

    * string sessionKey
    * int snapshotId - Id of snapshot to delete

Returns:

    * int - 1 on success, exception thrown otherwise. 



Method: deleteSnapshots
Description:
Deletes all snapshots of a given server

Parameters:

    * string sessionKey
    * int sid - system id of system to delete snapshots for

Returns:

    * int - 1 on success, exception thrown otherwise.

Comment 7 Todd Warner 2009-03-05 11:49:45 UTC
'do you still want us to add the "delete snapshots by date"?'

Yes. And shouldn't this bug be beyond the NEW state by now?

Comment 8 Brad Buckingham 2009-04-07 20:12:25 UTC
master git commit: c55ad4bf0952843b458b33579544338069cb442e

Note: more work to be done before moving to MODIFIED and cherry picking to vader branch.

Comment 9 Brad Buckingham 2009-04-24 14:08:39 UTC
The initial modifications for the script have been completed and will be included in the spacewalk-utils package.

Once spacewalk-utils is installed, the script will be placed in /usr/bin/sw-system-snapshot.  A man page is also included.  Refer to it for more details along with example scenarios.

The following is the script usage information:

bash-3.2$ sw-system-snapshot --help

usage: sw-system-snapshot [options]

options:
  -v, --verbose         Increase verbosity
  -u USERNAME, --username=USERNAME
                        Username
  -p PASSWORD, --password=PASSWORD
                        Password
  -d, --delete          Delete snapshots.
  -l, --list            List snapshot summary.
  -a, --all             Include all snapshots based on criteria provided.
  --start-date=START_DATE
                        Include only snapshots taken on or after this date.
                        Must be in the format 'YYYYMMDDHH24MISS'.
  --end-date=END_DATE   Include only snapshots taken on or before this date.
                        Must be in the format 'YYYYMMDDHH24MISS'.
  --satellite=SATELLITE
                        Server.
  --system-id=SYSTEM_ID
                        System Id.
  --snapshot-id=SNAPSHOT_ID
                        Snapshot Id.
  -h, --help            show this help message and exit

----------------------------------------------------------------------------

Examples: note these do not cover all possible execution scenarios...

List examples, to see what would be deleted if using the same criteria:
-----------------------------------------------------------------------

sw-system-snapshot --list --all

sw-system-snapshot --list --all --start-date=20090403000000

sw-system-snapshot --list --system-id=1000010022

sw-system-snapshot --list  --system-id=1000010022 
  --start-date=20090101000000 --end-date=20091231000000

Delete examples:
----------------

sw-system-snapshot --delete --all

sw-system-snapshot --delete --all --start-date=20090403000000

sw-system-snapshot --delete --system-id=1000010022

sw-system-snapshot --delete --system-id=1000010022
  --start-date=20090101000000 --end-date=20091231000000

sw-system-snapshot --delete --system-id=1000010022
  --system-id=1000010033

Comment 10 wes hayutin 2009-05-19 21:16:26 UTC
verified 5/7.1

Comment 12 Brandon Perkins 2009-09-10 19:58:47 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHEA-2009-1434.html


Note You need to log in before you can comment on or make changes to this bug.