diff options
author | Andy Grover <agrover@redhat.com> | 2014-04-15 11:57:15 -0700 |
---|---|---|
committer | Andy Grover <agrover@redhat.com> | 2014-04-15 11:57:15 -0700 |
commit | 9e336d2137be30a1f5ec05bf0f78b86a5bf2ae6b (patch) | |
tree | b177486a683b907225c56aa20c43b870454e2930 /rtslib/utils.py | |
parent | e07dc0d9714699335ba9c356adae21b9aca2fb38 (diff) | |
download | rtslib-fb-9e336d2137be30a1f5ec05bf0f78b86a5bf2ae6b.tar.gz |
Change set_parameters/attributes to take an err_func
We don't want to silently hide errors when setting things, but we also
don't want to stop. Since these are both called from setup() functions,
we can just pass an err_func to them and they can call it if there's a
problem, but keep going.
When calling set_attribute for the storageobject, use a custom err_func
that also includes the name and plugin in the message.
Signed-off-by: Andy Grover <agrover@redhat.com>
Diffstat (limited to 'rtslib/utils.py')
-rw-r--r-- | rtslib/utils.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/rtslib/utils.py b/rtslib/utils.py index ca0e7bc..baae9e3 100644 --- a/rtslib/utils.py +++ b/rtslib/utils.py @@ -433,17 +433,19 @@ def _set_auth_attr(self, value, attribute, ignore=False): if not ignore: raise -def set_attributes(obj, attr_dict): +def set_attributes(obj, attr_dict, err_func): for name, value in attr_dict.iteritems(): - # Setting some attributes may return an error, before kernel 3.3 - with ignored(RTSLibError): + try: obj.set_attribute(name, value) + except RTSLibError as e: + err_func(str(e)) -def set_parameters(obj, param_dict): +def set_parameters(obj, param_dict, err_func): for name, value in param_dict.iteritems(): - # Setting some parameters may return an error, before kernel 3.3 - with ignored(RTSLibError): + try: obj.set_parameter(name, value) + except RTSLibError as e: + err_func(str(e)) def _test(): '''Run the doctests''' |