Repository: ambari
Updated Branches:
  refs/heads/branch-2.6 16ceccfa7 -> 26ff188e2


AMBARI-22204 Updating Ranger Admin pre-upgrade task (mugdha)


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

Branch: refs/heads/branch-2.6
Commit: 26ff188e2cce560fc73334c9f2d928f69b6beb2b
Parents: 16ceccf
Author: Mugdha Varadkar <mug...@apache.org>
Authored: Thu Oct 12 14:08:27 2017 +0530
Committer: Mugdha Varadkar <mug...@apache.org>
Committed: Thu Oct 12 14:34:35 2017 +0530

----------------------------------------------------------------------
 .../0.4.0/package/scripts/ranger_admin.py       | 23 ++++++++++++++----
 .../0.4.0/package/scripts/ranger_tagsync.py     | 23 ++++++++++++++----
 .../RANGER/package/scripts/ranger_admin.py      | 25 +++++++++++++++-----
 3 files changed, 57 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/26ff188e/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/ranger_admin.py
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/ranger_admin.py
 
b/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/ranger_admin.py
index f779c18..39dad77 100644
--- 
a/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/ranger_admin.py
+++ 
b/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/ranger_admin.py
@@ -20,6 +20,7 @@ limitations under the License.
 from resource_management.core.exceptions import Fail
 from resource_management.libraries.functions.check_process_status import 
check_process_status
 from resource_management.libraries.functions import stack_select
+from resource_management.libraries.functions import upgrade_summary
 from resource_management.libraries.functions.constants import Direction
 from resource_management.libraries.script import Script
 from resource_management.core.resources.system import Execute, File
@@ -198,11 +199,25 @@ class RangerAdmin(Script):
     import params
     env.set_params(params)
 
-    upgrade_stack = stack_select._get_upgrade_stack()
-    if upgrade_stack is None:
-      raise Fail('Unable to determine the stack and stack version')
+    orchestration = stack_select.PACKAGE_SCOPE_STANDARD
+    summary = upgrade_summary.get_upgrade_summary()
 
