Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull the correct collection plugin for the product #15658

Open
wants to merge 15 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions awx/main/models/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import copy
import os.path
from urllib.parse import urljoin
from importlib.metadata import entry_points
jessicamack marked this conversation as resolved.
Show resolved Hide resolved

# Django
from django.conf import settings
Expand All @@ -24,7 +25,7 @@
from rest_framework.exceptions import ParseError

from ansible_base.lib.utils.models import prevent_search
from awx_plugins.inventory.plugins import PluginFileInjector
from awx_plugins.interfaces._temporary_private_licensing_api import detect_server_product_name

# AWX
from awx.api.versioning import reverse
Expand Down Expand Up @@ -1404,5 +1405,10 @@ def get_absolute_url(self, request=None):
return reverse('api:inventory_script_detail', kwargs={'pk': self.pk}, request=request)


for cls in PluginFileInjector.__subclasses__():
InventorySourceOptions.injectors[cls.__name__] = cls
awx_entry_points = {ep.name: ep for ep in entry_points(group='awx_plugins.inventory')}
supported_entry_points = {ep.name: ep for ep in entry_points(group='awx_plugins.inventory.supported')}
entry_points = awx_entry_points if detect_server_product_name() == 'AWX' else {**awx_entry_points, **supported_entry_points}
jessicamack marked this conversation as resolved.
Show resolved Hide resolved
jessicamack marked this conversation as resolved.
Show resolved Hide resolved

for entry_point_name, entry_point in entry_points.items():
cls = entry_point.load()
InventorySourceOptions.injectors[entry_point_name] = cls
jessicamack marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 0 additions & 3 deletions awx/main/tests/functional/test_inventory_source_injectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,6 @@ def create_reference_data(source_dir, env, content):
@pytest.mark.django_db
@pytest.mark.parametrize('this_kind', discover_available_cloud_provider_plugin_names())
def test_inventory_update_injected_content(this_kind, inventory, fake_credential_factory, mock_me):
if this_kind.endswith('_supported'):
this_kind = this_kind[:-10]

ExecutionEnvironment.objects.create(name='Control Plane EE', managed=True)
ExecutionEnvironment.objects.create(name='Default Job EE', managed=False)

Expand Down
Loading