libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [libcloud] Kami commented on a change in pull request #1548: Equinix update
Date Fri, 12 Feb 2021 11:22:54 GMT

Kami commented on a change in pull request #1548:
URL: https://github.com/apache/libcloud/pull/1548#discussion_r575155736



##########
File path: libcloud/compute/drivers/equinixmetal.py
##########
@@ -443,22 +452,31 @@ def _to_location(self, data):
                             driver=self, extra=extra)
 
     def _to_size(self, data):
-        cpus = data['specs']['cpus'][0].get('count')
+        try:
+            cpus = data['specs']['cpus'][0].get('count')
+        except KeyError:
+            cpus = None
+        regions = [region.get('href').replace('/metal/v1/facilities/', '')
+                   for region in data.get('available_in', [])]
         extra = {'description': data['description'], 'line': data['line'],
-                 'cpus': cpus}
-
-        ram = data['specs']['memory']['total']
-        disk = 0
-        for disks in data['specs']['drives']:
-            disk_size = disks['size'].replace('GB', '')
-            if 'TB' in disk_size:
-                disk_size = float(disks['size'].replace('TB', '')) * 1000
-            disk += disks['count'] * int(disk_size)
+                 'cpus': cpus, 'regions': regions}
+        try:
+            ram = int(data['specs']['memory']['total'].replace('GB', '')) * 1024  # noqa
+        except KeyError:
+            ram = None
+        disk = None
+        if data['specs'].get('drives', ''):
+            disk = 0
+            for disks in data['specs']['drives']:

Review comment:
       Eventually it would be nice to split this formatting functionality in separate functions
to make (unit) testing easier, but not a blocker for now.




----------------------------------------------------------------
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



Mime
View raw message