You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by "Carlos Reategui (JIRA)" <ji...@apache.org> on 2013/11/14 15:45:21 UTC

[jira] [Comment Edited] (LIBCLOUD-439) Cloudstack list_nodes does not fill in image field

    [ https://issues.apache.org/jira/browse/LIBCLOUD-439?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13822485#comment-13822485 ] 

Carlos Reategui edited comment on LIBCLOUD-439 at 11/14/13 2:44 PM:
--------------------------------------------------------------------

Ah ok.  Looking at the list_images code for the Cloudstack driver we have most of the data to recreate the NodeImage in the native listVirtualMachines api that is use to fulfill list_nodes.  So how about something like this:
{code}
    image = NodeImage(
                id=vm['templateid'],
                name=vm['templatename'],
                driver=self.connection.driver,
                extra={
                    'hypervisor': vm['hypervisor']})
{code}
The only things missing would be format and os in extra.  Otherwise the right way is probably to query the list of images before looping through the node with:
{code}
        if location is not None:
            args['zoneid'] = location.id
        imgs = self._sync_request('listTemplates', **args)
{code}
then create a map with the NodeImages
{code}
        for img in imgs.get('template', []):
            img_map[img['id']]=NodeImage(
                id=img['id'],
                name=img['name'],
                driver=self.connection.driver,
                extra={
                    'hypervisor': img['hypervisor'],
                    'format': img['format'],
                    'os': img['ostypename']})
{code}
and finally assign it to the image with
{code}
    image=img_map[vm['templateid']]
{code}
Let me know which option you prefer and I can send a patch.

Also thinking of adding size to the node extra with the name of the size that the node is.


was (Author: creategui):
Ah ok.  Looking at the list_images code for the Cloudstack driver we have most of the data to recreate the NodeImage in the native listVirtualMachines api that is use to fulfill list_nodes.  So how about something like this:

    image = NodeImage(
                id=vm['templateid'],
                name=vm['templatename'],
                driver=self.connection.driver,
                extra={
                    'hypervisor': vm['hypervisor']})

The only things missing would be format and os in extra.  Otherwise the right way is probably to query the list of images before looping through the node with:
        if location is not None:
            args['zoneid'] = location.id
        imgs = self._sync_request('listTemplates', **args)

then create a map with the NodeImages
        for img in imgs.get('template', []):
            img_map[img['id']]=NodeImage(
                id=img['id'],
                name=img['name'],
                driver=self.connection.driver,
                extra={
                    'hypervisor': img['hypervisor'],
                    'format': img['format'],
                    'os': img['ostypename']})

and finally assign it to the image with
    image=img_map[vm['templateid']]

Let me know which option you prefer and I can send a patch.

Also thinking of adding size to the node extra with the name of the size that the node is.

> Cloudstack list_nodes does not fill in image field
> --------------------------------------------------
>
>                 Key: LIBCLOUD-439
>                 URL: https://issues.apache.org/jira/browse/LIBCLOUD-439
>             Project: Libcloud
>          Issue Type: Bug
>          Components: Compute
>    Affects Versions: 0.13.2
>         Environment: python 2.6
>            Reporter: Carlos Reategui
>            Priority: Trivial
>
> I made the following change but not sure if it is consistent with what other drivers put in the image field:
> --- 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
> @@ -229,6 +229,7 @@
>                  public_ips=public_ips,
>                  private_ips=private_ips,
>                  driver=self,
> +                image=vm.get('templatename', None),
>                  extra={'zoneid': vm['zoneid'], }
>              )
> Another alternative could be templateid instead of templatename



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