[3/4] ambari git commit: AMBARI-21050. Address config-groups while exporting blueprint from UI (alexantonenko)

2017-05-24 Thread jonathanhurley
AMBARI-21050. Address config-groups while exporting blueprint from UI 
(alexantonenko)


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

Branch: refs/heads/branch-feature-AMBARI-12556
Commit: 90abffd706448786cc02257abd76a22b4f96fcd3
Parents: 5b44fa4
Author: Alex Antonenko 
Authored: Wed May 24 12:02:52 2017 +0300
Committer: Alex Antonenko 
Committed: Wed May 24 12:02:52 2017 +0300

--
 .../app/controllers/wizard/step8_controller.js  | 158 ++-
 .../test/controllers/wizard/step8_test.js   |  78 ++---
 2 files changed, 178 insertions(+), 58 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/ambari/blob/90abffd7/ambari-web/app/controllers/wizard/step8_controller.js
--
diff --git a/ambari-web/app/controllers/wizard/step8_controller.js 
b/ambari-web/app/controllers/wizard/step8_controller.js
index 7e318e0..f2b4ca7 100644
--- a/ambari-web/app/controllers/wizard/step8_controller.js
+++ b/ambari-web/app/controllers/wizard/step8_controller.js
@@ -1811,9 +1811,9 @@ App.WizardStep8Controller = 
Em.Controller.extend(App.AddSecurityConfigs, App.wiz
 return configurationsDetails;
   },
 
