ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yus...@apache.org
Subject [2/7] ambari git commit: Revert "AMBARI-8373 Refactor the OS-dependent Ambari Server Windows components"
Date Fri, 19 Dec 2014 21:51:51 GMT
http://git-wip-us.apache.org/repos/asf/ambari/blob/fad56746/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 64349a1..0eae33b 100644
--- a/ambari-server/src/test/python/TestAmbariServer.py
+++ b/ambari-server/src/test/python/TestAmbariServer.py
@@ -35,44 +35,20 @@ import shutil
 from pwd import getpwnam
 from ambari_server.resourceFilesKeeper import ResourceFilesKeeper, KeeperException
 from ambari_server import BackupRestore
-
-from ambari_commons import OSCheck, OSConst, Firewall, FirewallChecks
-from ambari_commons.exceptions import *
-from ambari_commons.os_linux import *
-from ambari_commons.os_utils import *
-from ambari_commons.inet_utils import *
-
+ 
 # We have to use this import HACK because the filename contains a dash
-with patch("platform.linux_distribution", return_value = ('Suse','11','Final')):
-  with patch("os.symlink"):
-    with patch("__builtin__.open"):
-      with patch("glob.glob", return_value = ['/etc/init.d/postgresql-9.3']):
-        ambari__server = __import__('ambari-server')
+from ambari_commons import Firewall, OSCheck, OSConst, FirewallChecks
 
 with patch("platform.linux_distribution", return_value = ('Suse','11','Final')):
   with patch("os.symlink"):
     with patch("__builtin__.open"):
       with patch("glob.glob", return_value = ['/etc/init.d/postgresql-9.3']):
-        from ambari_server.dbConfiguration import *
-        from ambari_server.dbConfiguration_linux import *
-        from ambari_server.properties import *
-        from ambari_server.serverConfiguration import *
-        from ambari_server.serverSetup import *
-        from ambari_server.userInput import *
+        ambari_server = __import__('ambari-server')
 
+FatalException = ambari_server.FatalException
+NonFatalException = ambari_server.NonFatalException
 CURR_AMBARI_VERSION = "2.0.0"
 
-db_YN_Inputs_test_ambariServerSetupWithCustomDbName_call_count = 0
-
-def db_YN_Inputs_ret_test_ambariServerSetupWithCustomDbName(*args, **kwargs):
-  global db_YN_Inputs_test_ambariServerSetupWithCustomDbName_call_count
-  if db_YN_Inputs_test_ambariServerSetupWithCustomDbName_call_count == 0:
-    db_YN_Inputs_test_ambariServerSetupWithCustomDbName_call_count += 1
-    return False
-  else:
-    return True
-
-
 class TestAmbariServer(TestCase):
   def setUp(self):
     out = StringIO.StringIO()
@@ -82,18 +58,27 @@ class TestAmbariServer(TestCase):
   def tearDown(self):
     sys.stdout = sys.__stdout__
 
-  @patch("ambari_server.dbConfiguration_linux.run_os_command")
-  def test_configure_pg_hba_ambaridb_users(self, run_os_command_method):
+
+  @patch.object(ambari_server, 'configure_database_username_password')
+  @patch.object(ambari_server, 'run_os_command')
+  @patch('optparse.Values')
+  def test_configure_pg_hba_ambaridb_users(self, OptParseValuesMock,
+                                           run_os_command_method,
+                                           configure_database_username_password_method):
     # Prepare mocks
     run_os_command_method.return_value = (0, "", "")
-    database_username = "ffdf"
+    opvm = OptParseValuesMock.return_value
+    opvm.database_username = "ffdf"
     tf1 = tempfile.NamedTemporaryFile()
+    ambari_server.PG_HBA_CONF_FILE = tf1.name
     # Run test
-    PGConfig._configure_pg_hba_ambaridb_users(tf1.name, database_username)
+    ambari_server.configure_pg_hba_ambaridb_users()
     # Check results
     self.assertTrue(run_os_command_method.called)
-    string_expected = self.get_file_string(self.get_samples_dir("configure_pg_hba_ambaridb_users1"))
-    string_actual = self.get_file_string(tf1.name)
+    self.assertTrue(configure_database_username_password_method.called)
+    string_expected = self.get_file_string(self
+    .get_samples_dir("configure_pg_hba_ambaridb_users1"))
+    string_actual = self.get_file_string(ambari_server.PG_HBA_CONF_FILE)
     self.assertEquals(string_expected, string_actual)
     pass
 
@@ -101,9 +86,9 @@ class TestAmbariServer(TestCase):
   def test_servicename_regex(self, raw_input_method):
 
     ''' Test to make sure the service name can contain digits '''
-    ambari__server.SILENT = False
+    ambari_server.SILENT = False
     raw_input_method.return_value = "OT100"
-    result = OracleConfig._get_validated_service_name("ambari", 1)
+    result = ambari_server.get_validated_service_name("ambari", 1)
     self.assertEqual("OT100", result, "Not accepting digits")
     pass
 
@@ -111,31 +96,31 @@ class TestAmbariServer(TestCase):
   def test_dbname_regex(self, raw_input_method):
 
     ''' Test to make sure the service name can contain digits '''
-    ambari__server.SILENT = False
+    ambari_server.SILENT = False
     raw_input_method.return_value = "OT100"
-    result = LinuxDBMSConfig._get_validated_db_name("Database", "ambari")
+    result = ambari_server.get_validated_db_name("ambari")
     self.assertEqual("OT100", result, "Not accepting digits")
 
 
   def test_configure_pg_hba_postgres_user(self):
 
     tf1 = tempfile.NamedTemporaryFile()
-    PGConfig.PG_HBA_CONF_FILE = tf1.name
+    ambari_server.PG_HBA_CONF_FILE = tf1.name
 
-    with open(PGConfig.PG_HBA_CONF_FILE, 'w') as fout:
+    with open(ambari_server.PG_HBA_CONF_FILE, 'w') as fout:
       fout.write("\n")
       fout.write("local  all  all md5\n")
       fout.write("host  all   all 0.0.0.0/0  md5\n")
       fout.write("host  all   all ::/0 md5\n")
 
-    PGConfig._configure_pg_hba_postgres_user()
+    ambari_server.configure_pg_hba_postgres_user()
 
     expected = self.get_file_string(self.get_samples_dir(
       "configure_pg_hba_ambaridb_users2"))
-    result = self.get_file_string(PGConfig.PG_HBA_CONF_FILE)
+    result = self.get_file_string(ambari_server.PG_HBA_CONF_FILE)
     self.assertEqual(expected, result, "pg_hba_conf not processed")
 
-    mode = oct(os.stat(PGConfig.PG_HBA_CONF_FILE)[stat.ST_MODE])
+    mode = oct(os.stat(ambari_server.PG_HBA_CONF_FILE)[stat.ST_MODE])
     str_mode = str(mode)[-4:]
     self.assertEqual("0644", str_mode, "Wrong file permissions")
 
@@ -149,7 +134,7 @@ class TestAmbariServer(TestCase):
     # test first input
     raw_input_method.return_value = "Y"
 
