You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by yu...@apache.org on 2013/12/05 15:22:13 UTC
git commit: AMBARI-3865. Security Wizard: Add security Step4
controller and Disable security controller can be extended from same parent
controller. (jaimin via yusaku)
Updated Branches:
refs/heads/trunk 33688dd88 -> 3408cfec8
AMBARI-3865. Security Wizard: Add security Step4 controller and Disable security controller can be extended from same parent controller. (jaimin via yusaku)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/3408cfec
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/3408cfec
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/3408cfec
Branch: refs/heads/trunk
Commit: 3408cfec89364fbaf8750bee00ef809b326c5c5d
Parents: 33688dd
Author: Yusaku Sako <yu...@hortonworks.com>
Authored: Thu Dec 5 06:22:20 2013 -0800
Committer: Yusaku Sako <yu...@hortonworks.com>
Committed: Thu Dec 5 06:22:20 2013 -0800
----------------------------------------------------------------------
ambari-web/app/controllers.js | 1 +
.../main/admin/security/add/step4.js | 357 +------------------
.../controllers/main/admin/security/disable.js | 329 +----------------
.../security/security_progress_controller.js | 346 ++++++++++++++++++
ambari-web/app/utils/ajax.js | 2 +-
ambari-web/app/views/wizard/controls_view.js | 2 +-
6 files changed, 367 insertions(+), 670 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/3408cfec/ambari-web/app/controllers.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers.js b/ambari-web/app/controllers.js
index 48196d0..48c288f 100644
--- a/ambari-web/app/controllers.js
+++ b/ambari-web/app/controllers.js
@@ -52,6 +52,7 @@ require('controllers/main/admin/user/create');
require('controllers/main/admin/advanced');
require('utils/polling');
require('controllers/main/admin/security');
+require('controllers/main/admin/security/security_progress_controller');
require('controllers/main/admin/security/disable');
require('controllers/main/admin/security/add/addSecurity_controller');
require('controllers/main/admin/security/add/step1');
http://git-wip-us.apache.org/repos/asf/ambari/blob/3408cfec/ambari-web/app/controllers/main/admin/security/add/step4.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/security/add/step4.js b/ambari-web/app/controllers/main/admin/security/add/step4.js
index 6e8d6c1..dc16066 100644
--- a/ambari-web/app/controllers/main/admin/security/add/step4.js
+++ b/ambari-web/app/controllers/main/admin/security/add/step4.js
@@ -17,62 +17,41 @@
*/
var App = require('app');
-App.MainAdminSecurityAddStep4Controller = Em.Controller.extend({
+App.MainAdminSecurityAddStep4Controller = App.MainAdminSecurityProgressController.extend({
name: 'mainAdminSecurityAddStep4Controller',
- secureMapping: function () {
- if (App.get('isHadoop2Stack')) {
- return require('data/HDP2/secure_mapping');
- } else {
- return require('data/secure_mapping');
- }
- }.property(App.isHadoop2Stack),
- secureProperties: function () {
- if (App.get('isHadoop2Stack')) {
- return require('data/HDP2/secure_properties').configProperties;
- } else {
- return require('data/secure_properties').configProperties;
- }
- }.property(App.isHadoop2Stack),
- stages: [],
- configs: [],
- noOfWaitingAjaxCalls: 0,
- secureServices: [],
+
serviceUsersBinding: 'App.router.mainAdminSecurityController.serviceUsers',
- serviceConfigTags: [],
- globalProperties: [],
- totalSteps: 3,
- isSubmitDisabled: true,
+ secureServices: function() {
+ return this.get('content.services');
+ }.property('content.services'),
+
isBackBtnDisabled: function () {
return !this.get('stages').someProperty('isError', true);
}.property('stages.@each.isCompleted'),
isOozieSelected: function () {
- return this.get('content.services').someProperty('serviceName', 'OOZIE');
- }.property('content.services'),
+ return this.get('secureServices').someProperty('serviceName', 'OOZIE');
+ }.property('secureServices'),
isHiveSelected: function () {
- return this.get('content.services').someProperty('serviceName', 'HIVE');
- }.property('content.services'),
+ return this.get('secureServices').someProperty('serviceName', 'HIVE');
+ }.property('secureServices'),
isNagiosSelected: function () {
- return this.get('content.services').someProperty('serviceName', 'NAGIOS');
- }.property('content.services'),
+ return this.get('secureServices').someProperty('serviceName', 'NAGIOS');
+ }.property('secureServices'),
isZkSelected: function () {
- return this.get('content.services').someProperty('serviceName', 'ZOOKEEPER');
- }.property('content.services'),
+ return this.get('secureServices').someProperty('serviceName', 'ZOOKEEPER');
+ }.property('secureServices'),
isWebHcatSelected: function () {
var installedServices = App.Service.find().mapProperty('serviceName');
return installedServices.contains('WEBHCAT');
},
- hasHostPopup: true,
- services: [],
- serviceTimestamp: null,
-
isSecurityApplied: function () {
return this.get('stages').someProperty('stage', 'stage3') && this.get('stages').findProperty('stage', 'stage3').get('isSuccess');
}.property('stages.@each.isCompleted'),
@@ -84,15 +63,6 @@ App.MainAdminSecurityAddStep4Controller = Em.Controller.extend({
this.get('serviceConfigTags').clear();
},
- retry: function () {
- var failedStage = this.get('stages').findProperty('isError', true);
- if (failedStage) {
- failedStage.set('isStarted', false);
- failedStage.set('isError', false);
- this.startStage(failedStage);
- }
- },
-
loadStep: function () {
this.set('secureMapping', require('data/secure_mapping').slice(0));
this.clearStep();
@@ -140,110 +110,6 @@ App.MainAdminSecurityAddStep4Controller = Em.Controller.extend({
}
}.observes('stages.@each.isCompleted'),
- updateServices: function () {
- this.services.clear();
- var services = this.get("services");
- this.get("stages").forEach(function (stage) {
- var newService = Ember.Object.create({
- name: stage.label,
- hosts: []
- });
- if (stage && stage.get("polledData")) {
- var hostNames = stage.get("polledData").mapProperty('Tasks.host_name').uniq();
- hostNames.forEach(function (name) {
- newService.hosts.push({
- name: name,
- publicName: name,
- logTasks: stage.polledData.filterProperty("Tasks.host_name", name)
- });
- });
- services.push(newService);
- }
- });
- this.set('serviceTimestamp', new Date().getTime());
- }.observes('stages.@each.polledData'),
-
- loadStages: function () {
- this.get('stages').pushObjects([
- App.Poll.create({stage: 'stage2', label: Em.I18n.translations['admin.addSecurity.apply.stage2'], isPolling: true, name: 'STOP_SERVICES'}),
- App.Poll.create({stage: 'stage3', label: Em.I18n.translations['admin.addSecurity.apply.stage3'], isPolling: false, name: 'APPLY_CONFIGURATIONS'}),
- App.Poll.create({stage: 'stage4', label: Em.I18n.translations['admin.addSecurity.apply.stage4'], isPolling: true, name: 'START_SERVICES'})
- ]);
- },
-
- startStage: function (currentStage) {
- if (this.get('stages').length === this.totalSteps) {
- if (!currentStage) {
- var startedStages = this.get('stages').filterProperty('isStarted', true);
- currentStage = startedStages.findProperty('isCompleted', false);
- }
- if (currentStage && currentStage.get('isPolling') === true) {
- currentStage.set('isStarted', true);
- currentStage.start();
- } else if (currentStage && currentStage.get('stage') === 'stage3') {
- currentStage.set('isStarted', true);
- if (App.testMode) {
- currentStage.set('isError', false);
- currentStage.set('isSuccess', true);
- } else {
- this.loadClusterConfigs();
- }
- }
- }
- },
-
- onCompleteStage: function () {
- if (this.get('stages').length === this.totalSteps) {
- var index = this.get('stages').filterProperty('isSuccess', true).length;
- if (index > 0) {
- var lastCompletedStageResult = this.get('stages').objectAt(index - 1).get('isSuccess');
- if (lastCompletedStageResult) {
- var nextStage = this.get('stages').objectAt(index);
- this.moveToNextStage(nextStage);
- }
- }
- }
- },
-
- moveToNextStage: function (nextStage) {
- if (!nextStage) {
- nextStage = this.get('stages').findProperty('isStarted', false);
- }
- if (nextStage) {
- this.startStage(nextStage);
- }
- },
-
- addInfoToStages: function () {
- this.addInfoToStage2();
- this.addInfoToStage4();
- },
-
- addInfoToStage1: function () {
- var stage1 = this.get('stages').findProperty('stage', 'stage1');
- if (App.testMode) {
- stage1.set('isSuccess', true);
- stage1.set('isStarted', true);
- stage1.set('isCompleted', true);
- }
- },
-
- addInfoToStage2: function () {
- var stage2 = this.get('stages').findProperty('stage', 'stage2');
- var url = (App.testMode) ? '/data/wizard/deploy/2_hosts/poll_1.json' : App.apiPrefix + '/clusters/' + App.router.getClusterName() + '/services';
- var data = '{"RequestInfo": {"context" :"' + Em.I18n.t('requestInfo.stopAllServices') + '"}, "Body": {"ServiceInfo": {"state": "INSTALLED"}}}';
- stage2.set('url', url);
- stage2.set('data', data);
- },
-
- addInfoToStage4: function () {
- var stage4 = this.get('stages').findProperty('stage', 'stage4');
- var url = (App.testMode) ? '/data/wizard/deploy/2_hosts/poll_1.json' : App.apiPrefix + '/clusters/' + App.router.getClusterName() + '/services?params/run_smoke_test=true';
- var data = '{"RequestInfo": {"context": "' + Em.I18n.t('requestInfo.startAllServices') + '"}, "Body": {"ServiceInfo": {"state": "STARTED"}}}';
- stage4.set('url', url);
- stage4.set('data', data);
- },
-
loadUiSideConfigs: function () {
var uiConfig = [];
var configs = this.get('secureMapping').filterProperty('foreignKey', null);
@@ -470,160 +336,7 @@ App.MainAdminSecurityAddStep4Controller = Em.Controller.extend({
},
- loadClusterConfigs: function () {
- App.ajax.send({
- name: 'admin.security.add.cluster_configs',
- sender: this,
- success: 'loadClusterConfigsSuccessCallback',
- error: 'loadClusterConfigsErrorCallback'
- });
- },
-
- loadClusterConfigsSuccessCallback: function (data) {
- var self = this;
- //prepare tags to fetch all configuration for a service
- this.get('content.services').forEach(function (_secureService) {
- self.setServiceTagNames(_secureService, data.Clusters.desired_configs);
- });
- this.getAllConfigurations();
- },
-
- loadClusterConfigsErrorCallback: function (request, ajaxOptions, error) {
- var stage3 = this.get('stages').findProperty('stage', 'stage3');
- if (stage3) {
- stage3.set('isSuccess', false);
- stage3.set('isError', true);
- }
- console.log("TRACE: error code status is: " + request.status);
- },
-
- /**
- * set tagnames for configuration of the *-site.xml
- */
- setServiceTagNames: function (secureService, configs) {
- //var serviceConfigTags = this.get('serviceConfigTags');
- for (var index in configs) {
- if (secureService.sites && secureService.sites.contains(index)) {
- var serviceConfigObj = {
- siteName: index,
- tagName: configs[index].tag,
- newTagName: null,
- configs: {}
- };
- console.log("The value of serviceConfigTags[index]: " + configs[index]);
- this.get('serviceConfigTags').pushObject(serviceConfigObj);
- }
- }
- return serviceConfigObj;
- },
-
- applyConfigurationsToCluster: function () {
- var configData = [];
- this.get('serviceConfigTags').forEach(function (_serviceConfig) {
- var Clusters = {
- Clusters: {
- desired_config: {
- type: _serviceConfig.siteName,
- tag: _serviceConfig.newTagName,
- properties: _serviceConfig.configs
- }
- }
- };
- configData.pushObject(JSON.stringify(Clusters));
- }, this);
-
- var data = {
- configData: '[' + configData.toString() + ']'
- };
-
- App.ajax.send({
- name: 'admin.security.apply_configurations',
- sender: this,
- data: data,
- success: 'applyConfigurationToClusterSuccessCallback',
- error: 'applyConfigurationToClusterErrorCallback'
- });
- },
-
- applyConfigurationToClusterSuccessCallback: function (data) {
- var currentStage = this.get('stages').findProperty('stage', 'stage3');
- currentStage.set('isSuccess', true);
- currentStage.set('isError', false);
- },
-
- applyConfigurationToClusterErrorCallback: function (request, ajaxOptions, error) {
- var stage3 = this.get('stages').findProperty('stage', 'stage3');
- if (stage3) {
- stage3.set('isSuccess', false);
- stage3.set('isError', true);
- }
- },
-
- /**
- * gets site config properties from server and sets it for every configuration
- * @param serviceConfigTags
- */
-
- getAllConfigurations: function () {
- var urlParams = [];
- this.get('serviceConfigTags').forEach(function (_tag) {
- urlParams.push('(type=' + _tag.siteName + '&tag=' + _tag.tagName + ')');
- }, this);
- if (urlParams.length > 0) {
- App.ajax.send({
- name: 'admin.security.all_configurations',
- sender: this,
- data: {
- urlParams: urlParams.join('|')
- },
- success: 'getAllConfigurationsSuccessCallback',
- error: 'getAllConfigurationsErrorCallback'
- });
- }
- },
-
- getAllConfigurationsSuccessCallback: function (data) {
- console.log("TRACE: In success function for the GET getServiceConfigsFromServer call");
- var stage3 = this.get('stages').findProperty('stage', 'stage3');
- this.get('serviceConfigTags').forEach(function (_tag) {
- if (!data.items.someProperty('type', _tag.siteName)) {
- console.log("Error: Metadata for secure services (secure_configs.js) is having config tags that are not being retrieved from server");
- if (stage3) {
- stage3.set('isSuccess', false);
- stage3.set('isError', true);
- }
- }
- _tag.configs = data.items.findProperty('type', _tag.siteName).properties;
- }, this);
- if (this.addSecureConfigs()) {
- this.escapeXMLCharacters(this.get('serviceConfigTags'));
- this.applyConfigurationsToCluster();
- }
- },
-
- getAllConfigurationsErrorCallback: function (request, ajaxOptions, error) {
- var stage3 = this.get('stages').findProperty('stage', 'stage3');
- if (stage3) {
- stage3.set('isSuccess', false);
- stage3.set('isError', true);
- }
- console.log("TRACE: In error function for the getServiceConfigsFromServer call");
- console.log("TRACE: error code status is: " + request.status);
- },
-
- /*
- Iterate over keys of all configurations and escape xml characters in their values
- */
- escapeXMLCharacters: function (serviceConfigTags) {
- serviceConfigTags.forEach(function (_serviceConfigTags) {
- var configs = _serviceConfigTags.configs;
- for (var key in configs) {
- configs[key] = App.config.escapeXMLCharacters(configs[key]);
- }
- }, this);
- },
-
- addSecureConfigs: function () {
+ manageSecureConfigs: function () {
try {
this.get('serviceConfigTags').forEach(function (_serviceConfigTags) {
_serviceConfigTags.newTagName = 'version' + (new Date).getTime();
@@ -675,44 +388,6 @@ App.MainAdminSecurityAddStep4Controller = Em.Controller.extend({
template: Ember.Handlebars.compile('<p>{{t admin.security.apply.configuration.error}}</p>')
})
});
- },
-
- saveStagesOnRequestId: function () {
- this.saveStages();
- }.observes('stages.@each.requestId'),
-
- saveStagesOnCompleted: function () {
- this.saveStages();
- }.observes('stages.@each.isCompleted'),
-
- saveStages: function () {
- var stages = [];
- if (this.get('stages').length === this.totalSteps) {
- this.get('stages').forEach(function (_stage) {
- var stage = {
- name: _stage.get('name'),
- stage: _stage.get('stage'),
- label: _stage.get('label'),
- isPolling: _stage.get('isPolling'),
- isStarted: _stage.get('isStarted'),
- requestId: _stage.get('requestId'),
- isSuccess: _stage.get('isSuccess'),
- isError: _stage.get('isError'),
- url: _stage.get('url'),
- polledData: _stage.get('polledData'),
- data: _stage.get('data')
- };
- stages.pushObject(stage);
- }, this);
- App.db.setSecurityDeployStages(stages);
- if (!App.testMode) {
- App.clusterStatus.setClusterStatus({
- clusterName: this.get('clusterName'),
- clusterState: 'ADD_SECURITY_STEP_4',
- wizardControllerName: App.router.get('addSecurityController.name'),
- localdb: App.db.data
- });
- }
- }
}
+
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/3408cfec/ambari-web/app/controllers/main/admin/security/disable.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/security/disable.js b/ambari-web/app/controllers/main/admin/security/disable.js
index 91b1933..1f15afa 100644
--- a/ambari-web/app/controllers/main/admin/security/disable.js
+++ b/ambari-web/app/controllers/main/admin/security/disable.js
@@ -17,35 +17,10 @@
*/
var App = require('app');
-App.MainAdminSecurityDisableController = Em.Controller.extend({
+App.MainAdminSecurityDisableController = App.MainAdminSecurityProgressController.extend({
name: 'mainAdminSecurityDisableController',
- secureMapping: function() {
- if(App.get('isHadoop2Stack')) {
- return require('data/HDP2/secure_mapping');
- } else {
- return require('data/secure_mapping');
- }
- }.property('App.isHadoop2Stack'),
- secureProperties: function() {
- if(App.get('isHadoop2Stack')) {
- return require('data/HDP2/secure_properties').configProperties;
- } else {
- return require('data/secure_properties').configProperties;
- }
- }.property('App.isHadoop2Stack'),
-
- stages: [],
- configs: [],
- noOfWaitingAjaxCalls: 0,
secureServices: [],
- serviceConfigTags: [],
- globalProperties: [],
- hasHostPopup: true,
- services: [],
- serviceTimestamp: null,
- isSubmitDisabled: true,
- totalSteps: 3,
clearStep: function () {
this.get('stages').clear();
@@ -53,15 +28,6 @@ App.MainAdminSecurityDisableController = Em.Controller.extend({
this.get('serviceConfigTags').clear();
},
- retry: function () {
- var failedStage = this.get('stages').findProperty('isError', true);
- if (failedStage) {
- failedStage.set('isStarted', false);
- failedStage.set('isError', false);
- this.startStage(failedStage);
- }
- },
-
loadStep: function () {
this.clearStep();
var stages = App.db.getSecurityDeployStages();
@@ -97,14 +63,6 @@ App.MainAdminSecurityDisableController = Em.Controller.extend({
},
- loadStages: function () {
- this.get('stages').pushObjects([
- App.Poll.create({stage: 'stage2', label: Em.I18n.translations['admin.addSecurity.apply.stage2'], isPolling: true, name: 'STOP_SERVICES'}),
- App.Poll.create({stage: 'stage3', label: Em.I18n.translations['admin.addSecurity.apply.stage3'], isPolling: false, name: 'APPLY_CONFIGURATIONS'}),
- App.Poll.create({stage: 'stage4', label: Em.I18n.translations['admin.addSecurity.apply.stage4'], isPolling: true, name: 'START_SERVICES'})
- ]);
- },
-
enableSubmit: function () {
if (this.get('stages').someProperty('isError', true) || this.get('stages').everyProperty('isSuccess', true)) {
this.set('isSubmitDisabled', false);
@@ -113,194 +71,6 @@ App.MainAdminSecurityDisableController = Em.Controller.extend({
}
}.observes('stages.@each.isCompleted'),
- startStage: function (currentStage) {
- if (this.get('stages').length === this.totalSteps) {
- if (!currentStage) {
- var startedStages = this.get('stages').filterProperty('isStarted', true);
- currentStage = startedStages.findProperty('isCompleted', false);
- }
- if (currentStage && currentStage.get('isPolling') === true) {
- currentStage.set('isStarted', true);
- currentStage.start();
- } else if (currentStage && currentStage.get('stage') === 'stage3') {
- currentStage.set('isStarted', true);
- if (App.testMode) {
- currentStage.set('isError', false);
- currentStage.set('isSuccess', true);
- } else {
- this.loadClusterConfigs();
- }
- }
- }
- },
-
- onCompleteStage: function () {
- if (this.get('stages').length === this.totalSteps) {
- var index = this.get('stages').filterProperty('isSuccess', true).length;
- if (index > 0) {
- var lastCompletedStageResult = this.get('stages').objectAt(index - 1).get('isSuccess');
- if (lastCompletedStageResult) {
- var nextStage = this.get('stages').objectAt(index);
- this.moveToNextStage(nextStage);
- }
- }
- }
- },
-
- moveToNextStage: function (nextStage) {
- if (!nextStage) {
- nextStage = this.get('stages').findProperty('isStarted', false);
- }
- if (nextStage) {
- this.startStage(nextStage);
- }
- },
-
- updateServices: function () {
- this.services.clear();
- var services = this.get("services");
- this.get("stages").forEach(function (stage) {
- var newService = Ember.Object.create({
- name: stage.label,
- hosts: []
- });
- if (stage && stage.get("polledData")) {
- var hostNames = stage.get("polledData").mapProperty('Tasks.host_name').uniq();
- hostNames.forEach(function (name) {
- newService.hosts.push({
- name: name,
- publicName: name,
- logTasks: stage.polledData.filterProperty("Tasks.host_name", name)
- });
- });
- services.push(newService);
- }
- });
- this.set('serviceTimestamp', new Date().getTime());
- }.observes('stages.@each.polledData'),
-
- addInfoToStages: function () {
- this.addInfoToStage2();
- this.addInfoToStage4();
- },
-
- addInfoToStage1: function () {
- var stage1 = this.get('stages').findProperty('stage', 'stage1');
- if (App.testMode) {
- stage1.set('isSuccess', true);
- stage1.set('isStarted', true);
- stage1.set('isCompleted', true);
- }
- },
-
- addInfoToStage2: function () {
- var stage2 = this.get('stages').findProperty('stage', 'stage2');
- var url = (App.testMode) ? '/data/wizard/deploy/2_hosts/poll_1.json' : App.apiPrefix + '/clusters/' + App.router.getClusterName() + '/services';
- var data = '{"RequestInfo": {"context": "' + Em.I18n.t('requestInfo.stopAllServices') + '"}, "Body": {"ServiceInfo": {"state": "INSTALLED"}}}';
- stage2.set('url', url);
- stage2.set('data', data);
- },
-
- addInfoToStage4: function () {
- var stage4 = this.get('stages').findProperty('stage', 'stage4');
- var url = (App.testMode) ? '/data/wizard/deploy/2_hosts/poll_1.json' : App.apiPrefix + '/clusters/' + App.router.getClusterName() + '/services?params/run_smoke_test=true';
- var data = '{"RequestInfo": {"context": "' + Em.I18n.t('requestInfo.startAllServices') + '"}, "Body": {"ServiceInfo": {"state": "STARTED"}}}';
- stage4.set('url', url);
- stage4.set('data', data);
- },
-
- /**
- * set tagnames for configuration of the *-site.xml
- */
- setServiceTagNames: function (secureService, configs) {
- for (var index in configs) {
- if (secureService.sites && secureService.sites.contains(index)) {
- var serviceConfigObj = {
- siteName: index,
- tagName: configs[index].tag,
- newTagName: null,
- configs: {}
- };
- console.log("The value of serviceConfigTags[index]: " + configs[index]);
- this.get('serviceConfigTags').pushObject(serviceConfigObj);
- }
- }
- return serviceConfigObj;
- },
-
- loadClusterConfigs: function () {
- App.ajax.send({
- name: 'admin.security.cluster_configs',
- sender: this,
- success: 'loadClusterConfigsSuccessCallback',
- error: 'loadClusterConfigsErrorCallback'
- });
- },
-
- loadClusterConfigsSuccessCallback: function (jsonData) {
- //prepare tags to fetch all configuration for a service
- this.get('secureServices').forEach(function (_secureService) {
- this.setServiceTagNames(_secureService, jsonData.Clusters.desired_configs);
- }, this);
- this.getAllConfigurations();
- },
-
- loadClusterConfigsErrorCallback: function (request, ajaxOptions, error) {
- var stage3 = this.get('stages').findProperty('stage', 'stage3');
- if (stage3) {
- stage3.set('isSuccess', false);
- stage3.set('isError', true);
- }
- console.log("TRACE: error code status is: " + request.status);
- },
-
- getAllConfigurations: function () {
- var urlParams = [];
- this.get('serviceConfigTags').forEach(function (_tag) {
- urlParams.push('(type=' + _tag.siteName + '&tag=' + _tag.tagName + ')');
- }, this);
- if (urlParams.length > 0) {
- App.ajax.send({
- name: 'admin.security.all_configurations',
- sender: this,
- data: {
- urlParams: urlParams.join('|')
- },
- success: 'getAllConfigurationsSuccessCallback',
- error: 'getAllConfigurationsErrorCallback'
- });
- }
- },
-
- getAllConfigurationsSuccessCallback: function (data) {
- console.log("TRACE: In success function for the GET getServiceConfigsFromServer call");
- var stage3 = this.get('stages').findProperty('stage', 'stage3');
- this.get('serviceConfigTags').forEach(function (_tag) {
- if (!data.items.someProperty('type', _tag.siteName)) {
- console.log("Error: Metadata for secure services (secure_configs.js) is having config tags that are not being retrieved from server");
- if (stage3) {
- stage3.set('isSuccess', false);
- stage3.set('isError', true);
- }
- }
- _tag.configs = data.items.findProperty('type', _tag.siteName).properties;
- }, this);
- if (this.removeSecureConfigs()) {
- this.escapeXMLCharacters(this.get('serviceConfigTags'));
- this.applyConfigurationsToCluster();
- }
- },
-
- getAllConfigurationsErrorCallback: function (request, ajaxOptions, error) {
- var stage3 = this.get('stages').findProperty('stage', 'stage3');
- if (stage3) {
- stage3.set('isSuccess', false);
- stage3.set('isError', true);
- }
- console.log("TRACE: In error function for the getServiceConfigsFromServer call");
- console.log("TRACE: error code status is: " + request.status);
- },
-
loadSecureServices: function () {
var secureServices = require('data/secure_configs');
@@ -315,61 +85,8 @@ App.MainAdminSecurityDisableController = Em.Controller.extend({
}, this);
},
- applyConfigurationsToCluster: function () {
- var configData = [];
- this.get('serviceConfigTags').forEach(function (_serviceConfig) {
- var Clusters = {
- Clusters: {
- desired_config: {
- type: _serviceConfig.siteName,
- tag: _serviceConfig.newTagName,
- properties: _serviceConfig.configs
- }
- }
- };
- configData.pushObject(JSON.stringify(Clusters));
- }, this);
-
- var data = {
- configData: '[' + configData.toString() + ']'
- };
-
- App.ajax.send({
- name: 'admin.security.apply_configurations',
- sender: this,
- data: data,
- success: 'applyConfigurationToClusterSuccessCallback',
- error: 'applyConfigurationToClusterErrorCallback'
- });
- },
-
- applyConfigurationToClusterSuccessCallback: function (data) {
- var currentStage = this.get('stages').findProperty('stage', 'stage3');
- currentStage.set('isSuccess', true);
- currentStage.set('isError', false);
- },
- applyConfigurationToClusterErrorCallback: function (request, ajaxOptions, error) {
- var stage3 = this.get('stages').findProperty('stage', 'stage3');
- if (stage3) {
- stage3.set('isSuccess', false);
- stage3.set('isError', true);
- }
- },
-
- /*
- Iterate over keys of all configurations and escape xml characters in their values
- */
- escapeXMLCharacters: function(serviceConfigTags) {
- serviceConfigTags.forEach(function (_serviceConfigTags) {
- var configs = _serviceConfigTags.configs;
- for (var key in configs) {
- configs[key] = App.config.escapeXMLCharacters(configs[key]);
- }
- },this);
- },
-
- removeSecureConfigs: function () {
+ manageSecureConfigs: function () {
try {
this.get('serviceConfigTags').forEach(function (_serviceConfigTags, index) {
_serviceConfigTags.newTagName = 'version' + (new Date).getTime();
@@ -434,48 +151,6 @@ App.MainAdminSecurityDisableController = Em.Controller.extend({
return false;
}
return true;
- },
-
- saveStagesOnRequestId: function () {
- this.saveStages();
- }.observes('stages.@each.requestId'),
-
- saveStagesOnCompleted: function () {
- var nonPollingStages = this.get('stages').filterProperty('isPolling', false).someProperty('isCompleted', true);
- if (nonPollingStages) {
- this.saveStages();
- }
- }.observes('stages.@each.isCompleted'),
-
- saveStages: function () {
- var stages = [];
- if (this.get('stages').length === this.totalSteps) {
- this.get('stages').forEach(function (_stage) {
- var stage = {
- name: _stage.get('name'),
- stage: _stage.get('stage'),
- label: _stage.get('label'),
- isPolling: _stage.get('isPolling'),
- isStarted: _stage.get('isStarted'),
- requestId: _stage.get('requestId'),
- isSuccess: _stage.get('isSuccess'),
- isError: _stage.get('isError'),
- url: _stage.get('url'),
- polledData: _stage.get('polledData'),
- data: _stage.get('data')
- };
- stages.pushObject(stage);
- }, this);
- App.db.setSecurityDeployStages(stages);
- if (!App.testMode) {
- App.clusterStatus.setClusterStatus({
- clusterName: this.get('clusterName'),
- clusterState: 'DISABLE_SECURITY',
- wizardControllerName: this.get('name'),
- localdb: App.db.data
- });
- }
- }
}
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/3408cfec/ambari-web/app/controllers/main/admin/security/security_progress_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/security/security_progress_controller.js b/ambari-web/app/controllers/main/admin/security/security_progress_controller.js
new file mode 100644
index 0000000..1e2e864
--- /dev/null
+++ b/ambari-web/app/controllers/main/admin/security/security_progress_controller.js
@@ -0,0 +1,346 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+App.MainAdminSecurityProgressController = Em.Controller.extend({
+
+ name: 'mainAdminSecurityProgressController',
+ secureMapping: function () {
+ if (App.get('isHadoop2Stack')) {
+ return require('data/HDP2/secure_mapping');
+ } else {
+ return require('data/secure_mapping');
+ }
+ }.property(App.isHadoop2Stack),
+ secureProperties: function () {
+ if (App.get('isHadoop2Stack')) {
+ return require('data/HDP2/secure_properties').configProperties;
+ } else {
+ return require('data/secure_properties').configProperties;
+ }
+ }.property(App.isHadoop2Stack),
+ stages: [],
+ configs: [],
+ serviceConfigTags: [],
+ globalProperties: [],
+ totalSteps: 3,
+
+ isSubmitDisabled: true,
+
+
+ hasHostPopup: true,
+ services: [],
+ serviceTimestamp: null,
+
+
+ retry: function () {
+ var failedStage = this.get('stages').findProperty('isError', true);
+ if (failedStage) {
+ failedStage.set('isStarted', false);
+ failedStage.set('isError', false);
+ this.startStage(failedStage);
+ }
+ },
+
+ updateServices: function () {
+ this.services.clear();
+ var services = this.get("services");
+ this.get("stages").forEach(function (stage) {
+ var newService = Ember.Object.create({
+ name: stage.label,
+ hosts: []
+ });
+ if (stage && stage.get("polledData")) {
+ var hostNames = stage.get("polledData").mapProperty('Tasks.host_name').uniq();
+ hostNames.forEach(function (name) {
+ newService.hosts.push({
+ name: name,
+ publicName: name,
+ logTasks: stage.polledData.filterProperty("Tasks.host_name", name)
+ });
+ });
+ services.push(newService);
+ }
+ });
+ this.set('serviceTimestamp', new Date().getTime());
+ }.observes('stages.@each.polledData'),
+
+ loadStages: function () {
+ this.get('stages').pushObjects([
+ App.Poll.create({stage: 'stage2', label: Em.I18n.translations['admin.addSecurity.apply.stage2'], isPolling: true, name: 'STOP_SERVICES'}),
+ App.Poll.create({stage: 'stage3', label: Em.I18n.translations['admin.addSecurity.apply.stage3'], isPolling: false, name: 'APPLY_CONFIGURATIONS'}),
+ App.Poll.create({stage: 'stage4', label: Em.I18n.translations['admin.addSecurity.apply.stage4'], isPolling: true, name: 'START_SERVICES'})
+ ]);
+ },
+
+ startStage: function (currentStage) {
+ if (this.get('stages').length === this.totalSteps) {
+ if (!currentStage) {
+ var startedStages = this.get('stages').filterProperty('isStarted', true);
+ currentStage = startedStages.findProperty('isCompleted', false);
+ }
+ if (currentStage && currentStage.get('isPolling') === true) {
+ currentStage.set('isStarted', true);
+ currentStage.start();
+ } else if (currentStage && currentStage.get('stage') === 'stage3') {
+ currentStage.set('isStarted', true);
+ if (App.testMode) {
+ currentStage.set('isError', false);
+ currentStage.set('isSuccess', true);
+ } else {
+ this.loadClusterConfigs();
+ }
+ }
+ }
+ },
+
+ onCompleteStage: function () {
+ if (this.get('stages').length === this.totalSteps) {
+ var index = this.get('stages').filterProperty('isSuccess', true).length;
+ if (index > 0) {
+ var lastCompletedStageResult = this.get('stages').objectAt(index - 1).get('isSuccess');
+ if (lastCompletedStageResult) {
+ var nextStage = this.get('stages').objectAt(index);
+ this.moveToNextStage(nextStage);
+ }
+ }
+ }
+ },
+
+ moveToNextStage: function (nextStage) {
+ if (!nextStage) {
+ nextStage = this.get('stages').findProperty('isStarted', false);
+ }
+ if (nextStage) {
+ this.startStage(nextStage);
+ }
+ },
+
+ addInfoToStages: function () {
+ this.addInfoToStage2();
+ this.addInfoToStage4();
+ },
+
+
+ addInfoToStage2: function () {
+ var stage2 = this.get('stages').findProperty('stage', 'stage2');
+ var url = (App.testMode) ? '/data/wizard/deploy/2_hosts/poll_1.json' : App.apiPrefix + '/clusters/' + App.router.getClusterName() + '/services';
+ var data = '{"RequestInfo": {"context" :"' + Em.I18n.t('requestInfo.stopAllServices') + '"}, "Body": {"ServiceInfo": {"state": "INSTALLED"}}}';
+ stage2.set('url', url);
+ stage2.set('data', data);
+ },
+
+ addInfoToStage4: function () {
+ var stage4 = this.get('stages').findProperty('stage', 'stage4');
+ var url = (App.testMode) ? '/data/wizard/deploy/2_hosts/poll_1.json' : App.apiPrefix + '/clusters/' + App.router.getClusterName() + '/services?params/run_smoke_test=true';
+ var data = '{"RequestInfo": {"context": "' + Em.I18n.t('requestInfo.startAllServices') + '"}, "Body": {"ServiceInfo": {"state": "STARTED"}}}';
+ stage4.set('url', url);
+ stage4.set('data', data);
+ },
+
+ loadClusterConfigs: function () {
+ App.ajax.send({
+ name: 'admin.security.add.cluster_configs',
+ sender: this,
+ success: 'loadClusterConfigsSuccessCallback',
+ error: 'loadClusterConfigsErrorCallback'
+ });
+ },
+
+ loadClusterConfigsSuccessCallback: function (data) {
+ var self = this;
+ //prepare tags to fetch all configuration for a service
+ this.get('secureServices').forEach(function (_secureService) {
+ self.setServiceTagNames(_secureService, data.Clusters.desired_configs);
+ },this);
+ this.getAllConfigurations();
+ },
+
+ loadClusterConfigsErrorCallback: function (request, ajaxOptions, error) {
+ var stage3 = this.get('stages').findProperty('stage', 'stage3');
+ if (stage3) {
+ stage3.set('isSuccess', false);
+ stage3.set('isError', true);
+ }
+ console.log("TRACE: error code status is: " + request.status);
+ },
+
+ /**
+ * set tagnames for configuration of the *-site.xml
+ */
+ setServiceTagNames: function (secureService, configs) {
+ //var serviceConfigTags = this.get('serviceConfigTags');
+ for (var index in configs) {
+ if (secureService.sites && secureService.sites.contains(index)) {
+ var serviceConfigObj = {
+ siteName: index,
+ tagName: configs[index].tag,
+ newTagName: null,
+ configs: {}
+ };
+ this.get('serviceConfigTags').pushObject(serviceConfigObj);
+ }
+ }
+ return serviceConfigObj;
+ },
+
+ applyConfigurationsToCluster: function () {
+ var configData = [];
+ this.get('serviceConfigTags').forEach(function (_serviceConfig) {
+ var Clusters = {
+ Clusters: {
+ desired_config: {
+ type: _serviceConfig.siteName,
+ tag: _serviceConfig.newTagName,
+ properties: _serviceConfig.configs
+ }
+ }
+ };
+ configData.pushObject(JSON.stringify(Clusters));
+ }, this);
+
+ var data = {
+ configData: '[' + configData.toString() + ']'
+ };
+
+ App.ajax.send({
+ name: 'admin.security.apply_configurations',
+ sender: this,
+ data: data,
+ success: 'applyConfigurationToClusterSuccessCallback',
+ error: 'applyConfigurationToClusterErrorCallback'
+ });
+ },
+
+ applyConfigurationToClusterSuccessCallback: function (data) {
+ var currentStage = this.get('stages').findProperty('stage', 'stage3');
+ currentStage.set('isSuccess', true);
+ currentStage.set('isError', false);
+ },
+
+ applyConfigurationToClusterErrorCallback: function (request, ajaxOptions, error) {
+ var stage3 = this.get('stages').findProperty('stage', 'stage3');
+ if (stage3) {
+ stage3.set('isSuccess', false);
+ stage3.set('isError', true);
+ }
+ },
+
+ /**
+ * gets site config properties from server and sets it for every configuration
+ * @param serviceConfigTags
+ */
+
+ getAllConfigurations: function () {
+ var urlParams = [];
+ this.get('serviceConfigTags').forEach(function (_tag) {
+ urlParams.push('(type=' + _tag.siteName + '&tag=' + _tag.tagName + ')');
+ }, this);
+ if (urlParams.length > 0) {
+ App.ajax.send({
+ name: 'admin.get.all_configurations',
+ sender: this,
+ data: {
+ urlParams: urlParams.join('|')
+ },
+ success: 'getAllConfigurationsSuccessCallback',
+ error: 'getAllConfigurationsErrorCallback'
+ });
+ }
+ },
+
+ getAllConfigurationsSuccessCallback: function (data) {
+ console.log("TRACE: In success function for the GET getServiceConfigsFromServer call");
+ var stage3 = this.get('stages').findProperty('stage', 'stage3');
+ this.get('serviceConfigTags').forEach(function (_tag) {
+ if (!data.items.someProperty('type', _tag.siteName)) {
+ console.log("Error: Metadata for secure services (secure_configs.js) is having config tags that are not being retrieved from server");
+ if (stage3) {
+ stage3.set('isSuccess', false);
+ stage3.set('isError', true);
+ }
+ }
+ _tag.configs = data.items.findProperty('type', _tag.siteName).properties;
+ }, this);
+ if (this.manageSecureConfigs()) {
+ this.escapeXMLCharacters(this.get('serviceConfigTags'));
+ this.applyConfigurationsToCluster();
+ }
+ },
+
+ getAllConfigurationsErrorCallback: function (request, ajaxOptions, error) {
+ var stage3 = this.get('stages').findProperty('stage', 'stage3');
+ if (stage3) {
+ stage3.set('isSuccess', false);
+ stage3.set('isError', true);
+ }
+ console.log("TRACE: In error function for the getServiceConfigsFromServer call");
+ console.log("TRACE: error code status is: " + request.status);
+ },
+
+ /*
+ Iterate over keys of all configurations and escape xml characters in their values
+ */
+ escapeXMLCharacters: function (serviceConfigTags) {
+ serviceConfigTags.forEach(function (_serviceConfigTags) {
+ var configs = _serviceConfigTags.configs;
+ for (var key in configs) {
+ configs[key] = App.config.escapeXMLCharacters(configs[key]);
+ }
+ }, this);
+ },
+
+ saveStagesOnRequestId: function () {
+ this.saveStages();
+ }.observes('stages.@each.requestId'),
+
+ saveStagesOnCompleted: function () {
+ this.saveStages();
+ }.observes('stages.@each.isCompleted'),
+
+ saveStages: function () {
+ var stages = [];
+ if (this.get('stages').length === this.totalSteps) {
+ this.get('stages').forEach(function (_stage) {
+ var stage = {
+ name: _stage.get('name'),
+ stage: _stage.get('stage'),
+ label: _stage.get('label'),
+ isPolling: _stage.get('isPolling'),
+ isStarted: _stage.get('isStarted'),
+ requestId: _stage.get('requestId'),
+ isSuccess: _stage.get('isSuccess'),
+ isError: _stage.get('isError'),
+ url: _stage.get('url'),
+ polledData: _stage.get('polledData'),
+ data: _stage.get('data')
+ };
+ stages.pushObject(stage);
+ }, this);
+ App.db.setSecurityDeployStages(stages);
+ if (!App.testMode) {
+ App.clusterStatus.setClusterStatus({
+ clusterName: this.get('clusterName'),
+ clusterState: 'ADD_SECURITY_STEP_4',
+ wizardControllerName: App.router.get('addSecurityController.name'),
+ localdb: App.db.data
+ });
+ }
+ }
+ }
+});
http://git-wip-us.apache.org/repos/asf/ambari/blob/3408cfec/ambari-web/app/utils/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax.js b/ambari-web/app/utils/ajax.js
index 320b25f..4f299f2 100644
--- a/ambari-web/app/utils/ajax.js
+++ b/ambari-web/app/utils/ajax.js
@@ -872,7 +872,7 @@ var urls = {
'mock': '',
'type': 'DELETE'
},
- 'admin.security.all_configurations': {
+ 'admin.get.all_configurations': {
'real': '/clusters/{clusterName}/configurations?{urlParams}',
'mock': '',
'format': function (data, opt) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/3408cfec/ambari-web/app/views/wizard/controls_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/wizard/controls_view.js b/ambari-web/app/views/wizard/controls_view.js
index 4e9d9fa..9651c04 100644
--- a/ambari-web/app/views/wizard/controls_view.js
+++ b/ambari-web/app/views/wizard/controls_view.js
@@ -85,7 +85,7 @@ App.ServiceConfigTextField = Ember.TextField.extend(App.ServiceConfigPopoverSupp
} else {
return ['span9'];
}
- }.property('serviceConfig.displayType', 'serviceConfig.unit'),
+ }.property('serviceConfig.displayType', 'serviceConfig.unit')
});