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 2017/04/10 02:10:29 UTC
[1/4] libcloud git commit: Added Billing Product for image in EC2
compute driver Closes #1024
Repository: libcloud
Updated Branches:
refs/heads/trunk ab59cf4a2 -> 9e864c66d
Added Billing Product for image in EC2 compute driver
Closes #1024
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/c68b85e3
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/c68b85e3
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/c68b85e3
Branch: refs/heads/trunk
Commit: c68b85e3d01cce258d217462438196780dc9050d
Parents: ab59cf4
Author: Nirzari Iyer <ni...@localhost.localdomain>
Authored: Fri Feb 24 17:39:52 2017 -0500
Committer: Anthony Shaw <an...@apache.org>
Committed: Mon Apr 10 12:02:20 2017 +1000
----------------------------------------------------------------------
libcloud/compute/drivers/ec2.py | 41 +++++++++++++++++++-
.../compute/fixtures/ec2/describe_images.xml | 12 +++++-
.../ec2/describe_images_ex_imageids.xml | 7 +++-
libcloud/test/compute/test_ec2.py | 8 +++-
4 files changed, 63 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/c68b85e3/libcloud/compute/drivers/ec2.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/ec2.py b/libcloud/compute/drivers/ec2.py
index 466b802..a8cd9da 100644
--- a/libcloud/compute/drivers/ec2.py
+++ b/libcloud/compute/drivers/ec2.py
@@ -3928,7 +3928,7 @@ class BaseEC2NodeDriver(NodeDriver):
image_location=None, root_device_name=None,
block_device_mapping=None, kernel_id=None,
ramdisk_id=None, virtualization_type=None,
- ena_support=None):
+ ena_support=None, billing_products=None):
"""
Registers an Amazon Machine Image based off of an EBS-backed instance.
Can also be used to create images from snapshots. More information
@@ -3972,6 +3972,9 @@ class BaseEC2NodeDriver(NodeDriver):
Network Adapter for the AMI
:type ena_support: ``bool``
+ :param billing_products: The billing product codes
+ :type billing_products: ''list''
+
:rtype: :class:`NodeImage`
"""
@@ -4006,6 +4009,10 @@ class BaseEC2NodeDriver(NodeDriver):
if ena_support is not None:
params['EnaSupport'] = ena_support
+ if billing_products is not None:
+ params.update(self._get_billing_product_params(
+ billing_products))
+
image = self._to_image(
self.connection.request(self.path, params=params).object
)
@@ -5944,6 +5951,13 @@ class BaseEC2NodeDriver(NodeDriver):
# Build block device mapping
block_device_mapping = self._to_device_mappings(element)
+ billing_products = []
+ for p in findall(element=element,
+ xpath="billingProducts/item/billingProduct",
+ namespace=NAMESPACE):
+
+ billing_products.append(p.text)
+
# Get our tags
tags = self._get_resource_tags(element)
@@ -5954,7 +5968,7 @@ class BaseEC2NodeDriver(NodeDriver):
# Add our tags and block device mapping
extra['tags'] = tags
extra['block_device_mapping'] = block_device_mapping
-
+ extra['billing_products'] = billing_products
return NodeImage(id=id, name=name, driver=self, extra=extra)
def _to_volume(self, element, name=None):
@@ -6696,6 +6710,29 @@ class BaseEC2NodeDriver(NodeDriver):
% (idx, k, key)] = str(value)
return params
+ def _get_billing_product_params(self, billing_products):
+ """
+ Return a list of dictionaries with valid param for billing product.
+
+ :param billing_product: List of billing code values(str)
+ :type billing product: ``list``
+
+ :return: Dictionary representation of the billing product codes
+ :rtype: ``dict``
+ """
+
+ if not isinstance(billing_products, (list, tuple)):
+ raise AttributeError(
+ 'billing_products not list or tuple')
+
+ params = {}
+
+ for idx, v in enumerate(billing_products):
+ idx += 1 # We want 1-based indexes
+ params['BillingProduct.%d' % (idx)] = str(v)
+
+ return params
+
def _get_common_security_group_params(self, group_id, protocol,
from_port, to_port, cidr_ips,
group_pairs):
http://git-wip-us.apache.org/repos/asf/libcloud/blob/c68b85e3/libcloud/test/compute/fixtures/ec2/describe_images.xml
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/ec2/describe_images.xml b/libcloud/test/compute/fixtures/ec2/describe_images.xml
index d541a38..167015a 100644
--- a/libcloud/test/compute/fixtures/ec2/describe_images.xml
+++ b/libcloud/test/compute/fixtures/ec2/describe_images.xml
@@ -14,6 +14,11 @@
<description>Testing Stuff</description>
<rootDeviceType>ebs</rootDeviceType>
<rootDeviceName>/dev/sda1</rootDeviceName>
+ <billingProducts>
+ <item>
+ <billingProduct>ab-5dh78019</billingProduct>
+ </item>
+ </billingProducts>
<blockDeviceMapping>
<item>
<deviceName>/dev/sda1</deviceName>
@@ -44,6 +49,11 @@
<name>Test Image 2</name>
<rootDeviceType>ebs</rootDeviceType>
<rootDeviceName>/dev/sda1</rootDeviceName>
+ <billingProducts>
+ <item>
+ <billingProduct>as-6dr90319</billingProduct>
+ </item>
+ </billingProducts>
<blockDeviceMapping>
<item>
<deviceName>/dev/sda1</deviceName>
@@ -59,4 +69,4 @@
<hypervisor>xen</hypervisor>
</item>
</imagesSet>
-</DescribeImagesResponse>
\ No newline at end of file
+</DescribeImagesResponse>
http://git-wip-us.apache.org/repos/asf/libcloud/blob/c68b85e3/libcloud/test/compute/fixtures/ec2/describe_images_ex_imageids.xml
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/ec2/describe_images_ex_imageids.xml b/libcloud/test/compute/fixtures/ec2/describe_images_ex_imageids.xml
index b73b866..f16092d 100644
--- a/libcloud/test/compute/fixtures/ec2/describe_images_ex_imageids.xml
+++ b/libcloud/test/compute/fixtures/ec2/describe_images_ex_imageids.xml
@@ -14,6 +14,11 @@
<description>Testing Stuff</description>
<rootDeviceType>ebs</rootDeviceType>
<rootDeviceName>/dev/sda1</rootDeviceName>
+ <billingProducts>
+ <item>
+ <billingProduct>ab-5dh78019</billingProduct>
+ </item>
+ </billingProducts>
<blockDeviceMapping>
<item>
<deviceName>/dev/sda1</deviceName>
@@ -33,4 +38,4 @@
<hypervisor>xen</hypervisor>
</item>
</imagesSet>
-</DescribeImagesResponse>
\ No newline at end of file
+</DescribeImagesResponse>
http://git-wip-us.apache.org/repos/asf/libcloud/blob/c68b85e3/libcloud/test/compute/test_ec2.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_ec2.py b/libcloud/test/compute/test_ec2.py
index 7702d82..e51cf42 100644
--- a/libcloud/test/compute/test_ec2.py
+++ b/libcloud/test/compute/test_ec2.py
@@ -486,6 +486,8 @@ class EC2Tests(LibcloudTestCase, TestCaseMixin):
self.assertEqual(len(images[0].extra['block_device_mapping']), 2)
ephemeral = images[0].extra['block_device_mapping'][1]['virtual_name']
self.assertEqual(ephemeral, 'ephemeral0')
+ billing_product1 = images[0].extra['billing_products'][0]
+ self.assertEqual(billing_product1, 'ab-5dh78019')
location = '123456788908/Test Image 2'
self.assertEqual(images[1].id, 'ami-85b2a8ae')
@@ -493,6 +495,8 @@ class EC2Tests(LibcloudTestCase, TestCaseMixin):
self.assertEqual(images[1].extra['image_location'], location)
self.assertEqual(images[1].extra['architecture'], 'x86_64')
size = images[1].extra['block_device_mapping'][0]['ebs']['volume_size']
+ billing_product2 = images[1].extra['billing_products'][0]
+ self.assertEqual(billing_product2, 'as-6dr90319')
self.assertEqual(size, 20)
def test_list_images_with_image_ids(self):
@@ -513,6 +517,7 @@ class EC2Tests(LibcloudTestCase, TestCaseMixin):
self.assertEqual(image.name, 'Test Image')
self.assertEqual(image.extra['architecture'], 'x86_64')
self.assertEqual(len(image.extra['block_device_mapping']), 2)
+ self.assertEqual(image.extra['billing_products'][0], 'ab-5dh78019')
def test_copy_image(self):
image = self.driver.list_images()[0]
@@ -559,7 +564,8 @@ class EC2Tests(LibcloudTestCase, TestCaseMixin):
description='My Image',
architecture='x86_64',
block_device_mapping=mapping,
- ena_support=True)
+ ena_support=True,
+ billing_products=['ab-5dh78019'])
self.assertEqual(image.id, 'ami-57c2fb3e')
def test_ex_list_availability_zones(self):
[2/4] libcloud git commit: changes for #1024
Posted by an...@apache.org.
changes for #1024
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/c06ce570
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/c06ce570
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/c06ce570
Branch: refs/heads/trunk
Commit: c06ce570fc09d7d32780f4ad8039ac00b82f839d
Parents: c68b85e
Author: Anthony Shaw <an...@apache.org>
Authored: Mon Apr 10 12:03:39 2017 +1000
Committer: Anthony Shaw <an...@apache.org>
Committed: Mon Apr 10 12:03:39 2017 +1000
----------------------------------------------------------------------
CHANGES.rst | 7 +++++++
1 file changed, 7 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/c06ce570/CHANGES.rst
----------------------------------------------------------------------
diff --git a/CHANGES.rst b/CHANGES.rst
index 0392b32..2e233a0 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -11,6 +11,13 @@ Common
[GITHUB-1028]
(Anthony Shaw)
+Compute
+~~~~~~~
+
+- Added Billing Product for image in EC2 compute driver
+ [GITHUB-1024]
+ (Nirzari Iyer)
+
Changes in Apache Libcloud 2.0.0rc2
-----------------------------------
[4/4] libcloud git commit: changes for #1022
Posted by an...@apache.org.
changes for #1022
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/9e864c66
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/9e864c66
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/9e864c66
Branch: refs/heads/trunk
Commit: 9e864c66dce5cccc391359618085ed568622cfce
Parents: 92b0690
Author: Anthony Shaw <an...@apache.org>
Authored: Mon Apr 10 12:10:21 2017 +1000
Committer: Anthony Shaw <an...@apache.org>
Committed: Mon Apr 10 12:10:21 2017 +1000
----------------------------------------------------------------------
CHANGES.rst | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/9e864c66/CHANGES.rst
----------------------------------------------------------------------
diff --git a/CHANGES.rst b/CHANGES.rst
index 2e233a0..031eb9b 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -14,6 +14,10 @@ Common
Compute
~~~~~~~
+- Fix - update t2.small image size from 11 CPU to 1
+ [GITHUB-1022]
+ (Francisco Ros)
+
- Added Billing Product for image in EC2 compute driver
[GITHUB-1024]
(Nirzari Iyer)
[3/4] libcloud git commit: Fix number of ec2 t2.small cpus to 1
Closes #1022
Posted by an...@apache.org.
Fix number of ec2 t2.small cpus to 1
Closes #1022
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/92b0690c
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/92b0690c
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/92b0690c
Branch: refs/heads/trunk
Commit: 92b0690c0608e0ed2e8534229dd2c3c1cfb3de48
Parents: c06ce57
Author: Francisco Ros <fj...@doalitic.com>
Authored: Tue Apr 4 20:32:42 2017 +0200
Committer: Anthony Shaw <an...@apache.org>
Committed: Mon Apr 10 12:09:15 2017 +1000
----------------------------------------------------------------------
libcloud/compute/drivers/ec2.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/92b0690c/libcloud/compute/drivers/ec2.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/ec2.py b/libcloud/compute/drivers/ec2.py
index a8cd9da..839b889 100644
--- a/libcloud/compute/drivers/ec2.py
+++ b/libcloud/compute/drivers/ec2.py
@@ -713,7 +713,7 @@ INSTANCE_TYPES = {
'disk': 0, # EBS Only
'bandwidth': None,
'extra': {
- 'cpu': 11
+ 'cpu': 1
}
},
't2.medium': {