diff options
author | Bala.FA <bala@gluster.com> | 2011-09-22 14:59:35 +0530 |
---|---|---|
committer | Tim <timothyasir@gluster.com> | 2011-09-23 13:58:03 +0530 |
commit | 86e7a6b30b223f26c843531f037c40f1490dac67 (patch) | |
tree | 2a1e4856c37ddb5369372cdb6d2598c9c0e7870f /src | |
parent | 829d4aaae24d44384854575b40a013b846994fcf (diff) |
Cleanup in get_volume_user_cifs.py
Signed-off-by: Bala.FA <bala@gluster.com>
Diffstat (limited to 'src')
-rwxr-xr-x | src/com.gluster.storage.management.gateway.scripts/src/gateway/get_volume_user_cifs.py | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/src/com.gluster.storage.management.gateway.scripts/src/gateway/get_volume_user_cifs.py b/src/com.gluster.storage.management.gateway.scripts/src/gateway/get_volume_user_cifs.py index c385633e..c072a556 100755 --- a/src/com.gluster.storage.management.gateway.scripts/src/gateway/get_volume_user_cifs.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/gateway/get_volume_user_cifs.py @@ -22,24 +22,16 @@ def main(): volumeName = sys.argv[1] - if not os.path.exists(Globals.CIFS_VOLUME_FILE): - sys.exit(0) - - try: - fp = open(Globals.CIFS_VOLUME_FILE) - content = fp.read() - fp.close() - for line in content.split(): - tokens = line.split(":") - if tokens[0] == volumeName: - print "\n".join(tokens[1:]) - sys.exit(0) - # given volume is not configured for cifs export - sys.exit(0) - except IOError, e: - Utils.log("failed to read file %s: %s" % (Globals.CIFS_VOLUME_FILE, str(e))) - sys.stderr.write("Failed to read cifs-volume-file %s: %s\n" % (Globals.CIFS_VOLUME_FILE, str(e))) - sys.exit(2) + lines = Utils.readFile(Globals.CIFS_VOLUME_FILE, lines=True) + for line in lines: + if not line.strip(): + continue + tokens = line.strip().split(":") + if tokens[0] == volumeName: + print "\n".join(tokens[1:]) + sys.exit(0) + # given volume is not configured for cifs export + sys.exit(0) if __name__ == "__main__": |