ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adorosz...@apache.org
Subject ambari git commit: AMBARI-20525. Unlimited Key JCE policy is enabled or not on each host (Attila Magyar via adoroszlai)
Date Wed, 12 Apr 2017 12:00:59 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 42b99b403 -> 688d000d3


AMBARI-20525. Unlimited Key JCE policy is enabled or not on each host (Attila Magyar via adoroszlai)


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

Branch: refs/heads/branch-2.5
Commit: 688d000d30f2c1f9f1d3053040f53b81d453ad53
Parents: 42b99b4
Author: Attila Magyar <amagyar@hortonworks.com>
Authored: Wed Apr 12 14:01:56 2017 +0200
Committer: Attila Doroszlai <adoroszlai@hortonworks.com>
Committed: Wed Apr 12 14:01:56 2017 +0200

----------------------------------------------------------------------
 .../src/main/python/ambari_agent/HostInfo.py    | 14 ++++++++++-
 .../test/python/ambari_agent/TestHostInfo.py    |  4 +++-
 .../core/resources/jcepolicyinfo.py             | 25 ++++++++------------
 .../apache/ambari/server/agent/AgentEnv.java    |  6 +++++
 .../server/configuration/Configuration.java     |  1 +
 .../scripts/shared_initialization.py            |  2 +-
 .../ambari/server/agent/AgentResourceTest.java  |  3 ++-
 .../app/controllers/global/update_controller.js |  2 +-
 ambari-web/app/mappers/hosts_mapper.js          |  1 +
 ambari-web/app/messages.js                      |  1 +
 ambari-web/app/models/host.js                   |  1 +
 ambari-web/app/templates/main/host/summary.hbs  |  3 +++
 12 files changed, 43 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/688d000d/ambari-agent/src/main/python/ambari_agent/HostInfo.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/HostInfo.py b/ambari-agent/src/main/python/ambari_agent/HostInfo.py
index 7f041eb..4b7bfd7 100644
--- a/ambari-agent/src/main/python/ambari_agent/HostInfo.py
+++ b/ambari-agent/src/main/python/ambari_agent/HostInfo.py
@@ -33,7 +33,8 @@ from ambari_commons.os_family_impl import OsFamilyImpl
 from resource_management.core import shell
 
 from ambari_agent.HostCheckReportFileHandler import HostCheckReportFileHandler
-
+from AmbariConfig import AmbariConfig
+from resource_management.core.resources.jcepolicyinfo import JcePolicyInfo
 
 logger = logging.getLogger()
 
@@ -285,6 +286,16 @@ class HostInfoLinux(HostInfo):
         result['target'] = realConf
         etcResults.append(result)
 
