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 <yus...@hortonworks.com> Authored: Wed Dec 28 10:02:53 2016 -0800 Committer: Yusaku Sako <yus...@hortonworks.com> 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"}} </div> </div> - {{else}} + {{/if}} + {{! alert-notification email end }} + + {{! alert-notification SNMP }} + {{#if view.isSNMPMethodSelected}} <div class="control-group"> <label class="control-label">{{controller.inputFields.version.label}}</label> @@ -202,14 +206,6 @@ </div> <div class="control-group"> - <label class="control-label">{{controller.inputFields.OIDs.label}}</label> - - <div class="controls"> - {{view Em.TextField valueBinding="controller.inputFields.OIDs.value" class="input-xlarge"}} - </div> - </div> - - <div class="control-group"> <label class="control-label">{{controller.inputFields.community.label}}</label> <div class="controls"> @@ -241,7 +237,59 @@ </div> </div> {{/if}} - {{! alert-notification email end }} + {{! alert-notification SNMP end }} + + {{! alert-notification Custom SNMP }} + {{#if view.isCustomSNMPMethodSelected}} + <div class="control-group"> + <label class="control-label">{{controller.inputFields.version.label}}</label> + + <div class="controls"> + {{view Em.Select selectionBinding="controller.inputFields.version.value" contentBinding="controller.SNMPVersions" class="input-xlarge"}} + </div> + </div> + + <div class="control-group"> + <label class="control-label">{{controller.inputFields.OIDs.label}}</label> + + <div class="controls"> + {{view Em.TextField valueBinding="controller.inputFields.OIDs.value" class="input-xlarge"}} + </div> + </div> + + <div class="control-group"> + <label class="control-label">{{controller.inputFields.community.label}}</label> + + <div class="controls"> + {{view Em.TextField valueBinding="controller.inputFields.community.value" class="input-xlarge"}} + </div> + </div> + + <div {{bindAttr class=":control-group controller.inputFields.host.errorMsg:error"}}> + <label class="control-label">{{controller.inputFields.host.label}}</label> + + <div class="controls"> + {{view Em.TextField valueBinding="controller.inputFields.host.value" class="input-xlarge"}} + </div> + + <div class="controls error-msg"> + {{controller.inputFields.host.errorMsg}} + </div> + </div> + + <div {{bindAttr class=":control-group controller.inputFields.port.errorMsg:error"}}> + <label class="control-label">{{controller.inputFields.port.label}}</label> + + <div class="controls"> + {{view Em.TextField valueBinding="controller.inputFields.port.value" class="input-xlarge"}} + </div> + + <div class="controls error-msg"> + {{controller.inputFields.port.errorMsg}} + </div> + </div> + {{/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'),