From: Paul Cuzner Date: Tue, 1 Sep 2020 04:39:35 +0000 (+1200) Subject: mgr/orchestrator: fix typing on lsm_data components X-Git-Tag: v15.2.9~122^2~44^2~56 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=415cf7d8e0375eba13301eb3a270d69b7ea57497;p=ceph.git mgr/orchestrator: fix typing on lsm_data components Resolves mypy issues Signed-off-by: Paul Cuzner (cherry picked from commit 3a2430fed9846251926a179989829812f9d74d99) --- diff --git a/src/pybind/mgr/orchestrator/module.py b/src/pybind/mgr/orchestrator/module.py index 4fbe6166d5e8..e29e6e5b5745 100644 --- a/src/pybind/mgr/orchestrator/module.py +++ b/src/pybind/mgr/orchestrator/module.py @@ -370,7 +370,7 @@ class OrchestratorCli(OrchestratorClientMixin, MgrModule): "name=wide,type=CephBool,req=false", 'List devices on a host') def _list_devices(self, hostname=None, format='plain', refresh=False, wide=False): - # type: (Optional[List[str]], str, bool) -> HandleCommandResult + # type: (Optional[List[str]], str, bool, bool) -> HandleCommandResult """ Provide information about storage devices present in cluster hosts @@ -400,12 +400,14 @@ class OrchestratorCli(OrchestratorClientMixin, MgrModule): out = [] if wide: table = PrettyTable( - ['Hostname', 'Path', 'Type', 'Transport', 'RPM', 'Vendor', 'Model', 'Serial', 'Size', 'Health', - 'Ident', 'Fault', 'Available', 'Reject Reasons'], + ['Hostname', 'Path', 'Type', 'Transport', 'RPM', 'Vendor', 'Model', + 'Serial', 'Size', 'Health', 'Ident', 'Fault', 'Available', + 'Reject Reasons'], border=False) else: table = PrettyTable( - ['Hostname', 'Path', 'Type', 'Serial', 'Size', 'Health', 'Ident', 'Fault', 'Available'], + ['Hostname', 'Path', 'Type', 'Serial', 'Size', + 'Health', 'Ident', 'Fault', 'Available'], border=False) table.align = 'l' table._align['SIZE'] = 'r' @@ -420,6 +422,11 @@ class OrchestratorCli(OrchestratorClientMixin, MgrModule): led_ident = d.lsm_data['ledSupport']['IDENTstatus'] led_fail = d.lsm_data['ledSupport']['FAILstatus'] + if d.device_id is not None: + fallback_serial = d.device_id.split('_')[-1] + else: + fallback_serial = "" + if wide: table.add_row( ( @@ -430,7 +437,7 @@ class OrchestratorCli(OrchestratorClientMixin, MgrModule): d.lsm_data.get('rpm', 'Unknown'), d.sys_api.get('vendor') or 'N/A', d.sys_api.get('model') or 'N/A', - d.lsm_data.get('serialNum', d.device_id.split('_')[-1]), + d.lsm_data.get('serialNum', fallback_serial), format_dimless(d.sys_api.get('size', 0), 5), d.lsm_data.get('health', 'Unknown'), display_map[led_ident], @@ -445,7 +452,7 @@ class OrchestratorCli(OrchestratorClientMixin, MgrModule): host_.name, d.path, d.human_readable_type, - d.lsm_data.get('serialNum', d.device_id.split('_')[-1]), + d.lsm_data.get('serialNum', fallback_serial), format_dimless(d.sys_api.get('size', 0), 5), d.lsm_data.get('health', 'Unknown'), display_map[led_ident], diff --git a/src/python-common/ceph/deployment/inventory.py b/src/python-common/ceph/deployment/inventory.py index 9bea5c8cdf0e..eb9852426c44 100644 --- a/src/python-common/ceph/deployment/inventory.py +++ b/src/python-common/ceph/deployment/inventory.py @@ -51,7 +51,7 @@ class Device(object): rejected_reasons=None, # type: Optional[List[str]] lvs=None, # type: Optional[List[str]] device_id=None, # type: Optional[str] - lsm_data=None, # type: Optional[str] + lsm_data={}, # type: Dict[str, Dict[str, str]] ): self.path = path self.sys_api = sys_api if sys_api is not None else {} # type: Dict[str, Any]