You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by an...@apache.org on 2016/10/07 02:25:06 UTC
[10/12] libcloud git commit: Add new GetProductType API in Outscale
EC2 driver
Add new GetProductType API in Outscale EC2 driver
Signed-off-by: Javier M. Mellid <jm...@igalia.com>
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/d277e988
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/d277e988
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/d277e988
Branch: refs/heads/trunk
Commit: d277e988f1f6c078e79cfb2e6848d465ceb24f26
Parents: 97223fa
Author: Javier M. Mellid <jm...@igalia.com>
Authored: Mon Oct 3 13:56:59 2016 +0200
Committer: Anthony Shaw <an...@apache.org>
Committed: Fri Oct 7 13:23:41 2016 +1100
----------------------------------------------------------------------
libcloud/compute/drivers/ec2.py | 37 ++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/d277e988/libcloud/compute/drivers/ec2.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/ec2.py b/libcloud/compute/drivers/ec2.py
index 77211cd..ec38dfd 100644
--- a/libcloud/compute/drivers/ec2.py
+++ b/libcloud/compute/drivers/ec2.py
@@ -6908,6 +6908,43 @@ class OutscaleNodeDriver(BaseEC2NodeDriver):
return is_truncated, quota
+ def _to_product_type(self, elem):
+
+ productTypeId = findtext(element=elem, xpath='productTypeId',
+ namespace=OUTSCALE_NAMESPACE)
+ description = findtext(element=elem, xpath='description',
+ namespace=OUTSCALE_NAMESPACE)
+
+ return {'productTypeId': productTypeId,
+ 'description': description}
+
+ def ex_get_product_type(self, image_id, snapshot_id=None):
+ """
+ Get the product type of a specified OMI or snapshot.
+
+ :param image_id: The ID of the OMI
+ :type image_id: ``string``
+
+ :param snapshot_id: The ID of the snapshot
+ :type snapshot_id: ``string``
+
+ :return: A product type
+ :rtype: ``dict``
+ """
+
+ params = {'Action': 'GetProductType'}
+
+ params.update({'ImageId': image_id})
+ if snapshot_id is not None:
+ params.update({'SnapshotId': snapshot_id})
+
+ response = self.connection.request(self.path, params=params,
+ method='GET').object
+
+ product_type = self._to_product_type(response)
+
+ return product_type
+
def _to_product_types(self, elem):
product_types = []