You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by yu...@apache.org on 2016/02/11 02:28:43 UTC

ambari git commit: Revert "AMBARI-14958. Alerts: Create new Alerts Notification type for SNMP to handle Ambari MIB (onechiporenko)"

Repository: ambari
Updated Branches:
  refs/heads/trunk 3242a5590 -> ba604ea6b


Revert "AMBARI-14958. Alerts: Create new Alerts Notification type for SNMP to handle Ambari MIB (onechiporenko)"

This reverts commit e139ef57ce0ec3d705489a36cb2d7cc78f6458c1.


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

Branch: refs/heads/trunk
Commit: ba604ea6be57bcbd5cff2219b0d821e6ff16d695
Parents: 3242a55
Author: Yusaku Sako <yu...@hortonworks.com>
Authored: Wed Feb 10 17:28:20 2016 -0800
Committer: Yusaku Sako <yu...@hortonworks.com>
Committed: Wed Feb 10 17:28:20 2016 -0800

----------------------------------------------------------------------
 .../manage_alert_notifications_controller.js    |  74 +++++-------
 ...anage_alert_notifications_controller_test.js | 121 ++++++++-----------
 .../views/common/log_file_search_view_test.js   |   3 +-
 3 files changed, 82 insertions(+), 116 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/ba604ea6/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 244b8f0..79e524e 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
@@ -61,7 +61,9 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
       value: '',
       defaultValue: 'custom',
       disabled: false,
