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/d693273d Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/d693273d Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/d693273d Branch: refs/heads/branch-feature-AMBARI-20859 Commit: d693273dd2ddaa0532dccbf5b709d377122a209d Parents: 242d79b Author: Andrew Onishuk <aonis...@hortonworks.com> Authored: Tue Jun 20 17:35:29 2017 +0300 Committer: Andrew Onishuk <aonis...@hortonworks.com> Committed: Tue Jun 20 17:35:29 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/d693273d/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]