Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Fri Jun 14, 2013 5:09 pm 
Offline
Senior Newbie
User avatar

Joined: Tue May 14, 2013 5:46 pm
Posts: 11
Website: http://danslimmon.com/
Location: Minneapolis, MN
I've been scripting with the Linode API a lot for my employer Exosite, and although tjfontaine's linode-python package does a great job of transliterating the API spec into Python territory, I've been longing for the object-orientedness of something like Fog. That's why I wrote

Chube!

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:

Code:
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()


You can install it with

Code:
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!

_________________
Dan Slimmon
Senior Platform Engineer
Exosite
Minneapolis, MN


Top
   
PostPosted: Fri Jun 14, 2013 5:21 pm 
Offline
Junior Member
User avatar

Joined: Fri May 04, 2012 8:57 pm
Posts: 49
Cool!

_________________
me | voltaireMC


Top
   
PostPosted: Fri Jun 14, 2013 5:34 pm 
Offline
Senior Newbie

Joined: Thu Nov 11, 2004 12:05 pm
Posts: 12
Always happy to see people working with the library, and fwiw I did a rudimentary OOP interface

https://github.com/tjfontaine/linode-py ... ode/oop.py

and briefly "documented" at http://atxconsulting.com/Linode_OOP_Bindings/


Top
   
PostPosted: Fri Jun 14, 2013 8:41 pm 
Offline
Senior Member

Joined: Fri Feb 18, 2005 4:09 pm
Posts: 594
deleted


Last edited by zunzun on Sun Aug 04, 2013 8:55 pm, edited 1 time in total.

Top
   
PostPosted: Fri Jun 21, 2013 11:43 am 
Offline
Senior Newbie
User avatar

Joined: Tue May 14, 2013 5:46 pm
Posts: 11
Website: http://danslimmon.com/
Location: Minneapolis, MN
This thing now supports all the Linode and Stackscript functionality of the API. Next stop: DNS.

Also, I beefed up the docs: https://github.com/exosite/chube/blob/master/README.md

_________________
Dan Slimmon
Senior Platform Engineer
Exosite
Minneapolis, MN


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group