Ejemplo n.º 1
0
 def purge_orphans(self):
     """
     Purge the catalog of orphaned entries.
     Orphans are entries are those entries contributed by a content
     source that no longer exists.
     """
     valid_ids = list(self.sources.keys())
     catalog = managers.content_catalog_manager()
     catalog.purge_orphans(valid_ids)
Ejemplo n.º 2
0
 def purge_orphans(self):
     """
     Purge the catalog of orphaned entries.
     Orphans are entries are those entries contributed by a content
     source that no longer exists.
     """
     valid_ids = list(self.sources.keys())
     catalog = managers.content_catalog_manager()
     catalog.purge_orphans(valid_ids)
Ejemplo n.º 3
0
 def delete_entry(self, type_id, unit_key):
     """
     Delete an entry from the content catalog.
     :param type_id: The content unit type ID.
     :type type_id: str
     :param unit_key: The content unit key.
     :type unit_key: dict
     """
     manager = managers.content_catalog_manager()
     manager.delete_entry(self.source_id, type_id, unit_key)
     self.deleted_count += 1
Ejemplo n.º 4
0
 def delete_entry(self, type_id, unit_key):
     """
     Delete an entry from the content catalog.
     :param type_id: The content unit type ID.
     :type type_id: str
     :param unit_key: The content unit key.
     :type unit_key: dict
     """
     manager = managers.content_catalog_manager()
     manager.delete_entry(self.source_id, type_id, unit_key)
     self.deleted_count += 1
Ejemplo n.º 5
0
 def add_entry(self, type_id, unit_key, url):
     """
     Add an entry to the content catalog.
     :param type_id: The content unit type ID.
     :type type_id: str
     :param unit_key: The content unit key.
     :type unit_key: dict
     :param url: The URL used to download content associated with the unit.
     :type url: str
     """
     manager = managers.content_catalog_manager()
     manager.add_entry(self.source_id, self.expires, type_id, unit_key, url)
     self.added_count += 1
Ejemplo n.º 6
0
 def add_entry(self, type_id, unit_key, url):
     """
     Add an entry to the content catalog.
     :param type_id: The content unit type ID.
     :type type_id: str
     :param unit_key: The content unit key.
     :type unit_key: dict
     :param url: The URL used to download content associated with the unit.
     :type url: str
     """
     manager = managers.content_catalog_manager()
     manager.add_entry(self.source_id, self.expires, type_id, unit_key, url)
     self.added_count += 1
Ejemplo n.º 7
0
    def delete(self, request, source_id):
        """
        Delete all entries from the catlog that have the provided source id

        :param request: WSGI request object
        :type  request: django.core.handlers.wsgi.WSGIRequest
        :param source_id: id of source whose content should be deleted
        :type  source_id: str

        :return: response containing a dict containing the number if items deleted
        :rtype : django.http.HttpResponse
        """
        manager = factory.content_catalog_manager()
        purged = manager.purge(source_id)
        deleted_info = dict(deleted=purged)
        return generate_json_response(deleted_info)
Ejemplo n.º 8
0
    def delete(self, request, source_id):
        """
        Delete all entries from the catlog that have the provided source id

        :param request: WSGI request object
        :type  request: django.core.handlers.wsgi.WSGIRequest
        :param source_id: id of source whose content should be deleted
        :type  source_id: str

        :return: response containing a dict containing the number if items deleted
        :rtype : django.http.HttpResponse
        """
        manager = factory.content_catalog_manager()
        purged = manager.purge(source_id)
        deleted_info = dict(deleted=purged)
        return generate_json_response(deleted_info)
Ejemplo n.º 9
0
    def refresh(self, force=False):
        """
        Refresh the content catalog using available content sources.

        :param force: Force refresh of content sources with unexpired catalog entries.
        :type force: bool
        :return: A list of refresh reports.
        :rtype: list of: pulp.server.content.sources.model.RefreshReport
        """
        reports = []
        catalog = managers.content_catalog_manager()
        for source_id, source in self.sources.items():
            if force or not catalog.has_entries(source_id):
                try:
                    report = source.refresh()
                    reports.extend(report)
                except Exception, e:
                    log.error('refresh %s, failed: %s', source_id, e)
                    report = RefreshReport(source_id, '')
                    report.errors.append(str(e))
                    reports.append(report)
