Introducing chube: Object-oriented bindings for Linode API
Exositetjfontaine's linode-python packageFog
It adds an abstraction layer on top of tjfontaine's bindings, and also gives you a nifty little command-line app called chuber.py that lets you mess with the API objects in a Python interpreter.
I think the best way to show you how it works is with an example chuber.py session:
you@localhost:~$ chuber
Python 2.7.2 (default, Oct 11 2012, 20:14:37)
>>> Linode.search()
[<linode api_id="13971," label="foo-01">, <linode api_id="20401," label="bar-04">, <linode api_id="13972," label="foo-02">]
>>>
>>> nodes = Linode.search(label_begins='foo-')
[<linode api_id="13971," label="foo-01">, <linode api_id="13972," label="foo-02">]
>>>
>>> for node in nodes:
... print node.ipaddresses[0].address
...
192.168.13.148
192.168.8.218
>>>
>>> plan = Plan.find(label="Linode 1024")
>>> plan
<plan label="Linode 1024">>>> datacenter = Datacenter.find(location_begins="dallas")
>>> datacenter
<datacenter location="Dallas, TX, USA">>>>
>>> new_node = Linode.create(plan=plan, datacenter=datacenter, payment_term=1)
>>> new_node
<linode api_id="345768," label="linode345768">>>> new_node.label = "web-14"
>>> new_node.save()
>>> Linode.find(label="web-14")
<linode api_id="345768," label="web-14">>>>
>>> distro = Distribution.find(label="Debian 7")
>>> disk = new_node.create_disk(distribution=distro, label="foo_disk", size=2000, root_pass="secret123")
>>> new_node.pending_jobs
[<job api_id="12310126," label="Disk Create From Distribution - Debian 7">, <job api_id="12310127," label="Linode Initial Configuration">]
>>> new_node.pending_jobs[0].wait()
>>>
>>> job = new_node.boot()
>>> job.wait()
>>>
>>> new_node.destroy()</job></job></linode></linode></datacenter></plan></linode></linode></linode></linode></linode>
You can install it with
pip install chube
And there's a to-do list
Play around with it, let me know what you think, and fork the crap out of it!
4 Replies
and briefly "documented" at
Also, I beefed up the docs: