AMBARI-21286. WebHDF request doesn't require user.name argument on secured clusters (aonishuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/0ef58369 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/0ef58369 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/0ef58369 Branch: refs/heads/branch-2.5 Commit: 0ef583699232bf6b9b9c6c284ce862ba1a1c83a1 Parents: 22e4b48 Author: Andrew Onishuk <[email protected]> Authored: Tue Jun 20 17:35:33 2017 +0300 Committer: Andrew Onishuk <[email protected]> Committed: Tue Jun 20 17:35:33 2017 +0300 ---------------------------------------------------------------------- .../libraries/providers/hdfs_resource.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/0ef58369/ambari-common/src/main/python/resource_management/libraries/providers/hdfs_resource.py ---------------------------------------------------------------------- diff --git a/ambari-common/src/main/python/resource_management/libraries/providers/hdfs_resource.py b/ambari-common/src/main/python/resource_management/libraries/providers/hdfs_resource.py index 69cc7cd..efca23d 100644 --- a/ambari-common/src/main/python/resource_management/libraries/providers/hdfs_resource.py +++ b/ambari-common/src/main/python/resource_management/libraries/providers/hdfs_resource.py @@ -160,9 +160,14 @@ class WebHDFSUtil: depending on if query was successful or not, we can assert this for them """ target = HdfsResourceProvider.parse_path(target) + + url = format("{address}/webhdfs/v1{target}?op={operation}", address=self.address) + request_args = kwargs + + if not self.security_enabled: + request_args['user.name'] = self.run_user - url = format("{address}/webhdfs/v1{target}?op={operation}&user.name={run_user}", address=self.address, run_user=self.run_user) - for k,v in kwargs.iteritems(): + for k,v in request_args.iteritems(): url = format("{url}&{k}={v}") cmd = ["curl", "-sS","-L", "-w", "%{http_code}", "-X", method]
