ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From atk...@apache.org
Subject git commit: AMBARI-4004 Duplicate hosts after closing addServiceWizard. (atkach)
Date Fri, 06 Dec 2013 13:33:58 GMT
Updated Branches:
  refs/heads/trunk 868a78904 -> 758c0a2a0


AMBARI-4004 Duplicate hosts after closing addServiceWizard. (atkach)


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

Branch: refs/heads/trunk
Commit: 758c0a2a05dce52ef4cdec79513fe2f733359279
Parents: 868a789
Author: atkach <atkach@hortonworks.com>
Authored: Fri Dec 6 15:33:55 2013 +0200
Committer: atkach <atkach@hortonworks.com>
Committed: Fri Dec 6 15:33:55 2013 +0200

----------------------------------------------------------------------
 .../app/controllers/wizard/step7_controller.js  | 59 ++++++++++----------
 1 file changed, 31 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/758c0a2a/ambari-web/app/controllers/wizard/step7_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step7_controller.js b/ambari-web/app/controllers/wizard/step7_controller.js
index d7e24ae..2c2848f 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -389,51 +389,54 @@ App.WizardStep7Controller = Em.Controller.extend({
     });
     return validComponents;
   }.property('content'),
-  
+
 
   getAllHosts: function () {
-    // Load hosts
-    var allHosts = Ember.A([]);
-    var hostNameToHostMap = {};
-    var hosts = this.get('content.hosts');
-    for ( var hostName in hosts) {
-      var host = hosts[hostName];
-      hostNameToHostMap[hostName] = App.Host.createRecord({
-        id: host.name,
-        hostName: host.name,
-        publicHostName: host.name,
-        cpu: host.cpu,
-        memory: host.memory
-      });
-      allHosts.pushObject(hostNameToHostMap[hostName]);
+    if (App.Host.find().content.length > 0) {
+      return App.Host.find();
     }
-
-    // Load host-components
+    var hosts = this.get('content.hosts');
     var masterComponents = this.get('content.masterComponentHosts');
     var slaveComponents = this.get('content.slaveComponentHosts');
     masterComponents.forEach(function (component) {
-      var host = hostNameToHostMap[component.hostName];
-      var hc = App.HostComponent.createRecord({
+      App.HostComponent.createRecord({
+        id: component.component + '_' + component.hostName,
         componentName: component.component,
-        host: host
+        host_id: component.hostName
       });
-      if (host != null) {
-        host.get('hostComponents').pushObject(hc);
+      if (!hosts[component.hostName].hostComponents) {
+        hosts[component.hostName].hostComponents = [];
       }
+      hosts[component.hostName].hostComponents.push(component.component + '_' + component.hostName);
     });
     slaveComponents.forEach(function (component) {
       component.hosts.forEach(function (host) {
-        var h = hostNameToHostMap[host.hostName];
-        var hc = App.HostComponent.createRecord({
+        App.HostComponent.createRecord({
+          id: component.componentName + '_' + host.hostName,
           componentName: component.componentName,
-          host: h
+          host_id: host.hostName
         });
-        if (h != null) {
-          h.get('hostComponents').pushObject(hc);
+        if (!hosts[host.hostName].hostComponents) {
+          hosts[host.hostName].hostComponents = [];
         }
+        hosts[host.hostName].hostComponents.push(component.componentName + '_' + host.hostName);
       });
     });
-    return allHosts;
+
+    for (var hostName in hosts) {
+      var host = hosts[hostName];
+      App.store.load(App.Host,
+        {
+          id: host.name,
+          host_name: host.name,
+          public_host_name: host.name,
+          cpu: host.cpu,
+          memory: host.memory,
+          host_components: host.hostComponents
+        }
+      )
+    }
+    return App.Host.find();
   }.property('content')
 
 });


Mime
View raw message