disable.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. App.MainAdminSecurityDisableController = App.MainAdminSecurityProgressController.extend({
  20. name: 'mainAdminSecurityDisableController',
  21. secureServices: [],
  22. clearStep: function () {
  23. this.get('commands').clear();
  24. this.get('secureServices').clear();
  25. this.get('serviceConfigTags').clear();
  26. },
  27. loadStep: function () {
  28. this.clearStep();
  29. var commands = App.db.getSecurityDeployCommands();
  30. if (commands && commands.length > 0) {
  31. commands.forEach(function (_command, index) {
  32. commands[index] = App.Poll.create(_command);
  33. }, this);
  34. if (commands.someProperty('isError', true)) {
  35. this.get('commands').pushObjects(commands);
  36. this.loadSecureServices();
  37. this.addObserverToCommands();
  38. return;
  39. } else if (commands.filterProperty('isStarted', true).someProperty('isCompleted', false)) {
  40. var runningCommand = commands.filterProperty('isStarted', true).findProperty('isCompleted', false);
  41. runningCommand.set('isStarted', false);
  42. this.get('commands').pushObjects(commands);
  43. } else {
  44. this.get('commands').pushObjects(commands);
  45. }
  46. } else {
  47. this.loadCommands();
  48. this.addInfoToCommands();
  49. var runningOperations = App.router.get('backgroundOperationsController.services').filterProperty('isRunning');
  50. var stopAllOperation = runningOperations.findProperty('name', 'Stop All Services');
  51. var stopCommand = this.get('commands').findProperty('name', 'STOP_SERVICES');
  52. if (stopCommand.get('name') === 'STOP_SERVICES' && stopAllOperation) {
  53. stopCommand.set('requestId', stopAllOperation.get('id'));
  54. }
  55. }
  56. this.loadSecureServices();
  57. this.addObserverToCommands();
  58. this.moveToNextCommand();
  59. },
  60. enableSubmit: function () {
  61. if (this.get('commands').someProperty('isError', true) || this.get('commands').everyProperty('isSuccess', true)) {
  62. this.set('isSubmitDisabled', false);
  63. } else {
  64. this.set('isSubmitDisabled', true);
  65. }
  66. }.observes('commands.@each.isCompleted'),
  67. loadSecureServices: function () {
  68. var secureServices = App.get('isHadoop2Stack')?require('data/HDP2/secure_configs'):require('data/secure_configs');
  69. var installedServices = App.Service.find().mapProperty('serviceName');
  70. this.get('secureServices').pushObject(secureServices.findProperty('serviceName', 'GENERAL'));
  71. //General (only non service tab) tab is always displayed
  72. installedServices.forEach(function (_service) {
  73. var secureService = secureServices.findProperty('serviceName', _service);
  74. if (secureService) {
  75. this.get('secureServices').pushObject(secureService);
  76. }
  77. }, this);
  78. },
  79. manageSecureConfigs: function () {
  80. try {
  81. this.get('serviceConfigTags').forEach(function (_serviceConfigTags, index) {
  82. _serviceConfigTags.newTagName = 'version' + (new Date).getTime();
  83. if (_serviceConfigTags.siteName === 'global') {
  84. this.get('secureProperties').forEach(function (_config) {
  85. if (_config.name in _serviceConfigTags.configs) {
  86. delete _serviceConfigTags.configs[_config.name];
  87. }
  88. }, this);
  89. _serviceConfigTags.configs.security_enabled = 'false';
  90. } else {
  91. this.get('secureMapping').filterProperty('filename', _serviceConfigTags.siteName + '.xml').forEach(function (_config) {
  92. var configName = _config.name;
  93. if (configName in _serviceConfigTags.configs) {
  94. switch (configName) {
  95. case 'dfs.datanode.address':
  96. _serviceConfigTags.configs[configName] = '0.0.0.0:50010';
  97. break;
  98. case 'dfs.datanode.http.address':
  99. _serviceConfigTags.configs[configName] = '0.0.0.0:50075';
  100. break;
  101. case 'mapred.task.tracker.task-controller':
  102. _serviceConfigTags.configs[configName] = 'org.apache.hadoop.mapred.DefaultTaskController';
  103. break;
  104. case 'yarn.nodemanager.container-executor.class':
  105. _serviceConfigTags.configs[configName] = 'org.apache.hadoop.yarn.server.nodemanager.DefaultContainerExecutor';
  106. break;
  107. case 'hbase.security.authentication':
  108. _serviceConfigTags.configs[configName] = 'simple';
  109. break;
  110. case 'hbase.rpc.engine':
  111. _serviceConfigTags.configs[configName] = 'org.apache.hadoop.hbase.ipc.WritableRpcEngine';
  112. break;
  113. case 'hbase.security.authorization':
  114. _serviceConfigTags.configs[configName] = 'false';
  115. break;
  116. case 'zookeeper.znode.parent':
  117. _serviceConfigTags.configs[configName] = '/hbase-unsecure';
  118. break;
  119. case 'hive.security.authorization.enabled':
  120. _serviceConfigTags.configs[configName] = 'false';
  121. break;
  122. default:
  123. delete _serviceConfigTags.configs[configName];
  124. }
  125. }
  126. console.log("Not Deleted" + _config.name);
  127. }, this);
  128. }
  129. }, this);
  130. } catch (err) {
  131. var command = this.get('commands').findProperty('name', 'APPLY_CONFIGURATIONS');
  132. command.set('isSuccess', false);
  133. command.set('isError', true);
  134. if (err) {
  135. console.log("Error: Error occurred while applying secure configs to the server. Error message: " + err);
  136. }
  137. return false;
  138. }
  139. return true;
  140. }
  141. });