Repository: cloudstack Updated Branches: refs/heads/master d22adf943 -> c7f325015
CLOUDSTACK-6435: Add new Command line options to setup/bindir/cloud-setup-databases.in and remove OS specific commands Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/c7f32501 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/c7f32501 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/c7f32501 Branch: refs/heads/master Commit: c7f325015100abd3aed2307f95943590758bdf42 Parents: d22adf9 Author: Damodar Reddy <[email protected]> Authored: Thu Apr 17 14:54:07 2014 +0530 Committer: Frank.Zhang <[email protected]> Committed: Wed Apr 23 10:36:50 2014 -0700 ---------------------------------------------------------------------- setup/bindir/cloud-setup-databases.in | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c7f32501/setup/bindir/cloud-setup-databases.in ---------------------------------------------------------------------- diff --git a/setup/bindir/cloud-setup-databases.in b/setup/bindir/cloud-setup-databases.in index 2ba7d51..dd22e56 100755 --- a/setup/bindir/cloud-setup-databases.in +++ b/setup/bindir/cloud-setup-databases.in @@ -25,8 +25,8 @@ from random import choice import string from optparse import OptionParser import commands -import MySQLdb import shutil +import socket # squelch mysqldb spurious warnings import warnings @@ -336,14 +336,8 @@ for example: def grabSystemInfo(self): def getIpAddr(): try: - stuff = runCmd(['ifconfig', '|', 'grep "inet addr"']) - for l in stuff.split("\n"): - l = l.strip() - secondSpace = l.find(' ', len('inet addr')) - ipStr = l[:secondSpace] - (x, ip) = ipStr.split(':') - if ip != '127.0.0.1': return ip - return '127.0.0.1' + ip = socket.gethostbyname(socket.gethostname()) + return ip except Exception, e: return "127.0.0.1" @@ -380,7 +374,7 @@ for example: def checkHostName(): self.info("Checking local machine hostname ...", None) try: - output= runCmd(['hostname', '--fqdn']) + output= socket.getfqdn() except Exception, e: err = "The host name of this computer does not resolve to an IP address.\nPlease use your operating system's network setup tools to fix this ('hostname --fqdn' %s).\n"%e.__str__() self.errorAndExit(err) @@ -404,7 +398,7 @@ for example: def processEncryptionStuff(self): def encrypt(input): cmd = ['java','-classpath',self.encryptionJarPath,'org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI', 'encrypt.sh', 'input=%s'%input, 'password=%s'%self.mgmtsecretkey,'verbose=false'] - return runCmd(cmd).strip('\n') + return runCmd(cmd).strip('\r\n') def saveMgmtServerSecretKey(): if self.encryptiontype == 'file': @@ -460,6 +454,14 @@ for example: self.mgmtsecretkey = self.options.mgmtsecretkey self.dbsecretkey = self.options.dbsecretkey self.isDebug = self.options.debug + if self.options.dbConfPath: + self.dbConfPath = self.options.dbConfPath + if self.options.dbFilesPath: + self.dbFilesPath = self.options.dbFilesPath + if self.options.encryptionKeyFile: + self.encryptionKeyFile = self.options.encryptionKeyFile + if self.options.encryptionJarPath: + self.encryptionJarPath = self.options.encryptionJarPath def parseUserAndPassword(cred): stuff = cred.split(':') @@ -576,6 +578,10 @@ for example: help="Cluster management server host IP. A string, by default it will try to detect a local IP") self.parser.add_option("-r", "--regionid", action="store", type="string", dest="regionid", default="1", help="Region Id for the management server cluster") + self.parser.add_option("-c", "--db-conf-path", action="store", dest="dbConfPath", help="The path to find db.properties which hold db properties") + self.parser.add_option("-f", "--db-files-path", action="store", dest="dbFilesPath", help="The path to find sql files to create initial database(s)") + self.parser.add_option("-j", "--encryption-jar-path", action="store", dest="encryptionJarPath", help="The path to the jasypt library to be used to encrypt the values in db.properties") + self.parser.add_option("-n", "--encryption-key-file", action="store", dest="encryptionKeyFile", help="The name of the file in which encryption key to be generated") (self.options, self.args) = self.parser.parse_args() parseCasualCredit()
