ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From swa...@apache.org
Subject [2/4] git commit: AMBARI-5649. Add postgres external as separate option in ambari-server.py. (Myroslav Papirkovskyy, swagle via swagle)
Date Fri, 02 May 2014 00:57:47 GMT
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/a68b0421
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/a68b0421
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/a68b0421

Branch: refs/heads/trunk
Commit: a68b04215a381a2903db99cfa67b3fe9f313e7ad
Parents: cd50f5c
Author: Siddharth Wagle <swagle@hortonworks.com>
Authored: Thu May 1 17:56:28 2014 -0700
Committer: Siddharth Wagle <swagle@hortonworks.com>
Committed: Thu May 1 17:56:28 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/a68b0421/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 36afa5a..e940fe4 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]
@@ -2063,12 +2064,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
@@ -4015,7 +4012,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",
@@ -4062,7 +4059,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/a68b0421/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 53e090e..f980309 100644
--- a/ambari-server/src/test/python/TestAmbariServer.py
+++ b/ambari-server/src/test/python/TestAmbariServer.py
@@ -3045,6 +3045,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)
@@ -3108,8 +3125,6 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
 
     self.assertTrue(failed)
     self.assertFalse(setup_mock.called)
-
-    setup_mock.reset_mock()
     pass
 
 


Mime
View raw message