diff options
author | Bala.FA <bala@gluster.com> | 2011-09-22 15:09:43 +0530 |
---|---|---|
committer | Tim <timothyasir@gluster.com> | 2011-09-23 13:58:03 +0530 |
commit | 3b0b5a804970fb41a77fc5c57f7926f6aa363e79 (patch) | |
tree | 433e8b828b947ac36a1091f8115b1400517899d8 /src | |
parent | 138fddf2735a7fa560b25dd1613dcce2cd8ab39e (diff) |
Cleanup in update_volume_cifs_all.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/update_volume_cifs_all.py | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/com.gluster.storage.management.gateway.scripts/src/gateway/update_volume_cifs_all.py b/src/com.gluster.storage.management.gateway.scripts/src/gateway/update_volume_cifs_all.py index c5c9d1ef..095ec0f7 100755 --- a/src/com.gluster.storage.management.gateway.scripts/src/gateway/update_volume_cifs_all.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/gateway/update_volume_cifs_all.py @@ -16,21 +16,16 @@ import Utils def updateVolumeCifsConf(volumeName, userList): - try: - fp = open(Globals.CIFS_VOLUME_FILE) - content = fp.read() - fp.close() - except IOError, e: - Utils.log("failed to read file %s: %s" % (Globals.CIFS_VOLUME_FILE, str(e))) - return False - + lines = Utils.readFile(Globals.CIFS_VOLUME_FILE, lines=True) try: fp = open(Globals.CIFS_VOLUME_FILE, "w") - for line in content.split(): - if line.split(":")[0] == volumeName: + for line in lines: + if not line.strip(): + continue + if line.strip().split(":")[0] == volumeName: fp.write("%s:%s\n" % (volumeName, ":".join(userList))) else: - fp.write("%s\n" % line) + fp.write("%s\n" % line.strip()) fp.close() except IOError, e: Utils.log("failed to write file %s: %s" % (Globals.CIFS_VOLUME_FILE, str(e))) |