stack_features.py 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. from resource_management.libraries.script import Script
  20. from resource_management.libraries.functions.default import default
  21. from resource_management.libraries.functions.version import compare_versions
  22. _DEFAULT_STACK_FEATURES = {
  23. "stack_features": [
  24. {
  25. "name": "snappy",
  26. "description": "Snappy compressor/decompressor support",
  27. "min_version": "2.0.0.0",
  28. "max_version": "2.2.0.0"
  29. },
  30. {
  31. "name": "express_upgrade",
  32. "description": "Express upgrade support",
  33. "min_version": "2.1.0.0"
  34. },
  35. {
  36. "name": "rolling_upgrade",
  37. "description": "Rolling upgrade support",
  38. "min_version": "2.2.0.0"
  39. },
  40. {
  41. "name": "config_versioning",
  42. "description": "Configurable versions support",
  43. "min_version": "2.3.0.0"
  44. },
  45. {
  46. "name": "datanode_non_root",
  47. "description": "DataNode running as non-root support (AMBARI-7615)",
  48. "min_version": "2.2.0.0"
  49. },
  50. {
  51. "name": "remove_ranger_hdfs_plugin_env",
  52. "description": "HDFS removes Ranger env files (AMBARI-14299)",
  53. "min_version": "2.3.0.0"
  54. },
  55. {
  56. "name": "ranger",
  57. "description": "Ranger Service support",
  58. "min_version": "2.2.0.0"
  59. },
  60. {
  61. "name": "phoenix",
  62. "description": "Phoenix Service support",
  63. "min_version": "2.3.0.0"
  64. },
  65. {
  66. "name": "nfs",
  67. "description": "NFS support",
  68. "min_version": "2.3.0.0"
  69. },
  70. {
  71. "name": "tez_for_spark",
  72. "description": "Tez dependency for Spark",
  73. "min_version": "2.2.0.0",
  74. "max_version": "2.3.0.0"
  75. },
  76. {
  77. "name": "timeline_state_store",
  78. "description": "Yarn application timeline-service supports state store property (AMBARI-11442)",
  79. "min_version": "2.2.0.0"
  80. },
  81. {
  82. "name": "copy_tarball_to_hdfs",
  83. "description": "Copy tarball to HDFS support (AMBARI-12113)",
  84. "min_version": "2.2.0.0"
  85. },
  86. {
  87. "name": "spark_16plus",
  88. "description": "Spark 1.6+",
  89. "min_version": "2.4.0.0"
  90. },
  91. {
  92. "name": "spark_thriftserver",
  93. "description": "Spark Thrift Server",
  94. "min_version": "2.3.2.0"
  95. },
  96. {
  97. "name": "storm_kerberos",
  98. "description": "Storm Kerberos support (AMBARI-7570)",
  99. "min_version": "2.2.0.0"
  100. },
  101. {
  102. "name": "storm_ams",
  103. "description": "Storm AMS integration (AMBARI-10710)",
  104. "min_version": "2.2.0.0"
  105. },
  106. {
  107. "name": "create_kafka_broker_id",
  108. "description": "Ambari should create Kafka Broker Id (AMBARI-12678)",
  109. "min_version": "2.2.0.0",
  110. "max_version": "2.3.0.0"
  111. },
  112. {
  113. "name": "kafka_listeners",
  114. "description": "Kafka listeners (AMBARI-10984)",
  115. "min_version": "2.3.0.0"
  116. },
  117. {
  118. "name": "kafka_kerberos",
  119. "description": "Kafka Kerberos support (AMBARI-10984)",
  120. "min_version": "2.3.0.0"
  121. },
  122. {
  123. "name": "pig_on_tez",
  124. "description": "Pig on Tez support (AMBARI-7863)",
  125. "min_version": "2.2.0.0"
  126. },
  127. {
  128. "name": "ranger_usersync_non_root",
  129. "description": "Ranger Usersync as non-root user (AMBARI-10416)",
  130. "min_version": "2.3.0.0"
  131. }
  132. ]
  133. }
  134. def check_stack_feature(stack_feature, stack_version):
  135. """
  136. Given a stack_feature and a specific stack_version, it validates that the feature is supported by the stack_version.
  137. :param stack_feature: Feature name to check if it is supported by the stack. For example: "rolling_upgrade"
  138. :param stack_version: Version of the stack
  139. :return: Will return True if successful, otherwise, False.
  140. """
  141. stack_features_config = default("/configurations/cluster-env/stack_features", None)
  142. data = _DEFAULT_STACK_FEATURES
  143. if stack_features_config:
  144. data = json.loads(stack_features_config)
  145. for feature in data["stack_features"]:
  146. if feature["name"] == stack_feature:
  147. if "min_version" in feature:
  148. min_version = feature["min_version"]
  149. if compare_versions(stack_version, min_version, format = True) < 0:
  150. return False
  151. if "max_version" in feature:
  152. max_version = feature["max_version"]
  153. if compare_versions(stack_version, max_version, format = True) >= 0:
  154. return False
  155. return True
  156. return False