Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP5:GA
lio-utils
0110-Handle-exception-during-non-existent-files...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0110-Handle-exception-during-non-existent-files.patch of Package lio-utils
From 981500a47c4dd1821b1511ed300896ecdaa5eb48 Mon Sep 17 00:00:00 2001 From: Ritesh Raj Sarraf <rrs@researchut.com> Date: Thu, 10 May 2012 17:47:14 +0530 Subject: Handle exception during non-existent files This could occur if the kernel moduel is not loaded Also fix, major typo, where I completely missed the try: block in the previously submitted patch. Sorry. Signed-off-by: Ritesh Raj Sarraf <rrs@researchut.com> Signed-off-by: Nicholas Bellinger <nab@risingtidesystems.com> --- tcm-py/tcm_fabric.py | 37 ++++++++++++++++++++----------------- tcm-py/tcm_node.py | 21 ++++++++++++--------- 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/tcm-py/tcm_fabric.py b/tcm-py/tcm_fabric.py index 2bdc77a..4e6dab1 100755 --- a/tcm-py/tcm_fabric.py +++ b/tcm-py/tcm_fabric.py @@ -9,6 +9,10 @@ import optparse target_root = "/sys/kernel/config/target/" spec_root = "/var/target/fabric/" +def fabric_err(msg): + print >> sys.stderr, msg + sys.exit(1) + def fabric_configfs_dump(fabric_name, fabric_root, module_name): if not os.path.isdir(fabric_root): @@ -455,28 +459,27 @@ def fabric_unloadall(): module_name = "" - for fabric_name in os.listdir(target_root): - if fabric_name == "version": - continue - if fabric_name == "core": - continue - # FIXME: currently using lio_node --unload - if fabric_name == "iscsi": - continue + try: + for fabric_name in os.listdir(target_root): + if fabric_name == "version": + continue + if fabric_name == "core": + continue + # FIXME: currently using lio_node --unload + if fabric_name == "iscsi": + continue - fabric_root = target_root + fabric_name - module_name = fabric_get_module_name(fabric_name) -# print "fabric_get_module_name() using: " + module_name + fabric_root = target_root + fabric_name + module_name = fabric_get_module_name(fabric_name) + #print "fabric_get_module_name() using: " + module_name - if module_name == "": - continue + if module_name == "": + continue - fabric_unload(fabric_name, fabric_root, module_name) + fabric_unload(fabric_name, fabric_root, module_name) except OSError, (errno, strerror): if errno == 2: - print "%s %s\n" % (target_root, strerror) - print "Is kernel module loaded?\n" - exit 1 + fabric_err("%s %s\n%s" % (target_root, strerror, "Is kernel module loaded?") ) def do_work(stdout_enable, stdout_enable_all, date_time, unload, unloadall, fabric_name, fabric_root, module_name): diff --git a/tcm-py/tcm_node.py b/tcm-py/tcm_node.py index b7c05cf..997009c 100755 --- a/tcm-py/tcm_node.py +++ b/tcm-py/tcm_node.py @@ -23,19 +23,22 @@ def tcm_err(msg): sys.exit(1) def tcm_read(filename): - with open(filename) as f: - return f.read() + try: + with open(filename) as f: + return f.read() except IOError, (errno, strerror): if errno == 2: - print "%s %s\n" % (filename, strerror) - print "Is kernel module loaded?\n" - exit 1 + tcm_err("%s %s\n%s" % (filename, strerror, "Is kernel module loaded?") ) def tcm_write(filename, value, newline=True): - with open(filename, "w") as f: - f.write(value) - if newline: - f.write("\n") + try: + with open(filename, "w") as f: + f.write(value) + if newline: + f.write("\n") + except IOError, (errno, strerror): + if errno == 2: + tcm_err("%s %s\n%s" % (filename, strerror, "Is kernel module loaded?") ) def tcm_full_path(arg): return tcm_root + "/" + arg -- 1.8.1.4
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor