ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smn...@apache.org
Subject ambari git commit: AMBARI-18793: Ambari-server: Support stack inheritance for credential store information
Date Fri, 04 Nov 2016 18:03:29 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 0272e8a43 -> c4f6d464f


AMBARI-18793: Ambari-server: Support stack inheritance for credential store information


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

Branch: refs/heads/trunk
Commit: c4f6d464fe45944acaa025fba2a037214b8b205d
Parents: 0272e8a
Author: Nahappan Somasundaram <nsomasundaram@hortonworks.com>
Authored: Thu Nov 3 17:18:15 2016 -0700
Committer: Nahappan Somasundaram <nsomasundaram@hortonworks.com>
Committed: Fri Nov 4 10:56:35 2016 -0700

----------------------------------------------------------------------
 .../ambari/server/stack/ServiceModule.java      |  8 +++++
 .../server/state/CredentialStoreInfo.java       | 11 ++++++
 .../apache/ambari/server/state/ServiceInfo.java | 18 ++++++++++
 .../ambari/server/stack/ServiceModuleTest.java  | 36 ++++++++++++++++++++
 4 files changed, 73 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/c4f6d464/ambari-server/src/main/java/org/apache/ambari/server/stack/ServiceModule.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/stack/ServiceModule.java
b/ambari-server/src/main/java/org/apache/ambari/server/stack/ServiceModule.java
index b6a0da5..d1dc1df 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/stack/ServiceModule.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/stack/ServiceModule.java
@@ -259,6 +259,14 @@ public class ServiceModule extends BaseModule<ServiceModule, ServiceInfo>
implem
       serviceInfo.setChecksFolder(parent.getChecksFolder());
     }
 
+    /**
+     * If current stack version does not specify the credential store information
+     * for the service, then use parent definition.
+     */
+    if (serviceInfo.getCredentialStoreInfo() == null) {
+      serviceInfo.setCredentialStoreInfo(parent.getCredentialStoreInfo());
+    }
+
     if (serviceInfo.isSelectionEmpty()) {
       serviceInfo.setSelection(parent.getSelection());
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/c4f6d464/ambari-server/src/main/java/org/apache/ambari/server/state/CredentialStoreInfo.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/CredentialStoreInfo.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/CredentialStoreInfo.java
index 605de99..43f6690 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/CredentialStoreInfo.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/CredentialStoreInfo.java
@@ -45,6 +45,17 @@ public class CredentialStoreInfo {
     }
 
     /**
+     * Constructor taking in values for supported and enabled
+     *
+     * @param supported
+     * @param enabled
+     */
+    public CredentialStoreInfo(Boolean supported, Boolean enabled) {
+        this.supported = supported;
+        this.enabled = enabled;
+    }
+
+    /**
      * Gets a value indicating if the service supports
      * credential store. If null, this was not specified.
      * @return

http://git-wip-us.apache.org/repos/asf/ambari/blob/c4f6d464/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java
index 16042e1..56fcd74 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java
@@ -497,6 +497,24 @@ public String getVersion() {
     credentialStoreInfo.setEnabled(credentialStoreEnabled);
   }
 
+  /**
+   * Get the credential store information object.
+   *
+   * @return
+   */
+  public CredentialStoreInfo getCredentialStoreInfo() {
+    return credentialStoreInfo;
+  }
+
+  /**
+   * Set a new value for the credential store information.
+   *
+   * @param credentialStoreInfo
+   */
+  public void setCredentialStoreInfo(CredentialStoreInfo credentialStoreInfo) {
+    this.credentialStoreInfo = credentialStoreInfo;
+  }
+
   @Override
   public String toString() {
     StringBuilder sb = new StringBuilder();

http://git-wip-us.apache.org/repos/asf/ambari/blob/c4f6d464/ambari-server/src/test/java/org/apache/ambari/server/stack/ServiceModuleTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/stack/ServiceModuleTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/stack/ServiceModuleTest.java
index 47f5eb9..3b963a8 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/stack/ServiceModuleTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/stack/ServiceModuleTest.java
@@ -24,6 +24,7 @@ import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.state.CommandScriptDefinition;
 import org.apache.ambari.server.state.ComponentInfo;
+import org.apache.ambari.server.state.CredentialStoreInfo;
 import org.apache.ambari.server.state.CustomCommandDefinition;
 import org.apache.ambari.server.state.PropertyInfo;
 import org.apache.ambari.server.state.ServiceInfo;
@@ -970,6 +971,41 @@ public class ServiceModuleTest {
     assertEquals(2, service.getModuleInfo().getExcludedConfigTypes().size());
   }
 
+  /**
+   * Verify stack resolution for credential-store
+   *
+   * @throws Exception
+   */
+  @Test
+  public void testResolve_CredentialStoreInfo() throws Exception {
+    CredentialStoreInfo credentialStoreInfoChild = new CredentialStoreInfo(true /* supported
*/, false /* enabled */);
+    CredentialStoreInfo credentialStoreInfoParent = new CredentialStoreInfo(true /* supported
*/, true /* enabled */);
+    ServiceInfo childInfo = new ServiceInfo();
+    ServiceInfo parentInfo = new ServiceInfo();
+    ServiceModule service;
+
+    // specified in child only, child wins
+    childInfo.setCredentialStoreInfo(credentialStoreInfoChild);
+    parentInfo.setCredentialStoreInfo(null);
+    service = resolveService(childInfo, parentInfo);
+    assertEquals(credentialStoreInfoChild.isSupported(), service.getModuleInfo().isCredentialStoreSupported());
+    assertEquals(credentialStoreInfoChild.isEnabled(), service.getModuleInfo().isCredentialStoreEnabled());
+
+    // specified in parent only, parent wins
+    childInfo.setCredentialStoreInfo(null);
+    parentInfo.setCredentialStoreInfo(credentialStoreInfoParent);
+    service = resolveService(childInfo, parentInfo);
+    assertEquals(credentialStoreInfoParent.isSupported(), service.getModuleInfo().isCredentialStoreSupported());
+    assertEquals(credentialStoreInfoParent.isEnabled(), service.getModuleInfo().isCredentialStoreEnabled());
+
+    // specified in both, child wins
+    childInfo.setCredentialStoreInfo(credentialStoreInfoChild);
+    parentInfo.setCredentialStoreInfo(credentialStoreInfoParent);
+    service = resolveService(childInfo, parentInfo);
+    assertEquals(credentialStoreInfoChild.isSupported(), service.getModuleInfo().isCredentialStoreSupported());
+    assertEquals(credentialStoreInfoChild.isEnabled(), service.getModuleInfo().isCredentialStoreEnabled());
+  }
+
   @Test
   public void testServiceCheckRegistered() throws Exception {
     ServiceInfo info = new ServiceInfo();


Mime
View raw message