stack_features.py 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. #!/usr/bin/env python
  2. """
  3. Licensed to the Apache Software Foundation (ASF) under one
  4. or more contributor license agreements. See the NOTICE file
  5. distributed with this work for additional information
  6. regarding copyright ownership. The ASF licenses this file
  7. to you under the Apache License, Version 2.0 (the
  8. "License"); you may not use this file except in compliance
  9. with the License. You may obtain a copy of the License at
  10. http://www.apache.org/licenses/LICENSE-2.0
  11. Unless required by applicable law or agreed to in writing, software
  12. distributed under the License is distributed on an "AS IS" BASIS,
  13. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. See the License for the specific language governing permissions and
  15. limitations under the License.
  16. """
  17. # simplejson is much faster comparing to Python 2.6 json module and has the same functions set.
  18. import ambari_simplejson as json
  19. _DEFAULT_STACK_FEATURES = {
  20. "stack_features": [
  21. {
  22. "name": "snappy",
  23. "description": "Snappy compressor/decompressor support",
  24. "min_version": "2.0.0.0",
  25. "max_version": "2.2.0.0"
  26. },
  27. {
  28. "name": "lzo",
  29. "description": "LZO libraries support",
  30. "min_version": "2.2.1.0"
  31. },
  32. {
  33. "name": "express_upgrade",
  34. "description": "Express upgrade support",
  35. "min_version": "2.1.0.0"
  36. },
  37. {
  38. "name": "rolling_upgrade",
  39. "description": "Rolling upgrade support",
  40. "min_version": "2.2.0.0"
  41. },
  42. {
  43. "name": "config_versioning",
  44. "description": "Configurable versions support",
  45. "min_version": "2.3.0.0"
  46. },
  47. {
  48. "name": "datanode_non_root",
  49. "description": "DataNode running as non-root support (AMBARI-7615)",
  50. "min_version": "2.2.0.0"
  51. },
  52. {
  53. "name": "remove_ranger_hdfs_plugin_env",
  54. "description": "HDFS removes Ranger env files (AMBARI-14299)",
  55. "min_version": "2.3.0.0"
  56. },
  57. {
  58. "name": "ranger",
  59. "description": "Ranger Service support",
  60. "min_version": "2.2.0.0"
  61. },
  62. {
  63. "name": "ranger_tagsync_component",
  64. "description": "Ranger Tagsync component support (AMBARI-14383)",
  65. "min_version": "2.5.0.0"
  66. },
  67. {
  68. "name": "phoenix",
  69. "description": "Phoenix Service support",
  70. "min_version": "2.3.0.0"
  71. },
  72. {
  73. "name": "nfs",
  74. "description": "NFS support",
  75. "min_version": "2.3.0.0"
  76. },
  77. {
  78. "name": "tez_for_spark",
  79. "description": "Tez dependency for Spark",
  80. "min_version": "2.2.0.0",
  81. "max_version": "2.3.0.0"
  82. },
  83. {
  84. "name": "timeline_state_store",
  85. "description": "Yarn application timeline-service supports state store property (AMBARI-11442)",
  86. "min_version": "2.2.0.0"
  87. },
  88. {
  89. "name": "copy_tarball_to_hdfs",
  90. "description": "Copy tarball to HDFS support (AMBARI-12113)",
  91. "min_version": "2.2.0.0"
  92. },
  93. {
  94. "name": "spark_16plus",
  95. "description": "Spark 1.6+",
  96. "min_version": "2.4.0.0"
  97. },
  98. {
  99. "name": "spark_thriftserver",
  100. "description": "Spark Thrift Server",
  101. "min_version": "2.3.2.0"
  102. },
  103. {
  104. "name": "storm_kerberos",
  105. "description": "Storm Kerberos support (AMBARI-7570)",
  106. "min_version": "2.2.0.0"
  107. },
  108. {
  109. "name": "storm_ams",
  110. "description": "Storm AMS integration (AMBARI-10710)",
  111. "min_version": "2.2.0.0"
  112. },
  113. {
  114. "name": "create_kafka_broker_id",
  115. "description": "Ambari should create Kafka Broker Id (AMBARI-12678)",
  116. "min_version": "2.2.0.0",
  117. "max_version": "2.3.0.0"
  118. },
  119. {
  120. "name": "kafka_listeners",
  121. "description": "Kafka listeners (AMBARI-10984)",
  122. "min_version": "2.3.0.0"
  123. },
  124. {
  125. "name": "kafka_kerberos",
  126. "description": "Kafka Kerberos support (AMBARI-10984)",
  127. "min_version": "2.3.0.0"
  128. },
  129. {
  130. "name": "pig_on_tez",
  131. "description": "Pig on Tez support (AMBARI-7863)",
  132. "min_version": "2.2.0.0"
  133. },
  134. {
  135. "name": "ranger_usersync_non_root",
  136. "description": "Ranger Usersync as non-root user (AMBARI-10416)",
  137. "min_version": "2.3.0.0"
  138. },
  139. {
  140. "name": "ranger_audit_db_support",
  141. "description": "Ranger Audit to DB support",
  142. "min_version": "2.2.0.0",
  143. "max_version": "2.5.0.0"
  144. },
  145. {
  146. "name": "accumulo_kerberos_user_auth",
  147. "description": "Accumulo Kerberos User Auth (AMBARI-10163)",
  148. "min_version": "2.3.0.0"
  149. },
  150. {
  151. "name": "knox_versioned_data_dir",
  152. "description": "Use versioned data dir for Knox (AMBARI-13164)",
  153. "min_version": "2.3.2.0"
  154. },
  155. {
  156. "name": "knox_sso_topology",
  157. "description": "Knox SSO Topology support (AMBARI-13975)",
  158. "min_version": "2.3.8.0"
  159. },
  160. {
  161. "name": "atlas_rolling_upgrade",
  162. "description": "Rolling upgrade support for Atlas",
  163. "min_version": "2.3.0.0"
  164. },
  165. {
  166. "name": "oozie_admin_user",
  167. "description": "Oozie install user as an Oozie admin user (AMBARI-7976)",
  168. "min_version": "2.2.0.0"
  169. },
  170. {
  171. "name": "oozie_create_hive_tez_configs",
  172. "description": "Oozie create configs for Ambari Hive and Tez deployments (AMBARI-8074)",
  173. "min_version": "2.2.0.0"
  174. },
  175. {
  176. "name": "oozie_setup_shared_lib",
  177. "description": "Oozie setup tools used to shared Oozie lib to HDFS (AMBARI-7240)",
  178. "min_version": "2.2.0.0"
  179. },
  180. {
  181. "name": "oozie_host_kerberos",
  182. "description": "Oozie in secured clusters uses _HOST in Kerberos principal (AMBARI-9775)",
  183. "min_version": "2.0.0.0",
  184. "max_version": "2.2.0.0"
  185. },
  186. {
  187. "name": "hive_metastore_upgrade_schema",
  188. "description": "Hive metastore upgrade schema support (AMBARI-11176)",
  189. "min_version": "2.3.0.0"
  190. },
  191. {
  192. "name": "hive_server_interactive",
  193. "description": "Hive server interactive support (AMBARI-15573)",
  194. "min_version": "2.5.0.0"
  195. },
  196. {
  197. "name": "hive_webhcat_specific_configs",
  198. "description": "Hive webhcat specific configurations support (AMBARI-12364)",
  199. "min_version": "2.3.0.0"
  200. },
  201. {
  202. "name": "hive_purge_table",
  203. "description": "Hive purge table support (AMBARI-12260)",
  204. "min_version": "2.3.0.0"
  205. },
  206. {
  207. "name": "hive_server2_kerberized_env",
  208. "description": "Hive server2 working on kerberized environment (AMBARI-13749)",
  209. "min_version": "2.2.3.0",
  210. "max_version": "2.2.5.0"
  211. },
  212. {
  213. "name": "hive_env_heapsize",
  214. "description": "Hive heapsize property defined in hive-env (AMBARI-12801)",
  215. "min_version": "2.2.0.0"
  216. },
  217. {
  218. "name": "ranger_kms_hsm_support",
  219. "description": "Ranger KMS HSM support (AMBARI-15752)",
  220. "min_version": "2.5.0.0"
  221. },
  222. {
  223. "name": "ranger_log4j_support",
  224. "description": "Ranger supporting log-4j properties (AMBARI-15681)",
  225. "min_version": "2.5.0.0"
  226. },
  227. {
  228. "name": "ranger_kerberos_support",
  229. "description": "Ranger Kerberos support",
  230. "min_version": "2.5.0.0"
  231. },
  232. {
  233. "name": "ranger_usersync_password_jceks",
  234. "description": "Saving Ranger Usersync credentials in jceks",
  235. "min_version": "2.5.0.0"
  236. },
  237. {
  238. "name": "logsearch_support",
  239. "description": "LogSearch Service support",
  240. "min_version": "2.5.0.0"
  241. },
  242. {
  243. "name": "hbase_home_directory",
  244. "description": "Hbase home directory in HDFS needed for HBASE backup",
  245. "min_version": "2.5.0.0"
  246. },
  247. {
  248. "name": "spark_livy",
  249. "description": "Livy as slave component of spark",
  250. "min_version": "2.5.0.0"
  251. }
  252. ]
  253. }
  254. def check_stack_feature(stack_feature, stack_version):
  255. """
  256. Given a stack_feature and a specific stack_version, it validates that the feature is supported by the stack_version.
  257. :param stack_feature: Feature name to check if it is supported by the stack. For example: "rolling_upgrade"
  258. :param stack_version: Version of the stack
  259. :return: Will return True if successful, otherwise, False.
  260. """
  261. from resource_management.libraries.functions.default import default
  262. from resource_management.libraries.functions.version import compare_versions
  263. stack_features_config = default("/configurations/cluster-env/stack_features", None)
  264. data = _DEFAULT_STACK_FEATURES
  265. if not stack_version:
  266. return False
  267. if stack_features_config:
  268. data = json.loads(stack_features_config)
  269. for feature in data["stack_features"]:
  270. if feature["name"] == stack_feature:
  271. if "min_version" in feature:
  272. min_version = feature["min_version"]
  273. if compare_versions(stack_version, min_version, format = True) < 0:
  274. return False
  275. if "max_version" in feature:
  276. max_version = feature["max_version"]
  277. if compare_versions(stack_version, max_version, format = True) >= 0:
  278. return False
  279. return True
  280. return False