You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2016/12/02 20:26:01 UTC
[03/50] [abbrv] ambari git commit: AMBARI-19026. Add Host Wizard:
validation failed on Assign Slaves step (alexantonenko)
AMBARI-19026. Add Host Wizard: validation failed on Assign Slaves step (alexantonenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/28d78348
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/28d78348
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/28d78348
Branch: refs/heads/branch-dev-patch-upgrade
Commit: 28d783486cb5f4f659126c77792fe44f39f43584
Parents: 89780fa
Author: Alex Antonenko <hi...@gmail.com>
Authored: Wed Nov 30 15:56:48 2016 +0200
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Wed Nov 30 15:56:57 2016 +0200
----------------------------------------------------------------------
.../app/controllers/wizard/step6_controller.js | 58 +++++++++++---------
.../test/controllers/wizard/step6_test.js | 6 +-
2 files changed, 36 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/28d78348/ambari-web/app/controllers/wizard/step6_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step6_controller.js b/ambari-web/app/controllers/wizard/step6_controller.js
index dfd0687..745ecc7 100644
--- a/ambari-web/app/controllers/wizard/step6_controller.js
+++ b/ambari-web/app/controllers/wizard/step6_controller.js
@@ -351,29 +351,36 @@ App.WizardStep6Controller = Em.Controller.extend(App.HostComponentValidationMixi
},
/**
- * Get active host names
- * @return {string[]}
- * @method getHostNames
- */
- getHostNames: function () {
- var hostInfo = this.get('content.hosts');
- var hostNames = [];
- //flag identify whether get all hosts or only uninstalled(newly added) hosts
- var getUninstalledHosts = this.get('content.controllerName') !== 'addServiceController';
-
- for (var index in hostInfo) {
- if (hostInfo.hasOwnProperty(index)) {
- if (hostInfo[index].bootStatus === 'REGISTERED') {
- if (!getUninstalledHosts || !hostInfo[index].isInstalled) {
- hostNames.push(hostInfo[index].name);
- }
- }
- }
- }
- return hostNames;
+ * Returns list of new hosts
+ *
+ * @param {object[]} [allHosts=null]
+ * @return {object[]}
+ */
+ getNewHosts: function(allHosts) {
+ var hosts = allHosts || this.getAllHosts();
+ return hosts.filterProperty('isInstalled', false);
},
/**
+ * Returns list of registered hosts
+ *
+ * @return {object[{hostName, isInstalled}]}
+ */
+ getAllHosts: function() {
+ var self = this;
+ var hosts = self.get('content.hosts');
+ return Em.keys(this.get('content.hosts')).reduce(function(res, hostName) {
+ var host = hosts[hostName];
+ if (Em.get(host, 'bootStatus') !== 'REGISTERED') {
+ return res;
+ }
+ return res.concat({
+ hostName: hostName,
+ isInstalled: Em.getWithDefault(host, 'isInstalled', false)
+ });
+ }, []);
+ },
+ /**
* Load all data needed for this module. Then it automatically renders in template
* @method render
*/
@@ -382,9 +389,10 @@ App.WizardStep6Controller = Em.Controller.extend(App.HostComponentValidationMixi
masterHosts = [],
headers = this.get('headers'),
masterHostNames = this.get('content.masterComponentHosts').mapProperty('hostName').uniq(),
- masterHostNamesMap = masterHostNames.toWickMap();
+ masterHostNamesMap = masterHostNames.toWickMap(),
+ hosts = this.get('isAddHostWizard') ? this.getNewHosts() : this.getAllHosts();
- this.getHostNames().forEach(function (_hostName) {
+ hosts.mapProperty('hostName').forEach(function (_hostName) {
var hasMaster = masterHostNamesMap[_hostName];
var obj = {
@@ -403,7 +411,7 @@ App.WizardStep6Controller = Em.Controller.extend(App.HostComponentValidationMixi
};
if (hasMaster) {
- masterHosts.pushObject(obj)
+ masterHosts.pushObject(obj);
} else {
hostsObj.pushObject(obj);
}
@@ -640,7 +648,7 @@ App.WizardStep6Controller = Em.Controller.extend(App.HostComponentValidationMixi
var selectedServices = App.StackService.find().filterProperty('isSelected').mapProperty('serviceName');
var installedServices = App.StackService.find().filterProperty('isInstalled').mapProperty('serviceName');
var services = installedServices.concat(selectedServices).uniq();
- var hostNames = this.get('hosts').mapProperty('hostName');
+ var hostNames = this.getAllHosts().mapProperty('hostName');
var bluePrintsForValidation = this.getValidationBlueprint();
this.set('content.recommendationsHostGroups', bluePrintsForValidation);
@@ -660,7 +668,7 @@ App.WizardStep6Controller = Em.Controller.extend(App.HostComponentValidationMixi
var slaveBlueprint = this.getCurrentBlueprint();
var masterBlueprint = null;
var invisibleInstalledMasters = [];
- var hostNames = this.get('hosts').mapProperty('hostName');
+ var hostNames = this.getAllHosts().mapProperty('hostName');
var invisibleSlavesAndClients = App.StackServiceComponent.find().filter(function (component) {
return component.get("isSlave") && component.get("isShownOnInstallerSlaveClientPage") === false ||
component.get("isClient") && component.get("isRequiredOnAllHosts");
http://git-wip-us.apache.org/repos/asf/ambari/blob/28d78348/ambari-web/test/controllers/wizard/step6_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step6_test.js b/ambari-web/test/controllers/wizard/step6_test.js
index b2bc879..851b984 100644
--- a/ambari-web/test/controllers/wizard/step6_test.js
+++ b/ambari-web/test/controllers/wizard/step6_test.js
@@ -972,7 +972,7 @@ describe('App.WizardStep6Controller', function () {
});
});
- describe('#getHostNames', function () {
+ describe('#getAllHosts', function () {
var tests = Em.A([
{
hosts: {
@@ -1010,8 +1010,8 @@ describe('App.WizardStep6Controller', function () {
tests.forEach(function (test) {
it(test.m, function () {
controller.set('content.hosts', test.hosts);
- var r = controller.getHostNames();
- expect(r).to.eql(test.e);
+ var r = controller.getAllHosts();
+ expect(r.mapProperty('hostName')).to.eql(test.e);
});
});
});