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: wip-pdonnell-testing-20200918.022351~159^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=3a2430fed9846251926a179989829812f9d74d99;p=ceph-ci.git mgr/orchestrator: fix typing on lsm_data components Resolves mypy issues Signed-off-by: Paul Cuzner --- diff --git a/src/pybind/mgr/orchestrator/module.py b/src/pybind/mgr/orchestrator/module.py index 4650d38ca89..a21b2a588d2 100644 --- a/src/pybind/mgr/orchestrator/module.py +++ b/src/pybind/mgr/orchestrator/module.py @@ -368,7 +368,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 @@ -398,12 +398,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' @@ -418,6 +420,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( ( @@ -428,7 +435,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], @@ -443,7 +450,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 9bea5c8cdf0..eb9852426c4 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]