The configure_dev_attribute should do whatever caller wants and the
logic should be move from this method to caller level.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
---
.../ENRT/ConfigMixins/BaseHWConfigMixin.py | 42 ++++++++++---------
1 file changed, 22 insertions(+), 20 deletions(-)
diff --git a/lnst/Recipes/ENRT/ConfigMixins/BaseHWConfigMixin.py
b/lnst/Recipes/ENRT/ConfigMixins/BaseHWConfigMixin.py
index 633a0fe6..29854ee6 100644
--- a/lnst/Recipes/ENRT/ConfigMixins/BaseHWConfigMixin.py
+++ b/lnst/Recipes/ENRT/ConfigMixins/BaseHWConfigMixin.py
@@ -10,29 +10,31 @@ class BaseHWConfigMixin(object):
def _configure_dev_attribute(self, config, dev_list, attr_name, value):
hw_config = config.hw_config
- if value:
- attr_cfg = hw_config[attr_name + "_configuration"] = {}
- for dev in dev_list:
- attr_cfg[dev] = {}
- attr_cfg[dev]["original"] = getattr(dev, attr_name)
- setattr(dev, attr_name, value)
- attr_cfg[dev]["configured"] = getattr(dev, attr_name)
+ attr_cfg = hw_config[attr_name + "_configuration"] = {}
+ for dev in dev_list:
+ attr_cfg[dev] = {}
+ attr_cfg[dev]["original"] = getattr(dev, attr_name)
+ setattr(dev, attr_name, value)
+ attr_cfg[dev]["configured"] = getattr(dev, attr_name)
def _describe_dev_attribute(self, config, attr_name):
hw_config = config.hw_config
res = []
- attr = hw_config.get(attr_name + "_configuration", None)
- if attr:
- for dev, info in attr.items():
- res.append(
- "{}.{}.{} configured to {}, original value {}".format(
- dev.host.hostid,
- dev.name,
- attr_name,
- info["configured"],
- info["original"],
- )
- )
- else:
+ try:
+ attr = hw_config[attr_name + "_configuration"]
+ except:
res.append("{} configuration skipped.".format(attr_name))
+ return res
+
+ for dev, info in attr.items():
+ res.append(
+ "{}.{}.{} configured to {}, original value {}".format(
+ dev.host.hostid,
+ dev.name,
+ attr_name,
+ info["configured"],
+ info["original"],
+ )
+ )
+
return res
--
2.21.1