You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ab...@apache.org on 2015/06/18 15:48:34 UTC
[4/4] ambari git commit: AMBARI-11995 Remove add security wizard from
Ambari. (ababiichuk)
AMBARI-11995 Remove add security wizard from Ambari. (ababiichuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/c61933d8
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/c61933d8
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/c61933d8
Branch: refs/heads/trunk
Commit: c61933d870b94f85aa41f91fa6728019ed74211f
Parents: 59a74cf
Author: aBabiichuk <ab...@cybervisiontech.com>
Authored: Thu Jun 18 16:43:46 2015 +0300
Committer: aBabiichuk <ab...@cybervisiontech.com>
Committed: Thu Jun 18 16:44:06 2015 +0300
----------------------------------------------------------------------
ambari-web/app/assets/test/tests.js | 8 -
ambari-web/app/controllers.js | 8 -
.../app/controllers/main/admin/kerberos.js | 2 +-
.../main/admin/kerberos/disable_controller.js | 1 -
.../app/controllers/main/admin/security.js | 387 ------
.../security/add/addSecurity_controller.js | 163 ---
.../main/admin/security/add/step1.js | 32 -
.../main/admin/security/add/step2.js | 449 -------
.../main/admin/security/add/step3.js | 448 -------
.../main/admin/security/add/step4.js | 203 ---
.../controllers/main/admin/security/disable.js | 212 ---
.../security/security_progress_controller.js | 465 -------
ambari-web/app/controllers/main/host/details.js | 9 -
.../app/controllers/wizard/step7_controller.js | 8 -
ambari-web/app/data/HDP2/secure_configs.js | 162 ---
ambari-web/app/data/HDP2/secure_properties.js | 1268 ------------------
ambari-web/app/data/controller_route.js | 8 -
ambari-web/app/messages.js | 28 +-
.../app/mixins/wizard/addSecurityConfigs.js | 324 -----
ambari-web/app/routes/add_security.js | 242 ----
ambari-web/app/routes/main.js | 39 +-
.../kerberos/notify_security_off_popup.hbs | 21 +
.../app/templates/main/admin/security.hbs | 43 -
.../templates/main/admin/security/add/menu.hbs | 42 -
.../templates/main/admin/security/add/step1.hbs | 38 -
.../templates/main/admin/security/add/step2.hbs | 34 -
.../templates/main/admin/security/add/step3.hbs | 31 -
.../templates/main/admin/security/add/step4.hbs | 32 -
.../templates/main/admin/security/disable.hbs | 26 -
.../security/notify_security_off_popup.hbs | 21 -
ambari-web/app/utils/host_progress_popup.js | 11 -
ambari-web/app/views.js | 8 -
.../configs/service_configs_by_category_view.js | 2 +-
ambari-web/app/views/main/admin/security.js | 53 -
.../app/views/main/admin/security/add/menu.js | 27 -
.../app/views/main/admin/security/add/step1.js | 33 -
.../app/views/main/admin/security/add/step2.js | 50 -
.../app/views/main/admin/security/add/step3.js | 28 -
.../app/views/main/admin/security/add/step4.js | 50 -
.../app/views/main/admin/security/disable.js | 44 -
.../security/add/addSecurity_controller_test.js | 256 ----
.../main/admin/security/add/step1_test.js | 72 -
.../main/admin/security/add/step2_test.js | 718 ----------
.../main/admin/security/add/step3_test.js | 560 --------
.../main/admin/security/add/step4_test.js | 484 -------
.../main/admin/security/disable_test.js | 386 ------
.../security_progress_controller_test.js | 443 ------
.../controllers/main/admin/security_test.js | 235 ----
.../test/controllers/main/host/details_test.js | 16 +-
.../test/controllers/wizard/step8_test.js | 1 -
.../mixins/wizard/addSeccurityConfigs_test.js | 326 +----
51 files changed, 32 insertions(+), 8525 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/c61933d8/ambari-web/app/assets/test/tests.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js
index f832a48..a0be22e 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -63,14 +63,6 @@ var files = ['test/init_model_test',
'test/controllers/main/admin/highAvailability/nameNode/step3_controller_test',
'test/controllers/main/admin/highAvailability/nameNode/step4_controller_test',
'test/controllers/main/admin/highAvailability/resourceManager/step3_controller_test',
- 'test/controllers/main/admin/security_test',
- 'test/controllers/main/admin/security/disable_test',
- 'test/controllers/main/admin/security/security_progress_controller_test',
- 'test/controllers/main/admin/security/add/addSecurity_controller_test',
- 'test/controllers/main/admin/security/add/step1_test',
- 'test/controllers/main/admin/security/add/step2_test',
- 'test/controllers/main/admin/security/add/step3_test',
- 'test/controllers/main/admin/security/add/step4_test',
'test/controllers/main/dashboard/config_history_controller_test',
'test/controllers/main/charts/heatmap_test',
'test/controllers/main/charts/heatmap_metrics/heatmap_metric_test',
http://git-wip-us.apache.org/repos/asf/ambari/blob/c61933d8/ambari-web/app/controllers.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers.js b/ambari-web/app/controllers.js
index 652142d..7748790 100644
--- a/ambari-web/app/controllers.js
+++ b/ambari-web/app/controllers.js
@@ -72,14 +72,6 @@ require('controllers/main/admin/kerberos/step5_controller');
require('controllers/main/admin/kerberos/step6_controller');
require('controllers/main/admin/kerberos/step7_controller');
require('controllers/main/admin/kerberos/step8_controller');
-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');
-require('controllers/main/admin/security/add/step2');
-require('controllers/main/admin/security/add/step3');
-require('controllers/main/admin/security/add/step4');
require('controllers/main/admin/authentication');
require('controllers/main/alert_definitions_controller');
require('controllers/main/alerts/alert_definitions_actions_controller');
http://git-wip-us.apache.org/repos/asf/ambari/blob/c61933d8/ambari-web/app/controllers/main/admin/kerberos.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/kerberos.js b/ambari-web/app/controllers/main/admin/kerberos.js
index 2bc7cfd..7e7fff8 100644
--- a/ambari-web/app/controllers/main/admin/kerberos.js
+++ b/ambari-web/app/controllers/main/admin/kerberos.js
@@ -63,7 +63,7 @@ App.MainAdminKerberosController = App.KerberosWizardStep4Controller.extend({
this.hide();
},
bodyClass: Ember.View.extend({
- templateName: require('templates/main/admin/security/notify_security_off_popup')
+ templateName: require('templates/main/admin/kerberos/notify_security_off_popup')
})
});
},
http://git-wip-us.apache.org/repos/asf/ambari/blob/c61933d8/ambari-web/app/controllers/main/admin/kerberos/disable_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/kerberos/disable_controller.js b/ambari-web/app/controllers/main/admin/kerberos/disable_controller.js
index 84e7007..cec4503 100644
--- a/ambari-web/app/controllers/main/admin/kerberos/disable_controller.js
+++ b/ambari-web/app/controllers/main/admin/kerberos/disable_controller.js
@@ -18,7 +18,6 @@
var App = require('app');
require('controllers/main/admin/kerberos/progress_controller');
-require('controllers/main/admin/security/security_progress_controller');
App.KerberosDisableController = App.KerberosProgressPageController.extend(App.WizardEnableDone, {
http://git-wip-us.apache.org/repos/asf/ambari/blob/c61933d8/ambari-web/app/controllers/main/admin/security.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/security.js b/ambari-web/app/controllers/main/admin/security.js
deleted file mode 100644
index 54c257f..0000000
--- a/ambari-web/app/controllers/main/admin/security.js
+++ /dev/null
@@ -1,387 +0,0 @@
-/**
- * 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.MainAdminSecurityController = Em.Controller.extend({
- name: 'mainAdminSecurityController',
- isSubmitDisabled: false,
- securityEnabled: false,
- dataIsLoaded: false,
- isRecommendedLoaded: true,
- serviceUsers: [],
- tag: {},
- getAddSecurityWizardStatus: function () {
- return App.db.getSecurityWizardStatus();
- },
- setAddSecurityWizardStatus: function (status) {
- App.db.setSecurityWizardStatus(status);
- },
-
- setDisableSecurityStatus: function (status) {
- App.db.setDisableSecurityStatus(status);
- },
- getDisableSecurityStatus: function (status) {
- return App.db.getDisableSecurityStatus();
- },
- content: Em.Object.create({
- isATSInstalled: function() {
- // Because the ATS component can be installed/removed at will, the check has to happen every time that security is added.
- var yarnService = App.Service.find().findProperty('serviceName','YARN');
- return !!yarnService && yarnService.get('hostComponents').someProperty('componentName', 'APP_TIMELINE_SERVER');
- }.property('App.router.clusterController.isLoaded')
- }),
- notifySecurityOff: false,
- notifySecurityAdd: false,
-
- stepConfigs: [],
- desiredConfigs: [],
- securityUsers: [],
- serviceConfigTags: [],
- selectedService: null,
- isNotEditable: true,
- /** need to define <code>filter, filterColumns</code> properties
- * for preventing errors in <code>App.ServiceConfigsByCategoryView</code>
- */
- filter: '',
- filterColumns: function () {
- return [];
- }.property(''),
- services: function () {
- var secureServices = $.extend(true, [], require('data/HDP2/secure_configs'));
- var services = [];
-
- // Typically, ATS will support Kerberos in HDP 2.2 and higher
- if (this.get('content.isATSInstalled') && App.get('doesATSSupportKerberos')) {
- var yarnConfigCategories = secureServices.findProperty('serviceName', 'YARN').configCategories;
- yarnConfigCategories.push(App.ServiceConfigCategory.create({ name: 'AppTimelineServer', displayName : 'Application Timeline Service'}));
- }
-
- var installedServices = App.Service.find().mapProperty('serviceName');
- //General (only non service tab) tab is always displayed
- services.push(secureServices.findProperty('serviceName', 'GENERAL'));
- installedServices.forEach(function (_service) {
- var secureService = secureServices.findProperty('serviceName', _service);
- if (secureService) {
- services.push(secureService);
- }
- }, this);
- return services;
- }.property('App.router.clusterController.isLoaded'),
-
- /**
- * default values of configs, which contains user names
- */
- userNameMap: {
- 'hdfs_user': {defaultValue: 'hdfs', siteName: 'hadoop-env', serviceName: 'HDFS'},
- 'yarn_user': {defaultValue: 'yarn', siteName: 'yarn-env', serviceName: 'YARN'},
- 'mapred_user': {defaultValue: 'mapred', siteName: 'mapred-env', serviceName: 'MAPREDUCE2'},
- 'hbase_user': {defaultValue: 'hbase', siteName: 'hbase-env', serviceName: 'HBASE'},
- 'hive_user': {defaultValue: 'hive', siteName: 'hive-env', serviceName: 'HIVE'},
- 'proxyuser_group': {defaultValue: 'users', siteName: 'hadoop-env', serviceName: 'HDFS'},
- 'smokeuser': {defaultValue: 'ambari-qa', siteName: 'cluster-env', serviceName: 'CLUSTER'},
- 'zk_user': {defaultValue: 'zookeeper', siteName: 'zookeeper-env', serviceName: 'ZOOKEEPER'},
- 'oozie_user': {defaultValue: 'oozie', siteName: 'oozie-env', serviceName: 'OOZIE'},
- 'user_group': {defaultValue: 'hadoop', siteName: 'hadoop-env', serviceName: 'HDFS'},
- 'storm_user': {defaultValue: 'storm', siteName: 'storm-env', serviceName: 'STORM'},
- 'falcon_user': {defaultValue: 'falcon', siteName: 'falcon-env', serviceName: 'FALCON'},
- 'knox_user': {defaultValue: 'knox', siteName: 'knox-env', serviceName: 'KNOX'}
- },
-
- loadStep: function () {
- var step2Controller = App.router.get('mainAdminSecurityAddStep2Controller');
- var services = this.get('services');
- var self = this;
- step2Controller.set('content', Em.Object.create({services: []}));
- step2Controller.set('content.services', services);
- this.get('stepConfigs').clear();
- this.get('securityUsers').clear();
- this.get('serviceConfigTags').clear();
- this.loadSecurityUsers();
- //loadSecurityUsers - desired configs fetched from server
- step2Controller.addUserPrincipals(services, this.get('securityUsers'));
- step2Controller.addMasterHostToConfigs();
- step2Controller.addSlaveHostToConfigs();
- this.renderServiceConfigs(services);
- step2Controller.changeCategoryOnHa(services, this.get('stepConfigs'));
-
- services.forEach(function (_secureService) {
- this.setServiceTagNames(_secureService, this.get('desiredConfigs'));
- }, this);
- App.router.get('configurationController').getConfigsByTags(this.get('serviceConfigTags')).done(function (serverConfigs) {
- self.setConfigValuesFromServer(self.get('stepConfigs'), serverConfigs);
- self.set('installedServices', App.Service.find().mapProperty('serviceName'));
- });
- },
-
- /**
- * get actual values of configurations from server
- * @param stepConfigs
- * @param serverConfigs
- */
- setConfigValuesFromServer: function (stepConfigs, serverConfigs) {
- var allConfigs = {};
- serverConfigs.mapProperty('properties').forEach(function (_properties) {
- allConfigs = $.extend(allConfigs, _properties);
- }, this);
- // for all services`
- stepConfigs.forEach(function (_content) {
- //for all components
- _content.get('configs').forEach(function (_config) {
-
- var componentVal = allConfigs[_config.get('name')];
- //if we have config for specified component
- if (componentVal) {
- //set it
- _config.set('value', componentVal);
- }
- }, this);
- }, this);
- },
-
- /**
- * set tag names according to installed services and desired configs
- * @param secureService
- * @param configs
- * @return {Object}
- */
- 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: {}
- };
- this.get('serviceConfigTags').pushObject(serviceConfigObj);
- }
- }
- return serviceConfigObj;
- },
-
- loadSecurityUsers: function () {
- var securityUsers = this.get('serviceUsers');
- if (!securityUsers || securityUsers.length < 1) { // Page could be refreshed in middle
- if (App.get('testMode')) {
- securityUsers.pushObject({id: 'puppet var', name: 'hdfs_user', value: 'hdfs'});
- securityUsers.pushObject({id: 'puppet var', name: 'mapred_user', value: 'mapred'});
- securityUsers.pushObject({id: 'puppet var', name: 'hbase_user', value: 'hbase'});
- securityUsers.pushObject({id: 'puppet var', name: 'hive_user', value: 'hive'});
- securityUsers.pushObject({id: 'puppet var', name: 'smokeuser', value: 'ambari-qa'});
- } else {
- this.setSecurityStatus();
- securityUsers = this.get('serviceUsers');
- }
- }
- this.set('securityUsers', securityUsers);
- },
- /**
- * Load child components to service config object
- * @param _componentConfig
- * @param componentConfig
- */
- loadComponentConfigs: function (_componentConfig, componentConfig) {
- _componentConfig.configs.forEach(function (_serviceConfigProperty) {
- var serviceConfigProperty = App.ServiceConfigProperty.create(_serviceConfigProperty);
- componentConfig.configs.pushObject(serviceConfigProperty);
- serviceConfigProperty.set('isEditable', serviceConfigProperty.get('isReconfigurable'));
- serviceConfigProperty.validate();
- }, this);
- },
-
- /**
- * Render configs for active services
- * @param serviceConfigs
- */
- renderServiceConfigs: function (serviceConfigs) {
- serviceConfigs.forEach(function (_serviceConfig) {
-
- var serviceConfig = App.ServiceConfig.create({
- filename: _serviceConfig.filename,
- serviceName: _serviceConfig.serviceName,
- displayName: _serviceConfig.displayName,
- configCategories: _serviceConfig.configCategories,
- showConfig: true,
- configs: []
- });
-
- this.loadComponentConfigs(_serviceConfig, serviceConfig);
-
- console.log('pushing ' + serviceConfig.serviceName, serviceConfig);
-
- this.get('stepConfigs').pushObject(serviceConfig);
- }, this);
- this.set('selectedService', this.get('stepConfigs').filterProperty('showConfig', true).objectAt(0));
- },
-
- notifySecurityOffPopup: function () {
- var self = this;
- if (!this.get('isSubmitDisabled')) {
- App.ModalPopup.show({
- header: Em.I18n.t('popup.confirmation.commonHeader'),
- primary: Em.I18n.t('ok'),
- onPrimary: function () {
- App.db.setSecurityDeployCommands(undefined);
- self.setDisableSecurityStatus("RUNNING");
- App.router.transitionTo('disableSecurity');
- this.hide();
- },
- bodyClass: Ember.View.extend({
- templateName: require('templates/main/admin/security/notify_security_off_popup')
- })
- })
- }
- },
-
- getUpdatedSecurityStatus: function () {
- this.setSecurityStatus();
- return this.get('securityEnabled');
- },
-
- setSecurityStatus: function () {
- if (App.get('testMode')) {
- this.set('securityEnabled', !App.get('testEnableSecurity'));
- this.set('dataIsLoaded', true);
- } else {
- //get Security Status From Server
- App.ajax.send({
- name: 'admin.security_status',
- sender: this,
- success: 'getSecurityStatusFromServerSuccessCallback',
- error: 'errorCallback'
- });
- }
- },
-
- errorCallback: function (jqXHR) {
- this.set('dataIsLoaded', true);
- // Show the error popup if the API call received a response from the server.
- // jqXHR.status will be empty when browser cancels the request. Refer to AMBARI-5921 for more info
- if (!!jqXHR.status) {
- this.showSecurityErrorPopup();
- }
- },
-
- getSecurityStatusFromServerSuccessCallback: function (data) {
- var configs = data.Clusters.desired_configs;
- var serviceNames = this.get('services').mapProperty('serviceName');
- var configTags = [];
- this.set('desiredConfigs', configs);
- for (var key in this.userNameMap) {
- if (serviceNames.contains(this.userNameMap[key]['serviceName']) || this.userNameMap[key]['serviceName'] === 'CLUSTER')
- configTags.push(this.userNameMap[key]['siteName']);
- }
- configTags = configTags.uniq();
-
- var errorFlag = false;
- configTags.forEach(function (_tag) {
- if (!configs[_tag]) {
- errorFlag = true;
- }
- }, this);
-
- if (errorFlag) {
- this.showSecurityErrorPopup();
- } else {
- var tags = configTags.map(function (_tag) {
- this.set('tag.' + _tag, configs[_tag].tag);
- return {
- siteName: _tag,
- tagName: configs[_tag].tag
- }
- }, this);
-
- if ('hdfs-site' in configs) {
- this.set('tag.hdfs-site', configs['hdfs-site'].tag);
- tags.pushObject({
- siteName: "hdfs-site",
- tagName: this.get('tag.hdfs-site')
- });
- }
- this.getServiceConfigsFromServer(tags);
- }
- },
-
- getServiceConfigsFromServer: function (tags) {
- var self = this;
-
- App.router.get('configurationController').getConfigsByTags(tags).done(function (data) {
- var configs = data.findProperty('tag', self.get('tag.cluster-env')).properties;
- if (configs && (configs['security_enabled'] === 'true' || configs['security_enabled'] === true)) {
- self.set('securityEnabled', true);
- }
- else {
- self.set('securityEnabled', false);
- if (!!self.get('tag.hdfs-site')) {
- var hdfsConfigs = data.findProperty('tag', self.get('tag.hdfs-site')).properties;
- self.setNnHaStatus(hdfsConfigs);
- }
- }
- var userConfigs = {};
- data.forEach(function(_config){
- $.extend(userConfigs, _config.properties);
- });
- self.loadUsers(userConfigs);
- self.set('dataIsLoaded', true);
- });
- },
-
- setNnHaStatus: function (hdfsConfigs) {
- var nnHaStatus = hdfsConfigs && hdfsConfigs['dfs.nameservices'];
- var namenodesKey;
- if (nnHaStatus) {
- namenodesKey = 'dfs.ha.namenodes.' + hdfsConfigs['dfs.nameservices'];
- }
- if (nnHaStatus && hdfsConfigs[namenodesKey]) {
- App.db.setIsNameNodeHa('true');
- } else {
- App.db.setIsNameNodeHa('false');
- }
- },
-
- /**
- * load users names,
- * substitute missing values with default
- * @param configs {Object}
- */
- loadUsers: function (configs) {
- var defaultUserNameMap = this.get('userNameMap');
- this.set('serviceUsers',[]);
-
- for (var configName in defaultUserNameMap) {
- this.get('serviceUsers').push({
- id: 'puppet var',
- name: configName,
- value: configs[configName] || defaultUserNameMap[configName]['defaultValue']
- });
- }
- App.db.setSecureUserInfo(this.get('serviceUsers'));
- },
-
- showSecurityErrorPopup: function () {
- App.ModalPopup.show({
- header: Em.I18n.t('common.error'),
- secondary: false,
- bodyClass: Ember.View.extend({
- template: Ember.Handlebars.compile('<p>{{t admin.security.status.error}}</p>')
- })
- });
- }
-});
-
-
http://git-wip-us.apache.org/repos/asf/ambari/blob/c61933d8/ambari-web/app/controllers/main/admin/security/add/addSecurity_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/security/add/addSecurity_controller.js b/ambari-web/app/controllers/main/admin/security/add/addSecurity_controller.js
deleted file mode 100644
index cf5fb77..0000000
--- a/ambari-web/app/controllers/main/admin/security/add/addSecurity_controller.js
+++ /dev/null
@@ -1,163 +0,0 @@
-/**
- * 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.AddSecurityController = App.WizardController.extend({
-
- name: 'addSecurityController',
- securityEnabled: false,
-
- totalSteps: 4,
-
- content: Em.Object.create({
- services: [],
- isNnHa: 'false',
- serviceConfigProperties: null,
- controllerName: 'addSecurityController',
- isATSInstalled: function() {
- // Because the ATS component can be installed/removed at will, the check has to happen every time that security is added.
- var yarnService = App.Service.find().findProperty('serviceName','YARN');
- return !!yarnService && yarnService.get('hostComponents').someProperty('componentName', 'APP_TIMELINE_SERVER');
- }.property('App.router.clusterController.isLoaded')
- }),
-
- /**
- * installed services on cluster
- */
- installedServices: function () {
- return App.Service.find().mapProperty('serviceName');
- }.property(),
-
- /**
- * services with security configurations
- */
- secureServices: function () {
- var configCategories = require('data/HDP2/secure_configs');
- if (this.get('content.isATSInstalled') && App.get('doesATSSupportKerberos')) {
- var yarnConfigCategories = configCategories.findProperty('serviceName', 'YARN').configCategories;
- yarnConfigCategories.push(App.ServiceConfigCategory.create({ name: 'AppTimelineServer', displayName : 'Application Timeline Service'}));
- }
- return configCategories;
- }.property('App.router.clusterController.isLoaded'),
-
- /**
- * Loads all prior steps on refresh
- */
- loadAllPriorSteps: function () {
- var step = this.get('currentStep');
- switch (step) {
- case '4':
- case '3':
- case '2':
- this.loadServiceConfigs();
- case '1':
- this.loadServices();
- this.loadNnHaStatus();
- }
- },
- /**
- * Load installed services, which match secure services, to content
- */
- loadServices: function () {
- var secureServices = this.get('secureServices');
- var installedServices = this.get('installedServices');
-
- this.get('content.services').clear();
- //General (only non service tab) tab is always displayed
- this.get('content.services').push(secureServices.findProperty('serviceName', 'GENERAL'));
- installedServices.forEach(function (_service) {
- var secureService = secureServices.findProperty('serviceName', _service);
- if (secureService) {
- this.get('content.services').push(secureService);
- }
- }, this);
- },
- /**
- * identify whether NameNode in high availability mode
- */
- loadNnHaStatus: function () {
- this.set('content.isNnHa', App.db.getIsNameNodeHa());
- },
-
- /**
- * save service config properties to localStorage
- * @param stepController
- */
- saveServiceConfigProperties: function (stepController) {
- var serviceConfigProperties = [];
- stepController.get('stepConfigs').forEach(function (_content) {
- _content.get('configs').forEach(function (_configProperties) {
- _configProperties.set('value', App.config.trimProperty(_configProperties, true));
- var configProperty = {
- id: _configProperties.get('id'),
- name: _configProperties.get('name'),
- value: _configProperties.get('value'),
- defaultValue: _configProperties.get('defaultValue'),
- serviceName: _configProperties.get('serviceName'),
- domain: _configProperties.get('domain'),
- filename: _configProperties.get('filename'),
- unit: _configProperties.get('unit'),
- components: _configProperties.get('components'),
- component: _configProperties.get('component'),
- overrides: this.getConfigOverrides(_configProperties)
- };
- serviceConfigProperties.push(configProperty);
- }, this);
- }, this);
- App.db.setSecureConfigProperties(serviceConfigProperties);
- this.set('content.serviceConfigProperties', serviceConfigProperties);
- },
-
- /**
- * get overrides of config
- * @param _configProperties
- * @return {Array}
- */
- getConfigOverrides: function (_configProperties) {
- var overrides = _configProperties.get('overrides');
- var overridesArray = [];
- if (Array.isArray(overrides)) {
- overrides.forEach(function (override) {
- var overrideEntry = {
- value: override.get('value'),
- hosts: []
- };
- override.get('selectedHostOptions').forEach(function (host) {
- overrideEntry.hosts.push(host);
- });
- overridesArray.push(overrideEntry);
- });
- }
- return (overridesArray.length > 0) ? overridesArray : null;
- },
-
- /**
- * Load service config properties from localStorage
- */
- loadServiceConfigs: function () {
- this.set('content.serviceConfigProperties', App.db.getSecureConfigProperties());
- },
-
- /**
- * Clear all local storage data for Add security wizard namespace
- */
- finish: function () {
- this.resetDbNamespace();
- }
-});
-
http://git-wip-us.apache.org/repos/asf/ambari/blob/c61933d8/ambari-web/app/controllers/main/admin/security/add/step1.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/security/add/step1.js b/ambari-web/app/controllers/main/admin/security/add/step1.js
deleted file mode 100644
index 51494c7..0000000
--- a/ambari-web/app/controllers/main/admin/security/add/step1.js
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * 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.MainAdminSecurityAddStep1Controller = Em.Controller.extend({
-
- name: 'mainAdminSecurityAddStep1Controller',
- /**
- * identify whether ATS(Application Timeline Server) is installed and does not support Kerberization.
- * @return {Boolean}
- */
- shouldRemoveATS: function() {
- var isATSInstalled = this.get('content.isATSInstalled');
- var doesATSSupportKerberos = App.get("doesATSSupportKerberos");
- return isATSInstalled && !doesATSSupportKerberos;
- }
-});
http://git-wip-us.apache.org/repos/asf/ambari/blob/c61933d8/ambari-web/app/controllers/main/admin/security/add/step2.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/security/add/step2.js b/ambari-web/app/controllers/main/admin/security/add/step2.js
deleted file mode 100644
index e9e37ff..0000000
--- a/ambari-web/app/controllers/main/admin/security/add/step2.js
+++ /dev/null
@@ -1,449 +0,0 @@
-/**
- * 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');
-var stringUtils = require('utils/string_utils');
-
-App.MainAdminSecurityAddStep2Controller = Em.Controller.extend({
-
- name: 'mainAdminSecurityAddStep2Controller',
- isRecommendedLoaded: true,
- stepConfigs: [],
- installedServices: [],
- selectedService: null,
- securityUsers: [],
- filter: '',
- filterColumns: [],
-
- /**
- * map which depict connection between config and slave component
- * in order to set component hosts to config value
- */
- slaveComponentMap: [
- {
- serviceName: 'HDFS',
- configName: 'datanode_hosts',
- component: 'DATANODE'
- },
- {
- serviceName: 'YARN',
- configName: 'nodemanager_host',
- component: 'NODEMANAGER'
- },
- {
- serviceName: 'HBASE',
- configName: 'regionserver_hosts',
- component: 'HBASE_REGIONSERVER'
- },
- {
- serviceName: 'STORM',
- configName: 'supervisor_hosts',
- component: 'SUPERVISOR'
- }
- ],
- /**
- * map which depict connection between config and master component
- * in order to set component hosts to config value
- */
- masterComponentMap: [
- {
- serviceName: 'OOZIE',
- configName: 'oozie_servername',
- components: ['OOZIE_SERVER']
- },
- {
- serviceName: 'HIVE',
- configName: 'hive_metastore',
- components: ['HIVE_METASTORE', 'HIVE_SERVER']
- },
- {
- serviceName: 'HIVE',
- configName: 'webhcatserver_host',
- components: ['WEBHCAT_SERVER']
- },
- {
- serviceName: 'HDFS',
- configName: 'namenode_host',
- components: ['NAMENODE']
- },
- {
- serviceName: 'HDFS',
- configName: 'snamenode_host',
- components: ['SECONDARY_NAMENODE']
- },
- {
- serviceName: 'HDFS',
- configName: 'journalnode_hosts',
- components: ['JOURNALNODE']
- },
- {
- serviceName: 'MAPREDUCE2',
- configName: 'jobhistoryserver_host',
- components: ['HISTORYSERVER']
- },
- {
- serviceName: 'YARN',
- configName: 'resourcemanager_host',
- components: ['RESOURCEMANAGER']
- },
- {
- serviceName: 'YARN',
- configName: 'apptimelineserver_host',
- components: ['APP_TIMELINE_SERVER']
- },
- {
- serviceName: 'HBASE',
- configName: 'hbasemaster_host',
- components: ['HBASE_MASTER']
- },
- {
- serviceName: 'ZOOKEEPER',
- configName: 'zookeeperserver_hosts',
- components: ['ZOOKEEPER_SERVER']
- },
- {
- serviceName: 'FALCON',
- configName: 'falcon_server_host',
- components: ['FALCON_SERVER']
- },
- {
- serviceName: 'STORM',
- configName: 'storm_host',
- components: ['STORM_UI_SERVER', 'NIMBUS', 'SUPERVISOR']
- },
- {
- serviceName: 'STORM',
- configName: 'nimbus_host',
- components: ['NIMBUS']
- },
- {
- serviceName: 'KNOX',
- configName: 'knox_gateway_hosts',
- components: ['KNOX_GATEWAY']
- }
- ],
-
- hostToPrincipalMap: [
- {
- serviceName: 'OOZIE',
- configName: 'oozie_servername',
- principalName: 'oozie_principal_name',
- primaryName: 'oozie/'
- },
- {
- serviceName: 'OOZIE',
- configName: 'oozie_servername',
- principalName: 'oozie_http_principal_name',
- primaryName: 'HTTP/'
- },
- {
- serviceName: 'FALCON',
- configName: 'falcon_server_host',
- principalName: 'falcon_principal_name',
- primaryName: 'falcon/'
- },
- {
- serviceName: 'FALCON',
- configName: 'falcon_server_host',
- principalName: 'falcon_http_principal_name',
- primaryName: 'HTTP/'
- },
- {
- serviceName: 'HIVE',
- configName: 'webhcatserver_host',
- principalName: 'webHCat_http_principal_name',
- primaryName: 'HTTP/'
- }
- ],
-
- isSubmitDisabled: function () {
- return !this.get('stepConfigs').filterProperty('showConfig').everyProperty('errorCount', 0);
- }.property('stepConfigs.@each.errorCount'),
-
- /**
- * clear info of step
- */
- clearStep: function () {
- this.get('stepConfigs').clear();
- this.get('securityUsers').clear();
- },
-
- /**
- * Function is called whenever the step is loaded
- */
- loadStep: function () {
- console.log("TRACE: Loading addSecurity step2: Configure Services");
- var versionNumber = App.get('currentStackVersionNumber');
- if( stringUtils.compareVersions(versionNumber, "2.2") >= 0){
- // Add Nimbus config options
- var masterComponentMap = this.get('masterComponentMap');
- masterComponentMap.filterProperty('configName', 'storm_host').components = ["SUPERVISOR", "STORM_UI_SERVER", "DRPC_SERVER", "STORM_REST_API"];
- masterComponentMap.pushObject({
- serviceName: 'STORM',
- configName: 'nimbus_host',
- components: ['NIMBUS']
- });
- this.get('hostToPrincipalMap').pushObject({
- serviceName: 'STORM',
- configName: 'nimbus_host',
- principalName: 'storm_principal_name',
- primaryName: 'storm'
- });
- }
- this.clearStep();
- this.loadUsers();
- this.addUserPrincipals(this.get('content.services'), this.get('securityUsers'));
- this.addMasterHostToConfigs();
- this.addHostPrincipals();
- this.addSlaveHostToConfigs();
- this.renderServiceConfigs(this.get('content.services'));
- this.changeCategoryOnHa(this.get('content.services'), this.get('stepConfigs'));
- this.setStoredConfigsValue(this.get('content.serviceConfigProperties'));
- this.set('installedServices', App.Service.find().mapProperty('serviceName'));
- },
-
- /**
- * set stored values to service configs
- * @param storedConfigProperties
- * @return {Boolean}
- */
- setStoredConfigsValue: function (storedConfigProperties) {
- if (!storedConfigProperties) return false;
-
- // for all services`
- this.get('stepConfigs').forEach(function (_content) {
- _content.get('configs').forEach(function (_config) {
- var configProperty = storedConfigProperties.findProperty('name', _config.get('name'));
-
- if (configProperty) {
- _config.set('value', configProperty.value);
- }
- }, this);
- }, this);
- return true;
- },
-
- /**
- * Render configs for active services
- * @param serviceConfigs
- */
- renderServiceConfigs: function (serviceConfigs) {
- serviceConfigs.forEach(function (_serviceConfig) {
- var serviceConfig = App.ServiceConfig.create({
- filename: _serviceConfig.filename,
- serviceName: _serviceConfig.serviceName,
- displayName: _serviceConfig.displayName,
- configCategories: _serviceConfig.configCategories,
- showConfig: true,
- configs: this.wrapConfigProperties(_serviceConfig)
- });
-
- this.get('stepConfigs').pushObject(serviceConfig);
- }, this);
- this.set('selectedService', this.get('stepConfigs').filterProperty('showConfig').objectAt(0));
- },
-
- /**
- * wrap configs into App.ServiceConfigProperty objects
- * @param _componentConfig
- */
- wrapConfigProperties: function (_componentConfig) {
- var configs = [];
- _componentConfig.configs.forEach(function (_serviceConfigProperty) {
- var serviceConfigProperty = App.ServiceConfigProperty.create(_serviceConfigProperty);
- serviceConfigProperty.set('isEditable', serviceConfigProperty.get('isReconfigurable'));
- serviceConfigProperty.validate();
- configs.pushObject(serviceConfigProperty);
- }, this);
- return configs;
- },
-
- /**
- * fill config with hosts of component
- * @param serviceName
- * @param configName
- * @param componentNames
- * @return {Boolean}
- */
- setHostsToConfig: function (serviceName, configName, componentNames) {
- var service = this.get('content.services').findProperty('serviceName', serviceName);
- if (service) {
- var hosts = service.configs.findProperty('name', configName);
- if (hosts) {
- hosts.defaultValue = App.Service.find(service.serviceName)
- .get('hostComponents')
- .filter(function (component) {
- return componentNames.contains(component.get('componentName'));
- })
- .mapProperty('hostName')
- .uniq();
- return true;
- }
- return false;
- }
- return false;
- },
-
- /**
- * set principal default value based on config host and default primary name
- * @param serviceName
- * @param hostConfigName
- * @param principalConfigName
- * @param defaultPrimaryName
- * @return {Boolean}
- */
- setHostToPrincipal: function (serviceName, hostConfigName, principalConfigName, defaultPrimaryName) {
- var service = this.get('content.services').findProperty('serviceName', serviceName);
- if (service) {
- var host = service.configs.findProperty('name', hostConfigName);
- var principal = service.configs.findProperty('name', principalConfigName);
- var versionNumber = App.get('currentStackVersionNumber');
- var special22ConfigsMap = {
- storm_principal_name: defaultPrimaryName,
- oozie_http_principal_name: defaultPrimaryName + '_HOST'
- };
- if (stringUtils.compareVersions(versionNumber, "2.2") >= 0 && special22ConfigsMap[principalConfigName]) {
- principal.defaultValue = special22ConfigsMap[principalConfigName];
- return true;
- }
- if (host && principal) {
- var host_defaultValue = Array.isArray(host.defaultValue) ? host.defaultValue[0] : host.defaultValue;
- principal.defaultValue = defaultPrimaryName + host_defaultValue;
- return true;
- }
- return false;
- }
- return false;
- },
-
- /**
- * load services users
- */
- loadUsers: function () {
- var securityUsers = App.router.get('mainAdminSecurityController').get('serviceUsers');
- if (Em.isNone(securityUsers) || securityUsers.length === 0) {
- if (App.get('testMode')) {
- securityUsers = securityUsers || [];
- securityUsers.pushObject({id: 'puppet var', name: 'hdfs_user', value: 'hdfs'});
- securityUsers.pushObject({id: 'puppet var', name: 'mapred_user', value: 'mapred'});
- securityUsers.pushObject({id: 'puppet var', name: 'hbase_user', value: 'hbase'});
- securityUsers.pushObject({id: 'puppet var', name: 'hive_user', value: 'hive'});
- securityUsers.pushObject({id: 'puppet var', name: 'smokeuser', value: 'ambari-qa'});
- } else {
- securityUsers = App.db.getSecureUserInfo();
- }
- }
- this.set('securityUsers', securityUsers);
- },
-
- /**
- * set default values to user principals and control their visibility
- * @param serviceConfigs
- * @param securityUsers
- */
- addUserPrincipals: function (serviceConfigs, securityUsers) {
- var generalService = serviceConfigs.findProperty('serviceName', 'GENERAL').configs;
- this.setUserPrincipalValue(securityUsers.findProperty('name', 'smokeuser'), generalService.findProperty('name', 'smokeuser_principal_name'));
- var servicesWithUserPrincipals = ['HDFS', 'HBASE'];
-
- servicesWithUserPrincipals.forEach(function (serviceName) {
- var isServiceInstalled = serviceConfigs.someProperty('serviceName', serviceName);
- var userPrincipal = generalService.findProperty('name', serviceName.toLowerCase() + '_principal_name');
- var userKeytab = generalService.findProperty('name', serviceName.toLowerCase() + '_user_keytab');
- var userName = securityUsers.findProperty('name', serviceName.toLowerCase() + '_user');
- if (isServiceInstalled && this.setUserPrincipalValue(userName, userPrincipal)) {
- userPrincipal.isVisible = true;
- userKeytab.isVisible = true;
- }
- }, this);
- },
- /**
- * set default value of user principal
- * @param user
- * @param userPrincipal
- */
- setUserPrincipalValue: function (user, userPrincipal) {
- if (user && userPrincipal) {
- userPrincipal.defaultValue = user.value;
- return true;
- }
- return false;
- },
-
- /**
- * put hosts of slave component into defaultValue of configs
- */
- addSlaveHostToConfigs: function () {
- this.get('slaveComponentMap').forEach(function (service) {
- this.setHostsToConfig(service.serviceName, service.configName, [service.component]);
- }, this);
- },
-
- /**
- * put hosts of master component into defaultValue of configs
- */
- addMasterHostToConfigs: function () {
- this.get('masterComponentMap').forEach(function (item) {
- this.setHostsToConfig(item.serviceName, item.configName, item.components);
- }, this);
- },
-
- /**
- * put hosts to principal default values
- */
- addHostPrincipals: function () {
- this.get('hostToPrincipalMap').forEach(function (item) {
- this.setHostToPrincipal(item.serviceName, item.configName, item.principalName, item.primaryName);
- }, this);
- },
-
- /**
- * modify config categories depending on whether HA is enabled or not
- * @param serviceConfigs
- * @param stepConfigs
- */
- changeCategoryOnHa: function (serviceConfigs, stepConfigs) {
- var hdfsService = serviceConfigs.findProperty('serviceName', 'HDFS');
- if (hdfsService) {
- var properties = stepConfigs.findProperty('serviceName', 'HDFS').get('configs');
- var configCategories = hdfsService.configCategories;
- if ((App.get('testMode') && App.get('testNameNodeHA')) || (this.get('content.isNnHa') === 'true')) {
- this.removeConfigCategory(properties, configCategories, 'SNameNode');
- } else {
- this.removeConfigCategory(properties, configCategories, 'JournalNode');
- }
- return true;
- }
- return false;
- },
- /**
- * remove config category that belong to component and hide category configs
- * @param properties
- * @param configCategories
- * @param component
- */
- removeConfigCategory: function (properties, configCategories, component) {
- properties.filterProperty('category', component).forEach(function (_snConfig) {
- _snConfig.set('isVisible', false);
- }, this);
- var category = configCategories.findProperty('name', component);
- if (category) {
- configCategories.removeObject(category);
- }
- }
-});
http://git-wip-us.apache.org/repos/asf/ambari/blob/c61933d8/ambari-web/app/controllers/main/admin/security/add/step3.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/security/add/step3.js b/ambari-web/app/controllers/main/admin/security/add/step3.js
deleted file mode 100644
index 0e66cc5..0000000
--- a/ambari-web/app/controllers/main/admin/security/add/step3.js
+++ /dev/null
@@ -1,448 +0,0 @@
-/**
- * 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');
-var stringUtils = require('utils/string_utils');
-
-App.MainAdminSecurityAddStep3Controller = Em.Controller.extend({
- name: 'mainAdminSecurityAddStep3Controller',
- hostComponents: [],
- hosts: [],
- isLoaded: false,
-
- componentToUserMap: function() {
- var map = {
- 'NAMENODE': 'hdfs_user',
- 'SECONDARY_NAMENODE': 'hdfs_user',
- 'DATANODE': 'hdfs_user',
- 'JOURNALNODE': 'hdfs_user',
- 'TASKTRACKER': 'mapred_user',
- 'JOBTRACKER': 'mapred_user',
- 'HISTORYSERVER': 'mapred_user',
- 'RESOURCEMANAGER': 'yarn_user',
- 'NODEMANAGER': 'yarn_user',
- 'ZOOKEEPER_SERVER': 'zk_user',
- 'HIVE_SERVER': 'hive_user',
- 'HIVE_METASTORE': 'hive_user',
- 'OOZIE_SERVER': 'oozie_user',
- 'HBASE_MASTER': 'hbase_user',
- 'HBASE_REGIONSERVER': 'hbase_user',
- 'SUPERVISOR': 'storm_user',
- 'NIMBUS': 'storm_user',
- 'STORM_UI_SERVER': 'storm_user',
- 'FALCON_SERVER': 'falcon_user',
- 'KNOX_GATEWAY': 'knox_user',
- 'APP_TIMELINE_SERVER': 'yarn_user'
- };
- if (App.get('isHadoop22Stack')) {
- map['DRPC_SERVER'] = 'storm_user'
- }
- return map;
- }.property('App.isHadoop22Stack'),
- // The componentName, principal, and keytab have to coincide with the values in secure_properties.js
- componentToConfigMap: [
- {
- componentName: 'NAMENODE',
- principal: 'hadoop_http_principal_name',
- keytab: 'hadoop_http_keytab',
- displayName: Em.I18n.t('admin.addSecurity.hdfs.user.httpUser')
- },
- {
- componentName: 'SECONDARY_NAMENODE',
- principal: 'hadoop_http_principal_name',
- keytab: 'hadoop_http_keytab',
- displayName: Em.I18n.t('admin.addSecurity.hdfs.user.httpUser')
- },
- {
- componentName: 'JOURNALNODE',
- principal: 'hadoop_http_principal_name',
- keytab: 'hadoop_http_keytab',
- displayName: Em.I18n.t('admin.addSecurity.hdfs.user.httpUser')
- },
- {
- componentName: 'WEBHCAT_SERVER',
- principal: 'webHCat_http_principal_name',
- keytab: 'webhcat_http_keytab',
- displayName: Em.I18n.t('admin.addSecurity.webhcat.user.httpUser')
- },
- {
- componentName: 'HIVE_SERVER',
- principal: 'hive_metastore_http_principal_name',
- keytab: 'hive_metastore_http_keytab',
- displayName: Em.I18n.t('admin.addSecurity.hive.user.httpUser')
- },
- {
- componentName: 'OOZIE_SERVER',
- principal: 'oozie_http_principal_name',
- keytab: 'oozie_http_keytab',
- displayName: Em.I18n.t('admin.addSecurity.oozie.user.httpUser')
- },
- {
- componentName: 'FALCON_SERVER',
- principal: 'falcon_http_principal_name',
- keytab: 'falcon_http_keytab',
- displayName: Em.I18n.t('admin.addSecurity.falcon.user.httpUser')
- },
- {
- componentName: 'HISTORYSERVER',
- principal: 'jobhistory_http_principal_name',
- keytab: 'jobhistory_http_keytab',
- displayName: Em.I18n.t('admin.addSecurity.historyServer.user.httpUser')
- },
- {
- componentName: 'RESOURCEMANAGER',
- principal: 'resourcemanager_http_principal_name',
- keytab: 'resourcemanager_http_keytab',
- displayName: Em.I18n.t('admin.addSecurity.rm.user.httpUser')
- },
- {
- componentName: 'NODEMANAGER',
- principal: 'nodemanager_http_principal_name',
- keytab: 'nodemanager_http_keytab',
- displayName: Em.I18n.t('admin.addSecurity.nm.user.httpUser')
- },
- {
- componentName: 'APP_TIMELINE_SERVER',
- principal: 'apptimelineserver_http_principal_name',
- keytab: 'apptimelineserver_http_keytab',
- displayName: Em.I18n.t('admin.addSecurity.user.yarn.atsHTTPUser')
- },
- {
- componentName: 'STORM_UI_SERVER',
- principal: 'storm_ui_principal_name',
- keytab: 'storm_ui_keytab',
- displayName: Em.I18n.t('admin.addSecurity.storm.user.httpUser'),
- isHadoop22Stack: true
- }
- ],
-
- mandatoryConfigs: [
- {
- userConfig: 'smokeuser',
- keytab: 'smokeuser_keytab',
- displayName: Em.I18n.t('admin.addSecurity.user.smokeUser')
- },
- {
- userConfig: 'hdfs_user',
- keytab: 'hdfs_user_keytab',
- displayName: Em.I18n.t('admin.addSecurity.user.hdfsUser'),
- checkService: 'HDFS'
- },
- {
- userConfig: 'hbase_user',
- keytab: 'hbase_user_keytab',
- displayName: Em.I18n.t('admin.addSecurity.user.hbaseUser'),
- checkService: 'HBASE'
- }
- ],
-
- /**
- * download CSV file
- */
- doDownloadCsv: function () {
- if ($.browser.msie && $.browser.version < 10) {
- this.openInfoInNewTab();
- } else {
- try {
- var blob = new Blob([stringUtils.arrayToCSV(this.get('hostComponents'))], {type: "text/csv;charset=utf-8;"});
- saveAs(blob, "host-principal-keytab-list.csv");
- } catch (e) {
- this.openInfoInNewTab();
- }
- }
- },
-
- /**
- * open content of CSV file in new window
- */
- openInfoInNewTab: function () {
- var newWindow = window.open('');
- var newDocument = newWindow.document;
- newDocument.write(stringUtils.arrayToCSV(this.get('hostComponents')));
- newWindow.focus();
- },
-
- /**
- * load hosts from server
- */
- loadHosts: function () {
- App.ajax.send({
- name: 'hosts.security.wizard',
- sender: this,
- data: {},
- error: 'loadHostsErrorCallback',
- success: 'loadHostsSuccessCallback'
- })
- },
-
- loadHostsSuccessCallback: function (data, opt, params) {
- var hosts = [];
-
- data.items.forEach(function (item) {
- var hostComponents = [];
-
- item.host_components.forEach(function (hostComponent) {
- hostComponents.push(Em.Object.create({
- componentName: hostComponent.HostRoles.component_name,
- service: Em.Object.create({
- serviceName: hostComponent.HostRoles.service_name
- }),
- displayName: App.format.role(hostComponent.HostRoles.component_name)
- }));
- });
- hosts.push(Em.Object.create({
- hostName: item.Hosts.host_name,
- hostComponents: hostComponents
- }));
- });
- this.set('isLoaded', true);
- this.set('hosts', hosts);
- this.loadStep();
- },
- loadHostsErrorCallback: function () {
- this.set('isLoaded', true);
- this.set('hosts', []);
- this.loadStep();
- },
-
- /**
- * load step info
- */
- loadStep: function () {
- var hosts = this.get('hosts');
- var result = [];
- var securityUsers = this.getSecurityUsers();
- var hadoopGroupId = securityUsers.findProperty('name', 'user_group').value;
- var addedPrincipalsHost = {}; //Keys = host_principal, Value = 'true'
-
- hosts.forEach(function (host) {
- this.setMandatoryConfigs(result, securityUsers, host.get('hostName'), hadoopGroupId);
- this.setComponentsConfig(result, host, hadoopGroupId);
- this.setHostComponentsSecureValue(result, host, addedPrincipalsHost, securityUsers, hadoopGroupId);
- }, this);
- this.set('hostComponents', result);
- },
-
- /**
- * Returns host name for Nimbus component
- */
- getNimbusHostName: function () {
- var host = this.get('hosts').find(function (host) {
- return !!host.get('hostComponents').findProperty('componentName', 'NIMBUS');
- });
- if (host) {
- return host.get('hostName');
- }
- },
-
- /**
- * build map of connections between component and user
- * @param securityUsers
- */
- buildComponentToOwnerMap: function (securityUsers) {
- var componentToUserMap = this.get('componentToUserMap');
- var componentToOwnerMap = {};
- for (var component in componentToUserMap) {
- var user = componentToUserMap[component];
- var securityUser = securityUsers.findProperty('name', user);
- componentToOwnerMap[component] = securityUser.value;
- }
- return componentToOwnerMap;
- },
-
- /**
- * set security settings(principal and keytab) to component depending on whether host has such component
- * @param result
- * @param host
- * @param hadoopGroupId
- */
- setComponentsConfig: function (result, host, hadoopGroupId) {
- var hostComponents = host.get('hostComponents');
-
- var isATSInstalled = this.get('content.isATSInstalled');
- var doesATSSupportKerberos = App.get("doesATSSupportKerberos");
-
- this.get('componentToConfigMap').forEach(function (component) {
- //add specific components that supported only in Hadoop2 stack
- if (component.isHadoop22Stack && !App.get('isHadoop22Stack')) return;
-
- if (hostComponents.someProperty('componentName', component.componentName)) {
-
- if (component.componentName === "APP_TIMELINE_SERVER" && (!isATSInstalled || !doesATSSupportKerberos)) {
- return;
- }
-
- var configs = this.get('content.serviceConfigProperties');
- var serviceName = App.StackServiceComponent.find(component.componentName).get('serviceName');
- var serviceConfigs = configs.filterProperty('serviceName', serviceName);
- var servicePrincipal = serviceConfigs.findProperty('name', component.principal);
- var serviceKeytabPath = serviceConfigs.findProperty('name', component.keytab).value;
- result.push({
- host: host.get('hostName'),
- component: component.displayName,
- principal: this.getPrincipal(servicePrincipal, host.get('hostName')),
- keytabfile: stringUtils.getFileFromPath(serviceKeytabPath),
- keytab: stringUtils.getPath(serviceKeytabPath),
- owner: 'root',
- group: hadoopGroupId,
- acl: '440'
- });
- }
- }, this);
- },
-
- /**
- * set security settings(principal and keytab) to component
- * if checkService is passed then verify that service to his existence in order to set configs to such service
- * @param result
- * @param securityUsers
- * @param hostName
- * @param hadoopGroupId
- */
- setMandatoryConfigs: function (result, securityUsers, hostName, hadoopGroupId) {
- var generalConfigs = this.get('content.serviceConfigProperties').filterProperty('serviceName', 'GENERAL');
- var realm = generalConfigs.findProperty('name', 'kerberos_domain').value;
- var installedServices = App.Service.find().mapProperty('serviceName');
-
- this.get('mandatoryConfigs').forEach(function (config) {
- if (config.checkService && !installedServices.contains(config.checkService)) return;
-
- var userId = securityUsers.findProperty('name', config.userConfig).value;
- var userKeytabPath = generalConfigs.findProperty('name', config.keytab).value;
- result.push({
- host: hostName,
- component: config.displayName,
- principal: userId + '@' + realm,
- keytabFile: stringUtils.getFileFromPath(userKeytabPath),
- keytab: stringUtils.getPath(userKeytabPath),
- owner: userId,
- group: hadoopGroupId,
- acl: '440'
- });
- }, this);
- },
-
- /**
- * set secure properties(keytab and principal) for components, which should be displayed
- * @param result
- * @param host
- * @param addedPrincipalsHost
- * @param securityUsers
- * @param hadoopGroupId
- */
- setHostComponentsSecureValue: function (result, host, addedPrincipalsHost, securityUsers, hadoopGroupId) {
- var componentsToDisplay = ['NAMENODE', 'SECONDARY_NAMENODE', 'DATANODE', 'JOBTRACKER', 'ZOOKEEPER_SERVER', 'HIVE_SERVER', 'HIVE_METASTORE',
- 'TASKTRACKER', 'OOZIE_SERVER', 'HBASE_MASTER', 'HBASE_REGIONSERVER', 'HISTORYSERVER', 'RESOURCEMANAGER', 'NODEMANAGER',
- 'JOURNALNODE', 'SUPERVISOR', 'NIMBUS', 'STORM_UI_SERVER','FALCON_SERVER', 'KNOX_GATEWAY', 'APP_TIMELINE_SERVER'];
- if (App.get('isHadoop22Stack')) {
- componentsToDisplay.push('DRPC_SERVER');
- }
- var configs = this.get('content.serviceConfigProperties');
- var componentToOwnerMap = this.buildComponentToOwnerMap(securityUsers);
- var hostName = host.get('hostName');
-
- var isATSInstalled = this.get('content.isATSInstalled');
- var doesATSSupportKerberos = App.get("doesATSSupportKerberos");
-
- host.get('hostComponents').forEach(function (hostComponent) {
- if (componentsToDisplay.contains(hostComponent.get('componentName'))) {
- var serviceConfigs = configs.filterProperty('serviceName', hostComponent.get('service.serviceName'));
- var targetHost = hostName;
- if (App.get('isHadoop22Stack') && hostComponent.get('componentName') === 'DRPC_SERVER') {
- targetHost = this.getNimbusHostName()
- }
- var secureProperties = this.getSecureProperties(serviceConfigs, hostComponent.get('componentName'), targetHost);
- var displayName = this.changeDisplayName(hostComponent.get('displayName'));
- var key = hostName + "--" + secureProperties.principal;
-
- if (hostComponent.get('componentName') === "APP_TIMELINE_SERVER" && (!isATSInstalled || !doesATSSupportKerberos)) {
- return;
- }
-
- if (Em.isNone(addedPrincipalsHost[key])) {
- var owner = componentToOwnerMap[hostComponent.get('componentName')] || '';
-
- result.push({
- host: hostName,
- component: displayName,
- principal: secureProperties.principal,
- keytabFile: stringUtils.getFileFromPath(secureProperties.keytab),
- keytab: stringUtils.getPath(secureProperties.keytab),
- owner: owner,
- group: hadoopGroupId,
- acl: '400'
- });
- addedPrincipalsHost[key] = true;
- }
- }
- }, this);
- },
-
- /**
- * get properties (keytab and principle) of secure config that match component
- * @param serviceConfigs
- * @param componentName
- * @param hostName
- * @return {Object}
- */
- getSecureProperties: function (serviceConfigs, componentName, hostName) {
- var secureProperties = {};
- serviceConfigs.forEach(function (config) {
- if ((config.component && config.component === componentName) ||
- (config.components && config.components.contains(componentName))) {
- if (config.name.endsWith('_principal_name')) {
- secureProperties.principal = this.getPrincipal(config, hostName);
- } else if (config.name.endsWith('_keytab') || config.name.endsWith('_keytab_path')) {
- secureProperties.keytab = config.value;
- }
- }
- }, this);
- return secureProperties;
- },
-
- /**
- * get formatted principal value
- * @param config
- * @param hostName
- * @return {String}
- */
- getPrincipal: function (config, hostName) {
- return config.value.replace('_HOST', hostName.toLowerCase()) + config.unit;
- },
-
- /**
- * get users from security configs
- * @return {Array}
- */
- getSecurityUsers: function () {
- return App.db.getSecureUserInfo();
- },
-
- /**
- * format display names of specific components
- * @param name
- * @return {*}
- */
- changeDisplayName: function (name) {
- if (name === 'HiveServer2' || name === 'Hive Metastore') {
- return 'Hive Metastore and HiveServer2';
- } else {
- return name;
- }
- }
-});
http://git-wip-us.apache.org/repos/asf/ambari/blob/c61933d8/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
deleted file mode 100644
index 406892d..0000000
--- a/ambari-web/app/controllers/main/admin/security/add/step4.js
+++ /dev/null
@@ -1,203 +0,0 @@
-/**
- * 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.MainAdminSecurityAddStep4Controller = App.MainAdminSecurityProgressController.extend(App.AddSecurityConfigs, {
-
- name: 'mainAdminSecurityAddStep4Controller',
-
- isBackBtnDisabled: function () {
- return !this.get('commands').someProperty('isError');
- }.property('commands.@each.isCompleted'),
-
- isSecurityApplied: function () {
- return this.get('commands').someProperty('name', 'START_SERVICES') && this.get('commands').findProperty('name', 'START_SERVICES').get('isSuccess');
- }.property('commands.@each.isCompleted'),
-
- /**
- * control disabled property of completion button
- */
- enableSubmit: function () {
- var addSecurityController = App.router.get('addSecurityController');
- if (this.get('commands').someProperty('isError') || this.get('commands').everyProperty('isSuccess')) {
- this.set('isSubmitDisabled', false);
- if (this.get('commands').someProperty('isError')) {
- addSecurityController.setStepsEnable();
- }
- } else {
- this.set('isSubmitDisabled', true);
- addSecurityController.setLowerStepsDisable(4);
- }
- }.observes('commands.@each.isCompleted'),
-
- /**
- * clear step info
- */
- clearStep: function () {
- this.set('commands', []);
- this.set('isSubmitDisabled', true);
- this.get('serviceConfigTags').clear();
- },
-
- loadCommands: function () {
- this._super();
-
- // Determine if ATS Component needs to be removed
- var isATSInstalled = this.get('content.isATSInstalled');
- var doesATSSupportKerberos = App.get("doesATSSupportKerberos");
- if (isATSInstalled && !doesATSSupportKerberos) {
- this.get('commands').splice(2, 0, App.Poll.create({name: 'DELETE_ATS', label: Em.I18n.translations['admin.addSecurity.apply.delete.ats'], isPolling: false}));
- }
- },
-
- /**
- * load step info
- */
- loadStep: function () {
- this.clearStep();
- this.prepareSecureConfigs();
-
- if (!this.resumeSavedCommands()) {
- this.loadCommands();
- this.addInfoToCommands();
- this.syncStopServicesOperation();
- this.addObserverToCommands();
- this.moveToNextCommand();
- }
- },
-
- /**
- * synchronize "STOP_SERVICES" operation from BO with command of step
- * @return {Boolean}
- */
- syncStopServicesOperation: function () {
- var runningOperations = App.router.get('backgroundOperationsController.services').filterProperty('isRunning');
- var stopAllOperation = runningOperations.findProperty('name', 'Stop All Services');
- var stopCommand = this.get('commands').findProperty('name', 'STOP_SERVICES');
- if (stopCommand && stopAllOperation) {
- stopCommand.set('requestId', stopAllOperation.get('id'));
- return true;
- }
- return false;
- },
-
- /**
- * resume previously saved commands
- * @return {Boolean}
- */
- resumeSavedCommands: function () {
- var commands = App.db.getSecurityDeployCommands();
- if (Em.isNone(commands) || commands.length === 0) return false;
-
- commands.forEach(function (_command, index) {
- commands[index] = App.Poll.create(_command);
- }, this);
- if (commands.someProperty('isError')) {
- this.get('commands').pushObjects(commands);
- this.addObserverToCommands();
- return true;
- } else if (commands.filterProperty('isStarted').someProperty('isCompleted', false)) {
- var runningCommand = commands.filterProperty('isStarted').findProperty('isCompleted', false);
- runningCommand.set('isStarted', false);
- this.get('commands').pushObjects(commands);
- } else {
- this.get('commands').pushObjects(commands);
- }
- this.addObserverToCommands();
- this.moveToNextCommand();
- return true;
- },
-
- manageSecureConfigs: function () {
- var serviceConfigTags = this.get('serviceConfigTags');
- var secureConfigs = this.get('secureConfigs');
- var siteProperties = this.get('configs');
- if (serviceConfigTags) {
- secureConfigs.forEach(function (config) {
- this.setPrincipalValue(config.serviceName, config.name);
- }, this);
- serviceConfigTags.forEach(function (_serviceConfigTags) {
- _serviceConfigTags.newTagName = 'version' + (new Date).getTime();
- siteProperties.filterProperty('filename', _serviceConfigTags.siteName + '.xml').forEach(function (_config) {
- if (!/_hosts?$/.test(_config.name)) {
- _serviceConfigTags.configs[_config.name] = _config.value;
- }
- }, this);
- }, this);
- return true;
- } else {
- var command = this.get('commands').findProperty('name', 'APPLY_CONFIGURATIONS');
- command.set('isSuccess', false);
- command.set('isError', true);
- this.onJsError();
- return false;
- }
- },
-
- /**
- * send DELETE command to server to delete component
- * @param componentName
- * @param hostName
- */
- deleteComponents: function(componentName, hostName) {
- App.ajax.send({
- name: 'common.delete.host_component',
- sender: this,
- data: {
- componentName: componentName,
- hostName: hostName
- },
- success: 'onDeleteComplete',
- error: 'onDeleteError'
- });
- },
-
- /**
- * callback on successful deletion of component
- */
- onDeleteComplete: function () {
- var deleteAtsCommand = this.get('commands').findProperty('name', 'DELETE_ATS');
- console.warn('APP_TIMELINE_SERVER doesn\'t support security mode in this HDP stack. It has been removed from YARN service ');
- deleteAtsCommand.set('isError', false);
- deleteAtsCommand.set('isSuccess', true);
- },
-
- /**
- * callback on failed deletion of component
- */
- onDeleteError: function () {
- var deleteAtsCommand = this.get('commands').findProperty('name', 'DELETE_ATS');
- console.warn('Error: Can\'t delete APP_TIMELINE_SERVER');
- deleteAtsCommand.set('isError', true);
- deleteAtsCommand.set('isSuccess', false);
- },
-
- /**
- * show popup when js error occurred
- */
- onJsError: function () {
- App.ModalPopup.show({
- header: Em.I18n.t('common.error'),
- secondary: false,
- bodyClass: Ember.View.extend({
- template: Ember.Handlebars.compile('<p>{{t admin.security.apply.configuration.error}}</p>')
- })
- });
- }
-});
http://git-wip-us.apache.org/repos/asf/ambari/blob/c61933d8/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
deleted file mode 100644
index 728ba67..0000000
--- a/ambari-web/app/controllers/main/admin/security/disable.js
+++ /dev/null
@@ -1,212 +0,0 @@
-/**
- * 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');
-require('controllers/main/admin/security/security_progress_controller');
-
-App.MainAdminSecurityDisableController = App.MainAdminSecurityProgressController.extend({
- name: 'mainAdminSecurityDisableController',
- secureServices: [],
- /**
- * values of site configs when security disabled.
- * Properties not defined in data/secure_mapping or data/HDP2/secure_mapping and needs to be changed on disabling
- * security should be defined in secureConfigValuesMap Object
- */
- secureConfigValuesMap: {
- 'nimbus.childopts': function(value) {
- return value.replace (/-Djava.security.auth.login.config\s*=\s*\S*/g, "");
- },
- 'ui.childopts': function(value) {
- return value.replace (/-Djava.security.auth.login.config\s*=\s*\S*/g, "");
- },
- 'supervisor.childopts': function(value) {
- return value.replace (/-Djava.security.auth.login.config\s*=\s*\S*/g, "");
- }
- },
-
- isSubmitDisabled: function () {
- return !(this.get('commands').someProperty('isError') || this.get('commands').everyProperty('isSuccess'));
- }.property('commands.@each.isCompleted'),
-
- /**
- * clear step info
- */
- clearStep: function () {
- this.get('commands').clear();
- this.get('secureServices').clear();
- this.get('serviceConfigTags').clear();
- },
-
- /**
- * load info required by current step
- */
- loadStep: function () {
- this.clearStep();
- var commands = App.db.getSecurityDeployCommands();
- if (commands && commands.length > 0) {
- commands.forEach(function (_command, index) {
- commands[index] = App.Poll.create(_command);
- }, this);
- if (commands.someProperty('isError', true)) {
- this.get('commands').pushObjects(commands);
- this.loadSecureServices();
- this.addObserverToCommands();
- return;
- } else if (commands.filterProperty('isStarted', true).someProperty('isCompleted', false)) {
- var runningCommand = commands.filterProperty('isStarted', true).findProperty('isCompleted', false);
- runningCommand.set('isStarted', false);
- this.get('commands').pushObjects(commands);
- } else {
- this.get('commands').pushObjects(commands);
- }
- } else {
- this.loadCommands();
- this.addInfoToCommands();
- this.syncStopServicesCommand();
- }
- this.loadSecureServices();
- this.addObserverToCommands();
- this.moveToNextCommand();
- },
-
- /**
- * resume info about commands from local storage
- * @return {Boolean}
- */
- resumeCommands: function () {
- var commands = App.db.getSecurityDeployCommands();
- if (!commands || commands.length === 0) return false;
-
- commands.forEach(function (_command) {
- this.get('commands').pushObject(App.Poll.create(_command));
- }, this);
- var runningCommand = this.get('commands').filterProperty('isStarted').findProperty('isCompleted', false);
- if (runningCommand) {
- runningCommand.set('isStarted', false);
- }
- return true;
- },
-
- /**
- * synchronize existing background operation "Stop All Services" with command in Security wizard
- */
- syncStopServicesCommand: function () {
- var runningOperations = App.router.get('backgroundOperationsController.services').filterProperty('isRunning');
- var stopAllOperation = runningOperations.findProperty('name', 'Stop All Services');
- var stopCommand = this.get('commands').findProperty('name', 'STOP_SERVICES');
- if (stopCommand && stopAllOperation) {
- stopCommand.set('requestId', stopAllOperation.get('id'));
- }
- },
-
- /**
- * load secure configs of installed services
- */
- loadSecureServices: function () {
- var secureServices = require('data/HDP2/secure_configs');
- var installedServices = App.Service.find().mapProperty('serviceName');
- this.get('secureServices').pushObject(secureServices.findProperty('serviceName', 'GENERAL'));
- //General (only non service tab) tab is always displayed
- installedServices.forEach(function (_service) {
- var secureService = secureServices.findProperty('serviceName', _service);
- if (secureService) {
- this.get('secureServices').pushObject(secureService);
- }
- }, this);
- },
-
- /**
- * manage configurations from serviceConfigTags
- * @return {Boolean}
- */
- manageSecureConfigs: function () {
- var serviceConfigTags = this.get('serviceConfigTags');
- var secureProperties = this.get('secureProperties');
- var secureMapping = this.get('secureMapping');
- if (!serviceConfigTags || !secureProperties || !secureMapping) {
- var command = this.get('commands').findProperty('name', 'APPLY_CONFIGURATIONS');
- command.set('isSuccess', false);
- command.set('isError', true);
- return false;
- } else {
- serviceConfigTags.forEach(function (_serviceConfigTags) {
- _serviceConfigTags.newTagName = 'version' + (new Date).getTime();
- if (_serviceConfigTags.siteName.contains('-env')) {
- this.deleteDisabledConfigs(secureProperties, _serviceConfigTags);
- if (_serviceConfigTags.siteName === 'cluster-env') {
- _serviceConfigTags.configs.security_enabled = 'false';
- }
- } else {
- this.modifySiteConfigs(secureMapping, _serviceConfigTags);
- }
- }, this);
- return true;
- }
- },
- /**
- * delete configs, which aren't required when security disabled
- * @param secureProperties
- * @param _serviceConfigTags
- * @return {Boolean}
- */
- deleteDisabledConfigs: function (secureProperties, _serviceConfigTags) {
- if (!secureProperties || !_serviceConfigTags) return false;
- secureProperties.forEach(function (_config) {
- if (_config.name in _serviceConfigTags.configs) {
- delete _serviceConfigTags.configs[_config.name];
- }
- }, this);
- return true;
- },
- /**
- * delete unnecessary site configs and
- * change config values
- * @param secureMapping
- * @param _serviceConfigTags
- * @return {Boolean}
- */
- modifySiteConfigs: function (secureMapping, _serviceConfigTags) {
- var secureConfigValuesMap = this.get('secureConfigValuesMap');
- if (!secureMapping || !_serviceConfigTags) return false;
-
- // iterate over secureConfigValuesMap to update service-site configProperties not present in secureMapping metadata
- for (var key in secureConfigValuesMap) {
- if (key in _serviceConfigTags.configs) {
- var value = secureConfigValuesMap[key];
- if (typeof value == 'function') {
- _serviceConfigTags.configs[key] = value(_serviceConfigTags.configs[key]);
- } else if (value) {
- _serviceConfigTags.configs[key] = value;
- }
- }
- }
-
- secureMapping.filterProperty('filename', _serviceConfigTags.siteName + '.xml').forEach(function (_config) {
- var configName = _config.name;
- var nonSecureConfigValue = _config.nonSecureValue;
- if (configName in _serviceConfigTags.configs) {
- if (nonSecureConfigValue) {
- _serviceConfigTags.configs[configName] = nonSecureConfigValue;
- } else {
- delete _serviceConfigTags.configs[configName]
- }
- }
- }, this);
- return true;
- }
-});