mirror of
https://github.com/ansible/awx.git
synced 2024-10-31 23:51:09 +03:00
related #4274 - moved function 'create_temporary_fifo' to 'awx/main/utils/common.py' and referenced it in other plugins
Signed-off-by: olia-dev <olia-dev@ktah.net>
This commit is contained in:
parent
2ee03b552d
commit
7b390fa2fc
@ -9,6 +9,10 @@ from urllib.parse import quote, urlencode, urljoin
|
|||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
# AWX
|
||||||
|
from awx.main.utils import (
|
||||||
|
create_temporary_fifo,
|
||||||
|
)
|
||||||
|
|
||||||
aim_inputs = {
|
aim_inputs = {
|
||||||
'fields': [{
|
'fields': [{
|
||||||
@ -60,24 +64,6 @@ aim_inputs = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def create_temporary_fifo(data):
|
|
||||||
"""Open fifo named pipe in a new thread using a temporary file path. The
|
|
||||||
thread blocks until data is read from the pipe.
|
|
||||||
|
|
||||||
Returns the path to the fifo.
|
|
||||||
|
|
||||||
:param data(bytes): Data to write to the pipe.
|
|
||||||
"""
|
|
||||||
path = os.path.join(tempfile.mkdtemp(), next(tempfile._get_candidate_names()))
|
|
||||||
os.mkfifo(path, stat.S_IRUSR | stat.S_IWUSR)
|
|
||||||
|
|
||||||
threading.Thread(
|
|
||||||
target=lambda p, d: open(p, 'wb').write(d),
|
|
||||||
args=(path, data)
|
|
||||||
).start()
|
|
||||||
return path
|
|
||||||
|
|
||||||
|
|
||||||
def aim_backend(**kwargs):
|
def aim_backend(**kwargs):
|
||||||
url = kwargs['url']
|
url = kwargs['url']
|
||||||
client_cert = kwargs.get('client_cert', None)
|
client_cert = kwargs.get('client_cert', None)
|
||||||
|
@ -10,6 +10,11 @@ from urllib.parse import urljoin, quote_plus
|
|||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
# AWX
|
||||||
|
from awx.main.utils import (
|
||||||
|
create_temporary_fifo,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
conjur_inputs = {
|
conjur_inputs = {
|
||||||
'fields': [{
|
'fields': [{
|
||||||
@ -51,24 +56,6 @@ conjur_inputs = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def create_temporary_fifo(data):
|
|
||||||
"""Open fifo named pipe in a new thread using a temporary file path. The
|
|
||||||
thread blocks until data is read from the pipe.
|
|
||||||
|
|
||||||
Returns the path to the fifo.
|
|
||||||
|
|
||||||
:param data(bytes): Data to write to the pipe.
|
|
||||||
"""
|
|
||||||
path = os.path.join(tempfile.mkdtemp(), next(tempfile._get_candidate_names()))
|
|
||||||
os.mkfifo(path, stat.S_IRUSR | stat.S_IWUSR)
|
|
||||||
|
|
||||||
threading.Thread(
|
|
||||||
target=lambda p, d: open(p, 'wb').write(d),
|
|
||||||
args=(path, data)
|
|
||||||
).start()
|
|
||||||
return path
|
|
||||||
|
|
||||||
|
|
||||||
def conjur_backend(**kwargs):
|
def conjur_backend(**kwargs):
|
||||||
url = kwargs['url']
|
url = kwargs['url']
|
||||||
api_key = kwargs['api_key']
|
api_key = kwargs['api_key']
|
||||||
|
@ -11,6 +11,10 @@ from .plugin import CredentialPlugin
|
|||||||
import requests
|
import requests
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
# AWX
|
||||||
|
from awx.main.utils import (
|
||||||
|
create_temporary_fifo,
|
||||||
|
)
|
||||||
|
|
||||||
base_inputs = {
|
base_inputs = {
|
||||||
'fields': [{
|
'fields': [{
|
||||||
@ -81,23 +85,6 @@ hashi_ssh_inputs['metadata'] = [{
|
|||||||
}]
|
}]
|
||||||
hashi_ssh_inputs['required'].extend(['public_key', 'role'])
|
hashi_ssh_inputs['required'].extend(['public_key', 'role'])
|
||||||
|
|
||||||
|
|
||||||
def create_temporary_fifo(data):
|
|
||||||
"""Open fifo named pipe in a new thread using a temporary file path. The
|
|
||||||
thread blocks until data is read from the pipe.
|
|
||||||
Returns the path to the fifo.
|
|
||||||
:param data(bytes): Data to write to the pipe.
|
|
||||||
"""
|
|
||||||
path = os.path.join(tempfile.mkdtemp(), next(tempfile._get_candidate_names()))
|
|
||||||
os.mkfifo(path, stat.S_IRUSR | stat.S_IWUSR)
|
|
||||||
|
|
||||||
threading.Thread(
|
|
||||||
target=lambda p, d: open(p, 'wb').write(d),
|
|
||||||
args=(path, data)
|
|
||||||
).start()
|
|
||||||
return path
|
|
||||||
|
|
||||||
|
|
||||||
def kv_backend(**kwargs):
|
def kv_backend(**kwargs):
|
||||||
token = kwargs['token']
|
token = kwargs['token']
|
||||||
url = urljoin(kwargs['url'], 'v1')
|
url = urljoin(kwargs['url'], 'v1')
|
||||||
|
@ -44,7 +44,7 @@ __all__ = ['get_object_or_400', 'camelcase_to_underscore', 'underscore_to_camelc
|
|||||||
'wrap_args_with_proot', 'build_proot_temp_dir', 'check_proot_installed', 'model_to_dict',
|
'wrap_args_with_proot', 'build_proot_temp_dir', 'check_proot_installed', 'model_to_dict',
|
||||||
'model_instance_diff', 'parse_yaml_or_json', 'RequireDebugTrueOrTest',
|
'model_instance_diff', 'parse_yaml_or_json', 'RequireDebugTrueOrTest',
|
||||||
'has_model_field_prefetched', 'set_environ', 'IllegalArgumentError', 'get_custom_venv_choices', 'get_external_account',
|
'has_model_field_prefetched', 'set_environ', 'IllegalArgumentError', 'get_custom_venv_choices', 'get_external_account',
|
||||||
'task_manager_bulk_reschedule', 'schedule_task_manager', 'classproperty']
|
'task_manager_bulk_reschedule', 'schedule_task_manager', 'classproperty', 'create_temporary_fifo']
|
||||||
|
|
||||||
|
|
||||||
def get_object_or_400(klass, *args, **kwargs):
|
def get_object_or_400(klass, *args, **kwargs):
|
||||||
@ -1015,3 +1015,19 @@ class classproperty:
|
|||||||
|
|
||||||
def __get__(self, instance, ownerclass):
|
def __get__(self, instance, ownerclass):
|
||||||
return self.fget(ownerclass)
|
return self.fget(ownerclass)
|
||||||
|
|
||||||
|
def create_temporary_fifo(data):
|
||||||
|
"""Open fifo named pipe in a new thread using a temporary file path. The
|
||||||
|
thread blocks until data is read from the pipe.
|
||||||
|
Returns the path to the fifo.
|
||||||
|
:param data(bytes): Data to write to the pipe.
|
||||||
|
"""
|
||||||
|
path = os.path.join(tempfile.mkdtemp(), next(tempfile._get_candidate_names()))
|
||||||
|
os.mkfifo(path, stat.S_IRUSR | stat.S_IWUSR)
|
||||||
|
|
||||||
|
threading.Thread(
|
||||||
|
target=lambda p, d: open(p, 'wb').write(d),
|
||||||
|
args=(path, data)
|
||||||
|
).start()
|
||||||
|
return path
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user