ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmitriu...@apache.org
Subject [2/2] ambari git commit: AMBARI-18877. Ambari change hcat.proxy.hosts value during add service (dlysnichenko)
Date Tue, 15 Nov 2016 11:11:38 GMT
AMBARI-18877. Ambari change hcat.proxy.hosts value during add service (dlysnichenko)


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

Branch: refs/heads/trunk
Commit: 4665c812f4d7b4ebd009db07beb76be1ec587fe7
Parents: 07cde1d
Author: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Authored: Tue Nov 15 13:10:59 2016 +0200
Committer: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Committed: Tue Nov 15 13:10:59 2016 +0200

----------------------------------------------------------------------
 .../stacks/HDP/2.0.6/services/stack_advisor.py  | 29 +++++++++++++++++---
 .../stacks/2.0.6/common/test_stack_advisor.py   |  4 +--
 2 files changed, 27 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/4665c812/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py
index 5e7698d..9b5ff68 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py
@@ -205,7 +205,10 @@ class HDP206StackAdvisor(DefaultStackAdvisor):
     if "HDFS" in servicesList:
       ambari_user = self.getAmbariUser(services)
       ambariHostName = socket.getfqdn()
-      putCoreSiteProperty("hadoop.proxyuser.{0}.hosts".format(ambari_user), ambariHostName)
+      is_wildcard_value, hosts = self.get_hosts_for_proxyuser(ambari_user, services)
+      if not is_wildcard_value:
+        hosts.add(ambariHostName)
+        putCoreSiteProperty("hadoop.proxyuser.{0}.hosts".format(ambari_user), ",".join(hosts))
       putCoreSiteProperty("hadoop.proxyuser.{0}.groups".format(ambari_user), "*")
       old_ambari_user = self.getOldAmbariUser(services)
       if old_ambari_user is not None:
@@ -251,7 +254,7 @@ class HDP206StackAdvisor(DefaultStackAdvisor):
         for proxyPropertyName, hostSelector in hostSelectorMap.iteritems():
           componentHostNamesString = hostSelector if isinstance(hostSelector, basestring)
else '*'
           if isinstance(hostSelector, (list, tuple)):
-            componentHostNames = set()
+            _, componentHostNames = self.get_hosts_for_proxyuser(user, services) # preserve
old values
             for component in hostSelector:
               componentHosts = self.getHostsWithComponent(serviceName, component, services,
hosts)
               if componentHosts is not None:
@@ -285,6 +288,21 @@ class HDP206StackAdvisor(DefaultStackAdvisor):
 
     return users
 
+  def get_hosts_for_proxyuser(self, user_name, services):
+    if "core-site" in services["configurations"]:
+      coreSite = services["configurations"]["core-site"]['properties']
+    else:
+      coreSite = {}
+
+    property_name = "hadoop.proxyuser.{0}.hosts".format(user_name)
+    if property_name in coreSite:
+      property_value = coreSite[property_name]
+      if property_value == "*":
+        return True, set()
+      else:
+        return False, set(property_value.split(","))
+    return False, set()
+
   def getServiceHadoopProxyUsersConfigurationDict(self):
     """
     Returns a map that is used by 'getHadoopProxyUsers' to determine service
@@ -347,9 +365,12 @@ class HDP206StackAdvisor(DefaultStackAdvisor):
         services["forced-configurations"].append({"type" : "core-site", "name" : "hadoop.proxyuser.{0}.hosts".format(hive_user)})
 
     for user_name, user_properties in users.iteritems():
+      is_wildcard_value, _ = self.get_hosts_for_proxyuser(user_name, services)
+
       # Add properties "hadoop.proxyuser.*.hosts", "hadoop.proxyuser.*.groups" to core-site
for all users
-      putCoreSiteProperty("hadoop.proxyuser.{0}.hosts".format(user_name) , user_properties["propertyHosts"])
-      Logger.info("Updated hadoop.proxyuser.{0}.hosts as : {1}".format(user_name, user_properties["propertyHosts"]))
+      if not is_wildcard_value:
+        putCoreSiteProperty("hadoop.proxyuser.{0}.hosts".format(user_name) , user_properties["propertyHosts"])
+        Logger.info("Updated hadoop.proxyuser.{0}.hosts as : {1}".format(user_name, user_properties["propertyHosts"]))
       if "propertyGroups" in user_properties:
         putCoreSiteProperty("hadoop.proxyuser.{0}.groups".format(user_name) , user_properties["propertyGroups"])
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/4665c812/ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py b/ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py
index 125c9ca..00ee563 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py
+++ b/ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py
@@ -1326,7 +1326,7 @@ class TestHDP206StackAdvisor(TestCase):
                       'hadoop.proxyuser.webhcat.groups': '*',
                       'hadoop.proxyuser.hdfs.groups': '*',
                       'hadoop.proxyuser.hdfs.hosts': '*',
-                      'hadoop.proxyuser.hive.hosts': 'c6401.ambari.apache.org,c6402.ambari.apache.org',
+                      'hadoop.proxyuser.hive.hosts': 'c6401.ambari.apache.org,c6402.ambari.apache.org,c6403.ambari.apache.org',
                       'hadoop.proxyuser.oozie.hosts': 'c6401.ambari.apache.org,c6402.ambari.apache.org',
                       'hadoop.proxyuser.falcon.groups': '*'}},
                 'falcon-env':
@@ -1459,7 +1459,7 @@ class TestHDP206StackAdvisor(TestCase):
                                  'hadoop.proxyuser.webhcat.groups': '*',
                                  'hadoop.proxyuser.hdfs.groups': '*',
                                  'hadoop.proxyuser.hdfs.hosts': '*',
-                                 'hadoop.proxyuser.hive.hosts': 'c6401.ambari.apache.org,c6402.ambari.apache.org',
+                                 'hadoop.proxyuser.hive.hosts': 'c6401.ambari.apache.org,c6402.ambari.apache.org,c6403.ambari.apache.org',
                                  'hadoop.proxyuser.oozie.hosts': 'c6401.ambari.apache.org,c6402.ambari.apache.org',
                                  'hadoop.proxyuser.falcon.groups': '*'},
                               'property_attributes':


Mime
View raw message