Print Email PDF

Virtual Cluster: Virtual Environments and Qumulo REST API

IN THIS ARTICLE

Outlines how to use virtual environments when using Qumulo REST API

  • Python virtualenv
  • Creating Virtual Environments for Python 2.7
  • Python on CentOS
  • Python on Windows
  • Other languages

REQUIREMENTS

  • Virtual cluster utilizing REST API

Reference the article Create a Virtual Cluster running Qumulo Core for additional details.

DETAILS

For python users using the Qumulo REST API, we currently require version 2.7 of Python. In some environments (such as OSX Yosemite), 2.7 is the default version of of the Python interpreter, but in other environments such as CentOS, version 2.6 or other versions may be the system default. This means that we cannot assume that the installed version of Python on a given system will match our requirements for using the Qumulo REST API.

To address this issue, use virtual environments for languages such as Python or Ruby (and even for javascript platforms such as Node). This isolates your applications from the default version of dynamic languages such as Python. It is also good in that you can run your application without potentially-impacting other applications that depend upon a version of Python or Python libraries that might be different than the versions you are using in your application. In other words, it’s much safer to run things this way whether your a developer or ops person.

Python virtualenv

The Hitchhiker’s Guide to Python has a great chapter on virtual environments and the tool virtualenv:

 "virtualenv is a tool to create isolated Python environments. virtualenv creates a folder which contains all the necessary executables to use the packages that a Python project would need."

Virtualnv is essentially all you need to isolate your Python applications and dependencies from the system defaults and other applications. It's recommended to use virtualenvwrapper as a convenience tool around virtualenv since it installs some nice conveniences such as the workon command:

➜ ~ workon
daily_storage_reports
fast_find
find_changed
project_template
py26
py27
py34
qdu
qm
qsplit
qsync
qumulo1211
qumulo1212

test

The packages currently installed in my qumulo1212 virtual environment is shown below. Note that the prompt now shows the currently-used virtual environment. 

➜ ~ workon qumulo1212
(qumulo1212)➜ ~ pip list
appnope (0.1.0)
arrow (0.6.0)
astroid (1.3.8)
decorator (4.0.2)
gnureadline (6.3.3)
ipdb (0.8.1)
ipython (4.0.0)
ipython-genutils (0.1.0)
logilab-common (1.0.2)
nose (1.3.7)
path.py (8.1.1)
pexpect (3.3)
pickleshare (0.5)
pip (7.1.2)
pylint (1.4.4)
python-dateutil (2.4.2)
qumulo-api (1.2.12.1)
setuptools (17.0)
simplegeneric (0.8.1)
six (1.9.0)
traitlets (4.0.0)

wheel (0.24.0)

If I run deactivate to unload my virtual environment or use the system environment again, note the difference in installed libraries.

➜ ~ pip list
You are using pip version 7.0.3, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
astroid (1.3.6)
Flask (0.10.1)
gnureadline (6.3.3)
ipdb (0.8.1)
ipython (3.1.0)
Jinja2 (2.7.3)
logilab-common (1.0.1)
MarkupSafe (0.23)
mercurial (3.4.1)
nose (1.3.7)
pbr (1.1.0)
pip (7.0.3)
pylint (1.4.4)
setuptools (17.0)
six (1.9.0)
stevedore (1.5.0)
virtualenv (13.0.3)
virtualenv-clone (0.2.5)
virtualenvwrapper (4.6.0)
Werkzeug (0.10.4)

Creating Virtual Environments for Python 2.7

You can even create virtual environments for a specific version of Python — in our case, we use Python 2.7.

mkvirtualenv foo --python=python2.7

It does assume that you have the specified version of python already installed/available to use:

  • on a Mac you can use homebrew to install versions of python
  • apt-get on linux variants and CygWin on Windows.

Stack Overflow has a good overview article on this here.

Python on CentOS

Digital Ocean has a good overview article on installing Python 2.7.6 (and 3.3.3) that you can find here. There is also a GitHub Gist here that provides a script that you can find here.

Python on Windows

The Hitchhiker’s Guide has a good section on installing Python 2.7 under Windows which you can read here.

Other Languages

Ruby, Node.js/javascript and other environments have similar tooling for virtual environment support to isolate your language versions and libraries from the system versions. For Ruby, check out either rbenv or rvm. For Node.js check out nodeenv.

RESOLUTION

You should now be able to successfully utilize virtual environments when using Qumulo REST API

ADDITIONAL RESOURCES

Video: Create a Qumulo virtual cluster on a Mac

Video: Create a Qumulo virtual cluster on Windows

Virtual Cluster: Create a virtual cluster running Qumulo Core

QQ CLI: Comprehensive List of Commands

 

Like what you see? Share this article with your network!

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.

Have more questions?
Open a Case
Share it, if you like it.