ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smoha...@apache.org
Subject git commit: AMBARI-3203. Ambari server reset needs a little UI improvement (Myroslav Papirkovskyy via smohanty).
Date Fri, 13 Sep 2013 01:40:56 GMT
Updated Branches:
  refs/heads/trunk 78867493c -> 72dc18d7e


AMBARI-3203. Ambari server reset needs a little UI improvement (Myroslav Papirkovskyy via
smohanty).


Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/72dc18d7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/72dc18d7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/72dc18d7

Branch: refs/heads/trunk
Commit: 72dc18d7eae1ac5140ccf9bcdd2de0095267fcc3
Parents: 7886749
Author: Sumit Mohanty <smohanty@hortonworks.com>
Authored: Thu Sep 12 18:40:33 2013 -0700
Committer: Sumit Mohanty <smohanty@hortonworks.com>
Committed: Thu Sep 12 18:40:33 2013 -0700

----------------------------------------------------------------------
 ambari-server/src/main/python/ambari-server.py    | 11 +++++++++--
 ambari-server/src/test/python/TestAmbariServer.py | 17 +++++++++++++++++
 2 files changed, 26 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/72dc18d7/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 0e6632b..7efa4f3 100755
--- a/ambari-server/src/main/python/ambari-server.py
+++ b/ambari-server/src/main/python/ambari-server.py
@@ -2037,6 +2037,13 @@ def setup(args):
 # Resets the Ambari Server.
 #
 def reset(args):
+  #force reset if silent option provided
+  global SILENT
+  if SILENT:
+    default = "yes"
+  else:
+    default = "no"
+
   if not is_root():
     err = 'Ambari-server reset should be run with ' \
           'root-level privileges'
@@ -2047,14 +2054,14 @@ def reset(args):
                      "You will be required to re-configure the Ambari server "
                      "and re-run the cluster wizard. \n"
                      "Are you SURE you want to perform the reset "
-                     "[yes/no]? ", True)
+                     "[yes/no] ({0})? ".format(default), SILENT)
   okToRun = choice
 
   if not okToRun:
     err =  "Ambari Server 'reset' cancelled"
     raise FatalException(1, err)
 
-  okToRun = get_YN_input("Confirm server reset [yes/no]? ", True)
+  okToRun = get_YN_input("Confirm server reset [yes/no]({0})? ".format(default), SILENT)
 
   if not okToRun:
     err =  "Ambari Server 'reset' cancelled"

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/72dc18d7/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 a097130..fcf332c 100644
--- a/ambari-server/src/test/python/TestAmbariServer.py
+++ b/ambari-server/src/test/python/TestAmbariServer.py
@@ -2037,6 +2037,23 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     self.assertEqual(None, rcode)
     self.assertTrue(execute_remote_script_mock.called)
 
+  @patch("__builtin__.raw_input")
+  @patch.object(ambari_server, "is_root")
+  def test_reset_default(self, is_root_mock, raw_input_mock):
+    is_root_mock.return_value=True
+    raw_input_mock.return_value=""
+    args = MagicMock()
+
+    try:
+      ambari_server.reset(args)
+      self.fail("Should throw exception")
+    except FatalException as fe:
+      # Expected
+      self.assertTrue(fe.code == 1)
+      pass
+
+    pass
+
 
   @patch.object(ambari_server, "setup_db")
   @patch.object(ambari_server, "print_info_msg")


Mime
View raw message