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 <rohit.yadav@citrix.com>
This commit is contained in:
Rohit Yadav 2012-09-26 11:14:33 +05:30 committed by Prasanna Santhanam
parent 6540ff8fa1
commit f2e0fa230d

View File

@ -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])