params.py 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 import *
  18. from resource_management.libraries.functions import conf_select
  19. from resource_management.libraries.functions import stack_select
  20. from resource_management.libraries.functions import format
  21. from resource_management.libraries.functions.version import format_stack_version
  22. from resource_management.libraries.functions.default import default
  23. from resource_management.libraries.functions import get_kinit_path
  24. from resource_management.libraries.script.script import Script
  25. # server configurations
  26. config = Script.get_config()
  27. tmp_dir = Script.get_tmp_dir()
  28. stack_name = default("/hostLevelParams/stack_name", None)
  29. host_sys_prepped = default("/hostLevelParams/host_sys_prepped", False)
  30. stack_version_unformatted = str(config['hostLevelParams']['stack_version'])
  31. stack_version_formatted = format_stack_version(stack_version_unformatted)
  32. # New Cluster Stack Version that is defined during the RESTART of a Rolling Upgrade
  33. version = default("/commandParams/version", None)
  34. #mahout params
  35. mahout_home = "/usr/hdp/current/mahout-client"
  36. mahout_conf_dir = "/usr/hdp/current/mahout-client/conf"
  37. mahout_user = config['configurations']['mahout-env']['mahout_user']
  38. yarn_log_dir_prefix = config['configurations']['yarn-env']['yarn_log_dir_prefix']
  39. #hadoop params
  40. hadoop_bin_dir = stack_select.get_hadoop_dir("bin")
  41. hadoop_home = stack_select.get_hadoop_dir("home")
  42. # the configuration direction for HDFS/YARN/MapR is the hadoop config
  43. # directory, which is symlinked by hadoop-client only
  44. hadoop_conf_dir = conf_select.get_hadoop_conf_dir()
  45. hdfs_user = config['configurations']['hadoop-env']['hdfs_user']
  46. yarn_user = config['configurations']['yarn-env']['yarn_user']
  47. hdfs_principal_name = config['configurations']['hadoop-env']['hdfs_principal_name']
  48. hdfs_user_keytab = config['configurations']['hadoop-env']['hdfs_user_keytab']
  49. smokeuser = config['configurations']['cluster-env']['smokeuser']
  50. smokeuser_principal = config['configurations']['cluster-env']['smokeuser_principal_name']
  51. user_group = config['configurations']['cluster-env']['user_group']
  52. security_enabled = config['configurations']['cluster-env']['security_enabled']
  53. smoke_user_keytab = config['configurations']['cluster-env']['smokeuser_keytab']
  54. kinit_path_local = get_kinit_path(default('/configurations/kerberos-env/executable_search_paths', None))
  55. # not supporting 32 bit jdk.
  56. java64_home = config['hostLevelParams']['java_home']
  57. log4j_props = config['configurations']['mahout-log4j']['content']
  58. hdfs_site = config['configurations']['hdfs-site']
  59. default_fs = config['configurations']['core-site']['fs.defaultFS']
  60. dfs_type = default("/commandParams/dfs_type", "")
  61. import functools
  62. #create partial functions with common arguments for every HdfsResource call
  63. #to create/delete hdfs directory/file/copyfromlocal we need to call params.HdfsResource in code
  64. HdfsResource = functools.partial(
  65. HdfsResource,
  66. user=hdfs_user,
  67. hdfs_resource_ignore_file = "/var/lib/ambari-agent/data/.hdfs_resource_ignore",
  68. security_enabled = security_enabled,
  69. keytab = hdfs_user_keytab,
  70. kinit_path_local = kinit_path_local,
  71. hadoop_bin_dir = hadoop_bin_dir,
  72. hadoop_conf_dir = hadoop_conf_dir,
  73. principal_name = hdfs_principal_name,
  74. hdfs_site = hdfs_site,
  75. default_fs = default_fs,
  76. dfs_type = dfs_type
  77. )