Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# hdfs_modules

cloned from https://github.com/BROADSoftware/hdfs_modules

This ansible role host a set of modules aimed to manipulate file and directory on HDFS (The Hadoop Distributed File System).

* hdfs\_file: Equivalent of the ansible files/file module, but on HDFS. Doc [at this location](docs/hdfs_file.txt)
Expand Down
4 changes: 3 additions & 1 deletion library/hdfs_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@
try:
import requests
HAS_REQUESTS = True
except ImportError, AttributeError:
except ImportError:
pass
except AttributeError:
# AttributeError if __version__ is not present
pass

Expand Down
6 changes: 4 additions & 2 deletions library/hdfs_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@
try:
import requests
HAS_REQUESTS = True
except ImportError, AttributeError:
except ImportError:
pass
except AttributeError:
# AttributeError if __version__ is not present
pass

Expand Down Expand Up @@ -393,7 +395,7 @@ def main():
except Exception:
error("mode must be in octal form")

p.mode = oct(p.mode).lstrip("0")
p.mode = '%03o' % p.mode
if p.mode == '': # Thanks Jocelyn
p.mode = '0'
#print '{ mode_type: "' + str(type(p.mode)) + '", mode_value: "' + str(p.mode) + '"}'
Expand Down
4 changes: 3 additions & 1 deletion library/hdfs_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@
try:
import requests
HAS_REQUESTS = True
except ImportError, AttributeError:
except ImportError:
pass
except AttributeError:
# AttributeError if __version__ is not present
pass

Expand Down
12 changes: 7 additions & 5 deletions library/hdfs_put.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@
try:
import requests
HAS_REQUESTS = True
except ImportError, AttributeError:
except ImportError:
pass
except AttributeError:
# AttributeError if __version__ is not present
pass

Expand Down Expand Up @@ -379,14 +381,14 @@ def checkParameters(p):
p.mode = int(p.mode, 8)
except Exception:
error("mode must be in octal form")
p.mode = oct(p.mode)
p.mode = '%03o' % p.mode
if p.directoryMode != None:
if not isinstance(p.directoryMode, int):
try:
p.directoryMode = int(p.directoryMode, 8)
except Exception:
error("directoryMode must be in octal form")
p.directoryMode = oct(p.directoryMode)
p.directoryMode = '%03o' % p.directoryMode
#print '{ mode_type: "' + str(type(p.directoryMode)) + '", directoryMode_value: "' + str(p.directoryMode) + '"}'

if not p.hdfsDest.startswith("/"):
Expand Down Expand Up @@ -481,14 +483,14 @@ def buildLocalTree(rroot):
f = {}
f['size'] = stat.st_size
f['modificationTime'] = int(stat.st_mtime)
f['mode'] = "0" + oct(stat.st_mode)[-3:]
f['mode'] = "0" + ('%03o' % stat.st_mode)[-3:]
fileMap[key] = f
for dirName in dirs:
key = os.path.join(root, dirName)[prefLen:]
path = os.path.join(rroot, key)
stat = os.stat(path)
f = {}
f['mode'] = "0" + oct(stat.st_mode)[-3:]
f['mode'] = "0" + ('%03o' % stat.st_mode)[-3:]
dirMap[key] = f
tree['files'] = fileMap
tree['directories'] = dirMap
Expand Down
6 changes: 3 additions & 3 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
# Required by hdfs_file, hdfs_cmd and hdfs_info

- name: Install python-requests and python-requests-kerberos for hdfs_xxxxx ansibles modules (RedHat)
yum: name=python-requests,python-requests-kerberos state=present
yum: name=python3-requests,python3-requests-kerberos state=present
when: ansible_os_family == 'RedHat'

- name: Install python-requests and python-requests-kerberos for hdfs_xxxxx ansibles modules (Debian)
apt: name=python-requests,python-requests-kerberos state=present
apt: name=python3-requests,python3-requests-kerberos state=present
when: ansible_os_family == 'Debian'