libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anthonys...@apache.org
Subject [5/8] libcloud git commit: Implement get_image function for softlayer
Date Fri, 11 Aug 2017 04:34:53 GMT
Implement get_image function for softlayer


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/32d54fd4
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/32d54fd4
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/32d54fd4

Branch: refs/heads/trunk
Commit: 32d54fd4f98ed441f224ffc9b03588e88d587558
Parents: ceffe6e
Author: Francois Regnoult <francois.regnoult@wandera.com>
Authored: Tue May 30 17:31:49 2017 +0100
Committer: Anthony Shaw <anthonyshaw@apache.org>
Committed: Fri Aug 11 14:33:43 2017 +1000

----------------------------------------------------------------------
 libcloud/compute/drivers/softlayer.py | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/32d54fd4/libcloud/compute/drivers/softlayer.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/softlayer.py b/libcloud/compute/drivers/softlayer.py
index 5243d0b..f2b9db1 100644
--- a/libcloud/compute/drivers/softlayer.py
+++ b/libcloud/compute/drivers/softlayer.py
@@ -24,6 +24,7 @@ except ImportError:
     crypto = False
 
 from libcloud.common.softlayer import SoftLayerConnection, SoftLayerException
+from libcloud.common.types import LibcloudError
 from libcloud.compute.types import Provider, NodeState
 from libcloud.compute.base import NodeDriver, Node, NodeLocation, NodeSize, \
     NodeImage, KeyPair
@@ -432,6 +433,24 @@ class SoftLayerNodeDriver(NodeDriver):
         ).object
         return [self._to_image(i) for i in result['operatingSystems']]
 
+    def get_image(self, image_id):
+        """
+        Gets an image based on an image_id.
+
+        :param image_id: Image identifier
+        :type image_id: ``str``
+
+        :return: A NodeImage object
+        :rtype: :class:`NodeImage`
+
+        """
+        images = self.list_images()
+        images = [image for image in images if image.id == image_id]
+        if len(images) < 1:
+            raise LibcloudError('could not find the image with id %s' % image_id)
+        image = images[0]
+        return image
+
     def _to_size(self, id, size):
         return NodeSize(
             id=id,


Mime
View raw message