You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jo...@apache.org on 2014/08/19 17:46:26 UTC
[1/9] git commit: AMBARI-6910 IE doesn't handle download configs
errors 2. (Max Shepel via ababiichuk)
Repository: ambari
Updated Branches:
refs/heads/branch-alerts-dev b2f25b6d7 -> 68042051b
AMBARI-6910 IE doesn't handle download configs errors 2. (Max Shepel via ababiichuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/40820f4f
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/40820f4f
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/40820f4f
Branch: refs/heads/branch-alerts-dev
Commit: 40820f4fd8fe3690376c1c73a0aea29992cb08b7
Parents: 3cede90
Author: aBabiichuk <ab...@cybervisiontech.com>
Authored: Tue Aug 19 17:55:49 2014 +0300
Committer: Jonathan Hurley <jh...@hortonworks.com>
Committed: Tue Aug 19 11:39:55 2014 -0400
----------------------------------------------------------------------
ambari-web/app/utils/components.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/40820f4f/ambari-web/app/utils/components.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/components.js b/ambari-web/app/utils/components.js
index e72cc04..a7fadec 100644
--- a/ambari-web/app/utils/components.js
+++ b/ambari-web/app/utils/components.js
@@ -109,7 +109,7 @@ module.exports = {
} else {
errorMessage += Em.I18n.t('services.service.actions.downloadClientConfigs.fail.popup.body.noErrorMessage').format(data.displayName);
}
- errorMessage += Em.I18n.t('services.service.actions.downloadClientConfigs.fail.popup.body.question');
+ errorMessage += isNoConfigs ? '' : Em.I18n.t('services.service.actions.downloadClientConfigs.fail.popup.body.question');
} else {
errorMessage += Em.I18n.t('services.service.actions.downloadClientConfigs.fail.popup.body.noErrorMessage').format(data.displayName) +
Em.I18n.t('services.service.actions.downloadClientConfigs.fail.popup.body.question');
[6/9] git commit: AMBARI-6910 IE doesn't handle download configs
errors
Posted by jo...@apache.org.
AMBARI-6910 IE doesn't handle download configs errors
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/1718bab4
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/1718bab4
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/1718bab4
Branch: refs/heads/branch-alerts-dev
Commit: 1718bab499691411a281ad4035aceb585510adda
Parents: 0e9a676
Author: aBabiichuk <ab...@cybervisiontech.com>
Authored: Tue Aug 19 14:44:03 2014 +0300
Committer: Jonathan Hurley <jh...@hortonworks.com>
Committed: Tue Aug 19 11:39:55 2014 -0400
----------------------------------------------------------------------
ambari-web/app/messages.js | 4 ++-
ambari-web/app/utils/components.js | 55 +++++++++++++++++++++------------
2 files changed, 39 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/1718bab4/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 5bd9a87..0a9fafd 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -1187,7 +1187,9 @@ Em.I18n.translations = {
'services.service.actions.downloadClientConfigs':'Download Client Configs',
'services.service.actions.downloadClientConfigs.fail.noConfigFile':'No configuration files defined for the component',
'services.service.actions.downloadClientConfigs.fail.popup.header':'{0} Configs',
- 'services.service.actions.downloadClientConfigs.fail.popup.body':'Generation of {0} configurations file has failed with {1} error: <br /><pre><span class="text-error">{2}</span></pre>Do you want to try again?',
+ 'services.service.actions.downloadClientConfigs.fail.popup.body.noErrorMessage':'Generation of {0} configurations file has failed. ',
+ 'services.service.actions.downloadClientConfigs.fail.popup.body.errorMessage':'Generation of {0} configurations file has failed with {1} error: <br /><pre><span class="text-error">{2}</span></pre>',
+ 'services.service.actions.downloadClientConfigs.fail.popup.body.question':'Do you want to try again?',
'services.service.actions.run.rebalancer':'Run Rebalancer',
'services.service.actions.run.rebalanceHdfsNodes':'Rebalance HDFS',
'services.service.actions.run.rebalanceHdfsNodes.title':'HDFS Rebalance',
http://git-wip-us.apache.org/repos/asf/ambari/blob/1718bab4/ambari-web/app/utils/components.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/components.js b/ambari-web/app/utils/components.js
index 3fb8d87..e72cc04 100644
--- a/ambari-web/app/utils/components.js
+++ b/ambari-web/app/utils/components.js
@@ -95,28 +95,45 @@ module.exports = {
var url = App.get('apiPrefix') + '/clusters/' + App.router.getClusterName() + '/' +
(isForHost ? 'hosts/' + data.hostName + '/host_components/' : 'services/' + data.serviceName + '/components/') +
data.componentName + '?format=client_config_tar';
- var self = this;
- $.fileDownload(url).fail(function (error) {
- var errorObj = JSON.parse($(error).text());
- var isNoConfigs = errorObj.message.contains(Em.I18n.t('services.service.actions.downloadClientConfigs.fail.noConfigFile'));
- var errorMessage = isNoConfigs ? Em.I18n.t('services.service.actions.downloadClientConfigs.fail.noConfigFile') :
- Em.I18n.t('services.service.actions.downloadClientConfigs.fail.popup.body').format(data.displayName, errorObj.status, errorObj.message);
- App.ModalPopup.show({
- header: Em.I18n.t('services.service.actions.downloadClientConfigs.fail.popup.header').format(data.displayName),
- bodyClass: Ember.View.extend({
- template: Em.Handlebars.compile(errorMessage)
- }),
- secondary: isNoConfigs ? false : Em.I18n.t('common.cancel'),
- onPrimary: function () {
- this.hide();
- if (!isNoConfigs) {
- self.downloadClientConfigs({
- context: Em.Object.create(data)
- })
+ try {
+ var self = this;
+ $.fileDownload(url).fail(function (error) {
+ var errorMessage = '';
+ var isNoConfigs = false;
+ if (error && $(error).text()) {
+ var errorObj = JSON.parse($(error).text());
+ if (errorObj && errorObj.message && errorObj.status) {
+ isNoConfigs = errorObj.message.indexOf(Em.I18n.t('services.service.actions.downloadClientConfigs.fail.noConfigFile')) !== -1;
+ errorMessage += isNoConfigs ? Em.I18n.t('services.service.actions.downloadClientConfigs.fail.noConfigFile') :
+ Em.I18n.t('services.service.actions.downloadClientConfigs.fail.popup.body.errorMessage').format(data.displayName, errorObj.status, errorObj.message);
+ } else {
+ errorMessage += Em.I18n.t('services.service.actions.downloadClientConfigs.fail.popup.body.noErrorMessage').format(data.displayName);
}
+ errorMessage += Em.I18n.t('services.service.actions.downloadClientConfigs.fail.popup.body.question');
+ } else {
+ errorMessage += Em.I18n.t('services.service.actions.downloadClientConfigs.fail.popup.body.noErrorMessage').format(data.displayName) +
+ Em.I18n.t('services.service.actions.downloadClientConfigs.fail.popup.body.question');
}
+ App.ModalPopup.show({
+ header: Em.I18n.t('services.service.actions.downloadClientConfigs.fail.popup.header').format(data.displayName),
+ bodyClass: Ember.View.extend({
+ template: Em.Handlebars.compile(errorMessage)
+ }),
+ secondary: isNoConfigs ? false : Em.I18n.t('common.cancel'),
+ onPrimary: function () {
+ this.hide();
+ if (!isNoConfigs) {
+ self.downloadClientConfigs({
+ context: Em.Object.create(data)
+ })
+ }
+ }
+ });
});
- });
+ } catch (err) {
+ var newWindow = window.open(url);
+ newWindow.focus();
+ }
}
};
\ No newline at end of file
[8/9] git commit: AMBARI-6860 - Alerts: Add Ability to Invalidate
Definition Hash For An Agent (jonathanhurley)
Posted by jo...@apache.org.
AMBARI-6860 - Alerts: Add Ability to Invalidate Definition Hash For An Agent (jonathanhurley)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/89922458
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/89922458
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/89922458
Branch: refs/heads/branch-alerts-dev
Commit: 8992245870a35925bae84f851147f901e21ba759
Parents: 2edb076
Author: Jonathan Hurley <jh...@hortonworks.com>
Authored: Thu Aug 14 09:22:49 2014 -0400
Committer: Jonathan Hurley <jh...@hortonworks.com>
Committed: Tue Aug 19 11:42:42 2014 -0400
----------------------------------------------------------------------
.../java/org/apache/ambari/server/controller/AmbariServer.java | 1 +
.../controller/internal/AlertDefinitionResourceProvider.java | 1 -
ambari-server/src/main/resources/properties.json | 3 +--
3 files changed, 2 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/89922458/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
index 489fbb2..687a3d0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
@@ -91,6 +91,7 @@ import org.apache.ambari.server.security.unsecured.rest.CertificateSign;
import org.apache.ambari.server.security.unsecured.rest.ConnectionInfo;
import org.apache.ambari.server.state.Clusters;
import org.apache.ambari.server.state.ConfigHelper;
+import org.apache.ambari.server.state.alert.AlertDefinitionHash;
import org.apache.ambari.server.utils.StageUtils;
import org.apache.ambari.server.utils.VersionUtils;
import org.apache.ambari.server.view.ViewRegistry;
http://git-wip-us.apache.org/repos/asf/ambari/blob/89922458/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProvider.java
index 9b0ce1c..bed25e7 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProvider.java
@@ -72,7 +72,6 @@ public class AlertDefinitionResourceProvider extends AbstractControllerResourceP
protected static final String ALERT_DEF_COMPONENT_NAME = "AlertDefinition/component_name";
protected static final String ALERT_DEF_ENABLED = "AlertDefinition/enabled";
protected static final String ALERT_DEF_SCOPE = "AlertDefinition/scope";
- protected static final String ALERT_DEF_UUID = "AlertDefinition/uuid";
protected static final String ALERT_DEF_SOURCE = "AlertDefinition/source";
protected static final String ALERT_DEF_SOURCE_TYPE = "AlertDefinition/source/type";
http://git-wip-us.apache.org/repos/asf/ambari/blob/89922458/ambari-server/src/main/resources/properties.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/properties.json b/ambari-server/src/main/resources/properties.json
index 6f79413..aa2bf71 100644
--- a/ambari-server/src/main/resources/properties.json
+++ b/ambari-server/src/main/resources/properties.json
@@ -420,8 +420,7 @@
"AlertDefinition/interval",
"AlertDefinition/enabled",
"AlertDefinition/scope",
- "AlertDefinition/source",
- "AlertDefinition/uuid"
+ "AlertDefinition/source"
],
"Controller":[
"Controllers/name",
[5/9] git commit: AMBARI-6899. Add unit test to ensure iptables stay
off (if they were initially turned off) (dlysnichenko)
Posted by jo...@apache.org.
AMBARI-6899. Add unit test to ensure iptables stay off (if they were initially turned off) (dlysnichenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/3cede908
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/3cede908
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/3cede908
Branch: refs/heads/branch-alerts-dev
Commit: 3cede908e6ca3b18e08a0901ad4539c1348fbc35
Parents: cfc9440
Author: Lisnichenko Dmitro <dl...@hortonworks.com>
Authored: Tue Aug 19 17:18:22 2014 +0300
Committer: Jonathan Hurley <jh...@hortonworks.com>
Committed: Tue Aug 19 11:39:55 2014 -0400
----------------------------------------------------------------------
.../src/main/python/ambari_agent/HostInfo.py | 104 +-------------
.../test/python/ambari_agent/TestHostInfo.py | 60 +++-----
.../python/ambari_agent/TestRegistration.py | 3 +-
.../src/main/python/ambari_commons/__init__.py | 3 +
.../src/main/python/ambari_commons/firewall.py | 140 +++++++++++++++++++
ambari-server/src/main/python/ambari-server.py | 113 +++------------
.../src/test/python/TestAmbariServer.py | 133 ++++++++++++------
7 files changed, 277 insertions(+), 279 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/3cede908/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 bd0c286..ff91dc4 100644
--- a/ambari-agent/src/main/python/ambari_agent/HostInfo.py
+++ b/ambari-agent/src/main/python/ambari_agent/HostInfo.py
@@ -32,23 +32,14 @@ import hostname
from PackagesAnalyzer import PackagesAnalyzer
from HostCheckReportFileHandler import HostCheckReportFileHandler
from Hardware import Hardware
-from ambari_commons import OSCheck, OSConst
+from ambari_commons import OSCheck, OSConst, Firewall
import socket
logger = logging.getLogger()
-# OS info
-OS_VERSION = OSCheck().get_os_major_version()
-OS_TYPE = OSCheck.get_os_type()
-OS_FAMILY = OSCheck.get_os_family()
-
# service cmd
SERVICE_CMD = "/sbin/service"
-# on ubuntu iptables service is called ufw
-if OS_FAMILY == OSConst.DEBIAN_FAMILY:
- SERVICE_CMD = "/usr/sbin/service"
-
class HostInfo:
# List of project names to be used to find alternatives folders etc.
@@ -324,25 +315,8 @@ class HostInfo:
else:
return ""
- def getFirewallObject(self):
- if OS_TYPE == OSConst.OS_UBUNTU:
- return UbuntuFirewallChecks()
- elif OS_TYPE == OSConst.OS_FEDORA and int(OS_VERSION) >= 18:
- return Fedora18FirewallChecks()
- elif OS_FAMILY == OSConst.SUSE_FAMILY:
- return SuseFirewallChecks()
- else:
- return FirewallChecks()
-
- def getFirewallObjectTypes(self):
- # To support test code, so tests can loop through the types
- return (FirewallChecks,
- UbuntuFirewallChecks,
- Fedora18FirewallChecks,
- SuseFirewallChecks)
-
def checkIptables(self):
- return self.getFirewallObject().check_iptables()
+ return Firewall().getFirewallObject().check_iptables()
""" Return various details about the host
componentsMapped: indicates if any components are mapped to this host
@@ -425,80 +399,6 @@ class HostInfo:
pass
return False
-
-class FirewallChecks(object):
- def __init__(self):
- self.FIREWALL_SERVICE_NAME = "iptables"
- self.SERVICE_CMD = SERVICE_CMD
- self.SERVICE_SUBCMD = "status"
-
- def get_command(self):
- return "%s %s %s" % (self.SERVICE_CMD, self.FIREWALL_SERVICE_NAME, self.SERVICE_SUBCMD)
-
- def check_result(self, retcode, out, err):
- return retcode == 0
-
- def check_iptables(self):
- retcode, out, err = self.run_os_command(self.get_command())
- return self.check_result(retcode, out, err)
-
- def get_running_result(self):
- # To support test code. Expected ouput from run_os_command.
- return (0, "", "")
-
- def get_stopped_result(self):
- # To support test code. Expected output from run_os_command.
- return (3, "", "")
-
- def run_os_command(self, cmd):
- if type(cmd) == str:
- cmd = shlex.split(cmd)
-
- try:
- process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stdin=subprocess.PIPE,
- stderr=subprocess.PIPE)
- (stdoutdata, stderrdata) = process.communicate()
- return process.returncode, stdoutdata, stderrdata
- except OSError:
- return self.get_stopped_result()
-
-
-class UbuntuFirewallChecks(FirewallChecks):
- def __init__(self):
- super(UbuntuFirewallChecks, self).__init__()
-
- self.FIREWALL_SERVICE_NAME = "ufw"
- self.SERVICE_CMD = 'service'
-
- def check_result(self, retcode, out, err):
- # On ubuntu, the status command returns 0 whether running or not
- return out and len(out) > 0 and out.strip() != "ufw stop/waiting"
-
- def get_running_result(self):
- # To support test code. Expected ouput from run_os_command.
- return (0, "ufw start/running", "")
-
- def get_stopped_result(self):
- # To support test code. Expected output from run_os_command.
- return (0, "ufw stop/waiting", "")
-
-
-class Fedora18FirewallChecks(FirewallChecks):
- def __init__(self):
- self.FIREWALL_SERVICE_NAME = "firewalld.service"
-
- def get_command(self):
- return "systemctl is-active firewalld.service"
-
-
-class SuseFirewallChecks(FirewallChecks):
- def __init__(self):
- self.FIREWALL_SERVICE_NAME = "SuSEfirewall2"
-
- def get_command(self):
- return "/sbin/SuSEfirewall2 status"
-
-
def main(argv=None):
h = HostInfo()
struct = {}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3cede908/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 ce4604d..08e7b47 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestHostInfo.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestHostInfo.py
@@ -32,11 +32,10 @@ with patch("platform.linux_distribution", return_value = ('redhat','11','Final')
from ambari_agent.HostCheckReportFileHandler import HostCheckReportFileHandler
from ambari_agent.PackagesAnalyzer import PackagesAnalyzer
from ambari_agent.HostInfo import HostInfo
- from ambari_agent.HostInfo import FirewallChecks
from ambari_agent.Hardware import Hardware
from ambari_agent.AmbariConfig import AmbariConfig
from resource_management.core.system import System
- from ambari_commons import OSCheck
+ from ambari_commons import OSCheck, Firewall, FirewallChecks ,OSConst
@patch.object(System, "os_family", new = 'redhat')
class TestHostInfo(TestCase):
@@ -269,6 +268,7 @@ class TestHostInfo(TestCase):
hostInfo = HostInfo()
dict = {}
hostInfo.register(dict, False, False)
+ self.assertTrue(cit_mock.called)
self.assertTrue(gir_mock.called)
self.assertTrue(gpd_mock.called)
self.assertTrue(aip_mock.called)
@@ -321,6 +321,7 @@ class TestHostInfo(TestCase):
self.verifyReturnedValues(dict)
self.assertTrue(os_umask_mock.call_count == 2)
+ cit_mock.reset_mock()
hostInfo = HostInfo()
dict = {}
hostInfo.register(dict, False, False)
@@ -328,6 +329,7 @@ class TestHostInfo(TestCase):
self.assertTrue(gpd_mock.called)
self.assertTrue(aip_mock.called)
self.assertTrue(cit_mock.called)
+ self.assertEqual(1, cit_mock.call_count)
for existingPkg in ["pkg1", "pkg2"]:
self.assertTrue(existingPkg in dict['installedPackages'])
@@ -515,13 +517,16 @@ class TestHostInfo(TestCase):
self.assertEquals(result[0]['name'], 'config1')
self.assertEquals(result[0]['target'], 'real_path_to_conf')
+ @patch.object(OSCheck, "get_os_family")
+ @patch.object(OSCheck, "get_os_type")
+ @patch.object(OSCheck, "get_os_major_version")
@patch.object(FirewallChecks, "run_os_command")
- def test_IpTablesRunning(self, run_os_command_mock):
- hostInfo = HostInfo()
- for firewallType in hostInfo.getFirewallObjectTypes():
- firewall = firewallType()
- run_os_command_mock.return_value = firewall.get_running_result()
- self.assertTrue(firewall.check_iptables())
+ def test_IpTablesRunning(self, run_os_command_mock, get_os_major_version_mock, get_os_type_mock, get_os_family_mock):
+ get_os_type_mock.return_value = ""
+ get_os_family_mock.return_value = OSConst.REDHAT_FAMILY
+ run_os_command_mock.return_value = 0, "Table: filter", ""
+ self.assertTrue(Firewall().getFirewallObject().check_iptables())
+
@patch.object(HostInfo, "osdiskAvailableSpace")
def test_createAlerts(self, osdiskAvailableSpace_mock):
@@ -538,30 +543,6 @@ class TestHostInfo(TestCase):
self.assertEquals(1, len(result))
-
- @patch("subprocess.Popen")
- def test_run_os_command_exception(self, popen_mock):
- def base_test():
- return "base test"
-
- def sub_test():
- return "output 1", "error 1"
-
- base_test.communicate = sub_test
- base_test.returncode = 0
-
- hostInfo = HostInfo()
- for firewallType in hostInfo.getFirewallObjectTypes():
- firewall = firewallType()
-
- popen_mock.side_effect = None
- popen_mock.return_value = base_test
- self.assertTrue(firewall.check_iptables())
-
- popen_mock.side_effect = OSError('File not found')
- popen_mock.return_value = None
- self.assertFalse(firewall.check_iptables())
-
@patch.object(socket, "getfqdn")
@patch.object(socket, "gethostbyname")
@patch.object(socket, "gethostname")
@@ -586,13 +567,16 @@ class TestHostInfo(TestCase):
self.assertFalse(hostInfo.checkReverseLookup())
+
+ @patch.object(OSCheck, "get_os_family")
+ @patch.object(OSCheck, "get_os_type")
+ @patch.object(OSCheck, "get_os_major_version")
@patch.object(FirewallChecks, "run_os_command")
- def test_IpTablesStopped(self, run_os_command_mock):
- hostInfo = HostInfo()
- for firewallType in hostInfo.getFirewallObjectTypes():
- firewall = firewallType()
- run_os_command_mock.return_value = firewall.get_stopped_result()
- self.assertFalse(firewall.check_iptables())
+ def test_IpTablesStopped(self, run_os_command_mock, get_os_major_version_mock, get_os_type_mock, get_os_family_mock):
+ get_os_type_mock.return_value = ""
+ get_os_family_mock.return_value = OSConst.REDHAT_FAMILY
+ run_os_command_mock.return_value = 3, "", ""
+ self.assertFalse(Firewall().getFirewallObject().check_iptables())
@patch("os.path.isfile")
@patch('__builtin__.open')
http://git-wip-us.apache.org/repos/asf/ambari/blob/3cede908/ambari-agent/src/test/python/ambari_agent/TestRegistration.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestRegistration.py b/ambari-agent/src/test/python/ambari_agent/TestRegistration.py
index afd82b9..2a9f716 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestRegistration.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestRegistration.py
@@ -28,8 +28,7 @@ with patch("platform.linux_distribution", return_value = ('Suse','11','Final')):
from ambari_agent.Register import Register
from ambari_agent.AmbariConfig import AmbariConfig
from ambari_agent.HostInfo import HostInfo
- from ambari_agent.HostInfo import FirewallChecks
- from ambari_commons import OSCheck
+ from ambari_commons import OSCheck, Firewall, FirewallChecks
class TestRegistration(TestCase):
@patch.object(FirewallChecks, "run_os_command")
http://git-wip-us.apache.org/repos/asf/ambari/blob/3cede908/ambari-common/src/main/python/ambari_commons/__init__.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/ambari_commons/__init__.py b/ambari-common/src/main/python/ambari_commons/__init__.py
index b759e76..df4d7d6 100644
--- a/ambari-common/src/main/python/ambari_commons/__init__.py
+++ b/ambari-common/src/main/python/ambari_commons/__init__.py
@@ -19,8 +19,11 @@ limitations under the License.
'''
from ambari_commons.os_check import OSCheck, OSConst
+from ambari_commons.firewall import Firewall, FirewallChecks
__all__ = [
'OSCheck',
'OSConst',
+ 'Firewall',
+ 'FirewallChecks'
]
http://git-wip-us.apache.org/repos/asf/ambari/blob/3cede908/ambari-common/src/main/python/ambari_commons/firewall.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/ambari_commons/firewall.py b/ambari-common/src/main/python/ambari_commons/firewall.py
new file mode 100644
index 0000000..1cf69ee
--- /dev/null
+++ b/ambari-common/src/main/python/ambari_commons/firewall.py
@@ -0,0 +1,140 @@
+#!/usr/bin/env python
+
+'''
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you 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.
+'''
+
+import subprocess
+import shlex
+from ambari_commons import OSCheck, OSConst
+
+
+class Firewall(object):
+ def __init__(self):
+ # OS info
+ self.OS_VERSION = OSCheck().get_os_major_version()
+ self.OS_TYPE = OSCheck.get_os_type()
+ self.OS_FAMILY = OSCheck.get_os_family()
+
+ def getFirewallObject(self):
+ if self.OS_TYPE == OSConst.OS_UBUNTU:
+ return UbuntuFirewallChecks()
+ elif self.OS_TYPE == OSConst.OS_FEDORA and int(self.OS_VERSION) >= 18:
+ return Fedora18FirewallChecks()
+ elif self.OS_FAMILY == OSConst.SUSE_FAMILY:
+ return SuseFirewallChecks()
+ else:
+ return FirewallChecks()
+
+class FirewallChecks(object):
+ def __init__(self):
+ self.FIREWALL_SERVICE_NAME = "iptables"
+ self.SERVICE_SUBCMD = "status"
+ # service cmd
+ self.SERVICE_CMD = "/sbin/service"
+ self.returncode = None
+ self.stdoutdata = None
+ self.stderrdata = None
+
+ def get_command(self):
+ return "%s %s %s" % (self.SERVICE_CMD, self.FIREWALL_SERVICE_NAME, self.SERVICE_SUBCMD)
+
+ def check_result(self, retcode, out, err):
+ result = False
+ if retcode == 3:
+ result = False
+ elif retcode == 0:
+ if "Table: filter" in out:
+ result = True
+ return result
+
+ def check_iptables(self):
+ try:
+ retcode, out, err = self.run_os_command(self.get_command())
+ return self.check_result(retcode, out, err)
+ except OSError:
+ return False
+
+ def run_os_command(self, cmd):
+ if type(cmd) == str:
+ cmd = shlex.split(cmd)
+
+ process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stdin=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ (stdoutdata, stderrdata) = process.communicate()
+ self.returncode = process.returncode
+ self.stdoutdata = stdoutdata
+ self.stderrdata = stderrdata
+ return self.returncode, self.stdoutdata, self.stderrdata
+
+
+
+class UbuntuFirewallChecks(FirewallChecks):
+ def __init__(self):
+ super(UbuntuFirewallChecks, self).__init__()
+ self.FIREWALL_SERVICE_NAME = "ufw"
+
+ def get_command(self):
+ return "%s %s" % (self.FIREWALL_SERVICE_NAME, self.SERVICE_SUBCMD)
+
+ def check_result(self, retcode, out, err):
+ # On ubuntu, the status command returns 0 whether running or not
+ result = False
+ if retcode == 0:
+ if "Status: inactive" in out:
+ result = False
+ elif "Status: active" in out:
+ result = True
+ return result
+
+ def get_running_result(self):
+ # To support test code. Expected ouput from run_os_command.
+ return (0, "ufw start/running", "")
+
+ def get_stopped_result(self):
+ # To support test code. Expected output from run_os_command.
+ return (0, "ufw stop/waiting", "")
+
+
+class Fedora18FirewallChecks(FirewallChecks):
+
+ def get_command(self):
+ return "systemctl is-active iptables"
+
+ def check_result(self, retcode, out, err):
+ result = False
+ if retcode == 0:
+ if "active" in out:
+ result = True
+ return result
+
+class SuseFirewallChecks(FirewallChecks):
+ def __init__(self):
+ self.FIREWALL_SERVICE_NAME = "SuSEfirewall2"
+ self.SERVICE_SUBCMD = "status"
+
+ def get_command(self):
+ return "%s %s" % (self.FIREWALL_SERVICE_NAME, self.SERVICE_SUBCMD)
+
+ def check_result(self, retcode, out, err):
+ result = False
+ if retcode == 0:
+ if "SuSEfirewall2 not active" in out:
+ result = False
+ elif "### iptables" in out:
+ result = True
+ return result
http://git-wip-us.apache.org/repos/asf/ambari/blob/3cede908/ambari-server/src/main/python/ambari-server.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari-server.py b/ambari-server/src/main/python/ambari-server.py
index 079b29f..bb9870b 100755
--- a/ambari-server/src/main/python/ambari-server.py
+++ b/ambari-server/src/main/python/ambari-server.py
@@ -41,7 +41,7 @@ import random
import pwd
from ambari_server.resourceFilesKeeper import ResourceFilesKeeper, KeeperException
import json
-from ambari_commons import OSCheck, OSConst
+from ambari_commons import OSCheck, OSConst, Firewall
from ambari_server import utils
# debug settings
@@ -427,100 +427,6 @@ ASF_LICENSE_HEADER = '''
# limitations under the License.
'''
-
-class FirewallChecks(object):
- def __init__(self):
-
- self.FIREWALL_SERVICE_NAME = "iptables"
- self.SERVICE_CMD = SERVICE_CMD
- self.SERVICE_SUBCMD = "status"
-
- def get_command(self):
- return "%s %s %s" % (self.SERVICE_CMD, self.FIREWALL_SERVICE_NAME, self.SERVICE_SUBCMD)
-
- def check_result(self, retcode, out, err):
- return retcode == 0
-
- def check_iptables(self):
- retcode, out, err = run_os_command(self.get_command())
- if err and len(err) > 0:
- print err
- if self.check_result(retcode, out, err):
- print_warning_msg("%s is running. Confirm the necessary Ambari ports are accessible. " %
- self.FIREWALL_SERVICE_NAME +
- "Refer to the Ambari documentation for more details on ports.")
- ok = get_YN_input("OK to continue [y/n] (y)? ", True)
- if not ok:
- raise FatalException(1, None)
-
- def get_running_result(self):
- # To support test code. Expected ouput from run_os_command.
- return (0, "", "")
-
- def get_stopped_result(self):
- # To support test code. Expected output from run_os_command.
- return (3, "", "")
-
-
-class UbuntuFirewallChecks(FirewallChecks):
- def __init__(self):
- super(UbuntuFirewallChecks, self).__init__()
-
- self.FIREWALL_SERVICE_NAME = "ufw"
- self.SERVICE_CMD = utils.locate_file('service', '/usr/sbin')
-
- def check_result(self, retcode, out, err):
- # On ubuntu, the status command returns 0 whether running or not
- return out and len(out) > 0 and out.strip() != "ufw stop/waiting"
-
- def get_running_result(self):
- # To support test code. Expected ouput from run_os_command.
- return (0, "ufw start/running", "")
-
- def get_stopped_result(self):
- # To support test code. Expected output from run_os_command.
- return (0, "ufw stop/waiting", "")
-
-
-class Fedora18FirewallChecks(FirewallChecks):
- def __init__(self):
- self.FIREWALL_SERVICE_NAME = "firewalld.service"
-
- def get_command(self):
- return "systemctl is-active firewalld.service"
-
-
-class OpenSuseFirewallChecks(FirewallChecks):
- def __init__(self):
- self.FIREWALL_SERVICE_NAME = "SuSEfirewall2"
-
- def get_command(self):
- return "/sbin/SuSEfirewall2 status"
-
-
-def get_firewall_object():
- if OS_TYPE == OSConst.OS_UBUNTU:
- return UbuntuFirewallChecks()
- elif OS_TYPE == OSConst.OS_FEDORA and int(OS_VERSION) >= 18:
- return Fedora18FirewallChecks()
- elif OS_TYPE == OSConst.OS_OPENSUSE:
- return OpenSuseFirewallChecks()
- else:
- return FirewallChecks()
-
-
-def get_firewall_object_types():
- # To support test code, so tests can loop through the types
- return (FirewallChecks,
- UbuntuFirewallChecks,
- Fedora18FirewallChecks,
- OpenSuseFirewallChecks)
-
-
-def check_iptables():
- return get_firewall_object().check_iptables()
-
-
def get_conf_dir():
try:
conf_dir = os.environ[AMBARI_CONF_VAR]
@@ -2230,8 +2136,21 @@ def setup(args):
err = 'Failed to create user. Exiting.'
raise FatalException(retcode, err)
- print 'Checking iptables...'
- check_iptables()
+ print 'Checking firewall...'
+ firewall_obj = Firewall().getFirewallObject()
+ firewall_on = firewall_obj.check_iptables()
+ if firewall_obj.stderrdata and len(firewall_obj.stderrdata) > 0:
+ print firewall_obj.stderrdata
+ if firewall_on:
+ print_warning_msg("%s is running. Confirm the necessary Ambari ports are accessible. " %
+ firewall_obj.FIREWALL_SERVICE_NAME +
+ "Refer to the Ambari documentation for more details on ports.")
+ ok = get_YN_input("OK to continue [y/n] (y)? ", True)
+ if not ok:
+ raise FatalException(1, None)
+
+
+
# proceed jdbc properties if they were set
if args.jdbc_driver is not None and args.jdbc_db is not None:
http://git-wip-us.apache.org/repos/asf/ambari/blob/3cede908/ambari-server/src/test/python/TestAmbariServer.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/TestAmbariServer.py b/ambari-server/src/test/python/TestAmbariServer.py
index b76e2bd..46078ac 100644
--- a/ambari-server/src/test/python/TestAmbariServer.py
+++ b/ambari-server/src/test/python/TestAmbariServer.py
@@ -31,6 +31,7 @@ import platform
import shutil
from pwd import getpwnam
from ambari_server.resourceFilesKeeper import ResourceFilesKeeper, KeeperException
+from ambari_commons import Firewall, OSCheck, OSConst, FirewallChecks
with patch("platform.linux_distribution", return_value = ('Suse','11','Final')):
# We have to use this import HACK because the filename contains a dash
@@ -1005,30 +1006,54 @@ class TestAmbariServer(TestCase):
self.assertTrue(set_file_permissions_mock.called)
- @patch.object(ambari_server, "run_os_command")
- @patch.object(ambari_server, "print_warning_msg")
- @patch.object(ambari_server, "get_YN_input")
- def test_check_iptables_is_running(self, get_YN_input_mock, print_warning_msg, run_os_command_mock):
- counter = 0
- for fwo_type in ambari_server.get_firewall_object_types():
- fwo = fwo_type()
- run_os_command_mock.return_value = fwo.get_running_result()
- get_YN_input_mock.side_effect = [True]
- fwo.check_iptables()
- self.assertEqual(len(print_warning_msg.call_args_list), counter+1)
- self.assertEqual(print_warning_msg.call_args_list[counter][0][0],
- "%s is running. Confirm the necessary Ambari ports are accessible. " % fwo.FIREWALL_SERVICE_NAME +
- "Refer to the Ambari documentation for more details on ports.")
- counter += 1
+ @patch.object(FirewallChecks, "run_os_command")
+ @patch.object(OSCheck, "get_os_family")
+ @patch.object(OSCheck, "get_os_type")
+ @patch.object(OSCheck, "get_os_major_version")
+ def test_check_iptables_is_running(self, get_os_major_version_mock, get_os_type_mock, get_os_family_mock, run_os_command_mock):
+
+ get_os_major_version_mock.return_value = 18
+ get_os_type_mock.return_value = OSConst.OS_FEDORA
+ get_os_family_mock.return_value = OSConst.REDHAT_FAMILY
+
+ firewall_obj = Firewall().getFirewallObject()
+ run_os_command_mock.return_value = 0, "active", ""
+ self.assertEqual("Fedora18FirewallChecks", firewall_obj.__class__.__name__)
+ self.assertTrue(firewall_obj.check_iptables())
+ run_os_command_mock.return_value = 3, "", ""
+ self.assertFalse(firewall_obj.check_iptables())
+
+
+ get_os_type_mock.return_value = OSConst.OS_UBUNTU
+ get_os_family_mock.return_value = OSConst.DEBIAN_FAMILY
+
+ firewall_obj = Firewall().getFirewallObject()
+ run_os_command_mock.return_value = 0, "Status: active", ""
+ self.assertEqual("UbuntuFirewallChecks", firewall_obj.__class__.__name__)
+ self.assertTrue(firewall_obj.check_iptables())
+ run_os_command_mock.return_value = 0, "Status: inactive", ""
+ self.assertFalse(firewall_obj.check_iptables())
+
+ get_os_type_mock.return_value = ""
+ get_os_family_mock.return_value = OSConst.SUSE_FAMILY
+
+ firewall_obj = Firewall().getFirewallObject()
+ run_os_command_mock.return_value = 0, "### iptables", ""
+ self.assertEqual("SuseFirewallChecks", firewall_obj.__class__.__name__)
+ self.assertTrue(firewall_obj.check_iptables())
+ run_os_command_mock.return_value = 0, "SuSEfirewall2 not active", ""
+ self.assertFalse(firewall_obj.check_iptables())
+
+ get_os_type_mock.return_value = ""
+ get_os_family_mock.return_value = OSConst.REDHAT_FAMILY
+
+ firewall_obj = Firewall().getFirewallObject()
+ run_os_command_mock.return_value = 0, "Table: filter", ""
+ self.assertEqual("FirewallChecks", firewall_obj.__class__.__name__)
+ self.assertTrue(firewall_obj.check_iptables())
+ run_os_command_mock.return_value = 3, "", ""
+ self.assertFalse(firewall_obj.check_iptables())
- @patch.object(ambari_server, "run_os_command")
- @patch.object(ambari_server, "print_warning_msg")
- def test_check_iptables_is_not_running(self, print_warning_msg, run_os_command_mock):
- for fwo_type in ambari_server.get_firewall_object_types():
- fwo = fwo_type()
- run_os_command_mock.return_value = fwo.get_stopped_result()
- fwo.check_iptables()
- self.assertFalse(print_warning_msg.called)
def test_dlprogress(self):
@@ -2301,6 +2326,10 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
result = ambari_server.find_jdk()
self.assertEqual(result, "two")
+ @patch.object(FirewallChecks, "run_os_command")
+ @patch.object(OSCheck, "get_os_family")
+ @patch.object(OSCheck, "get_os_type")
+ @patch.object(OSCheck, "get_os_major_version")
@patch("os.path.exists")
@patch("os.path.isfile")
@patch.object(ambari_server, "remove_file")
@@ -2312,7 +2341,6 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
@patch.object(ambari_server, "configure_postgres")
@patch.object(ambari_server, "setup_db")
@patch.object(ambari_server, "check_postgre_up")
- @patch.object(ambari_server, "check_iptables")
@patch.object(ambari_server, "check_ambari_user")
@patch.object(ambari_server, "check_jdbc_drivers")
@patch.object(ambari_server, "check_selinux")
@@ -2326,9 +2354,10 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
def test_setup(self, proceedJDBCProperties_mock, is_server_runing_mock, is_root_mock, store_local_properties_mock,
is_local_database_mock, store_remote_properties_mock,
setup_remote_db_mock, check_selinux_mock, check_jdbc_drivers_mock, check_ambari_user_mock,
- check_iptables_mock, check_postgre_up_mock, setup_db_mock, configure_postgres_mock,
+ check_postgre_up_mock, setup_db_mock, configure_postgres_mock,
download_jdk_mock, configure_os_settings_mock, get_YN_input,
- verify_setup_allowed_method, is_jdbc_user_changed_mock, remove_file_mock, isfile_mock, exists_mock):
+ verify_setup_allowed_method, is_jdbc_user_changed_mock, remove_file_mock, isfile_mock, exists_mock,
+ get_os_major_version_mock, get_os_type_mock,get_os_family_mock, run_os_command_mock):
args = MagicMock()
failed = False
is_server_runing_mock.return_value = (False, 0)
@@ -2337,6 +2366,9 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
verify_setup_allowed_method.return_value = 0
exists_mock.return_value = False
remove_file_mock.return_value = 0
+ get_os_type_mock.return_value = ""
+ get_os_family_mock.return_value = OSConst.REDHAT_FAMILY
+ run_os_command_mock.return_value = 3,"",""
def reset_mocks():
is_jdbc_user_changed_mock.reset_mock()
@@ -2348,7 +2380,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
check_selinux_mock.reset_mock()
check_jdbc_drivers_mock.reset_mock()
check_ambari_user_mock.reset_mock()
- check_iptables_mock.reset_mock()
+ run_os_command_mock.reset_mock()
check_postgre_up_mock.reset_mock()
setup_db_mock.reset_mock()
configure_postgres_mock.reset_mock()
@@ -2372,7 +2404,6 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
check_selinux_mock.return_value = 0
check_ambari_user_mock.return_value = 0
check_jdbc_drivers_mock.return_value = 0
- check_iptables_mock.return_value = (0, "other")
check_postgre_up_mock.return_value = "running", 0, "", ""
setup_db_mock.return_value = (0, None, None)
setup_remote_db_mock.return_value = 0
@@ -2389,6 +2420,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
self.assertEqual(None, result)
self.assertTrue(check_ambari_user_mock.called)
+ self.assertEqual(1, run_os_command_mock.call_count)
self.assertEquals(True, store_remote_properties_mock.called)
self.assertEquals(False, store_local_properties_mock.called)
@@ -3652,13 +3684,17 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
os.unlink(fn2)
+
+ @patch.object(FirewallChecks, "run_os_command")
+ @patch.object(OSCheck, "get_os_family")
+ @patch.object(OSCheck, "get_os_type")
+ @patch.object(OSCheck, "get_os_major_version")
@patch.object(ambari_server, 'verify_setup_allowed')
@patch("sys.exit")
@patch.object(ambari_server, "get_YN_input")
@patch.object(ambari_server, "get_db_cli_tool")
@patch.object(ambari_server, "store_remote_properties")
@patch.object(ambari_server, "is_local_database")
- @patch.object(ambari_server, "check_iptables")
@patch.object(ambari_server, "check_jdbc_drivers")
@patch.object(ambari_server, "is_root")
@patch.object(ambari_server, "check_ambari_user")
@@ -3668,9 +3704,10 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
@patch.object(ambari_server, "check_selinux")
def test_setup_remote_db_wo_client(self, check_selinux_mock, raw_input, configure_os_settings_mock,
download_jdk_mock, check_ambari_user_mock, is_root_mock,
- check_jdbc_drivers_mock, check_iptables_mock, is_local_db_mock,
+ check_jdbc_drivers_mock, is_local_db_mock,
store_remote_properties_mock, get_db_cli_tool_mock, get_YN_input,
- exit_mock, verify_setup_allowed_method):
+ exit_mock, verify_setup_allowed_method,
+ get_os_major_version_mock, get_os_type_mock,get_os_family_mock, run_os_command_mock):
args = MagicMock()
args.jdbc_driver= None
args.jdbc_db = None
@@ -3679,7 +3716,9 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
is_local_db_mock.return_value = False
get_YN_input.return_value = False
check_selinux_mock.return_value = 0
- check_iptables_mock.return_value = (0, "other")
+ get_os_type_mock.return_value = ""
+ get_os_family_mock.return_value = OSConst.REDHAT_FAMILY
+ run_os_command_mock.return_value = 3,"",""
store_remote_properties_mock.return_value = 0
get_db_cli_tool_mock.return_value = None
check_jdbc_drivers_mock.return_value = 0
@@ -3695,12 +3734,15 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
# Expected
self.assertTrue("Remote database setup aborted." in fe.reason)
+ @patch.object(FirewallChecks, "run_os_command")
+ @patch.object(OSCheck, "get_os_family")
+ @patch.object(OSCheck, "get_os_type")
+ @patch.object(OSCheck, "get_os_major_version")
@patch.object(ambari_server, 'verify_setup_allowed')
@patch("sys.exit")
@patch.object(ambari_server, "get_YN_input")
@patch.object(ambari_server, "get_db_cli_tool")
@patch.object(ambari_server, "is_local_database")
- @patch.object(ambari_server, "check_iptables")
@patch.object(ambari_server, "check_jdbc_drivers")
@patch.object(ambari_server, "is_root")
@patch.object(ambari_server, "check_ambari_user")
@@ -3709,14 +3751,18 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
@patch('__builtin__.raw_input')
def test_store_remote_properties(self, raw_input, configure_os_settings_mock,
download_jdk_mock, check_ambari_user_mock, is_root_mock,
- check_jdbc_drivers_mock, check_iptables_mock, is_local_db_mock,
- get_db_cli_tool_mock, get_YN_input, exit_mock, verify_setup_allowed_method):
+ check_jdbc_drivers_mock, is_local_db_mock,
+ get_db_cli_tool_mock, get_YN_input, exit_mock, verify_setup_allowed_method,
+ get_os_major_version_mock, get_os_type_mock,get_os_family_mock, run_os_command_mock
+ ):
raw_input.return_value = ""
is_root_mock.return_value = True
is_local_db_mock.return_value = False
get_YN_input.return_value = False
- check_iptables_mock.return_value = (0, "other")
+ get_os_type_mock.return_value = ""
+ get_os_family_mock.return_value = OSConst.REDHAT_FAMILY
+ run_os_command_mock.return_value = 3,"",""
get_db_cli_tool_mock.return_value = None
check_jdbc_drivers_mock.return_value = 0
check_ambari_user_mock.return_value = 0
@@ -4849,6 +4895,10 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
except FatalException:
self.fail("Setup should be successful")
+ @patch.object(FirewallChecks, "run_os_command")
+ @patch.object(OSCheck, "get_os_family")
+ @patch.object(OSCheck, "get_os_type")
+ @patch.object(OSCheck, "get_os_major_version")
@patch.object(ambari_server, "is_jdbc_user_changed")
@patch.object(ambari_server, 'verify_setup_allowed')
@patch.object(ambari_server, "get_YN_input")
@@ -4856,7 +4906,6 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
@patch.object(ambari_server, "download_jdk")
@patch.object(ambari_server, "configure_postgres")
@patch.object(ambari_server, "check_postgre_up")
- @patch.object(ambari_server, "check_iptables")
@patch.object(ambari_server, "check_ambari_user")
@patch.object(ambari_server, "check_jdbc_drivers")
@patch.object(ambari_server, "check_selinux")
@@ -4870,9 +4919,11 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
def test_ambariServerSetupWithCustomDbName(self, raw_input, exit_mock, store_password_file_mock,
get_is_secure_mock, setup_db_mock, is_root_mock, is_local_database_mock,
check_selinux_mock, check_jdbc_drivers_mock, check_ambari_user_mock,
- check_iptables_mock, check_postgre_up_mock, configure_postgres_mock,
+ check_postgre_up_mock, configure_postgres_mock,
download_jdk_mock, configure_os_settings_mock, get_YN_input,
- verify_setup_allowed_method, is_jdbc_user_changed_mock):
+ verify_setup_allowed_method, is_jdbc_user_changed_mock,
+ get_os_major_version_mock, get_os_type_mock,
+ get_os_family_mock, run_os_command_mock):
args = MagicMock()
@@ -4883,7 +4934,6 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
check_selinux_mock.return_value = 0
check_ambari_user_mock.return_value = 0
check_jdbc_drivers_mock.return_value = 0
- check_iptables_mock.return_value = (0, "other")
check_postgre_up_mock.return_value = "running", 0, "", ""
is_local_database_mock.return_value = True
configure_postgres_mock.return_value = 0, "", ""
@@ -4893,6 +4943,9 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
setup_db_mock.return_value = (0, None, None)
get_is_secure_mock.return_value = False
store_password_file_mock.return_value = "password"
+ get_os_type_mock.return_value = ""
+ get_os_family_mock.return_value = OSConst.REDHAT_FAMILY
+ run_os_command_mock.return_value = 3,"",""
new_db = "newDBName"
args.dbms = "postgres"
[7/9] git commit: AMBARI-6853 - Alerts: Calculate Hash Based On Alert
Definitions (jonathanhurley)
Posted by jo...@apache.org.
AMBARI-6853 - Alerts: Calculate Hash Based On Alert Definitions (jonathanhurley)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/2edb076f
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/2edb076f
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/2edb076f
Branch: refs/heads/branch-alerts-dev
Commit: 2edb076f2504110c9a09fa4629362b2ce1a5bb7e
Parents: 40820f4
Author: Jonathan Hurley <jh...@hortonworks.com>
Authored: Wed Aug 13 15:39:35 2014 -0400
Committer: Jonathan Hurley <jh...@hortonworks.com>
Committed: Tue Aug 19 11:40:45 2014 -0400
----------------------------------------------------------------------
.../apache/ambari/server/agent/HeartBeatHandler.java | 4 ++++
.../apache/ambari/server/agent/HeartBeatResponse.java | 12 ++++++++++++
.../internal/AlertDefinitionResourceProvider.java | 1 +
ambari-server/src/main/resources/properties.json | 3 ++-
.../internal/AlertDefinitionResourceProviderTest.java | 2 ++
5 files changed, 21 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/2edb076f/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java b/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
index 65b7b6f..3c16257 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
@@ -224,6 +224,10 @@ public class HeartBeatHandler {
annotateResponse(hostname, response);
}
+ // send the alert definition hash for this host
+ Map<String, String> alertDefinitionHashes = alertDefinitionHash.getHashes(hostname);
+ response.setAlertDefinitionHash(alertDefinitionHashes);
+
return response;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/2edb076f/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatResponse.java
index 1e9dc12..98b0be0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatResponse.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatResponse.java
@@ -20,6 +20,7 @@ package org.apache.ambari.server.agent;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import com.google.gson.annotations.SerializedName;
@@ -137,6 +138,16 @@ public class HeartBeatResponse {
this.hasMappedComponents = hasMappedComponents;
}
+ @JsonProperty("alertDefinitionHashes")
+ public Map<String, String> getAlertDefinitionHash() {
+ return alertDefinitionHashes;
+ }
+
+ @JsonProperty("alertDefinitionHashes")
+ public void setAlertDefinitionHash(Map<String, String> alertDefinitionHashes) {
+ this.alertDefinitionHashes = alertDefinitionHashes;
+ }
+
public void addExecutionCommand(ExecutionCommand execCmd) {
executionCommands.add(execCmd);
}
@@ -169,6 +180,7 @@ public class HeartBeatResponse {
buffer.append(", alertDefinitionCommands=").append(alertDefinitionCommands);
buffer.append(", registrationCommand=").append(registrationCommand);
buffer.append(", restartAgent=").append(restartAgent);
+ buffer.append(", alertDefinitionHashes=").append(alertDefinitionHashes);
buffer.append('}');
return buffer.toString();
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/2edb076f/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProvider.java
index bed25e7..9b0ce1c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProvider.java
@@ -72,6 +72,7 @@ public class AlertDefinitionResourceProvider extends AbstractControllerResourceP
protected static final String ALERT_DEF_COMPONENT_NAME = "AlertDefinition/component_name";
protected static final String ALERT_DEF_ENABLED = "AlertDefinition/enabled";
protected static final String ALERT_DEF_SCOPE = "AlertDefinition/scope";
+ protected static final String ALERT_DEF_UUID = "AlertDefinition/uuid";
protected static final String ALERT_DEF_SOURCE = "AlertDefinition/source";
protected static final String ALERT_DEF_SOURCE_TYPE = "AlertDefinition/source/type";
http://git-wip-us.apache.org/repos/asf/ambari/blob/2edb076f/ambari-server/src/main/resources/properties.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/properties.json b/ambari-server/src/main/resources/properties.json
index aa2bf71..6f79413 100644
--- a/ambari-server/src/main/resources/properties.json
+++ b/ambari-server/src/main/resources/properties.json
@@ -420,7 +420,8 @@
"AlertDefinition/interval",
"AlertDefinition/enabled",
"AlertDefinition/scope",
- "AlertDefinition/source"
+ "AlertDefinition/source",
+ "AlertDefinition/uuid"
],
"Controller":[
"Controllers/name",
http://git-wip-us.apache.org/repos/asf/ambari/blob/2edb076f/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProviderTest.java
index ab74614..6d73727 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProviderTest.java
@@ -82,6 +82,8 @@ public class AlertDefinitionResourceProviderTest {
private static String DEFINITION_UUID = UUID.randomUUID().toString();
+ private static String DEFINITION_UUID = UUID.randomUUID().toString();
+
@Before
public void before() {
dao = createStrictMock(AlertDefinitionDAO.class);
[3/9] git commit: AMBARI-6912. Browser uses a lot of processor and
memory with opened all background operations. (akovalenko)
Posted by jo...@apache.org.
AMBARI-6912. Browser uses a lot of processor and memory with opened all background operations. (akovalenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/3da57baf
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/3da57baf
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/3da57baf
Branch: refs/heads/branch-alerts-dev
Commit: 3da57baf28e0c1046a26ef2109002cda958f440c
Parents: 1718bab
Author: Aleksandr Kovalenko <ak...@hortonworks.com>
Authored: Tue Aug 19 15:30:56 2014 +0300
Committer: Jonathan Hurley <jh...@hortonworks.com>
Committed: Tue Aug 19 11:39:55 2014 -0400
----------------------------------------------------------------------
.../global/background_operations_controller.js | 2 +-
.../templates/common/host_progress_popup.hbs | 2 +-
ambari-web/app/utils/host_progress_popup.js | 131 +++++++++++++------
3 files changed, 96 insertions(+), 39 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/3da57baf/ambari-web/app/controllers/global/background_operations_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/background_operations_controller.js b/ambari-web/app/controllers/global/background_operations_controller.js
index f6cb80b..e6461d6 100644
--- a/ambari-web/app/controllers/global/background_operations_controller.js
+++ b/ambari-web/app/controllers/global/background_operations_controller.js
@@ -230,7 +230,7 @@ App.BackgroundOperationsController = Em.Controller.extend({
});
this.get("services").unshift(rq);
//To sort DESC by request id
- this.set("services", this.get("services").sort( function(a,b) { return b.get('id') - a.get('id'); })) ;
+ this.set("services", this.get("services").sort( function(a,b) { return b.get('id') - a.get('id'); }));
}
runningServices += ~~isRunning;
}, this);
http://git-wip-us.apache.org/repos/asf/ambari/blob/3da57baf/ambari-web/app/templates/common/host_progress_popup.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/common/host_progress_popup.hbs b/ambari-web/app/templates/common/host_progress_popup.hbs
index d598ec7..d60dd30 100644
--- a/ambari-web/app/templates/common/host_progress_popup.hbs
+++ b/ambari-web/app/templates/common/host_progress_popup.hbs
@@ -57,7 +57,7 @@
<div class="time-summary start-time-text">{{servicesInfo.startTime}}</div>
<div class="time-summary duration-text">{{servicesInfo.duration}}</div>
<div class="progress-bar span2">
- <div {{bindAttr class="servicesInfo.isInProgress:progress-striped :active servicesInfo.barColor :progress"}}>
+ <div {{bindAttr class="servicesInfo.isInProgress:progress-striped servicesInfo.isInProgress:active servicesInfo.barColor :progress"}}>
<div class="bar" {{bindAttr style="servicesInfo.barWidth"}}></div>
</div>
</div>
http://git-wip-us.apache.org/repos/asf/ambari/blob/3da57baf/ambari-web/app/utils/host_progress_popup.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/host_progress_popup.js b/ambari-web/app/utils/host_progress_popup.js
index 1d3b184..4d27132 100644
--- a/ambari-web/app/utils/host_progress_popup.js
+++ b/ambari-web/app/utils/host_progress_popup.js
@@ -27,7 +27,7 @@ App.HostPopup = Em.Object.create({
name: 'hostPopup',
- servicesInfo: null,
+ servicesInfo: [],
hosts: null,
inputData: null,
@@ -174,7 +174,7 @@ App.HostPopup = Em.Object.create({
* clear info popup data
*/
clearHostPopup: function () {
- this.set('servicesInfo', null);
+ this.set('servicesInfo', []);
this.set('hosts', null);
this.set('inputData', null);
this.set('serviceName', "");
@@ -321,6 +321,15 @@ App.HostPopup = Em.Object.create({
}
},
+ // map to get css class with styles by service status
+ statusesStyleMap: {
+ 'FAILED': ['FAILED', 'icon-exclamation-sign', 'progress-danger', false],
+ 'ABORTED': ['ABORTED', 'icon-minus', 'progress-warning', false],
+ 'TIMEDOUT': ['TIMEDOUT', 'icon-time', 'progress-warning', false],
+ 'IN_PROGRESS': ['IN_PROGRESS', 'icon-cogs', 'progress-info', true],
+ 'COMPLETED': ['SUCCESS', 'icon-ok', 'progress-success', false]
+ },
+
/**
* Create services obj data structure for popup
* Set data for services
@@ -328,56 +337,105 @@ App.HostPopup = Em.Object.create({
*/
onServiceUpdate: function (isServiceListHidden) {
if (this.get('isBackgroundOperations') && this.get("inputData")) {
- var self = this;
- var allNewServices = [];
- var statuses = {
- 'FAILED': ['FAILED', 'icon-exclamation-sign', 'progress-danger', false],
- 'ABORTED': ['ABORTED', 'icon-minus', 'progress-warning', false],
- 'TIMEDOUT': ['TIMEDOUT', 'icon-time', 'progress-warning', false],
- 'IN_PROGRESS': ['IN_PROGRESS', 'icon-cogs', 'progress-info', true],
- 'COMPLETED': ['SUCCESS', 'icon-ok', 'progress-success', false]
- };
- var pendingStatus = ['PENDING', 'icon-cog', 'progress-info', true];
- this.set("servicesInfo", null);
- this.get("inputData").forEach(function (service) {
- var status = statuses[service.status] || pendingStatus;
+ var statuses = this.get('statusesStyleMap');
+ var servicesInfo = this.get("servicesInfo");
+ var currentServices = [];
+ this.get("inputData").forEach(function (service, index) {
+ var updatedService;
var id = service.id;
- var newService = Ember.Object.create({
- id: id,
- displayName: service.displayName,
- progress: service.progress,
- status: App.format.taskStatus(status[0]),
- isRunning: service.isRunning,
- name: service.name,
- isVisible: true,
- startTime: date.startTime(service.startTime),
- duration: date.durationSummary(service.startTime, service.endTime),
- icon: status[1],
- barColor: status[2],
- isInProgress: status[3],
- barWidth: "width:" + service.progress + "%;",
- sourceRequestScheduleId: service.get('sourceRequestScheduleId'),
- contextCommand: service.get('contextCommand')
- });
+ currentServices.push(id);
+ var existedService = servicesInfo.findProperty('id', id);
+ updatedService = existedService;
+ if (existedService) {
+ updatedService = this.updateService(existedService, service);
+ } else {
+ updatedService = this.createService(service);
+ servicesInfo.insertAt(index, updatedService);
+ }
if (App.get('supports.abortRequests')) {
var abortable = !Em.keys(statuses).contains(service.status) || service.status == 'IN_PROGRESS';
if (!abortable) {
var abortedRequests = this.get('abortedRequests');
this.set('abortedRequests', abortedRequests.without(id));
}
- newService.setProperties({
+ updatedService.setProperties({
abortable: abortable,
abortClassName: 'abort' + id
});
}
- allNewServices.push(newService);
}, this);
- self.set('servicesInfo', allNewServices);
+ this.removeOldServices(servicesInfo, currentServices);
this.setBackgroundOperationHeader(isServiceListHidden);
}
},
/**
+ * Create service object from transmitted data
+ * @param service
+ */
+ createService: function (service) {
+ var statuses = this.get('statusesStyleMap');
+ var pendingStatus = ['PENDING', 'icon-cog', 'progress-info', true];
+ var status = statuses[service.status] || pendingStatus;
+ return Ember.Object.create({
+ id: service.id,
+ displayName: service.displayName,
+ progress: service.progress,
+ status: App.format.taskStatus(status[0]),
+ isRunning: service.isRunning,
+ name: service.name,
+ isVisible: true,
+ startTime: date.startTime(service.startTime),
+ duration: date.durationSummary(service.startTime, service.endTime),
+ icon: status[1],
+ barColor: status[2],
+ isInProgress: status[3],
+ barWidth: "width:" + service.progress + "%;",
+ sourceRequestScheduleId: service.get('sourceRequestScheduleId'),
+ contextCommand: service.get('contextCommand')
+ });
+ },
+
+ /**
+ * Update properties of existed service with new data
+ * @param service
+ * @param newData
+ * @returns {Ember.Object}
+ */
+ updateService: function (service, newData) {
+ var statuses = this.get('statusesStyleMap');
+ var pendingStatus = ['PENDING', 'icon-cog', 'progress-info', true];
+ var status = statuses[newData.status] || pendingStatus;
+ return service.setProperties({
+ progress: newData.progress,
+ status: App.format.taskStatus(status[0]),
+ isRunning: newData.isRunning,
+ startTime: date.startTime(newData.startTime),
+ duration: date.durationSummary(newData.startTime, newData.endTime),
+ icon: status[1],
+ barColor: status[2],
+ isInProgress: status[3],
+ barWidth: "width:" + newData.progress + "%;",
+ sourceRequestScheduleId: newData.get('sourceRequestScheduleId'),
+ contextCommand: newData.get('contextCommand')
+ });
+ },
+
+ /**
+ * remove old requests
+ * as API returns 10, or 20 , or 30 ...etc latest request, the requests that absent in response should be removed
+ * @param services
+ * @param currentServicesIds
+ */
+ removeOldServices: function (services, currentServicesIds) {
+ services.forEach(function (service, index, services) {
+ if (!currentServicesIds.contains(service.id)) {
+ services.removeAt(index, 1);
+ }
+ });
+ },
+
+ /**
* create task Ember object
* @param {Object} _task
* @return {Em.Object}
@@ -546,7 +604,7 @@ App.HostPopup = Em.Object.create({
}
}
if (App.get('supports.abortRequests')) {
- var operation = this.get('servicesInfo') && this.get('servicesInfo').findProperty('name', this.get('serviceName'));
+ var operation = this.get('servicesInfo').findProperty('name', this.get('serviceName'));
if (!operation || (operation && operation.get('progress') == 100)) {
this.set('operationInfo', null);
} else {
@@ -561,7 +619,6 @@ App.HostPopup = Em.Object.create({
*/
createPopup: function () {
var self = this;
- var hostsInfo = this.get("hosts");
var servicesInfo = this.get("servicesInfo");
var isBackgroundOperations = this.get('isBackgroundOperations');
var categoryObject = Em.Object.extend({
[2/9] git commit: AMBARI-6913. A lot of Ganglia metrics are absent on
UI on Centos 5.9 (aonishuk)
Posted by jo...@apache.org.
AMBARI-6913. A lot of Ganglia metrics are absent on UI on Centos 5.9 (aonishuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/cfc9440f
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/cfc9440f
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/cfc9440f
Branch: refs/heads/branch-alerts-dev
Commit: cfc9440fa7e2f44f156bf9fcaeccbb9ae37fd60f
Parents: 3da57ba
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Tue Aug 19 16:03:34 2014 +0300
Committer: Jonathan Hurley <jh...@hortonworks.com>
Committed: Tue Aug 19 11:39:55 2014 -0400
----------------------------------------------------------------------
.../2.0.6/services/GANGLIA/package/templates/rrd.py.j2 | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/cfc9440f/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/templates/rrd.py.j2
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/templates/rrd.py.j2 b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/templates/rrd.py.j2
index 055c810..65d70e2 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/templates/rrd.py.j2
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/GANGLIA/package/templates/rrd.py.j2
@@ -18,6 +18,9 @@ See the License for the specific language governing permissions and
limitations under the License.
'''
+# NOTE: This script is executed by Python 2.4 on Centos 5.
+# Make sure your changes are compatible.
+
import cgi
import glob
import os
@@ -109,7 +112,12 @@ def collectStatMetrics(clusterName, hostName, metricName, files, cf, start, end,
if timestamp is None and stepsize is None and concreteMetricName is None:
timestamp = rrdMetric[0][0]
stepsize = rrdMetric[0][2]
- suffix = metricStat if not isRate else '_rate.' + metricStat
+
+ if not isRate:
+ suffix = metricStat
+ else:
+ suffix = '_rate.' + metricStat
+
concreteMetricName = file.split(os.sep).pop().replace('rrd', suffix)
metricValues = rrdMetric[2]
[9/9] git commit: AMBARI-6880 - Alerts: Send Definitions Down Via
Commands to the Agent (jonathanhurley)
Posted by jo...@apache.org.
AMBARI-6880 - Alerts: Send Definitions Down Via Commands to the Agent (jonathanhurley)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/68042051
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/68042051
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/68042051
Branch: refs/heads/branch-alerts-dev
Commit: 68042051bef22bb922029d85df03eccc38059c07
Parents: 8992245
Author: Jonathan Hurley <jh...@hortonworks.com>
Authored: Fri Aug 15 14:27:27 2014 -0400
Committer: Jonathan Hurley <jh...@hortonworks.com>
Committed: Tue Aug 19 11:46:05 2014 -0400
----------------------------------------------------------------------
.../apache/ambari/server/agent/HeartBeatHandler.java | 4 ----
.../apache/ambari/server/agent/HeartBeatResponse.java | 12 ------------
.../apache/ambari/server/controller/AmbariServer.java | 1 -
.../internal/AlertDefinitionResourceProviderTest.java | 2 --
4 files changed, 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/68042051/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java b/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
index 3c16257..65b7b6f 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
@@ -224,10 +224,6 @@ public class HeartBeatHandler {
annotateResponse(hostname, response);
}
- // send the alert definition hash for this host
- Map<String, String> alertDefinitionHashes = alertDefinitionHash.getHashes(hostname);
- response.setAlertDefinitionHash(alertDefinitionHashes);
-
return response;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/68042051/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatResponse.java
index 98b0be0..1e9dc12 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatResponse.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatResponse.java
@@ -20,7 +20,6 @@ package org.apache.ambari.server.agent;
import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
import com.google.gson.annotations.SerializedName;
@@ -138,16 +137,6 @@ public class HeartBeatResponse {
this.hasMappedComponents = hasMappedComponents;
}
- @JsonProperty("alertDefinitionHashes")
- public Map<String, String> getAlertDefinitionHash() {
- return alertDefinitionHashes;
- }
-
- @JsonProperty("alertDefinitionHashes")
- public void setAlertDefinitionHash(Map<String, String> alertDefinitionHashes) {
- this.alertDefinitionHashes = alertDefinitionHashes;
- }
-
public void addExecutionCommand(ExecutionCommand execCmd) {
executionCommands.add(execCmd);
}
@@ -180,7 +169,6 @@ public class HeartBeatResponse {
buffer.append(", alertDefinitionCommands=").append(alertDefinitionCommands);
buffer.append(", registrationCommand=").append(registrationCommand);
buffer.append(", restartAgent=").append(restartAgent);
- buffer.append(", alertDefinitionHashes=").append(alertDefinitionHashes);
buffer.append('}');
return buffer.toString();
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/68042051/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
index 687a3d0..489fbb2 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
@@ -91,7 +91,6 @@ import org.apache.ambari.server.security.unsecured.rest.CertificateSign;
import org.apache.ambari.server.security.unsecured.rest.ConnectionInfo;
import org.apache.ambari.server.state.Clusters;
import org.apache.ambari.server.state.ConfigHelper;
-import org.apache.ambari.server.state.alert.AlertDefinitionHash;
import org.apache.ambari.server.utils.StageUtils;
import org.apache.ambari.server.utils.VersionUtils;
import org.apache.ambari.server.view.ViewRegistry;
http://git-wip-us.apache.org/repos/asf/ambari/blob/68042051/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProviderTest.java
index 6d73727..ab74614 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProviderTest.java
@@ -82,8 +82,6 @@ public class AlertDefinitionResourceProviderTest {
private static String DEFINITION_UUID = UUID.randomUUID().toString();
- private static String DEFINITION_UUID = UUID.randomUUID().toString();
-
@Before
public void before() {
dao = createStrictMock(AlertDefinitionDAO.class);
[4/9] git commit: AMBARI-6908 - Alerts: AlertDefinition Should Have a
Label (jonathanhurley)
Posted by jo...@apache.org.
AMBARI-6908 - Alerts: AlertDefinition Should Have a Label (jonathanhurley)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/0e9a676b
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/0e9a676b
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/0e9a676b
Branch: refs/heads/branch-alerts-dev
Commit: 0e9a676b55fc9c2926e1958f8b36f30bc1ba3e84
Parents: b2f25b6
Author: Jonathan Hurley <jh...@hortonworks.com>
Authored: Mon Aug 18 21:01:32 2014 -0400
Committer: Jonathan Hurley <jh...@hortonworks.com>
Committed: Tue Aug 19 11:39:55 2014 -0400
----------------------------------------------------------------------
.../controller/internal/AlertDefinitionResourceProviderTest.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/0e9a676b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProviderTest.java
index 7df999e..ab74614 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProviderTest.java
@@ -263,11 +263,11 @@ public class AlertDefinitionResourceProviderTest {
Assert.assertEquals(Integer.valueOf(1), entity.getScheduleInterval());
Assert.assertNull(entity.getScope());
Assert.assertEquals("HDFS", entity.getServiceName());
+ Assert.assertNotNull(entity.getSource());
Assert.assertEquals("METRIC", entity.getSourceType());
Assert.assertEquals("Mock Label (Create)", entity.getLabel());
// verify Source
- Assert.assertNotNull(entity.getSource());
Source actualSource = gson.fromJson(entity.getSource(), Source.class);
Assert.assertNotNull(actualSource);