admin.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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.MainAdminController = Em.Controller.extend({
  20. name: 'mainAdminController',
  21. category: 'user',
  22. securityEnabled: false,
  23. serviceUsers: [],
  24. deferred: null,
  25. tag: null,
  26. /**
  27. * return true if security status is loaded and false otherwise
  28. */
  29. securityStatusLoading: function () {
  30. var self = this;
  31. this.set('deferred', $.Deferred());
  32. if (App.testMode) {
  33. window.setTimeout(function () {
  34. self.get('deferred').resolve();
  35. }, 50);
  36. }
  37. else {
  38. //get Security Status From Server
  39. App.ajax.send({
  40. name: 'admin.security_status',
  41. sender: this,
  42. success: 'getSecurityStatusFromServerSuccessCallback',
  43. error: 'errorCallback'
  44. });
  45. }
  46. return this.get('deferred').promise();
  47. },
  48. errorCallback: function() {
  49. this.get('deferred').reject();
  50. },
  51. getSecurityStatusFromServerSuccessCallback: function (data) {
  52. var configs = data.Clusters.desired_configs;
  53. if ('global' in configs) {
  54. this.set('tag', configs['global'].tag);
  55. this.getServiceConfigsFromServer();
  56. }
  57. else {
  58. this.get('deferred').reject();
  59. }
  60. },
  61. getServiceConfigsFromServer: function () {
  62. App.ajax.send({
  63. name: 'admin.service_config',
  64. sender: this,
  65. data: {
  66. siteName: 'global',
  67. tagName: this.get('tag')
  68. },
  69. success: 'getServiceConfigsFromServerSuccessCallback',
  70. error: 'errorCallback'
  71. });
  72. },
  73. getServiceConfigsFromServerSuccessCallback: function (data) {
  74. console.log("TRACE: In success function for the GET getServiceConfigsFromServer call");
  75. var configs = data.items.findProperty('tag', this.get('tag')).properties;
  76. if (configs && configs['security_enabled'] === 'true') {
  77. this.set('securityEnabled', true);
  78. }
  79. else {
  80. this.loadUsers(configs);
  81. this.set('securityEnabled', false);
  82. }
  83. this.get('deferred').resolve();
  84. },
  85. loadUsers: function (configs) {
  86. var serviceUsers = this.get('serviceUsers');
  87. serviceUsers.pushObject({
  88. id: 'puppet var',
  89. name: 'hdfs_user',
  90. value: configs['hdfs_user'] ? configs['hdfs_user'] : 'hdfs'
  91. });
  92. serviceUsers.pushObject({
  93. id: 'puppet var',
  94. name: 'mapred_user',
  95. value: configs['mapred_user'] ? configs['mapred_user'] : 'mapred'
  96. });
  97. serviceUsers.pushObject({
  98. id: 'puppet var',
  99. name: 'hbase_user',
  100. value: configs['hbase_user'] ? configs['hbase_user'] : 'hbase'
  101. });
  102. serviceUsers.pushObject({
  103. id: 'puppet var',
  104. name: 'hive_user',
  105. value: configs['hive_user'] ? configs['hive_user'] : 'hive'
  106. });
  107. }
  108. });