-      isAll: Em.computed.equal('value', 'all')
+      isAll: function () {
+        return this.get('value') == 'all';
+      }.property('value')
     }),
     method: {
       label: Em.I18n.t('alerts.actions.manage_alert_notifications_popup.method'),
@@ -157,7 +159,7 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
    * used in Type combobox
    * @type {Array}
    */
-  methods: ['EMAIL', 'SNMP', 'Custom SNMP'],
+  methods: ['EMAIL', 'SNMP'],
 
   /**
    * List of available value for Severity Filter
@@ -218,8 +220,7 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
     'mail.smtp.from',
     'mail.smtp.host',
     'mail.smtp.port',
-    'mail.smtp.starttls.enable',
-    'ambari.dispatch-property.script'
+    'mail.smtp.starttls.enable'
   ],
 
   validationMap: {
@@ -241,16 +242,6 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
         validator: 'retypePasswordValidation'
       }
     ],
-    'Custom SNMP': [
-      {
-        errorKey: 'portError',
-        validator: 'portValidation'
-      },
-      {
-        errorKey: 'hostError',
-        validator: 'hostsValidation'
-      }
-    ],
     SNMP: [
       {
         errorKey: 'portError',
@@ -331,25 +322,24 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
   fillEditCreateInputs: function (addCopyToName) {
     var inputFields = this.get('inputFields');
     var selectedAlertNotification = this.get('selectedAlertNotification');
-    var props = selectedAlertNotification.get('properties');
     inputFields.set('name.value', (addCopyToName ? 'Copy of ' : '') + selectedAlertNotification.get('name'));
     inputFields.set('groups.value', selectedAlertNotification.get('groups').toArray());
-    inputFields.set('email.value', props['ambari.dispatch.recipients'] ?
-      props['ambari.dispatch.recipients'].join(', ') : '');
-    inputFields.set('SMTPServer.value', props['mail.smtp.host']);
-    inputFields.set('SMTPPort.value', props['mail.smtp.port']);
-    inputFields.set('SMTPUseAuthentication.value', props['mail.smtp.auth'] !== "false");
-    inputFields.set('SMTPUsername.value', props['ambari.dispatch.credential.username']);
-    inputFields.set('SMTPPassword.value', props['ambari.dispatch.credential.password']);
-    inputFields.set('retypeSMTPPassword.value', props['ambari.dispatch.credential.password']);
-    inputFields.set('SMTPSTARTTLS.value', props['mail.smtp.starttls.enable'] !== "false");
-    inputFields.set('emailFrom.value', props['mail.smtp.from']);
-    inputFields.set('version.value', props['ambari.dispatch.snmp.version']);
-    inputFields.set('OIDs.value', props['ambari.dispatch.snmp.oids.trap']);
-    inputFields.set('community.value', props['ambari.dispatch.snmp.community']);
-    inputFields.set('host.value', props['ambari.dispatch.recipients'] ?
-      props['ambari.dispatch.recipients'].join(', ') : '');
-    inputFields.set('port.value', props['ambari.dispatch.snmp.port']);
+    inputFields.set('email.value', selectedAlertNotification.get('properties')['ambari.dispatch.recipients'] ?
+      selectedAlertNotification.get('properties')['ambari.dispatch.recipients'].join(', ') : '');
+    inputFields.set('SMTPServer.value', selectedAlertNotification.get('properties')['mail.smtp.host']);
+    inputFields.set('SMTPPort.value', selectedAlertNotification.get('properties')['mail.smtp.port']);
+    inputFields.set('SMTPUseAuthentication.value', selectedAlertNotification.get('properties')['mail.smtp.auth'] !== "false");
+    inputFields.set('SMTPUsername.value', selectedAlertNotification.get('properties')['ambari.dispatch.credential.username']);
+    inputFields.set('SMTPPassword.value', selectedAlertNotification.get('properties')['ambari.dispatch.credential.password']);
+    inputFields.set('retypeSMTPPassword.value', selectedAlertNotification.get('properties')['ambari.dispatch.credential.password']);
+    inputFields.set('SMTPSTARTTLS.value', selectedAlertNotification.get('properties')['mail.smtp.starttls.enable'] !== "false");
+    inputFields.set('emailFrom.value', selectedAlertNotification.get('properties')['mail.smtp.from']);
+    inputFields.set('version.value', selectedAlertNotification.get('properties')['ambari.dispatch.snmp.version']);
+    inputFields.set('OIDs.value', selectedAlertNotification.get('properties')['ambari.dispatch.snmp.oids.trap']);
+    inputFields.set('community.value', selectedAlertNotification.get('properties')['ambari.dispatch.snmp.community']);
+    inputFields.set('host.value', selectedAlertNotification.get('properties')['ambari.dispatch.recipients'] ?
+      selectedAlertNotification.get('properties')['ambari.dispatch.recipients'].join(', ') : '');
+    inputFields.set('port.value', selectedAlertNotification.get('properties')['ambari.dispatch.snmp.port']);
     inputFields.set('severityFilter.value', selectedAlertNotification.get('alertStates'));
     inputFields.set('global.value', selectedAlertNotification.get('global'));
     inputFields.set('allGroups.value', selectedAlertNotification.get('global') ? 'all' : 'custom');
@@ -358,13 +348,14 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
     inputFields.set('description.value', selectedAlertNotification.get('description'));
     inputFields.set('method.value', selectedAlertNotification.get('type'));
     inputFields.get('customProperties').clear();
+    var properties = selectedAlertNotification.get('properties');
     var ignoredCustomProperties = this.get('ignoredCustomProperties');
-    Em.keys(props).forEach(function (k) {
+    Em.keys(properties).forEach(function (k) {
       if (ignoredCustomProperties.contains(k)) return;
       inputFields.get('customProperties').pushObject({
         name: k,
-        value: props[k],
-        defaultValue: props[k]
+        value: properties[k],
+        defaultValue: properties[k]
       });
     });
   },
@@ -403,7 +394,7 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
             validationMap = self.get('validationMap');
           self.get('methods').forEach(function (method) {
             var validations = validationMap[method];
-            if (method === currentMethod) {
+            if (method == currentMethod) {
               validations.mapProperty('validator').forEach(function (key) {
                 this.get(key).call(this);
               }, this);
@@ -427,7 +418,7 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
             if (!newName) {
               this.set('nameError', true);
               errorMessage = Em.I18n.t('alerts.actions.manage_alert_notifications_popup.error.name.empty');
-            } else if (newName && newName !== this.get('currentName') && self.get('alertNotifications').mapProperty('name').contains(newName)) {
+            } else if (newName && newName != this.get('currentName') && self.get('alertNotifications').mapProperty('name').contains(newName)) {
               this.set('nameError', true);
               errorMessage = Em.I18n.t('alerts.actions.manage_alert_notifications_popup.error.name.existed');
             } else {
@@ -484,7 +475,7 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
 
         hostsValidation: function() {
           var inputValue = this.get('controller.inputFields.host.value').trim(),
-            hostError = false;
+            hostError = false;;
           if (!this.get('isEmailMethodSelected')) {
             var array = inputValue.split(',');
             hostError = array.some(function(hostname) {
@@ -540,7 +531,7 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
          * @method selectAllGroups
          */
         selectAllGroups: function () {
-          if (this.get('controller.inputFields.allGroups.value') === 'custom') {
+          if (this.get('controller.inputFields.allGroups.value') == 'custom') {
             this.set('groupSelect.selection', this.get('groupSelect.content').slice());
           }
         },
@@ -550,7 +541,7 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
          * @method clearAllGroups
          */
         clearAllGroups: function () {
-          if (this.get('controller.inputFields.allGroups.value') === 'custom') {
+          if (this.get('controller.inputFields.allGroups.value') == 'custom') {
             this.set('groupSelect.selection', []);
           }
         },
@@ -654,9 +645,6 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
       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');
-      if (inputFields.get('method.value') === 'SNMP') {
-        properties['ambari.dispatch-property.script'] = "org.apache.ambari.contrib.snmp.script";
-      }
     }
     inputFields.get('customProperties').forEach(function (customProperty) {
       properties[customProperty.name] = customProperty.value;
@@ -671,7 +659,7 @@ App.ManageAlertNotificationsController = Em.Controller.extend({
         properties: properties
       }
     };
-    if (inputFields.get('allGroups.value') === 'custom') {
+    if (inputFields.get('allGroups.value') == 'custom') {
       apiObject.AlertTarget.groups = inputFields.get('groups.value').mapProperty('id');
     }
     return apiObject;

http://git-wip-us.apache.org/repos/asf/ambari/blob/ba604ea6/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js b/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js
index 283c0af..19d0c1b 100644
--- a/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js
+++ b/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js
@@ -699,77 +699,56 @@ describe('App.ManageAlertNotificationsController', function () {
 
   describe("#formatNotificationAPIObject()", function () {
 
-    var inputFields;
-
-    beforeEach(function () {
-      inputFields = Em.Object.create({
-        name: {
-          value: 'test_name'
-        },
-        groups: {
-          value: [{id: 1}, {id: 2}, {id: 3}]
-        },
-        allGroups: {
-          value: 'custom'
-        },
-        global: {
-          value: false
-        },
-        method: {
-          value: 'EMAIL'
-        },
-        email: {
-          value: 'test1@test.test, test2@test.test,test3@test.test , test4@test.test'
-        },
-        severityFilter: {
-          value: ['OK', 'CRITICAL']
-        },
-        SMTPServer: {
-          value: 's1'
-        },
-        SMTPPort: {
-          value: '25'
-        },
-        SMTPUseAuthentication: {
-          value: "true"
-        },
-        SMTPUsername: {
-          value: 'user'
-        },
-        SMTPPassword: {
-          value: 'pass'
-        },
-        SMTPSTARTTLS: {
-          value: "true"
-        },
-        emailFrom: {
-          value: 'from'
-        },
-        description: {
-          value: 'test_description'
-        },
-        host: {
-          value: ''
-        },
-        customProperties: [
-          {name: 'n1', value: 'v1'},
-          {name: 'n2', value: 'v2'}
-        ]
-      });
-    });
-
-    it('should set property `ambari.dispatch-property.script` for SNMP type', function () {
-      Em.set(inputFields, 'method.value', 'SNMP');
-      controller.set('inputFields', inputFields);
-      var result = controller.formatNotificationAPIObject();
-      expect(result.AlertTarget.properties['ambari.dispatch-property.script']).to.be.equal('org.apache.ambari.contrib.snmp.script');
-    });
-
-    it('should not set property `ambari.dispatch-property.script` for EMAIL type', function () {
-      Em.set(inputFields, 'method.value', 'EMAIL');
-      controller.set('inputFields', inputFields);
-      var result = controller.formatNotificationAPIObject();
-      expect(result.AlertTarget.properties).to.not.have.property('ambari.dispatch-property.script');
+    var inputFields = Em.Object.create({
+      name: {
+        value: 'test_name'
+      },
+      groups: {
+        value: [{id: 1}, {id: 2}, {id: 3}]
+      },
+      allGroups: {
+        value: 'custom'
+      },
+      global: {
+        value: false
+      },
+      method: {
+        value: 'EMAIL'
+      },
+      email: {
+        value: 'test1@test.test, test2@test.test,test3@test.test , test4@test.test'
+      },
+      severityFilter: {
+        value: ['OK', 'CRITICAL']
+      },
+      SMTPServer: {
+        value: 's1'
+      },
+      SMTPPort: {
+        value: '25'
+      },
+      SMTPUseAuthentication: {
+        value: "true"
+      },
+      SMTPUsername: {
+        value: 'user'
+      },
+      SMTPPassword: {
+        value: 'pass'
+      },
+      SMTPSTARTTLS: {
+        value: "true"
+      },
+      emailFrom: {
+        value: 'from'
+      },
+      description: {
+        value: 'test_description'
+      },
+      customProperties: [
+        {name: 'n1', value: 'v1'},
+        {name: 'n2', value: 'v2'}
+      ]
     });
 
     it("should create object with properties from inputFields values", function () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/ba604ea6/ambari-web/test/views/common/log_file_search_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/log_file_search_view_test.js b/ambari-web/test/views/common/log_file_search_view_test.js
index a5f940e..ca208b3 100644
--- a/ambari-web/test/views/common/log_file_search_view_test.js
+++ b/ambari-web/test/views/common/log_file_search_view_test.js
@@ -32,8 +32,7 @@ describe('App.LogFileSearchView', function() {
         isIncluded: !!isIncluded
       });
     };
-
-    [
+    var cases = [
       {
         viewContent: {
           keywordsFilterValue: 'some_keyword'