storm.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with this
  4. * work for additional information regarding copyright ownership. The ASF
  5. * licenses this file to you under the Apache License, Version 2.0 (the
  6. * "License"); you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  13. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  14. * License for the specific language governing permissions and limitations under
  15. * the License.
  16. */
  17. var App = require('app');
  18. require('utils/configs/modification_handlers/modification_handler');
  19. module.exports = App.ServiceConfigModificationHandler.create({
  20. serviceId : 'STORM',
  21. getConfig : function(allConfigs, configName, configFilename, configServiceName) {
  22. return allConfigs.findProperty("serviceName", configServiceName).get("configs").find(function(config) {
  23. return configName == config.get('name') && (configFilename == null || configFilename == config.get('filename'));
  24. });
  25. },
  26. getDependentConfigChanges : function(changedConfig, selectedServices, allConfigs, securityEnabled) {
  27. var affectedProperties = [];
  28. var newValue = changedConfig.get("value");
  29. var rangerPluginEnablePropertyName = "ranger-storm-plugin-enabled";
  30. var affectedPropertyName = changedConfig.get("name");
  31. if (affectedPropertyName == rangerPluginEnablePropertyName) {
  32. var authEnabled = newValue == "Yes";
  33. var configNimbusAuthorizer = this.getConfig(allConfigs, 'nimbus.authorizer', 'storm-site.xml', 'STORM');
  34. if (configNimbusAuthorizer != null) {
  35. // Only when configuration is already present, do we act on it.
  36. // Unsecured clusters do not have this config, and hence we skip any
  37. // updates
  38. var newNimbusAuthorizer = authEnabled ? "com.xasecure.authorization.storm.authorizer.XaSecureStormAuthorizer"
  39. : "backtype.storm.security.auth.authorizer.SimpleACLAuthorizer";
  40. // Add Hive-Ranger configs
  41. if (newNimbusAuthorizer !== configNimbusAuthorizer.get('value')) {
  42. affectedProperties.push({
  43. serviceName : "STORM",
  44. sourceServiceName : "STORM",
  45. propertyName : 'nimbus.authorizer',
  46. propertyDisplayName : 'nimbus.authorizer',
  47. newValue : newNimbusAuthorizer,
  48. curValue : configNimbusAuthorizer.get('value'),
  49. changedPropertyName : rangerPluginEnablePropertyName,
  50. removed : false,
  51. filename : 'storm-site.xml'
  52. });
  53. }
  54. }
  55. if (authEnabled && affectedProperties.length < 1 && !securityEnabled) {
  56. App.ModalPopup.show({
  57. header : Em.I18n.t('services.storm.configs.range-plugin-enable.dialog.title'),
  58. primary : Em.I18n.t('ok'),
  59. secondary : false,
  60. showCloseButton : false,
  61. onPrimary : function() {
  62. this.hide();
  63. },
  64. body : Em.I18n.t('services.storm.configs.range-plugin-enable.dialog.message')
  65. });
  66. }
  67. }
  68. return affectedProperties;
  69. }
  70. });