From a8690f1b50f0952155e327ffb17952d7cecfbe98 Mon Sep 17 00:00:00 2001 From: Paul Cuzner Date: Fri, 11 Dec 2020 17:25:08 +1300 Subject: [PATCH] orchestrator: drop redundant try/except YAML is validated up front, so the additional try/except clause is not needed. Signed-off-by: Paul Cuzner --- src/pybind/mgr/orchestrator/module.py | 42 ++++++++++++--------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/src/pybind/mgr/orchestrator/module.py b/src/pybind/mgr/orchestrator/module.py index 1345931415a..96af1b055ee 100644 --- a/src/pybind/mgr/orchestrator/module.py +++ b/src/pybind/mgr/orchestrator/module.py @@ -675,32 +675,28 @@ Examples: self.log.exception(e) return HandleCommandResult(-errno.EINVAL, stderr=msg) - try: - dg_specs = [] - for dg in drivegroups: - spec = DriveGroupSpec.from_json(dg) - if dry_run: - spec.preview_only = True - dg_specs.append(spec) - - completion = self.apply(dg_specs) + dg_specs = [] + for dg in drivegroups: + spec = DriveGroupSpec.from_json(dg) + if dry_run: + spec.preview_only = True + dg_specs.append(spec) + + completion = self.apply(dg_specs) + self._orchestrator_wait([completion]) + raise_if_exception(completion) + out = completion.result_str() + if dry_run: + completion = self.plan(dg_specs) self._orchestrator_wait([completion]) raise_if_exception(completion) - out = completion.result_str() - if dry_run: - completion = self.plan(dg_specs) - self._orchestrator_wait([completion]) - raise_if_exception(completion) - data = completion.result - if format == 'plain': - out = preview_table_osd(data) - else: - out = to_format(data, format, many=True, cls=None) - return HandleCommandResult(stdout=out) + data = completion.result + if format == 'plain': + out = preview_table_osd(data) + else: + out = to_format(data, format, many=True, cls=None) + return HandleCommandResult(stdout=out) - except ValueError as e: - msg = 'Failed to read JSON/YAML input: {}'.format(str(e)) + usage - return HandleCommandResult(-errno.EINVAL, stderr=msg) if all_available_devices: if unmanaged is None: unmanaged = False -- 2.39.5