params.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. from resource_management.libraries.functions.version import format_hdp_stack_version, compare_versions
  18. from resource_management import *
  19. # server configurations
  20. config = Script.get_config()
  21. # This is expected to be of the form #.#.#.#
  22. hdp_stack_version = str(config['hostLevelParams']['stack_version'])
  23. hdp_stack_version = format_hdp_stack_version(hdp_stack_version)
  24. # New Cluster Stack Version that is defined during the RESTART of a Rolling Upgrade
  25. version = default("/commandParams/version", None)
  26. if hdp_stack_version != "" and compare_versions(hdp_stack_version, '2.2') >= 0:
  27. hadoop_bin_dir = "/usr/hdp/current/hadoop-client/bin"
  28. else:
  29. hadoop_bin_dir = "/usr/bin"
  30. hadoop_conf_dir = "/etc/hadoop/conf"
  31. kinit_path_local = functions.get_kinit_path(["/usr/bin", "/usr/kerberos/bin", "/usr/sbin"])
  32. security_enabled = config['configurations']['cluster-env']['security_enabled']
  33. hdfs_user = config['configurations']['hadoop-env']['hdfs_user']
  34. hdfs_principal_name = config['configurations']['hadoop-env']['hdfs_principal_name']
  35. hdfs_user_keytab = config['configurations']['hadoop-env']['hdfs_user_keytab']
  36. config_dir_prefix = "/etc/tez"
  37. config_dir = format("{config_dir_prefix}/conf")
  38. hadoop_home = '/usr'
  39. java64_home = config['hostLevelParams']['java_home']
  40. tez_user = config['configurations']['tez-env']['tez_user']
  41. user_group = config['configurations']['cluster-env']['user_group']
  42. tez_env_sh_template = config['configurations']['tez-env']['content']
  43. import functools
  44. # Create partial functions with common arguments for every HdfsDirectory call
  45. # to create hdfs directory we need to call params.HdfsDirectory in code
  46. HdfsDirectory = functools.partial(
  47. HdfsDirectory,
  48. conf_dir=hadoop_conf_dir,
  49. hdfs_user=hdfs_principal_name if security_enabled else hdfs_user,
  50. security_enabled=security_enabled,
  51. keytab=hdfs_user_keytab,
  52. kinit_path_local=kinit_path_local,
  53. bin_dir=hadoop_bin_dir
  54. )