Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 93968200BEB for ; Wed, 28 Dec 2016 19:03:17 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 92193160B2E; Wed, 28 Dec 2016 18:03:17 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id B7C61160B2A for ; Wed, 28 Dec 2016 19:03:16 +0100 (CET) Received: (qmail 15386 invoked by uid 500); 28 Dec 2016 18:03:16 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 15377 invoked by uid 99); 28 Dec 2016 18:03:15 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Dec 2016 18:03:15 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D194FDFBE6; Wed, 28 Dec 2016 18:03:15 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: yusaku@apache.org To: commits@ambari.apache.org Message-Id: <791644f6349d47258695772c4c73736a@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: ambari git commit: AMBARI-14958. Alerts: Create new Alerts Notification type for SNMP to handle Ambari MIB. (Vivek Subramanian via yusaku) Date: Wed, 28 Dec 2016 18:03:15 +0000 (UTC) archived-at: Wed, 28 Dec 2016 18:03:17 -0000 Repository: ambari Updated Branches: refs/heads/branch-2.5 dc566c6cc -> 4f8934d68 AMBARI-14958. Alerts: Create new Alerts Notification type for SNMP to handle Ambari MIB. (Vivek Subramanian via yusaku) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/4f8934d6 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/4f8934d6 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/4f8934d6 Branch: refs/heads/branch-2.5 Commit: 4f8934d68575a4de01a579c731671fb6e22679da Parents: dc566c6 Author: Yusaku Sako Authored: Wed Dec 28 10:02:53 2016 -0800 Committer: Yusaku Sako Committed: Wed Dec 28 10:02:53 2016 -0800 ---------------------------------------------------------------------- .../manage_alert_notifications_controller.js | 36 ++++++++++- .../main/alerts/create_alert_notification.hbs | 68 +++++++++++++++++--- .../alerts/manage_alert_notifications_view.js | 6 ++ 3 files changed, 97 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/4f8934d6/ambari-web/app/controllers/main/alerts/manage_alert_notifications_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/alerts/manage_alert_notifications_controller.js b/ambari-web/app/controllers/main/alerts/manage_alert_notifications_controller.js index 1de15a6..369a053 100644 --- a/ambari-web/app/controllers/main/alerts/manage_alert_notifications_controller.js +++ b/ambari-web/app/controllers/main/alerts/manage_alert_notifications_controller.js @@ -157,7 +157,7 @@ App.ManageAlertNotificationsController = Em.Controller.extend({ * used in Type combobox * @type {Array} */ - methods: ['EMAIL', 'SNMP'], + methods: ['EMAIL', 'SNMP', 'Custom SNMP'], /** * List of available value for Severity Filter @@ -311,6 +311,16 @@ App.ManageAlertNotificationsController = Em.Controller.extend({ errorKey: 'hostError', validator: 'hostsValidation' } + ], + CustomSNMP: [ + { + errorKey: 'portError', + validator: 'portValidation' + }, + { + errorKey: 'hostError', + validator: 'hostsValidation' + } ] }, @@ -451,11 +461,17 @@ App.ManageAlertNotificationsController = Em.Controller.extend({ isEmailMethodSelected: Em.computed.equal('controller.inputFields.method.value', 'EMAIL'), + isSNMPMethodSelected: Em.computed.equal('controller.inputFields.method.value', 'SNMP'), + + isCustomSNMPMethodSelected: Em.computed.equal('controller.inputFields.method.value', 'Custom SNMP'), + methodObserver: function () { var currentMethod = this.get('controller.inputFields.method.value'), validationMap = self.get('validationMap'); self.get('methods').forEach(function (method) { - var validations = validationMap[method]; + // Replace blank spaces with empty character + var mapKey = method.replace(/\s/g, ""); + var validations = validationMap[mapKey]; if (method === currentMethod) { validations.mapProperty('validator').forEach(function (key) { this.get(key).call(this); @@ -735,6 +751,11 @@ App.ManageAlertNotificationsController = Em.Controller.extend({ properties['ambari.dispatch.credential.password'] = inputFields.get('SMTPPassword.value'); properties['mail.smtp.starttls.enable'] = inputFields.get('SMTPSTARTTLS.value'); } + } else if(inputFields.get('method.value') === 'SNMP') { + properties['ambari.dispatch.snmp.version'] = inputFields.get('version.value'); + properties['ambari.dispatch.snmp.community'] = inputFields.get('community.value'); + properties['ambari.dispatch.recipients'] = inputFields.get('host.value').replace(/\s/g, '').split(','); + properties['ambari.dispatch.snmp.port'] = inputFields.get('port.value'); } else { properties['ambari.dispatch.snmp.version'] = inputFields.get('version.value'); properties['ambari.dispatch.snmp.oids.trap'] = inputFields.get('OIDs.value'); @@ -747,12 +768,21 @@ App.ManageAlertNotificationsController = Em.Controller.extend({ inputFields.get('customProperties').forEach(function (customProperty) { properties[customProperty.name] = customProperty.value; }); + var getNotificationType = function() { + var methodValue = inputFields.get('method.value'); + if(methodValue == "Custom SNMP") { + methodValue = "SNMP"; + } else if(methodValue == "SNMP") { + methodValue = "AMBARI_SNMP" + } + return methodValue; + }; var apiObject = { AlertTarget: { name: inputFields.get('name.value'), description: inputFields.get('description.value'), global: inputFields.get('allGroups.value') === 'all', - notification_type: inputFields.get('method.value'), + notification_type: getNotificationType(), alert_states: inputFields.get('severityFilter.value'), properties: properties } http://git-wip-us.apache.org/repos/asf/ambari/blob/4f8934d6/ambari-web/app/templates/main/alerts/create_alert_notification.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/main/alerts/create_alert_notification.hbs b/ambari-web/app/templates/main/alerts/create_alert_notification.hbs index a248e57..00b0f2f 100644 --- a/ambari-web/app/templates/main/alerts/create_alert_notification.hbs +++ b/ambari-web/app/templates/main/alerts/create_alert_notification.hbs @@ -192,7 +192,11 @@ {{view Em.Checkbox disabledBinding="controller.inputFields.SMTPUseAuthentication.invertedValue" checkedBinding="controller.inputFields.SMTPSTARTTLS.value" id="inputSMTPSTARTTLS" class="input-xlarge"}} - {{else}} + {{/if}} + {{! alert-notification email end }} + + {{! alert-notification SNMP }} + {{#if view.isSNMPMethodSelected}}
@@ -202,14 +206,6 @@
- - -
- {{view Em.TextField valueBinding="controller.inputFields.OIDs.value" class="input-xlarge"}} -
-
- -
@@ -241,7 +237,59 @@
{{/if}} - {{! alert-notification email end }} + {{! alert-notification SNMP end }} + + {{! alert-notification Custom SNMP }} + {{#if view.isCustomSNMPMethodSelected}} +
+ + +
+ {{view Em.Select selectionBinding="controller.inputFields.version.value" contentBinding="controller.SNMPVersions" class="input-xlarge"}} +
+
+ +
+ + +
+ {{view Em.TextField valueBinding="controller.inputFields.OIDs.value" class="input-xlarge"}} +
+
+ +
+ + +
+ {{view Em.TextField valueBinding="controller.inputFields.community.value" class="input-xlarge"}} +
+
+ +
+ + +
+ {{view Em.TextField valueBinding="controller.inputFields.host.value" class="input-xlarge"}} +
+ +
+ {{controller.inputFields.host.errorMsg}} +
+
+ +
+ + +
+ {{view Em.TextField valueBinding="controller.inputFields.port.value" class="input-xlarge"}} +
+ +
+ {{controller.inputFields.port.errorMsg}} +
+
+ {{/if}} + {{! alert-notification Custom SNMP end }} {{! alert-notification custom properties }} {{#each customProperty in controller.inputFields.customProperties}} http://git-wip-us.apache.org/repos/asf/ambari/blob/4f8934d6/ambari-web/app/views/main/alerts/manage_alert_notifications_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/alerts/manage_alert_notifications_view.js b/ambari-web/app/views/main/alerts/manage_alert_notifications_view.js index 00d8e7b..53bbfc5 100644 --- a/ambari-web/app/views/main/alerts/manage_alert_notifications_view.js +++ b/ambari-web/app/views/main/alerts/manage_alert_notifications_view.js @@ -65,6 +65,12 @@ App.ManageAlertNotificationsView = Em.View.extend({ */ showSNMPDetails: Em.computed.equal('controller.selectedAlertNotification.type', 'SNMP'), + /** + * Show Custom SNMP information if selected alert notification has type Custom SNMP + * @type {boolean} + */ + showCustomSNMPDetails: Em.computed.equal('controller.selectedAlertNotification.type', 'Custom SNMP'), + email: function () { return this.get('controller.selectedAlertNotification.properties')['ambari.dispatch.recipients']; }.property('controller.selectedAlertNotification.properties'),