]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
orchestrator: drop redundant try/except 38413/head
authorPaul Cuzner <pcuzner@redhat.com>
Fri, 11 Dec 2020 04:25:08 +0000 (17:25 +1300)
committerPaul Cuzner <pcuzner@redhat.com>
Fri, 11 Dec 2020 04:25:08 +0000 (17:25 +1300)
YAML is validated up front, so the additional try/except
clause is not needed.

Signed-off-by: Paul Cuzner <pcuzner@redhat.com>
src/pybind/mgr/orchestrator/module.py

index 1345931415a7c126abf6d1d5a4d980de6f36bad7..96af1b055ee8da83f176fbeb0b556fcac63c237d 100644 (file)
@@ -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