|
@@ -53,7 +53,6 @@ App.AssignMasterOnStep7Controller = Em.Controller.extend(App.BlueprintMixin, App
|
|
|
this.set('configWidgetContext', context);
|
|
|
this.set('content', context.get('controller.content'));
|
|
|
this.set('configActionComponent', hostComponent);
|
|
|
- this.set('mastersToCreate', [hostComponent.componentName]);
|
|
|
var missingDependentServices = this.getAllMissingDependentServices();
|
|
|
var isNonWizardPage = !this.get('content.controllerName');
|
|
|
switch (action) {
|
|
@@ -61,10 +60,12 @@ App.AssignMasterOnStep7Controller = Em.Controller.extend(App.BlueprintMixin, App
|
|
|
if (missingDependentServices.length && isNonWizardPage) {
|
|
|
this.showInstallServicesPopup(missingDependentServices);
|
|
|
} else {
|
|
|
+ this.set('mastersToCreate', [hostComponent.componentName]);
|
|
|
this.showAssignComponentPopup();
|
|
|
}
|
|
|
break;
|
|
|
case 'DELETE':
|
|
|
+ this.set('mastersToCreate', [hostComponent.componentName]);
|
|
|
this.removeMasterComponent();
|
|
|
break;
|
|
|
}
|
|
@@ -139,11 +140,25 @@ App.AssignMasterOnStep7Controller = Em.Controller.extend(App.BlueprintMixin, App
|
|
|
if (this.get('content.controllerName')) {
|
|
|
var parentController = App.router.get(this.get('content.controllerName'));
|
|
|
var masterComponentHosts = this.get('content.masterComponentHosts');
|
|
|
+ var recommendationsHostGroups = this.get('content.recommendationsHostGroups');
|
|
|
componentsToDelete.forEach(function (_componentName) {
|
|
|
masterComponentHosts = masterComponentHosts.rejectProperty('component', _componentName);
|
|
|
+ recommendationsHostGroups.blueprint.host_groups.forEach(function(hostGroup){
|
|
|
+ hostGroup.components = hostGroup.components.rejectProperty('name', _componentName);
|
|
|
+ }, this);
|
|
|
}, this);
|
|
|
this.get('content').set('masterComponentHosts', masterComponentHosts);
|
|
|
parentController.setDBProperty('masterComponentHosts', masterComponentHosts);
|
|
|
+ parentController.setDBProperty('recommendationsHostGroups', recommendationsHostGroups);
|
|
|
+ } else {
|
|
|
+ this.clearComponentsToBeAdded(componentsToDelete[0]);
|
|
|
+ var hostComponent = App.HostComponent.find().findProperty('componentName', componentsToDelete[0]);
|
|
|
+ if (hostComponent) {
|
|
|
+ App.set('componentToBeDeleted', Em.Object.create({
|
|
|
+ componentName: componentsToDelete[0],
|
|
|
+ hostName: hostComponent.get('hostName')
|
|
|
+ }));
|
|
|
+ }
|
|
|
}
|
|
|
var configActionComponent = this.get('configActionComponent');
|
|
|
this.get('configWidgetContext.config').set('configActionComponent', configActionComponent);
|
|
@@ -218,6 +233,98 @@ App.AssignMasterOnStep7Controller = Em.Controller.extend(App.BlueprintMixin, App
|
|
|
});
|
|
|
},
|
|
|
|
|
|
+ /**
|
|
|
+ * This method saves masterComponent layout that is used on subsequent "Review" and "Install start and Test services" pages.
|
|
|
+ * @private
|
|
|
+ * @method {saveMasterComponentHosts}
|
|
|
+ */
|
|
|
+ saveMasterComponentHosts: function() {
|
|
|
+ var controller = App.router.get(this.get('content.controllerName'));
|
|
|
+ controller.saveMasterComponentHosts(this);
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * This method saves host group layout that is used for blueprint validation call made while transitioning to "Review" page.
|
|
|
+ * @private
|
|
|
+ * @method {saveRecommendationsHostGroups}
|
|
|
+ */
|
|
|
+ saveRecommendationsHostGroups: function() {
|
|
|
+ var controller = App.router.get(this.get('content.controllerName'));
|
|
|
+ var recommendationsHostGroups = this.get('content.recommendationsHostGroups');
|
|
|
+ var masterComponentHosts = this.get('content.masterComponentHosts');
|
|
|
+ var mastersToCreate = this.get('mastersToCreate');
|
|
|
+ mastersToCreate.forEach(function(componentName) {
|
|
|
+ var hostName = this.getSelectedHostName(componentName);
|
|
|
+ if (hostName && recommendationsHostGroups) {
|
|
|
+ var hostGroups = recommendationsHostGroups.blueprint_cluster_binding.host_groups;
|
|
|
+ var isHostPresent = false;
|
|
|
+ var i = 0;
|
|
|
+ while (i < hostGroups.length) {
|
|
|
+ var hosts = hostGroups[i].hosts;
|
|
|
+ isHostPresent = hosts.someProperty('fqdn', hostName);
|
|
|
+ if (isHostPresent) break;
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ if (isHostPresent) {
|
|
|
+ var hostGroupName = hostGroups[i].name;
|
|
|
+ var hostGroup = recommendationsHostGroups.blueprint.host_groups.findProperty('name', hostGroupName);
|
|
|
+ var addHostComponentInGroup = !hostGroup.components.someProperty('name', componentName);
|
|
|
+ if (addHostComponentInGroup) {
|
|
|
+ hostGroup.components.pushObject({name: componentName});
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, this);
|
|
|
+ controller.setDBProperty('recommendationsHostGroups', recommendationsHostGroups);
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Get the fqdn hostname as selected by the user for the component.
|
|
|
+ * @param componentName
|
|
|
+ * @return {String}
|
|
|
+ */
|
|
|
+ getSelectedHostName: function(componentName) {
|
|
|
+ var selectedServicesMasters = this.get('selectedServicesMasters');
|
|
|
+ return selectedServicesMasters.findProperty('component_name', componentName).selectedHost;
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * set App.componentToBeAdded to use it on subsequent validation call while saving configuration
|
|
|
+ * @param componentName {String}
|
|
|
+ * @param hostName {String}
|
|
|
+ * @method {setGlobalComponentToBeAdded}
|
|
|
+ */
|
|
|
+ setGlobalComponentToBeAdded: function(componentName, hostName) {
|
|
|
+ var componentToBeAdded = Em.Object.create({
|
|
|
+ componentName: componentName,
|
|
|
+ hostNames: [hostName]
|
|
|
+ });
|
|
|
+ App.set('componentToBeAdded', componentToBeAdded);
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * clear 'componentToBeDeleted' object
|
|
|
+ * @param componentName {String}
|
|
|
+ * @public
|
|
|
+ * @method {clearComponentsToBeDeleted}
|
|
|
+ */
|
|
|
+ clearComponentsToBeDeleted: function(componentName) {
|
|
|
+ var componentsToBeDeleted = App.get('componentToBeDeleted');
|
|
|
+ if (!App.isEmptyObject(componentsToBeDeleted) && componentsToBeDeleted.get('componentName') === componentName) {
|
|
|
+ App.set('componentToBeDeleted', {});
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * clear 'componentToBeAdded' object
|
|
|
+ * @param componentName {String}
|
|
|
+ */
|
|
|
+ clearComponentsToBeAdded: function(componentName) {
|
|
|
+ var componentsToBeAdded = App.get('componentToBeAdded');
|
|
|
+ if (!App.isEmptyObject(componentsToBeAdded) && componentsToBeAdded.get('componentName') === componentName) {
|
|
|
+ App.set('componentToBeAdded', {});
|
|
|
+ }
|
|
|
+ },
|
|
|
|
|
|
/**
|
|
|
* Submit button click handler
|
|
@@ -225,14 +332,16 @@ App.AssignMasterOnStep7Controller = Em.Controller.extend(App.BlueprintMixin, App
|
|
|
*/
|
|
|
submit: function () {
|
|
|
this.get('popup').hide();
|
|
|
- if (this.get('content.controllerName')) {
|
|
|
- var controller = App.router.get(this.get('content.controllerName'));
|
|
|
- controller.saveMasterComponentHosts(this);
|
|
|
- }
|
|
|
- var selectedServicesMasters = this.get('selectedServicesMasters');
|
|
|
var context = this.get('configWidgetContext');
|
|
|
var configActionComponent = this.get('configActionComponent');
|
|
|
- var componentHostName = selectedServicesMasters.findProperty('component_name', configActionComponent.componentName).selectedHost;
|
|
|
+ var componentHostName = this.getSelectedHostName(configActionComponent.componentName);
|
|
|
+ if (this.get('content.controllerName')) {
|
|
|
+ this.saveMasterComponentHosts();
|
|
|
+ this.saveRecommendationsHostGroups();
|
|
|
+ } else {
|
|
|
+ this.setGlobalComponentToBeAdded(configActionComponent.componentName, componentHostName);
|
|
|
+ this.clearComponentsToBeDeleted(configActionComponent.componentName);
|
|
|
+ }
|
|
|
|
|
|
var hostComponentConfig = context.get('config.configAction.hostComponentConfig');
|
|
|
var serviceConfigs = context.get('controller.stepConfigs').findProperty('serviceName', context.get('config.serviceName')).get('configs');
|