You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@libcloud.apache.org by "ssteinerX@gmail.com" <ss...@gmail.com> on 2010/03/19 22:57:30 UTC

Re: [libcloud] example.py tries to print "name" attribute of list, throws exception

On Mar 19, 2010, at 4:58 PM, Alex Polvi wrote:

> On Fri, Mar 19, 2010 at 9:03 AM, ssteinerX@gmail.com
> <ss...@gmail.com> wrote:
>>        node = filter(lambda x: x.name == 'test', nodes)[0]
>> 
>> "x" is a list, not a node, so it throws an Exception.
> 
> Whoops!
> 
>> Here's a more readable approach that reboots any node named "test", and that shows that the provider has to be accessed by Node.driver.name, not Node.provider as is implied by the string printed out by Node.__repr__:
>> 
>> # List out the nodes, grouped by provider and reboot any node named "test"
>> for provider in nodes:
>>        if provider:
>>                print "Provider: %s" % provider[0].driver.name
>>                for node in provider:
>>                        print "Node : %s" % node.name
>>                        if node.name == "test":
>>                                node.reboot()
>> 
>> I haven't cloned the repo yet...which of the git mirrors is the best for submitting pull requests?
> 
> Use http://github.com/apache/libcloud, which syncs with the SVN repo.

I'm not sure which direction that means but OK.

> Just submit patches to the list.

Wow...I guess I'm spoiled by git & mercurial.  Patch...hmmm...that's that thing with the diffs and stuff, right?

I'll see if I can figure out how to do that with a git clone -- i don't think I've ever needed to do that.

S


Re: [libcloud] example.py tries to print "name" attribute of list, throws exception

Posted by "ssteinerX@gmail.com" <ss...@gmail.com>.
On Mar 19, 2010, at 11:58 PM, Tom Davis wrote:

> Are you talking about access keys in the sense of SSH keys? If so, I'd assume Paramiko works like any other ssh client in that it talks to the user's running ssh-agent; figuring out how SSH keys work is left as an exercise to the reader.

No.

> If you mean some API-specific key variable, then for the purposes of a non-working example, just saying "key='asdf1234'" isn't icky, it's just a matter of pragmatism. Certainly we'd hope that users would take a more portable and security-conscious approach to private string storage, but AFAIK we have never suggested a standard for doing that, nor is it within the scope of the project to do so.

It's not a problem in demo code that ships with a product, but a little example of how to store keys under ~/.ssh with a usable piece of demo code might be handy.

> Hopefully that answers your question :)

Yes, would a simple module for storing private key=123 type things be worth including?  I have one that I use, it's just a simple class using ConfigParser, and has a simple command line utility for storing and retrieving key/value pairs.  

S


Re: [libcloud] example.py tries to print "name" attribute of list, throws exception

Posted by Tom Davis <to...@dislocatedday.com>.
Are you talking about access keys in the sense of SSH keys? If so, I'd  
assume Paramiko works like any other ssh client in that it talks to  
the user's running ssh-agent; figuring out how SSH keys work is left  
as an exercise to the reader.

If you mean some API-specific key variable, then for the purposes of a  
non-working example, just saying "key='asdf1234'" isn't icky, it's  
just a matter of pragmatism. Certainly we'd hope that users would take  
a more portable and security-conscious approach to private string  
storage, but AFAIK we have never suggested a standard for doing that,  
nor is it within the scope of the project to do so.

Hopefully that answers your question :)

On Mar 19, 2010, at 7:08 PM, "ssteinerX@gmail.com"  
<ss...@gmail.com> wrote:

>
> On Mar 19, 2010, at 6:20 PM, Tom Davis wrote:
>
>> See: git-format-patch
>
> Cool, thanks.
>
> Now, looking at my patch, I realize that I had also changed the  
> example to use my "access key" file that I store in ~/.ssh, that  
> I've used with other cloud access libraries I've used.
>
> It's just a common place to put access info that lets you distribute  
> code without worrying about accidentally leaving an access key in it.
>
> Would that type of thing be OK to add to the example, or could I add  
> another example showing how I use it, or something?
>
> I'm not sure if there's a "usual" way of storing access keys that  
> people commonly use with libcloud.  Coding it directly into the  
> source is just icky.
>
> Thanks,
>
> S
>
>

Re: [libcloud] example.py tries to print "name" attribute of list, throws exception

Posted by "ssteinerX@gmail.com" <ss...@gmail.com>.
On Mar 19, 2010, at 6:20 PM, Tom Davis wrote:

> See: git-format-patch

Cool, thanks.  

Now, looking at my patch, I realize that I had also changed the example to use my "access key" file that I store in ~/.ssh, that I've used with other cloud access libraries I've used.

It's just a common place to put access info that lets you distribute code without worrying about accidentally leaving an access key in it.

Would that type of thing be OK to add to the example, or could I add another example showing how I use it, or something?

I'm not sure if there's a "usual" way of storing access keys that people commonly use with libcloud.  Coding it directly into the source is just icky.

Thanks,

S



Re: [libcloud] example.py tries to print "name" attribute of list, throws exception

Posted by Tom Davis <to...@dislocatedday.com>.
See: git-format-patch

On Mar 19, 2010, at 5:57 PM, "ssteinerX@gmail.com"  
<ss...@gmail.com> wrote:

> On Mar 19, 2010, at 4:58 PM, Alex Polvi wrote:
>
>> On Fri, Mar 19, 2010 at 9:03 AM, ssteinerX@gmail.com
>> <ss...@gmail.com> wrote:
>>>       node = filter(lambda x: x.name == 'test', nodes)[0]
>>>
>>> "x" is a list, not a node, so it throws an Exception.
>>
>> Whoops!
>>
>>> Here's a more readable approach that reboots any node named  
>>> "test", and that shows that the provider has to be accessed by Node.driver.name 
>>> , not Node.provider as is implied by the string printed out by  
>>> Node.__repr__:
>>>
>>> # List out the nodes, grouped by provider and reboot any node  
>>> named "test"
>>> for provider in nodes:
>>>       if provider:
>>>               print "Provider: %s" % provider[0].driver.name
>>>               for node in provider:
>>>                       print "Node : %s" % node.name
>>>                       if node.name == "test":
>>>                               node.reboot()
>>>
>>> I haven't cloned the repo yet...which of the git mirrors is the  
>>> best for submitting pull requests?
>>
>> Use http://github.com/apache/libcloud, which syncs with the SVN repo.
>
> I'm not sure which direction that means but OK.
>
>> Just submit patches to the list.
>
> Wow...I guess I'm spoiled by git & mercurial.  Patch...hmmm...that's  
> that thing with the diffs and stuff, right?
>
> I'll see if I can figure out how to do that with a git clone -- i  
> don't think I've ever needed to do that.
>
> S
>