You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ed...@apache.org on 2012/09/27 06:58:04 UTC

[27/33] git commit: CLOUDSTACK-199: Fix how cloud-setup-databases parses user:password@host

CLOUDSTACK-199: Fix how cloud-setup-databases parses user:password@host

Patch splits by right most @ in supplied argument to get user:password
and host substrings.

Signed-off-by: Rohit Yadav <ro...@citrix.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/6500c3ad
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/6500c3ad
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/6500c3ad

Branch: refs/heads/4.0
Commit: 6500c3ad8f9e92047e2d04098df283852549fae9
Parents: 0cb655a
Author: Rohit Yadav <ro...@citrix.com>
Authored: Wed Sep 26 11:14:33 2012 +0530
Committer: Edison Su <di...@gmail.com>
Committed: Wed Sep 26 21:34:01 2012 -0700

----------------------------------------------------------------------
 setup/bindir/cloud-setup-databases.in |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/6500c3ad/setup/bindir/cloud-setup-databases.in
----------------------------------------------------------------------
diff --git a/setup/bindir/cloud-setup-databases.in b/setup/bindir/cloud-setup-databases.in
index 54c411d..a17b131 100755
--- a/setup/bindir/cloud-setup-databases.in
+++ b/setup/bindir/cloud-setup-databases.in
@@ -475,8 +475,15 @@ for example:
                 self.errorAndExit("There are more than one parameters for user:password@hostname (%s)"%self.args)
             
             arg = self.args[0]
-            stuff = arg.split("@", 1)
-            if len(stuff) == 1: stuff.append("localhost")
+            try:
+                splitIndex = arg.rindex('@')
+            except ValueError:
+                # If it failed to find @, use host=localhost
+                splitIndex = len(arg)
+                arg += "@localhost"
+            finally:
+                stuff = [arg[:splitIndex], arg[splitIndex+1:]]
+
             self.user,self.password = parseUserAndPassword(stuff[0])
             self.host,self.port = parseHostInfo(stuff[1])