-    stack_select.select_packages(params.version)
+    if summary is not None:
+      orchestration = summary.orchestration
+      if orchestration is None:
+        raise Fail("The upgrade summary does not contain an orchestration 
type")
+
+      if orchestration.upper() in stack_select._PARTIAL_ORCHESTRATION_SCOPES:
+        orchestration = stack_select.PACKAGE_SCOPE_PATCH
+
+    stack_select_packages = stack_select.get_packages(orchestration, 
service_name = "RANGER", component_name = "RANGER_ADMIN")
+    if stack_select_packages is None:
+      raise Fail("Unable to get packages for stack-select")
+
+    Logger.info("RANGER_ADMIN component will be stack-selected to version {0} 
using a {1} orchestration".format(params.version, orchestration.upper()))
+
+    for stack_select_package_name in stack_select_packages:
+      stack_select.select(stack_select_package_name, params.version)
 
   def get_log_folder(self):
     import params

http://git-wip-us.apache.org/repos/asf/ambari/blob/26ff188e/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/ranger_tagsync.py
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/ranger_tagsync.py
 
b/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/ranger_tagsync.py
index 74439bf..8875f7f 100644
--- 
a/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/ranger_tagsync.py
+++ 
b/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/ranger_tagsync.py
@@ -19,6 +19,7 @@ limitations under the License.
 """
 from resource_management.libraries.script import Script
 from resource_management.libraries.functions import stack_select
+from resource_management.libraries.functions import upgrade_summary
 from resource_management.core.resources.system import Execute, File
 from resource_management.libraries.functions.check_process_status import 
check_process_status
 from resource_management.core.exceptions import ComponentIsNotRunning
@@ -98,11 +99,25 @@ class RangerTagsync(Script):
     import params
     env.set_params(params)
 
-    upgrade_stack = stack_select._get_upgrade_stack()
-    if upgrade_stack is None:
-      raise Fail('Unable to determine the stack and stack version')
+    orchestration = stack_select.PACKAGE_SCOPE_STANDARD
+    summary = upgrade_summary.get_upgrade_summary()
 
-    stack_select.select_packages(params.version)
+    if summary is not None:
+      orchestration = summary.orchestration
+      if orchestration is None:
+        raise Fail("The upgrade summary does not contain an orchestration 
type")
+
+      if orchestration.upper() in stack_select._PARTIAL_ORCHESTRATION_SCOPES:
+        orchestration = stack_select.PACKAGE_SCOPE_PATCH
+
+    stack_select_packages = stack_select.get_packages(orchestration, 
service_name = "RANGER", component_name = "RANGER_TAGSYNC")
+    if stack_select_packages is None:
+      raise Fail("Unable to get packages for stack-select")
+
+    Logger.info("RANGER_TAGSYNC component will be stack-selected to version 
{0} using a {1} orchestration".format(params.version, orchestration.upper()))
+
+    for stack_select_package_name in stack_select_packages:
+      stack_select.select(stack_select_package_name, params.version)
 
     if params.stack_supports_ranger_tagsync_ssl_xml_support:
       Logger.info("Upgrading Tagsync, stack support Atlas user for Tagsync, 
creating keystore for same.")

http://git-wip-us.apache.org/repos/asf/ambari/blob/26ff188e/ambari-server/src/main/resources/stacks/BigInsights/4.2/services/RANGER/package/scripts/ranger_admin.py
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/BigInsights/4.2/services/RANGER/package/scripts/ranger_admin.py
 
b/ambari-server/src/main/resources/stacks/BigInsights/4.2/services/RANGER/package/scripts/ranger_admin.py
index 37555cc..13777ab 100755
--- 
a/ambari-server/src/main/resources/stacks/BigInsights/4.2/services/RANGER/package/scripts/ranger_admin.py
+++ 
b/ambari-server/src/main/resources/stacks/BigInsights/4.2/services/RANGER/package/scripts/ranger_admin.py
@@ -17,7 +17,9 @@ See the License for the specific language governing 
permissions and
 limitations under the License.
 
 """
+from resource_management.core.exceptions import Fail
 from resource_management.libraries.functions import stack_select
+from resource_management.libraries.functions import upgrade_summary
 from resource_management.libraries.functions.constants import Direction
 from resource_management.libraries.script import Script
 from resource_management.core.resources.system import Execute
@@ -167,14 +169,25 @@ class RangerAdmin(Script):
     import params
     env.set_params(params)
 
-    upgrade_stack = stack_select._get_upgrade_stack()
-    if upgrade_stack is None:
-      raise Fail('Unable to determine the stack and stack version')
+    orchestration = stack_select.PACKAGE_SCOPE_STANDARD
+    summary = upgrade_summary.get_upgrade_summary()
 
-    stack_name = upgrade_stack[0]
-    stack_version = upgrade_stack[1]
+    if summary is not None:
+      orchestration = summary.orchestration
+      if orchestration is None:
+        raise Fail("The upgrade summary does not contain an orchestration 
type")
+
+      if orchestration.upper() in stack_select._PARTIAL_ORCHESTRATION_SCOPES:
+        orchestration = stack_select.PACKAGE_SCOPE_PATCH
+
+    stack_select_packages = stack_select.get_packages(orchestration, 
service_name = "RANGER", component_name = "RANGER_ADMIN")
+    if stack_select_packages is None:
+      raise Fail("Unable to get packages for stack-select")
+
+    Logger.info("RANGER_ADMIN component will be stack-selected to version {0} 
using a {1} orchestration".format(params.version, orchestration.upper()))
 
-    stack_select.select_packages(params.version)
+    for stack_select_package_name in stack_select_packages:
+      stack_select.select(stack_select_package_name, params.version)
 
   def get_log_folder(self):
     import params

Reply via email to