diff options
| author | Shireesh Anjal <anjalshireesh@gmail.com> | 2011-08-10 02:03:48 -0700 |
|---|---|---|
| committer | Shireesh Anjal <anjalshireesh@gmail.com> | 2011-08-10 02:03:48 -0700 |
| commit | 5c4d1742737d33c050e35ac1cb9289024ecbb355 (patch) | |
| tree | 786e841a3facee76c68c78fc2fd2f2ae7f43d5e0 /src/com.gluster.storage.management.gateway/WebContent/scripts/create_volume_cifs_all.py | |
| parent | e83fc81fbc1c3379b7ae116f10fdbe3ac93ffe87 (diff) | |
| parent | d03d4570da36b01032e6e2b0c80f6c36b98bbe1f (diff) | |
Merge pull request #218 from TimothyAsir/master
Bug 3374 - [CIFS] updating volume with a non-existent user succeeds.
Diffstat (limited to 'src/com.gluster.storage.management.gateway/WebContent/scripts/create_volume_cifs_all.py')
| -rwxr-xr-x | src/com.gluster.storage.management.gateway/WebContent/scripts/create_volume_cifs_all.py | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/com.gluster.storage.management.gateway/WebContent/scripts/create_volume_cifs_all.py b/src/com.gluster.storage.management.gateway/WebContent/scripts/create_volume_cifs_all.py index 70b84e6b..59e74bed 100755 --- a/src/com.gluster.storage.management.gateway/WebContent/scripts/create_volume_cifs_all.py +++ b/src/com.gluster.storage.management.gateway/WebContent/scripts/create_volume_cifs_all.py @@ -11,30 +11,28 @@ if not p1 in sys.path: sys.path.append(p1) if not p2 in sys.path: sys.path.append(p2) +import Globals import Utils -cifsVolumeFile = "/opt/glustermg/etc/volumes.cifs" - - def addVolumeCifsConf(volumeName, userList): try: - fp = open(cifsVolumeFile) + fp = open(Globals.CIFS_VOLUME_FILE) content = fp.read() fp.close() except IOError, e: - Utils.log("failed to read file %s: %s" % (cifsVolumeFile, str(e))) + Utils.log("failed to read file %s: %s" % (Globals.CIFS_VOLUME_FILE, str(e))) content = "" try: - fp = open(cifsVolumeFile, "w") + fp = open(Globals.CIFS_VOLUME_FILE, "w") for line in content.split(): if line.split(":")[0] != volumeName: fp.write("%s\n" % line) fp.write("%s:%s\n" % (volumeName, ":".join(userList))) fp.close() except IOError, e: - Utils.log("failed to write file %s: %s" % (cifsVolumeFile, str(e))) + Utils.log("failed to write file %s: %s" % (Globals.CIFS_VOLUME_FILE, str(e))) return False return True @@ -48,6 +46,15 @@ def main(): volumeName = sys.argv[2] userList = sys.argv[3:] + missingUserList = [] + for userName in userList: + if not Utils.getCifsUserUid(userName): + missingUserList.append(userName) + + if missingUserList: + sys.stderr.write("User %s does not exists\n" % missingUserList) + sys.exit(1) + rv = Utils.runCommand(["grun.py", serverFile, "create_volume_cifs.py", volumeName] + userList) if rv == 0: if not addVolumeCifsConf(volumeName, userList): |
