You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2014/07/01 20:04:14 UTC

git commit: AMBARI-6277. Reload stack hashes without stopping Ambari (ncole)

Repository: ambari
Updated Branches:
  refs/heads/trunk bb883731c -> b9b800a9d


AMBARI-6277.  Reload stack hashes without stopping Ambari (ncole)


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

Branch: refs/heads/trunk
Commit: b9b800a9d77785c8bc6aafd37ac24da3650517b1
Parents: bb88373
Author: Nate Cole <nc...@hortonworks.com>
Authored: Wed Jun 25 16:54:55 2014 -0400
Committer: Nate Cole <nc...@hortonworks.com>
Committed: Tue Jul 1 14:02:04 2014 -0400

----------------------------------------------------------------------
 ambari-server/sbin/ambari-server                |  6 +++-
 ambari-server/src/main/python/ambari-server.py  | 34 ++++++++++++--------
 .../src/test/python/TestAmbariServer.py         | 13 ++++++++
 3 files changed, 39 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b9b800a9/ambari-server/sbin/ambari-server
----------------------------------------------------------------------
diff --git a/ambari-server/sbin/ambari-server b/ambari-server/sbin/ambari-server
index 74b8302..f4b66eb 100644
--- a/ambari-server/sbin/ambari-server
+++ b/ambari-server/sbin/ambari-server
@@ -119,9 +119,13 @@ case "$1" in
         echo -e "Security setup options..."
         $PYTHON /usr/sbin/ambari-server.py $@
         ;;
+  refresh-stack-hash)
+        echo -e "Refreshing stack hashes..."
+        $PYTHON /usr/sbin/ambari-server.py $@
+        ;;
   *)
         echo "Usage: /usr/sbin/ambari-server
-        {start|stop|restart|setup|upgrade|status|upgradestack|setup-ldap|setup-security} [options]
+        {start|stop|restart|setup|upgrade|status|upgradestack|setup-ldap|setup-security|refresh-stack-hash} [options]
         Use usr/sbin/ambari-server <action> --help to get details on options available.
         Or, simply invoke ambari-server.py --help to print the options."
         exit 1

http://git-wip-us.apache.org/repos/asf/ambari/blob/b9b800a9/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 32cd52c..a53c648 100755
--- a/ambari-server/src/main/python/ambari-server.py
+++ b/ambari-server/src/main/python/ambari-server.py
@@ -68,6 +68,7 @@ SETUP_GANGLIA_HTTPS_ACTION = "setup-ganglia-https"
 SETUP_NAGIOS_HTTPS_ACTION = "setup-nagios-https"
 ENCRYPT_PASSWORDS_ACTION = "encrypt-passwords"
 SETUP_SECURITY_ACTION = "setup-security"
+REFRESH_STACK_HASH_ACTION = "refresh-stack-hash"
 
 ACTION_REQUIRE_RESTART = [RESET_ACTION, UPGRADE_ACTION, UPGRADE_STACK_ACTION,
                           SETUP_SECURITY_ACTION, LDAP_SETUP_ACTION]
@@ -2487,20 +2488,9 @@ def start(args):
             "without root privileges."
       print "Please do not forget to start PostgreSQL server."
 
-  properties = get_ambari_properties()
-  stack_location = get_stack_location(properties)
-  # Hack: we determine resource dir as a parent dir for stack_location
-  resources_location = os.path.dirname(stack_location)
-  resource_files_keeper = ResourceFilesKeeper(resources_location)
+  refresh_stack_hash()
 
-  try:
-    print "Organizing resource files at {0}...".format(resources_location,
-                                                       verbose=VERBOSE)
-    resource_files_keeper.perform_housekeeping()
-  except KeeperException, ex:
-    msg = "Can not organize resource files at {0}: {1}".format(
-                                                resources_location, str(ex))
-    raise FatalException(-1, msg)
+  properties = get_ambari_properties()
 
   isSecure = get_is_secure(properties)
   (isPersisted, masterKeyFile) = get_is_persisted(properties)
@@ -4113,6 +4103,22 @@ def setup_security(args):
 
   return need_restart
 
+def refresh_stack_hash():
+  properties = get_ambari_properties()
+  stack_location = get_stack_location(properties)
+  # Hack: we determine resource dir as a parent dir for stack_location
+  resources_location = os.path.dirname(stack_location)
+  resource_files_keeper = ResourceFilesKeeper(resources_location)
+
+  try:
+    print "Organizing resource files at {0}...".format(resources_location,
+                                                       verbose=VERBOSE)
+    resource_files_keeper.perform_housekeeping()
+  except KeeperException, ex:
+    msg = "Can not organize resource files at {0}: {1}".format(
+                                                resources_location, str(ex))
+    raise FatalException(-1, msg)
+
 
 #
 # Main.
@@ -4292,6 +4298,8 @@ def main():
       setup_ldap()
     elif action == SETUP_SECURITY_ACTION:
       need_restart = setup_security(options)
+    elif action == REFRESH_STACK_HASH_ACTION:
+      refresh_stack_hash()
     else:
       parser.error("Invalid action")
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/b9b800a9/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 5c4d83a..4a5c21f 100644
--- a/ambari-server/src/test/python/TestAmbariServer.py
+++ b/ambari-server/src/test/python/TestAmbariServer.py
@@ -4933,3 +4933,16 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     self.assertTrue(run_metainfo_upgrade_mock.called)
     run_metainfo_upgrade_mock.assert_called_with({})
 
+  @patch.object(ambari_server, "get_ambari_properties")
+  @patch.object(ResourceFilesKeeper, "perform_housekeeping")
+  def test_refresh_stack_hash(self,
+    perform_housekeeping_mock,
+    get_ambari_properties_mock):
+
+    properties = ambari_server.Properties()
+    get_ambari_properties_mock.return_value = properties
+
+    ambari_server.refresh_stack_hash()
+
+    self.assertTrue(perform_housekeeping_mock.called)
+