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



##########
File path: libcloud/compute/drivers/cloudsigma.py
##########
@@ -1914,15 +2124,47 @@ def _parse_ips_from_nic(self, nic):
         return public_ips, private_ips
 
     def _to_node(self, data):
-        extra_keys = ['cpu', 'mem', 'nics', 'vnc_password', 'meta']
-
         id = data['uuid']
         name = data['name']
         state = self.NODE_STATE_MAP.get(data['status'], NodeState.UNKNOWN)
 
         public_ips = []
         private_ips = []
-        extra = self._extract_values(obj=data, keys=extra_keys)
+        extra = {
+            'cpus': data['cpu'] / 2000,
+            'memory': data['mem'] / 1024 / 1024,
+            'nics': data['nics'],
+            'vnc_password': data['vnc_password'],
+            'meta': data['meta'],
+            'runtime': data['runtime'],
+            'drives': data['drives'],
+        }
+        # find image name and boot drive size
+        image = None
+        drive_size = 0
+        for item in extra['drives']:
+            if item['boot_order'] == 1:
+                drive = self.ex_get_drive(item['drive']['uuid'])
+                drive_size = drive.size
+                image = '{} {}'.format(drive.extra.get('distribution', ''),
+                                       drive.extra.get('version', ''))
+                break
+        # try to find if node size is from example sizes given by CloudSigma

Review comment:
       It seems somewhat inefficient to run this on every to ``_to_node()`` 
method call (even if that ``list_nodes()`` method doesn't result in a HTTP 
request and just filters a local list).
   
   Is there any way we could handle this better / more efficiently?
   
   Perhaps we could build a module level dictionary constant where the key 
would be a tuple of (cpus, memory, drive_size) and the value would be 
``NodeSize``. Then we can just do a simple dictionary lookup.
   
   I think this should be fine since there isn't a lot of pre-defined sizes,




-- 
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:
[email protected]


Reply via email to