Introducing pylxd

This article was last updated 10 years ago.


In part of my work for nova-compute-lxd, we use a combination of httplib, UNIX domain sockets, and JSON to talk to the LXD daemon via the REST API. Talking to various people involved in the LXD project, I have decided to split this part of nova-compute-lxd into its own project called pylxd. Pylxd is a general python library that you can use to interact with LXD in order to do container operations.

Right now, it is about 80% complete, the bits that are missing is that it needs more unit tests and needs more container operations (snapshots, running commands in the container, etc). That functionality will be coming in later releases of pylxd. I intend to use pylxd in the next version of nova-compute-lxd for the Liberty release of OpenStack as well. I am sure that there is other use cases that developers and users can use pylxd for.

To use pylxd, you just have to clone the git tree and build it. An example usage of pylxd is that you need a way to display the ‘/etc/hosts’ from your running ‘test1′ container. With pylxd this is pretty simple to do:

#!/usr/bin/python

from pylxd import api
c = api.API()
print c.get_container_file(‘test1′, ‘/etc/hosts’)

The result of the above snippet is that the ‘/etc/hosts’ from the ‘test1′ container will be displayed. Pretty simple eh?

The code for pylxd is available on github. Please report give it a twirl, please report bugs, and would love to get feedback.

About the author

Chuck Short is a software engineer at Canonical. Originally from Vancouver but based in Ottawa, Chuck’s mission is to make sure OpenStack is a first class experience for both the X86 world and ARM world. You can follow his blog at zulcss.wordpress.com

Smart operations, optimal architecture, better pricing.

OpenStack and Ubuntu bring automated deployment and management that help you optimize infrastructure costs — no matter your industry or use case.

Learn about Canonical OpenStack ›

Newsletter signup

Get the latest Ubuntu news and updates in your inbox.

By submitting this form, I confirm that I have read and agree to Canonical's Privacy Policy.

Related posts

Canonical announces optimized Ubuntu images for Google Cloud’s Axion N4A Virtual Machines

Today Canonical, the publishers of Ubuntu, and Google Cloud announced the immediate availability of optimized Ubuntu images for the new Axion-based N4A...

OpenStack cloud – happy 15th anniversary!

Happy birthday, OpenStack! It’s astonishing how fast time flies – fifteen years already. Yet, here we are: OpenStack cloud still stands as a de facto standard...

The clock is ticking: Ubuntu Summit 25.10 is just around the corner

London has called, and the Ubuntu community has answered! This year, the Ubuntu Summit has the ambitious goal of extending its reach to everyone, no matter...