Browse Source

AMBARI-8512. Usability: clarify UI for bootstrap ssh + agent accounts in Install / Add Host Wizards (alexantonenko)

Alex Antonenko 10 năm trước cách đây
mục cha
commit
96285c8278

+ 2 - 1
ambari-web/app/config.js

@@ -61,7 +61,8 @@ App.supports = {
   autoRollbackHA: false,
   alerts: true,
   alwaysEnableManagedMySQLForHive: false,
-  automatedKerberos: false
+  automatedKerberos: false,
+  customizeAgentUserAccount: false
 };
 
 if (App.enableExperimental) {

+ 2 - 2
ambari-web/app/controllers/wizard/step2_controller.js

@@ -152,7 +152,7 @@ App.WizardStep2Controller = Em.Controller.extend({
    * @type {string|null}
    */
   agentUserError: function () {
-    if (this.get('manualInstall') === false && Em.isEmpty(this.get('agentUser').trim())) {
+    if (App.get('supports.customizeAgentUserAccount') && this.get('manualInstall') === false && Em.isEmpty(this.get('agentUser').trim())) {
       return Em.I18n.t('installer.step2.sshUser.required');
     }
     return null;
@@ -385,7 +385,7 @@ App.WizardStep2Controller = Em.Controller.extend({
       'sshKey': this.get('sshKey'),
       'hosts': this.get('hostNameArr'),
       'user': this.get('sshUser'),
-      'userRunAs': this.get('agentUser')
+      'userRunAs': App.get('supports.customizeAgentUserAccount') ? this.get('agentUser') : 'root'
     });
     App.router.get(this.get('content.controllerName')).launchBootstrap(bootStrapData, function (requestId) {
       if (requestId == '0') {

+ 2 - 2
ambari-web/app/controllers/wizard/step3_controller.js

@@ -350,8 +350,8 @@ App.WizardStep3Controller = Em.Controller.extend({
         'sshKey': this.get('content.installOptions.sshKey'),
         'hosts': hosts.mapProperty('name'),
         'user': this.get('content.installOptions.sshUser'),
-        'userRunAs': this.get('content.installOptions.agentUser')}
-    );
+        'userRunAs': App.get('supports.customizeAgentUserAccount') ? this.get('content.installOptions.agentUser') : 'root'
+      });
     this.set('numPolls', 0);
     this.set('registrationStartedAt', null);
     if (this.get('content.installOptions.manualInstall')) {

+ 4 - 5
ambari-web/app/messages.js

@@ -468,13 +468,12 @@ Em.I18n.translations = {
   'installer.step2.evaluateStep.installedHosts':'These hosts are already installed on the cluster and will be ignored:',
   'installer.step2.evaluateStep.continueConfirm':'Do you want to continue?',
   'installer.step2.evaluateStep.hostRegInProgress':'Host Registration is currently in progress.  Please try again later.',
-  'installer.step2.sshUser':'SSH user (root or',
-  'installer.step2.sshUser.link':'passwordless sudo',
-  'installer.step2.sshUser.account':'account)',
-  'installer.step2.sshUser.toolTip':'An account that can execute sudo without entering a password',
+  'installer.step2.sshUser':'SSH User Account',
+  'installer.step2.sshUser.toolTip':'The user account used to install the Ambari Agent on the target host(s) via SSH. This user must be set up with passwordless SSH and sudo access on all the target host(s)',
   'installer.step2.sshUser.placeholder':'Enter user name',
   'installer.step2.sshUser.required':'User name is required',
-  'installer.step2.agentUser':'Ambari Agent user (root or',
+  'installer.step2.agentUser':'Ambari Agent User Account',
+  'installer.step2.agentUser.toolTip':'The user account used to run the Ambari Agent daemon on the target host(s). This user must be set up with passwordless sudo access on all the target host(s)',
   'installer.step2.bootStrap.error':'Errors were encountered while setting up Ambari Agents on the hosts.',
   'installer.step2.bootStrap.inProgress':'Please wait while Ambari Agents are being set up on the hosts. This can take several minutes depending on the number of hosts.',
   'installer.step2.bootStrap.header':'Setting Up Ambari Agents',

+ 13 - 21
ambari-web/app/templates/wizard/step2.hbs

@@ -69,13 +69,8 @@
             {{/if}}
           </div>
           <div class="row-fluid">
-            <label class="ssh-user pull-left span5">
+            <label rel="tooltip" {{translateAttr title="installer.step2.sshUser.toolTip"}} class="ssh-user pull-left span4">
               {{t installer.step2.sshUser}}
-              <a href="javascript:void(null)"
-                 rel="popover"
-                {{translateAttr title="installer.step2.sshUser.link" data-content="installer.step2.sshUser.toolTip"}}>
-                {{t installer.step2.sshUser.link}}</a>
-              {{t installer.step2.sshUser.account}}
             </label>
 
             <div {{bindAttr class="sshUserError:error :control-group"}}>
@@ -85,23 +80,20 @@
               {{/if}}
             </div>
           </div>
-          <div class="row-fluid">
-            <label class="ssh-user pull-left span5">
-              {{t installer.step2.agentUser}}
-              <a href="javascript:void(null)"
-                 rel="popover"
-                {{translateAttr title="installer.step2.sshUser.link" data-content="installer.step2.sshUser.toolTip"}}>
-                {{t installer.step2.sshUser.link}}</a>
-              {{t installer.step2.sshUser.account}}
-            </label>
+          {{#if App.supports.customizeAgentUserAccount}}
+            <div class="row-fluid">
+              <label rel="tooltip" {{translateAttr title="installer.step2.agentUser.toolTip"}} class="ssh-user pull-left span4">
+                {{t installer.step2.agentUser}}
+              </label>
 
-            <div {{bindAttr class="agentUserError:error :control-group"}}>
-              {{view view.textFieldView valueBinding="content.installOptions.agentUser" isEnabledBinding="content.installOptions.useSsh"}}
-              {{#if agentUserError}}
-                <span class="help-inline">{{agentUserError}}</span>
-              {{/if}}
+              <div {{bindAttr class="agentUserError:error :control-group"}}>
+                {{view view.textFieldView valueBinding="content.installOptions.agentUser" isEnabledBinding="content.installOptions.useSsh"}}
+                {{#if agentUserError}}
+                  <span class="help-inline">{{agentUserError}}</span>
+                {{/if}}
+              </div>
             </div>
-          </div>
+          {{/if}}
 
         </div>
       {{/if}}

+ 1 - 0
ambari-web/app/views/wizard/step2_view.js

@@ -51,6 +51,7 @@ App.WizardStep2View = Em.View.extend({
 
   didInsertElement: function () {
     App.popover($("[rel=popover]"), {'placement': 'right', 'trigger': 'hover'});
+    App.tooltip($("[rel=tooltip]"), {'placement': 'top', 'trigger': 'hover'});
     //todo: move them to conroller
     this.set('controller.hostsError', null);
     this.set('controller.sshKeyError', null);

+ 55 - 20
ambari-web/test/controllers/wizard/step2_test.js

@@ -287,11 +287,16 @@ describe('App.WizardStep2Controller', function () {
 
   describe('#agentUserError', function () {
 
+    afterEach(function () {
+      App.get.restore();
+    });
+
     userErrorTests.forEach(function(test) {
-      it('', function() {
+      it('Ambari Agent user account customize enabled', function() {
+        sinon.stub(App, 'get').withArgs('supports.customizeAgentUserAccount').returns(true);
         var controller = App.WizardStep2Controller.create({content: {installOptions: {manualInstall: test.manualInstall, agentUser: test.user}}});
         if(Em.isNone(test.e)) {
-          expect(controller.get('agentUserError')).to.equal(null);
+          expect(controller.get('agentUserError')).to.be.null;
         }
         else {
           expect(controller.get('agentUserError').length).to.be.above(2);
@@ -299,6 +304,14 @@ describe('App.WizardStep2Controller', function () {
       });
     });
 
+    userErrorTests.forEach(function(test) {
+      it('Ambari Agent user account customize disabled', function() {
+        sinon.stub(App, 'get').withArgs('supports.customizeAgentUserAccount').returns(false);
+        var controller = App.WizardStep2Controller.create({content: {installOptions: {manualInstall: test.manualInstall, agentUser: test.user}}});
+        expect(controller.get('agentUserError')).to.be.null;
+      });
+    });
+
   });
 
   describe('#getHostInfo()', function () {
@@ -676,27 +689,49 @@ describe('App.WizardStep2Controller', function () {
 
   describe('#setupBootStrap', function () {
 
-    var controller = App.WizardStep2Controller.create({
-      sshKey: 'key',
-      hostNameArr: ['host0', 'host1'],
-      sshUser: 'root',
-      agentUser: 'user',
-      content: {
-        controllerName: 'installerController'
-      }
-    });
+    var cases = [
+        {
+          customizeAgentUserAccount: true,
+          userRunAs: 'user',
+          title: 'Ambari Agent user account customize enabled'
+        },
+        {
+          customizeAgentUserAccount: false,
+          userRunAs: 'root',
+          title: 'Ambari Agent user account customize disabled'
+        }
+      ],
+      controller = App.WizardStep2Controller.create({
+        sshKey: 'key',
+        hostNameArr: ['host0', 'host1'],
+        sshUser: 'root',
+        agentUser: 'user',
+        content: {
+          controllerName: 'installerController'
+        }
+      });
 
-    it('bootstrap data passed correctly', function () {
+    beforeEach(function () {
       sinon.spy(App.router.get('installerController'), 'launchBootstrap');
-      controller.setupBootStrap();
-      expect(App.router.get('installerController.launchBootstrap').firstCall.args[0]).to.equal(JSON.stringify({
-        verbose: true,
-        sshKey: 'key',
-        hosts: ['host0', 'host1'],
-        user: 'root',
-        userRunAs: 'user'
-      }));
+    });
+
+    afterEach(function () {
       App.router.get('installerController.launchBootstrap').restore();
+      App.get.restore();
+    });
+
+    cases.forEach(function (item) {
+      it(item.title, function () {
+        sinon.stub(App, 'get').withArgs('supports.customizeAgentUserAccount').returns(item.customizeAgentUserAccount);
+        controller.setupBootStrap();
+        expect(App.router.get('installerController.launchBootstrap').firstCall.args[0]).to.equal(JSON.stringify({
+          verbose: true,
+          sshKey: 'key',
+          hosts: ['host0', 'host1'],
+          user: 'root',
+          userRunAs: item.userRunAs
+        }));
+      });
     });
 
   });

+ 30 - 14
ambari-web/test/controllers/wizard/step3_test.js

@@ -434,6 +434,18 @@ describe('App.WizardStep3Controller', function () {
 
   describe('#retryHosts', function () {
     var s;
+    var agentUserCases = [
+      {
+        customizeAgentUserAccount: true,
+        userRunAs: 'user',
+        title: 'Ambari Agent user account customize enabled'
+      },
+      {
+        customizeAgentUserAccount: false,
+        userRunAs: 'root',
+        title: 'Ambari Agent user account customize disabled'
+      }
+    ];
     var installer = {launchBootstrap: Em.K};
 
     beforeEach(function () {
@@ -473,21 +485,25 @@ describe('App.WizardStep3Controller', function () {
       c.retryHosts(Em.A([]));
       expect(installer.launchBootstrap.calledOnce).to.be.true;
     });
-    it('bootstrap data passed correctly', function () {
-      var controller = App.WizardStep2Controller.create({
-        sshKey: 'key',
-        hostNameArr: ['host0', 'host1'],
-        sshUser: 'root',
-        agentUser: 'user'
+    agentUserCases.forEach(function (item) {
+      it(item.title, function () {
+        var controller = App.WizardStep2Controller.create({
+          sshKey: 'key',
+          hostNameArr: ['host0', 'host1'],
+          sshUser: 'root',
+          agentUser: 'user'
+        });
+        sinon.stub(App, 'get').withArgs('supports.customizeAgentUserAccount').returns(item.customizeAgentUserAccount);
+        controller.setupBootStrap();
+        expect(installer.launchBootstrap.firstCall.args[0]).to.equal(JSON.stringify({
+          verbose: true,
+          sshKey: 'key',
+          hosts: ['host0', 'host1'],
+          user: 'root',
+          userRunAs: item.userRunAs
+        }));
+        App.get.restore();
       });
-      controller.setupBootStrap();
-      expect(installer.launchBootstrap.firstCall.args[0]).to.equal(JSON.stringify({
-        verbose: true,
-        sshKey: 'key',
-        hosts: ['host0', 'host1'],
-        user: 'root',
-        userRunAs: 'user'
-      }));
     });
   });
 

+ 6 - 0
ambari-web/test/views/wizard/step2_view_test.js

@@ -41,11 +41,13 @@ describe('App.WizardStep0View', function () {
   describe('#didInsertElement', function() {
     beforeEach(function () {
       sinon.stub(App, 'popover', Em.K);
+      sinon.stub(App, 'tooltip', Em.K);
       view.set('controller.hostsError', 'some text');
       view.set('controller.sshKeyError', 'some text');
     });
     afterEach(function () {
       App.popover.restore();
+      App.tooltip.restore();
     });
     it('should clean hostsError', function () {
       view.didInsertElement();
@@ -59,6 +61,10 @@ describe('App.WizardStep0View', function () {
       view.didInsertElement();
       expect(App.popover.calledOnce).to.equal(true);
     });
+    it('should create tooltip', function () {
+      view.didInsertElement();
+      expect(App.tooltip.calledOnce).to.equal(true);
+    });
   });
 
   describe('#providingSSHKeyRadioButton', function() {