Repository: ambari
Updated Branches:
  refs/heads/branch-2.0.0 71c73dc8a -> c2d575861


AMBARI-9833. UI should get information about repos and packages for HostCheck 
from custom action. (akovalenko)


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

Branch: refs/heads/branch-2.0.0
Commit: c2d575861e6efe9a029721e314257f92eccd6f70
Parents: 71c73dc
Author: Aleksandr Kovalenko <akovale...@hortonworks.com>
Authored: Fri Feb 27 18:05:54 2015 +0200
Committer: Yusaku Sako <yus...@hortonworks.com>
Committed: Tue Mar 3 10:09:11 2015 -0800

----------------------------------------------------------------------
 .../app/controllers/wizard/step3_controller.js  | 26 ++++--
 ambari-web/app/styles/application.less          |  3 +
 .../test/controllers/wizard/step3_test.js       | 96 ++++++++------------
 3 files changed, 62 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/c2d57586/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 2c545c1..b07391a 100644
--- a/ambari-web/app/controllers/wizard/step3_controller.js
+++ b/ambari-web/app/controllers/wizard/step3_controller.js
@@ -94,6 +94,12 @@ App.WizardStep3Controller = Em.Controller.extend({
   hasMoreRegisteredHosts: false,
 
   /**
+   * Contain data about installed packages on hosts
+   * @type {Array}
+   */
+  hostsPackagesData: [],
+
+  /**
    * List of installed hostnames
    * @type {string[]}
    */
@@ -863,13 +869,13 @@ App.WizardStep3Controller = Em.Controller.extend({
     if (App.get('testMode')) {
       this.getHostInfo();
     } else {
-      var data = this.getDataForCheckRequest("last_agent_env_check", false);
+      var data = 
this.getDataForCheckRequest("last_agent_env_check,installed_packages,existing_repos",
 false);
       data ? this.requestToPerformHostCheck(data) : this.stopHostCheck();
     }
   },
 
   /**
-   * set all fields from which depends runnig host check to true value
+   * set all fields from which depends running host check to true value
    * which force finish checking;
    */
   stopHostCheck: function() {
@@ -961,7 +967,7 @@ App.WizardStep3Controller = Em.Controller.extend({
     var requestId = this.get("requestId");
     var checker = setTimeout(function () {
       if (self.get('stopChecking') == true) {
-        clearInterval(checker);
+        clearTimeout(checker);
       } else {
         App.ajax.send({
           name: 'preinstalled.checks.tasks',
@@ -990,7 +996,13 @@ App.WizardStep3Controller = Em.Controller.extend({
     if (["FAILED", "COMPLETED", 
"TIMEDOUT"].contains(data.Requests.request_status)) {
       if (data.Requests.inputs.indexOf("last_agent_env_check") != -1) {
         this.set('stopChecking', true);
-         this.getHostInfo();
+        this.set('hostsPackagesData', data.tasks.map(function (task) {
+          return {
+            hostName: Em.get(task, 'Tasks.host_name'),
+            installedPackages: Em.get(task, 
'Tasks.structured_out.installed_packages')
+          }
+        }));
+        this.getHostInfo();
       } else if (data.Requests.inputs.indexOf("host_resolution_check") != -1) {
         this.parseHostNameResolution(data);
         this.getGeneralHostCheck();
@@ -1424,6 +1436,7 @@ App.WizardStep3Controller = Em.Controller.extend({
       usersWarnings: {},
       alternativeWarnings: {}
     };
+    var hostsPackagesData = this.get('hostsPackagesData');
 
     data.items.sortPropertyLight('Hosts.host_name').forEach(function (_host) {
       var host = {
@@ -1458,8 +1471,9 @@ App.WizardStep3Controller = Em.Controller.extend({
       }, this);
 
       //parse all package warnings for host
-      if (_host.Hosts.last_agent_env.installedPackages) {
-        _host.Hosts.last_agent_env.installedPackages.forEach(function 
(_package) {
+      var hostPackagesData = hostsPackagesData.findProperty('hostName', 
_host.Hosts.host_name);
+      if (hostPackagesData) {
+        hostPackagesData.installedPackages.forEach(function (_package) {
           warning = warningCategories.packagesWarnings[_package.name];
           if (warning) {
             warning.hosts.push(_host.Hosts.host_name);

http://git-wip-us.apache.org/repos/asf/ambari/blob/c2d57586/ambari-web/app/styles/application.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/application.less 
b/ambari-web/app/styles/application.less
index 775aa6b..c0c43e8 100644
--- a/ambari-web/app/styles/application.less
+++ b/ambari-web/app/styles/application.less
@@ -3257,6 +3257,9 @@ table.graphs {
     margin-top: 10px;
     }
   }
+  .icon-warning-sign {
+    color: @health-status-yellow;
+  }
 }
 
 .host-checks-update {

http://git-wip-us.apache.org/repos/asf/ambari/blob/c2d57586/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 9846b69..5e3841c 100644
--- a/ambari-web/test/controllers/wizard/step3_test.js
+++ b/ambari-web/test/controllers/wizard/step3_test.js
@@ -1409,62 +1409,6 @@ describe('App.WizardStep3Controller', function () {
           ])
         },
         {
-          m: 'parse installedPackages',
-          tests: Em.A([
-            {
-              items: [
-                {Hosts: {host_name: 'c1', last_agent_env: {installedPackages: 
[]}}}
-              ],
-              m: 'empty installedPackages',
-              e: {
-                warnings: [],
-                warningsByHost: [0]
-              }
-            },
-            {
-              items: [
-                {Hosts: {host_name: 'c1', last_agent_env: {installedPackages: [
-                  {name: 'n1'}
-                ]}}}
-              ],
-              m: 'not empty installedPackages',
-              e: {
-                warnings: [
-                  {
-                    name: 'n1',
-                    hosts: ['c1'],
-                    onSingleHost: true,
-                    category: 'packages'
-                  }
-                ],
-                warningsByHost: [1]
-              }
-            },
-            {
-              items: [
-                {Hosts: {host_name: 'c1', last_agent_env: {installedPackages: [
-                  {name: 'n1'}
-                ]}}},
-                {Hosts: {host_name: 'c2', last_agent_env: {installedPackages: [
-                  {name: 'n1'}
-                ]}}}
-              ],
-              m: 'not empty installedPackages on two hosts',
-              e: {
-                warnings: [
-                  {
-                    name: 'n1',
-                    hosts: ['c1', 'c2'],
-                    onSingleHost: false,
-                    category: 'packages'
-                  }
-                ],
-                warningsByHost: [1]
-              }
-            }
-          ])
-        },
-        {
           m: 'parse hostHealth.liveServices',
           tests: Em.A([
             {
@@ -2523,12 +2467,50 @@ describe('App.WizardStep3Controller', function () {
       Requests: {
         request_status: "COMPLETED",
         inputs: "last_agent_env_check"
-      }
+      },
+      tasks: [
+        {
+          Tasks: {
+            host_name: 'h1',
+            structured_out: {
+              "installed_packages": [
+                {
+                  "version": "b1",
+                  "name": "n1",
+                  "repoName": "r1"
+                },
+                {
+                  "version": "b2",
+                  "name": "n2",
+                  "repoName": "r2"
+                }
+              ]
+            }
+          }
+        }
+      ]
     };
     it('run getHostInfo', function() {
       c.getHostCheckTasksSuccess(lastAgentEnvCheckComplete);
       expect(c.get('stopChecking')).to.be.true;
       expect(c.getHostInfo.calledOnce).to.be.true;
+      expect(c.get('hostsPackagesData')).eql([
+        {
+          hostName: 'h1',
+          installedPackages: [
+            {
+              "version": "b1",
+              "name": "n1",
+              "repoName": "r1"
+            },
+            {
+              "version": "b2",
+              "name": "n2",
+              "repoName": "r2"
+            }
+          ]
+        }
+      ]);
     });
 
   });

Reply via email to