[DRAFT/RFC] node driver writers guide + linode list_nodes support

1 view
Skip to first unread message

Alex Polvi

unread,
Aug 11, 2009, 4:42:47 AM8/11/09
to libc...@googlegroups.com
Team,

As promised, I've been working on a node driver writers guide. It is
really rough, but I wanted to kick it out ASAP. Here is my first cut:

http://wiki.github.com/cloudkick/libcloud/nodedriverwritersguide

For the guide, I showed how to implement basic Linode support. Jed,
would love to have you take a look and offer some feedback. The only
weird thing I had to do was an additional API call to get ipaddresses,
as they are not returned in linode.list, as far as I can tell.

http://github.com/cloudkick/libcloud/blob/9759214424abf00a7ddafca3256d4cff03a88c69/libcloud/drivers/linode.py

Let me know what you think! I'm probably going to stick this in a
sphinx doc, as soon as I can figure out how to use sphinx on the code
base.

-Alex

--
co-founder, cloudkick.com
twitter.com/cloudkick
541 231 0624

Tom Davis

unread,
Aug 11, 2009, 8:46:30 AM8/11/09
to libc...@googlegroups.com
Nice work, Alex! I will go over this more in the near future when at a
computer, but I like what you've got so far!

Ryan Tucker

unread,
Aug 11, 2009, 2:25:13 PM8/11/09
to libc...@googlegroups.com
On Tue, 2009-08-11 at 01:42 -0700, Alex Polvi wrote:
> For the guide, I showed how to implement basic Linode support. Jed,
> would love to have you take a look and offer some feedback. The only
> weird thing I had to do was an additional API call to get ipaddresses,
> as they are not returned in linode.list, as far as I can tell.
>
> http://github.com/cloudkick/libcloud/blob/9759214424abf00a7ddafca3256d4cff03a88c69/libcloud/drivers/linode.py

Looks good! The documentation will be a big help for future
implementers :-)

On the IP address subject, it is possible for a Linode instance to have
multiple public IP addresses. In such cases, the JSON return for
linode.ip.list is something like:

[{"LINODEID":61,
"ISPUBLIC":1,
"IPADDRESS":"72.14.191.56",
"RDNS_NAME":"li-56.members.linode.com",
"IPADDRESSID":113},
{"LINODEID":61,
"ISPUBLIC":1,
"IPADDRESS":"72.14.191.181",
"RDNS_NAME":"li-181.members.linode.com",
"IPADDRESSID":238},
{"LINODEID":61,
"ISPUBLIC":1,
"IPADDRESS":"72.14.191.187",
"RDNS_NAME":"li-187.members.linode.com",
"IPADDRESSID":244}]

Note that the IP addresses are not returned in chronological order; .181
came with the instance, then .187 and .56 were added in that order.

Right now, the linode.py driver is returning the last public IP address
returned:

>>> instance.list_nodes()[0].public_ip
u'72.14.191.187'

The Linode web interface uses a different algorithm to choose the "main"
IP address on the summary page; in this case, it displays the first
one, .56. I am not 100% sure what the web interface uses for the
algorithm, but I believe it displays the minimum of the IP address list.
To reduce confusion, returning the first IP address instead of the last
would probably be the way to go.

Alternatively, I propose defining public_ips as a list of all public IPs
returned by the provider (and defining private_ips in the same fashion).
For this particular Linode:

>>> instance.list_nodes()[0].public_ips
[u'72.14.191.56',u'72.14.191.181',u'72.14.191.187']
>>> instance.list_nodes()[0].private_ips
[]

Thoughts? -rt

--
Ryan Tucker <rtu...@gmail.com>

signature.asc

Tom Davis

unread,
Aug 11, 2009, 3:29:17 PM8/11/09
to libc...@googlegroups.com
Definitely. Many machines may have multiple IPs bound to them; we
shouldn't assume there will only be one, or simply pick one at random
if there are multiple. This also means public_ips and private_ips
should always return a sequence, regardless of count.
Reply all
Reply to author
Forward
0 new messages