You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by GitBox <gi...@apache.org> on 2019/12/24 16:34:32 UTC

[GitHub] [libcloud] kartiksubbarao commented on issue #1346: GCE ex_list_instancegroups('all') raises KeyError 'zone'

kartiksubbarao commented on issue #1346: GCE ex_list_instancegroups('all') raises KeyError 'zone'
URL: https://github.com/apache/libcloud/issues/1346#issuecomment-568775782
 
 
   Thanks for the response @Kami . I don't have access to that GCE environment anymore so I can't test, but I compared the August libcloud code to the current code and it doesn't seem like there were any changes to `libcloud/compute/drivers/gce.py` that would have fixed this issue:
   
   https://github.com/apache/libcloud/compare/5cbd788...4107267
   
   Hopefully the example object I provided above might shed some light into how GCP can return objects that have regions (but not zones) populated.
   
   Also, here is some code that I came up with to work around the issue, perhaps this may help in developing a proper fix:
   
   ```
   def list_all_instancegroups(gcp, projectid):
       instance_groups = []
       resp = gcp.connection.request('/aggregated/instanceGroups').object
       if 'items' in resp:
           for v in resp['items'].values():
               for ig in v.get('instanceGroups', []):
                   if 'zone' in ig:
                       try: instance_groups.append(gcp._to_instancegroup(ig))
                       except:
                           e = sys.exc_info()
                           print('{}: instancegroup: {}'.format(
                                projectid, e[1].value['message']), file=sys.stderr)
                           if e[0] != libcloud.common.google.ResourceNotFoundError:
                               raise
       return instance_groups
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services