API/Python/Open-Source Solutions

 View Only

Getting started with the Delphix Python Module

By Adam Bowen posted 05-01-2016 03:10:42 PM

Cross-posted from my blog, http://www.therealcloudsurgeon.com/2016/04/getting-started-with-delphix-python.html

This post includes a video, in case it gets removed from this post again, here is the link: https://vimeo.com/164779308

Allo everyone. By popular demand, I going to start a short series on using the Delphix python module, "delphixpy". If you have been following my work any time over the last two years and have downloaded the Landshark environment along with Delphix Express, then you have been a recipient of the benefits of delphixpy.

In short, delphixpy is a way to call the Delphix API from within python so that you can leverage all that object oriented goodness that python provides. This also allows you to treat json as dictionaries and many other powerful things of python. I have posted three common examples for DevOps, CI/CD, and Enterprise Automation shops and did try to meticulously comment them. I have recorded an intro video where I walk you through getting your Landshark environment setup to run the scripts and run the examples against a Landshark environment so that you can easily follow along where ever you are.

There will be much more information to come very soon, we are just getting started! (I apologize in advance for my repetition of the word "neat." It is so weird, but I never realized that I even use that word!)

You can get my examples from GitHub here
You can post questions, etc on the Delphix Community Site here
Landshark and Delphix Express download and setup instructions here

Summary of preparation commands:

  1. ssh into the Landshark LinuxTarget as the delphix user.
  2. assume root: su -
  3. yum install git -y
  4. pip install virtualenv
  5. exit root (you should now be the delphix user again)
  6. git clone https://github.com/CloudSurgeon/delph...
  7. virtualenv --system-site-packages ~/landshark
  8. source ~/landshark/bin/activate
  9. pip install --upgrade -r ~/delphixpy-examples/requirements.txt




05-15-2019 07:29:27 PM

The download links are not working anymore. Do you have a new link for the downloads of OVAs?

05-05-2016 11:02:12 AM


05-05-2016 11:01:37 AM

Thank you! I have it done. (landshark) [delphix@linuxtarget ~]$ ./dx_snapshot_db.py --group Sources --name "dbSource" {'--all': False, '--all_dbs': False, '--config': './dxtools.conf', '--debug': False, '--engine': None, '--group': 'Sources', '--help': False, '--host': None, '--logdir': './dx_snapshot_db.log', '--name': 'dbSource', '--object_type': None, '--parallel': None, '--poll': '10', '--usebackup': False, '--version': False, '-d': None} INFO: Welcome to dx_snapshot_db.py, version v.0.0.010 INFO: Executing against the default Delphix Engine in the dxtools.conf: Delphix5Demo INFO: Delphix5Demo: Syncing dbSource INFO: Delphix5Demo: dbSource: RUNNING INFO: Delphix5Demo: 1 jobs running. 0 jobs waiting to run INFO: Delphix5Demo: dbSource: COMPLETED INFO: Delphix5Demo: 0 jobs running. 0 jobs waiting to run INFO: script took 0.2 minutes to get this far. (landshark) [delphix@linuxtarget ~]$

05-05-2016 10:43:04 AM

Yep. I covered this in my video, as well (@3:35)

You got this error message because you were missing step 8.

05-05-2016 10:32:29 AM

I have step 9 repeated and you can see the output bellow and in uploaded image. [delphix@linuxtarget ~]$ pip install --upgrade -r ~/delphixpy-examples/requirements.txt Downloading/unpacking setuptools from https://pypi.python.org/packages/15/b7/a76624e5a3b18c8c1c8d33a5240b34cdabb08aef2da44b536a8b53ba1a45/setuptools-21.0.0-py2.py3-none-any.whl#md5=6027400d6870a7dad29952b7d2dfdc7b (from -r /home/delphix/delphixpy-examples/requirements.txt (line 1)) Downloading setuptools-21.0.0-py2.py3-none-any.whl (509kB): 509kB downloaded Downloading/unpacking pip from https://pypi.python.org/packages/31/6a/0f19a7edef6c8e5065f4346137cc2a08e22e141942d66af2e1e72d851462/pip-8.1.1-py2.py3-none-any.whl#md5=22db7b6a517a09c29d54a76650f170eb (from -r /home/delphix/delphixpy-examples/requirements.txt (line 2)) Downloading pip-8.1.1-py2.py3-none-any.whl (1.2MB): 1.2MB downloaded Downloading/unpacking docopt (from -r /home/delphix/delphixpy-examples/requirements.txt (line 3)) Downloading docopt-0.6.2.tar.gz Running setup.py (path:/u02/tmp/pip_build_delphix/docopt/setup.py) egg_info for package docopt Downloading/unpacking delphixpy from https://pypi.python.org/packages/ab/4c/3f6a123a89f7f463aaeb6fe5e076834c8cd1a49f121ec8810508f0bf5a9d/delphixpy- (from -r /home/delphix/delphixpy-examples/requirements.txt (line 4)) Downloading delphixpy- (3.9MB): 3.9MB downloaded Running setup.py (path:/u02/tmp/pip_build_delphix/delphixpy/setup.py) egg_info for package delphixpy Installing collected packages: setuptools, pip, docopt, delphixpy Found existing installation: setuptools 7.0 Uninstalling setuptools: Cleaning up... Exception: Traceback (most recent call last): File "/usr/local/lib/python2.7/site-packages/pip/basecommand.py", line 122, in main status = self.run(options, args)

05-05-2016 10:15:30 AM

It seems now you have skipped step 9. Step 9 installs docopt. If you did Step 9, can you repeat it and post your output?

05-05-2016 10:13:37 AM

Thank you, Adam. I have this resolved with your video along with. Now I have new one: [delphix@linuxtarget ~]$ ./dx_snapshot_db.py --group Sources --name "dbSource" Traceback (most recent call last): File "./dx_snapshot_db.py", line 60, in

05-05-2016 08:42:57 AM

Somehow my video was pulled out of this post, I have added it back. Follow along with my video, for clarity.

05-05-2016 08:41:13 AM

I amended the instructions to be more clear.

05-05-2016 08:40:14 AM

You are logged in as root. You missed step 5 where you exit as root. Steps 6 -9 should be completed as the delphix user, if you are following along in your Landshark environment. 

05-05-2016 08:13:19 AM

Hi Adam, I have an error on step 9: Could not open requirements file: [Errno 2] No such file or directory: '/root/delphixpy-examples/requirements.txt' Can you advise something?