diff --git a/inventory_provider/routes/ims_otrs.py b/inventory_provider/routes/ims_otrs.py index b03fec117fd2e6e70408e923d5a855f5d35e8cc8..dbe666f4ce8735166daa980859d4b56124ce8b85 100644 --- a/inventory_provider/routes/ims_otrs.py +++ b/inventory_provider/routes/ims_otrs.py @@ -63,9 +63,9 @@ def send_exports(): response=html.escape(f'Bad value for <files> {files_value}'), status=requests.codes.bad_request, mimetype="text/html") - task = export_data_for_otrs.delay( + debug_uuid = export_data_for_otrs( files_to_export=files_value, export_duplicates=duplicates) return Response( - response=task.id, + response=f'Exports sent, search logs for {debug_uuid} for details', status=requests.codes.ok, mimetype="text/html") diff --git a/inventory_provider/tasks/ims_worker.py b/inventory_provider/tasks/ims_worker.py index 26f7f09dccb3a2be7544604d73116d0228a7eaf7..b7c2e85c468acbd25891d7d5704c3552612d902d 100644 --- a/inventory_provider/tasks/ims_worker.py +++ b/inventory_provider/tasks/ims_worker.py @@ -6,6 +6,7 @@ import tempfile from datetime import datetime from enum import IntFlag from pathlib import Path +from uuid import uuid4 from inventory_provider.db import ims_data from inventory_provider.db.ims import IMS @@ -48,6 +49,8 @@ class OTRSFiles(IntFlag): @app.task(base=InventoryTask, bind=True, name='export_data_for_otrs') @log_task_entry_and_exit def export_data_for_otrs(self, files_to_export=None, export_duplicates=False): + debug_uuid = uuid4() + logger.debug(f'debug uuid: {debug_uuid}') if files_to_export: files_to_export = OTRSFiles(files_to_export) else: @@ -56,7 +59,7 @@ def export_data_for_otrs(self, files_to_export=None, export_duplicates=False): ims_config = InventoryTask.config["ims"] otrs_config = InventoryTask.config["otrs-export"] - command_template = 'rsync -aP --rsh="ssh -l {user} -p 22 -i {key_file} -o \'UserKnownHostsFile {known_hosts}\'" {source_dir}/* {destination}' # noqa + command_template = 'rsync -aPq --rsh="ssh -l {user} -p 22 -i {key_file} -o \'UserKnownHostsFile {known_hosts}\'" {source_dir}/* {destination}' # noqa with tempfile.TemporaryDirectory() as temp_dir: temp_path = Path(temp_dir) @@ -88,3 +91,4 @@ def export_data_for_otrs(self, files_to_export=None, export_duplicates=False): destination=otrs_config['destination'] ) subprocess.run(command, shell=True, check=True) + return debug_uuid diff --git a/test/test_ims_worker.py b/test/test_ims_worker.py index 7906c5bb49d15049d10d88691a494e7ae749b94a..d94796a65e4a0a1243357157fb726f686cc51f89 100644 --- a/test/test_ims_worker.py +++ b/test/test_ims_worker.py @@ -33,7 +33,7 @@ def test_otrs_exports(data_config_filename, data_config, mocker): args, kwargs = mocked_run.call_args called_with = args[0] - t = r'^rsync -aP --rsh="ssh -l {user} -p 22 -i {key_file} -o \'UserKnownHostsFile {known_hosts}\'" /\S+/\* {destination}$' # noqa + t = r'^rsync -aPq --rsh="ssh -l {user} -p 22 -i {key_file} -o \'UserKnownHostsFile {known_hosts}\'" /\S+/\* {destination}$' # noqa p = t.format( user=otrs_config['username'],