params.py 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. config = Script.get_config()
  22. tmp_dir = Script.get_tmp_dir()
  23. stack_name = default("/hostLevelParams/stack_name", None)
  24. stack_version_unformatted = str(config['hostLevelParams']['stack_version'])
  25. hdp_stack_version = format_hdp_stack_version(stack_version_unformatted)
  26. if hdp_stack_version != "" and compare_versions(hdp_stack_version, '2.2') >= 0:
  27. knox_bin = '/usr/hdp/current/knox-server/bin/gateway.sh'
  28. ldap_bin = '/usr/hdp/current/knox-server/bin/ldap.sh'
  29. knox_client_bin = '/usr/hdp/current/knox-server/bin/knoxcli.sh'
  30. else:
  31. knox_bin = '/usr/bin/gateway'
  32. ldap_bin = '/usr/lib/knox/bin/ldap.sh'
  33. knox_client_bin = '/usr/lib/knox/bin/knoxcli.sh'
  34. namenode_hosts = default("/clusterHostInfo/namenode_host", None)
  35. if type(namenode_hosts) is list:
  36. namenode_host = namenode_hosts[0]
  37. else:
  38. namenode_host = namenode_hosts
  39. has_namenode = not namenode_host == None
  40. namenode_http_port = "50070"
  41. namenode_rpc_port = "8020"
  42. if has_namenode:
  43. if 'dfs.namenode.http-address' in config['configurations']['hdfs-site']:
  44. namenode_http_port = get_port_from_url(config['configurations']['hdfs-site']['dfs.namenode.http-address'])
  45. if 'dfs.namenode.rpc-address' in config['configurations']['hdfs-site']:
  46. namenode_rpc_port = get_port_from_url(config['configurations']['hdfs-site']['dfs.namenode.rpc-address'])
  47. rm_hosts = default("/clusterHostInfo/rm_host", None)
  48. if type(rm_hosts) is list:
  49. rm_host = rm_hosts[0]
  50. else:
  51. rm_host = rm_hosts
  52. has_rm = not rm_host == None
  53. jt_rpc_port = "8050"
  54. rm_port = "8080"
  55. if has_rm:
  56. if 'yarn.resourcemanager.address' in config['configurations']['yarn-site']:
  57. jt_rpc_port = get_port_from_url(config['configurations']['yarn-site']['yarn.resourcemanager.address'])
  58. if 'yarn.resourcemanager.webapp.address' in config['configurations']['yarn-site']:
  59. rm_port = get_port_from_url(config['configurations']['yarn-site']['yarn.resourcemanager.webapp.address'])
  60. hive_http_port = default('/configurations/hive-site/hive.server2.thrift.http.port', "10001")
  61. hive_http_path = default('/configurations/hive-site/hive.server2.thrift.http.path', "cliservice")
  62. hive_server_hosts = default("/clusterHostInfo/hive_server_host", None)
  63. if type(hive_server_hosts) is list:
  64. hive_server_host = hive_server_hosts[0]
  65. else:
  66. hive_server_host = hive_server_hosts
  67. templeton_port = default('/configurations/webhcat-site/templeton.port', "50111")
  68. webhcat_server_hosts = default("/clusterHostInfo/webhcat_server_host", None)
  69. if type(webhcat_server_hosts) is list:
  70. webhcat_server_host = webhcat_server_hosts[0]
  71. else:
  72. webhcat_server_host = webhcat_server_hosts
  73. hbase_master_port = default('/configurations/hbase-site/hbase.rest.port', "8080")
  74. hbase_master_hosts = default("/clusterHostInfo/hbase_master_hosts", None)
  75. if type(hbase_master_hosts) is list:
  76. hbase_master_host = hbase_master_hosts[0]
  77. else:
  78. hbase_master_host = hbase_master_hosts
  79. oozie_server_hosts = default("/clusterHostInfo/oozie_server", None)
  80. if type(oozie_server_hosts) is list:
  81. oozie_server_host = oozie_server_hosts[0]
  82. else:
  83. oozie_server_host = oozie_server_hosts
  84. has_oozie = not oozie_server_host == None
  85. oozie_server_port = "11000"
  86. if has_oozie:
  87. if 'oozie.base.url' in config['configurations']['oozie-site']:
  88. oozie_server_port = get_port_from_url(config['configurations']['oozie-site']['oozie.base.url'])
  89. # server configurations
  90. knox_conf_dir = '/etc/knox/conf'
  91. knox_data_dir = '/var/lib/knox/data'
  92. knox_logs_dir = '/var/log/knox'
  93. knox_pid_dir = status_params.knox_pid_dir
  94. knox_user = default("/configurations/knox-env/knox_user", "knox")
  95. knox_group = default("/configurations/knox-env/knox_group", "knox")
  96. knox_pid_file = status_params.knox_pid_file
  97. ldap_pid_file = status_params.ldap_pid_file
  98. knox_master_secret = config['configurations']['knox-env']['knox_master_secret']
  99. knox_master_secret_path = '/var/lib/knox/data/security/master'
  100. knox_cert_store_path = '/var/lib/knox/data/security/keystores/gateway.jks'
  101. knox_host_name = config['clusterHostInfo']['knox_gateway_hosts'][0]
  102. knox_host_name_in_cluster = config['hostname']
  103. knox_host_port = config['configurations']['gateway-site']['gateway.port']
  104. topology_template = config['configurations']['topology']['content']
  105. gateway_log4j = config['configurations']['gateway-log4j']['content']
  106. ldap_log4j = config['configurations']['ldap-log4j']['content']
  107. users_ldif = config['configurations']['users-ldif']['content']
  108. java_home = config['hostLevelParams']['java_home']
  109. security_enabled = config['configurations']['cluster-env']['security_enabled']
  110. smokeuser = config['configurations']['cluster-env']['smokeuser']
  111. smoke_user_keytab = config['configurations']['cluster-env']['smokeuser_keytab']
  112. kinit_path_local = functions.get_kinit_path(["/usr/bin", "/usr/kerberos/bin", "/usr/sbin"])
  113. if security_enabled:
  114. knox_keytab_path = config['configurations']['knox-env']['knox_keytab_path']
  115. _hostname_lowercase = config['hostname'].lower()
  116. knox_principal_name = config['configurations']['knox-env']['knox_principal_name'].replace('_HOST',_hostname_lowercase)