Skip to content

Commit

Permalink
Replace discover_cloud_inventory_sources with compute_cloud_inventory…
Browse files Browse the repository at this point in the history
…_sources
  • Loading branch information
djyasin committed Oct 3, 2024
1 parent ac4f9f5 commit 139b3d6
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions awx/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
WorkflowJobTemplate,
WorkflowJobTemplateNode,
StdoutMaxBytesExceeded,
discover_cloud_inventory_sources,
compute_cloud_inventory_sources,
)
from awx.main.models.base import VERBOSITY_CHOICES, NEW_JOB_TYPE_CHOICES
from awx.main.models.rbac import role_summary_fields_generator, give_creator_permissions, get_role_codenames, to_permissions, get_role_from_object_role
Expand Down Expand Up @@ -5559,7 +5559,7 @@ def get_summary_fields(self, obj):
return summary_fields

def validate_unified_job_template(self, value):
if type(value) == InventorySource and value.source not in discover_cloud_inventory_sources():
if type(value) == InventorySource and value.source not in compute_cloud_inventory_sources():
raise serializers.ValidationError(_('Inventory Source must be a cloud resource.'))
elif type(value) == Project and value.scm_type == '':
raise serializers.ValidationError(_('Manual Project cannot have a schedule set.'))
Expand Down
4 changes: 2 additions & 2 deletions awx/api/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2234,11 +2234,11 @@ class InventorySourceNotificationTemplatesAnyList(SubListCreateAttachDetachAPIVi

def post(self, request, *args, **kwargs):
parent = self.get_parent_object()
if parent.source not in models.discover_cloud_inventory_sources():
if parent.source not in models.compute_cloud_inventory_sources():
return Response(
dict(
msg=_("Notification Templates can only be assigned when source is one of {}.").format(
models.discover_cloud_inventory_sources(), parent.source
models.compute_cloud_inventory_sources(), parent.source
)
),
status=status.HTTP_400_BAD_REQUEST,
Expand Down
2 changes: 1 addition & 1 deletion awx/main/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from ansible_base.lib.utils.models import user_summary_fields

# AWX
from awx.main.models.base import BaseModel, PrimordialModel, accepts_json, discover_cloud_inventory_sources, VERBOSITY_CHOICES # noqa
from awx.main.models.base import BaseModel, PrimordialModel, accepts_json, compute_cloud_inventory_sources, VERBOSITY_CHOICES # noqa
from awx.main.models.unified_jobs import UnifiedJob, UnifiedJobTemplate, StdoutMaxBytesExceeded # noqa
from awx.main.models.organization import Organization, Profile, Team, UserSessionMembership # noqa
from awx.main.models.credential import Credential, CredentialType, CredentialInputSource, ManagedCredentialType, build_safe_env # noqa
Expand Down
2 changes: 1 addition & 1 deletion awx/main/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
]


def discover_cloud_inventory_sources():
def compute_cloud_inventory_sources():
return discover_available_cloud_provider_plugin_names() + ['scm']


Expand Down
4 changes: 2 additions & 2 deletions awx/main/models/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
OrderedManyToManyField,
)
from awx.main.managers import HostManager, HostMetricActiveManager
from awx.main.models.base import BaseModel, CommonModelNameNotUnique, VarsDictProperty, discover_cloud_inventory_sources, accepts_json
from awx.main.models.base import BaseModel, CommonModelNameNotUnique, VarsDictProperty, compute_cloud_inventory_sources, accepts_json
from awx.main.models.events import InventoryUpdateEvent, UnpartitionedInventoryUpdateEvent
from awx.main.models.unified_jobs import UnifiedJob, UnifiedJobTemplate
from awx.main.models.mixins import (
Expand Down Expand Up @@ -394,7 +394,7 @@ def update_computed_fields(self):
if self.kind == 'smart':
active_inventory_sources = self.inventory_sources.none()
else:
active_inventory_sources = self.inventory_sources.filter(source__in=discover_cloud_inventory_sources())
active_inventory_sources = self.inventory_sources.filter(source__in=compute_cloud_inventory_sources())
failed_inventory_sources = active_inventory_sources.filter(last_job_failed=True)
total_hosts = active_hosts.count()
# if total_hosts has changed, set update_task_impact to True
Expand Down

0 comments on commit 139b3d6

Please sign in to comment.