Repository: ambari Updated Branches: refs/heads/trunk 162ee83c5 -> f936fd04d
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/f936fd04 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/f936fd04 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/f936fd04 Branch: refs/heads/trunk Commit: f936fd04ddbffa0cd78e827d61c2a27c4be1270c Parents: 162ee83 Author: Yusaku Sako <yus...@hortonworks.com> Authored: Wed Dec 14 12:43:53 2016 -0800 Committer: Yusaku Sako <yus...@hortonworks.com> Committed: Wed Dec 14 12:43:53 2016 -0800 ---------------------------------------------------------------------- .../manage_alert_notifications_controller.js | 36 +++++++++- .../main/alerts/create_alert_notification.hbs | 72 +++++++++++++++++--- .../alerts/manage_alert_notifications_view.js | 6 ++ 3 files changed, 101 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/f936fd04/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 10a7918..466d2e1 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 @@ -167,7 +167,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 @@ -321,6 +321,16 @@ App.ManageAlertNotificationsController = Em.Controller.extend({ errorKey: 'hostError', validator: 'hostsValidation' } + ], + CustomSNMP: [ + { + errorKey: 'portError', + validator: 'portValidation' + }, + { + errorKey: 'hostError', + validator: 'hostsValidation' + } ] }, @@ -461,11 +471,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); @@ -745,6 +761,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'); @@ -757,12 +778,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/f936fd04/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 342b247..5b40bca 100644 --- a/ambari-web/app/templates/main/alerts/create_alert_notification.hbs +++ b/ambari-web/app/templates/main/alerts/create_alert_notification.hbs @@ -208,7 +208,11 @@ {{view App.CheckboxView disabledBinding="controller.inputFields.SMTPUseAuthentication.invertedValue" checkedBinding="controller.inputFields.SMTPSTARTTLS.value" id="inputSMTPSTARTTLS"}} </div> </div> - {{else}} + {{/if}} + {{! alert-notification email end }} + + {{! alert-notification SNMP }} + {{#if view.isSNMPMethodSelected}} <div class="form-group"> <label class="control-label col-md-2">{{controller.inputFields.version.label}}</label> @@ -218,14 +222,6 @@ </div> <div class="form-group"> - <label class="control-label col-md-2">{{controller.inputFields.OIDs.label}}</label> - - <div class="col-md-10"> - {{view Em.TextField valueBinding="controller.inputFields.OIDs.value" classNames="form-control"}} - </div> - </div> - - <div class="form-group"> <label class="control-label col-md-2">{{controller.inputFields.community.label}}</label> <div class="col-md-10"> @@ -261,7 +257,63 @@ {{/if}} </div> {{/if}} - {{! alert-notification email end }} + {{! alert-notification SNMP end }} + + {{! alert-notification Custom SNMP }} + {{#if view.isCustomSNMPMethodSelected}} + <div class="form-group"> + <label class="control-label col-md-2">{{controller.inputFields.version.label}}</label> + + <div class="col-md-10"> + {{view Em.Select selectionBinding="controller.inputFields.version.value" contentBinding="controller.SNMPVersions" classNames="form-control"}} + </div> + </div> + + <div class="form-group"> + <label class="control-label col-md-2">{{controller.inputFields.OIDs.label}}</label> + + <div class="col-md-10"> + {{view Em.TextField valueBinding="controller.inputFields.OIDs.value" classNames="form-control"}} + </div> + </div> + + <div class="form-group"> + <label class="control-label col-md-2">{{controller.inputFields.community.label}}</label> + + <div class="col-md-10"> + {{view Em.TextField valueBinding="controller.inputFields.community.value" classNames="form-control"}} + </div> + </div> + + <div {{bindAttr class=":form-group controller.inputFields.host.errorMsg:has-error"}}> + <label class="control-label col-md-2">{{controller.inputFields.host.label}}</label> + + <div class="col-md-10"> + {{view Em.TextField valueBinding="controller.inputFields.host.value" classNames="form-control"}} + </div> + + {{#if controller.inputFields.host.errorMsg}} + <div class="col-md-10 col-md-offset-2 help-block validation-block error-msg"> + {{controller.inputFields.host.errorMsg}} + </div> + {{/if}} + </div> + + <div {{bindAttr class=":form-group controller.inputFields.port.errorMsg:has-error"}}> + <label class="control-label col-md-2">{{controller.inputFields.port.label}}</label> + + <div class="col-md-10"> + {{view Em.TextField valueBinding="controller.inputFields.port.value" classNames="form-control"}} + </div> + + {{#if controller.inputFields.port.errorMsg}} + <div class="col-md-10 col-md-offset-2 help-block validation-block error-msg"> + {{controller.inputFields.port.errorMsg}} + </div> + {{/if}} + </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/f936fd04/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 abb1694..9d01791 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 @@ -70,6 +70,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'),