libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anthonys...@apache.org
Subject [07/12] libcloud git commit: Add new DescribeInstanceTypes API in Outscale EC2 driver
Date Fri, 07 Oct 2016 02:25:03 GMT
Add new DescribeInstanceTypes API in Outscale EC2 driver

Signed-off-by: Javier M. Mellid <jmunhoz@igalia.com>


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

Branch: refs/heads/trunk
Commit: 97223fa311d3adea404420f51d4d75916a3011a3
Parents: c6527a5
Author: Javier M. Mellid <jmunhoz@igalia.com>
Authored: Mon Oct 3 13:38:36 2016 +0200
Committer: Anthony Shaw <anthonyshaw@apache.org>
Committed: Fri Oct 7 13:23:41 2016 +1100

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


http://git-wip-us.apache.org/repos/asf/libcloud/blob/97223fa3/libcloud/compute/drivers/ec2.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/ec2.py b/libcloud/compute/drivers/ec2.py
index cf5184c..77211cd 100644
--- a/libcloud/compute/drivers/ec2.py
+++ b/libcloud/compute/drivers/ec2.py
@@ -6949,6 +6949,68 @@ class OutscaleNodeDriver(BaseEC2NodeDriver):
 
         return product_types
 
+    def _to_instance_types(self, elem):
+
+        instance_types = []
+        for instance_types_item in findall(element=elem,
+                                           xpath='instanceTypeSet/item',
+                                           namespace=OUTSCALE_NAMESPACE):
+            name = findtext(element=instance_types_item,
+                            xpath='name',
+                            namespace=OUTSCALE_NAMESPACE)
+            vcpu = findtext(element=instance_types_item,
+                            xpath='vcpu',
+                            namespace=OUTSCALE_NAMESPACE)
+            memory = findtext(element=instance_types_item,
+                              xpath='memory',
+                              namespace=OUTSCALE_NAMESPACE)
+            storageSize = findtext(element=instance_types_item,
+                                   xpath='storageSize',
+                                   namespace=OUTSCALE_NAMESPACE)
+            storageCount = findtext(element=instance_types_item,
+                                    xpath='storageCount',
+                                    namespace=OUTSCALE_NAMESPACE)
+            maxIpAddresses = findtext(element=instance_types_item,
+                                      xpath='maxIpAddresses',
+                                      namespace=OUTSCALE_NAMESPACE)
+            ebsOptimizedAvailable = findtext(element=instance_types_item,
+                                             xpath='ebsOptimizedAvailable',
+                                             namespace=OUTSCALE_NAMESPACE)
+            d = {'name': name,
+                 'vcpu': vcpu,
+                 'memory': memory,
+                 'storageSize': storageSize,
+                 'storageCount': storageCount,
+                 'maxIpAddresses': maxIpAddresses,
+                 'ebsOptimizedAvailable': ebsOptimizedAvailable}
+            instance_types.append(d)
+
+        return instance_types
+
+    def ex_describe_instance_types(self, filters=None):
+        """
+        Describes Instance Types.
+
+        :param      filters: The filters so that the response includes
+                             information for only instance types
+        :type       filters: ``dict``
+
+        :return:    A instance types list
+        :rtype:     ``list``
+        """
+
+        params = {'Action': 'DescribeInstanceTypes'}
+
+        if filters:
+            params.update(self._build_filters(filters))
+
+        response = self.connection.request(self.path, params=params,
+                                           method='GET').object
+
+        instance_types = self._to_instance_types(response)
+
+        return instance_types
+
 
 class OutscaleSASNodeDriver(OutscaleNodeDriver):
     """


Mime
View raw message