You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by "Tomaz Muraus (JIRA)" <ji...@apache.org> on 2013/11/28 11:19:40 UTC

[jira] [Updated] (LIBCLOUD-438) Cloudstack driver ex_list_keypairs does not work if no keypairs exist

     [ https://issues.apache.org/jira/browse/LIBCLOUD-438?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tomaz Muraus updated LIBCLOUD-438:
----------------------------------

    Fix Version/s: 0.14.0-beta3

> Cloudstack driver ex_list_keypairs does not work if no keypairs exist
> ---------------------------------------------------------------------
>
>                 Key: LIBCLOUD-438
>                 URL: https://issues.apache.org/jira/browse/LIBCLOUD-438
>             Project: Libcloud
>          Issue Type: Bug
>          Components: Compute
>    Affects Versions: 0.13.2
>         Environment: python 2.6
>            Reporter: Carlos Reategui
>            Assignee: Tomaz Muraus
>             Fix For: 0.14.0-beta3
>
>
> If there are no sshkeypairs in cloudstack one gets the following when trying ex_list_keypairs or ex_create_keypair which calls the first:
> Traceback (most recent call last):
>   File "./csListKeyPairs.py", line 26, in <module>
>     keys = driver.ex_list_keypairs()
>   File "/usr/lib/python2.6/site-packages/libcloud/compute/drivers/cloudstack.py", line 601, in ex_list_keypairs
>     return res['sshkeypair']
> KeyError: 'sshkeypair'
> I fixed it with the following change.  Please note I am a python noob so not sure if this is the best way to do fix or not:
> --- apache-libcloud-0.13.2/libcloud/compute/drivers/cloudstack.py       2013-09-15 15:40:43.000000000 +0000
> +++ cloudstack.py       2013-11-14 04:05:26.000000000 +0000
> @@ -597,7 +598,9 @@
>  
>          extra_args = kwargs.copy()
>          res = self._sync_request('listSSHKeyPairs', **extra_args)
> -        return res['sshkeypair']
> +        if res.has_key('sshkeypair'):
> +            return res['sshkeypair']
> +        return {}
>  
>      def ex_create_keypair(self, name, **kwargs):
>          """



--
This message was sent by Atlassian JIRA
(v6.1#6144)