How to remove old content view versions in Red Hat Satellite 6 using CLI/hammer?

Solution Verified - Updated

Environment

  • Red Hat Satellite 6.x

Issue

  • How to remove old versions of content view in Red Hat Satellite 6 using hammer.

Resolution

  • With the help of hammer tool we can remove old versions of the content view from CLI. Login to hammer shell, collect the required information of the content view version to be deleted and then delete the same. For example.
# hammer shell
> organization list


-

ID | NAME   | LABEL  | DESCRIPTION
-|-|-|-

1  | RedHat | RedHat |            
-|-|-

> content-view list --organization-id 1


-

CONTENT VIEW ID | NAME                      | LABEL                     | COMPOSITE | REPOSITORY IDS
-|-|-|-|-
3               | RHSCL-TEST                | RHSCL-TEST                |           | 8             
2               | Rhel 7                    | Rhel_7                    |           | 2             

1               | Default Organization View | Default_Organization_View |           |               
-|-|-|-

> content-view version list --organization-id 1
-

ID | NAME                          | VERSION | LIFECYCLE ENVIRONMENTS
-|-|-|-
5  | Rhel 7 3.0                    | 3.0     | Library               
4  | Rhel 7 2.0                    | 2.0     |                       
3  | RHSCL-TEST 1.0                | 1.0     | Library, dev          

1  | Default Organization View 1.0 | 1.0     | Library               
-|-|-|-

hammer> content-view version delete --content-view-id 2 --id 4 --organization-id 1
[.........................................................................................................................] [100%]

hammer> content-view version list --organization-id 1
-

ID | NAME                          | VERSION | LIFECYCLE ENVIRONMENTS
-|-|-|-
5  | Rhel 7 3.0                    | 3.0     | Library               
3  | RHSCL-TEST 1.0                | 1.0     | Library, dev          

1  | Default Organization View 1.0 | 1.0     | Library               
-|-|-|-

Optionally, to delete all except for X newest versions, use the following commands:

hammer content-view purge --id <id> --count X ..

Example:

[root@satellite ~]# hammer content-view list 
-

CONTENT VIEW ID | NAME                      | LABEL                     | COMPOSITE | LAST PUBLISHED      
-|-|-|-|-
3               | composite                 | composite                 | true      | 2022/08/11 19:39:34    
1               | Default Organization View | Default_Organization_View | false     | 2022/05/12 16:23:18                
5               | Docker_CV                 | Docker_CV                 | false     | 2022/10/19 15:37:15            
2               | RHEL7_CV                  | RHEL7_CV                  | false     | 2023/01/12 19:23:41             

4               | Test_CV                  | Test_CV                  | false     | 2022/06/10 12:51:11          
-|-|-|-|-


[root@satellite ~]# hammer --no-headers content-view version list --content-view-id 4
11 | Test_CV 8.0 | 8.0     | Patch_7     | Library               
10 | Test_CV 7.0 | 7.0     | Patch_6     |                       
9  | Test_CV 6.0 | 6.0     | Patch_5     |                       
8  | Test_CV 5.0 | 5.0     | Patch_4     |                       
7  | Test_CV 4.0 | 4.0     | Patch_3     |                       
6  | Test_CV 3.0 | 3.0     | Patch_2     |                       
5  | Test_CV 2.0 | 2.0     | Patch_1     |                       
4  | Test_CV 1.0 | 1.0     |             |                       

[root@satellite ~]# hammer content-view purge --count 3 --id 4

[root@satellite ~]# hammer --no-headers content-view version list --content-view-id 4
11 | Test_CV 8.0 | 8.0     | Patch_7     | Library               
10 | Test_CV 7.0 | 7.0     | Patch_6     |                       
9  | Test_CV 6.0 | 6.0     | Patch_5     |                       
8  | Test_CV 5.0 | 5.0     | Patch_4     |     

Also see How to delete/purge the content view version of specific content view through CLI in Red Hat Satellite 6

When having many Content Views and their versions and unsure what versions are not further used, please follow this solution to identify them.

In rare scenarios if the above doesn't work for a specific CV, one may use the workaround Content from github.com is not included.script to delete unused content view versions.

For more KB articles/solutions related to Red Hat Satellite 6.x Content View Issues, please refer to the Red Hat Satellite Consolidated Troubleshooting Article for Red Hat Satellite 6.x Content View Issues

For more KB articles/solutions related to Red Hat Satellite 6.x hammer Issues, please refer to the Consolidated Troubleshooting Article for Red Hat Satellite 6.x hammer-related Issues

SBR
Product(s)
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.