You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sw...@apache.org on 2014/05/02 02:52:05 UTC
[4/4] git commit: AMBARI-5649. Add postgres external as separate
option in ambari-server.py. (Myroslav Papirkovskyy, swagle via swagle)
AMBARI-5649. Add postgres external as separate option in ambari-server.py. (Myroslav Papirkovskyy, swagle via swagle)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/f3574624
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/f3574624
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/f3574624
Branch: refs/heads/branch-1.6.0
Commit: f3574624326ea28086913452d40f88e32b5f5f36
Parents: d55c38d
Author: Siddharth Wagle <sw...@hortonworks.com>
Authored: Thu May 1 12:29:23 2014 -0700
Committer: Siddharth Wagle <sw...@hortonworks.com>
Committed: Thu May 1 17:26:08 2014 -0700
----------------------------------------------------------------------
ambari-server/src/main/python/ambari-server.py | 22 +++++++++++++-------
.../src/test/python/TestAmbariServer.py | 19 +++++++++++++++--
2 files changed, 31 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/f3574624/ambari-server/src/main/python/ambari-server.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari-server.py b/ambari-server/src/main/python/ambari-server.py
index 182bc38..fed962b 100755
--- a/ambari-server/src/main/python/ambari-server.py
+++ b/ambari-server/src/main/python/ambari-server.py
@@ -1161,6 +1161,7 @@ def get_pass_file_path(conf_file):
# Set database properties to default values
def load_default_db_properties(args):
+ args.persistence_type = 'local'
args.dbms = DATABASE_NAMES[DATABASE_INDEX]
args.database_host = "localhost"
args.database_port = DATABASE_PORTS[DATABASE_INDEX]
@@ -2072,12 +2073,8 @@ def find_jdk():
#
# Checks if options determine local DB configuration
#
-def is_local_database(options):
- if options.dbms == DATABASE_NAMES[0] \
- and options.database_host == "localhost" \
- and options.database_port == DATABASE_PORTS[0]:
- return True
- return False
+def is_local_database(args):
+ return args.persistence_type == 'local'
#Check if required jdbc drivers present
@@ -4054,7 +4051,7 @@ def main():
parser.add_option('-g', '--debug', action="store_true", dest='debug', default=False,
help="Start ambari-server in debug mode")
- parser.add_option('--database', default=None, help="Database to use postgres|oracle", dest="dbms")
+ parser.add_option('--database', default=None, help="Database to use embedded|oracle|mysql|postgres", dest="dbms")
parser.add_option('--databasehost', default=None, help="Hostname of database server", dest="database_host")
parser.add_option('--databaseport', default=None, help="Database port", dest="database_port")
parser.add_option('--databasename', default=None, help="Database/Schema/Service name or ServiceID",
@@ -4101,7 +4098,16 @@ def main():
parser.error('All database options should be set. Please see help for the options.')
#correct database
- if options.dbms is not None and options.dbms not in DATABASE_NAMES:
+ if options.dbms == 'embedded':
+ print "WARNING: HostName for postgres server " + options.database_host + \
+ " will be ignored: using localhost."
+ options.database_host = "localhost"
+ options.dbms = 'postgres'
+ options.persistence_type = 'local'
+ options.database_index = 0
+ DATABASE_INDEX = 0
+ pass
+ elif options.dbms is not None and options.dbms not in DATABASE_NAMES:
parser.print_help()
parser.error("Unsupported Database " + options.dbms)
elif options.dbms is not None:
http://git-wip-us.apache.org/repos/asf/ambari/blob/f3574624/ambari-server/src/test/python/TestAmbariServer.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/TestAmbariServer.py b/ambari-server/src/test/python/TestAmbariServer.py
index be3c64a..c781516 100644
--- a/ambari-server/src/test/python/TestAmbariServer.py
+++ b/ambari-server/src/test/python/TestAmbariServer.py
@@ -3048,6 +3048,23 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
setup_mock.reset_mock()
+ # test embedded option
+ failed = False
+ sys.argv = list(base_args)
+ sys.argv.extend(db_args[-10:])
+ sys.argv.extend(["--database", "embedded"])
+
+ try:
+ ambari_server.main()
+ except SystemExit:
+ failed = True
+ pass
+
+ self.assertFalse(failed)
+ self.assertTrue(setup_mock.called)
+
+ setup_mock.reset_mock()
+
#test full args
sys.argv = list(base_args)
sys.argv.extend(db_args)
@@ -3111,8 +3128,6 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
self.assertTrue(failed)
self.assertFalse(setup_mock.called)
-
- setup_mock.reset_mock()
pass