+  def checkUnlimitedJce(self):
+    if not self.config or not self.config.has_option(AmbariConfig.AMBARI_PROPERTIES_CATEGORY,
'java.home'):
+      return None
+    try:
+      jcePolicyInfo = JcePolicyInfo(self.config.get(AmbariConfig.AMBARI_PROPERTIES_CATEGORY,
'java.home'))
+      return jcePolicyInfo.is_unlimited_key_jce_policy()
+    except:
+      logger.exception('Unable to get information about JCE')
+      return None
+
   def register(self, dict, componentsMapped=True, commandsInProgress=True):
     """ Return various details about the host
     componentsMapped: indicates if any components are mapped to this host
@@ -307,6 +318,7 @@ class HostInfoLinux(HostInfo):
     dict['firewallRunning'] = self.checkFirewall()
     dict['firewallName'] = self.getFirewallName()
     dict['reverseLookup'] = self.checkReverseLookup()
+    dict['hasUnlimitedJcePolicy'] = self.checkUnlimitedJce()
     # If commands are in progress or components are already mapped to this host
     # Then do not perform certain expensive host checks
     if componentsMapped or commandsInProgress:

http://git-wip-us.apache.org/repos/asf/ambari/blob/688d000d/ambari-agent/src/test/python/ambari_agent/TestHostInfo.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestHostInfo.py b/ambari-agent/src/test/python/ambari_agent/TestHostInfo.py
index 67294e0..a00771d 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestHostInfo.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestHostInfo.py
@@ -198,7 +198,8 @@ class TestHostInfo(TestCase):
   @patch.object(HostInfoLinux, 'hadoopVarRunCount')
   @patch.object(HostInfoLinux, 'hadoopVarLogCount')
   @patch.object(HostInfoLinux, 'checkFirewall')
-  def test_hostinfo_register_suse(self, cit_mock, hvlc_mock, hvrc_mock, eac_mock, cf_mock,
jp_mock,
+  @patch.object(HostInfoLinux, 'checkUnlimitedJce')
+  def test_hostinfo_register_suse(self, jce_mock, cit_mock, hvlc_mock, hvrc_mock, eac_mock,
cf_mock, jp_mock,
                              cls_mock, cu_mock, gir_mock, gipbr_mock, gipbn_mock,
                              gpd_mock, aip_mock, aap_mock, whcf_mock, os_umask_mock, get_os_type_mock):
     cit_mock.return_value = True
@@ -215,6 +216,7 @@ class TestHostInfo(TestCase):
     self.assertTrue(cit_mock.called)
     self.assertTrue(os_umask_mock.called)
     self.assertTrue(whcf_mock.called)
+    self.assertTrue(jce_mock.called)
 
     self.assertTrue('agentTimeStampAtReporting' in dict['hostHealth'])
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/688d000d/ambari-common/src/main/python/resource_management/core/resources/jcepolicyinfo.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/core/resources/jcepolicyinfo.py
b/ambari-common/src/main/python/resource_management/core/resources/jcepolicyinfo.py
index a4e4f6e..c269f59 100644
--- a/ambari-common/src/main/python/resource_management/core/resources/jcepolicyinfo.py
+++ b/ambari-common/src/main/python/resource_management/core/resources/jcepolicyinfo.py
@@ -20,28 +20,23 @@ Ambari Agent
 
 """
 
-from resource_management.core.resources.system import Execute
 from resource_management.core.logger import Logger
-
+from resource_management.core import shell
+import subprocess
 
 class JcePolicyInfo:
-  def __init__(self, java_exec, java_home):
-    self.java_exec = java_exec
+  def __init__(self, java_home):
     self.java_home = java_home
     self.jar = "/var/lib/ambari-agent/tools/jcepolicyinfo.jar"
 
   def is_unlimited_key_jce_policy(self):
     Logger.info("Testing the JVM's JCE policy to see it if supports an unlimited key length.")
-
-    try:
-      Execute(self._command("-tu"),
-              environment={'JAVA_HOME': self.java_home},
-              logoutput=True
-              )
-      return True
-    except Exception:
-      return False
-
+    return shell.call(
+      self._command('-tu'),
+      stdout = subprocess.PIPE,
+      stderr = subprocess.PIPE,
+      timeout = 5,
+      quiet = True)[0] == 0
 
   def _command(self, options):
-    return "{0} -jar {1} {2}".format(self.java_exec, self.jar, options)
+    return '{0}/bin/java -jar /var/lib/ambari-agent/tools/jcepolicyinfo.jar {1}'.format(self.java_home,
options)

