pig.py 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. import os
  18. from resource_management import *
  19. from ambari_commons import OSConst
  20. from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl
  21. @OsFamilyFuncImpl(os_family=OsFamilyImpl.DEFAULT)
  22. def pig():
  23. import params
  24. Directory( params.pig_conf_dir,
  25. create_parents = True,
  26. owner = params.hdfs_user,
  27. group = params.user_group
  28. )
  29. File(format("{pig_conf_dir}/pig-env.sh"),
  30. owner=params.hdfs_user,
  31. mode=0755,
  32. content=InlineTemplate(params.pig_env_sh_template)
  33. )
  34. # pig_properties is always set to a default even if it's not in the payload
  35. File(format("{params.pig_conf_dir}/pig.properties"),
  36. mode=0644,
  37. group=params.user_group,
  38. owner=params.hdfs_user,
  39. content=params.pig_properties
  40. )
  41. if (params.log4j_props != None):
  42. File(format("{params.pig_conf_dir}/log4j.properties"),
  43. mode=0644,
  44. group=params.user_group,
  45. owner=params.hdfs_user,
  46. content=params.log4j_props
  47. )
  48. elif (os.path.exists(format("{params.pig_conf_dir}/log4j.properties"))):
  49. File(format("{params.pig_conf_dir}/log4j.properties"),
  50. mode=0644,
  51. group=params.user_group,
  52. owner=params.hdfs_user
  53. )
  54. @OsFamilyFuncImpl(os_family=OSConst.WINSRV_FAMILY)
  55. def pig():
  56. import params
  57. File(os.path.join(params.pig_conf_dir, "pig.properties"),
  58. mode="f",
  59. owner=params.pig_user,
  60. content=params.pig_properties
  61. )
  62. if (params.log4j_props != None):
  63. File(os.path.join(params.pig_conf_dir, "log4j.properties"),
  64. mode='f',
  65. owner=params.pig_user,
  66. content=params.log4j_props
  67. )