-    result = ambari__server.get_choice_string_input(prompt, default,
+    result = ambari_server.get_choice_string_input(prompt, default,
                                                    firstChoice, secondChoice)
     self.assertEquals(result, True)
     raw_input_method.reset_mock()
@@ -157,7 +142,7 @@ class TestAmbariServer(TestCase):
 
     raw_input_method.return_value = "N"
 
-    result = ambari__server.get_choice_string_input(prompt, default,
+    result = ambari_server.get_choice_string_input(prompt, default,
                                                    firstChoice, secondChoice)
     self.assertEquals(result, False)
 
@@ -167,7 +152,7 @@ class TestAmbariServer(TestCase):
 
     raw_input_method.return_value = ""
 
-    result = ambari__server.get_choice_string_input(prompt, default,
+    result = ambari_server.get_choice_string_input(prompt, default,
                                                    firstChoice, secondChoice)
     self.assertEquals(result, default)
 
@@ -181,7 +166,7 @@ class TestAmbariServer(TestCase):
 
     raw_input_method.side_effect = side_effect
 
-    result = ambari__server.get_choice_string_input(prompt, default,
+    result = ambari_server.get_choice_string_input(prompt, default,
                                                    firstChoice, secondChoice)
     self.assertEquals(result, True)
     self.assertEquals(raw_input_method.call_count, 3)
@@ -199,11 +184,11 @@ class TestAmbariServer(TestCase):
     pattern = "pattern_pp"
     description = "blabla2"
     # check password input
-    self.assertFalse(False, ambari__server.SILENT)
+    self.assertFalse(False, ambari_server.SILENT)
     is_pass = True
     get_pass_method.return_value = "dfdsfdsfds"
 
-    result = ambari__server.get_validated_string_input(prompt, default,
+    result = ambari_server.get_validated_string_input(prompt, default,
                                                       pattern, description, is_pass)
 
     self.assertEquals(get_pass_method.return_value, result)
@@ -216,7 +201,7 @@ class TestAmbariServer(TestCase):
     is_pass = False
     raw_input_method.return_value = "dkf90ewuf0"
 
-    result = ambari__server.get_validated_string_input(prompt, default,
+    result = ambari_server.get_validated_string_input(prompt, default,
                                                       pattern, description, is_pass)
 
     self.assertEquals(raw_input_method.return_value, result)
@@ -225,12 +210,12 @@ class TestAmbariServer(TestCase):
 
 
   def test_get_pass_file_path(self):
-    result = ambari__server.get_pass_file_path("/etc/ambari/conf_file")
+    result = ambari_server.get_pass_file_path("/etc/ambari/conf_file")
     self.assertEquals("/etc/ambari/password.dat", result)
     pass
 
 
-  @patch.object(ambari__server, 'setup_security')
+  @patch.object(ambari_server, 'setup_security')
   @patch('optparse.OptionParser')
   def test_main_test_setup_security(self, OptionParserMock,
                                     setup_security_method):
@@ -242,46 +227,46 @@ class TestAmbariServer(TestCase):
     options.sid_or_sname = "sid"
     setup_security_method.return_value = None
 
-    ambari__server.main()
+    ambari_server.main()
 
-    ambari__server.main()
+    ambari_server.main()
     self.assertTrue(setup_security_method.called)
-    self.assertFalse(False, ambari__server.VERBOSE)
-    self.assertFalse(False, ambari__server.SILENT)
-
-  @patch.object(ambari__server, 'setup_ambari_krb5_jaas')
-  @patch.object(ambari__server, 'setup_master_key')
-  @patch.object(ambari__server, 'setup_component_https')
-  @patch.object(ambari__server, 'setup_https')
-  @patch.object(ambari__server, "get_validated_string_input")
+    self.assertFalse(False, ambari_server.VERBOSE)
+    self.assertFalse(False, ambari_server.SILENT)
+
+  @patch.object(ambari_server, 'setup_ambari_krb5_jaas')
+  @patch.object(ambari_server, 'setup_master_key')
+  @patch.object(ambari_server, 'setup_component_https')
+  @patch.object(ambari_server, 'setup_https')
+  @patch.object(ambari_server, 'get_validated_string_input')
   def test_setup_security(self, get_validated_string_input_mock, setup_https,
                           setup_component_https, setup_master_key,
                           setup_ambari_krb5_jaas):
 
     args = {}
     get_validated_string_input_mock.return_value = '1'
-    ambari__server.setup_security(args)
+    ambari_server.setup_security(args)
     self.assertTrue(setup_https.called)
 
     get_validated_string_input_mock.return_value = '2'
-    ambari__server.setup_security(args)
+    ambari_server.setup_security(args)
     self.assertTrue(setup_component_https.called)
     setup_component_https.assert_called_with("Ganglia", "setup-ganglia-https",
-                          ambari__server.GANGLIA_HTTPS, "ganglia_cert")
+                          ambari_server.GANGLIA_HTTPS, "ganglia_cert")
 
     get_validated_string_input_mock.return_value = '3'
-    ambari__server.setup_security(args)
+    ambari_server.setup_security(args)
     self.assertTrue(setup_master_key.called)
 
     get_validated_string_input_mock.return_value = '4'
-    ambari__server.setup_security(args)
+    ambari_server.setup_security(args)
     self.assertTrue(setup_ambari_krb5_jaas.called)
 
 
   @patch('re.sub')
   @patch('fileinput.FileInput')
-  @patch("ambari_server.userInput.get_validated_string_input")
-  @patch.object(ambari__server, "search_file")
+  @patch.object(ambari_server, 'get_validated_string_input')
+  @patch.object(ambari_server, 'search_file')
   @patch('os.path.exists')
   def test_setup_ambari_krb5_jaas(self, exists_mock, search_mock,
                                   get_validated_string_input_mock,
@@ -292,7 +277,7 @@ class TestAmbariServer(TestCase):
 
     # Negative case
     try:
-      ambari__server.setup_ambari_krb5_jaas()
+      ambari_server.setup_ambari_krb5_jaas()
       self.fail("Should throw exception")
     except NonFatalException as fe:
       # Expected
@@ -307,17 +292,17 @@ class TestAmbariServer(TestCase):
 
     fileinput_mock.return_value = [ 'keyTab=xyz', 'principal=xyz' ]
 
-    ambari__server.setup_ambari_krb5_jaas()
+    ambari_server.setup_ambari_krb5_jaas()
 
     self.assertTrue(fileinput_mock.called)
     self.assertTrue(re_sub_mock.called)
     self.assertTrue(re_sub_mock.call_args_list, [('aaa@aaa.cnn'),
                                                  ('pathtokeytab')])
 
-  @patch.object(ambari__server, 'setup')
-  @patch.object(ambari__server, 'start')
-  @patch.object(ambari__server, 'stop')
-  @patch.object(ambari__server, 'reset')
+  @patch.object(ambari_server, 'setup')
+  @patch.object(ambari_server, 'start')
+  @patch.object(ambari_server, 'stop')
+  @patch.object(ambari_server, 'reset')
   @patch('optparse.OptionParser')
   def test_main_test_setup(self, OptionParserMock, reset_method, stop_method,
                            start_method, setup_method):
@@ -328,21 +313,21 @@ class TestAmbariServer(TestCase):
 
     options.dbms = None
     options.sid_or_sname = "sid"
-    ambari__server.main()
+    ambari_server.main()
 
     self.assertTrue(setup_method.called)
     self.assertFalse(start_method.called)
     self.assertFalse(stop_method.called)
     self.assertFalse(reset_method.called)
 
-    self.assertFalse(False, ambari__server.VERBOSE)
-    self.assertFalse(False, ambari__server.SILENT)
+    self.assertFalse(False, ambari_server.VERBOSE)
+    self.assertFalse(False, ambari_server.SILENT)
 
 
-  @patch.object(ambari__server, 'setup')
-  @patch.object(ambari__server, 'start')
-  @patch.object(ambari__server, 'stop')
-  @patch.object(ambari__server, 'reset')
+  @patch.object(ambari_server, 'setup')
+  @patch.object(ambari_server, 'start')
+  @patch.object(ambari_server, 'stop')
+  @patch.object(ambari_server, 'reset')
   @patch('optparse.OptionParser')
   def test_main_test_start(self, OptionParserMock, reset_method, stop_method,
                            start_method, setup_method):
@@ -353,21 +338,21 @@ class TestAmbariServer(TestCase):
 
     options.dbms = None
     options.sid_or_sname = "sname"
-    ambari__server.main()
+    ambari_server.main()
 
     self.assertTrue(setup_method.called)
     self.assertFalse(start_method.called)
     self.assertFalse(stop_method.called)
     self.assertFalse(reset_method.called)
 
-    self.assertFalse(False, ambari__server.VERBOSE)
-    self.assertFalse(False, ambari__server.SILENT)
+    self.assertFalse(False, ambari_server.VERBOSE)
+    self.assertFalse(False, ambari_server.SILENT)
 
 
-  @patch.object(ambari__server, 'setup')
-  @patch.object(ambari__server, 'start')
-  @patch.object(ambari__server, 'stop')
-  @patch.object(ambari__server, 'reset')
+  @patch.object(ambari_server, 'setup')
+  @patch.object(ambari_server, 'start')
+  @patch.object(ambari_server, 'stop')
+  @patch.object(ambari_server, 'reset')
   @patch('optparse.OptionParser')
   def test_main_test_start_debug_short(self, OptionParserMock, reset_method, stop_method,
                                        start_method, setup_method):
@@ -379,20 +364,20 @@ class TestAmbariServer(TestCase):
     options.dbms = None
     options.sid_or_sname = "sid"
 
-    ambari__server.main()
+    ambari_server.main()
 
     self.assertFalse(setup_method.called)
     self.assertTrue(start_method.called)
     self.assertFalse(stop_method.called)
     self.assertFalse(reset_method.called)
 
-    self.assertTrue(ambari__server.SERVER_DEBUG_MODE)
+    self.assertTrue(ambari_server.SERVER_DEBUG_MODE)
 
 
-  @patch.object(ambari__server, 'setup')
-  @patch.object(ambari__server, 'start')
-  @patch.object(ambari__server, 'stop')
-  @patch.object(ambari__server, 'reset')
+  @patch.object(ambari_server, 'setup')
+  @patch.object(ambari_server, 'start')
+  @patch.object(ambari_server, 'stop')
+  @patch.object(ambari_server, 'reset')
   @patch('optparse.OptionParser')
   def test_main_test_start_debug_long(self, OptionParserMock, reset_method, stop_method,
                                       start_method, setup_method):
@@ -403,21 +388,21 @@ class TestAmbariServer(TestCase):
     options.dbms = None
     options.sid_or_sname = "sid"
 
-    ambari__server.main()
+    ambari_server.main()
 
     self.assertFalse(setup_method.called)
     self.assertTrue(start_method.called)
     self.assertFalse(stop_method.called)
     self.assertFalse(reset_method.called)
 
-    self.assertTrue(ambari__server.SERVER_DEBUG_MODE)
+    self.assertTrue(ambari_server.SERVER_DEBUG_MODE)
 
-  @patch.object(ambari__server, 'setup')
-  @patch.object(ambari__server, 'start')
-  @patch.object(ambari__server, 'stop')
-  @patch.object(ambari__server, 'reset')
-  @patch.object(ambari__server, 'backup')
-  @patch.object(ambari__server, 'restore')
+  @patch.object(ambari_server, 'setup')
+  @patch.object(ambari_server, 'start')
+  @patch.object(ambari_server, 'stop')
+  @patch.object(ambari_server, 'reset')
+  @patch.object(ambari_server, 'backup')
+  @patch.object(ambari_server, 'restore')
   @patch('optparse.OptionParser')
   def test_main_test_backup(self, OptionParserMock, restore_mock, backup_mock, reset_method, stop_method,
                            start_method, setup_method):
@@ -428,7 +413,7 @@ class TestAmbariServer(TestCase):
 
     options.dbms = None
     options.sid_or_sname = "sname"
-    ambari__server.main()
+    ambari_server.main()
 
     self.assertTrue(backup_mock.called)
     self.assertFalse(restore_mock.called)
@@ -437,15 +422,15 @@ class TestAmbariServer(TestCase):
     self.assertFalse(stop_method.called)
     self.assertFalse(reset_method.called)
 
-    self.assertFalse(False, ambari__server.VERBOSE)
-    self.assertFalse(False, ambari__server.SILENT)
+    self.assertFalse(False, ambari_server.VERBOSE)
+    self.assertFalse(False, ambari_server.SILENT)
 
-  @patch.object(ambari__server, 'setup')
-  @patch.object(ambari__server, 'start')
-  @patch.object(ambari__server, 'stop')
-  @patch.object(ambari__server, 'reset')
-  @patch.object(ambari__server, 'backup')
-  @patch.object(ambari__server, 'restore')
+  @patch.object(ambari_server, 'setup')
+  @patch.object(ambari_server, 'start')
+  @patch.object(ambari_server, 'stop')
+  @patch.object(ambari_server, 'reset')
+  @patch.object(ambari_server, 'backup')
+  @patch.object(ambari_server, 'restore')
   @patch('optparse.OptionParser')
   def test_main_test_restore(self, OptionParserMock, restore_mock, backup_mock, reset_method, stop_method,
                             start_method, setup_method):
@@ -456,7 +441,7 @@ class TestAmbariServer(TestCase):
 
     options.dbms = None
     options.sid_or_sname = "sname"
-    ambari__server.main()
+    ambari_server.main()
 
     self.assertTrue(restore_mock.called)
     self.assertFalse(backup_mock.called)
@@ -465,13 +450,13 @@ class TestAmbariServer(TestCase):
     self.assertFalse(stop_method.called)
     self.assertFalse(reset_method.called)
 
-    self.assertFalse(False, ambari__server.VERBOSE)
-    self.assertFalse(False, ambari__server.SILENT)
+    self.assertFalse(False, ambari_server.VERBOSE)
+    self.assertFalse(False, ambari_server.SILENT)
 
-  @patch.object(ambari__server, 'setup')
-  @patch.object(ambari__server, 'start')
-  @patch.object(ambari__server, 'stop')
-  @patch.object(ambari__server, 'reset')
+  @patch.object(ambari_server, 'setup')
+  @patch.object(ambari_server, 'start')
+  @patch.object(ambari_server, 'stop')
+  @patch.object(ambari_server, 'reset')
   @patch('optparse.OptionParser')
   def test_main_test_stop(self, OptionParserMock, reset_method, stop_method,
                           start_method, setup_method):
@@ -483,21 +468,21 @@ class TestAmbariServer(TestCase):
     options.dbms = None
     options.sid_or_sname = "sid"
 
-    ambari__server.main()
+    ambari_server.main()
 
     self.assertFalse(setup_method.called)
     self.assertFalse(start_method.called)
     self.assertTrue(stop_method.called)
     self.assertFalse(reset_method.called)
 
-    self.assertFalse(False, ambari__server.VERBOSE)
-    self.assertFalse(False, ambari__server.SILENT)
+    self.assertFalse(False, ambari_server.VERBOSE)
+    self.assertFalse(False, ambari_server.SILENT)
 
 
-  @patch.object(ambari__server, 'setup')
-  @patch.object(ambari__server, 'start')
-  @patch.object(ambari__server, 'stop')
-  @patch.object(ambari__server, 'reset')
+  @patch.object(ambari_server, 'setup')
+  @patch.object(ambari_server, 'start')
+  @patch.object(ambari_server, 'stop')
+  @patch.object(ambari_server, 'reset')
   @patch('optparse.OptionParser')
   def test_main_test_reset(self, OptionParserMock, reset_method, stop_method,
                            start_method, setup_method):
@@ -509,130 +494,108 @@ class TestAmbariServer(TestCase):
     options.dbms = None
     options.sid_or_sname = "sid"
 
-    ambari__server.main()
+    ambari_server.main()
 
     self.assertFalse(setup_method.called)
     self.assertFalse(start_method.called)
     self.assertFalse(stop_method.called)
     self.assertTrue(reset_method.called)
 
-    self.assertFalse(False, ambari__server.VERBOSE)
-    self.assertFalse(False, ambari__server.SILENT)
+    self.assertFalse(False, ambari_server.VERBOSE)
+    self.assertFalse(False, ambari_server.SILENT)
+
 
   def test_configure_postgresql_conf(self):
     tf1 = tempfile.NamedTemporaryFile()
-    PGConfig.POSTGRESQL_CONF_FILE = tf1.name
+    ambari_server.POSTGRESQL_CONF_FILE = tf1.name
 
-    with open(PGConfig.POSTGRESQL_CONF_FILE, 'w') as f:
+    with open(ambari_server.POSTGRESQL_CONF_FILE, 'w') as f:
       f.write("#listen_addresses = '127.0.0.1'        #\n")
       f.write("#listen_addresses = '127.0.0.1'")
 
-    PGConfig._configure_postgresql_conf()
+    ambari_server.configure_postgresql_conf()
 
     expected = self.get_file_string(self.get_samples_dir(
       "configure_postgresql_conf1"))
-    result = self.get_file_string(PGConfig.POSTGRESQL_CONF_FILE)
+    result = self.get_file_string(ambari_server.POSTGRESQL_CONF_FILE)
     self.assertEqual(expected, result, "postgresql.conf not updated")
 
-    mode = oct(os.stat(PGConfig.POSTGRESQL_CONF_FILE)[stat.ST_MODE])
+    mode = oct(os.stat(ambari_server.POSTGRESQL_CONF_FILE)[stat.ST_MODE])
     str_mode = str(mode)[-4:]
     self.assertEqual("0644", str_mode, "Wrong file permissions")
 
 
-  @patch.object(OSCheck, "get_os_family")
-  @patch.object(OSCheck, "get_os_type")
-  @patch.object(OSCheck, "get_os_major_version")
-  @patch("ambari_server.dbConfiguration_linux.PGConfig._restart_postgres")
-  @patch("ambari_server.dbConfiguration_linux.PGConfig._get_postgre_status")
-  @patch("ambari_server.dbConfiguration_linux.PGConfig._configure_postgresql_conf")
-  @patch("ambari_server.dbConfiguration_linux.run_os_command")
-  def test_configure_postgres(self,
-                              run_os_command_mock,
+  @patch.object(ambari_server, "restart_postgres")
+  @patch.object(ambari_server, "get_postgre_status")
+  @patch.object(ambari_server, "configure_postgresql_conf")
+  @patch.object(ambari_server, "configure_pg_hba_ambaridb_users")
+  @patch.object(ambari_server, "configure_pg_hba_postgres_user")
+  def test_configure_postgres(self, configure_pg_hba_postgres_user_mock,
+                              configure_pg_hba_ambaridb_users_mock,
                               configure_postgresql_conf_mock,
                               get_postgre_status_mock,
-                              restart_postgres_mock,
-                              get_os_major_version_mock, get_os_type_mock, get_os_family_mock):
-    args = MagicMock()
-    properties = Properties()
-
-    args.dbms_index = 0
-
-    del args.dbms
-    del args.database_host
-    del args.database_port
-    del args.database_name
-    del args.database_username
-    del args.database_password
-    del args.silent
-
-    factory = DBMSConfigFactory()
-    dbConfig = factory.create(args, properties)
-
-    self.assertTrue(dbConfig.dbms, "postgres")
-    self.assertTrue(dbConfig.persistence_type, "local")
-
+                              restart_postgres_mock):
     tf1 = tempfile.NamedTemporaryFile()
     tf2 = tempfile.NamedTemporaryFile()
-
-    PGConfig.PG_HBA_CONF_FILE = tf1.name
-    PGConfig.PG_HBA_CONF_FILE_BACKUP = tf2.name
+    ambari_server.PG_HBA_CONF_FILE = tf1.name
+    ambari_server.PG_HBA_CONF_FILE_BACKUP = tf2.name
+    args = MagicMock()
 
     out = StringIO.StringIO()
     sys.stdout = out
-    retcode, out1, err = dbConfig._configure_postgres()
+    retcode, out1, err = ambari_server.configure_postgres()
     sys.stdout = sys.__stdout__
     self.assertEqual(0, retcode)
     self.assertEqual("Backup for pg_hba found, reconfiguration not required\n",
                      out.getvalue())
-    tf2.close()
 
-    get_postgre_status_mock.return_value = PGConfig.PG_STATUS_RUNNING, 0, "", ""
-    run_os_command_mock.return_value = 0, "", ""
+    ambari_server.PG_HBA_CONF_FILE_BACKUP = tempfile.mktemp()
+    get_postgre_status_mock.return_value = ambari_server.PG_STATUS_RUNNING, 0, "", ""
     restart_postgres_mock.return_value = 0, "", ""
 
-    rcode, out, err = dbConfig._configure_postgres()
+    rcode, out, err = ambari_server.configure_postgres()
 
-    self.assertTrue(os.path.isfile(PGConfig.PG_HBA_CONF_FILE_BACKUP),
+    self.assertTrue(os.path.isfile(ambari_server.PG_HBA_CONF_FILE_BACKUP),
                     "postgresql.conf backup not created")
-    self.assertTrue(run_os_command_mock.called)
-    mode = oct(os.stat(PGConfig.PG_HBA_CONF_FILE)[stat.ST_MODE])
+    self.assertTrue(configure_pg_hba_postgres_user_mock.called)
+    self.assertTrue(configure_pg_hba_ambaridb_users_mock.called)
+    mode = oct(os.stat(ambari_server.PG_HBA_CONF_FILE)[stat.ST_MODE])
     str_mode = str(mode)[-4:]
     self.assertEqual("0644", str_mode, "Wrong file permissions")
     self.assertTrue(configure_postgresql_conf_mock.called)
     self.assertEqual(0, rcode)
 
-    os.unlink(PGConfig.PG_HBA_CONF_FILE_BACKUP)
-
+    os.unlink(ambari_server.PG_HBA_CONF_FILE_BACKUP)
     get_postgre_status_mock.return_value = "stopped", 0, "", ""
-    rcode, out, err = dbConfig._configure_postgres()
+    rcode, out, err = ambari_server.configure_postgres()
     self.assertEqual(0, rcode)
-    os.unlink(PGConfig.PG_HBA_CONF_FILE_BACKUP)
+    os.unlink(ambari_server.PG_HBA_CONF_FILE_BACKUP)
     sys.stdout = sys.__stdout__
 
 
   @patch("time.sleep")
   @patch("subprocess.Popen")
-  @patch("ambari_server.dbConfiguration_linux.run_os_command")
-  @patch("ambari_server.dbConfiguration_linux.PGConfig._get_postgre_status")
-  @patch("ambari_server.dbConfiguration_linux.print_info_msg")
+  @patch.object(ambari_server, "run_os_command")
+  @patch.object(ambari_server, "get_postgre_status")
+  @patch.object(ambari_server, "print_info_msg")
   def test_restart_postgres(self, printInfoMsg_mock, get_postgre_status_mock,
                             run_os_command_mock, popenMock, sleepMock):
     p = MagicMock()
     p.poll.return_value = 0
     popenMock.return_value = p
-    retcode, out, err = PGConfig._restart_postgres()
+    retcode, out, err = ambari_server.restart_postgres()
     self.assertEqual(0, retcode)
 
     p.poll.return_value = None
     get_postgre_status_mock.return_value = "stopped", 0, "", ""
     run_os_command_mock.return_value = (1, None, None)
-    retcode, out, err = PGConfig._restart_postgres()
+    retcode, out, err = ambari_server.restart_postgres()
     self.assertEqual(1, retcode)
 
 
   @patch("shlex.split")
   @patch("subprocess.Popen")
-  @patch("ambari_commons.os_linux.print_info_msg")
+  @patch.object(ambari_server, "print_info_msg")
   def test_run_os_command(self, printInfoMsg_mock, popenMock, splitMock):
 
     p = MagicMock()
@@ -642,283 +605,151 @@ class TestAmbariServer(TestCase):
 
     # with list arg
     cmd = ["exec", "arg"]
-    run_os_command(cmd)
+    ambari_server.run_os_command(cmd)
     self.assertFalse(splitMock.called)
 
     # with str arg
-    resp = run_os_command("runme")
+    resp = ambari_server.run_os_command("runme")
     self.assertEqual(3, resp[0])
     self.assertTrue(splitMock.called)
 
 
-  @patch.object(ambari__server, "get_conf_dir")
-  @patch.object(ambari__server, "search_file")
+  @patch.object(ambari_server, "get_conf_dir")
+  @patch.object(ambari_server, "search_file")
   def test_write_property(self, search_file_mock, get_conf_dir_mock):
 
     expected_content = "key1=val1\n"
 
     tf1 = tempfile.NamedTemporaryFile()
     search_file_mock.return_value = tf1.name
-    ambari__server.write_property("key1", "val1")
+    ambari_server.write_property("key1", "val1")
     result = tf1.read()
     self.assertTrue(expected_content in result)
 
 
-  #TODO Deprecate
-  @patch.object(ambari__server, "configure_database_username_password")
-  @patch.object(ambari__server, 'run_os_command')
-  def test_setup_db_old(self, run_os_command_mock,
+  @patch.object(ambari_server, "configure_database_username_password")
+  @patch.object(ambari_server, "run_os_command")
+  def test_setup_db(self, run_os_command_mock,
                     configure_database_username_password_mock):
 
     run_os_command_mock.return_value = (0, None, None)
-    result = ambari__server.setup_db(MagicMock())
+    result = ambari_server.setup_db(MagicMock())
     self.assertTrue(configure_database_username_password_mock.called)
     self.assertEqual((0, None, None), result)
 
-  #TODO Deprecate
-  @patch.object(ambari__server, "configure_database_username_password")
+  @patch.object(ambari_server, "configure_database_username_password")
   @patch("time.sleep")
-  @patch.object(ambari__server, 'run_os_command')
-  def test_setup_db_connect_attempts_fail_old(self, run_os_command_mock,
+  @patch.object(ambari_server, "run_os_command")
+  def test_setup_db_connect_attempts_fail(self, run_os_command_mock,
                                           sleep_mock, config_db_mock):
     run_os_command_mock.side_effect = [(1, "error", "error"), (1, "error", "error"),
                                        (1, "error", "error")]
-    result = ambari__server.setup_db(MagicMock())
+    result = ambari_server.setup_db(MagicMock())
     self.assertTrue(run_os_command_mock.called)
     self.assertEqual((1, 'error', 'error') , result)
     self.assertEqual(2, sleep_mock.call_count)
     pass
 
-  #TODO Deprecate
-  @patch.object(ambari__server, "configure_database_username_password")
+  @patch.object(ambari_server, "configure_database_username_password")
   @patch("time.sleep")
-  @patch.object(ambari__server, 'run_os_command')
-  def test_setup_db_connect_attempts_success_old(self, run_os_command_mock, sleep_mock,
-                                             config_db_mock):
+  @patch.object(ambari_server, "run_os_command")
+  def test_setup_db_connect_attempts_success(self, run_os_command_mock,
+                                             sleep_mock, config_db_mock):
     run_os_command_mock.side_effect = [(1, "error", "error"), (0, None, None),
                                        (0, None, None)]
-    result = ambari__server.setup_db(MagicMock())
-    self.assertTrue(run_os_command_mock.called)
-    self.assertEqual((0, None, None) , result)
-    self.assertEqual(1, sleep_mock.call_count)
-    pass
-
-
-  @patch.object(OSCheck, "get_os_family")
-  @patch.object(OSCheck, "get_os_type")
-  @patch.object(OSCheck, "get_os_major_version")
-  @patch("time.sleep")
-  @patch("ambari_server.dbConfiguration_linux.run_os_command")
-  def test_setup_db(self, run_os_command_mock, sleep_mock,
-                    get_os_major_version_mock, get_os_type_mock, get_os_family_mock):
-    args = MagicMock()
-    properties = Properties()
-
-    args.dbms_index = 0
-
-    del args.dbms
-    del args.database_host
-    del args.database_port
-    del args.database_name
-    del args.database_username
-    del args.database_password
-    del args.silent
-
-    run_os_command_mock.return_value = (0, None, None)
-
-    factory = DBMSConfigFactory()
-    dbConfig = factory.create(args, properties)
-
-    self.assertTrue(dbConfig.dbms, "postgres")
-    self.assertTrue(dbConfig.persistence_type, "local")
-
-    result = dbConfig._setup_db()
-    self.assertEqual((0, None, None), result)
-
-  @patch.object(OSCheck, "get_os_family")
-  @patch.object(OSCheck, "get_os_type")
-  @patch.object(OSCheck, "get_os_major_version")
-  @patch("time.sleep")
-  @patch("ambari_server.dbConfiguration_linux.run_os_command")
-  def test_setup_db_connect_attempts_fail(self, run_os_command_mock, sleep_mock,
-                                          get_os_major_version_mock, get_os_type_mock, get_os_family_mock):
-    args = MagicMock()
-    properties = Properties()
-
-    args.dbms_index = 0
-
-    del args.dbms
-    del args.database_host
-    del args.database_port
-    del args.database_name
-    del args.database_username
-    del args.database_password
-    del args.silent
-
-    run_os_command_mock.side_effect = [(1, "error", "error"), (1, "error", "error"),
-                                       (1, "error", "error")]
-
-    factory = DBMSConfigFactory()
-    dbConfig = factory.create(args, properties)
-
-    self.assertTrue(dbConfig.dbms, "postgres")
-    self.assertTrue(dbConfig.persistence_type, "local")
-
-    result = dbConfig._setup_db()
-    self.assertTrue(run_os_command_mock.called)
-    self.assertEqual((1, 'error', 'error') , result)
-    self.assertEqual(2, sleep_mock.call_count)
-    pass
-
-  @patch.object(OSCheck, "get_os_family")
-  @patch.object(OSCheck, "get_os_type")
-  @patch.object(OSCheck, "get_os_major_version")
-  @patch("time.sleep")
-  @patch("ambari_server.dbConfiguration_linux.run_os_command")
-  def test_setup_db_connect_attempts_success(self, run_os_command_mock, sleep_mock,
-                                             get_os_major_version_mock, get_os_type_mock, get_os_family_mock):
-    args = MagicMock()
-    properties = Properties()
-
-    args.dbms_index = 0
-
-    del args.dbms
-    del args.database_host
-    del args.database_port
-    del args.database_name
-    del args.database_username
-    del args.database_password
-    del args.silent
-
-    run_os_command_mock.side_effect = [(1, "error", "error"), (0, None, None),
-                                       (0, None, None)]
-
-    factory = DBMSConfigFactory()
-    dbConfig = factory.create(args, properties)
-
-    self.assertTrue(dbConfig.dbms, "postgres")
-    self.assertTrue(dbConfig.persistence_type, "local")
-
-    result = dbConfig._setup_db()
+    result = ambari_server.setup_db(MagicMock())
     self.assertTrue(run_os_command_mock.called)
     self.assertEqual((0, None, None) , result)
     self.assertEqual(1, sleep_mock.call_count)
     pass
 
-  @patch.object(OSCheck, "get_os_family")
-  @patch.object(OSCheck, "get_os_type")
-  @patch.object(OSCheck, "get_os_major_version")
-  @patch("ambari_server.serverSetup.get_YN_input")
-  @patch("ambari_server.serverSetup.run_os_command")
-  def test_disable_security_enhancements(self, run_os_command_mock, getYNInput_mock,
-                                         get_os_major_version_mock, get_os_type_mock, get_os_family_mock):
-    run_os_command_mock.return_value = (0, ambari__server.SE_STATUS_DISABLED,
+  @patch.object(ambari_server, "get_YN_input")
+  @patch.object(ambari_server, "run_os_command")
+  def test_check_selinux(self, run_os_command_mock, getYNInput_mock):
+    run_os_command_mock.return_value = (0, ambari_server.SE_STATUS_DISABLED,
                                         None)
-    (rcode, err) = disable_security_enhancements()
+    rcode = ambari_server.check_selinux()
     self.assertEqual(0, rcode)
 
     getYNInput_mock.return_value = True
     run_os_command_mock.return_value = (0, "enabled "
-                                           + ambari__server.SE_MODE_ENFORCING,
+                                           + ambari_server.SE_MODE_ENFORCING,
                                         None)
-    (rcode, err) = disable_security_enhancements()
+    rcode = ambari_server.check_selinux()
     self.assertEqual(0, rcode)
     self.assertTrue(run_os_command_mock.called)
     self.assertTrue(getYNInput_mock.called)
 
 
-  @patch("ambari_server.serverConfiguration.print_info_msg")
+  @patch.object(ambari_server, "print_info_msg")
   def test_get_ambari_jars(self, printInfoMsg_mock):
 
     env = "/ambari/jars"
-    os.environ[ambari__server.AMBARI_SERVER_LIB] = env
-    result = get_ambari_jars()
+    os.environ[ambari_server.AMBARI_SERVER_LIB] = env
+    result = ambari_server.get_ambari_jars()
     self.assertEqual(env, result)
 
-    del os.environ[ambari__server.AMBARI_SERVER_LIB]
-    result = get_ambari_jars()
+    del os.environ[ambari_server.AMBARI_SERVER_LIB]
+    result = ambari_server.get_ambari_jars()
     self.assertEqual("/usr/lib/ambari-server", result)
     self.assertTrue(printInfoMsg_mock.called)
 
 
   @patch("glob.glob")
-  @patch("ambari_server.serverConfiguration.print_info_msg")
+  @patch.object(ambari_server, "print_info_msg")
   def test_get_share_jars(self, printInfoMsg_mock, globMock):
     globMock.return_value = ["one", "two"]
     expected = "one:two:one:two"
-    result = get_share_jars()
+    result = ambari_server.get_share_jars()
     self.assertEqual(expected, result)
     globMock.return_value = []
     expected = ""
-    result = get_share_jars()
+    result = ambari_server.get_share_jars()
     self.assertEqual(expected, result)
 
 
   @patch("glob.glob")
-  @patch("ambari_server.serverConfiguration.get_ambari_properties")
-  @patch("ambari_server.serverConfiguration.print_info_msg")
-  def test_get_ambari_classpath(self, printInfoMsg_mock, get_ambari_properties_mock, globMock):
-    props = {}
-    props[JDBC_DRIVER_PATH_PROPERTY] = "/driver"
-    get_ambari_properties_mock.return_value = props
+  @patch.object(ambari_server, "print_info_msg")
+  def test_get_ambari_classpath(self, printInfoMsg_mock, globMock):
     globMock.return_value = ["one"]
-    result = get_ambari_classpath()
-    self.assertTrue(get_ambari_jars() in result)
-    self.assertTrue("/driver" in result)
-    self.assertTrue(get_share_jars() in result)
+    result = ambari_server.get_ambari_classpath()
+    self.assertTrue(ambari_server.get_ambari_jars() in result)
+    self.assertTrue(ambari_server.get_share_jars() in result)
     globMock.return_value = []
-    props[JDBC_DRIVER_PATH_PROPERTY] = ""
-    result = get_ambari_classpath()
-    self.assertTrue(get_ambari_jars() in result)
+    result = ambari_server.get_ambari_classpath()
+    self.assertTrue(ambari_server.get_ambari_jars() in result)
     self.assertFalse(":" in result)
 
 
-  @patch("glob.glob")
-  @patch("ambari_server.serverConfiguration.get_ambari_properties")
-  @patch("ambari_server.serverConfiguration.print_info_msg")
-  def test_get_full_ambari_classpath(self, printInfoMsg_mock, get_ambari_properties_mock, globMock):
-    props = {}
-    props[JDBC_DRIVER_PATH_PROPERTY] = "/driver"
-    get_ambari_properties_mock.return_value = props
-    globMock.return_value = ["one"]
-    result = get_full_ambari_classpath()
-    self.assertTrue(get_ambari_jars() in result)
-    self.assertTrue(get_share_jars() in result)
-    props[JDBC_DRIVER_PATH_PROPERTY] = "/driver dir"
-    result = get_full_ambari_classpath()
-    self.assertEqual(result[0], '"')
-    self.assertEqual(result[len(result) - 1], '"')
-
-
-  @patch("ambari_server.serverConfiguration.print_info_msg")
+  @patch.object(ambari_server, "print_info_msg")
   def test_get_conf_dir(self, printInfoMsg_mock):
     env = "/dummy/ambari/conf"
-    os.environ[ambari__server.AMBARI_CONF_VAR] = env
-    result = get_conf_dir()
+    os.environ[ambari_server.AMBARI_CONF_VAR] = env
+    result = ambari_server.get_conf_dir()
     self.assertEqual(env, result)
 
-    del os.environ[ambari__server.AMBARI_CONF_VAR]
-    result = get_conf_dir()
+    del os.environ[ambari_server.AMBARI_CONF_VAR]
+    result = ambari_server.get_conf_dir()
     self.assertEqual("/etc/ambari-server/conf", result)
 
 
   def test_search_file(self):
 
     path = os.path.dirname(__file__)
-    result = search_file(__file__, path)
+    result = ambari_server.search_file(__file__, path)
     expected = os.path.abspath(__file__)
     self.assertEqual(expected, result)
 
-    result = search_file("non_existent_file", path)
+    result = ambari_server.search_file("non_existent_file", path)
     self.assertEqual(None, result)
 
 
-  @patch("ambari_server.serverConfiguration.search_file")
+  @patch.object(ambari_server, "search_file")
   def test_find_properties_file(self, search_file_mock):
     # Testing case when file is not found
     search_file_mock.return_value = None
     try:
-      find_properties_file()
+      ambari_server.find_properties_file()
       self.fail("File not found'")
     except FatalException:
       # Expected
@@ -928,73 +759,71 @@ class TestAmbariServer(TestCase):
     # Testing case when file is found
     value = MagicMock()
     search_file_mock.return_value = value
-    result = find_properties_file()
+    result = ambari_server.find_properties_file()
     self.assertTrue(result is value)
 
 
-  @patch.object(ambari__server, "find_properties_file")
+  @patch.object(ambari_server, "find_properties_file")
   @patch("__builtin__.open")
-  @patch.object(ambari__server, "Properties")
+  @patch("ambari-server.Properties")
   def test_read_ambari_user(self, properties_mock, open_mock, find_properties_file_mock):
     open_mock.return_value = "dummy"
     find_properties_file_mock.return_value = "dummy"
     # Testing with defined user
     properties_mock.return_value.__getitem__.return_value = "dummy_user"
-    user = ambari__server.read_ambari_user()
+    user = ambari_server.read_ambari_user()
     self.assertEquals(user, "dummy_user")
     # Testing with undefined user
     properties_mock.return_value.__getitem__.return_value = None
-    user = ambari__server.read_ambari_user()
+    user = ambari_server.read_ambari_user()
     self.assertEquals(user, None)
 
 
   @patch("os.path.exists")
-  @patch("ambari_server.setupSecurity.set_file_permissions")
-  @patch("ambari_server.setupSecurity.run_os_command")
-  @patch("ambari_server.setupSecurity.get_ambari_properties")
-  @patch("ambari_server.setupSecurity.get_value_from_properties")
-  @patch("shutil.rmtree")
-  @patch("os.makedirs")
-  def test_adjust_directory_permissions(self, mkdir_mock, rmtree_mock,
+  @patch.object(ambari_server, "set_file_permissions")
+  @patch.object(ambari_server, "run_os_command")
+  @patch.object(ambari_server, "get_ambari_properties")
+  @patch.object(ambari_server, "get_value_from_properties")
+  @patch("os.mkdir")
+  def test_adjust_directory_permissions(self, mkdir_mock,
                                         get_value_from_properties_mock, get_ambari_properties_mock,
                                         run_os_command_mock, set_file_permissions_mock, exists_mock):
     # Testing boostrap dir wipe
     properties_mock = MagicMock()
     get_value_from_properties_mock.return_value = "dummy_bootstrap_dir"
-    adjust_directory_permissions("user")
+    ambari_server.adjust_directory_permissions("user")
     exists_mock.return_value = False
-    self.assertTrue(set_file_permissions_mock.called)
-    self.assertTrue(rmtree_mock.called)
+    self.assertEquals(run_os_command_mock.call_args_list[0][0][0], "rm -rf dummy_bootstrap_dir")
     self.assertTrue(mkdir_mock.called)
 
     set_file_permissions_mock.reset_mock()
     # Test recursive calls
-    old_list = configDefaults.NR_ADJUST_OWNERSHIP_LIST
+    old_list = ambari_server.NR_ADJUST_OWNERSHIP_LIST
 
-    configDefaults.NR_ADJUST_OWNERSHIP_LIST = [
+    ambari_server.NR_ADJUST_OWNERSHIP_LIST = [
       ( "/etc/ambari-server/conf", "755", "{0}", True ),
       ( "/etc/ambari-server/conf/ambari.properties", "644", "{0}", False )
     ]
 
-    adjust_directory_permissions("user")
+    ambari_server.adjust_directory_permissions("user")
     self.assertTrue(len(set_file_permissions_mock.call_args_list) ==
-                    len(configDefaults.NR_ADJUST_OWNERSHIP_LIST))
+                    len(ambari_server.NR_ADJUST_OWNERSHIP_LIST))
     self.assertEquals(set_file_permissions_mock.call_args_list[0][0][3], True)
     self.assertEquals(set_file_permissions_mock.call_args_list[1][0][3], False)
 
-    configDefaults.NR_ADJUST_OWNERSHIP_LIST = old_list
+    ambari_server.NR_ADJUST_OWNERSHIP_LIST = old_list
 
 
   @patch("os.path.exists")
-  @patch("ambari_commons.os_linux.os_run_os_command")
-  @patch("ambari_commons.os_linux.print_warning_msg")
-  @patch("ambari_commons.os_utils.print_info_msg")
+  @patch.object(ambari_server, "run_os_command")
+  @patch.object(ambari_server, "print_warning_msg")
+  @patch.object(ambari_server, "print_info_msg")
   def test_set_file_permissions(self, print_info_msg_mock, print_warning_msg_mock,
                                 run_os_command_mock, exists_mock):
 
     # Testing not existent file scenario
     exists_mock.return_value = False
-    set_file_permissions("dummy-file", "dummy-mod",
+    ambari_server.set_file_permissions("dummy-file", "dummy-mod",
                                        "dummy-user", False)
     self.assertFalse(run_os_command_mock.called)
     self.assertTrue(print_info_msg_mock.called)
@@ -1005,7 +834,7 @@ class TestAmbariServer(TestCase):
     # Testing OK scenario
     exists_mock.return_value = True
     run_os_command_mock.side_effect = [(0, "", ""), (0, "", "")]
-    set_file_permissions("dummy-file", "dummy-mod",
+    ambari_server.set_file_permissions("dummy-file", "dummy-mod",
                                        "dummy-user", False)
     self.assertTrue(len(run_os_command_mock.call_args_list) == 2)
     self.assertFalse(print_warning_msg_mock.called)
@@ -1015,7 +844,7 @@ class TestAmbariServer(TestCase):
 
     # Testing first command fail
     run_os_command_mock.side_effect = [(1, "", ""), (0, "", "")]
-    set_file_permissions("dummy-file", "dummy-mod",
+    ambari_server.set_file_permissions("dummy-file", "dummy-mod",
                                        "dummy-user", False)
     self.assertTrue(len(run_os_command_mock.call_args_list) == 2)
     self.assertTrue(print_warning_msg_mock.called)
@@ -1025,7 +854,7 @@ class TestAmbariServer(TestCase):
 
     # Testing second command fail
     run_os_command_mock.side_effect = [(0, "", ""), (1, "", "")]
-    set_file_permissions("dummy-file", "dummy-mod",
+    ambari_server.set_file_permissions("dummy-file", "dummy-mod",
                                        "dummy-user", False)
     self.assertTrue(len(run_os_command_mock.call_args_list) == 2)
     self.assertTrue(print_warning_msg_mock.called)
@@ -1037,7 +866,7 @@ class TestAmbariServer(TestCase):
 
     exists_mock.return_value = True
     run_os_command_mock.side_effect = [(0, "", ""), (0, "", "")]
-    set_file_permissions("dummy-file", "dummy-mod",
+    ambari_server.set_file_permissions("dummy-file", "dummy-mod",
                                        "dummy-user", True)
     self.assertTrue(len(run_os_command_mock.call_args_list) == 2)
     self.assertTrue("-R" in run_os_command_mock.call_args_list[0][0][0])
@@ -1051,7 +880,7 @@ class TestAmbariServer(TestCase):
 
     exists_mock.return_value = True
     run_os_command_mock.side_effect = [(0, "", ""), (0, "", "")]
-    set_file_permissions("dummy-file", "dummy-mod",
+    ambari_server.set_file_permissions("dummy-file", "dummy-mod",
                                        "dummy-user", False)
     self.assertTrue(len(run_os_command_mock.call_args_list) == 2)
     self.assertFalse("-R" in run_os_command_mock.call_args_list[0][0][0])
@@ -1062,24 +891,18 @@ class TestAmbariServer(TestCase):
     print_warning_msg_mock.reset_mock()
 
 
-  @patch.object(OSCheck, "get_os_family")
-  @patch.object(OSCheck, "get_os_type")
-  @patch.object(OSCheck, "get_os_major_version")
-  @patch("ambari_server.serverSetup.get_validated_string_input")
-  @patch("ambari_server.serverSetup.print_info_msg")
-  @patch("ambari_server.serverSetup.print_warning_msg")
-  @patch("ambari_server.serverSetup.run_os_command")
+  @patch.object(ambari_server, "get_validated_string_input")
+  @patch.object(ambari_server, "print_info_msg")
+  @patch.object(ambari_server, "print_warning_msg")
+  @patch.object(ambari_server, "run_os_command")
   def test_create_custom_user(self, run_os_command_mock, print_warning_msg_mock,
-                              print_info_msg_mock, get_validated_string_input_mock,
-                              get_os_major_version_mock, get_os_type_mock, get_os_family_mock):
+                              print_info_msg_mock, get_validated_string_input_mock):
     user = "dummy-user"
     get_validated_string_input_mock.return_value = user
 
-    checks = AmbariUserChecks()
-
     # Testing scenario: absent user
     run_os_command_mock.side_effect = [(0, "", "")]
-    result = checks._create_custom_user()
+    result = ambari_server.create_custom_user()
     self.assertFalse(print_warning_msg_mock.called)
     self.assertEquals(result, (0, user))
 
@@ -1089,7 +912,7 @@ class TestAmbariServer(TestCase):
 
     # Testing scenario: existing user
     run_os_command_mock.side_effect = [(9, "", "")]
-    result = checks._create_custom_user()
+    result = ambari_server.create_custom_user()
     self.assertTrue("User dummy-user already exists" in str(print_info_msg_mock.call_args_list[1][0]))
     self.assertEquals(result, (0, user))
 
@@ -1099,29 +922,25 @@ class TestAmbariServer(TestCase):
 
     # Testing scenario: os command fail
     run_os_command_mock.side_effect = [(1, "", "")]
-    result = checks._create_custom_user()
+    result = ambari_server.create_custom_user()
     self.assertTrue(print_warning_msg_mock.called)
     self.assertEquals(result, (1, None))
 
 
-  @patch.object(OSCheck, "get_os_family")
-  @patch.object(OSCheck, "get_os_type")
-  @patch.object(OSCheck, "get_os_major_version")
-  @patch("ambari_server.serverSetup.read_ambari_user")
-  @patch("ambari_server.serverSetup.get_YN_input")
-  @patch("ambari_server.serverSetup.AmbariUserChecksLinux._create_custom_user")
-  @patch("ambari_server.serverSetup.write_property")
-  @patch("ambari_server.serverSetup.adjust_directory_permissions")
-  @patch("ambari_server.serverSetup.print_error_msg")
+  @patch.object(ambari_server, "read_ambari_user")
+  @patch.object(ambari_server, "get_YN_input")
+  @patch.object(ambari_server, "create_custom_user")
+  @patch.object(ambari_server, "write_property")
+  @patch.object(ambari_server, "adjust_directory_permissions")
+  @patch.object(ambari_server, "print_error_msg")
   def test_check_ambari_user(self, print_error_msg_mock,
                              adjust_directory_permissions_mock, write_property_mock,
-                             create_custom_user_mock, get_YN_input_mock, read_ambari_user_mock,
-                             get_os_major_version_mock, get_os_type_mock, get_os_family_mock):
+                             create_custom_user_mock, get_YN_input_mock, read_ambari_user_mock):
 
     # Scenario: user is already defined, user does not want to reconfigure it
     read_ambari_user_mock.return_value = "dummy-user"
     get_YN_input_mock.return_value = False
-    result = check_ambari_user()
+    result = ambari_server.check_ambari_user()
     self.assertTrue(get_YN_input_mock.called)
     self.assertFalse(write_property_mock.called)
     self.assertFalse(create_custom_user_mock.called)
@@ -1138,7 +957,7 @@ class TestAmbariServer(TestCase):
     read_ambari_user_mock.return_value = "dummy-user"
     create_custom_user_mock.return_value = (0, "new-dummy-user")
     get_YN_input_mock.return_value = True
-    result = check_ambari_user()
+    result = ambari_server.check_ambari_user()
     self.assertTrue(get_YN_input_mock.called)
     self.assertTrue(write_property_mock.called)
     self.assertTrue(write_property_mock.call_args[0][1] == "new-dummy-user")
@@ -1157,7 +976,7 @@ class TestAmbariServer(TestCase):
     read_ambari_user_mock.return_value = "dummy-user"
     create_custom_user_mock.return_value = (1, None)
     get_YN_input_mock.return_value = True
-    result = check_ambari_user()
+    result = ambari_server.check_ambari_user()
     self.assertTrue(get_YN_input_mock.called)
     self.assertTrue(create_custom_user_mock.called)
     self.assertFalse(write_property_mock.called)
@@ -1173,7 +992,7 @@ class TestAmbariServer(TestCase):
     read_ambari_user_mock.return_value = None
     get_YN_input_mock.return_value = True
     create_custom_user_mock.return_value = (0, "dummy-user")
-    result = check_ambari_user()
+    result = ambari_server.check_ambari_user()
     self.assertTrue(get_YN_input_mock.called)
     self.assertTrue(create_custom_user_mock.called)
     self.assertTrue(write_property_mock.called)
@@ -1191,7 +1010,7 @@ class TestAmbariServer(TestCase):
     read_ambari_user_mock.return_value = None
     get_YN_input_mock.return_value = True
     create_custom_user_mock.return_value = (1, None)
-    result = check_ambari_user()
+    result = ambari_server.check_ambari_user()
     self.assertTrue(get_YN_input_mock.called)
     self.assertTrue(create_custom_user_mock.called)
     self.assertFalse(write_property_mock.called)
@@ -1208,7 +1027,7 @@ class TestAmbariServer(TestCase):
     read_ambari_user_mock.return_value = None
     get_YN_input_mock.return_value = True
     create_custom_user_mock.return_value = (1, None)
-    result = check_ambari_user()
+    result = ambari_server.check_ambari_user()
     self.assertTrue(get_YN_input_mock.called)
     self.assertTrue(create_custom_user_mock.called)
     self.assertFalse(write_property_mock.called)
@@ -1223,7 +1042,7 @@ class TestAmbariServer(TestCase):
     # Scenario: user is not defined and left to be root
     read_ambari_user_mock.return_value = None
     get_YN_input_mock.return_value = False
-    result = check_ambari_user()
+    result = ambari_server.check_ambari_user()
     self.assertTrue(get_YN_input_mock.called)
     self.assertFalse(create_custom_user_mock.called)
     self.assertTrue(write_property_mock.called)
@@ -1232,15 +1051,15 @@ class TestAmbariServer(TestCase):
     self.assertEqual(result, 0)
 
 
+  @patch.object(ambari_server, "search_file")
   @patch("__builtin__.open")
-  @patch.object(ambari__server, "search_file")
-  @patch.object(ambari__server, "set_file_permissions")
-  @patch.object(ambari__server, "read_ambari_user")
-  def test_store_password_file(self, read_ambari_user_mock, set_file_permissions_mock,
-                               search_file_mock, open_mock):
+  @patch.object(ambari_server, "read_ambari_user")
+  @patch.object(ambari_server, "set_file_permissions")
+  def test_store_password_file(self, set_file_permissions_mock,
+                               read_ambari_user_mock, open_mock, search_file_mock):
     search_file_mock.return_value = "/etc/ambari-server/conf/ambari.properties"
     open_mock.return_value = MagicMock()
-    ambari__server.store_password_file("password", "passfile")
+    ambari_server.store_password_file("password", "passfile")
     self.assertTrue(set_file_permissions_mock.called)
 
   @patch("subprocess.Popen")
@@ -1305,36 +1124,23 @@ class TestAmbariServer(TestCase):
     self.assertFalse(firewall_obj.check_iptables())
     self.assertEqual("err", firewall_obj.stderrdata)
 
-  def test_download_progress(self):
+
+  def test_dlprogress(self):
 
     out = StringIO.StringIO()
     sys.stdout = out
-    download_progress("filename", 10, 2, 100)
+    ambari_server.dlprogress("filename", 10, 2, 100)
     sys.stdout = sys.__stdout__
     self.assertNotEqual("", out.getvalue())
 
 
-  @patch("os.makedirs")
-  @patch("os.path.exists")
-  @patch("os.rename")
-  @patch("os.stat")
   @patch("urllib2.urlopen")
   @patch("__builtin__.open")
-  @patch("ambari_commons.inet_utils.download_progress")
-  @patch("ambari_commons.inet_utils.print_info_msg")
-  def test_track_jdk(self, print_info_msg_mock, download_progress_mock, openMock,
-                     urlopenMock, os_stat_mock, os_rename_mock, os_path_exists_mock, os_makedirs_mock):
-    os_path_exists_mock.return_value = False
-
-    fsize = MagicMock()
-    fsize.st_size = 24576
-    os_stat_mock.return_value = fsize
-
-    inf = MagicMock()
-    inf.getheaders.return_value = ["bytes 0-24575/24576"]
+  @patch.object(ambari_server, "dlprogress")
+  def test_track_jdk(self, dlprogress_mock, openMock, urlopenMock):
 
     u = MagicMock()
-    u.info.return_value = inf
+    u.info.return_value = {"Content-Length": "24576"}
     chunks = [None, "second", "first"]
 
     def side_effect(*args, **kwargs):
@@ -1346,19 +1152,19 @@ class TestAmbariServer(TestCase):
     f = MagicMock()
     openMock.return_value = f
 
-    force_download_file("base", "url", progress_func=download_progress_mock)
+    ambari_server.track_jdk("base", "url", "local")
 
     self.assertEqual(0, len(chunks))
     self.assertTrue(f.write.called)
+    self.assertTrue(f.flush.called)
     self.assertTrue(f.close.called)
-    self.assertEqual(2, len(download_progress_mock.call_args_list))
-    self.assertTrue(print_info_msg_mock.called)
+    self.assertEqual(2, len(dlprogress_mock.call_args_list))
 
   @patch("shutil.copy")
   @patch("os.path.join")
   @patch("os.path.exists")
   @patch("os.path.isdir")
-  @patch.object(ambari__server, "get_ambari_properties")
+  @patch.object(ambari_server, "get_ambari_properties")
   def test_install_jce_manualy(self, get_ambari_properties_mock, \
                                os_path_isdir_mock, os_path_exists_mock, os_path_join_mock, \
                                shutil_copy_mock):
@@ -1372,7 +1178,7 @@ class TestAmbariServer(TestCase):
     # Case when JCE path doesn't exists
     os_path_exists_mock.return_value = False
     try:
-      ambari__server.install_jce_manualy(args)
+      ambari_server.install_jce_manualy(args)
       self.fail("Should throw exception")
     except FatalException as fe:
       # Expected
@@ -1384,7 +1190,7 @@ class TestAmbariServer(TestCase):
     os_path_exists_mock.return_value = True
     os_path_isdir_mock.return_value = True
     try:
-      ambari__server.install_jce_manualy(args)
+      ambari_server.install_jce_manualy(args)
       self.fail("Should throw exception")
     except FatalException as fe:
       # Expected
@@ -1395,12 +1201,12 @@ class TestAmbariServer(TestCase):
     os_path_isdir_mock.return_value = False
     os_path_join_mock.return_value = \
       "/var/lib/ambari-server/resources/jce_policy-6.zip"
-    ambari__server.install_jce_manualy(args)
+    ambari_server.install_jce_manualy(args)
     self.assertTrue(shutil_copy_mock.called)
 
     shutil_copy_mock.side_effect = Exception("exception")
     try:
-      ambari__server.install_jce_manualy(args)
+      ambari_server.install_jce_manualy(args)
       self.fail("Should throw exception because of not found jce_policy-6.zip")
     except Exception:
     # Expected
@@ -1409,20 +1215,20 @@ class TestAmbariServer(TestCase):
 
     shutil_copy_mock.side_effect = None
     args.jce_policy = None
-    ambari__server.install_jce_manualy(args)
+    ambari_server.install_jce_manualy(args)
 
-  @patch.object(ambari__server, "get_validated_filepath_input")
-  @patch.object(ambari__server, 'run_os_command')
-  @patch.object(ambari__server, "get_truststore_type")
+  @patch.object(ambari_server, "get_validated_filepath_input")
+  @patch.object(ambari_server, "run_os_command")
+  @patch.object(ambari_server, "get_truststore_type")
   @patch("__builtin__.open")
-  @patch.object(ambari__server, "find_properties_file")
-  @patch.object(ambari__server, "run_component_https_cmd")
-  @patch.object(ambari__server, "get_delete_cert_command")
-  @patch.object(ambari__server, "get_truststore_password")
-  @patch.object(ambari__server, "get_truststore_path")
-  @patch.object(ambari__server, "get_YN_input")
-  @patch.object(ambari__server, "get_ambari_properties")
-  @patch.object(ambari__server, "find_jdk")
+  @patch.object(ambari_server, "find_properties_file")
+  @patch.object(ambari_server, "run_component_https_cmd")
+  @patch.object(ambari_server, "get_delete_cert_command")
+  @patch.object(ambari_server, "get_truststore_password")
+  @patch.object(ambari_server, "get_truststore_path")
+  @patch.object(ambari_server, "get_YN_input")
+  @patch.object(ambari_server, "get_ambari_properties")
+  @patch.object(ambari_server, "find_jdk")
   def test_setup_component_https(self, find_jdk_mock, get_ambari_properties_mock, get_YN_input_mock,
                                  get_truststore_path_mock, get_truststore_password_mock,
                                  get_delete_cert_command_mock, run_component_https_cmd_mock,
@@ -1436,18 +1242,18 @@ class TestAmbariServer(TestCase):
     property = "use_ssl"
     alias = "alias"
     #Silent mode
-    ambari__server.SILENT = True
-    ambari__server.setup_component_https(component, command, property, alias)
+    ambari_server.SILENT = True
+    ambari_server.setup_component_https(component, command, property, alias)
     self.assertEqual('command is not enabled in silent mode.\n', out.getvalue())
     sys.stdout = sys.__stdout__
     #Verbouse mode and jdk_path is None
-    ambari__server.SILENT = False
+    ambari_server.SILENT = False
     p = get_ambari_properties_mock.return_value
     # Use ssl
     p.get_property.side_effect = ["true"]
     # Dont disable ssl
     get_YN_input_mock.side_effect = [False]
-    ambari__server.setup_component_https(component, command, property, alias)
+    ambari_server.setup_component_https(component, command, property, alias)
     self.assertTrue(p.get_property.called)
     self.assertTrue(get_YN_input_mock.called)
     p.get_property.reset_mock()
@@ -1456,7 +1262,7 @@ class TestAmbariServer(TestCase):
     p.get_property.side_effect = ["false"]
     # Dont enable ssl
     get_YN_input_mock.side_effect = [False]
-    ambari__server.setup_component_https(component, command, property, alias)
+    ambari_server.setup_component_https(component, command, property, alias)
     self.assertTrue(p.get_property.called)
     self.assertTrue(get_YN_input_mock.called)
     p.get_property.reset_mock()
@@ -1464,7 +1270,7 @@ class TestAmbariServer(TestCase):
     # Cant find jdk
     find_jdk_mock.return_value = None
     try:
-        ambari__server.setup_component_https(component, command, property, alias)
+        ambari_server.setup_component_https(component, command, property, alias)
         self.fail("Should throw exception")
     except FatalException as fe:
         # Expected
@@ -1478,7 +1284,7 @@ class TestAmbariServer(TestCase):
     get_truststore_path_mock.return_value = "/truststore_path"
     get_truststore_password_mock.return_value = "/truststore_password"
     get_delete_cert_command_mock.return_value = "rm -f"
-    ambari__server.setup_component_https(component, command, property, alias)
+    ambari_server.setup_component_https(component, command, property, alias)
 
     self.assertTrue(p.process_pair.called)
     self.assertTrue(get_truststore_path_mock.called)
@@ -1499,7 +1305,7 @@ class TestAmbariServer(TestCase):
     #Verbouse mode and jdk_path is not None (use_https = false) and import cert
     p.get_property.side_effect = ["false"]
     get_YN_input_mock.side_effect = [True]
-    ambari__server.setup_component_https(component, command, property, alias)
+    ambari_server.setup_component_https(component, command, property, alias)
 
     self.assertTrue(p.process_pair.called)
     self.assertTrue(get_truststore_type_mock.called)
@@ -1524,19 +1330,19 @@ class TestAmbariServer(TestCase):
     run_os_command_mock.reset_mock()
     get_validated_filepath_input_mock.reset_mock()
 
-  @patch.object(ambari__server, "adjust_directory_permissions")
-  @patch.object(ambari__server, "read_ambari_user")
-  @patch.object(ambari__server, "get_validated_string_input")
-  @patch.object(ambari__server, "find_properties_file")
-  @patch.object(ambari__server, "get_ambari_properties")
-  @patch.object(ambari__server, "is_server_runing")
-  @patch.object(ambari__server, "import_cert_and_key_action")
-  @patch.object(ambari__server, "get_YN_input")
+  @patch.object(ambari_server, 'adjust_directory_permissions')
+  @patch.object(ambari_server, 'read_ambari_user')
+  @patch.object(ambari_server, "get_validated_string_input")
+  @patch.object(ambari_server, "find_properties_file")
+  @patch.object(ambari_server, "get_ambari_properties")
+  @patch.object(ambari_server, "is_server_runing")
+  @patch.object(ambari_server, "import_cert_and_key_action")
+  @patch.object(ambari_server, "get_YN_input")
   @patch("__builtin__.open")
-  @patch("ambari_server.properties.Properties")
-  @patch.object(ambari__server, "is_root")
-  @patch.object(ambari__server, "is_valid_cert_host")
-  @patch.object(ambari__server, "is_valid_cert_exp")
+  @patch("ambari-server.Properties")
+  @patch.object(ambari_server, "is_root")
+  @patch.object(ambari_server, "is_valid_cert_host")
+  @patch.object(ambari_server, "is_valid_cert_exp")
   def test_setup_https(self, is_valid_cert_exp_mock, is_valid_cert_host_mock, \
                        is_root_mock, Properties_mock, open_Mock, get_YN_input_mock, \
                        import_cert_and_key_action_mock,
@@ -1554,7 +1360,7 @@ class TestAmbariServer(TestCase):
     # Testing call under non-root
     is_root_mock.return_value = False
     try:
-      ambari__server.setup_https(args)
+      ambari_server.setup_https(args)
       self.fail("Should throw exception")
     except FatalException as fe:
       # Expected
@@ -1573,8 +1379,8 @@ class TestAmbariServer(TestCase):
                             " call('client.api.ssl.port'),\n" + \
                             " call('client.api.ssl.port'),\n call('api.ssl')]"
     process_pair_expected = "[call('client.api.ssl.port', '4444')]"
-    ambari__server.SILENT = False
-    ambari__server.setup_https(args)
+    ambari_server.SILENT = False
+    ambari_server.setup_https(args)
 
     self.assertTrue(p.process_pair.called)
     self.assertTrue(p.get_property.call_count == 4)
@@ -1595,7 +1401,7 @@ class TestAmbariServer(TestCase):
     get_property_expected = "[call('security.server.keys_dir'),\n" + \
                             " call('client.api.ssl.port'),\n call('api.ssl')]"
     process_pair_expected = "[call('api.ssl', 'false')]"
-    ambari__server.setup_https(args)
+    ambari_server.setup_https(args)
 
     self.assertTrue(p.process_pair.called)
     self.assertTrue(p.get_property.call_count == 3)
@@ -1617,7 +1423,7 @@ class TestAmbariServer(TestCase):
     get_property_expected = "[call('security.server.keys_dir'),\n" + \
                             " call('client.api.ssl.port'),\n call('api.ssl')]"
     process_pair_expected = "[call('client.api.ssl.port', '4444')]"
-    ambari__server.setup_https(args)
+    ambari_server.setup_https(args)
 
     self.assertTrue(p.process_pair.called)
     self.assertTrue(p.get_property.call_count == 3)
@@ -1639,7 +1445,7 @@ class TestAmbariServer(TestCase):
     get_property_expected = "[call('security.server.keys_dir'),\n" + \
                             " call('client.api.ssl.port'),\n call('api.ssl')]"
     process_pair_expected = "[]"
-    ambari__server.setup_https(args)
+    ambari_server.setup_https(args)
 
     self.assertFalse(p.process_pair.called)
     self.assertTrue(p.get_property.call_count == 3)
@@ -1661,7 +1467,7 @@ class TestAmbariServer(TestCase):
     get_property_expected = "[call('security.server.keys_dir'),\n" + \
                             " call('client.api.ssl.port'),\n call('api.ssl')]"
     process_pair_expected = "[call('client.api.ssl.port', '4444')]"
-    self.assertFalse(ambari__server.setup_https(args))
+    self.assertFalse(ambari_server.setup_https(args))
     self.assertTrue(p.process_pair.called)
     self.assertTrue(p.get_property.call_count == 3)
     self.assertEqual(str(p.get_property.call_args_list), get_property_expected)
@@ -1675,9 +1481,9 @@ class TestAmbariServer(TestCase):
     import_cert_and_key_action_mock.reset_mock()
 
     #Case #6: if silent mode is enabled
-    ambari__server.SILENT = True
+    ambari_server.SILENT = True
     try:
-      ambari__server.setup_https(args)
+      ambari_server.setup_https(args)
       self.fail("Should throw exception")
     except NonFatalException as fe:
       self.assertTrue("setup-https is not enabled in silent mode" in fe.reason)
@@ -1688,18 +1494,18 @@ class TestAmbariServer(TestCase):
     import_cert_and_key_action_mock.reset_mock()
 
     #Case #7: read property throw exception
-    ambari__server.SILENT = False
+    ambari_server.SILENT = False
     find_properties_file_mock.return_value = "propertyFile"
     p.get_property.side_effect = KeyError("Failed to read property")
     try:
-        ambari__server.setup_https(args)
+        ambari_server.setup_https(args)
         self.fail("Should throw exception")
     except FatalException as fe:
         self.assertTrue("Failed to read property" in fe.reason)
 
 
 
-  @patch.object(ambari__server, "import_cert_and_key")
+  @patch.object(ambari_server, "import_cert_and_key")
   def test_import_cert_and_key_action(self, import_cert_and_key_mock):
     import_cert_and_key_mock.return_value = True
     properties = MagicMock()
@@ -1708,24 +1514,24 @@ class TestAmbariServer(TestCase):
     expect_process_pair = "[call('client.api.ssl.cert_name', 'https.crt'),\n" + \
                           " call('client.api.ssl.key_name', 'https.key'),\n" + \
                           " call('api.ssl', 'true')]"
-    ambari__server.import_cert_and_key_action("key_dir", properties)
+    ambari_server.import_cert_and_key_action("key_dir", properties)
 
     self.assertEqual(str(properties.process_pair.call_args_list), \
                      expect_process_pair)
 
-  @patch.object(ambari__server, "remove_file")
-  @patch.object(ambari__server, "copy_file")
-  @patch.object(ambari__server, "read_ambari_user")
-  @patch.object(ambari__server, "set_file_permissions")
-  @patch.object(ambari__server, "import_file_to_keystore")
+  @patch.object(ambari_server, "remove_file")
+  @patch.object(ambari_server, "copy_file")
+  @patch.object(ambari_server, "read_ambari_user")
+  @patch.object(ambari_server, "set_file_permissions")
+  @patch.object(ambari_server, "import_file_to_keystore")
   @patch("__builtin__.open")
-  @patch.object(ambari__server, 'run_os_command')
+  @patch.object(ambari_server, "run_os_command")
   @patch("os.path.join")
   @patch("os.path.isfile")
   @patch('__builtin__.raw_input')
-  @patch.object(ambari__server, "get_validated_string_input")
-  @patch.object(ambari__server, "is_valid_cert_host")
-  @patch.object(ambari__server, "is_valid_cert_exp")
+  @patch.object(ambari_server, "get_validated_string_input")
+  @patch.object(ambari_server, "is_valid_cert_host")
+  @patch.object(ambari_server, "is_valid_cert_exp")
   def test_import_cert_and_key(self, is_valid_cert_exp_mock, \
                                is_valid_cert_host_mock, \
                                get_validated_string_input_mock, \
@@ -1757,7 +1563,7 @@ class TestAmbariServer(TestCase):
                                      " call('key_file_path'," + \
                                      " 'keystore_cert_key_file_path')]"
 
-    ambari__server.import_cert_and_key("key_dir")
+    ambari_server.import_cert_and_key("key_dir")
     self.assertTrue(raw_input_mock.call_count == 2)
     self.assertTrue(get_validated_string_input_mock.called)
     self.assertEqual(os_path_join_mock.call_count, 8)
@@ -1765,19 +1571,19 @@ class TestAmbariServer(TestCase):
     self.assertEqual(str(import_file_to_keystore_mock.call_args_list), \
                      expect_import_file_to_keystore)
 
-  @patch.object(ambari__server, "remove_file")
-  @patch.object(ambari__server, "copy_file")
-  @patch.object(ambari__server, "generate_random_string")
-  @patch.object(ambari__server, "read_ambari_user")
-  @patch.object(ambari__server, "set_file_permissions")
-  @patch.object(ambari__server, "import_file_to_keystore")
+  @patch.object(ambari_server, "remove_file")
+  @patch.object(ambari_server, "copy_file")
+  @patch.object(ambari_server, "generate_random_string")
+  @patch.object(ambari_server, "read_ambari_user")
+  @patch.object(ambari_server, "set_file_permissions")
+  @patch.object(ambari_server, "import_file_to_keystore")
   @patch("__builtin__.open")
-  @patch.object(ambari__server, 'run_os_command')
+  @patch.object(ambari_server, "run_os_command")
   @patch("os.path.join")
-  @patch.object(ambari__server, "get_validated_filepath_input")
-  @patch.object(ambari__server, "get_validated_string_input")
-  @patch.object(ambari__server, "is_valid_cert_host")
-  @patch.object(ambari__server, "is_valid_cert_exp")
+  @patch.object(ambari_server, "get_validated_filepath_input")
+  @patch.object(ambari_server, "get_validated_string_input")
+  @patch.object(ambari_server, "is_valid_cert_host")
+  @patch.object(ambari_server, "is_valid_cert_exp")
   def test_import_cert_and_key_with_empty_password(self, \
                                                    is_valid_cert_exp_mock, is_valid_cert_host_mock,
                                                    get_validated_string_input_mock, get_validated_filepath_input_mock, \
@@ -1807,7 +1613,7 @@ class TestAmbariServer(TestCase):
                                      " call('key_file_path.secured'," + \
                                      " 'keystore_cert_key_file_path')]"
 
-    ambari__server.import_cert_and_key("key_dir")
+    ambari_server.import_cert_and_key("key_dir")
     self.assertEquals(get_validated_filepath_input_mock.call_count, 2)
     self.assertTrue(get_validated_string_input_mock.called)
     self.assertEquals(os_path_join_mock.call_count, 8)
@@ -1817,15 +1623,15 @@ class TestAmbariServer(TestCase):
     self.assertTrue(generate_random_string_mock.called)
 
   @patch("__builtin__.open")
-  @patch.object(ambari__server, "copy_file")
-  @patch.object(ambari__server, "is_root")
-  @patch.object(ambari__server, "read_ambari_user")
-  @patch.object(ambari__server, "set_file_permissions")
-  @patch.object(ambari__server, "import_file_to_keystore")
-  @patch.object(ambari__server, 'run_os_command')
+  @patch.object(ambari_server, "copy_file")
+  @patch.object(ambari_server, "is_root")
+  @patch.object(ambari_server, "read_ambari_user")
+  @patch.object(ambari_server, "set_file_permissions")
+  @patch.object(ambari_server, "import_file_to_keystore")
+  @patch.object(ambari_server, "run_os_command")
   @patch("os.path.join")
-  @patch.object(ambari__server, "get_validated_filepath_input")
-  @patch.object(ambari__server, "get_validated_string_input")
+  @patch.object(ambari_server, "get_validated_filepath_input")
+  @patch.object(ambari_server, "get_validated_string_input")
   def test_import_cert_and_key_with_incorrect_password(self,
                                                        get_validated_string_input_mock, \
                                                        get_validated_filepath_input_mock, \
@@ -1848,110 +1654,110 @@ class TestAmbariServer(TestCase):
     #provided password doesn't match, openssl command returns an error
     run_os_command_mock.return_value = (1, "", "Some error message")
 
-    self.assertFalse(ambari__server.import_cert_and_key_action(*["key_dir", None]))
-    self.assertFalse(ambari__server.import_cert_and_key("key_dir"))
+    self.assertFalse(ambari_server.import_cert_and_key_action(*["key_dir", None]))
+    self.assertFalse(ambari_server.import_cert_and_key("key_dir"))
 
   def test_is_valid_cert_exp(self):
 
     #No data in certInfo
     certInfo = {}
-    is_valid = ambari__server.is_valid_cert_exp(certInfo)
+    is_valid = ambari_server.is_valid_cert_exp(certInfo)
     self.assertFalse(is_valid)
 
     #Issued in future
-    issuedOn = (datetime.datetime.now() + datetime.timedelta(hours=1000)).strftime(ambari__server.SSL_DATE_FORMAT)
-    expiresOn = (datetime.datetime.now() + datetime.timedelta(hours=2000)).strftime(ambari__server.SSL_DATE_FORMAT)
-    certInfo = {ambari__server.NOT_BEFORE_ATTR: issuedOn,
-                ambari__server.NOT_AFTER_ATTR: expiresOn}
-    is_valid = ambari__server.is_valid_cert_exp(certInfo)
+    issuedOn = (datetime.datetime.now() + datetime.timedelta(hours=1000)).strftime(ambari_server.SSL_DATE_FORMAT)
+    expiresOn = (datetime.datetime.now() + datetime.timedelta(hours=2000)).strftime(ambari_server.SSL_DATE_FORMAT)
+    certInfo = {ambari_server.NOT_BEFORE_ATTR: issuedOn,
+                ambari_server.NOT_AFTER_ATTR: expiresOn}
+    is_valid = ambari_server.is_valid_cert_exp(certInfo)
     self.assertFalse(is_valid)
 
     #Was expired
-    issuedOn = (datetime.datetime.now() - datetime.timedelta(hours=2000)).strftime(ambari__server.SSL_DATE_FORMAT)
-    expiresOn = (datetime.datetime.now() - datetime.timedelta(hours=1000)).strftime(ambari__server.SSL_DATE_FORMAT)
-    certInfo = {ambari__server.NOT_BEFORE_ATTR: issuedOn,
-                ambari__server.NOT_AFTER_ATTR: expiresOn}
-    is_valid = ambari__server.is_valid_cert_exp(certInfo)
+    issuedOn = (datetime.datetime.now() - datetime.timedelta(hours=2000)).strftime(ambari_server.SSL_DATE_FORMAT)
+    expiresOn = (datetime.datetime.now() - datetime.timedelta(hours=1000)).strftime(ambari_server.SSL_DATE_FORMAT)
+    certInfo = {ambari_server.NOT_BEFORE_ATTR: issuedOn,
+                ambari_server.NOT_AFTER_ATTR: expiresOn}
+    is_valid = ambari_server.is_valid_cert_exp(certInfo)
     self.assertFalse(is_valid)
 
     #Valid
-    issuedOn = (datetime.datetime.now() - datetime.timedelta(hours=2000)).strftime(ambari__server.SSL_DATE_FORMAT)
-    expiresOn = (datetime.datetime.now() + datetime.timedelta(hours=1000)).strftime(ambari__server.SSL_DATE_FORMAT)
-    certInfo = {ambari__server.NOT_BEFORE_ATTR: issuedOn,
-                ambari__server.NOT_AFTER_ATTR: expiresOn}
-    is_valid = ambari__server.is_valid_cert_exp(certInfo)
+    issuedOn = (datetime.datetime.now() - datetime.timedelta(hours=2000)).strftime(ambari_server.SSL_DATE_FORMAT)
+    expiresOn = (datetime.datetime.now() + datetime.timedelta(hours=1000)).strftime(ambari_server.SSL_DATE_FORMAT)
+    certInfo = {ambari_server.NOT_BEFORE_ATTR: issuedOn,
+                ambari_server.NOT_AFTER_ATTR: expiresOn}
+    is_valid = ambari_server.is_valid_cert_exp(certInfo)
     self.assertTrue(is_valid)
 
-  @patch.object(ambari__server, "get_fqdn")
+  @patch.object(ambari_server, "get_fqdn")
   def test_is_valid_cert_host(self, get_fqdn_mock):
 
     #No data in certInfo
     certInfo = {}
-    is_valid = ambari__server.is_valid_cert_host(certInfo)
+    is_valid = ambari_server.is_valid_cert_host(certInfo)
     self.assertFalse(is_valid)
 
     #Failed to get FQDN
     get_fqdn_mock.return_value = None
-    is_valid = ambari__server.is_valid_cert_host(certInfo)
+    is_valid = ambari_server.is_valid_cert_host(certInfo)
     self.assertFalse(is_valid)
 
     #FQDN and Common name in certificated don't correspond
     get_fqdn_mock.return_value = 'host1'
-    certInfo = {ambari__server.COMMON_NAME_ATTR: 'host2'}
-    is_valid = ambari__server.is_valid_cert_host(certInfo)
+    certInfo = {ambari_server.COMMON_NAME_ATTR: 'host2'}
+    is_valid = ambari_server.is_valid_cert_host(certInfo)
     self.assertFalse(is_valid)
 
     #FQDN and Common name in certificated correspond
     get_fqdn_mock.return_value = 'host1'
-    certInfo = {ambari__server.COMMON_NAME_ATTR: 'host1'}
-    is_valid = ambari__server.is_valid_cert_host(certInfo)
+    certInfo = {ambari_server.COMMON_NAME_ATTR: 'host1'}
+    is_valid = ambari_server.is_valid_cert_host(certInfo)
     self.assertTrue(is_valid)
 
 
-  @patch.object(ambari__server, "get_ambari_properties")
+  @patch.object(ambari_server, "get_ambari_properties")
   def test_is_valid_https_port(self, get_ambari_properties_mock):
 
     #No ambari.properties
     get_ambari_properties_mock.return_value = -1
-    is_valid = ambari__server.is_valid_https_port(1111)
+    is_valid = ambari_server.is_valid_https_port(1111)
     self.assertEqual(is_valid, False)
 
     #User entered port used by one way auth
     portOneWay = "1111"
     portTwoWay = "2222"
     validPort = "3333"
-    get_ambari_properties_mock.return_value = {ambari__server.SRVR_ONE_WAY_SSL_PORT_PROPERTY: portOneWay,
-                                               ambari__server.SRVR_TWO_WAY_SSL_PORT_PROPERTY: portTwoWay}
-    is_valid = ambari__server.is_valid_https_port(portOneWay)
+    get_ambari_properties_mock.return_value = {ambari_server.SRVR_ONE_WAY_SSL_PORT_PROPERTY: portOneWay,
+                                               ambari_server.SRVR_TWO_WAY_SSL_PORT_PROPERTY: portTwoWay}
+    is_valid = ambari_server.is_valid_https_port(portOneWay)
     self.assertEqual(is_valid, False)
 
     #User entered port used by two way auth
-    is_valid = ambari__server.is_valid_https_port(portTwoWay)
+    is_valid = ambari_server.is_valid_https_port(portTwoWay)
     self.assertEqual(is_valid, False)
 
     #User entered valid port
-    get_ambari_properties_mock.return_value = {ambari__server.SRVR_ONE_WAY_SSL_PORT_PROPERTY: portOneWay,
-                                               ambari__server.SRVR_TWO_WAY_SSL_PORT_PROPERTY: portTwoWay}
-    is_valid = ambari__server.is_valid_https_port(validPort)
+    get_ambari_properties_mock.return_value = {ambari_server.SRVR_ONE_WAY_SSL_PORT_PROPERTY: portOneWay,
+                                               ambari_server.SRVR_TWO_WAY_SSL_PORT_PROPERTY: portTwoWay}
+    is_valid = ambari_server.is_valid_https_port(validPort)
     self.assertEqual(is_valid, True)
 
   @patch("socket.getfqdn")
   @patch("urllib2.urlopen")
-  @patch.object(ambari__server, "get_ambari_properties")
+  @patch.object(ambari_server, "get_ambari_properties")
   def test_get_fqdn(self, get_ambari_properties_mock, url_open_mock, getfqdn_mock):
 
     #No ambari.properties
     get_ambari_properties_mock.return_value = -1
-    fqdn = ambari__server.get_fqdn()
+    fqdn = ambari_server.get_fqdn()
     self.assertEqual(fqdn, None)
 
     #Check mbari_server.GET_FQDN_SERVICE_URL property name (AMBARI-2612)
     #property name should be server.fqdn.service.url
-    self.assertEqual(ambari__server.GET_FQDN_SERVICE_URL, "server.fqdn.service.url")
+    self.assertEqual(ambari_server.GET_FQDN_SERVICE_URL, "server.fqdn.service.url")
 
     #Read FQDN from service
     p = MagicMock()
-    p[ambari__server.GET_FQDN_SERVICE_URL] = 'someurl'
+    p[ambari_server.GET_FQDN_SERVICE_URL] = 'someurl'
     get_ambari_properties_mock.return_value = p
 
     u = MagicMock()
@@ -1959,57 +1765,57 @@ class TestAmbariServer(TestCase):
     u.read.return_value = host
     url_open_mock.return_value = u
 
-    fqdn = ambari__server.get_fqdn()
+    fqdn = ambari_server.get_fqdn()
     self.assertEqual(fqdn, host)
 
     #Failed to read FQDN from service, getting from socket
     u.reset_mock()
     u.side_effect = Exception("Failed to read FQDN from service")
     getfqdn_mock.return_value = host
-    fqdn = ambari__server.get_fqdn()
+    fqdn = ambari_server.get_fqdn()
     self.assertEqual(fqdn, host)
 
 
-  @patch.object(ambari__server, "find_properties_file")
+  @patch.object(ambari_server, "find_properties_file")
   def test_get_ulimit_open_files(self, find_properties_file_mock):
 
     # 1 - No ambari.properties
     find_properties_file_mock.return_value = None
-    open_files = ambari__server.get_fqdn()
+    open_files = ambari_server.get_fqdn()
     self.assertEqual(open_files, None)
 
     # 2 - With ambari.properties - ok
     tf1 = tempfile.NamedTemporaryFile()
     prop_value = 65000
     with open(tf1.name, 'w') as fout:
-      fout.write(ambari__server.ULIMIT_OPEN_FILES_KEY + '=' + str(prop_value))
+      fout.write(ambari_server.ULIMIT_OPEN_FILES_KEY + '=' + str(prop_value))
     fout.close()
     find_properties_file_mock.return_value = tf1.name
-    open_files = ambari__server.get_ulimit_open_files()
+    open_files = ambari_server.get_ulimit_open_files()
     self.assertEqual(open_files, 65000)
 
     # 2 - With ambari.properties - default
     tf1 = tempfile.NamedTemporaryFile()
     prop_value = 0
     with open(tf1.name, 'w') as fout:
-      fout.write(ambari__server.ULIMIT_OPEN_FILES_KEY + '=' + str(prop_value))
+      fout.write(ambari_server.ULIMIT_OPEN_FILES_KEY + '=' + str(prop_value))
     fout.close()
     find_properties_file_mock.return_value = tf1.name
-    open_files = ambari__server.get_ulimit_open_files()
-    self.assertEqual(open_files, ambari__server.ULIMIT_OPEN_FILES_DEFAULT)
+    open_files = ambari_server.get_ulimit_open_files()
+    self.assertEqual(open_files, ambari_server.ULIMIT_OPEN_FILES_DEFAULT)
 
 
-  @patch.object(ambari__server, 'run_os_command')
+  @patch.object(ambari_server, "run_os_command")
   def test_get_cert_info(self, run_os_command_mock):
     # Error running openssl command
     path = 'path/to/certificate'
     run_os_command_mock.return_value = -1, None, None
-    cert_info = ambari__server.get_cert_info(path)
+    cert_info = ambari_server.get_cert_info(path)
     self.assertEqual(cert_info, None)
 
     #Empty result of openssl command
     run_os_command_mock.return_value = 0, None, None
-    cert_info = ambari__server.get_cert_info(path)
+    cert_info = ambari_server.get_cert_info(path)
     self.assertEqual(cert_info, None)
 
     #Positive scenario
@@ -2037,7 +1843,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     """
     out = out_pattern.format(notAfter=notAfter, notBefore=notBefore, subject=subject)
     run_os_command_mock.return_value = 0, out, None
-    cert_info = ambari__server.get_cert_info(path)
+    cert_info = ambari_server.get_cert_info(path)
     self.assertEqual(cert_info['notAfter'], notAfter)
     self.assertEqual(cert_info['notBefore'], notBefore)
     self.assertEqual(cert_info['subject'], subject)
@@ -2056,19 +1862,19 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     inputed_value1 = 'val1'
     inputed_value2 = 'val2'
     raw_input_mock.return_value = inputed_value1
-    input = ambari__server.get_validated_string_input(prompt, default_value, None,
+    input = ambari_server.get_validated_string_input(prompt, default_value, None,
                                                      description, False, False, validator)
     self.assertTrue(validator.called)
     self.assertEqual(inputed_value1, input)
 
     validator.side_effect = [False, True]
     raw_input_mock.side_effect = [inputed_value1, inputed_value2]
-    input = ambari__server.get_validated_string_input(prompt, default_value, None,
+    input = ambari_server.get_validated_string_input(prompt, default_value, None,
                                                      description, False, False, validator)
     self.assertEqual(inputed_value2, input)
 
 
-  @patch.object(ambari__server, 'run_os_command')
+  @patch.object(ambari_server, "run_os_command")
   @patch("__builtin__.open")
   @patch("os.path.exists")
   def test_is_server_runing(self, os_path_exists_mock, open_mock, \
@@ -2077,15 +1883,15 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     f = open_mock.return_value
     f.readline.return_value = "111"
     run_os_command_mock.return_value = 0, "", ""
-    status, pid = ambari__server.is_server_runing()
+    status, pid = ambari_server.is_server_runing()
     self.assertTrue(status)
     self.assertEqual(111, pid)
     os_path_exists_mock.return_value = False
-    status, pid = ambari__server.is_server_runing()
+    status, pid = ambari_server.is_server_runing()
     self.assertFalse(status)
 
 
-  @patch.object(ambari__server, 'run_os_command')
+  @patch.object(ambari_server, "run_os_command")
   @patch("__builtin__.open")
   @patch("os.path.exists")
   def test_is_server_runing_bad_file(self, os_path_exists_mock, open_mock, \
@@ -2094,169 +1900,144 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     f = open_mock.return_value
     f.readline.return_value = "" # empty file content
     run_os_command_mock.return_value = 0, "", ""
-
-    try:
-      ambari__server.is_server_runing()
-      self.fail("Should throw NonFatalException")
-    except NonFatalException as fe:
-      pass
+    self.assertRaises(NonFatalException, ambari_server.is_server_runing)
 
     open_mock.side_effect = IOError('[Errno 13] Permission denied: /var/run/ambari-server/ambari-server.pid')
-
-    try:
-      ambari__server.is_server_runing()
-      self.fail("Should throw FatalException")
-    except FatalException as fe:
-      pass
+    self.assertRaises(FatalException, ambari_server.is_server_runing)
 
 
-  @patch.object(OSCheck, "get_os_family")
-  @patch.object(OSCheck, "get_os_type")
-  @patch.object(OSCheck, "get_os_major_version")
   @patch("os.chdir")
-  @patch("ambari_commons.os_linux.os_run_os_command")
-  def test_install_jdk(self, run_os_command_mock, os_chdir_mock,
-               

<TRUNCATED>

Mime
View raw message