예제 #1
0
파일: api.py 프로젝트: beav/pulp
def list_importer_types(importer_id):
    """
    List the supported content types for the given importer id.

    This should be the signature:
      return: tuple of types supported by the importer
      rtype: tuple
    However it's actually returning a dict where the types are under key
    "types". I don't have time to dig into what is calling this to fix it,
    so for now I'm fixing the docs.

    :param importer_id: id of the importer
    :type importer_id: str

    :return: dict containing the type IDs at key "types"
    :rtype:  dict {str : list}

    :raise: PluginNotFound if no importer corresponds to the id
    """
    assert _is_initialized()
    types = _MANAGER.importers.get_loaded_plugins().get(importer_id, None)
    if types is None:
        raise loader_exceptions.PluginNotFound(
            _('No plugin found: %(n)s') % {'n': importer_id})
    return types
예제 #2
0
 def get_plugin_ids_by_type(self, type_):
     """
     @type type_: str
     @rtype: tuple (str, ...)
     @raises L{PluginNotFound}
     """
     plugins = self.types.get(type_, [])
     if not plugins:
         raise loader_exceptions.PluginNotFound(_('No plugin found for: %(t)s') % {'t': type_})
     return tuple(plugins)
예제 #3
0
 def get_plugin_by_id(self, id):
     """
     @type id: str
     @rtype: tuple (type, dict)
     @raises L{PluginNotFound}
     """
     if not self.has_plugin(id):
         raise loader_exceptions.PluginNotFound(_('No plugin found: %(n)s') % {'n': id})
     # return a deepcopy of the config to avoid persisting external changes
     return self.plugins[id], copy.deepcopy(self.configs[id])
예제 #4
0
    def test_find_profiler_not_found(self, mock_plugins):
        type_id = '2344'
        mock_plugins.get_profiler_by_type.side_effect = plugin_exceptions.PluginNotFound()

        # test manager

        plugin, cfg = AgentManager._profiler(type_id)

        # validation

        mock_plugins.get_profiler_by_type.assert_called_with(type_id)
        self.assertTrue(isinstance(plugin, Profiler))
        self.assertEqual(cfg, {})
예제 #5
0
def get_importer_by_id(object_id):
    """
    Get a plugin and call configuration using the document ID
    of the repository-importer association document.

    :param object_id: The document ID.
    :type object_id: str
    :return: A tuple of:
        (pulp.plugins.importer.Importer, pulp.plugins.config.PluginCallConfiguration)
    :rtype: tuple
    :raise pulp.plugins.loader.exceptions.PluginNotFound: not found.
    """
    try:
        object_id = ObjectId(object_id)
    except InvalidId:
        raise plugin_exceptions.PluginNotFound()
    try:
        document = model.Importer.objects.get(id=object_id)
    except DoesNotExist:
        raise plugin_exceptions.PluginNotFound()
    plugin, cfg = plugin_api.get_importer_by_id(document.importer_type_id)
    call_conf = PluginCallConfiguration(cfg, document.config)
    return plugin, call_conf
예제 #6
0
파일: api.py 프로젝트: beav/pulp
def list_profiler_types(profiler_id):
    """
    List the supported profile types for the given profiler id.
    :param profiler_id: id of the profiler
    :type profiler_id: str
    :return: tuple of types supported by the profiler
    :rtype: tuple
    :raise: PluginNotFound if no profiler corresponds to the id
    """
    assert _is_initialized()
    types = _MANAGER.profilers.get_loaded_plugins().get(profiler_id, None)
    if types is None:
        raise loader_exceptions.PluginNotFound(
            _('No plugin found: %(n)s') % {'n': profiler_id})
    return types
예제 #7
0
def list_distributor_types(id):
    """
    List the supported distribution types for the given distributor id.
    @param id: id of the distributor
    @type id: str
    @return: tuple of types supported by the distributor
    @rtype: tuple
    @raise: L{PluginNotFound} if no distributor corresponds to the id
    """
    assert _is_initialized()
    types = _MANAGER.distributors.get_loaded_plugins().get(id, None)
    if types is None:
        raise loader_exceptions.PluginNotFound(
            _('No plugin found: %(n)s') % {'n': id})
    return types
예제 #8
0
    def mock_get_profiler_by_type(type):
        if type not in PROFILER_MAPPINGS:
            raise plugin_exceptions.PluginNotFound()

        return PROFILER_MAPPINGS[type], {}
예제 #9
0
    def mock_get_group_importer_by_id(id):
        if id not in GROUP_IMPORTER_MAPPINGS:
            raise plugin_exceptions.PluginNotFound()

        return GROUP_IMPORTER_MAPPINGS[id], {}
예제 #10
0
    def mock_get_group_distributor_by_id(id):
        if id not in GROUP_DISTRIBUTOR_MAPPINGS:
            raise plugin_exceptions.PluginNotFound()

        return GROUP_DISTRIBUTOR_MAPPINGS[id], {}
예제 #11
0
 def dummy_get_distributor_by_id(id):
     if id not in DISTRIBUTOR_MAPPINGS:
         raise plugin_exceptions.PluginNotFound()
     return DISTRIBUTOR_MAPPINGS[id], {}
예제 #12
0
 def dummy_get_importer_by_id(id):
     if id not in IMPORTER_MAPPINGS:
         raise plugin_exceptions.PluginNotFound()
     return IMPORTER_MAPPINGS[id], {}