ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From swa...@apache.org
Subject [24/24] ambari git commit: AMBARI-18905 - Management pack purge option should support extensions
Date Wed, 16 Nov 2016 21:58:57 GMT
AMBARI-18905 - Management pack purge option should support extensions


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

Branch: refs/heads/branch-feature-AMBARI-18901
Commit: d1b777714bd0d8d843e8ac8bb39a8c2c6579f615
Parents: 940143e
Author: Tim Thorpe <tthorpe@apache.org>
Authored: Wed Nov 16 13:33:48 2016 -0800
Committer: Tim Thorpe <tthorpe@apache.org>
Committed: Wed Nov 16 13:33:48 2016 -0800

----------------------------------------------------------------------
 .../src/main/python/ambari_server/setupMpacks.py       |  8 +++++++-
 ambari-server/src/test/python/TestMpacks.py            | 13 ++++++++++++-
 2 files changed, 19 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d1b77771/ambari-server/src/main/python/ambari_server/setupMpacks.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari_server/setupMpacks.py b/ambari-server/src/main/python/ambari_server/setupMpacks.py
index 3b8a67a..773d946 100755
--- a/ambari-server/src/main/python/ambari_server/setupMpacks.py
+++ b/ambari-server/src/main/python/ambari_server/setupMpacks.py
@@ -51,6 +51,7 @@ logger = logging.getLogger(__name__)
 MPACKS_REPLAY_LOG_FILENAME = "mpacks_replay.log"
 MPACKS_CACHE_DIRNAME = "cache"
 STACK_DEFINITIONS_RESOURCE_NAME = "stack-definitions"
+EXTENSION_DEFINITIONS_RESOURCE_NAME = "extension-definitions"
 SERVICE_DEFINITIONS_RESOURCE_NAME = "service-definitions"
 MPACKS_RESOURCE_NAME = "mpacks"
 
@@ -70,6 +71,7 @@ STACK_ADDON_SERVICE_DEFINITIONS_ARTIFACT_NAME = "stack-addon-service-definitions
 RESOURCE_FRIENDLY_NAMES = {
   STACK_DEFINITIONS_RESOURCE_NAME : "stack definitions",
   SERVICE_DEFINITIONS_RESOURCE_NAME: "service definitions",
+  EXTENSION_DEFINITIONS_RESOURCE_NAME: "extension definitions",
   MPACKS_RESOURCE_NAME: "management packs"
 }
 
@@ -309,7 +311,7 @@ def validate_purge(options, purge_list, mpack_dir, mpack_metadata, replay_mode=F
       err = "The management pack you are attempting to install does not contain {0}. Since
this management pack " \
             "does not contain a stack, the --purge option with --purge-list={1} would cause
your existing Ambari " \
             "installation to be unusable. Due to that we cannot install this management pack.".format(
-          RESOURCE_FRIENDLY_NAMES[STACK_DEFINITIONS_ARTIFACT_NAME], purge_list)
+          RESOURCE_FRIENDLY_NAMES[STACK_DEFINITIONS_RESOURCE_NAME], purge_list)
       print_error_msg(err)
       raise FatalException(1, err)
     else:
@@ -352,6 +354,10 @@ def purge_stacks_and_mpacks(purge_list, replay_mode=False):
       if(os.path.isdir(path)):
         sudo.rmtree(path)
 
+  if EXTENSION_DEFINITIONS_RESOURCE_NAME in purge_list and os.path.exists(extension_location):
+    print_info_msg("Purging extension location: " + extension_location)
+    sudo.rmtree(extension_location)
+
   if SERVICE_DEFINITIONS_RESOURCE_NAME in purge_list and os.path.exists(service_definitions_location):
     print_info_msg("Purging service definitions location: " + service_definitions_location)
     sudo.rmtree(service_definitions_location)

http://git-wip-us.apache.org/repos/asf/ambari/blob/d1b77771/ambari-server/src/test/python/TestMpacks.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/TestMpacks.py b/ambari-server/src/test/python/TestMpacks.py
index d935b5a..7fb21ae 100644
--- a/ambari-server/src/test/python/TestMpacks.py
+++ b/ambari-server/src/test/python/TestMpacks.py
@@ -49,7 +49,8 @@ with patch.object(platform, "linux_distribution", return_value = MagicMock(retur
 
 from ambari_server.setupMpacks import install_mpack, upgrade_mpack, replay_mpack_logs, \
   purge_stacks_and_mpacks, validate_purge, read_mpack_metadata, \
-  STACK_DEFINITIONS_RESOURCE_NAME, SERVICE_DEFINITIONS_RESOURCE_NAME, MPACKS_RESOURCE_NAME
+  STACK_DEFINITIONS_RESOURCE_NAME, EXTENSION_DEFINITIONS_RESOURCE_NAME, \
+  SERVICE_DEFINITIONS_RESOURCE_NAME, MPACKS_RESOURCE_NAME
 
 with patch.object(os, "geteuid", new=MagicMock(return_value=0)):
   from resource_management.core import sudo
@@ -153,6 +154,7 @@ class TestMpacks(TestCase):
     options = self._create_empty_options_mock()
     get_ambari_version_mock.return_value = configs
     stacks_directory = configs[serverConfiguration.STACK_LOCATION_KEY]
+    extensions_directory = configs[serverConfiguration.EXTENSION_PATH_PROPERTY]
     common_services_directory = configs[serverConfiguration.COMMON_SERVICES_PATH_PROPERTY]
     mpacks_directory = configs[serverConfiguration.MPACKS_STAGING_PATH_PROPERTY]
     os_path_exists_mock.return_value = False
@@ -177,6 +179,15 @@ class TestMpacks(TestCase):
     ]
     os_path_exists_mock.assert_has_calls(os_path_exists_calls)
 
+    options.purge_list = ",".join([STACK_DEFINITIONS_RESOURCE_NAME, EXTENSION_DEFINITIONS_RESOURCE_NAME,
MPACKS_RESOURCE_NAME])
+    purge_stacks_and_mpacks(options.purge_list.split(","))
+    os_path_exists_calls = [
+      call(stacks_directory),
+      call(extensions_directory),
+      call(mpacks_directory)
+    ]
+    os_path_exists_mock.assert_has_calls(os_path_exists_calls)
+
     options.purge_list = ",".join([STACK_DEFINITIONS_RESOURCE_NAME, SERVICE_DEFINITIONS_RESOURCE_NAME,
MPACKS_RESOURCE_NAME])
     options.replay_mode = True
     purge_stacks_and_mpacks(options.purge_list.split(","))


Mime
View raw message