disable.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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('stages').clear();
  24. this.get('secureServices').clear();
  25. this.get('serviceConfigTags').clear();
  26. },
  27. loadStep: function () {
  28. this.clearStep();
  29. var stages = App.db.getSecurityDeployStages();
  30. if (stages && stages.length > 0) {
  31. stages.forEach(function (_stage, index) {
  32. stages[index] = App.Poll.create(_stage);
  33. }, this);
  34. if (stages.someProperty('isError', true)) {
  35. this.get('stages').pushObjects(stages);
  36. this.loadSecureServices();
  37. this.addObserver('stages.@each.isSuccess', this, 'onCompleteStage');
  38. return;
  39. } else if (stages.filterProperty('isStarted', true).someProperty('isCompleted', false)) {
  40. var runningStage = stages.filterProperty('isStarted', true).findProperty('isCompleted', false);
  41. runningStage.set('isStarted', false);
  42. this.get('stages').pushObjects(stages);
  43. } else {
  44. this.get('stages').pushObjects(stages);
  45. }
  46. } else {
  47. this.loadStages();
  48. this.addInfoToStages();
  49. var runningOperations = App.router.get('backgroundOperationsController.services').filterProperty('isRunning');
  50. var stopAllOperation = runningOperations.findProperty('name', 'Stop All Services');
  51. var stopStage = this.get('stages').findProperty('name', 'STOP_SERVICES');
  52. if (stopStage.get('name') === 'STOP_SERVICES' && stopAllOperation) {
  53. stopStage.set('requestId', stopAllOperation.get('id'));
  54. }
  55. }
  56. this.loadSecureServices();
  57. this.addObserver('stages.@each.isSuccess', this, 'onCompleteStage');
  58. this.moveToNextStage();
  59. },
  60. enableSubmit: function () {
  61. if (this.get('stages').someProperty('isError', true) || this.get('stages').everyProperty('isSuccess', true)) {
  62. this.set('isSubmitDisabled', false);
  63. } else {
  64. this.set('isSubmitDisabled', true);
  65. }
  66. }.observes('stages.@each.isCompleted'),
  67. loadSecureServices: function () {
  68. var secureServices = 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. _serviceConfigTags.configs.dfs_datanode_address = '50010';
  91. _serviceConfigTags.configs.dfs_datanode_http_address = '50075';
  92. } else {
  93. this.get('secureMapping').filterProperty('filename', _serviceConfigTags.siteName + '.xml').forEach(function (_config) {
  94. var configName = _config.name;
  95. if (configName in _serviceConfigTags.configs) {
  96. switch (configName) {
  97. case 'ambari.dfs.datanode.port':
  98. _serviceConfigTags.configs[configName] = '50010';
  99. break;
  100. case 'ambari.dfs.datanode.http.port':
  101. _serviceConfigTags.configs[configName] = '50075';
  102. break;
  103. case 'mapred.task.tracker.task-controller':
  104. _serviceConfigTags.configs[configName] = 'org.apache.hadoop.mapred.DefaultTaskController';
  105. break;
  106. case 'yarn.nodemanager.container-executor.class':
  107. _serviceConfigTags.configs[configName] = 'org.apache.hadoop.yarn.server.nodemanager.DefaultContainerExecutor';
  108. break;
  109. case 'hbase.security.authentication':
  110. _serviceConfigTags.configs[configName] = 'simple';
  111. break;
  112. case 'hbase.rpc.engine':
  113. _serviceConfigTags.configs[configName] = 'org.apache.hadoop.hbase.ipc.WritableRpcEngine';
  114. break;
  115. case 'hbase.security.authorization':
  116. _serviceConfigTags.configs[configName] = 'false';
  117. break;
  118. case 'zookeeper.znode.parent':
  119. _serviceConfigTags.configs[configName] = '/hbase-unsecure';
  120. break;
  121. case 'hive.security.authorization.enabled':
  122. _serviceConfigTags.configs[configName] = 'false';
  123. break;
  124. default:
  125. delete _serviceConfigTags.configs[configName];
  126. }
  127. }
  128. console.log("Not Deleted" + _config.name);
  129. }, this);
  130. }
  131. }, this);
  132. } catch (err) {
  133. var stage3 = this.get('stages').findProperty('stage', 'stage3');
  134. if (stage3) {
  135. stage3.set('isSuccess', false);
  136. stage3.set('isError', true);
  137. }
  138. if (err) {
  139. console.log("Error: Error occurred while applying secure configs to the server. Error message: " + err);
  140. }
  141. return false;
  142. }
  143. return true;
  144. }
  145. });