Pārlūkot izejas kodu

AMBARI-8313 - Remove Nagios SSL Configuration From Ambari Scripts (jonathanhurley)

Jonathan Hurley 10 gadi atpakaļ
vecāks
revīzija
d6b0db0b58

+ 5 - 12
ambari-server/src/main/java/org/apache/ambari/server/configuration/ComponentSSLConfiguration.java

@@ -18,7 +18,11 @@
 package org.apache.ambari.server.configuration;
 
 /**
- * Configuration for SSL on components (Ganglia & Nagios).
+ * Configuration for SSL communication between Ambari and 3rd party services.
+ * Currently, the following services are supported with SSL communication:
+ * <ul>
+ * <li>Ganglia</li>
+ * </ul>
  */
 public class ComponentSSLConfiguration {
 
@@ -29,7 +33,6 @@ public class ComponentSSLConfiguration {
   private String truststorePassword;
   private String truststoreType;
   private boolean gangliaSSL;
-  private boolean nagiosSSL;
 
   /**
    * The singleton.
@@ -58,7 +61,6 @@ public class ComponentSSLConfiguration {
     truststorePassword = getPassword(configuration);
     truststoreType     = configuration.getProperty(Configuration.SSL_TRUSTSTORE_TYPE_KEY);
     gangliaSSL         = Boolean.parseBoolean(configuration.getProperty(Configuration.GANGLIA_HTTPS_KEY));
-    nagiosSSL          = Boolean.parseBoolean(configuration.getProperty(Configuration.NAGIOS_HTTPS_KEY));
   }
 
 
@@ -100,15 +102,6 @@ public class ComponentSSLConfiguration {
     return gangliaSSL;
   }
 
-  /**
-   * Indicates whether or not Nagios is setup for SSL.
-   *
-   * @return true if Nagios is setup for SSL
-   */
-  public boolean isNagiosSSL() {
-    return nagiosSSL;
-  }
-
   /**
    * Get the singleton instance.
    *

+ 0 - 3
ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java

@@ -190,9 +190,6 @@ public class Configuration {
   public static final String JAVAX_SSL_TRUSTSTORE_PASSWORD = "javax.net.ssl.trustStorePassword";
   public static final String JAVAX_SSL_TRUSTSTORE_TYPE = "javax.net.ssl.trustStoreType";
   public static final String GANGLIA_HTTPS_KEY = "ganglia.https";
-  public static final String NAGIOS_HTTPS_KEY = "nagios.https";
-  public static final String NAGIOS_IGNORE_FOR_SERVICES_KEY = "nagios.ignore_for_services";
-  public static final String NAGIOS_IGNORE_FOR_HOSTS_KEY = "nagios.ignore_for_hosts";
   public static final String SRVR_TWO_WAY_SSL_PORT_DEFAULT = "8441";
   public static final String SRVR_ONE_WAY_SSL_PORT_DEFAULT = "8440";
   public static final String SRVR_CRT_NAME_DEFAULT = "ca.crt";

+ 4 - 10
ambari-server/src/main/python/ambari-server.py

@@ -74,7 +74,6 @@ SETUP_HTTPS_ACTION = "setup-https"
 LDAP_SETUP_ACTION = "setup-ldap"
 LDAP_SYNC_ACTION = "sync-ldap"
 SETUP_GANGLIA_HTTPS_ACTION = "setup-ganglia-https"
-SETUP_NAGIOS_HTTPS_ACTION = "setup-nagios-https"
 ENCRYPT_PASSWORDS_ACTION = "encrypt-passwords"
 SETUP_SECURITY_ACTION = "setup-security"
 REFRESH_STACK_HASH_ACTION = "refresh-stack-hash"
@@ -235,7 +234,6 @@ DEFAULT_SSL_API_PORT = 8443
 SSL_DATE_FORMAT = '%b  %d %H:%M:%S %Y GMT'
 
 GANGLIA_HTTPS = 'ganglia.https'
-NAGIOS_HTTPS = 'nagios.https'
 
 JDBC_RCA_PASSWORD_ALIAS = "ambari.db.password"
 CLIENT_SECURITY_KEY = "client.security"
@@ -4349,11 +4347,10 @@ def setup_security(args):
   print 'Choose one of the following options: '
   print '  [1] Enable HTTPS for Ambari server.'
   print '  [2] Enable HTTPS for Ganglia service.'
-  print '  [3] Enable HTTPS for Nagios service.'
-  print '  [4] Encrypt passwords stored in ambari.properties file.'
-  print '  [5] Setup Ambari kerberos JAAS configuration.'
+  print '  [3] Encrypt passwords stored in ambari.properties file.'
+  print '  [4] Setup Ambari kerberos JAAS configuration.'
   print '=' * 75
-  choice = get_validated_string_input('Enter choice, (1-5): ', '0', '[1-5]',
+  choice = get_validated_string_input('Enter choice, (1-4): ', '0', '[1-4]',
                                       'Invalid choice', False, False)
 
   if choice == '1':
@@ -4362,11 +4359,8 @@ def setup_security(args):
     setup_component_https("Ganglia", "setup-ganglia-https", GANGLIA_HTTPS,
                          "ganglia_cert")
   elif choice == '3':
-    setup_component_https("Nagios", "setup-nagios-https", NAGIOS_HTTPS,
-                          "nagios_cert")
-  elif choice == '4':
     setup_master_key()
-  elif choice == '5':
+  elif choice == '4':
     setup_ambari_krb5_jaas()
   else:
     raise FatalException('Unknown option for setup-security command.')

+ 12 - 12
ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BaseBlueprintProcessorTest.java

@@ -93,8 +93,8 @@ public class BaseBlueprintProcessorTest {
         super.registerConditionalDependencies();
 
         Map<DependencyInfo, String> dependencyConditionalServiceMap = getDependencyConditionalServiceMap();
-        Collection<DependencyInfo> nagiosDependencies = getDependenciesForComponent("FAKE_MONITORING_SERVER");
-        for (DependencyInfo dependency : nagiosDependencies) {
+        Collection<DependencyInfo> monitoringDependencies = getDependenciesForComponent("FAKE_MONITORING_SERVER");
+        for (DependencyInfo dependency : monitoringDependencies) {
           if (dependency.getComponentName().equals("HCAT")) {
             dependencyConditionalServiceMap.put(dependency, "HIVE");
           } else if (dependency.getComponentName().equals("OOZIE_CLIENT")) {
@@ -190,8 +190,8 @@ public class BaseBlueprintProcessorTest {
         super.registerConditionalDependencies();
 
         Map<DependencyInfo, String> dependencyConditionalServiceMap = getDependencyConditionalServiceMap();
-        Collection<DependencyInfo> nagiosDependencies = getDependenciesForComponent("FAKE_MONITORING_SERVER");
-        for (DependencyInfo dependency : nagiosDependencies) {
+        Collection<DependencyInfo> monitoringDependencies = getDependenciesForComponent("FAKE_MONITORING_SERVER");
+        for (DependencyInfo dependency : monitoringDependencies) {
           if (dependency.getComponentName().equals("HCAT")) {
             dependencyConditionalServiceMap.put(dependency, "HIVE");
           } else if (dependency.getComponentName().equals("OOZIE_CLIENT")) {
@@ -285,8 +285,8 @@ public class BaseBlueprintProcessorTest {
         super.registerConditionalDependencies();
 
         Map<DependencyInfo, String> dependencyConditionalServiceMap = getDependencyConditionalServiceMap();
-        Collection<DependencyInfo> nagiosDependencies = getDependenciesForComponent("FAKE_MONITORING_SERVER");
-        for (DependencyInfo dependency : nagiosDependencies) {
+        Collection<DependencyInfo> monitoringDependencies = getDependenciesForComponent("FAKE_MONITORING_SERVER");
+        for (DependencyInfo dependency : monitoringDependencies) {
           if (dependency.getComponentName().equals("HCAT")) {
             dependencyConditionalServiceMap.put(dependency, "HIVE");
           } else if (dependency.getComponentName().equals("OOZIE_CLIENT")) {
@@ -378,8 +378,8 @@ public class BaseBlueprintProcessorTest {
         super.registerConditionalDependencies();
 
         Map<DependencyInfo, String> dependencyConditionalServiceMap = getDependencyConditionalServiceMap();
-        Collection<DependencyInfo> nagiosDependencies = getDependenciesForComponent("FAKE_MONITORING_SERVER");
-        for (DependencyInfo dependency : nagiosDependencies) {
+        Collection<DependencyInfo> monitoringDependencies = getDependenciesForComponent("FAKE_MONITORING_SERVER");
+        for (DependencyInfo dependency : monitoringDependencies) {
           if (dependency.getComponentName().equals("HCAT")) {
             dependencyConditionalServiceMap.put(dependency, "HIVE");
           } else if (dependency.getComponentName().equals("OOZIE_CLIENT")) {
@@ -473,8 +473,8 @@ public class BaseBlueprintProcessorTest {
         super.registerConditionalDependencies();
 
         Map<DependencyInfo, String> dependencyConditionalServiceMap = getDependencyConditionalServiceMap();
-        Collection<DependencyInfo> nagiosDependencies = getDependenciesForComponent("FAKE_MONITORING_SERVER");
-        for (DependencyInfo dependency : nagiosDependencies) {
+        Collection<DependencyInfo> monitoringDependencies = getDependenciesForComponent("FAKE_MONITORING_SERVER");
+        for (DependencyInfo dependency : monitoringDependencies) {
           if (dependency.getComponentName().equals("HCAT")) {
             dependencyConditionalServiceMap.put(dependency, "HIVE");
           } else if (dependency.getComponentName().equals("OOZIE_CLIENT")) {
@@ -566,8 +566,8 @@ public class BaseBlueprintProcessorTest {
         super.registerConditionalDependencies();
 
         Map<DependencyInfo, String> dependencyConditionalServiceMap = getDependencyConditionalServiceMap();
-        Collection<DependencyInfo> nagiosDependencies = getDependenciesForComponent("FAKE_MONITORING_SERVER");
-        for (DependencyInfo dependency : nagiosDependencies) {
+        Collection<DependencyInfo> monitoringDependencies = getDependenciesForComponent("FAKE_MONITORING_SERVER");
+        for (DependencyInfo dependency : monitoringDependencies) {
           if (dependency.getComponentName().equals("HCAT")) {
             dependencyConditionalServiceMap.put(dependency, "HIVE");
           } else if (dependency.getComponentName().equals("OOZIE_CLIENT")) {

+ 34 - 34
ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintResourceProviderTest.java

@@ -18,7 +18,33 @@
 
 package org.apache.ambari.server.controller.internal;
 
-import com.google.gson.Gson;
+import static org.easymock.EasyMock.capture;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.createNiceMock;
+import static org.easymock.EasyMock.createStrictMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.reset;
+import static org.easymock.EasyMock.verify;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
@@ -30,6 +56,9 @@ import org.apache.ambari.server.controller.StackServiceComponentRequest;
 import org.apache.ambari.server.controller.StackServiceComponentResponse;
 import org.apache.ambari.server.controller.StackServiceRequest;
 import org.apache.ambari.server.controller.StackServiceResponse;
+import org.apache.ambari.server.controller.internal.BlueprintResourceProvider.BlueprintConfigPopulationStrategy;
+import org.apache.ambari.server.controller.internal.BlueprintResourceProvider.BlueprintConfigPopulationStrategyV1;
+import org.apache.ambari.server.controller.internal.BlueprintResourceProvider.BlueprintConfigPopulationStrategyV2;
 import org.apache.ambari.server.controller.predicate.EqualsPredicate;
 import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
 import org.apache.ambari.server.controller.spi.NoSuchResourceException;
@@ -54,42 +83,13 @@ import org.apache.ambari.server.state.DependencyInfo;
 import org.apache.ambari.server.state.ServiceInfo;
 import org.apache.ambari.server.utils.StageUtils;
 import org.easymock.Capture;
-
-import static org.easymock.EasyMock.expectLastCall;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertNotNull;
-
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import static org.apache.ambari.server.controller.internal.BlueprintResourceProvider.*;
-import static org.easymock.EasyMock.capture;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.createNiceMock;
-import static org.easymock.EasyMock.createStrictMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.reset;
-import static org.easymock.EasyMock.verify;
-import static org.junit.Assert.fail;
+import com.google.gson.Gson;
 
 /**
  * BlueprintResourceProvider unit tests.
@@ -1450,7 +1450,7 @@ public class BlueprintResourceProviderTest {
   @Test
   public void testDecidePopulationStrategy_withNewSchema_attributes() throws Exception {
     Map<String, String> configMap = new HashMap<String, String>();
-    configMap.put("global/properties_attributes/final/nagios_contact", "true");
+    configMap.put("global/properties_attributes/final/foo_contact", "true");
 
     BlueprintConfigPopulationStrategy provisioner =
         provider.decidePopulationStrategy(configMap);
@@ -1462,7 +1462,7 @@ public class BlueprintResourceProviderTest {
   @Test
   public void testDecidePopulationStrategy_withNewSchema_properties() throws Exception {
     Map<String, String> configMap = new HashMap<String, String>();
-    configMap.put("global/properties/nagios_contact", "foo@ffl.dsfds");
+    configMap.put("global/properties/foo_contact", "foo@ffl.dsfds");
 
     BlueprintConfigPopulationStrategy provisioner =
         provider.decidePopulationStrategy(configMap);
@@ -1474,7 +1474,7 @@ public class BlueprintResourceProviderTest {
   @Test
   public void testDecidePopulationStrategy_unsupportedSchema() throws Exception {
     Map<String, String> configMap = new HashMap<String, String>();
-    configMap.put("global/properties/lot/nagios_contact", "foo@ffl.dsfds");
+    configMap.put("global/properties/lot/foo_contact", "foo@ffl.dsfds");
     expectedException.expect(IllegalArgumentException.class);
     expectedException.expectMessage(provider.SCHEMA_IS_NOT_SUPPORTED_MESSAGE);
 

+ 1 - 7
ambari-server/src/test/python/TestAmbariServer.py

@@ -254,15 +254,9 @@ class TestAmbariServer(TestCase):
 
     get_validated_string_input_mock.return_value = '3'
     ambari_server.setup_security(args)
-    self.assertTrue(setup_component_https.called)
-    setup_component_https.assert_called_with("Nagios", "setup-nagios-https",
-                          ambari_server.NAGIOS_HTTPS, "nagios_cert")
-
-    get_validated_string_input_mock.return_value = '4'
-    ambari_server.setup_security(args)
     self.assertTrue(setup_master_key.called)
 
-    get_validated_string_input_mock.return_value = '5'
+    get_validated_string_input_mock.return_value = '4'
     ambari_server.setup_security(args)
     self.assertTrue(setup_ambari_krb5_jaas.called)
 

+ 7 - 0
contrib/addons/src/addOns/nagios/conf.d/hdp_mon_nagios_addons.conf

@@ -0,0 +1,7 @@
+Alias /ambarinagios /usr/share/hdp
+<Directory /usr/share/hdp>
+  Options None
+  AllowOverride None
+  Order allow,deny
+  Allow from all
+</Directory>

+ 13 - 0
contrib/addons/src/addOns/nagios/plugins/README

@@ -0,0 +1,13 @@
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+
+This is a placeholder for Nagios contribution plugins.

+ 13 - 0
contrib/addons/src/addOns/nagios/scripts/README

@@ -0,0 +1,13 @@
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+
+This is a placeholder for Nagios contribution scripts.