From 807e3325f7255cfe04bf0de8bd755b64ed5048be Mon Sep 17 00:00:00 2001 From: =?utf8?q?Juan=20Miguel=20Olmo=20Mart=C3=ADnez?= Date: Wed, 23 Jan 2019 09:23:33 +0100 Subject: [PATCH] mgr/ansible: Adapt code to use DriveGroupSpec and OrchestratorClientMixin MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Apart of this two major changes, and due the long time this PR has been opened, other minor modifications coming from the orchestrators world has been merged. Not solved yet the discussion around . Once we have a a common code base we can decide what names we should use and what implementation is the more adequate. Signed-off-by: Juan Miguel Olmo Martínez --- src/pybind/mgr/ansible/module.py | 23 +++++++++++++---------- src/pybind/mgr/orchestrator_cli/module.py | 8 ++++---- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/pybind/mgr/ansible/module.py b/src/pybind/mgr/ansible/module.py index 8e4d85d89e6..87d016d135b 100644 --- a/src/pybind/mgr/ansible/module.py +++ b/src/pybind/mgr/ansible/module.py @@ -104,16 +104,19 @@ class AnsibleReadOperation(orchestrator.ReadCompletion): processed_result = [] - if self._is_complete: - raw_result = self.pb_execution.get_result(self.event_filter) - - if self.process_output: - processed_result = self.process_output( - raw_result, - self.ar_client, - self.pb_execution.play_uuid) - else: - processed_result = raw_result + raw_result = self.pb_execution.get_result(self.event_filter) + + if self.process_output: + processed_result = self.process_output( + raw_result, + self.ar_client, + self.pb_execution.play_uuid) + else: + processed_result = raw_result + + #Clean objects to avoid problems between interpreters + self.pb_execution = None + self.ar_client = None self._result = processed_result diff --git a/src/pybind/mgr/orchestrator_cli/module.py b/src/pybind/mgr/orchestrator_cli/module.py index 1ec99d032e1..76711170754 100644 --- a/src/pybind/mgr/orchestrator_cli/module.py +++ b/src/pybind/mgr/orchestrator_cli/module.py @@ -232,10 +232,10 @@ class OrchestratorCli(orchestrator.OrchestratorClientMixin, MgrModule): self.wait([host_completion]) all_hosts = [h.name for h in host_completion.result] - completion = self.create_osds(spec, all_hosts) - self._orchestrator_wait([completion]) - #return result - return HandleCommandResult(stdout=completion.result) + try: + json_dg = json.loads(params) + except ValueError as msg: + return HandleCommandResult(-errno.EINVAL, stderr=msg) def _add_stateless_svc(self, svc_type, spec): completion = self.add_stateless_service(svc_type, spec) -- 2.39.5