Skip to content

Instantly share code, notes, and snippets.

@MichaelSEA
Last active February 3, 2016 00:58
Show Gist options
  • Save MichaelSEA/cb9ce21a1fdf3a18da64 to your computer and use it in GitHub Desktop.
Save MichaelSEA/cb9ce21a1fdf3a18da64 to your computer and use it in GitHub Desktop.
quick snippet showing how to use Qumulo REST API to read file contents
import tempfile
import qumulo.lib.auth
import qumulo.lib.request
import qumulo.rest.fs as fs
host = 'yourhost'
port = 8000
user = 'user'
passwd = 'passwd'
filepath = '/path/file'
# login
connection = None
credentials = None
connection = qumulo.lib.request.Connection(host, port)
login_results, _ = qumulo.rest.auth.login(connection, None, user, passwd)
credentials = qumulo.lib.auth.Credentials.from_login_response(login_results)
# get file contents for a well-known file
file = tempfile.TemporaryFile()
fs.read_file(connection, credentials, file, path=filepath, id_=None)
# from here you can dump the content of file, etc.
print "done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment