params.py 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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.libraries.functions.default import default
  19. from resource_management import *
  20. import status_params
  21. # server configurations
  22. config = Script.get_config()
  23. tmp_dir = Script.get_tmp_dir()
  24. stack_version_unformatted = str(config['hostLevelParams']['stack_version'])
  25. hdp_stack_version = format_hdp_stack_version(stack_version_unformatted)
  26. # New Cluster Stack Version that is defined during the RESTART of a Rolling Upgrade
  27. version = default("/commandParams/version", None)
  28. #hadoop params
  29. if hdp_stack_version != "" and compare_versions(hdp_stack_version, '2.2') >= 0:
  30. role_root = ""
  31. command_role = default("/role", "")
  32. if command_role == "ZOOKEEPER_SERVER":
  33. role_root = "zookeeper-server"
  34. elif command_role == "ZOOKEEPER_CLIENT":
  35. role_root = "zookeeper-client"
  36. zk_home = format("/usr/hdp/current/{role_root}")
  37. zk_bin = format("/usr/hdp/current/{role_root}/bin")
  38. zk_cli_shell = format("/usr/hdp/current/{role_root}/bin/zkCli.sh")
  39. else:
  40. zk_home = "/usr"
  41. zk_bin = "/usr/lib/zookeeper/bin"
  42. zk_cli_shell = "/usr/lib/zookeeper/bin/zkCli.sh"
  43. config_dir = "/etc/zookeeper/conf"
  44. zk_user = config['configurations']['zookeeper-env']['zk_user']
  45. hostname = config['hostname']
  46. user_group = config['configurations']['cluster-env']['user_group']
  47. zk_env_sh_template = config['configurations']['zookeeper-env']['content']
  48. zk_log_dir = config['configurations']['zookeeper-env']['zk_log_dir']
  49. zk_data_dir = config['configurations']['zoo.cfg']['dataDir']
  50. zk_pid_dir = status_params.zk_pid_dir
  51. zk_pid_file = status_params.zk_pid_file
  52. zk_server_heapsize = "-Xmx1024m"
  53. clientPort = config['configurations']['zoo.cfg']['clientPort']
  54. if 'zoo.cfg' in config['configurations']:
  55. zoo_cfg_properties_map = config['configurations']['zoo.cfg']
  56. else:
  57. zoo_cfg_properties_map = {}
  58. zoo_cfg_properties_map_length = len(zoo_cfg_properties_map)
  59. zk_principal_name = default("/configurations/zookeeper-env/zookeeper_principal_name", "zookeeper@EXAMPLE.COM")
  60. zk_principal = zk_principal_name.replace('_HOST',hostname.lower())
  61. java64_home = config['hostLevelParams']['java_home']
  62. zookeeper_hosts = config['clusterHostInfo']['zookeeper_hosts']
  63. zookeeper_hosts.sort()
  64. zk_keytab_path = config['configurations']['zookeeper-env']['zookeeper_keytab_path']
  65. zk_server_jaas_file = format("{config_dir}/zookeeper_jaas.conf")
  66. zk_client_jaas_file = format("{config_dir}/zookeeper_client_jaas.conf")
  67. security_enabled = config['configurations']['cluster-env']['security_enabled']
  68. smoke_user_keytab = config['configurations']['cluster-env']['smokeuser_keytab']
  69. smokeuser = config['configurations']['cluster-env']['smokeuser']
  70. kinit_path_local = functions.get_kinit_path(["/usr/bin", "/usr/kerberos/bin", "/usr/sbin"])
  71. #log4j.properties
  72. if (('zookeeper-log4j' in config['configurations']) and ('content' in config['configurations']['zookeeper-log4j'])):
  73. log4j_props = config['configurations']['zookeeper-log4j']['content']
  74. else:
  75. log4j_props = None