config_mapping.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. var configs = [
  20. /**********************************************core-site***************************************/
  21. {
  22. "name": "hadoop.proxyuser.<foreignKey[0]>.groups",
  23. "templateName": ["proxyuser_group"],
  24. "foreignKey": ["hive_user"],
  25. "value": "<templateName[0]>",
  26. "filename": "core-site.xml",
  27. "isOverridable": true
  28. },
  29. {
  30. "name": "hadoop.proxyuser.<foreignKey[0]>.hosts",
  31. "templateName": ["hivemetastore_host"],
  32. "foreignKey": ["hive_user"],
  33. "value": "<templateName[0]>",
  34. "filename": "core-site.xml",
  35. "isOverridable": true
  36. },
  37. {
  38. "name": "hadoop.proxyuser.<foreignKey[0]>.groups",
  39. "templateName": ["proxyuser_group"],
  40. "foreignKey": ["oozie_user"],
  41. "value": "<templateName[0]>",
  42. "filename": "core-site.xml",
  43. "isOverridable": true
  44. },
  45. {
  46. "name": "hadoop.proxyuser.<foreignKey[0]>.hosts",
  47. "templateName": ["oozieserver_host"],
  48. "foreignKey": ["oozie_user"],
  49. "value": "<templateName[0]>",
  50. "filename": "core-site.xml",
  51. "isOverridable": true
  52. },
  53. {
  54. "name": "hadoop.proxyuser.<foreignKey[0]>.groups",
  55. "templateName": ["proxyuser_group"],
  56. "foreignKey": ["webhcat_user"],
  57. "value": "<templateName[0]>",
  58. "filename": "core-site.xml",
  59. "isOverridable": true
  60. },
  61. {
  62. "name": "hadoop.proxyuser.<foreignKey[0]>.hosts",
  63. "templateName": ["hivemetastore_host"],
  64. "foreignKey": ["webhcat_user"],
  65. "value": "<templateName[0]>",
  66. "filename": "core-site.xml",
  67. "isOverridable": true
  68. },
  69. {
  70. "name": "hadoop.proxyuser.<foreignKey[0]>.groups",
  71. "templateName": ["proxyuser_group"],
  72. "foreignKey": ["falcon_user"],
  73. "value": "<templateName[0]>",
  74. "filename": "core-site.xml",
  75. "isOverridable": true
  76. },
  77. {
  78. "name": "hadoop.proxyuser.<foreignKey[0]>.hosts",
  79. "templateName": ["falconserver_host"],
  80. "foreignKey": ["falcon_user"],
  81. "value": "<templateName[0]>",
  82. "filename": "core-site.xml",
  83. "isOverridable": true
  84. },
  85. /********************GLUSTERFS*************************************/
  86. {
  87. "name": "fs.glusterfs.impl",
  88. "templateName": ["fs_glusterfs_impl"],
  89. "foreignKey": null,
  90. "value": "<templateName[0]>",
  91. "filename": "core-site.xml",
  92. "serviceName": "GLUSTERFS"
  93. },
  94. {
  95. "name": "fs.glusterfs.volname",
  96. "templateName": ["fs_glusterfs_volname"],
  97. "foreignKey": null,
  98. "value": "<templateName[0]>",
  99. "filename": "core-site.xml",
  100. "serviceName": "GLUSTERFS"
  101. },
  102. {
  103. "name": "fs.glusterfs.mount",
  104. "templateName": ["fs_glusterfs_mount"],
  105. "foreignKey": null,
  106. "value": "<templateName[0]>",
  107. "filename": "core-site.xml",
  108. "serviceName": "GLUSTERFS"
  109. },
  110. {
  111. "name": "fs.glusterfs.getfattrcmd",
  112. "templateName": ["fs_glusterfs_getfattrcmd"],
  113. "foreignKey": null,
  114. "value": "<templateName[0]>",
  115. "filename": "core-site.xml",
  116. "serviceName": "GLUSTERFS"
  117. },
  118. {
  119. "name": "fs.AbstractFileSystem.glusterfs.impl",
  120. "templateName": ["fs_AbstractFileSystem_glusterfs_impl"],
  121. "foreignKey": null,
  122. "value": "<templateName[0]>",
  123. "filename": "core-site.xml",
  124. "serviceName": "GLUSTERFS"
  125. },
  126. {
  127. "name": "gluster.daemon.user",
  128. "templateName": ["gluster_daemon_user"],
  129. "foreignKey": null,
  130. "value": "<templateName[0]>",
  131. "filename": "core-site.xml",
  132. "serviceName": "GLUSTERFS"
  133. }
  134. ];
  135. /**
  136. * Configs consists of 2 types: Computed values, which cannot be modified by user
  137. * and overridable values, which user can modify. We provide interface how to get all of this
  138. * configs separately
  139. * @type {Object}
  140. */
  141. module.exports = {
  142. checkPrecondition: function () {
  143. return configs.filter(function (config) {
  144. return ((!config.precondition) || (config.precondition()));
  145. });
  146. },
  147. all: function (skipPreconditionCheck) {
  148. if (skipPreconditionCheck) {
  149. return configs.slice(0);
  150. } else {
  151. return this.checkPrecondition().slice(0);
  152. }
  153. },
  154. overridable: function (skipPreconditionCheck) {
  155. if (skipPreconditionCheck) {
  156. return configs.filterProperty('foreignKey');
  157. } else {
  158. return this.checkPrecondition().filterProperty('foreignKey');
  159. }
  160. },
  161. computed: function (skipPreconditionCheck) {
  162. if (skipPreconditionCheck) {
  163. return configs.filterProperty('foreignKey', null);
  164. } else {
  165. return this.checkPrecondition().filterProperty('foreignKey', null);
  166. }
  167. }
  168. };