mirror of
https://github.com/ansible/awx.git
synced 2026-03-11 14:39:30 -02:30
Adding awx_task_env as wrapper while invoking backend
This commit is contained in:
@@ -172,6 +172,7 @@ from awx.api.views.root import ( # noqa
|
|||||||
)
|
)
|
||||||
from awx.api.views.webhooks import WebhookKeyView, GithubWebhookReceiver, GitlabWebhookReceiver # noqa
|
from awx.api.views.webhooks import WebhookKeyView, GithubWebhookReceiver, GitlabWebhookReceiver # noqa
|
||||||
from awx.api.pagination import UnifiedJobEventPagination
|
from awx.api.pagination import UnifiedJobEventPagination
|
||||||
|
from awx.main.utils import set_environ
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger('awx.api.views')
|
logger = logging.getLogger('awx.api.views')
|
||||||
@@ -1555,8 +1556,9 @@ class CredentialExternalTest(SubDetailAPIView):
|
|||||||
backend_kwargs[field_name] = value
|
backend_kwargs[field_name] = value
|
||||||
backend_kwargs.update(request.data.get('metadata', {}))
|
backend_kwargs.update(request.data.get('metadata', {}))
|
||||||
try:
|
try:
|
||||||
obj.credential_type.plugin.backend(**backend_kwargs)
|
with set_environ(**settings.AWX_TASK_ENV):
|
||||||
return Response({}, status=status.HTTP_202_ACCEPTED)
|
obj.credential_type.plugin.backend(**backend_kwargs)
|
||||||
|
return Response({}, status=status.HTTP_202_ACCEPTED)
|
||||||
except requests.exceptions.HTTPError as exc:
|
except requests.exceptions.HTTPError as exc:
|
||||||
message = 'HTTP {}'.format(exc.response.status_code)
|
message = 'HTTP {}'.format(exc.response.status_code)
|
||||||
return Response({'inputs': message}, status=status.HTTP_400_BAD_REQUEST)
|
return Response({'inputs': message}, status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|||||||
Reference in New Issue
Block a user