Repository: ambari Updated Branches: refs/heads/trunk 5cadb0636 -> 50b0d984e
AMBARI-19781 Reassign wizard erases config properties attributes. (ababiichuk) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/50b0d984 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/50b0d984 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/50b0d984 Branch: refs/heads/trunk Commit: 50b0d984ef186e18ebca3901f7f35d21f8294c81 Parents: 5cadb06 Author: Max Shepel <[email protected]> Authored: Tue Jan 31 00:03:34 2017 +0200 Committer: Max Shepel <[email protected]> Committed: Tue Jan 31 00:03:34 2017 +0200 ---------------------------------------------------------------------- .../main/service/reassign/step3_controller.js | 9 +++++++++ .../main/service/reassign/step4_controller.js | 12 ++++++++---- .../main/service/reassign_controller.js | 18 ++++++++++++------ ambari-web/app/routes/reassign_master_routes.js | 3 ++- .../service/reassign/step4_controller_test.js | 10 +++++----- 5 files changed, 36 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/50b0d984/ambari-web/app/controllers/main/service/reassign/step3_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/service/reassign/step3_controller.js b/ambari-web/app/controllers/main/service/reassign/step3_controller.js index f13cf0b..d4edb1e 100644 --- a/ambari-web/app/controllers/main/service/reassign/step3_controller.js +++ b/ambari-web/app/controllers/main/service/reassign/step3_controller.js @@ -259,6 +259,8 @@ App.ReassignMasterWizardStep3Controller = Em.Controller.extend({ configs: null, + configsAttributes: null, + secureConfigs: [], stepConfigs: [], @@ -281,6 +283,7 @@ App.ReassignMasterWizardStep3Controller = Em.Controller.extend({ clearStep: function () { this.setProperties({ configs: null, + configsAttributes: null, secureConfigs: [], propertiesToChange: {} }); @@ -396,12 +399,18 @@ App.ReassignMasterWizardStep3Controller = Em.Controller.extend({ var componentName = this.get('content.reassign.component_name'); var targetHostName = this.get('content.reassignHosts.target'); var configs = {}; + var attributes = {}; var secureConfigs = []; data.items.forEach(function (item) { configs[item.type] = item.properties; + if (item.properties_attributes) { + attributes[item.type] = item.properties_attributes; + } }); + this.set('configsAttributes', attributes); + this.setAdditionalConfigs(configs, componentName, targetHostName); this.setSecureConfigs(secureConfigs, configs, componentName); http://git-wip-us.apache.org/repos/asf/ambari/blob/50b0d984/ambari-web/app/controllers/main/service/reassign/step4_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/service/reassign/step4_controller.js b/ambari-web/app/controllers/main/service/reassign/step4_controller.js index 2e9d431..f87d05b 100644 --- a/ambari-web/app/controllers/main/service/reassign/step4_controller.js +++ b/ambari-web/app/controllers/main/service/reassign/step4_controller.js @@ -276,22 +276,24 @@ App.ReassignMasterWizardStep4Controller = App.HighAvailabilityProgressPageContro reconfigure: function () { var configs = this.get('content.configs'), + attributes = this.get('content.configsAttributes'), secureConfigs = this.get('content.secureConfigs'), componentName = this.get('content.reassign.component_name'); this.saveClusterStatus(secureConfigs, this.getComponentDir(configs, componentName)); - this.saveConfigsToServer(configs); + this.saveConfigsToServer(configs, attributes); }, /** * make PUT call to save configs to server * @param configs + * @param attributes */ - saveConfigsToServer: function (configs) { + saveConfigsToServer: function (configs, attributes) { App.ajax.send({ name: 'common.across.services.configurations', sender: this, data: { - data: '[' + this.getServiceConfigData(configs).toString() + ']' + data: '[' + this.getServiceConfigData(configs, attributes).toString() + ']' }, success: 'onSaveConfigs', error: 'onTaskError' @@ -300,10 +302,11 @@ App.ReassignMasterWizardStep4Controller = App.HighAvailabilityProgressPageContro /** * gather and format config data before sending to server * @param configs + * @param attributes * @return {Array} * @method getServiceConfigData */ - getServiceConfigData: function (configs) { + getServiceConfigData: function (configs, attributes) { var componentName = this.get('content.reassign.component_name'); var tagName = 'version' + (new Date).getTime(); var configData = Object.keys(configs).map(function (_siteName) { @@ -311,6 +314,7 @@ App.ReassignMasterWizardStep4Controller = App.HighAvailabilityProgressPageContro type: _siteName, tag: tagName, properties: configs[_siteName], + properties_attributes: attributes[_siteName] || {}, service_config_version_note: Em.I18n.t('services.reassign.step4.save.configuration.note').format(App.format.role(componentName, false)) } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/50b0d984/ambari-web/app/controllers/main/service/reassign_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/service/reassign_controller.js b/ambari-web/app/controllers/main/service/reassign_controller.js index e512835..5b3e951 100644 --- a/ambari-web/app/controllers/main/service/reassign_controller.js +++ b/ambari-web/app/controllers/main/service/reassign_controller.js @@ -65,7 +65,9 @@ App.ReassignMasterController = App.WizardController.extend({ hasCheckDBStep: false, componentsWithCheckDBStep: ['HIVE_METASTORE', 'HIVE_SERVER', 'OOZIE_SERVER'], componentsWithoutSecurityConfigs: ['MYSQL_SERVER'], - reassignComponentsInMM: [] + reassignComponentsInMM: [], + configs: null, + configsAttributes: null }), /** @@ -320,14 +322,18 @@ App.ReassignMasterController = App.WizardController.extend({ this.set('content.serviceProperties', serviceProperties); }, - saveConfigs: function (configs) { - this.setDBProperty('configs', configs); - this.set('content.configs', configs); + saveConfigs: function (configs, attributes) { + var configsObject = { + configs: configs, + configsAttributes: attributes + }; + this.setDBProperties(configsObject); + this.get('content').setProperties(configsObject); }, loadConfigs: function () { - var configs = this.getDBProperty('configs'); - this.set('content.configs', configs); + var configsObject = this.getDBProperties(['configs', 'configsAttributes']); + this.get('content').setProperties(configsObject); }, saveDatabaseType: function (type) { http://git-wip-us.apache.org/repos/asf/ambari/blob/50b0d984/ambari-web/app/routes/reassign_master_routes.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/routes/reassign_master_routes.js b/ambari-web/app/routes/reassign_master_routes.js index a2a9743..798ec0f 100644 --- a/ambari-web/app/routes/reassign_master_routes.js +++ b/ambari-web/app/routes/reassign_master_routes.js @@ -184,6 +184,7 @@ module.exports = App.WizardRoute.extend({ var controller = router.get('reassignMasterController'), stepController = router.get('reassignMasterWizardStep3Controller'), configs = stepController.get('configs'), + attributes = stepController.get('configsAttributes'), secureConfigs = stepController.get('secureConfigs'); App.db.setReassignTasksStatuses(undefined); App.db.setReassignTasksRequestIds(undefined); @@ -195,7 +196,7 @@ module.exports = App.WizardRoute.extend({ }); controller.saveReassignComponentsInMM(controller.getReassignComponentsInMM()); stepController.updateServiceConfigs(); - controller.saveConfigs(configs); + controller.saveConfigs(configs, attributes); controller.saveSecureConfigs(secureConfigs); router.transitionTo('step4'); }, http://git-wip-us.apache.org/repos/asf/ambari/blob/50b0d984/ambari-web/test/controllers/main/service/reassign/step4_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/service/reassign/step4_controller_test.js b/ambari-web/test/controllers/main/service/reassign/step4_controller_test.js index 6bf381a..612efd0 100644 --- a/ambari-web/test/controllers/main/service/reassign/step4_controller_test.js +++ b/ambari-web/test/controllers/main/service/reassign/step4_controller_test.js @@ -801,13 +801,13 @@ describe('App.ReassignMasterWizardStep4Controller', function () { it('No services', function () { services = []; controller.set('content.reassign.component_name', 'COMP1'); - expect(controller.getServiceConfigData([])).to.eql([]); + expect(controller.getServiceConfigData({})).to.eql([]); }); it('No services in stackServices', function () { services = [Em.Object.create({serviceName: 'S1'})]; stackServices = []; controller.set('content.reassign.component_name', 'COMP1'); - expect(controller.getServiceConfigData([])).to.eql([]); + expect(controller.getServiceConfigData({}, {})).to.eql([]); }); it('Services in stackServices, but configTypesRendered is empty', function () { services = [Em.Object.create({serviceName: 'S1'})]; @@ -816,7 +816,7 @@ describe('App.ReassignMasterWizardStep4Controller', function () { configTypesRendered: {} })]; controller.set('content.reassign.component_name', 'COMP1'); - expect(controller.getServiceConfigData([])[0]).to.equal("{\"Clusters\":{\"desired_config\":[]}}"); + expect(controller.getServiceConfigData({}, {})[0]).to.equal("{\"Clusters\":{\"desired_config\":[]}}"); }); it('Services in stackServices, and configTypesRendered has data, but configs is empty', function () { services = [Em.Object.create({serviceName: 'S1'})]; @@ -827,7 +827,7 @@ describe('App.ReassignMasterWizardStep4Controller', function () { }) ]; controller.set('content.reassign.component_name', 'COMP1'); - expect(controller.getServiceConfigData([])[0]).to.equal("{\"Clusters\":{\"desired_config\":[]}}"); + expect(controller.getServiceConfigData({}, {})[0]).to.equal("{\"Clusters\":{\"desired_config\":[]}}"); }); it('Services in stackServices, and configTypesRendered has data, and configs present', function () { services = [Em.Object.create({serviceName: 'S1'})]; @@ -843,7 +843,7 @@ describe('App.ReassignMasterWizardStep4Controller', function () { } }; controller.set('content.reassign.component_name', 'COMP1'); - expect(JSON.parse(controller.getServiceConfigData(configs)[0]).Clusters.desired_config.length).to.equal(1); + expect(JSON.parse(controller.getServiceConfigData(configs, {})[0]).Clusters.desired_config.length).to.equal(1); }); });
