libcloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Bicking <ianbick...@gmail.com>
Subject Re: [libcloud] expanding & rethinking create_node
Date Thu, 31 Dec 2009 19:12:13 GMT
On Thu, Dec 31, 2009 at 1:44 AM, Paul Querna <paul@querna.org> wrote:

> Example usage for authentication:
>
> auth = None
> if driver.has_feature(Features.AUTH_SSH_KEY):
>   auth = NodeAuthSSHKey(open("mykey.pub").read())
> elif driver.has_feature(Features.AUTH_PASSWORD):
>  auth = NodeAuthPassword(mypass)
>
> driver.create_node("new-machine", NodeOptions(size=size, image=image,
> location=location, auth=auth))
>
> Thoughts on these API changes?


Maybe this could be done in a lighter manner.  For instance:

if 'ssh_key' in driver.create_node.features:
    kw = dict(ssh_key=open('mykey.pub').read())
elif 'password' in driver.create_node.features:
    kw = dict(password=mypass) # username?
else:
    assert False, "How do you auth then?!?"

driver.create_node('new-machine', **kw)


Documentation should cover the possible keyword arguments, and of course
drivers for services that provide the same features should use the same
keyword.

This way the API isn't really any more complicated than it is now, and if
you aren't being particularly provider-agnostic then you don't have to worry
about this stuff, but if you are provider agnostic then there's the metadata
to support that.


-- 
Ian Bicking  |  http://blog.ianbicking.org  |
http://topplabs.org/civichacker

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message