disable.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. require('controllers/main/admin/security/security_progress_controller');
  20. App.MainAdminSecurityDisableController = App.MainAdminSecurityProgressController.extend({
  21. name: 'mainAdminSecurityDisableController',
  22. secureServices: [],
  23. /**
  24. * values of site configs when security disabled
  25. */
  26. secureConfigValuesMap: {
  27. 'dfs.datanode.address': '0.0.0.0:50010',
  28. 'dfs.datanode.http.address': '0.0.0.0:50075',
  29. 'mapred.task.tracker.task-controller': 'org.apache.hadoop.mapred.DefaultTaskController',
  30. 'yarn.nodemanager.container-executor.class': 'org.apache.hadoop.yarn.server.nodemanager.DefaultContainerExecutor',
  31. 'hbase.security.authentication': 'simple',
  32. 'hbase.rpc.engine': 'org.apache.hadoop.hbase.ipc.WritableRpcEngine',
  33. 'hbase.security.authorization': 'false',
  34. 'zookeeper.znode.parent': '/hbase-unsecure',
  35. 'hive.security.authorization.enabled': 'false',
  36. '*.falcon.authentication.type': 'simple',
  37. '*.falcon.http.authentication.type': 'simple'
  38. },
  39. isSubmitDisabled: function () {
  40. return !(this.get('commands').someProperty('isError') || this.get('commands').everyProperty('isSuccess'));
  41. }.property('commands.@each.isCompleted'),
  42. /**
  43. * clear step info
  44. */
  45. clearStep: function () {
  46. this.get('commands').clear();
  47. this.get('secureServices').clear();
  48. this.get('serviceConfigTags').clear();
  49. },
  50. /**
  51. * load info required by current step
  52. */
  53. loadStep: function () {
  54. this.clearStep();
  55. var commands = App.db.getSecurityDeployCommands();
  56. if (commands && commands.length > 0) {
  57. commands.forEach(function (_command, index) {
  58. commands[index] = App.Poll.create(_command);
  59. }, this);
  60. if (commands.someProperty('isError', true)) {
  61. this.get('commands').pushObjects(commands);
  62. this.loadSecureServices();
  63. this.addObserverToCommands();
  64. return;
  65. } else if (commands.filterProperty('isStarted', true).someProperty('isCompleted', false)) {
  66. var runningCommand = commands.filterProperty('isStarted', true).findProperty('isCompleted', false);
  67. runningCommand.set('isStarted', false);
  68. this.get('commands').pushObjects(commands);
  69. } else {
  70. this.get('commands').pushObjects(commands);
  71. }
  72. } else {
  73. this.loadCommands();
  74. this.addInfoToCommands();
  75. this.syncStopServicesCommand();
  76. }
  77. this.loadSecureServices();
  78. this.addObserverToCommands();
  79. this.moveToNextCommand();
  80. },
  81. /**
  82. * resume info about commands from local storage
  83. * @return {Boolean}
  84. */
  85. resumeCommands: function () {
  86. var commands = App.db.getSecurityDeployCommands();
  87. if (!commands || commands.length === 0) return false;
  88. commands.forEach(function (_command) {
  89. this.get('commands').pushObject(App.Poll.create(_command));
  90. }, this);
  91. var runningCommand = this.get('commands').filterProperty('isStarted').findProperty('isCompleted', false);
  92. if (runningCommand) {
  93. runningCommand.set('isStarted', false);
  94. }
  95. return true;
  96. },
  97. /**
  98. * synchronize existing background operation "Stop All Services" with command in Security wizard
  99. */
  100. syncStopServicesCommand: function () {
  101. var runningOperations = App.router.get('backgroundOperationsController.services').filterProperty('isRunning');
  102. var stopAllOperation = runningOperations.findProperty('name', 'Stop All Services');
  103. var stopCommand = this.get('commands').findProperty('name', 'STOP_SERVICES');
  104. if (stopCommand && stopAllOperation) {
  105. stopCommand.set('requestId', stopAllOperation.get('id'));
  106. }
  107. },
  108. /**
  109. * load secure configs of installed services
  110. */
  111. loadSecureServices: function () {
  112. var secureServices = App.get('isHadoop2Stack') ? require('data/HDP2/secure_configs') : require('data/secure_configs');
  113. var installedServices = App.Service.find().mapProperty('serviceName');
  114. this.get('secureServices').pushObject(secureServices.findProperty('serviceName', 'GENERAL'));
  115. //General (only non service tab) tab is always displayed
  116. installedServices.forEach(function (_service) {
  117. var secureService = secureServices.findProperty('serviceName', _service);
  118. if (secureService) {
  119. this.get('secureServices').pushObject(secureService);
  120. }
  121. }, this);
  122. },
  123. /**
  124. * manage configurations from serviceConfigTags
  125. * @return {Boolean}
  126. */
  127. manageSecureConfigs: function () {
  128. var serviceConfigTags = this.get('serviceConfigTags');
  129. var secureProperties = this.get('secureProperties');
  130. var secureMapping = this.get('secureMapping');
  131. if (!serviceConfigTags || !secureProperties || !secureMapping) {
  132. var command = this.get('commands').findProperty('name', 'APPLY_CONFIGURATIONS');
  133. command.set('isSuccess', false);
  134. command.set('isError', true);
  135. return false;
  136. } else {
  137. serviceConfigTags.forEach(function (_serviceConfigTags) {
  138. _serviceConfigTags.newTagName = 'version' + (new Date).getTime();
  139. if (_serviceConfigTags.siteName === 'global') {
  140. this.deleteDisabledGlobalConfigs(secureProperties, _serviceConfigTags);
  141. _serviceConfigTags.configs.security_enabled = 'false';
  142. } else {
  143. this.modifySiteConfigs(secureMapping, _serviceConfigTags);
  144. }
  145. }, this);
  146. return true;
  147. }
  148. },
  149. /**
  150. * delete global configs, which aren't required when security disabled
  151. * @param secureProperties
  152. * @param _serviceConfigTags
  153. * @return {Boolean}
  154. */
  155. deleteDisabledGlobalConfigs: function (secureProperties, _serviceConfigTags) {
  156. if (!secureProperties || !_serviceConfigTags) return false;
  157. secureProperties.forEach(function (_config) {
  158. if (_config.name in _serviceConfigTags.configs) {
  159. delete _serviceConfigTags.configs[_config.name];
  160. }
  161. }, this);
  162. return true;
  163. },
  164. /**
  165. * delete unnecessary site configs and
  166. * change config values
  167. * @param secureMapping
  168. * @param _serviceConfigTags
  169. * @return {Boolean}
  170. */
  171. modifySiteConfigs: function (secureMapping, _serviceConfigTags) {
  172. var secureConfigValuesMap = this.get('secureConfigValuesMap');
  173. if (!secureMapping || !_serviceConfigTags) return false;
  174. secureMapping.filterProperty('filename', _serviceConfigTags.siteName + '.xml').forEach(function (_config) {
  175. var configName = _config.name;
  176. if (configName in _serviceConfigTags.configs) {
  177. if (secureConfigValuesMap[configName]) {
  178. _serviceConfigTags.configs[configName] = secureConfigValuesMap[configName]
  179. } else {
  180. delete _serviceConfigTags.configs[configName]
  181. }
  182. }
  183. }, this);
  184. return true;
  185. }
  186. });