params.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. http://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing, software
  11. distributed under the License is distributed on an "AS IS" BASIS,
  12. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. See the License for the specific language governing permissions and
  14. limitations under the License.
  15. Ambari Agent
  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. tmp_dir = Script.get_tmp_dir()
  22. hdp_stack_version = str(config['hostLevelParams']['stack_version'])
  23. hdp_stack_version = format_hdp_stack_version(hdp_stack_version)
  24. #hadoop params
  25. if hdp_stack_version != "" and compare_versions(hdp_stack_version, '2.2') >= 0:
  26. hadoop_bin_dir = "/usr/hdp/current/hadoop-client/bin"
  27. hadoop_home = '/usr/hdp/current/hadoop-client'
  28. pig_bin_dir = '/usr/hdp/current/pig-client/bin'
  29. else:
  30. hadoop_bin_dir = "/usr/bin"
  31. hadoop_home = '/usr'
  32. pig_bin_dir = ""
  33. hadoop_conf_dir = "/etc/hadoop/conf"
  34. pig_conf_dir = "/etc/pig/conf"
  35. hdfs_user = config['configurations']['hadoop-env']['hdfs_user']
  36. hdfs_principal_name = config['configurations']['hadoop-env']['hdfs_principal_name']
  37. hdfs_user_keytab = config['configurations']['hadoop-env']['hdfs_user_keytab']
  38. smokeuser = config['configurations']['cluster-env']['smokeuser']
  39. user_group = config['configurations']['cluster-env']['user_group']
  40. security_enabled = config['configurations']['cluster-env']['security_enabled']
  41. smoke_user_keytab = config['configurations']['cluster-env']['smokeuser_keytab']
  42. kinit_path_local = functions.get_kinit_path(["/usr/bin", "/usr/kerberos/bin", "/usr/sbin"])
  43. pig_env_sh_template = config['configurations']['pig-env']['content']
  44. # not supporting 32 bit jdk.
  45. java64_home = config['hostLevelParams']['java_home']
  46. pig_properties = config['configurations']['pig-properties']['content']
  47. log4j_props = config['configurations']['pig-log4j']['content']
  48. import functools
  49. #create partial functions with common arguments for every HdfsDirectory call
  50. #to create hdfs directory we need to call params.HdfsDirectory in code
  51. HdfsDirectory = functools.partial(
  52. HdfsDirectory,
  53. conf_dir=hadoop_conf_dir,
  54. hdfs_user=hdfs_principal_name if security_enabled else hdfs_user,
  55. security_enabled = security_enabled,
  56. keytab = hdfs_user_keytab,
  57. kinit_path_local = kinit_path_local,
  58. bin_dir = hadoop_bin_dir
  59. )