This is an automated email from the ASF dual-hosted git repository. ishanbha pushed a commit to branch branch-feature-AMBARI-14714-ui in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/branch-feature-AMBARI-14714-ui by this push: new b5e77e9 Implemented use of service config API in UI. (#836) b5e77e9 is described below commit b5e77e930bf3cc9e52fb6ecd5d7a36c6b86dabfd Author: Jason Golieb <j...@golieb.net> AuthorDate: Thu Mar 29 16:02:55 2018 -0400 Implemented use of service config API in UI. (#836) --- .../app/controllers/wizard/step8_controller.js | 49 ++++++++++++---------- ambari-web/app/routes/installer.js | 6 +-- ambari-web/app/utils/ajax/ajax.js | 12 ++++++ ambari-web/test/controllers/wizard/step8_test.js | 34 +++++++-------- 4 files changed, 57 insertions(+), 44 deletions(-) diff --git a/ambari-web/app/controllers/wizard/step8_controller.js b/ambari-web/app/controllers/wizard/step8_controller.js index 2ef1597..e4da276 100644 --- a/ambari-web/app/controllers/wizard/step8_controller.js +++ b/ambari-web/app/controllers/wizard/step8_controller.js @@ -1465,6 +1465,8 @@ App.WizardStep8Controller = App.WizardStepController.extend(App.AddSecurityConfi registerHostsToComponent: function (hostNames, componentName) { if (!hostNames.length) return; + let serviceName, + serviceGroupName; var queryStr = ''; hostNames.forEach(function (hostName) { queryStr += 'Hosts/host_name=' + hostName + '|'; @@ -1472,6 +1474,13 @@ App.WizardStep8Controller = App.WizardStepController.extend(App.AddSecurityConfi //slice off last symbol '|' queryStr = queryStr.slice(0, -1); + this.get('selectedServices').forEach( function (service) { + if (service.get('serviceComponents').findProperty('componentName', componentName)) { + serviceName = service.get('serviceName'); + serviceGroupName = service.get('stackName') + "-" + service.get('stackVersion'); + } + }); + var data = { "RequestInfo": { "query": queryStr @@ -1480,7 +1489,9 @@ App.WizardStep8Controller = App.WizardStepController.extend(App.AddSecurityConfi "host_components": [ { "HostRoles": { - "component_name": componentName + "component_name": componentName, + "service_name": serviceName, + "service_group_name": serviceGroupName } } ] @@ -1557,39 +1568,33 @@ App.WizardStep8Controller = App.WizardStepController.extend(App.AddSecurityConfi */ applyConfigurationsToCluster: function (serviceConfigTags) { var allServices = this.get('installedServices').concat(this.get('selectedServices')); - var allConfigData = []; + allServices.forEach(function (service) { var serviceConfigData = []; + Object.keys(service.get('configTypesRendered')).forEach(function (type) { var serviceConfigTag = serviceConfigTags.findProperty('type', type); if (serviceConfigTag) { serviceConfigData.pushObject(serviceConfigTag); } }, this); + if (serviceConfigData.length) { - allConfigData.pushObject(JSON.stringify({ - Clusters: { - desired_config: serviceConfigData.map(function(item) { - var props = {}; - Em.keys(item.properties).forEach(function(propName) { - if (item.properties[propName] !== null) { - props[propName] = item.properties[propName]; - } - }); - item.properties = props; - return item; - }) + //TODO: Remove this delete call when the API supports service_config_version_note + serviceConfigData.forEach(scd => { + delete scd.service_config_version_note; + }) + + this.addRequestToAjaxQueue({ + name: 'common.service.create.configs', + data: { + serviceName: service.get('serviceName'), + serviceGroupName: `${service.get('stackName')}-${service.get('stackVersion')}`, + data: serviceConfigData } - })); + }); } }, this); - - this.addRequestToAjaxQueue({ - name: 'common.across.services.configurations', - data: { - data: '[' + allConfigData.toString() + ']' - } - }); }, /** diff --git a/ambari-web/app/routes/installer.js b/ambari-web/app/routes/installer.js index ffa392f..2082052 100644 --- a/ambari-web/app/routes/installer.js +++ b/ambari-web/app/routes/installer.js @@ -303,16 +303,16 @@ module.exports = Em.Route.extend(App.RouterRedirections, { controller.save('selectedServices'); controller.save('selectedMpacks'); controller.save('advancedMode'); - var wizardStep6Controller = router.get('wizardStep6Controller'); + var wizardSelectMpacksController = router.get('wizardSelectMpacksController'); // Clear subsequent settings if user changed service selections - if (!wizardStep6Controller.get('isSaved')) { + if (!wizardSelectMpacksController.get('isSaved')) { router.get('wizardStep5Controller').clearRecommendations(); controller.setDBProperty('recommendations', undefined); controller.set('content.masterComponentHosts', undefined); controller.setDBProperty('masterComponentHosts', undefined); controller.clearEnhancedConfigs(); controller.setDBProperty('slaveComponentHosts', undefined); - wizardStep6Controller.set('isClientsSet', false); + router.get('wizardStep6Controller').set('isClientsSet', false); } controller.setStepSaved('selectMpacks'); const downloadConfig = controller.get('content.downloadConfig'); diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js index 674d792..f00f08a 100644 --- a/ambari-web/app/utils/ajax/ajax.js +++ b/ambari-web/app/utils/ajax/ajax.js @@ -228,6 +228,7 @@ var urls = { } }, + //This is now legacy and should be replaced by common.service.create.configs below 'common.across.services.configurations': { 'type': 'PUT', 'real':'/clusters/{clusterName}', @@ -240,6 +241,17 @@ var urls = { } }, + 'common.service.create.configs': { + 'type': 'POST', + 'real':'/clusters/{clusterName}/servicegroups/{serviceGroupName}/services/{serviceName}/configurations', + 'format': function(data) { + return { + apiPrefix: 'api/v2', + data: JSON.stringify(data.data) + } + } + }, + 'common.request.polling': { 'real': '/clusters/{clusterName}/requests/{requestId}?fields=tasks/Tasks/request_id,tasks/Tasks/command,tasks/Tasks/command_detail,tasks/Tasks/ops_display_name,tasks/Tasks/start_time,tasks/Tasks/end_time,tasks/Tasks/exit_code,tasks/Tasks/host_name,tasks/Tasks/id,tasks/Tasks/role,tasks/Tasks/status,tasks/Tasks/structured_out,Requests/*&tasks/Tasks/stage_id={stageId}', 'mock': '/data/background_operations/host_upgrade_tasks.json' diff --git a/ambari-web/test/controllers/wizard/step8_test.js b/ambari-web/test/controllers/wizard/step8_test.js index 597265d..896a731 100644 --- a/ambari-web/test/controllers/wizard/step8_test.js +++ b/ambari-web/test/controllers/wizard/step8_test.js @@ -1302,30 +1302,26 @@ describe('App.WizardStep8Controller', function () { describe('#applyConfigurationsToCluster', function() { it('should call addRequestToAjaxQueue', function() { var serviceConfigTags = [ - { - type: 'hdfs', - tag: 'tag1', - properties: { - 'prop1': 'value1' - } - } - ], - data = '['+JSON.stringify({ - Clusters: { - desired_config: [serviceConfigTags[0]] + { + type: 'hdfs', + properties: { + 'prop1': 'value1' } - })+']'; + } + ]; + installerStep8Controller.reopen({ installedServices: [ - Em.Object.create({ - isSelected: true, - isInstalled: false, - configTypesRendered: {hdfs:'tag1'} - }) - ], selectedServices: [] + Em.Object.create({ + isSelected: true, + isInstalled: false, + configTypesRendered: { hdfs: 'tag1' } + }) + ], + selectedServices: [] }); installerStep8Controller.applyConfigurationsToCluster(serviceConfigTags); - expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data).to.equal(data); + expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data).to.deep.equal(serviceConfigTags); }); }); -- To stop receiving notification emails like this one, please contact ishan...@apache.org.