You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@libcloud.apache.org by Robert Keizer <ro...@keizer.ca> on 2011/11/15 19:49:55 UTC

[dev] Introspection of create_node and deploy_node.

Greetings,

Utilizing the inspect module and getcmdargspec on constructors I've
been able to dynamically create a GUI that connects to multiple
providers, and can act upon the objects. What I'm trying to accomplish
is a completely introspective product - that is, upgrade the libcloud
version behind the scenes and the GUI suddenly has more options and
providers.

I've hit a snag with create_node and deploy_node as defined in
libcloud.compute.drivers.* and libcloud.compute.base.NodeDriver.
Because these functions are defined with **kwargs rather than specific
arguments I cannot continue using getcmdargspec to in part generate a
GUI.

One solution that I think is possible, although is undeniably a hack,
is to utilize inspect.getdoc(), and then parse valid options with
pydoc.

I'm asking 2 questions to the dev list:

1) Am I missing something? Is there a helper function in some location
to get a valid list of arguments for create_node and deploy_node that
includes provider specific entries?
2) Can you think of a better way then parsing documentation to
generate an equivalent of getcmdargspec?

All the best,
Rob

Re: [dev] Introspection of create_node and deploy_node.

Posted by Tomaž Muraus <to...@apache.org>.
Hi,

Sorry for the delay, my replies are in-line.

On Tue, Nov 15, 2011 at 7:49 PM, Robert Keizer <ro...@keizer.ca> wrote:

> Greetings,
>
> Utilizing the inspect module and getcmdargspec on constructors I've
> been able to dynamically create a GUI that connects to multiple
> providers, and can act upon the objects. What I'm trying to accomplish
> is a completely introspective product - that is, upgrade the libcloud
> version behind the scenes and the GUI suddenly has more options and
> providers.
>
> I've hit a snag with create_node and deploy_node as defined in
> libcloud.compute.drivers.* and libcloud.compute.base.NodeDriver.
> Because these functions are defined with **kwargs rather than specific
> arguments I cannot continue using getcmdargspec to in part generate a
> GUI.
>
> One solution that I think is possible, although is undeniably a hack,
> is to utilize inspect.getdoc(), and then parse valid options with
> pydoc.
>
> I'm asking 2 questions to the dev list:
>
> 1) Am I missing something? Is there a helper function in some location
> to get a valid list of arguments for create_node and deploy_node that
> includes provider specific entries?
>

Nope, currently there is no method which returns valid arguments for
create_node / deploy_node with includes provider specific arguments.

I can see that having some kind of utility function which does that could
be handy though.


> 2) Can you think of a better way then parsing documentation to generate an
> equivalent of getcmdargspec?


Hm, I can't think of a better solution. We use pydoctor (
http://codespeak.net/~mwh/pydoctor/) for generating API documentation so
you could probably use it to get just the argument names and types from the
docstrings.


>
> All the best,
> Rob
>