]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/mgr: Add orchestrator_cli to mgr/tox.ini 32272/head
authorSebastian Wagner <sebastian.wagner@suse.com>
Wed, 18 Dec 2019 14:13:26 +0000 (15:13 +0100)
committerSebastian Wagner <sebastian.wagner@suse.com>
Wed, 18 Dec 2019 14:13:26 +0000 (15:13 +0100)
* module is now tested with mypy
* cleanup `orchestroatr_cli/__init__.py`

Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
src/pybind/mgr/orchestrator_cli/__init__.py
src/pybind/mgr/orchestrator_cli/module.py
src/pybind/mgr/tox.ini

index 07c29b4796178dfebffc95c5d7e8fb1eb7f9f75c..ef27d74a3795de055f02e65433bf993c90807b4b 100644 (file)
@@ -1,10 +1,3 @@
 from __future__ import absolute_import
-import os
 
-if 'UNITTEST' not in os.environ:
-    from .module import OrchestratorCli
-else:
-    import sys
-    import mock
-    sys.path.append("..")
-    sys.modules['ceph_module'] = mock.Mock()
+from .module import OrchestratorCli
index d78be1135f4e08a34629a2b9604fa0b017380530..02450db2cce262c957fcdf90936a7ac53f60bcb5 100644 (file)
@@ -32,7 +32,7 @@ class OrchestratorCli(orchestrator.OrchestratorClientMixin, MgrModule):
             'runtime': True,
         },
     ]
-    NATIVE_OPTIONS = []
+    NATIVE_OPTIONS = []  # type: List[dict]
 
     def __init__(self, *args, **kwargs):
         super(OrchestratorCli, self).__init__(*args, **kwargs)
@@ -226,7 +226,7 @@ class OrchestratorCli(orchestrator.OrchestratorClientMixin, MgrModule):
         "name=refresh,type=CephBool,req=false",
         'List devices on a node')
     def _list_devices(self, host=None, format='plain', refresh=False):
-        # type: (List[str], str, bool) -> HandleCommandResult
+        # type: (Optional[List[str]], str, bool) -> HandleCommandResult
         """
         Provide information about storage devices present in cluster hosts
 
@@ -255,11 +255,11 @@ class OrchestratorCli(orchestrator.OrchestratorClientMixin, MgrModule):
             table._align['SIZE'] = 'r'
             table.left_padding_width = 0
             table.right_padding_width = 1
-            for host in completion.result: # type: orchestrator.InventoryNode
-                for d in host.devices.devices:  # type: Device
+            for host_ in completion.result: # type: orchestrator.InventoryNode
+                for d in host_.devices.devices:  # type: Device
                     table.add_row(
                         (
-                            host.name,
+                            host_.name,
                             d.path,
                             d.human_readable_type,
                             format_bytes(d.sys_api.get('size', 0), 5, colored=False),
@@ -330,7 +330,7 @@ class OrchestratorCli(orchestrator.OrchestratorClientMixin, MgrModule):
         "name=svc_arg,type=CephString,req=false",
         'Create an OSD service. Either --svc_arg=host:drives or -i <drive_group>')
     def _create_osd(self, svc_arg=None, inbuf=None):
-        # type: (str, str) -> HandleCommandResult
+        # type: (Optional[str], Optional[str]) -> HandleCommandResult
         """Create one or more OSDs"""
 
         usage = """
@@ -722,16 +722,16 @@ Usage:
         assert self._select_orchestrator() is None
         self._set_backend(old_orch)
 
-        e = self.remote('selftest', 'remote_from_orchestrator_cli_self_test', "ZeroDivisionError")
+        e1 = self.remote('selftest', 'remote_from_orchestrator_cli_self_test', "ZeroDivisionError")
         try:
-            orchestrator.raise_if_exception(e)
+            orchestrator.raise_if_exception(e1)
             assert False
         except ZeroDivisionError as e:
             assert e.args == ('hello', 'world')
 
-        e = self.remote('selftest', 'remote_from_orchestrator_cli_self_test', "OrchestratorError")
+        e2 = self.remote('selftest', 'remote_from_orchestrator_cli_self_test', "OrchestratorError")
         try:
-            orchestrator.raise_if_exception(e)
+            orchestrator.raise_if_exception(e2)
             assert False
         except orchestrator.OrchestratorError as e:
             assert e.args == ('hello', 'world')
index 7cce321c687593ce674ce8acc7098cf7aebffeeb..2de75e2e90cfa2972af7b061207c8121584293ff 100644 (file)
@@ -12,4 +12,4 @@ basepython = python3
 deps =
     -r requirements.txt
     mypy
-commands = mypy --config-file=../../mypy.ini orchestrator.py cephadm/module.py rook/module.py ansible/module.py
\ No newline at end of file
+commands = mypy --config-file=../../mypy.ini orchestrator.py cephadm/module.py rook/module.py ansible/module.py orchestrator_cli/module.py
\ No newline at end of file