-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add dynamic pull for cloud inventory plugins and update corresponding…
… tests Add corresponding migrations Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
- Loading branch information
Showing
11 changed files
with
100 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
awx/main/migrations/0196_alter_inventorysource_source_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Generated by Django 4.2.10 on 2024-09-24 15:53 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('main', '0195_EE_permissions'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='inventorysource', | ||
name='source', | ||
field=models.CharField(default=None, max_length=32), | ||
), | ||
migrations.AlterField( | ||
model_name='inventoryupdate', | ||
name='source', | ||
field=models.CharField(default=None, max_length=32), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Generated by Django 4.2.10 on 2024-10-16 17:59 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('main', '0196_alter_inventorysource_source_and_more'), | ||
('main', '0197_remove_sso_app_content'), | ||
] | ||
|
||
operations = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Copyright (c) 2024 Ansible, Inc. | ||
# All Rights Reserved. | ||
|
||
""" | ||
This module contains the code responsible for extracting the lists of dynamically discovered plugins. | ||
""" | ||
|
||
from functools import cache | ||
|
||
|
||
@cache | ||
def discover_available_cloud_provider_plugin_names() -> list[str]: | ||
"""Return a list of cloud plugin names available in runtime. | ||
The discovery result is cached since it does not change throughout | ||
the life cycle of the server run. | ||
:returns: List of plugin cloud names. | ||
:rtype: list[str] | ||
""" | ||
from awx.main.models.inventory import InventorySourceOptions | ||
|
||
return list(InventorySourceOptions.injectors.keys()) | ||
|
||
|
||
@cache | ||
def compute_cloud_inventory_sources() -> dict[str, str]: | ||
"""Return a dictionary of cloud provider plugin names | ||
available plus source control management. | ||
:returns: Dictionary of plugin cloud names plus source control. | ||
:rtype: dict[str, str] | ||
""" | ||
|
||
plugins = discover_available_cloud_provider_plugin_names() | ||
|
||
return dict(zip(plugins, plugins), scm='scm') |