From 13497e6c63b0c8c5143958df3e4382f453c3c102 Mon Sep 17 00:00:00 2001 From: Martin Belanger Date: Wed, 7 Jun 2023 18:12:38 -0400 Subject: [PATCH] trid: Fix migration of old TID object (introspect self._cfg member) Signed-off-by: Martin Belanger --- NEWS.md | 6 ++++++ meson.build | 2 +- staslib/trid.py | 7 ++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index bdda8d3..5fa3fd4 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,11 @@ # STorage Appliance Services (STAS) +## Changes with release 2.2.2 + +Bug fixes: + +* Fix migration of old "last known config" to new format. Old TID objects did not contain a `_cfg` member. Therefore, one needs to check for its existence (through introspection) before blindly trying to access it. + ## Changes with release 2.2.1 Added a few more unit and coverage tests. Fixed the following bugs. diff --git a/meson.build b/meson.build index b84e3d1..bf2dda5 100644 --- a/meson.build +++ b/meson.build @@ -9,7 +9,7 @@ project( 'nvme-stas', meson_version: '>= 0.53.0', - version: '2.2.1', + version: '2.2.2', license: 'Apache-2.0', default_options: [ 'buildtype=release', diff --git a/staslib/trid.py b/staslib/trid.py index ea40b7d..d9a05ba 100644 --- a/staslib/trid.py +++ b/staslib/trid.py @@ -106,7 +106,12 @@ def as_dict(self): 'host-traddr': self.host_traddr, 'host-iface': self.host_iface, } - data.update(self._cfg) + + # When migrating an old last known config, the "_cfg" member may + # not exist. Therefor retrive it with getattr() to avoid a crash. + cfg = getattr(self, '_cfg', None) + if cfg: + data.update(cfg) return data def __str__(self):