You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by al...@apache.org on 2014/12/02 18:38:53 UTC

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

Repository: ambari
Updated Branches:
  refs/heads/trunk 93b8348fa -> 96285c827


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


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

Branch: refs/heads/trunk
Commit: 96285c82788be05f20edddd28365ce7620650128
Parents: 93b8348
Author: Alex Antonenko <hi...@gmail.com>
Authored: Tue Dec 2 19:04:44 2014 +0200
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Tue Dec 2 19:37:06 2014 +0200

----------------------------------------------------------------------
 ambari-web/app/config.js                        |  3 +-
 .../app/controllers/wizard/step2_controller.js  |  4 +-
 .../app/controllers/wizard/step3_controller.js  |  4 +-
 ambari-web/app/messages.js                      |  9 ++-
 ambari-web/app/templates/wizard/step2.hbs       | 34 ++++-----
 ambari-web/app/views/wizard/step2_view.js       |  1 +
 .../test/controllers/wizard/step2_test.js       | 75 ++++++++++++++------
 .../test/controllers/wizard/step3_test.js       | 44 ++++++++----
 ambari-web/test/views/wizard/step2_view_test.js |  6 ++
 9 files changed, 115 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/96285c82/ambari-web/app/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/config.js b/ambari-web/app/config.js
index 69e033b..2b50b26 100644
--- a/ambari-web/app/config.js
+++ b/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) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/96285c82/ambari-web/app/controllers/wizard/step2_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step2_controller.js b/ambari-web/app/controllers/wizard/step2_controller.js
index c408b37..ec82823 100644
--- a/ambari-web/app/controllers/wizard/step2_controller.js
+++ b/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') {

http://git-wip-us.apache.org/repos/asf/ambari/blob/96285c82/ambari-web/app/controllers/wizard/step3_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step3_controller.js b/ambari-web/app/controllers/wizard/step3_controller.js
index 0caf756..8a6c54a 100644
--- a/ambari-web/app/controllers/wizard/step3_controller.js
+++ b/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')) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/96285c82/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index e1fa969..e148eb6 100644
--- a/ambari-web/app/messages.js
+++ b/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',

http://git-wip-us.apache.org/repos/asf/ambari/blob/96285c82/ambari-web/app/templates/wizard/step2.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/wizard/step2.hbs b/ambari-web/app/templates/wizard/step2.hbs
index dbf425c..0260b76 100644
--- a/ambari-web/app/templates/wizard/step2.hbs
+++ b/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}}

http://git-wip-us.apache.org/repos/asf/ambari/blob/96285c82/ambari-web/app/views/wizard/step2_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/wizard/step2_view.js b/ambari-web/app/views/wizard/step2_view.js
index e227e8c..f5bf377 100644
--- a/ambari-web/app/views/wizard/step2_view.js
+++ b/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);

http://git-wip-us.apache.org/repos/asf/ambari/blob/96285c82/ambari-web/test/controllers/wizard/step2_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step2_test.js b/ambari-web/test/controllers/wizard/step2_test.js
index da7cd6a..bb736ee 100644
--- a/ambari-web/test/controllers/wizard/step2_test.js
+++ b/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
+        }));
+      });
     });
 
   });

http://git-wip-us.apache.org/repos/asf/ambari/blob/96285c82/ambari-web/test/controllers/wizard/step3_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step3_test.js b/ambari-web/test/controllers/wizard/step3_test.js
index 742b4d6..a433f23 100644
--- a/ambari-web/test/controllers/wizard/step3_test.js
+++ b/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'
-      }));
     });
   });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/96285c82/ambari-web/test/views/wizard/step2_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/wizard/step2_view_test.js b/ambari-web/test/views/wizard/step2_view_test.js
index 47db377..fc8f79f 100644
--- a/ambari-web/test/views/wizard/step2_view_test.js
+++ b/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() {