From 45fd5ee275aa94409bbe9d9c3874c9aad82850a8 Mon Sep 17 00:00:00 2001 From: Kiefer Chang Date: Thu, 16 Apr 2020 15:30:24 +0800 Subject: [PATCH] mgr/orch: Fixes some deserialization errors Fixes errors when calling `from_json` of these classes: - InventoryHost: parsing labels - ServiceDescription: `last_refresh` and `created` fields should be parsed to datetime type. Signed-off-by: Kiefer Chang --- src/pybind/mgr/orchestrator/_interface.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pybind/mgr/orchestrator/_interface.py b/src/pybind/mgr/orchestrator/_interface.py index 336febc5693..4622fa6be28 100644 --- a/src/pybind/mgr/orchestrator/_interface.py +++ b/src/pybind/mgr/orchestrator/_interface.py @@ -1426,7 +1426,7 @@ class ServiceDescription(object): c_status = status.copy() for k in ['last_refresh', 'created']: - if k in c: + if k in c_status: c_status[k] = datetime.datetime.strptime(c_status[k], DATEFMT) return cls(spec=spec, **c_status) @@ -1487,10 +1487,10 @@ class InventoryHost(object): name = _data.pop('name') addr = _data.pop('addr', None) or name devices = inventory.Devices.from_json(_data.pop('devices')) + labels = _data.pop('labels', list()) if _data: error_msg = 'Unknown key(s) in Inventory: {}'.format(','.join(_data.keys())) raise OrchestratorValidationError(error_msg) - labels = _data.get('labels', list()) return cls(name, devices, labels, addr) except KeyError as e: error_msg = '{} is required for {}'.format(e, cls.__name__) -- 2.39.5