From 5aedaa167537baee512759ff7199d56cc243c60c Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Wed, 18 Dec 2019 15:13:26 +0100 Subject: [PATCH] pybind/mgr: Add orchestrator_cli to mgr/tox.ini * module is now tested with mypy * cleanup `orchestroatr_cli/__init__.py` Signed-off-by: Sebastian Wagner --- src/pybind/mgr/orchestrator_cli/__init__.py | 9 +-------- src/pybind/mgr/orchestrator_cli/module.py | 20 ++++++++++---------- src/pybind/mgr/tox.ini | 2 +- 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/pybind/mgr/orchestrator_cli/__init__.py b/src/pybind/mgr/orchestrator_cli/__init__.py index 07c29b47961..ef27d74a379 100644 --- a/src/pybind/mgr/orchestrator_cli/__init__.py +++ b/src/pybind/mgr/orchestrator_cli/__init__.py @@ -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 diff --git a/src/pybind/mgr/orchestrator_cli/module.py b/src/pybind/mgr/orchestrator_cli/module.py index d78be1135f4..02450db2cce 100644 --- a/src/pybind/mgr/orchestrator_cli/module.py +++ b/src/pybind/mgr/orchestrator_cli/module.py @@ -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 ') 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') diff --git a/src/pybind/mgr/tox.ini b/src/pybind/mgr/tox.ini index 7cce321c687..2de75e2e90c 100644 --- a/src/pybind/mgr/tox.ini +++ b/src/pybind/mgr/tox.ini @@ -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 -- 2.39.5