diff options
-rwxr-xr-x | src/com.gluster.storage.management.gateway.scripts/src/gateway/create_volume_cifs_all.py | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/com.gluster.storage.management.gateway.scripts/src/gateway/create_volume_cifs_all.py b/src/com.gluster.storage.management.gateway.scripts/src/gateway/create_volume_cifs_all.py index 59e74bed..7186283c 100755 --- a/src/com.gluster.storage.management.gateway.scripts/src/gateway/create_volume_cifs_all.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/gateway/create_volume_cifs_all.py @@ -16,18 +16,13 @@ import Utils def addVolumeCifsConf(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))) - content = "" - + 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\n" % line) fp.write("%s:%s\n" % (volumeName, ":".join(userList))) fp.close() |