Explorar o código

AMBARI-9430 Specify install requirements in Ranger Add Service Wizard. (ababiichuk)

aBabiichuk %!s(int64=10) %!d(string=hai) anos
pai
achega
0865f9e2f3

+ 46 - 8
ambari-web/app/controllers/wizard/step4_controller.js

@@ -84,14 +84,27 @@ App.WizardStep4Controller = Em.ArrayController.extend({
   ambariMetricsValidation: function () {
     //TODO Change 'AMS' to the actual serviceName after it's changed
     var ambariMetricsService = this.findProperty('serviceName', 'AMS');
-    if (ambariMetricsService) {
-      if (!ambariMetricsService.get('isSelected')) {
-        this.addValidationError({
-          id: 'ambariMetricsCheck',
-          type: 'WARNING',
-          callback: this.ambariMetricsCheckPopup
-        });
-      }
+    if (ambariMetricsService && !ambariMetricsService.get('isSelected')) {
+      this.addValidationError({
+        id: 'ambariMetricsCheck',
+        type: 'WARNING',
+        callback: this.ambariMetricsCheckPopup
+      });
+    }
+  },
+
+  /**
+   * Check whether Ranger is selected and show installation requirements if yes
+   * @method rangerValidation
+   */
+  rangerValidation: function () {
+    var rangerService = this.findProperty('serviceName', 'RANGER');
+    if (rangerService && rangerService.get('isSelected')) {
+      this.addValidationError({
+        id: 'rangerRequirements',
+        type: 'WARNING',
+        callback: this.rangerRequirementsPopup
+      });
     }
   },
 
@@ -132,6 +145,7 @@ App.WizardStep4Controller = Em.ArrayController.extend({
     if (this.get('wizardController.name') == 'installerController') {
       this.ambariMetricsValidation();
     }
+    this.rangerValidation();
     if (!!this.get('errorStack').filterProperty('isShown', false).length) {
       this.showError(this.get('errorStack').findProperty('isShown', false));
       return false;
@@ -361,5 +375,29 @@ App.WizardStep4Controller = Em.ArrayController.extend({
         this.hide();
       }
     });
+  },
+
+  /**
+   * Show popup with installation requirements for Ranger service
+   * @return {App.ModalPopup}
+   * @method rangerRequirementsPopup
+   */
+  rangerRequirementsPopup: function () {
+    var self = this;
+    return App.ModalPopup.show({
+      header: Em.I18n.t('installer.step4.rangerRequirements.popup.header'),
+      bodyClass: Em.View.extend({
+        templateName: require('templates/wizard/step4/step4_ranger_requirements_popup')
+      }),
+      primary: Em.I18n.t('common.proceed'),
+      isChecked: false,
+      disablePrimary: function () {
+        return !this.get('isChecked');
+      }.property('isChecked'),
+      onPrimary: function () {
+        self.onPrimaryPopupCallback();
+        this.hide();
+      }
+    });
   }
 });

+ 7 - 0
ambari-web/app/messages.js

@@ -657,6 +657,13 @@ Em.I18n.translations = {
   'installer.step4.serviceCheck.popup.body':'You did not select {0}, but it is needed by other services you selected. We will automatically add {0}. Is this OK?',
   'installer.step4.ambariMetricsCheck.popup.header':'Limited Functionality Warning',
   'installer.step4.ambariMetricsCheck.popup.body':'Ambari Metrics collects metrics from the cluster and makes them available to Ambari.  If you do not install Ambari Metrics service, metrics will not be accessible from Ambari.  Are you sure you want to proceed without Ambari Metrics?',
+  'installer.step4.rangerRequirements.popup.header': 'Ranger Requirements',
+  'installer.step4.rangerRequirements.popup.body.requirements': '<ol><li>You must have an <strong>existing MySQL Server or Oracle Server</strong> database instance running to be used by Ranger.</li>' +
+    '<li>In Assign Masters step of this wizard, you will be prompted to specify which host for the Ranger Admin. On that host, you <strong>must have MySQL Client or Oracle Client installed</strong> for Ranger to access to the database.</li>' +
+    '<li>Ensure that the access for the DB Admin user (<strong>root</strong> in case of MySQL or <strong>SYS</strong> in case of Oracle) is enabled in DB server from any host.</li>' +
+    '<li>Execute the following command on the Ambari Server host. Replace <code>database-type</code> with <strong>mysql</strong> or <strong>oracle</strong> and <code>/jdbc/driver/path</code> based on the location of the MySQL or Oracle JDBC driver:' +
+    '<pre>ambari-server setup --jdbc-db={database-type} --jdbc-driver={/jdbc/driver/path}</pre></li></ol>',
+  'installer.step4.rangerRequirements.popup.body.confirmation': 'I have met all the requirements above.',
 
   'installer.step5.header':'Assign Masters',
   'installer.step5.reassign.header':'Select Target Host',

+ 20 - 0
ambari-web/app/templates/wizard/step4/step4_ranger_requirements_popup.hbs

@@ -0,0 +1,20 @@
+{{!
+* 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.
+}}
+
+{{t installer.step4.rangerRequirements.popup.body.requirements}}
+<label class="checkbox">{{view Em.Checkbox checkedBinding="isChecked"}}{{t installer.step4.rangerRequirements.popup.body.confirmation}}</label>

+ 44 - 1
ambari-web/test/controllers/wizard/step4_test.js

@@ -25,7 +25,7 @@ describe('App.WizardStep4Controller', function () {
 
   var services = [
     'HDFS', 'NAGIOS', 'GANGLIA', 'OOZIE', 'HIVE', 'HBASE', 'PIG', 'SCOOP', 'ZOOKEEPER',
-    'YARN', 'MAPREDUCE2', 'FALCON', 'TEZ', 'STORM', 'AMS'
+    'YARN', 'MAPREDUCE2', 'FALCON', 'TEZ', 'STORM', 'AMS', 'RANGER'
   ];
 
   var controller = App.WizardStep4Controller.create();
@@ -290,6 +290,10 @@ describe('App.WizardStep4Controller', function () {
         {
           services: ['HDFS','ZOOKEEPER', 'NAGIOS', 'GANGLIA', 'AMS'],
           errorsExpected: []
+        },
+        {
+          services: ['RANGER'],
+          errorsExpected: ['ambariMetricsCheck', 'rangerRequirements']
         }
       ],
       controllerNames = ['installerController', 'addServiceController'],
@@ -556,4 +560,43 @@ describe('App.WizardStep4Controller', function () {
 
   });
 
+  describe('#rangerValidation', function () {
+
+    var cases = [
+      {
+        services: ['HDFS'],
+        isRangerWarning: false,
+        title: 'Ranger not available'
+      },
+      {
+        services: ['RANGER'],
+        isRangerSelected: false,
+        isRangerWarning: false,
+        title: 'Ranger not selected'
+      },
+      {
+        services: ['RANGER'],
+        isRangerSelected: true,
+        isRangerWarning: true,
+        title: 'Ranger selected'
+      }
+    ];
+
+    cases.forEach(function (item) {
+      it(item.title, function () {
+        controller.clear();
+        controller.set('content', generateSelectedServicesContent(item.services));
+        var ranger = controller.findProperty('serviceName', 'RANGER');
+        if (item.services.contains('RANGER')) {
+          ranger.set('isSelected', item.isRangerSelected);
+        } else {
+          controller.removeObject(ranger);
+        }
+        controller.rangerValidation();
+        expect(controller.get('errorStack').mapProperty('id').contains('rangerRequirements')).to.equal(item.isRangerWarning);
+      });
+    });
+
+  });
+
 });