Ejemplo n.º 10
0
 def find_sources(self, primary, alternates):
     """
     Find and set the list of content sources in the order they are to
     be used to satisfy the request.  The alternate sources are
     ordered by priority.  The primary content source is always last.
     :param primary: The primary content source.
     :type primary: ContentSource
     :param alternates: A list of alternative sources.
     :type list of: ContentSource
     """
     resolved = [(primary, self.url)]
     catalog = managers.content_catalog_manager()
     for entry in catalog.find(self.type_id, self.unit_key):
         source_id = entry[constants.SOURCE_ID]
         source = alternates.get(source_id)
         if source is None:
             continue
         url = entry[constants.URL]
         resolved.append((source, url))
     resolved.sort()
     self.sources = iter(resolved)
Ejemplo n.º 11
0
 def find_sources(self, primary, alternates):
     """
     Find and set the list of content sources in the order they are to
     be used to satisfy the request.  The alternate sources are
     ordered by priority.  The primary content source is always last.
     :param primary: The primary content source.
     :type primary: ContentSource
     :param alternates: A list of alternative sources.
     :type list of: ContentSource
     """
     resolved = [(primary, self.url)]
     catalog = managers.content_catalog_manager()
     for entry in catalog.find(self.type_id, self.unit_key):
         source_id = entry[constants.SOURCE_ID]
         source = alternates.get(source_id)
         if source is None:
             continue
         url = entry[constants.URL]
         resolved.append((source, url))
     resolved.sort()
     self.sources = iter(resolved)
Ejemplo n.º 12
0
    def refresh(self, force=False):
        """
        Refresh the content catalog using available content sources.

        :param force: Force refresh of content sources with unexpired catalog entries.
        :type force: bool
        :return: A list of refresh reports.
        :rtype: list of: pulp.server.content.sources.model.RefreshReport
        """
        reports = []
        catalog = managers.content_catalog_manager()
        for source_id, source in self.sources.items():
            if force or not catalog.has_entries(source_id):
                try:
                    report = source.refresh()
                    reports.extend(report)
                except Exception, e:
                    log.error('refresh %s, failed: %s', source_id, e)
                    report = RefreshReport(source_id, '')
                    report.errors.append(str(e))
                    reports.append(report)
Ejemplo n.º 13
0
 def refresh(self, canceled, force=False):
     """
     Refresh the content catalog using available content sources.
     :param canceled: An event that indicates the refresh has been canceled.
     :type canceled: threading.Event
     :param force: Force refresh of content sources with unexpired catalog entries.
     :type force: bool
     :return: A list of refresh reports.
     :rtype: list of: pulp.server.content.sources.model.RefreshReport
     """
     reports = []
     catalog = managers.content_catalog_manager()
     for source_id, source in self.sources.items():
         if canceled.is_set():
             break
         if force or not catalog.has_entries(source_id):
             try:
                 report = source.refresh(canceled)
                 reports.extend(report)
             except Exception, e:
                 log.error("refresh %s, failed: %s", source_id, e)
                 report = RefreshReport(source_id, "")
                 report.errors.append(str(e))
                 reports.append(report)
Ejemplo n.º 14
0
 def DELETE(self, source_id):
     manager = factory.content_catalog_manager()
     purged = manager.purge(source_id)
     deleted = dict(deleted=purged)
     return self.ok(deleted)
Ejemplo n.º 15
0
 def test_factory(self):
     manager = factory.content_catalog_manager()
     self.assertTrue(isinstance(manager, ContentCatalogManager))
Ejemplo n.º 16
0
 def test_factory(self):
     manager = factory.content_catalog_manager()
     self.assertTrue(isinstance(manager, ContentCatalogManager))
Ejemplo n.º 17
0
 def DELETE(self, source_id):
     manager = factory.content_catalog_manager()
     purged = manager.purge(source_id)
     deleted = dict(deleted=purged)
     return self.ok(deleted)
Ejemplo n.º 18
0
 def DELETE(self, source_id):
     manager = factory.content_catalog_manager()
     manager.purge(source_id)
     return self.ok(None)
Ejemplo n.º 19
0
 def DELETE(self, source_id):
     manager = factory.content_catalog_manager()
     manager.purge(source_id)
     return self.ok(None)