[Pulp-list] Removing content from repo via API

Trey Dockendorf treydock at gmail.com
Fri Dec 11 20:18:48 UTC 2015


I'm attempting to cleanup some of my repositories via API, and am finding I
can successfully remove everything except RPMs.  Right now I have a repo
like 'centos-6-base' that is synced against CentOS 6 base repo.  I then
copy all the content to another repo, 'local-centos-6-base'.  Normally I
copy individual RPMs, but now I'd like the local-centos-6-base repo to be a
clone of centos-6-base.  I figured the easy way is
delete local-centos-6-base, re-create, then run 'copy all'.  However I'd
like to utilize API to remove items from local-centos-6-base that do not
exist in centos-6-base.

Right now my method is get all units via source =
/api/v2/repositories/centos-6-base/search/units and dest =
/api/v2/repositories/local-centos-6-base/search/units.  I then identify the
values for each unit's unit_id that exist in dest but not in source.  I
then send a POST request to
/api/v2/repositories/local-centos-6-base/actions/unassociate/ that looks
like this:

{
  'criteria': {
    'type_ids': [unit_type_id],
    'filters': {
      'unit': { 'unit_id': { '$in' unit_ids } },
    }
  }
}

The unit_ids is a Python list that contains all the "unit_id" values that
existed in dest but not in source.  The unit_ids all have the same
"unit_type_id".  So far this method seems to have worked for type_ids
"package_group" and "package_category" but not for "rpm".

Any suggestions on what I'm doing wrong?

Thanks,
- Trey
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/pulp-list/attachments/20151211/15dbd842/attachment.htm>


More information about the Pulp-list mailing list