Exemple #1
0
 def is_valid(self):
     """
     Get whether the content source has a valid descriptor,
     references a valid cataloger plugin, and can create a nectar downloader.
     :return: True if valid.
     :rtype: bool
     """
     try:
         self.downloader()
         plugin_id = self.descriptor[constants.TYPE]
         plugins.get_cataloger_by_id(plugin_id)
         return is_valid(self.id, self.descriptor)
     except Exception:
         return False
Exemple #2
0
 def refresh(self, cancel_event):
     """
     Refresh the content catalog using the cataloger plugin as
     defined by the "type" descriptor property.
     :param cancel_event: An event that indicates the refresh has been canceled.
     :type cancel_event: threading.Event
     :return: The list of refresh reports.
     :rtype: list of: RefreshReport
     """
     reports = []
     plugin_id = self.descriptor[constants.TYPE]
     plugin, cfg = plugins.get_cataloger_by_id(plugin_id)
     conduit = CatalogerConduit(self.id, self.expires())
     for url in self.urls():
         if cancel_event.isSet():
             break
         conduit.reset()
         report = RefreshReport(self.id, url)
         log.info(REFRESHING, self.id, url)
         try:
             plugin.refresh(conduit, self.descriptor, url)
             log.info(REFRESH_SUCCEEDED, self.id, conduit.added_count, conduit.deleted_count)
             report.succeeded = True
             report.added_count = conduit.added_count
             report.deleted_count = conduit.deleted_count
         except Exception, e:
             log.error(REFRESH_FAILED, self.id, url, e)
             report.errors.append(str(e))
         finally:
Exemple #3
0
 def get_cataloger(self):
     """
     Get the cataloger plugin.
     :return: A cataloger plugin.
     :rtype: pulp.server.plugins.cataloger.Cataloger
     """
     plugin_id = self.descriptor[constants.TYPE]
     plugin, cfg = plugins.get_cataloger_by_id(plugin_id)
     return plugin
Exemple #4
0
 def get_cataloger(self):
     """
     Get the cataloger plugin.
     :return: A cataloger plugin.
     :rtype: pulp.server.plugins.cataloger.Cataloger
     """
     plugin_id = self.descriptor[constants.TYPE]
     plugin, cfg = plugins.get_cataloger_by_id(plugin_id)
     return plugin
Exemple #5
0
 def test_catalogers(self):
     # listing
     catalogers = api.list_catalogers()
     self.assertEqual(len(catalogers), 1)
     self.assertEqual(catalogers, {CATALOGER_ID: METADATA})
     # by id
     cataloger = api.get_cataloger_by_id(CATALOGER_ID)
     self.assertFalse(cataloger is None)
     self.assertTrue(isinstance(cataloger[0], MockCataloger))
     self.assertRaises(PluginNotFound, api.get_cataloger_by_id, 'not-valid')
     # is_valid
     self.assertTrue(api.is_valid_cataloger(CATALOGER_ID))
     self.assertFalse(api.is_valid_cataloger('not-valid'))