You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ja...@apache.org on 2014/12/19 00:52:01 UTC

ambari git commit: AMBARI-8780. Replace variable with relevant host in Kerberos Descriptors. (Robert Levas via jaimin)

Repository: ambari
Updated Branches:
  refs/heads/trunk 438d6c244 -> 912bf7796


AMBARI-8780. Replace  variable with relevant host in Kerberos Descriptors. (Robert Levas via jaimin)


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

Branch: refs/heads/trunk
Commit: 912bf77966c741b4a817bde0836bd7726527a2b1
Parents: 438d6c2
Author: Jaimin Jetly <ja...@hortonworks.com>
Authored: Thu Dec 18 15:49:12 2014 -0800
Committer: Jaimin Jetly <ja...@hortonworks.com>
Committed: Thu Dec 18 15:49:12 2014 -0800

----------------------------------------------------------------------
 .../server/controller/KerberosHelper.java       | 27 ++++++++++++++------
 .../server/controller/KerberosHelperTest.java   |  4 +--
 2 files changed, 21 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/912bf779/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelper.java
index 625c0f6..ea59f34 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelper.java
@@ -295,18 +295,29 @@ public class KerberosHelper {
                 // variables within the Kerberos descriptor data
                 Map<String, Map<String, String>> configurations = calculateConfigurations(cluster, hostname);
 
+                // A map to hold un-categorized properties.  This may come from the KerberosDescriptor
+                // and will also contain a value for the current host
+                Map<String, String> generalProperties = new HashMap<String, String>();
+
+                // Make sure the configurations exist.
+                if (configurations == null) {
+                  configurations = new HashMap<String, Map<String, String>>();
+                }
+
                 // If any properties are set in the calculated KerberosDescriptor, add them into the
                 // Map of configurations as an un-categorized type (using an empty string)
                 if (kerberosDescriptorProperties != null) {
-                  if (configurations == null) {
-                    configurations = new HashMap<String, Map<String, String>>();
-                  }
+                  generalProperties.putAll(kerberosDescriptorProperties);
+                }
 
-                  if (configurations.get("") == null) {
-                    configurations.put("", kerberosDescriptorProperties);
-                  } else {
-                    configurations.get("").putAll(kerberosDescriptorProperties);
-                  }
+                // Add the current hostname under "host" and "hostname"
+                generalProperties.put("host", hostname);
+                generalProperties.put("hostname", hostname);
+
+                if (configurations.get("") == null) {
+                  configurations.put("", generalProperties);
+                } else {
+                  configurations.get("").putAll(generalProperties);
                 }
 
                 // Iterate over the components installed on the current host to get the service and

http://git-wip-us.apache.org/repos/asf/ambari/blob/912bf779/ambari-server/src/test/java/org/apache/ambari/server/controller/KerberosHelperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/KerberosHelperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/KerberosHelperTest.java
index 8804550..df335d5 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/KerberosHelperTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/KerberosHelperTest.java
@@ -251,11 +251,11 @@ public class KerberosHelperTest extends EasyMockSupport {
         .once();
 
     final KerberosPrincipalDescriptor principalDescriptor1 = createNiceMock(KerberosPrincipalDescriptor.class);
-    expect(principalDescriptor1.getValue()).andReturn("component1/_HOST@${realm").once();
+    expect(principalDescriptor1.getValue()).andReturn("component1/_HOST@${realm}").once();
     expect(principalDescriptor1.getConfiguration()).andReturn("service1-site/component1.kerberos.principal").once();
 
     final KerberosPrincipalDescriptor principalDescriptor2 = createNiceMock(KerberosPrincipalDescriptor.class);
-    expect(principalDescriptor2.getValue()).andReturn("component2/_HOST@${realm").once();
+    expect(principalDescriptor2.getValue()).andReturn("component2/${host}@${realm}").once();
     expect(principalDescriptor2.getConfiguration()).andReturn("service2-site/component2.kerberos.principal").once();
 
     final KerberosKeytabDescriptor keytabDescriptor1 = createNiceMock(KerberosKeytabDescriptor.class);