-  hostInExistingHostGroup: function (newHost, cluster_template_host_groups) {
+  hostInExistingHostGroup: function (newHost, host_groups) {
 var hostGroupMatched = false;
-  cluster_template_host_groups.some(function (existingHostGroup) {
+  host_groups.some(function (existingHostGroup) {
 if(!hostGroupMatched) {
 var fqdnInHostGroup =  existingHostGroup.hosts[0].fqdn;
 var componentsInExistingHostGroup = 
this.getRegisteredHosts().filterProperty('hostName', 
fqdnInHostGroup)[0].hostComponents;
@@ -1830,8 +1830,8 @@ App.WizardStep8Controller = 
Em.Controller.extend(App.AddSecurityConfigs, App.wiz
   });
   if(!componentMismatch) {
 hostGroupMatched = true;
-existingHostGroup["cardinality"]["cardinality"] = 
parseInt(existingHostGroup["cardinality"]["cardinality"]) + 1;
-existingHostGroup.hosts.push({"fqdn" : newHost.hostName})
+existingHostGroup["cardinality"] = 
parseInt(existingHostGroup["cardinality"]) + 1;
+existingHostGroup.hosts.push({"fqdn" : newHost.hostName});
 return true;
   }
 }
@@ -1840,6 +1840,17 @@ App.WizardStep8Controller = 
Em.Controller.extend(App.AddSecurityConfigs, App.wiz
 return hostGroupMatched;
   },
 
+   hostInChildHostGroup: function (presentHostGroup, configGroupName, 
hostInConfigGroup) {
+return  presentHostGroup['childHostGroups'].some(function (childHostGroup) 
{
+  //Check if childHostGroup name is same as this configgroupname, if yes, 
update childHostGroup else, compare with other childhostgroups
+  if(childHostGroup.configGroupName === configGroupName) {
+childHostGroup.hosts.push( { "fqdn" : hostInConfigGroup } );
+childHostGroup['cardinality'] = childHostGroup['cardinality'] + 1;
+return true;
+  }
+  });
+  },
+
   generateBlueprint: function () {
 console.log("Prepare blueprint for download...");
 var blueprint = {};
@@ -1863,59 +1874,130 @@ App.WizardStep8Controller = 
Em.Controller.extend(App.AddSecurityConfigs, App.wiz
   }, this);
 }, this);
 
-//TODO address configGroups
 var host_groups = [];
 var cluster_template_host_groups = [];
 var counter = 0;
 
 this.getRegisteredHosts().filterProperty('isInstalled', 
false).map(function (host) {
-  var clusterTemplateHostGroupDetail = {};
-  if(self.hostInExistingHostGroup(host, cluster_template_host_groups)) {
+  if(self.hostInExistingHostGroup(host, host_groups)) {
 return;
   }
-
+  //Create new host_group if host is not mapped to existing host_groups
   var hostGroupId = "host_group_" + counter;
-  var cardinality = {"cardinality": 1};
+  var hostListForGroup = [];
+  hostListForGroup.push({ "fqdn": host.hostName });
   var hostGroupDetail = {
 "name": hostGroupId,
 "components": self.getComponentsForHost(host),
-cardinality
+"hosts": hostListForGroup,
+"cardinality" : 1
   };
   hostGroupDetail.toJSON = function () {
-  var hostGroupDetailResult = {};
-  for (var x in this) {
-if (x === "cardinality") {
-  hostGroupDetailResult[x] = (this[x]["cardinality"]).toString();
-  } else {
-hostGroupDetailResult[x] = this[x];
-}
-  }
-  return hostGroupDetailResult;
-  }
+var hostGroupDetailResult = _.omit(this, [ "hosts", "

ambari git commit: AMBARI-21050. Address config-groups while exporting blueprint from UI (alexantonenko)

2017-05-24 Thread alexantonenko
Repository: ambari
Updated Branches:
  refs/heads/trunk 5b44fa44e -> 90abffd70


AMBARI-21050. Address config-groups while exporting blueprint from UI 
(alexantonenko)


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

Branch: refs/heads/trunk
Commit: 90abffd706448786cc02257abd76a22b4f96fcd3
Parents: 5b44fa4
Author: Alex Antonenko 
Authored: Wed May 24 12:02:52 2017 +0300
Committer: Alex Antonenko 
Committed: Wed May 24 12:02:52 2017 +0300

--
 .../app/controllers/wizard/step8_controller.js  | 158 ++-
 .../test/controllers/wizard/step8_test.js   |  78 ++---
 2 files changed, 178 insertions(+), 58 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/ambari/blob/90abffd7/ambari-web/app/controllers/wizard/step8_controller.js
--
diff --git a/ambari-web/app/controllers/wizard/step8_controller.js 
b/ambari-web/app/controllers/wizard/step8_controller.js
index 7e318e0..f2b4ca7 100644
--- a/ambari-web/app/controllers/wizard/step8_controller.js
+++ b/ambari-web/app/controllers/wizard/step8_controller.js
@@ -1811,9 +1811,9 @@ App.WizardStep8Controller = 
Em.Controller.extend(App.AddSecurityConfigs, App.wiz
 return configurationsDetails;
   },
 
-  hostInExistingHostGroup: function (newHost, cluster_template_host_groups) {
+  hostInExistingHostGroup: function (newHost, host_groups) {
 var hostGroupMatched = false;
-  cluster_template_host_groups.some(function (existingHostGroup) {
+  host_groups.some(function (existingHostGroup) {
 if(!hostGroupMatched) {
 var fqdnInHostGroup =  existingHostGroup.hosts[0].fqdn;
 var componentsInExistingHostGroup = 
this.getRegisteredHosts().filterProperty('hostName', 
fqdnInHostGroup)[0].hostComponents;
@@ -1830,8 +1830,8 @@ App.WizardStep8Controller = 
Em.Controller.extend(App.AddSecurityConfigs, App.wiz
   });
   if(!componentMismatch) {
 hostGroupMatched = true;
-existingHostGroup["cardinality"]["cardinality"] = 
parseInt(existingHostGroup["cardinality"]["cardinality"]) + 1;
-existingHostGroup.hosts.push({"fqdn" : newHost.hostName})
+existingHostGroup["cardinality"] = 
parseInt(existingHostGroup["cardinality"]) + 1;
+existingHostGroup.hosts.push({"fqdn" : newHost.hostName});
 return true;
   }
 }
@@ -1840,6 +1840,17 @@ App.WizardStep8Controller = 
Em.Controller.extend(App.AddSecurityConfigs, App.wiz
 return hostGroupMatched;
   },
 
+   hostInChildHostGroup: function (presentHostGroup, configGroupName, 
hostInConfigGroup) {
+return  presentHostGroup['childHostGroups'].some(function (childHostGroup) 
{
+  //Check if childHostGroup name is same as this configgroupname, if yes, 
update childHostGroup else, compare with other childhostgroups
+  if(childHostGroup.configGroupName === configGroupName) {
+childHostGroup.hosts.push( { "fqdn" : hostInConfigGroup } );
+childHostGroup['cardinality'] = childHostGroup['cardinality'] + 1;
+return true;
+  }
+  });
+  },
+
   generateBlueprint: function () {
 console.log("Prepare blueprint for download...");
 var blueprint = {};
@@ -1863,59 +1874,130 @@ App.WizardStep8Controller = 
Em.Controller.extend(App.AddSecurityConfigs, App.wiz
   }, this);
 }, this);
 
-//TODO address configGroups
 var host_groups = [];
 var cluster_template_host_groups = [];
 var counter = 0;
 
 this.getRegisteredHosts().filterProperty('isInstalled', 
false).map(function (host) {
-  var clusterTemplateHostGroupDetail = {};
-  if(self.hostInExistingHostGroup(host, cluster_template_host_groups)) {
+  if(self.hostInExistingHostGroup(host, host_groups)) {
 return;
   }
-
+  //Create new host_group if host is not mapped to existing host_groups
   var hostGroupId = "host_group_" + counter;
-  var cardinality = {"cardinality": 1};
+  var hostListForGroup = [];
+  hostListForGroup.push({ "fqdn": host.hostName });
   var hostGroupDetail = {
 "name": hostGroupId,
 "components": self.getComponentsForHost(host),
-cardinality
+"hosts": hostListForGroup,
+"cardinality" : 1
   };
   hostGroupDetail.toJSON = function () {
-  var hostGroupDetailResult = {};
-  for (var x in this) {
-if (x === "cardinality") {
-  hostGroupDetailResult[x] = (this[x]["cardinality"]).toString();
-  } else {
-hostGroupDetailResult[x] = this[x];
-}
-  }
-  return hostGroupDetailResult;
-  }
+