http://git-wip-us.apache.org/repos/asf/ambari/blob/688d000d/ambari-server/src/main/java/org/apache/ambari/server/agent/AgentEnv.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/AgentEnv.java b/ambari-server/src/main/java/org/apache/ambari/server/agent/AgentEnv.java
index ede3965..515f9fb 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/AgentEnv.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/AgentEnv.java
@@ -64,6 +64,8 @@ public class AgentEnv {
 
   private String firewallName;
 
+  private Boolean hasUnlimitedJcePolicy;
+
   private Boolean reverseLookup;
 
   public Boolean getReverseLookup() {
@@ -154,6 +156,10 @@ public class AgentEnv {
     this.firewallName = firewallName;
   }
 
+  public Boolean getHasUnlimitedJcePolicy() {
+    return hasUnlimitedJcePolicy;
+  }
+
   public static class HostHealth {
     /**
      * Java processes running on the system.  Default empty array.

http://git-wip-us.apache.org/repos/asf/ambari/blob/688d000d/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
index b3088eb..f01df9b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
@@ -2926,6 +2926,7 @@ public class Configuration {
     agentConfigsMap.put(CHECK_REMOTE_MOUNTS.getKey(), getProperty(CHECK_REMOTE_MOUNTS));
     agentConfigsMap.put(CHECK_MOUNTS_TIMEOUT.getKey(), getProperty(CHECK_MOUNTS_TIMEOUT));
     agentConfigsMap.put(ENABLE_AUTO_AGENT_CACHE_UPDATE.getKey(), getProperty(ENABLE_AUTO_AGENT_CACHE_UPDATE));
+    agentConfigsMap.put(JAVA_HOME.getKey(), getProperty(JAVA_HOME));
 
     configsMap = new HashMap<>();
     configsMap.putAll(agentConfigsMap);

http://git-wip-us.apache.org/repos/asf/ambari/blob/688d000d/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-START/scripts/shared_initialization.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-START/scripts/shared_initialization.py
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-START/scripts/shared_initialization.py
index 3c36962..148d235 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-START/scripts/shared_initialization.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-START/scripts/shared_initialization.py
@@ -230,7 +230,7 @@ def setup_unlimited_key_jce_policy():
     Logger.debug("Skipping unlimited key JCE policy check and setup since it is not required")
 
   else:
-    jcePolicyInfo = JcePolicyInfo(java_exec=params.java_exec, java_home=params.java_home)
+    jcePolicyInfo = JcePolicyInfo(params.java_home)
 
     if jcePolicyInfo.is_unlimited_key_jce_policy():
       Logger.info("The unlimited key JCE policy is required, and appears to have been installed.")

http://git-wip-us.apache.org/repos/asf/ambari/blob/688d000d/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java
index 3f62366..5feb3cc 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java
@@ -215,7 +215,7 @@ public class AgentResourceTest extends RandomPortJerseyTest {
             ", \"existingUsers\": "+ ExistingUserJSON +
             ", \"umask\": \"18\", \"installedPackages\": "+
             PackageDetailJSON +", \"stackFoldersAndFiles\": "+ DirectoryJSON +
-            ", \"firewallRunning\": \"true\", \"firewallName\": \"iptables\", \"transparentHugePage\":
\"never\"}";
+            ", \"firewallRunning\": \"true\", \"firewallName\": \"iptables\", \"transparentHugePage\":
\"never\", \"hasUnlimitedJcePolicy\" : true}";
     AgentEnv.Directory[] dirs = getJsonFormString(
             DirectoryJSON, AgentEnv.Directory[].class);
     Assert.assertEquals("/var/lib", dirs[0].getName());
@@ -251,6 +251,7 @@ public class AgentResourceTest extends RandomPortJerseyTest {
             AgentEnvJSON, AgentEnv.class);
     Assert.assertTrue(18 == agentEnv.getUmask());
     Assert.assertEquals("never", agentEnv.getTransparentHugePage());
+    Assert.assertTrue(agentEnv.getHasUnlimitedJcePolicy());
     Assert.assertTrue(Boolean.TRUE == agentEnv.getFirewallRunning());
     Assert.assertEquals("iptables", agentEnv.getFirewallName());
     Assert.assertEquals("/etc/alternatives/hdfs-conf", agentEnv.getAlternatives()[0].getName());

http://git-wip-us.apache.org/repos/asf/ambari/blob/688d000d/ambari-web/app/controllers/global/update_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/update_controller.js b/ambari-web/app/controllers/global/update_controller.js
index e53f79d..9b8614d 100644
--- a/ambari-web/app/controllers/global/update_controller.js
+++ b/ambari-web/app/controllers/global/update_controller.js
@@ -216,7 +216,7 @@ App.UpdateController = Em.Controller.extend({
     var testUrl = this.get('HOSTS_TEST_URL'),
         self = this,
         hostDetailsFilter = '',
-        realUrl = '/hosts?fields=Hosts/rack_info,Hosts/host_name,Hosts/maintenance_state,Hosts/public_host_name,Hosts/cpu_count,Hosts/ph_cpu_count,'
+
+        realUrl = '/hosts?fields=Hosts/rack_info,Hosts/host_name,Hosts/maintenance_state,Hosts/public_host_name,Hosts/cpu_count,Hosts/ph_cpu_count,Hosts/last_agent_env,'
+
             'alerts_summary,Hosts/host_status,Hosts/last_heartbeat_time,Hosts/ip,host_components/HostRoles/state,host_components/HostRoles/maintenance_state,'
+
             'host_components/HostRoles/stale_configs,host_components/HostRoles/service_name,host_components/HostRoles/display_name,host_components/HostRoles/desired_admin_state,'
+
             '<metrics>Hosts/total_mem<hostDetailsParams><stackVersions>&minimal_response=true',

http://git-wip-us.apache.org/repos/asf/ambari/blob/688d000d/ambari-web/app/mappers/hosts_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/hosts_mapper.js b/ambari-web/app/mappers/hosts_mapper.js
index e4dd08f..203cd67 100644
--- a/ambari-web/app/mappers/hosts_mapper.js
+++ b/ambari-web/app/mappers/hosts_mapper.js
@@ -38,6 +38,7 @@ App.hostsMapper = App.QuickDataMapper.create({
     cpu: 'Hosts.cpu_count',
     cpu_physical: 'Hosts.ph_cpu_count',
     memory: 'Hosts.total_mem',
+    has_jce_policy: "Hosts.last_agent_env.hasUnlimitedJcePolicy",
     disk_info: 'Hosts.disk_info',
     disk_total: 'metrics.disk.disk_total',
     disk_free: 'metrics.disk.disk_free',

http://git-wip-us.apache.org/repos/asf/ambari/blob/688d000d/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 8173ca3..971a1f3 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -2620,6 +2620,7 @@ Em.I18n.translations = {
   'hosts.host.summary.header':'Summary',
   'hosts.host.summary.hostname':'Hostname',
   'hosts.host.summary.agentHeartbeat':'Heartbeat',
+  'hosts.host.summary.agentHasJce':'Unlimited JCE installed',
   'hosts.host.summary.hostMetrics':'Host Metrics',
   'hosts.host.summary.hostLogMetrics':'Host Log Metrics',
   'hosts.host.summary.addComponent':'Add Component',

http://git-wip-us.apache.org/repos/asf/ambari/blob/688d000d/ambari-web/app/models/host.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/host.js b/ambari-web/app/models/host.js
index 1b7b326..58ffd41 100644
--- a/ambari-web/app/models/host.js
+++ b/ambari-web/app/models/host.js
@@ -39,6 +39,7 @@ App.Host = DS.Model.extend({
   healthStatus: DS.attr('string'),
   lastHeartBeatTime: DS.attr('number'),
   rawLastHeartBeatTime: DS.attr('number'),
+  hasJcePolicy: DS.attr('string'),
   osType: DS.attr("string"),
   diskInfo: DS.attr('object'),
   loadOne:DS.attr('number'),

http://git-wip-us.apache.org/repos/asf/ambari/blob/688d000d/ambari-web/app/templates/main/host/summary.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/host/summary.hbs b/ambari-web/app/templates/main/host/summary.hbs
index 7cf3314..6365849 100644
--- a/ambari-web/app/templates/main/host/summary.hbs
+++ b/ambari-web/app/templates/main/host/summary.hbs
@@ -168,6 +168,9 @@
 
                         <dt class="summary-cur-ver-label">{{t hosts.host.summary.currentVersion}}:</dt>
                           <dd class="summary-cur-ver-value">&nbsp;{{view.content.currentVersion}}</dd>
+
+                        <dt class="summary-agent-jce-label">{{t hosts.host.summary.agentHasJce}}:</dt>
+                          <dd class="summary-agent-jce-value">&nbsp;{{view.content.hasJcePolicy}}</dd>
                     </dl>
                 </div>
             </div>


Mime
View raw message